CloudProvider.cpp 18.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*****************************************************************************
 * CloudProvider.cpp : implementation of CloudProvider
 *
 *****************************************************************************
 * Copyright (C) 2016-2016 VideoLAN
 *
 * Authors: Paweł Wegner <pawel.wegner95@gmail.com>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

#include "CloudProvider.h"

Paweł Wegner's avatar
Paweł Wegner committed
26
#include <json/json.h>
27
#include <cstring>
Paweł Wegner's avatar
Paweł Wegner committed
28
#include <fstream>
Paweł Wegner's avatar
Paweł Wegner committed
29
#include <sstream>
30

Paweł Wegner's avatar
Paweł Wegner committed
31 32
#include "Utility/Item.h"
#include "Utility/Utility.h"
33

Paweł Wegner's avatar
Paweł Wegner committed
34
#include "Request/CreateDirectoryRequest.h"
Paweł Wegner's avatar
Paweł Wegner committed
35
#include "Request/DeleteItemRequest.h"
Paweł Wegner's avatar
Paweł Wegner committed
36
#include "Request/DownloadFileRequest.h"
37
#include "Request/ExchangeCodeRequest.h"
Paweł Wegner's avatar
Paweł Wegner committed
38 39
#include "Request/GetItemDataRequest.h"
#include "Request/GetItemRequest.h"
Paweł Wegner's avatar
Paweł Wegner committed
40
#include "Request/GetItemUrlRequest.h"
41
#include "Request/ListDirectoryPageRequest.h"
Paweł Wegner's avatar
Paweł Wegner committed
42
#include "Request/ListDirectoryRequest.h"
Paweł Wegner's avatar
Paweł Wegner committed
43
#include "Request/MoveItemRequest.h"
44
#include "Request/RenameItemRequest.h"
Paweł Wegner's avatar
Paweł Wegner committed
45 46
#include "Request/UploadFileRequest.h"

Paweł Wegner's avatar
Paweł Wegner committed
47 48 49 50
#ifdef WITH_CRYPTOPP
#include "Utility/CryptoPP.h"
#endif

Paweł Wegner's avatar
Paweł Wegner committed
51 52 53 54
#ifdef WITH_CURL
#include "Utility/CurlHttp.h"
#endif

55 56 57 58
#ifdef WITH_MICROHTTPD
#include "Utility/MicroHttpdServer.h"
#endif

59 60
using namespace std::placeholders;

61 62
const std::string DEFAULT_STATE = "DEFAULT_STATE";

Paweł Wegner's avatar
Paweł Wegner committed
63 64 65 66 67 68 69 70 71
namespace {

class ListDirectoryCallback : public cloudstorage::IListDirectoryCallback {
 public:
  ListDirectoryCallback(cloudstorage::ListDirectoryCallback callback)
      : callback_(callback) {}

  void receivedItem(cloudstorage::IItem::Pointer) override {}

Paweł Wegner's avatar
Paweł Wegner committed
72 73
  void done(cloudstorage::EitherError<std::vector<cloudstorage::IItem::Pointer>>
                result) override {
Paweł Wegner's avatar
Paweł Wegner committed
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
    callback_(result);
  }

 private:
  cloudstorage::ListDirectoryCallback callback_;
};

class DownloadFileCallback : public cloudstorage::IDownloadFileCallback {
 public:
  DownloadFileCallback(const std::string& filename,
                       cloudstorage::DownloadFileCallback callback)
      : file_(filename, std::ios_base::out | std::ios_base::binary),
        callback_(callback) {}

  void receivedData(const char* data, uint32_t length) override {
    file_.write(data, length);
  }

92
  void done(cloudstorage::EitherError<void> e) override {
Paweł Wegner's avatar
Paweł Wegner committed
93
    file_.close();
Paweł Wegner's avatar
Paweł Wegner committed
94
    callback_(e);
Paweł Wegner's avatar
Paweł Wegner committed
95 96 97 98 99 100 101 102 103 104 105
  }

  void progress(uint32_t, uint32_t) override {}

