2023-03-04 12:24:01 -06:00
|
|
|
/* -*- 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"
|
2023-03-10 17:35:17 -06:00
|
|
|
#include <Storage.hpp>
|
2023-03-04 12:24:01 -06:00
|
|
|
#include "WebSocketHandler.hpp"
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
class RequestVettingStation
|
|
|
|
{
|
|
|
|
public:
|
2024-01-12 18:17:01 -06:00
|
|
|
RequestVettingStation(const std::string& id, const std::shared_ptr<WebSocketHandler>& ws,
|
2023-03-09 18:01:44 -06:00
|
|
|
const RequestDetails& requestDetails,
|
2023-03-04 12:24:01 -06:00
|
|
|
const std::shared_ptr<StreamSocket>& socket, unsigned mobileAppDocId)
|
2024-01-12 18:17:01 -06:00
|
|
|
: _id(id)
|
2023-03-04 12:24:01 -06:00
|
|
|
, _ws(ws)
|
|
|
|
, _requestDetails(requestDetails)
|
|
|
|
, _socket(socket)
|
|
|
|
, _mobileAppDocId(mobileAppDocId)
|
|
|
|
{
|
2023-05-21 19:58:46 -05:00
|
|
|
// Indicate to the client that document broker is searching.
|
2024-01-12 18:17:01 -06:00
|
|
|
static constexpr const char* const status = "statusindicator: find";
|
|
|
|
LOG_TRC("Sending to Client [" << status << ']');
|
2023-05-21 19:58:46 -05:00
|
|
|
_ws->sendMessage(status);
|
2023-03-04 12:24:01 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void logPrefix(std::ostream& os) const { os << '#' << _socket->getFD() << ": "; }
|
|
|
|
|
2023-03-09 18:01:44 -06:00
|
|
|
void handleRequest(SocketPoll& poll, SocketDisposition& disposition);
|
|
|
|
|
|
|
|
private:
|
|
|
|
void createDocBroker(const std::string& docKey, const std::string& url,
|
2023-03-10 17:35:17 -06:00
|
|
|
const Poco::URI& uriPublic, const bool isReadOnly,
|
|
|
|
Poco::JSON::Object::Ptr wopiInfo = nullptr);
|
2023-03-04 12:24:01 -06:00
|
|
|
|
2024-01-20 12:02:33 -06:00
|
|
|
#if !MOBILEAPP
|
2023-05-21 19:58:46 -05:00
|
|
|
void checkFileInfo(SocketPoll& poll, const std::string& url, const Poco::URI& uriPublic,
|
2023-05-21 21:31:29 -05:00
|
|
|
const std::string& docKey, bool isReadOnly, int redirectionLimit);
|
2024-01-20 12:02:33 -06:00
|
|
|
#endif //!MOBILEAPP
|
2023-05-21 19:58:46 -05:00
|
|
|
|
2023-09-17 16:24:16 -05:00
|
|
|
/// Send an error to the client and disconnect the socket.
|
|
|
|
static void sendErrorAndShutdown(const std::shared_ptr<WebSocketHandler>& ws,
|
2024-01-11 19:43:23 -06:00
|
|
|
const std::string& msg,
|
2023-09-17 16:24:16 -05:00
|
|
|
WebSocketHandler::StatusCodes statusCode);
|
|
|
|
|
2023-03-04 12:24:01 -06:00
|
|
|
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;
|
2023-03-10 17:35:17 -06:00
|
|
|
const unsigned _mobileAppDocId;
|
|
|
|
std::unique_ptr<WopiStorage::WOPIFileInfo> _wopiInfo;
|
|
|
|
LockContext _lockCtx;
|
2023-03-04 12:24:01 -06:00
|
|
|
};
|