From 60c34e5881dea016bdc56cfc919f40777197a16b Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Fri, 5 Aug 2016 12:39:56 +0200 Subject: [PATCH] W.I.P of collaborative odf editor: - Define ServerFactory for egw collab - Revert unintentional commits on Server.js --- api/js/webodf/collab/ServerFactory.js | 30 +++++++++++++++++++ .../webodf/collab/backend/pullbox/Server.js | 12 -------- filemanager/js/app.js | 4 +-- 3 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 api/js/webodf/collab/ServerFactory.js diff --git a/api/js/webodf/collab/ServerFactory.js b/api/js/webodf/collab/ServerFactory.js new file mode 100644 index 0000000000..85003f73fb --- /dev/null +++ b/api/js/webodf/collab/ServerFactory.js @@ -0,0 +1,30 @@ +define("egwCollab/ServerFactory", [ + "webodf/editor/backend/pullbox/Server", + "webodf/editor/backend/pullbox/SessionBackend", + "webodf/editor/backend/pullbox/SessionList"], + function (PullBoxServer, PullBoxSessionBackend, PullBoxSessionList) { + "use strict"; + + /** + * @constructor + * @implements ServerFactory + */ + return function egwCollabServerFactory() { + this.createServer = function (args) { + var server; + args = args || {}; + + server = new PullBoxServer(args); + server.getGenesisUrl = function(sid) { + return args.genesisUrl; + }; + return server; + }; + this.createSessionBackend = function (sid, mid, server) { + return new PullBoxSessionBackend(sid, mid, server); + }; + this.createSessionList = function (server) { + return new PullBoxSessionList(server); + }; + }; +}); diff --git a/api/js/webodf/collab/backend/pullbox/Server.js b/api/js/webodf/collab/backend/pullbox/Server.js index e473778e98..a8abd72325 100644 --- a/api/js/webodf/collab/backend/pullbox/Server.js +++ b/api/js/webodf/collab/backend/pullbox/Server.js @@ -144,16 +144,6 @@ define("webodf/editor/backend/pullbox/Server", [], function () { * @return {undefined} */ this.login = function (login, password, successCb, failCb) { - successCb ({ - 'full_name' :'Hadi Nategh', - 'uid' : 'sysop', - 'securityToken' : '10000', - 'token' : '10000', - 'sessiondata_list' : [], - 'success' : true, - 'member_id' : 'sysop' - }); - return; call({ command: "login", args: { @@ -183,8 +173,6 @@ define("webodf/editor/backend/pullbox/Server", [], function () { * @return {undefined} */ this.joinSession = function (userId, sessionId, successCb, failCb) { - successCb('sysop'); - return; call({ command: "join_session", args: { diff --git a/filemanager/js/app.js b/filemanager/js/app.js index 73fa91e1c3..2e1eb1fc74 100644 --- a/filemanager/js/app.js +++ b/filemanager/js/app.js @@ -1381,7 +1381,7 @@ app.classes.filemanager = AppJS.extend( var sid = _sessionId; server.joinSession(userId, sid, function (_memberId) { memberId = _memberId; - if (self.editor) { + if (Object.keys(self.editor).length == 0) { Wodo.createCollabTextEditor('filemanager-editor_odfEditor', editorOptions, onEditorCreated); } else { self.editor.joinSession(serverFactory.createSessionBackend(sid, _memberId, server), onEditing); @@ -1391,7 +1391,7 @@ app.classes.filemanager = AppJS.extend( }); }; - require(["webodf/editor/backend/pullbox/ServerFactory"], function (ServerFactory) { + require(["egwCollab/ServerFactory"], function (ServerFactory) { serverFactory = new ServerFactory(); server = serverFactory.createServer(serverParams); server.connect(8000, function (state) {