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

New commits:
commit 2e9af9da16a7ed42bde4b6294f7970c00be9c566
Author:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
AuthorDate: Tue Dec 4 08:49:49 2018 +0100
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@cib.de>
CommitDate: Wed Dec 5 11:50:59 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>

diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp
index c2dda9221..3b4de7ee6 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 09ee0e9d6..3d47c722d 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 b40bebfb3..11c658b65 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", getIsAutosave()? "true": 
"false");
+            request.set("X-LOOL-WOPI-IsExitSave", isExitSave()? "true": 
"false");
 
             if (!getForceSave())
             {
diff --git a/wsd/Storage.hpp b/wsd/Storage.hpp
index 893fa9e35..6d56c64b0 100644
--- a/wsd/Storage.hpp
+++ b/wsd/Storage.hpp
@@ -174,10 +174,11 @@ public:
 
     bool isUserModified() const { return _isUserModified; }
 
-    /// To be able to set the WOPI 'is autosave?' header appropriately.
+    /// To be able to set the WOPI 'is autosave/is exitsave?' headers 
appropriately.
     void setIsAutosave(bool isAutosave) { _isAutosave = isAutosave; }
-
     bool getIsAutosave() const { return _isAutosave; }
+    void setIsExitSave(bool isExitSave) { _isExitSave = isExitSave; }
+    bool isExitSave() const { return _isExitSave; }
 
     void setFileInfo(const FileInfo& fileInfo) { _fileInfo = fileInfo; }
 
@@ -225,6 +226,8 @@ private:
 
     /// 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