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 <application-devel.h>
24 #include <dali/public-api/signals/callback.h>
25 #ifdef APPCORE_WATCH_AVAILABLE
26 #include "wearable/watch/watch-application.h"
30 #include <abort-handler.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.
54 NORMAL, ///< normal appFramework
55 WATCH, ///< watch appFramework
56 WIDGET ///< widget appFramework
60 * Observer class for the framework.
67 * Invoked when the application is to be initialised.
69 virtual void OnInit() {}
72 * Invoked when the application is to be terminated.
74 virtual void OnTerminate() {}
77 * Invoked when the application is to be paused.
79 virtual void OnPause() {}
82 * Invoked when the application is to be resumed.
84 virtual void OnResume() {}
87 * Invoked when the application is to be reset.
89 virtual void OnReset() {}
92 * Invoked when the AppControl message is received.
93 * @param[in] The bundle data of AppControl message.
95 virtual void OnAppControl(void *) {}
97 #ifdef APPCORE_WATCH_AVAILABLE
99 * Invoked at every second
101 virtual void OnTimeTick(WatchTime&) {}
104 * Invoked at every second in ambient mode
106 virtual void OnAmbientTick(WatchTime&) {}
109 * Invoked when the device enters or exits ambient mode
111 virtual void OnAmbientChanged(bool ambient) {}
115 * Invoked when the language of the device is changed.
117 virtual void OnLanguageChanged( const std::string& language ) {}
120 * Invoked when the region is changed.
122 virtual void OnRegionChanged( const std::string& region ) {}
125 * Invoked when the battery level of the device is low.
127 virtual void OnBatteryLow( Dali::DevelApplication::BatteryStatus::Type status ) {}
130 * Invoked when the memory level of the device is low.
132 virtual void OnMemoryLow( Dali::DevelApplication::MemoryStatus::Type status ) {}
139 * @param[in] observer The observer of the Framework.
140 * @param[in] argc A pointer to the number of arguments.
141 * @param[in] argv A pointer the the argument list.
142 * @param[in] type The type of application
144 Framework( Observer& observer, int* argc, char ***argv, Type type = NORMAL );
154 * Runs the main loop of framework
159 * Quits the main loop
164 * Checks whether the main loop of the framework is running.
165 * @return true, if the main loop is running, false otherwise.
167 bool IsMainLoopRunning();
170 * If the main loop aborts unexpectedly, then the connected callback function is called.
171 * @param[in] callBack The function to call.
172 * @note Only one callback can be registered. The last callback to be set will be called on abort.
173 * @note The ownership of callback is passed onto this class.
175 void AddAbortCallback( CallbackBase* callback );
178 * Gets bundle name which was passed in app_reset callback.
180 std::string GetBundleName() const;
183 * Gets bundle id which was passed in app_reset callback.
185 std::string GetBundleId() const;
188 * Gets the path at which application resources are stored.
190 static std::string GetResourcePath();
195 Framework(const Framework&);
196 Framework& operator=(Framework&);
201 * Called when the application is created.
206 * Called by the App framework when an application lifecycle event occurs.
207 * @param[in] type The type of event occurred.
208 * @param[in] bundleData The bundle data of event occurred.
210 bool AppStatusHandler(int type, void *bundleData);
213 * Called app_reset callback was called with bundle.
215 void SetBundleName(const std::string& name);
218 * Called app_reset callback was called with bundle.
220 void SetBundleId(const std::string& id);
223 * Called if the application is aborted.
225 void AbortCallback();
228 * Called for initializing on specified backend. (X11 or Wayland)
238 std::string mBundleName;
239 std::string mBundleId;
240 AbortHandler mAbortHandler;
242 private: // impl members
248 } // namespace Adaptor
250 } // namespace Internal
254 #endif // __DALI_INTERNAL_FRAMEWORK_H__