Merge branch 'devel/master' into tizen
[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 #endif
26 #include <Ecore_Wayland.h>
27 #include <system_settings.h>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 namespace Adaptor
36 {
37
38 namespace
39 {
40
41 static void OnSystemLanguageChanged( system_settings_key_e key, void* data )
42 {
43   char* locale = NULL;
44   if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
45       locale == NULL )
46   {
47     DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
48     return;
49   }
50
51   Adaptor* adaptor = static_cast< Adaptor* >( data );
52   if( adaptor != NULL )
53   {
54     adaptor->SetRootLayoutDirection( locale );
55   }
56
57   free( locale );
58 }
59
60 } // namesapce
61
62 void Adaptor::GetDataStoragePath( std::string& path)
63 {
64 #ifdef USE_APPFW
65   char *pathInt = app_get_data_path();
66   if ( pathInt )
67   {
68     path = pathInt;
69     free( pathInt );
70   }
71   else
72   {
73     path = "";
74   }
75 #endif
76
77 }
78
79 void Adaptor::GetAppId( std::string& appId )
80 {
81 #ifdef USE_APPFW
82   char *id;
83   app_get_id(&id);
84   if ( id )
85   {
86     appId = id;
87   }
88   else
89   {
90     appId = "";
91   }
92 #endif
93 }
94
95 void Adaptor::SurfaceInitialized()
96 {
97 #ifdef APPCORE_WATCH_AVAILABLE
98   if ( !mUseRemoteSurface )
99   {
100     return;
101   }
102   char *appId;
103   app_get_id(&appId);
104
105   // Use strdup() in app_get_id(), so need to free memory
106   if( appId )
107   {
108     Ecore_Wl_Window* ecoreWlWindow = AnyCast<Ecore_Wl_Window*>( mNativeWindow );
109     screen_connector_provider_remote_enable(appId, ecore_wl_window_surface_get(ecoreWlWindow));
110     free( appId );
111   }
112 #endif
113 }
114
115 void Adaptor::SetupSystemInformation()
116 {
117   if( system_settings_set_changed_cb( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged, this ) != SYSTEM_SETTINGS_ERROR_NONE )
118   {
119     DALI_LOG_ERROR( "DALI system_settings_set_changed_cb failed.\n" );
120     return;
121   }
122
123   char* locale = NULL;
124   if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
125       locale == NULL )
126   {
127     DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
128     return;
129   }
130
131   SetRootLayoutDirection( locale );
132
133   free( locale );
134
135 }
136
137 } // namespace Adaptor
138
139 } // namespace Internal
140
141 } // namespace Dali