Find app name translated using ail tizen_2.2 2.2.1_release submit/tizen_2.2/20131107.055830
authorTaeyoung Kim <ty317.kim@samsung.com>
Sun, 13 Oct 2013 11:11:01 +0000 (20:11 +0900)
committerTaeyoung Kim <ty317.kim@samsung.com>
Sun, 13 Oct 2013 11:11:01 +0000 (20:11 +0900)
Signed-off-by: Taeyoung Kim <ty317.kim@samsung.com>
crash-popup/CMakeLists.txt
crash-popup/src/crash-popup.c
crash-popup/src/crash-popup.h

index f3e9245..3869599 100644 (file)
@@ -40,6 +40,7 @@ pkg_check_modules(pkgs REQUIRED
        ecore-imf
        appcore-common
        ecore-imf
+       ail
 )
 
 FOREACH(flag ${pkgs_CFLAGS})
index c4ede7a..a34a1e6 100644 (file)
 #include <unistd.h>
 #include <grp.h>
 #include <X11/Xlib.h>
+#include <ail.h>
 
 #include "util_log.h"
 #include "crash-popup.h"
 
 #define KEY_ESC_ON_KEYBOARD "Escape"
 
+static char *appname[256];
+
 /**
  * callback function of ECORE_EVENT_KEY_DOWN
  */
@@ -117,14 +120,85 @@ static void popup_close_cb(void *data, Evas_Object *obj, void *event_info)
        elm_shutdown();
        elm_exit();
 }
+
+static ail_cb_ret_e appinfo_get_name_func(const ail_appinfo_h appinfo, void *user_data)
+{
+       char *str;
+       ail_cb_ret_e ret = AIL_CB_RET_CONTINUE;
+
+       ret = ail_appinfo_get_str(appinfo, AIL_PROP_NAME_STR, &str);
+       if (str) {
+               snprintf(appname, sizeof(appname), "%s", str);
+               ret = AIL_CB_RET_CANCEL;
+       }
+
+       return ret;
+}
+
+static int get_appname_by_exepath(const char *exepath)
+{
+       ail_filter_h f;
+       ail_error_e ret;
+       int count, r;
+
+       if (!exepath)
+               return -EINVAL;
+
+       ret = ail_filter_new(&f);
+       if (ret != AIL_ERROR_OK) {
+               _E("FAIL: ail_filter_new()");
+               return -EINVAL;
+       }
+
+       ret = ail_filter_add_str(f, AIL_PROP_EXEC_STR, exepath);
+       if (ret != AIL_ERROR_OK) {
+               _E("FAIL: ail_filter_add_str()");
+               r = -EINVAL;
+               goto out;
+       }
+
+       ret = ail_filter_count_appinfo(f, &count);
+       if (ret != AIL_ERROR_OK) {
+               _E("FAIL: ail_filter_count_appinfo()");
+               r = -EINVAL;
+               goto out;
+       }
+
+       if (count < 1) {
+               _E("There is no app matching to the exepath");
+               r = -EINVAL;
+               goto out;
+       }
+
+       ret = ail_filter_list_appinfo_foreach(f, appinfo_get_name_func, NULL);
+       if (ret != AIL_ERROR_OK) {
+               _E("FAIL: ail_filter_list_appinfo_foreach()");
+               r = -EINVAL;
+               goto out;
+       }
+
+       r = 0;
+
+out:
+       ail_filter_destroy(f);
+       return r;
+}
+
 static void add_sorry_popup(struct appdata *ad)
 {
        Evas_Object *pu, *bt1;
        char buf[512] = {0, };
-       char *r;
+       char *name;
+       int ret;
+
+       ret = get_appname_by_exepath(ad->exepath);
+       if (ret < 0)
+               name = ad->appname;
+       else
+               name = appname;
 
        snprintf(buf, sizeof(buf),
-                       _("IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"), ad->appname);
+                       _("IDS_ST_BODY_PS_HAS_CLOSED_UNEXPECTEDLY"), name);
        pu = elm_popup_add(ad->win);
        elm_object_text_set(pu, buf);
        bt1 = elm_button_add(pu);
@@ -304,7 +378,7 @@ int main(int argc, char *argv[])
                setuid(pw->pw_uid);
 
        _D("argc(%d)\n", argc);
-       if (argc < 2) {
+       if (argc < 3) {
                _D("argc is (%d) wrong argument\n", argc);
                return -1;
        }
@@ -325,6 +399,7 @@ int main(int argc, char *argv[])
                        appcore_measure_time_from("APP_START_TIME"));
        memset(&ad, 0x0, sizeof(struct appdata));
        snprintf(ad.appname, sizeof(ad.appname), "%s", argv[1]);
+       snprintf(ad.exepath, sizeof(ad.exepath), "%s", argv[2]);
        ops.data = &ad;
        return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
 }
index 8b6aa7d..67c4c52 100644 (file)
@@ -65,6 +65,7 @@ struct appdata
        Ecore_X_Display *x_disp;
        Ecore_Timer *et;
        char appname[256];
+       char exepath[256];
        /* add more variables here */
 };