[Internal: API change] When profile gets, input param changed.
[platform/core/system/sync-agent.git] / include / event / oma_ds_api.h
index 559b04c..979fff0 100755 (executable)
@@ -45,6 +45,58 @@ extern "C" {
        } sync_agent_ds_service_type_e;
 
 /**
+ * Enumerations of sync mode
+ */
+       typedef enum {
+               SYNC_AGENT_SYNC_MODE_MANUAL = 0,                /**< Manual */
+               SYNC_AGENT_SYNC_MODE_PERIODIC = 1,      /**< Periodic */
+               SYNC_AGENT_SYNC_MODE_PUSH = 2                   /**< Push */
+       } sync_agent_ds_sync_mode_e;
+
+/**
+ * Enumerations of sync type
+ */
+       typedef enum {
+               SYNC_AGENT_SYNC_TYPE_FULL_SYNC = 0,                                             /**< Full */
+               SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH = 1,                                   /**< Update both */
+               SYNC_AGENT_SYNC_TYPE_UPDATE_TO_SERVER = 2,                      /**< Update to server */
+               SYNC_AGENT_SYNC_TYPE_UPDATE_TO_PHONE = 3,                               /**< Update to phone */
+               SYNC_AGENT_SYNC_TYPE_REFRESH_FROM_SERVER = 4,           /**< Refresh from server */
+               SYNC_AGENT_SYNC_TYPE_REFRESH_FROM_PHONE = 5                     /**< Refresh from phone */
+       } sync_agent_ds_sync_type_e;
+
+/**
+ * Enumerations of sync interval
+ */
+       typedef enum {
+               SYNC_AGENT_SYNC_INTERVAL_NONE = 0,                                      /**< None */
+               SYNC_AGENT_SYNC_INTERVAL_5_MINUTES = 1,                                 /**< 5 minutes */
+               SYNC_AGENT_SYNC_INTERVAL_15_MINUTES = 2,                                /**< 15 minutes */
+               SYNC_AGENT_SYNC_INTERVAL_1_HOUR = 3,                                            /**< 1 hour */
+               SYNC_AGENT_SYNC_INTERVAL_4_HOURS = 4,                                   /**< 4 hours */
+               SYNC_AGENT_SYNC_INTERVAL_12_HOURS = 5,                                  /**< 12 hours */
+               SYNC_AGENT_SYNC_INTERVAL_1_DAY = 6,                                             /**< 1 day */
+               SYNC_AGENT_SYNC_INTERVAL_1_WEEK = 7,                                            /**< 1 week */
+               SYNC_AGENT_SYNC_INTERVAL_1_MONTH = 8                                    /**< 1 month */
+       } sync_agent_ds_sync_interval_e;
+
+/**
+ * Enumerations of src uri
+ */
+       typedef enum {
+               SYNC_AGENT_SRC_URI_CONTACT = 0,                                         /**< Contacts */
+               SYNC_AGENT_SRC_URI_CALENDAR = 1                                 /**< Calendar */
+       } sync_agent_ds_src_uri_e;
+
+/**
+ * Enumerations of sync callback
+ */
+       typedef enum {
+               SYNC_AGENT_DS_SYNC_SESSION = 1, /**< Sync session */
+               SYNC_AGENT_DS_SYNC_PROCESS = 2  /**< Sync process */
+       } sync_agent_ds_sync_callback_e;
+
+/**
  * @brief      Structure of OMA DS Server information instance
  */
        typedef struct {
@@ -57,9 +109,9 @@ extern "C" {
  * @brief      Structure of OMA DS Sync information instance
  */
        typedef struct {
-               char *sync_mode;                /**< Sync mode */
-               char *sync_type;                /**< Sync type */
-               char *interval;                 /**< Interval */
+               sync_agent_ds_sync_mode_e sync_mode;            /**< Sync mode */
+               sync_agent_ds_sync_type_e sync_type;            /**< Sync type */
+               sync_agent_ds_sync_interval_e interval;                 /**< Interval */
        } sync_agent_ds_sync_info;
 
 /**
@@ -68,7 +120,7 @@ extern "C" {
        typedef struct {
                sync_agent_ds_service_type_e service_type;      /**< Service type */
                int enabled;                                                            /**< Enable or not */
-               char *src_uri;                                                          /**< Source uri */
+               sync_agent_ds_src_uri_e src_uri;                                                                /**< Source uri */
                char *tgt_uri;                                                          /**< Target uri */
                char *id;                                                                       /**< Id */
                char *password;                                                         /**< password */
@@ -78,6 +130,7 @@ extern "C" {
  * @brief      Structure of OMA DS Profile information instance
  */
        typedef struct {
+               int profile_id;                                                                 /**< Profile id */
                char *profile_dir_name;                                         /**< Profile dir name */
                char *profile_name;                                                     /**< Profile name */
                sync_agent_ds_server_info server_info;          /**< Server information */
@@ -154,7 +207,6 @@ extern "C" {
  *
  * ds_profile_h profile_h = NULL;
  * char *profile_dir_name = "Sync1";
- * char *profile_name = "profile name";
  *
  * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
@@ -163,7 +215,7 @@ extern "C" {
  *
  *     ...
  *
- * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ * ds_err = sync_agent_ds_set_profile_dir_name(profile_h, profile_dir_name);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -173,10 +225,38 @@ extern "C" {
  * @endcode
  * @param[in]  profile_h                       profile info initialized
  * @param[in]  profile_dir_name        profile dir name
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+       sync_agent_ds_error_e sync_agent_ds_set_profile_dir_name(ds_profile_h profile_h, char *profile_dir_name);
+
+/**
+ * @brief set profile name into profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * char *profile_name = "profile name";
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                       profile info initialized
  * @param[in]  profile_name            profile name
  * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
  */
-       sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_dir_name, char *profile_name);
+       sync_agent_ds_error_e sync_agent_ds_set_profile_name(ds_profile_h profile_h, char *profile_name);
 
 /**
  * @brief set server information into profile info
@@ -217,9 +297,9 @@ extern "C" {
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *sync_mode = "Periodic";
- * char *sync_type = "Update both";
- * char *interval = "1 hour";
+ * sync_agent_ds_sync_mode_e sync_mode = SYNC_AGENT_SYNC_MODE_PERIODIC;
+ * sync_agent_ds_sync_type_e sync_type = SYNC_AGENT_SYNC_TYPE_UPDATE_BOTH;
+ * sync_agent_ds_sync_interval_e interval = SYNC_AGENT_SYNC_INTERVAL_1_HOUR;
  *
  * sync_agent_ds_error_e ds_err = sync_agent_ds_create_profile_info(&profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
@@ -237,12 +317,12 @@ extern "C" {
  *
  * @endcode
  * @param[in]  profile_h               profile info initialized
- * @param[in]  sync_mode               sync mode(Push, Manual, Periodic)
- * @param[in]  sync_type               sync type(Full, Update both, Update to server, Update to phone, Refresh from server, Refresh from phone)
- * @param[in]  interval                interval(only for periodic sync(5 minutes, 15 minutes, 1 hour, 4 hours, 12 hours, 1 day, 1 week))
+ * @param[in]  sync_mode               sync mode(sync_agent_ds_sync_mode_e value)
+ * @param[in]  sync_type               sync type(sync_agent_ds_sync_type_e value)
+ * @param[in]  interval                        interval(sync_agent_ds_sync_interval_e)
  * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
  */
-       sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, char *sync_mode, char *sync_type, char *interval);
+       sync_agent_ds_error_e sync_agent_ds_set_sync_info(ds_profile_h profile_h, sync_agent_ds_sync_mode_e sync_mode, sync_agent_ds_sync_type_e sync_type, sync_agent_ds_sync_interval_e interval);
 
 /**
  * @brief set service information into profile info
@@ -275,32 +355,64 @@ extern "C" {
  * @param[in]  profile_h               profile info initialized
  * @param[in]  service_type    service type(SYNC_AGENT_CONTACT, SYNC_AGENT_CALENDAR, SYNC_AGENT_MEMO,  SYNC_AGENT_CALLLOG)
  * @param[in]  enabled                 enable or not( 1 =  enable, 0 = prevent)
- * @param[in]  src_uri                 source uri
+ * @param[in]  src_uri                 source uri (sync_agent_ds_src_uri_e)
  * @param[in]  tgt_uri                 target uri
  * @param[in]  id                              id
  * @param[in]  password                password
  * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
  */
-       sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, char *src_uri, char *tgt_uri, char *id, char *password);
+       sync_agent_ds_error_e sync_agent_ds_set_sync_service_info(ds_profile_h profile_h, sync_agent_ds_service_type_e service_type, int enabled, sync_agent_ds_src_uri_e src_uri, char *tgt_uri, char *id, char *password);
 
 /**
- * @brief get profile dir name, profile name from profile info
+ * @brief get profile id, profile id from profile info
  * @par Usage:
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *profile_dir_name = "Sync1";
+ * int profile_id = 0;
+ * GList **profile_list = NULL;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_all_profile(&profile_list);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ * for (iter = profile_list; iter != NULL; iter = g_list_next(iter)) {
+ *             profile_h = (ds_profile_h)iter->data;
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_profile_id(profile_h, &profile_id);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                       profile info
+ * @param[out] profile_id      profile_id
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_profile_id(ds_profile_h profile_h, int *profile_id);
+
+/**
+ * @brief get profile dir name, profile dir name from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * int profile_id = 1;
  * char *get_profile_dir_name = NULL;
- * char *profile_name = NULL;
  *
- * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_id, &profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
  *
  *     ...
  *
- * ds_err = sync_agent_ds_get_profile_name(profile_h, &get_profile_dir_name, &profile_name);
+ * ds_err = sync_agent_ds_get_profile_dir_name(profile_h, &get_profile_dir_name);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -310,11 +422,41 @@ extern "C" {
  * @endcode
  * @param[in]  profile_h                       profile info
  * @param[out] profile_dir_name        profile dir name
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ * @see sync_agent_ds_get_profile
+ */
+       sync_agent_ds_error_e sync_agent_ds_get_profile_dir_name(ds_profile_h profile_h, char **profile_dir_name);
+
+/**
+ * @brief get profile dir name, profile name from profile info
+ * @par Usage:
+ * @code
+ *
+ * ds_profile_h profile_h = NULL;
+ * int profile_id = 1;
+ * char *profile_name = NULL;
+ *
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_id, &profile_h);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * ds_err = sync_agent_ds_get_profile_name(profile_h, &profile_name);
+ * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     ...
+ * }
+ *
+ *     ...
+ *
+ * @endcode
+ * @param[in]  profile_h                       profile info
  * @param[out] profile_name            profile name
  * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
  * @see sync_agent_ds_get_profile
  */
-       sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_dir_name, char **profile_name);
+       sync_agent_ds_error_e sync_agent_ds_get_profile_name(ds_profile_h profile_h, char **profile_name);
 
 /**
  * @brief get profile server information from profile info
@@ -322,10 +464,10 @@ extern "C" {
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *profile_dir_name = "Sync1";
+ * int profile_id = 1;
  * sync_agent_ds_server_info server_info = {NULL};
  *
- * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_id, &profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -353,10 +495,10 @@ extern "C" {
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *profile_dir_name = "Sync1";
+ * int profile_id = 1;
  * sync_agent_ds_sync_info sync_info = {NULL};
  *
- * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_id, &profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -384,10 +526,10 @@ extern "C" {
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *profile_dir_name = "Sync1";
+ * int profile_id = 1;
  * GList service_list = NULL;
  *
- * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_id, &profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -415,11 +557,11 @@ extern "C" {
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *profile_dir_name = "Sync1";
+ * int profile_id = 1;
  * int last_sync_status = 0;
  * int last_sync_time = 0;
  *
- * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_id, &profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -448,10 +590,10 @@ extern "C" {
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *profile_dir_name = "Sync1";
+ * int profile_id = 1;
  * GList *statistics_list = NULL;
  *
- * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_dir_name, &profile_h);
+ * sync_agent_ds_error_e ds_err = sync_agent_ds_get_profile(profile_id, &profile_h);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -479,7 +621,6 @@ extern "C" {
  * @code
  *
  * ds_profile_h profile_h = NULL;
- * char *profile_dir_name = "Sync1";
  * char *profile_name = "profile name";
  *
  * char *addr = "http://xxx.xxx.xxx";
@@ -505,7 +646,7 @@ extern "C" {
  * }
  *
  *
- * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_dir_name, profile_name);
+ * ds_err = sync_agent_ds_set_profile_name(profile_h, profile_name);
  * if(ds_err != SYNC_AGENT_DS_SUCCESS) {
  *     ...
  * }
@@ -557,12 +698,12 @@ extern "C" {
  * }
  *
  * @endcode
- * @param[in]  profile_dir_name                profile dir name
+ * @param[in]  profile_id              profile id
  * @param[out] profile_h               profile info
  * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
  * @see sync_agent_ds_free_profile_info
  */
-       sync_agent_ds_error_e sync_agent_ds_get_profile(char *profile_dir_name, ds_profile_h * profile_h);
+       sync_agent_ds_error_e sync_agent_ds_get_profile(int profile_id, ds_profile_h * profile_h);
 
 /**
  * @brief get all profiles info
@@ -792,6 +933,33 @@ extern "C" {
        sync_agent_ds_error_e sync_agent_ds_deinit();
 
 /**
+ * @brief deinitialize OMA DS
+ * @par Usage:
+ * @code
+ *
+ * sync_agent_ds_error_e ds_err = SYNC_AGENT_DS_SUCCESS;
+ *
+ * ds_err = sync_agent_ds_set_noti_callback(SYNC_AGENT_DS_SYNC_SESSION, _session_process_noti_cb, NULL);
+ * if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     _DEBUG_ERROR("sync_agent_ds_set_noti_callback() failed!!");
+ *     return -1;
+ * }
+ *
+ * ds_err = sync_agent_ds_set_noti_callback(SYNC_AGENT_DS_SYNC_PROCESS, _process_update_noti_cb, NULL);
+ * if (ds_err != SYNC_AGENT_DS_SUCCESS) {
+ *     _DEBUG_ERROR("sync_agent_ds_set_noti_callback() failed!!");
+ *     return -1;
+ * }
+ *
+ * @endcode
+ * @param[in]  type            noti callback type (sync_agent_ds_sync_callback_e)
+ * @param[in]  callback        noti callback function
+ * @param[in]  data            data
+ * @return SYNC_AGENT_DS_SUCCESS on success, SYNC_AGENT_DS_FAIL on fail
+ */
+       sync_agent_ds_error_e sync_agent_ds_set_noti_callback(sync_agent_ds_sync_callback_e type, sync_agent_noti_cb callback, void *data);
+
+/**
  *     @}
  */