wsd/DocumentBroker.cpp |   12 +++++++++---
 wsd/DocumentBroker.hpp |    4 +++-
 wsd/Storage.cpp        |    1 +
 wsd/Storage.hpp        |    4 ++++
 wsd/reference.md       |    4 ++++
 5 files changed, 21 insertions(+), 4 deletions(-)

New commits:
commit ff1f3d8249bf9676335b0e91676abbab7e0e3bdf
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Tue Dec 4 08:49:49 2018 +0100
Commit:     Thorsten Behrens <thorsten.behr...@cib.de>
CommitDate: Mon Dec 10 13:28:22 2018 +0100

    Add custom http header when saving before document is cleaned up from memory
    
    Change-Id: I3ac417d83a79a665ae6575097835542f43d40cef
    Reviewed-on: https://gerrit.libreoffice.org/64499
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
    Tested-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
    (cherry picked from commit 2e9af9da16a7ed42bde4b6294f7970c00be9c566)
    Reviewed-on: https://gerrit.libreoffice.org/64757
    Reviewed-by: Thorsten Behrens <thorsten.behr...@cib.de>
    Tested-by: Thorsten Behrens <thorsten.behr...@cib.de>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c14e5a111..661dbb2a2 100644
--- a/wsd/DocumentBroker.cpp
+++ b/wsd/DocumentBroker.cpp
@@ -962,7 +962,9 @@ bool DocumentBroker::autoSave(const bool force)
     {
         LOG_TRC("Sending forced save command for [" << _docKey << "].");
         // Don't terminate editing as this can be invoked by the admin OOM, 
but otherwise force saving anyway.
-        sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/ true, 
/*dontSaveIfUnmodified=*/ true, /*isAutosave=*/ false);
+        sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/true,
+                           /*dontSaveIfUnmodified=*/true, /*isAutosave=*/false,
+                           /*isExitSave=*/true);
     }
     else if (_isModified)
     {
@@ -979,14 +981,17 @@ bool DocumentBroker::autoSave(const bool force)
             timeSinceLastSaveMs >= autoSaveDurationMs)
         {
             LOG_TRC("Sending timed save command for [" << _docKey << "].");
-            sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/ true, 
/*dontSaveIfUnmodified=*/ true, /*isAutosave=*/ true);
+            sent = sendUnoSave(savingSessionId, /*dontTerminateEdit=*/true,
+                               /*dontSaveIfUnmodified=*/true, 
/*isAutosave=*/true,
+                               /*isExitSave=*/false);
         }
     }
 
     return sent;
 }
 
-bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool 
dontTerminateEdit, bool dontSaveIfUnmodified, bool isAutosave)
+bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool 
dontTerminateEdit,
+                                 bool dontSaveIfUnmodified, bool isAutosave, 
bool isExitSave)
 {
     assertCorrectThread();
 
@@ -1029,6 +1034,7 @@ bool DocumentBroker::sendUnoSave(const std::string& 
sessionId, bool dontTerminat
 
         assert(_storage);
         _storage->setIsAutosave(isAutosave || UnitWSD::get().isAutosave());
+        _storage->setIsExitSave(isExitSave);
 
         const std::string saveArgs = oss.str();
         LOG_TRC(".uno:Save arguments: " << saveArgs);
diff --git a/wsd/DocumentBroker.hpp b/wsd/DocumentBroker.hpp
index 6f66bfb58..45f37edd1 100644
--- a/wsd/DocumentBroker.hpp
+++ b/wsd/DocumentBroker.hpp
@@ -348,7 +348,9 @@ public:
     }
 
     /// Sends the .uno:Save command to LoKit.
-    bool sendUnoSave(const std::string& sessionId, bool dontTerminateEdit = 
true, bool dontSaveIfUnmodified = true, bool isAutosave = false);
+    bool sendUnoSave(const std::string& sessionId, bool dontTerminateEdit = 
true,
+                     bool dontSaveIfUnmodified = true, bool isAutosave = false,
+                     bool isExitSave = false);
 
     /// Sends a message to all sessions
     void broadcastMessage(const std::string& message);
diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp
index a3f86e743..3b36ef7d7 100644
--- a/wsd/Storage.cpp
+++ b/wsd/Storage.cpp
@@ -717,6 +717,7 @@ StorageBase::SaveResult 
WopiStorage::saveLocalFileToStorage(const Authorization&
             request.set("X-WOPI-Override", "PUT");
             request.set("X-LOOL-WOPI-IsModifiedByUser", _isUserModified? 
"true": "false");
             request.set("X-LOOL-WOPI-IsAutosave", _isAutosave? "true": 
"false");
+            request.set("X-LOOL-WOPI-IsExitSave", isExitSave()? "true": 
"false");
 
             if (!_forceSave)
             {
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index cbb6f9c42..67cda1dfb 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -151,6 +151,8 @@ public:
 
     /// To be able to set the WOPI 'is autosave?' header appropriately.
     void setIsAutosave(bool isAutosave) { _isAutosave = isAutosave; }
+    void setIsExitSave(bool isExitSave) { _isExitSave = isExitSave; }
+    bool isExitSave() const { return _isExitSave; }
 
     /// Returns the basic information about the file.
     const FileInfo& getFileInfo() const { return _fileInfo; }
@@ -196,6 +198,8 @@ protected:
 
     /// This save operation is an autosave.
     bool _isAutosave;
+    /// Saving on exit (when the document is cleaned up from memory)
+    bool _isExitSave;
 
     static bool FilesystemEnabled;
     static bool WopiEnabled;
diff --git a/wsd/reference.md b/wsd/reference.md
index 194c8571b..243e60d17 100644
--- a/wsd/reference.md
+++ b/wsd/reference.md
@@ -134,6 +134,10 @@ To distinguish autosave vs. explicit user requests to 
save, the following header
 
 will have the value 'true' when the PutFile is triggered by autosave, and 
'false' when triggered by explicit user operation (Save button or menu entry).
 
+When the document gets cleaned up from memory (e.g. when all users 
disconnect), an automatic save will be triggered. In this case the following 
header will be set to "true":
+
+    X-LOOL-WOPI-IsExitSave
+
 Detecting external document change
 ----------------------------------
 
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to