summaryrefslogtreecommitdiffstats
path: root/wsd/ClientSession.hpp
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@collabora.com>2019-07-04 10:50:33 +0100
committerMichael Meeks <michael.meeks@collabora.com>2019-08-05 22:21:54 -0400
commit9e791fb0d4d4c701c50b8b50091b5665b832c3f1 (patch)
tree3588dfda4e66e48caa1e74dbad1da743c8fea7d5 /wsd/ClientSession.hpp
parentwsd: add 'meta origin' to clipboardcontent payloads too (diff)
downloadonline-9e791fb0d4d4c701c50b8b50091b5665b832c3f1.tar.gz
online-9e791fb0d4d4c701c50b8b50091b5665b832c3f1.zip
clipboard: persist selections for a while after a view closes.
re-factor ClientSession state to be a simpler state machine. Have a nice disconnect / disconnected handshake on view close. Change-Id: Ie933cc5c7dfab46c66f4d38a4d75c459aa1cff87
Diffstat (limited to 'wsd/ClientSession.hpp')
-rw-r--r--wsd/ClientSession.hpp33
1 files changed, 24 insertions, 9 deletions
diff --git a/wsd/ClientSession.hpp b/wsd/ClientSession.hpp
index 5d5d68249e..d4b31dbeac 100644
--- a/wsd/ClientSession.hpp
+++ b/wsd/ClientSession.hpp
@@ -44,13 +44,21 @@ public:
void setReadOnly() override;
- /// Returns true if this session is added to a DocBroker.
- bool isAttached() const { return _isAttached; }
- void setAttached() { _isAttached = true; }
+ enum SessionState {
+ DETACHED, // initial
+ LOADING, // attached to a DocBroker & waiting for load
+ LIVE, // Document is loaded & editable or viewable.
+ WAIT_DISCONNECT // closed and waiting for Kit's disconnected message
+ };
/// Returns true if this session has loaded a view (i.e. we got status message).
- bool isViewLoaded() const { return _isViewLoaded; }
- void setViewLoaded() { _isViewLoaded = true; }
+ bool isViewLoaded() const { return _state == SessionState::LIVE; }
+
+ /// returns true if we're waiting for the kit to acknowledge disconnect.
+ bool inWaitDisconnected() const { return _state == SessionState::WAIT_DISCONNECT; }
+
+ /// transition to a new state
+ void setState(SessionState newState);
void setDocumentOwner(const bool documentOwner) { _isDocumentOwner = documentOwner; }
bool isDocumentOwner() const { return _isDocumentOwner; }
@@ -61,6 +69,9 @@ public:
/// Integer id of the view in the kit process, or -1 if unknown
int getKitViewId() const { return _kitViewId; }
+ /// Disconnect the session and do final cleanup, @returns true if we should not wait.
+ bool disconnectFromKit();
+
// sendTextFrame that takes std::string and string literal.
using Session::sendTextFrame;
@@ -147,6 +158,7 @@ public:
/// Handle a clipboard fetch / put request.
void handleClipboardRequest(DocumentBroker::ClipboardRequest type,
const std::shared_ptr<StreamSocket> &socket,
+ const std::string &tag,
const std::shared_ptr<std::string> &data);
/// Create URI for transient clipboard content.
@@ -155,6 +167,9 @@ public:
/// Adds and/or modified the copied payload before sending on to the client.
void postProcessCopyPayload(std::shared_ptr<Message> payload);
+ /// Returns true if we're expired waiting for a clipboard and should be removed
+ bool staleWaitDisconnect(const std::chrono::steady_clock::time_point &now);
+
/// Generate and rotate a new clipboard hash, sending it if appropriate
void rotateClipboardKey(bool notifyClient);
@@ -211,11 +226,11 @@ private:
/// The socket to which the converted (saveas) doc is sent.
std::shared_ptr<StreamSocket> _saveAsSocket;
- /// If we are added to a DocBroker.
- bool _isAttached;
+ /// The phase of our lifecycle that we're in.
+ SessionState _state;
- /// If we have loaded a view.
- bool _isViewLoaded;
+ /// Time of last state transition
+ std::chrono::steady_clock::time_point _lastStateTime;
/// Wopi FileInfo object
std::unique_ptr<WopiStorage::WOPIFileInfo> _wopiFileInfo;