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>
|
|
|
|
|
2019-05-29 04:39:46 -05:00
|
|
|
#define LOK_USE_UNSTABLE_API
|
|
|
|
#include <LibreOfficeKit/LibreOfficeKit.hxx>
|
|
|
|
|
2019-02-12 05:16:40 -06:00
|
|
|
#if MOBILEAPP
|
2018-09-11 01:30:55 -05:00
|
|
|
|
2018-09-13 11:16:00 -05:00
|
|
|
#include "ClientSession.hpp"
|
|
|
|
#include "DocumentBroker.hpp"
|
2018-09-11 01:30:55 -05:00
|
|
|
#include "Socket.hpp"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void lokit_main(
|
2019-02-12 05:16:40 -06:00
|
|
|
#if !MOBILEAPP
|
2018-09-11 01:30:55 -05:00
|
|
|
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,
|
2019-09-21 13:39:32 -05:00
|
|
|
bool displayVersion,
|
2018-09-11 01:30:55 -05:00
|
|
|
#else
|
|
|
|
const std::string& documentUri,
|
2019-09-21 13:39:32 -05:00
|
|
|
int docBrokerSocket,
|
2018-09-11 01:30:55 -05:00
|
|
|
#endif
|
2019-09-21 13:39:32 -05:00
|
|
|
size_t spareKitId
|
2018-09-11 01:30:55 -05:00
|
|
|
);
|
2016-04-05 08:32:10 -05:00
|
|
|
|
2020-02-15 13:32:57 -06:00
|
|
|
/// We need to get several env. vars right
|
|
|
|
void setupKitEnvironment();
|
|
|
|
|
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-10-31 03:02:08 -05:00
|
|
|
CallbackDescriptor(DocumentManagerInterface* const doc,
|
|
|
|
const int viewId) :
|
|
|
|
_doc(doc),
|
|
|
|
_viewId(viewId)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DocumentManagerInterface* getDoc() const
|
|
|
|
{
|
|
|
|
return _doc;
|
|
|
|
}
|
|
|
|
|
|
|
|
int getViewId() const
|
|
|
|
{
|
|
|
|
return _viewId;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
DocumentManagerInterface* const _doc;
|
|
|
|
const int _viewId;
|
2016-09-30 08:42:27 -05:00
|
|
|
};
|
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,
|
2018-10-30 02:41:46 -05:00
|
|
|
const std::string& userName,
|
2017-05-28 11:20:49 -05:00
|
|
|
const std::string& userExtraInfo,
|
2018-10-30 02:41:46 -05:00
|
|
|
bool readOnly) :
|
|
|
|
_userId(userId),
|
|
|
|
_userName(userName),
|
|
|
|
_userExtraInfo(userExtraInfo),
|
|
|
|
_readOnly(readOnly)
|
2017-05-28 11:20:49 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-10-30 02:41:46 -05:00
|
|
|
const std::string& getUserId() const
|
|
|
|
{
|
|
|
|
return _userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& getUserName() const
|
|
|
|
{
|
|
|
|
return _userName;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& getUserExtraInfo() const
|
|
|
|
{
|
|
|
|
return _userExtraInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isReadOnly() const
|
|
|
|
{
|
|
|
|
return _readOnly;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _userId;
|
|
|
|
std::string _userName;
|
|
|
|
std::string _userExtraInfo;
|
|
|
|
bool _readOnly;
|
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);
|
|
|
|
|
2018-06-10 21:30:42 -05:00
|
|
|
/// Anonymize the basename of filenames, preserving the path and extension.
|
|
|
|
std::string anonymizeUrl(const std::string& url);
|
|
|
|
|
|
|
|
/// Anonymize usernames.
|
|
|
|
std::string anonymizeUsername(const std::string& username);
|
|
|
|
|
2019-05-29 04:39:46 -05:00
|
|
|
/// For the mobile, we need access to the document to perform eg. saveAs() for printing.
|
|
|
|
std::shared_ptr<lok::Document> getLOKDocument();
|
|
|
|
|
2016-04-08 03:08:41 -05:00
|
|
|
#endif
|
2016-04-05 08:32:10 -05:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|