[Tizen] Create Widget Application
[platform/core/uifw/dali-adaptor.git] / adaptors / common / framework.h
index fe714c7..36115f2 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_FRAMEWORK_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 // EXTERNAL INCLUDES
 #include <string>
-#include <boost/function.hpp>
+#include <dali/public-api/signals/callback.h>
+#ifdef APPCORE_WATCH_AVAILABLE
+#include "wearable/watch/watch-application.h"
+#endif
 
 // INTERNAL INCLUDES
-#include "abort-handler.h"
+#include <abort-handler.h>
 
 namespace Dali
 {
@@ -35,13 +38,22 @@ namespace Adaptor
 {
 
 /**
- * The Framework class is used to register callbacks with the SLP platform so that
+ * The Framework class is ideally placed to provide key API required by Applications.
+ *
+ * The class is also used to register callbacks with the TIZEN platform so that
  * we know when any of the application lifecycle events occur.  This includes events
  * like when our application is to be initialised, terminated, paused, resumed etc.
+ *
  */
 class Framework
 {
 public:
+  enum Type
+  {
+    NORMAL,       ///<  normal appFramework
+    WATCH,        ///<  watch appFramework
+    WIDGET        ///<  widget appFramework
+  };
 
   /**
    * Observer class for the framework.
@@ -76,9 +88,47 @@ public:
     virtual void OnReset() {}
 
     /**
+    * Invoked when the AppControl message is received.
+    * @param[in] The bundle data of AppControl message.
+    */
+    virtual void OnAppControl(void *) {}
+
+#ifdef APPCORE_WATCH_AVAILABLE
+    /**
+     * Invoked at every second
+     */
+    virtual void OnTimeTick(WatchTime&) {}
+
+    /**
+     * Invoked at every second in ambient mode
+     */
+    virtual void OnAmbientTick(WatchTime&) {}
+
+    /**
+     * Invoked when the device enters or exits ambient mode
+     */
+    virtual void OnAmbientChanged(bool ambient) {}
+#endif
+
+    /**
      * Invoked when the language of the device is changed.
      */
     virtual void OnLanguageChanged() {}
+
+    /**
+    * Invoked when the region is changed.
+    */
+    virtual void OnRegionChanged() {}
+
+    /**
+    * Invoked when the battery level of the device is low.
+    */
+    virtual void OnBatteryLow() {}
+
+    /**
+    * Invoked when the memory level of the device is low.
+    */
+    virtual void OnMemoryLow() {}
   };
 
 public:
@@ -88,8 +138,9 @@ public:
    * @param[in]  observer  The observer of the Framework.
    * @param[in]  argc      A pointer to the number of arguments.
    * @param[in]  argv      A pointer the the argument list.
+   * @param[in]  type      The type of application
    */
-  Framework(Observer& observer, int* argc, char ***argv, const std::string& name);
+  Framework( Observer& observer, int* argc, char ***argv, Type type = NORMAL );
 
   /**
    * Destructor
@@ -118,8 +169,9 @@ public:
    * If the main loop aborts unexpectedly, then the connected callback function is called.
    * @param[in]  callBack  The function to call.
    * @note Only one callback can be registered.  The last callback to be set will be called on abort.
+   * @note The ownership of callback is passed onto this class.
    */
-  void AddAbortCallback(boost::function<void(void)> callBack);
+  void AddAbortCallback( CallbackBase* callback );
 
   /**
    * Gets bundle name which was passed in app_reset callback.
@@ -131,6 +183,11 @@ public:
    */
   std::string GetBundleId() const;
 
+  /**
+   *  Gets the path at which application resources are stored.
+   */
+  static std::string GetResourcePath();
+
 private:
 
   // Undefined
@@ -138,11 +195,18 @@ private:
   Framework& operator=(Framework&);
 
 private:
+
   /**
-   * Called by the SLP framework when an application lifecycle event occurs.
-   * @param[in]  type  The type of event occurred.
+   * Called when the application is created.
    */
-  bool SlpAppStatusHandler(int type);
+  bool Create();
+
+  /**
+   * Called by the App framework when an application lifecycle event occurs.
+   * @param[in] type The type of event occurred.
+   * @param[in] bundleData The bundle data of event occurred.
+   */
+  bool AppStatusHandler(int type, void *bundleData);
 
   /**
    * Called app_reset callback was called with bundle.
@@ -170,7 +234,6 @@ private:
   bool               mRunning;
   int*               mArgc;
   char***            mArgv;
-  std::string        mName;
   std::string        mBundleName;
   std::string        mBundleId;
   AbortHandler       mAbortHandler;
@@ -179,7 +242,6 @@ private: // impl members
 
   struct Impl;
   Impl* mImpl;
-
 };
 
 } // namespace Adaptor