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