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.
24 #include <sync_agent.h>
26 #define EXPORT_API __attribute__ ((visibility("default")))
29 #ifndef OMADM_AGENT_LOG
31 #define LOG_TAG "PLUGIN_FUMO"
36 static sync_agent_get_devinfo_cb func_get_dev_info = 0;
38 //static int _get_index(const char *name);
39 //static char *_get_mo_value_str(const char *vconf_key, int n_index);
41 EXPORT_API char **sync_agent_plugin_get_server_id_list(int *server_id_list_cnt)
45 *server_id_list_cnt = 0;
46 char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
47 if (temp_id_list == NULL) {
57 for (i = 0; i < SERVER_NUM; i++) {
61 sever_name = ALTER_SYNCMLDM_ACCNAME_1;
64 sever_name = ALTER_SYNCMLDM_ACCNAME_2;
68 server_idx = _get_index(sever_name);
69 server_id = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_SERVID, server_idx);
70 if (server_id == NULL) {
73 server_id = strdup(ALTER_SYNCMLDM_SERVID_1);
76 server_id = strdup(ALTER_SYNCMLDM_SERVID_2);
80 _DEBUG_INFO("Temp_id_list[%d] = %s\n", i, server_id);
81 temp_id_list[i] = server_id;
82 (*server_id_list_cnt)++;
84 _DEBUG_INFO("server_id_list_cnt = %d\n", *server_id_list_cnt);
89 *server_id_list_cnt = 1;
90 char **temp_id_list = (char **)calloc(SERVER_NUM, sizeof(char *));
91 if (temp_id_list == NULL) {
95 char *server_id = NULL;
96 server_id = strdup("*");
97 *temp_id_list = server_id;
99 _DEBUG_INFO("fumo server_id = %s\n", server_id);
100 _DEBUG_INFO("fumo server_id_list_cnt = %d\n", *server_id_list_cnt);
106 EXPORT_API int sync_agent_plugin_get_mo_value(const char *mo_pull_path, const char *mo_name, char **mo_value)
110 retvm_if((mo_pull_path) == NULL, -1, "mo_pull_path is NULL!!");
111 retvm_if((mo_name) == NULL, -1, "mo_name is NULL!!");
113 _DEBUG_INFO("mo_name : %s", mo_name);
116 if (!strcmp(mo_name, "PkgName")) {
118 if (pFunc_Get_DevInfo == NULL) {
121 sync_agent_dev_return_e res = pFunc_Get_DevInfo(2, "FwV", mo_value);
123 } else if (!strcmp(mo_name, "PkgVersion")) {
125 } else if (!strcmp(mo_name, "State")) {
126 *mo_value = strdup("10");
129 _DEBUG_INFO("mo_value : %s", *mo_value);
134 EXPORT_API void sync_agent_plugin_set_function_get_devinfo(sync_agent_get_devinfo_cb func)
138 func_get_dev_info = func;
143 EXPORT_API int sync_agent_plugin_initialize()
148 result = 1; //_req_fumo_server_reg(0);
165 static int _get_index(const char *name)
169 retvm_if((name) == NULL, -1, "name is NULL!!");
172 if (vconf_get_int(CSC_VCONF_KEY_SYNCMLDM_NBFIELD, &n_acc_count)) {
173 _DEBUG_TRACE("vconf_get_int FAIL");
175 n_acc_count =ALTER_SYNCMLDM_NBFIELD;
178 _DEBUG_TRACE("nAccCount : %d", n_acc_count);
181 for (; i < n_acc_count; i++) {
182 char *compare_name = _get_mo_value_str(CSC_VCONF_KEY_SYNCMLDM_ACCNAME, i + 1);
183 if (compare_name == NULL) {
186 compare_name = ALTER_SYNCMLDM_ACCNAME_1;
189 compare_name = ALTER_SYNCMLDM_ACCNAME_2;
197 _DEBUG_TRACE("[%d] compare_name : %s [%d], name : %s [%d]", i, compare_name, strlen(compare_name), name, strlen(name));
198 if (!strcmp(name, compare_name)) {
199 _DEBUG_TRACE("nIndex : %d", i + 1);
208 static char *_get_mo_value_str(const char *vconf_key, int n_index)
212 retvm_if((vconf_key) == NULL, NULL, "vconf_key is NULL!!");
219 char input_vconf_path[200] = { 0, };
222 memset(rec_idx, 0x0, sizeof(rec_idx));
223 snprintf(rec_idx, sizeof(rec_idx), "%d", n_index);
224 snprintf(input_vconf_path, strlen(vconf_key) + strlen(rec_idx) + 1, vconf_key, n_index);
226 char *value = vconf_get_str(input_vconf_path);
228 _DEBUG_TRACE("vconf_get_str FAIL");