applied app setting code for 3rd part app installation
authorMyoungJune Park <mj2004.park@samsung.com>
Sat, 1 Sep 2012 07:27:50 +0000 (16:27 +0900)
committerMyoungJune Park <mj2004.park@samsung.com>
Sat, 1 Sep 2012 07:40:53 +0000 (16:40 +0900)
debian/changelog
include/setting-plugin.h
packaging/settings.spec
setting-common/src/setting-common-draw-genlist.c
src/CMakeLists.txt
src/setting-main.c
src/setting-plugin.c

index 9c9fa55..2028cac 100755 (executable)
@@ -1,3 +1,10 @@
+setting (0.1.88-69) unstable; urgency=low
+
+  * fixed many tizendev/bugs issues
+  * applied App Setting test (3rd party)
+
+ -- MyoungJune Park <mj2004.park@samsung.com>  Sat, 01 Sep 2012 16:26:35 +0900
+
 setting (0.1.88-68) precise; urgency=low
 
   * release 
index 5484ca0..7606b9c 100755 (executable)
@@ -6,7 +6,7 @@
 #define FALSE 0
 #endif
 
-#if 0
+#if 1
 #define PLUGIN_INIT \
 {\
        setting_drawer_list_init();\
index 1d2c125..9e1e5c5 100755 (executable)
@@ -31,6 +31,7 @@ BuildRequires:  pkgconfig(ail)
 BuildRequires:  pkgconfig(sysman)
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(gthread-2.0)
+BuildRequires:  pkgconfig(dbus-glib-1)
 BuildRequires:  pkgconfig(ecore-imf)
 BuildRequires:  pkgconfig(ecore-x)
 BuildRequires:  pkgconfig(ecore)
@@ -440,5 +441,4 @@ ln -sf /usr/bin/ug-client /opt/ug/bin/setting-font-efl
 /opt/data/setting/langlist.xml
 /opt/data/setting/plugin-cfg/*
 /opt/data/setting/plugin-xml/*
-#/opt/apps/org.tizen.setting/bin/test_server
-
+/opt/apps/org.tizen.setting/bin/test_server
index 8c93e96..61b0998 100755 (executable)
@@ -1036,7 +1036,6 @@ Setting_GenGroupItem_Data *setting_create_Gendial_field_groupitem(
                elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
 
                char speciliztion[MAX_SPECIALIZITION_LEN] = { 0, };
-               //char *temp1 = setting_customize_text(keyStr, 0, "#9C9C9C", "left");
                char* temp1 = (char *)keyStr;
                char*temp2 = strchr(temp1, '&');
                char* temp = NULL;
index e29563b..43f6f20 100755 (executable)
@@ -13,6 +13,7 @@ pkg_check_modules(pkgs_main REQUIRED
                                          sysman icu-i18n icu-io icu-le icu-lx icu-uc
                                          appsvc libxml-2.0
                                          capi-system-system-settings
+                                         dbus-glib-1
                                          ##setting-service
                                  )
 
@@ -46,20 +47,20 @@ ADD_EXECUTABLE(${PROJECT_NAME}
        ./setting.c
        ./setting-main.c
        ./setting-more-menu.c
-#      ./setting-plugin.c
+       ./setting-plugin.c
        )
 
 ####FOR TEST>>>>########
-# ADD_DEFINITIONS("-DPLUGIN")
+ ADD_DEFINITIONS("-DPLUGIN")
 # test server
-#SET(TEST_PKG_NAME test_server)
-#
-#ADD_EXECUTABLE(${TEST_PKG_NAME}
-#      ./plugin-resource/test_server.c
-#      )
-#TARGET_LINK_LIBRARIES(${TEST_PKG_NAME} -L${CMAKE_BINARY_DIR}/${SETTING_COMMON} -lsetting-common)
-#TARGET_LINK_LIBRARIES(${TEST_PKG_NAME} ${pkgs_main_LDFLAGS} "-pie")
-#INSTALL(TARGETS ${TEST_PKG_NAME} DESTINATION /opt/apps/${SETTING_PKG_NAME}/bin)
+SET(TEST_PKG_NAME test_server)
+
+ADD_EXECUTABLE(${TEST_PKG_NAME}
+       ./plugin-resource/test_server.c
+       )
+TARGET_LINK_LIBRARIES(${TEST_PKG_NAME} -L${CMAKE_BINARY_DIR}/${SETTING_COMMON} -lsetting-common)
+TARGET_LINK_LIBRARIES(${TEST_PKG_NAME} ${pkgs_main_LDFLAGS} "-pie")
+INSTALL(TARGETS ${TEST_PKG_NAME} DESTINATION /opt/apps/${SETTING_PKG_NAME}/bin)
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/plugin-resource/plugin-cfg DESTINATION /opt/data/setting FILES_MATCHING PATTERN "*.cfg")
 INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/src/plugin-resource/plugin-xml DESTINATION /opt/data/setting FILES_MATCHING PATTERN "*.xml")
 ####FOR TEST>>>>########
index 518130e..bb78138 100755 (executable)
 
 #include <tapi_common.h>
 #include <aul.h>
+#include <ail.h>
 #include <time.h>
 #include <setting-main.h>
 #include <setting-plugin.h>
 
+
+typedef struct DrawAppInfo DrawAppInfo;
+typedef struct DrawAppInfo
+{
+       int ncount;
+       //------------------------------------
+       void (*draw_app)(void* arg, char* name, char* pkgname);
+       void* data;
+};
+
 static int setting_main_create(void *cb);
 static int setting_main_destroy(void *cb);
 static int setting_main_update(void *cb);
@@ -980,6 +991,168 @@ static void __load_applications_level_all_list(void *data)
        __load_applications_menu_list(ad, Cfg_Item_Pos_Level_All);
 }
 
+bool is_3rdapp_installed_setting_cfg(char* pkgname)
+{
+       SETTING_TRACE_BEGIN;
+       // /opt/apps/
+       char path[512];
+
+       SETTING_TRACE("1");
+       if (snprintf(path, 512, "/opt/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_main_appdata *ad = data;
+
+       //3rd cfg
+       char fullpath[512];
+
+       if (snprintf(fullpath, 512, "/opt/apps/%s/setting/setting.xml", pkgname) < 0)
+               return false;
+
+       SETTING_TRACE(" fullpath : %s", fullpath);
+
+       if (ad)
+       {
+               setting_create_Gendial_field_groupitem(ad->main_genlist,
+                                                          &(ad->itc[GENDIAL_Type_1text_1icon_2]),
+                                                          NULL,
+                                                          setting_main_click_list_plugin_cb,
+                                                          strdup(fullpath),
+                                                          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)
+{
+       SETTING_TRACE_BEGIN;
+
+       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 : ----> %s ", id);
+                       pinfo->ncount++;
+
+                       // draw code here
+                       if (pinfo->draw_app != NULL)
+                       {
+                               SETTING_TRACE(">>> pkg name --> %s ", id);
+                               // draw !!!
+                               pinfo->draw_app(pinfo->data, strdup(id)/* 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;
+}
+
 static int __get_downloaded_apps_num(Cfg_Item_Position inputPos)
 {
        SETTING_TRACE_BEGIN;
@@ -1003,28 +1176,16 @@ static int __get_downloaded_apps_num(Cfg_Item_Position inputPos)
                }
        }
 
+       // draw UI with AUL code
 #ifdef PLUGIN
-       //3rd cfg
-       DIR *dp = opendir (PLUGIN_CFG_DIR);
-       if (dp != NULL)
-       {
-               struct dirent *ep;
-               while (ep = readdir (dp))
-               {
-                               if (0 == safeStrCmp(".", ep->d_name)
-                                   || 0 == safeStrCmp("..", ep->d_name))
-                               {
-                                       continue;
-                               }
-                               downloaded_apps_num++;
-               }
-               (void) closedir (dp);
-       }
-#endif
+       downloaded_apps_num = get_downloadapp_list(NULL);
        SETTING_TRACE("Exit %s with return[%d]",__FUNCTION__, downloaded_apps_num);
+#endif
+
        return downloaded_apps_num;
 }
 
+
 static void __load_downloaded_apps_menu_list(void *data,
                                             Cfg_Item_Position inputPos)
 {
@@ -1048,6 +1209,7 @@ static void __load_downloaded_apps_menu_list(void *data,
                                                     ELM_GENLIST_ITEM_NONE,
                                                     KeyStr_DownloadedAPPs,
                                                     NULL);
+#if DISABLED_CODE
        char *keyStr = NULL;
        char *icon_path = NULL;
        char *ug_args = NULL;
@@ -1083,8 +1245,11 @@ static void __load_downloaded_apps_menu_list(void *data,
 
                }
        }
+#endif
+
 
-       #ifdef PLUGIN
+       //#ifdef PLUGIN
+       #if 0
        //3rd cfg
        DIR *dp = opendir (PLUGIN_CFG_DIR);
        if (dp != NULL)
@@ -1122,6 +1287,13 @@ static void __load_downloaded_apps_menu_list(void *data,
                }
                (void) closedir (dp);
        }
+       #else
+       // TODO: DRAW 3RD PARTY APPS LIST here with EFL code
+       int downloaded_apps_num = get_downloadapp_list(ad);
+
+       // loop condition : 0 ---> ncount
+       //
+
        #endif
        SETTING_TRACE_END;
 }
index 7896658..70a3d10 100755 (executable)
@@ -42,6 +42,7 @@ typedef void (*drawer_fp)(void *data, xmlNode *xmlObj);
 static void group_func(void *data, xmlNode *xmlObj);
 static void link_func(void *data, xmlNode *xmlObj);
 static void slider_func(void *data, xmlNode *xmlObj);
+static void label_func(void *data, xmlNode *xmlObj);
 static void navigationbar_func(void *data, xmlNode *xmlObj);
 static void checkbox_func(void *data, xmlNode *xmlObj);
 static void editbox_func(void *data, xmlNode *xmlObj);
@@ -101,7 +102,8 @@ void setting_drawer_list_init()
        /* <string>        */__drawer_add("string", editbox_func);
        /* <group>         */__drawer_add("group", group_func);
        /* <integer>       */__drawer_add("integer", slider_func);
-       /* <link           */__drawer_add("link", link_func);
+       /* <label>         */__drawer_add("label", label_func);
+       /* <link>          */__drawer_add("link", link_func);
        /* <extendlist>    */__drawer_add("expandlist", expandlist_func);
        /* <extenditem>    */__drawer_add("expanditem", expanditem_func);
        /* <settings>      */__drawer_add("settings", settings_func);
@@ -417,6 +419,19 @@ static void __link_list_cb(void *data, Evas_Object *obj, void *event_info)
 }
 
 
