From: jk7744.park Date: Sat, 24 Oct 2015 06:47:35 +0000 (+0900) Subject: tizen 2.4 release X-Git-Tag: accepted/tizen/2.4/mobile/20151029.040938^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fheads%2Faccepted%2Ftizen_2.4_mobile;p=apps%2Fhome%2Fvolume-app.git tizen 2.4 release --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ef7a01e..be7ea99 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ SET(SRCS src/key_event.c src/timer.c src/sound.c + src/bt.c ) SET(VENDOR "tizen") @@ -40,16 +41,15 @@ pkg_check_modules(pkgs REQUIRED evas edje capi-media-sound-manager + capi-network-bluetooth vconf utilX syspopup syspopup-caller bundle feedback - ui-gadget-1 notification x11 xcomposite xext xi - efl-assist ) FOREACH(flag ${pkgs_CFLAGS}) diff --git a/LICENSE b/LICENSE old mode 100755 new mode 100644 index 3d4a47d..54b213e --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved +Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved. Apache License Version 2.0, January 2004 diff --git a/NOTICE b/NOTICE index 717d8cf..887a3bd 100644 --- a/NOTICE +++ b/NOTICE @@ -1,2 +1,2 @@ -Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved +Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved diff --git a/data/color_classes.edc b/data/color_classes.edc new file mode 100644 index 0000000..363380c --- /dev/null +++ b/data/color_classes.edc @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +color_classes { + color_class { + name: "W0113"; + //color: 188 70 80 100; + color: 61 185 204 100; + } + color_class { + name: "W0113D"; + color: 61 185 204 30; + } + color_class { + name: "W0113P"; + color: 34 104 115 100; + } + color_class { + name: "AO001"; + color: 201 201 201 100; + } +} diff --git a/data/images/private/volume/sound_slider_icon_incoming_call.png b/data/images/private/volume/sound_slider_icon_incoming_call.png new file mode 100644 index 0000000..37a9d35 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_incoming_call.png differ diff --git a/data/images/private/volume/sound_slider_icon_notification.png b/data/images/private/volume/sound_slider_icon_notification.png new file mode 100644 index 0000000..31d2579 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_notification.png differ diff --git a/data/images/private/volume/sound_slider_icon_notification_mute.png b/data/images/private/volume/sound_slider_icon_notification_mute.png new file mode 100644 index 0000000..e57a141 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_notification_mute.png differ diff --git a/data/images/private/volume/sound_slider_icon_notification_vibrate.png b/data/images/private/volume/sound_slider_icon_notification_vibrate.png new file mode 100644 index 0000000..84450cd Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_notification_vibrate.png differ diff --git a/data/images/private/volume/sound_slider_icon_system.png b/data/images/private/volume/sound_slider_icon_system.png new file mode 100644 index 0000000..95083f5 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_system.png differ diff --git a/data/images/private/volume/sound_slider_icon_system_mute.png b/data/images/private/volume/sound_slider_icon_system_mute.png new file mode 100644 index 0000000..54748dc Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_system_mute.png differ diff --git a/data/images/private/volume/sound_slider_icon_system_vibrate.png b/data/images/private/volume/sound_slider_icon_system_vibrate.png new file mode 100644 index 0000000..254fa44 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_system_vibrate.png differ diff --git a/data/images/private/volume/sound_slider_icon_volume.png b/data/images/private/volume/sound_slider_icon_volume.png new file mode 100644 index 0000000..5bc5a27 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_volume.png differ diff --git a/data/images/private/volume/sound_slider_icon_volume_mute.png b/data/images/private/volume/sound_slider_icon_volume_mute.png new file mode 100644 index 0000000..3eb2585 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_volume_mute.png differ diff --git a/data/images/private/volume/sound_slider_icon_volume_vibrate.png b/data/images/private/volume/sound_slider_icon_volume_vibrate.png new file mode 100644 index 0000000..2b83af8 Binary files /dev/null and b/data/images/private/volume/sound_slider_icon_volume_vibrate.png differ diff --git a/data/images/private/volume/sound_volume_ic_setting.png b/data/images/private/volume/sound_volume_ic_setting.png new file mode 100644 index 0000000..197fd12 Binary files /dev/null and b/data/images/private/volume/sound_volume_ic_setting.png differ diff --git a/data/images/private/volume/sound_volume_popup_bg.#.png b/data/images/private/volume/sound_volume_popup_bg.#.png new file mode 100644 index 0000000..0dcfc27 Binary files /dev/null and b/data/images/private/volume/sound_volume_popup_bg.#.png differ diff --git a/data/volume_app.edc b/data/volume_app.edc index 5aa50cb..04b0ad3 100755 --- a/data/volume_app.edc +++ b/data/volume_app.edc @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +31,8 @@ */ +#include + /* * Helper sizes */ @@ -163,7 +165,7 @@ image.normal : FILE_NAME; \ aspect : 1 1; \ aspect_preference : BOTH; \ - color_class: "W0661"; \ + color_class: "W0113"; \ } \ } \ } \ @@ -180,7 +182,7 @@ image.normal : FILE_NAME; \ aspect : 1 1; \ aspect_preference : BOTH; \ - color_class: "W0661D"; \ + color_class: "W0113D"; \ } \ } \ } \ @@ -197,7 +199,7 @@ image.normal : FILE_NAME; \ aspect : 1 1; \ aspect_preference : BOTH; \ - color_class: "B0563L1P"; \ + color_class: "W0113P"; \ } \ } \ } \ @@ -206,23 +208,23 @@ collections { -RESOURCE_IMAGE("00_volume_icon.png"); -RESOURCE_IMAGE("00_volume_icon_call.png"); -RESOURCE_IMAGE("00_volume_icon_mute.png"); -RESOURCE_IMAGE("00_volume_icon_vibrat.png"); +RESOURCE_IMAGE("sound_slider_icon_volume.png"); +RESOURCE_IMAGE("sound_slider_icon_incoming_call.png"); +RESOURCE_IMAGE("sound_slider_icon_volume_mute.png"); +RESOURCE_IMAGE("sound_slider_icon_volume_vibrate.png"); RESOURCE_IMAGE("00_volume_icon_headphone.png"); RESOURCE_IMAGE("00_volume_icon_media.png"); -RESOURCE_IMAGE("00_volume_icon_notification.png"); -RESOURCE_IMAGE("00_volume_icon_notification_vibrate.png"); -RESOURCE_IMAGE("00_volume_icon_notification_mute.png"); +RESOURCE_IMAGE("sound_slider_icon_notification.png"); +RESOURCE_IMAGE("sound_slider_icon_notification_vibrate.png"); +RESOURCE_IMAGE("sound_slider_icon_notification_mute.png"); RESOURCE_IMAGE_DIM("00_volume_icon_settings_disabled.png"); -RESOURCE_IMAGE("00_volume_icon_settings.png"); +RESOURCE_IMAGE("sound_volume_ic_setting.png"); RESOURCE_IMAGE_PRESS("00_volume_icon_settings_pressed.png"); group { name : "volume_layout"; images { - image: "00_popup_bubble_bg.#.png" COMP; + image: "sound_volume_popup_bg.#.png" COMP; } styles { style { @@ -235,13 +237,12 @@ RESOURCE_IMAGE_PRESS("00_volume_icon_settings_pressed.png"); name : "clipper"; type : RECT; - scale: 1; description { state : "default" 0.0; } description{ state : "transit" 0.0; - color: 255 255 255 0; + color: 0 0 0 0; } } @@ -288,15 +289,21 @@ RESOURCE_IMAGE_PRESS("00_volume_icon_settings_pressed.png"); mouse_events : 0; scale : 1; description { + state : "default" 0.0; + image.normal: "sound_volume_popup_bg.#.png"; + rel1.to : "bg"; + rel2.to : "bg"; + } + description { state : "portrait" 0.0; - image.normal: "00_popup_bubble_bg.#.png"; + image.normal: "sound_volume_popup_bg.#.png"; rel1.to : "bg"; rel2.to : "bg"; } description { state : "landscape" 0.0; visible : 1; - image.normal: "00_popup_bubble_bg.#.png"; + image.normal: "sound_volume_popup_bg.#.png"; rel1.to : "bg"; rel2.to : "bg"; } @@ -359,7 +366,7 @@ RESOURCE_IMAGE_PRESS("00_volume_icon_settings_pressed.png"); scale : 1; description { state : "default" 0.0; - color: 200 200 200 100; + color_class: "AO001"; visible : 1; rel1 { relative : DIVIDER_X_MIN DIVIDER_Y_MIN; to : "clipper";} rel2 { relative : DIVIDER_X_MAX DIVIDER_Y_MAX; to : "clipper";} @@ -382,6 +389,7 @@ RESOURCE_IMAGE_PRESS("00_volume_icon_settings_pressed.png"); scale : 1; description { state : "default" 0.0; + fixed: 1 1; rel1 { relative : IC_CONTENT_X_MIN IC_CONTENT_Y_MIN; to : "clipper";} rel2 { relative : IC_CONTENT_X_MAX IC_CONTENT_Y_MAX; to : "clipper";} visible : 1; diff --git a/include/_util_efl.h b/include/_util_efl.h index c64148f..b7fc033 100755 --- a/include/_util_efl.h +++ b/include/_util_efl.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/_util_log.h b/include/_util_log.h index 43703a9..00876bd 100755 --- a/include/_util_log.h +++ b/include/_util_log.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/bt.h b/include/bt.h new file mode 100644 index 0000000..c873d14 --- /dev/null +++ b/include/bt.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#ifndef __VOLUME_BT_H__ +#define __VOLUME_BT_H__ + +extern int bt_get_bt_volume(void); +extern void bt_init_sco(void); +extern void bt_deinit_sco(void); + +#endif diff --git a/include/control.h b/include/control.h index b2c811e..30f84e5 100755 --- a/include/control.h +++ b/include/control.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,35 +31,38 @@ enum{ LOCK_AND_MEDIA, }; +extern void volume_control_check_syspopup(); +extern int volume_register_shape_timer(); +extern void volume_control_check_once(void); +extern int volume_control_get_viewport_height(); +extern int volume_control_get_viewport_width(); +extern void volume_control_show_hide_worning(); +extern Eina_Bool volume_control_viewport_is_warning_visible(); -int volume_control_viewport_height_get(); -int volume_control_viewport_width_get(); -void volume_control_show_hide_worning(); -Eina_Bool volume_control_viewport_is_warning_visible(); +extern bundle *volume_control_reset_get_bundle(void); +extern Eina_Bool volume_control_get_is_deleting(void); +extern Eina_Bool volume_control_get_is_launching(void); +extern int volume_control_get_current_angle(void); +extern sound_type_e volume_control_get_sound_type_at_show(void); -bundle *volume_control_reset_bundle_get(void); -Eina_Bool volume_control_is_deleting_get(void); -Eina_Bool volume_control_is_launching_get(void); -int volume_control_current_angle_get(void); -sound_type_e volume_control_sound_type_at_show_get(void); +extern volume_error_e volume_control_cache_flush(void); -volume_error_e volume_control_cache_flush(void); +extern volume_error_e volume_control_app_launch_with_bundle(const char *op_type, const char *operation, const char *pkgname); +extern volume_error_e volume_control_mode_syspopup_launch(void); +extern int volume_control_get_vconf_idlelock(void); -volume_error_e volume_control_app_launch_with_bundle(const char *op_type, const char *operation, const char *pkgname); -volume_error_e volume_control_mode_syspopup_launch(void); -int volume_control_vconf_idlelock_get(void); +extern int volume_control_check_status(int *lock, sound_type_e *sound_type); -int volume_control_status_check(int *lock, sound_type_e *sound_type); +extern Eina_Bool volume_control_show_view(int status, sound_type_e sound_type, int sound, bool bt_opened); +extern int volume_control_hide_view(void); +extern volume_error_e volume_control_close_bt_display(); -Eina_Bool volume_control_show(void); -int volume_control_close(void); +extern void volume_control_register_vconfkey(void); +extern void volume_control_unregister_vconfkey(void); -void volume_control_vconfkey_register(void); -void volume_control_vconfkey_unregister(void); - -volume_error_e volume_control_pause(void); -volume_error_e volume_control_reset(bundle *b); -volume_error_e volume_control_initialize(void); -void volume_control_deinitialize(void); +extern volume_error_e volume_control_pause(void); +extern volume_error_e volume_control_reset(bundle *b); +extern volume_error_e volume_control_initialize(void); +extern void volume_control_deinitialize(void); #endif /* __VOLUME_CONTROL_H__ */ diff --git a/include/key_event.h b/include/key_event.h index 4933631..3ca1718 100755 --- a/include/key_event.h +++ b/include/key_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,12 @@ #ifndef __VOLUME_KEY_EVENT_H__ #define __VOLUME_KEY_EVENT_H__ +#define KEY_VOLUMEUP "XF86AudioRaiseVolume" +#define KEY_VOLUMEDOWN "XF86AudioLowerVolume" +#define KEY_MUTE "XF86AudioMute" +#define KEY_BACK "XF86Back" +#define KEY_CANCEL "Cancel" + Ecore_X_Window volume_key_event_input_window_get(void); Ecore_Event_Handler *volume_key_event_handler_volume_up_get(void); Ecore_Event_Handler *volume_key_event_handler_volume_down_get(void); diff --git a/include/main.h b/include/main.h index 17af031..7d80712 100755 --- a/include/main.h +++ b/include/main.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -49,16 +48,16 @@ #define EDJ_APP EDJDIR"/volume_app.edj" -#define IMG_VOLUME_ICON "00_volume_icon.png" -#define IMG_VOLUME_ICON_CALL "00_volume_icon_call.png" -#define IMG_VOLUME_ICON_MUTE "00_volume_icon_mute.png" -#define IMG_VOLUME_ICON_VIB "00_volume_icon_vibrat.png" -#define IMG_VOLUME_ICON_NOTI "00_volume_icon_notification.png" -#define IMG_VOLUME_ICON_NOTI_VIB "00_volume_icon_notification_vibrate.png" -#define IMG_VOLUME_ICON_NOTI_MUTE "00_volume_icon_notification_mute.png" +#define IMG_VOLUME_ICON "sound_slider_icon_volume.png" +#define IMG_VOLUME_ICON_CALL "sound_slider_icon_incoming_call.png" +#define IMG_VOLUME_ICON_MUTE "sound_slider_icon_volume_mute.png" +#define IMG_VOLUME_ICON_VIB "sound_slider_icon_volume_vibrate.png" +#define IMG_VOLUME_ICON_NOTI "sound_slider_icon_notification.png" +#define IMG_VOLUME_ICON_NOTI_VIB "sound_slider_icon_notification_vibrate.png" +#define IMG_VOLUME_ICON_NOTI_MUTE "sound_slider_icon_notification_mute.png" #define IMG_VOLUME_ICON_HEADPHONE "00_volume_icon_headphone.png" #define IMG_VOLUME_ICON_MEDIA "00_volume_icon_media.png" -#define IMG_VOLUME_ICON_SETTINGS "00_volume_icon_settings.png" +#define IMG_VOLUME_ICON_SETTINGS "sound_volume_ic_setting.png" #define IMG_VOLUME_ICON_SETTINGS_PRESSED "00_volume_icon_settings_pressed.png" #define IMG_VOLUME_ICON_SETTINGS_DISABLED "00_volume_icon_settings_disabled.png" @@ -97,8 +96,8 @@ #define WIN_HEIGHT 102 #define WIN_LANDSCAPE_X 79 -#define WIN_LANDSCAPE_INVERTED_X volume_control_viewport_width_get()-WIN_HEIGHT_WITH_WARNING-WIN_LANDSCAPE_X -#define WIN_LANDSCAPE_Y (volume_control_viewport_height_get()-WIN_WIDTH)/2 +#define WIN_LANDSCAPE_INVERTED_X volume_control_get_viewport_width()-WIN_HEIGHT_WITH_WARNING-WIN_LANDSCAPE_X +#define WIN_LANDSCAPE_Y (volume_control_get_viewport_height()-WIN_WIDTH)/2 #define WIN_PORTRAIT_X 12 #define WIN_PORTRAIT_Y 113 #define WIN_SLIDER_TOUCHING_OFFSET 55 diff --git a/include/sound.h b/include/sound.h index 6e8c54b..cff3268 100755 --- a/include/sound.h +++ b/include/sound.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/include/timer.h b/include/timer.h index 35b8de9..8e62ca7 100755 --- a/include/timer.h +++ b/include/timer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,31 +19,32 @@ #define DEL_TIMER(x) \ if (x) {\ - _D("DELTIMER x : %d\n", x);\ + _D("DELTIMER x : %p\n", x);\ ecore_timer_del(x);\ x = NULL;\ } #define ADD_TIMER(x, time, _timer_cb, data) \ if(x != NULL) DEL_TIMER(x); \ x = ecore_timer_add(time, _timer_cb, data);\ - _D("ADDTIMER x : %d\n", x);\ + _D("ADDTIMER x : %p\n", x);\ typedef enum { TYPE_TIMER_POPUP = 0, TYPE_TIMER_SLIDER, TYPE_TIMER_SD, - TYPE_TIMER_SU + TYPE_TIMER_SU, + TYPE_TIMER_BT } volume_timer_type; -Ecore_Timer *volume_timer_popup_timer_get(void); -Ecore_Timer *volume_timer_slider_timer_get(void); -Ecore_Timer *volume_timer_su_timer_get(void); -Ecore_Timer *volume_timer_sd_timer_get(void); +extern Ecore_Timer *volume_timer_popup_timer_get(void); +extern Ecore_Timer *volume_timer_slider_timer_get(void); +extern Ecore_Timer *volume_timer_su_timer_get(void); +extern Ecore_Timer *volume_timer_sd_timer_get(void); -Eina_Bool volume_timer_popup_cb(void *data); -Eina_Bool volume_timer_slider_timer_cb(void *data); +extern Eina_Bool volume_timer_popup_cb(void *data); +extern Eina_Bool volume_timer_slider_timer_cb(void *data); -void volume_timer_add(double time, volume_timer_type type); -void volume_timer_del(volume_timer_type); +extern void volume_timer_add(double time, volume_timer_type type); +extern void volume_timer_del(volume_timer_type); #endif /* __VOLUME_TIMER_H__ */ diff --git a/include/view.h b/include/view.h index 5c8df26..18dfd1f 100755 --- a/include/view.h +++ b/include/view.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,22 +19,24 @@ #define __VOLUME_VIEW_H__ Evas_Object *volume_view_win_get(void); +Evas_Object *volume_view_evas_get(void); Evas_Object *volume_view_outer_layout_get(void); Evas_Object *volume_view_icon_volume_get(void); Evas_Object *volume_view_icon_setting_get(void); Evas_Object *volume_view_slider_get(void); +sound_type_e volume_view_pre_sound_type_get(void); Eina_Bool volume_view_is_registered_callback_get(void); Eina_Bool volume_view_is_slider_touching_get(void); void volume_view_is_registered_callback_set(Eina_Bool val); int volume_mute_toggle_set(void); volume_error_e volume_view_slider_value_set(int val); -//volume_error_e volume_view_icon_set(void); -void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int vibration); +volume_error_e volume_change_slider_max_value(sound_type_e type); +void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int vibration, bool bt_opened); void volume_view_setting_icon_set(const char *file); void volume_view_setting_icon_callback_del(void); -volume_error_e volume_view_window_show(void); +volume_error_e volume_view_window_show(sound_type_e type); volume_error_e volume_view_window_hide(void); volume_error_e volume_view_layout_create(Evas_Object *win); diff --git a/include/x_event.h b/include/x_event.h index 0e9fa1b..a0c8727 100755 --- a/include/x_event.h +++ b/include/x_event.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/org.tizen.volume.efl b/org.tizen.volume.efl index ff739b4..b8b3fd9 100644 --- a/org.tizen.volume.efl +++ b/org.tizen.volume.efl @@ -5,50 +5,26 @@ org.tizen.volume isf rwx--- ------ org.tizen.volume sound_server rw---- ------ org.tizen.volume syspopup::db rw---- ------ org.tizen.volume pulseaudio rwxat- ------ -org.tizen.volume ail::db rw---- ------ org.tizen.volume connman r----- ------ org.tizen.volume system rwx--- ------ org.tizen.volume immvibed rw---- ------ org.tizen.volume svi-data r-x--- ------ -org.tizen.volume org.tizen.setting rwx--- ------ -org.tizen.volume org.tizen.message rw---- ------ -org.tizen.volume org.tizen.lockscreen rwx--- ------ org.tizen.volume e17 r-x--- ------ -org.tizen.volume system::vconf_setting rw---- ------ -org.tizen.volume system::vconf_inhouse rw---- ------ org.tizen.volume notification::db rw---- ------ org.tizen.volume org.tizen.indicator rw---- ------ org.tizen.volume data-provider-master::notification rw---- ------ org.tizen.volume data-provider-master::notification.client rw---- ------ -org.tizen.volume system::vconf_multimedia rw---- ------ org.tizen.volume org.tizen.setting::default-resources r-x--- ------ -org.tizen.volume ug-image-viewer-efl rwx--- ------ -org.tizen.volume org.tizen.clock rw---- ------ org.tizen.volume sdbd rw---- ------ -org.tizen.volume clock::vconf_share rw---- ------ org.tizen.volume aul::launch --x--- ------ -org.tizen.volume starter::vconf rw---- ------ -org.tizen.volume ug-setting-call-efl::vconf rw---- ------ -org.tizen.volume org.tizen.safetyvolume-syspopup r-x--- ------ org.tizen.volume pkgmgr::db rw---l ------ org.tizen.volume trm -w---- ------ org.tizen.volume app-svc --x--- ------ -org.tizen.volume org.tizen.music-player-lite rw---- ------ org.tizen.volume deviced::haptic rw---- ------ -org.tizen.volume org.tizen.wallpaper-service rwx--- ------ -org.tizen.volume org.tizen.wallpaper-service::wallpaper-service rwx--- ------ aul org.tizen.volume r-x--- ------ system org.tizen.volume -w---- ------ -org.tizen.cluster-home org.tizen.volume r-x--- ------ -org.tizen.app-tray org.tizen.volume r-x--- ------ org.tizen.indicator org.tizen.volume -w---- ------ -org.tizen.music-player-lite org.tizen.volume r----- ------ -org.tizen.clock org.tizen.volume rw---- ------ -org.tizen.mode-syspopup org.tizen.volume --x--- ------ -org.tizen.dailybriefing-agent org.tizen.volume --x--- ------ -org.tizen.safetyvolume-syspopup org.tizen.volume r-x--- ------ org.tizen.volume system::homedir rwxat- ------ -org.tizen.volume system::vconf rwxat- ------ org.tizen.volume system::media rwxat- ------ org.tizen.volume system::share rwxat- ------ e17 org.tizen.volume -w---- ------ @@ -56,8 +32,16 @@ org.tizen.volume device::app_logging rw---- ------ org.tizen.volume device::sys_logging rw---- ------ org.tizen.volume sys-assert::core rwxat- ------ org.tizen.volume privacy-manager::db r----l ------ -org.tizen.volume system::vconf_privacy rw---- ------ -org.tizen.volume system::vconf_system rw---- ------ -org.tizen.volume system::vconf_network rw---- ------ -org.tizen.volume system::vconf_misc rw---- ------ org.tizen.volume ecore::lock rwxat- ------ +org.tizen.volume tizen::vconf::platform::r rwx--- ------- +org.tizen.volume tizen::vconf::platform::rw r----l ------- +org.tizen.volume tizen::vconf::telephony::admin r----l ------- +org.tizen.volume tizen::vconf::display r----l ------- +org.tizen.volume tizen::vconf::volume::set rw---l ------- +org.tizen.volume tizen::vconf::setting::admin rw---l ------- +org.tizen.volume tizen::vconf::public::r r----l ------ +org.tizen.volume tizen::vconf::public::r::platform::rw r----l ------ +org.tizen.volume tizen::vconf::public::rw r----l ------ +org.tizen.volume tizen::vconf::public::admin r----l ------ +org.tizen.volume tizen::vconf::camcorder r----l ------ +org.tizen.volume notification r-x--l ------ diff --git a/org.tizen.volume.xml b/org.tizen.volume.xml index 8634727..dc83005 100755 --- a/org.tizen.volume.xml +++ b/org.tizen.volume.xml @@ -1,7 +1,7 @@ - Hong Kwon + junkyu Han Volume Application org.tizen.volume.png diff --git a/packaging/org.tizen.volume.spec b/packaging/org.tizen.volume.spec index 3f03638..7a79fe3 100755 --- a/packaging/org.tizen.volume.spec +++ b/packaging/org.tizen.volume.spec @@ -4,6 +4,10 @@ ExcludeArch: %{arm} %ix86 x86_64 %endif +%if "%{?tizen_profile_name}" == "tv" +ExcludeArch: %{arm} %ix86 x86_64 +%endif + Name: org.tizen.volume Summary: Volume application (EFL) Version: 0.1.148 @@ -19,7 +23,6 @@ BuildRequires: pkgconfig(utilX) BuildRequires: pkgconfig(capi-media-sound-manager) BuildRequires: pkgconfig(syspopup) BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(ui-gadget-1) BuildRequires: pkgconfig(notification) BuildRequires: pkgconfig(feedback) BuildRequires: pkgconfig(syspopup-caller) @@ -27,7 +30,7 @@ BuildRequires: pkgconfig(x11) BuildRequires: pkgconfig(xcomposite) BuildRequires: pkgconfig(xext) BuildRequires: pkgconfig(xi) -BuildRequires: pkgconfig(efl-assist) +BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: cmake BuildRequires: edje-bin diff --git a/src/bt.c b/src/bt.c new file mode 100644 index 0000000..d321407 --- /dev/null +++ b/src/bt.c @@ -0,0 +1,184 @@ +/* + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +#include +#include +#include +#include +#include +#include +#include + +#include "main.h" +#include "_util_log.h" +#include "view.h" +#include "control.h" +#include "sound.h" +#include "x_event.h" +#include "timer.h" + +static void _bt_display_bt_volume_view(sound_type_e sound_type, int sound, int vibration, bool bt_opened); +static void _bt_volume_changed_cb(int volume, void *user_data); +static void _bt_state_changed_cb(int result, bool opened, void *user_data); +static int _bt_register_changed_cb(void); +static int _bt_unregister_changed_cb(void); + +int bt_get_bt_volume(void) +{ + int ret = BT_ERROR_NONE; + int bt_vol = 0; + + ret = bt_ag_get_speaker_gain(&bt_vol); + if (ret != BT_ERROR_NONE) + { + _E("bt_ag_get_speaker_gain Failed"); + return -1; + } + _D("bt vol: %d", bt_vol); + return bt_vol; +} + +void bt_init_sco(void) +{ + _D("SCO volume initialize"); + if (BT_ERROR_NONE != bt_initialize()) { + _E("BT initialize failed"); + } + + if (_bt_register_changed_cb() != BT_ERROR_NONE) { + _E("volume bt register changed cb failed"); + } +} + +void bt_deinit_sco(void) +{ + _D("SCO volume Deinitialize"); + if (_bt_unregister_changed_cb() != BT_ERROR_NONE) { + _E("volume bt Unregister changed cb failed"); + } + + if (BT_ERROR_NONE != bt_deinitialize()) { + _E("BT Deinitialize failed"); + } +} + +static void _bt_display_bt_volume_view(sound_type_e sound_type, int sound, int vibration, bool bt_opened) +{ + if (VOLUME_ERROR_OK != volume_view_window_show(sound_type)) { + _E("Failed to show volume window"); + } + + if (VOLUME_ERROR_OK != volume_x_input_event_register()) { + _E("Failed to add x input event handler"); + } + + volume_control_check_syspopup(); + + volume_control_check_once(); + + volume_view_volume_icon_set(sound_type, sound, vibration, bt_opened); + + if (VOLUME_ERROR_OK != volume_register_shape_timer()) + _E("Failed to register shape timer"); +} + +static void _bt_volume_changed_cb(int volume, void *user_data) +{ + bool bt_opened = false; + int error = 0; + int status = 0; + int sound = 0; + int lock = 1; + int vibration = 0; + sound_type_e sound_type = 0; + _D("BT VOLUME is changed"); + + status = volume_control_check_status(&lock, &sound_type); + _D("status: %d, lock: %d, sound type : %d", status, lock, sound_type); + + sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); + _D("sound status : %d", sound); + + error = bt_ag_is_sco_opened(&bt_opened); + if (error != BT_ERROR_NONE) + _E("bt_ag_is_sco_opened return [%d]", error); + _D("BT state %d", bt_opened); + + if (bt_opened == true && sound_type == SOUND_TYPE_CALL) + { + _D("BT volume is : %d", volume); + _bt_display_bt_volume_view(sound_type, sound, vibration, bt_opened); + if (VOLUME_ERROR_OK != volume_view_slider_value_set(volume)) + _E("Failed to set slider value"); + + volume_timer_add(3.0, TYPE_TIMER_BT); + } +} + +static void _bt_state_changed_cb(int result, bool opened, void *user_data) +{ + _D("SCO opened [%s]", opened ? "YES" : "NO"); +} + +static int _bt_register_changed_cb(void) +{ + int ret = 0; + + ret = bt_audio_initialize(); + if (ret != BT_ERROR_NONE) + { + _E("bt audio initialize failed"); + return -1; + } + + ret = bt_ag_set_speaker_gain_changed_cb(_bt_volume_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + { + _E("register bt volume changed callback failed"); + return -1; + } + + ret = bt_ag_set_sco_state_changed_cb(_bt_state_changed_cb, NULL); + if (ret != BT_ERROR_NONE) + _E("register bt state changed callback failed"); + + return 0; +} + +static int _bt_unregister_changed_cb(void) +{ + int ret = 0; + + ret = bt_audio_deinitialize(); + if (ret != BT_ERROR_NONE) { + _E("bt audio initialize failed"); + return -1; + } + + ret = bt_ag_unset_speaker_gain_changed_cb(); + if (ret != BT_ERROR_NONE) { + _E("register bt volume changed callback failed"); + return -1; + } + + ret = bt_ag_unset_sco_state_changed_cb(); + if (ret != BT_ERROR_NONE) + _E("register bt state changed callback failed"); + + return 0; +} + diff --git a/src/control.c b/src/control.c index 908330c..dacd8b8 100755 --- a/src/control.c +++ b/src/control.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,7 +17,9 @@ #include #include #include -#include +#include +#include +#include #include "main.h" #include "_util_efl.h" @@ -28,43 +30,39 @@ #include "timer.h" #include "x_event.h" #include "key_event.h" +#include "bt.h" #define VCONF_KEY_FMRADIO_RECORDING "memory/private/Sound/FMRadioRecording" -int myterm(bundle *b, void *data); -int mytimeout(bundle *b, void *data); - -syspopup_handler handler = { - .def_term_fn = myterm, - .def_timeout_fn = mytimeout -}; - -static struct _s_info { +struct _control_s_info{ bundle *volume_bundle; Ecore_Event_Handler *handler_qp_state; Ecore_Timer *shape_timer; Eina_Bool is_deleting; Eina_Bool is_launching; - Eina_Bool is_quickpanel; Eina_Bool is_new; Eina_Bool is_warning_visible; + Eina_Bool reset_once; + Eina_Bool show_once; int current_angle; int viewport_width; int viewport_height; sound_type_e sound_type_at_show; -} s_info = { +}; +static struct _control_s_info control_info = { .volume_bundle = NULL, .handler_qp_state = NULL, .shape_timer = NULL, .is_deleting = EINA_FALSE, .is_launching = EINA_FALSE, - .is_quickpanel = EINA_FALSE, .is_new = EINA_FALSE, .is_warning_visible = EINA_FALSE, + .reset_once = EINA_FALSE, + .show_once = EINA_FALSE, .current_angle = 0, .viewport_width = 0, @@ -73,50 +71,56 @@ static struct _s_info { .sound_type_at_show = SOUND_TYPE_RINGTONE, }; -static void _rotate_changed_cb(void *data, Evas_Object *obj, void *event_info); +static int _myterm(bundle *b, void *data); +static int _mytimeout(bundle *b, void *data); +static void _notify_pm_lcdoff_cb(keynode_t * node, void *data); +static void _idle_lock_state_vconf_changed_cb(keynode_t *key, void *data); +static void _starter_user_volume_key_vconf_changed_cb(keynode_t *key, void *data); static Eina_Bool _shape_cb(void *data); +static Eina_Bool _idler_top_position_grab(void *data); +static void _control_set_window_rotation(Evas_Object *win); +static void _rotate_changed_cb(void *data, Evas_Object *obj, void *event_info); -bundle* volume_control_reset_bundle_get(void) +bundle* volume_control_reset_get_bundle(void) { - return s_info.volume_bundle; + return control_info.volume_bundle; } -Eina_Bool volume_control_is_deleting_get(void) +Eina_Bool volume_control_get_is_deleting(void) { - return s_info.is_deleting; + return control_info.is_deleting; } -Eina_Bool volume_control_is_launching_get(void) +Eina_Bool volume_control_get_is_launching(void) { - return s_info.is_launching; + return control_info.is_launching; } -int volume_control_current_angle_get(void) +int volume_control_get_current_angle(void) { - return s_info.current_angle; + return control_info.current_angle; } -sound_type_e volume_control_sound_type_at_show_get(void) +sound_type_e volume_control_get_sound_type_at_show(void) { - return s_info.sound_type_at_show; + return control_info.sound_type_at_show; } -int volume_control_viewport_height_get() +int volume_control_get_viewport_height() { - return s_info.viewport_height; + return control_info.viewport_height; } -int volume_control_viewport_width_get() +int volume_control_get_viewport_width() { - return s_info.viewport_width; + return control_info.viewport_width; } Eina_Bool volume_control_viewport_is_warning_visible() { - return s_info.is_warning_visible; + return control_info.is_warning_visible; } -//int _cache_flush(void *data) volume_error_e volume_control_cache_flush(void) { Evas_Object *win = volume_view_win_get(); @@ -157,107 +161,13 @@ volume_error_e volume_control_cache_flush(void) } /* rotation event callback func. */ -static void _rotate_changed_cb(void *data, Evas_Object *obj, void *event_info) -{ - static int current_angle = -1; - int changed_angle = elm_win_rotation_get(obj); - LOGD("MIK"); - Evas_Object *win = volume_view_win_get(); - ret_if(!win); - - Evas_Object *ly_outer = volume_view_outer_layout_get(); - ret_if(!ly_outer); - - _D("window rotated [%d] => [%d]", current_angle, changed_angle); - if(current_angle != changed_angle) { - current_angle = changed_angle; - s_info.current_angle = current_angle; - switch(current_angle){ - case 90 : - _D("show,landscape"); - elm_object_signal_emit(ly_outer, "show,landscape", "bg"); - if(s_info.is_warning_visible) - { - elm_object_signal_emit(ly_outer, "show_warning_l", "clipper"); - } - break; - case 270 : - _D("show,landscape"); - elm_object_signal_emit(ly_outer, "show,landscape", "bg"); - if(s_info.is_warning_visible) - { - elm_object_signal_emit(ly_outer, "show_warning_l", "clipper"); - } - break; - default : - _D("show,portrait"); - elm_object_signal_emit(ly_outer, "show,portrait", "bg"); - if(s_info.is_warning_visible) - { - elm_object_signal_emit(ly_outer, "show_warning", "clipper"); - } - break; - } - - volume_x_input_event_shape(win, s_info.is_warning_visible); - } -} - -static void _control_window_rotation_set(Evas_Object *win) -{ - ret_if(!win); - - if (elm_win_wm_rotation_supported_get(win)) - { - const int rots[4] = { 0, 90, 180, 270 }; - elm_win_wm_rotation_available_rotations_set(win, (const int *)&rots, 4); - _D("set available rotations"); - } - - /* rotation event callback */ - evas_object_smart_callback_add(win, "wm,rotation,changed", _rotate_changed_cb, NULL); - - /* initialize degree */ - _rotate_changed_cb(NULL, win, NULL); -} - -static Eina_Bool _qp_state_check_cb(void *data, int type, void *event) -{ - retv_if(!event, ECORE_CALLBACK_PASS_ON); - - Ecore_X_Event_Client_Message *ev = event; - if (ev->message_type == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_STATE) - { - if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_OFF) - { - _D("quickpanel off state"); - s_info.is_quickpanel = EINA_FALSE; - } - else if (ev->data.l[0] == ECORE_X_ATOM_E_ILLUME_QUICKPANEL_ON) - { - _D("quickpanel on state"); - s_info.is_quickpanel = EINA_TRUE; - } - } - - return ECORE_CALLBACK_PASS_ON; -} - -static void _control_qp_state_handler_add(void) -{ - Ecore_Event_Handler *handler_qp_state = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _qp_state_check_cb, NULL); - s_info.handler_qp_state = handler_qp_state; -} - - volume_error_e volume_control_app_launch_with_bundle(const char *op_type, const char *operation, const char *pkgname) { app_control_h app_control; int ret = 0; ret = app_control_create(&app_control); - if (ret != 0) - { + if (ret != 0) { _E("Failed to create app control"); return VOLUME_ERROR_FAIL; } @@ -286,8 +196,7 @@ volume_error_e volume_control_app_launch_with_bundle(const char *op_type, const return VOLUME_ERROR_OK; } -//int _get_vconf_idlelock -int volume_control_vconf_idlelock_get(void) +int volume_control_get_vconf_idlelock(void) { int lock = IDLELOCK_OFF; int pm_state = VCONFKEY_PM_STATE_NORMAL; @@ -315,9 +224,9 @@ int volume_control_vconf_idlelock_get(void) } -int volume_control_status_check(int *lock, sound_type_e *sound_type) +int volume_control_check_status(int *lock, sound_type_e *sound_type) { - *lock = volume_control_vconf_idlelock_get(); + *lock = volume_control_get_vconf_idlelock(); *sound_type = volume_sound_sound_manager_type_get(); _D("lock : %d / sound_type : %d", *lock, *sound_type); @@ -341,17 +250,11 @@ int volume_control_status_check(int *lock, sound_type_e *sound_type) return UNLOCK_STATUS; } -static Eina_Bool _idler_top_position_grab(void *data) +void volume_control_shape_event_area(Eina_Bool is_warning_visible) { - volume_key_event_key_grab(-1, TOP_POSITION_GRAB); - - return ECORE_CALLBACK_CANCEL; -} - -void volume_control_event_shape(Eina_Bool is_warning_visible) -{ - Evas_Object *win = volume_view_win_get(); - volume_x_input_event_shape(win, is_warning_visible); + _D("shape event area"); + Evas_Object *win = volume_view_win_get(); + volume_x_input_event_shape(win, is_warning_visible); } void volume_control_show_hide_worning() @@ -363,11 +266,11 @@ void volume_control_show_hide_worning() if(sound_type == SOUND_TYPE_MEDIA && volume>VOLUME_MAX_SAFETY_VOLUME_LEVEL) { - if(!s_info.is_warning_visible) + if(!control_info.is_warning_visible) { - s_info.is_warning_visible = EINA_TRUE; + control_info.is_warning_visible = EINA_TRUE; - if(s_info.current_angle == 90 || s_info.current_angle == 270) + if(control_info.current_angle == 90 || control_info.current_angle == 270) { elm_object_signal_emit(ly_outer, "show_warning_l", "clipper"); //landscape } @@ -376,14 +279,14 @@ void volume_control_show_hide_worning() elm_object_signal_emit(ly_outer, "show_warning", "clipper"); //landscape } - volume_control_event_shape(EINA_TRUE); + volume_control_shape_event_area(EINA_TRUE); } } - else if(s_info.is_warning_visible) + else if(control_info.is_warning_visible) { - s_info.is_warning_visible = EINA_FALSE; + control_info.is_warning_visible = EINA_FALSE; - if(s_info.current_angle == 90 || s_info.current_angle == 270) + if(control_info.current_angle == 90 || control_info.current_angle == 270) { elm_object_signal_emit(ly_outer, "hide_warning_l", "clipper"); //landscape } @@ -392,45 +295,62 @@ void volume_control_show_hide_worning() elm_object_signal_emit(ly_outer, "hide_warning", "clipper"); //landscape } - volume_control_event_shape(EINA_FALSE); + volume_control_shape_event_area(EINA_FALSE); } } -Eina_Bool volume_control_show(void) +int volume_register_shape_timer() { - int status = -1; - int lock = IDLELOCK_ON; - int lock_state = VCONFKEY_IDLE_UNLOCK; - int pw_type = 0; - bool is_running = false; - int ret = 0; - int sound_step = 0; - static Eina_Bool once = EINA_TRUE; + if (control_info.shape_timer) { + ecore_timer_del(control_info.shape_timer); + control_info.shape_timer = NULL; + } + + control_info.shape_timer = ecore_timer_add(0.1, _shape_cb, NULL); + + if (control_info.shape_timer) + return VOLUME_ERROR_OK; + else + return VOLUME_ERROR_FAIL; +} + +void volume_control_check_syspopup() +{ + if(syspopup_has_popup(control_info.volume_bundle)) { + syspopup_reset(control_info.volume_bundle); + } +} + +void volume_control_check_once(void) +{ + if(control_info.show_once) { + ecore_idler_add(_idler_top_position_grab, NULL); + control_info.show_once = EINA_FALSE; + } +} + +Eina_Bool volume_control_show_view(int status, sound_type_e sound_type, int sound, bool bt_opened) +{ + _D("Volume control show"); Evas_Object *win = NULL; - sound_type_e sound_type = 0; + int volume = 0; + int vibration = 0; + int pre_sound_type = 0; - retv_if(s_info.is_deleting, EINA_FALSE); + retv_if(control_info.is_deleting, EINA_FALSE); - s_info.is_new = EINA_TRUE; + control_info.is_new = EINA_TRUE; win = volume_view_win_get(); retv_if(!win, EINA_FALSE); + pre_sound_type = volume_view_pre_sound_type_get(); - status = volume_control_status_check(&lock, &sound_type); - _D("status : %d", status); - - if(vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock_state) < 0) - { - _E("Failed to get vconfkey : VCONFKEY_IDLE_LOCK_STATE"); - return EINA_FALSE; - } - - if(status == LOCK_AND_NOT_MEDIA || lock_state == VCONFKEY_IDLE_LAUNCHING_LOCK) + if(status == LOCK_AND_NOT_MEDIA) { _D("Lock and Not Media"); if(evas_object_visible_get(win)) { - if(VOLUME_ERROR_OK != volume_control_close()) + if(VOLUME_ERROR_OK != volume_control_hide_view()) { _E("Failed to close volume"); } @@ -441,84 +361,111 @@ Eina_Bool volume_control_show(void) } } return EINA_FALSE; - } - else if(status != LOCK_AND_NOT_MEDIA) - { - if(status == UNLOCK_STATUS) - { - /* Show volume window */ - if(VOLUME_ERROR_OK != volume_view_window_show()) + } else { + _D("UNLOCK or LOCK_AND_MEDIA"); + control_info.sound_type_at_show = sound_type; + + if(sound_type != pre_sound_type) { + if(VOLUME_ERROR_OK != volume_change_slider_max_value(sound_type)) { + _E("Failed to change max volume"); + } + } + + if(status == UNLOCK_STATUS) { + if(VOLUME_ERROR_OK != volume_view_window_show(sound_type)) { _E("Failed to show volume window"); } - /* register outer window event */ - if(VOLUME_ERROR_OK != volume_x_input_event_register()) - { + if(VOLUME_ERROR_OK != volume_x_input_event_register()) { _E("Failed to add x input event handler"); } - if(syspopup_has_popup(s_info.volume_bundle)) - { - syspopup_reset(s_info.volume_bundle); - } + volume_control_check_syspopup(); - if(once) - { - ecore_idler_add(_idler_top_position_grab, NULL); - once = EINA_FALSE; - } + volume_control_check_once(); } - s_info.is_launching = EINA_TRUE; + control_info.is_launching = EINA_TRUE; - int volume = volume_sound_sound_manager_volume_get(sound_type); - _D("volume : %d", volume); + if(bt_opened == 1 && sound_type == SOUND_TYPE_CALL) + { + _D("bt is opened and is calling"); + volume = bt_get_bt_volume(); + _D("bt volume is : %d", volume); - int sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); - _D("sound status : %d", sound); + if(VOLUME_ERROR_OK != volume_view_slider_value_set(volume)) + { + _E("Failed to set volume value to slider"); + } + } + else + { + volume = volume_sound_sound_manager_volume_get(sound_type); + _D("volume : %d", volume); - int vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); - _D("vibration : %d", vibration); + vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); + _D("vibration : %d", vibration); - if(((vibration == 1 && sound == 0) || sound == 0) && sound_type == SOUND_TYPE_RINGTONE) - { - volume = 0; - } + if(((vibration == 1 && sound == 0) || sound == 0) && sound_type == SOUND_TYPE_RINGTONE) + { + volume = 0; + } - if(VOLUME_ERROR_OK != volume_view_slider_value_set(volume)) - { - _E("Failed to set volume value to slider"); + if(VOLUME_ERROR_OK != volume_view_slider_value_set(volume)) + { + _E("Failed to set volume value to slider"); + } } - /* Set Volume icon */ //@TODO: need to check - volume_view_volume_icon_set(sound_type, sound, vibration); + volume_view_volume_icon_set(sound_type, sound, vibration, bt_opened); - if(!s_info.shape_timer) + if(VOLUME_ERROR_OK != volume_register_shape_timer()) { - s_info.shape_timer = ecore_timer_add(0.1, _shape_cb, NULL); - } - else - { - ecore_timer_del(s_info.shape_timer); - s_info.shape_timer = NULL; - - s_info.shape_timer = ecore_timer_add(0.1, _shape_cb, NULL); + _E("Failed to register shape_timer"); } return EINA_TRUE; } +} + +volume_error_e volume_control_close_bt_display(void) +{ + retv_if(volume_control_get_is_deleting(), VOLUME_ERROR_FAIL); + + _D("Start closing bt display"); + + Ecore_X_Window input_win = volume_key_event_input_window_get(); + retv_if(!input_win, VOLUME_ERROR_FAIL); + + control_info.is_deleting = EINA_TRUE; + + /* unregister outer event handler */ + if(VOLUME_ERROR_OK != volume_x_input_event_unregister()) + { + _E("Failed to unregister x input event handler"); + } - return EINA_FALSE; + /* hide window */ + if(VOLUME_ERROR_OK != volume_view_window_hide()) + { + _E("Failed to hide window"); + } + + control_info.is_deleting = EINA_FALSE; + + _D("End closing bt display"); + volume_timer_del(TYPE_TIMER_BT); + + return 0; } -//_close_volume(ad); -volume_error_e volume_control_close(void) +volume_error_e volume_control_hide_view(void) { - retv_if(volume_control_is_deleting_get(), VOLUME_ERROR_FAIL); + retv_if(volume_control_get_is_deleting(), VOLUME_ERROR_FAIL); - _D("Start closing volume"); + _D("Start closing volume view"); int i = 0; int count_grabed = volume_key_event_count_grabed_get(); @@ -526,28 +473,25 @@ volume_error_e volume_control_close(void) Ecore_X_Window input_win = volume_key_event_input_window_get(); retv_if(!input_win, VOLUME_ERROR_FAIL); - s_info.is_deleting = EINA_TRUE; + control_info.is_deleting = EINA_TRUE; /* unregister outer event handler */ if(VOLUME_ERROR_OK != volume_x_input_event_unregister()) { _E("Failed to unregister x input event handler"); -// s_info.is_deleting = EINA_FALSE; +// control_info.is_deleting = EINA_FALSE; // return VOLUME_ERROR_FAIL; } - for(i = 0; i < count_grabed; i++) - { - if(VOLUME_ERROR_OK != volume_key_event_key_ungrab()) - { + for (i = 0; i < count_grabed; i++) { + if (VOLUME_ERROR_OK != volume_key_event_key_ungrab()) { _E("Failed to ungrab key"); continue; } _D("ungrab key : %d/%d", i+1, count_grabed); } volume_key_event_count_grabed_set(0); - if(VOLUME_ERROR_OK != volume_key_event_key_grab(input_win, SHARED_GRAB)) - { + if (VOLUME_ERROR_OK != volume_key_event_key_grab(input_win, SHARED_GRAB)) { _E("Failed to grab key : SHARED_GRAB"); } @@ -557,101 +501,19 @@ volume_error_e volume_control_close(void) volume_timer_del(TYPE_TIMER_POPUP); /* hide window */ - if(VOLUME_ERROR_OK != volume_view_window_hide()) - { + if (VOLUME_ERROR_OK != volume_view_window_hide()) { _E("Failed to hide window"); } - s_info.is_deleting = EINA_FALSE; - s_info.is_launching = EINA_FALSE; + control_info.is_deleting = EINA_FALSE; + control_info.is_launching = EINA_FALSE; - _D("End closing volume"); + _D("End closing volume view"); return 0; } -static void _starter_user_volume_key_vconf_changed_cb(keynode_t *key, void *data) -{ - int ret = EINA_FALSE; - - if(vconf_get_int(VCONFKEY_STARTER_USE_VOLUME_KEY, &ret) < 0) - { - _E("Failed to get vconfkey : VCONFKEY_STARTER_USE_VOLUME_KEY"); - return; - } - _D("ret : %d", ret); - - if(ret == 1) - { - _D("any other App grab volume hard key"); - if(VOLUME_ERROR_OK != volume_control_close()) { - _E("Failed to close volume"); - return; - } - if(VOLUME_ERROR_OK != volume_control_cache_flush()) { - _E("Failed to flush cache"); - return; - } - if(vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 0) < 0) { - _E("Failed to get vconfkey : VCONFKEY_STATER_USE_VOLUME_KEY"); - return; - } - } - else if(ret == 2) - { - _D("setting App grab volume hard key"); -// _close_volume(ad); -// _cache_flush(ad); - } -} - -static void _idle_lock_state_vconf_changed_cb(keynode_t *key, void *data) -{ - int lock = VCONFKEY_IDLE_UNLOCK; - - if(vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock) < 0) - { - _E("Failed to get vconfkey : VCONFKEY_IDLE_LOCK_STATE"); - return; - } - _D("idle lock state : %d", lock); - - if(lock == VCONFKEY_IDLE_LAUNCHING_LOCK) - { - const char *splash_path = vconf_get_str(VCONFKEY_IDLE_LOCK_BGSET); - - if (splash_path) - { -// show_lockscreen_splash(splash_path); - } else { - _E("No background found"); - } - - if(VOLUME_ERROR_OK != volume_view_window_hide()) - { - _E("Failed to hide window"); - } - } - else if(lock == VCONFKEY_IDLE_UNLOCK) - { -// hide_lockscreen_splash(); - } -} - -static void _notify_pm_lcdoff_cb(keynode_t * node, void *data) -{ - if(VOLUME_ERROR_OK != volume_control_close()) - { - _E("Failed to close volume"); - } - - if(VOLUME_ERROR_OK != volume_control_cache_flush()) - { - _E("Failed to flush cache"); - } -} - -void volume_control_vconfkey_register(void) +void volume_control_register_vconfkey(void) { /* other app grab volume key => close volume */ if(vconf_notify_key_changed(VCONFKEY_STARTER_USE_VOLUME_KEY, _starter_user_volume_key_vconf_changed_cb, NULL) != 0) @@ -670,7 +532,7 @@ void volume_control_vconfkey_register(void) } } -void volume_control_vconfkey_unregister(void) +void volume_control_unregister_vconfkey(void) { /* other app grab volume key => close volume */ if(vconf_ignore_key_changed(VCONFKEY_STARTER_USE_VOLUME_KEY, _starter_user_volume_key_vconf_changed_cb) < 0) @@ -690,14 +552,13 @@ void volume_control_vconfkey_unregister(void) } } -//int _app_pause(struct appdata *ad) volume_error_e volume_control_pause(void) { Evas_Object *win = volume_view_win_get(); retv_if(!win, VOLUME_ERROR_FAIL); if(evas_object_visible_get(win)) { - if(VOLUME_ERROR_OK != volume_control_close()) + if(VOLUME_ERROR_OK != volume_control_hide_view()) { _E("Failed to close volume"); } @@ -711,25 +572,6 @@ volume_error_e volume_control_pause(void) return VOLUME_ERROR_OK; } -int myterm(bundle *b, void *data) -{ - if(VOLUME_ERROR_OK != volume_control_close()) - { - _E("Failed to close volume"); - } - if(VOLUME_ERROR_OK != volume_control_cache_flush()) - { - _E("Failed to flush cache"); - } - - return 0; -} - -int mytimeout(bundle *b, void *data) -{ - return 0; -} - volume_error_e volume_control_reset(bundle *b) { _D("Volume control reset"); @@ -738,23 +580,43 @@ volume_error_e volume_control_reset(bundle *b) int ret = -1; int lock = IDLELOCK_ON; + int status = 0; + int volume = 0; + int sound = 0; + int error = 0; + bool bt_opened = false; + sound_type_e sound_type = 0; + const char *show_volume = NULL; + + if(control_info.reset_once) { + static syspopup_handler handler = { + .def_term_fn = _myterm, + .def_timeout_fn = _mytimeout + }; - static int once = EINA_TRUE; - if(once) - { ret = syspopup_create(b, &handler, win, NULL); retvm_if(ret < 0, VOLUME_ERROR_FAIL, "Failed to create syspopup"); - s_info.volume_bundle = bundle_dup(b); - once = EINA_FALSE; + control_info.volume_bundle = bundle_dup(b); + control_info.reset_once = EINA_FALSE; } - sound_type_e sound_type = volume_sound_sound_manager_type_get(); - _D("sound type : %d", sound_type); + status = volume_control_check_status(&lock, &sound_type); + _D("status: %d, lock: %d, sound type : %d", status, lock, sound_type); - int volume = volume_sound_sound_manager_volume_get(sound_type); + volume = volume_sound_sound_manager_volume_get(sound_type); _D("volume : %d", volume); - const char *show_volume = bundle_get_val(b, SHOWVOLUME); + sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); + _D("sound status : %d", sound); + + error = bt_ag_is_sco_opened(&bt_opened); + if(error != BT_ERROR_NONE) + { + _E("bt_ag_is_sco_opened return [%d]", error); + } + _D("BT state %d", bt_opened); + + show_volume = bundle_get_val(b, SHOWVOLUME); retv_if(!show_volume, VOLUME_ERROR_FAIL); if(!strncasecmp(show_volume, ISTRUE, strlen(ISTRUE))) @@ -764,7 +626,7 @@ volume_error_e volume_control_reset(bundle *b) { _D("Show Volume"); volume_timer_add(3.0, TYPE_TIMER_POPUP); - volume_control_show(); + volume_control_show_view(status, sound_type, sound, bt_opened); } } @@ -774,10 +636,6 @@ volume_error_e volume_control_reset(bundle *b) volume_error_e volume_control_initialize(void) { _D("Volume control initialize"); -#if TBD - /* Use GL */ - elm_config_preferred_engine_set("opengl_x11"); -#endif /* Create main window */ Evas_Object *win = volume_view_window_create(); @@ -795,18 +653,18 @@ volume_error_e volume_control_initialize(void) return VOLUME_ERROR_FAIL; } - ecore_x_window_size_get(ecore_x_window_root_first_get(), &(s_info.viewport_width), &(s_info.viewport_height)); + elm_win_screen_size_get(win, NULL, NULL, &(control_info.viewport_width), &(control_info.viewport_height)); /* Set available rotations */ - _control_window_rotation_set(win); + _control_set_window_rotation(win); /* Register vconfkey changed callback * : VCONFKEY_STARTER_USE_VOLUME_KEY * : VCONFKEY_IDLE_LOCK_STATE * : VCONFKEY_LOCKSCREEN_SVIEW_STATE * */ - volume_control_vconfkey_register(); + volume_control_register_vconfkey(); /* Register vconfkey changed callback * : VCONFKEY_SETAPPL_SOUND_STATUS_BOOL @@ -817,14 +675,11 @@ volume_error_e volume_control_initialize(void) /* Add key event handler */ volume_key_event_handler_add(); - /* Add quick panel event handler */ - _control_qp_state_handler_add(); - /* Register volume changed callback */ volume_sound_mm_sound_init(); - /* theme */ - ea_theme_changeable_ui_enabled_set(EINA_TRUE); + /* BT initialize and register changed callback */ + bt_init_sco(); return VOLUME_ERROR_OK; } @@ -832,16 +687,166 @@ volume_error_e volume_control_initialize(void) void volume_control_deinitialize(void) { /* Unregister vconfkey changed callback */ - volume_control_vconfkey_unregister(); + volume_control_unregister_vconfkey(); /* Unregister sound vconfkey changed callback */ volume_sound_vconfkey_unregister(); + + /* Unregister bt changed callback */ + bt_deinit_sco(); +} + +static void _rotate_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + static int current_angle = -1; + int changed_angle = elm_win_rotation_get(obj); + LOGD("MIK"); + + Evas_Object *ly_outer = volume_view_outer_layout_get(); + ret_if(!ly_outer); + + _D("window rotated [%d] => [%d]", current_angle, changed_angle); + if(current_angle != changed_angle) { + current_angle = changed_angle; + control_info.current_angle = current_angle; + switch(current_angle){ + case 90 : + case 270 : + _D("show,landscape"); + elm_object_signal_emit(ly_outer, "show,landscape", "bg"); + if(control_info.is_warning_visible) + { + elm_object_signal_emit(ly_outer, "show_warning_l", "clipper"); + } + break; + default : + _D("show,portrait"); + elm_object_signal_emit(ly_outer, "show,portrait", "bg"); + if(control_info.is_warning_visible) + { + elm_object_signal_emit(ly_outer, "show_warning", "clipper"); + } + break; + } + + volume_x_input_event_shape(obj, control_info.is_warning_visible); + } +} + +static void _control_set_window_rotation(Evas_Object *win) +{ + ret_if(!win); + + if (elm_win_wm_rotation_supported_get(win)) { + const int rots[4] = { 0, 90, 180, 270 }; + elm_win_wm_rotation_available_rotations_set(win, (const int *)&rots, 4); + _D("set available rotations"); + } + + /* rotation event callback */ + evas_object_smart_callback_add(win, "wm,rotation,changed", _rotate_changed_cb, NULL); + + /* initialize degree */ + _rotate_changed_cb(NULL, win, NULL); +} + +static Eina_Bool _idler_top_position_grab(void *data) +{ + volume_key_event_key_grab(-1, TOP_POSITION_GRAB); + + return ECORE_CALLBACK_CANCEL; } static Eina_Bool _shape_cb(void *data) { - LOGD("Mik"); - volume_control_event_shape(s_info.is_warning_visible); - s_info.shape_timer = NULL; + LOGD("shape callback"); + volume_control_shape_event_area(control_info.is_warning_visible); + control_info.shape_timer = NULL; return ECORE_CALLBACK_CANCEL; } + +static void _starter_user_volume_key_vconf_changed_cb(keynode_t *key, void *data) +{ + int ret = EINA_FALSE; + + if(vconf_get_int(VCONFKEY_STARTER_USE_VOLUME_KEY, &ret) < 0) + { + _E("Failed to get vconfkey : VCONFKEY_STARTER_USE_VOLUME_KEY"); + return; + } + _D("ret : %d", ret); + + if(ret == 1) + { + _D("any other App grab volume hard key"); + if(VOLUME_ERROR_OK != volume_control_hide_view()) { + _E("Failed to close volume"); + return; + } + if(VOLUME_ERROR_OK != volume_control_cache_flush()) { + _E("Failed to flush cache"); + return; + } + if(vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 0) < 0) { + _E("Failed to get vconfkey : VCONFKEY_STATER_USE_VOLUME_KEY"); + return; + } + } + else if(ret == 2) + { + _D("setting App grab volume hard key"); + } +} + +static void _idle_lock_state_vconf_changed_cb(keynode_t *key, void *data) +{ + int lock = VCONFKEY_IDLE_UNLOCK; + + if(vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock) < 0) + { + _E("Failed to get vconfkey : VCONFKEY_IDLE_LOCK_STATE"); + return; + } + _D("idle lock state : %d", lock); + + if(lock == VCONFKEY_IDLE_LAUNCHING_LOCK) + { + if(VOLUME_ERROR_OK != volume_view_window_hide()) + { + _E("Failed to hide window"); + } + } +} + +static void _notify_pm_lcdoff_cb(keynode_t * node, void *data) +{ + if(VOLUME_ERROR_OK != volume_control_hide_view()) + { + _E("Failed to close volume"); + } + + if(VOLUME_ERROR_OK != volume_control_cache_flush()) + { + _E("Failed to flush cache"); + } +} + +static int _mytimeout(bundle *b, void *data) +{ + return 0; +} + +static int _myterm(bundle *b, void *data) +{ + if (VOLUME_ERROR_OK != volume_control_hide_view()) + { + _E("Failed to close volume"); + } + if (VOLUME_ERROR_OK != volume_control_cache_flush()) + { + _E("Failed to flush cache"); + } + + return 0; +} + diff --git a/src/key_event.c b/src/key_event.c index 7955eca..653ce5f 100755 --- a/src/key_event.c +++ b/src/key_event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include "main.h" #include "_util_log.h" @@ -27,11 +30,13 @@ #include "control.h" #include "sound.h" #include "timer.h" +#include "key_event.h" +#include "bt.h" #define VCONFKEY_ALARM_VOLUME_POPUP_ENABLE "memory/alarm/volume_popup_enable" #define VOLUME_INPUT_WIN_NAME "volumekey-input-window" -static struct _s_info { +struct _key_event_s_info { Ecore_X_Window input_win; Ecore_Event_Handler *handler_volume_up; @@ -44,7 +49,9 @@ static struct _s_info { int count_grabed; int last_value_in_media; -} s_info = { +}; + +static struct _key_event_s_info key_event_info = { .input_win = 0, .handler_volume_up = NULL, @@ -59,6 +66,13 @@ static struct _s_info { .last_value_in_media = 0, }; +static Eina_Bool _key_release_cb(void *data, int type, void *event); +static Eina_Bool _key_press_cb(void *data, int type, void *event); +static volume_error_e _volume_popup_check_in_alarm_type(sound_type_e sound_type); +static volume_error_e _volume_down_key_press(sound_type_e sound_type, int sound, bool bt_opened); +static volume_error_e _volume_up_key_press(sound_type_e sound_type, int sound, bool bt_opened); +static volume_error_e _mute_key_press(); + Ecore_X_Window _add_input_window(void) { Ecore_X_Window win = 0; @@ -75,41 +89,39 @@ Ecore_X_Window _add_input_window(void) Ecore_X_Window volume_key_event_input_window_get(void) { - return s_info.input_win; + return key_event_info.input_win; } Ecore_Event_Handler* volume_key_event_handler_volume_up_get(void) { - return s_info.handler_volume_up; + return key_event_info.handler_volume_up; } Ecore_Event_Handler* volume_key_event_handler_volume_down_get(void) { - return s_info.handler_volume_down; + return key_event_info.handler_volume_down; } Ecore_Event_Handler* volume_key_event_handler_qp_state_check(void) { - return s_info.handler_qp_state_check; + return key_event_info.handler_qp_state_check; } Eina_Bool volume_key_event_is_pressing_get(void) { - return s_info.is_pressing; + return key_event_info.is_pressing; } int volume_key_event_count_grabed_get(void) { - return s_info.count_grabed; + return key_event_info.count_grabed; } void volume_key_event_count_grabed_set(int val) { - s_info.count_grabed = val; + key_event_info.count_grabed = val; } -//int _grab_key_new -//volume_error_e volume_key_event_key_grab(Ecore_X_Window _xwin, int grab_mode) volume_error_e volume_key_event_key_grab(Ecore_X_Window _xwin, int grab_mode) { Evas_Object *win = volume_view_win_get(); @@ -119,20 +131,19 @@ volume_error_e volume_key_event_key_grab(Ecore_X_Window _xwin, int grab_mode) Ecore_X_Window xwin = 0; int ret = -1; - s_info.count_grabed++; - _D("count_grabed : %d", s_info.count_grabed); + key_event_info.count_grabed++; + _D("count_grabed : %d", key_event_info.count_grabed); disp = ecore_x_display_get(); retvm_if(disp == NULL, VOLUME_ERROR_FAIL, "Failed to get display"); /* Check TOP_POSITION_GRAB */ - if(_xwin == -1) { + if (_xwin == -1) { _D("Top position grab"); xwin = elm_win_xwindow_get(win); retvm_if(xwin == 0, VOLUME_ERROR_FAIL, "Failed to get xwindow"); - } else { + } else xwin = _xwin; - } ret = utilx_grab_key(disp, xwin, KEY_VOLUMEDOWN, grab_mode); retvm_if(ret < 0, VOLUME_ERROR_FAIL, "Failed to grab key down"); @@ -176,82 +187,128 @@ volume_error_e volume_key_event_key_ungrab(void) return VOLUME_ERROR_OK; } +void volume_key_event_handler_add(void) +{ + if(!key_event_info.handler_volume_up) + key_event_info.handler_volume_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, NULL); + + if(!key_event_info.handler_volume_down) + key_event_info.handler_volume_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL); +} + +void volume_key_event_handler_del(void) +{ + ret_if(key_event_info.handler_volume_up == NULL); + ecore_event_handler_del(key_event_info.handler_volume_up); + key_event_info.handler_volume_up= NULL; + + ret_if(key_event_info.handler_volume_down == NULL); + ecore_event_handler_del(key_event_info.handler_volume_down); + key_event_info.handler_volume_down = NULL; +} + +volume_error_e volume_key_event_input_window_create(void) +{ + Ecore_X_Window input_win = _add_input_window(); + retv_if(!input_win, VOLUME_ERROR_FAIL); + + key_event_info.input_win = input_win; + + return volume_key_event_key_grab(input_win, SHARED_GRAB); +} + static volume_error_e _mute_key_press() { int lastval = -1; + int lock = IDLELOCK_ON; + int status = 0; + int sound = 0; + int error = 0; + bool bt_opened = false; + sound_type_e sound_type = 0; + + status = volume_control_check_status(&lock, &sound_type); + _D("status: %d, lock: %d, sound type : %d", status, lock, sound_type); - volume_control_show(); + sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); + _D("sound status : %d", sound); - sound_type_e sound_type = volume_control_sound_type_at_show_get(); - _D("sound type at show : %d", sound_type); + error = bt_ag_is_sco_opened(&bt_opened); + if(error != BT_ERROR_NONE) + _E("bt_ag_is_sco_opened return [%d]", error); - if(sound_type == SOUND_TYPE_MEDIA){ - if(s_info.is_mute == EINA_FALSE){ + _D("BT state %d", bt_opened); + + volume_control_show_view(status, sound_type, sound, bt_opened); + + if (sound_type == SOUND_TYPE_MEDIA) { + if (key_event_info.is_mute == EINA_FALSE) { _D("media is playing. set media volume to 0."); lastval = volume_sound_level_get(sound_type); retv_if(lastval == -1, VOLUME_ERROR_FAIL); - s_info.last_value_in_media = lastval; + key_event_info.last_value_in_media = lastval; volume_sound_level_set(sound_type, 0); - if(VOLUME_ERROR_OK != volume_view_slider_value_set(0)) { + if (VOLUME_ERROR_OK != volume_view_slider_value_set(0)) { _E("Failed to set slider value"); return VOLUME_ERROR_FAIL; } - s_info.is_mute = EINA_TRUE; + key_event_info.is_mute = EINA_TRUE; return VOLUME_ERROR_OK; } else { - _D("toggle the mute key to normal in media. last value in media : %d", s_info.last_value_in_media); + _D("toggle the mute key to normal in media. last value in media : %d", key_event_info.last_value_in_media); volume_sound_level_set(sound_type, lastval); - if(VOLUME_ERROR_OK != volume_view_slider_value_set(lastval)) { + if (VOLUME_ERROR_OK != volume_view_slider_value_set(lastval)) { _E("Failed to set slider value"); return VOLUME_ERROR_FAIL; } - s_info.is_mute = EINA_FALSE; + key_event_info.is_mute = EINA_FALSE; return VOLUME_ERROR_OK; } } else { - int lock = volume_control_vconf_idlelock_get(); - if(lock == IDLELOCK_ON){ + if (lock == IDLELOCK_ON) { _D("lock is on, block the MUTE key"); return VOLUME_ERROR_OK; } - if (volume_mute_toggle_set()) { + if (volume_mute_toggle_set()) volume_sound_feedback_play(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_GENERAL); - } return VOLUME_ERROR_OK; } } -static volume_error_e _volume_up_key_press(sound_type_e sound_type, int sound) +static volume_error_e _volume_up_key_press(sound_type_e sound_type, int sound, bool bt_opened) { + int sound_step = 0; + int sound_level = 0; + int vibration = 0; + _D("Volume Up Key Pressed"); - s_info.is_mute = EINA_FALSE; + key_event_info.is_mute = EINA_FALSE; - int sound_step = volume_sound_step_get(); + sound_step = volume_sound_step_get(); _D("sound step : %d", sound_step); - int sound_level = volume_sound_level_get(sound_type); + sound_level = volume_sound_level_get(sound_type); retv_if(sound_level == -1, VOLUME_ERROR_FAIL); _D("sound level : %d", sound_level); - int vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); + vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); _D("vibration : %d", vibration); - if(elm_object_disabled_get(volume_view_slider_get())){ + if (elm_object_disabled_get(volume_view_slider_get())) elm_object_disabled_set(volume_view_slider_get(), EINA_FALSE); - } - if(sound_type == SOUND_TYPE_RINGTONE){ - if(!sound){ + if (sound_type == SOUND_TYPE_RINGTONE) { + if (!sound) { /* Check sound status change case. */ - if(!vibration){ + if (!vibration) { _D("mute -> vib."); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 1); volume_sound_vib_play(); } - else{ + else { _D("vib -> sound"); volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 1); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0); @@ -260,24 +317,24 @@ static volume_error_e _volume_up_key_press(sound_type_e sound_type, int sound) _D("new sound value: %d", sound_level+1); } } - else{ + else { /*adjust the sound level normally */ - if(sound_level != sound_step){ + if (sound_level != sound_step) { volume_sound_level_set(sound_type, sound_level+1); volume_view_slider_value_set(sound_level+1); _D("new sound value: %d", sound_level+1); } } } - else if(sound_type == SOUND_TYPE_NOTIFICATION){ - if(!sound){ + else if (sound_type == SOUND_TYPE_NOTIFICATION) { + if (!sound) { /* No sound in notification type. */ volume_view_slider_value_set(0); elm_object_disabled_set(volume_view_slider_get(), EINA_TRUE); } - else{ + else { /*adjust the sound level normally */ - if(sound_level != sound_step){ + if (sound_level != sound_step) { volume_sound_level_set(sound_type, sound_level+1); volume_view_slider_value_set(sound_level+1); _D("new sound value: %d", sound_level+1); @@ -285,25 +342,36 @@ static volume_error_e _volume_up_key_press(sound_type_e sound_type, int sound) } } /* Sound type is not ringtone. Need to adjust sound level */ - else{ - if(sound_level != sound_step){ + else if (sound_type == SOUND_TYPE_CALL && bt_opened) { + int bt_vol = 0; + if (bt_ag_get_speaker_gain(&bt_vol) != BT_ERROR_NONE) + _E("Getting bt volume is failed"); + + _D("BT VOLUME : %d", bt_vol); + + if (bt_vol != sound_step) { + if(bt_ag_notify_speaker_gain(bt_vol+1) != BT_ERROR_NONE) + _E("Setting bt volume is failed"); + volume_view_slider_value_set(bt_vol+1); + _D("New BT VOLUME : %d", bt_vol+1); + } + } + else { + if (sound_level != sound_step) { volume_sound_level_set(sound_type, sound_level+1); volume_view_slider_value_set(sound_level+1); _D("new sound value: %d", sound_level+1); } } - if(sound_type != SOUND_TYPE_ALARM) - { + if (sound_type != SOUND_TYPE_ALARM) volume_sound_play(); - } volume_timer_del(TYPE_TIMER_SU); volume_timer_del(TYPE_TIMER_SD); volume_timer_add(0.5, TYPE_TIMER_SU); - if(!volume_timer_su_timer_get()) - { + if (!volume_timer_su_timer_get()) { _E("Failed to get SUTIMER"); return VOLUME_ERROR_FAIL; } @@ -311,9 +379,9 @@ static volume_error_e _volume_up_key_press(sound_type_e sound_type, int sound) return VOLUME_ERROR_OK; } -static volume_error_e _volume_down_key_press(sound_type_e sound_type, int sound) +static volume_error_e _volume_down_key_press(sound_type_e sound_type, int sound, bool bt_opened) { - s_info.is_mute = EINA_FALSE; + key_event_info.is_mute = EINA_FALSE; int val = volume_sound_level_get(sound_type); retv_if(val == -1, VOLUME_ERROR_FAIL); @@ -324,21 +392,19 @@ static volume_error_e _volume_down_key_press(sound_type_e sound_type, int sound) int vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); _D("vibration : %d", vibration); - if(elm_object_disabled_get(volume_view_slider_get())){ + if (elm_object_disabled_get(volume_view_slider_get())) elm_object_disabled_set(volume_view_slider_get(), EINA_FALSE); - } if(sound_type == SOUND_TYPE_RINGTONE){ - if(!sound){ + if (!sound) /* Check sound status change case. */ _D("Do nothing."); - } - else{ - if(val != 0){ + else { + if (val != 0) { volume_sound_level_set(sound_type, val - 1); volume_view_slider_value_set(val - 1); /*adjust the sound level normally */ - if(val == 1){ + if (val == 1) { volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 0); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 1); volume_sound_vib_play(); @@ -346,24 +412,36 @@ static volume_error_e _volume_down_key_press(sound_type_e sound_type, int sound) } } } - else if(sound_type == SOUND_TYPE_NOTIFICATION){ - if(!sound){ + else if (sound_type == SOUND_TYPE_NOTIFICATION) { + if(!sound) { /* No sound in notification type. */ volume_view_slider_value_set(0); elm_object_disabled_set(volume_view_slider_get(), EINA_TRUE); } - else{ + else { /*adjust the sound level normally */ - if(val != 0){ + if (val != 0) { volume_sound_level_set(sound_type, val-1); volume_view_slider_value_set(val-1); _D("new sound value: %d", val-1); } } } + else if(sound_type == SOUND_TYPE_CALL && bt_opened) { + int bt_vol = 0; + if(bt_ag_get_speaker_gain(&bt_vol) != BT_ERROR_NONE) + _E("Getting bt volume is failed"); + + _D("BT VOLUME : %d", bt_vol); + if(bt_ag_notify_speaker_gain(bt_vol-1) != BT_ERROR_NONE) + _E("Setting bt volume is failed"); + volume_view_slider_value_set(bt_vol-1); + + _D("New BT VOLUME : %d", bt_vol-1); + } /* Sound type is not ringtone. Need to adjust sound level */ - else{ - if(val != 0){ + else { + if (val != 0) { volume_sound_level_set(sound_type, val - 1); volume_view_slider_value_set(val - 1); _D("new sound value: %d", val-1); @@ -371,9 +449,7 @@ static volume_error_e _volume_down_key_press(sound_type_e sound_type, int sound) } if(sound_type != SOUND_TYPE_ALARM) - { volume_sound_play(); - } volume_timer_del(TYPE_TIMER_SD); volume_timer_del(TYPE_TIMER_SU); @@ -386,18 +462,15 @@ static volume_error_e _volume_popup_check_in_alarm_type(sound_type_e sound_type) { int is_enabled = 0; - if(sound_type == SOUND_TYPE_ALARM) - { + if(sound_type == SOUND_TYPE_ALARM) { _D("Sound type is Alarm Type"); - if(vconf_get_bool(VCONFKEY_ALARM_VOLUME_POPUP_ENABLE, &is_enabled) < 0) - { + if(vconf_get_bool(VCONFKEY_ALARM_VOLUME_POPUP_ENABLE, &is_enabled) < 0) { _E("Failed to get vconfkey : VCONFKEY_ALARM_VOLUME_POPUP_ENABLE"); return VOLUME_ERROR_FAIL; } _D("volume popup enabled in alarm type : %d", is_enabled); - if(!is_enabled) - { + if(!is_enabled) { _D("alarm type but vconf for the volume popup is disabled"); return VOLUME_ERROR_FAIL; } @@ -412,6 +485,8 @@ static Eina_Bool _key_press_cb(void *data, int type, void *event) int lock = IDLELOCK_ON; int key_status = 0; int status = 0; + int error = 0; + bool bt_opened = false; sound_type_e sound_type = 0; Evas_Object *win = NULL; Ecore_Event_Key *ev = NULL; @@ -424,20 +499,17 @@ static Eina_Bool _key_press_cb(void *data, int type, void *event) win = volume_view_win_get(); retv_if(!win, ECORE_CALLBACK_CANCEL); - if(!strncmp(ev->keyname, KEY_CANCEL, strlen(KEY_CANCEL)) || !strncmp(ev->keyname, KEY_BACK, strlen(KEY_BACK))) - { + if(!strncmp(ev->keyname, KEY_CANCEL, strlen(KEY_CANCEL)) || !strncmp(ev->keyname, KEY_BACK, strlen(KEY_BACK))) { _D("%s is pressed", ev->keyname); return ECORE_CALLBACK_CANCEL; } - if(volume_view_is_slider_touching_get()) - { + if(volume_view_is_slider_touching_get()) { _E("Failed to show volume : is_slider_touching is EINA_TRUE"); return ECORE_CALLBACK_CANCEL; } - if(vconf_get_int(VCONFKEY_STARTER_USE_VOLUME_KEY, &key_status) < 0) - { + if(vconf_get_int(VCONFKEY_STARTER_USE_VOLUME_KEY, &key_status) < 0) { _E("Failed to get vconf : VCONFKEY_STATER_USE_VOLUME_KEY"); return ECORE_CALLBACK_CANCEL; } @@ -445,59 +517,53 @@ static Eina_Bool _key_press_cb(void *data, int type, void *event) #ifndef FEATURE_SDK int is_call = -1; - if(!strncmp(ev->keyname, KEY_MUTE, strlen(KEY_MUTE))) - { + if(!strncmp(ev->keyname, KEY_MUTE, strlen(KEY_MUTE))) { _D("MUTE key is pressed"); if(VOLUME_ERROR_OK != _mute_key_press()) - { _E("Failed to press MUTE key"); - } return ECORE_CALLBACK_CANCEL; } - if(vconf_get_int(VCONFKEY_TELEPHONY_CALL_STATE, &is_call) < 0 || is_call < 0) - { + if(vconf_get_int(VCONFKEY_TELEPHONY_CALL_STATE, &is_call) < 0 || is_call < 0) { _E("Failed to get call state vconf"); return ECORE_CALLBACK_CANCEL; } - if(is_call>0) - { + if(is_call>0) { _D("Call is active"); return ECORE_CALLBACK_CANCEL; } #endif - status = volume_control_status_check(&lock, &sound_type); + status = volume_control_check_status(&lock, &sound_type); _D("status: %d, lock: %d, sound type : %d", status, lock, sound_type); - if(VOLUME_ERROR_OK != _volume_popup_check_in_alarm_type(sound_type)) - { + sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); + _D("sound status : %d", sound); + + error = bt_ag_is_sco_opened(&bt_opened); + if(error != BT_ERROR_NONE) + _E("bt_ag_is_sco_opened return [%d]", error); + + _D("BT state %d", bt_opened); + + if(VOLUME_ERROR_OK != _volume_popup_check_in_alarm_type(sound_type)) { _E("Failed to set volume popup"); return ECORE_CALLBACK_CANCEL; } - volume_control_show(); + volume_control_show_view(status, sound_type, sound, bt_opened); - s_info.is_pressing = EINA_TRUE; + key_event_info.is_pressing = EINA_TRUE; volume_timer_del(TYPE_TIMER_POPUP); - sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); - _D("sound status : %d", sound); - - if (!strncmp(ev->keyname, KEY_VOLUMEUP, strlen(KEY_VOLUMEUP))) - { - if(VOLUME_ERROR_OK != _volume_up_key_press(sound_type, sound)) - { + if (!strncmp(ev->keyname, KEY_VOLUMEUP, strlen(KEY_VOLUMEUP))) { + if(VOLUME_ERROR_OK != _volume_up_key_press(sound_type, sound, bt_opened)) _E("Failed to press volume up key"); - } } - else if (!strncmp(ev->keyname, KEY_VOLUMEDOWN, strlen(KEY_VOLUMEDOWN))) - { - if(VOLUME_ERROR_OK != _volume_down_key_press(sound_type, sound)) - { + else if (!strncmp(ev->keyname, KEY_VOLUMEDOWN, strlen(KEY_VOLUMEDOWN))) { + if(VOLUME_ERROR_OK != _volume_down_key_press(sound_type, sound, bt_opened)) _E("Failed to press volume down key"); - } } return ECORE_CALLBACK_CANCEL; @@ -512,35 +578,27 @@ static Eina_Bool _key_release_cb(void *data, int type, void *event) Evas_Object *win = volume_view_win_get(); retv_if(win == NULL, ECORE_CALLBACK_CANCEL); - s_info.is_pressing = EINA_FALSE; + key_event_info.is_pressing = EINA_FALSE; - if(!strncmp(ev->keyname, KEY_CANCEL, strlen(KEY_CANCEL))) - { + if(!strncmp(ev->keyname, KEY_CANCEL, strlen(KEY_CANCEL))) { _D("%s is released", ev->keyname); - if(VOLUME_ERROR_OK != volume_control_close()) - { + if(VOLUME_ERROR_OK != volume_control_hide_view()) _E("Failed to close volume"); - } if(VOLUME_ERROR_OK != volume_control_cache_flush()) - { _E("Failed to flush cache"); - } return ECORE_CALLBACK_CANCEL; } - if(!strncmp(ev->keyname, KEY_BACK, strlen(KEY_BACK))) - { + if(!strncmp(ev->keyname, KEY_BACK, strlen(KEY_BACK))) { _D("BACK Key is released"); return ECORE_CALLBACK_CANCEL; } - if (!strncmp(ev->keyname, KEY_VOLUMEUP, strlen(KEY_VOLUMEUP))) - { + if (!strncmp(ev->keyname, KEY_VOLUMEUP, strlen(KEY_VOLUMEUP))) { _D("up key released and del timer"); volume_timer_del(TYPE_TIMER_SU); } - else if (!strncmp(ev->keyname, KEY_VOLUMEDOWN, strlen(KEY_VOLUMEDOWN))) - { + else if (!strncmp(ev->keyname, KEY_VOLUMEDOWN, strlen(KEY_VOLUMEDOWN))) { _D("down key released and del timer"); volume_timer_del(TYPE_TIMER_SD); } @@ -548,44 +606,9 @@ static Eina_Bool _key_release_cb(void *data, int type, void *event) volume_timer_del(TYPE_TIMER_POPUP); if(volume_view_is_slider_touching_get() == EINA_FALSE) - { volume_timer_add(3.0, TYPE_TIMER_POPUP); - } _D("key release fini"); return ECORE_CALLBACK_CANCEL; } -void volume_key_event_handler_add(void) -{ - if(!s_info.handler_volume_up) - { - s_info.handler_volume_up = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _key_release_cb, NULL); - } - - if(!s_info.handler_volume_down) - { - s_info.handler_volume_down = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _key_press_cb, NULL); - } -} - -void volume_key_event_handler_del(void) -{ - ret_if(s_info.handler_volume_up == NULL); - ecore_event_handler_del(s_info.handler_volume_up); - s_info.handler_volume_up= NULL; - - ret_if(s_info.handler_volume_down == NULL); - ecore_event_handler_del(s_info.handler_volume_down); - s_info.handler_volume_down = NULL; -} - -volume_error_e volume_key_event_input_window_create(void) -{ - Ecore_X_Window input_win = _add_input_window(); - retv_if(!input_win, VOLUME_ERROR_FAIL); - - s_info.input_win = input_win; - - return volume_key_event_key_grab(input_win, SHARED_GRAB); -} diff --git a/src/main.c b/src/main.c index 4bf402f..fdd3dcb 100755 --- a/src/main.c +++ b/src/main.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ #include #include +#include #include "main.h" #include "_util_log.h" @@ -23,15 +24,47 @@ #include "view.h" #include "control.h" -static bool app_create(void *user_data) +static bool _create_app(void *user_data); +static void _terminate_app(void *user_data); +static void _pause_app(void *user_data); +static void _resume_app(void *user_data); +static void _control_app(app_control_h service, void *user_data); +static void _changed_language(app_event_info_h event_info, void *user_data); + +int main(int argc, char *argv[]) +{ + int ret = 0; + + ui_app_lifecycle_callback_s lifecycle_callback = {0,}; + app_event_handler_h handlers[5] = {NULL, }; + + lifecycle_callback.create = _create_app; + lifecycle_callback.terminate = _terminate_app; + lifecycle_callback.pause = _pause_app; + lifecycle_callback.resume = _resume_app; + lifecycle_callback.app_control = _control_app; + + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL); + ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL); + ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL); + ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, _changed_language, NULL); + ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL); + + ret = ui_app_main(argc, argv, &lifecycle_callback, NULL); + if (ret != APP_ERROR_NONE) + _E("app_main() is failed. err = %d", ret); + + return ret; +} + +static bool _create_app(void *user_data) { elm_app_base_scale_set(1.8); /* Initialize feedback */ feedback_initialize(); /* Initialize volume */ - if(VOLUME_ERROR_OK != volume_control_initialize()) - { + if (VOLUME_ERROR_OK != volume_control_initialize()) { _E("Failed to initialize volume"); return false; } @@ -39,7 +72,7 @@ static bool app_create(void *user_data) return true; } -static void app_terminate(void *user_data) +static void _terminate_app(void *user_data) { /* Deinitialize feedback */ feedback_deinitialize(); @@ -48,67 +81,37 @@ static void app_terminate(void *user_data) volume_control_deinitialize(); } -static void app_pause(void *user_data) +static void _pause_app(void *user_data) { if(VOLUME_ERROR_OK != volume_control_pause()) - { _E("Failed to pause volume"); - } } -static void app_resume(void *user_data) +static void _resume_app(void *user_data) { } -static void app_control(app_control_h service, void *user_data) +static void _control_app(app_control_h service, void *user_data) { bundle *b = NULL; app_control_to_bundle(service, &b); - if(VOLUME_ERROR_OK != volume_control_reset(b)) - { + if(VOLUME_ERROR_OK != volume_control_reset(b)) { _E("Failed to reset volume"); return; } Evas_Object *win = volume_view_win_get(); if(win) - { elm_win_activate(win); - } } -static void lang_changed(app_event_info_h event_info, void *user_data) +static void _changed_language(app_event_info_h event_info, void *user_data) { _D("language changed"); char *locale = vconf_get_str(VCONFKEY_LANGSET); - if (locale) elm_language_set(locale); -} - -int main(int argc, char *argv[]) -{ - int ret = 0; - - ui_app_lifecycle_callback_s lifecycle_callback = {0,}; - app_event_handler_h handlers[5] = {NULL, }; - - lifecycle_callback.create = app_create; - lifecycle_callback.terminate = app_terminate; - lifecycle_callback.pause = app_pause; - lifecycle_callback.resume = app_resume; - lifecycle_callback.app_control = app_control; - - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, NULL, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, NULL, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, NULL, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, lang_changed, NULL); - ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, NULL, NULL); - - ret = ui_app_main(argc, argv, &lifecycle_callback, NULL); - if (ret != APP_ERROR_NONE) { - _E("app_main() is failed. err = %d", ret); - } - - return ret; + if (locale) + elm_language_set(locale); + free(locale); } diff --git a/src/sound.c b/src/sound.c index 5ccadb8..8fed6ca 100755 --- a/src/sound.c +++ b/src/sound.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,42 +25,48 @@ #include "view.h" #include "control.h" #include "sound.h" +#include "bt.h" -static struct _s_info { +struct _sound_s_info { int sound_step; int sound_status; int vibration_status; Eina_Bool is_vibration; -} s_info = { +}; + +static struct _sound_s_info sound_info = { .sound_step = 0, .sound_status = 0, .vibration_status = 0, .is_vibration = EINA_FALSE, }; +static void _sound_status_changed_cb(keynode_t *key, void *data); +static int _setting_sound_enabled(void); + int volume_sound_step_get(void) { - return s_info.sound_step; + return sound_info.sound_step; } int volume_sound_sound_status_get(void) { - return s_info.sound_status; + return sound_info.sound_status; } int volume_sound_vibration_status_get(void) { - return s_info.vibration_status; + return sound_info.vibration_status; } Eina_Bool volume_sound_is_vibration_get(void) { - return s_info.is_vibration; + return sound_info.is_vibration; } void volume_sound_is_vibration_set(Eina_Bool val) { - s_info.is_vibration = val; + sound_info.is_vibration = val; } void volume_sound_feedback_play(int feedback_type, int pattern) @@ -68,28 +74,24 @@ void volume_sound_feedback_play(int feedback_type, int pattern) _D("Feedback type : %d / pattern : %d", feedback_type, pattern); if (FEEDBACK_ERROR_NONE != feedback_play_type(feedback_type, pattern)) - { _E("Failed to play feedback"); - } } void volume_sound_vib_play(void) { - ret_if(s_info.is_vibration); + ret_if(sound_info.is_vibration); _D("Play Feedback : vibration"); if (FEEDBACK_ERROR_NONE != feedback_play_type(FEEDBACK_TYPE_VIBRATION, FEEDBACK_PATTERN_VIBRATION_ON)) - { _E("Failed to play feedback"); - } - s_info.is_vibration = EINA_TRUE; + sound_info.is_vibration = EINA_TRUE; } void volume_sound_play(void) { - sound_type_e sound_type = volume_control_sound_type_at_show_get(); + sound_type_e sound_type = volume_control_get_sound_type_at_show(); _D("sound type at show : %d", sound_type); ret_if(sound_type == SOUND_TYPE_ALARM); @@ -105,44 +107,24 @@ void volume_sound_play(void) return; } -static int _setting_sound_enabled(void) -{ - int snd_status = 0; - - if(vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &snd_status) < 0) - { - _E("Failed to get vconfkey : VCONFKEY_SETAPPL_SOUND_STATUS_BOOL"); - } - - if (snd_status == 1) - { - return 1; - } - - return 0; -} - -//void _play_setting_sound(void) void volume_sound_setting_sound_play(void) { int snd_enabled = _setting_sound_enabled(); _D("snd_enabled(%d)", snd_enabled); if(snd_enabled == 1) - { - //feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TOUCH_TAP); - volume_sound_feedback_play(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TOUCH_TAP); - } + volume_sound_feedback_play(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_TAP); } int volume_sound_sound_manager_step_get(sound_type_e type) { + _D("volume sound manager step get"); int ret = -1, step = 0; ret = sound_manager_get_max_volume(type, &step); retvm_if(ret < 0, -1, "Failed to get step"); - s_info.sound_step = step; + sound_info.sound_step = step; return step; } @@ -155,7 +137,6 @@ int volume_sound_sound_manager_volume_get(sound_type_e type) return val; } -//sound_type_e _get_volume_type sound_type_e volume_sound_sound_manager_type_get(void) { _D(" Volume sound manager type get"); @@ -163,10 +144,13 @@ sound_type_e volume_sound_sound_manager_type_get(void) sound_type_e sound_type = -1; ret = sound_manager_get_current_sound_type(&sound_type); + _D("ret: %d, sound type: %d", ret, sound_type); switch (ret) { case SOUND_MANAGER_ERROR_NONE: + _D("Error none"); break; case SOUND_MANAGER_ERROR_NO_PLAYING_SOUND: + _D("NO playing sound"); sound_type = SOUND_TYPE_RINGTONE; break; default: @@ -175,50 +159,45 @@ sound_type_e volume_sound_sound_manager_type_get(void) return sound_type; } - if(sound_type == SOUND_TYPE_SYSTEM) { + if(sound_type == SOUND_TYPE_SYSTEM) sound_type = SOUND_TYPE_RINGTONE; - } return sound_type; } void _mm_func(sound_type_e type, unsigned int volume, void *data) { - _D("type : %d, volume : %d", type, volume); - if(type == volume_control_sound_type_at_show_get()){ + bool bt_opened = false; + + _D("mm func is called type : %d, volume : %d", type, volume); + if (type == volume_control_get_sound_type_at_show()) { _D("current show type : %d, volume : %d", type, volume); /* Need to check sound type & device in media type volume. */ - if(type == SOUND_TYPE_MEDIA){ + if (type == SOUND_TYPE_MEDIA) { int sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); _D("sound status : %d", sound); int vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); _D("vibration : %d", vibration); - volume_view_volume_icon_set(type, sound, vibration); + volume_view_volume_icon_set(type, sound, vibration, bt_opened); } - if(VOLUME_ERROR_OK != volume_view_slider_value_set(volume)) - { + if (VOLUME_ERROR_OK != volume_view_slider_value_set(volume)) _E("Failed to set slider value"); - } } } -//int _init_mm_sound(void *data); void volume_sound_mm_sound_init(void) { + _D("MM sound Init"); int ret = sound_manager_set_volume_changed_cb(_mm_func, NULL); if (ret != SOUND_MANAGER_ERROR_NONE) - { _E("Failed to set volume changed event[%d]", ret); - } } -//int _get_sound_level(sound_type_e type, int *val) int volume_sound_level_get(sound_type_e type) { int val = -1; - if(sound_manager_get_volume(type, &val) < 0) - { + if (sound_manager_get_volume(type, &val) < 0) { _E("Failed to get Volume step"); return -1; } @@ -226,9 +205,9 @@ int volume_sound_level_get(sound_type_e type) return val; } -//int _set_sound_level(sound_type_e type, int val) int volume_sound_level_set(sound_type_e type, int val) { + _D("sound level set: %d", val); int ret = -1; ret = sound_manager_set_volume(type, val); @@ -237,83 +216,40 @@ int volume_sound_level_set(sound_type_e type, int val) void volume_sound_change_set(int val) { - sound_type_e sound_type = volume_control_sound_type_at_show_get(); + sound_type_e sound_type = volume_control_get_sound_type_at_show(); _D("sound type at show : %d", sound_type); int sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); _D("sound status : %d", sound); - if (val) - { - if(sound_type != SOUND_TYPE_MEDIA) - { - if(!volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS)) - { + if (val) { + if (sound_type != SOUND_TYPE_MEDIA) { + if (!volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS)) { volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 1); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0); } } - if(volume_sound_level_set(sound_type, val) != 0) - { + if (volume_sound_level_set(sound_type, val) != 0) volume_sound_level_set(sound_type, 9); - } volume_sound_play(); - } - else - { - if(sound_type != SOUND_TYPE_MEDIA) - { + } else { + if (sound_type != SOUND_TYPE_MEDIA) volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 0); - } volume_view_slider_value_set(0); volume_sound_level_set(sound_type, 0); - if(sound_type == SOUND_TYPE_RINGTONE) - { + if (sound_type == SOUND_TYPE_RINGTONE) { volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 1); volume_sound_vib_play(); } } } -static void _sound_status_changed_cb(keynode_t *key, void *data) -{ - const char *keyname = vconf_keynode_get_name(key); - ret_if(!keyname); - _D("keyname : %s", keyname); - - sound_type_e sound_type = volume_control_sound_type_at_show_get(); - _D("sound type at show : %d", sound_type); - - int sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); - _D("sound status : %d", sound); - s_info.sound_status = sound; - - int vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); - _D("vibration : %d", vibration); - s_info.vibration_status = vibration; - - if(sound == 0 && vibration == 1) - { - _D("vibration mode"); - } else if(sound == 1 && vibration == 0) - { - _D("sound mode"); - s_info.is_vibration = EINA_FALSE; - } else if(sound == 0 && vibration == 0) - { - _D("mute mode"); - s_info.is_vibration = EINA_FALSE; - } - - volume_view_volume_icon_set(sound_type, sound, vibration); -} - void volume_sound_vconf_status_set(volume_vconf_type_e type, int val) { char *vconfkey = NULL; - switch(type) + switch (type) { case TYPE_VCONF_SOUND_STATUS: vconfkey = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL; @@ -326,10 +262,8 @@ void volume_sound_vconf_status_set(volume_vconf_type_e type, int val) return; } - if(vconf_set_bool(vconfkey, val) < 0) - { + if (vconf_set_bool(vconfkey, val) < 0) _E("Failed to set vconfkey : %s", vconfkey); - } } int volume_sound_vconf_status_get(volume_vconf_type_e type) @@ -337,7 +271,7 @@ int volume_sound_vconf_status_get(volume_vconf_type_e type) int ret = -1; char *vconfkey = NULL; - switch(type) + switch (type) { case TYPE_VCONF_SOUND_STATUS: vconfkey = VCONFKEY_SETAPPL_SOUND_STATUS_BOOL; @@ -350,8 +284,7 @@ int volume_sound_vconf_status_get(volume_vconf_type_e type) return -1; } - if(vconf_get_bool(vconfkey, &ret) < 0) - { + if (vconf_get_bool(vconfkey, &ret) < 0) { _E("Failed to get vconfkey : %s", vconfkey); return -1; } @@ -361,27 +294,64 @@ int volume_sound_vconf_status_get(volume_vconf_type_e type) void volume_sound_vconfkey_register(void) { - if(vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, _sound_status_changed_cb, NULL) < 0) - { + if (vconf_notify_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, _sound_status_changed_cb, NULL) < 0) _E("Failed to notify vconfkey : VCONFKEY_SETAPPL_SOUND_STATUS_BOOL"); - } - if(vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, _sound_status_changed_cb, NULL) < 0) - { + if (vconf_notify_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, _sound_status_changed_cb, NULL) < 0) _E("Failed to notify vconfkey : VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL"); - } _sound_status_changed_cb(NULL, NULL); } void volume_sound_vconfkey_unregister(void) { - if(vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, _sound_status_changed_cb) < 0) - { + if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, _sound_status_changed_cb) < 0) _E("Failed to ignore vconfkey : VCONFKEY_SETAPPL_SOUND_STATUS_BOOL"); - } - if(vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, _sound_status_changed_cb) < 0) - { + if (vconf_ignore_key_changed(VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL, _sound_status_changed_cb) < 0) _E("Failed to ignore vconfkey : VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL"); +} + +static int _setting_sound_enabled(void) +{ + int snd_status = 0; + + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &snd_status) < 0) + _E("Failed to get vconfkey : VCONFKEY_SETAPPL_SOUND_STATUS_BOOL"); + + if (snd_status == 1) + return 1; + + return 0; +} + +static void _sound_status_changed_cb(keynode_t *key, void *data) +{ + bool bt_opened = false; + const char *keyname = vconf_keynode_get_name(key); + ret_if(!keyname); + _D("keyname : %s", keyname); + + sound_type_e sound_type = volume_control_get_sound_type_at_show(); + _D("sound type at show : %d", sound_type); + + int sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); + _D("sound status : %d", sound); + sound_info.sound_status = sound; + + int vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); + _D("vibration : %d", vibration); + sound_info.vibration_status = vibration; + + if (sound == 0 && vibration == 1) + _D("vibration mode"); + else if (sound == 1 && vibration == 0) { + _D("sound mode"); + sound_info.is_vibration = EINA_FALSE; + } else if (sound == 0 && vibration == 0) { + _D("mute mode"); + sound_info.is_vibration = EINA_FALSE; } + + volume_view_volume_icon_set(sound_type, sound, vibration, bt_opened); } + diff --git a/src/timer.c b/src/timer.c index 1854a69..c8bd61c 100755 --- a/src/timer.c +++ b/src/timer.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,62 +26,120 @@ #define DEL_TIMER(x) \ if (x) {\ - _D("DELTIMER x : %d\n", x);\ + _D("DELTIMER x : %p\n", x);\ ecore_timer_del(x);\ x = NULL;\ } #define ADD_TIMER(x, time, _timer_cb, data) \ if(x != NULL) DEL_TIMER(x); \ x = ecore_timer_add(time, _timer_cb, data);\ - _D("ADDTIMER x : %d\n", x);\ + _D("ADDTIMER x : %p\n", x);\ -static struct _s_info { +struct _timer_s_info { Ecore_Timer *popup_timer; /* pop-up timer */ Ecore_Timer *slider_timer; /* slider timer */ Ecore_Timer *su_timer; /* short up timer */ Ecore_Timer *sd_timer; /* short down timer */ Ecore_Timer *lu_timer; /* long up timer */ Ecore_Timer *ld_timer; /* long down timer */ -} s_info = { + Ecore_Timer *bt_timer; /* long down timer */ +}; + +static struct _timer_s_info timer_info = { .popup_timer = NULL, .slider_timer = NULL, .su_timer = NULL, .sd_timer = NULL, .lu_timer = NULL, .ld_timer = NULL, + .bt_timer = NULL, }; +static Eina_Bool _timer_short_down_cb(void *data); +static Eina_Bool _timer_short_up_cb(void *data); +static Eina_Bool _timer_slider_cb(void *data); +static Eina_Bool _timer_popup_cb(void *data); +static Eina_Bool _timer_bt_cb(void *data); + +Ecore_Timer *volume_timer_bt_timer_get(void) +{ + return timer_info.bt_timer; +} + Ecore_Timer *volume_timer_popup_timer_get(void) { - return s_info.popup_timer; + return timer_info.popup_timer; } Ecore_Timer *volume_timer_slider_timer_get(void) { - return s_info.slider_timer; + return timer_info.slider_timer; } Ecore_Timer *volume_timer_su_timer_get(void) { - return s_info.su_timer; + return timer_info.su_timer; } Ecore_Timer *volume_timer_sd_timer_get(void) { - return s_info.sd_timer; + return timer_info.sd_timer; +} + +void volume_timer_add(double time, volume_timer_type type) +{ + _D("VOLUME TIMER ADD"); + if (type == TYPE_TIMER_POPUP) { + ADD_TIMER(timer_info.popup_timer, time, _timer_popup_cb, NULL); + } else if (type == TYPE_TIMER_SLIDER) { + ADD_TIMER(timer_info.slider_timer, time, _timer_slider_cb, NULL); + } else if (type == TYPE_TIMER_SD) { + ADD_TIMER(timer_info.sd_timer, time, _timer_short_down_cb, NULL); + } else if (type == TYPE_TIMER_SU) { + ADD_TIMER(timer_info.su_timer, time, _timer_short_up_cb, NULL); + } else if (type == TYPE_TIMER_BT) { + ADD_TIMER(timer_info.bt_timer, time, _timer_bt_cb, NULL); + } else { + _E("Failed to get type : type error(%d)", type); + return; + } +} + +void volume_timer_del(volume_timer_type type) +{ + if (type == TYPE_TIMER_POPUP) { + DEL_TIMER(timer_info.popup_timer); + } else if (type == TYPE_TIMER_SLIDER) { + DEL_TIMER(timer_info.slider_timer); + } else if (type == TYPE_TIMER_SD) { + DEL_TIMER(timer_info.sd_timer); + } else if (type == TYPE_TIMER_SU) { + DEL_TIMER(timer_info.su_timer); + } else if (type == TYPE_TIMER_BT) { + DEL_TIMER(timer_info.bt_timer); + } else { + _E("Failed to get type : type error(%d)", type); + return; + } +} + +static Eina_Bool _timer_bt_cb(void *data) +{ + if (VOLUME_ERROR_OK != volume_control_close_bt_display()) + _E("Failed to close volume"); + if (VOLUME_ERROR_OK != volume_control_cache_flush()) + _E("Failed to flush cache"); + + return ECORE_CALLBACK_CANCEL; } static Eina_Bool _timer_popup_cb(void *data) { - if(VOLUME_ERROR_OK != volume_control_close()) - { + if (VOLUME_ERROR_OK != volume_control_hide_view()) _E("Failed to close volume"); - } - if(VOLUME_ERROR_OK != volume_control_cache_flush()) - { + if (VOLUME_ERROR_OK != volume_control_cache_flush()) _E("Failed to flush cache"); - } return ECORE_CALLBACK_CANCEL; } @@ -89,8 +147,8 @@ static Eina_Bool _timer_popup_cb(void *data) static Eina_Bool _timer_slider_cb(void *data) { Evas_Object *slider = volume_view_slider_get(); - if(slider == NULL) { - s_info.slider_timer = NULL; + if (slider == NULL) { + timer_info.slider_timer = NULL; return ECORE_CALLBACK_CANCEL; } @@ -104,8 +162,7 @@ static Eina_Bool _timer_slider_cb(void *data) _D("vibration : %d", vibration); #endif - //sound_type_e sound_type = volume_sound_sound_manager_type_get(); - sound_type_e sound_type = volume_control_sound_type_at_show_get(); + sound_type_e sound_type = volume_control_get_sound_type_at_show(); _D("sound type at show : %d", sound_type); val = elm_slider_value_get(slider); @@ -113,22 +170,17 @@ static Eina_Bool _timer_slider_cb(void *data) _D("slider value : %d", (int)val); if ((int)val != 0) { - if(sound_type != SOUND_TYPE_MEDIA){ + if (sound_type != SOUND_TYPE_MEDIA) { volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 1); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0); } volume_sound_is_vibration_set(EINA_FALSE); -#if 0 - if(VOLUME_ERROR_OK != volume_view_icon_set()) { - _E("Failed to set icon"); - } -#endif } if (val < 1) { - if(sound_type != SOUND_TYPE_MEDIA) { + if (sound_type != SOUND_TYPE_MEDIA) { volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 0); - if(sound) { + if (sound) { volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 1); volume_sound_vib_play(); } @@ -142,28 +194,25 @@ static Eina_Bool _timer_slider_cb(void *data) static Eina_Bool _timer_short_up_cb(void *data) { + _D("volume is in LongPress"); Evas_Object *win = volume_view_win_get(); - if(!win) - { + if (!win) { _E("Window is NULL"); return ECORE_CALLBACK_CANCEL; } - sound_type_e sound_type = volume_control_sound_type_at_show_get(); + sound_type_e sound_type = volume_control_get_sound_type_at_show(); _D("sound type at show : %d", sound_type); - if(!evas_object_visible_get(win) && sound_type == SOUND_TYPE_RINGTONE) - { + if (!evas_object_visible_get(win) && sound_type == SOUND_TYPE_RINGTONE) { _E("Window is hidden"); return ECORE_CALLBACK_CANCEL; } - if(volume_view_is_slider_touching_get()) - { + if (volume_view_is_slider_touching_get()) return ECORE_CALLBACK_RENEW; - } - ecore_timer_interval_set(s_info.su_timer, 0.1); + ecore_timer_interval_set(timer_info.su_timer, 0.1); volume_timer_del(TYPE_TIMER_SLIDER); int sound_step = volume_sound_step_get(); @@ -173,35 +222,32 @@ static Eina_Bool _timer_short_up_cb(void *data) _D("sound status : %d", sound); int val = volume_sound_level_get(sound_type); - if(val == -1) - { + if (val == -1) { _E("Failed to get volume level"); return ECORE_CALLBACK_CANCEL; } _D("sound value : %d", val); - if(val == sound_step) - { + if (val == sound_step) { _D("already sound value : %d", sound_step); return ECORE_CALLBACK_RENEW; } - if(!sound && sound_type == SOUND_TYPE_NOTIFICATION){ + if (!sound && sound_type == SOUND_TYPE_NOTIFICATION) { _D("Do not adjust the noti type in no sound."); return ECORE_CALLBACK_RENEW; } - if(!sound && sound_type == SOUND_TYPE_RINGTONE) - { + if (!sound && sound_type == SOUND_TYPE_RINGTONE) { volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 1); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0); } - if(volume_sound_level_set(sound_type, val+1 > sound_step ? sound_step : val+1)) - { + if (volume_sound_level_set(sound_type, val+1 > sound_step ? sound_step : val+1)) { _D("[SAFETY_SOUND] release timer"); volume_timer_add(3.0, TYPE_TIMER_POPUP); } + val = volume_sound_level_get(sound_type); return ECORE_CALLBACK_RENEW; } @@ -209,115 +255,55 @@ static Eina_Bool _timer_short_up_cb(void *data) static Eina_Bool _timer_short_down_cb(void *data) { Evas_Object *win = volume_view_win_get(); - if(!win) - { + if (!win) { _E("Window is NULL"); return ECORE_CALLBACK_CANCEL; } - sound_type_e sound_type = volume_control_sound_type_at_show_get(); + sound_type_e sound_type = volume_control_get_sound_type_at_show(); _D("sound type at show : %d", sound_type); - if(!evas_object_visible_get(win) && sound_type == SOUND_TYPE_RINGTONE) - { + if (!evas_object_visible_get(win) && sound_type == SOUND_TYPE_RINGTONE) { _E("Window is hidden");; return ECORE_CALLBACK_CANCEL; } - if(volume_view_is_slider_touching_get()) - { + if (volume_view_is_slider_touching_get()) return ECORE_CALLBACK_RENEW; - } - ecore_timer_interval_set(s_info.sd_timer, 0.1); + ecore_timer_interval_set(timer_info.sd_timer, 0.1); volume_timer_del(TYPE_TIMER_SLIDER); int sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); _D("sound status : %d", sound); int val = volume_sound_level_get(sound_type); - if(val == -1) - { + if (val == -1) { _E("Failed to get volume level"); return ECORE_CALLBACK_CANCEL; } - if(!sound && sound_type == SOUND_TYPE_NOTIFICATION){ + if (!sound && sound_type == SOUND_TYPE_NOTIFICATION) { _D("Do not adjust the noti type in no sound."); return ECORE_CALLBACK_RENEW; } _D("sound value : %d", val); - if(val == 1) - { - if(sound && sound_type == SOUND_TYPE_RINGTONE) - { + if (val == 1) { + if (sound && sound_type == SOUND_TYPE_RINGTONE) { _D("Set sound status to vibration in long press"); volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 0); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 1); volume_sound_vib_play(); } - } - else if(!val) - { + } else if (!val) { _D("already sound value : 0"); return ECORE_CALLBACK_RENEW; } - if(sound || sound_type != SOUND_TYPE_RINGTONE) - { + if (sound || sound_type != SOUND_TYPE_RINGTONE) volume_sound_level_set(sound_type, val-1 <= 0 ? 0 : val-1); - } return ECORE_CALLBACK_RENEW; } -void volume_timer_add(double time, volume_timer_type type) -{ - if(type == TYPE_TIMER_POPUP) - { - ADD_TIMER(s_info.popup_timer, time, _timer_popup_cb, NULL); - } - else if(type == TYPE_TIMER_SLIDER) - { - ADD_TIMER(s_info.slider_timer, time, _timer_slider_cb, NULL); - } - else if(type == TYPE_TIMER_SD) - { - ADD_TIMER(s_info.sd_timer, time, _timer_short_down_cb, NULL); - } - else if(type == TYPE_TIMER_SU) - { - ADD_TIMER(s_info.su_timer, time, _timer_short_up_cb, NULL); - } - else - { - _E("Failed to get type : type error(%d)", type); - return; - } -} - -void volume_timer_del(volume_timer_type type) -{ - if(type == TYPE_TIMER_POPUP) - { - DEL_TIMER(s_info.popup_timer); - } - else if(type == TYPE_TIMER_SLIDER) - { - DEL_TIMER(s_info.slider_timer); - } - else if(type == TYPE_TIMER_SD) - { - DEL_TIMER(s_info.sd_timer); - } - else if(type == TYPE_TIMER_SU) - { - DEL_TIMER(s_info.su_timer); - } - else - { - _E("Failed to get type : type error(%d)", type); - return; - } -} diff --git a/src/view.c b/src/view.c index 83007e9..a0c2ed0 100755 --- a/src/view.c +++ b/src/view.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,8 +30,9 @@ #include "key_event.h" #include "sound.h" -static struct _s_info { +struct _view_s_info { Evas_Object *win; + Evas_Object *evas; Evas_Object *ly_outer; Evas_Object *icon_volume; Evas_Object *icon_setting; @@ -44,8 +45,11 @@ static struct _s_info { Eina_Bool is_registered_callback; Eina_Bool is_slider_touching; Eina_Bool is_warning_displayed; -} s_info = { + int pre_sound_type; +}; +static struct _view_s_info view_info = { .win = NULL, + .evas = NULL, .ly_outer = NULL, .icon_volume = NULL, .icon_setting = NULL, @@ -57,45 +61,64 @@ static struct _s_info { .is_registered_callback = EINA_FALSE, .is_slider_touching = EINA_FALSE, - .is_warning_displayed = EINA_FALSE + .is_warning_displayed = EINA_FALSE, + .pre_sound_type = 0 }; static void _button_cb(void *data, Evas_Object *obj, void *event_info); static void _button_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info); +static void _app_control_error_check(int ret); +static void _hide_launcher(void *data, Evas_Object *obj, const char *emission, const char *source); +static void _slider_stop_cb(void *data, Evas_Object *obj, void *event_info); +static void _slider_start_cb(void *data, Evas_Object *obj, void *event_info); +static void _slider_changed_cb(void *data, Evas_Object *obj, void *event_info); +static Evas_Object* _slider_make(); +static Evas_Object* _volume_icon_make(); +static Evas_Object* _setting_icon_make(); Evas_Object* volume_view_win_get(void) { - return s_info.win; + return view_info.win; +} + +Evas_Object* volume_view_evas_get(void) +{ + return view_info.evas; } Evas_Object* volume_view_outer_layout_get(void) { - return s_info.ly_outer; + return view_info.ly_outer; } Evas_Object* volume_view_icon_volume_get(void) { - return s_info.icon_volume; + return view_info.icon_volume; } Evas_Object* volume_view_icon_setting_get(void) { - return s_info.icon_setting; + return view_info.icon_setting; } Evas_Object* volume_view_slider_get(void) { - return s_info.slider; + return view_info.slider; +} + +sound_type_e volume_view_pre_sound_type_get(void) +{ + return view_info.pre_sound_type; } Eina_Bool volume_view_is_registered_callback_get(void) { - return s_info.is_registered_callback; + return view_info.is_registered_callback; } Eina_Bool volume_view_is_slider_touching_get(void) { - return s_info.is_slider_touching; + return view_info.is_slider_touching; } volume_error_e volume_view_set_default_slider(){ @@ -117,7 +140,7 @@ volume_error_e volume_view_set_warning_slider(){ int volume_mute_toggle_set() { - sound_type_e sound_type = volume_control_sound_type_at_show_get(); + sound_type_e sound_type = volume_control_get_sound_type_at_show(); _D("sound type at show : %d", sound_type); int sound = volume_sound_vconf_status_get(TYPE_VCONF_SOUND_STATUS); @@ -126,231 +149,102 @@ int volume_mute_toggle_set() int vibration = volume_sound_vconf_status_get(TYPE_VCONF_VIBRATION_STATUS); _E("vibration : %d", vibration); - if (sound == 1 || vibration == 1) - { + if (sound == 1 || vibration == 1) { volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 0); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0); if(VOLUME_ERROR_OK != volume_view_slider_value_set(0)) - { _E("Failed to set slider value"); - } return 0; } - else - { + else { volume_sound_vconf_status_set(TYPE_VCONF_SOUND_STATUS, 1); volume_sound_vconf_status_set(TYPE_VCONF_VIBRATION_STATUS, 0); int val = volume_sound_level_get(sound_type); retv_if(val == -1, 0); - if(val == 0) - { - if(VOLUME_ERROR_OK != volume_view_slider_value_set(1)) { + if (val == 0) { + if (VOLUME_ERROR_OK != volume_view_slider_value_set(1)) _E("Failed to set slider value"); - } volume_sound_level_set(sound_type, 1); - } else - { - if(VOLUME_ERROR_OK != volume_view_slider_value_set(val)) { + } else { + if (VOLUME_ERROR_OK != volume_view_slider_value_set(val)) _E("Failed to set slider value"); - } } return 1; } } -static void _slider_start_cb(void *data, Evas_Object *obj, void *event_info) +volume_error_e volume_change_slider_max_value(sound_type_e type) { - s_info.is_slider_touching = EINA_TRUE; + _D("Slider change for state : %d", type); + int ret = 0; + int step = 0; - volume_timer_del(TYPE_TIMER_POPUP); - - volume_timer_add(0.2, TYPE_TIMER_SLIDER); -} - -static void _slider_changed_cb(void *data, Evas_Object *obj, void *event_info) -{ - volume_timer_del(TYPE_TIMER_POPUP); - - double val = 0; - - sound_type_e sound_type = volume_control_sound_type_at_show_get(); - _D("sound type at show : %d", sound_type); - - val = elm_slider_value_get(s_info.slider); - val += 0.5; - _D("slider value : %d", val); - - if (s_info.is_slider_touching) - { - return; + ret = sound_manager_get_max_volume(type, &step); + if (ret < 0) { + _D("Failed to get max volume, sound_type: %d", type); } + _D("sound type: %d, max: %d", type, step); - volume_sound_change_set((int)val); - - if(!volume_key_event_is_pressing_get()) - { - volume_timer_add(3.0, TYPE_TIMER_POPUP); - return; - } + elm_slider_min_max_set(view_info.slider, 0, step); - if(!s_info.is_slider_touching) - { - volume_timer_add(3.0, TYPE_TIMER_POPUP); - return; - } -} + view_info.pre_sound_type = type; -static void _slider_stop_cb(void *data, Evas_Object *obj, void *event_info) -{ - s_info.is_slider_touching = EINA_FALSE; - - volume_timer_del(TYPE_TIMER_SLIDER); - - Evas_Object *slider = volume_view_slider_get(); - ret_if(slider == NULL); - - double val = 0; - - val = elm_slider_value_get(slider); - val += 0.5; - _D("slider value : %d", (int)val); - - volume_sound_change_set((int)val); - - volume_timer_add(3.0, TYPE_TIMER_POPUP); -} - -static void _hide_launcher(void *data, Evas_Object *obj, const char *emission, const char *source) -{ - evas_object_hide(s_info.win); + return VOLUME_ERROR_OK; } -//int _set_slider_value(void *data, int val) volume_error_e volume_view_slider_value_set(int val) { - retv_if(s_info.is_slider_touching, VOLUME_ERROR_FAIL); + _D("Slider value set : %d", val); + retv_if(view_info.is_slider_touching, VOLUME_ERROR_FAIL); retv_if(val<0, VOLUME_ERROR_FAIL); - elm_slider_value_set(s_info.slider, val); + elm_slider_value_set(view_info.slider, val); return VOLUME_ERROR_OK; } -static void _button_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - volume_view_setting_icon_set(IMG_VOLUME_ICON_SETTINGS_PRESSED); -} - -static void _app_control_error_check(int ret) -{ - if(ret != APP_CONTROL_ERROR_NONE) - { - switch(ret) - { - case APP_CONTROL_ERROR_INVALID_PARAMETER : - _E("error : APP_CONTROL_ERROR_INVALID_PARAMETER"); - break; - case APP_CONTROL_ERROR_OUT_OF_MEMORY : - _E("error : APP_CONTROL_ERROR_OUT_OF_MEMORY"); - break; - case APP_CONTROL_ERROR_APP_NOT_FOUND : - _E("error : APP_CONTROL_ERROR_APP_NOT_FOUND"); - break; - case APP_CONTROL_ERROR_LAUNCH_REJECTED : - _E("error : APP_CONTROL_ERROR_LAUNCH_REJECTED"); - break; - default : - _E("error : %d", ret); - break; - } - } -} - -static void _button_cb(void *data, Evas_Object *obj, void *event_info) -{ - _D("volume setting is clicked"); - int ret = -1; - app_control_h svc; - - if(evas_object_visible_get(s_info.win)) - { - volume_timer_del(TYPE_TIMER_POPUP); - if(ecore_x_e_illume_quickpanel_state_get(ecore_x_e_illume_zone_get(elm_win_xwindow_get(s_info.win))) != ECORE_X_ILLUME_QUICKPANEL_STATE_OFF) - { - _D("Quickpanel is hide"); - ecore_x_e_illume_quickpanel_state_send(ecore_x_e_illume_zone_get(elm_win_xwindow_get(s_info.win)), ECORE_X_ILLUME_QUICKPANEL_STATE_OFF); - } - - ret = app_control_create(&svc); - _app_control_error_check(ret); - - ret = app_control_set_app_id(svc, "org.tizen.setting.volume"); - _app_control_error_check(ret); - - ret = app_control_send_launch_request(svc, NULL, NULL); - _app_control_error_check(ret); - - if(VOLUME_ERROR_OK != volume_control_pause()) - { - _E("Failed to pause volume"); - } - - app_control_destroy(svc); - } -} - -void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int vibration) +void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int vibration, bool bt_opened) { char *img = NULL; - if(sound == -1 || vibration == -1) - { + if (sound == -1 || vibration == -1) { img = IMG_VOLUME_ICON_MUTE; _D("img : %s", img); - elm_image_file_set(s_info.icon_volume, EDJ_APP, img); + elm_image_file_set(view_info.icon_volume, EDJ_APP, img); return; } - switch(sound_type) + switch (sound_type) { case SOUND_TYPE_RINGTONE: - if(sound) - { + if (sound) img = IMG_VOLUME_ICON; - } - else if(vibration) - { + else if (vibration) img = IMG_VOLUME_ICON_VIB; - } else - { img = IMG_VOLUME_ICON_MUTE; - } break; case SOUND_TYPE_MEDIA: img = IMG_VOLUME_ICON_MEDIA; break; case SOUND_TYPE_CALL: - img = IMG_VOLUME_ICON_CALL; + if (bt_opened) + img = IMG_VOLUME_ICON_CALL; + else + img = IMG_VOLUME_ICON_CALL; break; case SOUND_TYPE_NOTIFICATION: - if(sound) - { + if (sound) img = IMG_VOLUME_ICON_NOTI; - } else if(vibration) - { img = IMG_VOLUME_ICON_NOTI_VIB; - } else - { img = IMG_VOLUME_ICON_NOTI_MUTE; - } break; case SOUND_TYPE_ALARM: img = IMG_VOLUME_ICON_MEDIA; @@ -363,14 +257,14 @@ void volume_view_volume_icon_set(sound_type_e sound_type, int sound, int vibrati volume_view_set_default_slider(); _D("img : %s", img); - elm_image_file_set(s_info.icon_volume, EDJ_APP, img); + elm_image_file_set(view_info.icon_volume, EDJ_APP, img); } void volume_view_setting_icon_set(const char *file) { ret_if(!file); - Evas_Object *icon_setting = s_info.icon_setting; + Evas_Object *icon_setting = view_info.icon_setting; ret_if(!icon_setting); elm_image_file_set(icon_setting, EDJ_APP, file); @@ -379,66 +273,39 @@ void volume_view_setting_icon_set(const char *file) void volume_view_setting_icon_callback_add(void) { _D("Setting callback add"); - ret_if(s_info.is_registered_callback); + ret_if(view_info.is_registered_callback); - Evas_Object *icon_setting = s_info.icon_setting; + Evas_Object *icon_setting = view_info.icon_setting; ret_if(!icon_setting); evas_object_event_callback_add(icon_setting, EVAS_CALLBACK_MOUSE_DOWN, _button_mouse_down_cb, NULL); evas_object_smart_callback_add(icon_setting, "clicked", _button_cb, NULL); - s_info.is_registered_callback = EINA_TRUE; + view_info.is_registered_callback = EINA_TRUE; } void volume_view_setting_icon_callback_del(void) { _D("Setting callback del"); - ret_if(!s_info.is_registered_callback); + ret_if(!view_info.is_registered_callback); - Evas_Object *icon_setting = s_info.icon_setting; + Evas_Object *icon_setting = view_info.icon_setting; ret_if(!icon_setting); evas_object_smart_callback_del(icon_setting, "clicked", _button_cb ); evas_object_event_callback_del(icon_setting, EVAS_CALLBACK_MOUSE_DOWN, _button_mouse_down_cb); - s_info.is_registered_callback = EINA_FALSE; -} - -static Evas_Object* _setting_icon_make() -{ - Evas_Object *icon_setting = elm_icon_add(s_info.ly_outer); - retv_if(!icon_setting, NULL); - - evas_object_size_hint_aspect_set(icon_setting, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - elm_image_resizable_set(icon_setting, EINA_TRUE, EINA_TRUE); - - s_info.icon_setting = icon_setting; - - volume_view_setting_icon_set(IMG_VOLUME_ICON_SETTINGS); - evas_object_show(icon_setting); - - return icon_setting; -} - -static Evas_Object* _volume_icon_make() -{ - Evas_Object *icon_volume = elm_icon_add(s_info.ly_outer); - retv_if(!icon_volume, NULL); - - evas_object_size_hint_aspect_set(icon_volume, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); - elm_image_resizable_set(icon_volume, EINA_TRUE, EINA_TRUE); - evas_object_show(icon_volume); - - return icon_volume; + view_info.is_registered_callback = EINA_FALSE; } Evas_Object *add_slider(Evas_Object *parent, int min, int max, int val) { + retv_if(!parent, NULL); Evas_Object *slider = elm_slider_add(parent); retvm_if(!slider, NULL, "Failed to add slider"); elm_slider_horizontal_set(slider, EINA_TRUE); - elm_slider_indicator_show_set(slider, EINA_FALSE); + elm_slider_indicator_show_set(slider, EINA_TRUE); elm_slider_indicator_format_set(slider, "%.0f"); evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, 0.0); evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5); @@ -448,54 +315,21 @@ Evas_Object *add_slider(Evas_Object *parent, int min, int max, int val) return slider; } -static Evas_Object* _slider_make() -{ - sound_type_e sound_type = volume_control_sound_type_at_show_get(); - _D("sound type at show : %d", sound_type); - - int sound_step = volume_sound_sound_manager_step_get(sound_type); - _D("sound step : %d", sound_step); - - int sound_val = volume_sound_level_get(sound_type); - if(sound_val == -1) - { - _E("Failed to get volume level"); - sound_val = 0; - } - _D("sound value : %d", sound_val); - - Evas_Object *slider = add_slider(s_info.ly_outer, 0, sound_step, sound_val); - evas_object_smart_callback_add(slider, "slider,drag,start", _slider_start_cb, NULL); - evas_object_smart_callback_add(slider, "changed", _slider_changed_cb, NULL); - evas_object_smart_callback_add(slider, "slider,drag,stop", _slider_stop_cb, NULL); - - return slider; -} - - -static void _safety_warning_text_load() +volume_error_e volume_view_window_show(sound_type_e type) { - elm_object_domain_translatable_part_text_set(s_info.ly_outer, "warning_rect", "org.tizen.volume", "IDS_COM_POP_TO_LOWER_YOUR_RISK_OF_HEARING_DAMAGE_DO_NOT_LISTEN_AT_HIGH_VOLUMES_FOR_LONG_PERIODS"); - elm_object_part_text_translatable_set(s_info.ly_outer, "warning_rect", EINA_TRUE); - if (!elm_object_part_text_get(s_info.ly_outer, "warning_rect")) - { - _E("Failed to set warning text"); - return; - } -} + evas_object_show(view_info.win); + elm_object_signal_emit(view_info.ly_outer, "show_effect", "clipper"); -volume_error_e volume_view_window_show(void) -{ - evas_object_show(s_info.win); - elm_object_signal_emit(s_info.ly_outer, "show_effect", "clipper"); - volume_view_setting_icon_callback_add(); + if (type == SOUND_TYPE_CALL) { + _D("Sound type is CALL"); + } else volume_view_setting_icon_callback_add(); return VOLUME_ERROR_OK; } volume_error_e volume_view_window_hide(void) { - elm_object_signal_emit(s_info.ly_outer, "hide_effect", "clipper"); + elm_object_signal_emit(view_info.ly_outer, "hide_effect", "clipper"); volume_view_setting_icon_callback_del(); return VOLUME_ERROR_OK; @@ -512,8 +346,7 @@ Evas_Object *add_layout(Evas_Object *parent, const char *file, const char *group int r = -1; r = elm_layout_file_set(eo, file, group); - if (!r) - { + if (!r) { _E("Failed to set file[%s]\n", file); evas_object_del(eo); return NULL; @@ -535,50 +368,50 @@ volume_error_e volume_view_layout_create(Evas_Object *win) retv_if(!ly_outer, VOLUME_ERROR_FAIL); elm_win_resize_object_add(win, ly_outer); elm_object_signal_callback_add(ly_outer, "hide,popup", "event", _hide_launcher, NULL); - s_info.ly_outer = ly_outer; + view_info.ly_outer = ly_outer; /* make setting icon */ Evas_Object *icon_setting = _setting_icon_make(); retv_if(!icon_setting, VOLUME_ERROR_FAIL); elm_object_part_content_set(ly_outer, "ic_setting", icon_setting); - s_info.icon_setting = icon_setting; + view_info.icon_setting = icon_setting; /* make volume icon */ Evas_Object *icon_volume = _volume_icon_make(); retv_if(!icon_volume, VOLUME_ERROR_FAIL); elm_object_part_content_set(ly_outer, "ic_sound", icon_volume); - s_info.icon_volume = icon_volume; + view_info.icon_volume = icon_volume; /* make slider */ Evas_Object *slider = _slider_make(); retv_if(!slider, VOLUME_ERROR_FAIL); - s_info.slider = slider; + view_info.slider = slider; elm_object_part_content_set(ly_outer, "sw.slider", slider); - _safety_warning_text_load(); - return VOLUME_ERROR_OK; } Evas_Object *add_volume_window(const char *name) { Evas_Object *eo = NULL; - int w = -1, h = -1; + Evas *evas = NULL; + int x, y, w, h = 0; eo = elm_win_add(NULL, name, ELM_WIN_NOTIFICATION); retv_if(!eo, NULL); + evas = evas_object_evas_get(eo); + retv_if(!evas, NULL); + view_info.evas = evas; + elm_win_alpha_set(eo, EINA_TRUE); elm_win_title_set(eo, name); elm_win_borderless_set(eo, EINA_TRUE); - elm_win_alpha_set(eo, EINA_TRUE); + ecore_evas_name_class_set(ecore_evas_ecore_evas_get(evas), "SYSTEM_POPUP", "SYSTEM_POPUP"); + elm_win_prop_focus_skip_set(eo, EINA_TRUE); elm_win_role_set(eo, "no-dim"); - ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); - if(w == -1 || h == -1) - { - _E("ecore_x_window_size_get() is failed\n"); - return NULL; - } + elm_win_screen_size_get(eo, &x, &y, &w, &h); + _D("volume screen size => x: %d, y: %d, w: %d, h: %d", x, y, w, h); return eo; } @@ -588,7 +421,7 @@ Evas_Object *volume_view_window_create(void) Evas_Object *win = add_volume_window(PACKAGE); retv_if(!win, NULL); - s_info.win = win; + view_info.win = win; return win; } @@ -599,36 +432,31 @@ void _lock_sound_check(void) int lock_sound = -1; int lock_type = -1; - if(vconf_get_int(VCONFKEY_PM_LCDOFF_SOURCE, &lcdoff_source) < 0) { + if (vconf_get_int(VCONFKEY_PM_LCDOFF_SOURCE, &lcdoff_source) < 0) { _E("Failed to get vconfkey : VCONFKEY_PM_LCDOFF_SOURCE"); return; } _D("lcd off source : %d", lcdoff_source); - if(lcdoff_source != VCONFKEY_PM_LCDOFF_BY_POWERKEY) { + if (lcdoff_source != VCONFKEY_PM_LCDOFF_BY_POWERKEY) { _E("Should not play lock sound"); return; } - if(vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &lock_sound) < 0) { + if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_LOCK_BOOL, &lock_sound) < 0) { _E("Failed to get vconfkey : VCONFKEY_SETAPPL_SOUND_LOCK_BOOL"); return; } _D("lock sound : %d", lock_sound); - if(lock_sound) { // play sound - if(vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type) < 0){ + if (lock_sound) { + if (vconf_get_int(VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT, &lock_type) < 0) { _E("Failed to get vconfkey : VCONFKEY_SETAPPL_SCREEN_LOCK_TYPE_INT"); lock_type = 0; } _D("lock type : %d", lock_type); - if(lock_type == SETTING_SCREEN_LOCK_TYPE_SWIPE) { - feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_LOCK_SWIPE); - - } else { - feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_LOCK); - } + feedback_play_type(FEEDBACK_TYPE_SOUND, FEEDBACK_PATTERN_LOCK); } } @@ -638,11 +466,10 @@ Evas_Object* show_lockscreen_splash(const char* bg_path) retv_if(bg_path == NULL, NULL); - if(s_info.lockscreen_splash) - { + if (view_info.lockscreen_splash) { _E("There is remain fake_bg : remove old one"); - evas_object_del(s_info.lockscreen_splash); - s_info.lockscreen_splash = NULL; + evas_object_del(view_info.lockscreen_splash); + view_info.lockscreen_splash = NULL; } /* Check Lock Sound */ @@ -650,14 +477,11 @@ Evas_Object* show_lockscreen_splash(const char* bg_path) /* hide volume window */ if(VOLUME_ERROR_OK != volume_view_window_hide()) - { _E("Failed to hide window"); - } Evas_Object *win_splash = elm_win_add(NULL,"lockscreen_splash", ELM_WIN_NOTIFICATION); - if(!win_splash) - { + if (!win_splash) { _E("Failed to add splash window"); return NULL; } @@ -665,8 +489,7 @@ Evas_Object* show_lockscreen_splash(const char* bg_path) _D("Splash window created"); Evas_Object *bg = elm_bg_add(win_splash); - if(!bg) - { + if (!bg) { _D("Failed to get background"); evas_object_del(win_splash); return NULL; @@ -680,7 +503,7 @@ Evas_Object* show_lockscreen_splash(const char* bg_path) _D("Splash window shown"); - s_info.lockscreen_splash = win_splash; + view_info.lockscreen_splash = win_splash; return win_splash; } @@ -689,14 +512,185 @@ volume_error_e hide_lockscreen_splash(void) { _D(" "); - if (!s_info.lockscreen_splash) { + if (!view_info.lockscreen_splash) { _E("No splash window found"); return VOLUME_ERROR_FAIL; } - evas_object_del(s_info.lockscreen_splash); - s_info.lockscreen_splash = NULL; + evas_object_del(view_info.lockscreen_splash); + view_info.lockscreen_splash = NULL; _D("Splash window closed"); return VOLUME_ERROR_OK; } +static void _slider_start_cb(void *data, Evas_Object *obj, void *event_info) +{ + view_info.is_slider_touching = EINA_TRUE; + + volume_timer_del(TYPE_TIMER_POPUP); + + volume_timer_add(0.2, TYPE_TIMER_SLIDER); +} + +static void _slider_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + _D("slider changed callback"); + volume_timer_del(TYPE_TIMER_POPUP); + + double val = 0; + + sound_type_e sound_type = volume_control_get_sound_type_at_show(); + _D("sound type at show : %d", sound_type); + + val = elm_slider_value_get(view_info.slider); + val += 0.5; + _D("slider value : %d", val); + + if (view_info.is_slider_touching) + return; + + volume_sound_change_set((int)val); + + if (!volume_key_event_is_pressing_get()) { + volume_timer_add(3.0, TYPE_TIMER_POPUP); + return; + } + + if (!view_info.is_slider_touching) { + volume_timer_add(3.0, TYPE_TIMER_POPUP); + return; + } +} + +static void _slider_stop_cb(void *data, Evas_Object *obj, void *event_info) +{ + view_info.is_slider_touching = EINA_FALSE; + + volume_timer_del(TYPE_TIMER_SLIDER); + + Evas_Object *slider = volume_view_slider_get(); + ret_if(slider == NULL); + + double val = 0; + + val = elm_slider_value_get(slider); + val += 0.5; + _D("slider value : %d", (int)val); + + volume_sound_change_set((int)val); + + volume_timer_add(3.0, TYPE_TIMER_POPUP); +} + +static void _hide_launcher(void *data, Evas_Object *obj, const char *emission, const char *source) +{ + evas_object_hide(view_info.win); +} + +static void _button_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) +{ + volume_view_setting_icon_set(IMG_VOLUME_ICON_SETTINGS_PRESSED); +} + +static void _app_control_error_check(int ret) +{ + if (ret != APP_CONTROL_ERROR_NONE) { + switch (ret) + { + case APP_CONTROL_ERROR_INVALID_PARAMETER : + _E("error : APP_CONTROL_ERROR_INVALID_PARAMETER"); + break; + case APP_CONTROL_ERROR_OUT_OF_MEMORY : + _E("error : APP_CONTROL_ERROR_OUT_OF_MEMORY"); + break; + case APP_CONTROL_ERROR_APP_NOT_FOUND : + _E("error : APP_CONTROL_ERROR_APP_NOT_FOUND"); + break; + case APP_CONTROL_ERROR_LAUNCH_REJECTED : + _E("error : APP_CONTROL_ERROR_LAUNCH_REJECTED"); + break; + default : + _E("error : %d", ret); + break; + } + } +} + +static void _button_cb(void *data, Evas_Object *obj, void *event_info) +{ + _D("volume setting is clicked"); + int ret = -1; + app_control_h svc; + + if (evas_object_visible_get(view_info.win)) { + volume_timer_del(TYPE_TIMER_POPUP); + + ret = app_control_create(&svc); + _app_control_error_check(ret); + + ret = app_control_set_app_id(svc, "org.tizen.setting.volume"); + _app_control_error_check(ret); + + ret = app_control_send_launch_request(svc, NULL, NULL); + _app_control_error_check(ret); + + if (VOLUME_ERROR_OK != volume_control_pause()) + _E("Failed to pause volume"); + + app_control_destroy(svc); + } +} + +static Evas_Object* _setting_icon_make() +{ + Evas_Object *icon_setting = elm_icon_add(view_info.ly_outer); + retv_if(!icon_setting, NULL); + + evas_object_size_hint_aspect_set(icon_setting, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + elm_image_resizable_set(icon_setting, EINA_TRUE, EINA_TRUE); + + view_info.icon_setting = icon_setting; + + volume_view_setting_icon_set(IMG_VOLUME_ICON_SETTINGS); + evas_object_show(icon_setting); + + return icon_setting; +} + +static Evas_Object* _volume_icon_make() +{ + Evas_Object *icon_volume = elm_icon_add(view_info.ly_outer); + retv_if(!icon_volume, NULL); + + evas_object_size_hint_aspect_set(icon_volume, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + elm_image_resizable_set(icon_volume, EINA_TRUE, EINA_TRUE); + evas_object_show(icon_volume); + + return icon_volume; +} + +static Evas_Object* _slider_make() +{ + _D("Volume Slider Make"); + sound_type_e sound_type = volume_control_get_sound_type_at_show(); + _D("sound type at show : %d", sound_type); + + int sound_step = volume_sound_sound_manager_step_get(sound_type); + _D("sound step : %d", sound_step); + + int sound_val = volume_sound_level_get(sound_type); + if (sound_val == -1) { + _E("Failed to get volume level"); + sound_val = 0; + } + _D("sound value : %d", sound_val); + + Evas_Object *slider = add_slider(view_info.ly_outer, 0, sound_step, sound_val); + retv_if(!slider, NULL); + evas_object_smart_callback_add(slider, "slider,drag,start", _slider_start_cb, NULL); + evas_object_smart_callback_add(slider, "changed", _slider_changed_cb, NULL); + evas_object_smart_callback_add(slider, "slider,drag,stop", _slider_stop_cb, NULL); + + return slider; +} + diff --git a/src/x_event.c b/src/x_event.c index 45d3774..e21956a 100755 --- a/src/x_event.c +++ b/src/x_event.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009-2014 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,143 +24,21 @@ #include "control.h" #include "_util_log.h" -static struct _s_info { +struct _x_event_s_info { Ecore_Event_Handler *event_outer_touch_handler; -#if 0 - Ecore_Event_Handler *x_mouse_down_handler; - Ecore_Event_Handler *x_mouse_up_handler; - Ecore_Event_Handler *x_mouse_move_handler; - Ecore_Event_Handler *x_mouse_in_handler; - Ecore_Event_Handler *x_mouse_out_handler; - Ecore_Event_Handler *x_win_visibility_change_handler; - - Eina_Bool is_down; - Eina_Bool is_moving; -#endif Eina_Bool is_first_touch; -} s_info = { +}; +static struct _x_event_s_info x_event_info = { .event_outer_touch_handler = NULL, -#if 0 - .x_mouse_down_handler = NULL, - .x_mouse_up_handler = NULL, - .x_mouse_move_handler = NULL, - .x_mouse_in_handler = NULL, - .x_mouse_out_handler = NULL, - .x_win_visibility_change_handler = NULL, - - .is_down = EINA_FALSE, - .is_moving = EINA_FALSE, -#endif .is_first_touch = EINA_TRUE, }; -static void _x_touch_check(int cur_x, int cur_y) -{ - int current_angle = volume_control_current_angle_get(); - - int x = 0, y = 0; - int w = 0, h = 0; - - Evas_Object *ly = volume_view_outer_layout_get(); - - if(!ly) - { - _E("Failed to load edje"); - return; - } - - edje_object_part_geometry_get(_EDJ(ly), "bg", &x, &y, &w, &h); - - w = x + w; //WIDTH - h = y + h; //HEIGHT - - if(current_angle == 90) - { - if(cur_x > y && cur_x < h && cur_y > x && cur_y < w) - { - _D("touched inside"); - } - else - { - _D("current angle : %d / touched outside ", current_angle); - if(VOLUME_ERROR_OK != volume_control_close()) - { - _E("Failed to close volume"); - } - - if(VOLUME_ERROR_OK != volume_control_cache_flush()) - { - _E("Failed to flush cache"); - } - } - } - else if(current_angle == 270) - { - if(cur_x > h && cur_x < (volume_control_viewport_width_get() - y) && cur_y > x && cur_y < w) - { - _D("touched inside"); - } - else - { - _D("current angle : %d / touched outside ", current_angle); - if(VOLUME_ERROR_OK != volume_control_close()) - { - _E("Failed to close volume"); - } - - if(VOLUME_ERROR_OK != volume_control_cache_flush()) - { - _E("Failed to flush cache"); - } - } - } - else - { - if(x < cur_x && cur_x < w && y < cur_y && cur_y < h) - { - _D("current angle : %d / touched inside", current_angle); - } - else - { - _D("current angle : %d / touched outside ", current_angle); - if(VOLUME_ERROR_OK != volume_control_close()) - { - _E("Failed to close volume"); - } - - if(VOLUME_ERROR_OK != volume_control_cache_flush()) - { - _E("Failed to flush cache"); - } - } - } -} - -static Eina_Bool _event_handler_cb(void *data, int type, void *event_info) -{ - _D("%s", __func__); - - Ecore_X_Event_Generic *e = (Ecore_X_Event_Generic *)event_info; - retv_if(e->evtype != XI_RawMotion, ECORE_CALLBACK_DONE); - - if(s_info.is_first_touch == EINA_TRUE) - { - s_info.is_first_touch = EINA_FALSE; - return ECORE_CALLBACK_DONE; - } - s_info.is_first_touch = EINA_TRUE; - - int cur_x = 0, cur_y = 0; - ecore_x_pointer_xy_get(ecore_x_window_root_first_get(), &cur_x, &cur_y); - _D("cur_x : %d / cur_y : %d", cur_x, cur_y); - - _x_touch_check(cur_x, cur_y); - - return ECORE_CALLBACK_DONE; -} +static Eina_Bool _event_handler_cb(void *data, int type, void *event_info); +static void _x_touch_check(int cur_x, int cur_y); void volume_x_input_event_shape(Evas_Object *win, Eina_Bool is_warning_visible) { + _D("X input event shape"); Evas_Object *ly = NULL; XRectangle rect; @@ -170,19 +48,19 @@ void volume_x_input_event_shape(Evas_Object *win, Eina_Bool is_warning_visible) int tmp_w; int tmp_h; - int current_angle = volume_control_current_angle_get(); + int current_angle = volume_control_get_current_angle(); + _D("Current angle : %d", current_angle); ly = volume_view_outer_layout_get(); - if(!ly) - { + if (!ly) { _E("Failed to load edje"); return; } edje_object_part_geometry_get(_EDJ(ly), "bg", &x, &y, &w, &h); + _D("The position of bg x: %d, y: %d, w: %d, h: %d", x, y, w, h); - if(current_angle == 90) - { + if (current_angle == 90) { tmp_x = x; tmp_y = y; tmp_w = w; @@ -193,31 +71,29 @@ void volume_x_input_event_shape(Evas_Object *win, Eina_Bool is_warning_visible) w = tmp_h; h = tmp_w; } - else if(current_angle == 270) - { + else if (current_angle == 270) { tmp_x = x; tmp_y = y; tmp_w = w; tmp_h = h; - x = volume_control_viewport_width_get()-tmp_y-tmp_h; + x = volume_control_get_viewport_width()-tmp_y-tmp_h; y = tmp_x; w = tmp_h; h = tmp_w; } - rect.x = x; rect.y = y; rect.height = h; rect.width = w; - XShapeCombineRectangles(ecore_x_display_get(), elm_win_xwindow_get(win), ShapeInput, 0, 0, &rect, 1, ShapeSet, Unsorted); + _D("shape x: %d, y: %d, w: %d, h: %d", x, y, w, h); + XShapeCombineRectangles(ecore_x_display_get(), elm_win_xwindow_get(win), ShapeInput, 0, 0, &rect, 1, ShapeSet, Unsorted); } volume_error_e volume_x_input_event_register(void) { - if(s_info.event_outer_touch_handler == NULL) - { + if (x_event_info.event_outer_touch_handler == NULL) { XIEventMask event_mask; event_mask.deviceid = XIAllMasterDevices; @@ -228,9 +104,9 @@ volume_error_e volume_x_input_event_register(void) XISetMask(event_mask.mask, XI_RawMotion); XISelectEvents(ecore_x_display_get(), ecore_x_window_root_first_get(), &event_mask, 1); - s_info.event_outer_touch_handler = ecore_event_handler_add(ECORE_X_EVENT_GENERIC, (Ecore_Event_Handler_Cb)_event_handler_cb, NULL); + x_event_info.event_outer_touch_handler = ecore_event_handler_add(ECORE_X_EVENT_GENERIC, (Ecore_Event_Handler_Cb)_event_handler_cb, NULL); - s_info.is_first_touch = EINA_TRUE; + x_event_info.is_first_touch = EINA_TRUE; free(event_mask.mask); } @@ -239,10 +115,89 @@ volume_error_e volume_x_input_event_register(void) volume_error_e volume_x_input_event_unregister(void) { - retv_if(s_info.event_outer_touch_handler == NULL, VOLUME_ERROR_FAIL); + retv_if(x_event_info.event_outer_touch_handler == NULL, VOLUME_ERROR_FAIL); - ecore_event_handler_del(s_info.event_outer_touch_handler); - s_info.event_outer_touch_handler = NULL; + ecore_event_handler_del(x_event_info.event_outer_touch_handler); + x_event_info.event_outer_touch_handler = NULL; return VOLUME_ERROR_OK; } + +static void _x_touch_check(int cur_x, int cur_y) +{ + int current_angle = volume_control_get_current_angle(); + + int x = 0, y = 0; + int w = 0, h = 0; + + Evas_Object *ly = volume_view_outer_layout_get(); + + if (!ly) { + _E("Failed to load edje"); + return; + } + + edje_object_part_geometry_get(_EDJ(ly), "bg", &x, &y, &w, &h); + _D("control view x: %d, y: %d, w: %d, h: %d", x, y, w, h); + + w = x + w; //WIDTH + h = y + h; //HEIGHT + + if (current_angle == 90) { + if (cur_x > y && cur_x < h && cur_y > x && cur_y < w) + _D("touched inside"); + else { + _D("current angle : %d / touched outside ", current_angle); + if (VOLUME_ERROR_OK != volume_control_hide_view()) + _E("Failed to close volume"); + + if (VOLUME_ERROR_OK != volume_control_cache_flush()) + _E("Failed to flush cache"); + } + } else if (current_angle == 270) { + if (cur_x > h && cur_x < (volume_control_get_viewport_width() - y) && cur_y > x && cur_y < w) + _D("touched inside"); + else { + _D("current angle : %d / touched outside ", current_angle); + if (VOLUME_ERROR_OK != volume_control_hide_view()) + _E("Failed to close volume"); + + if (VOLUME_ERROR_OK != volume_control_cache_flush()) + _E("Failed to flush cache"); + } + } else { + if (x < cur_x && cur_x < w && y < cur_y && cur_y < h) + _D("current angle : %d / touched inside", current_angle); + else { + _D("current angle : %d / touched outside ", current_angle); + if (VOLUME_ERROR_OK != volume_control_hide_view()) + _E("Failed to close volume"); + + if (VOLUME_ERROR_OK != volume_control_cache_flush()) + _E("Failed to flush cache"); + } + } +} + +static Eina_Bool _event_handler_cb(void *data, int type, void *event_info) +{ + _D("%s", __func__); + + Ecore_X_Event_Generic *e = (Ecore_X_Event_Generic *)event_info; + retv_if(e->evtype != XI_RawMotion, ECORE_CALLBACK_DONE); + + if (x_event_info.is_first_touch == EINA_TRUE) { + x_event_info.is_first_touch = EINA_FALSE; + return ECORE_CALLBACK_DONE; + } + x_event_info.is_first_touch = EINA_TRUE; + + int cur_x = 0, cur_y = 0; + ecore_x_pointer_xy_get(ecore_x_window_root_first_get(), &cur_x, &cur_y); + _D("cur_x : %d / cur_y : %d", cur_x, cur_y); + + _x_touch_check(cur_x, cur_y); + + return ECORE_CALLBACK_DONE; +} +