Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFilehandle required for client-server text app.
Qt 6.11 is out! See what's new in the release blog

QFilehandle required for client-server text app.

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 6 Posters 392 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S stefbon

    Hi,

    I want to make Calligra use a client-server model when it comes to the documents.

    I'm working on software (OSNS) which offers developers the possibility to write code which makes use of a fd to a remote document (for example) via SSH. It's possible to connect to a ssh subsystem (well known is sftp) like a document server.
    This way it is possible to have a client (the UI) on the workstation, while you the document is on server, which gives you to be independent of the computer/workstation, which is very nice. It also makes possible to work on a document with more than one. (a locking scheme is required though).

    Now Calligra looks abandonned.
    But to make it work a QFilehandle is required. This Qt implementation is required for the client to "talk" to the server. Since client and server maybe on different machines, the normal fd or Qfile is useless.

    I do not see a QFilehandle class, but messages about the need for it though.

    What do you think? Do I have to add iit myself?

    Stef Bon

    SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote last edited by
    #4

    @stefbon Hi,

    Since Calligra is part of KDE, you should check whether it already makes use of KIO. If not, then you should rather go this route as it provides everything you need for what you want to achieve.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    S 1 Reply Last reply
    1
    • SGaistS SGaist

      @stefbon Hi,

      Since Calligra is part of KDE, you should check whether it already makes use of KIO. If not, then you should rather go this route as it provides everything you need for what you want to achieve.

      S Offline
      S Offline
      stefbon
      wrote last edited by
      #5

      @SGaist As far as I can see it's not making use of KIO.

      But that said, I want to create a set of tools offering an unified interface to network services.
      At this moment there are too many different ones. I name some:

      • KDE use KIO as you mention
      • GNOME use GFS
      • VLC uses it's own implementation
      • LibreOffice uses it's own implementation

      My software OSNS is an attempt to replace them all (and offering one interface). It's very ambitious, I know.

      Stef Bon
      the Netherlands

      1 Reply Last reply
      0
      • JonBJ JonB

        @stefbon said in QFilehandle required for client-server text app.:

        which makes use of a fd to a remote document

        If you are saying you have been given a fd which does whatever you want remotely, be aware that you can "connect" it to a QFile via bool QFile::open(int fd, QIODeviceBase::OpenMode mode, QFileDevice::FileHandleFlags handleFlags = DontCloseHandle).

        If not you have to write your own functionality like @Nils-Sjoberg said.

        S Offline
        S Offline
        stefbon
        wrote last edited by stefbon
        #6

        @JonB Well I notice some not knowing how OSNS will work.

        OSNS will contact the remote documents server (which is a SSH subsystem), and gets a SSH channel. This is mapped to a local fd. So the applicartion will use an fd (behind the scenes) .

        So:

        local client fd <-> ssh channel < --- (ssh transport) ---> ssh channel ->ssh subsystem (OSNS documentserver) -> fd to document on remote server

        How the remote side handles it's side it;s up to the remote server.

        Stef Bon
        the Netherlands

        1 Reply Last reply
        0
        • Nils SjobergN Nils Sjoberg

          To achieve client-server separation of document virtualization, you need to create a custom class that inherits from QIODevice (or from QFileDevice) that implements communication via the fd or SSH/SFTP, thus replacing the QFile

          S Offline
          S Offline
          stefbon
          wrote last edited by
          #7

          @Nils-Sjoberg said in QFilehandle required for client-server text app.:

          QFileDevice

          Thanks a lot. This looks exactly what I'm looking for. At first I missed the offset in read and write functions, but the seek function will give the desired functionality.

          Thanks again,

          Stef Bon

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stefbon
            wrote last edited by stefbon
            #8

            As I have your attention, the QIODevice class offers functionality to access a file (local or remote).
            I have to add the functionality to implement use by more than one user, like locking a part of the file,
            and notifiying the user about events like someone else started editing the file.

            And I need a class for users to browse the exported/shared directories.

            Anyway, have a good day,

            Stef Bon

            JonBJ 1 Reply Last reply
            0
            • S Offline
              S Offline
              SimonSchroeder
              wrote last edited by
              #9

              I didn't know that only locking part of a file is a thing. Even more so, most office formats are ZIP files, so you cannot just change parts of it. Even with a text file, if you insert text in the middle everything that comes after it has to be moved. File based synchronization for collaborative editing would be really hard to implement. I expect modern software to just communicate directly with each other.

              1 Reply Last reply
              1
              • S stefbon

                As I have your attention, the QIODevice class offers functionality to access a file (local or remote).
                I have to add the functionality to implement use by more than one user, like locking a part of the file,
                and notifiying the user about events like someone else started editing the file.

                And I need a class for users to browse the exported/shared directories.

                Anyway, have a good day,

                Stef Bon

                JonBJ Offline
                JonBJ Offline
                JonB
                wrote last edited by
                #10

                @stefbon
                If you appear to have a "working" fd which does what you want and you then want a QFile wrapper for a Qt program then as I said earlier you could use that QFile::open() overload.

                File byte range locking is only of use in a database-type file which is accessed directly from clients, not client-server with a central server.

                I am not aware of any means of seeing an "event" like someone else "starting to edit the file", however you might define that. The closest is Qt's QFileSystemWatcher Class, but it doesn't achieve that.

                Most important is: any solution involving Qt classes the way you want would only at best work if everyone goes through Qt/your code. Assuming you want to allow for non-Qt access from other programs you would need to work at the fd level. Qt does not do anything in QFile etc. which you could not do yourself. And any approach is liable to be platform-dependent and depend on what low-level facilities each platform offers.

                S 1 Reply Last reply
                0
                • JonBJ JonB

                  @stefbon
                  If you appear to have a "working" fd which does what you want and you then want a QFile wrapper for a Qt program then as I said earlier you could use that QFile::open() overload.

                  File byte range locking is only of use in a database-type file which is accessed directly from clients, not client-server with a central server.

                  I am not aware of any means of seeing an "event" like someone else "starting to edit the file", however you might define that. The closest is Qt's QFileSystemWatcher Class, but it doesn't achieve that.

                  Most important is: any solution involving Qt classes the way you want would only at best work if everyone goes through Qt/your code. Assuming you want to allow for non-Qt access from other programs you would need to work at the fd level. Qt does not do anything in QFile etc. which you could not do yourself. And any approach is liable to be platform-dependent and depend on what low-level facilities each platform offers.

                  S Offline
                  S Offline
                  stefbon
                  wrote last edited by
                  #11

                  @JonB and others

                  you are absolutely right. When inserting text in a normal file the synchronisation is a challenge.
                  I have to think that over. Every user has it's own window to a document. And synchronisation is only required when another user's window "reaches" the text you've inserted/changed.

                  Lot's of work.

                  Thanks,

                  Stef Bon
                  the Netherlands

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    stefbon
                    wrote last edited by
                    #12

                    Last post before I start another topic how to solve this. I think that the classic idea of a file (and a filedescriptor) does not work with collborative editing. I think that a document is not a file anymore, but a group of ordered paragraps. Every paragrap has it's own record in a database, so it's easy to achieve the desired locking: everyone can edit (=write to ) a paragraph, unless someone else is already doing that. And inserting, changing and deleting a paragraph is easy to maintain by a server.

                    So internally a document is not a file anymore, but a group of ordered paragraphs.
                    A paragraph is a piece of text, but also an image, an inserted piece of another langauge (R for example).

                    To have a file you need a goord export function (to ODT and PDF).,

                    Stef

                    JonBJ 1 Reply Last reply
                    0
                    • S stefbon has marked this topic as solved
                    • S stefbon

                      Last post before I start another topic how to solve this. I think that the classic idea of a file (and a filedescriptor) does not work with collborative editing. I think that a document is not a file anymore, but a group of ordered paragraps. Every paragrap has it's own record in a database, so it's easy to achieve the desired locking: everyone can edit (=write to ) a paragraph, unless someone else is already doing that. And inserting, changing and deleting a paragraph is easy to maintain by a server.

                      So internally a document is not a file anymore, but a group of ordered paragraphs.
                      A paragraph is a piece of text, but also an image, an inserted piece of another langauge (R for example).

                      To have a file you need a goord export function (to ODT and PDF).,

                      Stef

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote last edited by
                      #13

                      @stefbon said in QFilehandle required for client-server text app.:

                      Every paragrap has it's own record in a database, so it's easy to achieve the desired locking: everyone can edit (=write to ) a paragraph, unless someone else is already doing that. And inserting, changing and deleting a paragraph is easy to maintain by a server.

                      It's not going to be as simple as that in your real-world situation.

                      You are describing pessimistic locking. You are going to require each user to do something before they can edit or delete a paragraph to "lock" it. What are you going to do if the locker then goes to lunch, or never returns? Having a pessimistic lock held for a long time is a pita.

                      Alternative is optimistic locking. No "blocking" lock held. You save state of paragraph when user starts to edit. When ready to submit changes you make it UPDATE ... SET paragraph = new_paragraph WHERE paragraph = old_paragraph. This ensures update is committed only when nobody else has changed paragraph while you were editing. Often better for sharing. But you still have to deal with what to do if someone else has changed it while you were editing. Usual is to throw away new change and make user redo from newly changed paragraph state. Not so bad for "little records", not so good for "paragraphs".

                      Then you have inserts. Between two existing paragraphs you & I each decide we want to insert our own new paragraph. There is nothing to lock or compare. Which order do you place these two paragraphs after we each submit? Perhaps "first (based on submit time) submitter's paragraph is inserted and then second submitter's paragraph is inserted after first one" (or other way round). But maybe first inserter's paragraph has to go before the old paragraph after it and second inserter's paragraph has to go after the old paragraph which was before it. they are now the wrong way round.

                      And a whole host of other similars. It's one thing handling contention on small rows/columns, it's another on documents. Not to mention stuff like your interface may have to "push" changes from one user into another user's session while they are middle of doing something/their own editing. I foresee many problems....

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SimonSchroeder
                        wrote last edited by
                        #14

                        I would say that Microsoft Word has already established what users expect when editing files together: You see all changes happening immediately together with a colored cursor for each user with a tag of their name. And those cursors move around live. The best thing is that you can follow where other users are currently editing the document and you'll most likely avoid editing the same thing.

                        This usually requires for your documents to live in a "cloud" (even if the cloud is your own private cloud at home) and a server that at least tracks all concurrent users of the document and tells each user about the others.

                        The best example of what it should have been like is Google Wave (unfortunately, this project has been shut down after only a few years). It was based on XMPP for realtime communication.

                        1 Reply Last reply
                        0
                        • S stefbon

                          Hi,

                          I want to make Calligra use a client-server model when it comes to the documents.

                          I'm working on software (OSNS) which offers developers the possibility to write code which makes use of a fd to a remote document (for example) via SSH. It's possible to connect to a ssh subsystem (well known is sftp) like a document server.
                          This way it is possible to have a client (the UI) on the workstation, while you the document is on server, which gives you to be independent of the computer/workstation, which is very nice. It also makes possible to work on a document with more than one. (a locking scheme is required though).

                          Now Calligra looks abandonned.
                          But to make it work a QFilehandle is required. This Qt implementation is required for the client to "talk" to the server. Since client and server maybe on different machines, the normal fd or Qfile is useless.

                          I do not see a QFilehandle class, but messages about the need for it though.

                          What do you think? Do I have to add iit myself?

                          Stef Bon

                          E Offline
                          E Offline
                          Emma-2000
                          Banned
                          wrote last edited by Emma-2000
                          #15
                          This post is deleted!
                          1 Reply Last reply
                          0

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved