mcloud  1.0.0
MCloud API library for cmcc cloud service
uploadtask.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2016 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Gary Wang <gary.wang@canonical.com>
17  */
18 
19 #ifndef MCLOUD_API_UPLOADTASK_H_
20 #define MCLOUD_API_UPLOADTASK_H_
21 
22 #include <mcloud/api/task.h>
23 #include <mcloud/api/visibility.h>
24 
25 #include <memory>
26 #include <vector>
27 
28 namespace mcloud {
29 namespace api {
30 
31 class TaskHandler;
32 
38 {
39  std::string file_path;
40  std::string folder_id;
41  std::string content_name;
42 };
43 typedef std::vector<UploadRequest> UploadRequestList;
44 
50 {
52  size_t buffer_size;
53  std::string folder_id;
54  std::string content_name;
55 };
56 typedef std::vector<UploadBufferCb> UploadBufferCbList;
57 
58 class UploadTaskPriv;
59 class SyncManagerPriv;
60 
67 public:
68  typedef std::shared_ptr<UploadTask> Ptr;
69 
70  virtual ~UploadTask() = default;
71 
72  UploadTask(const UploadTask& ) = delete;
73 
74  UploadTask& operator=(const UploadTask& ) = delete;
75 
79  const std::string & task_id() const override;
80 
84  const std::string & content_id() const override;
85 
89  const std::string & content_name() const override;
90 
94  const std::string & file_path() const override;
95 
99  const std::string & error_string() const override;
100 
105  const std::string & task_url() const override;
106 
110  Task::Status status() const override;
111 
116  Task::ProgressHandler & progress_changed() override;
117 
122  Task::StatusHandler & status_changed() override;
123 
128  void cancel() override;
129 
133  size_t file_size() const;
134 
138  bool is_need_upload() const;
139 
140 private:
141  UploadTask(std::shared_ptr<UploadTaskPriv> p);
142 
143  friend class SyncManagerPriv;
144 
145  std::shared_ptr<UploadTaskPriv> p_;
146 };
147 
148 }
149 }
150 
151 #endif // MCLOUD_API_UPLOADTASK_H_
Task::Buffer_Callback read_cb
Definition: uploadtask.h:51
UploadBufferCb is a upload request item which consists of a upload folder id, upload buffer size...
Definition: uploadtask.h:49
Task is an abstract class that defines common interfaces for upload and download task.
Definition: task.h:34
std::shared_ptr< UploadTask > Ptr
Definition: uploadtask.h:68
std::vector< UploadRequest > UploadRequestList
Definition: uploadtask.h:43
std::function< void(Status)> StatusHandler
Definition: task.h:50
UploadRequest is a upload request item which consists of a upload folder id, up-front buffer size...
Definition: uploadtask.h:37
std::function< void(float)> ProgressHandler
Definition: task.h:48
Definition: client.h:37
std::function< size_t(void *dest, size_t buf_size)> Buffer_Callback
Definition: task.h:52
#define MCLOUD_API_DLL_PUBLIC
Definition: visibility.h:26
UploadTask is a task item that can be accessed from application layer to fetch basic upload item info...
Definition: uploadtask.h:66
Status
The Status enum indicates current status of this task.
Definition: task.h:39
std::vector< UploadBufferCb > UploadBufferCbList
Definition: uploadtask.h:56