9 #include <pkgmgr-info.h>
11 #include "amd_config.h"
12 #include "simple_util.h"
13 #include "amd_appinfo.h"
16 #define SERVICE_GROUP "Service"
19 GHashTable *tbl; /* key is filename, value is struct appinfo */
23 _AI_FILE = 0, /* service filename */
39 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
43 #ifdef _APPFW_FEATURE_PROCESS_POOL
47 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
49 _AI_MULTI_INSTANCE_MAINID,
52 #ifdef _APPFW_FEATURE_MULTI_WINDOW
55 #ifdef _APPFW_FEATURE_TTS_MODE
58 #ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
63 #define _AI_START _AI_NAME /* start index */
67 enum appinfo_type type;
70 static struct appinfo_t _appinfos[] = {
71 [_AI_NAME] = { "Name", AIT_NAME, },
72 [_AI_COMP] = { "Component", AIT_COMP, },
73 [_AI_EXEC] = { "Exec", AIT_EXEC, },
74 [_AI_TYPE] = { "PkgType", AIT_TYPE, },
75 [_AI_ONBOOT] = { "StartOnBoot", AIT_ONBOOT, },
76 [_AI_RESTART] = { "AutoRestart", AIT_RESTART, },
77 [_AI_MULTI] = { "Multiple", AIT_MULTI, },
78 [_AI_HWACC] = { "Hwacceleration", AIT_HWACC, },
79 [_AI_PERM] = { "PermissionType", AIT_PERM, },
80 [_AI_PKGID] = { "PackageId", AIT_PKGID, },
81 [_AI_TASKMANAGE] = { "Taskmanage", AIT_TASKMANAGE, },
82 [_AI_PRELOAD] = { "Preload", AIT_PRELOAD, },
83 [_AI_INDICATORDISP] = { "indicatordisplay", AIT_INDICATOR_DISP, },
84 [_AI_EFFECTIMAGEPORT] = { "portaitimg", AIT_EFFECTIMAGEPORT, },
85 [_AI_EFFECTIMAGELAND] = { "landscapeimg", AIT_EFFECTIMAGELAND, },
86 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
87 [_AI_EFFECTTYPE] = { "EffectType", AIT_EFFECTTYPE, },
89 [_AI_STATUS] = { "status", AIT_STATUS, },
90 #ifdef _APPFW_FEATURE_PROCESS_POOL
91 [_AI_POOL] = { "ProcessPool", AIT_POOL, },
93 [_AI_COMPTYPE] = { "ComponentType", AIT_COMPTYPE, },
94 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
95 [_AI_MULTI_INSTANCE] = { "multi-instance", AIT_MULTI_INSTANCE, },
96 [_AI_MULTI_INSTANCE_MAINID] = { "multi-instance-mainid", AIT_MULTI_INSTANCE_MAINID, },
97 [_AI_TOGGLE_ORDER] = { "toggleOrder", AIT_TOGGLE_ORDER, },
99 #ifdef _APPFW_FEATURE_MULTI_WINDOW
100 [_AI_MULTI_WINDOW] = { "multi-window", AIT_MULTI_WINDOW, },
102 #ifdef _APPFW_FEATURE_TTS_MODE
103 [_AI_TTS] = { "TTS", AIT_TTS, },
105 #ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
106 [_AI_UPS] = { "UPS", AIT_UPS, },
123 static void _free_appinfo(gpointer data)
125 struct appinfo *c = data;
131 for (i = 0; i < sizeof(c->val)/sizeof(c->val[0]); i++) {
132 if(c->val[i] != NULL)
139 static void _fini(struct appinfomgr *cf)
143 g_hash_table_destroy(cf->tbl);
144 g_hash_table_destroy(pkg_tbl);
148 static int __app_info_insert_handler (const pkgmgrinfo_appinfo_h handle, void *data)
151 struct appinfomgr *cf = (struct appinfomgr *)data;
156 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
157 char *effectimg_type;
162 char *component_type;
165 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
168 #ifdef _APPFW_FEATURE_MULTI_WINDOW
173 pkgmgrinfo_app_hwacceleration hwacc;
174 pkgmgrinfo_app_component component;
175 pkgmgrinfo_permission_type permission;
176 bool indicator_display;
180 #ifdef _APPFW_FEATURE_PROCESS_POOL
181 bool process_pool = 0;
183 int support_mode = 0;
185 _D("__app_info_insert_handler");
188 _E("null app handle");
192 ret = pkgmgrinfo_appinfo_get_appid(handle, &appid);
194 _E("fail to get appinfo");
198 g_hash_table_remove(cf->tbl, appid);
200 c = calloc(1, sizeof(*c));
202 _E("create appinfo: %s", strerror(errno));
206 memset(c, 0, sizeof(struct appinfo));
208 c->val[_AI_FILE] = strdup(appid);
209 if (!c->val[_AI_FILE]) {
210 _E("create appinfo: %s", strerror(errno));
215 c->val[_AI_NAME] = strdup(appid); //TODO :
217 ret = pkgmgrinfo_appinfo_get_component(handle, &component);
219 _E("fail to get component");
223 if(component == PMINFO_UI_APP) {
224 c->val[_AI_COMP] = strdup("ui"); //TODO :
226 r = pkgmgrinfo_appinfo_is_multiple(handle, &multiple);
228 c->val[_AI_MULTI] = strdup("true");
229 else c->val[_AI_MULTI] = strdup("false");
231 r = pkgmgrinfo_appinfo_is_taskmanage(handle, &taskmanage);
232 if (taskmanage == false) {
233 c->val[_AI_TASKMANAGE] = strdup("false");
235 c->val[_AI_TASKMANAGE] = strdup("true");
238 r = pkgmgrinfo_appinfo_is_preload(handle, &preload);
239 if (preload == false) {
240 c->val[_AI_PRELOAD] = strdup("false");
242 c->val[_AI_PRELOAD] = strdup("true");
246 c->val[_AI_HWACC] = strdup("NOT_USE");
249 r = pkgmgrinfo_appinfo_get_hwacceleration(handle, &hwacc);
250 if (hwacc == PMINFO_HWACCELERATION_ON) {
251 c->val[_AI_HWACC] = strdup("USE");
252 } else if (hwacc == PMINFO_HWACCELERATION_DEFAULT) {
253 c->val[_AI_HWACC] = strdup("SYS");
255 c->val[_AI_HWACC] = strdup("NOT_USE");
259 r = pkgmgrinfo_appinfo_is_indicator_display_allowed(handle, &indicator_display);
261 _E("ERROR IN FETCHING INDICATOR DISP INFO\n");
262 c->val[_AI_INDICATORDISP] = strdup("true");
264 if (indicator_display == true){
265 c->val[_AI_INDICATORDISP] = strdup("true");
267 c->val[_AI_INDICATORDISP] = strdup("false");
271 r = pkgmgrinfo_appinfo_get_effectimage(handle, &portraitimg, &landscapeimg);
273 _E("ERROR IN FETCHING EFFECT IMAGES\n");
274 c->val[_AI_EFFECTIMAGEPORT] = NULL;
275 c->val[_AI_EFFECTIMAGELAND] = NULL;
278 c->val[_AI_EFFECTIMAGEPORT] = strdup(portraitimg);
280 c->val[_AI_EFFECTIMAGEPORT] = NULL;
282 c->val[_AI_EFFECTIMAGELAND] = strdup(landscapeimg);
284 c->val[_AI_EFFECTIMAGELAND] = NULL;
286 #ifdef _APPFW_FEATURE_CHANGEABLE_COLOR
287 r = pkgmgrinfo_appinfo_get_effectimage_type(handle, &effectimg_type);
288 c->val[_AI_EFFECTTYPE] = strdup(effectimg_type);
291 #ifdef _APPFW_FEATURE_PROCESS_POOL
292 r = pkgmgrinfo_appinfo_is_process_pool(handle, &process_pool);
293 if (process_pool == false) {
294 c->val[_AI_POOL] = strdup("false");
296 c->val[_AI_POOL] = strdup("true");
299 r = pkgmgrinfo_appinfo_get_component_type(handle, &component_type);
300 c->val[_AI_COMPTYPE] = strdup(component_type);
302 r = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
304 c->val[_AI_ONBOOT] = strdup("true");
305 else c->val[_AI_ONBOOT] = strdup("false");
307 r = pkgmgrinfo_appinfo_is_autorestart(handle, &restart);
309 c->val[_AI_RESTART] = strdup("true");
310 else c->val[_AI_RESTART] = strdup("false");
312 #ifdef _APPFW_FEATURE_MULTI_INSTANCE
313 r = pkgmgrinfo_appinfo_is_multi_instance(handle, &multi_instance);
314 if(multi_instance == true)
315 c->val[_AI_MULTI_INSTANCE] = strdup("true");
317 c->val[_AI_MULTI_INSTANCE] = strdup("false");
319 r = pkgmgrinfo_appinfo_get_multi_instance_mainid(handle, &multi_mainid);
320 c->val[_AI_MULTI_INSTANCE_MAINID] = strdup(multi_mainid);
323 c->val[_AI_TOGGLE_ORDER] = strdup("0");
325 #ifdef _APPFW_FEATURE_MULTI_WINDOW
326 r = pkgmgrinfo_appinfo_is_multi_window(handle, &multi_window);
327 if((r == PMINFO_R_OK) && (multi_window == true))
328 c->val[_AI_MULTI_WINDOW] = strdup("true");
330 c->val[_AI_MULTI_WINDOW] = strdup("false");
333 c->val[_AI_COMP] = strdup("svc");
335 r = pkgmgrinfo_appinfo_is_onboot(handle, &onboot);
337 c->val[_AI_ONBOOT] = strdup("true");
338 else c->val[_AI_ONBOOT] = strdup("false");
340 r = pkgmgrinfo_appinfo_is_autorestart(handle, &restart);
342 c->val[_AI_RESTART] = strdup("true");
343 else c->val[_AI_RESTART] = strdup("false");
346 r = pkgmgrinfo_appinfo_get_exec(handle, &exec);
347 c->val[_AI_EXEC] = strdup(exec);
349 r = pkgmgrinfo_appinfo_get_apptype(handle, &type);
350 if(strncmp(type, "capp", 4) == 0 ) {
351 c->val[_AI_TYPE] = strdup("rpm");
352 } else if (strncmp(type, "c++app", 6) == 0 || strncmp(type, "ospapp", 6) == 0) {
353 c->val[_AI_TYPE] = strdup("tpk");
354 } else if (strncmp(type, "webapp", 6) == 0) {
355 c->val[_AI_TYPE] = strdup("wgt");
358 r = pkgmgrinfo_appinfo_get_permission_type(handle, &permission);
359 if (permission == PMINFO_PERMISSION_SIGNATURE) {
360 c->val[_AI_PERM] = strdup("signature");
361 } else if (permission == PMINFO_PERMISSION_PRIVILEGE) {
362 c->val[_AI_PERM] = strdup("privilege");
364 c->val[_AI_PERM] = strdup("normal");
367 pkgmgrinfo_appinfo_get_support_mode(handle, &support_mode);
368 #ifdef _APPFW_FEATURE_TTS_MODE
369 if(support_mode & PMINFO_MODE_PROP_SCREEN_READER) {
370 c->val[_AI_TTS] = strdup("true");
372 c->val[_AI_TTS] = strdup("false");
375 #ifdef _APPFW_FEATURE_ULTRA_POWER_SAVING_MODE
376 if(support_mode & PMINFO_MODE_PROP_ULTRA_POWER_SAVING) {
377 c->val[_AI_UPS] = strdup("true");
379 c->val[_AI_UPS] = strdup("false");
383 r = pkgmgrinfo_appinfo_get_pkgid(handle, &pkgid);
384 c->val[_AI_PKGID] = strdup(pkgid);
386 c->val[_AI_STATUS] = strdup("installed");
388 SECURE_LOGD("appinfo file:%s, comp:%s, type:%s", c->val[_AI_FILE], c->val[_AI_COMP], c->val[_AI_TYPE]);
390 g_hash_table_insert(cf->tbl, c->val[_AI_FILE], c);
395 static int __app_info_delete_handler (const pkgmgrinfo_appinfo_h handle, void *data)
397 struct appinfomgr *cf = (struct appinfomgr *)data;
400 pkgmgrinfo_appinfo_get_appid(handle, &appid);
402 g_hash_table_remove(cf->tbl, appid);
407 static int _read_pkg_info(struct appinfomgr *cf)
409 int ret = pkgmgrinfo_appinfo_get_install_list(__app_info_insert_handler, cf);
411 assert(ret == PMINFO_R_OK);
416 static struct appinfomgr *_init()
418 struct appinfomgr *cf;
420 cf = calloc(1, sizeof(*cf));
422 _E("appinfo init: %s", strerror(errno));
426 cf->tbl = g_hash_table_new_full(g_str_hash, g_str_equal,
427 NULL, _free_appinfo);
429 pkg_tbl = g_hash_table_new(g_str_hash, g_str_equal);
430 _E("pkg_tbl : %x", pkg_tbl);
434 static gboolean __amd_pkgmgrinfo_start_handler (gpointer key, gpointer value, gpointer user_data)
436 struct appinfo *c = value;
437 char *pkgid = (char *)user_data;
439 if (c != NULL && strcmp(c->val[_AI_PKGID], pkgid) == 0) {
440 free(c->val[_AI_STATUS]);
441 c->val[_AI_STATUS] = strdup("blocking");
442 SECURE_LOGD("pkgmgr working for this application(%s)", c->val[_AI_NAME]);
447 static gboolean __amd_pkgmgrinfo_fail_handler (gpointer key, gpointer value, gpointer user_data)
449 struct appinfo *c = value;
450 char *pkgid = (char *)user_data;
452 if (c != NULL && strcmp(c->val[_AI_PKGID], pkgid) == 0) {
453 free(c->val[_AI_STATUS]);
454 c->val[_AI_STATUS] = strdup("installed");
455 SECURE_LOGD("pkgmgr fail(%s)", c->val[_AI_NAME]);
460 static int __amd_pkgmgrinfo_install_end_handler(pkgmgrinfo_appinfo_h handle, void *user_data)
463 struct appinfomgr *cf = (struct appinfomgr *)user_data;
465 const char *componet;
468 pkgmgrinfo_appinfo_get_appid(handle, &appid);
470 __app_info_insert_handler(handle, user_data);
471 c = g_hash_table_lookup(cf->tbl, appid);
473 componet = appinfo_get_value(c, AIT_COMPTYPE);
474 r = appinfo_get_boolean(c, AIT_ONBOOT);
476 if (r == 1 && componet && strncmp(componet, "svcapp", 6) == 0)
478 _D("start service - %s", appid);
485 static int __amd_pkgmgrinfo_update_end_handler(pkgmgrinfo_appinfo_h handle, void *user_data)
488 struct appinfomgr *cf = (struct appinfomgr *)user_data;
490 const char *componet;
493 pkgmgrinfo_appinfo_get_appid(handle, &appid);
494 c = g_hash_table_lookup(cf->tbl, appid);
496 if (c != NULL && strncmp(c->val[_AI_STATUS], "restart", 7) == 0) {
497 __app_info_insert_handler(handle, user_data);
498 __release_srv(appid);
500 __app_info_insert_handler(handle, user_data);
501 c = g_hash_table_lookup(cf->tbl, appid);
503 componet = appinfo_get_value(c, AIT_COMPTYPE);
504 r = appinfo_get_boolean(c, AIT_ONBOOT);
506 if (r == 1 && componet && strncmp(componet, "svcapp", 6) == 0)
508 _D("start service - %s", appid);
516 static gboolean __amd_pkgmgrinfo_uninstall_end_handler (gpointer key, gpointer value, gpointer user_data)
518 struct appinfo *c = value;
519 char *pkgid = (char *)user_data;
521 if (strcmp(c->val[_AI_PKGID], pkgid) == 0) {
522 SECURE_LOGD("appid(%s), pkgid(%s)", c->val[_AI_NAME], pkgid);
528 static int __amd_pkgmgrinfo_status_cb(int req_id, const char *pkg_type,
529 const char *pkgid, const char *key, const char *val,
530 const void *pmsg, void *user_data)
533 pkgmgrinfo_pkginfo_h handle;
535 struct pkginfo *p = NULL;
536 struct appinfomgr *cf = (struct appinfomgr *)user_data;
538 SECURE_LOGD("pkgid(%s), key(%s), value(%s)", pkgid, key, val);
540 if(strncmp(key,"start", 5) == 0) {
541 g_hash_table_remove(pkg_tbl, pkgid);
542 p = calloc(1, sizeof(*p));
548 p->pkgid = strdup(pkgid);
550 g_hash_table_insert(pkg_tbl, p->pkgid, p);
551 if (strncmp(val, "install", 7) == 0) {
554 else if ((strncmp(val, "update", 6) == 0) || (strncmp(val, "uninstall", 9) == 0)) {
555 g_hash_table_foreach(cf->tbl, __amd_pkgmgrinfo_start_handler, (gpointer)pkgid);
556 _D("__amd_pkgmgrinfo_start_handler");
560 else if (strncmp(key,"end", 3) == 0) {
561 p = g_hash_table_lookup(pkg_tbl, pkgid);
564 SECURE_LOGD("op(%s), value(%s)", op, val);
565 if (strncmp(val, "ok", 2) == 0) {
566 if (op && strncmp(op, "install", 7)== 0) {
567 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
568 if (ret != PMINFO_R_OK)
570 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __amd_pkgmgrinfo_install_end_handler, user_data);
571 if (ret != PMINFO_R_OK) {
572 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
575 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
577 else if (op && strncmp(op, "update", 6) == 0){
578 ret = pkgmgrinfo_pkginfo_get_pkginfo(pkgid, &handle);
579 if (ret != PMINFO_R_OK)
581 ret = pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __amd_pkgmgrinfo_update_end_handler, user_data);
582 if (ret != PMINFO_R_OK) {
583 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
586 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
588 else if (op && strncmp(op, "uninstall", 9) == 0) {
589 ret = g_hash_table_foreach_remove(cf->tbl, __amd_pkgmgrinfo_uninstall_end_handler, (gpointer)pkgid);
590 _D("g_hash_table_foreach_remove, %d", ret);
594 else if (strncmp(val, "fail", 4) == 0) {
595 if ((op && strncmp(op, "update", 6) == 0) || (op && strncmp(op, "uninstall", 9) == 0) ) {
596 g_hash_table_foreach(cf->tbl, __amd_pkgmgrinfo_fail_handler, (gpointer)pkgid);
597 _D("__amd_pkgmgrinfo_fail_handler");
601 g_hash_table_remove(pkg_tbl, p->pkgid);
610 static int __unmounted_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
613 struct appinfomgr *cf = (struct appinfomgr *)user_data;
616 pkgmgrinfo_appinfo_get_appid(handle, &appid);
617 c = g_hash_table_lookup(cf->tbl, appid);
621 SECURE_LOGD("%s : %s", c->val[_AI_FILE], c->val[_AI_STATUS]);
622 free(c->val[_AI_STATUS]);
623 c->val[_AI_STATUS] = strdup("unmounted");
624 SECURE_LOGD("unmounted(%s)", appid);
629 static int __mounted_list_cb(const pkgmgrinfo_appinfo_h handle, void *user_data)
632 struct appinfomgr *cf = (struct appinfomgr *)user_data;
635 pkgmgrinfo_appinfo_get_appid(handle, &appid);
636 c = g_hash_table_lookup(cf->tbl, appid);
640 SECURE_LOGD("%s : %s", c->val[_AI_FILE], c->val[_AI_STATUS]);
641 if(strncmp(c->val[_AI_STATUS], "unmounted", 9) ==0 ) {
642 free(c->val[_AI_STATUS]);
643 c->val[_AI_STATUS] = strdup("installed");
645 SECURE_LOGD("mounted(%s)", appid);
650 static void __amd_mmc_vconf_cb(keynode_t *key, void *data)
653 struct appinfomgr *cf = (struct appinfomgr *)data;
656 status = vconf_keynode_get_int(key);
661 if(status == VCONFKEY_SYSMAN_MMC_REMOVED || status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) {
662 ret = pkgmgrinfo_appinfo_get_unmounted_list(__unmounted_list_cb, data);
663 if (ret != PMINFO_R_OK){
664 _E("pkgmgrinfo_appinfo_get_unmounted_list failed: %d", ret);
666 } else if(status == VCONFKEY_SYSMAN_MMC_MOUNTED){
667 ret = pkgmgrinfo_appinfo_get_mounted_list(__mounted_list_cb, data);
668 if (ret != PMINFO_R_OK){
669 _E("pkgmgrinfo_appinfo_get_mounted_list failed: %d", ret);
674 int appinfo_init(struct appinfomgr **cf)
676 struct appinfomgr *_cf;
679 char buf[4096] = {0,};
684 _E("appinfo init: %s", strerror(errno));
688 fp = fopen("/proc/cmdline", "r");
690 _E("appinfo init failed: %s", strerror(errno));
693 r = fgets(buf, sizeof(buf), fp);
694 tmp = strstr(buf, "gles");
696 sscanf(tmp,"gles=%d", &gles);
706 r = _read_pkg_info(_cf);
707 if (r != PMINFO_R_OK) {
712 r = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, __amd_mmc_vconf_cb, _cf);
714 _E("Unable to register vconf notification callback for VCONFKEY_SYSMAN_MMC_STATUS\n");
716 int event_type = PMINFO_CLIENT_STATUS_UPGRADE | PMINFO_CLIENT_STATUS_UNINSTALL | PMINFO_CLIENT_STATUS_INSTALL;
717 pkgmgrinfo_client *pc = NULL;
718 pc = pkgmgrinfo_client_new(PMINFO_LISTENING);
719 pkgmgrinfo_client_set_status_type(pc, event_type);
720 pkgmgrinfo_client_listen_status(pc, __amd_pkgmgrinfo_status_cb , _cf);
727 void appinfo_fini(struct appinfomgr **cf)
736 const struct appinfo *appinfo_insert(struct appinfomgr *cf, const char *pkg_name)
738 pkgmgrinfo_pkginfo_h handle;
739 if (pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle) == PMINFO_R_OK){
740 pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_insert_handler, cf);
741 pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_insert_handler, cf);
742 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
747 void appinfo_delete(struct appinfomgr *cf, const char *pkg_name)
749 pkgmgrinfo_pkginfo_h handle;
750 if (pkgmgrinfo_pkginfo_get_pkginfo(pkg_name, &handle) != PMINFO_R_OK)
752 pkgmgrinfo_appinfo_get_list(handle, PMINFO_SVC_APP, __app_info_delete_handler, cf);
753 pkgmgrinfo_appinfo_get_list(handle, PMINFO_UI_APP, __app_info_delete_handler, cf);
754 pkgmgrinfo_pkginfo_destroy_pkginfo(handle);
757 const struct appinfo *appinfo_find(struct appinfomgr *cf, const char *filename)
759 if (!cf || !filename || !*filename) {
764 return g_hash_table_lookup(cf->tbl, FILENAME(filename));
767 const char *appinfo_get_value(const struct appinfo *c, enum appinfo_type type)
773 _E("appinfo get value: %s, %d", strerror(errno), type);
777 for (i = _AI_START; i < sizeof(_appinfos)/sizeof(_appinfos[0]); i++) {
778 if (type == _appinfos[i].type)
783 _E("appinfo get value: %s", strerror(errno));
788 const char *appinfo_set_value(struct appinfo *c, enum appinfo_type type, const char* val)
791 for (i = _AI_START; i < sizeof(_appinfos)/sizeof(_appinfos[0]); i++) {
792 if (type == _appinfos[i].type) {
793 SECURE_LOGD("%s : %s : %s", c->val[_AI_FILE], c->val[i], val);
795 c->val[i] = strdup(val);
802 const char *appinfo_get_filename(const struct appinfo *c)
806 SECURE_LOGE("appinfo get filename: %s", strerror(errno));
810 return c->val[_AI_FILE];
814 appinfo_iter_callback cb;
818 static void _iter_cb(gpointer key, gpointer value, gpointer user_data)
820 struct _cbinfo *cbi = user_data;
824 cbi->cb(cbi->cb_data, key, value);
827 void appinfo_foreach(struct appinfomgr *cf, appinfo_iter_callback cb, void *user_data)
833 _E("appinfo foreach: %s", strerror(errno));
838 cbi.cb_data = user_data;
840 g_hash_table_foreach(cf->tbl, _iter_cb, &cbi);
843 int appinfo_get_boolean(const struct appinfo *c, enum appinfo_type type)
847 v = appinfo_get_value(c, type);
851 if (!strcmp(v, "1") || !strcasecmp(v, "true"))
854 if (!strcmp(v, "0") || !strcasecmp(v, "false"))