15
15
#include <QNetworkAccessManager>
16
16
#include <QNetworkReply>
17
17
#include <QNetworkRequest>
18
#include <unity/storage/common.h>
18
19
#include <unity/storage/provider/Exceptions.h>
19
#include <unity/storage/provider/metadata_keys.h>
21
21
using namespace std;
22
22
using namespace unity::storage::provider;
23
using namespace unity::storage::metadata;
23
24
using unity::storage::ItemType;
25
26
DavProvider::DavProvider()
30
31
DavProvider::~DavProvider() = default;
32
boost::future<ItemList> DavProvider::roots(Context const& ctx)
33
boost::future<ItemList> DavProvider::roots(
34
vector<string> const& metadata_keys, Context const& ctx)
36
Q_UNUSED(metadata_keys);
34
37
auto handler = new RootsHandler(*this, ctx);
35
38
return handler->get_future();
38
41
boost::future<tuple<ItemList,string>> DavProvider::list(
39
string const& item_id, string const& page_token, Context const& ctx)
42
string const& item_id, string const& page_token,
43
vector<string> const& metadata_keys, Context const& ctx)
45
Q_UNUSED(metadata_keys);
41
46
if (!page_token.empty())
43
48
throw InvalidArgumentException("Invalid paging token: " + page_token);
49
54
boost::future<ItemList> DavProvider::lookup(
50
string const& parent_id, string const& name, Context const& ctx)
55
string const& parent_id, string const& name,
56
vector<string> const& metadata_keys, Context const& ctx)
58
Q_UNUSED(metadata_keys);
52
59
string item_id = make_child_id(parent_id, name);
53
60
auto handler = new LookupHandler(*this, item_id, ctx);
54
61
return handler->get_future();
57
64
boost::future<Item> DavProvider::metadata(
58
string const& item_id, Context const& ctx)
65
string const& item_id, vector<string> const& metadata_keys,
68
Q_UNUSED(metadata_keys);
60
69
auto handler = new MetadataHandler(*this, item_id, ctx);
61
70
return handler->get_future();
64
73
boost::future<Item> DavProvider::create_folder(
65
string const& parent_id, string const& name, Context const& ctx)
74
string const& parent_id, string const& name,
75
vector<string> const& metadata_keys, Context const& ctx)
77
Q_UNUSED(metadata_keys);
67
78
auto handler = new CreateFolderHandler(*this, parent_id, name, ctx);
68
79
return handler->get_future();
71
82
boost::future<unique_ptr<UploadJob>> DavProvider::create_file(
72
83
string const& parent_id, string const& name, int64_t size,
73
string const& content_type, bool allow_overwrite, Context const& ctx)
84
string const& content_type, bool allow_overwrite,
85
vector<string> const& metadata_keys, Context const& ctx)
87
Q_UNUSED(metadata_keys);
75
88
string item_id = make_child_id(parent_id, name);
76
89
boost::promise<unique_ptr<UploadJob>> p;
77
90
p.set_value(unique_ptr<UploadJob>(new DavUploadJob(
82
95
boost::future<unique_ptr<UploadJob>> DavProvider::update(
83
96
string const& item_id, int64_t size, string const& old_etag,
97
vector<string> const& metadata_keys, Context const& ctx)
99
Q_UNUSED(metadata_keys);
86
100
boost::promise<unique_ptr<UploadJob>> p;
87
101
p.set_value(unique_ptr<UploadJob>(new DavUploadJob(
88
102
*this, item_id, size, string(), true, old_etag, ctx)));
92
106
boost::future<unique_ptr<DownloadJob>> DavProvider::download(
93
string const& item_id, Context const& ctx)
107
string const& item_id, string const& match_etag, Context const& ctx)
95
109
boost::promise<unique_ptr<DownloadJob>> p;
96
110
p.set_value(unique_ptr<DownloadJob>(new DavDownloadJob(
97
*this, item_id, string(), ctx)));
111
*this, item_id, match_etag, ctx)));
98
112
return p.get_future();
108
122
boost::future<Item> DavProvider::move(
109
123
string const& item_id, string const& new_parent_id, string const& new_name,
124
vector<string> const& metadata_keys, Context const& ctx)
114
128
boost::future<Item> DavProvider::copy(
115
129
string const& item_id, string const& new_parent_id, string const& new_name,
130
vector<string> const& metadata_keys, Context const& ctx)