[Libreoffice-commits] online.git: common/Session.cpp common/Session.hpp kit/Kit.cpp loleaflet/js loleaflet/src wsd/ClientSession.cpp wsd/protocol.txt
Marco Cecchetti (via logerrit)
logerrit at kemper.freedesktop.org
Wed Apr 29 11:19:08 UTC 2020
common/Session.cpp | 5 +++++
common/Session.hpp | 5 +++++
kit/Kit.cpp | 4 ++++
loleaflet/js/global.js | 17 +++++++++++++++++
loleaflet/src/core/Socket.js | 4 ++++
loleaflet/src/map/Map.js | 6 ++----
wsd/ClientSession.cpp | 5 +++++
wsd/protocol.txt | 5 ++++-
8 files changed, 46 insertions(+), 5 deletions(-)
New commits:
commit 255d24ba8fc8669b4197887e69bd4406af4cba14
Author: Marco Cecchetti <marco.cecchetti at collabora.com>
AuthorDate: Mon Apr 20 21:26:21 2020 +0200
Commit: Marco Cecchetti <marco.cecchetti at collabora.com>
CommitDate: Wed Apr 29 13:18:49 2020 +0200
forward the device form factor of the client on a new view request
This patch allows the lok core to know about the device form facor of
the client requesting the creation of a new view, immediately instead
of a later time.
When a request for a new view is sent a 'deviceFormFactor' parameter
is appended to the message.
This parameter can have one of the following values: 'desktop',
'tablet','mobile' and is forwarded to the lok core.
Change-Id: I21739ddb8c43c960164b3c625e4cf0a80f4616a4
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92691
Tested-by: Marco Cecchetti <marco.cecchetti at collabora.com>
Reviewed-by: Marco Cecchetti <marco.cecchetti at collabora.com>
diff --git a/common/Session.cpp b/common/Session.cpp
index e7f551979..ef8deea25 100644
--- a/common/Session.cpp
+++ b/common/Session.cpp
@@ -184,6 +184,11 @@ void Session::parseDocOptions(const StringVector& tokens, int& part, std::string
doctemplate = value;
++offset;
}
+ else if (name == "deviceFormFactor")
+ {
+ _deviceFormFactor = value;
+ ++offset;
+ }
}
Util::mapAnonymized(_userId, _userIdAnonym);
diff --git a/common/Session.hpp b/common/Session.hpp
index 3e5f4c89b..402223963 100644
--- a/common/Session.hpp
+++ b/common/Session.hpp
@@ -197,6 +197,8 @@ public:
_canonicalViewId = map.getCanonicalId(_watermarkText);
}
+ const std::string& getDeviceFormFactor() const { return _deviceFormFactor; }
+
protected:
Session(const std::shared_ptr<ProtocolHandlerInterface> &handler,
const std::string& name, const std::string& id, bool readonly);
@@ -288,6 +290,9 @@ private:
/// the canonical id unique to the set of rendering properties of this session
int _canonicalViewId;
+
+ /// The form factor of the device where the client is running: desktop, tablet, mobile.
+ std::string _deviceFormFactor;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/kit/Kit.cpp b/kit/Kit.cpp
index b5409ca68..52cd43f8c 100644
--- a/kit/Kit.cpp
+++ b/kit/Kit.cpp
@@ -1675,11 +1675,15 @@ private:
const std::string& docPassword = session->getDocPassword();
const bool haveDocPassword = session->getHaveDocPassword();
const std::string& lang = session->getLang();
+ const std::string& deviceFormFactor = session->getDeviceFormFactor();
std::string options;
if (!lang.empty())
options = "Language=" + lang;
+ if (!deviceFormFactor.empty())
+ options += ",DeviceFormFactor=" + deviceFormFactor;
+
if (!_loKitDocument)
{
// This is the first time we are loading the document
diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js
index c2935ab96..07ae23ad9 100644
--- a/loleaflet/js/global.js
+++ b/loleaflet/js/global.js
@@ -158,9 +158,21 @@
},
isDesktop: function() {
return !L.Browser.mobile;
+ },
+ getDeviceFormFactor: function() {
+ if (window.mode.isMobile())
+ return 'mobile';
+ else if (window.mode.isTablet())
+ return 'tablet';
+ else if (window.mode.isDesktop())
+ return 'desktop';
+ else
+ return null;
}
};
+ global.deviceFormFactor = window.mode.getDeviceFormFactor();
+
document.addEventListener('contextmenu', function(e) {
if (e.preventDefault) {
e.preventDefault();
@@ -548,6 +560,11 @@
}
// renderingOptions?
}
+
+ if (window.deviceFormFactor) {
+ msg += ' deviceFormFactor=' + window.deviceFormFactor;
+ }
+
global.socket.send(msg);
}
};
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index fdd0b2db6..f6ba2a5c1 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -187,12 +187,16 @@ L.Socket = L.Class.extend({
if (String.locale) {
msg += ' lang=' + String.locale;
}
+ if (window.deviceFormFactor) {
+ msg += ' deviceFormFactor=' + window.deviceFormFactor;
+ }
if (this._map.options.renderingOptions) {
var options = {
'rendering': this._map.options.renderingOptions
};
msg += ' options=' + JSON.stringify(options);
}
+
this._doSend(msg);
for (var i = 0; i < this._msgQueue.length; i++) {
this._doSend(this._msgQueue[i]);
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index bebb1af99..bf331537e 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -215,14 +215,12 @@ L.Map = L.Evented.extend({
L.DomUtil.remove(L.DomUtil.get('presentation-controls-wrapper'));
}
- // We need core's knowledge of whether it is a mobile phone or not (which is
- // what .uno:LOKSetMobile does) to be in sync with the test in
- // _onJSDialogMsg in TileLayer.js.
+ // We need core's knowledge of whether it is a mobile phone
+ // or not to be in sync with the test in _onJSDialogMsg in TileLayer.js.
if (window.mode.isMobile())
{
this._size = new L.Point(0,0);
this._onResize();
- this._socket.sendMessage('uno .uno:LOKSetMobile');
}
});
this.on('updatetoolbarcommandvalues', function(e) {
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index a73749352..c31db7317 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -820,6 +820,11 @@ bool ClientSession::loadDocument(const char* /*buffer*/, int /*length*/,
oss << " lang=" << getLang();
}
+ if (!getDeviceFormFactor().empty())
+ {
+ oss << " deviceFormFactor=" << getDeviceFormFactor();
+ }
+
if (!getWatermarkText().empty())
{
std::string encodedWatermarkText;
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index 8e8eaa847..9b1f43e03 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -90,7 +90,7 @@ load <pathname>
Deprecated.
-load [part=<partNumber>] url=<url> [timestamp=<time>] [lang=<locale>] [options=<options>]
+load [part=<partNumber>] url=<url> [timestamp=<time>] [lang=<locale>] [deviceFormFactor=<device type>] [options=<options>]
part is an optional parameter. <partNumber> is a number.
@@ -100,6 +100,9 @@ load [part=<partNumber>] url=<url> [timestamp=<time>] [lang=<locale>] [options=<
lang specifies the locale to which we should switch before loading the
document
+ deviceFormFactor specifies the form factor of the device the client is running on
+ it can be one of the following: 'desktop', 'tablet', 'mobile'
+
options are the whole rest of the line, not URL-encoded, and must be valid JSON.
loolclient <major.minor[-patch]>
More information about the Libreoffice-commits
mailing list