Change to use new AppFW APi for TV profile 17/36317/1
authorsuhyung Eom <suhyung.eom@samsung.com>
Thu, 5 Mar 2015 02:15:54 +0000 (11:15 +0900)
committersuhyung Eom <suhyung.eom@samsung.com>
Thu, 5 Mar 2015 02:16:47 +0000 (11:16 +0900)
Signed-off-by: suhyung Eom <suhyung.eom@samsung.com>
Change-Id: I7f4beddc92824402c49ca3aa408d0ad14e72e8a9

adaptors/common/application-impl.cpp [changed mode: 0644->0755]
adaptors/common/application-impl.h [changed mode: 0644->0755]
adaptors/common/framework.h [changed mode: 0644->0755]
adaptors/public-api/adaptor-framework/application.cpp [changed mode: 0644->0755]
adaptors/public-api/adaptor-framework/application.h [changed mode: 0644->0755]
adaptors/tizen/framework-tizen.cpp [changed mode: 0644->0755]
adaptors/ubuntu/framework-ubuntu.cpp [changed mode: 0644->0755]
packaging/dali-adaptor.spec [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index eac238e..fa34d9c
@@ -74,7 +74,11 @@ Application::Application( int* argc, char** argv[], const std::string& name, con
   mResumeSignal(),
   mResetSignal(),
   mResizeSignal(),
+  mAppControlSignal(),
   mLanguageChangedSignal(),
+  mRegionChangedSignal(),
+  mBatteryLowSignal(),
+  mMemoryLowSignal(),
   mEventLoop( NULL ),
   mFramework( NULL ),
   mCommandLineOptions( NULL ),
@@ -251,11 +255,35 @@ void Application::OnReset()
   mWindow.Raise();
 }
 
+void Application::OnAppControl(void *data)
+{
+  Dali::Application application(this);
+  mAppControlSignal.Emit( application , data );
+}
+
 void Application::OnLanguageChanged()
 {
   mAdaptor->NotifyLanguageChanged();
 }
 
+void Application::OnRegionChanged()
+{
+  Dali::Application application(this);
+  mRegionChangedSignal.Emit( application );
+}
+
+void Application::OnBatteryLow()
+{
+  Dali::Application application(this);
+  mBatteryLowSignal.Emit( application );
+}
+
+void Application::OnMemoryLow()
+{
+  Dali::Application application(this);
+  mMemoryLowSignal.Emit( application );
+}
+
 void Application::OnResize(Dali::Adaptor& adaptor)
 {
   Dali::Application application(this);
old mode 100644 (file)
new mode 100755 (executable)
index 919a7e3..64ce521
@@ -55,6 +55,7 @@ class Application : public BaseObject, public Framework::Observer
 public:
 
   typedef Dali::Application::AppSignalType AppSignalType;
+  typedef Dali::Application::AppControlSignalType AppControlSignalType;
 
   /**
    * Constructor
@@ -168,6 +169,12 @@ public: // From Framework::Observer
   virtual void OnResume();
 
   /**
+  * Called when the framework received AppControlSignal.
+  * @param[in] The bundle data of AppControl event.
+  */
+  virtual void OnAppControl(void *data);
+
+  /**
    * Called when the framework informs the application that it should reset itself.
    */
   virtual void OnReset();
@@ -177,6 +184,21 @@ public: // From Framework::Observer
    */
   virtual void OnLanguageChanged();
 
+  /**
+  * Called when the framework informs the application that the region of the device has changed.
+  */
+  virtual void OnRegionChanged();
+
+  /**
+  * Called when the framework informs the application that the battery level of the device is low.
+  */
+  virtual void OnBatteryLow();
+
+  /**
+  * Called when the framework informs the application that the memory level of the device is low.
+  */
+  virtual void OnMemoryLow();
+
 public:
 
   /**
@@ -213,6 +235,11 @@ public:  // Signals
   Dali::Application::AppSignalType& ResetSignal() { return mResetSignal; }
 
   /**
+  * @copydoc Dali::Application::AppControlSignal()
+  */
+  Dali::Application::AppControlSignalType& AppControlSignal() { return mAppControlSignal; }
+
+  /**
    * @copydoc Dali::Application::ResizeSignal()
    */
   Dali::Application::AppSignalType& ResizeSignal() { return mResizeSignal; }
@@ -222,6 +249,21 @@ public:  // Signals
    */
   Dali::Application::AppSignalType& LanguageChangedSignal() { return mLanguageChangedSignal; }
 
+  /**
+  * @copydoc Dali::Application::RegionChangedSignal()
+  */
+  Dali::Application::AppSignalType& RegionChangedSignal() { return mRegionChangedSignal; }
+
+  /**
+  * @copydoc Dali::Application::BatteryLowSignal()
+  */
+  Dali::Application::AppSignalType& BatteryLowSignal() { return mBatteryLowSignal; }
+
+  /**
+  * @copydoc Dali::Application::MemoryLowSignal()
+  */
+  Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
+
 private:
 
   // Undefined
@@ -252,7 +294,12 @@ private:
   AppSignalType                           mResumeSignal;
   AppSignalType                           mResetSignal;
   AppSignalType                           mResizeSignal;
+  AppControlSignalType                    mAppControlSignal;
   AppSignalType                           mLanguageChangedSignal;
+  AppSignalType                           mRegionChangedSignal;
+  AppSignalType                           mBatteryLowSignal;
+  AppSignalType                           mMemoryLowSignal;
+
 
   EventLoop*                            mEventLoop;
   Framework*                            mFramework;
old mode 100644 (file)
new mode 100755 (executable)
index 19c5d25..4e414ba
@@ -76,9 +76,31 @@ public:
     virtual void OnReset() {}
 
     /**
+    * Invoked when the AppControl message is received.
+    * @param[in] The bundle data of AppControl message.
+    */
+    virtual void OnAppControl(void *) {}
+
+    /**
      * 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:
@@ -140,10 +162,11 @@ private:
 
 private:
   /**
-   * Called by the SLP framework when an application lifecycle event occurs.
+   * 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 SlpAppStatusHandler(int type);
+   bool AppStatusHandler(int type, void *bundleData);
 
   /**
    * Called app_reset callback was called with bundle.
old mode 100644 (file)
new mode 100755 (executable)
index fd3d4cb..89ca011
@@ -181,11 +181,31 @@ Application::AppSignalType& Application::ResizeSignal()
   return Internal::Adaptor::GetImplementation(*this).ResizeSignal();
 }
 
+Application::AppControlSignalType & Application::AppControlSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
+}
+
 Application::AppSignalType& Application::LanguageChangedSignal()
 {
   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
 }
 
+Application::AppSignalType& Application::RegionChangedSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
+}
+
+Application::AppSignalType& Application::BatteryLowSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).BatteryLowSignal();
+}
+
+Application::AppSignalType& Application::MemoryLowSignal()
+{
+  return Internal::Adaptor::GetImplementation(*this).MemoryLowSignal();
+}
+
 Application::Application(Internal::Adaptor::Application* application)
 : BaseHandle(application)
 {
old mode 100644 (file)
new mode 100755 (executable)
index 9e135b8..09408e0
@@ -93,6 +93,7 @@ class DALI_IMPORT_API Application : public BaseHandle
 public:
 
   typedef Signal< void (Application&) > AppSignalType;
+  typedef Signal< void (Application&, void *) > AppControlSignalType;
 
   /**
    * Decides whether a Dali application window is opaque or transparent.
@@ -327,10 +328,33 @@ public:  // Signals
   AppSignalType& ResizeSignal();
 
   /**
+  * This signal is emitted when another application sends a launch request to the application.
+  * When the application is launched, this signal is emitted after the main loop of the application starts up.
+  * The passed parameter describes the launch request and contains the information about why the application is launched.
+  */
+  AppControlSignalType& AppControlSignal();
+
+  /**
    * This signal is emitted when the language is changed on the device.
    */
   AppSignalType& LanguageChangedSignal();
 
+  /**
+  * This signal is emitted when the region of the device is changed.
+  */
+  AppSignalType& RegionChangedSignal();
+
+  /**
+  * This signal is emitted when the battery level of the device is low.
+  */
+  AppSignalType& BatteryLowSignal();
+
+  /**
+  * This signal is emitted when the memory level of the device is low.
+  */
+  AppSignalType& MemoryLowSignal();
+
+
 public: // Not intended for application developers
   /**
    * Internal constructor
old mode 100644 (file)
new mode 100755 (executable)
index 5171324..5cca1cd
@@ -48,7 +48,12 @@ enum
   APP_PAUSE,
   APP_RESUME,
   APP_RESET,
+  APP_CONTROL,
   APP_LANGUAGE_CHANGE,
+  APP_DEVICE_ROTATED,
+  APP_REGION_CHANGED,
+  APP_BATTERY_LOW,
+  APP_MEMORY_LOW
 };
 
 } // Unnamed namespace
@@ -68,17 +73,26 @@ struct Framework::Impl
     mEventCallback.terminate = AppTerminate;
     mEventCallback.pause = AppPause;
     mEventCallback.resume = AppResume;
-#if defined(TIZEN_SDK_2_3)
-    mEventCallback.app_control = AppControl;
-#else
+#ifndef OVER_TIZEN_SDK_2_2
     mEventCallback.service = AppService;
-#endif
+
     mEventCallback.low_memory = NULL;
     mEventCallback.low_battery = NULL;
-    mEventCallback.device_orientation = DeviceRotated;
-    mEventCallback.language_changed = AppLanguageChange;
+    mEventCallback.device_orientation = AppDeviceRotated;
+    mEventCallback.language_changed = AppLanguageChanged;
     mEventCallback.region_format_changed = NULL;
 
+#else
+    mEventCallback.app_control = AppControl;
+
+    ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, AppBatteryLow, data);
+    ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, AppMemoryLow, data);
+    ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, AppDeviceRotated, data);
+    ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, AppLanguageChanged, data);
+    ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, AppRegionChanged, data);
+
+#endif
+
     mCallbackManager = CallbackManager::New();
   }
 
@@ -95,16 +109,21 @@ struct Framework::Impl
   // Data
 
   CallbackBase* mAbortCallBack;
-  app_event_callback_s mEventCallback;
   CallbackManager *mCallbackManager;
-  // Static methods
+
+#ifndef OVER_TIZEN_SDK_2_2
+  app_event_callback_s mEventCallback;
+#else
+  ui_app_lifecycle_callback_s mEventCallback;
+  app_event_handler_h handlers[5];
+#endif
 
   /**
    * Called by AppCore on application creation.
    */
   static bool AppCreate(void *data)
   {
-    return static_cast<Framework*>(data)->SlpAppStatusHandler(APP_CREATE);
+    return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
   }
 
   /**
@@ -112,7 +131,7 @@ struct Framework::Impl
    */
   static void AppTerminate(void *data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_TERMINATE);
+    static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
   }
 
   /**
@@ -120,7 +139,7 @@ struct Framework::Impl
    */
   static void AppPause(void *data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_PAUSE);
+    static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
   }
 
   /**
@@ -128,74 +147,111 @@ struct Framework::Impl
    */
   static void AppResume(void *data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_RESUME);
