Merge lp:~marcustomlinson/storage-framework/fix-for-dev-ppa into lp:storage-framework
- fix-for-dev-ppa
- Merge into trunk
Proposed by
Marcus Tomlinson
Status: | Superseded |
---|---|
Proposed branch: | lp:~marcustomlinson/storage-framework/fix-for-dev-ppa |
Merge into: | lp:storage-framework |
Diff against target: |
17230 lines (+15106/-1070) 185 files modified
.bzr-builddeb/default.conf (+2/-0) CMakeLists.txt (+43/-2) data/build-docs.sh (+32/-0) data/metadata-types.yaml (+31/-0) data/provider.xml (+256/-0) data/registry.xml (+35/-0) debian/changelog (+1/-1) debian/control (+66/-2) debian/copyright (+19/-0) debian/libstorage-framework-provider-1-0.install (+1/-0) debian/libstorage-framework-qt-client-1-0.install (+1/-0) debian/libstorage-framework-qt-local-client-1-0.install (+1/-0) debian/source/format (+1/-0) debian/storage-framework-client-dev.install (+3/-0) debian/storage-framework-provider-dev.install (+3/-0) demo/CMakeLists.txt (+1/-0) demo/provider_test/CMakeLists.txt (+5/-0) demo/provider_test/provider-test.cpp (+311/-0) demo/provider_test/test-client.py (+160/-0) include/CMakeLists.txt (+3/-0) include/unity/storage/CMakeLists.txt (+11/-1) include/unity/storage/client/Account.h (+0/-50) include/unity/storage/client/AccountsResult.h (+0/-35) include/unity/storage/client/CreateResult.h (+0/-33) include/unity/storage/client/DestroyResult.h (+0/-33) include/unity/storage/client/Directory.h (+0/-82) include/unity/storage/client/DownloadResult.h (+0/-40) include/unity/storage/client/Downloader.h (+0/-86) include/unity/storage/client/File.h (+0/-59) include/unity/storage/client/Item.h (+0/-74) include/unity/storage/client/IterationResult.h (+0/-33) include/unity/storage/client/MetadataResult.h (+0/-49) include/unity/storage/client/ParentResult.h (+0/-33) include/unity/storage/client/Root.h (+0/-44) include/unity/storage/client/Runtime.h (+0/-39) include/unity/storage/client/UploadResult.h (+0/-40) include/unity/storage/client/Uploader.h (+0/-77) include/unity/storage/client/Variant.h (+0/-236) include/unity/storage/common.h (+41/-0) include/unity/storage/internal/ItemMetadata.h (+48/-0) include/unity/storage/provider/CMakeLists.txt (+5/-0) include/unity/storage/provider/Credentials.h (+62/-0) include/unity/storage/provider/DownloadJob.h (+68/-0) include/unity/storage/provider/ProviderBase.h (+110/-0) include/unity/storage/provider/Server.h (+70/-0) include/unity/storage/provider/TempfileUploadJob.h (+53/-0) include/unity/storage/provider/UploadJob.h (+68/-0) include/unity/storage/provider/internal/AccountData.h (+88/-0) include/unity/storage/provider/internal/DBusPeerCache.h (+80/-0) include/unity/storage/provider/internal/DownloadJobImpl.h (+78/-0) include/unity/storage/provider/internal/Handler.h (+82/-0) include/unity/storage/provider/internal/MainLoopExecutor.h (+84/-0) include/unity/storage/provider/internal/PendingJobs.h (+80/-0) include/unity/storage/provider/internal/ProviderInterface.h (+87/-0) include/unity/storage/provider/internal/ServerImpl.h (+73/-0) include/unity/storage/provider/internal/TempfileUploadJobImpl.h (+63/-0) include/unity/storage/provider/internal/UploadJobImpl.h (+78/-0) include/unity/storage/provider/internal/dbusmarshal.h (+44/-0) include/unity/storage/qt/CMakeLists.txt (+1/-0) include/unity/storage/qt/client/Account.h (+108/-0) include/unity/storage/qt/client/CMakeLists.txt (+15/-0) include/unity/storage/qt/client/Downloader.h (+138/-0) include/unity/storage/qt/client/Exceptions.h (+141/-0) include/unity/storage/qt/client/File.h (+105/-0) include/unity/storage/qt/client/Folder.h (+123/-0) include/unity/storage/qt/client/Item.h (+210/-0) include/unity/storage/qt/client/Root.h (+92/-0) include/unity/storage/qt/client/Runtime.h (+108/-0) include/unity/storage/qt/client/Uploader.h (+135/-0) include/unity/storage/qt/client/internal/AccountBase.h (+71/-0) include/unity/storage/qt/client/internal/DownloaderBase.h (+63/-0) include/unity/storage/qt/client/internal/FileBase.h (+53/-0) include/unity/storage/qt/client/internal/FolderBase.h (+53/-0) include/unity/storage/qt/client/internal/ItemBase.h (+92/-0) include/unity/storage/qt/client/internal/RootBase.h (+69/-0) include/unity/storage/qt/client/internal/RuntimeBase.h (+69/-0) include/unity/storage/qt/client/internal/UploaderBase.h (+66/-0) include/unity/storage/qt/client/internal/boost_filesystem.h (+29/-0) include/unity/storage/qt/client/internal/local_client/AccountImpl.h (+61/-0) include/unity/storage/qt/client/internal/local_client/DownloaderImpl.h (+118/-0) include/unity/storage/qt/client/internal/local_client/FileImpl.h (+55/-0) include/unity/storage/qt/client/internal/local_client/FolderImpl.h (+56/-0) include/unity/storage/qt/client/internal/local_client/ItemImpl.h (+79/-0) include/unity/storage/qt/client/internal/local_client/RootImpl.h (+59/-0) include/unity/storage/qt/client/internal/local_client/RuntimeImpl.h (+51/-0) include/unity/storage/qt/client/internal/local_client/UploaderImpl.h (+131/-0) include/unity/storage/qt/client/internal/local_client/tmpfile-prefix.h (+21/-0) include/unity/storage/qt/client/internal/make_future.h (+97/-0) include/unity/storage/qt/client/internal/remote_client/AccountImpl.h (+71/-0) include/unity/storage/qt/client/internal/remote_client/DownloaderImpl.h (+76/-0) include/unity/storage/qt/client/internal/remote_client/FileImpl.h (+61/-0) include/unity/storage/qt/client/internal/remote_client/FolderImpl.h (+56/-0) include/unity/storage/qt/client/internal/remote_client/Handler.h (+100/-0) include/unity/storage/qt/client/internal/remote_client/HandlerBase.h (+75/-0) include/unity/storage/qt/client/internal/remote_client/ItemImpl.h (+75/-0) include/unity/storage/qt/client/internal/remote_client/RootImpl.h (+68/-0) include/unity/storage/qt/client/internal/remote_client/RuntimeImpl.h (+74/-0) include/unity/storage/qt/client/internal/remote_client/UploaderImpl.h (+79/-0) include/unity/storage/qt/client/internal/remote_client/dbusmarshal.h (+46/-0) include/unity/storage/visibility.h (+22/-0) src/CMakeLists.txt (+3/-1) src/client/CMakeLists.txt (+0/-1) src/common/CMakeLists.txt (+1/-0) src/common/internal/CMakeLists.txt (+4/-0) src/provider/CMakeLists.txt (+80/-0) src/provider/DownloadJob.cpp (+79/-0) src/provider/ProviderBase.cpp (+36/-0) src/provider/Server.cpp (+52/-0) src/provider/TempfileUploadJob.cpp (+50/-0) src/provider/UploadJob.cpp (+74/-0) src/provider/bus.xml (+9/-0) src/provider/internal/AccountData.cpp (+158/-0) src/provider/internal/DBusPeerCache.cpp (+195/-0) src/provider/internal/DownloadJobImpl.cpp (+153/-0) src/provider/internal/Handler.cpp (+109/-0) src/provider/internal/MainLoopExecutor.cpp (+111/-0) src/provider/internal/PendingJobs.cpp (+206/-0) src/provider/internal/ProviderInterface.cpp (+360/-0) src/provider/internal/ServerImpl.cpp (+97/-0) src/provider/internal/TempfileUploadJobImpl.cpp (+91/-0) src/provider/internal/UploadJobImpl.cpp (+140/-0) src/provider/internal/dbusmarshal.cpp (+77/-0) src/provider/storage-framework-provider.pc.in (+5/-0) src/qt/CMakeLists.txt (+1/-0) src/qt/client/Account.cpp (+72/-0) src/qt/client/CMakeLists.txt (+130/-0) src/qt/client/Downloader.cpp (+62/-0) src/qt/client/Exceptions.cpp (+145/-0) src/qt/client/File.cpp (+61/-0) src/qt/client/Folder.cpp (+65/-0) src/qt/client/Item.cpp (+111/-0) src/qt/client/Root.cpp (+64/-0) src/qt/client/Runtime.cpp (+70/-0) src/qt/client/Uploader.cpp (+62/-0) src/qt/client/internal/AccountBase.cpp (+63/-0) src/qt/client/internal/CMakeLists.txt (+5/-0) src/qt/client/internal/DownloaderBase.cpp (+48/-0) src/qt/client/internal/FileBase.cpp (+43/-0) src/qt/client/internal/FolderBase.cpp (+48/-0) src/qt/client/internal/ItemBase.cpp (+82/-0) src/qt/client/internal/RootBase.cpp (+57/-0) src/qt/client/internal/RuntimeBase.cpp (+52/-0) src/qt/client/internal/UploaderBase.cpp (+48/-0) src/qt/client/internal/local_client/AccountImpl.cpp (+145/-0) src/qt/client/internal/local_client/CMakeLists.txt (+16/-0) src/qt/client/internal/local_client/DownloaderImpl.cpp (+310/-0) src/qt/client/internal/local_client/FileImpl.cpp (+144/-0) src/qt/client/internal/local_client/FolderImpl.cpp (+241/-0) src/qt/client/internal/local_client/ItemImpl.cpp (+447/-0) src/qt/client/internal/local_client/RootImpl.cpp (+192/-0) src/qt/client/internal/local_client/RuntimeImpl.cpp (+109/-0) src/qt/client/internal/local_client/Runtime_create.cpp (+49/-0) src/qt/client/internal/local_client/UploaderImpl.cpp (+383/-0) src/qt/client/internal/remote_client/AccountImpl.cpp (+117/-0) src/qt/client/internal/remote_client/CMakeLists.txt (+15/-0) src/qt/client/internal/remote_client/DownloaderImpl.cpp (+112/-0) src/qt/client/internal/remote_client/FileImpl.cpp (+131/-0) src/qt/client/internal/remote_client/FolderImpl.cpp (+199/-0) src/qt/client/internal/remote_client/HandlerBase.cpp (+65/-0) src/qt/client/internal/remote_client/ItemImpl.cpp (+225/-0) src/qt/client/internal/remote_client/RootImpl.cpp (+117/-0) src/qt/client/internal/remote_client/RuntimeImpl.cpp (+146/-0) src/qt/client/internal/remote_client/Runtime_create.cpp (+47/-0) src/qt/client/internal/remote_client/UploaderImpl.cpp (+120/-0) src/qt/client/internal/remote_client/dbusmarshal.cpp (+126/-0) src/qt/client/storage-framework-qt-client.pc.in (+6/-0) src/qt/client/storage-framework-qt-local-client.pc.in (+6/-0) tests/CMakeLists.txt (+7/-1) tests/copyright/CMakeLists.txt (+2/-3) tests/copyright/check_copyright.sh (+1/-1) tests/debian-version/CMakeLists.txt (+4/-0) tests/debian-version/check-debian-version.sh (+33/-0) tests/headers/CMakeLists.txt (+13/-12) tests/headers/check_public_headers.py (+12/-2) tests/local-client/CMakeLists.txt (+15/-0) tests/local-client/local-client_test.cpp (+946/-0) tests/remote-client/CMakeLists.txt (+19/-0) tests/remote-client/remote-client_test.cpp (+1052/-0) tests/testsetup.h.in (+4/-0) tests/utils/CMakeLists.txt (+9/-0) tests/utils/DBusEnvironment.cpp (+79/-0) tests/utils/DBusEnvironment.h (+48/-0) tests/utils/com.ubuntu.OnlineAccounts.Manager.xml (+153/-0) tests/utils/fake-online-accounts-daemon.py (+200/-0) tools/create_globalheader.py (+42/-0) |
To merge this branch: | bzr merge lp:~marcustomlinson/storage-framework/fix-for-dev-ppa |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Unity API Team | Pending | ||
Review via email: mp+300752@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-07-21.
Commit message
Fix to get storage-framework building in the dev-build-4 PPA
Description of the change
To post a comment you must log in.
Revision history for this message
Marcus Tomlinson (marcustomlinson) wrote : | # |
- 29. By Michi Henning
-
Merged lp:~michihenning/storage-framework/fix-version-typo:
Fixed wrong version comparison for boost. - 30. By Marcus Tomlinson
-
Fix for building in dev PPA
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === added directory '.bzr-builddeb' |
2 | === added file '.bzr-builddeb/default.conf' |
3 | --- .bzr-builddeb/default.conf 1970-01-01 00:00:00 +0000 |
4 | +++ .bzr-builddeb/default.conf 2016-07-21 12:22:21 +0000 |
5 | @@ -0,0 +1,2 @@ |
6 | +[BUILDDEB] |
7 | +split = True |
8 | |
9 | === modified file 'CMakeLists.txt' |
10 | --- CMakeLists.txt 2016-04-20 01:56:37 +0000 |
11 | +++ CMakeLists.txt 2016-07-21 12:22:21 +0000 |
12 | @@ -4,9 +4,23 @@ |
13 | set(LOCAL_INSTALL "ON") |
14 | endif() |
15 | |
16 | -project(storage-framework C CXX) |
17 | - |
18 | cmake_minimum_required(VERSION 3.0.2) |
19 | +project(storage-framework VERSION "0.1" LANGUAGES C CXX) |
20 | + |
21 | +# These variables should be incremented when we wish to create a new |
22 | +# source incompatible version of the the library where users of the |
23 | +# old API could will not compile against the new one. It is not |
24 | +# necessary to increment this for ABI breaks that are source compatible. |
25 | +set(SF_PROVIDER_API_VERSION "1") |
26 | +set(SF_CLIENT_API_VERSION "1") |
27 | + |
28 | +# These two should be incremented when the ABI changes. |
29 | +set(SF_PROVIDER_SOVERSION "0") |
30 | +set(SF_CLIENT_SOVERSION "0") |
31 | + |
32 | +set(SF_PROVIDER_LIBVERSION "${SF_PROVIDER_SOVERSION}.${PROJECT_VERSION}") |
33 | +set(SF_CLIENT_LIBVERSION "${SF_CLIENT_SOVERSION}.${PROJECT_VERSION}") |
34 | + |
35 | |
36 | string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lower case |
37 | |
38 | @@ -16,6 +30,12 @@ |
39 | message(FATAL_ERROR "Invalid CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}\nValid types are: ${ACCEPTED_BUILD_TYPES}") |
40 | endif() |
41 | |
42 | +# Ensure that generated files can be linked with. |
43 | +set(CMAKE_INCLUDE_CURRENT_DIR ON) |
44 | + |
45 | +include_directories(include) |
46 | +include_directories(${CMAKE_BINARY_DIR}/include) # For generated headers |
47 | + |
48 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++11 -Wall -pedantic -Wextra -fvisibility=hidden") |
49 | |
50 | # Some additional warnings not included by the general flags set above. |
51 | @@ -79,11 +99,32 @@ |
52 | |
53 | include(EnableCoverageReport) |
54 | |
55 | +include(GNUInstallDirs) |
56 | + |
57 | +find_package(Boost COMPONENTS filesystem system thread REQUIRED) |
58 | +find_package(Qt5Concurrent REQUIRED) |
59 | +find_package(Qt5Core REQUIRED) |
60 | +find_package(Qt5DBus REQUIRED) |
61 | +find_package(Qt5Network REQUIRED) |
62 | +find_package(Qt5Test REQUIRED) |
63 | + |
64 | +include(FindPkgConfig) |
65 | +pkg_check_modules(APPARMOR_DEPS REQUIRED libapparmor) |
66 | +pkg_check_modules(GLIB_DEPS REQUIRED glib-2.0) |
67 | +pkg_check_modules(ONLINEACCOUNTS_DEPS REQUIRED OnlineAccountsQt) |
68 | + |
69 | +add_definitions(-DQT_NO_KEYWORDS) |
70 | + |
71 | +add_subdirectory(include) |
72 | add_subdirectory(src) |
73 | add_subdirectory(tests) |
74 | +add_subdirectory(demo) |
75 | |
76 | enable_coverage_report( |
77 | TARGETS |
78 | + qt-client-lib-common |
79 | + storage-framework-qt-client |
80 | + storage-framework-qt-local-client |
81 | FILTER |
82 | ${CMAKE_SOURCE_DIR}/tests/* |
83 | ${CMAKE_BINARY_DIR}/* |
84 | |
85 | === added directory 'data' |
86 | === added file 'data/build-docs.sh' |
87 | --- data/build-docs.sh 1970-01-01 00:00:00 +0000 |
88 | +++ data/build-docs.sh 2016-07-21 12:22:21 +0000 |
89 | @@ -0,0 +1,32 @@ |
90 | +#!/bin/bash |
91 | + |
92 | +# |
93 | +# Copyright (C) 2016 Canonical Ltd |
94 | +# |
95 | +# This program is free software: you can redistribute it and/or modify |
96 | +# it under the terms of the GNU Lesser General Public License version 3 as |
97 | +# published by the Free Software Foundation. |
98 | +# |
99 | +# This program is distributed in the hope that it will be useful, |
100 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
101 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
102 | +# GNU Lesser General Public License for more details. |
103 | +# |
104 | +# You should have received a copy of the GNU Lesser General Public License |
105 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
106 | +# |
107 | +# Authors: James Henstridge <james.henstridge@canonical.com> |
108 | +# |
109 | + |
110 | +set -e |
111 | + |
112 | +mkdir doc-temp || true |
113 | +cd doc-temp |
114 | + |
115 | +gdbus-codegen --generate-docbook=docbook ../registry.xml ../provider.xml |
116 | + |
117 | +find . -name "docbook*.xml" -exec docbook2x-texi {} \; |
118 | + |
119 | +find . -name "com.canonical.*.texi" -exec texi2pdf --quiet {} \; |
120 | + |
121 | +pdfunite com.canonical.*.pdf ../dbus-interface.pdf |
122 | |
123 | === added file 'data/metadata-types.yaml' |
124 | --- data/metadata-types.yaml 1970-01-01 00:00:00 +0000 |
125 | +++ data/metadata-types.yaml 2016-07-21 12:22:21 +0000 |
126 | @@ -0,0 +1,31 @@ |
127 | +# Name that should be shown to the user |
128 | +display-name: string |
129 | + |
130 | +# Whether there is data associated with this node |
131 | +has-document: boolean |
132 | + |
133 | +# If there is data, how much? In bytes |
134 | +document-size: uint64 |
135 | + |
136 | +# When was it last modified? |
137 | +modification-time: date |
138 | + |
139 | +# If there's a thumbnail, what is its document id |
140 | +thumbnail: document-id |
141 | + |
142 | +# What are the MIME types of the data |
143 | +mimetype: string-list |
144 | + |
145 | +# Is there a copy of the document local? |
146 | +document-local: boolean |
147 | + |
148 | +# Whether there is a copy on the service we're exporting |
149 | +# to. Mostly useful for content originating locally to |
150 | +# ensure it has been uploaded. |
151 | +copy-on-service: boolean |
152 | + |
153 | +###### |
154 | +# NOTE: These are the default entries that are defined, various |
155 | +# backends can provide their own metadata keys in the x- namespace. |
156 | +# That can then be supported by their libraries or developer docs. |
157 | +###### |
158 | |
159 | === added file 'data/provider.xml' |
160 | --- data/provider.xml 1970-01-01 00:00:00 +0000 |
161 | +++ data/provider.xml 2016-07-21 12:22:21 +0000 |
162 | @@ -0,0 +1,256 @@ |
163 | +<?xml version="1.0" encoding="UTF-8" ?> |
164 | +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> |
165 | +<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> |
166 | + <!-- |
167 | + com.canonical.StorageFramework.Provider: |
168 | + @short_description: Interface providing access to a storage account |
169 | + |
170 | + For methods dealing with metadata, the representation |
171 | + "(ssssia{sv})" is used, where the struct members are: |
172 | + - item_id |
173 | + - parent_id |
174 | + - title |
175 | + - etag |
176 | + - type (enum: file, folder, root) |
177 | + - metadata |
178 | + --> |
179 | + <interface name="com.canonical.StorageFramework.Provider"> |
180 | + <!-- |
181 | + Roots: |
182 | + @short_description: Get the list of roots for the storage account |
183 | + @roots: Returned list of roots. |
184 | + |
185 | + Returns the list of top level root items provided by the |
186 | + storage account. For providers that expose a single hierarchy |
187 | + of files, this list will contain a single item. |
188 | + --> |
189 | + <method name="Roots"> |
190 | + <arg type="a(ssssia{sv})" name="roots" direction="out"/> |
191 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList<unity::storage::internal::ItemMetadata>"/> |
192 | + </method> |
193 | + |
194 | + <!-- |
195 | + List: |
196 | + @short_description: list the children of the given folder |
197 | + @item_id: the ID identifying the folder |
198 | + @page_token: if not empty, return the page of results identified by this token. |
199 | + @children: returned list of children |
200 | + @next_token: if not empty, a token that can be used to request more results. |
201 | + |
202 | + Lists the contents of the folder identified by the given ID. |
203 | + If the folder contains many children, a subset of results may |
204 | + be returned together with a token that can be used in a |
205 | + subsequent List call to request more results. |
206 | + --> |
207 | + <method name="List"> |
208 | + <arg type="s" name="item_id" direction="in"/> |
209 | + <arg type="s" name="page_token" direction="in"/> |
210 | + <arg type="a(ssssia{sv})" name="children" direction="out"/> |
211 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList<unity::storage::internal::ItemMetadata>"/> |
212 | + <arg type="s" name="next_token" direction="out"/> |
213 | + </method> |
214 | + |
215 | + <!-- |
216 | + Lookup: |
217 | + @short_description: lookup a child in a folder by name |
218 | + @parent_id: the ID of the parent folder |
219 | + @name: the name of the child |
220 | + @items: the matching items in the folder |
221 | + --> |
222 | + <method name="Lookup"> |
223 | + <arg type="s" name="parent_id" direction="in"/> |
224 | + <arg type="s" name="name" direction="in"/> |
225 | + <arg type="a(ssssia{sv})" name="items" direction="out"/> |
226 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QList<unity::storage::internal::ItemMetadata>"/> |
227 | + </method> |
228 | + |
229 | + <!-- |
230 | + Metadata: |
231 | + @short_description: get metadata for an item |
232 | + @item_id: the ID of the item |
233 | + @metadata: the item metadata |
234 | + --> |
235 | + <method name="Metadata"> |
236 | + <arg type="s" name="item_id" direction="in"/> |
237 | + <arg type="(ssssia{sv})" name="metadata" direction="out"/> |
238 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="unity::storage::internal::ItemMetadata"/> |
239 | + </method> |
240 | + |
241 | + <!-- |
242 | + CreateFolder: |
243 | + @short_description: create a new folder |
244 | + @parent_id: the ID of the parent folder |
245 | + @name: the name of the new folder |
246 | + @metadata: the metadata for the new folder |
247 | + --> |
248 | + <method name="CreateFolder"> |
249 | + <arg type="s" name="parent_id" direction="in"/> |
250 | + <arg type="s" name="name" direction="in"/> |
251 | + <arg type="(ssssia{sv})" name="metadata" direction="out"/> |
252 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="unity::storage::internal::ItemMetadata"/> |
253 | + </method> |
254 | + |
255 | + <!-- |
256 | + CreateFile: |
257 | + @short_description: create a new file |
258 | + @parent_id: the ID of the parent folder |
259 | + @name: the name of the new file |
260 | + @content_type: the content type of the new file |
261 | + @allow_overwrite: if false, the file creation will fail if it |
262 | + would overwrite an existing file. |
263 | + @upload_id: the identifier for this upload job |
264 | + @file_descriptor: a file descriptor to write the file contents to |
265 | + |
266 | + Begin the process of uploading a file. To complete the |
267 | + process, the application should write the file data to the |
268 | + provided file descriptor, close it, and then call |
269 | + FinishUpload. |
270 | + --> |
271 | + <method name="CreateFile"> |
272 | + <arg type="s" name="parent_id" direction="in"/> |
273 | + <arg type="s" name="name" direction="in"/> |
274 | + <arg type="s" name="content_type" direction="in"/> |
275 | + <arg type="b" name="allow_overwrite" direction="in"/> |
276 | + <arg type="s" name="upload_id" direction="out"/> |
277 | + <arg type="h" name="file_descriptor" direction="out"/> |
278 | + </method> |
279 | + |
280 | + <!-- |
281 | + Update: |
282 | + @short_description: update the contents of an existing file |
283 | + @item_id: the ID of the file |
284 | + @old_etag: if not empty, the expected etag of the old version |
285 | + of the file. |
286 | + @upload_id: the identifier for this upload job |
287 | + @file_descriptor: a file descriptor to write the file contents to |
288 | + |
289 | + Begin the process of updating an existing file. Like with |
290 | + CreateFile, the application must write the file contents to |
291 | + the provided file descriptor, close it, and call |
292 | + FinishUpload. |
293 | + |
294 | + If old_etag is not empty, then the update will only succeed if |
295 | + the current version of the file matches the given etag. This |
296 | + allows for lockless read-modify-update operations that detect |
297 | + other writers. |
298 | + --> |
299 | + <method name="Update"> |
300 | + <arg type="s" name="item_id" direction="in"/> |
301 | + <arg type="s" name="old_etag" direction="in"/> |
302 | + <arg type="s" name="upload_id" direction="out"/> |
303 | + <arg type="h" name="file_descriptor" direction="out"/> |
304 | + </method> |
305 | + |
306 | + <!-- |
307 | + FinishUpload: |
308 | + @short_description: finish a CreateFile or Update job |
309 | + @upload_id: the identifier for this upload |
310 | + @metadata: the metadata for the file after the upload |
311 | + completes. |
312 | + |
313 | + Finish off an upload job (whether it is creating a new file or |
314 | + updating an existing one). The application is expected to |
315 | + have closed the file descriptor associated with its end of the |
316 | + upload before calling this, and an error will be returned if |
317 | + it remains open. |
318 | + --> |
319 | + <method name="FinishUpload"> |
320 | + <arg type="s" name="upload_id" direction="in"/> |
321 | + <arg type="(ssssia{sv})" name="metadata" direction="out"/> |
322 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="unity::storage::internal::ItemMetadata"/> |
323 | + </method> |
324 | + |
325 | + <!-- |
326 | + CancelUpload: |
327 | + @short_description: cancel an in progress upload job. |
328 | + @upload_id: the identifier for this upload |
329 | + |
330 | + Cancel an in-progress upload job. This will release any |
331 | + resources allocated as part of the upload, and may also be |
332 | + called while a FinishUpload call is in progress (although it |
333 | + might not have an effect). |
334 | + |
335 | + If an application drops off the bus during an upload, the |
336 | + storage provider will act as if an implicit CancelUpload |
337 | + method call occurred. |
338 | + --> |
339 | + <method name="CancelUpload"> |
340 | + <arg type="s" name="upload_id" direction="in"/> |
341 | + </method> |
342 | + |
343 | + <!-- |
344 | + Download: |
345 | + @short_description: download the contents of a file. |
346 | + @item_id: the ID for the file |
347 | + @download_id: an identifier for the download |
348 | + @file_descriptor: a file descriptor used to read the contents |
349 | + |
350 | + Start downloading the contents of a file. The provided file |
351 | + descriptor will be closed when the end of file is reached. |
352 | + The application can check for errors in the download (e.g. if |
353 | + the file was truncated) with the FinishDownload method. |
354 | + |
355 | + The application can cancel the download by closing the file |
356 | + descriptor early. |
357 | + --> |
358 | + <method name="Download"> |
359 | + <arg type="s" name="item_id" direction="in"/> |
360 | + <arg type="s" name="download_id" direction="out"/> |
361 | + <arg type="h" name="file_descriptor" direction="out"/> |
362 | + </method> |
363 | + |
364 | + <!-- |
365 | + FinishDownload: |
366 | + @short_description: Finish a download and check for errors |
367 | + @download_id: the identifier for the download |
368 | + --> |
369 | + <method name="FinishDownload"> |
370 | + <arg type="s" name="download_id" direction="in"/> |
371 | + </method> |
372 | + |
373 | + <!-- |
374 | + Delete: |
375 | + @short_description: delete an item from storage |
376 | + @item_id: the ID for the item |
377 | + |
378 | + Delete an item from storage. If the item is a folder, then |
379 | + all children will be deleted too. |
380 | + --> |
381 | + <method name="Delete"> |
382 | + <arg type="s" name="item_id" direction="in"/> |
383 | + </method> |
384 | + |
385 | + <!-- |
386 | + Move: |
387 | + @short_description: move an item to a new location |
388 | + @item_id: the ID for the item |
389 | + @new_parent_id: the ID for the new parent folder |
390 | + @new_name: the new name for the item |
391 | + @metadata: the metadata for the file in the new location |
392 | + --> |
393 | + <method name="Move"> |
394 | + <arg type="s" name="item_id" direction="in"/> |
395 | + <arg type="s" name="new_parent_id" direction="in"/> |
396 | + <arg type="s" name="new_name" direction="in"/> |
397 | + <arg type="(ssssia{sv})" name="metadata" direction="out"/> |
398 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="unity::storage::internal::ItemMetadata"/> |
399 | + </method> |
400 | + |
401 | + <!-- |
402 | + Copy: |
403 | + @short_description: copy an item to a new location |
404 | + @item_id: the ID for the item |
405 | + @new_parent_id: the ID for the new parent folder |
406 | + @new_name: the new name for the item |
407 | + @metadata: the metadata for the file in the new location |
408 | + --> |
409 | + <method name="Copy"> |
410 | + <arg type="s" name="item_id" direction="in"/> |
411 | + <arg type="s" name="new_parent_id" direction="in"/> |
412 | + <arg type="s" name="new_name" direction="in"/> |
413 | + <arg type="(ssssia{sv})" name="metadata" direction="out"/> |
414 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="unity::storage::internal::ItemMetadata"/> |
415 | + </method> |
416 | + |
417 | + </interface> |
418 | +</node> |
419 | |
420 | === added file 'data/registry.xml' |
421 | --- data/registry.xml 1970-01-01 00:00:00 +0000 |
422 | +++ data/registry.xml 2016-07-21 12:22:21 +0000 |
423 | @@ -0,0 +1,35 @@ |
424 | +<?xml version="1.0" encoding="UTF-8" ?> |
425 | +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> |
426 | +<node xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd"> |
427 | + <!-- |
428 | + com.canonical.StorageFramework.Registry: |
429 | + @short_description: Interface to query the backend registry |
430 | + |
431 | + Inteface to query the repository of backends that are |
432 | + available. |
433 | + --> |
434 | + <interface name="com.canonical.StorageFramework.Registry"> |
435 | + |
436 | + <!-- |
437 | + GetBackend: |
438 | + @short_description: request access to a storage account |
439 | + @service_id: if not empty, restrict results to accounts |
440 | + matching this service ID. |
441 | + @bus_name: the bus name of the storage provider |
442 | + @path: the object path of the storage account at the provider |
443 | + |
444 | + Interactively prompt the user to pick a storage account for |
445 | + use by the application, and return the D-Bus endpoint that can |
446 | + be used to communicate with the associated provider. |
447 | + |
448 | + As this involves user interaction, the caller should use a |
449 | + relatively long time out for this method call. |
450 | + --> |
451 | + <method name="GetProvider"> |
452 | + <arg type="s" name="service_id" direction="in" /> |
453 | + |
454 | + <arg type="s" name="bus_name" direction="out" /> |
455 | + <arg type="o" name="path" direction="out" /> |
456 | + </method> |
457 | + </interface> |
458 | +</node> |
459 | |
460 | === modified file 'debian/changelog' |
461 | --- debian/changelog 2016-04-20 01:24:53 +0000 |
462 | +++ debian/changelog 2016-07-21 12:22:21 +0000 |
463 | @@ -1,4 +1,4 @@ |
464 | -storage-framework (0.0.1) UNRELEASED; urgency=medium |
465 | +storage-framework (0.1-0ubuntu1) UNRELEASED; urgency=medium |
466 | |
467 | * Initial release. |
468 | |
469 | |
470 | === modified file 'debian/control' |
471 | --- debian/control 2016-04-20 01:06:54 +0000 |
472 | +++ debian/control 2016-07-21 12:22:21 +0000 |
473 | @@ -1,5 +1,5 @@ |
474 | Source: storage-framework |
475 | -Section: libdevel |
476 | +Section: libs |
477 | Priority: optional |
478 | Maintainer: Ubuntu Core Developers <ubuntu-devel-discuss@lists.ubuntu.com> |
479 | Standards-Version: 3.9.6 |
480 | @@ -7,11 +7,75 @@ |
481 | cmake-extras (>= 0.4), |
482 | debhelper (>= 9), |
483 | devscripts, |
484 | + doxygen, |
485 | google-mock, |
486 | + libapparmor-dev, |
487 | + libboost-filesystem-dev, |
488 | + libboost-system-dev, |
489 | + libboost-thread-dev, |
490 | + libglib2.0-dev, |
491 | libgtest-dev, |
492 | - doxygen, |
493 | + libonline-accounts-qt-dev, |
494 | + libqtdbustest1-dev, |
495 | + libunity-api-dev, |
496 | + python3-gi, |
497 | + qtbase5-dev, |
498 | + qtbase5-dev-tools, |
499 | Homepage: https://launchpad.net/storage-framework |
500 | # if you don't have have commit access to this branch but would like to upload |
501 | # directly to Ubuntu, don't worry: your changes will be merged back into the |
502 | # upstream branch |
503 | Vcs-Bzr: lp:storage-framework |
504 | + |
505 | +Package: libstorage-framework-provider-1-0 |
506 | +Architecture: any |
507 | +Multi-Arch: same |
508 | +Pre-Depends: ${misc:Pre-Depends}, |
509 | +Depends: ${misc:Depends}, |
510 | + ${shlibs:Depends}, |
511 | +Description: Library for Storage Framework providers |
512 | + Server-side runtime support for provider implementations. |
513 | + |
514 | +Package: libstorage-framework-qt-client-1-0 |
515 | +Architecture: any |
516 | +Multi-Arch: same |
517 | +Pre-Depends: ${misc:Pre-Depends}, |
518 | +Depends: ${misc:Depends}, |
519 | + ${shlibs:Depends}, |
520 | +Description: Client library for the Storage Framework |
521 | + Runtime support for storage framework clients. |
522 | + |
523 | +Package: libstorage-framework-qt-local-client-1-0 |
524 | +Architecture: any |
525 | +Multi-Arch: same |
526 | +Pre-Depends: ${misc:Pre-Depends}, |
527 | +Depends: ${misc:Depends}, |
528 | + ${shlibs:Depends}, |
529 | +Description: Client library for the Storage Framework backed by the local file system |
530 | + A version of the client-side API that implements a local |
531 | + file system provider. This is intended mainly for testing; |
532 | + it allows application code to use the storage framework |
533 | + API without requiring use of DBus and cloud service account. |
534 | + |
535 | +Package: storage-framework-client-dev |
536 | +Section: libdevel |
537 | +Architecture: any |
538 | +Multi-Arch: same |
539 | +Pre-Depends: ${misc:Pre-Depends}, |
540 | +Depends: libstorage-framework-qt-client-1-0 (= ${binary:Version}), |
541 | + libstorage-framework-qt-local-client-1-0 (= ${binary:Version}), |
542 | + qtbase5-dev, |
543 | + ${misc:Depends}, |
544 | +Description: Header files for the Storage Framework client libraries |
545 | + Development C++ headers for the client side API. |
546 | + |
547 | +Package: storage-framework-provider-dev |
548 | +Section: libdevel |
549 | +Architecture: any |
550 | +Multi-Arch: same |
551 | +Pre-Depends: ${misc:Pre-Depends}, |
552 | +Depends: libstorage-framework-provider-1-0 (= ${binary:Version}), |
553 | + libboost-thread-dev, |
554 | + ${misc:Depends}, |
555 | +Description: Header files for the Storage Framework provider library |
556 | + Development C++ headers for the provider API. |
557 | |
558 | === added file 'debian/copyright' |
559 | --- debian/copyright 1970-01-01 00:00:00 +0000 |
560 | +++ debian/copyright 2016-07-21 12:22:21 +0000 |
561 | @@ -0,0 +1,19 @@ |
562 | +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ |
563 | +Upstream-Name: storage-framework |
564 | +Source: https://launchpad.net/storage-framework |
565 | + |
566 | +Files: * |
567 | +Copyright: 2016 Canonical Ltd. |
568 | +License: LGPL-3 |
569 | + This program is free software: you can redistribute it and/or modify |
570 | + it under the terms of version 3 of the GNU Lesser General Public |
571 | + License as published by the Free Software Foundation. |
572 | + . |
573 | + This program is distributed in the hope that it will be useful, |
574 | + but WITHOUT ANY WARRANTY; without even the implied warranty of |
575 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
576 | + GNU Lesser General Public License for more details. |
577 | + . |
578 | + On Debian systems, the full text of the GNU Lesser General Public |
579 | + License version 3 can be found in the file |
580 | + `/usr/share/common-licenses/LGPL-3' |
581 | |
582 | === added file 'debian/libstorage-framework-provider-1-0.install' |
583 | --- debian/libstorage-framework-provider-1-0.install 1970-01-01 00:00:00 +0000 |
584 | +++ debian/libstorage-framework-provider-1-0.install 2016-07-21 12:22:21 +0000 |
585 | @@ -0,0 +1,1 @@ |
586 | +usr/lib/*/libstorage-framework-provider-*.so.* |
587 | |
588 | === added file 'debian/libstorage-framework-qt-client-1-0.install' |
589 | --- debian/libstorage-framework-qt-client-1-0.install 1970-01-01 00:00:00 +0000 |
590 | +++ debian/libstorage-framework-qt-client-1-0.install 2016-07-21 12:22:21 +0000 |
591 | @@ -0,0 +1,1 @@ |
592 | +usr/lib/*/libstorage-framework-qt-client-*.so.* |
593 | |
594 | === added file 'debian/libstorage-framework-qt-local-client-1-0.install' |
595 | --- debian/libstorage-framework-qt-local-client-1-0.install 1970-01-01 00:00:00 +0000 |
596 | +++ debian/libstorage-framework-qt-local-client-1-0.install 2016-07-21 12:22:21 +0000 |
597 | @@ -0,0 +1,1 @@ |
598 | +usr/lib/*/libstorage-framework-qt-local-client-*.so.* |
599 | |
600 | === modified file 'debian/rules' (properties changed: -x to +x) |
601 | === added directory 'debian/source' |
602 | === added file 'debian/source/format' |
603 | --- debian/source/format 1970-01-01 00:00:00 +0000 |
604 | +++ debian/source/format 2016-07-21 12:22:21 +0000 |
605 | @@ -0,0 +1,1 @@ |
606 | +1.0 |
607 | |
608 | === added file 'debian/storage-framework-client-dev.install' |
609 | --- debian/storage-framework-client-dev.install 1970-01-01 00:00:00 +0000 |
610 | +++ debian/storage-framework-client-dev.install 2016-07-21 12:22:21 +0000 |
611 | @@ -0,0 +1,3 @@ |
612 | +usr/include/storage-framework-client-* |
613 | +usr/lib/*/libstorage-framework*client*.so |
614 | +usr/lib/*/pkgconfig/storage-framework*client*.pc |
615 | |
616 | === added file 'debian/storage-framework-provider-dev.install' |
617 | --- debian/storage-framework-provider-dev.install 1970-01-01 00:00:00 +0000 |
618 | +++ debian/storage-framework-provider-dev.install 2016-07-21 12:22:21 +0000 |
619 | @@ -0,0 +1,3 @@ |
620 | +usr/include/storage-framework-provider-* |
621 | +usr/lib/*/libstorage-framework-provider*.so |
622 | +usr/lib/*/pkgconfig/storage-framework-provider*.pc |
623 | |
624 | === added directory 'demo' |
625 | === added file 'demo/CMakeLists.txt' |
626 | --- demo/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
627 | +++ demo/CMakeLists.txt 2016-07-21 12:22:21 +0000 |
628 | @@ -0,0 +1,1 @@ |
629 | +add_subdirectory(provider_test) |
630 | |
631 | === added directory 'demo/provider_test' |
632 | === added file 'demo/provider_test/CMakeLists.txt' |
633 | --- demo/provider_test/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
634 | +++ demo/provider_test/CMakeLists.txt 2016-07-21 12:22:21 +0000 |
635 | @@ -0,0 +1,5 @@ |
636 | + |
637 | +add_definitions(-DBOOST_THREAD_VERSION=4) |
638 | + |
639 | +add_executable(provider-test provider-test.cpp) |
640 | +target_link_libraries(provider-test storage-framework-provider) |
641 | |
642 | === added file 'demo/provider_test/provider-test.cpp' |
643 | --- demo/provider_test/provider-test.cpp 1970-01-01 00:00:00 +0000 |
644 | +++ demo/provider_test/provider-test.cpp 2016-07-21 12:22:21 +0000 |
645 | @@ -0,0 +1,311 @@ |
646 | +/* |
647 | + * Copyright (C) 2016 Canonical Ltd |
648 | + * |
649 | + * This program is free software: you can redistribute it and/or modify |
650 | + * it under the terms of the GNU Lesser General Public License version 3 as |
651 | + * published by the Free Software Foundation. |
652 | + * |
653 | + * This program is distributed in the hope that it will be useful, |
654 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
655 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
656 | + * GNU Lesser General Public License for more details. |
657 | + * |
658 | + * You should have received a copy of the GNU Lesser General Public License |
659 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
660 | + * |
661 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
662 | + */ |
663 | + |
664 | +#include <unity/storage/provider/DownloadJob.h> |
665 | +#include <unity/storage/provider/ProviderBase.h> |
666 | +#include <unity/storage/provider/Server.h> |
667 | +#include <unity/storage/provider/TempfileUploadJob.h> |
668 | +#include <unity/storage/provider/UploadJob.h> |
669 | + |
670 | +#include <boost/version.hpp> |
671 | +#include <boost/thread/future.hpp> |
672 | + |
673 | +#include <unistd.h> |
674 | + |
675 | +using namespace unity::storage; |
676 | +using namespace unity::storage::provider; |
677 | +using namespace std; |
678 | + |
679 | +#if BOOST_VERSION >= 105600 |
680 | +using boost::make_ready_future; |
681 | +using boost::make_exceptional_future; |
682 | +#else |
683 | +namespace |
684 | +{ |
685 | + |
686 | +boost::future<void> make_ready_future() |
687 | +{ |
688 | + boost::promise<void> p; |
689 | + p.set_value(); |
690 | + return p.get_future(); |
691 | +} |
692 | + |
693 | +template <typename T> |
694 | +boost::future<T> make_ready_future(T& value) |
695 | +{ |
696 | + boost::promise<T> p; |
697 | + p.set_value(value); |
698 | + return p.get_future(); |
699 | +} |
700 | + |
701 | +template <typename T> |
702 | +boost::future<T> make_ready_future(T&& value) |
703 | +{ |
704 | + boost::promise<T> p; |
705 | + p.set_value(std::move(value)); |
706 | + return p.get_future(); |
707 | +} |
708 | + |
709 | +template <typename T, typename E> |
710 | +boost::future<T> make_exceptional_future(E const& ex) |
711 | +{ |
712 | + boost::promise<T> p; |
713 | + p.set_exception(boost::copy_exception(ex)); |
714 | + return p.get_future(); |
715 | +} |
716 | + |
717 | +} |
718 | +#endif |
719 | + |
720 | + |
721 | +class MyProvider : public ProviderBase |
722 | +{ |
723 | +public: |
724 | + MyProvider(); |
725 | + |
726 | + boost::future<ItemList> roots(Context const& ctx) override; |
727 | + boost::future<tuple<ItemList,string>> list( |
728 | + string const& item_id, string const& page_token, |
729 | + Context const& ctx) override; |
730 | + boost::future<ItemList> lookup( |
731 | + string const& parent_id, string const& name, |
732 | + Context const& ctx) override; |
733 | + boost::future<Item> metadata( |
734 | + string const& item_id, Context const& ctx) override; |
735 | + boost::future<Item> create_folder( |
736 | + string const& parent_id, string const& name, |
737 | + Context const& ctx) override; |
738 | + |
739 | + boost::future<unique_ptr<UploadJob>> create_file( |
740 | + string const& parent_id, string const& title, |
741 | + string const& content_type, bool allow_overwrite, |
742 | + Context const& ctx) override; |
743 | + boost::future<unique_ptr<UploadJob>> update( |
744 | + string const& item_id, string const& old_etag, |
745 | + Context const& ctx) override; |
746 | + |
747 | + boost::future<unique_ptr<DownloadJob>> download( |
748 | + string const& item_id, Context const& ctx) override; |
749 | + |
750 | + boost::future<void> delete_item( |
751 | + string const& item_id, Context const& ctx) override; |
752 | + boost::future<Item> move( |
753 | + string const& item_id, string const& new_parent_id, |
754 | + string const& new_name, Context const& ctx) override; |
755 | + boost::future<Item> copy( |
756 | + string const& item_id, string const& new_parent_id, |
757 | + string const& new_name, Context const& ctx) override; |
758 | +}; |
759 | + |
760 | +class MyUploadJob : public TempfileUploadJob |
761 | +{ |
762 | +public: |
763 | + using TempfileUploadJob::TempfileUploadJob; |
764 | + |
765 | + boost::future<void> cancel() override; |
766 | + boost::future<Item> finish() override; |
767 | +}; |
768 | + |
769 | +class MyDownloadJob : public DownloadJob |
770 | +{ |
771 | +public: |
772 | + using DownloadJob::DownloadJob; |
773 | + |
774 | + boost::future<void> cancel() override; |
775 | + boost::future<void> finish() override; |
776 | +}; |
777 | + |
778 | +MyProvider::MyProvider() |
779 | +{ |
780 | +} |
781 | + |
782 | +boost::future<ItemList> MyProvider::roots(Context const& ctx) |
783 | +{ |
784 | + printf("roots() called by %s (%d)\n", ctx.security_label.c_str(), ctx.pid); |
785 | + ItemList roots = { |
786 | + {"root_id", "", "Root", "etag", ItemType::root, {}}, |
787 | + }; |
788 | + return make_ready_future<ItemList>(roots); |
789 | +} |
790 | + |
791 | +boost::future<tuple<ItemList,string>> MyProvider::list( |
792 | + string const& item_id, string const& page_token, |
793 | + Context const& ctx) |
794 | +{ |
795 | + printf("list('%s', '%s') called by %s (%d)\n", item_id.c_str(), page_token.c_str(), ctx.security_label.c_str(), ctx.pid); |
796 | + if (item_id != "root_id") |
797 | + { |
798 | + return make_exceptional_future<tuple<ItemList,string>>(runtime_error("unknown folder")); |
799 | + } |
800 | + if (page_token != "") |
801 | + { |
802 | + return make_exceptional_future<tuple<ItemList,string>>(runtime_error("unknown page token")); |
803 | + } |
804 | + ItemList children = { |
805 | + {"child_id", "root_id", "Child", "etag", ItemType::file, {}} |
806 | + }; |
807 | + boost::promise<tuple<ItemList,string>> p; |
808 | + p.set_value(make_tuple(children, string())); |
809 | + return p.get_future(); |
810 | +} |
811 | + |
812 | +boost::future<ItemList> MyProvider::lookup( |
813 | + string const& parent_id, string const& name, Context const& ctx) |
814 | +{ |
815 | + printf("lookup('%s', '%s') called by %s (%d)\n", parent_id.c_str(), name.c_str(), ctx.security_label.c_str(), ctx.pid); |
816 | + if (parent_id != "root_id" || name != "Child") |
817 | + { |
818 | + return make_exceptional_future<ItemList>(runtime_error("file not found")); |
819 | + } |
820 | + ItemList children = { |
821 | + {"child_id", "root_id", "Child", "etag", ItemType::file, {}} |
822 | + }; |
823 | + return make_ready_future<ItemList>(children); |
824 | +} |
825 | + |
826 | +boost::future<Item> MyProvider::metadata(string const& item_id, |
827 | + Context const& ctx) |
828 | +{ |
829 | + printf("metadata('%s') called by %s (%d)\n", item_id.c_str(), ctx.security_label.c_str(), ctx.pid); |
830 | + if (item_id == "root_id") |
831 | + { |
832 | + Item metadata{"root_id", "", "Root", "etag", ItemType::root, {}}; |
833 | + return make_ready_future<Item>(metadata); |
834 | + } |
835 | + else if (item_id == "child_id") |
836 | + { |
837 | + Item metadata{"child_id", "root_id", "Child", "etag", ItemType::file, {}}; |
838 | + return make_ready_future<Item>(metadata); |
839 | + } |
840 | + return make_exceptional_future<Item>(runtime_error("no such file")); |
841 | +} |
842 | + |
843 | +boost::future<Item> MyProvider::create_folder( |
844 | + string const& parent_id, string const& name, |
845 | + Context const& ctx) |
846 | +{ |
847 | + printf("create_folder('%s', '%s') called by %s (%d)\n", parent_id.c_str(), name.c_str(), ctx.security_label.c_str(), ctx.pid); |
848 | + Item metadata{"new_folder_id", parent_id, name, "etag", ItemType::folder, {}}; |
849 | + return make_ready_future<Item>(metadata); |
850 | +} |
851 | + |
852 | +string make_job_id() |
853 | +{ |
854 | + static int last_job_id = 0; |
855 | + return to_string(++last_job_id); |
856 | +} |
857 | + |
858 | +boost::future<unique_ptr<UploadJob>> MyProvider::create_file( |
859 | + string const& parent_id, string const& title, |
860 | + string const& content_type, bool allow_overwrite, |
861 | + Context const& ctx) |
862 | +{ |
863 | + printf("create_file('%s', '%s', '%s', %d) called by %s (%d)\n", parent_id.c_str(), title.c_str(), content_type.c_str(), allow_overwrite, ctx.security_label.c_str(), ctx.pid); |
864 | + return make_ready_future(unique_ptr<UploadJob>(new MyUploadJob(make_job_id()))); |
865 | +} |
866 | + |
867 | +boost::future<unique_ptr<UploadJob>> MyProvider::update( |
868 | + string const& item_id, string const& old_etag, Context const& ctx) |
869 | +{ |
870 | + printf("update('%s', '%s') called by %s (%d)\n", item_id.c_str(), old_etag.c_str(), ctx.security_label.c_str(), ctx.pid); |
871 | + return make_ready_future(unique_ptr<UploadJob>(new MyUploadJob(make_job_id()))); |
872 | +} |
873 | + |
874 | +boost::future<unique_ptr<DownloadJob>> MyProvider::download( |
875 | + string const& item_id, Context const& ctx) |
876 | +{ |
877 | + printf("download('%s') called by %s (%d)\n", item_id.c_str(), ctx.security_label.c_str(), ctx.pid); |
878 | + |
879 | + unique_ptr<DownloadJob> job(new MyDownloadJob(make_job_id())); |
880 | + const char contents[] = "Hello world"; |
881 | + write(job->write_socket(), contents, sizeof(contents)); |
882 | + job->report_complete(); |
883 | + return make_ready_future(std::move(job)); |
884 | +} |
885 | + |
886 | +boost::future<void> MyProvider::delete_item( |
887 | + string const& item_id, Context const& ctx) |
888 | +{ |
889 | + printf("delete('%s') called by %s (%d)\n", item_id.c_str(), ctx.security_label.c_str(), ctx.pid); |
890 | + return make_ready_future(); |
891 | +} |
892 | + |
893 | +boost::future<Item> MyProvider::move( |
894 | + string const& item_id, string const& new_parent_id, |
895 | + string const& new_name, Context const& ctx) |
896 | +{ |
897 | + printf("move('%s', '%s', '%s') called by %s (%d)\n", item_id.c_str(), new_parent_id.c_str(), new_name.c_str(), ctx.security_label.c_str(), ctx.pid); |
898 | + Item metadata{item_id, new_parent_id, new_name, "etag", ItemType::file, {}}; |
899 | + return make_ready_future(metadata); |
900 | +} |
901 | + |
902 | +boost::future<Item> MyProvider::copy( |
903 | + string const& item_id, string const& new_parent_id, |
904 | + string const& new_name, Context const& ctx) |
905 | +{ |
906 | + printf("copy('%s', '%s', '%s') called by %s (%d)\n", item_id.c_str(), new_parent_id.c_str(), new_name.c_str(), ctx.security_label.c_str(), ctx.pid); |
907 | + Item metadata{"new_item_id", new_parent_id, new_name, "etag", ItemType::file, {}}; |
908 | + return make_ready_future(metadata); |
909 | +} |
910 | + |
911 | +boost::future<void> MyUploadJob::cancel() |
912 | +{ |
913 | + printf("cancel_upload('%s')\n", upload_id().c_str()); |
914 | + return make_ready_future(); |
915 | +} |
916 | + |
917 | +boost::future<Item> MyUploadJob::finish() |
918 | +{ |
919 | + printf("finish_upload('%s')\n", upload_id().c_str()); |
920 | + |
921 | + string old_filename = file_name(); |
922 | + string new_filename = upload_id() + ".txt"; |
923 | + printf("Linking %s to %s\n", old_filename.c_str(), new_filename.c_str()); |
924 | + unlink(new_filename.c_str()); |
925 | + link(old_filename.c_str(), new_filename.c_str()); |
926 | + |
927 | + Item metadata{"some_id", "", "some_upload", "etag", ItemType::file, {}}; |
928 | + return make_ready_future(metadata); |
929 | +} |
930 | + |
931 | +boost::future<void> MyDownloadJob::cancel() |
932 | +{ |
933 | + printf("cancel_download('%s')\n", download_id().c_str()); |
934 | + return make_ready_future(); |
935 | +} |
936 | + |
937 | +boost::future<void> MyDownloadJob::finish() |
938 | +{ |
939 | + printf("finish_download('%s')\n", download_id().c_str()); |
940 | + |
941 | + return make_ready_future(); |
942 | +} |
943 | + |
944 | + |
945 | +int main(int argc, char **argv) |
946 | +{ |
947 | + const std::string bus_name = "com.canonical.StorageFramework.Provider.ProviderTest"; |
948 | + std::string account_service_id = "google-drive-scope"; |
949 | + if (argc > 1) |
950 | + { |
951 | + account_service_id = argv[1]; |
952 | + } |
953 | + Server<MyProvider> server(bus_name, account_service_id); |
954 | + server.init(argc, argv); |
955 | + server.run(); |
956 | +} |
957 | |
958 | === added file 'demo/provider_test/test-client.py' |
959 | --- demo/provider_test/test-client.py 1970-01-01 00:00:00 +0000 |
960 | +++ demo/provider_test/test-client.py 2016-07-21 12:22:21 +0000 |
961 | @@ -0,0 +1,160 @@ |
962 | +#!/usr/bin/python3 |
963 | + |
964 | +# |
965 | +# Copyright (C) 2016 Canonical Ltd |
966 | +# |
967 | +# This program is free software: you can redistribute it and/or modify |
968 | +# it under the terms of the GNU Lesser General Public License version 3 as |
969 | +# published by the Free Software Foundation. |
970 | +# |
971 | +# This program is distributed in the hope that it will be useful, |
972 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
973 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
974 | +# GNU Lesser General Public License for more details. |
975 | +# |
976 | +# You should have received a copy of the GNU Lesser General Public License |
977 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
978 | +# |
979 | +# Authored by: James Henstridge <james.henstridge@canonical.com> |
980 | +# |
981 | + |
982 | +import os |
983 | +import sys |
984 | + |
985 | +from gi.repository import Gio, GLib |
986 | + |
987 | +PROVIDER_BUS_NAME = 'com.canonical.StorageFramework.Provider.ProviderTest' |
988 | +PROVIDER_IFACE = 'com.canonical.StorageFramework.Provider' |
989 | + |
990 | +class Provider: |
991 | + def __init__(self, bus, bus_name, object_path): |
992 | + self._proxy = Gio.DBusProxy.new_sync( |
993 | + bus, Gio.DBusProxyFlags.NONE, None, |
994 | + bus_name, object_path, PROVIDER_IFACE, None) |
995 | + |
996 | + def roots(self): |
997 | + return self._proxy.Roots('()') |
998 | + |
999 | + def list(self, item_id, page_token): |
1000 | + return self._proxy.List('(ss)', item_id, page_token) |
1001 | + |
1002 | + def lookup(self, parent_id, name): |
1003 | + return self._proxy.Lookup('(ss)', parent_id, name) |
1004 | + |
1005 | + def metadata(self, item_id): |
1006 | + return self._proxy.Metadata('(s)', item_id) |
1007 | + |
1008 | + def create_folder(self, parent_id, name): |
1009 | + return self._proxy.CreateFolder('(ss)', parent_id, name) |
1010 | + |
1011 | + def create_file(self, parent_id, name, content_type, allow_overwrite): |
1012 | + args = GLib.Variant('(sssb)', (parent_id, name, content_type, allow_overwrite)) |
1013 | + result, fd_list = self._proxy.call_with_unix_fd_list_sync( |
1014 | + 'CreateFile', args, 0, -1) |
1015 | + upload_id, fd_idx = result.unpack() |
1016 | + assert fd_list.get_length() == 1 |
1017 | + assert fd_idx == 0 |
1018 | + return upload_id, fd_list.steal_fds()[fd_idx] |
1019 | + |
1020 | + def update(self, item_id, old_etag=''): |
1021 | + args = GLib.Variant('(ss)', (item_id, old_etag)) |
1022 | + result, fd_list = self._proxy.call_with_unix_fd_list_sync( |
1023 | + 'Update', args, 0, -1) |
1024 | + upload_id, fd_idx = result.unpack() |
1025 | + assert fd_list.get_length() == 1 |
1026 | + assert fd_idx == 0 |
1027 | + return upload_id, fd_list.steal_fds()[fd_idx] |
1028 | + |
1029 | + def cancel_upload(self, upload_id): |
1030 | + self._proxy.CancelUpload('(s)', upload_id) |
1031 | + |
1032 | + def finish_upload(self, upload_id): |
1033 | + return self._proxy.FinishUpload('(s)', upload_id) |
1034 | + |
1035 | + def download(self, item_id): |
1036 | + args = GLib.Variant('(s)', (item_id,)) |
1037 | + result, fd_list = self._proxy.call_with_unix_fd_list_sync( |
1038 | + 'Download', args, 0, -1) |
1039 | + download_id, fd_idx = result.unpack() |
1040 | + assert fd_list.get_length() == 1 |
1041 | + assert fd_idx == 0 |
1042 | + return download_id, fd_list.steal_fds()[fd_idx] |
1043 | + |
1044 | + def finish_download(self, download_id): |
1045 | + return self._proxy.FinishDownload('(s)', download_id) |
1046 | + |
1047 | + def delete(self, item_id): |
1048 | + self._proxy.Delete('(s)', item_id) |
1049 | + |
1050 | + def move(self, item_id, new_parent_id, new_name): |
1051 | + return self._proxy.Move('(sss)', item_id, new_parent_id, new_name) |
1052 | + |
1053 | + def copy(self, item_id, new_parent_id, new_name): |
1054 | + return self._proxy.Copy('(sss)', item_id, new_parent_id, new_name) |
1055 | + |
1056 | + |
1057 | +def main(argv): |
1058 | + bus = Gio.bus_get_sync(Gio.BusType.SESSION, None) |
1059 | + provider = Provider(bus, PROVIDER_BUS_NAME, argv[1]) |
1060 | + |
1061 | + print("Getting roots...", end='', flush=True) |
1062 | + roots = provider.roots() |
1063 | + print(roots) |
1064 | + print() |
1065 | + |
1066 | + root_id = roots[0][0] |
1067 | + |
1068 | + print("Listing %r..." % root_id, end='', flush=True) |
1069 | + children, next_token = provider.list(root_id, '') |
1070 | + print(children) |
1071 | + print() |
1072 | + |
1073 | + child_id = children[0][0] |
1074 | + child_name = children[0][2] |
1075 | + print("Looking up %r under %r..." % (child_name, root_id), end='', flush=True) |
1076 | + items = provider.lookup(root_id, child_name) |
1077 | + print(items) |
1078 | + print() |
1079 | + |
1080 | + print("Getting metadata for %r..." % child_id, end='', flush=True) |
1081 | + item = provider.metadata(child_id) |
1082 | + print(item) |
1083 | + print() |
1084 | + |
1085 | + print("Creating folder...", end='', flush=True) |
1086 | + provider.create_folder(root_id, 'Some folder') |
1087 | + print("done") |
1088 | + print() |
1089 | + |
1090 | + print("Preparing to upload file...", end='', flush=True) |
1091 | + upload_id, fd = provider.create_file( |
1092 | + root_id, 'file name', 'text/plain', False) |
1093 | + print(upload_id, fd) |
1094 | + |
1095 | + os.write(fd, b'Hello world\n' * 1000) |
1096 | + os.close(fd) |
1097 | + |
1098 | + provider.finish_upload(upload_id) |
1099 | + print("Completed upload") |
1100 | + print() |
1101 | + |
1102 | + print("Preparing to download file...", end='', flush=True) |
1103 | + download_id, fd = provider.download("some-id") |
1104 | + print(download_id, fd) |
1105 | + with os.fdopen(fd) as fp: |
1106 | + contents = fp.read() |
1107 | + provider.finish_download(download_id) |
1108 | + print("Contents: %r" % contents) |
1109 | + |
1110 | + print("Moving file...", end='', flush=True) |
1111 | + item = provider.move(child_id, root_id, "New Name") |
1112 | + print(item) |
1113 | + print() |
1114 | + |
1115 | + print("Copying file...", end='', flush=True) |
1116 | + item = provider.copy(child_id, root_id, "Copy name") |
1117 | + print(item) |
1118 | + print() |
1119 | + |
1120 | +if __name__ == '__main__': |
1121 | + sys.exit(main(sys.argv)) |
1122 | |
1123 | === modified file 'include/CMakeLists.txt' |
1124 | --- include/CMakeLists.txt 2016-04-20 00:53:53 +0000 |
1125 | +++ include/CMakeLists.txt 2016-07-21 12:22:21 +0000 |
1126 | @@ -1,1 +1,4 @@ |
1127 | +set(client_base_includedir ${CMAKE_INSTALL_INCLUDEDIR}/storage-framework-client-${SF_CLIENT_API_VERSION}) |
1128 | +set(provider_base_includedir ${CMAKE_INSTALL_INCLUDEDIR}/storage-framework-provider-${SF_PROVIDER_API_VERSION}) |
1129 | + |
1130 | add_subdirectory(unity) |
1131 | |
1132 | === modified file 'include/unity/storage/CMakeLists.txt' |
1133 | --- include/unity/storage/CMakeLists.txt 2016-04-20 00:53:53 +0000 |
1134 | +++ include/unity/storage/CMakeLists.txt 2016-07-21 12:22:21 +0000 |
1135 | @@ -1,1 +1,11 @@ |
1136 | -add_subdirectory(client) |
1137 | +set(includeprefix unity/storage) |
1138 | +file(GLOB common_headers *.h) |
1139 | + |
1140 | +# Install common headers to both include prefixes |
1141 | +install(FILES ${common_headers} |
1142 | + DESTINATION ${client_base_includedir}/${includeprefix}) |
1143 | +install(FILES ${common_headers} |
1144 | + DESTINATION ${provider_base_includedir}/${includeprefix}) |
1145 | + |
1146 | +add_subdirectory(provider) |
1147 | +add_subdirectory(qt) |
1148 | |
1149 | === removed directory 'include/unity/storage/client' |
1150 | === removed file 'include/unity/storage/client/Account.h' |
1151 | --- include/unity/storage/client/Account.h 2016-04-19 04:01:16 +0000 |
1152 | +++ include/unity/storage/client/Account.h 1970-01-01 00:00:00 +0000 |
1153 | @@ -1,50 +0,0 @@ |
1154 | -#pragma once |
1155 | - |
1156 | -#include <memory> |
1157 | -#include <vector> |
1158 | - |
1159 | -namespace unity |
1160 | -{ |
1161 | - |
1162 | -namespace storage |
1163 | -{ |
1164 | - |
1165 | -namespace client |
1166 | -{ |
1167 | - |
1168 | -class RootsResult; |
1169 | - |
1170 | -/** |
1171 | -\brief Class that represents an account. |
1172 | -*/ |
1173 | - |
1174 | -class Account |
1175 | -{ |
1176 | -public: |
1177 | - ~Account(); |
1178 | - Account(Account const&) = delete; |
1179 | - Account& operator=(Account const&) = delete; |
1180 | - Account(Account&&); |
1181 | - Account& operator=(Account&&); |
1182 | - |
1183 | - typedef std::unique_ptr<Account> UPtr; |
1184 | - |
1185 | - std::string owner() const; |
1186 | - std::string owner_id() const; |
1187 | - std::string description() const; |
1188 | - |
1189 | - // TODO: Will almost certainly need more here. Description? Other details? |
1190 | - |
1191 | - /** |
1192 | - \brief Returns the root directories for the account. |
1193 | - |
1194 | - An account can have more than one root directory (for providers that support the concept of multiple drives). |
1195 | - */ |
1196 | - void get_roots(std::function<void(RootsResult const&)> roots_callback) const; |
1197 | -}; |
1198 | - |
1199 | -} // namespace client |
1200 | - |
1201 | -} // namespace storage |
1202 | - |
1203 | -} // namespace unity |
1204 | |
1205 | === removed file 'include/unity/storage/client/AccountsResult.h' |
1206 | --- include/unity/storage/client/AccountsResult.h 2016-04-20 01:56:37 +0000 |
1207 | +++ include/unity/storage/client/AccountsResult.h 1970-01-01 00:00:00 +0000 |
1208 | @@ -1,35 +0,0 @@ |
1209 | -#pragma once |
1210 | - |
1211 | -#include <unity/storage/client/Account.h> |
1212 | - |
1213 | -namespace unity |
1214 | -{ |
1215 | - |
1216 | -namespace storage |
1217 | -{ |
1218 | - |
1219 | -namespace client |
1220 | -{ |
1221 | - |
1222 | -typedef std::vector<Account::UPtr> AccountList; |
1223 | - |
1224 | -class AccountsResult |
1225 | -{ |
1226 | -public: |
1227 | - ~AccountsResult(); |
1228 | - AccountsResult(AccountsResult const&) = delete; |
1229 | - AccountsResult& operator=(AccountsResult const&) = delete; |
1230 | - AccountsResult(AccountsResult&&) = delete; |
1231 | - AccountsResult& operator=(AccountsResult&&) = delete; |
1232 | - |
1233 | - AccountList get_accounts() const; |
1234 | - |
1235 | -private: |
1236 | - AccountsResult(); |
1237 | -}; |
1238 | - |
1239 | -} // namespace client |
1240 | - |
1241 | -} // namespace storage |
1242 | - |
1243 | -} // namespace unity |
1244 | |
1245 | === removed file 'include/unity/storage/client/CreateResult.h' |
1246 | --- include/unity/storage/client/CreateResult.h 2016-04-20 01:56:37 +0000 |
1247 | +++ include/unity/storage/client/CreateResult.h 1970-01-01 00:00:00 +0000 |
1248 | @@ -1,33 +0,0 @@ |
1249 | -#pragma once |
1250 | - |
1251 | -#include <unity/storage/client/Item.h> |
1252 | - |
1253 | -namespace unity |
1254 | -{ |
1255 | - |
1256 | -namespace storage |
1257 | -{ |
1258 | - |
1259 | -namespace client |
1260 | -{ |
1261 | - |
1262 | -class CreateResult |
1263 | -{ |
1264 | -public: |
1265 | - ~CreateResult(); |
1266 | - CreateResult(CreateResult const&) = delete; |
1267 | - CreateResult& operator=(CreateResult const&) = delete; |
1268 | - CreateResult(CreateResult&&) = delete; |
1269 | - CreateResult& operator=(CreateResult&&) = delete; |
1270 | - |
1271 | - Item::UPtr get_item() const; |
1272 | - |
1273 | -private: |
1274 | - CreateResult(); |
1275 | -}; |
1276 | - |
1277 | -} // namespace client |
1278 | - |
1279 | -} // namespace storage |
1280 | - |
1281 | -} // namespace unity |
1282 | |
1283 | === removed file 'include/unity/storage/client/DestroyResult.h' |
1284 | --- include/unity/storage/client/DestroyResult.h 2016-04-18 02:55:43 +0000 |
1285 | +++ include/unity/storage/client/DestroyResult.h 1970-01-01 00:00:00 +0000 |
1286 | @@ -1,33 +0,0 @@ |
1287 | -#pragma once |
1288 | - |
1289 | -namespace unity |
1290 | -{ |
1291 | - |
1292 | -namespace storage |
1293 | -{ |
1294 | - |
1295 | -namespace client |
1296 | -{ |
1297 | - |
1298 | -class Item; |
1299 | - |
1300 | -class DestroyResult |
1301 | -{ |
1302 | -public: |
1303 | - ~DestroyResult(); |
1304 | - DestroyResult(DestroyResult const&) = delete; |
1305 | - DestroyResult& operator=(DestroyResult const&) = delete; |
1306 | - DestroyResult(DestroyResult&&) = delete; |
1307 | - DestroyResult& operator=(DestroyResult&&) = delete; |
1308 | - |
1309 | - Item const& get_item() const; // Dubious, what if Item is no longer there? |
1310 | - |
1311 | -private: |
1312 | - DestroyResult(); |
1313 | -}; |
1314 | - |
1315 | -} // namespace client |
1316 | - |
1317 | -} // namespace storage |
1318 | - |
1319 | -} // namespace unity |
1320 | |
1321 | === removed file 'include/unity/storage/client/Directory.h' |
1322 | --- include/unity/storage/client/Directory.h 2016-04-20 01:56:37 +0000 |
1323 | +++ include/unity/storage/client/Directory.h 1970-01-01 00:00:00 +0000 |
1324 | @@ -1,82 +0,0 @@ |
1325 | -#pragma once |
1326 | - |
1327 | -#include <unity/storage/client/Item.h> |
1328 | - |
1329 | -namespace unity |
1330 | -{ |
1331 | - |
1332 | -namespace storage |
1333 | -{ |
1334 | - |
1335 | -namespace client |
1336 | -{ |
1337 | - |
1338 | -class CreateResult; |
1339 | -class IterationResult; |
1340 | -class ParentResult; |
1341 | - |
1342 | -/** |
1343 | -\brief Class that represents a directory. |
1344 | - |
1345 | -A directory is an unordered set of files and/or directories. The names (as returned by Item::name()) |
1346 | -of the members of a directory are unique. |
1347 | -*/ |
1348 | - |
1349 | -class Directory : public Item |
1350 | -{ |
1351 | -public: |
1352 | - ~Directory(); |
1353 | - Directory(Directory const&) = delete; |
1354 | - Directory& operator=(Directory const&) = delete; |
1355 | - Directory(Directory&&); |
1356 | - Directory& operator=(Directory&&); |
1357 | - |
1358 | - typedef std::unique_ptr<Directory> UPtr; |
1359 | - |
1360 | - /** |
1361 | - \brief Returns the contents of a directory. |
1362 | - \param iteration_callback As results become available, the runtime |
1363 | - calls iteration_callback once for each item. The iteration functor |
1364 | - can call IterationResult::get_item() to retrieve the item. A `nullptr` |
1365 | - return value from `get_item()` indicates end-of-iteration. |
1366 | - */ |
1367 | - void list(std::function<void(IterationResult const&)> iteration_callback); |
1368 | - |
1369 | - /** |
1370 | - \brief Returns the list of parent directories of this directory. |
1371 | - \param parents_callback As parent directories become available, the runtime |
1372 | - calls parents_callback once for each parent directory. The parents functor |
1373 | - can call ParentResult::get_directory() to retrieve the Directory. A `nullptr` |
1374 | - return value from `get_directory()` indicates end-of-iteration. |
1375 | - */ |
1376 | - void parents(std::function<void(ParentResult const&)> parents_callback); |
1377 | - |
1378 | - /** |
1379 | - \brief Creates a new directory with the current directory as the parent. |
1380 | - \param name The name of the new directory. Note that the actual name may be changed |
1381 | - by the provider; call Item::name() once the directory is created to get its actual name. |
1382 | - \param completion_callback Once the directory is created, the runtime calls completion_callback. |
1383 | - The completion functor can call CreateResult::get_item() to access the new directory. |
1384 | - \note Error information is returned as exceptions that are thrown from `get_item`. |
1385 | - */ |
1386 | - void create_dir(std::string const& name, std::function<void(CreateResult const&)> completion_callback); |
1387 | - |
1388 | - /** |
1389 | - \brief Creates a new empty file with the current directory as the parent. |
1390 | - \param name The name of the new file. Note that the actual name may be changed |
1391 | - by the provider; call Item::name() once the file is created to get its actual name. |
1392 | - \param completion_callback Once the file is created, the runtime calls completion_callback. |
1393 | - The completion functor can call CreateResult::get_item() to access the new file. |
1394 | - \note Error information is returned as exceptions that are thrown from `get_item`. |
1395 | - */ |
1396 | - void create_file(std::string const& name, std::function<void(CreateResult const&)> completion_callback); |
1397 | - |
1398 | -private: |
1399 | - Directory(); |
1400 | -}; |
1401 | - |
1402 | -} // namespace client |
1403 | - |
1404 | -} // namespace storage |
1405 | - |
1406 | -} // namespace unity |
1407 | |
1408 | === removed file 'include/unity/storage/client/DownloadResult.h' |
1409 | --- include/unity/storage/client/DownloadResult.h 2016-04-20 01:56:37 +0000 |
1410 | +++ include/unity/storage/client/DownloadResult.h 1970-01-01 00:00:00 +0000 |
1411 | @@ -1,40 +0,0 @@ |
1412 | -#pragma once |
1413 | - |
1414 | -#include <unity/storage/client/Item.h> |
1415 | - |
1416 | -namespace unity |
1417 | -{ |
1418 | - |
1419 | -namespace storage |
1420 | -{ |
1421 | - |
1422 | -namespace client |
1423 | -{ |
1424 | - |
1425 | -class DownloadResult |
1426 | -{ |
1427 | -public: |
1428 | - ~DownloadResult(); |
1429 | - DownloadResult(DownloadResult const&) = delete; |
1430 | - DownloadResult& operator=(DownloadResult const&) = delete; |
1431 | - DownloadResult(DownloadResult&&) = delete; |
1432 | - DownloadResult& operator=(DownloadResult&&) = delete; |
1433 | - |
1434 | - /** |
1435 | - Checks for errors once a download has completed. |
1436 | - |
1437 | - If the download has completed, this method returns normally. Otherwise, it throws an exception |
1438 | - that provides more details about the error. |
1439 | - \throws TODO: list of exceptions |
1440 | - */ |
1441 | - void check_error() const; |
1442 | - |
1443 | -private: |
1444 | - DownloadResult(); |
1445 | -}; |
1446 | - |
1447 | -} // namespace client |
1448 | - |
1449 | -} // namespace storage |
1450 | - |
1451 | -} // namespace unity |
1452 | |
1453 | === removed file 'include/unity/storage/client/Downloader.h' |
1454 | --- include/unity/storage/client/Downloader.h 2016-04-20 01:56:37 +0000 |
1455 | +++ include/unity/storage/client/Downloader.h 1970-01-01 00:00:00 +0000 |
1456 | @@ -1,86 +0,0 @@ |
1457 | -#pragma once |
1458 | - |
1459 | -#include <memory> |
1460 | - |
1461 | -namespace unity |
1462 | -{ |
1463 | - |
1464 | -namespace storage |
1465 | -{ |
1466 | - |
1467 | -namespace client |
1468 | -{ |
1469 | - |
1470 | -class DownloadResult; |
1471 | - |
1472 | -class Downloader |
1473 | -{ |
1474 | -public: |
1475 | - /** |
1476 | - \brief Destroys the downloader. |
1477 | - |
1478 | - The destructor implicitly calls close() if it has not been called already. |
1479 | - */ |
1480 | - ~Downloader(); |
1481 | - |
1482 | - Downloader(Downloader const&) = delete; |
1483 | - Downloader& operator=(Downloader const&) = delete; |
1484 | - Downloader(Downloader&&); |
1485 | - Downloader& operator=(Downloader&&); |
1486 | - |
1487 | - typedef std::unique_ptr<Downloader> UPtr; |
1488 | - |
1489 | - /** |
1490 | - \brief Returns a file descriptor that is open for reading. |
1491 | - |
1492 | - To download the file contents, read from the returned file descriptor. The descriptor |
1493 | - may not be able to deliver arbitrarily large amounts of data without blocking. If the |
1494 | - code that reads from the descriptor cannot block, use non-blocking reads. Once the |
1495 | - descriptor indicates EOF, call close() to check for errors. |
1496 | - |
1497 | - \return A file descriptor open for reading. If fd() is called after close() or cancel() |
1498 | - have been called, the return value is `-1`. |
1499 | - \throws TODO: All sorts of exceptions when things go wrong, list them. |
1500 | - */ |
1501 | - int fd() const; |
1502 | - |
1503 | - /** |
1504 | - \brief Finalizes the download. |
1505 | - |
1506 | - Once the descriptor returned by fd() indicates EOF, you must call close(). The runtime |
1507 | - closes the descriptor and calls close_callback once the state of the download has been verified. |
1508 | - Call DownloadResult::check_error() from the callback to verify whether the download completed successfully. |
1509 | - |
1510 | - If a read on the descriptor returns an error, this indicates a fatal error condition, and further |
1511 | - reads on the descriptor will fail as well. In this case, a call to close() results in close_callback() |
1512 | - being invoked as usual, and DownloadResult::check_error() will return the error details |
1513 | - via an exception. |
1514 | - |
1515 | - \param close_callback The functor called by the runtime once the download is finalized. |
1516 | - The passed value must not be `nullptr`. |
1517 | - \warning Do not assume that a download completed successfully once you detect EOF on the file descriptor. |
1518 | - If something goes wrong during a download on the server side, the file descriptor will return EOF |
1519 | - for a partially-downloaded file. |
1520 | - */ |
1521 | - void close(std::function<void(DownloadResult const&)> close_callback); |
1522 | - |
1523 | - /** |
1524 | - \brief Cancels a download. |
1525 | - |
1526 | - Calling cancel() informs the provider that the download is no longer needed. The provider |
1527 | - will make a best-effort attempt to cancel the download from the remote service. |
1528 | - |
1529 | - Calling cancel() more than once, or calling cancel() after a call to close() is safe and does nothing. |
1530 | - \throws TODO: All sorts of things. |
1531 | - */ |
1532 | - void cancel(); |
1533 | - |
1534 | -private: |
1535 | - Downloader(); |
1536 | -}; |
1537 | - |
1538 | -} // namespace client |
1539 | - |
1540 | -} // namespace storage |
1541 | - |
1542 | -} // namespace unity |
1543 | |
1544 | === removed file 'include/unity/storage/client/File.h' |
1545 | --- include/unity/storage/client/File.h 2016-04-20 01:56:37 +0000 |
1546 | +++ include/unity/storage/client/File.h 1970-01-01 00:00:00 +0000 |
1547 | @@ -1,59 +0,0 @@ |
1548 | -#pragma once |
1549 | - |
1550 | -#include <unity/storage/client/Downloader.h> |
1551 | -#include <unity/storage/client/Item.h> |
1552 | -#include <unity/storage/client/Uploader.h> |
1553 | - |
1554 | -namespace unity |
1555 | -{ |
1556 | - |
1557 | -namespace storage |
1558 | -{ |
1559 | - |
1560 | -namespace client |
1561 | -{ |
1562 | - |
1563 | -enum class ConflictPolicy { error_if_conflict, overwrite }; |
1564 | - |
1565 | -/** |
1566 | -\brief Class that represents a file. |
1567 | - |
1568 | -A file is a sequence of bytes. |
1569 | -*/ |
1570 | - |
1571 | -class File : public Item |
1572 | -{ |
1573 | -public: |
1574 | - ~File(); |
1575 | - File(File const&) = delete; |
1576 | - File& operator=(File const&) = delete; |
1577 | - File(File&&); |
1578 | - File& operator=(File&&); |
1579 | - |
1580 | - typedef std::unique_ptr<File> UPtr; |
1581 | - |
1582 | - /** |
1583 | - \brief Returns the size of the file in bytes. |
1584 | - \throws DestroyedException if the file has been destroyed. |
1585 | - */ |
1586 | - int64_t size() const; |
1587 | - |
1588 | - /** |
1589 | - \brief Creates an uploader for the file. |
1590 | - \param policy The conflict resolution policy. |
1591 | - \param ready_callback The runtime calls ready_callback once the uploader is ready to accept data. |
1592 | - */ |
1593 | - void create_uploader(ConflictPolicy policy, std::function<void(Uploader::UPtr)> ready_callback); |
1594 | - |
1595 | - /** |
1596 | - \brief Creates a downloader for the file. |
1597 | - \param ready_callback The runtime calls ready_callback once the downloader is ready to deliver data. |
1598 | - */ |
1599 | - void create_downloader(std::function<void(Downloader::UPtr)> ready_callback); |
1600 | -}; |
1601 | - |
1602 | -} // namespace client |
1603 | - |
1604 | -} // namespace storage |
1605 | - |
1606 | -} // namespace unity |
1607 | |
1608 | === removed file 'include/unity/storage/client/Item.h' |
1609 | --- include/unity/storage/client/Item.h 2016-04-19 04:01:16 +0000 |
1610 | +++ include/unity/storage/client/Item.h 1970-01-01 00:00:00 +0000 |
1611 | @@ -1,74 +0,0 @@ |
1612 | -#pragma once |
1613 | - |
1614 | -#include <map> |
1615 | -#include <memory> |
1616 | -#include <string> |
1617 | - |
1618 | -namespace unity |
1619 | -{ |
1620 | - |
1621 | -namespace storage |
1622 | -{ |
1623 | - |
1624 | -namespace client |
1625 | -{ |
1626 | - |
1627 | -namespace internal |
1628 | -{ |
1629 | - |
1630 | -class ItemImpl; |
1631 | - |
1632 | -} // namespace internal |
1633 | - |
1634 | -class DestroyResult; |
1635 | -class MetadataResult; |
1636 | - |
1637 | -/** |
1638 | -\brief Base class for files and directories. |
1639 | -*/ |
1640 | - |
1641 | -class Item |
1642 | -{ |
1643 | -public: |
1644 | - ~Item(); |
1645 | - Item(Item const&) = delete; |
1646 | - Item& operator=(Item const&) = delete; |
1647 | - Item(Item&&); |
1648 | - Item& operator=(Item&&); |
1649 | - |
1650 | - typedef std::unique_ptr<Item> UPtr; |
1651 | - |
1652 | - /** |
1653 | - \brief Returns the native identifier used by the provider. |
1654 | - */ |
1655 | - std::string native_identity() const; |
1656 | - |
1657 | - /** |
1658 | - \brief Returns the name of the file or directory. |
1659 | - |
1660 | - The returned name may not be the same as the name that was used to create the item because the provider |
1661 | - may have changed it in some way (such as converting upper case characters to lower case). |
1662 | - */ |
1663 | - std::string name() const; |
1664 | - |
1665 | - /** |
1666 | - \brief Returns metadata for the item. |
1667 | - \param metadata_callback The metadata functor can call MetadataResult::get_metadata() to retrieve the metadata. |
1668 | - */ |
1669 | - void get_metadata(std::function<void(MetadataResult const&)> metadata_callback); |
1670 | - |
1671 | - /** |
1672 | - \brief Permamently destroys the item. |
1673 | - \warning Destroying a directory recursively destroys its contents. |
1674 | - */ |
1675 | - void destroy(std::function<void(DestroyResult const&)> completion_callback); |
1676 | - |
1677 | -private: |
1678 | - Item(); |
1679 | -}; |
1680 | - |
1681 | -} // namespace client |
1682 | - |
1683 | -} // namespace storage |
1684 | - |
1685 | -} // namespace unity |
1686 | |
1687 | === removed file 'include/unity/storage/client/IterationResult.h' |
1688 | --- include/unity/storage/client/IterationResult.h 2016-04-20 01:56:37 +0000 |
1689 | +++ include/unity/storage/client/IterationResult.h 1970-01-01 00:00:00 +0000 |
1690 | @@ -1,33 +0,0 @@ |
1691 | -#pragma once |
1692 | - |
1693 | -#include <unity/storage/client/Item.h> |
1694 | - |
1695 | -namespace unity |
1696 | -{ |
1697 | - |
1698 | -namespace storage |
1699 | -{ |
1700 | - |
1701 | -namespace client |
1702 | -{ |
1703 | - |
1704 | -class IterationResult |
1705 | -{ |
1706 | -public: |
1707 | - ~IterationResult(); |
1708 | - IterationResult(IterationResult const&) = delete; |
1709 | - IterationResult& operator=(IterationResult const&) = delete; |
1710 | - IterationResult(IterationResult&&) = delete; |
1711 | - IterationResult& operator=(IterationResult&&) = delete; |
1712 | - |
1713 | - Item::UPtr get_item() const; |
1714 | - |
1715 | -private: |
1716 | - IterationResult(); |
1717 | -}; |
1718 | - |
1719 | -} // namespace client |
1720 | - |
1721 | -} // namespace storage |
1722 | - |
1723 | -} // namespace unity |
1724 | |
1725 | === removed file 'include/unity/storage/client/MetadataResult.h' |
1726 | --- include/unity/storage/client/MetadataResult.h 2016-04-20 01:56:37 +0000 |
1727 | +++ include/unity/storage/client/MetadataResult.h 1970-01-01 00:00:00 +0000 |
1728 | @@ -1,49 +0,0 @@ |
1729 | -#pragma once |
1730 | - |
1731 | -#include <unity/storage/client/Variant.h> |
1732 | - |
1733 | -#include <chrono> |
1734 | - |
1735 | -namespace unity |
1736 | -{ |
1737 | - |
1738 | -namespace storage |
1739 | -{ |
1740 | - |
1741 | -namespace client |
1742 | -{ |
1743 | - |
1744 | -class MetadataResult |
1745 | -{ |
1746 | -public: |
1747 | - ~MetadataResult(); |
1748 | - MetadataResult(MetadataResult const&) = delete; |
1749 | - MetadataResult& operator=(MetadataResult const&) = delete; |
1750 | - MetadataResult(MetadataResult&&) = delete; |
1751 | - MetadataResult& operator=(MetadataResult&&) = delete; |
1752 | - |
1753 | - VariantMap get_metadata() const; |
1754 | - |
1755 | - /** |
1756 | - \brief Returns the time at which the item was last modified. |
1757 | - \throws DestroyedException if the item has been destroyed. |
1758 | - */ |
1759 | - std::chrono::system_clock::time_point modified_time() const; |
1760 | - |
1761 | - /** |
1762 | - \brief Returns the mime type of the item. |
1763 | - \returns For directories, the mime type is `inode/directory`. If the mime type is unknown, the returned string is empty. |
1764 | - \throws DestroyedException if the item has been destroyed. |
1765 | - */ |
1766 | - std::string mime_type() const; |
1767 | - |
1768 | - |
1769 | -private: |
1770 | - MetadataResult(); |
1771 | -}; |
1772 | - |
1773 | -} // namespace client |
1774 | - |
1775 | -} // namespace storage |
1776 | - |
1777 | -} // namespace unity |
1778 | |
1779 | === removed file 'include/unity/storage/client/ParentResult.h' |
1780 | --- include/unity/storage/client/ParentResult.h 2016-04-20 01:56:37 +0000 |
1781 | +++ include/unity/storage/client/ParentResult.h 1970-01-01 00:00:00 +0000 |
1782 | @@ -1,33 +0,0 @@ |
1783 | -#pragma once |
1784 | - |
1785 | -#include <unity/storage/client/Directory.h> |
1786 | - |
1787 | -namespace unity |
1788 | -{ |
1789 | - |
1790 | -namespace storage |
1791 | -{ |
1792 | - |
1793 | -namespace client |
1794 | -{ |
1795 | - |
1796 | -class ParentResult |
1797 | -{ |
1798 | -public: |
1799 | - ~ParentResult(); |
1800 | - ParentResult(ParentResult const&) = delete; |
1801 | - ParentResult& operator=(ParentResult const&) = delete; |
1802 | - ParentResult(ParentResult&&) = delete; |
1803 | - ParentResult& operator=(ParentResult&&) = delete; |
1804 | - |
1805 | - Directory::UPtr get_directory() const; |
1806 | - |
1807 | -private: |
1808 | - ParentResult(); |
1809 | -}; |
1810 | - |
1811 | -} // namespace client |
1812 | - |
1813 | -} // namespace storage |
1814 | - |
1815 | -} // namespace unity |
1816 | |
1817 | === removed file 'include/unity/storage/client/Root.h' |
1818 | --- include/unity/storage/client/Root.h 2016-04-20 01:56:37 +0000 |
1819 | +++ include/unity/storage/client/Root.h 1970-01-01 00:00:00 +0000 |
1820 | @@ -1,44 +0,0 @@ |
1821 | -#pragma once |
1822 | - |
1823 | -#include <unity/storage/client/Directory.h> |
1824 | - |
1825 | -namespace unity |
1826 | -{ |
1827 | - |
1828 | -namespace storage |
1829 | -{ |
1830 | - |
1831 | -namespace client |
1832 | -{ |
1833 | - |
1834 | -class Result; // Same as CreateResult? |
1835 | - |
1836 | -/** |
1837 | -\brief Class that represents a root directory. |
1838 | -*/ |
1839 | - |
1840 | -class Root : public Directory |
1841 | -{ |
1842 | -public: |
1843 | - ~Root(); |
1844 | - Root(Root const&) = delete; |
1845 | - Root& operator=(Root const&) = delete; |
1846 | - Root(Root&&); |
1847 | - Root& operator=(Root&&); |
1848 | - |
1849 | - typedef std::unique_ptr<Root> UPtr; |
1850 | - |
1851 | - int64_t free_space_bytes() const; // Needs to be async, make part of metadata? |
1852 | - int64_t used_space_bytes() const; // Needs to be async, make part of metadata? |
1853 | - |
1854 | - void get(std::string native_identity, std::function<void(Result)> result_callback) const; |
1855 | - |
1856 | -private: |
1857 | - Root(); |
1858 | -}; |
1859 | - |
1860 | -} // namespace client |
1861 | - |
1862 | -} // namespace storage |
1863 | - |
1864 | -} // namespace unity |
1865 | |
1866 | === removed file 'include/unity/storage/client/Runtime.h' |
1867 | --- include/unity/storage/client/Runtime.h 2016-04-19 04:01:16 +0000 |
1868 | +++ include/unity/storage/client/Runtime.h 1970-01-01 00:00:00 +0000 |
1869 | @@ -1,39 +0,0 @@ |
1870 | -#pragma once |
1871 | - |
1872 | -#include <memory> |
1873 | - |
1874 | -namespace unity |
1875 | -{ |
1876 | - |
1877 | -namespace storage |
1878 | -{ |
1879 | - |
1880 | -namespace client |
1881 | -{ |
1882 | - |
1883 | -class AccountsResult; |
1884 | - |
1885 | -class Runtime |
1886 | -{ |
1887 | -public: |
1888 | - ~Runtime(); |
1889 | - Runtime(Runtime const&) = delete; |
1890 | - Runtime& operator=(Runtime const&) = delete; |
1891 | - Runtime(Runtime&&); |
1892 | - Runtime& operator=(Runtime&&); |
1893 | - |
1894 | - typedef std::unique_ptr<Runtime> UPtr; |
1895 | - |
1896 | - static UPtr create(); |
1897 | - |
1898 | - void get_accounts(std::function<void(AccountsResult const&)> accounts_callback); |
1899 | - |
1900 | -private: |
1901 | - Runtime(); |
1902 | -}; |
1903 | - |
1904 | -} // namespace client |
1905 | - |
1906 | -} // namespace storage |
1907 | - |
1908 | -} // namespace unity |
1909 | |
1910 | === removed file 'include/unity/storage/client/UploadResult.h' |
1911 | --- include/unity/storage/client/UploadResult.h 2016-04-20 01:56:37 +0000 |
1912 | +++ include/unity/storage/client/UploadResult.h 1970-01-01 00:00:00 +0000 |
1913 | @@ -1,40 +0,0 @@ |
1914 | -#pragma once |
1915 | - |
1916 | -#include <unity/storage/client/Item.h> |
1917 | - |
1918 | -namespace unity |
1919 | -{ |
1920 | - |
1921 | -namespace storage |
1922 | -{ |
1923 | - |
1924 | -namespace client |
1925 | -{ |
1926 | - |
1927 | -class UploadResult |
1928 | -{ |
1929 | -public: |
1930 | - ~UploadResult(); |
1931 | - UploadResult(UploadResult const&) = delete; |
1932 | - UploadResult& operator=(UploadResult const&) = delete; |
1933 | - UploadResult(UploadResult&&) = delete; |
1934 | - UploadResult& operator=(UploadResult&&) = delete; |
1935 | - |
1936 | - /** |
1937 | - Checks for errors once an upload has completed. |
1938 | - |
1939 | - If the download has completed, this method returns normally. Otherwise, it throws an exception |
1940 | - that provides more details about the error. |
1941 | - \throws TODO: list of exceptions |
1942 | - */ |
1943 | - void check_error() const; |
1944 | - |
1945 | -private: |
1946 | - UploadResult(); |
1947 | -}; |
1948 | - |
1949 | -} // namespace client |
1950 | - |
1951 | -} // namespace storage |
1952 | - |
1953 | -} // namespace unity |
1954 | |
1955 | === removed file 'include/unity/storage/client/Uploader.h' |
1956 | --- include/unity/storage/client/Uploader.h 2016-04-20 01:56:37 +0000 |
1957 | +++ include/unity/storage/client/Uploader.h 1970-01-01 00:00:00 +0000 |
1958 | @@ -1,77 +0,0 @@ |
1959 | -#pragma once |
1960 | - |
1961 | -#include <memory> |
1962 | - |
1963 | -namespace unity |
1964 | -{ |
1965 | - |
1966 | -namespace storage |
1967 | -{ |
1968 | - |
1969 | -namespace client |
1970 | -{ |
1971 | - |
1972 | -class UploadResult; |
1973 | - |
1974 | -class Uploader |
1975 | -{ |
1976 | -public: |
1977 | - ~Uploader(); |
1978 | - Uploader(Uploader const&) = delete; |
1979 | - Uploader& operator=(Uploader const&) = delete; |
1980 | - Uploader(Uploader&&); |
1981 | - Uploader& operator=(Uploader&&); |
1982 | - |
1983 | - typedef std::unique_ptr<Uploader> UPtr; |
1984 | - |
1985 | - /** |
1986 | - \brief Returns a file descriptor that is open for writing. |
1987 | - |
1988 | - To upload the file contents, write to the returned file descriptor. The descriptor |
1989 | - may not be able to accept arbitrarily large amounts of data without blocking. If the |
1990 | - code that writes to the descriptor cannot block, use non-blocking writes. Once the |
1991 | - contents of the file have been written, call close() to check for errors. |
1992 | - |
1993 | - If a write on the descriptor returns an error, this indicates a fatal error condition, and further |
1994 | - writes on the descriptor will fail as well. In this case, a call to close() results in close_callback() |
1995 | - being invoked as usual, and UploadResult::check_error() will return the error details |
1996 | - via an exception. |
1997 | - |
1998 | - After an error, the file is in an indeterminate state. |
1999 | - \return A file descriptor open for writing. If fd() is called after close() or cancel() |
2000 | - have been called, the return value is `-1`. |
2001 | - \throws TODO: All sorts of exceptions when things go wrong, list them. |
2002 | - */ |
2003 | - int fd() const; |
2004 | - |
2005 | - /** |
2006 | - \brief Finalizes the upload. |
2007 | - |
2008 | - Once you have written the file contents to the descriptor returned by fd(), you must call close(). The runtime |
2009 | - calls closes the descriptor and calls close_callback once the state of the upload has been verified. |
2010 | - Call UploadResult::check_error() from the callback to verify whether the upload completed successfully. |
2011 | - \param close_callback The functor called by the runtime once the upload is finalized. |
2012 | - The passed value must not be `nullptr`. |
2013 | - */ |
2014 | - void close(std::function<void(UploadResult const&)> close_callback); |
2015 | - |
2016 | - /** |
2017 | - \brief Cancels an upload. |
2018 | - |
2019 | - Calling cancel() informs the provider that the upload is no longer needed. The provider |
2020 | - will make a best-effort attempt to cancel the upload to the remote service. |
2021 | - |
2022 | - Calling cancel() more than once, or calling cancel() after a call to close() is safe and does nothing. |
2023 | - \throws TODO: All sorts of things. |
2024 | - */ |
2025 | - void cancel(); |
2026 | - |
2027 | -private: |
2028 | - Uploader(); |
2029 | -}; |
2030 | - |
2031 | -} // namespace client |
2032 | - |
2033 | -} // namespace storage |
2034 | - |
2035 | -} // namespace unity |
2036 | |
2037 | === removed file 'include/unity/storage/client/Variant.h' |
2038 | --- include/unity/storage/client/Variant.h 2016-04-19 04:01:16 +0000 |
2039 | +++ include/unity/storage/client/Variant.h 1970-01-01 00:00:00 +0000 |
2040 | @@ -1,236 +0,0 @@ |
2041 | -/* |
2042 | - * Copyright (C) 2013 Canonical Ltd |
2043 | - * |
2044 | - * This program is free software: you can redistribute it and/or modify |
2045 | - * it under the terms of the GNU Lesser General Public License version 3 as |
2046 | - * published by the Free Software Foundation. |
2047 | - * |
2048 | - * This program is distributed in the hope that it will be useful, |
2049 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2050 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2051 | - * GNU Lesser General Public License for more details. |
2052 | - * |
2053 | - * You should have received a copy of the GNU Lesser General Public License |
2054 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2055 | - * |
2056 | - * Authored by: Michi Henning <michi.henning@canonical.com> |
2057 | - */ |
2058 | - |
2059 | -#pragma once |
2060 | - |
2061 | -#include <memory> |
2062 | -#include <string> |
2063 | -#include <map> |
2064 | -#include <vector> |
2065 | - |
2066 | -namespace unity |
2067 | -{ |
2068 | - |
2069 | -namespace storage |
2070 | -{ |
2071 | - |
2072 | -namespace client |
2073 | -{ |
2074 | - |
2075 | -class Variant; |
2076 | - |
2077 | -/** |
2078 | - \typedef VariantMap |
2079 | - \brief A dictionary of (string, Variant) pairs. |
2080 | -*/ |
2081 | -typedef std::map<std::string, Variant> VariantMap; |
2082 | - |
2083 | -/** |
2084 | - \brief An array of variants |
2085 | -*/ |
2086 | -typedef std::vector<Variant> VariantArray; |
2087 | - |
2088 | -namespace internal |
2089 | -{ |
2090 | - |
2091 | -class VariantImpl; |
2092 | -class NullVariant; |
2093 | - |
2094 | -} // namespace internal |
2095 | - |
2096 | -/** |
2097 | -\brief Simple variant class that can hold an integer, boolean, string, double, dictionary, array or null value. |
2098 | -*/ |
2099 | - |
2100 | -class Variant final |
2101 | -{ |
2102 | -public: |
2103 | - /** |
2104 | - \brief Type of value held by a Variant instance. |
2105 | - */ |
2106 | - enum Type { Null, Int, Bool, String, Double, Dict, Array }; |
2107 | - |
2108 | - /**@name Constructors and destructor |
2109 | - */ |
2110 | - /** |
2111 | - \brief The default constructor creates a Variant instance containing a null. |
2112 | - */ |
2113 | - Variant() noexcept; |
2114 | - |
2115 | - /** |
2116 | - \brief Creates a Variant instance that stores the supplied integer. |
2117 | - */ |
2118 | - explicit Variant(int64_t val) noexcept; |
2119 | - |
2120 | - /** |
2121 | - \brief Creates a Variant instance that stores the supplied double. |
2122 | - */ |
2123 | - explicit Variant(double val) noexcept; |
2124 | - |
2125 | - /** |
2126 | - \brief Creates a Variant instance that stores the supplied boolean. |
2127 | - */ |
2128 | - explicit Variant(bool val) noexcept; |
2129 | - |
2130 | - /** |
2131 | - \brief Creates a Variant instance that stores the supplied string. |
2132 | - */ |
2133 | - explicit Variant(std::string const& val); |
2134 | - |
2135 | - /** |
2136 | - \brief Converts the supplied pointer to a string and stores the string in the Variant instance. |
2137 | - */ |
2138 | - explicit Variant(char const* val); // Required to prevent Variant("Hello") from storing a bool |
2139 | - |
2140 | - explicit Variant(VariantMap const& val); |
2141 | - |
2142 | - explicit Variant(VariantArray const& val); |
2143 | - |
2144 | - /** |
2145 | - \brief Constructs a null variant. |
2146 | - */ |
2147 | - static Variant const& null(); |
2148 | - |
2149 | - /** |
2150 | - \brief Destructor. |
2151 | - */ |
2152 | - ~Variant(); |
2153 | - |
2154 | - /**@name Copy and assignment |
2155 | - Copy and assignment operators (move and non-move versions) have the usual value semantics. |
2156 | - */ |
2157 | - //{@ |
2158 | - Variant(Variant const&); |
2159 | - Variant(Variant&&); |
2160 | - Variant& operator=(Variant const&); |
2161 | - Variant& operator=(Variant&&); |
2162 | - //@} |
2163 | - |
2164 | - /**@name Value assignment |
2165 | - The assignment operators replace the value currently held by a Variant with the supplied value, potentially |
2166 | - changing the type of the value held by the Variant. Assigning a `const char*` to a Variant stores the |
2167 | - corresponding `std::string` value. |
2168 | - */ |
2169 | - //{@ |
2170 | - Variant& operator=(int64_t val) noexcept; |
2171 | - Variant& operator=(double val) noexcept; |
2172 | - Variant& operator=(bool val) noexcept; |
2173 | - Variant& operator=(std::string const& val); |
2174 | - Variant& operator=(char const* val); // Required to prevent v = "Hello" from storing a bool |
2175 | - Variant& operator=(VariantMap const& val); |
2176 | - Variant& operator=(VariantArray const& val); |
2177 | - //@} |
2178 | - |
2179 | - /**@name Comparison operators |
2180 | - Two variants are considered equal if they both store values of the same type and equal value. |
2181 | - |
2182 | - For Variants storing values of different type, ordering follows the types defined in the Type enum. For example, |
2183 | - any integer value compares less than any boolean value. For Variants of the same type, the stored values determine |
2184 | - order as usual. |
2185 | - */ |
2186 | - //{@ |
2187 | - bool operator==(Variant const&) const noexcept; |
2188 | - bool operator<(Variant const&) const noexcept; |
2189 | - //@} |
2190 | - |
2191 | - /**@name Value accessors |
2192 | - The accessor methods retrieve a value of the specified type. |
2193 | - |
2194 | - If a Variant currently stores a value of different type, these methods throw `unity::LogicException`. |
2195 | - */ |
2196 | - //{@ |
2197 | - int64_t get_int() const; |
2198 | - double get_double() const; |
2199 | - bool get_bool() const; |
2200 | - std::string get_string() const; |
2201 | - VariantMap get_dict() const; |
2202 | - VariantArray get_array() const; |
2203 | - |
2204 | - /** |
2205 | - \brief Test if variant holds null value. |
2206 | - \return True if variant holds null. |
2207 | - */ |
2208 | - bool is_null() const; |
2209 | - //@} |
2210 | - |
2211 | - /**@name Observers |
2212 | - */ |
2213 | - /** |
2214 | - \brief Returns the type of value currently stored by this Variant. |
2215 | - */ |
2216 | - Type which() const noexcept; |
2217 | - |
2218 | - /** |
2219 | - \brief Returns a hash value for this Variant. |
2220 | - */ |
2221 | - size_t hash() const; |
2222 | - |
2223 | - /**@name Modifiers |
2224 | - */ |
2225 | - /** |
2226 | - \brief Swaps the contents of this Variant with `other`. |
2227 | - */ |
2228 | - void swap(Variant& other) noexcept; |
2229 | - |
2230 | - /**@name Serialization |
2231 | - */ |
2232 | - //@{ |
2233 | - /** |
2234 | - \brief Serializes the variant to a JSON encoded string. |
2235 | - */ |
2236 | - std::string serialize_json() const; // TODO: drop this? |
2237 | - /** |
2238 | - \brief Deserializes a JSON encoded string to a `Variant`. |
2239 | - */ |
2240 | - static Variant deserialize_json(std::string const& json_string); // TODO: drop this? |
2241 | - //@} |
2242 | - |
2243 | -private: |
2244 | - Variant(internal::NullVariant const&); |
2245 | - |
2246 | - std::unique_ptr<internal::VariantImpl> p; |
2247 | - friend class VariantImpl; |
2248 | -}; |
2249 | - |
2250 | -/** |
2251 | -\brief Swaps the contents of two Variants. |
2252 | -*/ |
2253 | -void swap(Variant&, Variant&) noexcept; |
2254 | - |
2255 | -} // namespace client |
2256 | - |
2257 | -} // namespace storage |
2258 | - |
2259 | -} // namespace unity |
2260 | - |
2261 | -namespace std |
2262 | -{ |
2263 | - |
2264 | -template<> |
2265 | -struct hash<unity::storage::client::Variant> |
2266 | -{ |
2267 | - typedef unity::storage::client::Variant argument_type; |
2268 | - typedef std::size_t result_type; |
2269 | - |
2270 | - result_type operator()(argument_type const& s) const |
2271 | - { |
2272 | - return s.hash(); |
2273 | - } |
2274 | -}; |
2275 | - |
2276 | -} // namespace std |
2277 | |
2278 | === removed directory 'include/unity/storage/client/internal' |
2279 | === added file 'include/unity/storage/common.h' |
2280 | --- include/unity/storage/common.h 1970-01-01 00:00:00 +0000 |
2281 | +++ include/unity/storage/common.h 2016-07-21 12:22:21 +0000 |
2282 | @@ -0,0 +1,41 @@ |
2283 | +/* |
2284 | + * Copyright (C) 2016 Canonical Ltd |
2285 | + * |
2286 | + * This program is free software: you can redistribute it and/or modify |
2287 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2288 | + * published by the Free Software Foundation. |
2289 | + * |
2290 | + * This program is distributed in the hope that it will be useful, |
2291 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2292 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2293 | + * GNU Lesser General Public License for more details. |
2294 | + * |
2295 | + * You should have received a copy of the GNU Lesser General Public License |
2296 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2297 | + * |
2298 | + * Authors: Michi Henning <michi.henning@canonical.com> |
2299 | + */ |
2300 | + |
2301 | +#pragma once |
2302 | + |
2303 | +namespace unity |
2304 | +{ |
2305 | +namespace storage |
2306 | +{ |
2307 | + |
2308 | +enum class ItemType |
2309 | +{ |
2310 | + file, |
2311 | + folder, |
2312 | + root, |
2313 | + LAST_ENTRY__ |
2314 | +}; |
2315 | + |
2316 | +enum class ConflictPolicy |
2317 | +{ |
2318 | + error_if_conflict, |
2319 | + overwrite, |
2320 | +}; |
2321 | + |
2322 | +} // namespace storage |
2323 | +} // namespace unity |
2324 | |
2325 | === added directory 'include/unity/storage/internal' |
2326 | === added file 'include/unity/storage/internal/ItemMetadata.h' |
2327 | --- include/unity/storage/internal/ItemMetadata.h 1970-01-01 00:00:00 +0000 |
2328 | +++ include/unity/storage/internal/ItemMetadata.h 2016-07-21 12:22:21 +0000 |
2329 | @@ -0,0 +1,48 @@ |
2330 | +/* |
2331 | + * Copyright (C) 2016 Canonical Ltd |
2332 | + * |
2333 | + * This program is free software: you can redistribute it and/or modify |
2334 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2335 | + * published by the Free Software Foundation. |
2336 | + * |
2337 | + * This program is distributed in the hope that it will be useful, |
2338 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2339 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2340 | + * GNU Lesser General Public License for more details. |
2341 | + * |
2342 | + * You should have received a copy of the GNU Lesser General Public License |
2343 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2344 | + * |
2345 | + * Authors: Michi Henning <michi.henning@canonical.com> |
2346 | + */ |
2347 | + |
2348 | +#pragma once |
2349 | + |
2350 | +#include <unity/storage/common.h> |
2351 | + |
2352 | +#pragma GCC diagnostic push |
2353 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
2354 | +#include <QMap> |
2355 | +#include <QVariant> |
2356 | +#pragma GCC diagnostic pop |
2357 | + |
2358 | +namespace unity |
2359 | +{ |
2360 | +namespace storage |
2361 | +{ |
2362 | +namespace internal |
2363 | +{ |
2364 | + |
2365 | +struct ItemMetadata |
2366 | +{ |
2367 | + QString item_id; |
2368 | + QString parent_id; |
2369 | + QString name; |
2370 | + QString etag; |
2371 | + ItemType type; |
2372 | + QMap<QString, QVariant> metadata; |
2373 | +}; |
2374 | + |
2375 | +} // namespace internal |
2376 | +} // namespace storage |
2377 | +} // namespace unity |
2378 | |
2379 | === added directory 'include/unity/storage/provider' |
2380 | === added file 'include/unity/storage/provider/CMakeLists.txt' |
2381 | --- include/unity/storage/provider/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
2382 | +++ include/unity/storage/provider/CMakeLists.txt 2016-07-21 12:22:21 +0000 |
2383 | @@ -0,0 +1,5 @@ |
2384 | +set(includeprefix unity/storage/provider) |
2385 | +file(GLOB provider_headers *.h) |
2386 | + |
2387 | +install(FILES ${provider_headers} |
2388 | + DESTINATION ${provider_base_includedir}/${includeprefix}) |
2389 | |
2390 | === added file 'include/unity/storage/provider/Credentials.h' |
2391 | --- include/unity/storage/provider/Credentials.h 1970-01-01 00:00:00 +0000 |
2392 | +++ include/unity/storage/provider/Credentials.h 2016-07-21 12:22:21 +0000 |
2393 | @@ -0,0 +1,62 @@ |
2394 | +/* |
2395 | + * Copyright (C) 2016 Canonical Ltd |
2396 | + * |
2397 | + * This program is free software: you can redistribute it and/or modify |
2398 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2399 | + * published by the Free Software Foundation. |
2400 | + * |
2401 | + * This program is distributed in the hope that it will be useful, |
2402 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2403 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2404 | + * GNU Lesser General Public License for more details. |
2405 | + * |
2406 | + * You should have received a copy of the GNU Lesser General Public License |
2407 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2408 | + * |
2409 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2410 | + */ |
2411 | + |
2412 | +#pragma once |
2413 | + |
2414 | +#include <unity/storage/visibility.h> |
2415 | + |
2416 | +#include <boost/blank.hpp> |
2417 | +#include <boost/variant.hpp> |
2418 | + |
2419 | +#include <string> |
2420 | + |
2421 | +namespace unity |
2422 | +{ |
2423 | +namespace storage |
2424 | +{ |
2425 | +namespace provider |
2426 | +{ |
2427 | + |
2428 | +struct UNITY_STORAGE_EXPORT NoCredentials |
2429 | +{ |
2430 | +}; |
2431 | + |
2432 | +struct UNITY_STORAGE_EXPORT OAuth1Credentials |
2433 | +{ |
2434 | + std::string consumer_key; |
2435 | + std::string consumer_secret; |
2436 | + std::string token; |
2437 | + std::string token_secret; |
2438 | +}; |
2439 | + |
2440 | +struct UNITY_STORAGE_EXPORT OAuth2Credentials |
2441 | +{ |
2442 | + std::string access_token; |
2443 | +}; |
2444 | + |
2445 | +struct UNITY_STORAGE_EXPORT PasswordCredentials |
2446 | +{ |
2447 | + std::string username; |
2448 | + std::string password; |
2449 | +}; |
2450 | + |
2451 | +typedef boost::variant<boost::blank,OAuth1Credentials,OAuth2Credentials,PasswordCredentials> Credentials; |
2452 | + |
2453 | +} |
2454 | +} |
2455 | +} |
2456 | |
2457 | === added file 'include/unity/storage/provider/DownloadJob.h' |
2458 | --- include/unity/storage/provider/DownloadJob.h 1970-01-01 00:00:00 +0000 |
2459 | +++ include/unity/storage/provider/DownloadJob.h 2016-07-21 12:22:21 +0000 |
2460 | @@ -0,0 +1,68 @@ |
2461 | +/* |
2462 | + * Copyright (C) 2016 Canonical Ltd |
2463 | + * |
2464 | + * This program is free software: you can redistribute it and/or modify |
2465 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2466 | + * published by the Free Software Foundation. |
2467 | + * |
2468 | + * This program is distributed in the hope that it will be useful, |
2469 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2470 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2471 | + * GNU Lesser General Public License for more details. |
2472 | + * |
2473 | + * You should have received a copy of the GNU Lesser General Public License |
2474 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2475 | + * |
2476 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2477 | + */ |
2478 | + |
2479 | +#pragma once |
2480 | + |
2481 | +#include <unity/storage/visibility.h> |
2482 | + |
2483 | +#include <boost/thread/future.hpp> |
2484 | +#include <stdexcept> |
2485 | +#include <string> |
2486 | + |
2487 | +namespace unity |
2488 | +{ |
2489 | +namespace storage |
2490 | +{ |
2491 | +namespace provider |
2492 | +{ |
2493 | +namespace internal |
2494 | +{ |
2495 | +class DownloadJobImpl; |
2496 | +class PendingJobs; |
2497 | +class ProviderInterface; |
2498 | +} |
2499 | + |
2500 | +class UNITY_STORAGE_EXPORT DownloadJob |
2501 | +{ |
2502 | +public: |
2503 | + DownloadJob(std::string const& download_id); |
2504 | + virtual ~DownloadJob(); |
2505 | + |
2506 | + std::string const& download_id() const; |
2507 | + int write_socket() const; |
2508 | + |
2509 | + // If the result of the download is reported with either of the |
2510 | + // following two functions, then neither cancel() or finish() will |
2511 | + // be called. |
2512 | + void report_complete(); |
2513 | + void report_error(std::exception_ptr p); |
2514 | + |
2515 | + virtual boost::future<void> cancel() = 0; |
2516 | + virtual boost::future<void> finish() = 0; |
2517 | + |
2518 | +protected: |
2519 | + DownloadJob(internal::DownloadJobImpl *p) UNITY_STORAGE_HIDDEN; |
2520 | + internal::DownloadJobImpl *p_ = nullptr; |
2521 | + |
2522 | + friend class internal::PendingJobs; |
2523 | + friend class internal::ProviderInterface; |
2524 | +}; |
2525 | + |
2526 | +} |
2527 | +} |
2528 | +} |
2529 | |
2530 | === added file 'include/unity/storage/provider/ProviderBase.h' |
2531 | --- include/unity/storage/provider/ProviderBase.h 1970-01-01 00:00:00 +0000 |
2532 | +++ include/unity/storage/provider/ProviderBase.h 2016-07-21 12:22:21 +0000 |
2533 | @@ -0,0 +1,110 @@ |
2534 | +/* |
2535 | + * Copyright (C) 2016 Canonical Ltd |
2536 | + * |
2537 | + * This program is free software: you can redistribute it and/or modify |
2538 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2539 | + * published by the Free Software Foundation. |
2540 | + * |
2541 | + * This program is distributed in the hope that it will be useful, |
2542 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2543 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2544 | + * GNU Lesser General Public License for more details. |
2545 | + * |
2546 | + * You should have received a copy of the GNU Lesser General Public License |
2547 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2548 | + * |
2549 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2550 | + */ |
2551 | + |
2552 | +#pragma once |
2553 | + |
2554 | +#include <unity/storage/common.h> |
2555 | +#include <unity/storage/visibility.h> |
2556 | +#include <unity/storage/provider/Credentials.h> |
2557 | + |
2558 | +#include <boost/thread/future.hpp> |
2559 | + |
2560 | +#include <sys/types.h> |
2561 | +#include <string> |
2562 | +#include <map> |
2563 | +#include <vector> |
2564 | + |
2565 | +namespace unity |
2566 | +{ |
2567 | +namespace storage |
2568 | +{ |
2569 | +namespace provider |
2570 | +{ |
2571 | + |
2572 | +class DownloadJob; |
2573 | +class UploadJob; |
2574 | + |
2575 | +struct UNITY_STORAGE_EXPORT Context |
2576 | +{ |
2577 | + uid_t uid; |
2578 | + pid_t pid; |
2579 | + std::string security_label; |
2580 | + |
2581 | + Credentials credentials; |
2582 | +}; |
2583 | + |
2584 | +struct UNITY_STORAGE_EXPORT Item |
2585 | +{ |
2586 | + std::string item_id; |
2587 | + std::string parent_id; |
2588 | + std::string title; |
2589 | + std::string etag; |
2590 | + unity::storage::ItemType type; |
2591 | + // Should be map<string,variant> |
2592 | + std::map<std::string,std::string> metadata; |
2593 | +}; |
2594 | + |
2595 | +typedef std::vector<Item> ItemList; |
2596 | + |
2597 | +class UNITY_STORAGE_EXPORT ProviderBase |
2598 | +{ |
2599 | +public: |
2600 | + ProviderBase(); |
2601 | + virtual ~ProviderBase(); |
2602 | + |
2603 | + ProviderBase(ProviderBase const& other) = delete; |
2604 | + ProviderBase& operator=(ProviderBase const& other) = delete; |
2605 | + |
2606 | + virtual boost::future<ItemList> roots(Context const& context) = 0; |
2607 | + virtual boost::future<std::tuple<ItemList,std::string>> list( |
2608 | + std::string const& item_id, std::string const& page_token, |
2609 | + Context const& context) = 0; |
2610 | + virtual boost::future<ItemList> lookup( |
2611 | + std::string const& parent_id, std::string const& name, |
2612 | + Context const& context) = 0; |
2613 | + virtual boost::future<Item> metadata(std::string const& item_id, |
2614 | + Context const& context) = 0; |
2615 | + |
2616 | + virtual boost::future<Item> create_folder( |
2617 | + std::string const& parent_id, std::string const& name, |
2618 | + Context const& context) = 0; |
2619 | + |
2620 | + virtual boost::future<std::unique_ptr<UploadJob>> create_file( |
2621 | + std::string const& parent_id, std::string const& title, |
2622 | + std::string const& content_type, bool allow_overwrite, |
2623 | + Context const& context) = 0; |
2624 | + virtual boost::future<std::unique_ptr<UploadJob>> update( |
2625 | + std::string const& item_id, std::string const& old_etag, |
2626 | + Context const& context) = 0; |
2627 | + |
2628 | + virtual boost::future<std::unique_ptr<DownloadJob>> download( |
2629 | + std::string const& item_id, Context const& context) = 0; |
2630 | + |
2631 | + virtual boost::future<void> delete_item( |
2632 | + std::string const& item_id, Context const& context) = 0; |
2633 | + virtual boost::future<Item> move( |
2634 | + std::string const& item_id, std::string const& new_parent_id, |
2635 | + std::string const& new_name, Context const& context) = 0; |
2636 | + virtual boost::future<Item> copy( |
2637 | + std::string const& item_id, std::string const& new_parent_id, |
2638 | + std::string const& new_name, Context const& context) = 0; |
2639 | +}; |
2640 | + |
2641 | +} |
2642 | +} |
2643 | +} |
2644 | |
2645 | === added file 'include/unity/storage/provider/Server.h' |
2646 | --- include/unity/storage/provider/Server.h 1970-01-01 00:00:00 +0000 |
2647 | +++ include/unity/storage/provider/Server.h 2016-07-21 12:22:21 +0000 |
2648 | @@ -0,0 +1,70 @@ |
2649 | +/* |
2650 | + * Copyright (C) 2016 Canonical Ltd |
2651 | + * |
2652 | + * This program is free software: you can redistribute it and/or modify |
2653 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2654 | + * published by the Free Software Foundation. |
2655 | + * |
2656 | + * This program is distributed in the hope that it will be useful, |
2657 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2658 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2659 | + * GNU Lesser General Public License for more details. |
2660 | + * |
2661 | + * You should have received a copy of the GNU Lesser General Public License |
2662 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2663 | + * |
2664 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2665 | + */ |
2666 | + |
2667 | +#pragma once |
2668 | + |
2669 | +#include <unity/storage/visibility.h> |
2670 | + |
2671 | +#include <memory> |
2672 | +#include <string> |
2673 | + |
2674 | +namespace unity |
2675 | +{ |
2676 | +namespace storage |
2677 | +{ |
2678 | +namespace provider |
2679 | +{ |
2680 | + |
2681 | +namespace internal |
2682 | +{ |
2683 | +class ServerImpl; |
2684 | +} |
2685 | + |
2686 | +class ProviderBase; |
2687 | + |
2688 | +class UNITY_STORAGE_EXPORT ServerBase |
2689 | +{ |
2690 | +public: |
2691 | + ServerBase(std::string const& bus_name, std::string const& account_service_id); |
2692 | + virtual ~ServerBase(); |
2693 | + |
2694 | + void init(int& argc, char** argv); |
2695 | + void run(); |
2696 | + |
2697 | +protected: |
2698 | + virtual std::unique_ptr<ProviderBase> make_provider() = 0; |
2699 | +private: |
2700 | + std::unique_ptr<internal::ServerImpl> p_; |
2701 | + |
2702 | + friend class internal::ServerImpl; |
2703 | +}; |
2704 | + |
2705 | +template <typename T> |
2706 | +class Server : public ServerBase |
2707 | +{ |
2708 | +public: |
2709 | + using ServerBase::ServerBase; |
2710 | +protected: |
2711 | + std::unique_ptr<ProviderBase> make_provider() override { |
2712 | + return std::unique_ptr<ProviderBase>(new T); |
2713 | + } |
2714 | +}; |
2715 | + |
2716 | +} |
2717 | +} |
2718 | +} |
2719 | |
2720 | === added file 'include/unity/storage/provider/TempfileUploadJob.h' |
2721 | --- include/unity/storage/provider/TempfileUploadJob.h 1970-01-01 00:00:00 +0000 |
2722 | +++ include/unity/storage/provider/TempfileUploadJob.h 2016-07-21 12:22:21 +0000 |
2723 | @@ -0,0 +1,53 @@ |
2724 | +/* |
2725 | + * Copyright (C) 2016 Canonical Ltd |
2726 | + * |
2727 | + * This program is free software: you can redistribute it and/or modify |
2728 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2729 | + * published by the Free Software Foundation. |
2730 | + * |
2731 | + * This program is distributed in the hope that it will be useful, |
2732 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2733 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2734 | + * GNU Lesser General Public License for more details. |
2735 | + * |
2736 | + * You should have received a copy of the GNU Lesser General Public License |
2737 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2738 | + * |
2739 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2740 | + */ |
2741 | + |
2742 | +#pragma once |
2743 | + |
2744 | +#include <unity/storage/provider/UploadJob.h> |
2745 | +#include <unity/storage/visibility.h> |
2746 | + |
2747 | +#include <string> |
2748 | +#include <memory> |
2749 | + |
2750 | +namespace unity |
2751 | +{ |
2752 | +namespace storage |
2753 | +{ |
2754 | +namespace provider |
2755 | +{ |
2756 | + |
2757 | +namespace internal |
2758 | +{ |
2759 | +class TempfileUploadJobImpl; |
2760 | +} |
2761 | + |
2762 | +class UNITY_STORAGE_EXPORT TempfileUploadJob : public UploadJob |
2763 | +{ |
2764 | +public: |
2765 | + TempfileUploadJob(std::string const& upload_id); |
2766 | + virtual ~TempfileUploadJob(); |
2767 | + |
2768 | + std::string file_name() const; |
2769 | + |
2770 | +protected: |
2771 | + TempfileUploadJob(internal::TempfileUploadJobImpl *p) UNITY_STORAGE_HIDDEN; |
2772 | +}; |
2773 | + |
2774 | +} |
2775 | +} |
2776 | +} |
2777 | |
2778 | === added file 'include/unity/storage/provider/UploadJob.h' |
2779 | --- include/unity/storage/provider/UploadJob.h 1970-01-01 00:00:00 +0000 |
2780 | +++ include/unity/storage/provider/UploadJob.h 2016-07-21 12:22:21 +0000 |
2781 | @@ -0,0 +1,68 @@ |
2782 | +/* |
2783 | + * Copyright (C) 2016 Canonical Ltd |
2784 | + * |
2785 | + * This program is free software: you can redistribute it and/or modify |
2786 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2787 | + * published by the Free Software Foundation. |
2788 | + * |
2789 | + * This program is distributed in the hope that it will be useful, |
2790 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2791 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2792 | + * GNU Lesser General Public License for more details. |
2793 | + * |
2794 | + * You should have received a copy of the GNU Lesser General Public License |
2795 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2796 | + * |
2797 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2798 | + */ |
2799 | + |
2800 | +#pragma once |
2801 | + |
2802 | +#include <unity/storage/visibility.h> |
2803 | + |
2804 | +#include <boost/thread/future.hpp> |
2805 | +#include <string> |
2806 | + |
2807 | +namespace unity |
2808 | +{ |
2809 | +namespace storage |
2810 | +{ |
2811 | +namespace provider |
2812 | +{ |
2813 | + |
2814 | +struct Item; |
2815 | + |
2816 | +namespace internal |
2817 | +{ |
2818 | +class PendingJobs; |
2819 | +class ProviderInterface; |
2820 | +class UploadJobImpl; |
2821 | +} |
2822 | + |
2823 | +class UNITY_STORAGE_EXPORT UploadJob |
2824 | +{ |
2825 | +public: |
2826 | + UploadJob(std::string const& upload_id); |
2827 | + virtual ~UploadJob(); |
2828 | + |
2829 | + std::string const& upload_id() const; |
2830 | + int read_socket() const; |
2831 | + |
2832 | + // If an error is reported early, cancel() or finish() will not be |
2833 | + // invoked. |
2834 | + void report_error(std::exception_ptr p); |
2835 | + |
2836 | + virtual boost::future<void> cancel() = 0; |
2837 | + virtual boost::future<Item> finish() = 0; |
2838 | + |
2839 | +protected: |
2840 | + UploadJob(internal::UploadJobImpl *p) UNITY_STORAGE_HIDDEN; |
2841 | + internal::UploadJobImpl *p_ = nullptr; |
2842 | + |
2843 | + friend class internal::PendingJobs; |
2844 | + friend class internal::ProviderInterface; |
2845 | +}; |
2846 | + |
2847 | +} |
2848 | +} |
2849 | +} |
2850 | |
2851 | === added directory 'include/unity/storage/provider/internal' |
2852 | === added file 'include/unity/storage/provider/internal/AccountData.h' |
2853 | --- include/unity/storage/provider/internal/AccountData.h 1970-01-01 00:00:00 +0000 |
2854 | +++ include/unity/storage/provider/internal/AccountData.h 2016-07-21 12:22:21 +0000 |
2855 | @@ -0,0 +1,88 @@ |
2856 | +/* |
2857 | + * Copyright (C) 2016 Canonical Ltd |
2858 | + * |
2859 | + * This program is free software: you can redistribute it and/or modify |
2860 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2861 | + * published by the Free Software Foundation. |
2862 | + * |
2863 | + * This program is distributed in the hope that it will be useful, |
2864 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2865 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2866 | + * GNU Lesser General Public License for more details. |
2867 | + * |
2868 | + * You should have received a copy of the GNU Lesser General Public License |
2869 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2870 | + * |
2871 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2872 | + */ |
2873 | + |
2874 | +#pragma once |
2875 | + |
2876 | +#include <unity/storage/provider/Credentials.h> |
2877 | + |
2878 | +#include <OnlineAccounts/Account> |
2879 | +#include <OnlineAccounts/PendingCallWatcher> |
2880 | +#include <QObject> |
2881 | +#include <QDBusConnection> |
2882 | + |
2883 | +#include <string> |
2884 | + |
2885 | +namespace unity |
2886 | +{ |
2887 | +namespace storage |
2888 | +{ |
2889 | +namespace provider |
2890 | +{ |
2891 | + |
2892 | +class ProviderBase; |
2893 | + |
2894 | +namespace internal |
2895 | +{ |
2896 | + |
2897 | +class DBusPeerCache; |
2898 | +class PendingJobs; |
2899 | + |
2900 | +class AccountData : public QObject |
2901 | +{ |
2902 | + Q_OBJECT |
2903 | +public: |
2904 | + AccountData(std::unique_ptr<ProviderBase>&& provider, |
2905 | + std::shared_ptr<DBusPeerCache> const& dbus_peer, |
2906 | + QDBusConnection const& bus, |
2907 | + OnlineAccounts::Account* account, |
2908 | + QObject* parent=nullptr); |
2909 | + virtual ~AccountData(); |
2910 | + |
2911 | + void authenticate(bool interactive); |
2912 | + bool has_credentials(); |
2913 | + Credentials const& credentials(); |
2914 | + |
2915 | + ProviderBase& provider(); |
2916 | + DBusPeerCache& dbus_peer(); |
2917 | + PendingJobs& jobs(); |
2918 | + |
2919 | +Q_SIGNALS: |
2920 | + void authenticated(); |
2921 | + |
2922 | +private Q_SLOTS: |
2923 | + void on_authenticated(); |
2924 | + |
2925 | +private: |
2926 | + std::unique_ptr<ProviderBase> const provider_; |
2927 | + std::shared_ptr<DBusPeerCache> const dbus_peer_; |
2928 | + std::unique_ptr<PendingJobs> const jobs_; |
2929 | + |
2930 | + OnlineAccounts::Account* const account_; |
2931 | + std::unique_ptr<OnlineAccounts::PendingCallWatcher> auth_watcher_; |
2932 | + bool authenticating_interactively_ = false; |
2933 | + |
2934 | + bool credentials_valid_ = false; |
2935 | + Credentials credentials_; |
2936 | + |
2937 | + Q_DISABLE_COPY(AccountData) |
2938 | +}; |
2939 | + |
2940 | +} |
2941 | +} |
2942 | +} |
2943 | +} |
2944 | |
2945 | === added file 'include/unity/storage/provider/internal/DBusPeerCache.h' |
2946 | --- include/unity/storage/provider/internal/DBusPeerCache.h 1970-01-01 00:00:00 +0000 |
2947 | +++ include/unity/storage/provider/internal/DBusPeerCache.h 2016-07-21 12:22:21 +0000 |
2948 | @@ -0,0 +1,80 @@ |
2949 | +/* |
2950 | + * Copyright (C) 2016 Canonical Ltd |
2951 | + * |
2952 | + * This program is free software: you can redistribute it and/or modify |
2953 | + * it under the terms of the GNU Lesser General Public License version 3 as |
2954 | + * published by the Free Software Foundation. |
2955 | + * |
2956 | + * This program is distributed in the hope that it will be useful, |
2957 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2958 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2959 | + * GNU Lesser General Public License for more details. |
2960 | + * |
2961 | + * You should have received a copy of the GNU Lesser General Public License |
2962 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2963 | + * |
2964 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
2965 | + */ |
2966 | + |
2967 | + |
2968 | +#pragma once |
2969 | + |
2970 | +#include <boost/thread/future.hpp> |
2971 | +#include <QDBusConnection> |
2972 | +#include <QDBusPendingReply> |
2973 | +#include <QString> |
2974 | + |
2975 | +#include <functional> |
2976 | +#include <map> |
2977 | +#include <memory> |
2978 | +#include <string> |
2979 | +#include <sys/types.h> |
2980 | + |
2981 | +class BusInterface; |
2982 | + |
2983 | +namespace unity |
2984 | +{ |
2985 | +namespace storage |
2986 | +{ |
2987 | +namespace provider |
2988 | +{ |
2989 | +namespace internal |
2990 | +{ |
2991 | + |
2992 | +class DBusPeerCache final { |
2993 | +public: |
2994 | + struct Credentials |
2995 | + { |
2996 | + bool valid = false; |
2997 | + uid_t uid = 0; |
2998 | + pid_t pid = 0; |
2999 | + // Not using QString, because this is not necessarily unicode. |
3000 | + std::string label; |
3001 | + }; |
3002 | + |
3003 | + DBusPeerCache(QDBusConnection const& bus); |
3004 | + ~DBusPeerCache(); |
3005 | + |
3006 | + DBusPeerCache(DBusPeerCache const&) = delete; |
3007 | + DBusPeerCache& operator=(DBusPeerCache const&) = delete; |
3008 | + |
3009 | + // Retrieve the security credentials for the given D-Bus peer. |
3010 | + boost::future<Credentials> get(QString const& peer); |
3011 | + |
3012 | +private: |
3013 | + struct Request; |
3014 | + |
3015 | + std::unique_ptr<BusInterface> bus_daemon_; |
3016 | + bool apparmor_enabled_; |
3017 | + |
3018 | + std::map<QString,Credentials> cache_; |
3019 | + std::map<QString,Credentials> old_cache_; |
3020 | + std::map<QString,std::unique_ptr<Request>> pending_; |
3021 | + |
3022 | + void received_credentials(QString const& peer, QDBusPendingReply<QVariantMap> const& reply); |
3023 | +}; |
3024 | + |
3025 | +} // namespace internal |
3026 | +} // namespace provider |
3027 | +} // namespace storage |
3028 | +} // namespace unity |
3029 | |
3030 | === added file 'include/unity/storage/provider/internal/DownloadJobImpl.h' |
3031 | --- include/unity/storage/provider/internal/DownloadJobImpl.h 1970-01-01 00:00:00 +0000 |
3032 | +++ include/unity/storage/provider/internal/DownloadJobImpl.h 2016-07-21 12:22:21 +0000 |
3033 | @@ -0,0 +1,78 @@ |
3034 | +/* |
3035 | + * Copyright (C) 2016 Canonical Ltd |
3036 | + * |
3037 | + * This program is free software: you can redistribute it and/or modify |
3038 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3039 | + * published by the Free Software Foundation. |
3040 | + * |
3041 | + * This program is distributed in the hope that it will be useful, |
3042 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3043 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3044 | + * GNU Lesser General Public License for more details. |
3045 | + * |
3046 | + * You should have received a copy of the GNU Lesser General Public License |
3047 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3048 | + * |
3049 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3050 | + */ |
3051 | + |
3052 | +#pragma once |
3053 | + |
3054 | +#include <QObject> |
3055 | + |
3056 | +#include <boost/thread/future.hpp> |
3057 | + |
3058 | +#include <exception> |
3059 | +#include <mutex> |
3060 | +#include <string> |
3061 | + |
3062 | +namespace unity |
3063 | +{ |
3064 | +namespace storage |
3065 | +{ |
3066 | +namespace provider |
3067 | +{ |
3068 | +class DownloadJob; |
3069 | + |
3070 | +namespace internal |
3071 | +{ |
3072 | + |
3073 | +class DownloadJobImpl : public QObject |
3074 | +{ |
3075 | + Q_OBJECT |
3076 | +public: |
3077 | + explicit DownloadJobImpl(std::string const& download_id); |
3078 | + virtual ~DownloadJobImpl(); |
3079 | + |
3080 | + std::string const& download_id() const; |
3081 | + int write_socket() const; |
3082 | + int take_read_socket(); |
3083 | + |
3084 | + std::string const& sender_bus_name() const; |
3085 | + void set_sender_bus_name(std::string const& bus_name); |
3086 | + |
3087 | + void report_complete(); |
3088 | + void report_error(std::exception_ptr p); |
3089 | + boost::future<void> finish(DownloadJob& job); |
3090 | + boost::future<void> cancel(DownloadJob& job); |
3091 | + |
3092 | +public Q_SLOTS: |
3093 | + virtual void complete_init(); |
3094 | + |
3095 | +protected: |
3096 | + std::string const download_id_; |
3097 | + int read_socket_ = -1; |
3098 | + int write_socket_ = -1; |
3099 | + std::string sender_bus_name_; |
3100 | + |
3101 | + std::mutex completion_lock_; |
3102 | + bool completed_ = false; |
3103 | + boost::promise<void> completion_promise_; |
3104 | + |
3105 | + Q_DISABLE_COPY(DownloadJobImpl) |
3106 | +}; |
3107 | + |
3108 | +} |
3109 | +} |
3110 | +} |
3111 | +} |
3112 | |
3113 | === added file 'include/unity/storage/provider/internal/Handler.h' |
3114 | --- include/unity/storage/provider/internal/Handler.h 1970-01-01 00:00:00 +0000 |
3115 | +++ include/unity/storage/provider/internal/Handler.h 2016-07-21 12:22:21 +0000 |
3116 | @@ -0,0 +1,82 @@ |
3117 | +/* |
3118 | + * Copyright (C) 2016 Canonical Ltd |
3119 | + * |
3120 | + * This program is free software: you can redistribute it and/or modify |
3121 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3122 | + * published by the Free Software Foundation. |
3123 | + * |
3124 | + * This program is distributed in the hope that it will be useful, |
3125 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3126 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3127 | + * GNU Lesser General Public License for more details. |
3128 | + * |
3129 | + * You should have received a copy of the GNU Lesser General Public License |
3130 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3131 | + * |
3132 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3133 | + */ |
3134 | + |
3135 | +#pragma once |
3136 | + |
3137 | +#include <unity/storage/provider/ProviderBase.h> |
3138 | +#include <unity/storage/provider/internal/DBusPeerCache.h> |
3139 | + |
3140 | +#include <boost/thread/future.hpp> |
3141 | + |
3142 | +#include <QObject> |
3143 | +#include <QDBusConnection> |
3144 | +#include <QDBusMessage> |
3145 | + |
3146 | +#include <functional> |
3147 | +#include <memory> |
3148 | + |
3149 | +namespace unity |
3150 | +{ |
3151 | +namespace storage |
3152 | +{ |
3153 | +namespace provider |
3154 | +{ |
3155 | +namespace internal |
3156 | +{ |
3157 | + |
3158 | +class AccountData; |
3159 | +class PendingJobs; |
3160 | + |
3161 | +class Handler : public QObject |
3162 | +{ |
3163 | + Q_OBJECT |
3164 | +public: |
3165 | + typedef std::function<boost::future<QDBusMessage>(std::shared_ptr<AccountData> const&, Context const&, QDBusMessage const&)> Callback; |
3166 | + |
3167 | + Handler(std::shared_ptr<AccountData> const& account, |
3168 | + Callback const& callback, |
3169 | + QDBusConnection const& bus, QDBusMessage const& message); |
3170 | + |
3171 | +public Q_SLOTS: |
3172 | + void begin(); |
3173 | + |
3174 | +private Q_SLOTS: |
3175 | + void credentials_received(); |
3176 | + void send_reply(); |
3177 | + |
3178 | +Q_SIGNALS: |
3179 | + void finished(); |
3180 | + |
3181 | +private: |
3182 | + std::shared_ptr<AccountData> const account_; |
3183 | + Callback const callback_; |
3184 | + QDBusConnection const bus_; |
3185 | + QDBusMessage const message_; |
3186 | + |
3187 | + boost::future<void> creds_future_; |
3188 | + boost::future<void> reply_future_; |
3189 | + Context context_; |
3190 | + QDBusMessage reply_; |
3191 | + |
3192 | + Q_DISABLE_COPY(Handler) |
3193 | +}; |
3194 | + |
3195 | +} |
3196 | +} |
3197 | +} |
3198 | +} |
3199 | |
3200 | === added file 'include/unity/storage/provider/internal/MainLoopExecutor.h' |
3201 | --- include/unity/storage/provider/internal/MainLoopExecutor.h 1970-01-01 00:00:00 +0000 |
3202 | +++ include/unity/storage/provider/internal/MainLoopExecutor.h 2016-07-21 12:22:21 +0000 |
3203 | @@ -0,0 +1,84 @@ |
3204 | +/* |
3205 | + * Copyright (C) 2016 Canonical Ltd |
3206 | + * |
3207 | + * This program is free software: you can redistribute it and/or modify |
3208 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3209 | + * published by the Free Software Foundation. |
3210 | + * |
3211 | + * This program is distributed in the hope that it will be useful, |
3212 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3213 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3214 | + * GNU Lesser General Public License for more details. |
3215 | + * |
3216 | + * You should have received a copy of the GNU Lesser General Public License |
3217 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3218 | + * |
3219 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3220 | + */ |
3221 | + |
3222 | +#pragma once |
3223 | + |
3224 | +#include <boost/version.hpp> |
3225 | + |
3226 | +#if BOOST_VERSION >= 105600 |
3227 | +# define SF_SUPPORTS_EXECUTORS |
3228 | +#endif |
3229 | +#ifdef SF_SUPPORTS_EXECUTORS |
3230 | +# include <boost/thread/executor.hpp> |
3231 | +#endif |
3232 | +#include <QObject> |
3233 | + |
3234 | +#include <functional> |
3235 | + |
3236 | +namespace unity |
3237 | +{ |
3238 | +namespace storage |
3239 | +{ |
3240 | +namespace provider |
3241 | +{ |
3242 | +namespace internal |
3243 | +{ |
3244 | + |
3245 | +#ifdef SF_SUPPORTS_EXECUTORS |
3246 | + |
3247 | +/* Declare future continuations like so to execute within the event |
3248 | + * loop if possible: |
3249 | + * |
3250 | + * auto f2 = f.then(EXEC_IN_MAIN [](decltype(f) f) { ... }); |
3251 | + * |
3252 | + * On Boost >= 1.56, this will use a custom executor to run the |
3253 | + * continuation as an event in the main thread. On older versions, |
3254 | + * the continuation will be executed in a new thread. |
3255 | + */ |
3256 | + |
3257 | +#define EXEC_IN_MAIN MainLoopExecutor::instance(), |
3258 | + |
3259 | +class MainLoopExecutor : public QObject, public boost::executors::executor { |
3260 | + Q_OBJECT |
3261 | +public: |
3262 | + static MainLoopExecutor& instance(); |
3263 | + |
3264 | + void submit(work&& closure) override; |
3265 | + void close() override; |
3266 | + bool closed() override; |
3267 | + bool try_executing_one() override; |
3268 | + |
3269 | + bool event(QEvent *event) override; |
3270 | + |
3271 | +private: |
3272 | + MainLoopExecutor(); |
3273 | + void execute(work& closure) noexcept; |
3274 | + |
3275 | + Q_DISABLE_COPY(MainLoopExecutor) |
3276 | +}; |
3277 | + |
3278 | +#else |
3279 | + |
3280 | +#define EXEC_IN_MAIN /*nothing*/ |
3281 | + |
3282 | +#endif |
3283 | + |
3284 | +} |
3285 | +} |
3286 | +} |
3287 | +} |
3288 | |
3289 | === added file 'include/unity/storage/provider/internal/PendingJobs.h' |
3290 | --- include/unity/storage/provider/internal/PendingJobs.h 1970-01-01 00:00:00 +0000 |
3291 | +++ include/unity/storage/provider/internal/PendingJobs.h 2016-07-21 12:22:21 +0000 |
3292 | @@ -0,0 +1,80 @@ |
3293 | +/* |
3294 | + * Copyright (C) 2016 Canonical Ltd |
3295 | + * |
3296 | + * This program is free software: you can redistribute it and/or modify |
3297 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3298 | + * published by the Free Software Foundation. |
3299 | + * |
3300 | + * This program is distributed in the hope that it will be useful, |
3301 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3302 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3303 | + * GNU Lesser General Public License for more details. |
3304 | + * |
3305 | + * You should have received a copy of the GNU Lesser General Public License |
3306 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3307 | + * |
3308 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3309 | + */ |
3310 | + |
3311 | +#pragma once |
3312 | + |
3313 | +#include <QDBusConnection> |
3314 | +#include <QDBusServiceWatcher> |
3315 | +#include <QObject> |
3316 | + |
3317 | +#include <map> |
3318 | +#include <memory> |
3319 | +#include <mutex> |
3320 | +#include <string> |
3321 | + |
3322 | +namespace unity |
3323 | +{ |
3324 | +namespace storage |
3325 | +{ |
3326 | +namespace provider |
3327 | +{ |
3328 | + |
3329 | +class DownloadJob; |
3330 | +class UploadJob; |
3331 | + |
3332 | +namespace internal |
3333 | +{ |
3334 | + |
3335 | + |
3336 | +class PendingJobs : public QObject |
3337 | +{ |
3338 | + Q_OBJECT |
3339 | + |
3340 | +public: |
3341 | + explicit PendingJobs(QDBusConnection const& bus, QObject *parent=nullptr); |
3342 | + virtual ~PendingJobs(); |
3343 | + |
3344 | + void add_download(std::unique_ptr<DownloadJob> &&job); |
3345 | + std::shared_ptr<DownloadJob> get_download(std::string const& download_id); |
3346 | + std::shared_ptr<DownloadJob> remove_download(std::string const& download_id); |
3347 | + |
3348 | + void add_upload(std::unique_ptr<UploadJob> &&job); |
3349 | + std::shared_ptr<UploadJob> get_upload(std::string const& upload_id); |
3350 | + std::shared_ptr<UploadJob> remove_upload(std::string const& upload_id); |
3351 | + |
3352 | +private Q_SLOTS: |
3353 | + void service_disconnected(QString const& service_name); |
3354 | + |
3355 | +private: |
3356 | + void watch_peer(std::string const& bus_name); |
3357 | + void unwatch_peer(std::string const& bus_name); |
3358 | + |
3359 | + std::mutex lock_; |
3360 | + std::map<std::string,std::shared_ptr<UploadJob>> uploads_; |
3361 | + std::map<std::string,std::shared_ptr<DownloadJob>> downloads_; |
3362 | + |
3363 | + QDBusServiceWatcher watcher_; |
3364 | + std::map<std::string,int> services_; |
3365 | + |
3366 | + Q_DISABLE_COPY(PendingJobs) |
3367 | +}; |
3368 | + |
3369 | +} |
3370 | +} |
3371 | +} |
3372 | +} |
3373 | |
3374 | === added file 'include/unity/storage/provider/internal/ProviderInterface.h' |
3375 | --- include/unity/storage/provider/internal/ProviderInterface.h 1970-01-01 00:00:00 +0000 |
3376 | +++ include/unity/storage/provider/internal/ProviderInterface.h 2016-07-21 12:22:21 +0000 |
3377 | @@ -0,0 +1,87 @@ |
3378 | +/* |
3379 | + * Copyright (C) 2016 Canonical Ltd |
3380 | + * |
3381 | + * This program is free software: you can redistribute it and/or modify |
3382 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3383 | + * published by the Free Software Foundation. |
3384 | + * |
3385 | + * This program is distributed in the hope that it will be useful, |
3386 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3387 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3388 | + * GNU Lesser General Public License for more details. |
3389 | + * |
3390 | + * You should have received a copy of the GNU Lesser General Public License |
3391 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3392 | + * |
3393 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3394 | + */ |
3395 | + |
3396 | +#pragma once |
3397 | + |
3398 | +#include <unity/storage/internal/ItemMetadata.h> |
3399 | +#include <unity/storage/provider/internal/Handler.h> |
3400 | + |
3401 | +#include <QObject> |
3402 | +#include <QList> |
3403 | +#include <QDBusConnection> |
3404 | +#include <QDBusContext> |
3405 | +#include <QDBusUnixFileDescriptor> |
3406 | + |
3407 | +#include <map> |
3408 | +#include <memory> |
3409 | + |
3410 | +namespace unity |
3411 | +{ |
3412 | +namespace storage |
3413 | +{ |
3414 | +namespace provider |
3415 | +{ |
3416 | +namespace internal |
3417 | +{ |
3418 | + |
3419 | +class AccountData; |
3420 | + |
3421 | +class ProviderInterface : public QObject, protected QDBusContext |
3422 | +{ |
3423 | + Q_OBJECT |
3424 | + |
3425 | +public: |
3426 | + ProviderInterface(std::shared_ptr<AccountData> const& account_data, |
3427 | + QObject *parent=nullptr); |
3428 | + ~ProviderInterface(); |
3429 | + |
3430 | +private: |
3431 | + typedef unity::storage::internal::ItemMetadata IMD; // To keep things readable |
3432 | + |
3433 | +public Q_SLOTS: |
3434 | + QList<IMD> Roots(); |
3435 | + QList<IMD> List(QString const& item_id, QString const& page_token, QString& next_token); |
3436 | + QList<IMD> Lookup(QString const& parent_id, QString const& name); |
3437 | + IMD Metadata(QString const& item_id); |
3438 | + IMD CreateFolder(QString const& parent_id, QString const& name); |
3439 | + QString CreateFile(QString const& parent_id, QString const& name, QString const& content_type, bool allow_overwrite, QDBusUnixFileDescriptor& file_descriptor); |
3440 | + QString Update(QString const& item_id, QString const& old_etag, QDBusUnixFileDescriptor& file_descriptor); |
3441 | + IMD FinishUpload(QString const& upload_id); |
3442 | + void CancelUpload(QString const& upload_id); |
3443 | + QString Download(QString const& item_id, QDBusUnixFileDescriptor& file_descriptor); |
3444 | + void FinishDownload(QString const& download_id); |
3445 | + void Delete(QString const& item_id); |
3446 | + IMD Move(QString const& item_id, QString const& new_parent_id, QString const& new_name); |
3447 | + IMD Copy(QString const& item_id, QString const& new_parent_id, QString const& new_name); |
3448 | + |
3449 | +private Q_SLOTS: |
3450 | + void request_finished(); |
3451 | + |
3452 | +private: |
3453 | + void queue_request(Handler::Callback callback); |
3454 | + |
3455 | + std::shared_ptr<AccountData> const account_; |
3456 | + std::map<Handler*, std::unique_ptr<Handler>> requests_; |
3457 | + |
3458 | + Q_DISABLE_COPY(ProviderInterface) |
3459 | +}; |
3460 | + |
3461 | +} |
3462 | +} |
3463 | +} |
3464 | +} |
3465 | |
3466 | === added file 'include/unity/storage/provider/internal/ServerImpl.h' |
3467 | --- include/unity/storage/provider/internal/ServerImpl.h 1970-01-01 00:00:00 +0000 |
3468 | +++ include/unity/storage/provider/internal/ServerImpl.h 2016-07-21 12:22:21 +0000 |
3469 | @@ -0,0 +1,73 @@ |
3470 | +/* |
3471 | + * Copyright (C) 2016 Canonical Ltd |
3472 | + * |
3473 | + * This program is free software: you can redistribute it and/or modify |
3474 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3475 | + * published by the Free Software Foundation. |
3476 | + * |
3477 | + * This program is distributed in the hope that it will be useful, |
3478 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3479 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3480 | + * GNU Lesser General Public License for more details. |
3481 | + * |
3482 | + * You should have received a copy of the GNU Lesser General Public License |
3483 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3484 | + * |
3485 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3486 | + */ |
3487 | + |
3488 | +#pragma once |
3489 | + |
3490 | +#include <unity/storage/provider/Server.h> |
3491 | +#include <unity/storage/provider/internal/DBusPeerCache.h> |
3492 | +#include <unity/storage/provider/internal/ProviderInterface.h> |
3493 | + |
3494 | +#include <OnlineAccounts/Manager> |
3495 | +#include <OnlineAccounts/Account> |
3496 | +#include <QObject> |
3497 | +#include <QCoreApplication> |
3498 | +#include <QDBusConnection> |
3499 | + |
3500 | +#include <map> |
3501 | +#include <memory> |
3502 | +#include <string> |
3503 | + |
3504 | +namespace unity |
3505 | +{ |
3506 | +namespace storage |
3507 | +{ |
3508 | +namespace provider |
3509 | +{ |
3510 | + |
3511 | +namespace internal |
3512 | +{ |
3513 | + |
3514 | +class ServerImpl : public QObject { |
3515 | + Q_OBJECT |
3516 | +public: |
3517 | + ServerImpl(ServerBase* server, std::string const& bus_name, std::string const& account_service_id); |
3518 | + ~ServerImpl(); |
3519 | + |
3520 | + void init(int& argc, char **argv); |
3521 | + void run(); |
3522 | + |
3523 | +private Q_SLOTS: |
3524 | + void account_manager_ready(); |
3525 | + |
3526 | +private: |
3527 | + ServerBase* const server_; |
3528 | + std::string const bus_name_; |
3529 | + std::string const service_id_; |
3530 | + |
3531 | + std::unique_ptr<QCoreApplication> app_; |
3532 | + std::unique_ptr<OnlineAccounts::Manager> manager_; |
3533 | + std::shared_ptr<DBusPeerCache> dbus_peer_; |
3534 | + std::map<OnlineAccounts::AccountId,std::unique_ptr<ProviderInterface>> interfaces_; |
3535 | + |
3536 | + Q_DISABLE_COPY(ServerImpl) |
3537 | +}; |
3538 | + |
3539 | +} |
3540 | +} |
3541 | +} |
3542 | +} |
3543 | |
3544 | === added file 'include/unity/storage/provider/internal/TempfileUploadJobImpl.h' |
3545 | --- include/unity/storage/provider/internal/TempfileUploadJobImpl.h 1970-01-01 00:00:00 +0000 |
3546 | +++ include/unity/storage/provider/internal/TempfileUploadJobImpl.h 2016-07-21 12:22:21 +0000 |
3547 | @@ -0,0 +1,63 @@ |
3548 | +/* |
3549 | + * Copyright (C) 2016 Canonical Ltd |
3550 | + * |
3551 | + * This program is free software: you can redistribute it and/or modify |
3552 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3553 | + * published by the Free Software Foundation. |
3554 | + * |
3555 | + * This program is distributed in the hope that it will be useful, |
3556 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3557 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3558 | + * GNU Lesser General Public License for more details. |
3559 | + * |
3560 | + * You should have received a copy of the GNU Lesser General Public License |
3561 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3562 | + * |
3563 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3564 | + */ |
3565 | + |
3566 | +#pragma once |
3567 | + |
3568 | +#include <unity/storage/provider/internal/UploadJobImpl.h> |
3569 | + |
3570 | +#include <QLocalSocket> |
3571 | +#include <QTemporaryFile> |
3572 | + |
3573 | +#include <memory> |
3574 | +#include <string> |
3575 | + |
3576 | +namespace unity |
3577 | +{ |
3578 | +namespace storage |
3579 | +{ |
3580 | +namespace provider |
3581 | +{ |
3582 | +namespace internal |
3583 | +{ |
3584 | + |
3585 | +class TempfileUploadJobImpl : public UploadJobImpl |
3586 | +{ |
3587 | + Q_OBJECT |
3588 | +public: |
3589 | + explicit TempfileUploadJobImpl(std::string const& upload_id); |
3590 | + virtual ~TempfileUploadJobImpl(); |
3591 | + |
3592 | + void complete_init() override; |
3593 | + |
3594 | + std::string file_name() const; |
3595 | + |
3596 | +private Q_SLOTS: |
3597 | + void on_ready_read(); |
3598 | + void on_read_channel_finished(); |
3599 | + |
3600 | +private: |
3601 | + std::unique_ptr<QLocalSocket> reader_; |
3602 | + std::unique_ptr<QTemporaryFile> tmpfile_; |
3603 | + |
3604 | + Q_DISABLE_COPY(TempfileUploadJobImpl) |
3605 | +}; |
3606 | + |
3607 | +} |
3608 | +} |
3609 | +} |
3610 | +} |
3611 | |
3612 | === added file 'include/unity/storage/provider/internal/UploadJobImpl.h' |
3613 | --- include/unity/storage/provider/internal/UploadJobImpl.h 1970-01-01 00:00:00 +0000 |
3614 | +++ include/unity/storage/provider/internal/UploadJobImpl.h 2016-07-21 12:22:21 +0000 |
3615 | @@ -0,0 +1,78 @@ |
3616 | +/* |
3617 | + * Copyright (C) 2016 Canonical Ltd |
3618 | + * |
3619 | + * This program is free software: you can redistribute it and/or modify |
3620 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3621 | + * published by the Free Software Foundation. |
3622 | + * |
3623 | + * This program is distributed in the hope that it will be useful, |
3624 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3625 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3626 | + * GNU Lesser General Public License for more details. |
3627 | + * |
3628 | + * You should have received a copy of the GNU Lesser General Public License |
3629 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3630 | + * |
3631 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3632 | + */ |
3633 | + |
3634 | +#pragma once |
3635 | + |
3636 | +#include <unity/storage/provider/ProviderBase.h> |
3637 | + |
3638 | +#include <boost/thread/future.hpp> |
3639 | +#include <QObject> |
3640 | + |
3641 | +#include <exception> |
3642 | +#include <mutex> |
3643 | +#include <string> |
3644 | + |
3645 | +namespace unity |
3646 | +{ |
3647 | +namespace storage |
3648 | +{ |
3649 | +namespace provider |
3650 | +{ |
3651 | +class UploadJob; |
3652 | + |
3653 | +namespace internal |
3654 | +{ |
3655 | + |
3656 | +class UploadJobImpl : public QObject |
3657 | +{ |
3658 | + Q_OBJECT |
3659 | +public: |
3660 | + explicit UploadJobImpl(std::string const& upload_id); |
3661 | + virtual ~UploadJobImpl(); |
3662 | + |
3663 | + std::string const& upload_id() const; |
3664 | + int read_socket() const; |
3665 | + int take_write_socket(); |
3666 | + |
3667 | + std::string const& sender_bus_name() const; |
3668 | + void set_sender_bus_name(std::string const& bus_name); |
3669 | + |
3670 | + void report_error(std::exception_ptr p); |
3671 | + boost::future<Item> finish(UploadJob& job); |
3672 | + boost::future<void> cancel(UploadJob& job); |
3673 | + |
3674 | +public Q_SLOTS: |
3675 | + virtual void complete_init(); |
3676 | + |
3677 | +protected: |
3678 | + std::string const upload_id_; |
3679 | + int read_socket_ = -1; |
3680 | + int write_socket_ = -1; |
3681 | + std::string sender_bus_name_; |
3682 | + |
3683 | + std::mutex completion_lock_; |
3684 | + bool completed_ = false; |
3685 | + boost::promise<Item> completion_promise_; |
3686 | + |
3687 | + Q_DISABLE_COPY(UploadJobImpl) |
3688 | +}; |
3689 | + |
3690 | +} |
3691 | +} |
3692 | +} |
3693 | +} |
3694 | |
3695 | === added file 'include/unity/storage/provider/internal/dbusmarshal.h' |
3696 | --- include/unity/storage/provider/internal/dbusmarshal.h 1970-01-01 00:00:00 +0000 |
3697 | +++ include/unity/storage/provider/internal/dbusmarshal.h 2016-07-21 12:22:21 +0000 |
3698 | @@ -0,0 +1,44 @@ |
3699 | +/* |
3700 | + * Copyright (C) 2016 Canonical Ltd |
3701 | + * |
3702 | + * This program is free software: you can redistribute it and/or modify |
3703 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3704 | + * published by the Free Software Foundation. |
3705 | + * |
3706 | + * This program is distributed in the hope that it will be useful, |
3707 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3708 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3709 | + * GNU Lesser General Public License for more details. |
3710 | + * |
3711 | + * You should have received a copy of the GNU Lesser General Public License |
3712 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3713 | + * |
3714 | + * Authors: James Henstridge <james.henstridge@canonical.com> |
3715 | + */ |
3716 | + |
3717 | +#pragma once |
3718 | + |
3719 | +#include <QDBusArgument> |
3720 | +#include <QVariant> |
3721 | +#include <vector> |
3722 | + |
3723 | +namespace unity |
3724 | +{ |
3725 | +namespace storage |
3726 | +{ |
3727 | +namespace provider |
3728 | +{ |
3729 | + |
3730 | +struct Item; |
3731 | + |
3732 | +QDBusArgument& operator<<(QDBusArgument& argument, Item const& item); |
3733 | +QDBusArgument const& operator>>(QDBusArgument const& argument, Item& item); |
3734 | + |
3735 | +QDBusArgument& operator<<(QDBusArgument& argument, std::vector<Item> const& items); |
3736 | +QDBusArgument const& operator>>(QDBusArgument const& argument, std::vector<Item>& items); |
3737 | + |
3738 | +} |
3739 | +} |
3740 | +} |
3741 | + |
3742 | +Q_DECLARE_METATYPE(unity::storage::provider::Item) |
3743 | |
3744 | === added directory 'include/unity/storage/qt' |
3745 | === added file 'include/unity/storage/qt/CMakeLists.txt' |
3746 | --- include/unity/storage/qt/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
3747 | +++ include/unity/storage/qt/CMakeLists.txt 2016-07-21 12:22:21 +0000 |
3748 | @@ -0,0 +1,1 @@ |
3749 | +add_subdirectory(client) |
3750 | |
3751 | === added directory 'include/unity/storage/qt/client' |
3752 | === added file 'include/unity/storage/qt/client/Account.h' |
3753 | --- include/unity/storage/qt/client/Account.h 1970-01-01 00:00:00 +0000 |
3754 | +++ include/unity/storage/qt/client/Account.h 2016-07-21 12:22:21 +0000 |
3755 | @@ -0,0 +1,108 @@ |
3756 | +/* |
3757 | + * Copyright (C) 2016 Canonical Ltd |
3758 | + * |
3759 | + * This program is free software: you can redistribute it and/or modify |
3760 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3761 | + * published by the Free Software Foundation. |
3762 | + * |
3763 | + * This program is distributed in the hope that it will be useful, |
3764 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3765 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3766 | + * GNU Lesser General Public License for more details. |
3767 | + * |
3768 | + * You should have received a copy of the GNU Lesser General Public License |
3769 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3770 | + * |
3771 | + * Authors: Michi Henning <michi.henning@canonical.com> |
3772 | + */ |
3773 | + |
3774 | +#pragma once |
3775 | + |
3776 | +#include <unity/storage/visibility.h> |
3777 | + |
3778 | +#pragma GCC diagnostic push |
3779 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
3780 | +#include <QFuture> |
3781 | +#pragma GCC diagnostic pop |
3782 | +#include <QString> |
3783 | +#include <QVector> |
3784 | + |
3785 | +#include <memory> |
3786 | + |
3787 | +namespace unity |
3788 | +{ |
3789 | +namespace storage |
3790 | +{ |
3791 | +namespace qt |
3792 | +{ |
3793 | +namespace client |
3794 | +{ |
3795 | + |
3796 | +class Runtime; |
3797 | +class Root; |
3798 | + |
3799 | +namespace internal |
3800 | +{ |
3801 | + |
3802 | +class AccountBase; |
3803 | + |
3804 | +namespace local_client |
3805 | +{ |
3806 | + |
3807 | +class RuntimeImpl; |
3808 | + |
3809 | +} // namespace local_client |
3810 | + |
3811 | +namespace remote_client |
3812 | +{ |
3813 | + |
3814 | +class ItemImpl; |
3815 | +class RuntimeImpl; |
3816 | + |
3817 | +} // namespace remote_client |
3818 | +} // namespace internal |
3819 | + |
3820 | +/** |
3821 | +\brief Class that represents an account. |
3822 | +*/ |
3823 | +class UNITY_STORAGE_EXPORT Account final |
3824 | +{ |
3825 | +public: |
3826 | + /// @cond |
3827 | + ~Account(); |
3828 | + /// @endcond |
3829 | + |
3830 | + Account(Account&&); |
3831 | + Account& operator=(Account&&); |
3832 | + |
3833 | + typedef std::shared_ptr<Account> SPtr; |
3834 | + |
3835 | + Runtime* runtime() const; |
3836 | + |
3837 | + QString owner() const; |
3838 | + QString owner_id() const; |
3839 | + QString description() const; |
3840 | + |
3841 | + // TODO: Will almost certainly need more here. Other details? |
3842 | + |
3843 | + /** |
3844 | + \brief Returns the root directories for the account. |
3845 | + |
3846 | + An account can have more than one root directory (for providers that support the concept of multiple drives). |
3847 | + */ |
3848 | + QFuture<QVector<std::shared_ptr<Root>>> roots() const; |
3849 | + |
3850 | +private: |
3851 | + Account(internal::AccountBase*) UNITY_STORAGE_HIDDEN; |
3852 | + |
3853 | + std::shared_ptr<internal::AccountBase> p_; |
3854 | + |
3855 | + friend class internal::local_client::RuntimeImpl; |
3856 | + friend class internal::remote_client::ItemImpl; |
3857 | + friend class internal::remote_client::RuntimeImpl; |
3858 | +}; |
3859 | + |
3860 | +} // namespace client |
3861 | +} // namespace qt |
3862 | +} // namespace storage |
3863 | +} // namespace unity |
3864 | |
3865 | === added file 'include/unity/storage/qt/client/CMakeLists.txt' |
3866 | --- include/unity/storage/qt/client/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
3867 | +++ include/unity/storage/qt/client/CMakeLists.txt 2016-07-21 12:22:21 +0000 |
3868 | @@ -0,0 +1,15 @@ |
3869 | +set(includeprefix unity/storage/qt/client) |
3870 | +file(GLOB public_hdrs *.h) |
3871 | +set(convenience_hdr ${CMAKE_CURRENT_BINARY_DIR}/client-api.h) |
3872 | + |
3873 | +add_custom_command( |
3874 | + OUTPUT ${convenience_hdr} |
3875 | + COMMAND ${CMAKE_SOURCE_DIR}/tools/create_globalheader.py |
3876 | + ${convenience_hdr} ${includeprefix} ${CMAKE_CURRENT_SOURCE_DIR} |
3877 | + DEPENDS ${public_hdrs}) |
3878 | + |
3879 | +add_custom_target(qt-client-all-headers ALL DEPENDS ${convenience_hdr}) |
3880 | + |
3881 | +install( |
3882 | + FILES ${public_hdrs} ${convenience_hdr} |
3883 | + DESTINATION ${client_base_includedir}/${includeprefix}) |
3884 | |
3885 | === added file 'include/unity/storage/qt/client/Downloader.h' |
3886 | --- include/unity/storage/qt/client/Downloader.h 1970-01-01 00:00:00 +0000 |
3887 | +++ include/unity/storage/qt/client/Downloader.h 2016-07-21 12:22:21 +0000 |
3888 | @@ -0,0 +1,138 @@ |
3889 | +/* |
3890 | + * Copyright (C) 2016 Canonical Ltd |
3891 | + * |
3892 | + * This program is free software: you can redistribute it and/or modify |
3893 | + * it under the terms of the GNU Lesser General Public License version 3 as |
3894 | + * published by the Free Software Foundation. |
3895 | + * |
3896 | + * This program is distributed in the hope that it will be useful, |
3897 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3898 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3899 | + * GNU Lesser General Public License for more details. |
3900 | + * |
3901 | + * You should have received a copy of the GNU Lesser General Public License |
3902 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3903 | + * |
3904 | + * Authors: Michi Henning <michi.henning@canonical.com> |
3905 | + */ |
3906 | + |
3907 | +#pragma once |
3908 | + |
3909 | +#include <unity/storage/common.h> |
3910 | +#include <unity/storage/visibility.h> |
3911 | + |
3912 | +#pragma GCC diagnostic push |
3913 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
3914 | +#include <QFuture> |
3915 | +#pragma GCC diagnostic pop |
3916 | +#include <QLocalSocket> |
3917 | + |
3918 | +#include <memory> |
3919 | + |
3920 | +class QLocalSocket; |
3921 | + |
3922 | +namespace unity |
3923 | +{ |
3924 | +namespace storage |
3925 | +{ |
3926 | +namespace qt |
3927 | +{ |
3928 | +namespace client |
3929 | +{ |
3930 | + |
3931 | +class File; |
3932 | + |
3933 | +namespace internal |
3934 | +{ |
3935 | + |
3936 | +class DownloaderBase; |
3937 | + |
3938 | +namespace local_client |
3939 | +{ |
3940 | + |
3941 | +class FileImpl; |
3942 | + |
3943 | +} // namespace local_client |
3944 | + |
3945 | +namespace remote_client |
3946 | +{ |
3947 | + |
3948 | +class DownloaderImpl; |
3949 | + |
3950 | +} // namespace remote_client |
3951 | +} // namespace internal |
3952 | + |
3953 | +class UNITY_STORAGE_EXPORT Downloader final |
3954 | +{ |
3955 | +public: |
3956 | + /** |
3957 | + \brief Destroys the downloader. |
3958 | + |
3959 | + The destructor implicitly calls cancel() if it has not been called already. |
3960 | + */ |
3961 | + ~Downloader(); |
3962 | + |
3963 | + Downloader(Downloader&&); |
3964 | + Downloader& operator=(Downloader&&); |
3965 | + |
3966 | + /** |
3967 | + \brief Convenience type definition. |
3968 | + */ |
3969 | + typedef std::shared_ptr<Downloader> SPtr; |
3970 | + |
3971 | + /** |
3972 | + \brief Returns the file for this downloader. |
3973 | + */ |
3974 | + std::shared_ptr<File> file() const; |
3975 | + |
3976 | + /** |
3977 | + \brief Returns a socket that is open for reading. |
3978 | + |
3979 | + To download the file contents, read from the returned socket. |
3980 | + \return A socket open for reading. |
3981 | + */ |
3982 | + std::shared_ptr<QLocalSocket> socket() const; |
3983 | + |
3984 | + /** |
3985 | + \brief Finalizes the download. |
3986 | + |
3987 | + Once the returned socket indicates EOF, you must call finish_download(), which closes |
3988 | + the socket. Call `waitForFinished()` on the returned future to check for errors. If an error |
3989 | + occurred, `waitForFinished()` throws an exception. If the download was cancelled, `waitForFinished()` throws |
3990 | + CancelledException. |
3991 | + |
3992 | + \warning Do not assume that a download completed successfully once you detect EOF on the socket. |
3993 | + If something goes wrong during a download on the server side, the socket will return EOF |
3994 | + for a partially-downloaded file. |
3995 | + */ |
3996 | + QFuture<void> finish_download(); |
3997 | + |
3998 | + /** |
3999 | + \brief Cancels a download. |
4000 | + |
4001 | + Calling cancel() informs the provider that the download is no longer needed. The provider |
4002 | + will make a best-effort attempt to cancel the download from the remote service. |
4003 | + |
4004 | + You can check whether the cancel was successfully sent by calling `waitForFinished()` on the returned future. |
4005 | + If this does not throw an exception, the message was received and acted upon by the provider. However, |
4006 | + successful completion does _not_ indicate that the download was actually cancelled. (For example, |
4007 | + the download may have completed already by the time the provider received the cancel request, or the provider |
4008 | + may not support cancellation.) |
4009 | + |
4010 | + Calling cancel() more than once, or calling cancel() after a call to finish_download() is safe and does nothing. |
4011 | + */ |
4012 | + QFuture<void> cancel(); |
4013 | + |
4014 | +private: |
4015 | + Downloader(internal::DownloaderBase*) UNITY_STORAGE_HIDDEN; |
4016 | + |
4017 | + std::shared_ptr<internal::DownloaderBase> p_; |
4018 | + |
4019 | + friend class internal::local_client::FileImpl; |
4020 | + friend class internal::remote_client::DownloaderImpl; |
4021 | +}; |
4022 | + |
4023 | +} // namespace client |
4024 | +} // namespace qt |
4025 | +} // namespace storage |
4026 | +} // namespace unity |
4027 | |
4028 | === added file 'include/unity/storage/qt/client/Exceptions.h' |
4029 | --- include/unity/storage/qt/client/Exceptions.h 1970-01-01 00:00:00 +0000 |
4030 | +++ include/unity/storage/qt/client/Exceptions.h 2016-07-21 12:22:21 +0000 |
4031 | @@ -0,0 +1,141 @@ |
4032 | +/* |
4033 | + * Copyright (C) 2016 Canonical Ltd |
4034 | + * |
4035 | + * This program is free software: you can redistribute it and/or modify |
4036 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4037 | + * published by the Free Software Foundation. |
4038 | + * |
4039 | + * This program is distributed in the hope that it will be useful, |
4040 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4041 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4042 | + * GNU Lesser General Public License for more details. |
4043 | + * |
4044 | + * You should have received a copy of the GNU Lesser General Public License |
4045 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4046 | + * |
4047 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4048 | + */ |
4049 | + |
4050 | +#pragma once |
4051 | + |
4052 | +#include <unity/storage/visibility.h> |
4053 | + |
4054 | +#include <QException> |
4055 | + |
4056 | +namespace unity |
4057 | +{ |
4058 | +namespace storage |
4059 | +{ |
4060 | +namespace qt |
4061 | +{ |
4062 | +namespace client |
4063 | +{ |
4064 | + |
4065 | +/** |
4066 | +\brief Base exception class for all exceptions returned by the API. |
4067 | +*/ |
4068 | +class UNITY_STORAGE_EXPORT StorageException : public QException |
4069 | +{ |
4070 | +public: |
4071 | + StorageException(); |
4072 | + ~StorageException(); |
4073 | + |
4074 | + virtual StorageException* clone() const override; |
4075 | + virtual void raise() const override; |
4076 | +}; |
4077 | + |
4078 | +/** |
4079 | +\brief Indicates errors in the communication with the storage provider service. |
4080 | +*/ |
4081 | +class UNITY_STORAGE_EXPORT LocalCommsException : public StorageException |
4082 | +{ |
4083 | +public: |
4084 | + LocalCommsException(); |
4085 | + ~LocalCommsException(); |
4086 | + |
4087 | + virtual LocalCommsException* clone() const override; |
4088 | + virtual void raise() const override; |
4089 | +}; |
4090 | + |
4091 | +/** |
4092 | +\brief Indicates errors in the communication between the storage provider and the cloud service. |
4093 | +*/ |
4094 | +class UNITY_STORAGE_EXPORT RemoteCommsException : public StorageException |
4095 | +{ |
4096 | +public: |
4097 | + RemoteCommsException(); |
4098 | + ~RemoteCommsException(); |
4099 | + |
4100 | + virtual RemoteCommsException* clone() const override; |
4101 | + virtual void raise() const override; |
4102 | +}; |
4103 | + |
4104 | +/** |
4105 | +\brief Indicates that the caller invoked an operation on a file or folder that was deleted. |
4106 | +*/ |
4107 | +class UNITY_STORAGE_EXPORT DeletedException : public StorageException |
4108 | +{ |
4109 | +public: |
4110 | + DeletedException(); |
4111 | + ~DeletedException(); |
4112 | + |
4113 | + virtual DeletedException* clone() const override; |
4114 | + virtual void raise() const override; |
4115 | +}; |
4116 | + |
4117 | +/** |
4118 | +\brief Indicates that the caller destroyed the runtime. |
4119 | +*/ |
4120 | +class UNITY_STORAGE_EXPORT RuntimeDestroyedException : public StorageException |
4121 | +{ |
4122 | +public: |
4123 | + RuntimeDestroyedException(); |
4124 | + ~RuntimeDestroyedException(); |
4125 | + |
4126 | + virtual RuntimeDestroyedException* clone() const override; |
4127 | + virtual void raise() const override; |
4128 | +}; |
4129 | + |
4130 | +/** |
4131 | +\brief Indicates that an item does not exist. |
4132 | +*/ |
4133 | +class UNITY_STORAGE_EXPORT NotExistException : public StorageException |
4134 | +{ |
4135 | +public: |
4136 | + NotExistException(); |
4137 | + ~NotExistException(); |
4138 | + |
4139 | + virtual NotExistException* clone() const override; |
4140 | + virtual void raise() const override; |
4141 | +}; |
4142 | + |
4143 | +/** |
4144 | +\brief Indicates that an upload detected a version mismatch. |
4145 | +*/ |
4146 | +class UNITY_STORAGE_EXPORT ConflictException : public StorageException |
4147 | +{ |
4148 | +public: |
4149 | + ConflictException(); |
4150 | + ~ConflictException(); |
4151 | + |
4152 | + virtual ConflictException* clone() const override; |
4153 | + virtual void raise() const override; |
4154 | +}; |
4155 | + |
4156 | +/** |
4157 | +\brief Indicates that an upload or download was cancelled before it could complete. |
4158 | +*/ |
4159 | +class UNITY_STORAGE_EXPORT CancelledException : public StorageException |
4160 | +{ |
4161 | +public: |
4162 | + CancelledException(); |
4163 | + ~CancelledException(); |
4164 | + |
4165 | + virtual CancelledException* clone() const override; |
4166 | + virtual void raise() const override; |
4167 | +}; |
4168 | + |
4169 | +} // namespace client |
4170 | +} // namespace qt |
4171 | +} // namespace storage |
4172 | +} // namespace unity |
4173 | |
4174 | === added file 'include/unity/storage/qt/client/File.h' |
4175 | --- include/unity/storage/qt/client/File.h 1970-01-01 00:00:00 +0000 |
4176 | +++ include/unity/storage/qt/client/File.h 2016-07-21 12:22:21 +0000 |
4177 | @@ -0,0 +1,105 @@ |
4178 | +/* |
4179 | + * Copyright (C) 2016 Canonical Ltd |
4180 | + * |
4181 | + * This program is free software: you can redistribute it and/or modify |
4182 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4183 | + * published by the Free Software Foundation. |
4184 | + * |
4185 | + * This program is distributed in the hope that it will be useful, |
4186 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4187 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4188 | + * GNU Lesser General Public License for more details. |
4189 | + * |
4190 | + * You should have received a copy of the GNU Lesser General Public License |
4191 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4192 | + * |
4193 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4194 | + */ |
4195 | + |
4196 | +#pragma once |
4197 | + |
4198 | +#include <unity/storage/qt/client/Item.h> |
4199 | + |
4200 | +namespace unity |
4201 | +{ |
4202 | +namespace storage |
4203 | +{ |
4204 | +namespace qt |
4205 | +{ |
4206 | +namespace client |
4207 | +{ |
4208 | + |
4209 | +class Downloader; |
4210 | +class Uploader; |
4211 | +namespace internal |
4212 | +{ |
4213 | + |
4214 | +class FileBase; |
4215 | + |
4216 | +namespace local_client |
4217 | +{ |
4218 | + |
4219 | +class FileImpl; |
4220 | + |
4221 | +} // namespace local_client |
4222 | + |
4223 | +namespace remote_client |
4224 | +{ |
4225 | + |
4226 | +class FileImpl; |
4227 | + |
4228 | +} // namespace remotelocal_client |
4229 | +} // namespace internal |
4230 | + |
4231 | +/** |
4232 | +\brief Class that represents a file. |
4233 | + |
4234 | +A file is a sequence of bytes. |
4235 | +*/ |
4236 | +class UNITY_STORAGE_EXPORT File final : public Item |
4237 | +{ |
4238 | +public: |
4239 | + /// @cond |
4240 | + virtual ~File(); |
4241 | + /// @endcond |
4242 | + |
4243 | + File(File&&); |
4244 | + File& operator=(File&&); |
4245 | + |
4246 | + /** |
4247 | + \brief Convenience type definition. |
4248 | + */ |
4249 | + typedef std::shared_ptr<File> SPtr; |
4250 | + |
4251 | + /** |
4252 | + \brief Returns the size of the file in bytes. |
4253 | + \throws DestroyedException if the file has been destroyed. |
4254 | + */ |
4255 | + int64_t size() const; |
4256 | + |
4257 | + /** |
4258 | + \brief Creates an uploader for the file. |
4259 | + \param policy The conflict resolution policy. If set to ConflictPolicy::overwrite, |
4260 | + the contents of the file will be overwritten even if the file was modified |
4261 | + after this File instance was retrieved. Otherwise, if set to ConflictPolicy::error_if_conflict, |
4262 | + an attempt to retrieve the File instance from the future returned by Uploader::finish_upload() |
4263 | + throws ConflictException. |
4264 | + */ |
4265 | + QFuture<std::shared_ptr<Uploader>> create_uploader(ConflictPolicy policy); |
4266 | + |
4267 | + /** |
4268 | + \brief Creates a downloader for the file. |
4269 | + */ |
4270 | + QFuture<std::shared_ptr<Downloader>> create_downloader(); |
4271 | + |
4272 | +private: |
4273 | + File(internal::FileBase*) UNITY_STORAGE_HIDDEN; |
4274 | + |
4275 | + friend class internal::local_client::FileImpl; |
4276 | + friend class internal::remote_client::FileImpl; |
4277 | +}; |
4278 | + |
4279 | +} // namespace client |
4280 | +} // namespace qt |
4281 | +} // namespace storage |
4282 | +} // namespace unity |
4283 | |
4284 | === added file 'include/unity/storage/qt/client/Folder.h' |
4285 | --- include/unity/storage/qt/client/Folder.h 1970-01-01 00:00:00 +0000 |
4286 | +++ include/unity/storage/qt/client/Folder.h 2016-07-21 12:22:21 +0000 |
4287 | @@ -0,0 +1,123 @@ |
4288 | +/* |
4289 | + * Copyright (C) 2016 Canonical Ltd |
4290 | + * |
4291 | + * This program is free software: you can redistribute it and/or modify |
4292 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4293 | + * published by the Free Software Foundation. |
4294 | + * |
4295 | + * This program is distributed in the hope that it will be useful, |
4296 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4297 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4298 | + * GNU Lesser General Public License for more details. |
4299 | + * |
4300 | + * You should have received a copy of the GNU Lesser General Public License |
4301 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4302 | + * |
4303 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4304 | + */ |
4305 | + |
4306 | +#pragma once |
4307 | + |
4308 | +#include <unity/storage/qt/client/File.h> |
4309 | + |
4310 | +namespace unity |
4311 | +{ |
4312 | +namespace storage |
4313 | +{ |
4314 | +namespace qt |
4315 | +{ |
4316 | +namespace client |
4317 | +{ |
4318 | +namespace internal |
4319 | +{ |
4320 | + |
4321 | +class FolderBase; |
4322 | + |
4323 | +namespace local_client |
4324 | +{ |
4325 | + |
4326 | +class FolderImpl; |
4327 | +class ItemImpl; |
4328 | + |
4329 | +} // namespace local_client |
4330 | + |
4331 | +namespace remote_client |
4332 | +{ |
4333 | + |
4334 | +class FolderImpl; |
4335 | +class ItemImpl; |
4336 | + |
4337 | +} // namespace local_client |
4338 | +} // namespace internal |
4339 | + |
4340 | +/** |
4341 | +\brief Class that represents a folder. |
4342 | + |
4343 | +A folder is an unordered set of files and/or folders. |
4344 | +*/ |
4345 | +class UNITY_STORAGE_EXPORT Folder : public Item |
4346 | +{ |
4347 | +public: |
4348 | + /// @cond |
4349 | + virtual ~Folder(); |
4350 | + /// @endcond |
4351 | + |
4352 | + Folder(Folder&&); |
4353 | + Folder& operator=(Folder&&); |
4354 | + |
4355 | + typedef std::shared_ptr<Folder> SPtr; |
4356 | + |
4357 | + /** |
4358 | + \brief Returns the contents of a folder. |
4359 | + \return A vector of items or, if this folder is empty, |
4360 | + an empty vector. If there is a large number of items, |
4361 | + the returned future may become ready |
4362 | + more than once. (See QFutureWatcher for more information.) |
4363 | + */ |
4364 | + QFuture<QVector<Item::SPtr>> list() const; |
4365 | + |
4366 | + /** |
4367 | + \brief Returns the item within this folder with the given name. |
4368 | + \return The item. If no such item exists, retrieving the result |
4369 | + from the future throws an exception. |
4370 | + */ |
4371 | + QFuture<QVector<Item::SPtr>> lookup(QString const& name) const; |
4372 | + |
4373 | + /** |
4374 | + \brief Creates a new folder with the current folder as the parent. |
4375 | + \param name The name of the new folder. Note that the actual name may be changed |
4376 | + by the provider; call Item::name() once the folder is created to get its actual name. |
4377 | + \warn Do not rely on create_folder() to fail if an attempt is made to create |
4378 | + a folder with the same name as an already existing folder or file. Depending on the cloud |
4379 | + provider, it may be possible to have several folders with the same name. |
4380 | + // TODO: Explain issues with metacharacters. |
4381 | + \return The new folder. |
4382 | + */ |
4383 | + QFuture<Folder::SPtr> create_folder(QString const& name); |
4384 | + |
4385 | + /** |
4386 | + \brief Creates a new file with the current folder as the parent. |
4387 | + |
4388 | + Use the returned Uploader to write data to the file. You must call Uploader::finish_upload() |
4389 | + for the file to actually be created (whether data was written to the file or not). |
4390 | + \param name The name of the new file. Note that the actual name may be changed |
4391 | + by the provider; call Item::name() once the file is created to get its actual name. |
4392 | + \warn Do not rely on create_file() to fail if an attempt is made to create |
4393 | + a file with the same name as an already existing file or folder. Depending on the cloud |
4394 | + provider, it may be possible to have several files with the same name. |
4395 | + // TODO: Explain issues with metacharacters. |
4396 | + */ |
4397 | + QFuture<std::shared_ptr<Uploader>> create_file(QString const& name); |
4398 | + |
4399 | +protected: |
4400 | + Folder(internal::FolderBase*) UNITY_STORAGE_HIDDEN; |
4401 | + |
4402 | + friend class internal::local_client::FolderImpl; |
4403 | + friend class internal::local_client::ItemImpl; |
4404 | + friend class internal::remote_client::FolderImpl; |
4405 | +}; |
4406 | + |
4407 | +} // namespace client |
4408 | +} // namespace qt |
4409 | +} // namespace storage |
4410 | +} // namespace unity |
4411 | |
4412 | === added file 'include/unity/storage/qt/client/Item.h' |
4413 | --- include/unity/storage/qt/client/Item.h 1970-01-01 00:00:00 +0000 |
4414 | +++ include/unity/storage/qt/client/Item.h 2016-07-21 12:22:21 +0000 |
4415 | @@ -0,0 +1,210 @@ |
4416 | +/* |
4417 | + * Copyright (C) 2016 Canonical Ltd |
4418 | + * |
4419 | + * This program is free software: you can redistribute it and/or modify |
4420 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4421 | + * published by the Free Software Foundation. |
4422 | + * |
4423 | + * This program is distributed in the hope that it will be useful, |
4424 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4425 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4426 | + * GNU Lesser General Public License for more details. |
4427 | + * |
4428 | + * You should have received a copy of the GNU Lesser General Public License |
4429 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4430 | + * |
4431 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4432 | + */ |
4433 | + |
4434 | +#pragma once |
4435 | + |
4436 | +#include <unity/storage/common.h> |
4437 | +#include <unity/storage/visibility.h> |
4438 | + |
4439 | +#include <QDateTime> |
4440 | +#pragma GCC diagnostic push |
4441 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
4442 | +#include <QFuture> |
4443 | +#pragma GCC diagnostic pop |
4444 | +#include <QString> |
4445 | + |
4446 | +#include <memory> |
4447 | + |
4448 | +namespace unity |
4449 | +{ |
4450 | +namespace storage |
4451 | +{ |
4452 | +namespace qt |
4453 | +{ |
4454 | +namespace client |
4455 | +{ |
4456 | + |
4457 | +class Folder; |
4458 | +class Root; |
4459 | + |
4460 | +namespace internal |
4461 | +{ |
4462 | + |
4463 | +class ItemBase; |
4464 | + |
4465 | +namespace local_client |
4466 | +{ |
4467 | + |
4468 | +class UploadWorker; |
4469 | + |
4470 | +} // namespace local_client |
4471 | + |
4472 | +namespace remote_client |
4473 | +{ |
4474 | + |
4475 | +class CopyHandler; |
4476 | +class ItemImpl; |
4477 | +class LookupHandler; |
4478 | +class MetadataHandler; |
4479 | + |
4480 | +} // namespace remote_client |
4481 | +} // namespace internal |
4482 | + |
4483 | +/** |
4484 | +\brief Base class for files and folders. |
4485 | +*/ |
4486 | +class UNITY_STORAGE_EXPORT Item |
4487 | +{ |
4488 | +public: |
4489 | + /// @cond |
4490 | + virtual ~Item(); |
4491 | + /// @endcond |
4492 | + |
4493 | + Item(Item&&); |
4494 | + Item& operator=(Item&&); |
4495 | + |
4496 | + /** |
4497 | + \brief Convenience type definition. |
4498 | + */ |
4499 | + typedef std::shared_ptr<Item> SPtr; |
4500 | + |
4501 | + /** |
4502 | + \brief Returns the native identifier used by the provider. |
4503 | + */ |
4504 | + QString native_identity() const; |
4505 | + |
4506 | + /** |
4507 | + \brief Returns the name of the file or folder. |
4508 | + |
4509 | + The returned name may not be the same as the name that was used to create the item because the provider |
4510 | + may have changed it in some way (such as converting upper case characters to lower case). |
4511 | + */ |
4512 | + QString name() const; |
4513 | + |
4514 | + /** |
4515 | + \brief Returns the root folder for this item. |
4516 | + |
4517 | + If this item is a root, the returned pointer points at this item. |
4518 | + */ |
4519 | + Root* root() const; |
4520 | + |
4521 | + /** |
4522 | + \brief Returns the type of the item. |
4523 | + */ |
4524 | + ItemType type() const; |
4525 | + |
4526 | + /** |
4527 | + \brief Returns a version identifier for the item. |
4528 | + |
4529 | + The version identifier changes each time the file is updated (possibly |
4530 | + via some channel other than this API). |
4531 | + */ |
4532 | + QString etag() const; |
4533 | + |
4534 | + /** |
4535 | + \brief Returns metadata for the item. |
4536 | + |
4537 | + TODO: Needs a lot more doc. Explain standard and provider-specific metadata. |
4538 | + */ |
4539 | + QVariantMap metadata() const; |
4540 | + |
4541 | + /** |
4542 | + \brief Returns the time at which the item was last modified. |
4543 | + */ |
4544 | + QDateTime last_modified_time() const; |
4545 | + |
4546 | + /** |
4547 | + \brief Returns a list of parent folders of this item. |
4548 | + \return A vector of parents. For a root, the returned vector is empty. |
4549 | + \warn Depending on the provider, a single file or folder may have multiple |
4550 | + parents. Do not assume that only a single parent will be returned, or that |
4551 | + parents are returned in a particular order. |
4552 | + */ |
4553 | + QFuture<QVector<std::shared_ptr<Folder>>> parents() const; |
4554 | + |
4555 | + /** |
4556 | + \brief Returns the native identities of the parents of this item. |
4557 | + \return A vector of parent identities. For a root, the returned vector is empty. |
4558 | + \warn Depending on the provider, a single file or folder may have multiple |
4559 | + parents. Do not assume that only a single parent ID will be returned, or that |
4560 | + parent IDs are returned in a particular order. |
4561 | + */ |
4562 | + QVector<QString> parent_ids() const; |
4563 | + |
4564 | + /** |
4565 | + \brief Copies this item. |
4566 | + |
4567 | + Copying a folder recursively copies its contents. |
4568 | + \param new_parent The new parent folder for the item. If the item is to be copied within |
4569 | + its current folder, this parameter must designate the currently existing parent. |
4570 | + \param new_name The new name for the file. |
4571 | + \warn Do not rely on copy() to fail if an attempt is made to copy |
4572 | + a file or folder to a destination name that is the same as that of an already existing file or folder. |
4573 | + Depending on the cloud provider, it may be possible to have several folders with the same name. |
4574 | + */ |
4575 | + QFuture<Item::SPtr> copy(std::shared_ptr<Folder> const& new_parent, QString const& new_name); |
4576 | + |
4577 | + /** |
4578 | + \brief Renames and/or moves a file or folder. |
4579 | + \param new_parent The new parent folder for the item. If the item is to be renamed within |
4580 | + its current folder, this parameter must designate the currently existing parent. |
4581 | + \param new_name The new name for the item. |
4582 | + \warn Do not rely on move() to fail if an attempt is made to move |
4583 | + a file or folder to a destination name that is the same as that of an already existing file or folder. |
4584 | + Depending on the cloud provider, it may be possible to have several files or folders with the same name. |
4585 | + \note It is not possible to move or rename the root folder. |
4586 | + */ |
4587 | + QFuture<Item::SPtr> move(std::shared_ptr<Folder> const& new_parent, QString const& new_name); |
4588 | + |
4589 | + /** |
4590 | + \brief Permamently deletes the item. |
4591 | + \warning Deleting a folder recursively deletes its contents. |
4592 | + */ |
4593 | + QFuture<void> delete_item(); |
4594 | + |
4595 | + /** |
4596 | + \brief Compares two items for equality. |
4597 | + |
4598 | + Equality comparison is deep, that is, it compares the native identities of two items, not |
4599 | + their `shared_ptr` values. |
4600 | + \note If you retrieve the same item more than once (such as by calling Root::get() twice |
4601 | + with the same file ID) and then perform an upload using one of the two file handles, the |
4602 | + files still have the same identity after the upload. However, the etag() values of the two |
4603 | + file handles differ after the upload. Despite this, equal_to() still returns `true` for |
4604 | + the two files, that is, the ETags are ignored for equality comparison. |
4605 | + \return `!this->native_identity() == other->native_identity()` |
4606 | + \throws DeletedException if `this` or `other` have been deleted. |
4607 | + */ |
4608 | + bool equal_to(Item::SPtr const& other) const noexcept; |
4609 | + |
4610 | +protected: |
4611 | + Item(internal::ItemBase* p) UNITY_STORAGE_HIDDEN; |
4612 | + |
4613 | + std::shared_ptr<internal::ItemBase> p_; |
4614 | + |
4615 | + friend class internal::local_client::UploadWorker; |
4616 | + friend class internal::remote_client::CopyHandler; |
4617 | + friend class internal::remote_client::ItemImpl; |
4618 | + friend class internal::remote_client::LookupHandler; |
4619 | + friend class internal::remote_client::MetadataHandler; |
4620 | +}; |
4621 | + |
4622 | +} // namespace client |
4623 | +} // namespace qt |
4624 | +} // namespace storage |
4625 | +} // namespace unity |
4626 | |
4627 | === added file 'include/unity/storage/qt/client/Root.h' |
4628 | --- include/unity/storage/qt/client/Root.h 1970-01-01 00:00:00 +0000 |
4629 | +++ include/unity/storage/qt/client/Root.h 2016-07-21 12:22:21 +0000 |
4630 | @@ -0,0 +1,92 @@ |
4631 | +/* |
4632 | + * Copyright (C) 2016 Canonical Ltd |
4633 | + * |
4634 | + * This program is free software: you can redistribute it and/or modify |
4635 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4636 | + * published by the Free Software Foundation. |
4637 | + * |
4638 | + * This program is distributed in the hope that it will be useful, |
4639 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4640 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4641 | + * GNU Lesser General Public License for more details. |
4642 | + * |
4643 | + * You should have received a copy of the GNU Lesser General Public License |
4644 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4645 | + * |
4646 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4647 | + */ |
4648 | + |
4649 | +#pragma once |
4650 | + |
4651 | +#include <unity/storage/qt/client/Folder.h> |
4652 | + |
4653 | +namespace unity |
4654 | +{ |
4655 | +namespace storage |
4656 | +{ |
4657 | +namespace qt |
4658 | +{ |
4659 | +namespace client |
4660 | +{ |
4661 | + |
4662 | +class Account; |
4663 | +class Item; |
4664 | + |
4665 | +namespace internal |
4666 | +{ |
4667 | + |
4668 | +class RootBase; |
4669 | + |
4670 | +namespace local_client |
4671 | +{ |
4672 | + |
4673 | +class RootImpl; |
4674 | + |
4675 | +} // namespace local_client |
4676 | + |
4677 | +namespace remote_client |
4678 | +{ |
4679 | + |
4680 | +class RootImpl; |
4681 | + |
4682 | +} // namespace remote_client |
4683 | +} // namespace internal |
4684 | + |
4685 | +/** |
4686 | +\brief Class that represents a root folder. |
4687 | +*/ |
4688 | +class UNITY_STORAGE_EXPORT Root final : public Folder |
4689 | +{ |
4690 | +public: |
4691 | + // @cond |
4692 | + virtual ~Root(); |
4693 | + /// @endcond |
4694 | + |
4695 | + Root(Root&&); |
4696 | + Root& operator=(Root&&); |
4697 | + |
4698 | + typedef std::shared_ptr<Root> SPtr; |
4699 | + |
4700 | + /** |
4701 | + \brief Returns the account for this root. |
4702 | + */ |
4703 | + Account* account() const; |
4704 | + |
4705 | + QFuture<int64_t> free_space_bytes() const; |
4706 | + QFuture<int64_t> used_space_bytes() const; |
4707 | + |
4708 | + QFuture<Item::SPtr> get(QString native_identity) const; |
4709 | + |
4710 | + // TODO: Do we need a method to get lots of things? |
4711 | + |
4712 | +private: |
4713 | + Root(internal::RootBase*) UNITY_STORAGE_HIDDEN; |
4714 | + |
4715 | + friend class internal::local_client::RootImpl; |
4716 | + friend class internal::remote_client::RootImpl; |
4717 | +}; |
4718 | + |
4719 | +} // namespace client |
4720 | +} // namespace qt |
4721 | +} // namespace storage |
4722 | +} // namespace unity |
4723 | |
4724 | === added file 'include/unity/storage/qt/client/Runtime.h' |
4725 | --- include/unity/storage/qt/client/Runtime.h 1970-01-01 00:00:00 +0000 |
4726 | +++ include/unity/storage/qt/client/Runtime.h 2016-07-21 12:22:21 +0000 |
4727 | @@ -0,0 +1,108 @@ |
4728 | +/* |
4729 | + * Copyright (C) 2016 Canonical Ltd |
4730 | + * |
4731 | + * This program is free software: you can redistribute it and/or modify |
4732 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4733 | + * published by the Free Software Foundation. |
4734 | + * |
4735 | + * This program is distributed in the hope that it will be useful, |
4736 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4737 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4738 | + * GNU Lesser General Public License for more details. |
4739 | + * |
4740 | + * You should have received a copy of the GNU Lesser General Public License |
4741 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4742 | + * |
4743 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4744 | + */ |
4745 | + |
4746 | +#pragma once |
4747 | + |
4748 | +#include <unity/storage/visibility.h> |
4749 | + |
4750 | +#pragma GCC diagnostic push |
4751 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
4752 | +#include <QFuture> |
4753 | +#pragma GCC diagnostic pop |
4754 | + |
4755 | +#include <memory> |
4756 | + |
4757 | +class QDBusConnection; |
4758 | + |
4759 | +namespace unity |
4760 | +{ |
4761 | +namespace storage |
4762 | +{ |
4763 | +namespace qt |
4764 | +{ |
4765 | +namespace client |
4766 | +{ |
4767 | + |
4768 | +class Account; |
4769 | + |
4770 | +namespace internal |
4771 | +{ |
4772 | + |
4773 | +class RuntimeBase; |
4774 | + |
4775 | +namespace remote_client |
4776 | +{ |
4777 | + |
4778 | +class AccountImpl; |
4779 | + |
4780 | +} // namespace remote_client |
4781 | + |
4782 | +} // namespace internal |
4783 | + |
4784 | +/** |
4785 | +TODO |
4786 | +*/ |
4787 | +class UNITY_STORAGE_EXPORT Runtime final |
4788 | +{ |
4789 | +public: |
4790 | + /** |
4791 | + \brief Destroys the runtime. |
4792 | + |
4793 | + The destructor implicitly calls shutdown(). |
4794 | + |
4795 | + \warning Do not invoke methods on any other part of the API once the runtime is destroyed; |
4796 | + doing so has undefined behavior. |
4797 | + */ |
4798 | + ~Runtime(); |
4799 | + |
4800 | + Runtime(Runtime&&); |
4801 | + Runtime& operator=(Runtime&&); |
4802 | + |
4803 | + typedef std::shared_ptr<Runtime> SPtr; |
4804 | + |
4805 | + /** |
4806 | + \brief Initializes the runtime. |
4807 | + */ |
4808 | + static SPtr create(); |
4809 | + static SPtr create(QDBusConnection const& bus); |
4810 | + |
4811 | + /** |
4812 | + \brief Shuts down the runtime. |
4813 | + |
4814 | + This method shuts down the runtime. Calling shutdown() more than once is safe and does nothing. |
4815 | + |
4816 | + The destructor implicitly calls shutdown(). This method is provided mainly to permit logging of any |
4817 | + errors that might arise during shut-down. |
4818 | + \throws Various exceptions, depending on the error. TODO |
4819 | + */ |
4820 | + void shutdown(); |
4821 | + |
4822 | + QFuture<QVector<std::shared_ptr<Account>>> accounts(); |
4823 | + |
4824 | +private: |
4825 | + Runtime(internal::RuntimeBase* p) UNITY_STORAGE_HIDDEN; |
4826 | + |
4827 | + std::shared_ptr<internal::RuntimeBase> p_; |
4828 | + |
4829 | + friend class internal::remote_client::AccountImpl; |
4830 | +}; |
4831 | + |
4832 | +} // namespace client |
4833 | +} // namespace qt |
4834 | +} // namespace storage |
4835 | +} // namespace unity |
4836 | |
4837 | === added file 'include/unity/storage/qt/client/Uploader.h' |
4838 | --- include/unity/storage/qt/client/Uploader.h 1970-01-01 00:00:00 +0000 |
4839 | +++ include/unity/storage/qt/client/Uploader.h 2016-07-21 12:22:21 +0000 |
4840 | @@ -0,0 +1,135 @@ |
4841 | +/* |
4842 | + * Copyright (C) 2016 Canonical Ltd |
4843 | + * |
4844 | + * This program is free software: you can redistribute it and/or modify |
4845 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4846 | + * published by the Free Software Foundation. |
4847 | + * |
4848 | + * This program is distributed in the hope that it will be useful, |
4849 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4850 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4851 | + * GNU Lesser General Public License for more details. |
4852 | + * |
4853 | + * You should have received a copy of the GNU Lesser General Public License |
4854 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4855 | + * |
4856 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4857 | + */ |
4858 | + |
4859 | +#pragma once |
4860 | + |
4861 | +#include <unity/storage/visibility.h> |
4862 | + |
4863 | +#pragma GCC diagnostic push |
4864 | +#pragma GCC diagnostic ignored "-Wctor-dtor-privacy" |
4865 | +#include <QFuture> |
4866 | +#pragma GCC diagnostic pop |
4867 | +#include <QLocalSocket> |
4868 | + |
4869 | +#include <memory> |
4870 | + |
4871 | +class QLocalSocket; |
4872 | + |
4873 | +namespace unity |
4874 | +{ |
4875 | +namespace storage |
4876 | +{ |
4877 | +namespace qt |
4878 | +{ |
4879 | +namespace client |
4880 | +{ |
4881 | + |
4882 | +class File; |
4883 | + |
4884 | +namespace internal |
4885 | +{ |
4886 | + |
4887 | +class UploaderBase; |
4888 | + |
4889 | +namespace local_client |
4890 | +{ |
4891 | + |
4892 | +class FileImpl; |
4893 | +class FolderImpl; |
4894 | + |
4895 | +} // namespace local_client |
4896 | + |
4897 | +namespace remote_client |
4898 | +{ |
4899 | + |
4900 | +class UploaderImpl; |
4901 | + |
4902 | +} // namespace remote_client |
4903 | +} // namespace internal |
4904 | + |
4905 | +class UNITY_STORAGE_EXPORT Uploader final |
4906 | +{ |
4907 | +public: |
4908 | + /** |
4909 | + \brief Destroys the uploader. |
4910 | + |
4911 | + The destructor implicitly calls cancel() if it has not been called already. |
4912 | + */ |
4913 | + ~Uploader(); |
4914 | + |
4915 | + Uploader(Uploader&&); |
4916 | + Uploader& operator=(Uploader&&); |
4917 | + |
4918 | + /** |
4919 | + \brief Convenience type definition. |
4920 | + */ |
4921 | + typedef std::shared_ptr<Uploader> SPtr; |
4922 | + |
4923 | + /** |
4924 | + \brief Returns a socket that is open for writing. |
4925 | + |
4926 | + To upload the file contents, write to the returned socket. |
4927 | + If an operation on the socket returns an error, the file is in an indeterminate state. |
4928 | + |
4929 | + \return A socket open for writing. |
4930 | + */ |
4931 | + std::shared_ptr<QLocalSocket> socket() const; |
4932 | + |
4933 | + /** |
4934 | + \brief Finalizes the upload. |
4935 | + |
4936 | + Once you have written the file contents to the socket returned by socket(), you must call finish_upload(), |
4937 | + which closes the socket. Call `result()` on the returned future to check for errors. If an error |
4938 | + occurred, `result()` throws an exception. If the upload was cancelled, `result` throws CancelledException. |
4939 | + Otherwise, it returns the File that was uploaded. |
4940 | + |
4941 | + Calling finish_upload() more than once is safe; subsequent calls do nothing and return the future |
4942 | + that was returned by the first call. |
4943 | + */ |
4944 | + QFuture<std::shared_ptr<File>> finish_upload(); |
4945 | + |
4946 | + /** |
4947 | + \brief Cancels an upload. |
4948 | + |
4949 | + Calling cancel() informs the provider that the upload is no longer needed. The provider |
4950 | + will make a best-effort attempt to cancel the upload to the remote service. |
4951 | + |
4952 | + You can check whether the cancel was successfully sent by calling `waitForFinished()` on the returned future. |
4953 | + If this does not throw an exception, the message was received and acted upon by the provider. However, |
4954 | + successful completion does _not_ indicate that the upload was actually cancelled. (For example, |
4955 | + the upload may have completed already by the time the provider received the cancel request, or the provider |
4956 | + may not support cancellation.) |
4957 | + |
4958 | + Calling cancel() more than once, or calling cancel() after a call to finish_upload() is safe and does nothing. |
4959 | + */ |
4960 | + QFuture<void> cancel(); |
4961 | + |
4962 | +private: |
4963 | + Uploader(internal::UploaderBase*) UNITY_STORAGE_HIDDEN; |
4964 | + |
4965 | + std::shared_ptr<internal::UploaderBase> p_; |
4966 | + |
4967 | + friend class internal::local_client::FileImpl; |
4968 | + friend class internal::local_client::FolderImpl; |
4969 | + friend class internal::remote_client::UploaderImpl; |
4970 | +}; |
4971 | + |
4972 | +} // namespace client |
4973 | +} // namespace qt |
4974 | +} // namespace storage |
4975 | +} // namespace unity |
4976 | |
4977 | === added directory 'include/unity/storage/qt/client/internal' |
4978 | === added file 'include/unity/storage/qt/client/internal/AccountBase.h' |
4979 | --- include/unity/storage/qt/client/internal/AccountBase.h 1970-01-01 00:00:00 +0000 |
4980 | +++ include/unity/storage/qt/client/internal/AccountBase.h 2016-07-21 12:22:21 +0000 |
4981 | @@ -0,0 +1,71 @@ |
4982 | +/* |
4983 | + * Copyright (C) 2016 Canonical Ltd |
4984 | + * |
4985 | + * This program is free software: you can redistribute it and/or modify |
4986 | + * it under the terms of the GNU Lesser General Public License version 3 as |
4987 | + * published by the Free Software Foundation. |
4988 | + * |
4989 | + * This program is distributed in the hope that it will be useful, |
4990 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
4991 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4992 | + * GNU Lesser General Public License for more details. |
4993 | + * |
4994 | + * You should have received a copy of the GNU Lesser General Public License |
4995 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
4996 | + * |
4997 | + * Authors: Michi Henning <michi.henning@canonical.com> |
4998 | + */ |
4999 | + |
5000 | +#pragma once |
The diff has been truncated for viewing.
Got this when building in the dev-build-4 PPA
test 2
Start 2: remote-client
2: Test command: /«PKGBUILDDIR» /obj-x86_ 64-linux- gnu/tests/ remote- client/ remote- client_ test lifecycle "org.freedeskto p.DBus. Error.UnknownMe thod", "No such interface 'com.ubuntu. OnlineAccounts. Manager' on object at path /com/ubuntu/ OnlineAccounts/ Manager" ) connection_ real_closed: Remote peer vanished with error: Underlying GIOStream returned 0 bytes on an async read (g-io-error-quark, 0). Exiting. lifecycle (101 ms) "org.freedeskto p.DBus. Error.UnknownMe thod", "No such interface 'com.ubuntu. OnlineAccounts. Manager' on object at path /com/ubuntu/ OnlineAccounts/ Manager" ) "org.freedeskto p.DBus. Error.UnknownMe thod", "No such interface 'com.ubuntu. OnlineAccounts. Manager' on object at path /com/ubuntu/ OnlineAccounts/ Manager" ) ....... ....... ....... ....... ....... ....... ....... ***Exception: SegFault 1.14 sec lifecycle "org.freedeskto p.DBus. Error.UnknownMe thod", "No such interface 'com.ubuntu. OnlineAccounts. Manager' on object at path /com/ubuntu/ OnlineAccounts/ Manager" ) connection_ real_closed: Remote peer vanished with error: Underlying GIOStream returned 0 bytes on an async read (g-io-error-quark, 0). Exiting. lifecycle (101 ms) "org.freedeskto p.DBus. Error.UnknownMe thod", "No such interface 'com.ubuntu. OnlineAccounts. Manager' on object at path /com/ubuntu/ OnlineAccounts/ Manager" ) "org.freedeskto p.DBus. Error.UnknownMe thod", "No such interface 'com.ubuntu. OnlineAccounts. Manager' on object at path /com/ubuntu/ OnlineAccounts/ Manager" )
2: Test timeout computed to be: 1500
2: [==========] Running 6 tests from 4 test cases.
2: [----------] Global test environment set-up.
2: [----------] 3 tests from RuntimeTest
2: [ RUN ] RuntimeTest.
2: GetAccounts call failed: QDBusError(
2: Bus unique name: ":1.2"
2: g_dbus_
2: [ OK ] RuntimeTest.
2: [ RUN ] RuntimeTest.basic
2: GetAccounts call failed: QDBusError(
2: Bus unique name: ":1.2"
2: GetAccounts call failed: QDBusError(
2: Cannot find any online account
2: Configure at least one online account for a provider in System Settings -> Online Accounts
2/13 Test #2: remote-client .......
[==========] Running 6 tests from 4 test cases.
[----------] Global test environment set-up.
[----------] 3 tests from RuntimeTest
[ RUN ] RuntimeTest.
GetAccounts call failed: QDBusError(
Bus unique name: ":1.2"
g_dbus_
[ OK ] RuntimeTest.
[ RUN ] RuntimeTest.basic
GetAccounts call failed: QDBusError(
Bus unique name: ":1.2"
GetAccounts call failed: QDBusError(
Cannot find any online account
Configure at least one online account for a provider in System Settings -> Online Accounts