2 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
4 * This file is part of <ciss>
5 * Written by <Sungjoon Won> <sungjoon.won@samsung.com>, <Jungmin Kim> <jm15.kim@samsung.com>
7 * PROPRIETARY/CONFIDENTIAL
9 * This software is the confidential and proprietary information of SAMSUNG ELECTRONICS ("Confidential Information").
10 * You shall not disclose such Confidential Information and shall use it only in accordance
11 * with the terms of the license agreement you entered into with SAMSUNG ELECTRONICS.
12 * SAMSUNG make no representations or warranties about the suitability of the software,
13 * either express or implied, including but not limited to the implied warranties of merchantability,
14 * fitness for a particular purpose, or non-infringement.
15 * SAMSUNG shall not be liable for any damages suffered by licensee as a result of using,
16 * modifying or distributing this software or its derivatives.
20 #include "ciss-respnd.h"
21 #include "ciss-common.h"
22 #include "ciss-widget.h"
23 #include <TapiEvent.h>
24 #include <Ecore_IMF.h>
28 BT_CHINESE_MODE = 1, /* Not support yet */
29 BT_ENG_LOWER_MODE = 2,
30 BT_ENG_UPPER_MODE = 3,
39 static Elm_Entry_Filter_Limit_Size limit_filter_data;
41 static void __ciss_respond_cb(void *data, Evas_Object *obj, void *event_info)
43 DBG("coming inside __ciss_respond_cb \n");
46 char ussd_str[TAPI_SS_USSD_DATA_SIZE_MAX] = {0, };
48 Ecore_IMF_Context *imf_context;
49 Evas_Object *error_popup;
50 struct appdata *ad = (struct appdata *)data;
52 buf = (char *)elm_entry_entry_get(ad->ef_entry);
53 imf_context = elm_entry_imf_context_get(ad->ef_entry);
55 ecore_imf_context_input_panel_hide(imf_context);
57 snprintf(ussd_str, TAPI_SS_USSD_DATA_SIZE_MAX, "%s", buf);
58 if (strlen(ussd_str) == 0) {
59 error_popup = _ciss_create_popup(ad->nf, CISS_STR_ENTER_NUMBER);
60 evas_object_show(error_popup);
64 DBG("The data is %s %d \n", ussd_str, strlen(buf));
66 TelSsUssdMsgInfo_t ussdRspRecord;
67 memset(&ussdRspRecord, 0, sizeof(TelSsUssdMsgInfo_t));
68 strncpy(ussdRspRecord.szUssdString, ussd_str, sizeof(ussdRspRecord.szUssdString) - 1);
69 ussdRspRecord.szUssdString[strlen(ussdRspRecord.szUssdString)] = '\0';
70 ussdRspRecord.UssdStringLength = strlen(ussdRspRecord.szUssdString);
71 ad->popup = _ciss_create_noti_popup(ad->win_main,
72 CISS_STR_REQUESTING, NULL, POPUP_DISPLAY_DURATION, ad);
73 ret = tel_send_ss_ussd_response(&ussdRspRecord, &pRequestId);
75 DBG("The value of ret is %d and request id is %d \n", ret, pRequestId);
76 ad->request_id = pRequestId; /* of no use as of now */
79 static void __ciss_changed_cb(void *data, Evas_Object *obj, void *event_info)
83 struct appdata *ad = (struct appdata *)data;
84 Evas_Object *editfield = ad->ef_layout;
85 Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ad->nf);
88 if (elm_object_focus_get(editfield)) {
89 Evas_Object *btn = elm_object_item_part_content_get(navi_it,
92 if (elm_entry_is_empty(obj)) {
93 elm_object_signal_emit(editfield, "elm,state,eraser,hide", "elm");
95 elm_object_disabled_set(btn, EINA_TRUE);
97 elm_object_signal_emit(editfield, "elm,state,eraser,show", "elm");
99 elm_object_disabled_set(btn, EINA_FALSE);
104 static void __ciss_focused_cb(void *data, Evas_Object *obj, void *event_info)
106 ret_if(NULL == data);
107 struct appdata *ad = (struct appdata *)data;
108 Evas_Object *editfield = ad->ef_layout;
110 if (!elm_entry_is_empty(obj))
111 elm_object_signal_emit(editfield, "elm,state,eraser,show", "elm");
112 elm_object_signal_emit(editfield, "elm,state,guidetext,hide", "elm");
115 static void __ciss_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
117 ret_if(NULL == data);
118 struct appdata *ad = (struct appdata *)data;
119 Evas_Object *editfield = ad->ef_layout;
121 if (elm_entry_is_empty(obj))
122 elm_object_signal_emit(editfield, "elm,state,guidetext,show", "elm");
123 elm_object_signal_emit(editfield, "elm,state,eraser,hide", "elm");
126 static void __ciss_eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
128 elm_entry_entry_set(data, "");
131 static Evas_Object *__ciss_editfield_add(Evas_Object *parent, void *data)
133 retv_if(data == NULL, NULL);
134 struct appdata *ad = (struct appdata *)data;
136 Evas_Object *layout = NULL;
137 Evas_Object *entry = NULL;
139 layout = elm_layout_add(parent);
140 ad->ef_layout = layout;
141 elm_layout_theme_set(layout, "layout", "editfield", "title");
143 entry = elm_entry_add(parent);
144 ad->ef_entry = entry;
145 elm_entry_scrollable_set(entry, EINA_TRUE);
146 elm_entry_single_line_set(entry, EINA_TRUE);
148 limit_filter_data.max_char_count = 0;
149 limit_filter_data.max_byte_count = TAPI_SS_USSD_DATA_SIZE_MAX;
150 elm_entry_markup_filter_append(entry, elm_entry_filter_limit_size, &limit_filter_data);
151 evas_object_smart_callback_add(entry, "changed", __ciss_changed_cb, ad);
152 evas_object_smart_callback_add(entry, "focused", __ciss_focused_cb, ad);
153 evas_object_smart_callback_add(entry, "unfocused", __ciss_unfocused_cb, ad);
154 evas_object_show(entry);
156 elm_object_part_content_set(layout, "elm.swallow.content", entry);
157 elm_object_part_text_set(layout, "elm.text", CISS_STR_ENTER_NUMBER);
158 elm_object_signal_callback_add(layout, "elm,eraser,clicked", "elm", __ciss_eraser_clicked_cb, entry);
159 elm_object_focus_set(entry, EINA_TRUE);
164 static Evas_Object *__ciss_gl_content_respond_ime(void *data, Evas_Object *obj, const char *part)
166 Evas_Object *editfield = NULL;
168 if (!strcmp(part, "elm.icon")) {
169 editfield = __ciss_editfield_add(obj, data);
176 static Evas_Object *__ciss_respond_ime_genlist(void *data)
178 Elm_Object_Item *item = NULL;
179 Evas_Object *genlist;
180 struct appdata *ad = (struct appdata *)data;
182 genlist = elm_genlist_add(ad->nf);
184 ad->itc_ime->item_style = "1icon";
185 ad->itc_ime->func.text_get = NULL;
186 ad->itc_ime->func.content_get = __ciss_gl_content_respond_ime;
187 ad->itc_ime->func.state_get = NULL;
188 ad->itc_ime->func.del = NULL;
190 item = elm_genlist_item_append(genlist, ad->itc_ime,
191 (void *)ad, NULL, ELM_GENLIST_ITEM_NONE,
196 void _ciss_create_respond_view(void *data)
199 struct appdata *ad = (struct appdata *)data;
200 Evas_Object *ime_genlist;
201 Elm_Object_Item *navi_it = NULL;
202 Evas_Object *btn = NULL;
204 ime_genlist = __ciss_respond_ime_genlist(ad);
206 _ciss_remove_naviframe(ad->nf);
207 navi_it = elm_naviframe_item_push(ad->nf, CISS_STR_INFORMATION,
208 NULL, NULL, ime_genlist, "1line");
210 btn = _cst_create_title_btn(ad->nf, CISS_STR_QUIT,
211 _ciss_ussd_quit_cb, (void *)ad);
212 elm_object_item_part_content_set(navi_it, "title_left_btn", btn);
214 btn = _cst_create_title_btn(ad->nf, CISS_STR_REPLY,
215 __ciss_respond_cb, (void *)ad);
216 elm_object_item_part_content_set(navi_it, "title_right_btn", btn);
217 elm_object_disabled_set(btn, EINA_TRUE);