+    static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
   }
 
+  static void ProcessBundle(Framework* framework, bundle *bundleData)
+  {
+    if(bundleData == NULL)
+    {
+      return;
+    }
+
+    // get bundle name
+    char* bundleName = const_cast<char*>(bundle_get_val(bundleData, "name"));
+    if(bundleName != NULL)
+    {
+      framework->SetBundleName(bundleName);
+    }
+
+    // get bundle id
+    char* bundleId = const_cast<char*>(bundle_get_val(bundleData, "id"));
+    if(bundleId != NULL)
+    {
+      framework->SetBundleId(bundleId);
+    }
+  }
+
+#ifndef OVER_TIZEN_SDK_2_2
   /**
    * Called by AppCore when the application is launched from another module (e.g. homescreen).
    * @param[in] b the bundle data which the launcher module sent
    */
-
-#if defined(TIZEN_SDK_2_3)
-  static void AppControl(app_control_h app_control, void *data)
-#else
   static void AppService(service_h service, void *data)
-#endif
   {
     Framework* framework = static_cast<Framework*>(data);
 
-    if(framework)
+    if(framework == NULL)
     {
-      bundle *bundleData = NULL;
-#if defined(TIZEN_SDK_2_3)
-      app_control_to_bundle(app_control, &bundleData);
-#else
-      service_to_bundle(service, &bundleData);
-#endif
-
-      if(bundleData)
-      {
-        // get bundle name
-        char* bundleName = const_cast<char*>(bundle_get_val(bundleData, "name"));
-        if(bundleName != NULL)
-        {
-          framework->SetBundleName(bundleName);
-        }
-
-        // get bundle id
-        char* bundleId = const_cast<char*>(bundle_get_val(bundleData, "id"));
-        if(bundleId != NULL)
-        {
-          framework->SetBundleId(bundleId);
-        }
-      }
-      framework->SlpAppStatusHandler(APP_RESET);
+      return;
     }
+    bundle *bundleData = NULL;
+
+    service_to_bundle(service, &bundleData);
+    ProcessBundle(framework, bundleData);
+
+    framework->AppStatusHandler(APP_RESET, NULL);
   }
 
