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.
23 *@defgroup setting-ringtone
24 *UG creation code for setting-ringtone
28 #include <setting-ringtone.h>
29 #include <setting-ringtone-util.h>
32 #define UG_MODULE_API __attribute__ ((visibility("default")))
35 bool __parse_ug_argument(app_control_h service, void *priv)
38 SettingRingtoneUG *ad = priv;
41 app_control_get_extra_data(service, "marked_mode", &(ad->file_path));
42 setting_retvm_if(!ad->file_path, FALSE, "no arguement to specialize file");
45 app_control_get_extra_data(service, "path", &(ad->dir_path));
46 setting_retvm_if(!ad->dir_path, FALSE, "no arguement to specialize file");
49 app_control_get_extra_data(service, "silent", &silent);
50 if (!safeStrCmp(silent , "silent show")) {
51 ad->is_show_silent = 1;
54 char *default_str = NULL;
55 app_control_get_extra_data(service, "default", &default_str);
56 if (!safeStrCmp(default_str , "default show")) {
60 SETTING_TRACE("dir path: %s", ad->dir_path);
61 SETTING_TRACE("current file path: %s", ad->file_path);
62 SETTING_TRACE("show silent: %d", ad->is_show_silent);
67 * Event process when the sizeof UG view changes
74 static void setting_ringtone_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
77 SettingRingtoneUG *ad = (SettingRingtoneUG *) data;
78 setting_view_update(&setting_view_ringtone_main, ad);
82 * on_create function of the UG
91 static void *setting_ringtone_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
92 app_control_h service, void *priv)
95 setting_retvm_if((NULL == priv), NULL, "NULL == priv");
96 SettingRingtoneUG *ringtoneUG = priv;
99 ringtoneUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
100 ringtoneUG->win_get = (Evas_Object *) ug_get_window();
101 evas_object_show(ringtoneUG->win_main_layout);
102 ringtoneUG->evas = evas_object_evas_get(ringtoneUG->win_main_layout);
104 setting_retvm_if(ringtoneUG->win_main_layout == NULL, NULL,
105 "cannot get main window ");
107 /* creating a view. */
108 if (!__parse_ug_argument(service, priv)) {
109 SETTING_TRACE_ERROR("Invalid arguement");
113 if (0 != app_control_clone(&(ringtoneUG->source_svc), service)) {
114 SETTING_TRACE_ERROR("failed to clone svc");
117 setting_view_create(&setting_view_ringtone_main, (void *)ringtoneUG);
118 evas_object_event_callback_add(ringtoneUG->win_main_layout,
119 EVAS_CALLBACK_RESIZE,
120 setting_ringtone_ug_cb_resize, ringtoneUG);
121 return ringtoneUG->ly_main;
124 static void setting_ringtone_ug_on_start(ui_gadget_h ug, app_control_h service,
129 static void setting_ringtone_ug_on_pause(ui_gadget_h ug, app_control_h service,
135 static void setting_ringtone_ug_on_resume(ui_gadget_h ug, app_control_h service,
142 * on_destroy function of the UG
148 static void setting_ringtone_ug_on_destroy(ui_gadget_h ug, app_control_h service,
152 setting_retm_if((!priv), "!priv");
153 SettingRingtoneUG *ringtoneUG = priv;
155 evas_object_event_callback_del(ringtoneUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_ringtone_ug_cb_resize); /* fix flash issue for gallery */
157 /* delete the allocated objects. */
158 setting_view_destroy(&setting_view_ringtone_main, ringtoneUG);
160 if (ringtoneUG->source_svc) {
161 app_control_destroy(ringtoneUG->source_svc);
162 ringtoneUG->source_svc = NULL;
165 if (NULL != ug_get_layout(ringtoneUG->ug)) {
166 evas_object_hide((Evas_Object *) ug_get_layout(ringtoneUG->ug));
167 evas_object_del((Evas_Object *) ug_get_layout(ringtoneUG->ug));
173 static void setting_ringtone_ug_on_message(ui_gadget_h ug, app_control_h msg,
174 app_control_h service, void *priv)
179 static void setting_ringtone_ug_on_event(ui_gadget_h ug, enum ug_event event,
180 app_control_h service, void *priv)
184 case UG_EVENT_LOW_MEMORY:
186 case UG_EVENT_LOW_BATTERY:
188 case UG_EVENT_LANG_CHANGE:
190 case UG_EVENT_ROTATE_PORTRAIT:
192 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
194 case UG_EVENT_ROTATE_LANDSCAPE:
196 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
198 case UG_EVENT_REGION_CHANGE:
205 static void setting_ringtone_ug_on_key_event(ui_gadget_h ug,
206 enum ug_key_event event,
207 app_control_h service, void *priv)
210 SettingRingtoneUG *ad = (SettingRingtoneUG *) priv;
213 case UG_KEY_EVENT_END: {
214 if (elm_naviframe_top_item_get(ad->navi_bar) ==
215 elm_naviframe_bottom_item_get(ad->navi_bar)) {
218 /* elm_naviframe_item_pop(ad->navi_bar); */
219 setting_view_cb_at_endKey(ad);
228 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
231 SettingRingtoneUG *ringtoneUG = calloc(1, sizeof(SettingRingtoneUG));
232 setting_retvm_if(!ringtoneUG, -1, "Create SettingRingtoneUG obj failed");
234 ops->create = setting_ringtone_ug_on_create;
235 ops->start = setting_ringtone_ug_on_start;
236 ops->pause = setting_ringtone_ug_on_pause;
237 ops->resume = setting_ringtone_ug_on_resume;
238 ops->destroy = setting_ringtone_ug_on_destroy;
239 ops->message = setting_ringtone_ug_on_message;
240 ops->event = setting_ringtone_ug_on_event;
241 ops->key_event = setting_ringtone_ug_on_key_event;
242 ops->priv = ringtoneUG;
243 ops->opt = UG_OPT_INDICATOR_ENABLE;
248 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
251 struct SettingRingtoneUG *ringtoneUG;
252 setting_retm_if(!ops, "ops == NULL");
254 ringtoneUG = ops->priv;
260 /* ***************************************************
264 ****************************************************/