[ACR-1025] added error enum and feature check 88/140588/4 accepted/tizen/4.0/unified/20170816.010524 accepted/tizen/4.0/unified/20170816.014244 accepted/tizen/unified/20170727.191342 submit/tizen/20170727.053736 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170814.115522 submit/tizen_4.0_unified/20170814.115522
authorIckhee Woo <ickhee.woo@samsung.com>
Tue, 25 Jul 2017 12:11:10 +0000 (21:11 +0900)
committerIckhee Woo <ickhee.woo@samsung.com>
Thu, 27 Jul 2017 05:09:24 +0000 (14:09 +0900)
Change-Id: I94c086c1473261f8b9d02a2c2f9bfa2ce09e935f
Signed-off-by: Ickhee Woo <ickhee.woo@samsung.com>
common/sync-log.h
doc/sync_manager_doc.h
include/sync-error.h
include/sync_adapter.h
include/sync_manager.h
include/sync_manager_internal.h
packaging/sync-manager.spec
src/sync-client/sync_adapter.c
src/sync-client/sync_manager.c

index 44b3cb19aafdc50e383066d1901e671faf9e202b..6e2b8e05d68a430deb97105b8198464624e80660 100644 (file)
@@ -26,6 +26,7 @@
 
 #include <dlog.h>
 #include <stdbool.h>
+#include <system_info.h>
 
 #define TIZEN_DEBUG_ENABLE
 #define ENABLE_DEBUG
@@ -90,5 +91,17 @@ typedef bool  result;
 #endif /* ENABLE_DEBUG_MSG */
 
 
+#define SYNC_MANAGER_FEATURE "http://tizen.org/feature/account.sync"
+#define CHECK_SYNC_SUPPORTED(feature_name) \
+       do { \
+               bool is_supported = false; \
+               if (!system_info_get_platform_bool(feature_name, &is_supported)) { \
+                       if (!is_supported) { \
+                               LOG_LOGD("[%s] feature is disabled", feature_name); \
+                               return SYNC_ERROR_NOT_SUPPORTED; \
+                       } \
+               } \
+       } while(0)
+
 
 #endif /* SYNC_LOG_H_ */
index 890b9eb29f346f5ceaa1ffacc0c8b110f30828eb..e4d9734661122575e0820733809d68f2e7b5f247 100644 (file)
  * The Sync Manager provides APIs for managing the sync operations. Applications will call these APIs to schedule their sync operations.
  * Sync Manager maintains sync requests from all the applications and invokes their respective callback methods to perform data synchronization operations.
  *
+ * @section CAPI_SYNC_MANAGER_MODULE_FEATURE Related Features
+ * This API is related with the following features:\n
+ * - http://tizen.org/feature/account.sync\n
+ * It is recommended to use features in your application for reliability. \n
+ * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, and control your application's actions accordingly. \n
+ * To ensure your application is running only on devices with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
+ * More details on using features in your application can be found from <a href="https://developer.tizen.org/development/tizen-studio/native-tools/configuring-your-app/manifest-text-editor#feature"><b>Feature Element</b>.</a>
+ *
  * @defgroup  CAPI_SYNC_ADAPTER_MODULE Sync Adapter
  * @ingroup   CAPI_SYNC_MANAGER_MODULE
  * @brief     The Sync Adapter.
