4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
22 #include <setting-profile.h>
25 #define UG_MODULE_API __attribute__ ((visibility("default")))
29 static void setting_sound_ug_cb_resize(void *data, Evas *e,
30 Evas_Object *obj, void *event_info)
34 SettingProfileUG *ad = (SettingProfileUG *) data;
35 setting_view_update(&setting_view_sound_main, ad);
38 static void *setting_sound_ug_on_create(ui_gadget_h ug,
39 enum ug_mode mode, app_control_h service,
43 /*appcore_measure_start(); */
44 retv_if(priv == NULL, NULL);
46 SettingProfileUG *profileUG = priv;
49 profileUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
50 profileUG->win_get = (Evas_Object *) ug_get_window();
51 evas_object_show(profileUG->win_main_layout);
52 profileUG->evas = evas_object_evas_get(profileUG->win_main_layout);
53 setting_retvm_if(profileUG->win_main_layout == NULL, NULL, "cannot get main window ");
55 app_control_get_caller(service, &(profileUG->viewtype));
56 setting_sound_init(profileUG);
57 evas_object_event_callback_add(profileUG->win_main_layout,
59 setting_sound_ug_cb_resize, profileUG);
60 return profileUG->ly_main;
63 static void setting_sound_ug_on_start(ui_gadget_h ug, app_control_h service, void *priv)
67 static void setting_sound_ug_on_pause(ui_gadget_h ug, app_control_h service, void *priv)
70 SettingProfileUG *profileUG = (SettingProfileUG *)priv;
72 if (profileUG->calling_popup) {
73 evas_object_del(profileUG->calling_popup);
74 profileUG->calling_popup = NULL;
77 /* if click home key, players have to be closed */
78 setting_sound_close_all_mm_players(profileUG);
80 /* If sound ug is paused, others can use volume HW key popup (set 0) */
81 vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 0);
85 static void setting_sound_ug_on_resume(ui_gadget_h ug, app_control_h service, void *priv)
88 SettingProfileUG *profileUG = (SettingProfileUG *)priv;
90 /* If current view is sound main, block volume app */
91 /* To prevent conflict with volume app */
92 if (!safeStrCmp(profileUG->viewtype, "com.samsung.volume")) {
93 vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 2);
95 vconf_set_int(VCONFKEY_STARTER_USE_VOLUME_KEY, 0);
98 /* update path of tones */
99 char *pa_tone_path = NULL;
101 /* 1. incoming call ringtone */
102 if (profileUG->data_call_alert_tone) {
103 SETTING_TRACE_DEBUG("change call_alert_tone %x", profileUG->data_call_alert_tone);
104 pa_tone_path = vconf_get_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR);
105 if ((pa_tone_path == NULL) || (setting_sound_check_file_exist(profileUG, pa_tone_path) == SETTING_RETURN_FAIL)) {
107 pa_tone_path = (char *)strdup(SETTING_DEFAULT_CALL_TONE_SDK);
109 pa_tone_path = (char *)strdup(SETTING_DEFAULT_CALL_TONE);
110 if (vconf_set_str(VCONFKEY_SETAPPL_CALL_RINGTONE_PATH_STR, pa_tone_path) < 0) {
114 profileUG->data_call_alert_tone->sub_desc = setting_media_basename(pa_tone_path);
115 elm_genlist_item_update(profileUG->data_call_alert_tone->item);
120 /* 2. message ringtone */
121 if (profileUG->data_msg_alert_tone) {
122 SETTING_TRACE_DEBUG("change msg_alert_tone %x", profileUG->data_msg_alert_tone);
123 pa_tone_path = vconf_get_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR);
124 if ((pa_tone_path == NULL) || (setting_sound_check_file_exist(profileUG, pa_tone_path) == SETTING_RETURN_FAIL)) {
125 pa_tone_path = (char *)strdup(SETTING_DEFAULT_MSG_TONE);
126 if (vconf_set_str(VCONFKEY_SETAPPL_NOTI_MSG_RINGTONE_PATH_STR, SETTING_DEFAULT_MSG_TONE) < 0) {
131 profileUG->data_msg_alert_tone->sub_desc = setting_media_basename(pa_tone_path);
132 elm_genlist_item_update(profileUG->data_msg_alert_tone->item);
137 int sound_value = 0, volume = 0;
139 if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &sound_value) < 0)
142 (void)sound_manager_get_volume(SOUND_TYPE_RINGTONE, &volume);
143 if (sound_value == FALSE)
145 if (profileUG->data_call_volume && profileUG->data_call_volume->eo_check) {
146 profileUG->data_call_volume->chk_status = volume;
147 elm_slider_value_set(profileUG->data_call_volume->eo_check, volume);
150 (void)sound_manager_get_volume(SOUND_TYPE_NOTIFICATION, &volume);
151 if (sound_value == FALSE)
153 if (profileUG->data_noti_volume && profileUG->data_noti_volume->eo_check) {
154 profileUG->data_noti_volume->chk_status = volume;
155 elm_slider_value_set(profileUG->data_noti_volume->eo_check, volume);
158 (void)sound_manager_get_volume(SOUND_TYPE_MEDIA, &volume);
159 if (profileUG->data_media_volume && profileUG->data_media_volume->eo_check) {
160 profileUG->data_media_volume->chk_status = volume;
161 elm_slider_value_set(profileUG->data_media_volume->eo_check, volume);
164 (void)sound_manager_get_volume(SOUND_TYPE_SYSTEM, &volume);
165 if (sound_value == FALSE)
167 if (profileUG->data_touch_volume && profileUG->data_touch_volume->eo_check) {
168 profileUG->data_touch_volume->chk_status = volume;
169 elm_slider_value_set(profileUG->data_touch_volume->eo_check, volume);
172 setting_sound_update_slider_icon(profileUG->data_call_volume, SND_SLIDER_CALL);
173 setting_sound_update_slider_icon(profileUG->data_noti_volume, SND_SLIDER_NOTI);
174 setting_sound_update_slider_icon(profileUG->data_media_volume, SND_SLIDER_MEDIA);
175 setting_sound_update_slider_icon(profileUG->data_touch_volume, SND_SLIDER_SYSTEM);
178 static void setting_sound_ug_on_destroy(ui_gadget_h ug, app_control_h service, void *priv)
181 ret_if(priv == NULL);
183 SettingProfileUG *ad = priv;
184 evas_object_event_callback_del(ad->win_main_layout, EVAS_CALLBACK_RESIZE, setting_sound_ug_cb_resize); /* fix flash issue for gallery */
185 setting_sound_deinit(ad);
187 if (NULL != ug_get_layout(ad->ug)) {
188 evas_object_hide((Evas_Object *) ug_get_layout(ad->ug));
189 evas_object_del((Evas_Object *) ug_get_layout(ad->ug));
194 static void setting_sound_ug_on_message(ui_gadget_h ug, app_control_h msg,
195 app_control_h service, void *priv)
199 static void setting_sound_ug_on_event(ui_gadget_h ug,
200 enum ug_event event, app_control_h service, void *priv)
203 /*SettingProfileUG *ad = (SettingProfileUG *)priv; */
206 case UG_EVENT_LOW_MEMORY:
208 case UG_EVENT_LOW_BATTERY:
210 case UG_EVENT_LANG_CHANGE:
212 case UG_EVENT_ROTATE_PORTRAIT:
213 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
215 case UG_EVENT_ROTATE_LANDSCAPE:
216 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
218 case UG_EVENT_REGION_CHANGE:
225 static void setting_sound_ug_on_key_event(ui_gadget_h ug,
226 enum ug_key_event event, app_control_h service, void *priv)
228 ret_if(priv == NULL);
230 /*SettingProfileUG *ad = (SettingProfileUG *) priv; */
233 case UG_KEY_EVENT_END:
240 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
243 /*appcore_measure_start(); */
244 SettingProfileUG *profileUG = calloc(1, sizeof(SettingProfileUG));
245 setting_retvm_if(!profileUG, -1, "Create SettingProfileUG obj failed");
247 ops->create = setting_sound_ug_on_create;
248 ops->start = setting_sound_ug_on_start;
249 ops->pause = setting_sound_ug_on_pause;
250 ops->resume = setting_sound_ug_on_resume;
251 ops->destroy = setting_sound_ug_on_destroy;
252 ops->message = setting_sound_ug_on_message;
253 ops->event = setting_sound_ug_on_event;
254 ops->key_event = setting_sound_ug_on_key_event;
255 ops->priv = profileUG;
256 ops->opt = UG_OPT_INDICATOR_ENABLE;
258 memset(profileUG, 0x00, sizeof(SettingProfileUG));
263 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
267 struct SettingProfileUG *profileUG;
268 profileUG = ops->priv;
273 /* ***************************************************
277 ***************************************************/