2 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
19 #include <dali/internal/adaptor/common/framework.h>
\r
21 // EXTERNAL INCLUDES
\r
22 #include <dali/integration-api/debug.h>
\r
24 // INTERNAL INCLUDES
\r
25 #include <dali/internal/window-system/windows/platform-implement-win.h>
\r
26 #include <dali/internal/system/common/callback-manager.h>
\r
28 int64_t counter = 0;
\r
42 /// Application Status Enum
\r
50 APP_LANGUAGE_CHANGE,
\r
53 } // Unnamed namespace
\r
55 * Impl to hide WindowsSystem data members
\r
57 struct Framework::Impl
\r
62 : mAbortCallBack( NULL ),
\r
63 mCallbackManager( CallbackManager::New() ),
\r
64 mLanguage( "NOT_SUPPORTED" ),
\r
65 mRegion( "NOT_SUPPORTED" )
\r
71 delete mAbortCallBack;
\r
73 // we're quiting the main loop so
\r
74 // mCallbackManager->RemoveAllCallBacks() does not need to be called
\r
75 // to delete our abort handler
\r
76 delete mCallbackManager;
\r
79 std::string GetLanguage() const
\r
84 std::string GetRegion() const
\r
90 CallbackBase* mAbortCallBack;
\r
91 CallbackManager *mCallbackManager;
\r
92 std::string mLanguage;
\r
93 std::string mRegion;
\r
98 * Called by AppCore on application creation.
\r
100 static bool AppCreate(void *data)
\r
102 return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
\r
106 * Called by AppCore when the application should terminate.
\r
108 static void AppTerminate(void *data)
\r
110 static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
\r
114 * Called by AppCore when the application is paused.
\r
116 static void AppPause(void *data)
\r
118 static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
\r
122 * Called by AppCore when the application is resumed.
\r
124 static void AppResume(void *data)
\r
126 static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
\r
130 * Called by AppCore when the language changes on the device.
\r
132 static void AppLanguageChange(void* data)
\r
134 static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
\r
139 WindowsPlatformImplement::RunLoop();
\r
145 //uv_stop( mMainLoop );
\r
151 Impl( const Impl& impl );
\r
154 Impl& operator=( const Impl& impl );
\r
157 Framework::Framework( Framework::Observer& observer, int *argc, char ***argv, Type type )
\r
158 : mObserver(observer),
\r
159 mInitialised(false),
\r
165 mAbortHandler( MakeCallback( this, &Framework::AbortCallback ) ),
\r
169 mImpl = new Impl(this);
\r
172 Framework::~Framework()
\r
182 void Framework::Run()
\r
186 Impl::AppCreate(this);
\r
191 void Framework::Quit()
\r
193 Impl::AppTerminate(this);
\r
197 bool Framework::IsMainLoopRunning()
\r
202 void Framework::AddAbortCallback( CallbackBase* callback )
\r
204 mImpl->mAbortCallBack = callback;
\r
207 std::string Framework::GetBundleName() const
\r
209 return mBundleName;
\r
212 void Framework::SetBundleName(const std::string& name)
\r
214 mBundleName = name;
\r
217 std::string Framework::GetBundleId() const
\r
222 std::string Framework::GetResourcePath()
\r
224 // "DALI_APPLICATION_PACKAGE" is used by Ubuntu specifically to get the already configured Application package path.
\r
225 const char* ubuntuEnvironmentVariable = "DALI_APPLICATION_PACKAGE";
\r
226 char* value = getenv( ubuntuEnvironmentVariable );
\r
227 printf( "DALI_APPLICATION_PACKAGE is %s\n", value );
\r
228 std::string resourcePath;
\r
229 if ( value != NULL )
\r
231 resourcePath = value;
\r
234 return resourcePath;
\r
237 void Framework::SetBundleId(const std::string& id)
\r
242 void Framework::AbortCallback( )
\r
244 // if an abort call back has been installed run it.
\r
245 if (mImpl->mAbortCallBack)
\r
247 CallbackBase::Execute( *mImpl->mAbortCallBack );
\r
255 bool Framework::AppStatusHandler(int type, void *bundleData)
\r
261 mInitialised = true;
\r
263 mObserver.OnInit();
\r
268 mObserver.OnReset();
\r
272 mObserver.OnResume();
\r
275 case APP_TERMINATE:
\r
276 mObserver.OnTerminate();
\r
280 mObserver.OnPause();
\r
283 case APP_LANGUAGE_CHANGE:
\r
284 mObserver.OnLanguageChanged();
\r
294 void Framework::InitThreads()
\r
299 std::string Framework::GetLanguage() const
\r
301 return mImpl->GetLanguage();
\r
304 std::string Framework::GetRegion() const
\r
306 return mImpl->GetRegion();
\r
309 } // namespace Adaptor
\r
311 } // namespace Internal
\r
313 } // namespace Dali
\r