+bool is_3rdapp_installed_setting_cfg(char* pkgname)
+{
+ SETTING_TRACE_BEGIN;
+ // /usr/apps/
+ char path[512];
+
+ if (snprintf(path, 512, "/usr/apps/%s/setting/setting.xml", pkgname) < 0)
+ return false;
+
+ struct stat st;
+ bool result_opt = false;
+
+ if(stat(path, &st) == 0) {
+ result_opt = true;
+ } else {
+ SETTING_TRACE_ERROR(" %s is *NOT* present\n", path);
+ result_opt = false;
+ }
+
+ return result_opt;
+}
+
+
+/**
+ * @param data
+ */
+static void draw_3rdapp(void* data, char* name, char* pkgname)
+{
+ SETTING_TRACE_BEGIN;
+ SETTING_TRACE(" name : %s", name);
+ SETTING_TRACE(" pkgname : %s", pkgname);
+
+ setting_main_appdata *ad = data;
+
+ //3rd cfg
+ char fullpath[512];
+
+ if (snprintf(fullpath, 512, "/usr/apps/%s/setting/setting.xml", pkgname) < 0)
+ return false;
+
+ SETTING_TRACE(" fullpath : %s", fullpath);
+
+ if (ad)
+ {
+ if (ad->plugin_path)
+ {
+ free(ad->plugin_path);
+ ad->plugin_path = NULL;
+ }
+ ad->plugin_path = strdup(fullpath);
+
+ setting_create_Gendial_field_groupitem(ad->main_genlist,
+ &(ad->itc[GENDIAL_Type_1text_1icon_2]),
+ NULL,
+ setting_main_click_list_plugin_cb,
+ ad,
+ SWALLOW_Type_INVALID,
+ IMG_DefaultIcon, NULL,
+ 0, name, NULL,
+ NULL);
+ }
+ SETTING_TRACE_END;
+}
+
+/**
+ *
+ * ail code here
+ */
+static ail_cb_ret_e __download_apps_cb(ail_appinfo_h ai, void* data)
+{
+ DrawAppInfo* pinfo = (DrawAppInfo*)data;
+ char *id;
+
+ if (AIL_ERROR_OK == ail_appinfo_get_str(ai, AIL_PROP_PACKAGE_STR, &id))
+ {
+ //SETTING_TRACE(" 3rd party - app name : ----> %s ", id);
+ }
+
+ ail_appinfo_h handle;
+
+ char *name = NULL;
+ char *icon = NULL;
+ int installed_time;
+ bool nodisplay = false;
+ bool removable = true;
+
+ if (AIL_ERROR_OK == ail_package_get_appinfo(id, &handle))
+ {
+ if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_NAME_STR, &name))
+ SETTING_TRACE("cannot get name");
+
+ if (AIL_ERROR_OK != ail_appinfo_get_str(handle, AIL_PROP_ICON_STR, &icon))
+ SETTING_TRACE("cannot get icon");
+
+ if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_NODISPLAY_BOOL, &nodisplay))
+ SETTING_TRACE("cannot get nodisplay");
+
+ if (AIL_ERROR_OK != ail_appinfo_get_bool(handle, AIL_PROP_X_SLP_REMOVABLE_BOOL, &removable))
+ SETTING_TRACE("cannot get removable");
+
+ if (AIL_ERROR_OK != ail_appinfo_get_int(handle, AIL_PROP_X_SLP_INSTALLEDTIME_INT, &installed_time))
+ SETTING_TRACE("cannot get installed_time");
+
+ //SETTING_TRACE("installed_time = %d ", installed_time);
+ if (installed_time != 0 && is_3rdapp_installed_setting_cfg(id) == true )
+ {
+ SETTING_TRACE(" 3rd party - app name : ----> id : %s --- name : %s ", id, name);
+ SETTING_TRACE(" 3rd party - icon : ----> %s ", icon);
+ SETTING_TRACE(" 3rd party - nodisplay : ----> %d ", nodisplay);
+ pinfo->ncount++;
+
+ // draw code here
+ if (pinfo->draw_app != NULL)
+ {
+ SETTING_TRACE(">>> pkg name --> %s ", id);
+ pinfo->draw_app(pinfo->data, strdup(name)/* appname*/, strdup(id)/* pkg_name*/);
+ }
+ }
+ }
+ SETTING_TRACE_END;
+ return AIL_CB_RET_CONTINUE;
+}
+
+
+/**
+ * get 3rd party applist from AIL & searching dir/file by the defined rule
+ * @param data ad
+ * if data is NULL --> just get how many items are there
+ * if data is NOT NULL --> draw UI code
+ */
+static int get_downloadapp_list(void* data)
+{
+ SETTING_TRACE_BEGIN;
+
+ setting_main_appdata *ad = data;
+
+ int ncount = 0;
+ ail_filter_h f;
+ ail_appinfo_h handle;
+
+ DrawAppInfo* pinfo = (DrawAppInfo*)malloc(sizeof(DrawAppInfo));
+ pinfo->ncount = 0;
+ pinfo->draw_app = draw_3rdapp;
+ pinfo->data = ad;
+
+ if (ail_filter_new(&f) == AIL_ERROR_OK)
+ {
+ if (ail_filter_add_bool(f, AIL_PROP_NODISPLAY_BOOL, false) != AIL_ERROR_OK)
+ {
+ SETTING_TRACE("ail filter error");
+ return;
+ }
+
+ ail_filter_list_appinfo_foreach(f, __download_apps_cb, pinfo);
+ //---------------------------------------------------------------
+ ail_filter_destroy(f);
+ }
+ ncount = pinfo->ncount;
+
+ if (pinfo) {
+ free(pinfo);
+ pinfo = NULL;
+ }
+
+ SETTING_TRACE_END;
+ return ncount;
+}
+