[Tizen] ecore-wl2: applying ecore-wl2
[platform/core/uifw/dali-adaptor.git] / dali / internal / adaptor / tizen / adaptor-impl-tizen.cpp
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/internal/adaptor/common/adaptor-impl.h>
20
21 // EXTERNAL INCLUDES
22 #include <app_common.h>
23 #ifdef APPCORE_WATCH_AVAILABLE
24 #include <screen_connector_provider.h>
25 #ifdef ECORE_WL2
26 #include <dali/integration-api/wayland/ecore-wl2/ecore-wl2-render-surface.h>
27 #else
28 #include <dali/integration-api/wayland/ecore-wl/ecore-wl-render-surface.h>
29 #endif
30 #endif
31
32 #include <system_settings.h>
33
34 namespace Dali
35 {
36
37 namespace Internal
38 {
39
40 namespace Adaptor
41 {
42
43 namespace
44 {
45
46 static void OnSystemLanguageChanged( system_settings_key_e key, void* data )
47 {
48   char* locale = NULL;
49   if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
50       locale == NULL )
51   {
52     DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
53     return;
54   }
55
56   Adaptor* adaptor = static_cast< Adaptor* >( data );
57   if( adaptor != NULL )
58   {
59     adaptor->SetRootLayoutDirection( locale );
60   }
61
62   free( locale );
63 }
64
65 } // namesapce
66
67 void Adaptor::GetDataStoragePath( std::string& path)
68 {
69 #ifdef USE_APPFW
70   char *pathInt = app_get_data_path();
71   if ( pathInt )
72   {
73     path = pathInt;
74     free( pathInt );
75   }
76   else
77   {
78     path = "";
79   }
80 #endif
81
82 }
83
84 void Adaptor::GetAppId( std::string& appId )
85 {
86 #ifdef USE_APPFW
87   char *id;
88   app_get_id(&id);
89   if ( id )
90   {
91     appId = id;
92   }
93   else
94   {
95     appId = "";
96   }
97 #endif
98 }
99
100 void Adaptor::SurfaceInitialized()
101 {
102 #ifdef APPCORE_WATCH_AVAILABLE
103   if ( !mUseRemoteSurface )
104   {
105     return;
106   }
107   char *appId;
108   app_get_id(&appId);
109
110   // Use strdup() in app_get_id(), so need to free memory
111   if( appId )
112   {
113 #ifdef ECORE_WL2
114     Ecore_Wl2_Window* ecoreWlWindow = AnyCast<Ecore_Wl2_Window*>( mNativeWindow );
115     screen_connector_provider_remote_enable(appId, ecore_wl2_window_surface_get(ecoreWlWindow));
116 #else
117     Ecore_Wl_Window* ecoreWlWindow = AnyCast<Ecore_Wl_Window*>( mNativeWindow );
118     screen_connector_provider_remote_enable(appId, ecore_wl_window_surface_get(ecoreWlWindow));
119 #endif
120     free( appId );
121   }
122 #endif
123 }
124
125 void Adaptor::SetupSystemInformation()
126 {
127   if( system_settings_set_changed_cb( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged, this ) != SYSTEM_SETTINGS_ERROR_NONE )
128   {
129     DALI_LOG_ERROR( "DALI system_settings_set_changed_cb failed.\n" );
130     return;
131   }
132
133   char* locale = NULL;
134   if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
135       locale == NULL )
136   {
137     DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
138     return;
139   }
140
141   SetRootLayoutDirection( locale );
142
143   free( locale );
144
145 }
146
147 } // namespace Adaptor
148
149 } // namespace Internal
150
151 } // namespace Dali