2016-05-16 06:37:02 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_CLIENTSSESSION_HPP
|
|
|
|
#define INCLUDED_CLIENTSSESSION_HPP
|
|
|
|
|
|
|
|
#include "LOOLSession.hpp"
|
|
|
|
#include "MessageQueue.hpp"
|
|
|
|
|
2016-10-16 11:40:52 -05:00
|
|
|
#include <Poco/URI.h>
|
|
|
|
|
2016-05-16 06:37:02 -05:00
|
|
|
class DocumentBroker;
|
|
|
|
class PrisonerSession;
|
|
|
|
|
2016-09-16 01:56:35 -05:00
|
|
|
/// Represents a session to a LOOL client, in the WSD process.
|
2016-05-16 21:48:33 -05:00
|
|
|
class ClientSession final : public LOOLSession, public std::enable_shared_from_this<ClientSession>
|
2016-05-16 06:37:02 -05:00
|
|
|
{
|
|
|
|
public:
|
2016-05-16 19:49:36 -05:00
|
|
|
ClientSession(const std::string& id,
|
2016-10-16 12:20:49 -05:00
|
|
|
const std::shared_ptr<Poco::Net::WebSocket>& ws,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker,
|
2016-10-16 11:40:52 -05:00
|
|
|
const Poco::URI& uriPublic,
|
|
|
|
const bool isReadOnly = false);
|
2016-05-16 06:37:02 -05:00
|
|
|
|
2016-05-16 18:05:22 -05:00
|
|
|
virtual ~ClientSession();
|
|
|
|
|
2016-07-10 23:50:25 -05:00
|
|
|
bool isReadOnly() const { return _isReadOnly; }
|
2016-05-16 17:22:41 -05:00
|
|
|
|
2016-05-16 21:48:33 -05:00
|
|
|
void setPeer(const std::shared_ptr<PrisonerSession>& peer) { _peer = peer; }
|
2016-10-12 22:04:07 -05:00
|
|
|
std::shared_ptr<PrisonerSession> getPeer() const { return _peer; }
|
2016-10-12 05:05:57 -05:00
|
|
|
bool shutdownPeer(Poco::UInt16 statusCode);
|
2016-05-16 17:22:41 -05:00
|
|
|
|
2016-08-29 13:08:01 -05:00
|
|
|
void setUserName(const std::string& userName) { _userName = userName; }
|
|
|
|
|
2016-05-16 18:05:22 -05:00
|
|
|
/**
|
|
|
|
* Return the URL of the saved-as document when it's ready. If called
|
|
|
|
* before it's ready, the call blocks till then.
|
|
|
|
*/
|
2016-10-09 10:59:00 -05:00
|
|
|
std::string getSaveAsUrl(const unsigned timeoutMs)
|
2016-05-16 18:05:22 -05:00
|
|
|
{
|
2016-10-09 10:59:00 -05:00
|
|
|
const auto payload = _saveAsQueue.get(timeoutMs);
|
2016-05-16 18:05:22 -05:00
|
|
|
return std::string(payload.data(), payload.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void setSaveAsUrl(const std::string& url)
|
|
|
|
{
|
|
|
|
_saveAsQueue.put(url);
|
|
|
|
}
|
|
|
|
|
2016-10-16 12:20:49 -05:00
|
|
|
std::shared_ptr<DocumentBroker> getDocumentBroker() const { return _docBroker.lock(); }
|
2016-05-16 20:03:45 -05:00
|
|
|
|
2016-10-16 11:40:52 -05:00
|
|
|
/// Exact URI (including query params - access tokens etc.) with which
|
|
|
|
/// client made the request to us
|
|
|
|
const Poco::URI& getPublicUri() const { return _uriPublic; }
|
|
|
|
|
2016-05-16 18:05:22 -05:00
|
|
|
private:
|
|
|
|
|
|
|
|
virtual bool _handleInput(const char *buffer, int length) override;
|
2016-05-16 06:37:02 -05:00
|
|
|
|
2016-10-16 12:20:49 -05:00
|
|
|
bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
2016-05-16 18:11:34 -05:00
|
|
|
|
2016-10-16 12:20:49 -05:00
|
|
|
bool getStatus(const char *buffer, int length,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
|
|
|
bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
|
|
|
bool getPartPageRectangles(const char *buffer, int length,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
2016-05-16 18:20:35 -05:00
|
|
|
|
2016-10-16 12:20:49 -05:00
|
|
|
bool sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
|
|
|
bool sendCombinedTiles(const char *buffer, int length, Poco::StringTokenizer& tokens,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
2016-05-16 18:20:35 -05:00
|
|
|
|
2016-10-16 12:20:49 -05:00
|
|
|
bool sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens,
|
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
|
|
|
|
2016-10-16 12:43:44 -05:00
|
|
|
bool forwardToChild(const std::string& message,
|
2016-10-16 12:20:49 -05:00
|
|
|
const std::shared_ptr<DocumentBroker>& docBroker);
|
2016-10-08 13:25:27 -05:00
|
|
|
|
2016-05-16 06:37:02 -05:00
|
|
|
private:
|
|
|
|
|
2016-10-16 12:20:49 -05:00
|
|
|
std::weak_ptr<DocumentBroker> _docBroker;
|
2016-05-16 20:03:45 -05:00
|
|
|
|
2016-10-16 11:40:52 -05:00
|
|
|
/// URI with which client made request to us
|
|
|
|
const Poco::URI _uriPublic;
|
|
|
|
|
|
|
|
/// Whether the session is opened as readonly
|
2016-07-10 23:50:25 -05:00
|
|
|
bool _isReadOnly;
|
|
|
|
|
2016-05-16 22:02:05 -05:00
|
|
|
/// Our peer that connects us to the child.
|
2016-10-12 22:04:07 -05:00
|
|
|
std::shared_ptr<PrisonerSession> _peer;
|
2016-05-16 06:37:02 -05:00
|
|
|
|
2016-05-16 18:05:22 -05:00
|
|
|
/// Store URLs of completed 'save as' documents.
|
|
|
|
MessageQueue _saveAsQueue;
|
2016-05-16 06:37:02 -05:00
|
|
|
|
2016-05-16 20:03:45 -05:00
|
|
|
int _loadPart;
|
2016-05-16 06:37:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|