Add app_control extra data type for Settings application without rotation 93/44593/1
authorSungmin Kwak <sungmin.kwak@samsung.com>
Thu, 23 Jul 2015 10:16:00 +0000 (19:16 +0900)
committerJihoon Kim <jihoon48.kim@samsung.com>
Thu, 23 Jul 2015 12:05:54 +0000 (21:05 +0900)
Code clean up

Change-Id: I459ce242b9b34d8442bb4bb8ca0461c87f5356de

im_setting_list/input_method_setting_list.cpp
im_setting_list/input_method_setting_list.h
im_setting_list/input_method_setting_list_ui.cpp
im_setting_selector/input_method_setting_selector.cpp
im_setting_selector/input_method_setting_selector.h
im_setting_selector/input_method_setting_selector_ui.cpp

index 3551f1b..2dc1d1a 100644 (file)
@@ -37,9 +37,15 @@ app_control(app_control_h app_control, void *data)
 {
     /* Handle the launch request. */
     appdata *ad = (appdata *)data;
+    char* type = NULL;
+    int res;
+
     LOGD("");
 
-    if(ad->app_state == APP_STATE_PAUSE || ad->app_state == APP_STATE_RESUME)
+    if (!ad)
+        return;
+
+    if (ad->app_state == APP_STATE_PAUSE || ad->app_state == APP_STATE_RESUME)
     {
         if (ad->win)
         {
@@ -50,19 +56,23 @@ app_control(app_control_h app_control, void *data)
         return;
     }
 
-    char* type = NULL;
-    int res = app_control_get_extra_data(app_control, "caller", &type);
-    if(APP_CONTROL_ERROR_NONE == res && NULL != type && strcmp(type, "settings") == 0)
-    {
-        ad->app_type = APP_TYPE_SETTING;
-    }
-    else
-    {
-        ad->app_type = APP_TYPE_NORMAL;
+    ad->app_type = APP_TYPE_NORMAL;
+
+    res = app_control_get_extra_data(app_control, "caller", &type);
+    if (APP_CONTROL_ERROR_NONE == res && NULL != type) {
+        if (strcmp(type, "settings") == 0)
+        {
+            ad->app_type = APP_TYPE_SETTING;
+        }
+        else if (strcmp(type, "settings_no_rotation") == 0)
+        {
+            ad->app_type = APP_TYPE_SETTING_NO_ROTATION;
+        }
     }
+
     ad->app_state = APP_STATE_SERVICE;
     im_setting_list_app_create(ad);
-    if(NULL != type)
+    if (NULL != type)
     {
         free(type);
     }
@@ -71,22 +81,25 @@ app_control(app_control_h app_control, void *data)
 static void
 app_pause(void *data)
 {
+    appdata *ad = (appdata *)data;
     LOGD("");
     /* Take necessary actions when application becomes invisible. */
-//    action_on_pause(data);
 
-    appdata *ad = (appdata *)data;
+    if (!ad)
+        return;
     ad->app_state = APP_STATE_PAUSE;
 }
 
 static void
 app_resume(void *data)
 {
+    appdata *ad = (appdata *)data;
     LOGD("");
     /* Take necessary actions when application becomes visible. */
-//    action_on_resume(data);
-    appdata *ad = (appdata *)data;
-    if(ad->app_state == APP_STATE_PAUSE)
+
+    if (!ad)
+        return;
+    if (ad->app_state == APP_STATE_PAUSE)
     {
         if (ad->win)
         {
@@ -102,10 +115,12 @@ app_resume(void *data)
 static void
 app_terminate(void *data)
 {
+    appdata *ad = (appdata *)data;
     LOGD("");
     /* Release all resources. */
-//    action_on_destroy(data);
-    appdata *ad = (appdata *)data;
+
+    if (!ad)
+        return;
     ad->app_state = APP_STATE_TERMINATE;
     im_setting_list_app_terminate(ad);
 }
@@ -115,12 +130,6 @@ ui_app_lang_changed(app_event_info_h event_info, void *user_data)
 {
     LOGD("");
     /*APP_EVENT_LANGUAGE_CHANGED*/
-/*    char *locale = vconf_get_str(VCONFKEY_LANGSET);
-    if (locale) {
-        elm_language_set(locale);
-        elm_config_all_flush();
-    }
-*/
 }
 
 static void
@@ -128,7 +137,6 @@ ui_app_orient_changed(app_event_info_h event_info, void *user_data)
 {
     LOGD("");
     /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
-    return;
 }
 
 static void
index 1793041..90ba0c8 100644 (file)
@@ -34,6 +34,7 @@ enum {
 
 enum {
     APP_TYPE_SETTING = 1,
+    APP_TYPE_SETTING_NO_ROTATION,
     APP_TYPE_NORMAL,
 };
 
index 1ce1919..f48b89b 100644 (file)
@@ -141,7 +141,7 @@ static void im_setting_list_text_domain_set(void)
 }
 
 static Evas_Object *
-im_setting_list_main_window_create(const char *name)
+im_setting_list_main_window_create(const char *name, int app_type)
 {
     Evas_Object *eo = NULL;
     int w = -1, h = -1;
@@ -158,8 +158,10 @@ im_setting_list_main_window_create(const char *name)
            return NULL;
         }
         evas_object_resize(eo, w, h);
-        int rots[4] = {0, 90, 180, 270};
-        elm_win_wm_rotation_available_rotations_set(eo, rots, 4);
+        if (app_type != APP_TYPE_SETTING_NO_ROTATION) {
+            int rots[4] = {0, 90, 180, 270};
+            elm_win_wm_rotation_available_rotations_set(eo, rots, 4);
+        }
     }
     return eo;
 }
@@ -247,50 +249,52 @@ im_setting_list_app_control_reply_cb(app_control_h request, app_control_h reply,
         return;
     }
     if (result == APP_CONTROL_RESULT_SUCCEEDED) {
-        char *value = NULL;
-        int res = app_control_get_extra_data(reply, "result", &value);
-        if (APP_CONTROL_ERROR_NONE == res && NULL != value) {
-            im_setting_list_update_window(user_data);
-        }
-        if (value){
-            free(value);
-        }
+        im_setting_list_update_window(user_data);
     }
 }
 
 static void im_setting_list_show_ime_selector(void *data)
 {
     int ret;
+    appdata *ad = (appdata *)data;
     app_control_h app_control;
-    const char *app_id = "org.tizen.inputmethod-setting-selector"; // This is temporary. AppId can be got using pkgmgr-info later.
+    const char *app_id = "org.tizen.inputmethod-setting-selector";
+
+    if (!ad)
+        return;
+
     ret = app_control_create (&app_control);
     if (ret != APP_CONTROL_ERROR_NONE) {
-          LOGD("app_control_create returned %d", ret);
-          return;
+        LOGD("app_control_create returned %d", ret);
+        return;
     }
 
     ret = app_control_set_operation (app_control, APP_CONTROL_OPERATION_DEFAULT);
     if (ret != APP_CONTROL_ERROR_NONE) {
-          LOGD("app_control_set_operation returned %d", ret);
-          app_control_destroy(app_control);
-          return;
-      }
-
-      ret = app_control_set_app_id (app_control, app_id);
-      if (ret != APP_CONTROL_ERROR_NONE) {
-          LOGD("app_control_set_app_id returned %d", ret);
-          app_control_destroy(app_control);
-          return;
-      }
-
-      app_control_add_extra_data(app_control, "caller", "settings");
-      ret = app_control_send_launch_request(app_control, im_setting_list_app_control_reply_cb, data);
-      if (ret != APP_CONTROL_ERROR_NONE) {
-         LOGD("app_control_send_launch_request returned %d, %s\n", ret, get_error_message(ret));
-         app_control_destroy(app_control);
-         return;
-      }
-      app_control_destroy(app_control);
+        LOGD("app_control_set_operation returned %d", ret);
+        app_control_destroy(app_control);
+        return;
+    }
+
+    ret = app_control_set_app_id (app_control, app_id);
+    if (ret != APP_CONTROL_ERROR_NONE) {
+        LOGD("app_control_set_app_id returned %d", ret);
+        app_control_destroy(app_control);
+        return;
+    }
+
+    if (ad->app_type == APP_TYPE_SETTING_NO_ROTATION)
+        app_control_add_extra_data(app_control, "caller", "settings_no_rotation");
+    else
+        app_control_add_extra_data(app_control, "caller", "settings");
+
+    ret = app_control_send_launch_request(app_control, im_setting_list_app_control_reply_cb, data);
+    if (ret != APP_CONTROL_ERROR_NONE) {
+        LOGD("app_control_send_launch_request returned %d, %s\n", ret, get_error_message(ret));
+        app_control_destroy(app_control);
+        return;
+    }
+    app_control_destroy(app_control);
 }
 
 static void
@@ -841,8 +845,10 @@ void
 im_setting_list_app_create(void *data)
 {
     appdata *ad = (appdata *)data;
+    if (!ad)
+        return;
     im_setting_list_text_domain_set();
-    ad->win = im_setting_list_main_window_create(PACKAGE);
+    ad->win = im_setting_list_main_window_create(PACKAGE, ad->app_type);
     im_setting_list_bg_create(ad->win);
     im_setting_list_load_ime_info();
 
index ab908af..2985390 100644 (file)
@@ -38,23 +38,33 @@ app_control(app_control_h app_control, void *data)
 {
     /* Handle the launch request. */
     appdata *ad = (appdata *)data;
+    int res;
     char* type = NULL;
 
     LOGD("");
 
-    int res = app_control_get_extra_data(app_control, "caller", &type);
-    if(APP_CONTROL_ERROR_NONE == res && NULL != type && strcmp(type,"settings") == 0)
-    {
-        ad->app_type = APP_TYPE_SETTING;
-        app_control_clone(&(ad->caller), app_control);
-    }
-    else
-    {
-        ad->app_type = APP_TYPE_NORMAL;
+    if (!ad)
+        return;
+
+    ad->app_type = APP_TYPE_NORMAL;
+
+    res = app_control_get_extra_data(app_control, "caller", &type);
+    if (APP_CONTROL_ERROR_NONE == res && NULL != type) {
+        if (strcmp(type,"settings") == 0)
+        {
+            ad->app_type = APP_TYPE_SETTING;
+            app_control_clone(&(ad->caller), app_control);
+        }
+        else if (strcmp(type, "settings_no_rotation") == 0)
+        {
+            ad->app_type = APP_TYPE_SETTING_NO_ROTATION;
+            app_control_clone(&(ad->caller), app_control);
+        }
     }
+
     ad->app_state = APP_STATE_SERVICE;
     im_setting_selector_app_create(ad);
-    if(NULL != type)
+    if (NULL != type)
     {
         free(type);
     }
@@ -63,9 +73,12 @@ app_control(app_control_h app_control, void *data)
 static void
 app_pause(void *data)
 {
+    appdata *ad = (appdata *)data;
     LOGD("");
     /* Take necessary actions when application becomes invisible. */
-    appdata *ad = (appdata *)data;
+
+    if (!ad)
+        return;
     ad->app_state = APP_STATE_PAUSE;
     im_setting_selector_app_pause(ad);
 }
@@ -73,21 +86,28 @@ app_pause(void *data)
 static void
 app_resume(void *data)
 {
+    appdata *ad = (appdata *)data;
     LOGD("");
     /* Take necessary actions when application becomes visible. */
-    appdata *ad = (appdata *)data;
+
+    if (!ad)
+        return;
     ad->app_state = APP_STATE_RESUME;
 }
 
 static void
 app_terminate(void *data)
 {
+    appdata *ad = (appdata *)data;
     LOGD("");
     /* Release all resources. */
-    appdata *ad = (appdata *)data;
+
+    if (!ad)
+        return;
     ad->app_state = APP_STATE_TERMINATE;
     im_setting_selector_app_terminate(ad);
-    app_control_destroy(ad->caller);
+    if (ad->caller)
+        app_control_destroy(ad->caller);
 }
 
 static void
@@ -95,12 +115,6 @@ ui_app_lang_changed(app_event_info_h event_info, void *user_data)
 {
     LOGD("");
     /*APP_EVENT_LANGUAGE_CHANGED*/
-/*    char *locale = vconf_get_str(VCONFKEY_LANGSET);
-    if (locale) {
-        elm_language_set(locale);
-        elm_config_all_flush();
-    }
-*/
 }
 
 static void
@@ -108,7 +122,6 @@ ui_app_orient_changed(app_event_info_h event_info, void *user_data)
 {
     LOGD("");
     /*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
-    return;
 }
 
 static void
index e559803..ab1b733 100644 (file)
@@ -35,6 +35,7 @@ enum {
 
 enum {
     APP_TYPE_SETTING = 1,
+    APP_TYPE_SETTING_NO_ROTATION,
     APP_TYPE_NORMAL,
 };
 
index ed2707c..c821c29 100644 (file)
@@ -54,7 +54,7 @@ static void im_setting_selector_text_domain_set(void)
 }
 
 static Evas_Object *
-im_setting_selector_main_window_create(const char *name)
+im_setting_selector_main_window_create(const char *name, int app_type)
 {
     Evas_Object *eo = NULL;
     int w = -1, h = -1;
@@ -72,8 +72,10 @@ im_setting_selector_main_window_create(const char *name)
            return NULL;
         }
         evas_object_resize(eo, w, h);
-        int rots[4] = {0, 90, 180, 270};
-        elm_win_wm_rotation_available_rotations_set(eo, rots, 4);
+        if (app_type != APP_TYPE_SETTING_NO_ROTATION) {
+            int rots[4] = {0, 90, 180, 270};
+            elm_win_wm_rotation_available_rotations_set(eo, rots, 4);
+        }
     }
     return eo;
 }
@@ -137,7 +139,7 @@ static void im_setting_selector_show_ime_list(void)
 {
      int ret;
      app_control_h app_control;
-     const char *app_id = "org.tizen.inputmethod-setting-list"; // This is temporary. AppId can be got using pkgmgr-info later.
+     const char *app_id = "org.tizen.inputmethod-setting-list";
      ret = app_control_create (&app_control);
      if (ret != APP_CONTROL_ERROR_NONE) {
          LOGD("app_control_create returned %d", ret);
@@ -158,7 +160,6 @@ static void im_setting_selector_show_ime_list(void)
          return;
      }
 
-     app_control_add_extra_data(app_control, "caller", "verify");
      ret = app_control_send_launch_request(app_control, NULL, NULL);
      if (ret != APP_CONTROL_ERROR_NONE) {
          LOGD("app_control_send_launch_request returned %d, %s\n", ret, get_error_message(ret));
@@ -210,7 +211,6 @@ static void im_setting_selector_ime_sel_cb(void *data, Evas_Object *obj, void *e
     if(ad->caller){
         app_control_h reply;
         app_control_create(&reply);
-        app_control_add_extra_data(reply, "result", g_ime_info_list[g_active_ime_id].appid);
         app_control_reply_to_launch_request(reply, ad->caller, APP_CONTROL_RESULT_SUCCEEDED);
         app_control_destroy(reply);
     }
@@ -376,8 +376,10 @@ void
 im_setting_selector_app_create(void *data)
 {
     appdata *ad = (appdata *)data;
+    if (!ad)
+        return;
     im_setting_selector_text_domain_set();
-    ad->win = im_setting_selector_main_window_create(PACKAGE);
+    ad->win = im_setting_selector_main_window_create(PACKAGE, ad->app_type);
     im_setting_selector_load_ime_info();
     im_setting_selector_popup_create(ad);