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/.
|
|
|
|
*/
|
|
|
|
|
2015-12-13 11:47:14 -06:00
|
|
|
#ifndef INCLUDED_LOOLCHILDPROCESSSESSION_HPP
|
|
|
|
#define INCLUDED_LOOLCHILDPROCESSSESSION_HPP
|
|
|
|
|
|
|
|
#define LOK_USE_UNSTABLE_API
|
|
|
|
#include <LibreOfficeKit/LibreOfficeKit.h>
|
2015-12-12 13:23:44 -06:00
|
|
|
|
2015-12-19 14:55:19 -06:00
|
|
|
#include <Poco/NotificationQueue.h>
|
2015-12-12 13:23:44 -06:00
|
|
|
#include "LOOLSession.hpp"
|
|
|
|
|
2016-01-06 12:47:03 -06:00
|
|
|
// The client port number, which is changed via loolwsd args.
|
|
|
|
static int ClientPortNumber = DEFAULT_CLIENT_PORT_NUMBER;
|
|
|
|
|
2015-12-12 13:23:44 -06:00
|
|
|
class ChildProcessSession final : public LOOLSession
|
|
|
|
{
|
|
|
|
public:
|
2015-12-13 13:25:57 -06:00
|
|
|
/// Create a new ChildProcessSession
|
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.
|
2015-12-27 21:47:39 -06:00
|
|
|
ChildProcessSession(const std::string& id,
|
|
|
|
std::shared_ptr<Poco::Net::WebSocket> ws,
|
2015-12-13 11:47:14 -06:00
|
|
|
LibreOfficeKit *loKit,
|
2015-12-13 13:25:57 -06:00
|
|
|
LibreOfficeKitDocument * loKitDocument,
|
2016-01-06 21:47:01 -06:00
|
|
|
const std::string& jailId,
|
2016-01-03 11:38:26 -06:00
|
|
|
std::function<void(LibreOfficeKitDocument*, int)> onLoad,
|
|
|
|
std::function<void(int)> onUnload);
|
2015-12-12 13:23:44 -06:00
|
|
|
virtual ~ChildProcessSession();
|
|
|
|
|
2016-01-07 01:35:24 -06:00
|
|
|
virtual bool getStatus(const char *buffer, int length) override;
|
2015-12-12 13:23:44 -06:00
|
|
|
|
2016-01-07 01:35:24 -06:00
|
|
|
virtual bool getCommandValues(const char *buffer, int length, Poco::StringTokenizer& tokens) override;
|
2015-12-12 13:23:44 -06:00
|
|
|
|
|
|
|
virtual bool getPartPageRectangles(const char *buffer, int length) override;
|
|
|
|
|
2016-01-03 09:56:41 -06:00
|
|
|
int getViewId() const { return _viewId; }
|
|
|
|
|
2015-12-12 13:23:44 -06:00
|
|
|
LibreOfficeKitDocument *_loKitDocument;
|
|
|
|
std::string _docType;
|
2015-12-19 14:55:19 -06:00
|
|
|
static Poco::NotificationQueue _callbackQueue;
|
|
|
|
static Poco::Mutex _mutex;
|
2015-12-12 13:23:44 -06:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual bool loadDocument(const char *buffer, int length, Poco::StringTokenizer& tokens) override;
|
|
|
|
|
2016-01-07 01:35:24 -06:00
|
|
|
virtual void sendTile(const char *buffer, int length, Poco::StringTokenizer& tokens) override;
|
2015-12-12 13:23:44 -06:00
|
|
|
|
2016-01-07 01:35:24 -06:00
|
|
|
virtual void sendFontRendering(const char *buffer, int length, Poco::StringTokenizer& tokens) override;
|
2015-12-12 13:23:44 -06:00
|
|
|
|
|
|
|
bool clientZoom(const char *buffer, int length, Poco::StringTokenizer& tokens);
|
|
|
|
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);
|
|
|
|
|
|
|
|
std::string _loSubPath;
|
|
|
|
LibreOfficeKit *_loKit;
|
2016-01-06 21:47:01 -06:00
|
|
|
const std::string _jailId;
|
2015-12-12 13:23:44 -06:00
|
|
|
|
2015-12-25 12:51:32 -06:00
|
|
|
private:
|
|
|
|
|
|
|
|
virtual bool _handleInput(const char *buffer, int length) override;
|
|
|
|
|
|
|
|
private:
|
2016-01-03 09:56:41 -06:00
|
|
|
/// View ID, returned by createView() or 0 by default.
|
|
|
|
int _viewId;
|
2015-12-12 13:23:44 -06:00
|
|
|
int _clientPart;
|
2016-01-03 11:38:26 -06:00
|
|
|
std::function<void(LibreOfficeKitDocument*, int)> _onLoad;
|
|
|
|
std::function<void(int)> _onUnload;
|
2015-12-12 13:23:44 -06:00
|
|
|
};
|
|
|
|
|
2015-12-19 14:55:19 -06:00
|
|
|
class CallBackNotification: public Poco::Notification
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Poco::AutoPtr<CallBackNotification> Ptr;
|
|
|
|
|
2015-12-23 20:20:49 -06:00
|
|
|
CallBackNotification(const int nType, const std::string& rPayload, void* pSession)
|
|
|
|
: m_nType(nType),
|
|
|
|
m_aPayload(rPayload),
|
|
|
|
m_pSession(pSession)
|
|
|
|
{
|
|
|
|
}
|
2015-12-19 14:55:19 -06:00
|
|
|
|
2015-12-23 20:20:49 -06:00
|
|
|
const int m_nType;
|
|
|
|
const std::string m_aPayload;
|
2015-12-19 14:55:19 -06:00
|
|
|
void* m_pSession;
|
|
|
|
};
|
|
|
|
|
2015-12-12 13:23:44 -06:00
|
|
|
#endif
|
|
|
|
|
2015-12-13 11:47:14 -06:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|