2 * Copyright (c) 2014 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 "framework.h"
23 #include <Elementary.h>
26 #include <dali/integration-api/debug.h>
29 #include <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),
149 mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
153 mImpl = new Impl(this);
156 Framework::~Framework()
166 void Framework::Run()
170 elm_init(*mArgc, *mArgv);
172 Impl::AppCreate(this);
179 void Framework::Quit()
181 Impl::AppTerminate(this);
186 bool Framework::IsMainLoopRunning()
191 void Framework::AddAbortCallback( CallbackBase* callback )
193 mImpl->mAbortCallBack = callback;
196 std::string Framework::GetBundleName() const
201 void Framework::SetBundleName(const std::string& name)
206 std::string Framework::GetBundleId() const
211 std::string Framework::GetResourcePath()
213 // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
214 const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
215 char* value = getenv( ubuntuEnvironmentVariable );
216 std::string resourcePath;
219 resourcePath = value;
225 void Framework::SetBundleId(const std::string& id)
230 void Framework::AbortCallback( )
232 // if an abort call back has been installed run it.
233 if (mImpl->mAbortCallBack)
235 CallbackBase::Execute( *mImpl->mAbortCallBack );
243 bool Framework::AppStatusHandler(int type, void *bundleData)
260 mObserver.OnResume();
264 mObserver.OnTerminate();
271 case APP_LANGUAGE_CHANGE:
272 mObserver.OnLanguageChanged();
282 void Framework::InitThreads()
287 std::string Framework::GetLanguage() const
289 return mImpl->GetLanguage();
292 std::string Framework::GetRegion() const
294 return mImpl->GetRegion();
297 } // namespace Adaptor
299 } // namespace Internal