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, const std::string& name)
128 : mObserver(observer),
136 mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
140 mImpl = new Impl(this);
143 Framework::~Framework()
153 void Framework::Run()
157 elm_init(*mArgc, *mArgv);
159 Impl::AppCreate(this);
166 void Framework::Quit()
168 Impl::AppTerminate(this);
173 bool Framework::IsMainLoopRunning()
178 void Framework::AddAbortCallback( CallbackBase* callback )
180 mImpl->mAbortCallBack = callback;
183 std::string Framework::GetBundleName() const
188 void Framework::SetBundleName(const std::string& name)
193 std::string Framework::GetBundleId() const
198 void Framework::SetBundleId(const std::string& id)
203 void Framework::AbortCallback( )
205 // if an abort call back has been installed run it.
206 if (mImpl->mAbortCallBack)
208 CallbackBase::Execute( *mImpl->mAbortCallBack );
216 bool Framework::AppStatusHandler(int type, void *bundleData)
224 // Connect to abnormal exit signals
225 mAbortHandler.AbortOnSignal( SIGINT );
226 mAbortHandler.AbortOnSignal( SIGQUIT );
227 mAbortHandler.AbortOnSignal( SIGKILL );
238 mObserver.OnResume();
242 mObserver.OnTerminate();
249 case APP_LANGUAGE_CHANGE:
250 mObserver.OnLanguageChanged();
260 void Framework::InitThreads()
265 } // namespace Adaptor
267 } // namespace Internal