+/*
+ * 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.
+ */
+
+#include <vconf.h>
+#include <vconf-keys.h>
+#include <app_manager.h>
+#include <efl_assist.h>
+
+#include "main.h"
+#include "_util_efl.h"
+#include "_util_log.h"
+#include "view.h"
+#include "control.h"
+#include "sound.h"
+#include "timer.h"
+#include "x_event.h"
+#include "key_event.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 {
+ 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;
+
+ int current_angle;
+ int viewport_width;
+ int viewport_height;
+
+ sound_type_e sound_type_at_show;
+} s_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,
+
+ .current_angle = 0,
+ .viewport_width = 0,
+ .viewport_height= 0,
+
+ .sound_type_at_show = SOUND_TYPE_RINGTONE,
+};
+
+static void _rotate_changed_cb(void *data, Evas_Object *obj, void *event_info);
+static Eina_Bool _shape_cb(void *data);
+
+bundle* volume_control_reset_bundle_get(void)
+{
+ return s_info.volume_bundle;
+}
+
+Eina_Bool volume_control_is_deleting_get(void)
+{
+ return s_info.is_deleting;
+}
+
+Eina_Bool volume_control_is_launching_get(void)
+{
+ return s_info.is_launching;
+}
+
+int volume_control_current_angle_get(void)
+{
+ return s_info.current_angle;
+}
+
+sound_type_e volume_control_sound_type_at_show_get(void)
+{
+ return s_info.sound_type_at_show;
+}
+
+int volume_control_viewport_height_get()
+{
+ return s_info.viewport_height;
+}
+
+int volume_control_viewport_width_get()
+{
+ return s_info.viewport_width;
+}
+
+Eina_Bool volume_control_viewport_is_warning_visible()
+{
+ return s_info.is_warning_visible;
+}
+
+//int _cache_flush(void *data)
+volume_error_e volume_control_cache_flush(void)
+{
+ Evas_Object *win = volume_view_win_get();
+ retv_if(win == NULL, VOLUME_ERROR_FAIL);
+
+ Evas *evas = NULL;
+ int file_cache = -1;
+ int collection_cache = -1;
+ int image_cache = -1;
+ int font_cache = -1;
+
+ evas = evas_object_evas_get(win);
+ retv_if(!evas, VOLUME_ERROR_FAIL);
+
+ file_cache = edje_file_cache_get();
+ collection_cache = edje_collection_cache_get();
+ image_cache = evas_image_cache_get(evas);
+ font_cache = evas_font_cache_get(evas);
+
+ edje_file_cache_set(file_cache);
+ edje_collection_cache_set(collection_cache);
+ evas_image_cache_set(evas, 0);
+ evas_font_cache_set(evas, 0);
+
+ evas_image_cache_flush(evas);
+ evas_render_idle_flush(evas);
+ evas_font_cache_flush(evas);
+
+ edje_file_cache_flush();
+ edje_collection_cache_flush();
+
+ edje_file_cache_set(file_cache);
+ edje_collection_cache_set(collection_cache);
+ evas_image_cache_set(evas, image_cache);
+ evas_font_cache_set(evas, font_cache);
+
+ return VOLUME_ERROR_OK;
+}
+
+/* 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)
+ {
+ _E("Failed to create app control");
+ return VOLUME_ERROR_FAIL;
+ }
+
+ ret = app_control_set_app_id(app_control, pkgname);
+ if (ret != 0)
+ {
+ _E("Failed to set appid");
+ app_control_destroy(app_control);
+ return VOLUME_ERROR_FAIL;
+ }
+
+ ret = app_control_add_extra_data(app_control, op_type, operation);
+ if (ret != 0)
+ {
+ _E("Failed to add extra data");
+ app_control_destroy(app_control);
+ return VOLUME_ERROR_FAIL;
+ }
+
+ ret = app_control_send_launch_request(app_control, NULL, NULL);
+ _D("launch app with service : [%s][%d]", pkgname, ret);
+
+ app_control_destroy(app_control);
+
+ return VOLUME_ERROR_OK;
+}
+
+//int _get_vconf_idlelock
+int volume_control_vconf_idlelock_get(void)
+{
+ int lock = IDLELOCK_OFF;
+ int pm_state = VCONFKEY_PM_STATE_NORMAL;
+
+ /* Check Idle-Lock */
+ if(vconf_get_int(VCONFKEY_IDLE_LOCK_STATE, &lock) < 0)
+ {
+ _E("Failed to get vconfkey : VCONFKEY_IDLE_LOCK_STATE");
+ return IDLELOCK_ERROR;
+ }
+ _D("idlelock vconf : %d", lock);
+
+ /* Check PM state */
+ if(vconf_get_int(VCONFKEY_PM_STATE, &pm_state) < 0)
+ {
+ _E("Failed to get vconfkey : VCONFKEY_PM_STATE");
+ return IDLELOCK_ERROR;
+ }
+ _D("PM STATE vconf : %d", pm_state);
+
+ return (lock == VCONFKEY_IDLE_LOCK ||
+ pm_state == VCONFKEY_PM_STATE_LCDOFF ||
+ pm_state == VCONFKEY_PM_STATE_SLEEP
+ ) ? IDLELOCK_ON : IDLELOCK_OFF;
+}
+
+
+int volume_control_status_check(int *lock, sound_type_e *sound_type)
+{
+ *lock = volume_control_vconf_idlelock_get();
+ *sound_type = volume_sound_sound_manager_type_get();
+ _D("lock : %d / sound_type : %d", *lock, *sound_type);
+
+ if(*lock == IDLELOCK_ON)
+ {
+ if(*sound_type == SOUND_TYPE_RINGTONE)
+ {
+ _D("IDLELOCK is ON / sound type is Ringtone");
+ return LOCK_AND_NOT_MEDIA;
+ }
+
+ if(*sound_type != SOUND_TYPE_RINGTONE)
+ {
+ _D("IDLELOCK is ON / sound type is not Ringtone(media or alaram)");
+ return LOCK_AND_MEDIA;
+ }
+ }
+
+ _D("IDLELOCK is OFF / normal case");
+
+ return UNLOCK_STATUS;
+}
+
+static Eina_Bool _idler_top_position_grab(void *data)
+{
+ 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);
+}
+
+void volume_control_show_hide_worning()
+{
+ Evas_Object *ly_outer = volume_view_outer_layout_get();
+ sound_type_e sound_type = volume_sound_sound_manager_type_get();
+ int volume = volume_sound_sound_manager_volume_get(sound_type);
+
+ if(sound_type == SOUND_TYPE_MEDIA
+ && volume>VOLUME_MAX_SAFETY_VOLUME_LEVEL)
+ {
+ if(!s_info.is_warning_visible)
+ {
+ s_info.is_warning_visible = EINA_TRUE;
+
+ if(s_info.current_angle == 90 || s_info.current_angle == 270)
+ {
+ elm_object_signal_emit(ly_outer, "show_warning_l", "clipper"); //landscape
+ }
+ else
+ {
+ elm_object_signal_emit(ly_outer, "show_warning", "clipper"); //landscape
+ }
+
+ volume_control_event_shape(EINA_TRUE);
+ }
+ }
+ else if(s_info.is_warning_visible)
+ {
+ s_info.is_warning_visible = EINA_FALSE;
+
+ if(s_info.current_angle == 90 || s_info.current_angle == 270)
+ {
+ elm_object_signal_emit(ly_outer, "hide_warning_l", "clipper"); //landscape
+ }
+ else
+ {
+ elm_object_signal_emit(ly_outer, "hide_warning", "clipper"); //landscape
+ }
+
+ volume_control_event_shape(EINA_FALSE);
+ }
+}
+
+Eina_Bool volume_control_show(void)
+{
+ 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;
+ Evas_Object *win = NULL;
+ sound_type_e sound_type = 0;
+
+ retv_if(s_info.is_deleting, EINA_FALSE);
+
+ s_info.is_new = EINA_TRUE;
+
+ win = volume_view_win_get();
+ retv_if(!win, EINA_FALSE);
+
+ 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)
+ {
+ _D("Lock and Not Media");
+ if(evas_object_visible_get(win))
+ {
+ 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 EINA_FALSE;
+ }
+ else if(status != LOCK_AND_NOT_MEDIA)
+ {
+ if(status == UNLOCK_STATUS)
+ {
+ /* Show volume window */
+ if(VOLUME_ERROR_OK != volume_view_window_show())
+ {
+ _E("Failed to show volume window");
+ }
+
+ /* register outer window event */
+ 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);
+ }
+
+ if(once)
+ {
+ ecore_idler_add(_idler_top_position_grab, NULL);
+ once = EINA_FALSE;
+ }
+ }
+
+ s_info.is_launching = EINA_TRUE;
+
+ int volume = volume_sound_sound_manager_volume_get(sound_type);
+ _D("volume : %d", volume);
+
+ 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);
+
+ 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");
+ }
+
+ /* Set Volume icon */
+ //@TODO: need to check
+ volume_view_volume_icon_set(sound_type, sound, vibration);
+
+ if(!s_info.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);
+ }
+
+ return EINA_TRUE;
+ }
+
+ return EINA_FALSE;
+}
+
+//_close_volume(ad);
+volume_error_e volume_control_close(void)
+{
+ retv_if(volume_control_is_deleting_get(), VOLUME_ERROR_FAIL);
+
+ _D("Start closing volume");
+
+ int i = 0;
+ int count_grabed = volume_key_event_count_grabed_get();
+
+ Ecore_X_Window input_win = volume_key_event_input_window_get();
+ retv_if(!input_win, VOLUME_ERROR_FAIL);
+
+ s_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;
+// return VOLUME_ERROR_FAIL;
+ }
+
+ 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))
+ {
+ _E("Failed to grab key : SHARED_GRAB");
+ }
+
+ volume_timer_del(TYPE_TIMER_SU);
+ volume_timer_del(TYPE_TIMER_SD);
+ volume_timer_del(TYPE_TIMER_SLIDER);
+ volume_timer_del(TYPE_TIMER_POPUP);
+
+ /* hide window */
+ 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;
+
+ _D("End closing volume");
+
+ 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)
+{
+ /* 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)
+ {
+ _E("Failed to register callback function : VCONFKEY_STARTER_USE_VOLUME_KEY");
+ }
+
+ /* Lock screen status vconf changed callback */
+ if(vconf_notify_key_changed(VCONFKEY_IDLE_LOCK_STATE, _idle_lock_state_vconf_changed_cb, NULL) != 0)
+ {
+ _E("Failed to notify vconfkey : VCONFKEY_IDLE_LOCK_STATE");
+ }
+
+ if (vconf_notify_key_changed(VCONFKEY_PM_LCDOFF_SOURCE, _notify_pm_lcdoff_cb, NULL) != 0) {
+ _E("Failed to notify vconfkey : VCONFKEY_PM_LCDOFF_SOURCE");
+ }
+}
+
+void volume_control_vconfkey_unregister(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)
+ {
+ _E("Failed to ignore vconfkey : VCONFKEY_STARTER_USE_VOLUME_KEY");
+ }
+
+ /* Lock screen status vconf changed callback */
+ if(vconf_ignore_key_changed(VCONFKEY_IDLE_LOCK_STATE, _idle_lock_state_vconf_changed_cb) < 0)
+ {
+ _E("Failed to ignore vconfkey : VCONFKEY_IDLE_LOCK_STATE");
+ }
+
+ if (vconf_ignore_key_changed
+ (VCONFKEY_PM_LCDOFF_SOURCE, _notify_pm_lcdoff_cb) != 0) {
+ _E("Fail vconf_ignore_key_changed : VCONFKEY_PM_LCDOFF_SOURCE");
+ }
+}
+
+//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())
+ {
+ _E("Failed to close volume");
+ }
+
+ if(VOLUME_ERROR_OK != volume_control_cache_flush())
+ {
+ _E("Failed to flush cache");
+ }
+ }
+
+ 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");
+ Evas_Object *win = volume_view_win_get();
+ retv_if(!win, VOLUME_ERROR_FAIL);
+
+ int ret = -1;
+ int lock = IDLELOCK_ON;
+
+ 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;
+ }
+
+ sound_type_e sound_type = volume_sound_sound_manager_type_get();
+ _D("sound type : %d", sound_type);
+
+ int volume = volume_sound_sound_manager_volume_get(sound_type);
+ _D("volume : %d", volume);
+
+ const char *show_volume = bundle_get_val(b, SHOWVOLUME);
+ retv_if(!show_volume, VOLUME_ERROR_FAIL);
+
+ if(!strncasecmp(show_volume, ISTRUE, strlen(ISTRUE)))
+ {
+ _D("Bundle : %s", show_volume);
+ if(lock == IDLELOCK_OFF)
+ {
+ _D("Show Volume");
+ volume_timer_add(3.0, TYPE_TIMER_POPUP);
+ volume_control_show();
+ }
+ }
+
+ return VOLUME_ERROR_OK;
+}
+
+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();
+ retv_if(!win, VOLUME_ERROR_FAIL);
+
+ /* Create input_window */
+ if(VOLUME_ERROR_OK != volume_key_event_input_window_create()) {
+ _E("Failed to create input window");
+ return VOLUME_ERROR_FAIL;
+ }
+
+ /* Create volume layout */
+ if(VOLUME_ERROR_OK != volume_view_layout_create(win)) {
+ _E("Failed to create volume layout");
+ return VOLUME_ERROR_FAIL;
+ }
+
+ ecore_x_window_size_get(ecore_x_window_root_first_get(), &(s_info.viewport_width), &(s_info.viewport_height));
+
+
+ /* Set available rotations */
+ _control_window_rotation_set(win);
+
+ /* Register vconfkey changed callback
+ * : VCONFKEY_STARTER_USE_VOLUME_KEY
+ * : VCONFKEY_IDLE_LOCK_STATE
+ * : VCONFKEY_LOCKSCREEN_SVIEW_STATE
+ * */
+ volume_control_vconfkey_register();
+
+ /* Register vconfkey changed callback
+ * : VCONFKEY_SETAPPL_SOUND_STATUS_BOOL
+ * : VCONFKEY_SETAPPL_VIBRATION_STATUS_BOOL
+ * */
+ volume_sound_vconfkey_register();
+
+ /* 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);
+
+ return VOLUME_ERROR_OK;
+}
+
+void volume_control_deinitialize(void)
+{
+ /* Unregister vconfkey changed callback */
+ volume_control_vconfkey_unregister();
+
+ /* Unregister sound vconfkey changed callback */
+ volume_sound_vconfkey_unregister();
+}
+
+static Eina_Bool _shape_cb(void *data)
+{
+ LOGD("Mik");
+ volume_control_event_shape(s_info.is_warning_visible);
+ s_info.shape_timer = NULL;
+ return ECORE_CALLBACK_CANCEL;
+}