2 * Copyright (c) 2019 Samsung Electronics Co., Ltd.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/adaptor/common/framework.h>
22 #include <dali/internal/system/linux/dali-ecore.h>
23 #include <dali/internal/system/linux/dali-elementary.h>
26 #include <dali/integration-api/debug.h>
29 #include <dali/internal/system/common/callback-manager.h>
43 /// Application Status Enum
54 } // Unnamed namespace
57 * Impl to hide EFL data members
59 struct Framework::Impl
64 : mAbortCallBack( NULL ),
65 mCallbackManager( CallbackManager::New() ),
66 mLanguage( "NOT_SUPPORTED" ),
67 mRegion( "NOT_SUPPORTED" )
73 delete mAbortCallBack;
75 // we're quiting the main loop so
76 // mCallbackManager->RemoveAllCallBacks() does not need to be called
77 // to delete our abort handler
78 delete mCallbackManager;
81 std::string GetLanguage() const
86 std::string GetRegion() const
92 CallbackBase* mAbortCallBack;
93 CallbackManager *mCallbackManager;
94 std::string mLanguage;
100 * Called by AppCore on application creation.
102 static bool AppCreate(void *data)
104 return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
108 * Called by AppCore when the application should terminate.
110 static void AppTerminate(void *data)
112 static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
116 * Called by AppCore when the application is paused.
118 static void AppPause(void *data)
120 static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
124 * Called by AppCore when the application is resumed.
126 static void AppResume(void *data)
128 static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
132 * Called by AppCore when the language changes on the device.
134 static void AppLanguageChange(void* data)
136 static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
141 Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
142 : mObserver(observer),
150 mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
154 mImpl = new Impl(this);
157 Framework::~Framework()
167 void Framework::Run()
171 elm_init( mArgc ? *mArgc : 0, mArgv ? *mArgv : nullptr );
173 Impl::AppCreate(this);
180 void Framework::Quit()
182 Impl::AppTerminate(this);
187 bool Framework::IsMainLoopRunning()
192 void Framework::AddAbortCallback( CallbackBase* callback )
194 mImpl->mAbortCallBack = callback;
197 std::string Framework::GetBundleName() const
202 void Framework::SetBundleName(const std::string& name)
207 std::string Framework::GetBundleId() const
212 std::string Framework::GetResourcePath()
214 // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
215 const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
216 char* value = getenv( ubuntuEnvironmentVariable );
217 std::string resourcePath;
220 resourcePath = value;
223 if( resourcePath.back() != '/' )
231 std::string Framework::GetDataPath()
233 const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_DATA_DIR";
234 char* value = getenv( ubuntuEnvironmentVariable );
235 std::string dataPath;
244 void Framework::SetBundleId(const std::string& id)
249 void Framework::AbortCallback( )
251 // if an abort call back has been installed run it.
252 if (mImpl->mAbortCallBack)
254 CallbackBase::Execute( *mImpl->mAbortCallBack );
262 bool Framework::AppStatusHandler(int type, void *bundleData)
279 mObserver.OnResume();
283 mObserver.OnTerminate();
290 case APP_LANGUAGE_CHANGE:
291 mObserver.OnLanguageChanged();
301 void Framework::InitThreads()
306 std::string Framework::GetLanguage() const
308 return mImpl->GetLanguage();
311 std::string Framework::GetRegion() const
313 return mImpl->GetRegion();
316 } // namespace Adaptor
318 } // namespace Internal