3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Apache License, Version 2.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
23 #include <glib/gprintf.h>
27 #include <sync_agent.h>
30 #define EXPORT_API __attribute__ ((visibility("default")))
33 #ifndef OMADM_AGENT_LOG
35 #define LOG_TAG "PLUGIN_MULTIAPPS"
40 #define CSC_VCONF_KEY_SYNCMLDM_NBFIELD "db/SyncML/oma-dm-service/DevManagement/NbDevManagement"
41 #define CSC_VCONF_KEY_SYNCMLDM_ACCNAME "db/SyncML/oma-dm-service/DevManagement/%d/AccName"
42 #define CSC_VCONF_KEY_SYNCMLDM_SERVID "db/SyncML/oma-dm-service/DevManagement/%d/ServID"
44 #define ALTER_SYNCMLDM_NBFIELD 3
46 #define ALTER_SYNCMLDM_ACCNAME "gcf"
47 #define ALTER_SYNCMLDM_SERVID "RSate"
50 #define ROOT "./Application"
52 static sync_agent_get_devinfo_cb func_get_dev_info = 0;
54 //static int _get_Index(const char *name);
55 //static char *_get_MO_Value_STR(const char *vconf_key, int nIndex);
57 EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
61 char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
62 if (temp_id_list == NULL) {
67 int server_idx = _get_Index(ALTER_SYNCMLDM_ACCNAME);
68 char *server_id = _get_MO_Value_STR(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
69 if (server_id == NULL) {
70 server_id = strdup(ALTER_SYNCMLDM_SERVID);
72 *temp_id_list = server_id;
73 *server_id_list_cnt = 1;
75 _DEBUG_INFO("server_id = %s\n", server_id);
76 _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
81 *server_id_list_cnt = 1;
82 char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
83 if (temp_id_list == NULL) {
87 char *server_id = NULL;
88 server_id = strdup("*");
89 *temp_id_list = server_id;
91 _DEBUG_INFO("multiapps server_id = %s\n", server_id);
92 _DEBUG_INFO("multiapps server_id_list_cnt = %d\n", *server_id_list_cnt);
98 EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
102 retvm_if((mo_pull_path) == NULL, -1, "mo_pull_path is NULL!!");
103 retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
105 _DEBUG_INFO("mo_name : %s", mo_name);
108 _DEBUG_INFO("mo_value : %s", *mo_value);
113 EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
117 func_get_dev_info = func;
122 EXPORT_API int sync_agent_plugin_initialize()
133 static int _get_Index(const char *name)
137 retvm_if((name) == NULL, -1, "name is NULL!!");
140 if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &acc_count)) {
141 _DEBUG_TRACE("vconf_get_int FAIL");
143 acc_count =ALTER_SYNCMLDM_NBFIELD;
146 _DEBUG_TRACE("nAccCount : %d", acc_count);
149 for (; i < acc_count; i++) {
150 char *compare_name = _get_MO_Value_STR(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
151 if (compare_name == NULL) {
152 compare_name = ALTER_SYNCMLDM_ACCNAME;
154 _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
155 if (!strcmp(name, compare_name)) {
156 _DEBUG_TRACE("nIndex : %d", i + 1);
166 static char *_get_MO_Value_STR(const char *vconf_key, int nIndex)
170 retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
177 char input_vconf_path[200] = { 0, };
180 memset(rec_idx, 0x0, sizeof(rec_idx));
181 snprintf(rec_idx, sizeof(rec_idx), "%d", nIndex);
182 snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, nIndex);
184 char *value = vconf_get_str(input_vconf_path);
186 _DEBUG_TRACE("vconf_get_str FAIL");