Discussion:
GSOC 2014: Update: Interactive LyX
Sushant Raikar
2014-06-04 19:16:05 UTC
Permalink
The patch attached below, allows collaborative editing with simple use
cases.
a) Cursor movements
b) Character insertion
c) Character Deletion
d) Mouse click, cursor location change
e) Cursor movement to and fro insets (boxes, tables etc.)

The patch has been diff-ed with master* branch.
Pavel Sanda
2014-06-04 22:20:17 UTC
Permalink
Sushant Raikar wrote:

More or less cosmetical comments, don't have time
to test or go into the logic of the code. Pavel
+void BufferView::Private::send(FuncRequest const & cmd, SocketConnection *p_excl_conn) {
+
+ LFUNHolder lh;
+ //just a random number for testing
+ lh.attach_version(10);
+ lh.attach_LFUN(cmd);
what this version means? why it's not in .h?
+ printf("Done\n");
use lyxerr instead of printf, don't pull stdio.h. used on more places.
+ connect(&d->timer_, SIGNAL(timeout()), this, SLOT(periodicTimer()));
+ d->timer_.setInterval(500);
+ d->p_conn_ = 0;
+ d->client_conn_ = true;
indentation wrong.
+ BufferView *p_bv = new BufferView(buffer());
+ p_bv->resize(320, 200);
looks fishy. what exactly you are trying to achieve?
-void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
+void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr,bool enable_send)
whitespace missing. would it make sense to add the bool into funcrequest?
diff --git a/src/BufferView.h b/src/BufferView.h
index a94ddfd..867bae4 100644
--- a/src/BufferView.h
+++ b/src/BufferView.h
@@ -20,6 +20,8 @@
#include "support/strfwd.h"
#include "support/types.h"
+#include "support/Socket.h"
+#include <QTimer>
i don't know whether there is general consensus how much should we pull
qt dependencies into core.
diff --git a/src/CursorSlice.h b/src/CursorSlice.h
index 01634bd..a6d6408 100644
--- a/src/CursorSlice.h
+++ b/src/CursorSlice.h
/// write some debug information to \p os
friend std::ostream & operator<<(std::ostream &, CursorSlice const &);
+
+ friend std::istream &
+ operator>>(std::istream &, CursorSlice & );
+
undocumented, why is it here who uses it etc.
the same in DocIterator.h
+
+void FuncRequest::serializeFrom(std::vector<unsigned char> const & v)
can be the variables named in more clear way or have some comments?
diff --git a/src/LFUNHolder.h b/src/LFUNHolder.h
new file mode 100644
index 0000000..bde2402
--- /dev/null
+++ b/src/LFUNHolder.h
@@ -0,0 +1,60 @@
+// -*- C++ -*-
+/**
+ * \file LFUNHolder.h
+ *
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author Sushant Raikar
+ *
+*/
+
+#ifndef LFUN_HOLDER_H
+#define LFUN_HOLDER_H
+
+
+#include <vector>
+#include <string>
+#include <errno.h>
+#include <FuncRequest.h>
+#include <Cursor.h>
+#include <DocIterator.h>
+
+
+namespace lyx {
+
+class FuncRequest;
+
+class LFUNHolder {
+ LFUNHolder();
+ LFUNHolder(Buffer * buffer);
+ ~LFUNHolder();
+
+ std::vector<unsigned char> serialize();
+ void unserialize(std::vector<unsigned char> const & v);
+
+ void attach_LFUN(FuncRequest cmd);
+ FuncRequest* detach_LFUN();
+ bool get_LFUN(FuncRequest &);
+
+ void attach_version(unsigned int const & ver);
+ unsigned int detach_version();
+ bool get_version(int &);
+
+ void attach_DocIt(DocIterator &);
+ DocIterator* detach_DocIt();
+ bool get_DocIt(DocIterator &);
+
+ void clear();
+
+ int prefix;
+ int version;
+ FuncRequest * funcrequest_;
+ DocIterator * dociterator_;
completely undocumented. this is the case in other headers as well.
+/*!
+ * \var lyx::FuncCode lyx::LFUN_COLLABORATE_CONNECT
+ * \li Action: Connect to remote LyX instance for collaborative editing
+ * \li Syntax: connect host port
+ * \li Params: <host>: The host name or IP address
+ * \li Params: <port>: The IP port where to connect to
\li Params: should be used only in first line
diff --git a/src/moc_BufferView.cpp b/src/moc_BufferView.cpp
new file mode 100644
index 0000000..1a3b40d
--- /dev/null
+++ b/src/moc_BufferView.cpp
i don't think we track moc files.
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <arpa/inet.h>
+#include <unistd.h>
i wonder how this is portable.
have you tried to run this under windows? looks
Tommaso Cucinotta
2014-06-04 23:56:05 UTC
Permalink
Post by Pavel Sanda
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <assert.h>
+#include <string.h>
+#include <errno.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <arpa/inet.h>
+#include <unistd.h>
i wonder how this is portable.
have you tried to run this under windows? looks
Pavel, seems like you didn't finish the sentence...

Sushant evolved my old patch, based on an asynchronous periodic polling
of sockets from both ends, done to the purpose of avoiding multi-threading.
Sockets were written in a UNIX-dependent fashion for the purpose of quick
prototyping ... never meant to be final.

At that time, I can remember someone suggesting to switch to QSocket, that
seem portable.
Post by Pavel Sanda
From a networking perspective, the real problem is how to get the 2 ends
connected and let them find each other. Perhaps a viable way might
be to just re-use the QXMPP framework as from the LyX Chat, and let all
the messages flow through the QXmppClient object.

For example, a user would issue "share document".
Another user would select a buddy from the above mentioned QXmpp buddies
pane, and then "collaborative edit...", then see a dialog with all documents
shared by that user, then pick one and proceed.

However, the original intention was to leave such details for later and focus
on the collaborative editing logic in the GSoC, deferring to later any network
specific or GUI specific issue...

T.
Cyrille Artho
2014-06-06 00:30:47 UTC
Permalink
Hi Sushant,
Thanks for posting the patch. It's good to see that you're making progress.

To understand your work better, it would be good if you could post some
more background on what you did/plan on doing, about every 1 - 2 weeks.

For example:

* What problems did you encounter/solve since you last gave us an update?

* What are the current problems? Any design/implementation decisions where
you'd like to hear our opinion?

* What are your plans for the next 1 - 3 weeks?

While you gave us an overall plan during your project proposal, once you
start implementing, things often look very different in reality than on
paper. So plans change... however, it is important to still have a plan,
especially in the last month. This allows us to reach a more or less stable
end point, from which work can continue in the future, after GSoC.
The patch attached below, allows collaborative editing with simple use cases.
a) Cursor movements
b) Character insertion
c) Character Deletion
d) Mouse click, cursor location change
e) Cursor movement to and fro insets (boxes, tables etc.)
The patch has been diff-ed with master* branch.
--
Regards,
Cyrille Artho - http://artho.com/
The heart has its reasons which reason knows nothing of.
-- Blaise Pascal
Sushant Raikar
2014-06-06 10:12:09 UTC
Permalink
Thanks Cyrille,

I have updated the project's Wiki page to show my progress so far (under
'Project Status' section)

note: all of the patches are diffed with master branch.
Post by Cyrille Artho
Hi Sushant,
Thanks for posting the patch. It's good to see that you're making progress.
To understand your work better, it would be good if you could post some
more background on what you did/plan on doing, about every 1 - 2 weeks.
* What problems did you encounter/solve since you last gave us an update?
* What are the current problems? Any design/implementation decisions where
you'd like to hear our opinion?
* What are your plans for the next 1 - 3 weeks?
While you gave us an overall plan during your project proposal, once you
start implementing, things often look very different in reality than on
paper. So plans change... however, it is important to still have a plan,
especially in the last month. This allows us to reach a more or less stable
end point, from which work can continue in the future, after GSoC.
The patch attached below, allows collaborative editing with simple use cases.
a) Cursor movements
b) Character insertion
c) Character Deletion
d) Mouse click, cursor location change
e) Cursor movement to and fro insets (boxes, tables etc.)
The patch has been diff-ed with master* branch.
--
Regards,
Cyrille Artho - http://artho.com/
The heart has its reasons which reason knows nothing of.
-- Blaise Pascal
Sushant Raikar
2014-06-06 14:01:23 UTC
Permalink
Here's a link to the updated patch (after fixing whitespace, indentation,
ignored moc_* files and commented header file)

https://gist.github.com/HotSushi/a989d1657775d8eca6fe


link to project wiki page:

http://wiki.lyx.org/GSoC/InteractiveLyX
Post by Sushant Raikar
The patch attached below, allows collaborative editing with simple use
cases.
a) Cursor movements
b) Character insertion
c) Character Deletion
d) Mouse click, cursor location change
e) Cursor movement to and fro insets (boxes, tables etc.)
The patch has been diff-ed with master* branch.
Loading...