Remove the duplicated local variable
[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 #include <dali/integration-api/wayland/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   // Use strdup() in app_get_id(), so need to free memory
107   if( appId )
108   {
109     Ecore_Wl_Window* ecoreWlWindow = AnyCast<Ecore_Wl_Window*>( mNativeWindow );
110     screen_connector_provider_remote_enable(appId, ecore_wl_window_surface_get(ecoreWlWindow));
111     free( appId );
112   }
113 #endif
114 }
115
116 void Adaptor::SetupSystemInformation()
117 {
118   if( system_settings_set_changed_cb( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, OnSystemLanguageChanged, this ) != SYSTEM_SETTINGS_ERROR_NONE )
119   {
120     DALI_LOG_ERROR( "DALI system_settings_set_changed_cb failed.\n" );
121     return;
122   }
123
124   char* locale = NULL;
125   if( system_settings_get_value_string( SYSTEM_SETTINGS_KEY_LOCALE_LANGUAGE, &locale ) != SYSTEM_SETTINGS_ERROR_NONE ||
126       locale == NULL )
127   {
128     DALI_LOG_ERROR( "DALI OnSystemLanguageChanged failed " );
129     return;
130   }
131
132   SetRootLayoutDirection( locale );
133
134   free( locale );
135
136 }
137
138 } // namespace Adaptor
139
140 } // namespace Internal
141
142 } // namespace Dali