kit/ChildSession.cpp | 26 +++++++++++++++++++++++ kit/ChildSession.hpp | 2 + loleaflet/.eslintignore | 1 loleaflet/build/deps.js | 1 loleaflet/src/control/Control.Menubar.js | 3 ++ loleaflet/src/control/Toolbar.js | 3 ++ loleaflet/src/layer/tile/TileLayer.js | 34 +++++++++++++++++++++++++++++++ loleaflet/src/vcl.js | 18 ++++++++++++++++ tools/KitClient.cpp | 1 wsd/ClientSession.cpp | 4 ++- wsd/protocol.txt | 19 +++++++++++++++++ 11 files changed, 111 insertions(+), 1 deletion(-)
New commits: commit dbe7e34f89a491f32802104e2f10df9494ad6fe3 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Fri Nov 9 08:16:52 2018 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Nov 9 09:06:15 2018 +0100 add javascript vcl (vereign client library) to loleaflet Change-Id: I59ef8f6c0d0f5caf02210b12d0d6957f1944fee8 Reviewed-on: https://gerrit.libreoffice.org/63151 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/loleaflet/.eslintignore b/loleaflet/.eslintignore index bb6daf5b5..16a26ae93 100644 --- a/loleaflet/.eslintignore +++ b/loleaflet/.eslintignore @@ -1,3 +1,4 @@ # We only directly edit toolbar.js in dist/ **/js/w2ui-1.5.rc1.js **/src/unocommands.js +**/src/vcl.js diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js index 241d8b0cd..448ebf136 100644 --- a/loleaflet/build/deps.js +++ b/loleaflet/build/deps.js @@ -4,6 +4,7 @@ var deps = { src: ['Leaflet.js', 'errormessages.js', 'unocommands.js', + 'vcl.js', 'core/Log.js', 'core/Util.js', 'core/LOUtil.js', diff --git a/loleaflet/src/vcl.js b/loleaflet/src/vcl.js new file mode 100644 index 000000000..c0febeba5 --- /dev/null +++ b/loleaflet/src/vcl.js @@ -0,0 +1,18 @@ +/* eslint-disable no-alert, no-console */ +/* jshint ignore:start*/ +!function(e,n){var r={};!function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=e.ERR_CONNECTION_DESTROYED="ConnectionDestroyed",r=e.ERR_CONNECTION_TIMEOUT="ConnectionTimeout",t=e.ERR_NOT_IN_IFRAME="NotInIframe",o={"http:":"80","https:":"443"},a=/^(https?:)?\/\/([^\/:]+)(:(\d+))?/,i={ERR_CONNECTION_DESTROYED:n,ERR_CONNECTION_TIMEOUT:r,ERR_NOT_IN_IFRAME:t,Promise:function(){try{return window?window.Promise:null}catch(e){return null}}(),debug:!1},d=function(){var e=0;return function(){return++e}}(),c=function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];if(i.debug){var t;(t=console).log.apply(t,["[Penpal]"].concat(n))}},u=function(e){var n=document.location,r=a.exec(e),t=void 0,i=void 0,d=void 0;return r?(t=r[1]?r[1]:n.protocol,i=r[2],d=r[4]):(t=n.protocol,i=n.hostname,d=n.port),t+"//"+i+(d&&d!==o[t]?":"+d:"")},s=function(e){var n=[];return e(function(){n.forEach(function(e){e()})}),{then:function(e){n.push(e)}}},l=function(e){return{n ame:e.name,message:e.message,stack:e.stack}},m=function(e){var n=new Error;return Object.keys(e).forEach(function(r){return n[r]=e[r]}),n},f=function(e,r,t,o){var a=r.localName,u=r.local,s=r.remote,l=r.remoteOrigin,f=!1;c(a+": Connecting call sender");var v=function(e){return function(){for(var r=arguments.length,t=Array(r),o=0;o<r;o++)t[o]=arguments[o];if(c(a+": Sending "+e+"() call"),f){var v=new Error("Unable to send "+e+"() call due to destroyed connection");throw v.code=n,v}return new i.Promise(function(n,r){var o=d(),i=function t(i){if(i.source===s&&i.origin===l&&"reply"===i.data.penpal&&i.data.id===o){c(a+": Received "+e+"() reply"),u.removeEventListener("message",t);var d=i.data.returnValue;i.data.returnValueIsError&&(d=m(d)),("fulfilled"===i.data.resolution?n:r)(d)}};u.addEventListener("message",i),s.postMessage({penpal:"call",id:o,methodName:e,args:t},l)})}};o.then(function(){f=!0}),t.reduce(function(e,n){return e[n]=v(n),e},e)},v=function(e,n,r){var t=e.localName,o=e.loca l,a=e.remote,d=e.remoteOrigin,u=!1;c(t+": Connecting call receiver");var s=function(e){if(e.source===a&&e.origin===d&&"call"===e.data.penpal){var r=e.data,o=r.methodName,s=r.args,m=r.id;if(c(t+": Received "+o+"() call"),o in n){var f=function(e){return function(n){if(c(t+": Sending "+o+"() reply"),u)return void c(t+": Unable to send "+o+"() reply due to destroyed connection");var r={penpal:"reply",id:m,resolution:e,returnValue:n};"rejected"===e&&n instanceof Error&&(r.returnValue=l(n),r.returnValueIsError=!0);try{a.postMessage(r,d)}catch(e){throw"DataCloneError"===e.name&&a.postMessage({penpal:"reply",id:m,resolution:"rejected",returnValue:l(e),returnValueIsError:!0},d),e}}};new i.Promise(function(e){return e(n[o].apply(n,s))}).then(f("fulfilled"),f("rejected"))}}};o.addEventListener("message",s),r.then(function(){u=!0,o.removeEventListener("message",s)})};i.connectToChild=function(e){var t=e.url,o=e.appendTo,a=e.methods,d=void 0===a?{}:a,l=e.timeout,m=void 0,p=new s(function(e){m=e }),h=window,g=document.createElement("iframe");(o||document.body).appendChild(g),p.then(function(){g.parentNode&&g.parentNode.removeChild(g)});var E=g.contentWindow||g.contentDocument.parentWindow,w=u(t);return{promise:new i.Promise(function(e,o){var a=void 0;void 0!==l&&(a=setTimeout(function(){var e=new Error("Connection to child timed out after "+l+"ms");e.code=r,o(e),m()},l));var i={},u=void 0,y=void 0,N=function(n){if(n.source===E&&n.origin===w&&"handshake"===n.data.penpal){c("Parent: Received handshake, sending reply"),n.source.postMessage({penpal:"handshake-reply",methodNames:Object.keys(d)},n.origin);var r={localName:"Parent",local:h,remote:E,remoteOrigin:n.origin};y&&y();var t=new s(function(e){p.then(e),y=e});v(r,d,t),u&&u.forEach(function(e){delete i[e]}),u=n.data.methodNames,f(i,r,u,p),clearTimeout(a),e(i)}};h.addEventListener("message",N),p.then(function(){h.removeEventListener("message",N);var e=new Error("Connection destroyed");e.code=n,o(e)}),c("Parent: Loading ifram e"),g.src=t}),iframe:g,destroy:m}},i.connectToParent=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=e.parentOrigin,a=void 0===o?"*":o,d=e.methods,u=void 0===d?{}:d,l=e.timeout;if(window===window.top){var m=new Error("connectToParent() must be called within an iframe");throw m.code=t,m}var p=void 0,h=new s(function(e){p=e}),g=window,E=g.parent;return{promise:new i.Promise(function(e,t){var o=void 0;void 0!==l&&(o=setTimeout(function(){var e=new Error("Connection to parent timed out after "+l+"ms");e.code=r,t(e),p()},l));var i=function n(r){if(("*"===a||a===r.origin)&&r.source===E&&"handshake-reply"===r.data.penpal){c("Child: Received handshake reply"),g.removeEventListener("message",n);var t={localName:"Child",local:g,remote:E,remoteOrigin:r.origin},i={};v(t,u,h),f(i,t,r.data.methodNames,h),clearTimeout(o),e(i)}};g.addEventListener("message",i),h.then(function(){g.removeEventListener("message",i);var e=new Error("Connection destroyed");e.code=n,t(e)}),c( "Child: Sending handshake"),E.postMessage({penpal:"handshake",methodNames:Object.keys(u)},a)}),destroy:p}},e.default=i}(r),"function"==typeof define&&define.amd?define("Penpal",r.default):e.Penpal=r.default}(this); + +function setupViamAPI(divId, methodsArg, envUrl) { + const connection = Penpal.connectToChild({ + // URL of page to load into iframe. + url: envUrl, + // Container to which the iframe should be appended. + appendTo: document.getElementById(divId), + // Methods parent is exposing to child + methods: methodsArg + }); + + return connection.promise +} +/* jshint ignore:end */ +/* eslint-enable no-alert, no-console */ commit d8140d545b7d32479c756588b6c332fb2561bf76 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Nov 5 09:03:17 2018 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Nov 9 09:06:11 2018 +0100 add menu entry "Sign Document" Change-Id: Ia1fd7bd47506d8ecf4b5f152e04e7dcabaf7c50b Reviewed-on: https://gerrit.libreoffice.org/63150 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js index 04f00c6d4..37255c6ad 100644 --- a/loleaflet/src/control/Control.Menubar.js +++ b/loleaflet/src/control/Control.Menubar.js @@ -27,6 +27,7 @@ L.Control.Menubar = L.Control.extend({ {name: _('Word 2003 Document (.doc)'), id: 'downloadas-doc', type: 'action'}, {name: _('Word Document (.docx)'), id: 'downloadas-docx', type: 'action'}, {name: _('Rich Text (.rtf)'), id: 'downloadas-rtf', type: 'action'}]}, + {name: _('Sign document'), id: 'signdocument', type: 'action'}, {type: 'separator'}, {uno: '.uno:SetDocumentProperties'} ]}, @@ -690,6 +691,8 @@ L.Control.Menubar = L.Control.extend({ fileName = fileName.substr(0, fileName.lastIndexOf('.')); fileName = fileName === '' ? 'document' : fileName; this._map.downloadAs(fileName + '.' + format, format); + } else if (id === 'signdocument') { + this._map.showSignDocument(); } else if (id === 'insertcomment') { this._map.insertComment(); } else if (id === 'insertgraphic') { diff --git a/loleaflet/src/control/Toolbar.js b/loleaflet/src/control/Toolbar.js index debc090d6..eff05e281 100644 --- a/loleaflet/src/control/Toolbar.js +++ b/loleaflet/src/control/Toolbar.js @@ -179,6 +179,9 @@ L.Map.include({ this._socket.sendMessage('renderfont font=' + window.encodeURIComponent(fontName)); }, + showSignDocument: function() { + }, + showLOKeyboardHelp: function() { var w = window.innerWidth / 2; var map = this; commit 98f9064cbb5afa9f14d86db0720f3eb91a1ba45e Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Tue Oct 30 00:10:48 2018 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Nov 9 09:06:06 2018 +0100 show infobar for signature status (callback) Change-Id: If3ba239e20475f25e370b9b836af913f91befd8e Reviewed-on: https://gerrit.libreoffice.org/62534 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 573b46d76..c6ce9ac96 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -482,6 +482,40 @@ L.TileLayer = L.GridLayer.extend({ else if (textMsg.startsWith('validitylistbutton:')) { this._onValidityListButtonMsg(textMsg); } + else if (textMsg.startsWith('signaturestatus:')) { + var signstatus = textMsg.substring('signaturestatus:'.length + 1); + + if (signstatus == '1') { + this._map.fire('infobar', + { + msg: 'Document signed and validated.', action: null, actionLabel: null + }); + } + else if (signstatus == '2') { + this._map.fire('infobar', + { + msg: 'Document signed but signatue is broken.', action: null, actionLabel: null + }); + } + else if (signstatus == '3') { + this._map.fire('infobar', + { + msg: 'Document signed but the document is already modified.', action: null, actionLabel: null + }); + } + else if (signstatus == '4') { + this._map.fire('infobar', + { + msg: 'Document signed but can not be validated.', action: null, actionLabel: null + }); + } + else if (signstatus == '5') { + this._map.fire('infobar', + { + msg: 'Document signed but not all files are signed.', action: null, actionLabel: null + }); + } + } }, toggleTileDebugModeImpl: function() { commit 852ed5d9819feb54a7f70a879dd89e9d071bfebf Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Mon Oct 29 23:34:14 2018 +0100 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Fri Nov 9 09:06:02 2018 +0100 handle signature status and prepare document signing in WSD This adds handling of signature status (manually request for the status or as a callback) in WSD. In addition prepare support for signing of document, but don't yet trigger the actual LOKit function (needs the JS building blocks set up first to know how to handle the payload - certificate and private key) Change-Id: Ic76baa5847bb52adde616338187d5979e0093c6d Reviewed-on: https://gerrit.libreoffice.org/62533 Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> Tested-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/kit/ChildSession.cpp b/kit/ChildSession.cpp index 3e6a904ce..4e6c3ef7a 100644 --- a/kit/ChildSession.cpp +++ b/kit/ChildSession.cpp @@ -331,6 +331,14 @@ bool ChildSession::_handleInput(const char *buffer, int length) { sendWindowCommand(buffer, length, tokens); } + else if (tokens[0] == "signdocument") + { + signDocumentContent(buffer, length, tokens); + } + else if (tokens[0] == "asksignaturestatus") + { + askSignatureStatus(buffer, length, tokens); + } else { assert(false && "Unknown command token."); @@ -1104,6 +1112,21 @@ bool ChildSession::sendWindowCommand(const char* /*buffer*/, int /*length*/, con return true; } +bool ChildSession::signDocumentContent(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& /*tokens*/) +{ + return true; +} + +bool ChildSession::askSignatureStatus(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& /*tokens*/) +{ + std::unique_lock<std::mutex> lock(_docManager.getDocumentMutex()); + + int nStatus = getLOKitDocument()->getSignatureState(); + + sendTextFrame("signaturestatus: " + nStatus); + return true; +} + bool ChildSession::selectGraphic(const char* /*buffer*/, int /*length*/, const std::vector<std::string>& tokens) { int type, x, y; @@ -1586,6 +1609,9 @@ void ChildSession::loKitCallback(const int type, const std::string& payload) sendTextFrame("clipboardchanged: " + selection); break; } + case LOK_CALLBACK_SIGNATURE_STATUS: + sendTextFrame("signaturestatus: " + payload); + break; default: LOG_ERR("Unknown callback event (" << type << "): " << payload); } diff --git a/kit/ChildSession.hpp b/kit/ChildSession.hpp index b67a18980..292614ff1 100644 --- a/kit/ChildSession.hpp +++ b/kit/ChildSession.hpp @@ -230,6 +230,8 @@ private: bool setClientPart(const char* buffer, int length, const std::vector<std::string>& tokens); bool setPage(const char* buffer, int length, const std::vector<std::string>& tokens); bool sendWindowCommand(const char* buffer, int length, const std::vector<std::string>& tokens); + bool signDocumentContent(const char* buffer, int length, const std::vector<std::string>& tokens); + bool askSignatureStatus(const char* buffer, int length, const std::vector<std::string>& tokens); void rememberEventsForInactiveUser(const int type, const std::string& payload); diff --git a/tools/KitClient.cpp b/tools/KitClient.cpp index bc756b1d7..cdceb8a7b 100644 --- a/tools/KitClient.cpp +++ b/tools/KitClient.cpp @@ -82,6 +82,7 @@ extern "C" CASE(WINDOW); CASE(VALIDITY_LIST_BUTTON); CASE(CLIPBOARD_CHANGED); + CASE(SIGNATURE_STATUS); #undef CASE } std::cout << " payload: " << payload << std::endl; diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 9101c7237..896163360 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -171,7 +171,9 @@ bool ClientSession::_handleInput(const char *buffer, int length) tokens[0] != "useractive" && tokens[0] != "userinactive" && tokens[0] != "paintwindow" && - tokens[0] != "windowcommand") + tokens[0] != "windowcommand" && + tokens[0] != "signdocument" && + tokens[0] != "asksignaturestatus") { sendTextFrame("error: cmd=" + tokens[0] + " kind=unknown"); return false; diff --git a/wsd/protocol.txt b/wsd/protocol.txt index 8bd29e638..bafebd452 100644 --- a/wsd/protocol.txt +++ b/wsd/protocol.txt @@ -223,6 +223,15 @@ versionrestore <action> - prerestore: The storage is about restore the document to an earlier revision. +asksignaturestatus + + Requests a signing status of the document. + +signdocument + + Sign the current document with the input cetificate and private key. + + server -> client ================ @@ -474,6 +483,16 @@ versionrestore: <action> - prerestore_ack: The host can go ahead with restoring the document to an earlier revision. +signaturestatus: <sign status> + Possible values: + 0xffff - Unknown + 0 - NOSIGNATURES + 1 - OK + 2 - BROKEN + 3 - INVALID (signature is OK, but doc is modified now) + 4 - NOTVALIDATED (signature is OK, but certificate could not be validated) + 5 - PARTIAL_OK (signature and certificate are ok, but not all files are signed - old documents only) + child -> parent =============== _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits