3 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * Licensed under the Flora License, Version 1.0 (the License);
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://floralicense.org/license/
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an AS IS BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
17 #include <setting-storage.h>
19 #define UG_MODULE_API __attribute__ ((visibility("default")))
22 static void setting_storage_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
25 SettingStorageUG *ad = (SettingStorageUG *) data;
26 setting_view_update(&setting_view_storage_main, ad);
29 static void *setting_storage_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
30 service_h service, void *priv)
32 setting_retvm_if((!ug || !priv), NULL, "!ug || !priv");
34 int ret = media_content_connect();
35 if(ret == MEDIA_CONTENT_ERROR_NONE) {
36 SETTING_TRACE("media_content_connect is success");
38 SETTING_TRACE_ERROR("media_content_connect is failed");
42 SettingStorageUG *storageUG = priv;
44 storageUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
45 storageUG->win_get = (Evas_Object *) ug_get_window();
46 evas_object_show(storageUG->win_main_layout);
47 storageUG->evas = evas_object_evas_get(storageUG->win_main_layout);
49 setting_retvm_if(storageUG->win_main_layout == NULL, NULL, "cannot get main window ");
51 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
53 /* register view node table */
54 setting_view_node_table_intialize();
55 setting_view_node_table_register(&setting_view_storage_main, NULL);
56 setting_view_node_table_register(&setting_view_storage_default_storage,
57 &setting_view_storage_main);
58 setting_view_node_table_register(&setting_view_storage_miscellaneous_files,
59 &setting_view_storage_main);
61 storageUG->itc_seperator.item_style = "dialogue/separator";
62 storageUG->itc_seperator.func.text_get = NULL;
63 storageUG->itc_seperator.func.content_get = NULL;
64 storageUG->itc_seperator.func.state_get = NULL;
65 storageUG->itc_seperator.func.del = NULL;
67 setting_create_Gendial_itc("dialogue/2text.3/expandable", &(storageUG->itc_2text_3_parent));
68 setting_create_Gendial_itc("dialogue/1text.1icon/expandable2", &(storageUG->itc_1icon_1text_sub));
69 setting_create_Gendial_itc("dialogue/2text.3", &(storageUG->itc_2text_2));
70 setting_create_Gendial_itc("dialogue/1text.1icon.2", &(storageUG->itc_1text_1icon_2));
71 setting_create_Gendial_itc("dialogue/title", &(storageUG->itc_group_item));
72 setting_create_Gendial_itc("multiline/1text", &(storageUG->itc_bg_1icon));
73 setting_create_Gendial_itc("dialogue/2text.1icon.3", &(storageUG->itc_2text_1icon_3));
74 setting_create_Gendial_itc("dialogue/1text", &(storageUG->itc_1text));
75 setting_create_Gendial_itc("1text.1icon.3", &(storageUG->itc_1text_1icon));
77 /* creating a view. */
78 setting_view_node_set_cur_view(&setting_view_storage_main);
79 setting_view_create(&setting_view_storage_main, (void *)storageUG);
80 evas_object_event_callback_add(storageUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_storage_ug_cb_resize, storageUG);
81 return storageUG->ly_main;
84 static void setting_storage_ug_on_start(ui_gadget_h ug, service_h service,
89 static void setting_storage_ug_on_pause(ui_gadget_h ug, service_h service,
94 static void setting_storage_ug_on_resume(ui_gadget_h ug, service_h service,
98 setting_retm_if((!ug || !priv), "!ug || !priv");
99 SettingStorageUG *storageUG = priv;
101 setting_view_update(&setting_view_storage_main, storageUG);
104 static void setting_storage_ug_on_destroy(ui_gadget_h ug, service_h service,
108 setting_retm_if((!ug || !priv), "!ug || !priv");
109 SettingStorageUG *storageUG = priv;
111 int ret = media_content_disconnect();
112 if (ret == MEDIA_CONTENT_ERROR_NONE) {
113 SETTING_TRACE("media_content_disconnect is success");
115 SETTING_TRACE_ERROR("media_content_disconnect is failed");
118 evas_object_event_callback_del(storageUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_storage_ug_cb_resize); /* fix flash issue for gallery */
121 /* delete the allocated objects. */
122 setting_view_destroy(&setting_view_storage_miscellaneous_files, storageUG);
123 setting_view_destroy(&setting_view_storage_default_storage, storageUG);
124 setting_view_destroy(&setting_view_storage_main, storageUG);
126 if (NULL != ug_get_layout(storageUG->ug)) {
127 evas_object_hide((Evas_Object *) ug_get_layout(storageUG->ug));
128 evas_object_del((Evas_Object *) ug_get_layout(storageUG->ug));
134 static void setting_storage_ug_on_message(ui_gadget_h ug, service_h msg,
135 service_h service, void *priv)
140 static void setting_storage_ug_on_event(ui_gadget_h ug, enum ug_event event,
141 service_h service, void *priv)
144 setting_retm_if(priv == NULL, "priv is NULL");
145 SettingStorageUG *ad = (SettingStorageUG *)priv;
148 case UG_EVENT_LOW_MEMORY:
150 case UG_EVENT_LOW_BATTERY:
152 case UG_EVENT_LANG_CHANGE:
154 case UG_EVENT_ROTATE_PORTRAIT:
155 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
157 SETTING_TRACE("UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN");
159 if (ad->internal->eo_check) {
160 evas_object_del(ad->internal->eo_check);
161 ad->internal->eo_check = NULL;
163 elm_object_item_data_set(ad->internal->item, ad->internal);
164 elm_genlist_item_update(ad->internal->item);
168 case UG_EVENT_ROTATE_LANDSCAPE:
169 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
171 SETTING_TRACE("UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN");
173 if (ad->internal->eo_check) {
174 evas_object_del(ad->internal->eo_check);
175 ad->internal->eo_check = NULL;
177 elm_object_item_data_set(ad->internal->item, ad->internal);
178 elm_genlist_item_update(ad->internal->item);
182 case UG_EVENT_REGION_CHANGE:
189 static void setting_storage_ug_on_key_event(ui_gadget_h ug,
190 enum ug_key_event event, service_h service,
198 case UG_KEY_EVENT_END:
206 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
209 SettingStorageUG *storageUG = calloc(1, sizeof(SettingStorageUG));
210 setting_retvm_if(!storageUG, -1, "Create SettingStorageUG obj failed");
212 ops->create = setting_storage_ug_on_create;
213 ops->start = setting_storage_ug_on_start;
214 ops->pause = setting_storage_ug_on_pause;
215 ops->resume = setting_storage_ug_on_resume;
216 ops->destroy = setting_storage_ug_on_destroy;
217 ops->message = setting_storage_ug_on_message;
218 ops->event = setting_storage_ug_on_event;
219 ops->key_event = setting_storage_ug_on_key_event;
220 ops->priv = storageUG;
221 ops->opt = UG_OPT_INDICATOR_ENABLE;
226 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
229 struct SettingStorageUG *storageUG;
230 setting_retm_if(!ops, "ops == NULL");
232 storageUG = ops->priv;
238 /* ***************************************************
242 ***************************************************/
245 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
247 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
251 int value = SETTING_DEF_MEMORY_PHONE;
252 ret += vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_WAP_INT, value);
253 ret += vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, value);
254 ret += vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_CAMERA_INT, value);
256 ret += vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_VOICE_RECORDER_INT, value);
257 ret += vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_FM_RADIO_INT, value);
258 ret += vconf_set_int(VCONFKEY_SETAPPL_DEFAULT_MEM_DVB_H_INT, value);