[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - loleaflet/src wsd/DocumentBroker.cpp wsd/reference.txt wsd/Storage.cpp wsd/Storage.hpp

2017-08-29 Thread Jan Holesovsky
 loleaflet/src/core/Socket.js  |9 +++--
 loleaflet/src/map/Map.js  |9 +++--
 loleaflet/src/map/handler/Map.WOPI.js |2 ++
 wsd/DocumentBroker.cpp|1 +
 wsd/Storage.cpp   |4 +++-
 wsd/Storage.hpp   |4 
 wsd/reference.txt |6 ++
 7 files changed, 30 insertions(+), 5 deletions(-)

New commits:
commit a23bcd535e55cc803c5676b44655331c30bad026
Author: Jan Holesovsky 
Date:   Tue Aug 29 18:59:14 2017 +0200

WOPI extension: DisableInactiveMessages to avoid showing message when 
dimmed.

Change-Id: I925602295dde95611ab1a6565dd7266460769a50
Reviewed-on: https://gerrit.libreoffice.org/41708
Reviewed-by: pranavk 
Tested-by: pranavk 

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 4a41145e..05d7d82b 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -236,7 +236,7 @@ L.Socket = L.Class.extend({
postMsgData['Reason'] = 'OwnerTermination';
}
else if (textMsg === 'idle' || textMsg === 'oom') {
-   msg = _('Session was terminated due to idleness 
- please click to reload');
+   msg = _('Idle document - please click to reload 
and resume editing');
this._map._documentIdle = true;
postMsgData['Reason'] = 'DocumentIdle';
if (textMsg === 'oom')
@@ -284,12 +284,17 @@ L.Socket = L.Class.extend({
vex.close(id);
}
 
+   var message = '';
+   if (!this._map['wopi'].DisableInactiveMessages) {
+   message = msg;
+   }
+
var options = $.extend({}, vex.defaultOptions, {
contentCSS: {'background':'rgba(0, 0, 0, 0)',
 'font-size': 'xx-large',
 'color': '#fff',
 'text-align': 'center'},
-   content: msg
+   content: message
});
options.id = vex.globalID;
vex.dialogID = options.id;
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 3d80e4ba..9553a567 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -859,12 +859,18 @@ L.Map = L.Evented.extend({
this._active = false;
clearTimeout(vex.timer);
 
+   var message = '';
+   var map = this;
+   if (!map['wopi'].DisableInactiveMessages) {
+   message = _('Inactive document - please click to resume 
editing');
+   }
+
var options = $.extend({}, vex.defaultOptions, {
contentCSS: {'background':'rgba(0, 0, 0, 0)',
 'font-size': 'xx-large',
 'color': '#fff',
 'text-align': 'center'},
-   content: _('Inactive document - please click to resume 
editing')
+   content: message
});
options.id = vex.globalID;
vex.dialogID = options.id;
@@ -876,7 +882,6 @@ L.Map = L.Evented.extend({
vex: options
});
 
-   var map = this;
options.$vex.bind('click.vex', function(e) {
console.debug('_dim: click.vex function');
return map._activate();
diff --git a/loleaflet/src/map/handler/Map.WOPI.js 
b/loleaflet/src/map/handler/Map.WOPI.js
index 3b3f31e2..a04a2162 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -15,6 +15,7 @@ L.Map.WOPI = L.Handler.extend({
DisablePrint: false,
DisableExport: false,
DisableCopy: false,
+   DisableInactiveMessages: false,
 
_appLoadedConditions: {
docloaded: false,
@@ -65,6 +66,7 @@ L.Map.WOPI = L.Handler.extend({
this.DisablePrint = !!wopiInfo['DisablePrint'];
this.DisableExport = !!wopiInfo['DisableExport'];
this.DisableCopy = !!wopiInfo['DisableCopy'];
+   this.DisableInactiveMessages = 
!!wopiInfo['DisableInactiveMessages'];
 
this._map.fire('postMessage', {msgId: 'App_LoadingStatus', 
args: {Status: 'Frame_Ready'}});
},
diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index 84e7441c..568187d9 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -430,6 +430,7 @@ bool DocumentBroker::load(const 
std::sha

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - loleaflet/src

2017-08-29 Thread Pranav Kant
 loleaflet/src/core/Socket.js |   12 
 1 file changed, 8 insertions(+), 4 deletions(-)

New commits:
commit dabbebfa927119d17f71887688bff60bd2a40681
Author: Pranav Kant 
Date:   Fri Aug 25 17:38:26 2017 +0530

loleaflet: Mention the reason of closing websocket to WOPI hosts

Reason is part of the JSON of post message with ID, 'Session_Close'.

Change-Id: I51a465f63fbd80843292a3f19c5b89f920301194
(cherry picked from commit 29aef0af4b5c2a883131f60c7cea5f13eddf48f6)
Reviewed-on: https://gerrit.libreoffice.org/41571
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index e37473be..4a41145e 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -229,21 +229,25 @@ L.Socket = L.Class.extend({
else if (textMsg.startsWith('close: ')) {
textMsg = textMsg.substring('close: '.length);
msg = '';
-
+   var postMsgData = {};
// This is due to document owner terminating the session
if (textMsg === 'ownertermination') {
msg = _('Session terminated by document owner');
+   postMsgData['Reason'] = 'OwnerTermination';
}
else if (textMsg === 'idle' || textMsg === 'oom') {
msg = _('Session was terminated due to idleness 
- please click to reload');
this._map._documentIdle = true;
+   postMsgData['Reason'] = 'DocumentIdle';
+   if (textMsg === 'oom')
+   postMsgData['Reason'] = 'OOM';
}
else if (textMsg === 'shuttingdown') {
msg = _('Server is shutting down for 
maintenance (auto-saving)');
+   postMsgData['Reason'] = 'ShuttingDown';
}
else if (textMsg === 'recycling') {
msg = _('Server is recycling and will be 
available shortly');
-
this._map._active = false;
this._map._serverRecycling = true;
 
@@ -316,9 +320,9 @@ L.Socket = L.Class.extend({
$(options.appendLocation).append(options.$vex);
vex.setupBodyClassName(options.$vex);
 
-   if (textMsg !== 'shuttingdown') {
+   if (postMsgData['Reason']) {
// Tell WOPI host about it which should handle 
this situation
-   this._map.fire('postMessage', {msgId: 
'Session_Closed'});
+   this._map.fire('postMessage', {msgId: 
'Session_Closed', args: postMsgData});
}
 
if (textMsg === 'ownertermination') {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - loleaflet/src

2017-08-14 Thread Pranav Kant
 loleaflet/src/map/handler/Map.WOPI.js |9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

New commits:
commit dd604fea10cb2dc126e0e8b6ebd7bf14babdaf7c
Author: Pranav Kant 
Date:   Mon Aug 14 17:42:07 2017 +0530

loleaflet: Handle Close_Session even if document is not loaded

Now the Close_Session Post message command can be used to close the
documents while it is loading.

Change-Id: If60391834fedc90b3dcb63848aa72503eb43888d
(cherry picked from commit 1a9d5c2cccaec2c845af012b2dea3dab89b5241e)
Reviewed-on: https://gerrit.libreoffice.org/41139
Reviewed-by: Ashod Nakashian 
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/loleaflet/src/map/handler/Map.WOPI.js 
b/loleaflet/src/map/handler/Map.WOPI.js
index 70efcea4..3b3f31e2 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -109,6 +109,12 @@ L.Map.WOPI = L.Handler.extend({
return;
}
 
+   // allow closing documents before they are completely loaded
+   if (msg.MessageId === 'Close_Session') {
+   this._map._socket.sendMessage('closedocument');
+   return;
+   }
+
// For all other messages, warn if trying to interact before we 
are completely loaded
if (!this._appLoaded) {
console.error('LibreOffice Online not loaded yet. 
Listen for App_LoadingStatus (Document_Loaded) event before using PostMessage 
API. Ignoring post message \'' + msg.MessageId + '\'.');
@@ -170,9 +176,6 @@ L.Map.WOPI = L.Handler.extend({
 
this._postMessage({msgId: 'Get_Views_Resp', args: 
getMembersRespVal});
}
-   else if (msg.MessageId === 'Close_Session') {
-   this._map._socket.sendMessage('closedocument');
-   }
else if (msg.MessageId === 'Action_Save') {
var dontTerminateEdit = msg.Values && 
msg.Values['DontTerminateEdit'];
var dontSaveIfUnmodified = msg.Values && 
msg.Values['DontSaveIfUnmodified'];
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - loleaflet/src

2017-08-14 Thread Pranav Kant
 loleaflet/src/map/handler/Map.WOPI.js |   11 +++
 1 file changed, 11 insertions(+)

New commits:
commit f7e5b5f2e8eca1a857c1b0e0e361253c7334b717
Author: Pranav Kant 
Date:   Tue Jun 20 17:12:43 2017 +0530

Warn users if they try to use post message API incorrectly

Change-Id: I09ce1a14587f558765e02fc8197030f4a5d2cee0
(cherry picked from commit 2abf2421f3e984693b114e8597d2e88fd1430ba8)
Reviewed-on: https://gerrit.libreoffice.org/41138
Reviewed-by: Ashod Nakashian 
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/loleaflet/src/map/handler/Map.WOPI.js 
b/loleaflet/src/map/handler/Map.WOPI.js
index b13bff44..70efcea4 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -104,6 +104,17 @@ L.Map.WOPI = L.Handler.extend({
}
 
var msg = JSON.parse(e.data);
+   if (msg.MessageId === 'Host_PostmessageReady') {
+   // We already have a listener for this in 
loleaflet.html, so ignore it here
+   return;
+   }
+
+   // For all other messages, warn if trying to interact before we 
are completely loaded
+   if (!this._appLoaded) {
+   console.error('LibreOffice Online not loaded yet. 
Listen for App_LoadingStatus (Document_Loaded) event before using PostMessage 
API. Ignoring post message \'' + msg.MessageId + '\'.');
+   return;
+   }
+
if (msg.MessageId === 'Insert_Button') {
if (msg.Values) {
if (msg.Values.id && 
!w2ui['toolbar-up'].get(msg.Values.id)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - loleaflet/src

2017-08-14 Thread Pranav Kant
 loleaflet/src/map/Map.js |8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

New commits:
commit 23a4a887f2ce1102d802837851efd85c1fd9d9d9
Author: Pranav Kant 
Date:   Fri Aug 11 22:32:34 2017 +0530

loleaflet: activate the inactivity timer after document load

The timer is cancelled right after 'statusindicator' is received, so a
document never really go to inactive mode after set inactivity time
period (unless user refocuses the document). Call _activate() to ensure
that timer is started after document is completely loaded.

Also timer shouldn't really start when the document is not yet loaded.

Change-Id: I58f5d7718c65cc37da9c3feb99ee6b16741a22a2
(cherry picked from commit 8c74d4a38d0fc13e859ea0e936fca0102a0e9d0d)
Reviewed-on: https://gerrit.libreoffice.org/41058
Reviewed-by: Ashod Nakashian 
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 5d6f08a2..3d80e4ba 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -152,14 +152,16 @@ L.Map = L.Evented.extend({
}, this);
 
this.on('docloaded', function(e) {
-   if (e.status) {
+   this._docLoaded = e.status;
+   if (this._docLoaded) {
// so that dim timer starts from now()
this.lastActiveTime = Date.now();
if (!document.hasFocus()) {
this._deactivate();
+   } else {
+   this._activate();
}
}
-   this._docLoaded = e.status;
}, this);
},
 
@@ -906,7 +908,7 @@ L.Map = L.Evented.extend({
},
 
_startInactiveTimer: function () {
-   if (this._serverRecycling || this._documentIdle) {
+   if (this._serverRecycling || this._documentIdle || 
!this._docLoaded) {
return;
}
 
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - loleaflet/src

2017-08-14 Thread Pranav Kant
 loleaflet/src/core/Socket.js  |  109 ++
 loleaflet/src/map/Map.js  |   19 +
 loleaflet/src/map/handler/Map.WOPI.js |   12 ++-
 3 files changed, 84 insertions(+), 56 deletions(-)

New commits:
commit e952a0a6ed8814849e1cf084025966093a0a77ea
Author: Pranav Kant 
Date:   Fri Aug 11 21:39:12 2017 +0530

loleaflet: new event, docloaded, to sync. various things

First, use the docloaded event to see whether we should be dimming the
document (make it inactive) or not. There is no point in inactivating a
document before document has completely loaded; so don't start the timer
until after the document is completely loaded.

It turns out that we were only emitting the WOPI's App_LoadingStatus
with DocumentLoaded for the first document load, but not for subsequent
reconnections. The problem here was that doclayerinit event is only
emitted during first document load (when TileLayer is -actually-
initialized), which was responsible for emitting this event. By
bifurcating the document load from document layer initialization, we
solve this problem.

Change-Id: I0b7b97fc6244ba9ebd6318d68d78d3abef2c0c08
(cherry picked from commit d0be89bffa339e6cefc88cd3ca56ccd86ec1f517)
Reviewed-on: https://gerrit.libreoffice.org/41057
Reviewed-by: Ashod Nakashian 
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index 9843d6e7..e37473be 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -62,6 +62,9 @@ L.Socket = L.Class.extend({
this.socket.onmessage = function () {};
this.socket.close();
 
+   // Reset wopi's app loaded so that reconnecting again informs 
outerframe about initialization
+   this._map['wopi'].resetAppLoaded();
+   this._map.fire('docloaded', {status: false});
clearTimeout(this._accessTokenExpireTimeout);
},
 
@@ -509,59 +512,64 @@ L.Socket = L.Class.extend({
var img = 'data:image/png;base64,' + 
window.btoa(strBytes);
}
 
-   if (textMsg.startsWith('status:') && !this._map._docLayer) {
-   // first status message, we need to create the document 
layer
-   var tileWidthTwips = this._map.options.tileWidthTwips;
-   var tileHeightTwips = this._map.options.tileHeightTwips;
-   if (this._map.options.zoom !== 
this._map.options.defaultZoom) {
-   var scale = 
this._map.options.crs.scale(this._map.options.defaultZoom - 
this._map.options.zoom);
-   tileWidthTwips = Math.round(tileWidthTwips * 
scale);
-   tileHeightTwips = Math.round(tileHeightTwips * 
scale);
-   }
+   if (textMsg.startsWith('status:')) {
+   if (!this._map._docLayer) {
+   // first status message, we need to create the 
document layer
+   var tileWidthTwips = 
this._map.options.tileWidthTwips;
+   var tileHeightTwips = 
this._map.options.tileHeightTwips;
+   if (this._map.options.zoom !== 
this._map.options.defaultZoom) {
+   var scale = 
this._map.options.crs.scale(this._map.options.defaultZoom - 
this._map.options.zoom);
+   tileWidthTwips = 
Math.round(tileWidthTwips * scale);
+   tileHeightTwips = 
Math.round(tileHeightTwips * scale);
+   }
 
-   var docLayer = null;
-   if (command.type === 'text') {
-   docLayer = new L.WriterTileLayer('', {
-   permission: 
this._map.options.permission,
-   tileWidthTwips: tileWidthTwips,
-   tileHeightTwips: tileHeightTwips,
-   docType: command.type
-   });
-   }
-   else if (command.type === 'spreadsheet') {
-   docLayer = new L.CalcTileLayer('', {
-   permission: 
this._map.options.permission,
-   tileWidthTwips: tileWidthTwips,
-   tileHeightTwips: tileHeightTwips,
-   docType: command.type
-   });
-   }
-   else {
-   if (command.type === 'presentation' &&
-   this._map.options.defaultZoom 

[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-cd' - loleaflet/src

2017-08-07 Thread Marco Cecchetti
 loleaflet/src/map/handler/Map.Mouse.js |   34 +
 1 file changed, 18 insertions(+), 16 deletions(-)

New commits:
commit 0c948fa62890cb68537008e2a4e3a60ffc594559
Author: Marco Cecchetti 
Date:   Tue Aug 1 17:51:27 2017 +0200

loleaflet: graphic selection can get misplaced if mouse is moved fast

Change-Id: I2c1893110ce76bed2c822c8d1ddd293c8f627307
Reviewed-on: https://gerrit.libreoffice.org/40644
Reviewed-by: Jan Holesovsky 
Tested-by: Jan Holesovsky 
(cherry picked from commit 67de89cbbc238b12b1064a2107967caecd9f126c)
Reviewed-on: https://gerrit.libreoffice.org/40826

diff --git a/loleaflet/src/map/handler/Map.Mouse.js 
b/loleaflet/src/map/handler/Map.Mouse.js
index b5861ff1..78229005 100644
--- a/loleaflet/src/map/handler/Map.Mouse.js
+++ b/loleaflet/src/map/handler/Map.Mouse.js
@@ -45,25 +45,27 @@ L.Map.Mouse = L.Handler.extend({
if (docLayer._graphicMarker.isDragged) {
return;
}
-   if 
(!docLayer._isEmptyRectangle(docLayer._graphicSelection) &&
-   
docLayer._graphicMarker.getBounds().contains(e.latlng)) {
+   if 
(!docLayer._isEmptyRectangle(docLayer._graphicSelection)) {
// if we have a graphic selection and the user 
clicks inside the rectangle
-   if (e.type === 'mousedown') {
+   var isInside = 
docLayer._graphicMarker.getBounds().contains(e.latlng);
+   if (e.type === 'mousedown' && isInside) {
this._prevMousePos = e.latlng;
}
-   else if (e.type === 'mousemove' && 
this._mouseDown && !this._prevMousePos) {
-   // if the user started to drag the 
shape before the selection
-   // has been drawn
-   this._prevMousePos = e.latlng;
-   }
-   else if (e.type === 'mousemove' && 
this._prevMousePos) {
-   // we have a graphic selection and the 
user started to drag it
-   var delta = L.latLng(e.latlng.lat - 
this._prevMousePos.lat, e.latlng.lng - this._prevMousePos.lng);
-   this._prevMousePos = e.latlng;
-   var oldSelectionCenter = 
docLayer._graphicMarker.getBounds().getCenter();
-   var newSelectionCenter = 
L.latLng(oldSelectionCenter.lat + delta.lat, oldSelectionCenter.lng + 
delta.lng);
-   if (docLayer._graphicMarker.editing) {
-   
docLayer._graphicMarker.editing._move(newSelectionCenter);
+   else if (e.type === 'mousemove' && 
this._mouseDown) {
+   if (!this._prevMousePos && isInside) {
+   // if the user started to drag 
the shape before the selection
+   // has been drawn
+   this._prevMousePos = e.latlng;
+   }
+   else {
+   // we have a graphic selection 
and the user started to drag it
+   var delta = 
L.latLng(e.latlng.lat - this._prevMousePos.lat, e.latlng.lng - 
this._prevMousePos.lng);
+   this._prevMousePos = e.latlng;
+   var oldSelectionCenter = 
docLayer._graphicMarker.getBounds().getCenter();
+   var newSelectionCenter = 
L.latLng(oldSelectionCenter.lat + delta.lat, oldSelectionCenter.lng + 
delta.lng);
+   if 
(docLayer._graphicMarker.editing) {
+   
docLayer._graphicMarker.editing._move(newSelectionCenter);
+   }
}
}
else if (e.type === 'mouseup') {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits