common/Util.cpp                  |   19 +++++++++++++++++++
 common/Util.hpp                  |    7 ++++++-
 loleaflet/html/loleaflet.html.m4 |    2 +-
 loleaflet/src/core/Socket.js     |    4 ++++
 wsd/ClientSession.cpp            |    6 ++++++
 wsd/ClientSession.hpp            |    1 +
 wsd/FileServer.cpp               |    1 -
 wsd/LOOLWSD.cpp                  |   22 ----------------------
 wsd/LOOLWSD.hpp                  |    4 ----
 wsd/protocol.txt                 |    4 ++++
 10 files changed, 41 insertions(+), 29 deletions(-)

New commits:
commit 9e0594ee2db2eff0afe7b4bc15e474c1e84f15bf
Author:     gokaysatir <gokaysa...@gmail.com>
AuthorDate: Fri Apr 10 20:02:39 2020 +0300
Commit:     Michael Meeks <michael.me...@collabora.com>
CommitDate: Sat Apr 11 13:43:31 2020 +0200

    add pretty name - Android patch
    
    Change-Id: If0de49884954cde26bfbe8ba1dce8844af5b30bf
    Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91831
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Michael Meeks <michael.me...@collabora.com>

diff --git a/common/Util.cpp b/common/Util.cpp
index 2abbd4d11..703bfdd4b 100644
--- a/common/Util.cpp
+++ b/common/Util.cpp
@@ -953,6 +953,25 @@ namespace Util
 
         return result;
     }
+
+    #if !MOBILEAPP
+        // If OS is not mobile, it must be Linux.
+        std::string getLinuxVersion(){
+            // Read operating system info. We can read "os-release" file, 
located in /etc.
+            std::ifstream ifs("/etc/os-release");
+            std::string str(std::istreambuf_iterator<char>{ifs}, {});
+            std::vector<std::string> infoList = Util::splitStringToVector(str, 
'\n');
+            std::map<std::string, std::string> releaseInfo = 
Util::stringVectorToMap(infoList, '=');
+
+            if (releaseInfo.find("PRETTY_NAME") != releaseInfo.end()) {
+                return releaseInfo["PRETTY_NAME"];
+            }
+            else{
+                return "unknown";
+            }
+        }
+    #endif
+
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/common/Util.hpp b/common/Util.hpp
index fd1589cfe..b4a6c8d7d 100644
--- a/common/Util.hpp
+++ b/common/Util.hpp
@@ -994,10 +994,15 @@ int main(int argc, char**argv)
 
     /**
      * Converts vector of strings to map. Strings should have formed like 
this: key + delimiter + value.
-     * In case of a misformed string or zero length vector, returns an empty 
map.
+     * In case of a misformed string or zero length vector, passes that item 
and warns the developer.
      */
     std::map<std::string, std::string> 
stringVectorToMap(std::vector<std::string> sVector, const char delimiter);
 
+    #if !MOBILEAPP
+        // If OS is not mobile, it must be Linux.
+        std::string getLinuxVersion();
+    #endif
+
 } // end namespace Util
 
 #endif