-  /**
-   * Called by AppCore when the language changes on the device.
-   */
-  static void AppLanguageChange(void* data)
+  static void AppLanguageChanged(void* user_data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_LANGUAGE_CHANGE);
+    static_cast<Framework*>(user_data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
   }
 
-  static void DeviceRotated(app_device_orientation_e orientation, void *user_data)
+  static void AppDeviceRotated(app_device_orientation_e orientation, void *user_data)
   {
-    switch(orientation)
+    static_cast<Framework*>(user_data)->AppStatusHandler(APP_DEVICE_ROTATED, NULL);
+  }
+
+#else
+
+  /**
+   * Called by AppCore when the application is launched from another module (e.g. homescreen).
+   * @param[in] b the bundle data which the launcher module sent
+   */
+  static void AppControl(app_control_h app_control, void *data)
+  {
+    Framework* framework = static_cast<Framework*>(data);
+    if(framework == NULL)
     {
-      case APP_DEVICE_ORIENTATION_0:
-        break;
-      case APP_DEVICE_ORIENTATION_90:
-        break;
-      case APP_DEVICE_ORIENTATION_180:
-        break;
-      case APP_DEVICE_ORIENTATION_270:
-        break;
+      return;
     }
+    bundle *bundleData = NULL;
+
+    app_control_to_bundle(app_control, &bundleData);
+    ProcessBundle(framework, bundleData);
+
+    framework->AppStatusHandler(APP_RESET, NULL);
+    framework->AppStatusHandler(APP_CONTROL, app_control);
+  }
+
+  static void AppLanguageChanged(app_event_info_h event_info, void *user_data)
+  {
+    static_cast<Framework*>(user_data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
+  }
+
+  static void AppDeviceRotated(app_event_info_h event_info, void *user_data)
+  {
+    static_cast<Framework*>(user_data)->AppStatusHandler(APP_DEVICE_ROTATED, NULL);
+  }
+
+  static void AppRegionChanged(app_event_info_h event_info, void *user_data)
+  {
+    static_cast<Framework*>(user_data)->AppStatusHandler(APP_REGION_CHANGED, NULL);
+  }
+
+  static void AppBatteryLow(app_event_info_h event_info, void *user_data)
+  {
+    static_cast<Framework*>(user_data)->AppStatusHandler(APP_BATTERY_LOW, NULL);
   }
 
+  static void AppMemoryLow(app_event_info_h event_info, void *user_data)
+  {
+    static_cast<Framework*>(user_data)->AppStatusHandler(APP_MEMORY_LOW, NULL);
+  }
+
+#endif
+
 };
 
 Framework::Framework(Framework::Observer& observer, int *argc, char ***argv, const std::string& name)
