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() )
71 delete mAbortCallBack;
73 // we're quiting the main loop so
74 // mCallbackManager->RemoveAllCallBacks() does not need to be called
75 // to delete our abort handler
76 delete mCallbackManager;
81 CallbackBase* mAbortCallBack;
82 CallbackManager *mCallbackManager;
86 * Called by AppCore on application creation.
88 static bool AppCreate(void *data)
90 return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
94 * Called by AppCore when the application should terminate.
96 static void AppTerminate(void *data)
98 static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
102 * Called by AppCore when the application is paused.
104 static void AppPause(void *data)
106 static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
110 * Called by AppCore when the application is resumed.
112 static void AppResume(void *data)
114 static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
118 * Called by AppCore when the language changes on the device.
120 static void AppLanguageChange(void* data)
122 static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
127 Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
128 : mObserver(observer),
135 mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
139 mImpl = new Impl(this);
142 Framework::~Framework()
152 void Framework::Run()
156 elm_init(*mArgc, *mArgv);
158 Impl::AppCreate(this);
165 void Framework::Quit()
167 Impl::AppTerminate(this);
172 bool Framework::IsMainLoopRunning()
177 void Framework::AddAbortCallback( CallbackBase* callback )
179 mImpl->mAbortCallBack = callback;
182 std::string Framework::GetBundleName() const
187 void Framework::SetBundleName(const std::string& name)
192 std::string Framework::GetBundleId() const
197 std::string Framework::GetResourcePath()
199 // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
200 const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
201 char* value = getenv( ubuntuEnvironmentVariable );
202 std::string resourcePath;
205 resourcePath = value;
211 void Framework::SetBundleId(const std::string& id)
216 void Framework::AbortCallback( )
218 // if an abort call back has been installed run it.
219 if (mImpl->mAbortCallBack)
221 CallbackBase::Execute( *mImpl->mAbortCallBack );
229 bool Framework::AppStatusHandler(int type, void *bundleData)
246 mObserver.OnResume();
250 mObserver.OnTerminate();
257 case APP_LANGUAGE_CHANGE:
258 mObserver.OnLanguageChanged();
268 void Framework::InitThreads()
273 } // namespace Adaptor
275 } // namespace Internal