common/FileUtil.cpp | 6 +++- common/Log.cpp | 2 - common/Session.cpp | 3 +- common/Unit.hpp | 4 +++ common/Util.cpp | 6 ++-- common/Util.hpp | 2 - kit/Kit.cpp | 16 ++++++++++-- net/Socket.cpp | 32 +++++++++++++++++------- net/Socket.hpp | 2 + net/WebSocketHandler.hpp | 2 + wsd/Auth.hpp | 4 +-- wsd/ClientSession.cpp | 8 ++++-- wsd/DocumentBroker.cpp | 52 +++++++++++++++++++++++++++++++++++---- wsd/LOOLWSD.cpp | 62 +++++++++++++++++++++++++++++++++-------------- wsd/Storage.cpp | 35 +++++++++++++++++++++----- wsd/TileCache.cpp | 4 ++- 16 files changed, 185 insertions(+), 55 deletions(-)
New commits: commit 75438baa70a0d15b18c5ca829b3e3b1307a27c08 Author: Tor Lillqvist <t...@iki.fi> AuthorDate: Wed Sep 5 15:11:05 2018 +0300 Commit: Tor Lillqvist <t...@iki.fi> CommitDate: Mon Sep 10 15:13:43 2018 +0300 More mobile app stuff, very much early state of work in progress Re-think Linux vs mobile ifdefs a bit. Use #ifdef __linux only to surround code that actually is Linux-specific. Use #ifdef MOBILEAPP for code that is for a mobile version (with no separste wsd, forkit, and kit processes, and with no WebSocket protocol used). Bypass UnitFoo for mobile. Possibly we do want the UnitFoo stuff after all on mobile, to run in some special testing mode? Hard to say, let's skipt it for now. diff --git a/common/FileUtil.cpp b/common/FileUtil.cpp index 22ca87f0a..cae138ed8 100644 --- a/common/FileUtil.cpp +++ b/common/FileUtil.cpp @@ -15,7 +15,7 @@ #include <sys/stat.h> #ifdef __linux #include <sys/vfs.h> -#else +#elif defined IOS #import <Foundation/Foundation.h> #endif @@ -238,9 +238,11 @@ namespace FileUtil { assert(!path.empty()); +#ifndef MOBILEAPP bool hookResult; if (UnitBase::get().filterCheckDiskSpace(path, hookResult)) return hookResult; +#endif // we should be able to run just OK with 5GB constexpr int64_t ENOUGH_SPACE = int64_t(5)*1024*1024*1024; @@ -260,7 +262,7 @@ namespace FileUtil if (static_cast<double>(sfs.f_bavail) / sfs.f_blocks <= 0.05) return false; -#else +#elif defined IOS NSDictionary *atDict = [[NSFileManager defaultManager] attributesOfFileSystemForPath:@"/" error:NULL]; long long freeSpace = [[atDict objectForKey:NSFileSystemFreeSize] longLongValue]; long long totalSpace = [[atDict objectForKey:NSFileSystemSize] longLongValue]; diff --git a/common/Log.cpp b/common/Log.cpp index 761cab9f4..115901ecc 100644 --- a/common/Log.cpp +++ b/common/Log.cpp @@ -12,8 +12,6 @@ #ifdef __linux #include <sys/prctl.h> #include <sys/syscall.h> -#else -#import <Foundation/Foundation.h> #endif #include <unistd.h> diff --git a/common/Session.cpp b/common/Session.cpp index d507bcf0e..adbbbb857 100644 --- a/common/Session.cpp +++ b/common/Session.cpp @@ -187,6 +187,7 @@ void Session::handleMessage(bool /*fin*/, WSOpCode /*code*/, std::vector<char> & { try { +#ifndef MOBILEAPP std::unique_ptr< std::vector<char> > replace; if (UnitBase::get().filterSessionInput(this, &data[0], data.size(), replace)) { @@ -194,7 +195,7 @@ void Session::handleMessage(bool /*fin*/, WSOpCode /*code*/, std::vector<char> & _handleInput(replace->data(), replace->size()); return; } - +#endif if (!data.empty()) _handleInput(&data[0], data.size()); } diff --git a/common/Unit.hpp b/common/Unit.hpp index 5844cc3bd..eaf393611 100644 --- a/common/Unit.hpp +++ b/common/Unit.hpp @@ -9,6 +9,8 @@ #ifndef INCLUDED_UNIT_HPP #define INCLUDED_UNIT_HPP +#ifndef MOBILEAPP + #include <atomic> #include <cassert> #include <memory> @@ -291,4 +293,6 @@ public: #endif +#endif + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/common/Util.cpp b/common/Util.cpp index f48978f37..b193304c1 100644 --- a/common/Util.cpp +++ b/common/Util.cpp @@ -18,7 +18,7 @@ #include <sys/prctl.h> #include <sys/syscall.h> #include <sys/vfs.h> -#else +#elif defined IOS #import <Foundation/Foundation.h> #endif #include <sys/stat.h> @@ -504,7 +504,7 @@ namespace Util LOG_INF("Thread " << getThreadId() << " (" << std::this_thread::get_id() << ") is now called [" << s << "]."); -#else +#elif defined IOS [[NSThread currentThread] setName:[NSString stringWithUTF8String:ThreadName]]; LOG_INF("Thread " << getThreadId() << " (" << std::this_thread::get_id() << @@ -520,7 +520,7 @@ namespace Util #ifdef __linux if (prctl(PR_GET_NAME, reinterpret_cast<unsigned long>(ThreadName), 0, 0, 0) != 0) ThreadName[0] = '\0'; -#else +#elif defined IOS const char *const name = [[[NSThread currentThread] name] UTF8String]; strncpy(ThreadName, name, 31); ThreadName[31] = '\0'; diff --git a/common/Util.hpp b/common/Util.hpp index 9233a2142..c6df31ab5 100644 --- a/common/Util.hpp +++ b/common/Util.hpp @@ -70,7 +70,7 @@ namespace Util bool windowingAvailable(); -#if !defined(BUILDING_TESTS) && !defined(KIT_IN_PROCESS) +#if !defined(BUILDING_TESTS) && !defined(KIT_IN_PROCESS) && !defined(MOBILEAPP) /// Send a message to all clients. void alertAllUsers(const std::string& msg); diff --git a/kit/Kit.cpp b/kit/Kit.cpp index 07befa2b6..da518d2fa 100644 --- a/kit/Kit.cpp +++ b/kit/Kit.cpp @@ -14,11 +14,13 @@ #include <config.h> #include <dlfcn.h> +#ifdef __linux #include <ftw.h> #include <sys/capability.h> +#include <sys/sysmacros.h> +#endif #include <unistd.h> #include <utime.h> -#include <sys/sysmacros.h> #include <sys/time.h> #include <sys/resource.h> @@ -99,7 +101,6 @@ using namespace LOOLProtocol; // We only host a single document in our lifetime. class Document; static std::shared_ptr<Document> document; -static LokHookFunction2* initFunction = nullptr; #if ENABLE_DEBUG # define ADD_DEBUG_RENDERID(s) ((s)+ " renderid=" + Util::UniqueId()) @@ -107,6 +108,10 @@ static LokHookFunction2* initFunction = nullptr; # define ADD_DEBUG_RENDERID(s) (s) #endif +#ifndef MOBILEAPP + +static LokHookFunction2* initFunction = nullptr; + namespace { #ifndef BUILDING_TESTS @@ -360,6 +365,8 @@ namespace #endif } +#endif + /// A quick & dirty cache of the last few PNGs /// and their hashes to avoid re-compression /// wherever possible. @@ -2108,7 +2115,10 @@ void documentViewCallback(const int type, const char* payload, void* data) Document::ViewCallback(type, payload, data); } +#ifndef MOBILEAPP + #ifndef BUILDING_TESTS + void lokit_main(const std::string& childRoot, const std::string& jailId, const std::string& sysTemplate, @@ -2481,4 +2491,6 @@ void alertAllUsers(const std::string& cmd, const std::string& kind) } #endif +#endif // MOBILEAPP + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/net/Socket.cpp b/net/Socket.cpp index 98bb6b996..38bacdde8 100644 --- a/net/Socket.cpp +++ b/net/Socket.cpp @@ -24,7 +24,7 @@ #include <SigUtil.hpp> #include "Socket.hpp" -#ifdef __linux +#ifndef MOBILEAPP #include "ServerSocket.hpp" #include "SslSocket.hpp" #endif @@ -34,7 +34,7 @@ int SocketPoll::DefaultPollTimeoutMs = 5000; std::atomic<bool> SocketPoll::InhibitThreadChecks(false); std::atomic<bool> Socket::InhibitThreadChecks(false); -#ifdef __linux +#ifndef MOBILEAPP int Socket::createSocket(Socket::Type type) { @@ -56,6 +56,8 @@ namespace { } } +#endif + SocketPoll::SocketPoll(const std::string& threadName) : _name(threadName), _stop(false), @@ -63,6 +65,7 @@ SocketPoll::SocketPoll(const std::string& threadName) _threadFinished(false), _owner(std::this_thread::get_id()) { +#ifndef MOBILEAPP // Create the wakeup fd. if (::pipe2(_wakeup, O_CLOEXEC | O_NONBLOCK) == -1) { @@ -71,10 +74,12 @@ SocketPoll::SocketPoll(const std::string& threadName) std::lock_guard<std::mutex> lock(getPollWakeupsMutex()); getWakeupsArray().push_back(_wakeup[1]); +#endif } SocketPoll::~SocketPoll() { +#ifndef MOBILEAPP joinThread(); { @@ -91,6 +96,7 @@ SocketPoll::~SocketPoll() ::close(_wakeup[1]); _wakeup[0] = -1; _wakeup[1] = -1; +#endif } void SocketPoll::startThread() @@ -110,6 +116,8 @@ void SocketPoll::startThread() } } +#ifndef MOBILEAPP + void SocketPoll::joinThread() { addCallback([this](){ removeSockets(); }); @@ -126,14 +134,19 @@ void SocketPoll::joinThread() } } +#endif + void SocketPoll::wakeupWorld() { +#ifndef MOBILEAPP for (const auto& fd : getWakeupsArray()) wakeup(fd); +#endif } void SocketPoll::insertNewWebSocketSync(const Poco::URI &uri, const std::shared_ptr<SocketHandlerInterface>& websocketHandler) { +#ifndef MOBILEAPP LOG_INF("Connecting to " << uri.getHost() << " : " << uri.getPort() << " : " << uri.getPath()); // FIXME: put this in a ClientSocket class ? @@ -218,11 +231,10 @@ void SocketPoll::insertNewWebSocketSync(const Poco::URI &uri, const std::shared_ } else LOG_ERR("Failed to lookup client websocket host '" << uri.getHost() << "' skipping"); -} - #endif +} -#ifdef __linux +#ifndef MOBILEAPP void ServerSocket::dumpState(std::ostream& os) { @@ -242,11 +254,11 @@ void SocketDisposition::execute() _socketMove = nullptr; } +#endif + const int WebSocketHandler::InitialPingDelayMs = 25; const int WebSocketHandler::PingFrequencyMs = 18 * 1000; -#endif - void WebSocketHandler::dumpState(std::ostream& os) { os << (_shuttingDown ? "shutd " : "alive ") @@ -281,10 +293,9 @@ void StreamSocket::send(Poco::Net::HTTPResponse& response) send(oss.str()); } -#ifdef __linux - void SocketPoll::dumpState(std::ostream& os) { +#ifndef MOBILEAPP // FIXME: NOT thread-safe! _pollSockets is modified from the polling thread! os << " Poll [" << _pollSockets.size() << "] - wakeup r: " << _wakeup[0] << " w: " << _wakeup[1] << "\n"; @@ -293,8 +304,11 @@ void SocketPoll::dumpState(std::ostream& os) os << "\tfd\tevents\trsize\twsize\n"; for (auto &i : _pollSockets) i->dumpState(os); +#endif } +#ifndef MOBILEAPP + /// Returns true on success only. bool ServerSocket::bind(Type type, int port) { diff --git a/net/Socket.hpp b/net/Socket.hpp index 5275ec61e..2a336f8fc 100644 --- a/net/Socket.hpp +++ b/net/Socket.hpp @@ -429,6 +429,7 @@ public: /// Poll the sockets for available data to read or buffer to write. void poll(int timeoutMaxMs) { +#ifndef MOBILEAPP assertCorrectThread(); std::chrono::steady_clock::time_point now = @@ -527,6 +528,7 @@ public: disposition.execute(); } +#endif } /// Write to a wakeup descriptor diff --git a/net/WebSocketHandler.hpp b/net/WebSocketHandler.hpp index 6ef1460e0..3e1faabb4 100644 --- a/net/WebSocketHandler.hpp +++ b/net/WebSocketHandler.hpp @@ -383,9 +383,11 @@ public: /// 0 for closed/invalid socket, and -1 for other errors. int sendMessage(const char* data, const size_t len, const WSOpCode code, const bool flush = true) const { +#ifndef MOBILEAPP int unitReturn = -1; if (UnitBase::get().filterSendMessage(data, len, code, flush, unitReturn)) return unitReturn; +#endif //TODO: Support fragmented messages. diff --git a/wsd/Auth.hpp b/wsd/Auth.hpp index 2ad47a3f1..1832b7868 100644 --- a/wsd/Auth.hpp +++ b/wsd/Auth.hpp @@ -14,7 +14,7 @@ #include <cassert> #include <string> -#ifdef __linux +#ifndef MOBILEAPP #include <Poco/Crypto/RSADigestEngine.h> #include <Poco/Crypto/RSAKey.h> #endif @@ -67,7 +67,7 @@ public: virtual bool verify(const std::string& token) = 0; }; -#ifdef __linux +#ifndef MOBILEAPP /// JWT Authorization. class JWTAuth : public AuthBase diff --git a/wsd/ClientSession.cpp b/wsd/ClientSession.cpp index 299cba324..c5b7bc1ac 100644 --- a/wsd/ClientSession.cpp +++ b/wsd/ClientSession.cpp @@ -66,10 +66,11 @@ ClientSession::~ClientSession() void ClientSession::handleIncomingMessage(SocketDisposition &disposition) { +#ifndef MOBILEAPP if (UnitWSD::get().filterHandleRequest( UnitWSD::TestRequest::Client, disposition, *this)) return; - +#endif Session::handleIncomingMessage(disposition); } @@ -94,6 +95,7 @@ bool ClientSession::_handleInput(const char *buffer, int length) updateLastActivityTime(); docBroker->updateLastActivityTime(); } +#ifndef MOBILEAPP if (tokens[0] == "loolclient") { if (tokens.size() < 1) @@ -123,7 +125,7 @@ bool ClientSession::_handleInput(const char *buffer, int length) return true; } - +#endif if (tokens[0] == "load") { if (_docURL != "") @@ -668,7 +670,9 @@ bool ClientSession::handleKitToClientMessage(const char* buffer, const int lengt return false; } +#ifndef MOBILEAPP LOOLWSD::dumpOutgoingTrace(docBroker->getJailId(), getId(), firstLine); +#endif const auto& tokens = payload->tokens(); if (tokens[0] == "unocommandresult:") diff --git a/wsd/DocumentBroker.cpp b/wsd/DocumentBroker.cpp index 48671a0dc..b29616ec6 100644 --- a/wsd/DocumentBroker.cpp +++ b/wsd/DocumentBroker.cpp @@ -194,6 +194,8 @@ void DocumentBroker::pollThread() _threadStart = std::chrono::steady_clock::now(); +#ifndef MOBILEAPP + // Request a kit process for this doc. do { @@ -234,6 +236,7 @@ void DocumentBroker::pollThread() LOG_INF("Finished docBroker polling thread for docKey [" << _docKey << "]."); return; } +#endif _childProcess->setDocumentBroker(shared_from_this()); LOG_INF("Doc [" << _docKey << "] attached to child [" << _childProcess->getPid() << "]."); @@ -242,19 +245,22 @@ void DocumentBroker::pollThread() static const size_t IdleDocTimeoutSecs = LOOLWSD::getConfigValue<int>( "per_document.idle_timeout_secs", 3600); +#ifndef MOBILEAPP // Used to accumulate B/W deltas. uint64_t adminSent = 0; uint64_t adminRecv = 0; auto lastBWUpdateTime = std::chrono::steady_clock::now(); +#endif auto last30SecCheckTime = std::chrono::steady_clock::now(); // Main polling loop goodness. while (!_stop && _poll->continuePolling() && !TerminationFlag) { - _poll->poll(SocketPoll::DefaultPollTimeoutMs); - const auto now = std::chrono::steady_clock::now(); +#ifndef MOBILEAPP + _poll->poll(SocketPoll::DefaultPollTimeoutMs); + if (std::chrono::duration_cast<std::chrono::milliseconds> (now - lastBWUpdateTime).count() >= 5 * 1000) { @@ -270,6 +276,7 @@ void DocumentBroker::pollThread() adminSent = sent; adminRecv = recv; } +#endif if (isSaving() && std::chrono::duration_cast<std::chrono::milliseconds> @@ -352,8 +359,10 @@ void DocumentBroker::pollThread() _poll->stop(); _poll->removeSockets(); +#ifndef MOBILEAPP // Async cleanup. LOOLWSD::doHousekeeping(); +#endif // Remove all tiles related to this document from the cache if configured so. if (_tileCache && !LOOLWSD::TileCachePersistent) @@ -375,13 +384,17 @@ DocumentBroker::~DocumentBroker() { assertCorrectThread(); +#ifndef MOBILEAPP Admin::instance().rmDoc(_docKey); +#endif LOG_INF("~DocumentBroker [" << _docKey << "] destroyed with " << _sessions.size() << " sessions left."); +#ifndef MOBILEAPP // Do this early - to avoid operating on _childProcess from two threads. _poll->joinThread(); +#endif if (!_sessions.empty()) { @@ -395,7 +408,9 @@ DocumentBroker::~DocumentBroker() void DocumentBroker::joinThread() { +#ifndef MOBILEAPP _poll->joinThread(); +#endif } void DocumentBroker::stop(const std::string& reason) @@ -414,11 +429,13 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s LOG_INF("Loading [" << _docKey << "] for session [" << sessionId << "] and jail [" << jailId << "]."); +#ifndef MOBILEAPP { bool result; if (UnitWSD::get().filterLoad(sessionId, jailId, result)) return result; } +#endif if (_markToDestroy) { @@ -463,6 +480,8 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s std::string userExtraInfo; std::string watermarkText; std::chrono::duration<double> getInfoCallDuration(0); + + #ifndef MOBILEAPP WopiStorage* wopiStorage = dynamic_cast<WopiStorage*>(_storage.get()); if (wopiStorage != nullptr) { @@ -532,6 +551,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s session->setWopiFileInfo(wopifileinfo); } else +#endif { LocalStorage* localStorage = dynamic_cast<LocalStorage*>(_storage.get()); if (localStorage != nullptr) @@ -601,6 +621,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s { std::string localPath = _storage->loadStorageFileToLocal(session->getAuthorization()); +#ifndef MOBILEAPP // Check if we have a prefilter "plugin" for this document format for (const auto& plugin : LOOLWSD::PluginConfigurations) { @@ -652,6 +673,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s // This plugin is not a proper prefilter one } } +#endif std::ifstream istr(localPath, std::ios::binary); Poco::SHA1Engine sha1; @@ -674,6 +696,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s _tileCache->setThreadOwner(std::this_thread::get_id()); } +#ifndef MOBILEAPP LOOLWSD::dumpNewSessionTrace(getJailId(), sessionId, _uriOrig, _storage->getRootFilePath()); // Since document has been loaded, send the stats if its WOPI @@ -687,7 +710,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s LOG_TRC("Sending to Client [" << msg << "]."); session->sendTextFrame(msg); } - +#endif return true; } @@ -973,7 +996,11 @@ bool DocumentBroker::sendUnoSave(const std::string& sessionId, bool dontTerminat oss << "}"; assert(_storage); - _storage->setIsAutosave(isAutosave || UnitWSD::get().isAutosave()); + _storage->setIsAutosave(isAutosave +#ifndef MOBILEAPP + || UnitWSD::get().isAutosave() +#endif + ); const std::string saveArgs = oss.str(); LOG_TRC(".uno:Save arguments: " << saveArgs); @@ -1044,8 +1071,10 @@ size_t DocumentBroker::addSessionInternal(const std::shared_ptr<ClientSession>& const std::string aMessage = "session " + id + ' ' + _docKey + ' ' + _docId; _childProcess->sendTextFrame(aMessage); +#ifndef MOBILEAPP // Tell the admin console about this new doc Admin::instance().addDoc(_docKey, getPid(), getFilename(), id, session->getUserName(), session->getUserId()); +#endif // Add and attach the session. _sessions.emplace(session->getId(), session); @@ -1098,12 +1127,15 @@ size_t DocumentBroker::removeSessionInternal(const std::string& id) assertCorrectThread(); try { +#ifndef MOBILEAPP Admin::instance().rmDoc(_docKey, id); - +#endif auto it = _sessions.find(id); if (it != _sessions.end()) { +#ifndef MOBILEAPP LOOLWSD::dumpEndSessionTrace(getJailId(), id, _uriOrig); +#endif const bool readonly = (it->second ? it->second->isReadOnly() : false); @@ -1158,8 +1190,10 @@ void DocumentBroker::alertAllUsers(const std::string& msg) { assertCorrectThread(); +#ifndef MOBILEAPP if (UnitWSD::get().filterAlertAllusers(msg)) return; +#endif auto payload = std::make_shared<Message>(msg, Message::Dir::Out); @@ -1177,7 +1211,9 @@ bool DocumentBroker::handleInput(const std::vector<char>& payload) const auto& msg = message->abbr(); LOG_TRC("DocumentBroker handling child message: [" << msg << "]."); +#ifndef MOBILEAPP LOOLWSD::dumpOutgoingTrace(getJailId(), "0", msg); +#endif if (LOOLProtocol::getFirstToken(message->forwardToken(), '-') == "client") { @@ -1204,6 +1240,7 @@ bool DocumentBroker::handleInput(const std::vector<char>& payload) LOG_CHECK_RET(kind != "", false); Util::alertAllUsers(cmd, kind); } +#ifndef MOBILEAPP else if (command == "procmemstats:") { int dirty; @@ -1212,6 +1249,7 @@ bool DocumentBroker::handleInput(const std::vector<char>& payload) Admin::instance().updateMemoryDirty(_docKey, dirty); } } +#endif else { LOG_ERR("Unexpected message: [" << msg << "]."); @@ -1555,7 +1593,9 @@ void DocumentBroker::setModified(const bool value) if (_isModified != value) { _isModified = value; +#ifndef MOBILEAPP Admin::instance().modificationAlert(_docKey, getPid(), value); +#endif } _storage->setUserModified(value); @@ -1742,7 +1782,9 @@ void DocumentBroker::broadcastMessage(const std::string& message) void DocumentBroker::updateLastActivityTime() { _lastActivityTime = std::chrono::steady_clock::now(); +#ifndef MOBILEAPP Admin::instance().updateLastActivityTime(_docKey); +#endif } void DocumentBroker::getIOStats(uint64_t &sent, uint64_t &recv) diff --git a/wsd/LOOLWSD.cpp b/wsd/LOOLWSD.cpp index 8248d28d8..8f83234da 100644 --- a/wsd/LOOLWSD.cpp +++ b/wsd/LOOLWSD.cpp @@ -49,6 +49,26 @@ #include <sstream> #include <thread> +#ifndef MOBILEAPP + +#include <Poco/Net/Context.h> +#include <Poco/Net/HTMLForm.h> +#include <Poco/Net/HTTPRequest.h> +#include <Poco/Net/IPAddress.h> +#include <Poco/Net/MessageHeader.h> +#include <Poco/Net/NameValueCollection.h> +#include <Poco/Net/Net.h> +#include <Poco/Net/NetException.h> +#include <Poco/Net/PartHandler.h> +#include <Poco/Net/SocketAddress.h> + +#include <ServerSocket.hpp> + +using Poco::Net::HTMLForm; +using Poco::Net::PartHandler; + +#endif + #include <Poco/DOM/AutoPtr.h> #include <Poco/DOM/DOMParser.h> #include <Poco/DOM/DOMWriter.h> @@ -62,16 +82,6 @@ #include <Poco/File.h> #include <Poco/FileStream.h> #include <Poco/MemoryStream.h> -#include <Poco/Net/Context.h> -#include <Poco/Net/HTMLForm.h> -#include <Poco/Net/HTTPRequest.h> -#include <Poco/Net/IPAddress.h> -#include <Poco/Net/MessageHeader.h> -#include <Poco/Net/NameValueCollection.h> -#include <Poco/Net/Net.h> -#include <Poco/Net/NetException.h> -#include <Poco/Net/PartHandler.h> -#include <Poco/Net/SocketAddress.h> #include <Poco/Path.h> #include <Poco/Pipe.h> #include <Poco/Process.h> @@ -106,7 +116,6 @@ #endif #include <Log.hpp> #include <Protocol.hpp> -#include <ServerSocket.hpp> #include <Session.hpp> #if ENABLE_SSL # include <SslSocket.hpp> @@ -130,12 +139,10 @@ using Poco::DirectoryIterator; using Poco::Environment; using Poco::Exception; using Poco::File; -using Poco::Net::HTMLForm; using Poco::Net::HTTPRequest; using Poco::Net::HTTPResponse; using Poco::Net::MessageHeader; using Poco::Net::NameValueCollection; -using Poco::Net::PartHandler; using Poco::Path; using Poco::Process; using Poco::StreamCopier; @@ -192,6 +199,28 @@ extern "C" { void dump_state(void); /* easy for gdb */ } static int careerSpanMs = 0; #endif +#ifdef IOS +#include "ios.h" +#endif + +bool LOOLWSD::NoCapsForKit = false; +bool LOOLWSD::TileCachePersistent = true; +std::atomic<unsigned> LOOLWSD::NumConnections; +std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR; +std::set<std::string> LOOLWSD::EditFileExtensions; + +#ifdef MOBILEAPP + +// Some dummy versions of static ember functions + +void LOOLWSD::dumpIncomingTrace(const std::string& id, const std::string& sessionId, const std::string& data) +{ +} + +#else + +// Most of this file is probably not used in a mobile app. Let's see. + namespace { @@ -582,13 +611,11 @@ std::atomic<int> LOOLWSD::ForKitWritePipe(-1); std::atomic<int> LOOLWSD::ForKitProcId(-1); #endif bool LOOLWSD::NoSeccomp = false; -bool LOOLWSD::NoCapsForKit = false; bool LOOLWSD::AdminEnabled = true; #ifdef FUZZER bool LOOLWSD::DummyLOK = false; std::string LOOLWSD::FuzzFileName; #endif -std::string LOOLWSD::Cache = LOOLWSD_CACHEDIR; std::string LOOLWSD::SysTemplate; std::string LOOLWSD::LoTemplate; std::string LOOLWSD::ChildRoot; @@ -601,7 +628,6 @@ std::string LOOLWSD::ConfigDir = LOOLWSD_CONFIGDIR "/conf.d"; std::string LOOLWSD::LogLevel = "trace"; Util::RuntimeConstant<bool> LOOLWSD::SSLEnabled; Util::RuntimeConstant<bool> LOOLWSD::SSLTermination; -std::set<std::string> LOOLWSD::EditFileExtensions; unsigned LOOLWSD::MaxConnections; unsigned LOOLWSD::MaxDocuments; std::string LOOLWSD::OverrideWatermark; @@ -610,8 +636,6 @@ std::set<const Poco::Util::AbstractConfiguration*> LOOLWSD::PluginConfigurations static std::string UnitTestLibrary; unsigned int LOOLWSD::NumPreSpawnedChildren = 0; -std::atomic<unsigned> LOOLWSD::NumConnections; -bool LOOLWSD::TileCachePersistent = true; std::unique_ptr<TraceFileWriter> LOOLWSD::TraceDumper; /// This thread polls basic web serving, and handling of @@ -3048,4 +3072,6 @@ void dump_state() POCO_SERVER_MAIN(LOOLWSD) +#endif // !MOBILEAPP + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/wsd/Storage.cpp b/wsd/Storage.cpp index f6f8066eb..52ab41d16 100644 --- a/wsd/Storage.cpp +++ b/wsd/Storage.cpp @@ -22,23 +22,26 @@ #include <Poco/Exception.h> #include <Poco/JSON/Object.h> #include <Poco/JSON/Parser.h> + +#ifndef MOBILEAPP + +#include <Poco/Net/AcceptCertificateHandler.h> +#include <Poco/Net/Context.h> #include <Poco/Net/DNS.h> #include <Poco/Net/HTTPClientSession.h> #include <Poco/Net/HTTPRequest.h> #include <Poco/Net/HTTPResponse.h> #include <Poco/Net/HTTPSClientSession.h> +#include <Poco/Net/KeyConsoleHandler.h> #include <Poco/Net/NameValueCollection.h> #include <Poco/Net/NetworkInterface.h> #include <Poco/Net/SSLManager.h> + +#endif + #include <Poco/StreamCopier.h> #include <Poco/Timestamp.h> -// For residual Poco SSL usage. -#include <Poco/Net/AcceptCertificateHandler.h> -#include <Poco/Net/Context.h> -#include <Poco/Net/KeyConsoleHandler.h> -#include <Poco/Net/SSLManager.h> - #include "Auth.hpp" #include <Common.hpp> #include "Exceptions.hpp" @@ -127,6 +130,8 @@ void StorageBase::initialize() #endif } +#ifndef MOBILEAPP + bool isLocalhost(const std::string& targetHost) { std::string targetAddress; @@ -165,6 +170,8 @@ bool isLocalhost(const std::string& targetHost) return false; } +#endif + std::unique_ptr<StorageBase> StorageBase::create(const Poco::URI& uri, const std::string& jailRoot, const std::string& jailPath) { // FIXME: By the time this gets called we have already sent to the client three @@ -172,6 +179,7 @@ std::unique_ptr<StorageBase> StorageBase::create(const Poco::URI& uri, const std // here much earlier. Also, using exceptions is lame and makes understanding the code harder, // but that is just my personal preference. +#ifndef MOBILEAPP std::unique_ptr<StorageBase> storage; if (UnitWSD::get().createStorage(uri, jailRoot, jailPath, storage)) @@ -182,6 +190,10 @@ std::unique_ptr<StorageBase> StorageBase::create(const Poco::URI& uri, const std return storage; } } +#else + if (false) + ; +#endif else if (uri.isRelative() || uri.getScheme() == "file") { LOG_INF("Public URI [" << uri.toString() << "] is a file."); @@ -215,6 +227,7 @@ std::unique_ptr<StorageBase> StorageBase::create(const Poco::URI& uri, const std LOG_ERR("Local Storage is disabled by default. Enable in the config file or on the command-line to enable."); } +#ifndef MOBILEAPP else if (WopiEnabled) { LOG_INF("Public URI [" << uri.toString() << "] considered WOPI."); @@ -226,7 +239,7 @@ std::unique_ptr<StorageBase> StorageBase::create(const Poco::URI& uri, const std LOG_ERR("No acceptable WOPI hosts found matching the target host [" << targetHost << "] in config."); throw UnauthorizedRequestException("No acceptable WOPI hosts found matching the target host [" + targetHost + "] in config."); } - +#endif throw BadRequestException("No Storage configured or invalid URI."); } @@ -330,6 +343,8 @@ StorageBase::SaveResult LocalStorage::saveLocalFileToStorage(const Authorization namespace { +#ifndef MOBILEAPP + inline Poco::Net::HTTPClientSession* getHTTPClientSession(const Poco::URI& uri) { @@ -341,6 +356,8 @@ Poco::Net::HTTPClientSession* getHTTPClientSession(const Poco::URI& uri) : new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort()); } +#endif + void addStorageDebugCookie(Poco::Net::HTTPRequest& request) { (void) request; @@ -380,6 +397,8 @@ Poco::Timestamp iso8601ToTimestamp(const std::string& iso8601Time, const std::st } // anonymous namespace +#ifndef MOBILEAPP + std::unique_ptr<WopiStorage::WOPIFileInfo> WopiStorage::getWOPIFileInfo(const Authorization& auth) { // update the access_token to the one matching to the session @@ -749,4 +768,6 @@ StorageBase::SaveResult WebDAVStorage::saveLocalFileToStorage(const Authorizatio return StorageBase::SaveResult(StorageBase::SaveResult::OK); } +#endif + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/wsd/TileCache.cpp b/wsd/TileCache.cpp index 5f995b30d..e76d1c7db 100644 --- a/wsd/TileCache.cpp +++ b/wsd/TileCache.cpp @@ -150,10 +150,12 @@ std::unique_ptr<std::fstream> TileCache::lookupTile(const TileDesc& tile) const std::string fileName = _cacheDir + "/" + cacheFileName(tile); std::unique_ptr<std::fstream> result(new std::fstream(fileName, std::ios::in)); + +#ifndef MOBILEAPP UnitWSD::get().lookupTile(tile.getPart(), tile.getWidth(), tile.getHeight(), tile.getTilePosX(), tile.getTilePosY(), tile.getTileWidth(), tile.getTileHeight(), result); - +#endif if (result && result->is_open()) { LOG_TRC("Found cache tile: " << fileName); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits