Tizen 2.4 SDK Rev5
[apps/home/b2-clocksetting.git] / src / setting-sound.c
1 /*
2  *  Copyright (c) 2014 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  *      http://floralicense.org/license/
9  *
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.
15  *
16  */
17 #include <feedback.h>
18 #include <sys/types.h>
19 #include <dirent.h>
20 #include <vconf.h>
21 #include <vconf-keys.h>
22
23 #include "setting-sound.h"
24 #include "util.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"
30
31
32 #define AUDIO_RESOURCE_EXTENSION        ".ogg"
33
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   }, */
42         { NULL, 0, NULL }
43 };
44
45 char *sound_mode_str[] = {
46         "IDS_ST_OPT_SOUND_ABB2",
47         "IDS_ST_BODY_VIBRATE_ABB2",
48         "IDS_ST_OPT_MUTE"
49 };
50 char *ringtone_str[] = {
51         "Ringtone1",
52         "Ringtone2",
53         "Ringtone3"
54 };
55 char *notification_str[] = {
56         "Notification1",
57         "Notification2",
58         "Notification3"
59 };
60 char *vibration_str[] = {
61         "IDS_ST_OPT_STRONG_M_INTENSITY",
62         "IDS_ST_OPT_WEAK_M_INTENSITY"
63 };
64 char *pref_arm_str[] = {
65         "IDS_ST_OPT_LEFT_ARM_ABB",
66         "IDS_ST_OPT_RIGHT_ARM_ABB"
67 };
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"
71 };
72
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];
77
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;
86
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;
95
96 static int ringtone_count = 0;
97 static int notification_count = 0;
98
99 char curr_ringtone_file_path[1023];
100 char curr_noti_file_path[1023];
101
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;
106
107 static Ecore_Timer *vibration_timer = NULL;
108
109 static int is_wav_playing = SOUND_STATE_STOP;
110 static int sound_id = -1;
111
112
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();
118
119 #ifdef O_TYPE
120 static char *
121 _gl_menu_title_text_get(void *data, Evas_Object *obj, const char *part)
122 {
123         char buf[1024];
124
125         snprintf(buf, 1023, "%s", _("IDS_ST_OPT_SOUND_ABB2"));
126         return strdup(buf);
127 }
128 #endif
129
130 void _initialize()
131 {
132         /* touch sound */
133         /*effect_playsound_init(); */
134 }
135
136 Eina_Bool _clear_sound_cb(void *data, Elm_Object_Item *it)
137 {
138         _clear_sound_resource();
139
140         return EINA_TRUE;
141 }
142
143 void _clear_sound_resource()
144 {
145         if (vibration_timer) {
146                 ecore_timer_del(vibration_timer);
147                 vibration_timer = NULL;
148         }
149
150         _haptic_close();
151
152         temp_ad = 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;
159         g_vib_item = NULL;
160
161         sound_mode = 0;
162         ringtone_type = 0;
163         notification_type = 0;
164         vibrate_type = 0;
165         pref_arm_type = 0;
166         cur_sound_type = 0;
167         is_loaded_ringtone_data = 0;
168         is_loaded_noti_data = 0;
169         origin_vibration_level = 0;
170
171         is_wav_playing = 0;
172         sound_id = -1;
173
174         _stop_player();
175
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);
179 }
180
181 void _stop_all_sound_play()
182 {
183         DBG("Setting - stop all sound");
184
185         stop_wav();
186
187         _stop_player();
188 }
189
190 static void stop_wav()
191 {
192         if (is_wav_playing == SOUND_STATE_PLAY) {
193                 DBG("Setting - sound id : %d", sound_id);
194
195                 wav_player_stop(sound_id);
196                 is_wav_playing = SOUND_STATE_STOP;
197                 sound_id = -1;
198         }
199 }
200
201 void _stop_wav_player()
202 {
203         stop_wav();
204 }
205
206 void _stop_player()
207 {
208         DBG("Setting - _stop_player() is called!");
209         if (is_created_player()) {
210                 _close_player(NULL, cur_sound_type);
211         }
212 }
213
214 static void get_sound_file_list(char *dir, int type)
215 {
216         DIR *dp;
217         struct dirent *dirp;
218         char *cur_ring_path = NULL;
219
220         if ((dp = opendir(dir)) == NULL) {
221                 DBG("Setting - dir open error!");
222                 return;
223         }
224
225         if (type) {
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);
229                 }
230                 ringtone_count = 0;
231         } else {
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);
235                 }
236                 notification_count = 0;
237         }
238
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) {
244                         if (type) {
245                                 strcpy(ringtone_arr[ringtone_count], dir);
246                                 strcat(ringtone_arr[ringtone_count], dirp->d_name);
247
248                                 strcpy(ringtone_name_arr[ringtone_count], replace(dirp->d_name, ".ogg", ""));
249
250                                 /*DBG("Setting - %s", ringtone_arr[ringtone_count]); */
251
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]); */
255                                 }
256                                 /*DBG("Settng - %s is same with %s", cur_ring_path, ringtone_arr[ringtone_count]); */
257
258                                 ringtone_count++;
259                         } else {
260                                 strcpy(notification_arr[notification_count], dir);
261                                 strcat(notification_arr[notification_count], dirp->d_name);
262
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], "_", " "));
265
266                                 /*DBG("Setting - %s", notification_arr[notification_count]); */
267
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]); */
271                                 }
272                                 /*DBG("Settng - %s is same with %s", cur_ring_path, notification_arr[notification_count]); */
273
274                                 notification_count++;
275                         }
276                 }
277         }
278         closedir(dp);
279 }
280
281
282 static int get_vibration_level()
283 {
284         int mode = 1;
285         int level = 0;
286
287         vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
288
289         switch (level) {
290         case VIBRATION_LEVEL_LOW_INT:
291                 mode = VIBRATION_LEVEL_LOW;
292                 break;
293                 /*      case VIBRATION_LEVEL_MID_INT : */
294                 /*              mode = VIBRATION_LEVEL_MID; */
295                 /*              break; */
296         case VIBRATION_LEVEL_HIGH_INT:
297                 mode = VIBRATION_LEVEL_HIGH;
298                 break;
299         }
300         return mode;
301 }
302
303 void _show_volume_list(void *data)
304 {
305         Evas_Object *genlist = NULL;
306         Elm_Object_Item *nf_it = NULL;
307         appdata *ad = data;
308
309         if (ad == NULL) {
310                 DBG("Setting - ad is null");
311                 return;
312         }
313
314         _initialize_volume();
315
316         genlist = _create_volume_list(data);
317         if (genlist == NULL) {
318                 DBG("%s", "volume cb - genlist is null");
319                 return;
320         }
321 #ifdef _CIRCLE
322         nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, "empty");
323 #else
324         nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, genlist, NULL);
325 #endif
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);
328 }
329
330 void _volume_cb(void *data, Evas_Object *obj, void *event_info)
331 {
332         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
333
334         _show_volume_list(data);
335 }
336
337 void _sound_mode_cb(void *data, Evas_Object *obj, void *event_info)
338 {
339         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
340
341         _show_sound_mode_list(data);
342 }
343
344 void _touch_sound_cb(void *data, Evas_Object *obj, void *event_info)
345 {
346         Elm_Object_Item *it = (Elm_Object_Item *)event_info;
347         appdata *ad = data;
348
349         if (ad == NULL) {
350                 DBG("%s", "_touch_sound_cb - appdata or check is null");
351                 return;
352         }
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);
356
357         elm_genlist_item_selected_set(it, EINA_FALSE);
358
359         elm_genlist_item_update(it);
360 }
361
362 void _ringtone_cb(void *data, Evas_Object *obj, void *event_info)
363 {
364         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
365
366         _show_ringtone_popup_cb(data, obj, event_info);
367 }
368
369 void _noti_cb(void *data, Evas_Object *obj, void *event_info)
370 {
371         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
372
373         _show_notification_popup_cb(data, obj, event_info);
374 }
375
376 void _vibrate_cb(void *data, Evas_Object *obj, void *event_info)
377 {
378         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
379
380         _show_vibration_popup_cb(data, obj, event_info);
381 }
382
383 void _preferred_cb(void *data, Evas_Object *obj, void *event_info)
384 {
385         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
386
387         _show_pref_arm_mode_list(data);
388 }
389
390 static char *_get_sound_file_name(char *full_name)
391 {
392         char *token = NULL;
393         char *temp_token = NULL;
394         char sep[] = "*/*";
395
396         DBG("Setting - %s, %s", token, full_name);
397
398         strtok(full_name, sep);
399
400         do {
401                 token = strtok(NULL, sep);
402                 if (token != NULL) {
403                         temp_token = token;
404                 }
405         } while (token != NULL);
406
407         char *result_token = NULL;
408         if (temp_token) {
409                 temp_token = replace(temp_token, ".ogg", "");
410                 result_token = replace(temp_token, "_", " ");
411         }
412         return result_token;
413 }
414
415 char *_gl_Sound_title_get(void *data, Evas_Object *obj, const char *part)
416 {
417         char buf[1024] = {0,};
418         Item_Data *id = data;
419         int index = id->index;
420         char *pa_cur_ringtone = NULL;
421
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")) {
425                 switch (index) {
426                 case 1:
427                         sound_mode = get_sound_mode();
428                         snprintf(buf, sizeof(buf) - 1, "%s", _(sound_mode_str[sound_mode % 3]));
429                         break;
430                 case 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);
434                         }
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);
438
439                                 snprintf(buf, sizeof(buf) - 1, "%s", _get_sound_file_name(pa_cur_ringtone));
440                         }
441                         break;
442                 case 4:
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);
446                         }
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);
450
451                                 snprintf(buf, sizeof(buf) - 1, "%s", _get_sound_file_name(pa_cur_ringtone));
452                         }
453                         break;
454                 case 5:
455                         vibrate_type = get_vibration_level();
456                         snprintf(buf, sizeof(buf) - 1, "%s", _(vibration_str[vibrate_type % 2]));
457                         break;
458                         /*
459                            case 5:
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]));
463                            break;
464                          */
465                 }
466                 index++;
467         }
468         return strdup(buf);
469 }
470
471 void _sound_chk_changed_cb(void *data, Evas_Object *obj, void *event_info)
472 {
473         DBG("Setting - _sound_chk_changed_cb() is called!!");
474
475         vconf_get_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, &sound_menu_its[2].is_enable_touch_sound);
476
477         sound_menu_its[2].is_enable_touch_sound = !sound_menu_its[2].is_enable_touch_sound;
478
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);
482 }
483
484 static void _sound_gl_del(void *data, Evas_Object *obj)
485 {
486         Sound_Item_Data *id = data;
487         if (id)
488                 free(id);
489 }
490
491 Evas_Object *_gl_sound_check_get(void *data, Evas_Object *obj, const char *part)
492 {
493         Evas_Object *check = NULL;
494
495         Sound_Item_Data *id = data;
496         int index = id->index;
497
498         if (!strcmp(part, "elm.icon")) {
499                 check = elm_check_add(obj);
500
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 */
503                 }
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);
509
510                 id->check = check;
511
512                 index++;
513         }
514
515         return check;
516 }
517
518
519 Evas_Object *_create_sound_list(void *data)
520 {
521         appdata *ad = data;
522         if (ad == NULL) {
523                 DBG("%s", "_create_sound_list - appdata is null");
524                 return NULL;
525         }
526
527         temp_ad = ad;
528
529         Evas_Object *genlist  = NULL;
530         struct _sound_menu_item *menu_its = NULL;
531         int idx = 0;
532
533         Elm_Genlist_Item_Class *itc_tmp;
534
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;
539
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;
544
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;
550
551         genlist = elm_genlist_add(ad->nf);
552         elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
553 #ifdef O_TYPE
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);
557 #endif
558
559 #ifdef _CIRCLE
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;
564
565         elm_genlist_item_append(genlist, title_item, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
566
567         elm_genlist_item_class_free(title_item);
568 #endif
569
570
571         menu_its = sound_menu_its;
572
573         for (idx = 0; idx < ITEM_SIZE; idx++) {
574                 if (idx == 0) {
575                         itc_tmp = itc_1text;
576                 } else if (idx == 2) {
577                         itc_tmp = itc_touch_snd;
578                 } else {
579                         itc_tmp = itc;
580                 }
581
582                 Sound_Item_Data *id = calloc(sizeof(Sound_Item_Data), 1);
583                 if (id) {
584                         id->index = idx;
585                         id->item = elm_genlist_item_append(
586                                                    genlist,                     /* genlist object */
587                                                    itc_tmp,                     /* item class */
588                                                    id,                      /* data */
589                                                    NULL,
590                                                    ELM_GENLIST_ITEM_NONE,
591                                                    menu_its[idx].func,  /* call back */
592                                                    ad);
593
594                         if (idx == ITEM_SIZE - 1) {
595                                 g_vib_item = id->item;
596                         }
597                 }
598         }
599 #ifdef _CIRCLE
600         Elm_Genlist_Item_Class *padding = elm_genlist_item_class_new();
601         padding->item_style = "padding";
602         padding->func.del = _sound_gl_del;
603
604         elm_genlist_item_append(genlist, padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
605         elm_genlist_item_class_free(padding);
606 #endif
607         elm_genlist_item_class_free(itc_1text);
608         elm_genlist_item_class_free(itc);
609         elm_genlist_item_class_free(itc_touch_snd);
610
611         g_sound_genlist = genlist;
612
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);
616
617         return genlist;
618 }
619
620 static char *_gl_sound_mode_title_get(void *data, Evas_Object *obj, const char *part)
621 {
622         char buf[1024] = {0,};
623         Item_Data *id = data;
624         int index = id->index;
625
626         if (!strcmp(part, "elm.text")) {
627                 snprintf(buf, sizeof(buf) - 1, "%s", _(sound_mode_str[index % 3]));
628                 index++;
629         }
630         return strdup(buf);
631 }
632
633 static Evas_Object *_gl_sound_mode_ridio_get(void *data, Evas_Object *obj, const char *part)
634 {
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;
639
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);
650
651                 index++;
652         }
653         return radio;
654 }
655
656 static void _sound_mode_gl_del(void *data, Evas_Object *obj)
657 {
658         Item_Data *id = data;
659         if (id)
660                 free(id);
661 }
662
663 static int curr_touch_sound = 0;
664
665
666 static void _sound_mode_gl_cb(void *data, Evas_Object *obj, void *event_info)
667 {
668         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
669
670         sound_mode = (int)data;
671
672         changing_sound_mode_myself = 1;
673
674         if (g_sound_mode_genlist) {
675                 elm_genlist_realized_items_update(g_sound_mode_genlist);
676         }
677
678         int ringtone_level = 0;
679         int prev_sound_mode = get_sound_mode();
680         int err = -1;
681         int enable = FALSE;
682
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!!");
687
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);
691                         }
692
693                         vconf_get_int(SETTING_RINGTONE_VOLUME_BACKUP, &ringtone_level);
694                         DBG("Setting - ringtone backup level: %d", ringtone_level);
695
696                         vconf_set_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, ringtone_level);
697
698                         if (is_created_player()) {
699                                 _close_player(NULL, SOUND_TYPE_RINGTONE);
700                         }
701                         play_sound_for_sound_mode(SETTING_DEFAULT_SILENT_OFF_TONE, 0.0, SOUND_TYPE_RINGTONE);
702                         set_looping(FALSE);
703
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);
708                         }
709
710                         vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, TRUE);
711                         vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, FALSE);
712
713                         vconf_set_bool(VCONFKEY_SETAPPL_TOUCH_SOUNDS_BOOL, curr_touch_sound);
714                         curr_touch_sound = 0;
715                 }
716                 break;
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!!");
720
721                         vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE);
722                         vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, TRUE);
723
724                         vconf_get_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, &ringtone_level);
725                         DBG("Setting - ringtone original level: %d", ringtone_level);
726
727                         vconf_set_int(SETTING_RINGTONE_VOLUME_BACKUP, ringtone_level);
728                         /*sound_manager_set_muteall(TRUE);      // mute!! */
729                 }
730                 _start_vibration(5, SETTING_VIB_STRONG_RATE, SETTING_DEFAULT_SYSTEM_HAPTIC_PREVIEW_VIB);
731                 break;
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!!");
735
736                         vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, FALSE);
737                         vconf_set_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, FALSE);
738
739                         vconf_get_int(VCONFKEY_SETAPPL_CALL_RINGTONE_SOUND_VOLUME_INT, &ringtone_level);
740                         DBG("Setting - ringtone original level: %d", ringtone_level);
741
742                         vconf_set_int(SETTING_RINGTONE_VOLUME_BACKUP, ringtone_level);
743                         /*sound_manager_set_muteall(TRUE);      // mute!! */
744                 }
745                 break;
746         default:
747                 ERR("Setting - wrong sound mode value!!");
748                 break;
749         }
750
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;
755         }
756
757         if (g_sound_genlist) {
758                 elm_genlist_realized_items_update(g_sound_genlist);
759         }
760 }
761
762 static void sound_vconf_changed_cb(keynode_t *key, void *data)
763 {
764         DBG("Setting - sound_vconf_changed_cb() is called!!");
765
766         if (changing_sound_mode_myself) {
767                 DBG("Setting - changing_sound_mode_myself!!");
768
769                 changing_sound_mode_myself = 0;
770                 return;
771         }
772
773         sound_mode = get_sound_mode();
774
775         if (g_sound_mode_genlist) {
776                 elm_genlist_realized_items_update(g_sound_mode_genlist);
777         }
778
779         if (g_sound_genlist) {
780                 elm_genlist_realized_items_update(g_sound_genlist);
781         }
782 }
783
784 static void vibrate_vconf_changed_cb(keynode_t *key, void *data)
785 {
786         DBG("Setting - vibrate_vconf_changed_cb() is called!!");
787
788         sound_mode = get_sound_mode();
789
790         if (g_sound_mode_genlist) {
791                 elm_genlist_realized_items_update(g_sound_mode_genlist);
792         }
793
794         if (g_sound_genlist) {
795                 elm_genlist_realized_items_update(g_sound_genlist);
796         }
797 }
798
799 Eina_Bool _sound_mode_back_cb(void *data, Elm_Object_Item *it)
800 {
801         g_sound_mode_genlist = NULL;
802
803         return EINA_TRUE;
804 }
805
806 #ifdef O_TYPE
807 static char *
808 _gl_menu_sound_mode_title_text_get(void *data, Evas_Object *obj, const char *part)
809 {
810         char buf[1024];
811
812         snprintf(buf, 1023, "%s", _("IDS_ST_OPT_SOUND_MODE_ABB"));
813         return strdup(buf);
814 }
815 #endif
816 void _show_sound_mode_list(void *data)
817 {
818         appdata *ad = data;
819         if (ad == NULL) {
820                 DBG("%s", "_show_sound_mode_list - appdata is null");
821                 return;
822         }
823         Evas_Object *genlist  = NULL;
824         Elm_Object_Item *item = NULL;
825         Elm_Object_Item *nf_it = NULL;
826
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;
832
833         sound_mode = get_sound_mode();
834
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);
838
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);
843 #ifdef O_TYPE
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);
847 #endif
848
849 #ifdef _CIRCLE
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;
854
855         elm_genlist_item_append(genlist, title_item, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
856
857         elm_genlist_item_class_free(title_item);
858 #endif
859         Item_Data *id = calloc(sizeof(Item_Data), 1);
860         if (id) {
861                 id->index = 0;
862                 item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void *)0);
863                 id->item = item;
864         }
865
866         Item_Data *id2 = calloc(sizeof(Item_Data), 1);
867         if (id2) {
868                 id2->index = 1;
869                 item = elm_genlist_item_append(genlist, itc, id2, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void *)1);
870                 id2->item = item;
871         }
872
873         Item_Data *id3 = calloc(sizeof(Item_Data), 1);
874         if (id3) {
875                 id3->index = 2;
876                 item = elm_genlist_item_append(genlist, itc, id3, NULL, ELM_GENLIST_ITEM_NONE, _sound_mode_gl_cb, (void *)2);
877                 id3->item = item;
878         }
879
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);
884
885         evas_object_data_set(genlist, "radio_main", ad->sound_mode_rdg);
886
887         elm_genlist_item_class_free(itc);
888
889 #ifdef _CIRCLE
890         Elm_Genlist_Item_Class *padding = elm_genlist_item_class_new();
891         padding->item_style = "padding";
892         padding->func.del = _sound_mode_gl_del;
893
894         elm_genlist_item_append(genlist, padding, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
895         elm_genlist_item_class_free(padding);
896 #endif
897         g_sound_mode_genlist = genlist;
898
899         elm_object_part_content_set(layout, "elm.genlist", genlist);
900 #ifdef _CIRCLE
901         nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, "empty");
902 #else
903         nf_it = elm_naviframe_item_push(ad->nf, NULL, NULL, NULL, layout, NULL);
904 #endif
905
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);
908 }
909
910 static void _response_ringtone_ok_cb(void *data, Evas_Object *obj, void *event_info)
911 {
912         appdata *ad = (appdata *)data;
913
914         _stop_player();
915
916 #if 0
917         /* stop wav sound! */
918         stop_wav();
919 #endif
920         /* save a ringtone type. */
921         vconf_set_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR , ringtone_arr[ringtone_type]);
922
923         if (g_ringtone_type_genlist != NULL) {
924                 evas_object_del(g_ringtone_type_genlist);
925                 g_ringtone_type_genlist = NULL;
926         }
927
928         if (temp_ad->ringtone_type_rdg != NULL) {
929                 evas_object_del(temp_ad->ringtone_type_rdg);
930                 temp_ad->ringtone_type_rdg = NULL;
931         }
932
933         if (ad != NULL) {
934                 elm_naviframe_item_pop(ad->nf);
935         }
936
937         if (g_sound_genlist != NULL) {
938                 elm_genlist_realized_items_update(g_sound_genlist);
939         }
940
941         confirmed_ringtone_type = ringtone_type;
942 }
943
944 static void _response_ringtone_cancel_cb(void *data, Evas_Object *obj, void *event_info)
945 {
946         if (g_ringtone_type_genlist != NULL) {
947                 evas_object_del(g_ringtone_type_genlist);
948                 g_ringtone_type_genlist = NULL;
949         }
950
951         appdata *ad = (appdata *)data;
952         if (ad != NULL) {
953                 elm_naviframe_item_pop(ad->nf);
954         }
955
956         _stop_player();
957
958         ringtone_type = confirmed_ringtone_type;
959
960 #if 0
961         /* stop wav sound! */
962         stop_wav();
963 #endif
964 }
965
966 static char *_gl_ringtone_text_get(void *data, Evas_Object *obj, const char *part)
967 {
968         Item_Data *item = data;
969         if (item == NULL)
970                 return NULL;
971
972         char buf[1024];
973
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]);
976
977         return strdup(buf);
978 }
979
980 static Evas_Object *_gl_ringtone_radio_get(void *data, Evas_Object *obj, const char *part)
981 {
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;
986
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);
994
995                 if (id->index == ringtone_type) {
996                         elm_radio_value_set(radio_main, id->index);
997                 }
998                 index++;
999         }
1000         return radio;
1001 }
1002
1003 static void _ringtone_type_gl_cb(void *data, Evas_Object *obj, void *event_info)
1004 {
1005         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1006
1007         ringtone_type = (int)data;
1008
1009 #if 0
1010         stop_wav();
1011
1012         is_wav_playing = SOUND_STATE_PLAY;
1013         wav_player_start(ringtone_arr[ringtone_type], SOUND_TYPE_RINGTONE, NULL, (void *)1, &sound_id);
1014 #endif
1015
1016         int volume = 0;
1017         sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
1018
1019         if (volume == 0 || get_sound_mode() != SOUND_MODE_SOUND) {
1020                 if (temp_ad) {
1021                         struct _toast_data *toast = _create_toast(temp_ad, _("IDS_ST_TPOP_VOLUME_CURRENTLY_SET_TO_0"));
1022                         if (toast) {
1023                                 _show_toast(temp_ad, toast);
1024                         }
1025                 }
1026         } else {
1027                 play_sound(ringtone_arr[ringtone_type], 0.0, SOUND_TYPE_RINGTONE);
1028         }
1029
1030         elm_genlist_realized_items_update(g_ringtone_type_genlist);
1031 }
1032
1033 static void _ringtone_back_cb(void *data, Evas_Object *obj, void *event_info)
1034 {
1035         appdata *ad = data;
1036         if (ad == NULL)
1037                 return;
1038
1039         ringtone_type = confirmed_ringtone_type;
1040
1041         _stop_all_sound_play();
1042
1043         unregister_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb);
1044 }
1045
1046
1047 static void pm_state_vconf_changed_cb(keynode_t *key, void *data)
1048 {
1049         DBG("Setting - pm_state_vconf_changed_cb() is called!");
1050
1051         int pm_state = 0;
1052         vconf_get_int(VCONFKEY_PM_STATE, &pm_state);
1053
1054         if (pm_state == VCONFKEY_PM_STATE_LCDOFF) {
1055                 DBG("Setting - LCD Off!! stop sound!");
1056                 _stop_all_sound_play();
1057         }
1058 }
1059
1060 int cstring_cmp(const void *a, const void *b)
1061 {
1062         const char *ia = (const char *)a;
1063         const char *ib = (const char *)b;
1064         return strcmp(ia, ib);
1065 }
1066
1067 void _show_ringtone_popup_cb(void *data, Evas_Object *obj, void *event_info)
1068 {
1069         DBG("ENTER _show_ringtone_popup_cb");
1070         Evas_Object *popup, *btn;
1071         unsigned int index;
1072         appdata *ad = data;
1073
1074         if (ad == NULL)
1075                 return;
1076
1077         ad->MENU_TYPE = SETTING_SOUND_RINGTONE;
1078
1079         if (is_loaded_ringtone_data == 0) {
1080                 get_sound_file_list("/opt/share/settings/Ringtones/", 1);
1081                 is_loaded_ringtone_data = 1;
1082
1083                 /* @todo apply eina_sort */
1084                 /*qsort (ringtone_name_arr, ringtone_count-1, sizeof(char*), cstring_cmp); */
1085         }
1086
1087         cur_sound_type = SOUND_TYPE_RINGTONE;
1088
1089         popup = elm_layout_add(ad->win_main);
1090
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");
1094         } else {
1095                 DBG("elm_layout_file_set OK with setting/genlist/2button-layout");
1096         }
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);
1099
1100
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;
1107
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);
1112 #ifdef O_TYPE
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);
1116 #endif
1117
1118
1119
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);
1124                 if (item) {
1125                         item->index = index;
1126                         item->item = elm_genlist_item_append(genlist,
1127                                                                                                  itc,
1128                                                                                                  item,
1129                                                                                                  NULL,
1130                                                                                                  ELM_GENLIST_ITEM_NONE,
1131                                                                                                  _ringtone_type_gl_cb,
1132                                                                                                  (void *)index);
1133                 }
1134         }
1135
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;
1140
1141         evas_object_data_set(genlist, "radio_main", ad->ringtone_type_rdg);
1142
1143         g_ringtone_type_genlist = genlist;
1144
1145         elm_object_part_content_set(popup, "elm.genlist", genlist);
1146         /*      evas_object_show(popup); */
1147         evas_object_show(genlist);
1148
1149         elm_genlist_item_class_free(itc);
1150
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);
1156
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);
1162
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);
1165
1166         /*VCONFKEY_PM_STATE */
1167         register_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb, NULL);
1168         DBG("LEAVE _show_ringtone_popup_cb");
1169 }
1170
1171 static void _notification_back_cb(void *data, Evas_Object *obj, void *event_info)
1172 {
1173         appdata *ad = data;
1174         if (ad == NULL)
1175                 return;
1176
1177         notification_type = confirmed_Notification_type;
1178
1179         _stop_all_sound_play();
1180
1181         unregister_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb);
1182 }
1183
1184 static void _response_notification_ok_cb(void *data, Evas_Object *obj, void *event_info)
1185 {
1186         /*stop_wav(); */
1187
1188         if (is_created_player()) {
1189                 _close_player(NULL, SOUND_TYPE_NOTIFICATION);
1190         }
1191
1192         /* save a notification type. */
1193         vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR , notification_arr[notification_type]);
1194
1195         if (g_notification_type_genlist != NULL) {
1196                 evas_object_del(g_notification_type_genlist);
1197                 g_notification_type_genlist = NULL;
1198         }
1199
1200         if (temp_ad->notification_rdg != NULL) {
1201                 evas_object_del(temp_ad->notification_rdg);
1202                 temp_ad->notification_rdg = NULL;
1203         }
1204
1205         confirmed_Notification_type = notification_type;
1206
1207         appdata *ad = (appdata *)data;
1208         if (ad != NULL) {
1209                 elm_naviframe_item_pop(ad->nf);
1210         }
1211
1212         if (g_sound_genlist != NULL) {
1213                 elm_genlist_realized_items_update(g_sound_genlist);
1214         }
1215 }
1216
1217 static void _response_notification_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1218 {
1219         if (g_notification_type_genlist != NULL) {
1220                 evas_object_del(g_notification_type_genlist);
1221                 g_notification_type_genlist = NULL;
1222         }
1223
1224         appdata *ad = (appdata *)data;
1225         if (ad != NULL) {
1226                 elm_naviframe_item_pop(ad->nf);
1227         }
1228
1229         notification_type = confirmed_Notification_type;
1230
1231         if (is_created_player()) {
1232                 _close_player(NULL, SOUND_TYPE_RINGTONE);
1233         }
1234
1235         /*stop_wav(); */
1236 }
1237
1238 static char *_gl_notification_text_get(void *data, Evas_Object *obj, const char *part)
1239 {
1240         Item_Data *item = data;
1241         if (item == NULL)
1242                 return NULL;
1243
1244         char buf[1024];
1245
1246         sprintf(buf, "%s", notification_name_arr[item->index % notification_count]);
1247
1248         return strdup(buf);
1249 }
1250
1251 static Evas_Object *_gl_notification_radio_get(void *data, Evas_Object *obj, const char *part)
1252 {
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;
1257
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);
1267                 }
1268                 index++;
1269         }
1270         return radio;
1271 }
1272
1273 static void _notification_gl_cb(void *data, Evas_Object *obj, void *event_info)
1274 {
1275         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1276
1277         notification_type = (int)data;
1278
1279 #if 0
1280         is_wav_playing = SOUND_STATE_PLAY;
1281         wav_player_start(notification_arr[notification_type], SOUND_TYPE_NOTIFICATION, NULL, (void *)2, &sound_id);
1282 #endif
1283
1284         int volume = 0;
1285         sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &volume);
1286
1287         if (volume == 0 || get_sound_mode() != SOUND_MODE_SOUND) {
1288                 if (temp_ad) {
1289                         struct _toast_data *toast = _create_toast(temp_ad, _("IDS_ST_TPOP_VOLUME_CURRENTLY_SET_TO_0"));
1290                         if (toast) {
1291                                 _show_toast(temp_ad, toast);
1292                         }
1293                 }
1294         } else {
1295                 play_sound(notification_arr[notification_type], 0.0, SOUND_TYPE_NOTIFICATION);
1296                 set_looping(FALSE);
1297         }
1298
1299         if (g_notification_type_genlist) {
1300                 elm_genlist_realized_items_update(g_notification_type_genlist);
1301         }
1302 }
1303
1304 void _show_notification_popup_cb(void *data, Evas_Object *obj, void *event_info)
1305 {
1306         Evas_Object *popup, *btn;
1307         unsigned int index;
1308         appdata *ad = data;
1309
1310         if (ad == NULL)
1311                 return;
1312
1313         ad->MENU_TYPE = SETTING_SOUND_NOTIFICATION;
1314
1315         if (is_loaded_noti_data == 0) {
1316                 get_sound_file_list("/opt/share/settings/Alerts/", 0);
1317                 is_loaded_noti_data = 1;
1318
1319                 /*sorting_file_list(0); */
1320         }
1321
1322         cur_sound_type = SOUND_TYPE_NOTIFICATION;
1323
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);
1328
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;
1335
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);
1340 #ifdef O_TYPE
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);
1344 #endif
1345
1346
1347         for (index = 0; index < notification_count; index++) {
1348                 Item_Data *item = (Item_Data *)calloc(sizeof(Item_Data), 1);
1349                 if (item) {
1350                         item->index = index;
1351                         item->item = elm_genlist_item_append(genlist,
1352                                                                                                  itc,
1353                                                                                                  item,
1354                                                                                                  NULL,
1355                                                                                                  ELM_GENLIST_ITEM_NONE,
1356                                                                                                  _notification_gl_cb,
1357                                                                                                  (void *)index);
1358                 }
1359         }
1360
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;
1365
1366         evas_object_data_set(genlist, "radio_main", ad->notification_rdg);
1367
1368         g_notification_type_genlist = genlist;
1369
1370         elm_object_part_content_set(popup, "elm.genlist", genlist);
1371         evas_object_show(genlist);
1372         elm_genlist_item_class_free(itc);
1373
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);
1379
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);
1385
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);
1388
1389         /*VCONFKEY_PM_STATE */
1390         register_vconf_changing(VCONFKEY_PM_STATE, pm_state_vconf_changed_cb, NULL);
1391 }
1392
1393 static void _response_vibration_ok_cb(void *data, Evas_Object *obj, void *event_info)
1394 {
1395         /* save a vibration level */
1396         int level = 0;
1397
1398         _haptic_close();
1399
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);
1404                 break;
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);
1408                 break;
1409         default:
1410                 break;
1411         }
1412
1413         vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &level);
1414         DBG("Setting - vibration level : %d", level);
1415
1416         if (g_vibration_type_genlist != NULL) {
1417                 evas_object_del(g_vibration_type_genlist);
1418                 g_vibration_type_genlist = NULL;
1419         }
1420
1421         if (temp_ad->vibration_rdg != NULL) {
1422                 evas_object_del(temp_ad->vibration_rdg);
1423                 temp_ad->vibration_rdg = NULL;
1424         }
1425
1426         appdata *ad = (appdata *)data;
1427         if (ad != NULL) {
1428                 elm_naviframe_item_pop(ad->nf);
1429         }
1430
1431         if (g_vib_item != NULL) {
1432                 elm_genlist_item_update(g_vib_item);
1433         }
1434 }
1435
1436 static void _response_vibration_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1437 {
1438         _haptic_close();
1439
1440         vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &vibrate_type);
1441
1442         DBG("Setting - vibrate type have backed : %d", vibrate_type);
1443
1444         if (g_vibration_type_genlist != NULL) {
1445                 evas_object_del(g_vibration_type_genlist);
1446                 g_vibration_type_genlist = NULL;
1447         }
1448
1449         appdata *ad = (appdata *)data;
1450         if (ad != NULL) {
1451                 elm_naviframe_item_pop(ad->nf);
1452         }
1453 }
1454
1455 static char *_gl_vibration_text_get(void *data, Evas_Object *obj, const char *part)
1456 {
1457         Item_Data *item = data;
1458         if (item == NULL)
1459                 return NULL;
1460
1461         return strdup(_(vibration_str[item->index % 2]));
1462 }
1463
1464 static Evas_Object *_gl_vibration_radio_get(void *data, Evas_Object *obj, const char *part)
1465 {
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;
1470
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);
1480
1481                 if (vibrate_type == id->index) {
1482                         elm_radio_value_set(radio_main, vibrate_type);
1483                 }
1484                 index++;
1485         }
1486         return radio;
1487 }
1488
1489 static void _vibration_gl_cb(void *data, Evas_Object *obj, void *event_info)
1490 {
1491         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1492
1493         vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &origin_vibration_level);
1494
1495         vibrate_type = (int)data;
1496
1497         int level = VIBRATION_LEVEL_LOW_INT;
1498         int feedback_rate = SETTING_VIB_MEDIUM_RATE;
1499         switch (vibrate_type) {
1500                 /*      case 2: */
1501                 /*              level = VIBRATION_LEVEL_LOW_INT; */
1502                 /*              feedback_rate = SETTING_VIB_WEAK_RATE; */
1503                 /*              break; */
1504         case 1:
1505                 level = VIBRATION_LEVEL_LOW_INT;
1506                 feedback_rate = SETTING_VIB_WEAK_RATE;
1507                 break;
1508         case 0:
1509                 level = VIBRATION_LEVEL_HIGH_INT;
1510                 feedback_rate = SETTING_VIB_STRONG_RATE;
1511                 break;
1512         }
1513
1514         DBG("Setting - feedback level: %d, rate: %d", level, feedback_rate);
1515
1516         _start_vibration(level, feedback_rate, SETTING_DEFAULT_NOTIFICATION_GENERAL_PREVIEW_VIB);
1517
1518         elm_genlist_realized_items_update(g_vibration_type_genlist);
1519 }
1520
1521 static void _vibration_layout_del_cb(void *data, Evas_Object *obj, void *event_info)
1522 {
1523         DBG("Setting - _vibration_layout_del_cb() is called!");
1524
1525         _haptic_close();
1526
1527         if (g_vib_item) {
1528                 elm_genlist_item_update(g_vib_item);
1529         }
1530 }
1531
1532 static int get_vibration_type()
1533 {
1534         int type = 1;
1535
1536         vconf_get_int(VCONFKEY_SETAPPL_NOTI_VIBRATION_LEVEL_INT, &origin_vibration_level);
1537         switch (origin_vibration_level) {
1538         case VIBRATION_LEVEL_LOW_INT:
1539                 type = 1;
1540                 break;
1541                 /*      case VIBRATION_LEVEL_MID_INT: */
1542                 /*              type = 1; */
1543                 /*              break; */
1544         case VIBRATION_LEVEL_HIGH_INT:
1545                 type = 0;
1546                 break;
1547         }
1548
1549         return type;
1550 }
1551
1552 void _show_vibration_popup_cb(void *data, Evas_Object *obj, void *event_info)
1553 {
1554         Evas_Object *popup, *btn;
1555         unsigned int index;
1556         appdata *ad = data;
1557
1558         vibrate_type = get_vibration_type();
1559
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);
1565
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;
1571
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);
1577 #ifdef O_TYPE
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);
1581 #endif
1582
1583
1584
1585         int count = sizeof(vibration_str) / sizeof(vibration_str[0]);
1586
1587         for (index = 0; index < count; index++) {
1588                 Item_Data *item = (Item_Data *)calloc(sizeof(Item_Data), 1);
1589                 if (item) {
1590                         item->index = index;
1591                         item->item = elm_genlist_item_append(genlist,
1592                                                                                                  itc,
1593                                                                                                  item,
1594                                                                                                  NULL,
1595                                                                                                  ELM_GENLIST_ITEM_NONE,
1596                                                                                                  _vibration_gl_cb,
1597                                                                                                  (void *)index);
1598                 }
1599         }
1600
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);
1604
1605         evas_object_data_set(genlist, "radio_main", ad->vibration_rdg);
1606
1607         g_vibration_type_genlist = genlist;
1608
1609         elm_object_part_content_set(popup, "elm.genlist", genlist);
1610         evas_object_show(genlist);
1611         elm_genlist_item_class_free(itc);
1612
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);
1619
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);
1626
1627         elm_naviframe_item_push(ad->nf, _("IDS_ST_HEADER_VIBRATION_ABB"), NULL, NULL, popup, NULL);
1628 }
1629
1630 static char *_gl_pref_arm_title_get(void *data, Evas_Object *obj, const char *part)
1631 {
1632         char buf[1024] = {0,};
1633         Item_Data *id = data;
1634         int index = id->index;
1635
1636         if (!strcmp(part, "elm.text")) {
1637                 snprintf(buf, sizeof(buf) - 1, "%s", _(pref_arm_str[index % 2]));
1638                 index++;
1639         }
1640         return strdup(buf);
1641 }
1642
1643 static Evas_Object *_gl_pref_arm_ridio_get(void *data, Evas_Object *obj, const char *part)
1644 {
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;
1650
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);
1658
1659                 vconf_get_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, &prefered_arm_type);
1660
1661                 prefered_arm_type = (prefered_arm_type) ? 0 : 1;
1662
1663                 if (pref_arm_type == id->index) {
1664                         elm_radio_value_set(radio_main, pref_arm_type);
1665                 }
1666                 index++;
1667         }
1668         return radio;
1669 }
1670
1671 static void _pref_arm_gl_del(void *data, Evas_Object *obj)
1672 {
1673         Item_Data *id = data;
1674         if (id)
1675                 free(id);
1676 }
1677
1678 static void _pref_arm_gl_cb(void *data, Evas_Object *obj, void *event_info)
1679 {
1680         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
1681
1682         pref_arm_type = (int)data;
1683
1684         elm_genlist_realized_items_update(g_pref_arm_type_genlist);
1685
1686         if (temp_ad) {
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;
1691                 }
1692         }
1693         /* save a perfered arm type */
1694         vconf_set_bool(VCONFKEY_SETAPPL_PERFERED_ARM_LEFT_BOOL, (pref_arm_type == 0) ? TRUE : FALSE);
1695
1696         if (g_sound_genlist) {
1697                 elm_genlist_realized_items_update(g_sound_genlist);
1698         }
1699
1700         /* show toast message */
1701         if (temp_ad) {
1702                 struct _toast_data *toast = _create_toast(temp_ad, _(pref_arm_toast_msg[pref_arm_type % 2]));
1703                 if (toast) {
1704                         _show_toast(temp_ad, toast);
1705                 }
1706         }
1707 }
1708
1709 void _show_pref_arm_mode_list(void *data)
1710 {
1711         appdata *ad = data;
1712         if (ad == NULL) {
1713                 DBG("%s", "_show_pref_arm_mode_list - appdata is null");
1714                 return;
1715         }
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; */
1720
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;
1726
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);
1730
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);
1735 #ifdef O_TYPE
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);
1739 #endif
1740
1741
1742
1743         Item_Data *id = calloc(sizeof(Item_Data), 1);
1744         if (id) {
1745                 id->index = 0;
1746                 item = elm_genlist_item_append(genlist, itc, id, NULL, ELM_GENLIST_ITEM_NONE, _pref_arm_gl_cb, (void *)0);
1747                 id->item = item;
1748         }
1749
1750         Item_Data *id2 = calloc(sizeof(Item_Data), 1);
1751         if (id2) {
1752                 id2->index = 1;
1753                 item = elm_genlist_item_append(genlist, itc, id2, NULL, ELM_GENLIST_ITEM_NONE, _pref_arm_gl_cb, (void *)1);
1754                 id2->item = item;
1755         }
1756
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);
1760
1761         evas_object_data_set(genlist, "radio_main", ad->pref_arm_rdg);
1762
1763         elm_genlist_item_class_free(itc);
1764
1765         g_pref_arm_type_genlist = genlist;
1766
1767         elm_object_part_content_set(layout, "elm.genlist", genlist);
1768
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);
1771 }