2 * Copyright (c) 2012-2013 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.
20 #include <appcore-efl.h>
22 #include <Elementary.h>
23 #include "sat-ui-debug.h"
24 #include "select-item-view.h"
26 #include "sat-ui-icon.h"
28 #include "tel-request.h"
30 #include "common_string.h"
33 static void __sat_ui_select_item_destory_object(void *data,Evas *evas, Evas_Object *obj, void *event_info)
35 evas_object_data_del(obj, "app_data");
36 evas_object_data_del(obj, "tapi_data");
39 static void _gl_sel(void *data, Evas_Object *obj, void *event_info)
42 Evas_Object *waiting_bar;
45 unsigned char selected_item_id;
47 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
49 TelSatSelectItemInd_t *select_item_info;
51 ad = (SatUiAppData_t *)evas_object_data_get(obj, "app_data");
52 select_item_info = (TelSatSelectItemInd_t *)evas_object_data_get(obj, "tapi_data");
55 index = (int)elm_object_item_data_get(item);
56 selected_item_id = select_item_info->menuItem[index].itemId;
58 send_ui_user_confirm(select_item_info->commandId,
59 TAPI_SAT_CMD_TYPE_SELECT_ITEM,
60 TAPI_SAT_USER_CONFIRM_YES,
61 sizeof(unsigned char),
62 &selected_item_id, ad);
64 waiting_bar = create_waiting_notify(ad->content);
65 ad->waiting_bar = waiting_bar;
67 ecore_timer_del(ad->timer);
73 static char *_gl_text_get(void *data, Evas_Object *obj, const char *part)
75 int index = (int) data;
77 TelSatSelectItemInd_t *select_item_info;
80 ad = (SatUiAppData_t *)evas_object_data_get(obj, "app_data");
81 retv_if(NULL == ad, NULL);
82 select_item_info = (TelSatSelectItemInd_t *)evas_object_data_get(obj, "tapi_data");
83 if (select_item_info->iconIdList.bIsPresent == true &&
84 select_item_info->iconIdList.iconListQualifier == TAPI_SAT_ICON_QUALI_SELF_EXPLANATORY)
87 stripped_str = strip_control_char((char *)select_item_info->menuItem[index].text);
92 static void on_clicked_help_button(void *data, Evas_Object *obj, void *event_info)
94 int index = (int) data;
95 TelSatSelectItemInd_t *select_item_info;
98 ad = (SatUiAppData_t *)evas_object_data_get(obj, "app_data");
100 select_item_info = (TelSatSelectItemInd_t *)evas_object_data_get(obj, "tapi_data");
101 ret_if(NULL == select_item_info);
102 send_ui_user_confirm(select_item_info->commandId,
103 TAPI_SAT_CMD_TYPE_SELECT_ITEM,
104 TAPI_SAT_USER_CONFIRM_HELP_INFO,
105 sizeof(unsigned char),
106 &(select_item_info->menuItem[index].itemId), ad);
109 static Evas_Object *_gl_content_get(void *data, Evas_Object *obj, const char *part)
113 TelSatSelectItemInd_t *select_item_info;
115 ad = (SatUiAppData_t *)evas_object_data_get(obj, "app_data");
116 select_item_info = (TelSatSelectItemInd_t *)evas_object_data_get(obj, "tapi_data");
117 retv_if(NULL == ad, NULL);
119 if ((!strcmp(part, "elm.icon"))
120 || (!strcmp(part, "elm.icon.2"))) {
121 if (select_item_info->bIsHelpInfoAvailable == true) {
122 btn = elm_button_add(ad->content);
123 elm_object_style_set(btn, "info");
124 evas_object_smart_callback_add(btn, "clicked", on_clicked_help_button, data);
125 evas_object_event_callback_add(btn, EVAS_CALLBACK_DEL, __sat_ui_select_item_destory_object, NULL);
126 evas_object_data_set(btn, "app_data",(void *)ad);
127 evas_object_data_set(btn, "tapi_data",(void *)select_item_info);
128 evas_object_propagate_events_set(btn, EINA_FALSE);
131 } else if (!strcmp(part, "elm.icon.1")) {
132 if (select_item_info->iconIdList.bIsPresent == true) {
139 static void on_clicked_back_btn( void *data, Evas_Object* obj, void* event_info )
141 SatUiAppData_t *ad = (SatUiAppData_t *)data;
142 send_ui_user_confirm(ad->cmd_id, TAPI_SAT_CMD_TYPE_SELECT_ITEM, TAPI_SAT_USER_CONFIRM_NO_OR_CANCEL, 0, NULL, ad);
144 ecore_timer_del(ad->timer);
150 static Eina_Bool on_timer_expired(void *data)
152 SatUiAppData_t *ad = (SatUiAppData_t *)data;
153 if (ad->timer == NULL) {
154 DBG("Cancel timout w/o user_confirm");
156 send_ui_user_confirm(ad->cmd_id, TAPI_SAT_CMD_TYPE_SELECT_ITEM, TAPI_SAT_USER_CONFIRM_TIMEOUT, 0, NULL, ad);
160 return ECORE_CALLBACK_CANCEL;
163 int draw_content_select_item(Evas_Object *content, void *tapi_data, void *data)
165 retv_if(NULL == content, -1);
166 retv_if(NULL == tapi_data, -1);
167 retv_if(NULL == data, -1);
169 SatUiAppData_t *ad = (SatUiAppData_t *)data;
170 TelSatSelectItemInd_t *select_item_info = (TelSatSelectItemInd_t *)tapi_data;
171 Evas_Object *l_button;
174 Evas_Object *genlist;
177 l_button = elm_button_add(ad->nf);
178 elm_object_style_set(l_button, "naviframe/end_btn/default");
179 evas_object_smart_callback_add(l_button, "clicked", on_clicked_back_btn, ad);
180 elm_object_item_part_content_set(ad->navi_it, "prev_btn", l_button);
181 ad->back_btn = l_button;
183 if (select_item_info->text.stringLen > 0) {
184 elm_object_item_text_set(ad->navi_it, (char *)select_item_info->text.string);
187 box = elm_box_add(ad->nf);
188 elm_box_horizontal_set(box, EINA_FALSE);
189 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
190 evas_object_show(box);
192 if (select_item_info->iconId.bIsPresent == true) {
193 DBG(" Select item text: %s", (char *)select_item_info->text.string);
195 image = convert_iconinfo_to_evas_object((void *)ad, &select_item_info->iconId.iconInfo);
197 if (select_item_info->iconId.iconQualifier == TAPI_SAT_ICON_QUALI_SELF_EXPLANATORY) {
198 elm_object_item_text_set(ad->navi_it, " ");
201 evas_object_size_hint_align_set(image, 0,0);
202 evas_object_show(image);
203 elm_box_pack_end(box, image);
206 /* Select Item List */
207 ad->itc_text_icon->func.text_get = _gl_text_get;
208 ad->itc_text_icon->func.content_get = _gl_content_get;
210 if (select_item_info->iconIdList.bIsPresent == true) {
211 ad->itc_text_icon->item_style= "1text.2icon";
213 ad->itc_text_icon->item_style = "1text.1icon";
216 genlist = elm_genlist_add(content);
217 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
218 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
219 evas_object_show(genlist);
220 evas_object_data_set(genlist, "app_data",(void *)ad);
221 evas_object_data_set(genlist, "tapi_data",(void *)select_item_info);
222 evas_object_event_callback_add(genlist, EVAS_CALLBACK_DEL, __sat_ui_select_item_destory_object, NULL);
224 for (index = 0; index < select_item_info->menuItemCount; index++) {
225 elm_genlist_item_append(
230 ELM_GENLIST_ITEM_NONE,
236 elm_box_pack_end(box, genlist);
237 elm_object_part_content_set(content, "body", box);
238 ad->timer = ecore_timer_add(SELECT_MENU_DURATION, on_timer_expired, ad);