2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
24 #include <ui-gadget.h>
25 #include <X11/Xatom.h>
26 #include <X11/Xutil.h>
27 #include <system_info.h>
31 #include "_util_log.h"
32 #include "_util_efl.h"
35 #define STRBUF_SIZE 128
36 #define PATHBUF_SIZE 256
44 /* _check_status() return value */
46 LOCK_AND_NOT_MEDIA = -0x1,
51 #ifndef VCONFKEY_SETAPPL_ACCESSIBILITY_TURN_OFF_ALL_SOUNDS
52 #define VCONFKEY_SETAPPL_ACCESSIBILITY_TURN_OFF_ALL_SOUNDS VCONFKEY_SETAPPL_PREFIX"/accessibility/turn_off_all_sounds"
55 int _close_volume(void *data)
57 struct appdata *ad = (struct appdata *)data;
58 retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
59 retvm_if(ad->flag_deleting == EINA_TRUE, -1, "Closing volume\n");
61 _D("start closing volume\n");
62 ad->flag_deleting = EINA_TRUE;
65 _grab_key_new(ad, ad->input_win, SHARED_GRAB);
67 DEL_TIMER(ad->sutimer)
68 DEL_TIMER(ad->lutimer)
69 DEL_TIMER(ad->sdtimer)
70 DEL_TIMER(ad->ldtimer)
74 evas_object_hide(ad->win);
76 appcore_flush_memory();
78 ad->flag_deleting = EINA_FALSE;
79 ad->flag_launching = EINA_FALSE;
80 _D("end closing volume\n");
84 Eina_Bool popup_timer_cb(void *data)
88 return ECORE_CALLBACK_CANCEL;
91 Eina_Bool _lu_timer_cb(void *data)
94 struct appdata *ad = (struct appdata *)data;
95 retvm_if(ad == NULL, 0, "Invalid argument: appdata is NULL\n");
96 if (ad->win == NULL || evas_object_visible_get(ad->win) == EINA_FALSE){
97 _D("win is NULL or hide state, so long press pass\n");
98 return ECORE_CALLBACK_CANCEL;
100 DEL_TIMER(ad->stimer)
102 _get_sound_level(ad->type, &val);
103 _set_sound_level(ad->type, val +1 > ad->step ? ad->step : val + 1);
104 _D("down, type(%d), step(%d) val[%d]\n", ad->type, ad->step, val+1);
105 return ECORE_CALLBACK_RENEW;
108 Eina_Bool _su_timer_cb(void *data)
110 struct appdata *ad = (struct appdata *)data;
111 retvm_if(ad == NULL, 0, "Invalid argument: appdata is NULL\n");
112 ADD_TIMER(ad->lutimer, 0.0, _lu_timer_cb, ad)
113 return ECORE_CALLBACK_CANCEL;
116 Eina_Bool _ld_timer_cb(void *data)
119 struct appdata *ad = (struct appdata *)data;
120 retvm_if(ad == NULL, 0, "Invalid argument: appdata is NULL\n");
121 if (ad->win == NULL || evas_object_visible_get(ad->win) == EINA_FALSE){
122 _D("win is NULL or hide state, so long press pass\n");
123 return ECORE_CALLBACK_CANCEL;
125 DEL_TIMER(ad->stimer)
127 _get_sound_level(ad->type, &val);
128 _set_sound_level(ad->type, val -1 <= 0 ? 0 : val - 1);
129 _D("down, type(%d), step(%d) val[%d]\n", ad->type, ad->step, val+1);
130 return ECORE_CALLBACK_RENEW;
133 Eina_Bool _sd_timer_cb(void *data)
135 struct appdata *ad = (struct appdata *)data;
136 retvm_if(ad == NULL, 0, "Invalid argument: appdata is NULL\n");
137 _D("add long down timer\n");
138 ADD_TIMER(ad->ldtimer, 0.0, _ld_timer_cb, ad)
139 return ECORE_CALLBACK_CANCEL;
142 Eina_Bool _volume_show(void *data)
144 _D("%s\n", __func__);
146 int type = MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY;
147 int lock = IDLELOCK_ON;
148 struct appdata *ad = (struct appdata *)data;
149 retvm_if(ad == NULL, EINA_FALSE, "Invalid argument: appdata is NULL\n");
151 status = _check_status(&lock, &type);
152 if(status != LOCK_AND_NOT_MEDIA && ad->win)
155 /* ungrab SHARED_GRAB */
158 if(status == UNLOCK_STATUS)
160 _grab_key_new(ad, -1, TOP_POSITION_GRAB);
163 elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_HIDE);
164 evas_object_show(ad->win);
165 if(syspopup_has_popup(ad->volume_bundle))
166 syspopup_reset(ad->volume_bundle);
168 else if(status == LOCK_AND_MEIDA)
170 _grab_key_new(ad, ad->input_win, EXCLUSIVE_GRAB);
172 ad->flag_launching = EINA_TRUE;
178 /* recreate window */
181 _D("status == LOCK_AND_NOT_MEDIA\n");
185 static Eina_Bool _key_press_cb(void *data, int type, void *event)
187 _D("%s\n", __func__);
188 int val=0, snd=0, vib=0;
189 Ecore_Event_Key *ev = event;
191 int mtype = MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY;
192 int lock = IDLELOCK_ON;
193 int is_turn_off_all_sounds = 0;
195 struct appdata *ad = (struct appdata *)data;
197 status = _check_status(&lock, &mtype);
199 retvm_if(ev == NULL, ECORE_CALLBACK_CANCEL, "Invalid arguemnt: event is NULL\n");
200 retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument: appdata is NULL\n");
201 retvm_if(ad->win == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument: window is NULL\n");
203 ret = vconf_get_bool(VCONFKEY_SETAPPL_ACCESSIBILITY_TURN_OFF_ALL_SOUNDS, &is_turn_off_all_sounds);
206 retvm_if(is_turn_off_all_sounds == EINA_TRUE, ECORE_CALLBACK_CANCEL,
207 "VCONFKEY_SETAPPL_ACCESSIBILITY_TURN_OFF_ALL_SOUNDS is set, all sound is mute\n");
210 if(!ad->flag_launching)
212 if(_volume_show(data) != EINA_TRUE)
214 return ECORE_CALLBACK_CANCEL;
218 if(ad->flag_touching == EINA_TRUE) {
219 return ECORE_CALLBACK_CANCEL;
222 ad->flag_pressing = EINA_TRUE;
224 DEL_TIMER(ad->ptimer)
225 vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &snd);
226 vconf_get_bool(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, &vib);
228 /* If sound is set off, only RINGTONE, MEDIA types are able to change. */
229 if(!snd && ad->type != VOLUME_TYPE_MEDIA && ad->type != VOLUME_TYPE_RINGTONE){
230 if(vib)_play_vib(ad->sh);
231 return ECORE_CALLBACK_CANCEL;
234 if (!strcmp(ev->keyname, KEY_VOLUMEUP)) {
235 _get_sound_level(ad->type, &val);
236 if (val == ad->step) {
237 _set_sound_level(ad->type, ad->step);
238 if(snd)_play_sound(ad->type, ad->sh);
239 return ECORE_CALLBACK_CANCEL;
241 _set_sound_level(ad->type, val + 1);
242 if(snd)_play_sound(ad->type, ad->sh);
243 DEL_TIMER(ad->sutimer)
244 ADD_TIMER(ad->sutimer, 0.5, _su_timer_cb, ad)
246 _D("set volume %d -> [%d]\n", val, val+1);
248 } else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN)) {
249 _get_sound_level(ad->type, &val);
251 if(vib)_play_vib(ad->sh);
252 return ECORE_CALLBACK_CANCEL;
254 _set_sound_level(ad->type, val - 1);
255 if(snd)_play_sound(ad->type, ad->sh);
256 DEL_TIMER(ad->sdtimer)
257 ADD_TIMER(ad->sdtimer, 0.5, _sd_timer_cb, ad)
259 _D("type (%d) set volume %d -> [%d]\n", ad->type, val, val-1);
262 return ECORE_CALLBACK_CANCEL;
265 static Eina_Bool _key_release_cb(void *data, int type, void *event)
267 Ecore_Event_Key *ev = event;
268 struct appdata *ad = (struct appdata *)data;
270 retvm_if(ev == NULL, ECORE_CALLBACK_CANCEL, "Invalid arguemnt: event is NULL\n");
271 retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument:appdata is NULL\n");
272 retvm_if(ad->win == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument: window is NULL\n");
274 if (ad->flag_touching == EINA_TRUE) {
275 return ECORE_CALLBACK_CANCEL;
278 if (!strcmp(ev->keyname, KEY_VOLUMEUP)) {
279 _D("up key released and del timer\n");
280 DEL_TIMER(ad->sutimer)
281 DEL_TIMER(ad->lutimer)
282 DEL_TIMER(ad->luwarmtimer)
283 } else if (!strcmp(ev->keyname, KEY_VOLUMEDOWN)) {
284 _D("down key released and del timer\n");
285 DEL_TIMER(ad->sdtimer)
286 DEL_TIMER(ad->ldtimer)
287 DEL_TIMER(ad->ldwarmtimer)
290 ad->flag_pressing = EINA_FALSE;
292 DEL_TIMER(ad->ptimer)
294 ADD_TIMER(ad->ptimer, 3.0, popup_timer_cb, ad)
296 return ECORE_CALLBACK_CANCEL;
299 int _grab_key_new(struct appdata *ad, Ecore_X_Window _xwin, int grab_mode)
301 _D("%s\n", __func__);
302 Ecore_X_Display *disp = NULL;
303 Ecore_X_Window xwin = 0;
306 /* ALREADY GRAB check */
309 case SHARED_GRAB : if(ad->flag_shared_grabed)return -1;
311 case EXCLUSIVE_GRAB : if(ad->flag_exclusive_grabed)return -1;
313 case TOP_POSITION_GRAB : if(ad->flag_top_positioni_grabed)return -1;
317 disp = ecore_x_display_get();
318 retvm_if(disp == NULL, -1, "Failed to get display\n");
322 /* TOP_POSITION_GRAB */
323 xwin = elm_win_xwindow_get(ad->win);
324 retvm_if(xwin == 0, -1, "elm_win_xwindow_get() failed\n");
329 ret = utilx_grab_key(disp, xwin, KEY_VOLUMEDOWN, grab_mode);
330 retvm_if(ret < 0, -1, "Failed to grab key down\n");
331 retvm_if(ret == 1, -1, "Already grab\n");
333 ret = utilx_grab_key(disp, xwin, KEY_VOLUMEUP, grab_mode);
334 retvm_if(ret < 0, -1, "Failed to grab key up\n");
335 retvm_if(ret == 1, -1, "Already grab\n");
340 ad->flag_shared_grabed = EINA_TRUE;
342 case EXCLUSIVE_GRAB :
343 ad->flag_exclusive_grabed = EINA_TRUE;
345 case TOP_POSITION_GRAB :
346 ad->flag_top_positioni_grabed = EINA_TRUE;
353 int _ungrab_key_new(struct appdata *ad)
355 Ecore_X_Window xwin = 0;
356 Ecore_X_Display *disp = NULL;
358 retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
359 retvm_if(ad->input_win == 0, -1, "Invalid argument: ad->win is NULL\n");
361 xwin = elm_win_xwindow_get(ad->win);
362 retvm_if(xwin == 0, -1, "Failed to get xwindow\n");
364 disp = ecore_x_display_get();
365 retvm_if(disp == NULL, -1, "Failed to get display\n");
367 utilx_ungrab_key(disp, ad->input_win, KEY_VOLUMEUP);
368 utilx_ungrab_key(disp, ad->input_win, KEY_VOLUMEDOWN);
369 _D("key ungrabed\n");
371 if(ad->flag_exclusive_grabed)
372 ad->flag_exclusive_grabed = EINA_FALSE;
373 else if(ad->flag_top_positioni_grabed)
374 ad->flag_top_positioni_grabed = EINA_FALSE;
375 else if(ad->flag_shared_grabed)
376 ad->flag_shared_grabed = EINA_FALSE;
381 int _get_vconf_idlelock(void)
384 int lock = IDLELOCK_OFF;
386 ret = vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock);
387 retvm_if(ret < 0, -1, "Failed to get vconf %s\n",
388 VCONFKEY_IDLE_LOCK_STATE);
389 _D("idlelock vconf:%d\n", lock);
391 return lock == VCONFKEY_IDLE_LOCK ? IDLELOCK_ON : IDLELOCK_OFF;
394 volume_type_t _get_volume_type(void)
396 int ret = MM_ERROR_NONE;
397 volume_type_t type = -1;
399 ret = mm_sound_volume_get_current_playing_type(&type);
403 case MM_ERROR_SOUND_VOLUME_NO_INSTANCE:
404 case MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY:
405 type = VOLUME_TYPE_RINGTONE;
408 _D("Failed to get sound type(errno:%x)\n", ret);
411 if(type == VOLUME_TYPE_NOTIFICATION || type == VOLUME_TYPE_SYSTEM)
412 type = VOLUME_TYPE_RINGTONE;
416 int _check_status(int *lock, int *type)
418 *lock = _get_vconf_idlelock();
419 *type = _get_volume_type();
420 _D("lock(%d) type(%d)\n", *lock, *type);
422 if (*type == MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY
423 || *type == MM_ERROR_SOUND_INTERNAL) {
424 _D("Do not show by type\n");
428 if (*lock == IDLELOCK_ON && *type != VOLUME_TYPE_MEDIA) {
429 _D("lock is set, not in media\n");
433 if (*lock == IDLELOCK_ON && *type == VOLUME_TYPE_MEDIA) {
434 _D("lock is set, in media\n");
437 _D("unlock status, normal case\n");
441 void _starter_user_volume_key_vconf_changed_cb(keynode_t *key, void *data){
442 _D("%s\n", __func__);
443 int ret = EINA_FALSE;
444 vconf_get_int(VCONFKEY_STARTER_USE_VOLUME_KEY, &ret);
447 _D("any other App grab volume hard key\n", __func__);
449 vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 0);
453 void _idle_lock_state_vconf_chnaged_cb(keynode_t *key, void *data){
457 int _app_create(struct appdata *ad)
459 _D("%s\n", __func__);
463 /* create input_window */
464 ad->input_win = _add_input_window();
465 retvm_if(ad->input_win == 0, -1, "Failed to create input window\n");
467 /* vconf changed callback */
468 vconf_notify_key_changed(VCONFKEY_STARTER_USE_VOLUME_KEY,
469 _starter_user_volume_key_vconf_changed_cb, ad);
471 /* Lock screen status vconf changed callback */
472 vconf_notify_key_changed(VCONFKEY_IDLE_LOCK_STATE,
473 _idle_lock_state_vconf_chnaged_cb, ad);
475 /* grab volume shared grab */
476 ret = _grab_key_new(ad, ad->input_win, SHARED_GRAB);
478 /* ecore event handler add once */
479 if(ad->event_volume_down == NULL)
480 ad->event_volume_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, ad);
481 if(ad->event_volume_up == NULL)
482 ad->event_volume_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, ad);
489 int __utilx_ss_get_window_property(Display *dpy, Window win, Atom atom,
490 Atom type, unsigned int *val,
493 unsigned char *prop_ret = NULL;
495 unsigned long bytes_after = 0;
496 unsigned long num_ret = -1;
502 if (XGetWindowProperty(dpy, win, atom, 0, 0x7fffffff, False,
503 type, &type_ret, &format_ret, &num_ret,
504 &bytes_after, &prop_ret) != Success)
507 if (type_ret != type || format_ret != 32)
509 else if (num_ret == 0 || !prop_ret)
514 for (i = 0; i < len; i++) {
515 val[i] = ((unsigned long *)prop_ret)[i];
526 int _x_rotation_get(Display *dpy, void *data)
528 Window active_win = 0;
533 Atom atom_active_win;
534 Atom atom_win_rotate_angle;
536 retvm_if(dpy == NULL, -1, "dpy is NULL\n");
537 root_win = XDefaultRootWindow(dpy);
539 atom_active_win = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
540 ret = __utilx_ss_get_window_property(dpy, root_win, atom_active_win,
542 (unsigned int *)&active_win, 1);
547 atom_win_rotate_angle = XInternAtom(dpy, "_E_ILLUME_ROTATE_ROOT_ANGLE", False);
548 ret = __utilx_ss_get_window_property(dpy, root_win,
549 atom_win_rotate_angle, XA_CARDINAL,
550 (unsigned int *)&rotation, 1);
558 int _volume_popup_resize(void *data, int angle)
562 Evas_Coord minw = -1, minh = -1;
563 Evas_Coord w = 0, h = 0;
564 struct appdata *ad = (struct appdata *)data;
565 retvm_if(ad->win == NULL, -1, "Invalid argument: window is NULL\n");
566 retvm_if(ad->block_events == NULL, -1, "Invalid argument: notify is NULL\n");
569 rotation = ad->angle;
573 system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_WIDTH, &w);
574 system_info_get_value_int(SYSTEM_INFO_KEY_SCREEN_HEIGHT, &h);
579 evas_object_resize(ad->block_events, h, w);
580 edje_object_size_min_get(ad->block_events, &minw, &minh);
581 edje_object_size_min_restricted_calc(ad->block_events, &minw, &minh, minw, minh);
582 offx = (h - minw) / 2;
583 offy = (w - minh) / 5;
588 evas_object_resize(ad->block_events, w, h);
589 edje_object_size_min_get(ad->block_events, &minw, &minh);
590 edje_object_size_min_restricted_calc(ad->block_events, &minw, &minh, minw, minh);
591 offx = (w - minw) / 2;
592 offy = (h - minh) / 5;
595 _D("w(%d) h(%d) offx(%d) offy(%d)\n", w, h, offx, offy);
596 evas_object_move(ad->ly, offx, offy);
600 int _efl_rotate(Display *dpy, void *data)
603 struct appdata *ad = (struct appdata *)data;
605 rotation = _x_rotation_get(dpy, ad);
611 elm_win_rotation_set(ad->win, rotation);
612 ad->angle = rotation;
613 return _volume_popup_resize(data, rotation);
619 int _rotate_func(void *data)
621 _D("%s\n", __func__);
622 struct appdata *ad = (struct appdata *)data;
626 retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
628 d = XOpenDisplay(NULL);
629 ret = _efl_rotate(d, ad);
635 int myterm(bundle *b, void *data)
640 int mytimeout(bundle *b, void *data)
645 syspopup_handler handler = {
646 .def_term_fn = myterm,
647 .def_timeout_fn = mytimeout
650 void _set_level(int type)
653 _get_sound_level(type, &val);
654 _set_sound_level(type, val);
655 _D("type(%d) val(%d)\n", type, val);
658 static void _block_clicked_cb(void *data, Evas_Object *o, const char *emission, const char *source)
663 Eina_Bool _slider_timer_cb(void *data)
666 struct appdata *ad = (struct appdata *)data;
667 retvm_if(ad == NULL, 0, "Invalid argument: appdata is NULL\n");
669 val = elm_slider_value_get(ad->sl);
672 _set_sound_level(ad->type, (int)val);
675 elm_slider_value_set(ad->sl, 0);
676 _set_sound_level(ad->type, 0);
678 return ECORE_CALLBACK_RENEW;
680 return ECORE_CALLBACK_CANCEL;
683 static void _slider_start_cb(void *data, Evas_Object *obj, void *event_info)
685 _D("%s\n", __func__);
687 struct appdata *ad = (struct appdata *)data;
688 retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
690 if (ad->flag_pressing == EINA_TRUE) {
693 ad->flag_touching = EINA_TRUE;
695 DEL_TIMER(ad->ptimer)
697 vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &snd);
699 vconf_set_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, EINA_TRUE);
703 if (ad->lutimer || ad->ldtimer) {
704 _D("return when long press is working\n");
708 ADD_TIMER(ad->stimer, 0.2, _slider_timer_cb, data)
711 static void _slider_changed_cb(void *data, Evas_Object *obj, void *event_info)
713 struct appdata *ad = (struct appdata *)data;
714 retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
716 if (ad->flag_pressing == EINA_TRUE) {
719 if (ad->lutimer || ad->ldtimer) {
720 _D("return when long press is working\n");
724 static void _slider_stop_cb(void *data, Evas_Object *obj, void *event_info)
728 struct appdata *ad = (struct appdata *)data;
729 retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
731 if (ad->flag_pressing == EINA_TRUE) {
734 if (ad->lutimer || ad->ldtimer) {
735 _D("return when long press is working\n");
738 DEL_TIMER(ad->stimer)
740 val = elm_slider_value_get(ad->sl);
742 _set_sound_level(ad->type, (int)val);
744 _play_sound(ad->type, ad->sh);
745 ad->flag_touching = EINA_FALSE;
746 ADD_TIMER(ad->ptimer, 3.0, popup_timer_cb, ad)
749 Eina_Bool _lu_warmup_timer_cb(void *data)
751 struct appdata *ad = (struct appdata *)data;
752 retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument: appdata is NULL\n");
753 ADD_TIMER(ad->lutimer, 0.0, _lu_timer_cb, ad)
754 return ECORE_CALLBACK_CANCEL;
757 Eina_Bool _ld_warmup_timer_cb(void *data)
759 struct appdata *ad = (struct appdata *)data;
760 retvm_if(ad == NULL, ECORE_CALLBACK_CANCEL, "Invalid argument: appdata is NULL\n");
761 ADD_TIMER(ad->ldtimer, 0.0, _ld_timer_cb, ad)
762 return ECORE_CALLBACK_CANCEL;
765 void _init_press_timers(void *data)
767 struct appdata *ad = (struct appdata *)data;
768 retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
769 DEL_TIMER(ad->sdtimer)
770 DEL_TIMER(ad->ldtimer)
771 DEL_TIMER(ad->ldwarmtimer)
772 DEL_TIMER(ad->sutimer)
773 DEL_TIMER(ad->lutimer)
774 DEL_TIMER(ad->luwarmtimer)
777 int _handle_bundle(bundle *b, struct appdata *ad)
779 const char *bval = NULL;
780 retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
782 bval = bundle_get_val(b, "LONG_PRESS");
784 _D("val(%s)\n", bval);
786 if (!strncmp(bval, "VOLUME_UP", strlen("LONG_PRESS"))) {
787 _D("volume up long press\n");
788 DEL_TIMER(ad->ptimer)
789 ADD_TIMER(ad->luwarmtimer, 0.5, _lu_warmup_timer_cb, ad);
790 } else if (!strncmp(bval, "VOLUME_DOWN", strlen("LONG_PRESS"))) {
791 _D("volume down long press\n");
792 DEL_TIMER(ad->ptimer)
793 ADD_TIMER(ad->ldwarmtimer, 0.5, _ld_warmup_timer_cb, ad);
795 ADD_TIMER(ad->ptimer, 3.0, popup_timer_cb, ad)
798 ADD_TIMER(ad->ptimer, 3.0, popup_timer_cb, ad)
799 _init_press_timers(ad);
804 static void _button_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
806 _D("%s\n", __func__);
807 struct appdata *ad = (struct appdata *)data;
808 retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
809 char buf[PATHBUF_SIZE] = {0, };
810 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, IMG_VOLUME_ICON_SETTINGS_PRESSED);
811 elm_image_file_set(obj, buf, NULL);
814 static void _button_cb(void *data, Evas_Object *obj, void *event_info)
816 _D("%s\n", __func__);
817 struct appdata *ad = (struct appdata *)data;
818 retm_if(ad == NULL, "Invalid argument: appdata is NULL\n");
819 char buf[PATHBUF_SIZE] = {0, };
820 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, IMG_VOLUME_ICON_SETTINGS);
821 elm_image_file_set(obj, buf, NULL);
822 if(evas_object_visible_get(ad->win)){
823 DEL_TIMER(ad->ptimer)
824 if(ecore_x_e_illume_quickpanel_state_get(
825 ecore_x_e_illume_zone_get(elm_win_xwindow_get(ad->win))) != ECORE_X_ILLUME_QUICKPANEL_STATE_OFF)
827 _D("Quickpanel is hide\n");
828 ecore_x_e_illume_quickpanel_state_send(
829 ecore_x_e_illume_zone_get(elm_win_xwindow_get(ad->win)), ECORE_X_ILLUME_QUICKPANEL_STATE_OFF);
832 service_create(&svc);
833 service_set_package(svc, "setting-profile-efl");
834 service_send_launch_request(svc, NULL, NULL);
837 service_destroy(svc);
841 int _app_reset(bundle *b, void *data)
843 _D("%s\n", __func__);
844 int ret = -1, status = -1, val = 0;
845 int type = MM_ERROR_SOUND_VOLUME_CAPTURE_ONLY;
846 int lock = IDLELOCK_ON;
847 Evas_Object *win, *sl, *ic, *ic_settings;
848 /* volume-app layout */
850 Evas_Object *outer, *inner, *block;
851 char buf[PATHBUF_SIZE] = {0, };
852 struct appdata *ad = (struct appdata *)data;
853 retvm_if(ad == NULL, -1, "Invalid argument: appdata is NULL\n");
855 ad->noti_seen = EINA_FALSE;
856 ad->flag_launching = EINA_FALSE;
857 ad->flag_pressing = EINA_FALSE;
858 ad->flag_touching = EINA_FALSE;
860 status = _check_status(&lock, &type);
862 mm_sound_volume_get_value(type, (unsigned int*)(&val));
864 win = _add_window(PACKAGE);
865 retvm_if(win == NULL, -1, "Failed add window\n");
868 th = elm_theme_new();
869 elm_theme_ref_set(th, NULL);
870 elm_theme_extension_add(th, EDJ_APP);
872 block = _add_layout(win, EDJ_APP, GRP_VOLUME_BLOCKEVENTS);
873 edje_object_signal_callback_add(elm_layout_edje_get(block), "clicked", "*", _block_clicked_cb, ad);
874 outer = _add_layout(win, EDJ_APP, GRP_VOLUME_LAYOUT);
875 inner = _add_layout(win, EDJ_APP, "popup_volumebar");
876 ad->block_events = block;
879 elm_object_part_content_set(outer, "elm.swallow.content", inner);
881 sl = _add_slider(win, 0, ad->step, val);
882 elm_object_theme_set(sl, th);
883 evas_object_smart_callback_add(sl, "slider,drag,start", _slider_start_cb, ad);
884 evas_object_smart_callback_add(sl, "changed", _slider_changed_cb, ad);
885 evas_object_smart_callback_add(sl, "slider,drag,stop", _slider_stop_cb, ad);
887 ic_settings = elm_icon_add(win);
888 evas_object_size_hint_aspect_set(ic_settings, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
889 elm_image_resizable_set(ic_settings, EINA_FALSE, EINA_FALSE);
890 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, IMG_VOLUME_ICON_SETTINGS);
892 elm_image_file_set(ic_settings, buf, NULL);
893 elm_object_part_content_set(inner, "elm.swallow.icon", ic_settings);
894 evas_object_event_callback_add(ic_settings, EVAS_CALLBACK_MOUSE_DOWN, _button_mouse_down_cb, ad);
895 evas_object_smart_callback_add(ic_settings, "clicked", _button_cb, ad);
896 evas_object_show(ic_settings);
897 ad->ic_settings = ic_settings;
900 elm_object_part_content_set(inner, "elm.swallow.content", sl);
902 ic = elm_icon_add(win);
903 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
904 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
905 elm_object_part_content_set(ad->sl, "icon", ic);
909 ret = syspopup_create(b, &handler, ad->win, ad);
910 retvm_if(ret < 0, -1, "Failed to create syspopup\n");
911 ad->volume_bundle = bundle_dup(b);
916 int _app_pause(struct appdata *ad)
918 _D("%s\n", __func__);