SyncManager handles all the requests to upload and download. It's constructed around two threads for content synchronization. One for content uploading to cloud, another for cloud item downloading to local. Both thread are running asynchronously. Calls.
More...
#include <syncmanager.h>
SyncManager handles all the requests to upload and download. It's constructed around two threads for content synchronization. One for content uploading to cloud, another for cloud item downloading to local. Both thread are running asynchronously. Calls.
- See also
- add_download_tasks() by passing a content id list for cloud content download, Calls
-
add_upload_tasks() by passing a local file list path for local content upload.
Definition at line 45 of file syncmanager.h.
§ DownloadList
§ Ptr
§ Stringlist
§ UploadList
§ ~SyncManager()
virtual mcloud::api::SyncManager::~SyncManager |
( |
| ) |
|
|
virtualdefault |
§ SyncManager()
mcloud::api::SyncManager::SyncManager |
( |
const SyncManager & |
| ) |
|
|
delete |
§ add_download_task() [1/2]
DownloadTask::Ptr mcloud::api::SyncManager::add_download_task |
( |
const std::string & |
content_id | ) |
|
Add a new task with a given content id into download queue.
- Returns
- a download task object that is pushed in sync-up manager.
- Exceptions
-
std::runtime_error | if error occurs. |
- See also
- add_download_tasks(), DownloadTask
§ add_download_task() [2/2]
Pushes a download buffer callback item buffer_cb to sync manager and add regarding upload task into download queue. A download buffer object consists of the following fields.
write_cb
(std::function<size_t(void *dest, size_t buf_size)>) buffer reading callback function. The buffer area pointed at by the pointer dest should be filled up with at most buf_size number of bytes.
content_id
(string) The id of content on mcloud. - Returns
- a download task object that is pushed in sync-up manager.
- Exceptions
-
std::runtime_error | if error occurs. |
- See also
- add_download_tasks(), DownloadTask
§ add_upload_task() [1/2]
Pushes a upload request item request_item to sync manager and add regarding upload task into upload queue. A upload request object consists of the following fields.
file_path
(string) local file path.
folder_id
(string) mcloud folder id which stores content in uploads folder.
content_name
(string) uploaded content name. If content_name is empty, local file name will be used as a content name displayed on mcloud. If folder_id is empty, content will be uploaded into root folder. - Returns
- a download task object that are pushed in sync-up manager.
- Exceptions
-
std::runtime_error | if error occurs. |
- Note
- A file name can not contain any of following characters: '\', '/', ':', '*', '?', '"', '<', '>', '|'
-
Sync manager will detect if the uploading file is already existing on cloud, if so, it simply sets the status of upload task completed to avoid duplicated upload.
- See also
- add_download_tasks(), UploadRequest, UploadTask,
§ add_upload_task() [2/2]
Pushes a new upload request object buffer_cb to sync manager and add regarding upload task into upload queue. A upload buffer request object consists of the following fields.
read_cb
(std::function<size_t(void *dest, size_t buf_size)>) buffer reading callback function. The buffer area pointed at by the pointer dest should be filled up with at most buf_size number of bytes.
buffer_size
(size_t) total size of data buffers.
folder_id
(string) mcloud folder id which stores content in uploads folder.
content_name
(string) uploaded content name, should not be empty. If folder_id is empty, content will be uploaded into root folder. - Returns
- a upload task object that are pushed in sync-up manager.
- Exceptions
-
std::runtime_error | if error occurs. |
- Note
- A file name can not contain any of following characters: '\', '/', ':', '*', '?', '"', '<', '>', '|'
- See also
- add_download_tasks(), UploadRequest, UploadTask,
§ cancel()
void mcloud::api::SyncManager::cancel |
( |
| ) |
|
Cancels all download or upload tasks from sync-up thread if sync manager is running.
- Note
- A canceled download or upload task has no chance to run again by sync-up thread.
- See also
- start(), pause()
§ download_queue()
Returns a download task list hold by sync up manager. Each item in the list contains basic information of associated task.
- See also
- upload_queue(), DownloadTask
§ operator=()
§ pause()
void mcloud::api::SyncManager::pause |
( |
| ) |
|
Pauses download or upload task from sync-up thread if sync manager is running. Sync-up thread can continue to run previous paused task by calling.
- See also
- start().
-
start(), cancel()
§ start()
void mcloud::api::SyncManager::start |
( |
| ) |
|
Starts to run download or upload tasks from sync-up thread. The tasks can be resumed by sync-up thread if sync manager is paused or canceled before.
- See also
- pause(), cancel()
§ upload_queue()
UploadList mcloud::api::SyncManager::upload_queue |
( |
| ) |
|
Returns a upload task list hold by sync up manager. Each item in the list contains basic information of associated task.
- See also
- download_queue(), UploadTask
§ ClientPriv
The documentation for this class was generated from the following file:
- /build/mcloud-sImUD4/mcloud-1.0.0+17.04.20161107.3/include/mcloud/api/syncmanager.h