summaryrefslogtreecommitdiff
path: root/src/agent/service-engine/se_account.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/agent/service-engine/se_account.c')
-rwxr-xr-xsrc/agent/service-engine/se_account.c1865
1 files changed, 1865 insertions, 0 deletions
diff --git a/src/agent/service-engine/se_account.c b/src/agent/service-engine/se_account.c
new file mode 100755
index 0000000..803f9d3
--- /dev/null
+++ b/src/agent/service-engine/se_account.c
@@ -0,0 +1,1865 @@
+/*
+ * oma-ds-agent
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @SE_Account.c
+ * @version 0.1
+ * @brief This file is the source file of implementation of account in Service Engine
+ */
+
+#include <sync_agent.h>
+#include <plugin/plugin_slp_sysnoti_alarm.h>
+
+#include "common/csc_keys.h"
+#include "common/common_vconf.h"
+#include "common/common_define.h"
+#include "common/common_util.h"
+#include "framework/event/oma_ds_platform_event_handler.h"
+#include "service-engine/se_account.h"
+#include "service-engine/se_error.h"
+#include "service-engine/se_common.h"
+#include "service-engine/se_notification.h"
+
+#ifndef OMADS_AGENT_LOG
+#undef LOG_TAG
+#define LOG_TAG "OMA_DS_SE"
+#endif
+
+#define MAX_DATASTORE_COUNT 3
+
+typedef struct {
+ char *serverName;
+ int index;
+} datastore_cp_info;
+
+static char *predefinedDatastore[][MAX_DATASTORE_COUNT][2] = {
+ {{"contacts", "text/x-vcard"}, {"calendar", "text/x-vcalendar"}, {"notes", "text/plain"}},
+ {{"Contacts", "text/x-vcard"}, {"Calendar", "text/x-vcalendar"}, {"Notes", "text/plain"}}
+};
+
+static datastore_cp_info predefinedServer[] = {
+ {"O3SIS SyncML", 0},
+ {"Everdroid", 1}
+};
+
+static se_error_type_e _add_profile(char *addr, char *id, char *password, char *access_name, int *account_id);
+static se_error_type_e _set_profile_info(int account_id, char *profile_name, char *sync_mode, char *sync_type, char *interval);
+static se_error_type_e _set_profile_category(int account_id, sync_service_s * category);
+static se_error_type_e _set_periodic_sync_config(int account_id, char *sync_mode, char *interval);
+static se_error_type_e _get_empty_profile_dir_name(char **empty_profile_dir_name);
+
+static se_error_type_e _set_profile_info_into_config_list(int account_id, char *profile_dir_name, char *addr, char *profile_name, char *sync_mode, char *sync_type, char *interval, char *nonce, char *server_id, GList ** config_list);
+static se_error_type_e _set_profile_category_info(int account_id, sync_service_s * category, GList ** config_list);
+static se_error_type_e _set_profile_category_info_csc(int account_id, int content_type, int index, GList ** config_list);
+static se_error_type_e _set_profile_category_info_cp(int account_id, int content_type, resource_cp_s * category, GList ** config_list);
+static se_error_type_e __set_profile_category_info_into_cofnig_list(int account_id, int content_type, int enabled, char *src_uri, char *tgt_uri, char *id, char *password, GList ** config_list);
+static se_error_type_e ___append_config_value(int account_id, char *key, char *value, char *type, char *access_name, GList ** list);
+
+static se_error_type_e _add_profile(char *addr, char *id, char *password, char *access_name, int *account_id)
+{
+ _INNER_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ sync_agent_acc_error_e account_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+
+ int account;
+ char *folderID = NULL;
+
+ account_err = sync_agent_create_fw_account(&fw_account);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_fw_account is fail");
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ fw_account->email = strdup(id);
+ fw_account->password = strdup(password);
+ fw_account->enable = 1;
+ fw_account->access_name = strdup(access_name);
+
+ account_err = sync_agent_add_fw_account(fw_account, &account);
+ if (account_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_add_fw_account is fail");
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ _DEBUG_TRACE("account_id = %d", account);
+
+ if (account < 0) {
+ _DEBUG_ERROR("account_id = %d", account);
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ folderID = sync_agent_generate_folder_luid();
+ if (folderID == NULL) {
+ _DEBUG_ERROR("failed in sync_agent_generate_folder_luid");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ sync_agent_da_return_e ret = SYNC_AGENT_DA_ERRORS;
+ sync_agent_da_folder_s *folder = NULL;
+ ret = sync_agent_create_folder(&folder);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_folder() failed !!");
+ goto error;
+ }
+
+ folder->account_id = account;
+ folder->folder_id = strdup(folderID);
+ folder->data_store_id = TYPE_CONTACT;
+ folder->folder_type_id = 0; /* Default contacts folder */
+ folder->parent_folder_id = NULL;
+ folder->service_id = strdup("0");
+ folder->access_name = strdup("EventHandler");
+
+ char *new_folder_id = NULL;
+ ret = sync_agent_add_folder(folder, &new_folder_id);
+ sync_agent_free_folder(folder);
+ folder = NULL;
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("Agent Add_Folder Failed_In sync_agent_add_account()!");
+ _DEBUG_ERROR("[process_Event_Add_Account] Agent Add_Folder Failed_In sync_agent_add_account()!");
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ _DEBUG_TRACE("[process_Event_Add_Account] Successed Agent Add_Folder in sync_agent_add_account(), added Folder ID : %s", new_folder_id);
+
+ if (folderID != NULL) {
+ free(folderID);
+ folderID = NULL;
+ }
+
+ if (new_folder_id != NULL) {
+ free(new_folder_id);
+ new_folder_id = NULL;
+ }
+
+ folderID = sync_agent_generate_folder_luid();
+ if (folderID == NULL) {
+ _DEBUG_ERROR("failed in sync_agent_generate_folder_luid");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ ret = sync_agent_create_folder(&folder);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_folder() failed !!");
+ goto error;
+ }
+
+ folder->account_id = account;
+ folder->folder_id = strdup(folderID);
+ folder->data_store_id = TYPE_CALENDAR;
+ folder->folder_type_id = 0; /* Default contacts folder */
+ folder->parent_folder_id = NULL;
+ folder->service_id = strdup("1");
+ folder->access_name = strdup("EventHandler");
+
+ ret = sync_agent_add_folder(folder, &new_folder_id);
+ sync_agent_free_folder(folder);
+ folder = NULL;
+
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("Agent Add_Folder Failed_In sync_agent_add_account()!");
+ _DEBUG_ERROR("[process_Event_Add_Account] Agent Add_Folder Failed_In sync_agent_add_account()!");
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ _DEBUG_TRACE("[process_Event_Add_Account] Successed Agent Add_Folder in sync_agent_add_account(), added Folder ID : %s", new_folder_id);
+
+ if (folderID != NULL) {
+ free(folderID);
+ folderID = NULL;
+ }
+
+ if (new_folder_id != NULL) {
+ free(new_folder_id);
+ new_folder_id = NULL;
+ }
+
+ folderID = sync_agent_generate_folder_luid();
+ if (folderID == NULL) {
+ _DEBUG_ERROR("failed in sync_agent_generate_folder_luid");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ ret = sync_agent_create_folder(&folder);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_folder() failed !!");
+ goto error;
+ }
+
+ folder->account_id = account;
+ folder->folder_id = strdup(folderID);
+ folder->data_store_id = TYPE_MEMO;
+ folder->folder_type_id = 0; /* Default contacts folder */
+ folder->parent_folder_id = NULL;
+ folder->service_id = strdup("0");
+ folder->access_name = strdup("EventHandler");
+
+ ret = sync_agent_add_folder(folder, &new_folder_id);
+ sync_agent_free_folder(folder);
+ folder = NULL;
+
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("Agent Add_Folder Failed_In sync_agent_add_account()!");
+ _DEBUG_ERROR("[process_Event_Add_Account] Agent Add_Folder Failed_In sync_agent_add_account()!");
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ _DEBUG_TRACE("[process_Event_Add_Account] Successed Agent Add_Folder in sync_agent_add_account(), added Folder ID : %s", new_folder_id);
+
+ if (folderID != NULL) {
+ free(folderID);
+ folderID = NULL;
+ }
+
+ if (new_folder_id != NULL) {
+ free(new_folder_id);
+ new_folder_id = NULL;
+ }
+
+ /* call log folder ID */
+ folderID = sync_agent_generate_folder_luid();
+ if (folderID == NULL) {
+ _DEBUG_ERROR("failed in sync_agent_generate_folder_luid");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ ret = sync_agent_create_folder(&folder);
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_create_folder() failed !!");
+ goto error;
+ }
+
+ folder->account_id = account;
+ folder->folder_id = strdup(folderID);
+ folder->data_store_id = TYPE_CALLLOG;
+ folder->folder_type_id = 0; /* Default contacts folder */
+ folder->parent_folder_id = NULL;
+ folder->service_id = strdup("0");
+ folder->access_name = strdup("EventHandler");
+
+ ret = sync_agent_add_folder(folder, &new_folder_id);
+ sync_agent_free_folder(folder);
+ folder = NULL;
+
+ if (ret != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("Agent Add_Folder Failed_In sync_agent_add_account()!");
+ _DEBUG_ERROR("[process_Event_Add_Account] Agent Add_Folder Failed_In sync_agent_add_account()!");
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ _DEBUG_TRACE("[process_Event_Add_Account] Successed Agent Add_Folder in sync_agent_add_account(), added Folder ID : %s", new_folder_id);
+
+ if (folderID != NULL) {
+ free(folderID);
+ folderID = NULL;
+ }
+
+ if (new_folder_id != NULL) {
+ free(new_folder_id);
+ new_folder_id = NULL;
+ }
+
+ *account_id = account;
+
+ error:
+
+ if (folderID != NULL)
+ free(folderID);
+
+ sync_agent_free_fw_account(fw_account);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static se_error_type_e _set_profile_info(int account_id, char *profile_name, char *sync_mode, char *sync_type, char *interval)
+{
+ _INNER_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ bool result;
+
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_NAME, profile_name, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, sync_mode, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_CLIENT_SYNC_TYPE, sync_type, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_SYNC_TYPE, sync_type, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL, interval, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static se_error_type_e _set_profile_category(int account_id, sync_service_s * category)
+{
+ _INNER_FUNC_ENTER;
+
+ _DEBUG_TRACE("category->content_type : %d", category->service_type);
+ _DEBUG_TRACE("category->enabled : %d", category->enabled);
+ _DEBUG_TRACE("category->src_uri : %s", category->src_uri);
+ _DEBUG_TRACE("category->tgt_uri : %s", category->tgt_uri);
+ _DEBUG_TRACE("category->id : %s", category->id);
+ _DEBUG_TRACE("category->password : %s", category->password);
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ bool result;
+
+ char *datastore = NULL;
+ char datastore_target[128];
+ char datastore_source[128];
+ char datastore_id[128];
+ char datastore_pw[128];
+
+ if (category->service_type == TYPE_CONTACT)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
+ else if (category->service_type == TYPE_CALENDAR)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
+ else if (category->service_type == TYPE_MEMO)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
+ else if (category->service_type == TYPE_CALLLOG)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG;
+
+ snprintf(datastore_target, sizeof(datastore_target), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET);
+ snprintf(datastore_source, sizeof(datastore_source), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE);
+ snprintf(datastore_id, sizeof(datastore_id), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID);
+ snprintf(datastore_pw, sizeof(datastore_pw), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD);
+
+ result = set_config_int(account_id, datastore, category->enabled, "int", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, datastore_source, category->src_uri, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, datastore_target, category->tgt_uri, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, datastore_id, category->id, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, datastore_pw, category->password, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+static se_error_type_e _set_periodic_sync_config(int account_id, char *sync_mode, char *interval)
+{
+ _INNER_FUNC_ENTER;
+ _DEBUG_TRACE("sync_mode = %s", sync_mode);
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ sync_agent_pm_return_e scheduler_err;
+ bool result;
+ char *value = NULL;
+ int alarm_id = 0;
+
+ pmci_alarm_s *alarm_info = (pmci_alarm_s *) calloc(1, sizeof(pmci_alarm_s));
+ if (alarm_info == NULL) {
+ _DEBUG_ERROR("alarm_info is NULL");
+ err = SE_INTERNAL_NO_MEMORY;
+ goto error;
+ }
+
+ result = get_config(account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, &value);
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ alarm_id = atoi(value);
+
+ if (alarm_id != 0) {
+ scheduler_err = sync_agent_remove_service_data(1, alarm_id);
+ if (scheduler_err != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_remove_service_data");
+ err = SE_INTERNAL_SCHEDULER_ERROR;
+ goto error;
+ }
+ }
+
+ if (strcmp(sync_mode, DEFINE_SYNC_MODE_PERIODIC) == 0 && interval != NULL) {
+
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_CLIENT_SYNC_TYPE, DEFINE_ALERT_TWO_WAY_STR, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ int week[] = { DAY_SUN, DAY_MON, DAY_TUE, DAY_WED, DAY_THU, DAY_FRI, DAY_SAT };
+ time_t current_time;
+ struct tm *struct_time;
+ time(&current_time);
+ struct_time = localtime(&current_time);
+ if (struct_time == NULL) {
+ _DEBUG_ERROR("struct_time is NULL");
+ err = SE_INTERNAL_ERROR;;
+ goto error;
+ }
+
+ alarm_info->start_alarm_time = g_strdup_printf("%.2d-%.2d-%.2dT%.2d:%.2d:%.2dZ", struct_time->tm_year + 1900, struct_time->tm_mon + 1, struct_time->tm_mday, struct_time->tm_hour, struct_time->tm_min, struct_time->tm_sec);
+ alarm_info->is_disposable = 0;
+
+ if (strcmp(interval, "5 minutes") == 0) {
+ _DEBUG_TRACE("5 minutes");
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = 5 * 60;
+ } else if (strcmp(interval, "15 minutes") == 0) {
+ _DEBUG_TRACE("15 minutes");
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = 15 * 60;
+ } else if (strcmp(interval, "1 hour") == 0) {
+ _DEBUG_TRACE("1 hour");
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((1 * 60) * 60);
+ } else if (strcmp(interval, "4 hours") == 0) {
+ _DEBUG_TRACE("4 hours");
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((4 * 60) * 60);
+ } else if (strcmp(interval, "12 hours") == 0) {
+ _DEBUG_TRACE("12 hours");
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((12 * 60) * 60);
+ } else if (strcmp(interval, "1 day") == 0) {
+ _DEBUG_TRACE("1 day");
+ alarm_info->repeat_type = REPEAT;
+ alarm_info->repeat_value = ((24 * 60) * 60);
+ } else if (strcmp(interval, "1 week") == 0) {
+ _DEBUG_TRACE("1 week");
+ alarm_info->repeat_type = REPEAT_WEEKLY;
+ alarm_info->repeat_value = week[struct_time->tm_wday];
+ }
+
+ scheduler_err = sync_agent_add_service_data(1, alarm_info, &alarm_id);
+ if (scheduler_err != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_add_service_data");
+ err = SE_INTERNAL_SCHEDULER_ERROR;
+ goto error;
+ }
+ _DEBUG_TRACE("alarm_id =%d", alarm_id);
+
+ result = set_config_int(account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, alarm_id, "int", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ } else {
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, "0", "int", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+ }
+
+ error:
+
+ if (value != NULL)
+ free(value);
+
+ if (alarm_info != NULL) {
+ if (alarm_info->start_alarm_time != NULL)
+ free(alarm_info->start_alarm_time);
+
+ free(alarm_info);
+ }
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static se_error_type_e _set_profile_info_into_config_list(int account_id, char *profile_dir_name, char *addr, char *profile_name, char *sync_mode, char *sync_type, char *interval, char *nonce, char *server_id, GList ** config_list)
+{
+ _INNER_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ bool result;
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, profile_dir_name, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, addr, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_NAME, profile_name, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_SYNC_MODE, sync_mode != NULL ? sync_mode : "Push", "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_CLIENT_SYNC_TYPE, sync_type != NULL ? sync_type : "Full", "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_SYNC_TYPE, sync_type != NULL ? sync_type : "Full", "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_SYNC_INTERVAL, interval != NULL ? interval : "5 minutes", "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_NEXT_NONCE, nonce, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_ID, server_id, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_STATUS, "-1", "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_LAST_SESSION_TIME, "-1", "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, "0", "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_SYNCHRONISING, "0", "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, DEFINE_CONFIG_KEY_PROFILE_RESUME, "0", "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in _append_config_value");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static se_error_type_e _set_profile_category_info(int account_id, sync_service_s * category, GList ** config_list)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(category == NULL, SE_INTERNAL_NOT_DEFINED, "category is NULL");
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ err = __set_profile_category_info_into_cofnig_list(account_id, category->service_type, category->enabled, category->src_uri, category->tgt_uri, category->id, category->password, config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in _set_profile_category_info_into_cofnig_list");
+ goto error;
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static se_error_type_e _set_profile_category_info_csc(int account_id, int content_type, int index, GList ** config_list)
+{
+ _INNER_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ char *is_enabled_path = NULL;
+ char *target_uri_path = NULL;
+ char *id_path = NULL;
+ char *pwd_path = NULL;
+
+ char *datastore = NULL;
+
+ int is_enabled = 0;
+ char *target_uri = NULL;
+ char *id = NULL;
+ char *pwd = NULL;
+ char profile_path[128];
+
+ char *source_uri = NULL;
+
+ bool result;
+
+ if (content_type == TYPE_CONTACT) {
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
+ source_uri = DEFINE_SOURCE_CONTACT_URI;
+ is_enabled_path = CSC_VCONF_KEY_SYNCMLDS_CONTACTS_ENABLED;
+ target_uri_path = CSC_VCONF_KEY_SYNCMLDS_CONTACTS_TGTURI;
+ id_path = CSC_VCONF_KEY_SYNCMLDS_CONTACTS_AUTHNAME;
+ pwd_path = CSC_VCONF_KEY_SYNCMLDS_CONTACTS_AUTHPWD;
+ } else if (content_type == TYPE_CALENDAR) {
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
+ source_uri = DEFINE_SOURCE_CALENDAR_URI;
+ is_enabled_path = CSC_VCONF_KEY_SYNCMLDS_CALENDAR_ENABLED;
+ target_uri_path = CSC_VCONF_KEY_SYNCMLDS_CALENDAR_TGTURI;
+ id_path = CSC_VCONF_KEY_SYNCMLDS_CALENDAR_AUTHNAME;
+ pwd_path = CSC_VCONF_KEY_SYNCMLDS_CALENDAR_AUTHPWD;
+ } else if (content_type == TYPE_MEMO) {
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
+ source_uri = DEFINE_SOURCE_MEMO_URI;
+ is_enabled_path = CSC_VCONF_KEY_SYNCMLDS_MEMO_ENABLED;
+ target_uri_path = CSC_VCONF_KEY_SYNCMLDS_MEMO_TGTURI;
+ id_path = CSC_VCONF_KEY_SYNCMLDS_MEMO_AUTHNAME;
+ pwd_path = CSC_VCONF_KEY_SYNCMLDS_MEMO_AUTHPWD;
+ } else if (content_type == TYPE_CALLLOG) {
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG;
+ source_uri = DEFINE_SOURCE_CALLLOG_URI;
+ } else {
+ err = SE_INTERNAL_ERROR;
+ _DEBUG_ERROR("No content type");
+ goto error;
+ }
+
+ if (content_type != TYPE_CALLLOG) {
+ snprintf(profile_path, sizeof(profile_path), is_enabled_path, index);
+ result = get_vconf_int_key(profile_path, &is_enabled);
+ if (result == false) {
+ _DEBUG_ERROR("No value in vconf key = %s", profile_path);
+ goto error;
+ }
+
+ snprintf(profile_path, sizeof(profile_path), target_uri_path, index);
+ target_uri = get_vconf_str_key(profile_path);
+
+ snprintf(profile_path, sizeof(profile_path), id_path, index);
+ id = get_vconf_str_key(profile_path);
+
+ snprintf(profile_path, sizeof(profile_path), pwd_path, index);
+ pwd = get_vconf_str_key(profile_path);
+ }
+
+ err = __set_profile_category_info_into_cofnig_list(account_id, content_type, is_enabled, source_uri, target_uri, id, pwd, config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in _set_profile_category_info_into_cofnig_list");
+ goto error;
+ }
+
+ error:
+
+ if (target_uri != NULL)
+ free(target_uri);
+
+ if (id != NULL)
+ free(id);
+
+ if (pwd != NULL)
+ free(pwd);
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+static se_error_type_e _set_profile_category_info_cp(int account_id, int content_type, resource_cp_s * category, GList ** config_list)
+{
+ _INNER_FUNC_ENTER;
+
+ retvm_if(category == NULL, SE_INTERNAL_NOT_DEFINED, "category is NULL");
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ char *sourceuri = NULL;
+
+ if (content_type == TYPE_CONTACT)
+ sourceuri = DEFINE_SOURCE_CONTACT_URI;
+ else if (content_type == TYPE_CALENDAR)
+ sourceuri = DEFINE_SOURCE_CALENDAR_URI;
+ else if (content_type == TYPE_MEMO)
+ sourceuri = DEFINE_SOURCE_MEMO_URI;
+ else if (content_type == TYPE_CALLLOG)
+ sourceuri = DEFINE_SOURCE_CALLLOG_URI;
+ else {
+ err = SE_INTERNAL_ERROR;
+ _DEBUG_ERROR("No content type");
+ goto error;
+ }
+
+ err = __set_profile_category_info_into_cofnig_list(account_id, content_type, 0, sourceuri, category->name, category->id, category->password, config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in _set_profile_category_info_into_cofnig_list");
+ goto error;
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+
+}
+
+static se_error_type_e __set_profile_category_info_into_cofnig_list(int account_id, int content_type, int enabled, char *src_uri, char *tgt_uri, char *id, char *password, GList ** config_list)
+{
+ _INNER_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ bool result;
+ char *enable = NULL;
+
+ char *datastore = NULL;
+ char datastore_target[128];
+ char datastore_source[128];
+ char datastore_id[128];
+ char datastore_pw[128];
+
+ char datastore_dbSynced[128];
+ char datastore_lastSessionTime[128];
+ char datastore_s2c_Total[128];
+ char datastore_s2c_NrOfAdd[128];
+ char datastore_s2c_NrOfDelete[128];
+ char datastore_s2c_NrOfReplace[128];
+ char datastore_c2s_Total[128];
+ char datastore_c2s_NrOfAdd[128];
+ char datastore_c2s_NrOfDelete[128];
+ char datastore_c2s_NrOfReplace[128];
+
+ if (content_type == TYPE_CONTACT)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CONTACTS;
+ else if (content_type == TYPE_CALENDAR)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALENDAR;
+ else if (content_type == TYPE_MEMO)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_MEMO;
+ else if (content_type == TYPE_CALLLOG)
+ datastore = DEFINE_CONFIG_KEY_PROFILE_CATEGORY_CALLLOG;
+
+ snprintf(datastore_target, sizeof(datastore_target), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_TARGET);
+ snprintf(datastore_source, sizeof(datastore_source), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_SOURCE);
+ snprintf(datastore_id, sizeof(datastore_id), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_ID);
+ snprintf(datastore_pw, sizeof(datastore_pw), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_CATEGORY_PASSWORD);
+
+ snprintf(datastore_dbSynced, sizeof(datastore_dbSynced), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_DBSYNCED);
+ snprintf(datastore_lastSessionTime, sizeof(datastore_lastSessionTime), "%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_LAST_TIME);
+
+ snprintf(datastore_s2c_Total, sizeof(datastore_s2c_Total), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_TOTAL);
+ snprintf(datastore_s2c_NrOfAdd, sizeof(datastore_s2c_NrOfAdd), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFADD);
+ snprintf(datastore_s2c_NrOfDelete, sizeof(datastore_s2c_NrOfDelete), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFDELETE);
+ snprintf(datastore_s2c_NrOfReplace, sizeof(datastore_s2c_NrOfReplace), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_SERVER, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFREPLACE);
+
+ snprintf(datastore_c2s_Total, sizeof(datastore_c2s_Total), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_TOTAL);
+ snprintf(datastore_c2s_NrOfAdd, sizeof(datastore_c2s_NrOfAdd), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFADD);
+ snprintf(datastore_c2s_NrOfDelete, sizeof(datastore_c2s_NrOfDelete), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFDELETE);
+ snprintf(datastore_c2s_NrOfReplace, sizeof(datastore_c2s_NrOfReplace), "%s_%s_%s", datastore, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_CLIENT, DEFINE_CONFIG_KEY_PROFILE_STATISTICS_NROFREPLACE);
+
+ enable = g_strdup_printf("%u", enabled);
+ result = ___append_config_value(account_id, datastore, enable, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_source, src_uri, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_target, tgt_uri, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_id, id, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_pw, password, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_dbSynced, DEFINE_DBSYNC_NO, "string", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_lastSessionTime, "-1", "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_s2c_Total, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_s2c_NrOfAdd, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_s2c_NrOfDelete, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_s2c_NrOfReplace, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_c2s_Total, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_c2s_NrOfAdd, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_c2s_NrOfDelete, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = ___append_config_value(account_id, datastore_c2s_NrOfReplace, 0, "int", "SE", config_list);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ error:
+
+ if (enable != NULL)
+ free(enable);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static se_error_type_e ___append_config_value(int account_id, char *key, char *value, char *type, char *access_name, GList ** list)
+{
+ _INNER_FUNC_ENTER;
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ bool result;
+
+ sync_agent_da_config_s *config = NULL;
+
+ result = create_config_str(account_id, key, value, type, access_name, &config);
+ if (result == false) {
+ _DEBUG_ERROR("failed in create_config_str");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ if (config != NULL) {
+ *list = g_list_append(*list, config);
+ config = NULL;
+ }
+
+ error:
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+static se_error_type_e _get_empty_profile_dir_name(char **empty_profile_dir_name)
+{
+ _INNER_FUNC_ENTER;
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ bool result;
+ char *profileDirName = NULL;
+ int profile[MAXIMUM_ACCOUNT_COUNT] = { 0 };
+ char profileIndex[2];
+ int index;
+ int i;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_NONE;
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_query_fw_account is failed");
+ goto error;
+ }
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ fw_account = (sync_agent_fw_account_s *) iter->data;
+
+ if (profileDirName != NULL) {
+ free(profileDirName);
+ profileDirName = NULL;
+ }
+
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, &profileDirName);
+ if (result == false) {
+ _DEBUG_ERROR("failed in get_Config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ _DEBUG_TRACE("profile_Dir_name = %s", profileDirName);
+ if (profileDirName == NULL)
+ continue;
+
+ strcpy(profileIndex, profileDirName + strlen(profileDirName) - 1);
+ _DEBUG_TRACE("profileIndex = %s", profileIndex);
+
+ index = atoi(profileIndex);
+ profile[index - 1] = 1;
+ }
+
+ for (i = 0; i < MAXIMUM_ACCOUNT_COUNT; i++) {
+ if (profile[i] != 1) {
+ *empty_profile_dir_name = g_strdup_printf("Sync%d", i + 1);
+ break;
+ }
+ }
+
+ error:
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ if (profileDirName != NULL)
+ free(profileDirName);
+
+ _INNER_FUNC_EXIT;
+ return err;
+}
+
+bool add_profile(char *profile_dir_name, char *profile_name, char *addr, char *id, char *password, char *sync_mode, char *sync_type, char *interval, GList * categories, int *account_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("profile_name = %s", profile_name);
+ _DEBUG_INFO("addr = %s", addr);
+ _DEBUG_INFO("id = %s", id);
+ _DEBUG_INFO("password = %s", password);
+ _DEBUG_INFO("sync_mode = %s", sync_mode);
+ _DEBUG_INFO("sync_type = %s", sync_type);
+ _DEBUG_INFO("interval = %s", interval);
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ int account = -1;
+ GList *config_list = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ err = _add_profile(addr, id, password, "SE", &account);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ err = _set_profile_info_into_config_list(account, profile_dir_name, addr, profile_name, sync_mode, sync_type, interval, NULL, NULL, &config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ sync_service_s *category = NULL;
+ GList *iter = NULL;
+ for (iter = categories; iter != NULL; iter = g_list_next(iter)) {
+ category = iter->data;
+ err = _set_profile_category_info(account, category, &config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in __set_profile_category");
+ goto error;
+ }
+ }
+
+ da_err = sync_agent_add_config_list(config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ err = _set_periodic_sync_config(account, sync_mode, interval);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in _set_periodic_sync_config");
+ goto error;
+ }
+
+ *account_id = account;
+
+ error:
+
+ sync_agent_free_config_list(config_list);
+
+ sync_agent_close_agent();
+
+ _DEBUG_INFO("err = %d", err);
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool add_profile_csc(int index)
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ char profile_path[128];
+ char *profile_dir_name = NULL;
+ char *profile_name = NULL;
+ char *id = NULL;
+ char *password = NULL;
+ char *server_ip = NULL;
+ char *sync_mode = NULL;
+ char *sync_type = NULL;
+ int account_id;
+
+ GList *config_list = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ err = _get_empty_profile_dir_name(&profile_dir_name);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in __get_empty_profileDirName");
+ goto error;
+ }
+
+ if (profile_dir_name == NULL) {
+ _DEBUG_ERROR("Maximum profiles count is %d, no more profile", MAXIMUM_ACCOUNT_COUNT);
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ snprintf(profile_path, sizeof(profile_path), CSC_VCONF_KEY_SYNCMLDS_AUTHNAME, index);
+ id = get_vconf_str_key(profile_path);
+
+ snprintf(profile_path, sizeof(profile_path), CSC_VCONF_KEY_SYNCMLDS_AUTHPWD, index);
+ password = get_vconf_str_key(profile_path);
+
+ snprintf(profile_path, sizeof(profile_path), CSC_VCONF_KEY_SYNCMLDS_ADDR, index);
+ server_ip = get_vconf_str_key(profile_path);
+
+ snprintf(profile_path, sizeof(profile_path), CSC_VCONF_KEY_SYNCMLDS_NAME, index);
+ profile_name = get_vconf_str_key(profile_path);
+
+ snprintf(profile_path, sizeof(profile_path), CSC_VCONF_KEY_SYNCMLDS_SYNCMODE, index);
+ sync_mode = get_vconf_str_key(profile_path);
+
+ snprintf(profile_path, sizeof(profile_path), CSC_VCONF_KEY_SYNCMLDS_SYNCTYPE, index);
+ sync_type = get_vconf_str_key(profile_path);
+
+ _DEBUG_INFO("email = %s", id);
+ _DEBUG_INFO("password = %s", password);
+ _DEBUG_INFO("serverIP = %s", server_ip);
+ _DEBUG_INFO("profileName = %s", profile_name);
+ _DEBUG_INFO("syncMode = %s", sync_mode);
+ _DEBUG_INFO("syncType = %s", sync_type);
+
+ err = _add_profile(server_ip, id, password, "SE", &account_id);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ err = _set_profile_info_into_config_list(account_id, profile_dir_name, server_ip, profile_name, sync_mode, sync_type, NULL, NULL, NULL, &config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ int content_type;
+ for (content_type = 0; content_type < TYPE_SERVICE_COUNT; content_type++) {
+ err = _set_profile_category_info_csc(account_id, content_type, index, &config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in set_DatastoreConfig");
+ goto error;
+ }
+ }
+
+ da_err = sync_agent_add_config_list(config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ error:
+
+ if (profile_dir_name != NULL)
+ free(profile_dir_name);
+ if (profile_name != NULL)
+ free(profile_name);
+ if (id != NULL)
+ free(id);
+ if (password != NULL)
+ free(password);
+ if (server_ip != NULL)
+ free(server_ip);
+ if (sync_mode != NULL)
+ free(sync_mode);
+ if (sync_type != NULL)
+ free(sync_type);
+
+ sync_agent_free_config_list(config_list);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool add_profile_cp(char *profile_name, char *addr, char *id, char *password, GList * categories, int *account_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ _DEBUG_INFO("profilename = %s", profile_name);
+ _DEBUG_INFO("addr = %s", addr);
+ _DEBUG_INFO("id = %s", id);
+ _DEBUG_INFO("password = %s", password);
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ int account = -1;
+
+ char *profile_dir_name = NULL;
+ GList *config_list = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ err = _get_empty_profile_dir_name(&profile_dir_name);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in __get_empty_profileDirName");
+ goto error;
+ }
+
+ if (profile_dir_name == NULL) {
+ _DEBUG_ERROR("Maximum profiles count is %d, no more profile", MAXIMUM_ACCOUNT_COUNT);
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ err = _add_profile(addr, id, password, "SE", &account);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ err = _set_profile_info_into_config_list(account, profile_dir_name, addr, profile_name, NULL, NULL, NULL, NULL, NULL, &config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ int i;
+ int cnt = (int)sizeof(predefinedServer) / sizeof(datastore_cp_info);
+ _DEBUG_INFO("cnt = %d", cnt);
+ for (i = 0; i < cnt; i++) {
+
+ _DEBUG_INFO("predefinedServer[%d].serverName = %s", i, predefinedServer[i].serverName);
+ if (strcmp(predefinedServer[i].serverName, profile_name) == 0) {
+
+ int j;
+ for (j = 0; j < MAX_DATASTORE_COUNT; j++) {
+ resource_cp_s *category = NULL;
+ GList *iter = NULL;
+ _DEBUG_INFO("categories length = %d", g_list_length(categories));
+ for (iter = categories; iter != NULL; iter = g_list_next(iter)) {
+ category = (resource_cp_s *) iter->data;
+ _DEBUG_INFO("category->name = %s", category->name);
+ _DEBUG_INFO("category->accept = %s", category->accept);
+
+ _DEBUG_INFO("predefinedDatastore[i][j][0] = %s", predefinedDatastore[i][j][0]);
+ _DEBUG_INFO("predefinedDatastore[i][j][1] = %s", predefinedDatastore[i][j][1]);
+
+ if (predefinedDatastore[i][j][0] != NULL && category->name != NULL && predefinedDatastore[i][j][1] != NULL && category->accept != NULL) {
+
+ if (strcasecmp(predefinedDatastore[i][j][0], category->name) == 0 && strcmp(predefinedDatastore[i][j][1], category->accept) == 0) {
+
+ err = _set_profile_category_info_cp(account, j, category, &config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in __set_profile_category");
+ goto error;
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ da_err = sync_agent_add_config_list(config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ *account_id = account;
+
+ error:
+
+ if (profile_dir_name != NULL)
+ free(profile_dir_name);
+
+ sync_agent_free_config_list(config_list);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool add_profile_dive(int *account_id)
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ sync_agent_dev_return_e dci_err = SYNC_AGENT_DEV_RETURN_SUCCESS;
+ char *id = NULL;
+ char *password = NULL;
+ char *encoded_nextnonce = NULL;
+ int account = -1;
+
+ GList *config_list = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ /* FIXME get id from somewhere */
+ id = "ss.linux.test@gmail.com";
+
+ /*get IMEI from Platform */
+ dci_err = sync_agent_get_devinfo(DEFINE_PLATFORM, "DevID", &password);
+ if (dci_err != SYNC_AGENT_DEV_RETURN_SUCCESS) {
+ _DEBUG_ERROR("failed to get devinfo");
+ goto error;
+ }
+
+ err = _add_profile(DEFINE_DIVE_SERVER_URL_HTTPS, id, password, "DIVE", &account);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ encoded_nextnonce = g_base64_encode((unsigned char *)DEFINE_DIVE_DEFAULT_NEXT_NONCE, strlen(DEFINE_DIVE_DEFAULT_NEXT_NONCE));
+
+ err = _set_profile_info_into_config_list(account, NULL, DEFINE_DIVE_SERVER_URL_HTTPS, NULL, NULL, DEFINE_ALERT_ONE_WAY_FROM_CLIENT_STR, NULL, encoded_nextnonce, DEFINE_DIVE_SERVER_ID, &config_list);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in add_Account");
+ goto error;
+ }
+
+ /*set calllog config value */
+ __set_profile_category_info_into_cofnig_list(account, TYPE_CALLLOG, 1, DEFINE_SOURCE_CALLLOG_URI, "./CallLog", NULL, NULL, &config_list);
+
+ da_err = sync_agent_add_config_list(config_list);
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ *account_id = account;
+
+ error:
+
+ if (password != NULL)
+ free(password);
+
+ sync_agent_free_config_list(config_list);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool edit_profile(int account_id, char *profile_name, char *addr, char *id, char *password, char *sync_mode, char *sync_type, char *interval, GList * categories)
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ bool result;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ acc_err = sync_agent_create_fw_account(&fw_account);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ err = SE_INTERNAL_ERROR;
+ goto error;
+ }
+
+ fw_account->account_id = account_id;
+ fw_account->email = strdup(id);
+ fw_account->password = strdup(password);
+ fw_account->enable = 1;
+ fw_account->access_name = strdup("SE");
+
+ acc_err = sync_agent_update_fw_account(fw_account);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = set_config_str(account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_IP, addr, "string", "SE");
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ err = _set_profile_info(account_id, profile_name, sync_mode, sync_type, interval);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in __set_profile_info");
+ goto error;
+ }
+
+ err = _set_periodic_sync_config(account_id, sync_mode, interval);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in __set_profile_info");
+ goto error;
+ }
+
+ sync_service_s *category = NULL;
+ GList *iter = NULL;
+ for (iter = categories; iter != NULL; iter = g_list_next(iter)) {
+ category = iter->data;
+ err = _set_profile_category(account_id, category);
+ if (err != SE_INTERNAL_OK) {
+ _DEBUG_ERROR("failed in __set_profile_category");
+ goto error;
+ }
+ }
+
+ error:
+
+ sync_agent_free_fw_account(fw_account);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool delete_profiles(GList * profiles)
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+ int *accountId = 0;
+ char *value = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ GList *iter = NULL;
+ int alarmId = 0;
+
+ bool result;
+ for (iter = profiles; iter != NULL; iter = g_list_next(iter)) {
+ accountId = (int *)(iter->data);
+
+ if (accountId != NULL) {
+ _DEBUG_INFO("accountId = %d", *accountId);
+ /*if deleteing Account's sync mode is periodic sync it has to be deleted from schedule_tbl */
+ result = get_config(*accountId, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, &value);
+ if (result == false) {
+ _DEBUG_ERROR("failed in get_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+ alarmId = atoi(value);
+ if (alarmId != 0) {
+ sync_agent_pm_return_e scheduler_err = sync_agent_remove_service_data(1, alarmId);
+ if (scheduler_err != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_remove_service_data");
+ err = SE_INTERNAL_SCHEDULER_ERROR;
+ goto error;
+ }
+ }
+ sync_agent_delete_fw_account(*accountId);
+ if (accountId != 0) {
+ free(accountId);
+ accountId = 0;
+ }
+ } else {
+ _DEBUG_ERROR("accountId is NULL !");
+ }
+ }
+
+ error:
+
+ if (value != NULL)
+ free(value);
+
+ if (accountId != NULL)
+ free(accountId);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool delete_profile_dive()
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+ sync_agent_fw_account_s *account_info = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_open_agent");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_ACCESS_NAME;
+ query.access_name = "DIVE";
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ account_info = (sync_agent_fw_account_s *) iter->data;
+ _DEBUG_INFO("accountId = %d", account_info->account_id);
+ sync_agent_delete_fw_account(account_info->account_id);
+ }
+
+ error:
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool delete_profile(char *access_name)
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+ sync_agent_fw_account_s *account_info = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_open_agent");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_ACCESS_NAME;
+ query.access_name = access_name;
+
+ /*delete account */
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ account_info = (sync_agent_fw_account_s *) iter->data;
+ _DEBUG_INFO("accountId = %d", account_info->account_id);
+ sync_agent_delete_fw_account(account_info->account_id);
+ }
+
+ error:
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool delete_all_profiles()
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+
+ int alarm_id = 0;
+ bool result;
+ char *value = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_NONE;
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_query_fw_account is failed");
+ goto error;
+ }
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ fw_account = (sync_agent_fw_account_s *) iter->data;
+
+ _DEBUG_INFO("accountId = %d", fw_account->account_id);
+ /*if deleteing Account's sync mode is periodic sync it has to be deleted from schedule_tbl */
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_ALARM_ID, &value);
+ if (result == false) {
+ _DEBUG_ERROR("failed in get_config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ if (value != NULL) {
+ alarm_id = atoi(value);
+ if (alarm_id != 0) {
+ sync_agent_pm_return_e scheduler_err = sync_agent_remove_service_data(1, alarm_id);
+ if (scheduler_err != SYNC_AGENT_PM_SUCCESS) {
+ _DEBUG_ERROR("failed in sync_agent_remove_service_data");
+ err = SE_INTERNAL_SCHEDULER_ERROR;
+ goto error;
+ }
+ }
+
+ free(value);
+ value = NULL;
+
+ sync_agent_delete_fw_account(fw_account->account_id);
+ } else {
+ _DEBUG_ERROR("value is NULL !");
+ }
+ }
+
+ error:
+
+ if (value != NULL)
+ free(value);
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool get_synchronising_profile(char **profile_Dir_name, char **sync_type)
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ bool result;
+ char *value = NULL;
+
+ sync_agent_acc_error_e acc_err = SYNC_AGENT_ACC_SUCCESS;
+ sync_agent_fw_account_s *fw_account = NULL;
+ GList *account_info_list = NULL;
+ GList *iter = NULL;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ sync_agent_fw_account_query_s query;
+ query.query = ACCOUNT_QUERY_BY_NONE;
+
+ acc_err = sync_agent_query_fw_account(&query, &account_info_list);
+ if (acc_err != SYNC_AGENT_ACC_SUCCESS) {
+ _DEBUG_ERROR("sync_agent_query_fw_account is failed");
+ goto error;
+ }
+
+ for (iter = account_info_list; iter != NULL; iter = g_list_next(iter)) {
+ fw_account = (sync_agent_fw_account_s *) iter->data;
+
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_SYNCHRONISING, &value);
+ if (result == false) {
+ _DEBUG_ERROR("failed in set_Config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ if (strcmp(value, "1") == 0) {
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_DIR_NAME, profile_Dir_name);
+ if (result == false) {
+ _DEBUG_ERROR("failed in get_Config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ result = get_config(fw_account->account_id, DEFINE_CONFIG_KEY_PROFILE_SERVER_SYNC_TYPE, sync_type);
+ if (result == false) {
+ _DEBUG_ERROR("failed in get_Config");
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+ break;
+ }
+
+ free(value);
+ value = NULL;
+ }
+
+ error:
+
+ if (value != NULL)
+ free(value);
+
+ sync_agent_free_fw_account_list(account_info_list);
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}
+
+bool delete_all_agent_default_table()
+{
+ _EXTERN_FUNC_ENTER;
+
+ se_error_type_e err = SE_INTERNAL_OK;
+
+ sync_agent_da_return_e da_err = sync_agent_open_agent();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ da_err = sync_agent_empty_all_agent_default_table();
+ if (da_err != SYNC_AGENT_DA_SUCCESS) {
+ err = SE_INTERNAL_DA_ERROR;
+ goto error;
+ }
+
+ error:
+
+ sync_agent_close_agent();
+
+ _EXTERN_FUNC_EXIT;
+
+ if (err != SE_INTERNAL_OK)
+ return false;
+ else
+ return true;
+}