2016-04-05 11:41:10 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2016-04-05 08:32:10 -05:00
|
|
|
/*
|
|
|
|
* 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-04-08 03:08:41 -05:00
|
|
|
#ifndef INCLUDED_LOOLKIT_HPP
|
|
|
|
#define INCLUDED_LOOLKIT_HPP
|
2016-04-05 08:32:10 -05:00
|
|
|
|
2017-05-28 11:20:49 -05:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <common/Util.hpp>
|
|
|
|
|
2018-09-11 01:30:55 -05:00
|
|
|
#ifdef MOBILEAPP
|
|
|
|
|
|
|
|
#include "Socket.hpp"
|
|
|
|
|
|
|
|
class JS2OnlineBridge
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void registerSocket(SocketPoll& socketPoll)
|
|
|
|
{
|
|
|
|
_SocketPoll = &socketPoll;
|
|
|
|
}
|
|
|
|
|
|
|
|
void registerJSSender(void (*function)(const char *, int, void *), void *data)
|
|
|
|
{
|
|
|
|
_JSCallbackFunction = function;
|
|
|
|
_JSCallbackData = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
void sendToOnline(const std::string& payload)
|
|
|
|
{
|
|
|
|
_SocketPoll->feed(payload);
|
|
|
|
}
|
|
|
|
|
|
|
|
void sendToJS(const char *data, int length)
|
|
|
|
{
|
|
|
|
_JSCallbackFunction(data, length, _JSCallbackData);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SocketPoll *_SocketPoll;
|
|
|
|
void (*_JSCallbackFunction)(const char *, int, void *);
|
|
|
|
void *_JSCallbackData;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void lokit_main(
|
|
|
|
#ifndef MOBILEAPP
|
|
|
|
const std::string& childRoot,
|
2017-05-07 10:05:34 -05:00
|
|
|
const std::string& jailId,
|
2016-04-05 08:32:10 -05:00
|
|
|
const std::string& sysTemplate,
|
|
|
|
const std::string& loTemplate,
|
2016-04-16 14:44:53 -05:00
|
|
|
const std::string& loSubPath,
|
2016-06-20 13:58:00 -05:00
|
|
|
bool noCapabilities,
|
2018-03-19 10:20:10 -05:00
|
|
|
bool noSeccomp,
|
2016-10-06 05:17:36 -05:00
|
|
|
bool queryVersionInfo,
|
2018-09-11 01:30:55 -05:00
|
|
|
bool displayVersion
|
|
|
|
#else
|
|
|
|
const std::string& documentUri,
|
|
|
|
JS2OnlineBridge& bridge
|
|
|
|
#endif
|
|
|
|
);
|
2016-04-05 08:32:10 -05:00
|
|
|
|
2016-10-29 20:15:00 -05:00
|
|
|
bool globalPreinit(const std::string& loTemplate);
|
2016-09-30 08:42:27 -05:00
|
|
|
/// Wrapper around private Document::ViewCallback().
|
2017-01-13 06:52:08 -06:00
|
|
|
void documentViewCallback(const int type, const char* p, void* data);
|
2016-04-05 08:32:10 -05:00
|
|
|
|
2018-09-12 11:05:01 -05:00
|
|
|
class DocumentManagerInterface;
|
2016-09-30 08:42:27 -05:00
|
|
|
|
|
|
|
/// Descriptor class used to link a LOK
|
|
|
|
/// callback to a specific view.
|
|
|
|
struct CallbackDescriptor
|
|
|
|
{
|
2018-09-12 11:05:01 -05:00
|
|
|
DocumentManagerInterface* const Doc;
|
2016-09-30 08:42:27 -05:00
|
|
|
const int ViewId;
|
|
|
|
};
|
2016-10-26 10:08:25 -05:00
|
|
|
|
|
|
|
/// User Info container used to store user information
|
|
|
|
/// till the end of process lifecycle - including
|
|
|
|
/// after any child session goes away
|
|
|
|
struct UserInfo
|
|
|
|
{
|
2017-05-28 11:20:49 -05:00
|
|
|
UserInfo()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UserInfo(const std::string& userId,
|
|
|
|
const std::string& username,
|
|
|
|
const std::string& userExtraInfo,
|
|
|
|
const bool readonly) :
|
|
|
|
UserId(userId),
|
|
|
|
Username(username),
|
2017-05-31 22:57:06 -05:00
|
|
|
UserExtraInfo(userExtraInfo),
|
2017-05-28 11:20:49 -05:00
|
|
|
IsReadOnly(readonly)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string UserId;
|
|
|
|
std::string Username;
|
|
|
|
std::string UserExtraInfo;
|
|
|
|
bool IsReadOnly;
|
2016-10-26 10:08:25 -05:00
|
|
|
};
|
|
|
|
|
2017-02-06 16:26:38 -06:00
|
|
|
/// Check the ForkCounter, and if non-zero, fork more of them accordingly.
|
|
|
|
/// @param limit If non-zero, set the ForkCounter to this limit.
|
|
|
|
void forkLibreOfficeKit(const std::string& childRoot,
|
|
|
|
const std::string& sysTemplate,
|
|
|
|
const std::string& loTemplate,
|
|
|
|
const std::string& loSubPath,
|
|
|
|
int limit = 0);
|
|
|
|
|
2016-04-08 03:08:41 -05:00
|
|
|
#endif
|
2016-04-05 08:32:10 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|