 private:
  std::fstream file_;
  cloudstorage::DownloadFileCallback callback_;
};

class UploadFileCallback : public cloudstorage::IUploadFileCallback {
 public:
106
  UploadFileCallback(const std::string& path,
Paweł Wegner's avatar
Paweł Wegner committed
107
                     cloudstorage::UploadFileCallback callback)
108
      : file_(path, std::ios_base::in | std::ios_base::binary),
Paweł Wegner's avatar
Paweł Wegner committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
        callback_(callback) {
    file_.seekg(0, std::ios::end);
    size_ = file_.tellg();
    file_.seekg(std::ios::beg);
  }

  void reset() override {
    file_.clear();
    file_.seekg(std::ios::beg);
  }

  uint32_t putData(char* data, uint32_t maxlength) override {
    file_.read(data, maxlength);
    return file_.gcount();
  }

  uint64_t size() override { return size_; }

127
  void done(cloudstorage::EitherError<void> e) override { callback_(e); }
Paweł Wegner's avatar
Paweł Wegner committed
128 129 130 131 132 133 134 135 136 137 138

  void progress(uint32_t, uint32_t) override {}

 private:
  std::fstream file_;
  cloudstorage::UploadFileCallback callback_;
  uint64_t size_;
};

}  // namespace

139 140
namespace cloudstorage {

141
CloudProvider::CloudProvider(IAuth::Pointer auth)
142
    : auth_(std::move(auth)), http_() {}
143

Paweł Wegner's avatar
Paweł Wegner committed
144
void CloudProvider::initialize(InitData&& data) {
Paweł Wegner's avatar
Paweł Wegner committed
145
  auto lock = auth_lock();
Paweł Wegner's avatar
Paweł Wegner committed
146 147 148
  callback_ = std::move(data.callback_);
  crypto_ = std::move(data.crypto_engine_);
  http_ = std::move(data.http_engine_);
149
  http_server_ = std::move(data.http_server_);
150

Paweł Wegner's avatar
Paweł Wegner committed
151 152 153
  auto t = auth()->fromTokenString(data.token_);
  setWithHint(data.hints_, "access_token",
              [&t](std::string v) { t->token_ = v; });
154
  auth()->set_access_token(std::move(t));
155

Paweł Wegner's avatar
Paweł Wegner committed
156
  setWithHint(data.hints_, "client_id",
157
              [this](std::string v) { auth()->set_client_id(v); });
Paweł Wegner's avatar
Paweł Wegner committed
158
  setWithHint(data.hints_, "client_secret",
159
              [this](std::string v) { auth()->set_client_secret(v); });
160 161
  setWithHint(data.hints_, "redirect_uri",
              [this](std::string v) { auth()->set_redirect_uri(v); });
Paweł Wegner's avatar
Paweł Wegner committed
162 163
  setWithHint(data.hints_, "state",
              [this](std::string v) { auth()->set_state(v); });
164 165 166 167 168 169
  setWithHint(data.hints_, "login_page",
              [this](std::string v) { auth()->set_login_page(v); });
  setWithHint(data.hints_, "success_page",
              [this](std::string v) { auth()->set_success_page(v); });
  setWithHint(data.hints_, "error_page",
              [this](std::string v) { auth()->set_error_page(v); });
Paweł Wegner's avatar
Paweł Wegner committed
170 171

#ifdef WITH_CRYPTOPP
172
  if (!crypto_) crypto_ = util::make_unique<CryptoPP>();
Paweł Wegner's avatar
Paweł Wegner committed
173
#endif
Paweł Wegner's avatar
Paweł Wegner committed
174 175

#ifdef WITH_CURL
176
  if (!http_) http_ = util::make_unique<curl::CurlHttp>();
Paweł Wegner's avatar
Paweł Wegner committed
177 178
#endif

179 180 181 182 183
#ifdef WITH_MICROHTTPD
  if (!http_server_)
    http_server_ = util::make_unique<MicroHttpdServerFactory>();
#endif

184
  if (!http_) throw std::runtime_error("No http module specified.");
185 186
  if (!http_server_)
    throw std::runtime_error("No http server module specified.");
187
  if (auth()->state().empty()) auth()->set_state(DEFAULT_STATE);
188
  auth()->initialize(http(), http_server());
189 190
}

Paweł Wegner's avatar
Paweł Wegner committed
191 192
void CloudProvider::destroy() {}

193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
std::string ICloudProvider::serializeSession(const std::string& token,
                                             const Hints& hints) {
  Json::Value root_json;
  Json::Value hints_json;
  for (const auto& hint : hints) {
    hints_json[hint.first] = hint.second;
  }
  root_json["hints"] = hints_json;
  root_json["token"] = token;

  Json::FastWriter fastWriter;
  fastWriter.omitEndingLineFeed();
  return fastWriter.write(root_json);
}

bool ICloudProvider::deserializeSession(const std::string& serialized_data,
                                        std::string& token, Hints& hints) {
  std::string token_tmp;
  Hints hints_tmp;
212 213
  Json::Reader reader;
  Json::Value unserialized_json;
Paweł Wegner's avatar
Paweł Wegner committed
214 215

  if (!reader.parse(serialized_data, unserialized_json)) return false;
216 217 218
  try {
    for (const auto& key : unserialized_json["hints"]) {
      std::string hint_key = key.asString();
Paweł Wegner's avatar
Paweł Wegner committed
219
      hints_tmp[hint_key] = unserialized_json["hints"][hint_key].asString();
220 221
    }
    token_tmp = unserialized_json["token"].asString();
222
  } catch (const std::runtime_error&) {
223 224 225 226 227 228 229
    return false;
  }
  token = token_tmp;
  hints = hints_tmp;
  return true;
}

230
ICloudProvider::Hints CloudProvider::hints() const {
231
  return {{"access_token", access_token()}, {"state", auth()->state()}};
232 233
}

234
std::string CloudProvider::access_token() const {
Paweł Wegner's avatar
Paweł Wegner committed
235
  auto lock = auth_lock();
236
  if (auth()->access_token() == nullptr) return "";
237 238 239 240 241 242 243 244 245
  return auth()->access_token()->token_;
}

IAuth* CloudProvider::auth() const { return auth_.get(); }

std::string CloudProvider::authorizeLibraryUrl() const {
  return auth()->authorizeLibraryUrl();
}

246
std::string CloudProvider::token() const {
Paweł Wegner's avatar
Paweł Wegner committed
247
  auto lock = auth_lock();
248
  if (auth()->access_token() == nullptr) return "";
Paweł Wegner's avatar
Paweł Wegner committed
249 250 251
  return auth()->access_token()->refresh_token_;
}

252
IItem::Pointer CloudProvider::rootDirectory() const {
Paweł Wegner's avatar
Paweł Wegner committed
253
  return util::make_unique<Item>("/", "root", IItem::UnknownSize,
Paweł Wegner's avatar
Paweł Wegner committed
254
                                 IItem::UnknownTimeStamp,
Paweł Wegner's avatar
Paweł Wegner committed
255
                                 IItem::FileType::Directory);
256 257
}

258
ICloudProvider::IAuthCallback* CloudProvider::auth_callback() const {
Paweł Wegner's avatar
Paweł Wegner committed
259 260 261
  return callback_.get();
}

Paweł Wegner's avatar
Paweł Wegner committed
262 263
ICrypto* CloudProvider::crypto() const { return crypto_.get(); }

Paweł Wegner's avatar
Paweł Wegner committed
264 265
IHttp* CloudProvider::http() const { return http_.get(); }

266 267 268 269
IHttpServerFactory* CloudProvider::http_server() const {
  return http_server_.get();
}

270 271 272 273 274
bool CloudProvider::isSuccess(int code,
                              const IHttpRequest::HeaderParameters&) const {
  return IHttpRequest::isSuccess(code);
}

275
ICloudProvider::ExchangeCodeRequest::Pointer CloudProvider::exchangeCodeAsync(
276
    const std::string& code, ExchangeCodeCallback callback) {
277 278 279
  return std::make_shared<cloudstorage::ExchangeCodeRequest>(shared_from_this(),
                                                             code, callback)
      ->run();
280 281
}

Paweł Wegner's avatar
Paweł Wegner committed
282 283
ICloudProvider::ListDirectoryRequest::Pointer CloudProvider::listDirectoryAsync(
    IItem::Pointer item, IListDirectoryCallback::Pointer callback) {
284 285 286
  return std::make_shared<cloudstorage::ListDirectoryRequest>(
             shared_from_this(), std::move(item), std::move(callback))
      ->run();
287 288
}

Paweł Wegner's avatar
Paweł Wegner committed
289 290
ICloudProvider::GetItemRequest::Pointer CloudProvider::getItemAsync(
    const std::string& absolute_path, GetItemCallback callback) {
291 292 293
  return std::make_shared<cloudstorage::GetItemRequest>(shared_from_this(),
                                                        absolute_path, callback)
      ->run();
294 295
}

Paweł Wegner's avatar
Paweł Wegner committed
296
ICloudProvider::DownloadFileRequest::Pointer CloudProvider::downloadFileAsync(
297
    IItem::Pointer file, IDownloadFileCallback::Pointer callback, Range range) {
298
  return std::make_shared<cloudstorage::DownloadFileRequest>(
299
             shared_from_this(), std::move(file), std::move(callback), range,
300 301
             std::bind(&CloudProvider::downloadFileRequest, this, _1, _2))
      ->run();
Paweł Wegner's avatar
Paweł Wegner committed
302 303
}

Paweł Wegner's avatar
Paweł Wegner committed
304
ICloudProvider::UploadFileRequest::Pointer CloudProvider::uploadFileAsync(
Paweł Wegner's avatar
Paweł Wegner committed
305
    IItem::Pointer directory, const std::string& filename,
Paweł Wegner's avatar
Paweł Wegner committed
306
    IUploadFileCallback::Pointer callback) {
307 308 309 310
  return std::make_shared<cloudstorage::UploadFileRequest>(
             shared_from_this(), std::move(directory), filename,
             std::move(callback))
      ->run();
Paweł Wegner's avatar
Paweł Wegner committed
311 312
}

Paweł Wegner's avatar
Paweł Wegner committed
313 314
ICloudProvider::GetItemDataRequest::Pointer CloudProvider::getItemDataAsync(
    const std::string& id, GetItemDataCallback f) {
315 316 317
  return std::make_shared<cloudstorage::GetItemDataRequest>(shared_from_this(),
                                                            id, f)
      ->run();
318 319
}

Paweł Wegner's avatar
Paweł Wegner committed
320
void CloudProvider::authorizeRequest(IHttpRequest& r) const {
321 322 323
  r.setHeaderParameter("Authorization", "Bearer " + access_token());
}

324 325
bool CloudProvider::reauthorize(int code,
                                const IHttpRequest::HeaderParameters&) const {
Paweł Wegner's avatar
Paweł Wegner committed
326
  return IHttpRequest::isAuthorizationError(code);
327 328
}

329
bool CloudProvider::unpackCredentials(const std::string&) { return false; }
Paweł Wegner's avatar
Paweł Wegner committed
330

331
AuthorizeRequest::Pointer CloudProvider::authorizeAsync() {
332
  return std::make_shared<AuthorizeRequest>(shared_from_this());
Paweł Wegner's avatar
Paweł Wegner committed
333 334
}

Paweł Wegner's avatar
Paweł Wegner committed
335 336 337
std::unique_lock<std::mutex> CloudProvider::auth_lock() const {
  return std::unique_lock<std::mutex>(auth_mutex_);
}
338

339 340 341 342 343 344 345
void CloudProvider::setWithHint(const ICloudProvider::Hints& hints,
                                const std::string& name,
                                std::function<void(std::string)> f) const {
  auto it = hints.find(name);
  if (it != hints.end()) f(it->second);
}

Paweł Wegner's avatar
Paweł Wegner committed
346 347 348 349 350 351
std::string CloudProvider::getPath(const std::string& p) {
  std::string result = p;
  if (result.back() == '/') result.pop_back();
  return result.substr(0, result.find_last_of('/'));
}

352 353 354 355 356 357
std::string CloudProvider::getFilename(const std::string& path) {
  std::string result = path;
  if (result.back() == '/') result.pop_back();
  return result.substr(result.find_last_of('/') + 1);
}

Paweł Wegner's avatar
Paweł Wegner committed
358
std::pair<std::string, std::string> CloudProvider::credentialsFromString(
359
    const std::string& str) {
360 361 362 363 364 365 366 367
  Json::Value json;
  if (Json::Reader().parse(util::from_base64(str), json)) {
    std::string username = json["username"].asString();
    std::string password = json["password"].asString();
    return {username, password};
  } else {
    return {};
  }
368 369
}

Paweł Wegner's avatar
Paweł Wegner committed
370 371
ICloudProvider::DownloadFileRequest::Pointer CloudProvider::getThumbnailAsync(
    IItem::Pointer item, IDownloadFileCallback::Pointer callback) {
372
  return std::make_shared<cloudstorage::DownloadFileRequest>(
373
             shared_from_this(), item, std::move(callback), FullRange,
374 375
             std::bind(&CloudProvider::getThumbnailRequest, this, _1, _2))
      ->run();
376 377
}

Paweł Wegner's avatar
Paweł Wegner committed
378
ICloudProvider::DeleteItemRequest::Pointer CloudProvider::deleteItemAsync(
Paweł Wegner's avatar
Paweł Wegner committed
379
    IItem::Pointer item, DeleteItemCallback callback) {
380 381 382
  return std::make_shared<cloudstorage::DeleteItemRequest>(shared_from_this(),
                                                           item, callback)
      ->run();
Paweł Wegner's avatar
Paweł Wegner committed
383 384
}

Paweł Wegner's avatar
Paweł Wegner committed
385 386 387 388
ICloudProvider::CreateDirectoryRequest::Pointer
CloudProvider::createDirectoryAsync(IItem::Pointer parent,
                                    const std::string& name,
                                    CreateDirectoryCallback callback) {
389 390 391
  return std::make_shared<cloudstorage::CreateDirectoryRequest>(
             shared_from_this(), parent, name, callback)
      ->run();
Paweł Wegner's avatar
Paweł Wegner committed
392 393
}

Paweł Wegner's avatar
Paweł Wegner committed
394 395 396
ICloudProvider::MoveItemRequest::Pointer CloudProvider::moveItemAsync(
    IItem::Pointer source, IItem::Pointer destination,
    MoveItemCallback callback) {
397 398 399
  return std::make_shared<cloudstorage::MoveItemRequest>(
             shared_from_this(), source, destination, callback)
      ->run();
Paweł Wegner's avatar
Paweł Wegner committed
400 401
}

402 403
ICloudProvider::RenameItemRequest::Pointer CloudProvider::renameItemAsync(
    IItem::Pointer item, const std::string& name, RenameItemCallback callback) {
404 405 406
  return std::make_shared<cloudstorage::RenameItemRequest>(shared_from_this(),
                                                           item, name, callback)
      ->run();
407 408
}

Paweł Wegner's avatar
Paweł Wegner committed
409 410 411 412 413 414 415
ICloudProvider::GetItemUrlRequest::Pointer CloudProvider::getItemUrlAsync(
    IItem::Pointer i, GetItemUrlCallback callback) {
  return std::make_shared<cloudstorage::GetItemUrlRequest>(shared_from_this(),
                                                           i, callback)
      ->run();
}

416 417 418 419 420 421 422 423 424
ICloudProvider::ListDirectoryPageRequest::Pointer
CloudProvider::listDirectoryPageAsync(IItem::Pointer directory,
                                      const std::string& token,
                                      ListDirectoryPageCallback completed) {
  return std::make_shared<cloudstorage::ListDirectoryPageRequest>(
             shared_from_this(), directory, token, completed)
      ->run();
}

Paweł Wegner's avatar
Paweł Wegner committed
425 426
ICloudProvider::ListDirectoryRequest::Pointer CloudProvider::listDirectoryAsync(
    IItem::Pointer item, ListDirectoryCallback callback) {
427 428
  return listDirectoryAsync(
      item, util::make_unique<::ListDirectoryCallback>(callback));
Paweł Wegner's avatar
Paweł Wegner committed
429 430 431 432 433 434
}

ICloudProvider::DownloadFileRequest::Pointer CloudProvider::downloadFileAsync(
    IItem::Pointer item, const std::string& filename,
    DownloadFileCallback callback) {
  return downloadFileAsync(
435 436
      item, util::make_unique<::DownloadFileCallback>(filename, callback),
      FullRange);
Paweł Wegner's avatar
Paweł Wegner committed
437 438
}

439 440 441 442
ICloudProvider::DownloadFileRequest::Pointer CloudProvider::getThumbnailAsync(
    IItem::Pointer item, const std::string& filename,
    GetThumbnailCallback callback) {
  return getThumbnailAsync(
443
      item, util::make_unique<::DownloadFileCallback>(filename, callback));
444 445
}

Paweł Wegner's avatar
Paweł Wegner committed
446
ICloudProvider::UploadFileRequest::Pointer CloudProvider::uploadFileAsync(
447
    IItem::Pointer parent, const std::string& path, const std::string& filename,
Paweł Wegner's avatar
Paweł Wegner committed
448
    UploadFileCallback callback) {
449 450 451
  return uploadFileAsync(
      parent, filename,
      util::make_unique<::UploadFileCallback>(path, callback));
Paweł Wegner's avatar
Paweł Wegner committed
452 453
}

Paweł Wegner's avatar
Paweł Wegner committed
454 455
IHttpRequest::Pointer CloudProvider::getItemDataRequest(const std::string&,
                                                        std::ostream&) const {
456 457 458
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
459 460 461 462 463
IHttpRequest::Pointer CloudProvider::getItemUrlRequest(const IItem&,
                                                       std::ostream&) const {
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
464 465 466
IHttpRequest::Pointer CloudProvider::listDirectoryRequest(const IItem&,
                                                          const std::string&,
                                                          std::ostream&) const {
467 468 469
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
470 471 472 473
IHttpRequest::Pointer CloudProvider::uploadFileRequest(const IItem&,
                                                       const std::string&,
                                                       std::ostream&,
                                                       std::ostream&) const {
474 475 476
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
477 478
IHttpRequest::Pointer CloudProvider::downloadFileRequest(const IItem&,
                                                         std::ostream&) const {
479 480 481
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
482 483
IHttpRequest::Pointer CloudProvider::getThumbnailRequest(const IItem& i,
                                                         std::ostream&) const {
484 485
  const Item& item = static_cast<const Item&>(i);
  if (item.thumbnail_url().empty()) return nullptr;
Paweł Wegner's avatar
Paweł Wegner committed
486
  return http()->create(item.thumbnail_url(), "GET");
487 488
}

Paweł Wegner's avatar
Paweł Wegner committed
489 490
IHttpRequest::Pointer CloudProvider::deleteItemRequest(const IItem&,
                                                       std::ostream&) const {
Paweł Wegner's avatar
Paweł Wegner committed
491 492 493
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
494
IHttpRequest::Pointer CloudProvider::createDirectoryRequest(
Paweł Wegner's avatar
Paweł Wegner committed
495 496 497 498
    const IItem&, const std::string&, std::ostream&) const {
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
499 500
IHttpRequest::Pointer CloudProvider::moveItemRequest(const IItem&, const IItem&,
                                                     std::ostream&) const {
Paweł Wegner's avatar
Paweł Wegner committed
501 502 503
  return nullptr;
}

Paweł Wegner's avatar
Paweł Wegner committed
504 505 506
IHttpRequest::Pointer CloudProvider::renameItemRequest(const IItem&,
                                                       const std::string&,
                                                       std::ostream&) const {
Paweł Wegner's avatar
Paweł Wegner committed
507 508 509
  return nullptr;
}

510 511 512 513
IItem::Pointer CloudProvider::getItemDataResponse(std::istream&) const {
  return nullptr;
}

514 515 516 517 518 519
IItem::Pointer CloudProvider::renameItemResponse(const IItem&,
                                                 const std::string&,
                                                 std::istream& response) const {
  return getItemDataResponse(response);
}

520 521 522 523 524
IItem::Pointer CloudProvider::moveItemResponse(const IItem&, const IItem&,
                                               std::istream& response) const {
  return getItemDataResponse(response);
}

525 526
std::string CloudProvider::getItemUrlResponse(const IItem&,
                                              std::istream&) const {
Paweł Wegner's avatar
Paweł Wegner committed
527 528 529
  return "";
}

530
std::vector<IItem::Pointer> CloudProvider::listDirectoryResponse(
531
    const IItem&, std::istream&, std::string&) const {
532 533 534
  return {};
}

535 536 537
IItem::Pointer CloudProvider::createDirectoryResponse(
    std::istream& stream) const {
  return getItemDataResponse(stream);
Paweł Wegner's avatar
Paweł Wegner committed
538 539
}

540
}  // namespace cloudstorage