2016-04-05 18:41:10 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2016-04-05 15:32:10 +02:00
|
|
|
/*
|
2023-11-09 19:23:00 +01:00
|
|
|
* Copyright the Collabora Online contributors.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MPL-2.0
|
|
|
|
*
|
2016-04-05 15:32:10 +02:00
|
|
|
* 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/.
|
|
|
|
*/
|
2020-04-18 10:39:50 +02:00
|
|
|
|
|
|
|
#pragma once
|
2016-04-05 15:32:10 +02:00
|
|
|
|
2021-03-27 14:39:03 +01:00
|
|
|
#include <Poco/Util/XMLConfiguration.h>
|
2017-05-28 18:20:49 +02:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <common/Util.hpp>
|
2023-07-06 13:08:59 +02:00
|
|
|
#include <wsd/TileDesc.hpp>
|
2023-07-31 16:28:27 +02:00
|
|
|
#include "Socket.hpp"
|
2017-05-28 18:20:49 +02:00
|
|
|
|
2019-05-29 11:39:46 +02:00
|
|
|
#define LOK_USE_UNSTABLE_API
|
|
|
|
#include <LibreOfficeKit/LibreOfficeKit.hxx>
|
|
|
|
|
2019-02-12 12:16:40 +01:00
|
|
|
#if MOBILEAPP
|
2018-09-11 08:30:55 +02:00
|
|
|
|
2018-09-13 18:16:00 +02:00
|
|
|
#include "ClientSession.hpp"
|
|
|
|
#include "DocumentBroker.hpp"
|
2018-09-11 08:30:55 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void lokit_main(
|
2019-02-12 12:16:40 +01:00
|
|
|
#if !MOBILEAPP
|
2018-09-11 08:30:55 +02:00
|
|
|
const std::string& childRoot,
|
2017-05-07 17:05:34 +02:00
|
|
|
const std::string& jailId,
|
2016-04-05 15:32:10 +02:00
|
|
|
const std::string& sysTemplate,
|
|
|
|
const std::string& loTemplate,
|
2016-06-20 20:58:00 +02:00
|
|
|
bool noCapabilities,
|
2018-03-19 16:20:10 +01:00
|
|
|
bool noSeccomp,
|
2016-10-06 12:17:36 +02:00
|
|
|
bool queryVersionInfo,
|
2019-09-21 20:39:32 +02:00
|
|
|
bool displayVersion,
|
2018-09-11 08:30:55 +02:00
|
|
|
#else
|
2019-09-21 20:39:32 +02:00
|
|
|
int docBrokerSocket,
|
2020-06-26 12:58:09 +02:00
|
|
|
const std::string& userInterface,
|
2018-09-11 08:30:55 +02:00
|
|
|
#endif
|
2021-03-27 22:40:59 +01:00
|
|
|
std::size_t numericIdentifier
|
2018-09-11 08:30:55 +02:00
|
|
|
);
|
2016-04-05 15:32:10 +02:00
|
|
|
|
2020-04-24 09:46:54 +02:00
|
|
|
#ifdef IOS
|
|
|
|
void runKitLoopInAThread();
|
|
|
|
#endif
|
|
|
|
|
2016-10-30 02:15:00 +01:00
|
|
|
bool globalPreinit(const std::string& loTemplate);
|
2016-09-30 15:42:27 +02:00
|
|
|
/// Wrapper around private Document::ViewCallback().
|
2017-01-13 13:52:08 +01:00
|
|
|
void documentViewCallback(const int type, const char* p, void* data);
|
2016-04-05 15:32:10 +02:00
|
|
|
|
2018-09-12 18:05:01 +02:00
|
|
|
class DocumentManagerInterface;
|
2016-09-30 15:42:27 +02:00
|
|
|
|
|
|
|
/// Descriptor class used to link a LOK
|
|
|
|
/// callback to a specific view.
|
|
|
|
struct CallbackDescriptor
|
|
|
|
{
|
2018-10-31 09:02:08 +01: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 15:42:27 +02:00
|
|
|
};
|
2016-10-26 17:08:25 +02: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 18:20:49 +02:00
|
|
|
UserInfo()
|
2023-06-12 09:59:32 +02:00
|
|
|
: _readOnly(false)
|
2017-05-28 18:20:49 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
UserInfo(const std::string& userId,
|
2018-10-30 08:41:46 +01:00
|
|
|
const std::string& userName,
|
2017-05-28 18:20:49 +02:00
|
|
|
const std::string& userExtraInfo,
|
2023-01-04 10:09:21 +01:00
|
|
|
const std::string& userPrivateInfo,
|
2018-10-30 08:41:46 +01:00
|
|
|
bool readOnly) :
|
|
|
|
_userId(userId),
|
|
|
|
_userName(userName),
|
|
|
|
_userExtraInfo(userExtraInfo),
|
2023-01-04 10:09:21 +01:00
|
|
|
_userPrivateInfo(userPrivateInfo),
|
2018-10-30 08:41:46 +01:00
|
|
|
_readOnly(readOnly)
|
2017-05-28 18:20:49 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-10-30 08:41:46 +01:00
|
|
|
const std::string& getUserId() const
|
|
|
|
{
|
|
|
|
return _userId;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& getUserName() const
|
|
|
|
{
|
|
|
|
return _userName;
|
|
|
|
}
|
|
|
|
|
|
|
|
const std::string& getUserExtraInfo() const
|
|
|
|
{
|
|
|
|
return _userExtraInfo;
|
|
|
|
}
|
|
|
|
|
2023-01-04 10:09:21 +01:00
|
|
|
const std::string& getUserPrivateInfo() const
|
|
|
|
{
|
|
|
|
return _userPrivateInfo;
|
|
|
|
}
|
|
|
|
|
2018-10-30 08:41:46 +01:00
|
|
|
bool isReadOnly() const
|
|
|
|
{
|
|
|
|
return _readOnly;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::string _userId;
|
|
|
|
std::string _userName;
|
|
|
|
std::string _userExtraInfo;
|
2023-01-04 10:09:21 +01:00
|
|
|
std::string _userPrivateInfo;
|
2018-10-30 08:41:46 +01:00
|
|
|
bool _readOnly;
|
2016-10-26 17:08:25 +02:00
|
|
|
};
|
|
|
|
|
2023-07-14 09:48:13 +02:00
|
|
|
|
|
|
|
/// We have two types of password protected documents
|
|
|
|
/// 1) Documents which require password to view
|
|
|
|
/// 2) Document which require password to modify
|
|
|
|
enum class DocumentPasswordType { ToView, ToModify };
|
|
|
|
|
2017-02-06 23:26:38 +01: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,
|
|
|
|
int limit = 0);
|
|
|
|
|
2018-06-11 04:30:42 +02: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);
|
|
|
|
|
2023-04-21 12:58:56 +02:00
|
|
|
/// Ensure there is no fatal system setup problem
|
|
|
|
void consistencyCheckJail();
|
|
|
|
|
2023-07-06 13:08:59 +02:00
|
|
|
/// Fetch the latest montonically incrementing wire-id
|
|
|
|
TileWireId getCurrentWireId(bool increment = false);
|
|
|
|
|
2020-04-21 12:42:24 +02:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
/// For the Android app, for now, we need access to the one and only document open to perform eg. saveAs() for printing.
|
|
|
|
std::shared_ptr<lok::Document> getLOKDocumentForAndroidOnly();
|
|
|
|
#endif
|
2019-05-29 11:39:46 +02:00
|
|
|
|
2022-02-23 11:47:53 +01:00
|
|
|
extern _LibreOfficeKit* loKitPtr;
|
|
|
|
|
2023-07-31 16:28:27 +02:00
|
|
|
/// Check if URP is enabled
|
|
|
|
bool isURPEnabled();
|
|
|
|
|
|
|
|
/// Start a URP connection, checking if URP is enabled and there is not already an active URP session
|
2023-09-07 15:19:05 +02:00
|
|
|
bool startURP(std::shared_ptr<lok::Office> LOKit, void** ppURPContext);
|
2023-07-31 16:28:27 +02:00
|
|
|
|
2016-04-05 15:32:10 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|