[Release] wrt_0.8.177
[platform/framework/web/wrt.git] / src / wrt-client / wrt-client.cpp
index 405d77e..e8df9a7 100644 (file)
@@ -57,11 +57,16 @@ static WindowData*  s_preparedWindowData = NULL;
 static int    app_argc = 0;
 static char** app_argv = NULL;
 
+// orientation
 const int WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE = 0;
 const int WIN_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE = 270;
 const int W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE = 0;
 const int W3C_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE = 90;
 
+// env
+const char* const HOME = "HOME";
+const char* const APP_HOME_PATH = "/opt/home/app";
+
 WrtClient::WrtClient(int argc, char **argv) :
     Application(argc, argv, "wrt-client", false),
     DPL::TaskDecl<WrtClient>(this),
@@ -493,16 +498,16 @@ void WrtClient::launchStep()
             languageChangedCallback, this);
 
     ADD_PROFILING_POINT("CreateWindow", "start");
-    if (s_preparedWindowData == NULL)
-    {
+    if (s_preparedWindowData == NULL) {
         m_windowData.reset(new WindowData(static_cast<unsigned long>(getpid()), true));
-    }
-    else
-    {
+    } else {
         m_windowData.reset(s_preparedWindowData);
         s_preparedWindowData = NULL;
     }
     ADD_PROFILING_POINT("CreateWindow", "stop");
+    evas_object_show(m_windowData->m_win);
+    // rotate window to initial value
+    setOrientationWindow();
 
     WRT::UserDelegatesPtr cbs(new WRT::UserDelegates);
     ADD_PROFILING_POINT("Create splash screen", "start");
@@ -524,6 +529,9 @@ void WrtClient::launchStep()
             NextStepEvent());
         return;
     }
+    // send rotate information to ewk
+    setOrientationEwk();
+
     //you can't show window with splash screen before PrepareView
     //ewk_view_add_with_context() in viewLogic breaks window
 
@@ -536,7 +544,7 @@ void WrtClient::launchStep()
         name = DPL::ToUTF8String(*(localizedInfo.name));
     }
     elm_win_title_set(m_windowData->m_win, name.c_str());
-    evas_object_show(m_windowData->m_win);
+
     initializeWindowModes();
     connectElmCallback();
 
@@ -624,44 +632,66 @@ int WrtClient::appcoreLowMemoryCallback(void* /*data*/)
     return 0;
 }
 
-void WrtClient::connectElmCallback()
+void WrtClient::setOrientationWindow(void)
 {
     Assert(m_windowData);
     Assert(m_dao);
-    if (m_dao->getWidgetType().appType == WrtDB::APP_TYPE_TIZENWEBAPP) {
-        WidgetSettings widgetSettings;
-        m_dao->getWidgetSettings(widgetSettings);
-        WidgetSettingList settings(widgetSettings);
-        if (settings.getBackButtonPresence() == BackButton_Enable) {
-            m_windowData->addFloatBackButtonCallback(
-                "clicked",
-                &WrtClient::backButtonCallback,
-                this);
-        }
 
-        WidgetSettingScreenLock rotationValue = settings.getRotationValue();
-        if (rotationValue == Screen_Portrait) {
-            elm_win_wm_rotation_preferred_rotation_set(
-                m_windowData->m_win,
-                WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
-            ewk_view_orientation_send(
-                m_widget->GetCurrentWebview(),
-                 W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
-        } else if (rotationValue == Screen_Landscape) {
-            elm_win_wm_rotation_preferred_rotation_set(
-                m_windowData->m_win,
-                WIN_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE);
-            ewk_view_orientation_send(
-                m_widget->GetCurrentWebview(),
-                W3C_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE);
-        } else {
-            elm_win_wm_rotation_preferred_rotation_set(
-                m_windowData->m_win,
-                WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
-            ewk_view_orientation_send(
-                m_widget->GetCurrentWebview(),
-                W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
-        }
+    WidgetSettings widgetSettings;
+    m_dao->getWidgetSettings(widgetSettings);
+    WidgetSettingList settings(widgetSettings);
+    WidgetSettingScreenLock rotationValue = settings.getRotationValue();
+    if (rotationValue == Screen_Portrait) {
+        elm_win_wm_rotation_preferred_rotation_set(
+            m_windowData->m_win,
+            WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
+    } else if (rotationValue == Screen_Landscape) {
+        elm_win_wm_rotation_preferred_rotation_set(
+            m_windowData->m_win,
+            WIN_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE);
+    } else {
+        elm_win_wm_rotation_preferred_rotation_set(
+            m_windowData->m_win,
+            WIN_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
+    }
+}
+
+void WrtClient::setOrientationEwk(void)
+{
+    Assert(m_widget);
+    Assert(m_dao);
+
+    WidgetSettings widgetSettings;
+    m_dao->getWidgetSettings(widgetSettings);
+    WidgetSettingList settings(widgetSettings);
+    WidgetSettingScreenLock rotationValue = settings.getRotationValue();
+    if (rotationValue == Screen_Portrait) {
+        ewk_view_orientation_send(
+            m_widget->GetCurrentWebview(),
+             W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
+    } else if (rotationValue == Screen_Landscape) {
+        ewk_view_orientation_send(
+            m_widget->GetCurrentWebview(),
+            W3C_ORIENTATION_LANDSCAPE_PRIMARY_ANGLE);
+    } else {
+        ewk_view_orientation_send(
+            m_widget->GetCurrentWebview(),
+            W3C_ORIENTATION_PORTRAIT_PRIMARY_ANGLE);
+    }
+}
+
+void WrtClient::connectElmCallback()
+{
+    Assert(m_windowData);
+    Assert(m_dao);
+    WidgetSettings widgetSettings;
+    m_dao->getWidgetSettings(widgetSettings);
+    WidgetSettingList settings(widgetSettings);
+    if (settings.getBackButtonPresence() == BackButton_Enable) {
+        m_windowData->addFloatBackButtonCallback(
+            "clicked",
+            &WrtClient::backButtonCallback,
+            this);
     }
 }
 
@@ -855,8 +885,15 @@ int main(int argc,
             }
 
             LogInfo("Prepare window_data");
+            // Temporarily change HOME path to app
+            // This change is needed for getting elementary profile
+            // /opt/home/app/.elementary/config/mobile/base.cfg
+            const char* backupEnv = getenv(HOME);
+            setenv(HOME, APP_HOME_PATH, 1);
             LogInfo("elm_init()");
             elm_init(argc, argv);
+            setenv(HOME, backupEnv, 1);
+
             LogInfo("WindowData()");
             s_preparedWindowData = new WindowData(static_cast<unsigned long>(getpid()));