1 #ifndef DALI_INTERNAL_FRAMEWORK_H
2 #define DALI_INTERNAL_FRAMEWORK_H
5 * Copyright (c) 2019 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 ) {}
136 * Invoked when the platform surface is created.
138 virtual void OnSurfaceCreated( Any newSurface ) {}
141 * Invoked when the platform surface is destroyed.
143 virtual void OnSurfaceDestroyed( Any newSurface ) {}
150 * @param[in] observer The observer of the Framework.
151 * @param[in] argc A pointer to the number of arguments.
152 * @param[in] argv A pointer the the argument list.
153 * @param[in] type The type of application
155 Framework( Observer& observer, int* argc, char ***argv, Type type = NORMAL );
165 * Runs the main loop of framework
170 * Quits the main loop
175 * Checks whether the main loop of the framework is running.
176 * @return true, if the main loop is running, false otherwise.
178 bool IsMainLoopRunning();
181 * If the main loop aborts unexpectedly, then the connected callback function is called.
182 * @param[in] callBack The function to call.
183 * @note Only one callback can be registered. The last callback to be set will be called on abort.
184 * @note The ownership of callback is passed onto this class.
186 void AddAbortCallback( CallbackBase* callback );
189 * Gets bundle name which was passed in app_reset callback.
191 std::string GetBundleName() const;
194 * Gets bundle id which was passed in app_reset callback.
196 std::string GetBundleId() const;
199 * Sets a command line options.
200 * This is used in case of the preinitialized application.
201 * @param[in] argc A pointer to the number of arguments
202 * @param[in] argv A pointer to the argument list
204 void SetCommandLineOptions( int* argc, char **argv[] )
212 * Gets the path at which application resources are stored.
214 static std::string GetResourcePath();
217 * Gets the path at which application data are stored.
219 static std::string GetDataPath();
222 * Sets system language.
224 void SetLanguage( const std::string& language );
227 * Sets system region.
229 void SetRegion( const std::string& region );
232 * Gets system language.
234 std::string GetLanguage() const;
237 * Gets system region.
239 std::string GetRegion() const;
242 * Called by the App framework when an application lifecycle event occurs.
243 * @param[in] type The type of event occurred.
244 * @param[in] data The data of event occurred.
246 bool AppStatusHandler(int type, void* data);
249 * Called by the adaptor when an idle callback is added.
250 * @param[in] timeout The timeout of the callback.
251 * @param[in] data The data of of the callback.
252 * @param[in] callback The callback.
253 * @return The callback id.
255 unsigned int AddIdle( int timeout, void* data, bool ( *callback )( void *data ) );
258 * Called by the adaptor when an idle callback is removed.
259 * @param[in] id The callback id.
261 void RemoveIdle( unsigned int id );
266 Framework(const Framework&);
267 Framework& operator=(Framework&);
272 * Called when the application is created.
277 * Called app_reset callback was called with bundle.
279 void SetBundleName(const std::string& name);
282 * Called app_reset callback was called with bundle.
284 void SetBundleId(const std::string& id);
287 * Called if the application is aborted.
289 void AbortCallback();
292 * Called for initializing on specified backend. (X11 or Wayland)
303 std::string mBundleName;
304 std::string mBundleId;
305 AbortHandler mAbortHandler;
307 private: // impl members
313 } // namespace Adaptor
315 } // namespace Internal
319 #endif // DALI_INTERNAL_FRAMEWORK_H