Merge "Fixed crash issues" into devel/master
[platform/core/uifw/dali-adaptor.git] / adaptors / tizen / adaptor-impl-tizen.cpp
index cc5f260..67afe39 100644 (file)
 #include <adaptor-impl.h>
 
 // EXTERNAL INCLUDES
-#ifdef  USE_APPFW
-#include <app.h>
+#include <app_common.h>
+#ifdef APPCORE_WATCH_AVAILABLE
+#include <screen_connector_provider.h>
+#include <ecore-wl-render-surface.h>
 #endif
 
+#include <system_settings.h>
+
 namespace Dali
 {
 
@@ -32,6 +36,30 @@ namespace Internal
 namespace Adaptor
 {
 
+namespace
+{
+
+static void OnSystemLanguageChanged( system_settings_key_e key, void* data )
+{
+  char* locale = NULL;
+  if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
+      locale == NULL )
+  {
+    DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
+    return;
+  }
+
+  Adaptor* adaptor = static_cast< Adaptor* >( data );
+  if( adaptor != NULL )
+  {
+    adaptor->SetRootLayoutDirection( locale );
+  }
+
+  free( locale );
+}
+
+} // namesapce
+
 void Adaptor::GetDataStoragePath( std::string& path)
 {
 #ifdef USE_APPFW
@@ -49,6 +77,59 @@ void Adaptor::GetDataStoragePath( std::string& path)
 
 }
 
+void Adaptor::GetAppId( std::string& appId )
+{
+#ifdef USE_APPFW
+  char *id;
+  app_get_id(&id);
+  if ( id )
+  {
+    appId = id;
+  }
+  else
+  {
+    appId = "";
+  }
+#endif
+}
+
+void Adaptor::SurfaceInitialized()
+{
+#ifdef APPCORE_WATCH_AVAILABLE
+  if ( !mUseRemoteSurface )
+  {
+    return;
+  }
+  char *appId;
+  app_get_id(&appId);
+
+  Ecore_Wl_Window* ecoreWlWindow = AnyCast<Ecore_Wl_Window*>( mNativeWindow );
+  screen_connector_provider_remote_enable(appId, ecore_wl_window_surface_get(ecoreWlWindow));
+#endif
+}
+
+void Adaptor::SetupSystemInformation()
+{
+  if( system_settings_set_changed_cb( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged, this ) != SYSTEM_SETTINGS_ERROR_NONE )
+  {
+    DALI_LOG_ERROR( "DALI system_settings_set_changed_cb failed.\n" );
+    return;
+  }
+
+  char* locale = NULL;
+  if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
+      locale == NULL )
+  {
+    DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
+    return;
+  }
+
+  SetRootLayoutDirection( locale );
+
+  free( locale );
+
+}
+
 } // namespace Adaptor
 
 } // namespace Internal