2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
19 #include "cst-common.h"
20 #include "cst-common-string.h"
21 #include "cst-status-tone.h"
22 #include "cst-widget.h"
25 static void __cst_set_gl_item_styles_call_status_tone(void);
26 static void __cst_destroy_genlist_item_styles(void);
27 static void __cst_click_call_status_tone_onoff(void *data, Evas *evas, Evas_Object *obj, void *event_info);
28 static void __cst_on_click_call_status_tone_back_button(void *data, Evas_Object *obj, void *event_info);
30 static Elm_Genlist_Item_Class *itc_1text_1icon = NULL;
31 static Elm_Genlist_Item_Class *itc_help = NULL;
32 static Evas_Object *callstatustone_gl = NULL;
34 static CstGlItemDisplayInfo_t list_call_status_tone[] = {
35 {1, CST_STR_CALL_CONNECT_TONE, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF, __cst_click_call_status_tone_onoff},
36 {1, CST_STR_THERE_WILL_BE_WEHN_LINE_IS_CONNECTED, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_HELP_TEXT, NULL},
37 {1, CST_STR_MINUTE_REMINDER, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF, __cst_click_call_status_tone_onoff},
38 {1, CST_STR_THERE_WILL_BE_EVERY_A_MINUTE, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_HELP_TEXT, NULL},
39 {1, CST_STR_CALL_END_TONE, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_1TEXT_ONOFF, __cst_click_call_status_tone_onoff},
40 {1, CST_STR_THERE_WILL_BE_WEHN_LINE_IS_DISCONNECTED, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_HELP_TEXT, NULL},
41 {1, -1, ELM_GENLIST_ITEM_NONE, CST_GL_ITEM_NONE, NULL},
44 static void __cst_destroy_genlist_item_styles(void)
46 ENTER(__cst_destroy_genlist_item_styles);
48 if (itc_1text_1icon) {
49 elm_genlist_item_class_free(itc_1text_1icon);
50 itc_1text_1icon = NULL;
53 elm_genlist_item_class_free(itc_help);
58 static void __cst_on_click_call_status_tone_back_button(void *data, Evas_Object *obj, void *event_info)
60 ENTER(__cst_on_click_call_status_tone_back_button);
62 _cst_destroy_call_status_tone();
65 static void __cst_click_call_status_tone_onoff(void *data, Evas *evas, Evas_Object *obj, void *event_info)
68 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
69 Eina_Bool check_state = elm_check_state_get(item_data->eo_check);
71 if (CST_STR_CALL_CONNECT_TONE == list_call_status_tone[item_data->index].str_id) {
72 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL, !check_state);
73 } else if (CST_STR_MINUTE_REMINDER == list_call_status_tone[item_data->index].str_id) {
74 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_MINUTE_MINDER_BOOL, !check_state);
75 } else if (CST_STR_CALL_END_TONE == list_call_status_tone[item_data->index].str_id) {
76 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_CALL_END_TONE_BOOL, !check_state);
78 elm_genlist_item_update(item_data->gl_item);
81 static void __cst_changed_call_connect_tone(void *data, Evas_Object *obj, void *event_info)
83 Eina_Bool check_state;
84 check_state = elm_check_state_get(obj);
85 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL, check_state);
88 static void __cst_changed_minute_minder(void *data, Evas_Object *obj, void *event_info)
90 Eina_Bool check_state;
91 check_state = elm_check_state_get(obj);
93 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_MINUTE_MINDER_BOOL, check_state);
96 static void __cst_changed_call_end_tone(void *data, Evas_Object *obj, void *event_info)
98 Eina_Bool check_state;
99 check_state = elm_check_state_get(obj);
101 _cst_vconf_set_bool(VCONFKEY_CISSAPPL_CALL_END_TONE_BOOL, check_state);
104 static char *__cst_gl_label_get_call_status_tone(void *data, Evas_Object *obj, const char *part)
106 retv_if(NULL == data, NULL);
107 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
109 if (!strcmp(part, "elm.text") ||
110 !strcmp(part, "elm.text.1") ||
111 !strcmp(part, "elm.text.2")) {
112 if (list_call_status_tone[item_data->index].str_id != -1) {
113 return strdup(T_(list_call_status_tone[item_data->index].str_id));
119 static Evas_Object *__cst_gl_icon_get_call_status_tone(void *data, Evas_Object *obj, const char *part)
121 retv_if(NULL == data, NULL);
122 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
124 if (!strcmp(part, "elm.icon")) {
126 if (CST_STR_CALL_CONNECT_TONE == list_call_status_tone[item_data->index].str_id) {
127 _cst_vconf_get_bool(VCONFKEY_CISSAPPL_CALL_CONNECT_TONE_BOOL, &value);
128 item_data->eo_check = _cst_create_onoff_button(obj, value,
129 __cst_changed_call_connect_tone, item_data);
130 } else if (CST_STR_MINUTE_REMINDER == list_call_status_tone[item_data->index].str_id) {
131 _cst_vconf_get_bool(VCONFKEY_CISSAPPL_MINUTE_MINDER_BOOL, &value);
132 item_data->eo_check = _cst_create_onoff_button(obj, value,
133 __cst_changed_minute_minder, item_data);
134 } else if (CST_STR_CALL_END_TONE == list_call_status_tone[item_data->index].str_id) {
135 _cst_vconf_get_bool(VCONFKEY_CISSAPPL_CALL_END_TONE_BOOL, &value);
136 item_data->eo_check = _cst_create_onoff_button(obj, value,
137 __cst_changed_call_end_tone, item_data);
139 return item_data->eo_check;
144 static void __cst_gl_del_call_status_tone(void *data, Evas_Object *obj)
146 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
153 static void __cst_gl_sel_call_status_tone(void *data, Evas_Object *obj, void *event_info)
155 ENTER(__cst_gl_sel_call_status_tone);
156 ret_if(data == NULL);
157 CstGlItemData_t *item_data = (CstGlItemData_t *)data;
158 elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
160 if (list_call_status_tone[item_data->index].func) {
161 list_call_status_tone[item_data->index].func((void *)item_data, NULL, obj, event_info);
166 static void __cst_set_gl_item_styles_call_status_tone(void)
168 ENTER(__cst_set_gl_item_styles_call_status_tone);
169 if (!itc_1text_1icon) {
170 itc_1text_1icon = elm_genlist_item_class_new();
173 itc_help = elm_genlist_item_class_new();
176 itc_1text_1icon->item_style = "dialogue/1text.1icon";
177 itc_1text_1icon->func.text_get = __cst_gl_label_get_call_status_tone;
178 itc_1text_1icon->func.content_get = __cst_gl_icon_get_call_status_tone;
179 itc_1text_1icon->func.state_get = NULL;
180 itc_1text_1icon->func.del = __cst_gl_del_call_status_tone;
182 itc_help->item_style = "multiline/1text";
183 itc_help->func.text_get = __cst_gl_label_get_call_status_tone;
184 itc_help->func.content_get = NULL;
185 itc_help->func.state_get = NULL;
186 itc_help->func.del = __cst_gl_del_call_status_tone;
189 static Evas_Object *__cst_create_call_status_tone_genlist(void *data)
191 ENTER(__cst_create_call_status_tone_genlist);
192 retv_if(NULL == data, NULL);
193 CstUgData_t *ugd = (CstUgData_t *)data;
195 Evas_Object *genlist;
196 Elm_Object_Item *item;
197 CstGlItemData_t *item_data;
199 genlist = elm_genlist_add(ugd->nf);
201 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
202 _cst_create_genlist_separator(genlist, EINA_FALSE);
203 for (index = 0; list_call_status_tone[index].style != CST_GL_ITEM_NONE; ++index) {
204 item_data = (CstGlItemData_t *)calloc(1, sizeof(CstGlItemData_t));
205 retv_if(NULL == item_data, NULL);
207 item_data->index = index;
208 item_data->ugd = ugd;
209 if (list_call_status_tone[index].style == CST_GL_ITEM_1TEXT_ONOFF) {
210 _cst_create_genlist_underline(genlist);
211 item = elm_genlist_item_append(genlist, itc_1text_1icon,
212 (void *)item_data, NULL, list_call_status_tone[index].flags,
213 __cst_gl_sel_call_status_tone, item_data);
214 } else if (list_call_status_tone[index].style == CST_GL_ITEM_HELP_TEXT) {
215 item = elm_genlist_item_append(genlist, itc_help,
216 (void *)item_data, NULL, list_call_status_tone[index].flags,
218 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
219 _cst_create_genlist_separator_no_line(genlist);
226 item_data->gl_item = item;
228 _cst_create_genlist_separator_no_line(genlist);
233 static void __cst_create_call_status_tone(Evas_Object *parent, void *data)
235 ENTER(__cst_create_call_status_tone);
236 CstUgData_t *ugd = data;
237 Evas_Object *back_btn = NULL;
238 Elm_Object_Item *navi_it;
241 __cst_set_gl_item_styles_call_status_tone();
242 callstatustone_gl = __cst_create_call_status_tone_genlist(ugd);
244 navi_it = elm_naviframe_item_push(ugd->nf, T_(CST_STR_CALL_STATUS_TONES), NULL, NULL, callstatustone_gl, NULL);
246 back_btn = elm_object_item_part_content_get(navi_it, "prev_btn");
247 evas_object_smart_callback_add(back_btn, "clicked", __cst_on_click_call_status_tone_back_button, ugd);
250 void _cst_on_click_call_status_tone(void *data, Evas *evas, Evas_Object *obj, void *event_info)
252 ENTER(_cst_on_click_call_status_tone);
253 ret_if(NULL == data);
254 CstUgData_t *ugd = (CstUgData_t *)data;
255 __cst_create_call_status_tone(ugd->nf, ugd);
258 void _cst_destroy_call_status_tone(void)
260 ENTER(_cst_destroy_call_status_tone);
262 __cst_destroy_genlist_item_styles();
264 if (callstatustone_gl != NULL) {
265 elm_genlist_clear(callstatustone_gl);
266 evas_object_del(callstatustone_gl);
267 callstatustone_gl = NULL;