libreoffice-online/wsd/RequestVettingStation.hpp
Ashod Nakashian 1f3441cc42 wsd: rvs: refactor CheckFileInfo
This breaks the CheckFileInfo fetching
code in RVS into its own function to
allow for redirection.

Change-Id: I8bfa3a71705c77af8f6e75ed1af75e710767cf19
Signed-off-by: Ashod Nakashian <ashod.nakashian@collabora.co.uk>
2024-01-18 18:59:18 +00:00

57 lines
2 KiB
C++

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
/*
* Copyright the Collabora Online contributors.
*
* SPDX-License-Identifier: MPL-2.0
*
* 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/.
*/
#include "RequestDetails.hpp"
#include <Storage.hpp>
#include "WebSocketHandler.hpp"
#include <string>
class RequestVettingStation
{
public:
RequestVettingStation(std::string id, std::shared_ptr<WebSocketHandler> ws,
const RequestDetails& requestDetails,
const std::shared_ptr<StreamSocket>& socket, unsigned mobileAppDocId)
: _id(std::move(id))
, _ws(ws)
, _requestDetails(requestDetails)
, _socket(socket)
, _mobileAppDocId(mobileAppDocId)
{
// Indicate to the client that document broker is searching.
static const std::string status("statusindicator: find");
LOG_TRC("Sending to Client [" << status << "].");
_ws->sendMessage(status);
}
inline void logPrefix(std::ostream& os) const { os << '#' << _socket->getFD() << ": "; }
void handleRequest(SocketPoll& poll, SocketDisposition& disposition);
private:
void createDocBroker(const std::string& docKey, const std::string& url,
const Poco::URI& uriPublic, const bool isReadOnly,
Poco::JSON::Object::Ptr wopiInfo = nullptr);
void checkFileInfo(SocketPoll& poll, const std::string& url, const Poco::URI& uriPublic,
const std::string& docKey, bool isReadOnly);
private:
const std::string _id;
std::shared_ptr<WebSocketHandler> _ws;
const RequestDetails _requestDetails;
const std::shared_ptr<StreamSocket> _socket;
std::shared_ptr<http::Session> _httpSession;
const unsigned _mobileAppDocId;
std::unique_ptr<WopiStorage::WOPIFileInfo> _wopiInfo;
LockContext _lockCtx;
};