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>
24 #include <boost/bind.hpp>
27 #include <dali/integration-api/debug.h>
30 #include <callback-manager.h>
44 /// Application Status Enum
55 } // Unnamed namespace
58 * Impl to hide EFL data members
60 struct Framework::Impl
66 mCallbackManager = CallbackManager::New();
71 // we're quiting the main loop so
72 // mCallbackManager->RemoveAllCallBacks() does not need to be called
73 // to delete our abort handler
74 delete mCallbackManager;
79 boost::function<void(void)> mAbortCallBack;
80 CallbackManager *mCallbackManager;
84 * Called by AppCore on application creation.
86 static bool AppCreate(void *data)
88 return static_cast<Framework*>(data)->SlpAppStatusHandler(APP_CREATE);
92 * Called by AppCore when the application should terminate.
94 static void AppTerminate(void *data)
96 static_cast<Framework*>(data)->SlpAppStatusHandler(APP_TERMINATE);
100 * Called by AppCore when the application is paused.
102 static void AppPause(void *data)
104 static_cast<Framework*>(data)->SlpAppStatusHandler(APP_PAUSE);
108 * Called by AppCore when the application is resumed.
110 static void AppResume(void *data)
112 static_cast<Framework*>(data)->SlpAppStatusHandler(APP_RESUME);
116 * Called by AppCore when the language changes on the device.
118 static void AppLanguageChange(void* data)
120 static_cast<Framework*>(data)->SlpAppStatusHandler(APP_LANGUAGE_CHANGE);
125 Framework::Framework(Framework::Observer& observer, int *argc, char ***argv, const std::string& name)
126 : mObserver(observer),
134 mAbortHandler(boost::bind(&Framework::AbortCallback, this)),
138 mImpl = new Impl(this);
141 Framework::~Framework()
151 void Framework::Run()
155 elm_init(*mArgc, *mArgv);
157 Impl::AppCreate(this);
164 void Framework::Quit()
166 Impl::AppTerminate(this);
171 bool Framework::IsMainLoopRunning()
176 void Framework::AddAbortCallback(boost::function<void(void)> callBack)
178 mImpl->mAbortCallBack = callBack;
181 std::string Framework::GetBundleName() const
186 void Framework::SetBundleName(const std::string& name)
191 std::string Framework::GetBundleId() const
196 void Framework::SetBundleId(const std::string& id)
201 void Framework::AbortCallback( )
203 // if an abort call back has been installed run it.
204 if (mImpl->mAbortCallBack)
206 mImpl->mAbortCallBack();
214 bool Framework::SlpAppStatusHandler(int type)
222 // Connect to abnormal exit signals
223 mAbortHandler.AbortOnSignal( SIGINT );
224 mAbortHandler.AbortOnSignal( SIGQUIT );
225 mAbortHandler.AbortOnSignal( SIGKILL );
236 mObserver.OnResume();
240 mObserver.OnTerminate();
247 case APP_LANGUAGE_CHANGE:
248 mObserver.OnLanguageChanged();
258 void Framework::InitThreads()
263 } // namespace Adaptor
265 } // namespace Internal