@@ -228,8 +284,17 @@ void Framework::Run()
 {
   mRunning = true;
 
+#ifndef OVER_TIZEN_SDK_2_2
   app_efl_main(mArgc, mArgv, &mImpl->mEventCallback, this);
 
+#else
+  int ret = ui_app_main(*mArgc, *mArgv, &mImpl->mEventCallback, this);
+  if (ret != APP_ERROR_NONE)
+  {
+    DALI_LOG_ERROR("Framework::Run(), ui_app_main() is failed. err = %d", ret);
+  }
+#endif
+
   mRunning = false;
 }
 
@@ -281,7 +346,7 @@ void Framework::AbortCallback( )
   }
 }
 
-bool Framework::SlpAppStatusHandler(int type)
+bool Framework::AppStatusHandler(int type, void *bundleData)
 {
   switch (type)
   {
@@ -299,24 +364,58 @@ bool Framework::SlpAppStatusHandler(int type)
     }
 
     case APP_RESET:
+    {
       mObserver.OnReset();
       break;
+    }
 
     case APP_RESUME:
+    {
       mObserver.OnResume();
       break;
+    }
 
     case APP_TERMINATE:
-     mObserver.OnTerminate();
+    {
+      mObserver.OnTerminate();
       break;
+    }
 
     case APP_PAUSE:
+    {
       mObserver.OnPause();
       break;
+    }
+
+    case APP_CONTROL:
+    {
+      mObserver.OnAppControl(bundleData);
+      break;
+    }
 
     case APP_LANGUAGE_CHANGE:
+    {
       mObserver.OnLanguageChanged();
       break;
+    }
+
+    case APP_REGION_CHANGED:
+    {
+      mObserver.OnRegionChanged();
+      break;
+    }
+
+    case APP_BATTERY_LOW:
+    {
+      mObserver.OnBatteryLow();
+      break;
+    }
+
+    case APP_MEMORY_LOW:
+    {
+      mObserver.OnMemoryLow();
+      break;
+    }
 
     default:
       break;
old mode 100644 (file)
new mode 100755 (executable)
index 49df4b5..e3832df
@@ -87,7 +87,7 @@ struct Framework::Impl
    */
   static bool AppCreate(void *data)
   {
-    return static_cast<Framework*>(data)->SlpAppStatusHandler(APP_CREATE);
+    return static_cast<Framework*>(data)->AppStatusHandler(APP_CREATE, NULL);
   }
 
   /**
@@ -95,7 +95,7 @@ struct Framework::Impl
    */
   static void AppTerminate(void *data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_TERMINATE);
+    static_cast<Framework*>(data)->AppStatusHandler(APP_TERMINATE, NULL);
   }
 
   /**
@@ -103,7 +103,7 @@ struct Framework::Impl
    */
   static void AppPause(void *data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_PAUSE);