index fe0cc7c9f17c028b0c6de59e99f4d302ec06b8ad..038f68cb32f84028c93519b9a2b0975eb0367213 100644 (file)
@@ -46,6 +46,7 @@ extern "C"
  */
 typedef enum {
        SYNC_ERROR_NONE                                         = TIZEN_ERROR_NONE,                                     /**< Successful */
+       SYNC_ERROR_NOT_SUPPORTED                        = TIZEN_ERROR_NOT_SUPPORTED,            /**< Not supported (Since 4.0) */
        SYNC_ERROR_OUT_OF_MEMORY                        = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of memory */
        SYNC_ERROR_IO_ERROR                                     = TIZEN_ERROR_IO_ERROR,                         /**< I/O error */
        SYNC_ERROR_PERMISSION_DENIED            = TIZEN_ERROR_PERMISSION_DENIED,        /**< Permission denied */
index 9db3bfca0af8b2f174717dba53e0daac2d69ed4e..e9c16ed2a083c5a210eeb0701b07b1b220ec72f4 100644 (file)
@@ -104,6 +104,7 @@ typedef void (*sync_adapter_cancel_sync_cb)(account_h account, const char *sync_
  *         otherwise a negative error value
  *
  * @retval #SYNC_ERROR_NONE                                    Successful
+ * @retval #SYNC_ERROR_NOT_SUPPORTED           Not supported
  * @retval #SYNC_ERROR_OUT_OF_MEMORY           Out of memory
  * @retval #SYNC_ERROR_IO_ERROR                                I/O error
  * @retval #SYNC_ERROR_INVALID_PARAMETER       Invalid parameter
@@ -125,8 +126,9 @@ int sync_adapter_set_callbacks(sync_adapter_start_sync_cb on_start_cb, sync_adap
  * @return @c 0 on success,
  *         otherwise a negative error value
  *
- * @retval #SYNC_ERROR_NONE                Successful
- * @retval #SYNC_ERROR_SYSTEM              System error
+ * @retval #SYNC_ERROR_NONE                                    Successful
+ * @retval #SYNC_ERROR_NOT_SUPPORTED           Not supported
+ * @retval #SYNC_ERROR_SYSTEM                          System error
  *
  * @pre Call sync_adapter_set_callbacks() before calling this function.
  *
index cef27f3d3765f4a77d1b1e724615fd0ce739165b..8e1f003203c4e9ace6e8a94b2f9fac14b918422a 100644 (file)
@@ -162,6 +162,7 @@ typedef bool (*sync_manager_sync_job_cb)(account_h account, const char *sync_job
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #SYNC_ERROR_NONE                                                                    Successful
+ * @retval #SYNC_ERROR_NOT_SUPPORTED                                           Not supported
  * @retval #SYNC_ERROR_INVALID_PARAMETER                                       Invalid parameter
  * @retval #SYNC_ERROR_QUOTA_EXCEEDED                                          Quota exceeded
  * @retval #SYNC_ERROR_SYSTEM                                                          Internal system error
@@ -196,6 +197,7 @@ int sync_manager_on_demand_sync_job(account_h account, const char *sync_job_name
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #SYNC_ERROR_NONE                                                            Successful
+ * @retval #SYNC_ERROR_NOT_SUPPORTED                                   Not supported
  * @retval #SYNC_ERROR_INVALID_PARAMETER                               Invalid parameter
  * @retval #SYNC_ERROR_QUOTA_EXCEEDED                                  Quota exceeded
  * @retval #SYNC_ERROR_SYSTEM                                                  Internal system error
@@ -232,6 +234,7 @@ int sync_manager_add_periodic_sync_job(account_h account, const char *sync_job_n
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #SYNC_ERROR_NONE                                                    Successful
+ * @retval #SYNC_ERROR_NOT_SUPPORTED                           Not supported
  * @retval #SYNC_ERROR_INVALID_PARAMETER                       Invalid parameter
  * @retval #SYNC_ERROR_QUOTA_EXCEEDED                          Quota exceeded
  * @retval #SYNC_ERROR_SYSTEM                                          Internal system error
@@ -258,6 +261,7 @@ int sync_manager_add_data_change_sync_job(account_h account, const char *sync_ca
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #SYNC_ERROR_NONE                                    Successful
+ * @retval #SYNC_ERROR_NOT_SUPPORTED           Not supported
  * @retval #SYNC_ERROR_INVALID_PARAMETER       Invalid parameter
  * @retval #SYNC_ERROR_SYSTEM                          Internal system error
  *
@@ -284,6 +288,7 @@ int sync_manager_remove_sync_job(int sync_job_id);
  * @return @c 0 on success,
  *         otherwise a negative error value
  * @retval #SYNC_ERROR_NONE                                    Successful
+ * @retval #SYNC_ERROR_NOT_SUPPORTED           Not supported
  * @retval #SYNC_ERROR_INVALID_PARAMETER       Invalid parameter
  * @retval #SYNC_ERROR_SYSTEM                          Internal system error
  *
index f32cb89262089913f8f563c35624eb41f5e6a4b0..8982e335cb7671e0a980b68b091a7eb83a4bf894 100644 (file)
@@ -18,6 +18,7 @@
 #ifndef __SYNC_MANAGER_INTERNAL_H__
 #define __SYNC_MANAGER_INTERNAL_H__
 
+
 #ifdef __cplusplus
 extern "C"
 {
index 4ebd6b87aec43451078910d079f224d236677607..e64314ce112b38086420fd6ea322867b300d0e1a 100644 (file)
@@ -2,7 +2,7 @@
 %global __provides_exclude_from ^.*\\.extension-calendar
 
 Name:      sync-service
-Version:   0.2.28
+Version:   0.3.28
 Release:   1
 License:   Apache-2.0
 Summary:   Sync manager daemon
index aaaa4a6f8f6d57ef6a564649cf668fb6b5118f56..19111f2c34fc1b45bf0c9793b8823d042e5333ae 100644 (file)
@@ -188,6 +188,8 @@ int __register_sync_adapter(bool flag)
 
 int sync_adapter_set_callbacks(sync_adapter_start_sync_cb on_start_cb, sync_adapter_cancel_sync_cb on_cancel_cb)
 {
+       CHECK_SYNC_SUPPORTED(SYNC_MANAGER_FEATURE);
+
        SYNC_LOGE_RET_RES(on_start_cb != NULL && on_cancel_cb != NULL, SYNC_ERROR_INVALID_PARAMETER, "Callback parameters must be passed");
 
        if (!g_sync_adapter) {
@@ -232,6 +234,8 @@ int sync_adapter_set_callbacks(sync_adapter_start_sync_cb on_start_cb, sync_adap
 
 int sync_adapter_unset_callbacks()
 {
+       CHECK_SYNC_SUPPORTED(SYNC_MANAGER_FEATURE);
+
        SYNC_LOGE_RET_RES(g_sync_adapter != NULL, SYNC_ERROR_SYSTEM, "sync_adapter_set_callbacks should be called first");
 
        LOG_LOGD("sync_adapter_destroy");
index 4343d120a1ebe406b8deb084a5c0493896542895..79d3188facd93f61da65ce33eff013b930e9ddf8 100644 (file)
@@ -284,6 +284,8 @@ int get_interval(sync_period_e period)
 
 int sync_manager_on_demand_sync_job(account_h account, const char *sync_job_name, sync_option_e sync_option, bundle *sync_job_user_data, int *sync_job_id)
 {
+       CHECK_SYNC_SUPPORTED(SYNC_MANAGER_FEATURE);
+
        SYNC_LOGE_RET_RES(sync_job_name != NULL, SYNC_ERROR_INVALID_PARAMETER, "sync_job_name is NULL");
        SYNC_LOGE_RET_RES(sync_option >= SYNC_OPTION_NONE && sync_option <= (SYNC_OPTION_EXPEDITED | SYNC_OPTION_NO_RETRY), SYNC_ERROR_INVALID_PARAMETER, "sync_option is invalid [%d]", sync_option);
        SYNC_LOGE_RET_RES(sync_job_id != NULL, SYNC_ERROR_INVALID_PARAMETER, "sync_job_id is NULL");
@@ -328,6 +330,8 @@ int sync_manager_on_demand_sync_job(account_h account, const char *sync_job_name
 
 int sync_manager_add_periodic_sync_job(account_h account, const char *sync_job_name, sync_period_e sync_period, sync_option_e sync_option, bundle *sync_job_user_data, int *sync_job_id)
 {
+       CHECK_SYNC_SUPPORTED(SYNC_MANAGER_FEATURE);
+
        SYNC_LOGE_RET_RES(sync_job_name != NULL, SYNC_ERROR_INVALID_PARAMETER, "sync_job_name is NULL");
        SYNC_LOGE_RET_RES((sync_period >= SYNC_PERIOD_INTERVAL_30MIN && sync_period < SYNC_PERIOD_INTERVAL_MAX), SYNC_ERROR_INVALID_PARAMETER, "Time interval not supported [%d]", sync_period);
        SYNC_LOGE_RET_RES(sync_option >= SYNC_OPTION_NONE && sync_option <= (SYNC_OPTION_EXPEDITED | SYNC_OPTION_NO_RETRY), SYNC_ERROR_INVALID_PARAMETER, "sync_option is invalid [%d]", sync_option);
@@ -372,6 +376,8 @@ int sync_manager_add_periodic_sync_job(account_h account, const char *sync_job_n
 
 int sync_manager_add_data_change_sync_job(account_h account, const char *sync_capability, sync_option_e sync_option, bundle *sync_job_user_data, int *sync_job_id)
 {
+       CHECK_SYNC_SUPPORTED(SYNC_MANAGER_FEATURE);
+
        if (sync_capability != NULL) {
                if (!(strcmp(sync_capability, "http://tizen.org/sync/capability/calendar")) ||
                        !(strcmp(sync_capability, "http://tizen.org/sync/capability/contact")) ||
@@ -429,6 +435,8 @@ int sync_manager_add_data_change_sync_job(account_h account, const char *sync_ca
 
 int sync_manager_remove_sync_job(int sync_job_id)
 {
+       CHECK_SYNC_SUPPORTED(SYNC_MANAGER_FEATURE);
+
        SYNC_LOGE_RET_RES(g_sync_manager != NULL, SYNC_ERROR_SYSTEM, "there is no sync job to be removed");
        SYNC_LOGE_RET_RES(g_sync_manager->ipcObj != NULL, SYNC_ERROR_SYSTEM, "sync manager is not connected");
        SYNC_LOGE_RET_RES(sync_job_id >= 1 && sync_job_id <= 100, SYNC_ERROR_INVALID_PARAMETER, "sync_job_id is inappropriate value");
@@ -457,6 +465,8 @@ int sync_manager_remove_sync_job(int sync_job_id)
 
 int sync_manager_foreach_sync_job(sync_manager_sync_job_cb sync_job_cb, void *user_data)
 {
+       CHECK_SYNC_SUPPORTED(SYNC_MANAGER_FEATURE);
+
        if (!sync_job_cb) {
                LOG_LOGD("sync client: sync_job_cb is NULL");
                return SYNC_ERROR_INVALID_PARAMETER;