diff --git a/loleaflet/html/loleaflet.html.m4 b/loleaflet/html/loleaflet.html.m4
index 12407c34b..dca62ada1 100644
--- a/loleaflet/html/loleaflet.html.m4
+++ b/loleaflet/html/loleaflet.html.m4
@@ -222,7 +222,7 @@ m4_ifelse(MOBILEAPP,[true],
       <div id="loolwsd-id"></div>
       <h3>LOKit</h3>
       <div id="lokit-version"></div>
-      m4_ifelse(MOBILEAPP,[],[<div id="os-name" 
style="text-align:center"><label>%OS_INFO%</label></div>])
+      m4_ifelse(MOBILEAPP,[],[<div id="os-info" 
style="text-align:center"></div>])
       <p>Copyright © _YEAR_, VENDOR.</p>
     </div>
 
diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index d4e76d4e4..a4aa948c5 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -303,6 +303,10 @@ L.Socket = L.Class.extend({
                                                 lokitVersionObj.ProductVersion 
+ lokitVersionObj.ProductExtension.replace('.10.','-') +
                                                 ' (git hash: ' + h + ')');
                }
+               else if (textMsg.startsWith('osinfo ')) {
+                       var osInfo = textMsg.replace('osinfo ', '');
+                       document.getElementById('os-info').innerText = osInfo;
+               }
                else if (textMsg.startsWith('clipboardkey: ')) {
                        var key = textMsg.substring('clipboardkey: '.length);
                        if (this._map._clip)
diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp
index ddb7f605b..c9dc7827a 100644
--- a/wsd/ClientSession.cpp
+++ b/wsd/ClientSession.cpp
@@ -360,6 +360,12 @@ bool ClientSession::_handleInput(const char *buffer, int 
length)
         sendTextFrame("loolserver " + LOOLWSD::getVersionJSON());
         // Send LOKit version information
         sendTextFrame("lokitversion " + LOOLWSD::LOKitVersion);
+
+        #if !MOBILEAPP
+            // If it is not mobile, it must be Linux (for now).
+            sendTextFrame(std::string("osinfo ") + Util::getLinuxVersion());
+        #endif
+
         // Send clipboard key
         rotateClipboardKey(true);
 
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index b47285dd0..e11ac721c 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -21,6 +21,7 @@
 #include <map>
 #include <list>
 #include <utility>
+#include "Util.hpp"
 
 class DocumentBroker;
 
diff --git a/wsd/FileServer.cpp b/wsd/FileServer.cpp
index 9d833c510..ce9e12756 100644
--- a/wsd/FileServer.cpp
+++ b/wsd/FileServer.cpp
@@ -649,7 +649,6 @@ void FileServerRequestHandler::preprocessFile(const 
HTTPRequest& request, Poco::
     Poco::replaceInPlace(preprocess, std::string("%HOST%"), host);
     Poco::replaceInPlace(preprocess, std::string("%VERSION%"), 
std::string(LOOLWSD_VERSION_HASH));
     Poco::replaceInPlace(preprocess, std::string("%SERVICE_ROOT%"), 
LOOLWSD::ServiceRoot);
-    Poco::replaceInPlace(preprocess, std::string("%OS_INFO%"), 
LOOLWSD::OSInfo);
 
     std::string protocolDebug = "false";
     if (config.getBool("logging.protocol"))
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 2c7ac0c11..dd1be52ba 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -719,7 +719,6 @@ std::string LOOLWSD::ServerName;
 std::string LOOLWSD::FileServerRoot;
 std::string LOOLWSD::ServiceRoot;
 std::string LOOLWSD::LOKitVersion;
-std::string LOOLWSD::OSInfo;
 std::string LOOLWSD::HostIdentifier;
 std::string LOOLWSD::ConfigFile = LOOLWSD_CONFIGDIR "/loolwsd.xml";
 std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d";
@@ -743,25 +742,6 @@ std::unique_ptr<TraceFileWriter> LOOLWSD::TraceDumper;
 std::unique_ptr<ClipboardCache> LOOLWSD::SavedClipboards;
 #endif
 
-void LOOLWSD::getOSInfo(){
-    #if !MOBILEAPP
-        // It might be neither mobile nor linux (in the future). That is not 
handled. If it is not mobile, it is Linux.
-
-        // Read operating system info. We can read "os-release" file, located 
in /etc.
-        std::ifstream ifs("/etc/os-release");
-        std::string str(std::istreambuf_iterator<char>{ifs}, {});
-        std::vector<std::string> infoList = Util::splitStringToVector(str, 
'\n');
-        std::map<std::string, std::string> releaseInfo = 
Util::stringVectorToMap(infoList, '=');
-        LOOLWSD::OSInfo = "unknown";
-
-        if (releaseInfo.find("PRETTY_NAME") != releaseInfo.end()) {
-            LOOLWSD::OSInfo = releaseInfo["PRETTY_NAME"];
-        }
-    #else
-        // Some more cases might be added in the future.
-    #endif
-}
-
 /// This thread polls basic web serving, and handling of
 /// websockets before upgrade: when upgraded they go to the
 /// relevant DocumentBroker poll instead.
@@ -962,8 +942,6 @@ void LOOLWSD::initialize(Application& self)
     AutoPtr<AppConfigMap> defConfig(new AppConfigMap(DefAppConfig));
     conf.addWriteable(defConfig, PRIO_SYSTEM); // Lowest priority
 
-    LOOLWSD::getOSInfo();
-
 #if !MOBILEAPP
 
     // Load default configuration files, if present.
diff --git a/wsd/LOOLWSD.hpp b/wsd/LOOLWSD.hpp
index 034dbfbe0..ec36fe26f 100644
--- a/wsd/LOOLWSD.hpp
+++ b/wsd/LOOLWSD.hpp
@@ -237,7 +237,6 @@ public:
     static std::string FileServerRoot;
     static std::string ServiceRoot; ///< There are installations that need 
prefixing every page with some path.
     static std::string LOKitVersion;
-    static std::string OSInfo;
     static std::string HostIdentifier; ///< A unique random hash that 
identifies this server
     static std::string LogLevel;
     static bool AnonymizeUserData;
@@ -390,9 +389,6 @@ public:
 
     static std::string getVersionJSON();
 
-    /// Reads OS information, puts them into LOOLWSD::OSInfo variable
-    static void getOSInfo();
-
     int innerMain();
 
 protected:
diff --git a/wsd/protocol.txt b/wsd/protocol.txt
index 40ceb0de1..649352454 100644
--- a/wsd/protocol.txt
+++ b/wsd/protocol.txt
@@ -292,6 +292,10 @@ lokitversion <JSON string>
          "ProductExtension": ".0.0.alpha0",
          "BuildId": "<full 40 char git hash>"}
 
+osinfo: <string>
+
+    string that contains OS name and version.
+
 clipboardkey: <token>
 
     Send access token for web clipboard use, may arrive periodically
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to