2015-04-13 04:09:02 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
2015-03-17 18:56:15 -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/.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef INCLUDED_LOOLWSD_HPP
|
|
|
|
#define INCLUDED_LOOLWSD_HPP
|
|
|
|
|
2015-12-27 21:47:39 -06:00
|
|
|
#include <atomic>
|
2016-03-08 01:31:29 -06:00
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2015-03-17 18:56:15 -05:00
|
|
|
|
2015-07-13 09:13:06 -05:00
|
|
|
#include <Poco/Path.h>
|
2016-01-25 19:07:10 -06:00
|
|
|
#include <Poco/Process.h>
|
2016-03-08 01:31:29 -06:00
|
|
|
#include <Poco/Random.h>
|
|
|
|
#include <Poco/Util/OptionSet.h>
|
|
|
|
#include <Poco/Util/ServerApplication.h>
|
2015-03-17 18:56:15 -05:00
|
|
|
|
2016-02-15 17:05:24 -06:00
|
|
|
#include "Auth.hpp"
|
2016-01-06 23:16:47 -06:00
|
|
|
#include "Common.hpp"
|
2016-03-12 18:29:17 -06:00
|
|
|
#include "DocumentBroker.hpp"
|
2015-12-27 21:47:39 -06:00
|
|
|
#include "Util.hpp"
|
|
|
|
|
2016-03-10 21:33:03 -06:00
|
|
|
class MasterProcessSession;
|
2016-01-06 23:16:47 -06:00
|
|
|
|
2015-03-17 18:56:15 -05:00
|
|
|
class LOOLWSD: public Poco::Util::ServerApplication
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LOOLWSD();
|
|
|
|
~LOOLWSD();
|
|
|
|
|
2016-03-10 21:33:03 -06:00
|
|
|
// An Application is a singleton anyway,
|
|
|
|
// so just keep these as statics.
|
2015-12-27 21:47:39 -06:00
|
|
|
static std::atomic<unsigned> NextSessionId;
|
2015-12-28 15:34:21 -06:00
|
|
|
static int NumPreSpawnedChildren;
|
|
|
|
static int BrokerWritePipe;
|
2016-01-15 02:40:54 -06:00
|
|
|
static bool DoTest;
|
|
|
|
static std::string Cache;
|
|
|
|
static std::string SysTemplate;
|
|
|
|
static std::string LoTemplate;
|
|
|
|
static std::string ChildRoot;
|
|
|
|
static std::string LoSubPath;
|
2016-02-15 17:05:24 -06:00
|
|
|
//static Auth AuthAgent;
|
2015-04-08 09:22:42 -05:00
|
|
|
|
2015-07-19 15:49:11 -05:00
|
|
|
static const std::string PIDLOG;
|
2016-02-13 11:22:15 -06:00
|
|
|
static const std::string FIFO_PATH;
|
|
|
|
static const std::string FIFO_LOOLWSD;
|
2015-08-05 19:20:05 -05:00
|
|
|
static const std::string LOKIT_PIDLOG;
|
2015-03-26 01:36:35 -05:00
|
|
|
|
2016-03-12 18:29:17 -06:00
|
|
|
// All DocumentBrokers by their DocKey (the URI path without host, port, or query).
|
|
|
|
static std::map<std::string, std::shared_ptr<DocumentBroker>> DocBrokers;
|
|
|
|
static std::mutex DocBrokersMutex;
|
2016-03-10 21:33:03 -06:00
|
|
|
|
2015-12-27 21:47:39 -06:00
|
|
|
static
|
|
|
|
std::string GenSessionId()
|
|
|
|
{
|
|
|
|
return Util::encodeId(++NextSessionId, 4);
|
|
|
|
}
|
|
|
|
|
2015-03-17 18:56:15 -05:00
|
|
|
protected:
|
|
|
|
void initialize(Poco::Util::Application& self) override;
|
|
|
|
void uninitialize() override;
|
|
|
|
void defineOptions(Poco::Util::OptionSet& options) override;
|
|
|
|
void handleOption(const std::string& name, const std::string& value) override;
|
|
|
|
int main(const std::vector<std::string>& args) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void displayHelp();
|
2015-12-19 12:38:44 -06:00
|
|
|
void displayVersion();
|
2016-02-13 08:15:28 -06:00
|
|
|
Poco::Process::PID createBroker();
|
2015-03-17 18:56:15 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|