da455c486a
The initial bits to serving some page with provision to ingest the different formats into a table. Doesn't yet link with the actual document, but it's a start. The link will have some unique id(s) in it to reference the document in question, which will be some hash (possibly changing with some logic for security reasons). This hash will have to be something valid that WSD will use to locate the DocBroker in question, connect to it and fetch the formats supported and generate unique links for each. When the user clicks on a link, the contents will be downloaded in the given format and copied to the user's clipboard. The clipboard.html template is based on loleaflet.html as we're very likely to use the same customization, branding, localization, and javascript bits. We would probably want to add a brandable title with logo etc. and possibly some more reasable background (ideally, an image enlarged and blured to give the page some semblance of having content). Change-Id: If0550184d4423bef1e98fecbb072bdf8df07701b
53 lines
2.1 KiB
C++
53 lines
2.1 KiB
C++
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
|
|
/*
|
|
* 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_FILESERVER_HPP
|
|
#define INCLUDED_FILESERVER_HPP
|
|
|
|
#include <string>
|
|
#include "Socket.hpp"
|
|
|
|
#include <Poco/MemoryStream.h>
|
|
|
|
/// Handles file requests over HTTP(S).
|
|
class FileServerRequestHandler
|
|
{
|
|
static std::string getRequestPathname(const Poco::Net::HTTPRequest& request);
|
|
|
|
static void preprocessFile(const Poco::Net::HTTPRequest& request, Poco::MemoryInputStream& message,
|
|
const std::shared_ptr<StreamSocket>& socket, const std::string& endPoint);
|
|
static void preprocessAdminFile(const Poco::Net::HTTPRequest& request, const std::shared_ptr<StreamSocket>& socket);
|
|
public:
|
|
/// Evaluate if the cookie exists, and if not, ask for the credentials.
|
|
static bool isAdminLoggedIn(const Poco::Net::HTTPRequest& request, Poco::Net::HTTPResponse& response);
|
|
|
|
static void handleRequest(const Poco::Net::HTTPRequest& request, Poco::MemoryInputStream& message, const std::shared_ptr<StreamSocket>& socket);
|
|
|
|
/// Read all files that we can serve into memory and compress them.
|
|
static void initialize();
|
|
|
|
/// Clean cached files.
|
|
static void uninitialize() { FileHash.clear(); }
|
|
|
|
static void readDirToHash(const std::string &basePath, const std::string &path);
|
|
|
|
static const std::string *getCompressedFile(const std::string &path);
|
|
|
|
static const std::string *getUncompressedFile(const std::string &path);
|
|
|
|
private:
|
|
static std::map<std::string, std::pair<std::string, std::string>> FileHash;
|
|
static void sendError(int errorCode, const Poco::Net::HTTPRequest& request,
|
|
const std::shared_ptr<StreamSocket>& socket, const std::string& shortMessage,
|
|
const std::string& longMessage, const std::string& extraHeader = "");
|
|
};
|
|
|
|
#endif
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|