+static void label_func(void *data, xmlNode *xmlObj)
+{
+       SETTING_TRACE_BEGIN;
+       ret_if(!data || !xmlObj);
+       Draw_Data *pd = data;
+       const char *title = (char*)xmlGetProp(xmlObj, "title");
+
+       setting_create_Gendial_field_def(pd->scroller, &(itc_1text),
+                                        NULL,
+                                        xmlObj, SWALLOW_Type_INVALID, NULL, NULL,
+                                        0, title, NULL, NULL);
+}
+
 static void link_func(void *data, xmlNode *xmlObj)
 {
        SETTING_TRACE_BEGIN;
@@ -650,7 +665,7 @@ static void __entry_unfocus_cb(void *data, Evas_Object *obj, void *event_info)
        xmlNode* xmlObj = list_item->userdata;
        ret_if(!xmlObj);
        xmlAttrPtr newattr;
-       const char *title = (char*)xmlSetProp(xmlObj, "string",entry_str_utf8);
+       const char *title = (char*)xmlSetProp(xmlObj, "value",entry_str_utf8);
 
        __send_string_msg(xmlObj, entry_str_utf8);
        __cfg_file_write((Draw_Data *)list_item->belongs_to);
@@ -707,8 +722,10 @@ static void editbox_func(void *data, xmlNode *xmlObj)
        Draw_Data *pd = data;
 
        const char *title = (char*)xmlGetProp(xmlObj, "title");
-       const char *key_str= (char*)xmlGetProp(xmlObj, "string");
+       const char *key_str= (char*)xmlGetProp(xmlObj, "value");
 
+       // TODO: minlength
+       // TODO: maxlength
        Setting_GenGroupItem_Data *list_item =
            setting_create_Gendial_field_def(pd->scroller, &(itc_1icon),
                                             __editbox_list_cb,
@@ -825,13 +842,46 @@ static void __expanditem_func_smart_cb(void *data, Evas_Object *obj, void *event
 
 static void settings_func(void *data, xmlNode *xmlObj)
 {
-       // DO NOTHING
+
 }
 
 // <setting>
 static void setting_func(void *data, xmlNode *xmlObj)
 {
+#if 0
        // DO NOTHING
+       //----------------------------------------------------------------
+       // [DATA] title, btn[0], btn[1]
+       Draw_Data *pd = data;
+       const char *title = (char*)xmlGetProp(xmlObj, "title");
+       char *btn[2] = {0, };
+
+       // find child nodes named 'elements'
+#if 0
+       if (xmlObj->children) {
+               xmlNode* cur = xmlObj->children;
+               int i =0;
+               while (cur != NULL)
+               {
+                       if (!xmlStrcmp(cur->name, (const xmlChar*)"button")) {
+                               btn[i] = xmlGetProp(cur, "title");
+                               SETTING_TRACE("------>>> node type : Element, name=%s id=%s / btn[%d] = %s ", cur->name,xmlGetProp(cur, "id"), i, btn[i]);
+                               i++;
+                       }
+                       cur = cur->next;
+               }
+       }
+#endif
+       //----------------------------------------------------------------
+       // [UI] with DATA
+       pd->ly_main = setting_create_layout_navi_bar_genlist(pd->win_get,
+                                                  pd->win_get,
+                                                  _(title),
+                                                  _("NO"), _("YES"),
+                                                  ___click_softkey_back_cb,
+                                                  ___click_softkey_back_cb, pd, &pd->scroller,
+                                                  &(pd->navi_bar));
+#endif
 }