2 * Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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_MEDIUM_M_INTENSITY",
63 "IDS_ST_OPT_WEAK_M_INTENSITY"
65 char* pref_arm_str[] = {
66 "IDS_ST_OPT_LEFT_ARM_ABB",
67 "IDS_ST_OPT_RIGHT_ARM_ABB"
69 char* pref_arm_toast_msg[] = {
70 "IDS_ST_TPOP_MAIN_MIC_ADJUSTED_FOR_LEFT_ARM",
71 "IDS_ST_TPOP_MAIN_MIC_ADJUSTED_FOR_RIGHT_ARM"
74 static char ringtone_arr[RINGTONE_MAX_COUNT][1024];
75 static char ringtone_name_arr[RINGTONE_MAX_COUNT][1024];
76 static char notification_arr[RINGTONE_MAX_COUNT][1024];
77 static char notification_name_arr[RINGTONE_MAX_COUNT][1024];
79 static appdata* temp_ad = NULL;
80 static Evas_Object* g_sound_genlist = NULL;
81 static Evas_Object* g_sound_mode_genlist = NULL;
82 static Evas_Object* g_ringtone_type_genlist = NULL;
83 static Evas_Object* g_notification_type_genlist = NULL;
84 static Evas_Object* g_vibration_type_genlist = NULL;
85 static Evas_Object* g_pref_arm_type_genlist = NULL;
86 static Elm_Object_Item * g_vib_item = NULL;
88 static int sound_mode = 1; // Vibrate
89 static int ringtone_type = 0; // Rigntone type
90 static int confirmed_ringtone_type = 0; // setted Rigntone type
91 static int notification_type = 0; // Notification type
92 static int confirmed_Notification_type = 0; // setted Notification type
93 static int vibrate_type = 0; // Vibration type
94 static int pref_arm_type = 0; // Pref_arm_type
95 static int changing_sound_mode_myself = 0;
97 static int ringtone_count = 0;
98 static int notification_count = 0;
100 char curr_ringtone_file_path[1023];
101 char curr_noti_file_path[1023];
103 static int cur_sound_type;
104 static int is_loaded_ringtone_data = 0;
105 static int is_loaded_noti_data = 0;
106 static int origin_vibration_level;
108 static Ecore_Timer * vibration_timer = NULL;
110 static int is_wav_playing = SOUND_STATE_STOP;
111 static int sound_id = -1;
114 static void sound_vconf_changed_cb(keynode_t * key, void * data);
115 static void vibrate_vconf_changed_cb(keynode_t * key, void * data);
116 static void pm_state_vconf_changed_cb(keynode_t * key, void * data);
117 static void _vibration_gl_cb(void *data, Evas_Object *obj, void *event_info);
118 static void stop_wav();
124 //effect_playsound_init();
127 Eina_Bool _clear_sound_cb(void *data, Elm_Object_Item *it)
129 _clear_sound_resource();
134 void _clear_sound_resource()
136 if( vibration_timer ) {
137 ecore_timer_del(vibration_timer);
138 vibration_timer = NULL;
144 g_sound_genlist = NULL;
145 g_sound_mode_genlist = NULL;
146 g_ringtone_type_genlist = NULL;
147 g_notification_type_genlist = NULL;
148 g_vibration_type_genlist = NULL;
149 g_pref_arm_type_genlist = NULL;
154 notification_type = 0;
158 is_loaded_ringtone_data = 0;
159 is_loaded_noti_data = 0;
160 origin_vibration_level = 0;
167 /* Unregister sound mode vconf callback */
168 unregister_vconf_changing(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, sound_vconf_changed_cb);
169 unregister_vconf_changing(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vibrate_vconf_changed_cb);
172 void _stop_all_sound_play()
174 DBG("Setting - stop all sound");
181 static void stop_wav()
183 if( is_wav_playing == SOUND_STATE_PLAY ) {
184 DBG("Setting - sound id : %d", sound_id);
186 wav_player_stop(sound_id);
187 is_wav_playing = SOUND_STATE_STOP;
192 void _stop_wav_player()
199 DBG("Setting - _stop_player() is called!");
200 if( is_created_player() )
202 _close_player(NULL, cur_sound_type);
206 static void sorting_file_list(int type)
210 char * cur_ring_path = NULL;
213 if( ringtone_count == 0 )
218 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
219 if( cur_ring_path == NULL )
221 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
224 for( i = 0; i < 3; i++ )
226 for( j = i+1; j < 3; j++ )
228 if( strcmp(ringtone_name_arr[i], ringtone_name_arr[j]) > 0 )
231 strcpy(temp, ringtone_name_arr[i]);
232 strcpy(ringtone_name_arr[i], ringtone_name_arr[j]);
233 strcpy(ringtone_name_arr[j], temp);
236 strcpy(temp, ringtone_arr[i]);
237 strcpy(ringtone_arr[i], ringtone_arr[j]);
238 strcpy(ringtone_arr[j], temp);
243 for( i = 0; i < 3; i++ )
245 if( !strcmp(cur_ring_path, ringtone_arr[i]))
254 if( notification_count == 0 )
259 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
260 if( cur_ring_path == NULL )
262 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
265 for( i = 0; i < 3; i++ )
267 for( j = i+1; j < 3; j++ )
269 if( strcmp(notification_name_arr[i], notification_name_arr[j]) > 0 )
272 strcpy(temp, notification_name_arr[i]);
273 strcpy(notification_name_arr[i], notification_name_arr[j]);
274 strcpy(notification_name_arr[j], temp);
277 strcpy(temp, notification_arr[i]);
278 strcpy(notification_arr[i], notification_arr[j]);
279 strcpy(notification_arr[j], temp);
284 for( i = 0; i < 3; i++ )
286 if( !strcmp(cur_ring_path, notification_arr[i]))
288 notification_type = i;
295 static void get_sound_file_list(char* dir, int type)
299 char * cur_ring_path = NULL;
301 if((dp = opendir(dir)) == NULL ) {
302 DBG("Setting - dir open error!");
307 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
308 if( cur_ring_path == NULL )
310 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
316 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
317 if( cur_ring_path == NULL )
319 cur_ring_path = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
321 notification_count = 0;
324 while( (dirp = readdir(dp)) )
326 if( strncmp(dirp->d_name, ".", 1) )
330 strcpy(ringtone_arr[ringtone_count], dir);
331 strcat(ringtone_arr[ringtone_count], dirp->d_name);
333 strcpy(ringtone_name_arr[ringtone_count], replace(dirp->d_name, ".ogg", ""));
335 //DBG("Setting - %s", ringtone_arr[ringtone_count]);
337 if(!strcmp(cur_ring_path, ringtone_arr[ringtone_count]))
339 ringtone_type = ringtone_count;
340 //DBG("Settng - %s is same with %s", cur_ring_path, ringtone_arr[ringtone_count]);
342 //DBG("Settng - %s is same with %s", cur_ring_path, ringtone_arr[ringtone_count]);
348 strcpy(notification_arr[notification_count], dir);
349 strcat(notification_arr[notification_count], dirp->d_name);
351 strcpy(notification_name_arr[notification_count], replace(dirp->d_name, ".ogg", ""));
352 strcpy(notification_name_arr[notification_count], replace(notification_name_arr[notification_count], "_", " "));
354 //DBG("Setting - %s", notification_arr[notification_count]);
356 if(!strcmp(cur_ring_path, notification_arr[notification_count]))
358 notification_type = notification_count;
359 //DBG("Settng - %s is same with %s", cur_ring_path, notification_arr[notification_count]);
361 //DBG("Settng - %s is same with %s", cur_ring_path, notification_arr[notification_count]);
363 notification_count++;
371 static int get_vibration_level()
376 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
379 case VIBRATION_LEVEL_LOW_INT :
380 mode = VIBRATION_LEVEL_LOW;
382 // case VIBRATION_LEVEL_MID_INT :
383 // mode = VIBRATION_LEVEL_MID;
385 case VIBRATION_LEVEL_HIGH_INT :
386 mode = VIBRATION_LEVEL_HIGH;
392 void _show_volume_list(void *data)
394 Evas_Object* genlist = NULL;
395 Elm_Object_Item *nf_it = NULL;
400 DBG("Setting - ad is null");
404 _initialize_volume();
406 genlist = _create_volume_list(data);
409 DBG("%s", "volume cb - genlist is null");
412 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
413 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
414 evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, _clear_volume_cb, ad);
417 void _volume_cb(void *data, Evas_Object *obj, void *event_info)
419 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
421 _show_volume_list(data);
424 void _sound_mode_cb(void *data, Evas_Object *obj, void *event_info)
426 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
428 _show_sound_mode_list(data);
431 void _touch_sound_cb(void *data, Evas_Object *obj, void *event_info)
433 Elm_Object_Item* it = (Elm_Object_Item *)event_info;
438 DBG("%s", "_touch_sound_cb - appdata or check is null");
441 sound_menu_its[2].is_enable_touch_sound = sound_menu_its[2].is_enable_touch_sound ? 0 : 1;
442 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
443 vconf_set_bool(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
445 elm_genlist_item_selected_set(it, EINA_FALSE);
447 elm_genlist_item_update(it);
450 void _ringtone_cb(void *data, Evas_Object *obj, void *event_info)
452 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
454 _show_ringtone_popup_cb(data, obj, event_info);
457 void _noti_cb(void *data, Evas_Object *obj, void *event_info)
459 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
461 _show_notification_popup_cb(data, obj, event_info);
464 void _vibrate_cb(void *data, Evas_Object *obj, void *event_info)
466 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
468 _show_vibration_popup_cb(data, obj, event_info);
471 void _preferred_cb(void *data, Evas_Object *obj, void *event_info)
473 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
475 _show_pref_arm_mode_list(data);
478 static char * _get_sound_file_name(char * full_name)
481 char * temp_token = NULL;
484 DBG("Setting - %s, %s", token, full_name);
486 strtok(full_name, sep);
489 token = strtok(NULL, sep);
490 if( token != NULL ) {
493 }while( token != NULL );
495 char * result_token = NULL;
498 temp_token = replace(temp_token, ".ogg", "");
499 result_token = replace(temp_token, "_", " ");
504 char * _gl_Sound_title_get(void *data, Evas_Object *obj, const char *part)
507 Item_Data *id = data;
508 int index = id->index;
509 char * pa_cur_ringtone = NULL;
511 if( !strcmp(part, "elm.text.1") || !strcmp(part, "elm.text") )
513 snprintf(buf, sizeof(buf)-1, "%s", _(sound_menu_its[index % ITEM_SIZE].name));
515 else if( !strcmp(part, "elm.text.2") )
519 sound_mode = get_sound_mode();
520 snprintf(buf, sizeof(buf)-1, "%s", _(sound_mode_str[sound_mode % 3]));
523 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
524 if( pa_cur_ringtone == NULL ) {
525 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_DEFAULT_PATH_STR);
527 strcpy(curr_ringtone_file_path, pa_cur_ringtone);
528 DBG("Setting - ringtone path : %s", pa_cur_ringtone);
530 snprintf(buf, sizeof(buf)-1, "%s", _get_sound_file_name(pa_cur_ringtone));
533 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
534 if( pa_cur_ringtone == NULL ) {
535 pa_cur_ringtone = vconf_get_str(VCONFKEY_SETAPPL_NOTI_RINGTONE_DEFAULT_PATH_STR);
537 strcpy(curr_noti_file_path, pa_cur_ringtone);
538 DBG("Setting - noti's ringtone path : %s", pa_cur_ringtone);
540 snprintf(buf, sizeof(buf)-1, "%s", _get_sound_file_name(pa_cur_ringtone));
543 vibrate_type = get_vibration_level();
544 snprintf(buf, sizeof(buf)-1, "%s", _(vibration_str[vibrate_type % 3]));
548 vconf_get_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, &pref_arm_type);
549 pref_arm_type = (pref_arm_type == TRUE) ? 0 : 1;
550 snprintf(buf, sizeof(buf)-1, "%s", _(pref_arm_str[pref_arm_type % 2]));
559 void _sound_chk_changed_cb(void *data, Evas_Object *obj, void *event_info)
561 DBG("Setting - _sound_chk_changed_cb() is called!!");
563 vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &sound_menu_its[2].is_enable_touch_sound);
565 sound_menu_its[2].is_enable_touch_sound = !sound_menu_its[2].is_enable_touch_sound;
567 /* Update touch sound enable state */
568 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
569 vconf_set_bool(VCONFKEY_SETAPPL_BUTTON_SOUNDS_BOOL, sound_menu_its[2].is_enable_touch_sound);
572 static void _sound_gl_del(void *data, Evas_Object *obj)
574 Sound_Item_Data *id = data;
579 Evas_Object * _gl_sound_check_get(void *data, Evas_Object *obj, const char *part)
581 Evas_Object *check = NULL;
583 Sound_Item_Data *id = data;
584 int index = id->index;
586 if( !strcmp(part, "elm.icon") )
588 check = elm_check_add(obj);
590 if (vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &sound_menu_its[2].is_enable_touch_sound) < 0)
592 sound_menu_its[2].is_enable_touch_sound = TOUCH_SOUND_ENABLE; /* default value of touch sounds : on */
594 elm_check_state_set(check, (sound_menu_its[2].is_enable_touch_sound) ? EINA_TRUE : EINA_FALSE);
595 evas_object_smart_callback_add(check, "changed", _sound_chk_changed_cb, (void *)1);
596 evas_object_size_hint_align_set(check, EVAS_HINT_FILL, EVAS_HINT_FILL);
597 evas_object_size_hint_weight_set(check, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
598 evas_object_propagate_events_set(check, EINA_FALSE);
608 Evas_Object* _create_sound_list(void* data)
613 DBG("%s", "_create_sound_list - appdata is null");
619 Evas_Object *genlist = NULL;
620 struct _sound_menu_item *menu_its = NULL;
623 Elm_Genlist_Item_Class *itc_tmp;
625 Elm_Genlist_Item_Class *itc_1text = elm_genlist_item_class_new();
626 itc_1text->item_style = "1text";
627 itc_1text->func.text_get = _gl_Sound_title_get;
628 itc_1text->func.del = _sound_gl_del;
630 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
631 itc->item_style = "2text";
632 itc->func.text_get = _gl_Sound_title_get;
633 itc->func.del = _sound_gl_del;
635 Elm_Genlist_Item_Class *itc_touch_snd = elm_genlist_item_class_new();
636 itc_touch_snd->item_style = "1text.1icon.1";
637 itc_touch_snd->func.text_get = _gl_Sound_title_get;
638 itc_touch_snd->func.content_get = _gl_sound_check_get;
639 itc_touch_snd->func.del = _sound_gl_del;
641 genlist = elm_genlist_add(ad->nf);
642 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
644 menu_its = sound_menu_its;
646 for (idx = 0; idx < ITEM_SIZE; idx++)
654 itc_tmp = itc_touch_snd;
661 Sound_Item_Data *id = calloc(sizeof(Sound_Item_Data), 1);
663 id->item = elm_genlist_item_append(
664 genlist, // genlist object
665 itc_tmp, // item class
668 ELM_GENLIST_ITEM_NONE,
669 menu_its[ idx ].func, // call back
672 if( idx == ITEM_SIZE-1 )
674 g_vib_item = id->item;
677 elm_genlist_item_class_free(itc_1text);
678 elm_genlist_item_class_free(itc);
679 elm_genlist_item_class_free(itc_touch_snd);
681 g_sound_genlist = genlist;
683 /* Register sound mode vconf callback */
684 register_vconf_changing(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, sound_vconf_changed_cb, NULL);
685 register_vconf_changing(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, vibrate_vconf_changed_cb, NULL);
690 static char * _gl_sound_mode_title_get(void *data, Evas_Object *obj, const char *part)
693 Item_Data *id = data;
694 int index = id->index;
696 if( !strcmp(part, "elm.text") )
698 snprintf(buf, sizeof(buf)-1, "%s", _(sound_mode_str[index % 3]));
704 static Evas_Object * _gl_sound_mode_ridio_get(void *data, Evas_Object *obj, const char *part)
706 Evas_Object *radio = NULL;
707 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
708 Item_Data *id = data;
709 int index = id->index;
711 if( !strcmp(part, "elm.icon") )
713 radio = elm_radio_add(obj);
714 elm_radio_state_value_set(radio, id->index);
715 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
716 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
717 elm_radio_group_add(radio, radio_main);
718 evas_object_smart_callback_add(radio, "changed", NULL, (void *)id->index);
719 if( sound_mode == id->index )
720 elm_radio_value_set(radio_main, sound_mode);
727 static void _sound_mode_gl_del(void *data, Evas_Object *obj)
729 Item_Data *id = data;
734 static int curr_touch_sound = 0;
737 static void _sound_mode_gl_cb(void *data, Evas_Object *obj, void *event_info)
739 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
741 sound_mode = (int)data;
743 changing_sound_mode_myself = 1;
745 if(g_sound_mode_genlist)
747 elm_genlist_realized_items_update(g_sound_mode_genlist);
750 int ringtone_level = 0;
751 int prev_sound_mode = get_sound_mode();
756 case SOUND_MODE_SOUND:
757 if( get_sound_mode() != SOUND_MODE_SOUND )
759 DBG("Setting - current sound mode is not sound!! Change sound mode to sound!!");
761 vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &curr_touch_sound);
762 if( curr_touch_sound )
764 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, FALSE);
767 vconf_get_int(SETTING_RINGTONE_VOLUME_BACKUP, &ringtone_level);
768 DBG("Setting - ringtone backup level: %d", ringtone_level);
770 vconf_set_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, ringtone_level);
772 if( is_created_player() )
774 _close_player(NULL, SOUND_TYPE_RINGTONE);
776 play_sound_for_sound_mode(SETTING_DEFAULT_SILENT_OFF_TONE, 0.0, SOUND_TYPE_RINGTONE);
779 sound_manager_get_volume(SOUND_TYPE_RINGTONE, &ringtone_level);
780 if( ringtone_level == 0 )
782 DBG("Setting - Ringtone volume is 0!! Restore to 1!!");
783 sound_manager_set_volume(SOUND_TYPE_RINGTONE, 1);
786 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, TRUE);
787 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, FALSE);
789 vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, curr_touch_sound);
790 curr_touch_sound = 0;
793 case SOUND_MODE_VIBRATE:
794 if( prev_sound_mode != SOUND_MODE_VIBRATE )
796 DBG("Setting - current sound mode is not vibration. Change sound mode to vibration!!");
798 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE);
799 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, TRUE);
801 vconf_get_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, &ringtone_level);
802 DBG("Setting - ringtone original level: %d", ringtone_level);
804 vconf_set_int(SETTING_RINGTONE_VOLUME_BACKUP, ringtone_level);
805 //sound_manager_set_muteall(TRUE); // mute!!
807 _start_vibration(5, SETTING_VIB_STRONG_RATE, SETTING_DEFAULT_SYSTEM_HAPTIC_PREVIEW_VIB);
809 case SOUND_MODE_MUTE:
810 if( prev_sound_mode != SOUND_MODE_MUTE )
812 DBG("Setting - current sound mode is not mute. Change sound mode to mute!!");
814 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE);
815 vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, FALSE);
817 vconf_get_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, &ringtone_level);
818 DBG("Setting - ringtone original level: %d", ringtone_level);
820 vconf_set_int(SETTING_RINGTONE_VOLUME_BACKUP, ringtone_level);
821 //sound_manager_set_muteall(TRUE); // mute!!
825 ERR("Setting - wrong sound mode value!!");
829 elm_naviframe_item_pop(temp_ad->nf);
830 if(!temp_ad->sound_mode_rdg)
832 evas_object_del(temp_ad->sound_mode_rdg);
833 temp_ad->sound_mode_rdg = NULL;
836 if( g_sound_genlist )
838 elm_genlist_realized_items_update(g_sound_genlist);
842 static void sound_vconf_changed_cb(keynode_t * key, void * data)
844 DBG("Setting - sound_vconf_changed_cb() is called!!");
846 if(changing_sound_mode_myself)
848 DBG("Setting - changing_sound_mode_myself!!");
850 changing_sound_mode_myself = 0;
854 sound_mode = get_sound_mode();
856 if( g_sound_mode_genlist )
858 elm_genlist_realized_items_update(g_sound_mode_genlist);
861 if( g_sound_genlist )
863 elm_genlist_realized_items_update(g_sound_genlist);
867 static void vibrate_vconf_changed_cb(keynode_t * key, void * data)
869 DBG("Setting - vibrate_vconf_changed_cb() is called!!");
871 sound_mode = get_sound_mode();
873 if( g_sound_mode_genlist )
875 elm_genlist_realized_items_update(g_sound_mode_genlist);
878 if( g_sound_genlist )
880 elm_genlist_realized_items_update(g_sound_genlist);
884 Eina_Bool _sound_mode_back_cb(void *data, Elm_Object_Item *it)
886 g_sound_mode_genlist = NULL;
891 void _show_sound_mode_list(void* data)
896 DBG("%s", "_show_sound_mode_list - appdata is null");
899 Evas_Object *genlist = NULL;
900 Elm_Object_Item *item = NULL;
901 Elm_Object_Item *nf_it = NULL;
903 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
904 itc->item_style = "1text.1icon.1";
905 itc->func.text_get = _gl_sound_mode_title_get;
906 itc->func.content_get = _gl_sound_mode_ridio_get;
907 itc->func.del = _sound_mode_gl_del;
909 sound_mode = get_sound_mode();
911 Evas_Object * layout = elm_layout_add(ad->nf);
912 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
913 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
915 genlist = elm_genlist_add(layout);
916 elm_genlist_block_count_set(genlist, 14);
917 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
918 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
920 Item_Data *id = calloc(sizeof(Item_Data), 1);
922 item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void*)0);
925 Item_Data *id2 = calloc(sizeof(Item_Data), 1);
927 item = elm_genlist_item_append(genlist, itc, id2, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void*)1);
930 Item_Data *id3 = calloc(sizeof(Item_Data), 1);
932 item = elm_genlist_item_append(genlist, itc, id3, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void*)2);
935 ad->sound_mode_rdg = elm_radio_add(genlist);
936 elm_radio_state_value_set(ad->sound_mode_rdg, 3);
937 elm_radio_value_set(ad->sound_mode_rdg, sound_mode);
939 evas_object_data_set(genlist, "radio_main", ad->sound_mode_rdg);
941 elm_genlist_item_class_free(itc);
943 g_sound_mode_genlist = genlist;
945 elm_object_part_content_set(layout, "elm.genlist", genlist);
947 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
948 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);
949 elm_naviframe_item_pop_cb_set(nf_it, _sound_mode_back_cb, ad);
952 static void _response_ringtone_ok_cb(void *data, Evas_Object *obj, void *event_info)
954 appdata * ad = (appdata *)data;
962 // save a ringtone type.
963 vconf_set_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR ,ringtone_arr[ringtone_type]);
965 if( g_ringtone_type_genlist != NULL)
967 evas_object_del(g_ringtone_type_genlist);
968 g_ringtone_type_genlist = NULL;
971 if( temp_ad->ringtone_type_rdg != NULL )
973 evas_object_del(temp_ad->ringtone_type_rdg);
974 temp_ad->ringtone_type_rdg = NULL;
979 elm_naviframe_item_pop(ad->nf);
982 if( g_sound_genlist != NULL )
984 elm_genlist_realized_items_update(g_sound_genlist);
987 confirmed_ringtone_type = ringtone_type;
990 static void _response_ringtone_cancel_cb(void *data, Evas_Object *obj, void *event_info)
992 if( g_ringtone_type_genlist != NULL)
994 evas_object_del(g_ringtone_type_genlist);
995 g_ringtone_type_genlist = NULL;
998 appdata * ad = (appdata *)data;
1001 elm_naviframe_item_pop(ad->nf);
1006 ringtone_type = confirmed_ringtone_type;
1014 static char *_gl_ringtone_text_get(void *data, Evas_Object *obj, const char *part)
1016 Item_Data * item = data;
1022 sprintf(buf, "%s", ringtone_name_arr[item->index % ringtone_count]);
1027 static Evas_Object *_gl_ringtone_radio_get(void *data, Evas_Object *obj, const char *part)
1029 Evas_Object *radio = NULL;
1030 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
1031 Item_Data *id = data;
1032 int index = id->index;
1034 if( !strcmp(part, "elm.icon") )
1036 radio = elm_radio_add(obj);
1037 elm_radio_state_value_set(radio, id->index);
1038 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
1039 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1040 elm_radio_group_add(radio, radio_main);
1042 if( id->index == ringtone_type )
1044 elm_radio_value_set(radio_main, id->index);
1051 static void _ringtone_type_gl_cb(void *data, Evas_Object *obj, void *event_info)
1053 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1055 ringtone_type = (int)data;
1060 is_wav_playing = SOUND_STATE_PLAY;
1061 wav_player_start(ringtone_arr[ringtone_type], SOUND_TYPE_RINGTONE, NULL, (void*)1, &sound_id);
1065 sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
1067 if( volume == 0 || get_sound_mode() != SOUND_MODE_SOUND )
1071 struct _toast_data * toast = _create_toast(temp_ad, _("IDS_ST_TPOP_VOLUME_CURRENTLY_SET_TO_0"));
1073 _show_toast(temp_ad, toast);
1079 play_sound(ringtone_arr[ringtone_type], 0.0, SOUND_TYPE_RINGTONE);
1082 elm_genlist_realized_items_update(g_ringtone_type_genlist);
1085 static void _ringtone_back_cb(void * data, Evas_Object * obj, void * event_info)
1091 ringtone_type = confirmed_ringtone_type;
1093 _stop_all_sound_play();
1095 unregister_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb);
1099 static void pm_state_vconf_changed_cb(keynode_t * key, void * data)
1101 DBG("Setting - pm_state_vconf_changed_cb() is called!");
1104 vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
1106 if (pm_state == VCONFKEY_PM_STATE_LCDOFF)
1108 DBG("Setting - LCD Off!! stop sound!");
1109 _stop_all_sound_play();
1113 void _show_ringtone_popup_cb(void *data, Evas_Object *obj, void *event_info)
1115 Evas_Object *popup, *btn;
1122 ad->MENU_TYPE = SETTING_SOUND_RINGTONE;
1124 if( is_loaded_ringtone_data == 0 )
1126 get_sound_file_list("/opt/share/settings/Ringtones/", 1);
1127 is_loaded_ringtone_data = 1;
1129 sorting_file_list(1);
1132 cur_sound_type = SOUND_TYPE_RINGTONE;
1134 popup = elm_layout_add(ad->win_main);
1135 elm_layout_file_set(popup, EDJE_PATH, "setting/genlist/2button-layout");
1136 evas_object_size_hint_weight_set (popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1137 evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
1140 Elm_Genlist_Item_Class *itc = NULL;
1141 itc = elm_genlist_item_class_new();
1142 itc->item_style = "settings.1text.1icon.1"; //"1text.1icon.1";
1143 itc->func.text_get = _gl_ringtone_text_get;
1144 itc->func.content_get = _gl_ringtone_radio_get;
1146 Evas_Object *genlist;
1147 genlist = elm_genlist_add(popup);
1148 elm_object_style_set(genlist, "popup");
1149 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1151 for (index = 0; index < ringtone_count; index++)
1153 Item_Data * item = (Item_Data*)calloc(sizeof(Item_Data), 1);
1154 item->index = index;
1155 item->item = elm_genlist_item_append(genlist,
1159 ELM_GENLIST_ITEM_NONE,
1160 _ringtone_type_gl_cb,
1164 ad->ringtone_type_rdg = elm_radio_add(genlist);
1165 elm_radio_state_value_set(ad->ringtone_type_rdg, ringtone_count);
1166 elm_radio_value_set(ad->ringtone_type_rdg, ringtone_type);
1167 confirmed_ringtone_type = ringtone_type;
1169 evas_object_data_set(genlist, "radio_main", ad->ringtone_type_rdg);
1171 g_ringtone_type_genlist = genlist;
1173 elm_object_part_content_set(popup, "elm.genlist", genlist);
1174 evas_object_show(genlist);
1176 elm_genlist_item_class_free(itc);
1178 btn = elm_button_add(popup);
1179 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1180 elm_object_text_set(btn, _("IDS_ST_BUTTON_CANCEL_ABB2"));
1181 elm_object_part_content_set(popup, "btn.left", btn);
1182 evas_object_smart_callback_add(btn, "clicked", _response_ringtone_cancel_cb, ad);
1184 btn = elm_button_add(popup);
1185 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1186 elm_object_text_set(btn, _("IDS_WNOTI_BUTTON_OK_ABB2"));
1187 elm_object_part_content_set(popup, "btn.right", btn);
1188 evas_object_smart_callback_add(btn, "clicked", _response_ringtone_ok_cb, ad);
1190 elm_naviframe_item_push( ad->nf, _("IDS_ST_HEADER_RINGTONES_ABB"), NULL, NULL, popup, NULL );
1191 ea_object_event_callback_add(ad->nf, EA_CALLBACK_BACK, _ringtone_back_cb, ad);
1194 register_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb,NULL);
1197 static void _notification_back_cb(void * data, Evas_Object * obj, void * event_info)
1203 notification_type = confirmed_Notification_type;
1205 _stop_all_sound_play();
1207 unregister_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb);
1210 static void _response_notification_ok_cb(void *data, Evas_Object *obj, void *event_info)
1214 if( is_created_player() )
1216 _close_player(NULL, SOUND_TYPE_NOTIFICATION);
1219 // save a notification type.
1220 vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR ,notification_arr[notification_type]);
1222 if( g_notification_type_genlist != NULL)
1224 evas_object_del(g_notification_type_genlist);
1225 g_notification_type_genlist = NULL;
1228 if( temp_ad->notification_rdg != NULL )
1230 evas_object_del(temp_ad->notification_rdg);
1231 temp_ad->notification_rdg = NULL;
1234 confirmed_Notification_type = notification_type;
1236 appdata * ad = (appdata *)data;
1239 elm_naviframe_item_pop(ad->nf);
1242 if( g_sound_genlist != NULL )
1244 elm_genlist_realized_items_update(g_sound_genlist);
1248 static void _response_notification_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1250 if( g_notification_type_genlist != NULL)
1252 evas_object_del(g_notification_type_genlist);
1253 g_notification_type_genlist = NULL;
1256 appdata * ad = (appdata *)data;
1259 elm_naviframe_item_pop(ad->nf);
1262 notification_type = confirmed_Notification_type;
1264 if( is_created_player() )
1266 _close_player(NULL, SOUND_TYPE_RINGTONE);
1272 static char *_gl_notification_text_get(void *data, Evas_Object *obj, const char *part)
1274 Item_Data * item = data;
1280 sprintf(buf, "%s", notification_name_arr[item->index % notification_count]);
1285 static Evas_Object *_gl_notification_radio_get(void *data, Evas_Object *obj, const char *part)
1287 Evas_Object *radio = NULL;
1288 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
1289 Item_Data *id = data;
1290 int index = id->index;
1292 if( !strcmp(part, "elm.icon") )
1294 radio = elm_radio_add(obj);
1295 elm_radio_state_value_set(radio, id->index);
1296 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
1297 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1298 elm_radio_group_add(radio, radio_main);
1299 if( id->index == notification_type )
1301 elm_radio_value_set(radio_main, id->index);
1308 static void _notification_gl_cb(void *data, Evas_Object *obj, void *event_info)
1310 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1312 notification_type = (int)data;
1315 is_wav_playing = SOUND_STATE_PLAY;
1316 wav_player_start(notification_arr[notification_type], SOUND_TYPE_NOTIFICATION, NULL, (void*)2, &sound_id);
1320 sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &volume);
1322 if( volume == 0 || get_sound_mode() != SOUND_MODE_SOUND )
1326 struct _toast_data * toast = _create_toast(temp_ad, _("IDS_ST_TPOP_VOLUME_CURRENTLY_SET_TO_0"));
1328 _show_toast(temp_ad, toast);
1334 play_sound(notification_arr[notification_type], 0.0, SOUND_TYPE_NOTIFICATION);
1338 if( g_notification_type_genlist )
1340 elm_genlist_realized_items_update(g_notification_type_genlist);
1344 void _show_notification_popup_cb(void *data, Evas_Object *obj, void *event_info)
1346 Evas_Object *popup, *btn;
1353 ad->MENU_TYPE = SETTING_SOUND_NOTIFICATION;
1355 if( is_loaded_noti_data == 0 )
1357 get_sound_file_list("/opt/share/settings/Alerts/", 0);
1358 is_loaded_noti_data = 1;
1360 sorting_file_list(0);
1363 cur_sound_type = SOUND_TYPE_NOTIFICATION;
1365 popup = elm_layout_add(ad->win_main);
1366 elm_layout_file_set(popup, EDJE_PATH, "setting/genlist/2button-layout");
1367 evas_object_size_hint_weight_set (popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1368 evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
1370 Elm_Genlist_Item_Class *itc = NULL;
1371 itc = elm_genlist_item_class_new();
1372 itc->item_style = "settings.1text.1icon.1"; //"1text.1icon.1";
1373 itc->func.text_get = _gl_notification_text_get;
1374 itc->func.content_get = _gl_notification_radio_get;
1376 Evas_Object *genlist;
1377 genlist = elm_genlist_add(popup);
1378 elm_object_style_set(genlist, "popup");
1379 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1382 for (index = 0; index < notification_count; index++)
1384 Item_Data * item = (Item_Data*)calloc(sizeof(Item_Data), 1);
1385 item->index = index;
1386 item->item = elm_genlist_item_append(genlist,
1390 ELM_GENLIST_ITEM_NONE,
1391 _notification_gl_cb,
1395 ad->notification_rdg = elm_radio_add(genlist);
1396 elm_radio_state_value_set(ad->notification_rdg, notification_count);
1397 elm_radio_value_set(ad->notification_rdg, notification_type);
1398 confirmed_Notification_type = notification_type;
1400 evas_object_data_set(genlist, "radio_main", ad->notification_rdg);
1402 g_notification_type_genlist = genlist;
1404 elm_object_part_content_set(popup, "elm.genlist", genlist);
1405 evas_object_show(genlist);
1406 elm_genlist_item_class_free(itc);
1408 btn = elm_button_add(popup);
1409 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1410 elm_object_text_set(btn, _("IDS_ST_BUTTON_CANCEL_ABB2"));
1411 elm_object_part_content_set(popup, "btn.left", btn);
1412 evas_object_smart_callback_add(btn, "clicked", _response_notification_cancel_cb, ad);
1414 btn = elm_button_add(popup);
1415 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1416 elm_object_text_set(btn, _("IDS_WNOTI_BUTTON_OK_ABB2"));
1417 elm_object_part_content_set(popup, "btn.right", btn);
1418 evas_object_smart_callback_add(btn, "clicked", _response_notification_ok_cb, ad);
1420 elm_naviframe_item_push( ad->nf, _("IDS_ST_BUTTON_NOTIFICATIONS"), NULL, NULL, popup, NULL );
1421 ea_object_event_callback_add(ad->nf, EA_CALLBACK_BACK, _notification_back_cb, ad);
1424 register_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb,NULL);
1427 static void _response_vibration_ok_cb(void *data, Evas_Object *obj, void *event_info)
1429 // save a vibration level
1434 switch(vibrate_type) {
1435 case VIBRATION_LEVEL_LOW:
1436 vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_LOW_INT);
1437 vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_LOW_INT);
1439 case VIBRATION_LEVEL_HIGH:
1440 vconf_set_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT);
1441 vconf_set_int(VCONFKEY_SETAPPL_TOUCH_FEEDBACK_VIBRATION_LEVEL_INT, VIBRATION_LEVEL_HIGH_INT);
1447 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
1448 DBG("Setting - vibration level : %d", level);
1450 if( g_vibration_type_genlist != NULL)
1452 evas_object_del(g_vibration_type_genlist);
1453 g_vibration_type_genlist = NULL;
1456 if( temp_ad->vibration_rdg != NULL )
1458 evas_object_del(temp_ad->vibration_rdg);
1459 temp_ad->vibration_rdg = NULL;
1462 appdata * ad = (appdata *)data;
1465 elm_naviframe_item_pop(ad->nf);
1468 if( g_vib_item != NULL )
1470 elm_genlist_item_update(g_vib_item);
1474 static void _response_vibration_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1478 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &vibrate_type);
1480 DBG("Setting - vibrate type have backed : %d", vibrate_type);
1482 if( g_vibration_type_genlist != NULL)
1484 evas_object_del(g_vibration_type_genlist);
1485 g_vibration_type_genlist = NULL;
1488 appdata * ad = (appdata *)data;
1491 elm_naviframe_item_pop(ad->nf);
1495 static char *_gl_vibration_text_get(void *data, Evas_Object *obj, const char *part)
1497 Item_Data * item = data;
1501 return strdup(_(vibration_str[item->index % 3]));
1504 static Evas_Object *_gl_vibration_radio_get(void *data, Evas_Object *obj, const char *part)
1506 Evas_Object *radio = NULL;
1507 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
1508 Item_Data *id = data;
1509 int index = id->index;
1511 if( !strcmp(part, "elm.icon") )
1513 radio = elm_radio_add(obj);
1514 elm_radio_state_value_set(radio, id->index);
1515 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
1516 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1517 elm_radio_group_add(radio, radio_main);
1518 evas_object_smart_callback_add(radio, "changed", _vibration_gl_cb, (void *)id->index);
1519 evas_object_propagate_events_set(radio, EINA_FALSE);
1521 if( vibrate_type == id->index )
1523 elm_radio_value_set(radio_main, vibrate_type);
1530 static void _vibration_gl_cb(void *data, Evas_Object *obj, void *event_info)
1532 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1534 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &origin_vibration_level);
1536 vibrate_type = (int)data;
1538 int level = VIBRATION_LEVEL_LOW_INT;
1539 int feedback_rate = SETTING_VIB_MEDIUM_RATE;
1540 switch( vibrate_type ){
1542 // level = VIBRATION_LEVEL_LOW_INT;
1543 // feedback_rate = SETTING_VIB_WEAK_RATE;
1546 level = VIBRATION_LEVEL_LOW_INT;
1547 feedback_rate = SETTING_VIB_WEAK_RATE;
1550 level = VIBRATION_LEVEL_HIGH_INT;
1551 feedback_rate = SETTING_VIB_STRONG_RATE;
1555 DBG("Setting - feedback level: %d, rate: %d", level, feedback_rate);
1557 _start_vibration(level, feedback_rate, SETTING_DEFAULT_NOTIFICATION_GENERAL_PREVIEW_VIB);
1559 elm_genlist_realized_items_update(g_vibration_type_genlist);
1562 static void _vibration_layout_del_cb(void *data, Evas_Object *obj, void *event_info)
1564 DBG("Setting - _vibration_layout_del_cb() is called!");
1570 elm_genlist_item_update(g_vib_item);
1574 static int get_vibration_type()
1578 vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &origin_vibration_level);
1579 switch( origin_vibration_level ){
1580 case VIBRATION_LEVEL_LOW_INT:
1583 // case VIBRATION_LEVEL_MID_INT:
1586 case VIBRATION_LEVEL_HIGH_INT:
1594 void _show_vibration_popup_cb(void *data, Evas_Object *obj, void *event_info)
1596 Evas_Object *popup, *btn;
1600 vibrate_type = get_vibration_type();
1602 popup = elm_layout_add(ad->win_main);
1603 elm_layout_file_set(popup, EDJE_PATH, "setting/genlist/2button-layout");
1604 evas_object_size_hint_weight_set (popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1605 evas_object_size_hint_align_set(popup, EVAS_HINT_FILL, EVAS_HINT_FILL);
1606 evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _vibration_layout_del_cb, ad);
1608 Elm_Genlist_Item_Class *itc = NULL;
1609 itc = elm_genlist_item_class_new();
1610 itc->item_style = "1text.1icon.1";
1611 itc->func.text_get = _gl_vibration_text_get;
1612 itc->func.content_get = _gl_vibration_radio_get;
1614 Evas_Object *genlist;
1615 genlist = elm_genlist_add(popup);
1616 elm_object_style_set(genlist, "popup");
1617 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1618 elm_genlist_homogeneous_set(genlist, EINA_TRUE);
1620 int count = sizeof(vibration_str) / sizeof(vibration_str[0]);
1622 for (index = 0; index < count; index++)
1624 Item_Data * item = (Item_Data*)calloc(sizeof(Item_Data), 1);
1625 item->index = index;
1626 item->item = elm_genlist_item_append(genlist,
1630 ELM_GENLIST_ITEM_NONE,
1635 ad->vibration_rdg = elm_radio_add(genlist);
1636 elm_radio_state_value_set(ad->vibration_rdg, 3);
1637 elm_radio_value_set(ad->vibration_rdg, notification_type);
1639 evas_object_data_set(genlist, "radio_main", ad->vibration_rdg);
1641 g_vibration_type_genlist = genlist;
1643 elm_object_part_content_set(popup, "elm.genlist", genlist);
1644 evas_object_show(genlist);
1645 elm_genlist_item_class_free(itc);
1647 btn = elm_button_add(popup);
1648 elm_object_style_set(btn, "default");
1649 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1650 elm_object_text_set(btn, _("IDS_ST_BUTTON_CANCEL_ABB2"));
1651 elm_object_part_content_set(popup, "btn.left", btn);
1652 evas_object_smart_callback_add(btn, "clicked", _response_vibration_cancel_cb, ad);
1654 btn = elm_button_add(popup);
1655 elm_object_style_set(btn, "default");
1656 evas_object_size_hint_weight_set(btn, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1657 elm_object_text_set(btn, _("IDS_WNOTI_BUTTON_OK_ABB2"));
1658 elm_object_part_content_set(popup, "btn.right", btn);
1659 evas_object_smart_callback_add(btn, "clicked", _response_vibration_ok_cb, ad);
1661 elm_naviframe_item_push( ad->nf, _("IDS_ST_HEADER_VIBRATION_ABB"), NULL, NULL, popup, NULL );
1664 static char * _gl_pref_arm_title_get(void *data, Evas_Object *obj, const char *part)
1667 Item_Data *id = data;
1668 int index = id->index;
1670 if( !strcmp(part, "elm.text") )
1672 snprintf(buf, sizeof(buf)-1, "%s", _(pref_arm_str[index % 2]));
1678 static Evas_Object * _gl_pref_arm_ridio_get(void *data, Evas_Object *obj, const char *part)
1680 Evas_Object *radio = NULL;
1681 Evas_Object *radio_main = evas_object_data_get(obj, "radio_main");
1682 Item_Data *id = data;
1683 int index = id->index;
1684 int prefered_arm_type = 0;
1686 if( !strcmp(part, "elm.icon") )
1688 radio = elm_radio_add(obj);
1689 elm_radio_state_value_set(radio, id->index);
1690 evas_object_size_hint_align_set(radio, EVAS_HINT_FILL, EVAS_HINT_FILL);
1691 evas_object_size_hint_weight_set(radio, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1692 elm_radio_group_add(radio, radio_main);
1693 evas_object_smart_callback_add(radio, "changed", NULL, (void *)id->index);
1695 vconf_get_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, &prefered_arm_type);
1697 prefered_arm_type = (prefered_arm_type) ? 0 : 1;
1699 if( pref_arm_type == id->index )
1701 elm_radio_value_set(radio_main, pref_arm_type);
1708 static void _pref_arm_gl_del(void *data, Evas_Object *obj)
1710 Item_Data *id = data;
1715 static void _pref_arm_gl_cb(void *data, Evas_Object *obj, void *event_info)
1717 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1719 pref_arm_type = (int)data;
1721 elm_genlist_realized_items_update(g_pref_arm_type_genlist);
1725 elm_naviframe_item_pop(temp_ad->nf);
1726 if(!temp_ad->pref_arm_rdg)
1728 evas_object_del(temp_ad->pref_arm_rdg);
1729 temp_ad->pref_arm_rdg = NULL;
1732 /* save a perfered arm type */
1733 vconf_set_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, (pref_arm_type==0) ? TRUE : FALSE);
1735 if( g_sound_genlist )
1737 elm_genlist_realized_items_update(g_sound_genlist);
1740 /* show toast message */
1743 struct _toast_data * toast = _create_toast(temp_ad, _(pref_arm_toast_msg[pref_arm_type % 2]));
1746 _show_toast(temp_ad, toast);
1751 void _show_pref_arm_mode_list(void* data)
1756 DBG("%s", "_show_pref_arm_mode_list - appdata is null");
1759 Evas_Object *genlist = NULL;
1760 Elm_Object_Item *item = NULL;
1761 Elm_Object_Item *nf_it = NULL;
1762 //struct _dt_menu_item *menu_its = NULL;
1764 Elm_Genlist_Item_Class *itc = elm_genlist_item_class_new();
1765 itc->item_style = "1text.1icon.1";
1766 itc->func.text_get = _gl_pref_arm_title_get;
1767 itc->func.content_get = _gl_pref_arm_ridio_get;
1768 itc->func.del = _pref_arm_gl_del;
1770 Evas_Object * layout = elm_layout_add(ad->nf);
1771 elm_layout_file_set(layout, EDJE_PATH, "setting/genlist/layout");
1772 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1774 genlist = elm_genlist_add(layout);
1775 elm_genlist_block_count_set(genlist, 14);
1776 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1777 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1779 Item_Data *id = calloc(sizeof(Item_Data), 1);
1781 item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _pref_arm_gl_cb, (void*)0);
1784 Item_Data *id2 = calloc(sizeof(Item_Data), 1);
1786 item = elm_genlist_item_append(genlist, itc, id2, NULL, ELM_GENLIST_ITEM_NONE, _pref_arm_gl_cb, (void*)1);
1789 ad->pref_arm_rdg = elm_radio_add(genlist);
1790 elm_radio_state_value_set(ad->pref_arm_rdg, 2);
1791 elm_radio_value_set(ad->pref_arm_rdg, pref_arm_type);
1793 evas_object_data_set(genlist, "radio_main", ad->pref_arm_rdg);
1795 elm_genlist_item_class_free(itc);
1797 g_pref_arm_type_genlist = genlist;
1799 elm_object_part_content_set(layout, "elm.genlist", genlist);
1801 nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
1802 elm_naviframe_item_title_enabled_set(nf_it, EINA_FALSE, EINA_FALSE);