[Libreoffice-commits] online.git: test/integration-http-server.cpp wsd/LOOLWSD.cpp

Ashod Nakashian ashod.nakashian at collabora.co.uk
Sun Mar 26 05:11:48 UTC 2017


 test/integration-http-server.cpp |    2 +-
 wsd/LOOLWSD.cpp                  |   39 +++++++++++++++++++++------------------
 2 files changed, 22 insertions(+), 19 deletions(-)

New commits:
commit 25dee367d43d12b924dea75e702cdfa20252b97d
Author: Ashod Nakashian <ashod.nakashian at collabora.co.uk>
Date:   Sun Mar 26 00:43:43 2017 -0400

    wsd: load the convert-to doc in callback
    
    Since this a fake session that doesn't
    have a client socket, we push the
    messages directly into the ClientSession.
    But since the DocBroker poll thread will
    probably not be ready by then, there
    is no child process and the other
    document bits needed to load (or indeed
    process any client messages).
    
    So we defer all the fake messages in
    a poll callback to insure they are done
    in the correct order.
    
    Change-Id: Id81dc4288b305829149e6e9c81d0f7da719c59ad
    Reviewed-on: https://gerrit.libreoffice.org/35712
    Reviewed-by: Ashod Nakashian <ashnakash at gmail.com>
    Tested-by: Ashod Nakashian <ashnakash at gmail.com>

diff --git a/test/integration-http-server.cpp b/test/integration-http-server.cpp
index 5db9c9a5..3530ed57 100644
--- a/test/integration-http-server.cpp
+++ b/test/integration-http-server.cpp
@@ -44,7 +44,7 @@ class HTTPServerTest : public CPPUNIT_NS::TestFixture
     CPPUNIT_TEST(testLoleafletPost);
     CPPUNIT_TEST(testScriptsAndLinksGet);
     CPPUNIT_TEST(testScriptsAndLinksPost);
-    // CPPUNIT_TEST(testConvertTo);
+    CPPUNIT_TEST(testConvertTo);
 
     CPPUNIT_TEST_SUITE_END();
 
diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp
index 4bb13ffc..eaa02fcb 100644
--- a/wsd/LOOLWSD.cpp
+++ b/wsd/LOOLWSD.cpp
@@ -1943,24 +1943,27 @@ private:
 
                         docBroker->startThread();
 
-                        // Load the document manually and request saving in the target format.
-                        std::string encodedFrom;
-                        URI::encode(docBroker->getPublicUri().getPath(), "", encodedFrom);
-                        const std::string load = "load url=" + encodedFrom;
-                        std::vector<char> loadRequest(load.begin(), load.end());
-                        clientSession->handleMessage(true, WebSocketHandler::WSOpCode::Text, loadRequest);
-
-                        // FIXME: Check for security violations.
-                        Path toPath(docBroker->getPublicUri().getPath());
-                        toPath.setExtension(format);
-                        const std::string toJailURL = "file://" + std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName();
-                        std::string encodedTo;
-                        URI::encode(toJailURL, "", encodedTo);
-
-                        // Convert it to the requested format.
-                        const auto saveas = "saveas url=" + encodedTo + " format=" + format + " options=";
-                        std::vector<char> saveasRequest(saveas.begin(), saveas.end());
-                        clientSession->handleMessage(true, WebSocketHandler::WSOpCode::Text, saveasRequest);
+                        docBroker->addCallback([&]()
+                        {
+                            // Load the document manually and request saving in the target format.
+                            std::string encodedFrom;
+                            URI::encode(docBroker->getPublicUri().getPath(), "", encodedFrom);
+                            const std::string load = "load url=" + encodedFrom;
+                            std::vector<char> loadRequest(load.begin(), load.end());
+                            clientSession->handleMessage(true, WebSocketHandler::WSOpCode::Text, loadRequest);
+
+                            // FIXME: Check for security violations.
+                            Path toPath(docBroker->getPublicUri().getPath());
+                            toPath.setExtension(format);
+                            const std::string toJailURL = "file://" + std::string(JAILED_DOCUMENT_ROOT) + toPath.getFileName();
+                            std::string encodedTo;
+                            URI::encode(toJailURL, "", encodedTo);
+
+                            // Convert it to the requested format.
+                            const auto saveas = "saveas url=" + encodedTo + " format=" + format + " options=";
+                            std::vector<char> saveasRequest(saveas.begin(), saveas.end());
+                            clientSession->handleMessage(true, WebSocketHandler::WSOpCode::Text, saveasRequest);
+                        });
 
                         sent = true;
                     }


More information about the Libreoffice-commits mailing list