Change of haptic lib regarding webkit vibration operation.
authorTaejeong Lee <taejeong.lee@samsung.com>
Tue, 8 Jan 2013 08:00:07 +0000 (17:00 +0900)
committerTaejeong Lee <taejeong.lee@samsung.com>
Tue, 8 Jan 2013 09:35:17 +0000 (18:35 +0900)
 * The capi-system-haptic libs was deprecated.
   So it will be replaced to libhaptic.

[Issue#] N/A
[Problem] The capi-system-haptic libs was deprecated.
[Cause] N/A
[Solution] It will be replaced to libhaptic.

Change-Id: I94b1383a30aa3ef534143c90d51c06ed8d05e231

packaging/wrt.spec
src/view/common/CMakeLists.txt
src/view/common/view_logic_vibration_support.cpp
src/view/common/view_logic_vibration_support.h
src/view/webkit/CMakeLists.txt
src/view/webkit/view_logic.cpp

index e45a68a..e9e637e 100644 (file)
@@ -39,7 +39,7 @@ BuildRequires:  pkgconfig(security-client)
 BuildRequires:  pkgconfig(notification)
 BuildRequires:  pkgconfig(libprivilege-control)
 BuildRequires:  pkgconfig(capi-appfw-app-manager)
-BuildRequires:  pkgconfig(capi-system-haptic)
+BuildRequires:  pkgconfig(haptic)
 BuildRequires:  pkgconfig(capi-web-url-download)
 BuildRequires:  pkgconfig(wrt-plugin-loading)
 BuildRequires:  pkgconfig(wrt-plugin-js-overlay)
index 0f704a8..5b9bfc3 100644 (file)
@@ -23,7 +23,7 @@ PKG_CHECK_MODULES(SYS_VIEW_COMMON_DEP
     appsvc
     cert-svc-vcore
     capi-appfw-app-manager
-    capi-system-haptic
+    haptic
     capi-web-url-download
     eina
     elementary
index 269598f..8c90818 100644 (file)
 
 namespace ViewModule {
 
-
-namespace {
-const int WRT_HAPTIC_DEVICE_ID = 0;
-}
-
-VibrationSupport::VibrationSupport(): m_initialized(false)
+VibrationSupport::VibrationSupport(): m_initialized(false),
+                                             m_handle(NULL),
+                                             m_effect_handle(NULL)
 {
 }
 
@@ -47,16 +44,21 @@ void VibrationSupport::initialize(void)
 void VibrationSupport::deinitialize(void)
 {
     LogDebug("deinitialize");
-    int ret = haptic_deinitialize();
-
-    if (HAPTIC_ERROR_NOT_INITIALIZED == ret) {
-        LogDebug("not initialized");
-        m_initialized = false;
-    } else if (HAPTIC_ERROR_NONE == ret) {
-        LogDebug("success");
-        m_initialized = false;
-    } else {
-        LogDebug("deinitialize failed");
+
+    if( m_initialized )
+    {
+        int ret = haptic_close(m_handle);
+
+        if( HAPTIC_ERROR_NONE == ret )
+        {
+            m_initialized = false;
+            LogDebug("deinitialize success");
+        }
+        else
+        {
+            m_initialized = true;
+            LogDebug("deinitialize failed - error code : " << ret);
+        }
     }
 }
 
@@ -64,44 +66,76 @@ void VibrationSupport::startVibration(const long vibrationTime)
 {
     LogDebug("startVibration called");
 
-    if (!m_initialized) {
-        if (!initializeVibration()) {
+    if ( m_initialized == false )
+    {
+        if ( initializeVibration() == false )
+        {
             return;
         }
     }
+
     int time = static_cast<int>(vibrationTime);
-    if (HAPTIC_ERROR_NONE != haptic_vibrate_monotone(WRT_HAPTIC_DEVICE_ID,
-                                                     time,
-                                                     HAPTIC_LEVEL_AUTO))
+    int ret = haptic_vibrate_monotone(m_handle, time, &m_effect_handle);
+
+    if( HAPTIC_ERROR_NONE == ret )
     {
-        LogDebug("haptic_vibrate_monotone failed.");
+        LogDebug("haptic_vibrate_monotone success");
     }
+    else
+    {
+        LogDebug("haptic_vibrate_monotone failed - error code : " << ret);
+    }
+
     return;
 }
 
 void VibrationSupport::stopVibration(void)
 {
     LogDebug("stopVibration called");
-    if (!m_initialized) {
+    if ( m_initialized == false )
+    {
         return;
     }
 
-    if (HAPTIC_ERROR_NONE != haptic_stop_device(WRT_HAPTIC_DEVICE_ID)) {
-        LogDebug("haptic_stop_device failed");
+    int ret = haptic_stop_all_effects(m_handle);
+
+    if( HAPTIC_ERROR_NONE == ret )
+    {
+        LogDebug("haptic_stop_all_effects success");
     }
+    else
+    {
+        LogDebug("haptic_stop_all_effects failed - error code : " << ret);
+    }
+
     return;
 }
 
 bool VibrationSupport::initializeVibration(void)
 {
     LogDebug("initializeVibration called");
-    if (HAPTIC_ERROR_NONE == haptic_initialize()) {
-        m_initialized = true;
-        return true;
-    } else {
-        LogDebug("haptic_initialize failed");
-        return false;
+
+
+    if ( m_initialized == false )
+    {
+        haptic_device_h handle = NULL;
+        int ret = haptic_open(HAPTIC_DEVICE_0, &handle);
+
+        if ( ret == HAPTIC_ERROR_NONE )
+        {
+            LogDebug("initializeVibration success");
+            m_initialized = true;
+            m_handle = handle;
+        }
+        else
+        {
+            LogDebug("initializeVibration failed - error code : " << ret);
+            m_initialized = false;
+            m_handle = NULL;
+        }
     }
+
+    return m_initialized;
 }
 
 } // namespace ViewModule
index bb99940..642288d 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef VIEW_LOGIC_VIBRATION_SUPPORT_H_
 #define VIEW_LOGIC_VIBRATION_SUPPORT_H_
 
+#include <haptic.h>
+
 namespace ViewModule {
 
 class VibrationSupport
@@ -36,6 +38,8 @@ class VibrationSupport
 
   private:
     bool m_initialized;
+    haptic_device_h m_handle;
+    haptic_effect_h m_effect_handle;
 
     bool initializeVibration(void);
 };
index 16f2b6b..2e3d3c7 100644 (file)
@@ -30,6 +30,7 @@ PKG_CHECK_MODULES(VIEW_MODULE_DEP
     wrt-popup-wrt-runner
     security-core
     security-client
+    haptic
     REQUIRED
 )
 
index 16f38cd..8ccfc67 100644 (file)
@@ -150,7 +150,7 @@ ViewLogic::ViewLogic():
     m_cbs(new WRT::UserDelegates),
     m_isBackgroundReload(false),
     m_appsSupport(new ViewModule::AppsSupport()),
-    m_vibrationSupport(),
+    m_vibrationSupport(new ViewModule::VibrationSupport()),
     m_attachedToCustomHandlerDao(false)
 {
 }
@@ -245,8 +245,7 @@ void ViewLogic::hideWidget()
     ViewModule::StorageSupport::deinitializeStorage(m_model);
     m_appsSupport->deinitialize();
 
-    // temp
-    // m_vibrationSupport->deinitialize();
+    m_vibrationSupport->deinitialize();
 
     while (m_ewkViewList.size()) {
         LogInfo("pop webview: " << m_ewkViewList.back());
@@ -497,8 +496,7 @@ void ViewLogic::initializeSupport()
     m_appsSupport->initialize(m_model);
     m_securityOriginSupport.reset(new ViewModule::SecurityOriginSupport(m_model));
 
-    // temp
-    // m_vibrationSupport->initialize();
+    m_vibrationSupport->initialize();
 }
 
 void ViewLogic::initializePluginLoading()
@@ -1608,8 +1606,7 @@ void ViewLogic::vibrationVibrateCallback(
     Assert(eventInfo);
     const long vibrationTime = *(static_cast<const long*>(eventInfo));
 
-    // temp
-    // This->m_vibrationSupport->startVibration(vibrationTime);
+    This->m_vibrationSupport->startVibration(vibrationTime);
 
     return;
 }
@@ -1623,8 +1620,7 @@ void ViewLogic::vibrationCancelCallback(
     Assert(data);
     ViewLogic* This = static_cast<ViewLogic*>(data);
 
-    // temp
-    // This->m_vibrationSupport->stopVibration();
+    This->m_vibrationSupport->stopVibration();
 
     return;
 }