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.
22 #include <glib-object.h>
25 #include <vconf-keys.h>
28 #include <sync_agent.h>
30 #include "plugin_slp_device_info.h"
33 #define EXPORT_API __attribute__ ((visibility("default")))
36 #ifndef OMADM_AGENT_LOG
38 #define LOG_TAG "PLUGIN_DEVICE_SLP_DM"
42 #define FW_VERSION_LEN 20
43 #define BUFF_SIZE 1000
45 /* todo : temporary definition */
46 #define HW_VERSION "1.0"
53 dici_name_key_map dev_key_map[] = {
54 {"SwV", VCONFKEY_TELEPHONY_SWVERSION},
55 {"HwV", VCONFKEY_TELEPHONY_HWVERSION},
56 /*{"Lang", "db/menu_widget/language"}, */
57 {"Lang", VCONFKEY_LANGSET},
61 static GList *devInfo;
62 static sync_agent_get_devinfo_cb func_get_dev_info_common = 0;
64 static char *_get_dev_info_common(char *key);
66 EXPORT_API int sync_agent_plugin_load_devinfo()
77 sync_agent_plugin_device_info_s *swv = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
82 memset(swv, 0x00, sizeof(sync_agent_plugin_device_info_s));
83 swv->info_name = strdup("SwV");
84 swv->value = _get_dev_info_common(swv->info_name);
85 devInfo = g_list_append(devInfo, swv);
88 sync_agent_plugin_device_info_s *hwv = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
93 memset(hwv, 0x00, sizeof(sync_agent_plugin_device_info_s));
94 hwv->info_name = strdup("HwV");
95 hwv->value = _get_dev_info_common(hwv->info_name);
96 devInfo = g_list_append(devInfo, hwv);
99 sync_agent_plugin_device_info_s *lang = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
104 memset(lang, 0x00, sizeof(sync_agent_plugin_device_info_s));
105 lang->info_name = strdup("Lang");
106 lang->value = _get_dev_info_common(lang->info_name);
107 devInfo = g_list_append(devInfo, lang);
110 sync_agent_plugin_device_info_s *devId = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
115 memset(devId, 0x00, sizeof(sync_agent_plugin_device_info_s));
116 devId->info_name = strdup("DevID");
117 devId->value = _get_dev_info_common(devId->info_name);
118 devInfo = g_list_append(devInfo, devId);
119 _DEBUG_INFO("mdi ============= \n");
121 /* get Manufacture */
122 sync_agent_plugin_device_info_s *man = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
127 memset(man, 0x00, sizeof(sync_agent_plugin_device_info_s));
128 man->info_name = strdup("Man");
129 man->value = _get_dev_info_common(man->info_name);
130 devInfo = g_list_append(devInfo, man);
133 sync_agent_plugin_device_info_s *mod = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
138 memset(mod, 0x00, sizeof(sync_agent_plugin_device_info_s));
139 mod->info_name = strdup("Mod");
140 mod->value = _get_dev_info_common(mod->info_name);
141 devInfo = g_list_append(devInfo, mod);
144 sync_agent_plugin_device_info_s *fw = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
149 memset(fw, 0x00, sizeof(sync_agent_plugin_device_info_s));
150 fw->info_name = strdup("FwV");
151 fw->value = _get_dev_info_common(fw->info_name);
152 devInfo = g_list_append(devInfo, fw);
155 sync_agent_plugin_device_info_s *oem = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
160 memset(oem, 0x00, sizeof(sync_agent_plugin_device_info_s));
161 oem->info_name = strdup("OEM");
162 oem->value = _get_dev_info_common(oem->info_name);
163 devInfo = g_list_append(devInfo, oem);
166 sync_agent_plugin_device_info_s *dev_type = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
167 if (dev_type == NULL) {
171 memset(dev_type, 0x00, sizeof(sync_agent_plugin_device_info_s));
172 dev_type->info_name = strdup("DevTyp");
173 dev_type->value = _get_dev_info_common(dev_type->info_name);
174 devInfo = g_list_append(devInfo, dev_type);
176 /* get Modem version */
177 sync_agent_plugin_device_info_s *modem_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
178 if (modem_version == NULL) {
182 memset(modem_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
183 modem_version->info_name = strdup("ModemV");
184 modem_version->value = _get_dev_info_common(modem_version->info_name);
185 devInfo = g_list_append(devInfo, modem_version);
187 /* get PDA version */
188 sync_agent_plugin_device_info_s *pda_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
189 if (pda_version == NULL) {
193 memset(pda_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
194 pda_version->info_name = strdup("PDAV");
195 pda_version->value = _get_dev_info_common(pda_version->info_name);
196 devInfo = g_list_append(devInfo, pda_version);
198 /* get CSC version */
199 sync_agent_plugin_device_info_s *csc_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
200 if (csc_version == NULL) {
204 memset(csc_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
205 csc_version->info_name = strdup("CSCV");
206 csc_version->value = _get_dev_info_common(csc_version->info_name);
207 devInfo = g_list_append(devInfo, csc_version);
209 /* get kernel version */
210 sync_agent_plugin_device_info_s *kernel_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
211 if (kernel_version == NULL) {
215 memset(kernel_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
216 kernel_version->info_name = strdup("KernelV");
217 kernel_version->value = slp_device_info_get_kernel_version();
218 devInfo = g_list_append(devInfo, kernel_version);
220 /* get FOTA_download dir */
221 sync_agent_plugin_device_info_s *fota_download_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
222 if (fota_download_dir == NULL) {
226 memset(fota_download_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
227 fota_download_dir->info_name = strdup("FOTADownDir");
228 fota_download_dir->value = slp_device_info_get_fota_download_dir();
229 devInfo = g_list_append(devInfo, fota_download_dir);
231 /* get FOTA save dir */
232 sync_agent_plugin_device_info_s *fota_save_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
233 if (fota_save_dir == NULL) {
237 memset(fota_save_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
238 fota_save_dir->info_name = strdup("FOTASaveDir");
239 fota_save_dir->value = slp_device_info_get_fota_save_dir();
240 devInfo = g_list_append(devInfo, fota_save_dir);
242 /* get SD_FOTA_download dir */
243 sync_agent_plugin_device_info_s *fota_sd_download_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
244 if (fota_sd_download_dir == NULL) {
248 memset(fota_sd_download_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
249 fota_sd_download_dir->info_name = strdup("FOTA_SD_DownDir");
250 fota_sd_download_dir->value = slp_device_info_get_fota_sd_download_dir();
251 devInfo = g_list_append(devInfo, fota_sd_download_dir);
253 /* get SD_FOTA save dir */
254 sync_agent_plugin_device_info_s *fota_sd_save_dir = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
255 if (fota_sd_save_dir == NULL) {
259 memset(fota_sd_save_dir, 0x00, sizeof(sync_agent_plugin_device_info_s));
260 fota_sd_save_dir->info_name = strdup("FOTA_SD_SaveDir");
261 fota_sd_save_dir->value = slp_device_info_get_fota_sd_save_dir();
262 devInfo = g_list_append(devInfo, fota_sd_save_dir);
264 /* get DTD version */
265 sync_agent_plugin_device_info_s *dtd_version = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
266 if (dtd_version == NULL) {
270 memset(dtd_version, 0x00, sizeof(sync_agent_plugin_device_info_s));
271 dtd_version->info_name = strdup("DTDV");
272 dtd_version->value = slp_device_info_get_dtd_version();
273 devInfo = g_list_append(devInfo, dtd_version);
276 sync_agent_plugin_device_info_s *opco_info = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
277 if (opco_info == NULL) {
281 memset(opco_info, 0x00, sizeof(sync_agent_plugin_device_info_s));
282 opco_info->info_name = strdup("OPCO");
283 opco_info->value = slp_device_info_get_opco_info();
284 devInfo = g_list_append(devInfo, opco_info);
286 /* get PHONE_NUM info */
287 sync_agent_plugin_device_info_s *phone_num = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
288 if (phone_num == NULL) {
292 memset(phone_num, 0x00, sizeof(sync_agent_plugin_device_info_s));
293 phone_num->info_name = strdup("PHONE_NUM");
294 phone_num->value = slp_device_info_get_msisdn_number();
295 devInfo = g_list_append(devInfo, phone_num);
298 sync_agent_plugin_device_info_s *imsi_value = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
299 if (imsi_value == NULL) {
303 memset(imsi_value, 0x00, sizeof(sync_agent_plugin_device_info_s));
304 imsi_value->info_name = strdup("IMSI");
305 imsi_value->value = slp_device_info_get_imsi_info();
306 devInfo = g_list_append(devInfo, imsi_value);
309 sync_agent_plugin_device_info_s *csc_value = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
310 if (csc_value == NULL) {
314 memset(csc_value, 0x00, sizeof(sync_agent_plugin_device_info_s));
315 csc_value->info_name = strdup("CSC");
316 csc_value->value = slp_device_info_get_csc();
317 devInfo = g_list_append(devInfo, csc_value);
320 sync_agent_plugin_device_info_s *mcc_value = (sync_agent_plugin_device_info_s *) malloc(sizeof(sync_agent_plugin_device_info_s));
321 if (mcc_value == NULL) {
325 memset(mcc_value, 0x00, sizeof(sync_agent_plugin_device_info_s));
326 mcc_value->info_name = strdup("MCC");
327 mcc_value->value = slp_device_info_get_mcc();
328 devInfo = g_list_append(devInfo, mcc_value);
333 for (iter = devInfo; iter != NULL; iter = g_list_next(iter)) {
334 _DEBUG_INFO("[devInfo_slp_plugIn] cnt : %d, info_name : %s, value : %s\n", cnt, ((sync_agent_plugin_device_info_s *) (iter->data))->info_name, ((sync_agent_plugin_device_info_s *) (iter->data))->value);
342 EXPORT_API int sync_agent_plugin_get_devinfo(char *info_name, char **value)
346 retvm_if((info_name) == NULL, 0, "info_name is NULL!!");
351 sync_agent_plugin_device_info_s *iter_data;
353 for (iter = devInfo; iter != NULL; iter = g_list_next(iter)) {
355 iter_data = (sync_agent_plugin_device_info_s *) (iter->data);
356 if (iter_data->info_name != NULL) {
357 if (!strcmp(iter_data->info_name, info_name)) {
358 if (iter_data->value != NULL) {
360 *value = strdup(iter_data->value);
365 _DEBUG_INFO("[devInfo_slp_plugIn] %s value is NULL !!\n", info_name);
374 if (strcmp("Battery", info_name) == 0) {
375 *value = _get_dev_info_common(info_name);
381 _DEBUG_INFO("[devInfo_slp_plugIn] not exist %s information !!\n", info_name);
391 EXPORT_API int sync_agent_plugin_clear_devinfo()
398 sync_agent_plugin_device_info_s *iter_data;
400 if (devInfo != NULL) {
401 for (iter = devInfo; iter != NULL;) {
403 iter_data = ((sync_agent_plugin_device_info_s *) (iter->data));
404 iter = g_list_next(iter);
405 devInfo = g_list_remove(devInfo, iter_data);
407 if (iter_data != NULL) {
408 if (((sync_agent_plugin_device_info_s *) (iter_data))->info_name != NULL)
409 free(((sync_agent_plugin_device_info_s *) (iter_data))->info_name);
410 if (((sync_agent_plugin_device_info_s *) (iter_data))->value != NULL)
411 free(((sync_agent_plugin_device_info_s *) (iter_data))->value);
412 free((sync_agent_plugin_device_info_s *) (iter_data));
416 g_list_free(devInfo);
423 EXPORT_API void sync_agent_plugin_set_common_devinfo_function(sync_agent_get_devinfo_cb func)
427 func_get_dev_info_common = func;
432 static char *_get_dev_info_common(char *key)
437 _DEBUG_TRACE("KEY name is NULL !!!");
443 sync_agent_dev_return_e ret = SYNC_AGENT_DEV_RETURN_SUCCESS;
445 ret = func_get_dev_info_common(1, key, &value);
446 if (ret == SYNC_AGENT_DEV_RETURN_SUCCESS) {
447 _DEBUG_TRACE(" key = %s, value = %s", key, value);
451 _DEBUG_TRACE(" key = %s has NULL value !!!", key, value);