From 4f62bcdde8631fb6acd9797206a53797d2f3a445 Mon Sep 17 00:00:00 2001 From: Hyejin Kim Date: Fri, 16 Nov 2012 14:05:55 +0900 Subject: [PATCH] support haptic --- setting-profile/CMakeLists.txt | 2 +- .../include/setting-profile-sound-main.h | 6 - setting-profile/include/setting-profile.h | 17 +- setting-profile/src/setting-profile-sound-main.c | 342 ++++++++++++++++++--- setting-profile/src/setting-profile.c | 231 +++++++++++--- 5 files changed, 511 insertions(+), 87 deletions(-) diff --git a/setting-profile/CMakeLists.txt b/setting-profile/CMakeLists.txt index 38e67b4..c752534 100755 --- a/setting-profile/CMakeLists.txt +++ b/setting-profile/CMakeLists.txt @@ -3,7 +3,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/${SETTING_COMMON}/include) INCLUDE(FindPkgConfig) -pkg_check_modules(pkgs_profile REQUIRED ecore ecore-file evas elementary appcore-common appcore-efl devman_haptic ui-gadget-1 capi-appfw-application vconf capi-media-player capi-media-sound-manager dlog svi devman capi-system-device capi-system-haptic) +pkg_check_modules(pkgs_profile REQUIRED ecore ecore-file evas elementary utilX appcore-common appcore-efl haptic ui-gadget-1 capi-appfw-application vconf capi-media-player capi-media-sound-manager dlog svi devman capi-system-device FOREACH(flag ${pkgs_profile_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/setting-profile/include/setting-profile-sound-main.h b/setting-profile/include/setting-profile-sound-main.h index e90d241..1aaaf67 100755 --- a/setting-profile/include/setting-profile-sound-main.h +++ b/setting-profile/include/setting-profile-sound-main.h @@ -23,7 +23,6 @@ #include -#define SETTING_SOUND_VIB_TYPE_LEN 5 #define SETTING_SOUND_REPEAT_TYPE_LEN 4 #define SETTING_SOUND_VOLUME_TIMER_INTERVAL 0.2 @@ -39,11 +38,6 @@ #define SETTING_SOUND_TEXT_SYSTEM "IDS_COM_BODY_SYSTEM" #define SETTING_SOUND_TEXT_MEDIA "IDS_COM_BODY_MEDIA" -#define SETTING_SOUND_TEXT_REPEAT_ONCE "IDS_ST_BODY_ONCE" -#define SETTING_SOUND_TEXT_REPEAT_2MIN "IDS_ST_BODY_EVERY_2MIN" -#define SETTING_SOUND_TEXT_REPEAT_5MIN "IDS_ST_BODY_EVERY_5MIN" -#define SETTING_SOUND_TEXT_REPEAT_10MIN "IDS_ST_BODY_EVERY_10MINUTES" - #define SETTING_SOUND_TEXT_CALL_RINGTONE "IDS_ST_BODY_INCOMING_CALL_RINGTONE" #define SETTING_SOUND_TEXT_CALL_VIBRATION "IDS_ST_BODY_INCOMING_CALL_VIBRATION" diff --git a/setting-profile/include/setting-profile.h b/setting-profile/include/setting-profile.h index 990213d..fe94f8d 100755 --- a/setting-profile/include/setting-profile.h +++ b/setting-profile/include/setting-profile.h @@ -30,18 +30,25 @@ #include #include -#include +#include #include #include #include #include -#define MIGRATION_HAPTIC 0 +#define MIGRATION_HAPTIC 1 #define HAPTIC_TEST_ITERATION 1 #define VOLUME_DEN (15.0) /* ie equals float(SETTING_SOUND_VOL_MAX) */ +#define SETTING_SOUND_TEXT_REPEAT_ONCE "IDS_ST_BODY_ONCE" +#define SETTING_SOUND_TEXT_REPEAT_2MIN "IDS_ST_BODY_EVERY_2MIN" +#define SETTING_SOUND_TEXT_REPEAT_5MIN "IDS_ST_BODY_EVERY_5MIN" +#define SETTING_SOUND_TEXT_REPEAT_10MIN "IDS_ST_BODY_EVERY_10MINUTES" + +#define SETTING_SOUND_REPEAT_TYPE_LEN 4 + typedef enum { SETTING_PROF_VIEW_VOL = 0, SETTING_PROF_VIEW_RTN, @@ -79,10 +86,12 @@ typedef enum { #define SETTING_DEFAULT_NOTI_VIB_INT 5 #define SETTING_DEFAULT_HAPTIC_VIB_INT 3 #define SETTING_DEFAULT_ALERT_REPEAT_TYPE_INT 0 +#define SETTING_SOUND_VIB_TYPE_LEN 5 #define SETTING_DEFAULT_RINGTONE_PATH "/opt/share/settings/Ringtones" #define SETTING_DEFAULT_ALERT_PATH "/opt/share/settings/Alerts" #define SETTING_PROFILE_MMC_PATH "/opt/storage/sdcard/" +#define SETTING_DEFAULT_VIB_PATH "/usr/share/svi/haptic/default/" #define DELIM "/" @@ -140,11 +149,13 @@ struct _SettingProfileUG { Ecore_Timer *volume_timer; setting_volume_types cur_vol_type; - int hnd_hpt; + haptic_device_h hnd_hpt; int playing_volume; char *song_playing; char *ringtone_type; + Ecore_Event_Handler *event_handler; + /* Ringtone tab */ Setting_GenGroupItem_Data *data_call_alert_tone; Setting_GenGroupItem_Data *data_call_alert_vib; diff --git a/setting-profile/src/setting-profile-sound-main.c b/setting-profile/src/setting-profile-sound-main.c index aeee6d0..90e8d82 100755 --- a/setting-profile/src/setting-profile-sound-main.c +++ b/setting-profile/src/setting-profile-sound-main.c @@ -25,6 +25,13 @@ #define SOUND_DESC "IDS_ST_BODY_ADJUST_VOLUME_AND_INTENSITY_FOR_SOUNDS_WHEN_MSG" +char *repeat_type[SETTING_SOUND_REPEAT_TYPE_LEN] = { + SETTING_SOUND_TEXT_REPEAT_ONCE, + SETTING_SOUND_TEXT_REPEAT_2MIN, + SETTING_SOUND_TEXT_REPEAT_5MIN, + SETTING_SOUND_TEXT_REPEAT_10MIN + }; + static int setting_profile_sound_main_create(void *cb); static int setting_profile_sound_main_destroy(void *cb); static int setting_profile_sound_main_update(void *cb); @@ -113,18 +120,21 @@ void __sound_sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info) elm_genlist_item_update(data_parentItem->item); } -#if MIGRATION_HAPTIC if (data_parentItem->int_slp_setting_binded == INT_SLP_SETTING_CALL_ALERT_VIB) { - if (device_haptic_stop_play(ad->hnd_hpt) != 0) { - SETTING_TRACE("ERROR device_haptic_stop_play"); + if(ad->hnd_hpt < 0) + { + SETTING_TRACE_DEBUG("[ERROR] Can't use haptic handle."); + return; + } + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); /* return; */ } setting_profile_play_vibration(ad, setting_profile_get_call_playing_vib_by_vconf_value (data_subItem->chk_status)); } -#endif } static void __sound_exp_cb(void *data, Evas_Object *obj, void *event_info) @@ -182,7 +192,7 @@ static void __sound_exp_cb(void *data, Evas_Object *obj, void *event_info) ad, parentItem, SWALLOW_Type_1RADIO, rgd, 0, - SETTING_SOUND_TEXT_REPEAT_ONCE, + _(SETTING_SOUND_TEXT_REPEAT_ONCE), NULL); setting_create_Gendial_exp_sub_field(scroller, @@ -191,7 +201,7 @@ static void __sound_exp_cb(void *data, Evas_Object *obj, void *event_info) ad, parentItem, SWALLOW_Type_1RADIO, rgd, 1, - SETTING_SOUND_TEXT_REPEAT_2MIN, + _(SETTING_SOUND_TEXT_REPEAT_2MIN), NULL); setting_create_Gendial_exp_sub_field(scroller, @@ -200,7 +210,7 @@ static void __sound_exp_cb(void *data, Evas_Object *obj, void *event_info) ad, parentItem, SWALLOW_Type_1RADIO, rgd, 2, - SETTING_SOUND_TEXT_REPEAT_5MIN, + _(SETTING_SOUND_TEXT_REPEAT_5MIN), NULL); setting_create_Gendial_exp_sub_field(scroller, &(ad->itc_1icon_1text_sub), @@ -208,7 +218,7 @@ static void __sound_exp_cb(void *data, Evas_Object *obj, void *event_info) ad, parentItem, SWALLOW_Type_1RADIO, rgd, 3, - SETTING_SOUND_TEXT_REPEAT_10MIN, + _(SETTING_SOUND_TEXT_REPEAT_10MIN), NULL); setting_update_chk_status(rgd, @@ -275,6 +285,46 @@ void __system_start_change_cb(void *data, Evas_Object *obj, void *event_info) setting_profile_close_other_mm_players_but_type(ad, SOUND_TYPE_SYSTEM); } +void __noti_vib_start_change_cb(void *data, Evas_Object *obj, void *event_info) +{ + ret_if(data == NULL); + + Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data; + SettingProfileUG *ad = list_item->userdata; + + ad->cur_vol_type = SETTING_VOL_TYPE_NOTI_VIB; + setting_profile_close_all_mm_players(ad); + + int err = 0; + char pattern_file[MAX_COMMON_BUFFER_LEN] = {0,}; + svi_get_path(SVI_TYPE_VIB, SVI_VIB_NOTIFICATION_GENERAL, pattern_file, MAX_COMMON_BUFFER_LEN); + haptic_stop_all_effects(ad->hnd_hpt); + err = haptic_vibrate_file_with_detail(ad->hnd_hpt, pattern_file, 1, list_item->chk_status * SETTING_VIB_FEEDBACK_RATE, HAPTIC_PRIORITY_MIN, NULL); + if (err < 0) + SETTING_TRACE("Failed to play haptic monotone"); +} + +void __haptic_vib_start_change_cb(void *data, Evas_Object *obj, void *event_info) + { + SETTING_TRACE_BEGIN; + ret_if(data == NULL); + + Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data; + SettingProfileUG *ad = list_item->userdata; + + ad->cur_vol_type = SETTING_VOL_TYPE_HAPTIC_VIB; + setting_profile_close_all_mm_players(ad); + + int err = 0; + char pattern_file[MAX_COMMON_BUFFER_LEN] = {0,}; + svi_get_path(SVI_TYPE_VIB, SVI_VIB_OPERATION_VIBRATION, pattern_file, MAX_COMMON_BUFFER_LEN); + haptic_stop_all_effects(ad->hnd_hpt); + err = haptic_vibrate_file_with_detail(ad->hnd_hpt, pattern_file, 1, list_item->chk_status * SETTING_VIB_FEEDBACK_RATE, HAPTIC_PRIORITY_MIN, NULL); + + if (err < 0) + SETTING_TRACE("Failed to play haptic monotone"); +} + void __volume_stop_change_cb(void *data, Evas_Object *obj, void *event_info) { SETTING_TRACE_BEGIN; @@ -364,6 +414,51 @@ void __volume_stop_change_cb(void *data, Evas_Object *obj, void *event_info) SETTING_TRACE_END; } +void __vibration_stop_change_cb(void *data, Evas_Object *obj, void *event_info) +{ + ret_if(data == NULL); + + Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data; + SettingProfileUG *ad = list_item->userdata; + + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); + /* return; */ + } + + double value = 0.0; + switch(ad->cur_vol_type) + { + case SETTING_VOL_TYPE_NOTI_VIB: + if(ad->data_vib_volume) + { + value = elm_slider_value_get(ad->data_vib_volume->eo_check); + vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, (unsigned int)(value+0.5)); + if(value < 0.5) + elm_slider_value_set(ad->data_vib_volume->eo_check, 0); + else + elm_slider_value_set(ad->data_vib_volume->eo_check, (unsigned int)(value+0.5)); + } + break; + case SETTING_VOL_TYPE_HAPTIC_VIB: + if(ad->data_touch_vib) + { + value = elm_slider_value_get(ad->data_touch_vib->eo_check); + vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, (unsigned int)(value+0.5)); + vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_BAK_INT, (unsigned int)(value+0.5)); + if(value < 0.5) + elm_slider_value_set(ad->data_touch_vib->eo_check, 0); + else + elm_slider_value_set(ad->data_touch_vib->eo_check, (unsigned int)(value+0.5)); + } + break; + default: + break; + } + ad->cur_vol_type = SETTING_VOL_TYPE_MAX; + SETTING_TRACE_END; +} + static void __main_list_unrealized_cb(void *data, Evas_Object *obj, void *event_info) { SETTING_TRACE_BEGIN; @@ -384,6 +479,10 @@ static void __main_list_unrealized_cb(void *data, Evas_Object *obj, void *event_ sound_manager_set_volume(SOUND_TYPE_MEDIA, ad->data_media_volume->chk_status); else if(list_item == ad->data_touch_volume) sound_manager_set_volume(SOUND_TYPE_SYSTEM, ad->data_touch_volume->chk_status); + else if(list_item == ad->data_vib_volume) + vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, ad->data_vib_volume->chk_status); + else if(list_item == ad->data_touch_vib) + vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, ad->data_touch_vib->chk_status); } static Evas_Object *__get_main_list(void *data) @@ -424,6 +523,21 @@ static Evas_Object *__get_main_list(void *data) } else { SETTING_TRACE_ERROR("ad->data_sound is NULL"); } + /* b.use vib */ + if (vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vconf_value) < 0) + vconf_value = TRUE; /* default value of vibration : on */ + ad->data_vibration = + setting_create_Gendial_field_def(genlist, &(ad->itc_1text_1icon), + setting_profile_sound_main_mouse_up_Gendial_list_cb, + ad, SWALLOW_Type_1TOGGLE, NULL, + NULL, vconf_value, + SETTING_SOUND_TEXT_VIBRATION, NULL, + setting_profile_sound_main_Gendial_chk_cb); + if (ad->data_vibration) { + ad->data_vibration->userdata = ad; + } else { + SETTING_TRACE_ERROR("ad->data_vibration is NULL"); + } (void)setting_create_Gendial_field_titleItem(genlist, &(ad->itc_group_item), @@ -531,6 +645,68 @@ static Evas_Object *__get_main_list(void *data) SETTING_TRACE_ERROR("ad->data_touch_volume is NULL"); } + (void)setting_create_Gendial_field_titleItem(genlist, + &(ad->itc_group_item), + "IDS_ST_BODY_CALLALERTTYPE_VIBRATION", NULL); + + /* f.noti vib */ + if (vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &vconf_value) < 0) + vconf_value = SETTING_DEFAULT_NOTI_VIB_INT; /* default value of notification vibration volume : 5 */ + + ad->data_vib_volume = + setting_create_Gendial_field_def(genlist, &(ad->itc_layout), NULL, + NULL, + SWALLOW_Type_LAYOUT_SLIDER, + IMG_VIBRATION_ICON_01, + IMG_VIBRATION_ICON_02, vconf_value, + SETTING_SOUND_TEXT_NOTIFICATION, + NULL, + setting_profile_sound_main_vib_sound_slider_value_change_cb); + if (ad->data_vib_volume) { + ad->data_vib_volume->win_main = ad->win_main_layout; + ad->data_vib_volume->evas = ad->evas; + ad->data_vib_volume->isIndicatorVisible = true; + ad->data_vib_volume->slider_min = 0; + ad->data_vib_volume->slider_max = SETTING_VIB_VOL_MAX; + ad->data_vib_volume->userdata = ad; + ad->data_vib_volume->start_change_cb = __noti_vib_start_change_cb; + ad->data_vib_volume->stop_change_cb = __vibration_stop_change_cb; + ad->data_vib_volume->belongs_to = SETTING_VOL_VIBRATION_GROUP; + } else { + SETTING_TRACE_ERROR("ad->data_vib_volume is NULL"); + } + + /* i.haptic vib */ + if (vconf_get_int + (VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, &vconf_value) < 0) + vconf_value = SETTING_DEFAULT_HAPTIC_VIB_INT; /* default value of haptic vibration volume : 3 */ + + ad->data_touch_vib = + setting_create_Gendial_field_def(genlist, &(ad->itc_layout), NULL, + NULL, + SWALLOW_Type_LAYOUT_SLIDER, + IMG_VIBRATION_ICON_01, + IMG_VIBRATION_ICON_02, vconf_value, + "IDS_ST_BODY_SOUNDFEEDBACK_HAPTIC_FEEDBACK", NULL, + setting_profile_sound_main_touchVib_sound_slider_value_change_cb); + if (ad->data_touch_vib) { + ad->data_touch_vib->win_main = ad->win_main_layout; + ad->data_touch_vib->evas = ad->evas; + ad->data_touch_vib->isIndicatorVisible = true; + ad->data_touch_vib->slider_min = 0; + ad->data_touch_vib->slider_max = SETTING_VIB_VOL_MAX; + ad->data_touch_vib->userdata = ad; + ad->data_touch_vib->start_change_cb = __haptic_vib_start_change_cb; + ad->data_touch_vib->stop_change_cb = __vibration_stop_change_cb; + ad->data_touch_vib->belongs_to = SETTING_VOL_VIBRATION_GROUP; + } else { + SETTING_TRACE_ERROR("ad->data_touch_vib is NULL"); + } + + setting_create_Gendial_field_def(genlist, &(ad->itc_bg_1icon), + NULL, ad, + SWALLOW_Type_LAYOUT_SPECIALIZTION_X, + NULL, NULL, 0, SOUND_DESC, NULL, NULL); elm_genlist_item_select_mode_set(elm_genlist_item_append(genlist, &(itc_seperator), NULL, NULL,ELM_GENLIST_ITEM_NONE, NULL, NULL), ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); @@ -621,12 +797,6 @@ static Evas_Object *__get_ringtone_list(void *data) SETTING_SOUND_TEXT_NOTIFICATION, NULL); - char *repeat_type[SETTING_SOUND_REPEAT_TYPE_LEN] = { - _(SETTING_SOUND_TEXT_REPEAT_ONCE), - _(SETTING_SOUND_TEXT_REPEAT_2MIN), - _(SETTING_SOUND_TEXT_REPEAT_5MIN), - _(SETTING_SOUND_TEXT_REPEAT_10MIN) - }; int repeat_value = 0; /* b-1. msg ringtone */ @@ -665,7 +835,7 @@ static Evas_Object *__get_ringtone_list(void *data) setting_profile_sound_main_mouse_up_Gendial_list_cb, ad, SWALLOW_Type_INVALID, SETTING_SOUND_TEXT_MSG_RINGTONE_REPEAT, - repeat_type[repeat_value]); + _(repeat_type[repeat_value])); if (ad->data_msg_alert_repeat) { ad->data_msg_alert_repeat->int_slp_setting_binded = INT_SLP_SETTING_MSG_ALERT_REPEAT; @@ -710,7 +880,7 @@ static Evas_Object *__get_ringtone_list(void *data) setting_profile_sound_main_mouse_up_Gendial_list_cb, ad, SWALLOW_Type_INVALID, SETTING_SOUND_TEXT_EMAIL_RINGTONE_REPEAT, - repeat_type[repeat_value]); + _(repeat_type[repeat_value])); if (ad->data_email_alert_repeat) { ad->data_email_alert_repeat->int_slp_setting_binded = INT_SLP_SETTING_EMAIL_ALERT_REPEAT; @@ -736,12 +906,10 @@ static void __view_change_cb(void *data, Evas_Object *obj, void *event_info) SettingProfileUG *ad = (SettingProfileUG *) data; -#if MIGRATION_HAPTIC - if (device_haptic_stop_play(ad->hnd_hpt) != 0) { - SETTING_TRACE("ERROR device_haptic_stop_play"); + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); /* return; */ } -#endif setting_profile_close_all_mm_players(ad); Evas_Object *sub_view = NULL; @@ -750,6 +918,8 @@ static void __view_change_cb(void *data, Evas_Object *obj, void *event_info) ret_if(!tab_lable); //SETTING_TRACE("tab_lable:%s", tab_lable); if (0 == safeStrCmp(tab_lable, VOLUME_STR)) { + if(ad->hnd_hpt) + haptic_stop_all_effects(ad->hnd_hpt); sub_view = __get_main_list(ad); } else if (0 == safeStrCmp(tab_lable, RINGTONE_STR)) { sub_view = __get_ringtone_list(ad); @@ -894,13 +1064,12 @@ setting_profile_sound_main_click_softkey_cancel_cb(void *data, /* close mm plaer */ setting_profile_close_all_mm_players(ad); -#if MIGRATION_HAPTIC /* close vibration */ - if (device_haptic_stop_play(ad->hnd_hpt) != 0) { - SETTING_TRACE("ERROR device_haptic_stop_play"); + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); /* return; */ } -#endif + /* Send destroy request */ ug_destroy_me(ad->ug); @@ -1106,9 +1275,7 @@ setting_profile_sound_main_Gendial_chk_cb(void *data, Evas_Object *obj, setting_disable_genlist_item(ad->data_media_volume->item); setting_disable_genlist_item(ad->data_touch_volume->item); } - } -#if MIGRATION_HAPTIC - else if (!safeStrCmp(SETTING_SOUND_TEXT_VIBRATION, list_item->keyStr)) { + } else if (!safeStrCmp(SETTING_SOUND_TEXT_VIBRATION, list_item->keyStr)) { if (vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, list_item->chk_status) < 0) { list_item->chk_status = !state; elm_check_state_set(list_item->eo_check, list_item->chk_status); @@ -1121,20 +1288,20 @@ setting_profile_sound_main_Gendial_chk_cb(void *data, Evas_Object *obj, int err = 0; char pattern_file[MAX_COMMON_BUFFER_LEN] = {0,}; svi_get_path(SVI_TYPE_VIB, SVI_VIB_NOTIFICATION_GENERAL, pattern_file, sizeof(pattern_file)); - device_haptic_stop_play(ad->hnd_hpt); - err = device_haptic_play_file(ad->hnd_hpt, pattern_file, 1, (int)(elm_slider_value_get(ad->data_vib_volume->eo_check)+0.5)); + haptic_stop_all_effects(ad->hnd_hpt); + err = haptic_vibrate_file_with_detail(ad->hnd_hpt, pattern_file, 1, (int)(elm_slider_value_get(ad->data_vib_volume->eo_check)+0.5) * SETTING_VIB_FEEDBACK_RATE, HAPTIC_PRIORITY_MIN, NULL); if (err < 0) SETTING_TRACE("Failed to play haptic monotone"); } else { - if (device_haptic_stop_play(ad->hnd_hpt) != 0) { - SETTING_TRACE("ERROR device_haptic_stop_play"); + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); } setting_disable_genlist_item(ad->data_vib_volume->item); setting_disable_genlist_item(ad->data_touch_vib->item); } } -#endif + /* additional items */ else if (!safeStrCmp(SETTING_SOUND_TEXT_LOCK_SOUND, list_item->keyStr)) { if (vconf_set_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, list_item->chk_status) < 0) { @@ -1169,10 +1336,8 @@ setting_profile_sound_main_mouse_up_Gendial_list_cb(void *data, SettingProfileUG *ad = data; -#if MIGRATION_HAPTIC if(ad->hnd_hpt) - device_haptic_stop_play(ad->hnd_hpt); -#endif + haptic_stop_all_effects(ad->hnd_hpt); SETTING_TRACE("clicking item[%s]", _(list_item->keyStr)); if (!safeStrCmp(SETTING_SOUND_TEXT_CALL_RINGTONE, list_item->keyStr) @@ -1200,6 +1365,34 @@ setting_profile_sound_main_mouse_up_Gendial_list_cb(void *data, } } return; + } else if (!safeStrCmp(SETTING_SOUND_TEXT_VIBRATION, list_item->keyStr)) { + int old_status = elm_check_state_get(list_item->eo_check); + if (vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, !old_status) == 0) { + /* new status */ + list_item->chk_status = !old_status; + elm_check_state_set(list_item->eo_check, list_item->chk_status); + if (list_item->chk_status) { + setting_enable_genlist_item(ad->data_vib_volume->item); + setting_enable_genlist_item(ad->data_touch_vib->item); + + /* Play vib if vib turns on */ + int err = 0; + char pattern_file[MAX_COMMON_BUFFER_LEN] = {0,}; + svi_get_path(SVI_TYPE_VIB, SVI_VIB_NOTIFICATION_GENERAL, pattern_file, sizeof(pattern_file)); + haptic_stop_all_effects(ad->hnd_hpt); + err = haptic_vibrate_file_with_detail(ad->hnd_hpt, pattern_file, 1, (int)(elm_slider_value_get(ad->data_vib_volume->eo_check)+0.5) * SETTING_VIB_FEEDBACK_RATE, HAPTIC_PRIORITY_MIN, NULL); + + if (err < 0) + SETTING_TRACE("Failed to play haptic monotone"); + } else { + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); + } + setting_disable_genlist_item(ad->data_vib_volume->item); + setting_disable_genlist_item(ad->data_touch_vib->item); + } + } + return; } else if (!safeStrCmp("IDS_ST_BODY_TOUCH_SOUNDS", list_item->keyStr)) { int old_status = elm_check_state_get(list_item->eo_check); @@ -1237,7 +1430,7 @@ setting_profile_sound_main_call_ringtone_sound_slider_value_change_cb(void *data if(list_item->chk_status != (int)(val+0.5)) { list_item->chk_status = (int)(val+0.5); - sound_manager_set_volume(SOUND_TYPE_RINGTONE, (unsigned int)list_item->chk_status); + sound_manager_set_volume(SOUND_TYPE_RINGTONE, list_item->chk_status); SETTING_TRACE_DEBUG("ringtone volume is %d, %f", list_item->chk_status, val); } } @@ -1261,7 +1454,7 @@ setting_profile_sound_main_noti_sound_slider_value_change_cb(void *data, if(list_item->chk_status != (int)(val+0.5)) { list_item->chk_status = val; - sound_manager_set_volume(SOUND_TYPE_NOTIFICATION, (unsigned int)list_item->chk_status); + sound_manager_set_volume(SOUND_TYPE_NOTIFICATION, list_item->chk_status); SETTING_TRACE_DEBUG("notification volume is %d, %f", list_item->chk_status, val); } } @@ -1284,7 +1477,7 @@ setting_profile_sound_main_media_sound_slider_value_change_cb(void *data, if(list_item->chk_status != (int)(val+0.5)) { list_item->chk_status = val; - sound_manager_set_volume(SOUND_TYPE_MEDIA, (unsigned int)list_item->chk_status); + sound_manager_set_volume(SOUND_TYPE_MEDIA, list_item->chk_status); SETTING_TRACE_DEBUG("media volume is %d, %f", list_item->chk_status, val); } } @@ -1308,8 +1501,79 @@ settings_profile_sound_main_sys_sound_slider_value_change_cb(void *data, if(list_item->chk_status != (int)(val+0.5)) { list_item->chk_status = val; - sound_manager_set_volume(SOUND_TYPE_SYSTEM, (unsigned int)list_item->chk_status); + sound_manager_set_volume(SOUND_TYPE_SYSTEM, list_item->chk_status); SETTING_TRACE_DEBUG("system volume is %d, %f", list_item->chk_status, val); } } +static void +setting_profile_sound_main_vib_sound_slider_value_change_cb(void *data, + Evas_Object *obj, + void *event_info) +{ + /* error check */ + ret_if(data == NULL); + + static double priv_val_db = 5.0; + static int priv_val_int = 0; + double val = elm_slider_value_get(obj); + SETTING_TRACE("val = %f", val); + Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data; + SettingProfileUG *ad = list_item->userdata; + + int value; + int err; + + value = (int)(val + 0.5); /* to sync displayed value on slider */ + list_item->chk_status = value; + if (value != priv_val_int) { + vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, list_item->chk_status); + char pattern_file[MAX_COMMON_BUFFER_LEN] = {0,}; + svi_get_path(SVI_TYPE_VIB, SVI_VIB_NOTIFICATION_GENERAL, pattern_file, sizeof(pattern_file)); + haptic_stop_all_effects(ad->hnd_hpt); + err = haptic_vibrate_file_with_detail(ad->hnd_hpt, pattern_file, 1, list_item->chk_status * SETTING_VIB_FEEDBACK_RATE, HAPTIC_PRIORITY_MIN, NULL); + + if (err < 0) + SETTING_TRACE("Failed to play haptic monotone"); + priv_val_int = value; + } + priv_val_db = val; + +} + +static void +setting_profile_sound_main_touchVib_sound_slider_value_change_cb(void *data, + Evas_Object * + obj, void + *event_info) +{ + /* error check */ + ret_if(data == NULL); + + static double priv_val_db = 3.0; + static int priv_val_int = 0; + double val = elm_slider_value_get(obj); + SETTING_TRACE("val = %f", val); + Setting_GenGroupItem_Data *list_item = + (Setting_GenGroupItem_Data *) data; + SettingProfileUG *ad = list_item->userdata; + + int value; + int err; + + value = (int)(val + 0.5); /* to sync displayed value on slider */ + list_item->chk_status = value; + if (value != priv_val_int) { + vconf_set_int (VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, list_item->chk_status); + char pattern_file[MAX_COMMON_BUFFER_LEN] = {0,}; + svi_get_path(SVI_TYPE_VIB, SVI_VIB_OPERATION_VIBRATION, pattern_file, sizeof(pattern_file)); + haptic_stop_all_effects(ad->hnd_hpt); + err = haptic_vibrate_file_with_detail(ad->hnd_hpt, pattern_file, 1, list_item->chk_status * SETTING_VIB_FEEDBACK_RATE, HAPTIC_PRIORITY_MIN, NULL); + + if (err < 0) + SETTING_TRACE("Failed to play haptic monotone"); + priv_val_int = value; + } + priv_val_db = val; +} + diff --git a/setting-profile/src/setting-profile.c b/setting-profile/src/setting-profile.c index ae84255..4d7c5de 100755 --- a/setting-profile/src/setting-profile.c +++ b/setting-profile/src/setting-profile.c @@ -20,9 +20,9 @@ */ #include -//#include -#include #include +#include +#include #ifndef UG_MODULE_API #define UG_MODULE_API __attribute__ ((visibility("default"))) @@ -30,6 +30,8 @@ SettingProfileUG *g_ProfileUG = NULL; /* just a handler */ +extern char *repeat_type[]; + static void setting_profile_ug_cb_resize(void *data, Evas *e, Evas_Object *obj, void *event_info) { @@ -179,6 +181,9 @@ static void setting_profile_vconf_change_cb(keynode_t *key, void *data) SettingProfileUG *ad = data; int status = 0; + int ret = 0; + char *pa_ringtone = NULL; + char *sub_desc = NULL; char *vconf_name = vconf_keynode_get_name(key); if (!safeStrCmp(vconf_name, VCONFKEY_SYSMAN_MMC_STATUS)) { @@ -196,8 +201,8 @@ static void setting_profile_vconf_change_cb(keynode_t *key, void *data) #if MIGRATION_HAPTIC - if (device_haptic_stop_play(ad->hnd_hpt) != 0) { - SETTING_TRACE("ERROR device_haptic_stop_play"); + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); } #endif } @@ -207,7 +212,6 @@ static void setting_profile_vconf_change_cb(keynode_t *key, void *data) status = vconf_keynode_get_bool(key); SETTING_TRACE_DEBUG("sound status is changed. %d", status); elm_check_state_set(ad->data_sound->eo_check, status); - ad->data_sound->chk_status = status; if(status) { setting_enable_genlist_item(ad->data_call_volume->item); @@ -227,7 +231,6 @@ static void setting_profile_vconf_change_cb(keynode_t *key, void *data) status = vconf_keynode_get_bool(key); SETTING_TRACE_DEBUG("vibration status is changed. %d", status); elm_check_state_set(ad->data_vibration->eo_check, status); - ad->data_vibration->chk_status = status; if(status) { setting_enable_genlist_item(ad->data_vib_volume->item); @@ -239,6 +242,80 @@ static void setting_profile_vconf_change_cb(keynode_t *key, void *data) setting_disable_genlist_item(ad->data_touch_vib->item); } } + else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR)) { + pa_ringtone = vconf_keynode_get_str(key); + if(setting_profile_check_file_exist(ad, pa_ringtone) == SETTING_RETURN_FAIL) + { + if(isEmulBin()) + pa_ringtone = (char *)strdup(SETTING_DEFAULT_CALL_TONE_SDK); + else + pa_ringtone = (char *)strdup(SETTING_DEFAULT_CALL_TONE); + ret = vconf_set_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, pa_ringtone); + if(ret < 0) + SETTING_TRACE_DEBUG("failed to set vconf"); + } + sub_desc = setting_file_basename(pa_ringtone); + if(ad->data_call_alert_tone) + { + ad->data_call_alert_tone->sub_desc = (char*)g_strdup(sub_desc); + elm_genlist_item_update(ad->data_call_alert_tone->item); + } + } + else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR)) { + pa_ringtone = vconf_keynode_get_str(key); + if(setting_profile_check_file_exist(ad, pa_ringtone) == SETTING_RETURN_FAIL) + { + pa_ringtone = (char *)strdup(SETTING_DEFAULT_MSG_TONE); + ret = vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, pa_ringtone); + if(ret < 0) + SETTING_TRACE_DEBUG("failed to set vconf"); + } + sub_desc = setting_file_basename(pa_ringtone); + if(ad->data_msg_alert_tone) + { + ad->data_msg_alert_tone->sub_desc = (char*)g_strdup(sub_desc); + elm_genlist_item_update(ad->data_msg_alert_tone->item); + } + } + else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT)) { + status = vconf_keynod_get_int(key); + + if(ad->data_msg_alert_repeat) + { + ad->data_msg_alert_repeat->sub_desc = (char*)g_strdup(_(repeat_type[status])); + elm_genlist_item_update(ad->data_msg_alert_repeat->item); + } + } + else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR)) { + pa_ringtone = vconf_keynode_get_str(key); + if(setting_profile_check_file_exist(ad, pa_ringtone) == SETTING_RETURN_FAIL) + { + pa_ringtone = (char *)strdup(SETTING_DEFAULT_EMAIL_TONE); + ret = vconf_set_str(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, pa_ringtone); + if(ret < 0) + SETTING_TRACE_DEBUG("failed to set vconf"); + } + sub_desc = setting_file_basename(pa_ringtone); + if(ad->data_email_alert_tone) + { + ad->data_email_alert_tone->sub_desc = (char*)g_strdup(sub_desc); + elm_genlist_item_update(ad->data_email_alert_tone->item); + } + } + else if (!safeStrCmp(vconf_name, VCONFKEY_SETAPPL_NOTI_EMAIL_ALERT_REP_TYPE_INT)) { + status = vconf_keynod_get_int(key); + + if(ad->data_email_alert_repeat) + { + ad->data_msg_alert_repeat->sub_desc = (char*)g_strdup(_(repeat_type[status])); + elm_genlist_item_update(ad->data_msg_alert_repeat->item); + } + } + + if(pa_ringtone) + FREE(pa_ringtone); + if(sub_desc) + G_FREE(sub_desc); } int setting_profile_listen_vconf_change(void *data) @@ -262,6 +339,32 @@ int setting_profile_listen_vconf_change(void *data) setting_retvm_if(ret < 0, ret, "%s notifications Failed(%d)", (char *)VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, ret); + /* add ringtone tab's vconfkeys */ + // incoming call ringtone. + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, + setting_profile_vconf_change_cb, data); + setting_retvm_if(ret < 0, ret, "%s notifications Failed(%d)", + (char *)VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, ret); + // message alert tone + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, + setting_profile_vconf_change_cb, data); + setting_retvm_if(ret < 0, ret, "%s notifications Failed(%d)", + (char *)VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, ret); + // message alert repitition. + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, + setting_profile_vconf_change_cb, data); + setting_retvm_if(ret < 0, ret, "%s notifications Failed(%d)", + (char *)VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, ret); + // email alert tone. + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, + setting_profile_vconf_change_cb, data); + setting_retvm_if(ret < 0, ret, "%s notifications Failed(%d)", + (char *)VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, ret); + // email_alert_repitition + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_NOTI_EMAIL_ALERT_REP_TYPE_INT, + setting_profile_vconf_change_cb, data); + setting_retvm_if(ret < 0, ret, "%s notifications Failed(%d)", + (char *)VCONFKEY_SETAPPL_NOTI_EMAIL_ALERT_REP_TYPE_INT, ret); return 0; } @@ -275,9 +378,69 @@ int setting_profile_unlisten_vconf_change(void *data) setting_profile_vconf_change_cb); (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, setting_profile_vconf_change_cb); + + (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, + setting_profile_vconf_change_cb); + (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, + setting_profile_vconf_change_cb); + (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_MSG_ALERT_REP_TYPE_INT, + setting_profile_vconf_change_cb); + (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_EMAIL_RINGTONE_PATH_STR, + setting_profile_vconf_change_cb); + (void)vconf_ignore_key_changed(VCONFKEY_SETAPPL_NOTI_EMAIL_ALERT_REP_TYPE_INT, + setting_profile_vconf_change_cb); + return 0; } +static void __setting_profile_ug_key_grab(SettingProfileUG *ad) +{ + SETTING_TRACE_BEGIN; + Ecore_X_Window xwin = 0; + Ecore_X_Display *disp = NULL; + + int ret = 0; + + if(ad == NULL) + return; + + disp = ecore_x_display_get(); + xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window()); + + ret = utilx_grab_key(disp, xwin, KEY_VOLUMEUP, TOP_POSITION_GRAB); + if(ret) + return; + ret = utilx_grab_key(disp, xwin, KEY_VOLUMEDOWN, TOP_POSITION_GRAB); + if(ret) + return; + + ad->event_handler = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, NULL, NULL); + SETTING_TRACE_END; +} +static void __setting_profile_ug_key_ungrab(SettingProfileUG *ad) +{ + SETTING_TRACE_BEGIN; + Ecore_X_Window xwin = 0; + Ecore_X_Display *disp = NULL; + + int ret = 0; + + if(ad == NULL) + return; + + disp = ecore_x_display_get(); + xwin = elm_win_xwindow_get((Evas_Object*)ug_get_window()); + + ret = utilx_ungrab_key(disp, xwin, KEY_VOLUMEUP); + if(ret) + return; + ret = utilx_ungrab_key(disp, xwin, KEY_VOLUMEDOWN); + if(ret) + return; + + ecore_event_handler_del(ad->event_handler); +} + static void *setting_profile_ug_on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) @@ -296,10 +459,10 @@ static void *setting_profile_ug_on_create(ui_gadget_h ug, profileUG->evas = evas_object_evas_get(profileUG->win_main_layout); setting_retvm_if(profileUG->win_main_layout == NULL, NULL, "cannot get main window "); - +#if DISABLED_CODE //At present, there are only 4 types supported:RINGTONE,NOTIFICATION,SYSTEM,MEDIA sound_manager_set_volume_changed_cb(__sound_volume_changed_cb, profileUG); - +#endif setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR); /* register view node table */ @@ -334,6 +497,7 @@ static void *setting_profile_ug_on_create(ui_gadget_h ug, setting_profile_ug_cb_resize, profileUG); setting_profile_listen_vconf_change(profileUG); + __setting_profile_ug_key_grab(profileUG); return profileUG->ly_main; } @@ -414,14 +578,18 @@ static void setting_profile_ug_on_destroy(ui_gadget_h ug, service_h service, voi ret_if(priv == NULL); SettingProfileUG *profileUG = priv; + + __setting_profile_ug_key_ungrab(profileUG); + setting_profile_unlisten_vconf_change(profileUG); evas_object_event_callback_del(profileUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_profile_ug_cb_resize); /* fix flash issue for gallery */ profileUG->ug = ug; - +#if DISABLED_CODE //At present, there are only 4 types supported:RINGTONE,NOTIFICATION,SYSTEM,MEDIA sound_manager_unset_volume_changed_cb(); +#endif - int ret = haptic_deinitialize(); + int ret = haptic_close(profileUG->hnd_hpt); if (ret != 0) { SETTING_TRACE_DEBUG("%s*** [ERR] Failed haptic_deinitialize ***%s", SETTING_FONT_RED, SETTING_FONT_BLACK); @@ -487,8 +655,8 @@ static void setting_profile_ug_on_key_event(ui_gadget_h ug, setting_profile_close_all_mm_players(ad); /* close vibration */ #if MIGRATION_HAPTIC - if (device_haptic_stop_play(ad->hnd_hpt) != 0) { - SETTING_TRACE("ERROR device_haptic_stop_play"); + if (haptic_stop_all_effects(ad->hnd_hpt) != 0) { + SETTING_TRACE("ERROR haptic_stop_all_effects"); } #endif } @@ -517,12 +685,13 @@ UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops) ops->priv = profileUG; ops->opt = UG_OPT_INDICATOR_ENABLE; /* Haptic init */ - profileUG->hnd_hpt = haptic_initialize(); - - if (profileUG->hnd_hpt < 0) { - SETTING_TRACE_DEBUG("%s*** [ERR] Failed haptic_initialize ***%s", + SETTING_TRACE("before haptic initilization"); + int haptic_return = 0; + haptic_return = haptic_open(HAPTIC_DEVICE_0, &(profileUG->hnd_hpt)); + SETTING_TRACE("profileUG->hnd_hpt : %d", profileUG->hnd_hpt); + if (haptic_return < 0) { + SETTING_TRACE_DEBUG("%s*** [ERR] Failed haptic_open ***%s", SETTING_FONT_RED, SETTING_FONT_BLACK); - return SETTING_RETURN_FAIL; } return 0; @@ -628,7 +797,7 @@ player_h *setting_profile_play_sound(void *data, void *cb, free(player); return NULL; } - SETTING_TRACE_DEBUG("player_set_sound_type [%d]", ad->cur_vol_type); + SETTING_TRACE_DEBUG("player_set_sound_type [%d]", sound_type); err = player_set_uri(*player, ad->song_playing); if (err != PLAYER_ERROR_NONE) { @@ -705,25 +874,6 @@ void setting_profile_play_sound_origin(player_h **mp_handle, void *data, } } -void setting_profile_change_player_volume(player_h **mp_handle, float vol) -{ - SETTING_TRACE_BEGIN; - if (*mp_handle == NULL) - return; - - int ret= 0; - player_state_e state = -1; - player_get_state(*(*mp_handle), &state); - - if(state != PLAYER_STATE_PLAYING) - return; - - float volumn = vol / VOLUME_DEN; - ret = player_set_volume(*(*mp_handle), volumn, volumn); - setting_retm_if(ret != PLAYER_ERROR_NONE, "mm player set volume failed"); -} - - int setting_profile_stop_sound(void *data, player_h *player) { SETTING_TRACE_BEGIN; @@ -914,7 +1064,12 @@ void setting_profile_play_vibration(void *data, int value) svi_get_path(SVI_TYPE_VIB, value, pattern_file, sizeof(pattern_file)); #if MIGRATION_HAPTIC - if(device_haptic_play_file(ad->hnd_hpt, pattern_file, 1, HAPTIC_FEEDBACK_LEVEL_AUTO) != 0){ + if(ad->hnd_hpt < 0) + { + SETTING_TRACE_DEBUG("[ERROR] Can't use haptic handle."); + return; + } + if(haptic_vibrate_file_with_detail(ad->hnd_hpt, pattern_file, 1, HAPTIC_FEEDBACK_AUTO, HAPTIC_PRIORITY_MIN, NULL) != 0){ SETTING_TRACE("ERROR device_haptic_play_pattern"); } #endif -- 2.7.4