+    static_cast<Framework*>(data)->AppStatusHandler(APP_PAUSE, NULL);
   }
 
   /**
@@ -111,7 +111,7 @@ struct Framework::Impl
    */
   static void AppResume(void *data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_RESUME);
+    static_cast<Framework*>(data)->AppStatusHandler(APP_RESUME, NULL);
   }
 
   /**
@@ -119,7 +119,7 @@ struct Framework::Impl
    */
   static void AppLanguageChange(void* data)
   {
-    static_cast<Framework*>(data)->SlpAppStatusHandler(APP_LANGUAGE_CHANGE);
+    static_cast<Framework*>(data)->AppStatusHandler(APP_LANGUAGE_CHANGE, NULL);
   }
 
 };
@@ -213,7 +213,7 @@ void Framework::AbortCallback( )
   }
 }
 
-bool Framework::SlpAppStatusHandler(int type)
+bool Framework::AppStatusHandler(int type, void *bundleData)
 {
   switch (type)
   {
old mode 100644 (file)
new mode 100755 (executable)
index 2182338..4bdf5bd
@@ -14,27 +14,30 @@ Source0:    %{name}-%{version}.tar.gz
 %define dali_feedback_plugin 0
 %define dali_bullet_plugin 0
 %define dali_assimp_plugin 0
-%endif
+%define over_tizen_2_2 0
 
-%if "%{profile}" == "tv"
+%else if "%{profile}" == "tv"
 %define dali_profile TV
 %define dali_feedback_plugin 0
 %define dali_bullet_plugin 0
 %define dali_assimp_plugin 0
-%endif
+%define over_tizen_2_2 1
 
-%if "%{profile}" == "wearable"
+%else if "%{profile}" == "wearable"
 %define dali_profile WEARABLE
 %define dali_feedback_plugin 0
 %define dali_bullet_plugin 0
 %define dali_assimp_plugin 0
-%endif
+%define over_tizen_2_2 0
 
-%if "%{profile}" == "common"
+%else
+## profile == common
 %define dali_profile COMMON
 %define dali_feedback_plugin 0
 %define dali_bullet_plugin 0
 %define dali_assimp_plugin 0
+%define over_tizen_2_2 0
+
 %endif
 
 Requires(post): /sbin/ldconfig
@@ -162,6 +165,11 @@ CXXFLAGS+=" -DWAYLAND"
 configure_flags="--enable-wayland"
 %endif
 
+%if 0%{?over_tizen_2_2}
+CFLAGS+=" -DOVER_TIZEN_SDK_2_2"
+CXXFLAGS+=" -DOVER_TIZEN_SDK_2_2"
+%endif
+
 libtoolize --force
 cd %{_builddir}/%{name}-%{version}/build/tizen && autoreconf --install
 cd %{_builddir}/%{name}-%{version}/build/tizen && CXXFLAGS=$CXXFLAGS LDFLAGS=$LDFLAGS DALI_DATA_RW_DIR="%{dali_data_rw_dir}" DALI_DATA_RO_DIR="%{dali_data_ro_dir}" FONT_PRELOADED_PATH="%{font_preloaded_path}" FONT_DOWNLOADED_PATH="%{font_downloaded_path}" FONT_APPLICATION_PATH="%{font_application_path}" FONT_CONFIGURATION_FILE="%{font_configuration_file}"