1 #ifndef __DALI_INTERNAL_FRAMEWORK_H__
2 #define __DALI_INTERNAL_FRAMEWORK_H__
5 * Copyright (c) 2016 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
23 #include <dali/public-api/signals/callback.h>
24 #ifdef APPCORE_WATCH_AVAILABLE
25 #include <dali/public-api/watch/watch-application.h>
29 #include <dali/internal/system/common/abort-handler.h>
30 #include <dali/public-api/adaptor-framework/device-status.h>
42 * The Framework class is ideally placed to provide key API required by Applications.
44 * The class is also used to register callbacks with the TIZEN platform so that
45 * we know when any of the application lifecycle events occur. This includes events
46 * like when our application is to be initialised, terminated, paused, resumed etc.
55 NORMAL, ///< normal appFramework
56 WATCH, ///< watch appFramework
57 WIDGET ///< widget appFramework
61 * Observer class for the framework.
68 * Invoked when the application is to be initialised.
70 virtual void OnInit() {}
73 * Invoked when the application is to be terminated.
75 virtual void OnTerminate() {}
78 * Invoked when the application is to be paused.
80 virtual void OnPause() {}
83 * Invoked when the application is to be resumed.
85 virtual void OnResume() {}
88 * Invoked when the application is to be reset.
90 virtual void OnReset() {}
93 * Invoked when the AppControl message is received.
94 * @param[in] The bundle data of AppControl message.
96 virtual void OnAppControl(void *) {}
98 #ifdef APPCORE_WATCH_AVAILABLE
100 * Invoked at every second
102 virtual void OnTimeTick(WatchTime&) {}
105 * Invoked at every second in ambient mode
107 virtual void OnAmbientTick(WatchTime&) {}
110 * Invoked when the device enters or exits ambient mode
112 virtual void OnAmbientChanged(bool ambient) {}
116 * Invoked when the language of the device is changed.
118 virtual void OnLanguageChanged() {}
121 * Invoked when the region is changed.
123 virtual void OnRegionChanged() {}
126 * Invoked when the battery level of the device is low.
128 virtual void OnBatteryLow( Dali::DeviceStatus::Battery::Status status ) {}
131 * Invoked when the memory level of the device is low.
133 virtual void OnMemoryLow( Dali::DeviceStatus::Memory::Status status ) {}
140 * @param[in] observer The observer of the Framework.
141 * @param[in] argc A pointer to the number of arguments.
142 * @param[in] argv A pointer the the argument list.
143 * @param[in] type The type of application
145 Framework( Observer& observer, int* argc, char ***argv, Type type = NORMAL );
155 * Runs the main loop of framework
160 * Quits the main loop
165 * Checks whether the main loop of the framework is running.
166 * @return true, if the main loop is running, false otherwise.
168 bool IsMainLoopRunning();
171 * If the main loop aborts unexpectedly, then the connected callback function is called.
172 * @param[in] callBack The function to call.
173 * @note Only one callback can be registered. The last callback to be set will be called on abort.
174 * @note The ownership of callback is passed onto this class.
176 void AddAbortCallback( CallbackBase* callback );
179 * Gets bundle name which was passed in app_reset callback.
181 std::string GetBundleName() const;
184 * Gets bundle id which was passed in app_reset callback.
186 std::string GetBundleId() const;
189 * Gets the path at which application resources are stored.
191 static std::string GetResourcePath();
194 * Sets system language.
196 void SetLanguage( const std::string& language );
199 * Sets system region.
201 void SetRegion( const std::string& region );
204 * Gets system language.
206 std::string GetLanguage() const;
209 * Gets system region.
211 std::string GetRegion() const;
216 Framework(const Framework&);
217 Framework& operator=(Framework&);
222 * Called when the application is created.
227 * Called by the App framework when an application lifecycle event occurs.
228 * @param[in] type The type of event occurred.
229 * @param[in] bundleData The bundle data of event occurred.
231 bool AppStatusHandler(int type, void *bundleData);
234 * Called app_reset callback was called with bundle.
236 void SetBundleName(const std::string& name);
239 * Called app_reset callback was called with bundle.
241 void SetBundleId(const std::string& id);
244 * Called if the application is aborted.
246 void AbortCallback();
249 * Called for initializing on specified backend. (X11 or Wayland)
259 std::string mBundleName;
260 std::string mBundleId;
261 AbortHandler mAbortHandler;
263 private: // impl members
269 } // namespace Adaptor
271 } // namespace Internal
275 #endif // __DALI_INTERNAL_FRAMEWORK_H__