move to appcore_get_rotation_state in the last of app_create
[framework/appfw/ui-gadget-1.git] / client / ug-client.c
index a592f66..5ed81e9 100755 (executable)
 #include <dlog.h>
 #include <aul.h>
 #include <appsvc.h>
+#include <runtime_info.h>
 
 #include "ug-client.h"
 
-#define POPUP_TITLE_MAX (128)
-
 #ifdef LOG_TAG
 #undef LOG_TAG
 #endif
@@ -67,10 +66,16 @@ static int rotate(enum appcore_rm m, void *data)
 {
        struct appdata *ad = data;
        int r;
+       bool is_rotation_lock = false;
 
        if (ad == NULL || ad->win == NULL)
                return 0;
 
+       /* rotation lock */
+       r = runtime_info_get_value_bool(RUNTIME_INFO_KEY_ROTATION_LOCK_ENABLED, &is_rotation_lock);
+       if ( !r && is_rotation_lock)
+               m = APPCORE_RM_PORTRAIT_NORMAL;
+
        switch (m) {
        case APPCORE_RM_PORTRAIT_NORMAL:
                ug_send_event(UG_EVENT_ROTATE_PORTRAIT);
@@ -93,35 +98,9 @@ static int rotate(enum appcore_rm m, void *data)
                break;
        }
 
-       if (r >= 0)
-               elm_win_rotation_with_resize_set(ad->win, r);
-
        return 0;
 }
 
-static void close_popup(void *data, Evas_Object *obj, void *event_info)
-{
-       evas_object_del(obj);
-       elm_exit();
-}
-
-static void show_popup(Evas_Object *win, const char *name)
-{
-       Evas_Object *pu;
-       char buf[POPUP_TITLE_MAX];
-
-       if (!name || !win)
-               return;
-
-       pu = elm_popup_add(win);
-       if (!pu)
-               return;
-
-       evas_object_size_hint_weight_set(pu, EVAS_HINT_EXPAND,
-                                        EVAS_HINT_EXPAND);
-       evas_object_show(pu);
-}
-
 void layout_cb(ui_gadget_h ug, enum ug_mode mode, void *priv)
 {
        struct appdata *ad;
@@ -234,6 +213,7 @@ static int lang_changed(void *data)
 static int app_create(void *data)
 {
        struct appdata *ad = data;
+       enum appcore_rm rm;
        Evas_Object *win;
        Evas_Object *ly;
 
@@ -260,6 +240,9 @@ static int app_create(void *data)
        appcore_set_event_callback(APPCORE_EVENT_LOW_BATTERY, low_battery, ad);
        appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, lang_changed, ad);
 
+       if (appcore_get_rotation_state(&rm) == 0)
+               rotate(rm, ad);
+
        return 0;
 }
 
@@ -326,6 +309,10 @@ static int app_reset(bundle *b, void *data)
        cbs.priv = ad;
 
        ad->ug = ug_create(NULL, ad->name, mode, service, &cbs);
+       if (ad->ug == NULL) {
+               LOGE("ug_create fail: %s\n", ad->name);
+               elm_exit();
+       }
 
        return 0;
 }