From: Taejeong Lee Date: Tue, 8 Jan 2013 08:00:07 +0000 (+0900) Subject: Change of haptic lib regarding webkit vibration operation. X-Git-Tag: 2.1b_release~22^2~122^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b9a17d2485d624afb71acd9d258ee334fc309df;p=platform%2Fframework%2Fweb%2Fwrt.git Change of haptic lib regarding webkit vibration operation. * 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 --- diff --git a/packaging/wrt.spec b/packaging/wrt.spec index e45a68a..e9e637e 100644 --- a/packaging/wrt.spec +++ b/packaging/wrt.spec @@ -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) diff --git a/src/view/common/CMakeLists.txt b/src/view/common/CMakeLists.txt index 0f704a8..5b9bfc3 100644 --- a/src/view/common/CMakeLists.txt +++ b/src/view/common/CMakeLists.txt @@ -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 diff --git a/src/view/common/view_logic_vibration_support.cpp b/src/view/common/view_logic_vibration_support.cpp index 269598f..8c90818 100644 --- a/src/view/common/view_logic_vibration_support.cpp +++ b/src/view/common/view_logic_vibration_support.cpp @@ -24,12 +24,9 @@ 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(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 diff --git a/src/view/common/view_logic_vibration_support.h b/src/view/common/view_logic_vibration_support.h index bb99940..642288d 100644 --- a/src/view/common/view_logic_vibration_support.h +++ b/src/view/common/view_logic_vibration_support.h @@ -21,6 +21,8 @@ #ifndef VIEW_LOGIC_VIBRATION_SUPPORT_H_ #define VIEW_LOGIC_VIBRATION_SUPPORT_H_ +#include + 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); }; diff --git a/src/view/webkit/CMakeLists.txt b/src/view/webkit/CMakeLists.txt index 16f2b6b..2e3d3c7 100644 --- a/src/view/webkit/CMakeLists.txt +++ b/src/view/webkit/CMakeLists.txt @@ -30,6 +30,7 @@ PKG_CHECK_MODULES(VIEW_MODULE_DEP wrt-popup-wrt-runner security-core security-client + haptic REQUIRED ) diff --git a/src/view/webkit/view_logic.cpp b/src/view/webkit/view_logic.cpp index 16f38cd..8ccfc67 100644 --- a/src/view/webkit/view_logic.cpp +++ b/src/view/webkit/view_logic.cpp @@ -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(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(data); - // temp - // This->m_vibrationSupport->stopVibration(); + This->m_vibrationSupport->stopVibration(); return; }