2015-12-12 13:23:44 -06: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/.
|
|
|
|
*/
|
|
|
|
|
2016-05-17 06:32:33 -05:00
|
|
|
#ifndef INCLUDED_CHILDSESSION_HPP
|
|
|
|
#define INCLUDED_CHILDSESSION_HPP
|
2015-12-13 11:47:14 -06:00
|
|
|
|
2016-01-10 21:52:00 -06:00
|
|
|
#include <mutex>
|
|
|
|
|
2016-01-24 17:25:02 -06:00
|
|
|
#include <Poco/Thread.h>
|
2015-12-19 14:55:19 -06:00
|
|
|
#include <Poco/NotificationQueue.h>
|
2016-02-26 00:25:13 -06:00
|
|
|
|
|
|
|
#include "Common.hpp"
|
2015-12-12 13:23:44 -06:00
|
|
|
#include "LOOLSession.hpp"
|
2016-05-17 17:28:59 -05:00
|
|
|
#include "LibreOfficeKit.hpp"
|
2015-12-12 13:23:44 -06:00
|
|
|
|
2016-08-21 10:12:12 -05:00
|
|
|
class ChildSession;
|
|
|
|
|
2016-08-14 17:02:51 -05:00
|
|
|
/// An abstract interface that defines the
|
|
|
|
/// DocumentManager interface and functionality.
|
|
|
|
class IDocumentManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Reqest loading a document, or a new view, if one exists.
|
|
|
|
virtual
|
|
|
|
std::shared_ptr<lok::Document> onLoad(const std::string& sessionId,
|
|
|
|
const std::string& jailedFilePath,
|
|
|
|
const std::string& docPassword,
|
|
|
|
const std::string& renderOpts,
|
|
|
|
const bool haveDocPassword) = 0;
|
|
|
|
|
|
|
|
/// Unload a client session, which unloads the document
|
|
|
|
/// if it is the last and only.
|
|
|
|
virtual
|
2016-08-21 10:12:12 -05:00
|
|
|
void onUnload(const ChildSession& session) = 0;
|
2016-08-14 21:20:35 -05:00
|
|
|
|
|
|
|
/// Get a list of all current view IDs.
|
|
|
|
virtual
|
|
|
|
std::vector<unsigned> getViewIds() const = 0;
|
2016-08-14 17:02:51 -05:00
|
|
|
};
|
2016-01-24 17:25:02 -06:00
|
|
|
|
2016-08-13 23:01:13 -05:00
|
|
|
/// Represents a client session, with the socket end-point,
|
|
|
|
/// and handles all incoming UI traffic.
|
2016-05-17 06:35:07 -05:00
|
|
|
class ChildSession final : public LOOLSession
|
2015-12-12 13:23:44 -06:00
|
|
|
{
|
|
|
|
public:
|
2016-05-17 06:35:07 -05:00
|
|
|
/// Create a new ChildSession
|
2015-12-23 20:20:49 -06:00
|
|
|
/// ws The socket between master and kit (jailed).
|
2015-12-13 13:25:57 -06:00
|
|
|
/// loKit The LOKit instance.
|
|
|
|
/// loKitDocument The instance to an existing document (when opening
|
|
|
|
/// a new view) or nullptr (when first view).
|
2016-01-06 21:47:01 -06:00
|
|
|
/// jailId The JailID of the jail root directory,
|
|
|
|
// used by downloadas to construct jailed path.
|
2016-05-17 06:35:07 -05:00
|
|
|
ChildSession(const std::string& id,
|
2016-05-17 17:28:59 -05:00
|
|
|
std::shared_ptr<Poco::Net::WebSocket> ws,
|
|
|
|
const std::string& jailId,
|
2016-08-14 17:02:51 -05:00
|
|
|
IDocumentManager& docManager);
|
2016-05-17 06:35:07 -05:00
|
|
|
virtual ~ChildSession();
|
2015-12-12 13:23:44 -06:00
|
|
|
|
2016-05-16 18:30:03 -05:00
|
|
|
bool getStatus(const char *buffer, int length);
|
|
|
|
bool getPartPageRectangles(const char *buffer, int length);
|
2016-08-12 20:15:38 -05:00
|
|
|
unsigned getViewId() const { return _viewId; }
|
2016-08-13 11:14:44 -05:00
|
|
|
int getPart() const { return _loKitDocument->getPart(); }
|
2016-01-03 09:56:41 -06:00
|
|
|
|
2016-08-13 17:25:06 -05:00
|
|
|
void loKitCallback(const int nType, const std::string& rPayload);
|
2016-01-24 17:25:02 -06:00
|
|
|
|
2016-08-13 11:14:44 -05:00
|
|
|
private:
|
2016-05-16 18:11:34 -05:00
|
|
|
bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
2015-12-12 13:23:44 -06:00
|
|
|
|
2016-05-21 10:47:13 -05:00
|
|
|
bool sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
2016-05-16 18:30:03 -05:00
|
|
|
bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
2015-12-12 13:23:44 -06:00
|
|
|
|
|
|
|
bool clientZoom(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
2016-02-02 04:48:41 -06:00
|
|
|
bool clientVisibleArea(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
2015-12-12 13:23:44 -06:00
|
|
|
bool downloadAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool getChildId();
|
|
|
|
bool getTextSelection(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool paste(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool insertFile(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool keyEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool mouseEvent(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool unoCommand(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool selectText(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool selectGraphic(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool resetSelection(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool saveAs(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool setClientPart(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
bool setPage(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
|
2016-08-13 11:14:44 -05:00
|
|
|
virtual void disconnect() override;
|
2015-12-25 12:51:32 -06:00
|
|
|
virtual bool _handleInput(const char *buffer, int length) override;
|
|
|
|
|
|
|
|
private:
|
2016-05-18 05:51:14 -05:00
|
|
|
std::shared_ptr<lok::Document> _loKitDocument;
|
2016-01-08 19:45:51 -06:00
|
|
|
std::string _docType;
|
2016-01-08 18:58:50 -06:00
|
|
|
const bool _multiView;
|
|
|
|
const std::string _jailId;
|
2016-01-03 09:56:41 -06:00
|
|
|
/// View ID, returned by createView() or 0 by default.
|
|
|
|
int _viewId;
|
2016-04-23 13:05:21 -05:00
|
|
|
std::map<int, std::string> _lastDocStates;
|
2016-08-14 17:02:51 -05:00
|
|
|
IDocumentManager& _docManager;
|
2016-01-10 21:52:00 -06:00
|
|
|
|
2016-01-11 21:57:49 -06:00
|
|
|
/// Synchronize _loKitDocument acess.
|
2016-01-24 17:25:02 -06:00
|
|
|
/// This should be owned by Document.
|
2016-01-18 02:41:04 -06:00
|
|
|
static std::recursive_mutex Mutex;
|
2015-12-12 13:23:44 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-12-13 11:47:14 -06:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|