2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Flora License, Version 1.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <sys/types.h>
21 #include <vconf-keys.h>
23 #include "setting-sound.h"
25 #include "setting-common-sound.h"
26 #include "setting_control_haptic.h"
27 #include "setting_view_toast.h"
28 #include "setting_data_vconf.h"
29 #include "setting-volume.h"
32 #define AUDIO_RESOURCE_EXTENSION ".ogg"
34 static struct _sound_menu_item sound_menu_its[] = {
35 { "IDS_ST_OPT_VOLUME", 0, _volume_cb },
36 { "IDS_ST_OPT_SOUND_MODE_ABB", 0, _sound_mode_cb },
37 { "IDS_ST_BODY_TOUCH_SOUNDS_ABB", 0, _touch_sound_cb },
38 { "IDS_CST_MBODY_RINGTONES", 0, _ringtone_cb },
39 { "IDS_ST_BUTTON_NOTIFICATIONS", 0, _noti_cb },
40 { "IDS_ST_HEADER_VIBRATION_ABB", 0, _vibrate_cb },
41 /* { "IDS_ST_BODY_PREFERRED_ARM_ABB", 0, _preferred_cb }, */
45 char *sound_mode_str[] = {
46 "IDS_ST_OPT_SOUND_ABB2",
47 "IDS_ST_BODY_VIBRATE_ABB2",
50 char *ringtone_str[] = {
55 char *notification_str[] = {
60 char *vibration_str[] = {
61 "IDS_ST_OPT_STRONG_M_INTENSITY",
62 "IDS_ST_OPT_WEAK_M_INTENSITY"
64 char *pref_arm_str[] = {
65 "IDS_ST_OPT_LEFT_ARM_ABB",
66 "IDS_ST_OPT_RIGHT_ARM_ABB"
68 char *pref_arm_toast_msg[] = {
69 "IDS_ST_TPOP_MAIN_MIC_ADJUSTED_FOR_LEFT_ARM",
70 "IDS_ST_TPOP_MAIN_MIC_ADJUSTED_FOR_RIGHT_ARM"
73 static char ringtone_arr[RINGTONE_MAX_COUNT][1024];
74 static char ringtone_name_arr[RINGTONE_MAX_COUNT][1024];
75 static char notification_arr[RINGTONE_MAX_COUNT][1024];
76 static char notification_name_arr[RINGTONE_MAX_COUNT][1024];
78 static appdata *temp_ad = NULL;
79 static Evas_Object *g_sound_genlist = NULL;
80 static Evas_Object *g_sound_mode_genlist = NULL;
81 static Evas_Object *g_ringtone_type_genlist = NULL;
82 static Evas_Object *g_notification_type_genlist = NULL;
83 static Evas_Object *g_vibration_type_genlist = NULL;
84 static Evas_Object *g_pref_arm_type_genlist = NULL;
85 static Elm_Object_Item *g_vib_item = NULL;
87 static int sound_mode = 1; /* Vibrate */
88 static int ringtone_type = 0; /* Rigntone type */
89 static int confirmed_ringtone_type = 0; /* setted Rigntone type */
90 static int notification_type = 0; /* Notification type */
91 static int confirmed_Notification_type = 0; /* setted Notification type */
92 static int vibrate_type = 0; /* Vibration type */
93 static int pref_arm_type = 0; /* Pref_arm_type */
94 static int changing_sound_mode_myself = 0;
96 static int ringtone_count = 0;
97 static int notification_count = 0;
99 char curr_ringtone_file_path[1023];
100 char curr_noti_file_path[1023];
102 static int cur_sound_type;
103 static int is_loaded_ringtone_data = 0;
104 static int is_loaded_noti_data = 0;
105 static int origin_vibration_level;
107 static Ecore_Timer *vibration_timer = NULL;
109 static int is_wav_playing = SOUND_STATE_STOP;
110 static int sound_id = -1;
113 static void sound_vconf_changed_cb(keynode_t *key, void *data);
114 static void vibrate_vconf_changed_cb(keynode_t *key, void *data);
115 static void pm_state_vconf_changed_cb(keynode_t *key, void *data);
116 static void _vibration_gl_cb(void *data, Evas_Object *obj, void *event_info);
117 static void stop_wav();
121 _gl_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
125 snprintf(buf, 1023, "%s", _("IDS_ST_OPT_SOUND_ABB2"));
133 /*effect_playsound_init(); */
136 Eina_Bool _clear_sound_cb(void *data, Elm_Object_Item *it)
138 _clear_sound_resource();
143 void _clear_sound_resource()
145 if (vibration_timer) {
146 ecore_timer_del(vibration_timer);
147 vibration_timer = NULL;
153 g_sound_genlist = NULL;
154 g_sound_mode_genlist = NULL;
155 g_ringtone_type_genlist = NULL;
156 g_notification_type_genlist = NULL;
157 g_vibration_type_genlist = NULL;
158 g_pref_arm_type_genlist = NULL;
163 notification_type = 0;
167 is_loaded_ringtone_data = 0;
168 is_loaded_noti_data = 0;
169 origin_vibration_level = 0;
176 /* Unregister sound mode vconf callback */
177 unregister_vconf_changing(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, sound_vconf_changed_cb);
178 unregister_vconf_changing(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vibrate_vconf_changed_cb);
181 void _stop_all_sound_play()
183 DBG("Setting - stop all sound");
190 static void stop_wav()
192 if (is_wav_playing == SOUND_STATE_PLAY) {
193 DBG("Setting - sound id : %d", sound_id);
195 wav_player_stop(sound_id);
196 is_wav_playing = SOUND_STATE_STOP;
201 void _stop_wav_player()
208 DBG("Setting - _stop_player() is called!");
209 if (is_created_player()) {
210 _close_player(NULL, cur_sound_type);
214 static void get_sound_file_list(char *dir, int type)
218 char *cur_ring_path = NULL;
220 if ((dp = opendir(dir)) == NULL) {
221 DBG("Setting - dir open error!");
226 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
227 if (cur_ring_path == NULL) {
228 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
232 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
233 if (cur_ring_path == NULL) {
234 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
236 notification_count = 0;
239 while ((dirp = readdir(dp))) {
240 if (strncmp(dirp->d_name, ".", 1)
241 && strlen(dir) < 1024
242 && strlen(replace(dirp->d_name, ".ogg", "")) < 1024
243 && strlen(replace(notification_name_arr[notification_count], "_", " ")) < 1024) {
245 strcpy(ringtone_arr[ringtone_count], dir);
246 strcat(ringtone_arr[ringtone_count], dirp->d_name);
248 strcpy(ringtone_name_arr[ringtone_count], replace(dirp->d_name, ".ogg", ""));
250 /*DBG("Setting - %s", ringtone_arr[ringtone_count]); */
252 if (!strcmp(cur_ring_path, ringtone_arr[ringtone_count])) {
253 ringtone_type = ringtone_count;
254 /*DBG("Settng - %s is same with %s", cur_ring_path, ringtone_arr[ringtone_count]); */
256 /*DBG("Settng - %s is same with %s", cur_ring_path, ringtone_arr[ringtone_count]); */
260 strcpy(notification_arr[notification_count], dir);
261 strcat(notification_arr[notification_count], dirp->d_name);
263 strcpy(notification_name_arr[notification_count], replace(dirp->d_name, ".ogg", ""));
264 strcpy(notification_name_arr[notification_count], replace(notification_name_arr[notification_count], "_", " "));
266 /*DBG("Setting - %s", notification_arr[notification_count]); */
268 if (!strcmp(cur_ring_path, notification_arr[notification_count])) {
269 notification_type = notification_count;
270 /*DBG("Settng - %s is same with %s", cur_ring_path, notification_arr[notification_count]); */
272 /*DBG("Settng - %s is same with %s", cur_ring_path, notification_arr[notification_count]); */
274 notification_count++;
282 static int get_vibration_level()
287 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
290 case VIBRATION_LEVEL_LOW_INT:
291 mode = VIBRATION_LEVEL_LOW;
293 /* case VIBRATION_LEVEL_MID_INT : */
294 /* mode = VIBRATION_LEVEL_MID; */
296 case VIBRATION_LEVEL_HIGH_INT:
297 mode = VIBRATION_LEVEL_HIGH;
303 void _show_volume_list(void *data)
305 Evas_Object *genlist = NULL;
306 Elm_Object_Item *nf_it = NULL;
310 DBG("Setting - ad is null");
314 _initialize_volume();
316 genlist = _create_volume_list(data);
317 if (genlist == NULL) {
318 DBG("%s", "volume cb - genlist is null");
322 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty");
324 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
326 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
327 evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, _clear_volume_cb, ad);
330 void _volume_cb(void *data, Evas_Object *obj, void *event_info)
332 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
334 _show_volume_list(data);
337 void _sound_mode_cb(void *data, Evas_Object *obj, void *event_info)
339 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
341 _show_sound_mode_list(data);
344 void _touch_sound_cb(void *data, Evas_Object *obj, void *event_info)
346 Elm_Object_Item *it = (Elm_Object_Item *)event_info;
350 DBG("%s", "_touch_sound_cb - appdata or check is null");
353 sound_menu_its[2].is_enable_touch_sound = sound_menu_its[2].is_enable_touch_sound ? 0 : 1;
354 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
355 vconf_set_bool(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
357 elm_genlist_item_selected_set(it, EINA_FALSE);
359 elm_genlist_item_update(it);
362 void _ringtone_cb(void *data, Evas_Object *obj, void *event_info)
364 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
366 _show_ringtone_popup_cb(data, obj, event_info);
369 void _noti_cb(void *data, Evas_Object *obj, void *event_info)
371 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
373 _show_notification_popup_cb(data, obj, event_info);
376 void _vibrate_cb(void *data, Evas_Object *obj, void *event_info)
378 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
380 _show_vibration_popup_cb(data, obj, event_info);
383 void _preferred_cb(void *data, Evas_Object *obj, void *event_info)
385 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
387 _show_pref_arm_mode_list(data);
390 static char *_get_sound_file_name(char *full_name)
393 char *temp_token = NULL;
396 DBG("Setting - %s, %s", token, full_name);
398 strtok(full_name, sep);
401 token = strtok(NULL, sep);
405 } while (token != NULL);
407 char *result_token = NULL;
409 temp_token = replace(temp_token, ".ogg", "");
410 result_token = replace(temp_token, "_", " ");
415 char *_gl_Sound_title_get(void *data, Evas_Object *obj, const char *part)
417 char buf[1024] = {0,};
418 Item_Data *id = data;
419 int index = id->index;
420 char *pa_cur_ringtone = NULL;
422 if (!strcmp(part, "elm.text")) {
423 snprintf(buf, sizeof(buf) - 1, "%s", _(sound_menu_its[index % ITEM_SIZE].name));
424 } else if (!strcmp(part, "elm.text.1")) {
427 sound_mode = get_sound_mode();
428 snprintf(buf, sizeof(buf) - 1, "%s", _(sound_mode_str[sound_mode % 3]));
431 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
432 if (pa_cur_ringtone == NULL) {
433 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
435 if (strlen(pa_cur_ringtone) < 1024) {
436 strcpy(curr_ringtone_file_path, pa_cur_ringtone);
437 DBG("Setting - ringtone path : %s", pa_cur_ringtone);
439 snprintf(buf, sizeof(buf) - 1, "%s", _get_sound_file_name(pa_cur_ringtone));
443 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
444 if (pa_cur_ringtone == NULL) {
445 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
447 if (strlen(pa_cur_ringtone) < 1024) {
448 strcpy(curr_noti_file_path, pa_cur_ringtone);
449 DBG("Setting - noti's ringtone path : %s", pa_cur_ringtone);
451 snprintf(buf, sizeof(buf) - 1, "%s", _get_sound_file_name(pa_cur_ringtone));
455 vibrate_type = get_vibration_level();
456 snprintf(buf, sizeof(buf) - 1, "%s", _(vibration_str[vibrate_type % 2]));
460 vconf_get_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, &pref_arm_type);
461 pref_arm_type = (pref_arm_type == TRUE) ? 0 : 1;
462 snprintf(buf, sizeof(buf)-1, "%s", _(pref_arm_str[pref_arm_type % 2]));
471 void _sound_chk_changed_cb(void *data, Evas_Object *obj, void *event_info)
473 DBG("Setting - _sound_chk_changed_cb() is called!!");
475 vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &sound_menu_its[2].is_enable_touch_sound);
477 sound_menu_its[2].is_enable_touch_sound = !sound_menu_its[2].is_enable_touch_sound;
479 /* Update touch sound enable state */
480 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
481 vconf_set_bool(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
484 static void _sound_gl_del(void *data, Evas_Object *obj)
486 Sound_Item_Data *id = data;
491 Evas_Object *_gl_sound_check_get(void *data, Evas_Object *obj, const char *part)
493 Evas_Object *check = NULL;
495 Sound_Item_Data *id = data;
496 int index = id->index;
498 if (!strcmp(part, "elm.icon")) {
499 check = elm_check_add(obj);
501 if (vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &sound_menu_its[2].is_enable_touch_sound) < 0) {
502 sound_menu_its[2].is_enable_touch_sound = TOUCH_SOUND_ENABLE; /* default value of touch sounds : on */
504 elm_check_state_set(check, (sound_menu_its[2].is_enable_touch_sound) ? EINA_TRUE : EINA_FALSE);
505 evas_object_smart_callback_add(check, "changed", _sound_chk_changed_cb, (void *)1);
506 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
507 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
508 evas_object_propagate_events_set(check, EINA_FALSE);
519 Evas_Object *_create_sound_list(void *data)
523 DBG("%s", "_create_sound_list - appdata is null");
529 Evas_Object *genlist = NULL;
530 struct _sound_menu_item *menu_its = NULL;
533 Elm_Genlist_Item_Class *itc_tmp;
535 Elm_Genlist_Item_Class *itc_1text = elm_genlist_item_class_new();
536 itc_1text->item_style = "1text";
537 itc_1text->func.text_get = _gl_Sound_title_get;
538 itc_1text->func.del = _sound_gl_del;
540 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
541 itc->item_style = "2text";
542 itc->func.text_get = _gl_Sound_title_get;
543 itc->func.del = _sound_gl_del;
545 Elm_Genlist_Item_Class *itc_touch_snd = elm_genlist_item_class_new();
546 itc_touch_snd->item_style = "1text.1icon.1";
547 itc_touch_snd->func.text_get = _gl_Sound_title_get;
548 itc_touch_snd->func.content_get = _gl_sound_check_get;
549 itc_touch_snd->func.del = _sound_gl_del;
551 genlist = elm_genlist_add(ad->nf);
552 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
554 Evas_Object *circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
555 eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
556 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
560 Elm_Genlist_Item_Class *title_item = elm_genlist_item_class_new();
561 title_item ->func.text_get = _gl_menu_title_text_get;
562 title_item->item_style = "title";
563 title_item->func.del = _sound_gl_del;
565 elm_genlist_item_append(genlist, title_item, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
567 elm_genlist_item_class_free(title_item);
571 menu_its = sound_menu_its;
573 for (idx = 0; idx < ITEM_SIZE; idx++) {
576 } else if (idx == 2) {
577 itc_tmp = itc_touch_snd;
582 Sound_Item_Data *id = calloc(sizeof(Sound_Item_Data), 1);
585 id->item = elm_genlist_item_append(
586 genlist, /* genlist object */
587 itc_tmp, /* item class */
590 ELM_GENLIST_ITEM_NONE,
591 menu_its[idx].func, /* call back */
594 if (idx == ITEM_SIZE - 1) {
595 g_vib_item = id->item;
600 Elm_Genlist_Item_Class *padding = elm_genlist_item_class_new();
601 padding->item_style = "padding";
602 padding->func.del = _sound_gl_del;
604 elm_genlist_item_append(genlist, padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
605 elm_genlist_item_class_free(padding);
607 elm_genlist_item_class_free(itc_1text);
608 elm_genlist_item_class_free(itc);
609 elm_genlist_item_class_free(itc_touch_snd);
611 g_sound_genlist = genlist;
613 /* Register sound mode vconf callback */
614 register_vconf_changing(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, sound_vconf_changed_cb, NULL);
615 register_vconf_changing(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vibrate_vconf_changed_cb, NULL);
620 static char *_gl_sound_mode_title_get(void *data, Evas_Object *obj, const char *part)
622 char buf[1024] = {0,};
623 Item_Data *id = data;
624 int index = id->index;
626 if (!strcmp(part, "elm.text")) {
627 snprintf(buf, sizeof(buf) - 1, "%s", _(sound_mode_str[index % 3]));
633 static Evas_Object *_gl_sound_mode_ridio_get(void *data, Evas_Object *obj, const char *part)
635 Evas_Object *radio = NULL;
636 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
637 Item_Data *id = data;
638 int index = id->index;
640 if (!strcmp(part, "elm.icon")) {
641 radio = elm_radio_add(obj);
642 elm_object_style_set(radio, "list");
643 elm_radio_state_value_set(radio, id->index);
644 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
645 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
646 elm_radio_group_add(radio, radio_main);
647 evas_object_smart_callback_add(radio, "changed", NULL, (void *)id->index);
648 if (sound_mode == id->index)
649 elm_radio_value_set(radio_main, sound_mode);
656 static void _sound_mode_gl_del(void *data, Evas_Object *obj)
658 Item_Data *id = data;
663 static int curr_touch_sound = 0;
666 static void _sound_mode_gl_cb(void *data, Evas_Object *obj, void *event_info)
668 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
670 sound_mode = (int)data;
672 changing_sound_mode_myself = 1;
674 if (g_sound_mode_genlist) {
675 elm_genlist_realized_items_update(g_sound_mode_genlist);
678 int ringtone_level = 0;
679 int prev_sound_mode = get_sound_mode();
683 switch (sound_mode) {
684 case SOUND_MODE_SOUND:
685 if (get_sound_mode() != SOUND_MODE_SOUND) {
686 DBG("Setting - current sound mode is not sound!! Change sound mode to sound!!");
688 vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &curr_touch_sound);
689 if (curr_touch_sound) {
690 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, FALSE);
693 vconf_get_int(SETTING_RINGTONE_VOLUME_BACKUP, &ringtone_level);
694 DBG("Setting - ringtone backup level: %d", ringtone_level);
696 vconf_set_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, ringtone_level);
698 if (is_created_player()) {
699 _close_player(NULL, SOUND_TYPE_RINGTONE);
701 play_sound_for_sound_mode(SETTING_DEFAULT_SILENT_OFF_TONE, 0.0, SOUND_TYPE_RINGTONE);
704 sound_manager_get_volume(SOUND_TYPE_RINGTONE, &ringtone_level);
705 if (ringtone_level == 0) {
706 DBG("Setting - Ringtone volume is 0!! Restore to 1!!");
707 sound_manager_set_volume(SOUND_TYPE_RINGTONE, 1);
710 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, TRUE);
711 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, FALSE);
713 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, curr_touch_sound);
714 curr_touch_sound = 0;
717 case SOUND_MODE_VIBRATE:
718 if (prev_sound_mode != SOUND_MODE_VIBRATE) {
719 DBG("Setting - current sound mode is not vibration. Change sound mode to vibration!!");
721 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE);
722 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, TRUE);
724 vconf_get_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, &ringtone_level);
725 DBG("Setting - ringtone original level: %d", ringtone_level);
727 vconf_set_int(SETTING_RINGTONE_VOLUME_BACKUP, ringtone_level);
728 /*sound_manager_set_muteall(TRUE); // mute!! */
730 _start_vibration(5, SETTING_VIB_STRONG_RATE, SETTING_DEFAULT_SYSTEM_HAPTIC_PREVIEW_VIB);
732 case SOUND_MODE_MUTE:
733 if (prev_sound_mode != SOUND_MODE_MUTE) {
734 DBG("Setting - current sound mode is not mute. Change sound mode to mute!!");
736 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE);
737 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, FALSE);
739 vconf_get_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, &ringtone_level);
740 DBG("Setting - ringtone original level: %d", ringtone_level);
742 vconf_set_int(SETTING_RINGTONE_VOLUME_BACKUP, ringtone_level);
743 /*sound_manager_set_muteall(TRUE); // mute!! */
747 ERR("Setting - wrong sound mode value!!");
751 elm_naviframe_item_pop(temp_ad->nf);
752 if (!temp_ad->sound_mode_rdg) {
753 evas_object_del(temp_ad->sound_mode_rdg);
754 temp_ad->sound_mode_rdg = NULL;
757 if (g_sound_genlist) {
758 elm_genlist_realized_items_update(g_sound_genlist);
762 static void sound_vconf_changed_cb(keynode_t *key, void *data)
764 DBG("Setting - sound_vconf_changed_cb() is called!!");
766 if (changing_sound_mode_myself) {
767 DBG("Setting - changing_sound_mode_myself!!");
769 changing_sound_mode_myself = 0;
773 sound_mode = get_sound_mode();
775 if (g_sound_mode_genlist) {
776 elm_genlist_realized_items_update(g_sound_mode_genlist);
779 if (g_sound_genlist) {
780 elm_genlist_realized_items_update(g_sound_genlist);
784 static void vibrate_vconf_changed_cb(keynode_t *key, void *data)
786 DBG("Setting - vibrate_vconf_changed_cb() is called!!");
788 sound_mode = get_sound_mode();
790 if (g_sound_mode_genlist) {
791 elm_genlist_realized_items_update(g_sound_mode_genlist);
794 if (g_sound_genlist) {
795 elm_genlist_realized_items_update(g_sound_genlist);
799 Eina_Bool _sound_mode_back_cb(void *data, Elm_Object_Item *it)
801 g_sound_mode_genlist = NULL;
808 _gl_menu_sound_mode_title_text_get(void *data, Evas_Object *obj, const char *part)
812 snprintf(buf, 1023, "%s", _("IDS_ST_OPT_SOUND_MODE_ABB"));
816 void _show_sound_mode_list(void *data)
820 DBG("%s", "_show_sound_mode_list - appdata is null");
823 Evas_Object *genlist = NULL;
824 Elm_Object_Item *item = NULL;
825 Elm_Object_Item *nf_it = NULL;
827 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
828 itc->item_style = "1text.1icon.1";
829 itc->func.text_get = _gl_sound_mode_title_get;
830 itc->func.content_get = _gl_sound_mode_ridio_get;
831 itc->func.del = _sound_mode_gl_del;
833 sound_mode = get_sound_mode();
835 Evas_Object *layout = elm_layout_add(ad->nf);
836 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
837 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
839 genlist = elm_genlist_add(layout);
840 elm_genlist_block_count_set(genlist, 14);
841 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
842 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
844 Evas_Object *circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
845 eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
846 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
850 Elm_Genlist_Item_Class *title_item = elm_genlist_item_class_new();
851 title_item ->func.text_get = _gl_menu_sound_mode_title_text_get;
852 title_item->item_style = "title";
853 title_item->func.del = _sound_mode_gl_del;
855 elm_genlist_item_append(genlist, title_item, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
857 elm_genlist_item_class_free(title_item);
859 Item_Data *id = calloc(sizeof(Item_Data), 1);
862 item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void *)0);
866 Item_Data *id2 = calloc(sizeof(Item_Data), 1);
869 item = elm_genlist_item_append(genlist, itc, id2, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void *)1);
873 Item_Data *id3 = calloc(sizeof(Item_Data), 1);
876 item = elm_genlist_item_append(genlist, itc, id3, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void *)2);
880 ad->sound_mode_rdg = elm_radio_add(genlist);
881 elm_object_style_set(ad->sound_mode_rdg, "elm/radio/base/list");
882 elm_radio_state_value_set(ad->sound_mode_rdg, 3);
883 elm_radio_value_set(ad->sound_mode_rdg, sound_mode);
885 evas_object_data_set(genlist, "radio_main", ad->sound_mode_rdg);
887 elm_genlist_item_class_free(itc);
890 Elm_Genlist_Item_Class *padding = elm_genlist_item_class_new();
891 padding->item_style = "padding";
892 padding->func.del = _sound_mode_gl_del;
894 elm_genlist_item_append(genlist, padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
895 elm_genlist_item_class_free(padding);
897 g_sound_mode_genlist = genlist;
899 elm_object_part_content_set(layout, "elm.genlist", genlist);
901 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, "empty");
903 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
906 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
907 elm_naviframe_item_pop_cb_set(nf_it, _sound_mode_back_cb, ad);
910 static void _response_ringtone_ok_cb(void *data, Evas_Object *obj, void *event_info)
912 appdata *ad = (appdata *)data;
917 /* stop wav sound! */
920 /* save a ringtone type. */
921 vconf_set_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR , ringtone_arr[ringtone_type]);
923 if (g_ringtone_type_genlist != NULL) {
924 evas_object_del(g_ringtone_type_genlist);
925 g_ringtone_type_genlist = NULL;
928 if (temp_ad->ringtone_type_rdg != NULL) {
929 evas_object_del(temp_ad->ringtone_type_rdg);
930 temp_ad->ringtone_type_rdg = NULL;
934 elm_naviframe_item_pop(ad->nf);
937 if (g_sound_genlist != NULL) {
938 elm_genlist_realized_items_update(g_sound_genlist);
941 confirmed_ringtone_type = ringtone_type;
944 static void _response_ringtone_cancel_cb(void *data, Evas_Object *obj, void *event_info)
946 if (g_ringtone_type_genlist != NULL) {
947 evas_object_del(g_ringtone_type_genlist);
948 g_ringtone_type_genlist = NULL;
951 appdata *ad = (appdata *)data;
953 elm_naviframe_item_pop(ad->nf);
958 ringtone_type = confirmed_ringtone_type;
961 /* stop wav sound! */
966 static char *_gl_ringtone_text_get(void *data, Evas_Object *obj, const char *part)
968 Item_Data *item = data;
974 /*DBG("---> %d ---> %s ", (item->index%ringtone_count), ringtone_name_arr[item->index % ringtone_count]); */
975 sprintf(buf, "%s", ringtone_name_arr[item->index % ringtone_count]);
980 static Evas_Object *_gl_ringtone_radio_get(void *data, Evas_Object *obj, const char *part)
982 Evas_Object *radio = NULL;
983 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
984 Item_Data *id = data;
985 int index = id->index;
987 if (!strcmp(part, "elm.icon")) {
988 radio = elm_radio_add(obj);
989 elm_object_style_set(radio, "list");
990 elm_radio_state_value_set(radio, id->index);
991 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
992 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
993 elm_radio_group_add(radio, radio_main);
995 if (id->index == ringtone_type) {
996 elm_radio_value_set(radio_main, id->index);
1003 static void _ringtone_type_gl_cb(void *data, Evas_Object *obj, void *event_info)
1005 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1007 ringtone_type = (int)data;
1012 is_wav_playing = SOUND_STATE_PLAY;
1013 wav_player_start(ringtone_arr[ringtone_type], SOUND_TYPE_RINGTONE, NULL, (void *)1, &sound_id);
1017 sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
1019 if (volume == 0 || get_sound_mode() != SOUND_MODE_SOUND) {
1021 struct _toast_data *toast = _create_toast(temp_ad, _("IDS_ST_TPOP_VOLUME_CURRENTLY_SET_TO_0"));
1023 _show_toast(temp_ad, toast);
1027 play_sound(ringtone_arr[ringtone_type], 0.0, SOUND_TYPE_RINGTONE);
1030 elm_genlist_realized_items_update(g_ringtone_type_genlist);
1033 static void _ringtone_back_cb(void *data, Evas_Object *obj, void *event_info)
1039 ringtone_type = confirmed_ringtone_type;
1041 _stop_all_sound_play();
1043 unregister_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb);
1047 static void pm_state_vconf_changed_cb(keynode_t *key, void *data)
1049 DBG("Setting - pm_state_vconf_changed_cb() is called!");
1052 vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
1054 if (pm_state == VCONFKEY_PM_STATE_LCDOFF) {
1055 DBG("Setting - LCD Off!! stop sound!");
1056 _stop_all_sound_play();
1060 int cstring_cmp(const void *a, const void *b)
1062 const char *ia = (const char *)a;
1063 const char *ib = (const char *)b;
1064 return strcmp(ia, ib);
1067 void _show_ringtone_popup_cb(void *data, Evas_Object *obj, void *event_info)
1069 DBG("ENTER _show_ringtone_popup_cb");
1070 Evas_Object *popup, *btn;
1077 ad->MENU_TYPE = SETTING_SOUND_RINGTONE;
1079 if (is_loaded_ringtone_data == 0) {
1080 get_sound_file_list("/opt/share/settings/Ringtones/", 1);
1081 is_loaded_ringtone_data = 1;
1083 /* @todo apply eina_sort */
1084 /*qsort (ringtone_name_arr, ringtone_count-1, sizeof(char*), cstring_cmp); */
1087 cur_sound_type = SOUND_TYPE_RINGTONE;
1089 popup = elm_layout_add(ad->win_main);
1091 EAPI Eina_Bool bret = elm_layout_file_set(popup, EDJE_PATH, "setting/genlist/2button-layout");
1092 if (bret == EINA_FALSE) {
1093 DBG("elm_layout_file_set FAILED with setting/genlist/2button-layout");
1095 DBG("elm_layout_file_set OK with setting/genlist/2button-layout");
1097 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1098 evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
1101 Elm_Genlist_Item_Class *itc = NULL;
1102 itc = elm_genlist_item_class_new();
1103 /*itc->item_style = "settings.1text.1icon.1"; //"1text.1icon.1"; */
1104 itc->item_style = "1text.1icon.1"; /*"1text.1icon.1"; */
1105 itc->func.text_get = _gl_ringtone_text_get;
1106 itc->func.content_get = _gl_ringtone_radio_get;
1108 Evas_Object *genlist;
1109 genlist = elm_genlist_add(popup);
1110 elm_object_style_set(genlist, "popup");
1111 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1113 Evas_Object *circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
1114 eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1115 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
1120 DBG("---> ringtone_count %d to GENLIST", ringtone_count);
1121 for (index = 0; index < ringtone_count; index++) {
1122 /*DBG("---> add item to list %d to GENLIST", index); */
1123 Item_Data *item = (Item_Data *)calloc(sizeof(Item_Data), 1);
1125 item->index = index;
1126 item->item = elm_genlist_item_append(genlist,
1130 ELM_GENLIST_ITEM_NONE,
1131 _ringtone_type_gl_cb,
1136 ad->ringtone_type_rdg = elm_radio_add(genlist);
1137 elm_radio_state_value_set(ad->ringtone_type_rdg, ringtone_count);
1138 elm_radio_value_set(ad->ringtone_type_rdg, ringtone_type);
1139 confirmed_ringtone_type = ringtone_type;
1141 evas_object_data_set(genlist, "radio_main", ad->ringtone_type_rdg);
1143 g_ringtone_type_genlist = genlist;
1145 elm_object_part_content_set(popup, "elm.genlist", genlist);
1146 /* evas_object_show(popup); */
1147 evas_object_show(genlist);
1149 elm_genlist_item_class_free(itc);
1151 btn = elm_button_add(popup);
1152 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1153 elm_object_text_set(btn, _("IDS_ST_BUTTON_CANCEL_ABB2"));
1154 elm_object_part_content_set(popup, "btn.left", btn);
1155 evas_object_smart_callback_add(btn, "clicked", _response_ringtone_cancel_cb, ad);
1157 btn = elm_button_add(popup);
1158 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1159 elm_object_text_set(btn, _("IDS_WNOTI_BUTTON_OK_ABB2"));
1160 elm_object_part_content_set(popup, "btn.right", btn);
1161 evas_object_smart_callback_add(btn, "clicked", _response_ringtone_ok_cb, ad);
1163 elm_naviframe_item_push(ad->nf, _("IDS_ST_HEADER_RINGTONES_ABB"), NULL, NULL, popup, NULL);
1164 ea_object_event_callback_add(ad->nf, EA_CALLBACK_BACK, _ringtone_back_cb, ad);
1166 /*VCONFKEY_PM_STATE */
1167 register_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb, NULL);
1168 DBG("LEAVE _show_ringtone_popup_cb");
1171 static void _notification_back_cb(void *data, Evas_Object *obj, void *event_info)
1177 notification_type = confirmed_Notification_type;
1179 _stop_all_sound_play();
1181 unregister_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb);
1184 static void _response_notification_ok_cb(void *data, Evas_Object *obj, void *event_info)
1188 if (is_created_player()) {
1189 _close_player(NULL, SOUND_TYPE_NOTIFICATION);
1192 /* save a notification type. */
1193 vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR , notification_arr[notification_type]);
1195 if (g_notification_type_genlist != NULL) {
1196 evas_object_del(g_notification_type_genlist);
1197 g_notification_type_genlist = NULL;
1200 if (temp_ad->notification_rdg != NULL) {
1201 evas_object_del(temp_ad->notification_rdg);
1202 temp_ad->notification_rdg = NULL;
1205 confirmed_Notification_type = notification_type;
1207 appdata *ad = (appdata *)data;
1209 elm_naviframe_item_pop(ad->nf);
1212 if (g_sound_genlist != NULL) {
1213 elm_genlist_realized_items_update(g_sound_genlist);
1217 static void _response_notification_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1219 if (g_notification_type_genlist != NULL) {
1220 evas_object_del(g_notification_type_genlist);
1221 g_notification_type_genlist = NULL;
1224 appdata *ad = (appdata *)data;
1226 elm_naviframe_item_pop(ad->nf);
1229 notification_type = confirmed_Notification_type;
1231 if (is_created_player()) {
1232 _close_player(NULL, SOUND_TYPE_RINGTONE);
1238 static char *_gl_notification_text_get(void *data, Evas_Object *obj, const char *part)
1240 Item_Data *item = data;
1246 sprintf(buf, "%s", notification_name_arr[item->index % notification_count]);
1251 static Evas_Object *_gl_notification_radio_get(void *data, Evas_Object *obj, const char *part)
1253 Evas_Object *radio = NULL;
1254 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
1255 Item_Data *id = data;
1256 int index = id->index;
1258 if (!strcmp(part, "elm.icon")) {
1259 radio = elm_radio_add(obj);
1260 elm_object_style_set(radio, "list");
1261 elm_radio_state_value_set(radio, id->index);
1262 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
1263 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1264 elm_radio_group_add(radio, radio_main);
1265 if (id->index == notification_type) {
1266 elm_radio_value_set(radio_main, id->index);
1273 static void _notification_gl_cb(void *data, Evas_Object *obj, void *event_info)
1275 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1277 notification_type = (int)data;
1280 is_wav_playing = SOUND_STATE_PLAY;
1281 wav_player_start(notification_arr[notification_type], SOUND_TYPE_NOTIFICATION, NULL, (void *)2, &sound_id);
1285 sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &volume);
1287 if (volume == 0 || get_sound_mode() != SOUND_MODE_SOUND) {
1289 struct _toast_data *toast = _create_toast(temp_ad, _("IDS_ST_TPOP_VOLUME_CURRENTLY_SET_TO_0"));
1291 _show_toast(temp_ad, toast);
1295 play_sound(notification_arr[notification_type], 0.0, SOUND_TYPE_NOTIFICATION);
1299 if (g_notification_type_genlist) {
1300 elm_genlist_realized_items_update(g_notification_type_genlist);
1304 void _show_notification_popup_cb(void *data, Evas_Object *obj, void *event_info)
1306 Evas_Object *popup, *btn;
1313 ad->MENU_TYPE = SETTING_SOUND_NOTIFICATION;
1315 if (is_loaded_noti_data == 0) {
1316 get_sound_file_list("/opt/share/settings/Alerts/", 0);
1317 is_loaded_noti_data = 1;
1319 /*sorting_file_list(0); */
1322 cur_sound_type = SOUND_TYPE_NOTIFICATION;
1324 popup = elm_layout_add(ad->win_main);
1325 elm_layout_file_set(popup, EDJE_PATH, "setting/genlist/2button-layout");
1326 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1327 evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
1329 Elm_Genlist_Item_Class *itc = NULL;
1330 itc = elm_genlist_item_class_new();
1331 /*itc->item_style = "settings.1text.1icon.1"; //"1text.1icon.1"; */
1332 itc->item_style = "1text.1icon.1";
1333 itc->func.text_get = _gl_notification_text_get;
1334 itc->func.content_get = _gl_notification_radio_get;
1336 Evas_Object *genlist;
1337 genlist = elm_genlist_add(popup);
1338 elm_object_style_set(genlist, "popup");
1339 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1341 Evas_Object *circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
1342 eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1343 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
1347 for (index = 0; index < notification_count; index++) {
1348 Item_Data *item = (Item_Data *)calloc(sizeof(Item_Data), 1);
1350 item->index = index;
1351 item->item = elm_genlist_item_append(genlist,
1355 ELM_GENLIST_ITEM_NONE,
1356 _notification_gl_cb,
1361 ad->notification_rdg = elm_radio_add(genlist);
1362 elm_radio_state_value_set(ad->notification_rdg, notification_count);
1363 elm_radio_value_set(ad->notification_rdg, notification_type);
1364 confirmed_Notification_type = notification_type;
1366 evas_object_data_set(genlist, "radio_main", ad->notification_rdg);
1368 g_notification_type_genlist = genlist;
1370 elm_object_part_content_set(popup, "elm.genlist", genlist);
1371 evas_object_show(genlist);
1372 elm_genlist_item_class_free(itc);
1374 btn = elm_button_add(popup);
1375 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1376 elm_object_text_set(btn, _("IDS_ST_BUTTON_CANCEL_ABB2"));
1377 elm_object_part_content_set(popup, "btn.left", btn);
1378 evas_object_smart_callback_add(btn, "clicked", _response_notification_cancel_cb, ad);
1380 btn = elm_button_add(popup);
1381 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1382 elm_object_text_set(btn, _("IDS_WNOTI_BUTTON_OK_ABB2"));
1383 elm_object_part_content_set(popup, "btn.right", btn);
1384 evas_object_smart_callback_add(btn, "clicked", _response_notification_ok_cb, ad);
1386 elm_naviframe_item_push(ad->nf, _("IDS_ST_BUTTON_NOTIFICATIONS"), NULL, NULL, popup, NULL);
1387 ea_object_event_callback_add(ad->nf, EA_CALLBACK_BACK, _notification_back_cb, ad);
1389 /*VCONFKEY_PM_STATE */
1390 register_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb, NULL);
1393 static void _response_vibration_ok_cb(void *data, Evas_Object *obj, void *event_info)
1395 /* save a vibration level */
1400 switch (vibrate_type) {
1401 case VIBRATION_LEVEL_LOW:
1402 vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_LOW_INT);
1403 vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_LOW_INT);
1405 case VIBRATION_LEVEL_HIGH:
1406 vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT);
1407 vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT);
1413 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
1414 DBG("Setting - vibration level : %d", level);
1416 if (g_vibration_type_genlist != NULL) {
1417 evas_object_del(g_vibration_type_genlist);
1418 g_vibration_type_genlist = NULL;
1421 if (temp_ad->vibration_rdg != NULL) {
1422 evas_object_del(temp_ad->vibration_rdg);
1423 temp_ad->vibration_rdg = NULL;
1426 appdata *ad = (appdata *)data;
1428 elm_naviframe_item_pop(ad->nf);
1431 if (g_vib_item != NULL) {
1432 elm_genlist_item_update(g_vib_item);
1436 static void _response_vibration_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1440 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &vibrate_type);
1442 DBG("Setting - vibrate type have backed : %d", vibrate_type);
1444 if (g_vibration_type_genlist != NULL) {
1445 evas_object_del(g_vibration_type_genlist);
1446 g_vibration_type_genlist = NULL;
1449 appdata *ad = (appdata *)data;
1451 elm_naviframe_item_pop(ad->nf);
1455 static char *_gl_vibration_text_get(void *data, Evas_Object *obj, const char *part)
1457 Item_Data *item = data;
1461 return strdup(_(vibration_str[item->index % 2]));
1464 static Evas_Object *_gl_vibration_radio_get(void *data, Evas_Object *obj, const char *part)
1466 Evas_Object *radio = NULL;
1467 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
1468 Item_Data *id = data;
1469 int index = id->index;
1471 if (!strcmp(part, "elm.icon")) {
1472 radio = elm_radio_add(obj);
1473 elm_object_style_set(radio, "list");
1474 elm_radio_state_value_set(radio, id->index);
1475 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
1476 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1477 elm_radio_group_add(radio, radio_main);
1478 evas_object_smart_callback_add(radio, "changed", _vibration_gl_cb, (void *)id->index);
1479 evas_object_propagate_events_set(radio, EINA_FALSE);
1481 if (vibrate_type == id->index) {
1482 elm_radio_value_set(radio_main, vibrate_type);
1489 static void _vibration_gl_cb(void *data, Evas_Object *obj, void *event_info)
1491 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1493 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &origin_vibration_level);
1495 vibrate_type = (int)data;
1497 int level = VIBRATION_LEVEL_LOW_INT;
1498 int feedback_rate = SETTING_VIB_MEDIUM_RATE;
1499 switch (vibrate_type) {
1501 /* level = VIBRATION_LEVEL_LOW_INT; */
1502 /* feedback_rate = SETTING_VIB_WEAK_RATE; */
1505 level = VIBRATION_LEVEL_LOW_INT;
1506 feedback_rate = SETTING_VIB_WEAK_RATE;
1509 level = VIBRATION_LEVEL_HIGH_INT;
1510 feedback_rate = SETTING_VIB_STRONG_RATE;
1514 DBG("Setting - feedback level: %d, rate: %d", level, feedback_rate);
1516 _start_vibration(level, feedback_rate, SETTING_DEFAULT_NOTIFICATION_GENERAL_PREVIEW_VIB);
1518 elm_genlist_realized_items_update(g_vibration_type_genlist);
1521 static void _vibration_layout_del_cb(void *data, Evas_Object *obj, void *event_info)
1523 DBG("Setting - _vibration_layout_del_cb() is called!");
1528 elm_genlist_item_update(g_vib_item);
1532 static int get_vibration_type()
1536 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &origin_vibration_level);
1537 switch (origin_vibration_level) {
1538 case VIBRATION_LEVEL_LOW_INT:
1541 /* case VIBRATION_LEVEL_MID_INT: */
1544 case VIBRATION_LEVEL_HIGH_INT:
1552 void _show_vibration_popup_cb(void *data, Evas_Object *obj, void *event_info)
1554 Evas_Object *popup, *btn;
1558 vibrate_type = get_vibration_type();
1560 popup = elm_layout_add(ad->win_main);
1561 elm_layout_file_set(popup, EDJE_PATH, "setting/genlist/2button-layout");
1562 evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1563 evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
1564 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _vibration_layout_del_cb, ad);
1566 Elm_Genlist_Item_Class *itc = NULL;
1567 itc = elm_genlist_item_class_new();
1568 itc->item_style = "1text.1icon.1";
1569 itc->func.text_get = _gl_vibration_text_get;
1570 itc->func.content_get = _gl_vibration_radio_get;
1572 Evas_Object *genlist;
1573 genlist = elm_genlist_add(popup);
1574 elm_object_style_set(genlist, "popup");
1575 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1576 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1578 Evas_Object *circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
1579 eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1580 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
1585 int count = sizeof(vibration_str) / sizeof(vibration_str[0]);
1587 for (index = 0; index < count; index++) {
1588 Item_Data *item = (Item_Data *)calloc(sizeof(Item_Data), 1);
1590 item->index = index;
1591 item->item = elm_genlist_item_append(genlist,
1595 ELM_GENLIST_ITEM_NONE,
1601 ad->vibration_rdg = elm_radio_add(genlist);
1602 elm_radio_state_value_set(ad->vibration_rdg, 3);
1603 elm_radio_value_set(ad->vibration_rdg, notification_type);
1605 evas_object_data_set(genlist, "radio_main", ad->vibration_rdg);
1607 g_vibration_type_genlist = genlist;
1609 elm_object_part_content_set(popup, "elm.genlist", genlist);
1610 evas_object_show(genlist);
1611 elm_genlist_item_class_free(itc);
1613 btn = elm_button_add(popup);
1614 elm_object_style_set(btn, "default");
1615 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1616 elm_object_text_set(btn, _("IDS_ST_BUTTON_CANCEL_ABB2"));
1617 elm_object_part_content_set(popup, "btn.left", btn);
1618 evas_object_smart_callback_add(btn, "clicked", _response_vibration_cancel_cb, ad);
1620 btn = elm_button_add(popup);
1621 elm_object_style_set(btn, "default");
1622 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1623 elm_object_text_set(btn, _("IDS_WNOTI_BUTTON_OK_ABB2"));
1624 elm_object_part_content_set(popup, "btn.right", btn);
1625 evas_object_smart_callback_add(btn, "clicked", _response_vibration_ok_cb, ad);
1627 elm_naviframe_item_push(ad->nf, _("IDS_ST_HEADER_VIBRATION_ABB"), NULL, NULL, popup, NULL);
1630 static char *_gl_pref_arm_title_get(void *data, Evas_Object *obj, const char *part)
1632 char buf[1024] = {0,};
1633 Item_Data *id = data;
1634 int index = id->index;
1636 if (!strcmp(part, "elm.text")) {
1637 snprintf(buf, sizeof(buf) - 1, "%s", _(pref_arm_str[index % 2]));
1643 static Evas_Object *_gl_pref_arm_ridio_get(void *data, Evas_Object *obj, const char *part)
1645 Evas_Object *radio = NULL;
1646 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
1647 Item_Data *id = data;
1648 int index = id->index;
1649 int prefered_arm_type = 0;
1651 if (!strcmp(part, "elm.icon")) {
1652 radio = elm_radio_add(obj);
1653 elm_radio_state_value_set(radio, id->index);
1654 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
1655 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1656 elm_radio_group_add(radio, radio_main);
1657 evas_object_smart_callback_add(radio, "changed", NULL, (void *)id->index);
1659 vconf_get_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, &prefered_arm_type);
1661 prefered_arm_type = (prefered_arm_type) ? 0 : 1;
1663 if (pref_arm_type == id->index) {
1664 elm_radio_value_set(radio_main, pref_arm_type);
1671 static void _pref_arm_gl_del(void *data, Evas_Object *obj)
1673 Item_Data *id = data;
1678 static void _pref_arm_gl_cb(void *data, Evas_Object *obj, void *event_info)
1680 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1682 pref_arm_type = (int)data;
1684 elm_genlist_realized_items_update(g_pref_arm_type_genlist);
1687 elm_naviframe_item_pop(temp_ad->nf);
1688 if (!temp_ad->pref_arm_rdg) {
1689 evas_object_del(temp_ad->pref_arm_rdg);
1690 temp_ad->pref_arm_rdg = NULL;
1693 /* save a perfered arm type */
1694 vconf_set_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, (pref_arm_type == 0) ? TRUE : FALSE);
1696 if (g_sound_genlist) {
1697 elm_genlist_realized_items_update(g_sound_genlist);
1700 /* show toast message */
1702 struct _toast_data *toast = _create_toast(temp_ad, _(pref_arm_toast_msg[pref_arm_type % 2]));
1704 _show_toast(temp_ad, toast);
1709 void _show_pref_arm_mode_list(void *data)
1713 DBG("%s", "_show_pref_arm_mode_list - appdata is null");
1716 Evas_Object *genlist = NULL;
1717 Elm_Object_Item *item = NULL;
1718 Elm_Object_Item *nf_it = NULL;
1719 /*struct _dt_menu_item *menu_its = NULL; */
1721 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
1722 itc->item_style = "1text.1icon.1";
1723 itc->func.text_get = _gl_pref_arm_title_get;
1724 itc->func.content_get = _gl_pref_arm_ridio_get;
1725 itc->func.del = _pref_arm_gl_del;
1727 Evas_Object *layout = elm_layout_add(ad->nf);
1728 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
1729 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1731 genlist = elm_genlist_add(layout);
1732 elm_genlist_block_count_set(genlist, 14);
1733 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1734 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1736 Evas_Object *circle_genlist = eext_circle_object_genlist_add(genlist, ad->circle_surface);
1737 eext_circle_object_genlist_scroller_policy_set(circle_genlist, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
1738 eext_rotary_object_event_activated_set(circle_genlist, EINA_TRUE);
1743 Item_Data *id = calloc(sizeof(Item_Data), 1);
1746 item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _pref_arm_gl_cb, (void *)0);
1750 Item_Data *id2 = calloc(sizeof(Item_Data), 1);
1753 item = elm_genlist_item_append(genlist, itc, id2, NULL, ELM_GENLIST_ITEM_NONE, _pref_arm_gl_cb, (void *)1);
1757 ad->pref_arm_rdg = elm_radio_add(genlist);
1758 elm_radio_state_value_set(ad->pref_arm_rdg, 2);
1759 elm_radio_value_set(ad->pref_arm_rdg, pref_arm_type);
1761 evas_object_data_set(genlist, "radio_main", ad->pref_arm_rdg);
1763 elm_genlist_item_class_free(itc);
1765 g_pref_arm_type_genlist = genlist;
1767 elm_object_part_content_set(layout, "elm.genlist", genlist);
1769 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
1770 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);