Tizen 2.1 base
[apps/home/call-setting.git] / src / cst-reject-msg.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
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
7  *
8  * http://floralicense.org/license/
9  *
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.
15  */
16
17 #include <Elementary.h>
18 #include <vconf.h>
19 #include "cst-common.h"
20 #include "cst-common-string.h"
21 #include "cst-widget.h"
22 #include "cst-call-setting.h"
23 #include "cst-delete-list.h"
24
25 #include "cst-reject-msg.h"
26 #include "cst-reject-msg-ime.h"
27 #include "cst-util.h"
28
29 static void __cst_set_genlist_item_styles_reject_msg(void);
30 static void __cst_destroy_genlist_item_styles(void);
31 static void __cst_edit_reject_message_list(void *data, Evas_Object *obj, void *event_info);
32 static void __cst_reject_msg_back_to_prev(CstUgData_t *ugd);
33
34 static Elm_Genlist_Item_Class *itc_1text = NULL;
35 char *header = NULL;
36 static gboolean b_edit_mode = EINA_FALSE;
37 static CstGlItemData_t *g_item_data = NULL;
38 Elm_Object_Item *g_navi_it;
39
40 Evas_Object *ec_item[3];
41
42 static void __cst_destroy_genlist_item_styles(void)
43 {
44         ENTER(__cst_destroy_genlist_item_styles);
45
46         if (itc_1text) {
47                 elm_genlist_item_class_free(itc_1text);
48                 itc_1text = NULL;
49         }
50 }
51
52 static void _back_btn_clicked_reject_msg_cb(void *data, Evas_Object *obj, void *event_info)
53 {
54         ENTER(_back_btn_clicked_reject_msg_cb);
55         ret_if(NULL == data);
56         CstUgData_t *ugd = (CstUgData_t *)data;
57
58         _cst_destroy_reject_message(ugd);
59 }
60
61 char *_cst_get_reject_message(int index)
62 {
63         char *message = NULL;
64         char *return_str = NULL;
65         switch (index) {
66         case 0:
67                 message = _cst_vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR);
68                 break;
69         case 1:
70                 message = _cst_vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR);
71                 break;
72         case 2:
73                 message = _cst_vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR);
74                 break;
75         case 3:
76                 message = _cst_vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR);
77                 break;
78         case 4:
79                 message = _cst_vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR);
80                 break;
81         case 5:
82                 message = _cst_vconf_get_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR);
83                 break;
84         default:
85                 return NULL;
86         }
87         retv_if(NULL == message, NULL);
88         return_str = strdup(dgettext(UGNAME,message));
89         free(message);
90         message = NULL;
91
92         return return_str;
93 }
94
95 void _cst_set_reject_message(int index, char *message)
96 {
97         switch (index) {
98         case 0:
99                 _cst_vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG1_STR, message);
100                 break;
101         case 1:
102                 _cst_vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG2_STR, message);
103                 break;
104         case 2:
105                 _cst_vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG3_STR, message);
106                 break;
107         case 3:
108                 _cst_vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG4_STR, message);
109                 break;
110         case 4:
111                 _cst_vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG5_STR, message);
112                 break;
113         case 5:
114                 _cst_vconf_set_str(VCONFKEY_CISSAPPL_USER_CREATE_MSG6_STR, message);
115                 break;
116         default:
117                 DBG("Error set reject message");
118                 break;
119         }
120 }
121
122 int _cst_set_reject_msg_button_status(int num)
123 {
124         ENTER(_cst_set_reject_msg_button_status);
125
126         if (ec_item[0] != NULL) {
127                 if (num == 6) {
128                         elm_object_disabled_set(ec_item[0], EINA_TRUE);
129                 } else {
130                         elm_object_disabled_set(ec_item[0], EINA_FALSE);
131                 }
132         }
133         if (ec_item[1] != NULL) {
134                 if (num == 0) {
135                         elm_object_disabled_set(ec_item[1], EINA_TRUE);
136                 } else {
137                         elm_object_disabled_set(ec_item[1], EINA_FALSE);
138                 }
139         }
140         return num;
141 }
142
143 int _cst_set_num_of_reject_message(int num)
144 {
145         ENTER(_cst_set_num_of_reject_message);
146
147         _cst_vconf_set_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, num);
148
149         return num;
150 }
151
152 int _cst_get_num_of_reject_message(void)
153 {
154         int cnt;
155         _cst_vconf_get_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, &cnt);
156         return cnt;
157 }
158
159 static Eina_Bool __cst_rejectcall_message_check_same_data(void *data, const char *string)
160 {
161         ENTER(__cst_rejectcall_message_check_same_data);
162         CstUgData_t *ugd = (CstUgData_t *)data;
163         char *buf;
164         int i, reject_message_count;
165         Eina_Bool value = EINA_TRUE;
166         Evas_Object *error;
167
168         DBG("Input string : %s", string);
169         _cst_vconf_get_int(VCONFKEY_CISSAPPL_REJECT_CALL_MSG_INT, &reject_message_count);
170         for (i = 0; i < reject_message_count; i++) {
171                 buf = _cst_get_reject_message(i);
172                 if (buf) {
173                         if (strcmp(buf, string) == 0) {
174                                 error = _cst_create_duplicate_msg_popup(ugd->nf, string);
175                                 ugd->popup = error;
176                                 evas_object_show(error);
177                                 value = EINA_FALSE;
178                         }
179                         free(buf);
180                         buf = NULL;
181                 }
182         }
183         return value;
184 }
185
186 static char *__cst_gl_label_get_reject_msg(void *data, Evas_Object *obj, const char *part)
187 {
188         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
189         retv_if(item_data == NULL, NULL);
190
191         if (!strcmp(part, "elm.text")) {
192                 char *entry_label = elm_entry_markup_to_utf8(item_data->label);
193                 retv_if(entry_label == NULL, NULL);
194                 char *buf = strdup(entry_label);
195                 free(entry_label);
196                 entry_label = NULL;
197                 return buf;
198         }
199
200         return NULL;
201 }
202
203 static void __cst_gl_del_reject_msg(void *data, Evas_Object *obj)
204 {
205         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
206         if (item_data) {
207                 if (item_data->label) {
208                         free(item_data->label);
209                 }
210                 free(item_data);
211         }
212
213         return;
214 }
215
216 static void __cst_set_genlist_item_styles_reject_msg(void)
217 {
218         if (!itc_1text) {
219                 itc_1text = elm_genlist_item_class_new();
220         }
221
222         itc_1text->item_style = "dialogue/1text";
223         itc_1text->func.text_get = __cst_gl_label_get_reject_msg;
224         itc_1text->func.content_get = NULL;
225         itc_1text->func.del = __cst_gl_del_reject_msg;
226 }
227
228 void _cst_genlist_append_reject_list_item(CstUgData_t *ugd, Evas_Object *genlist)
229 {
230         ENTER(_cst_genlist_append_reject_list_item);
231         Elm_Object_Item *item;
232         int num_of_message;
233         CstGlItemData_t *item_data;
234         int index = 0;
235
236         num_of_message = _cst_get_num_of_reject_message();
237
238         if (header) {
239                 snprintf(header, sizeof(char)*256, "%s (%d/6)", T_(CST_STR_REJECT_MESSAGES), num_of_message);
240                 elm_object_item_part_text_set(g_navi_it, "elm.text.title", header);
241         }
242         if (num_of_message == 0) {
243                 edje_object_signal_emit(_EDJ(ugd->backup_layout), "show,content2", "code");
244         } else {
245                 _cst_create_genlist_separator(genlist, EINA_TRUE);
246                 for (index = 0; index < num_of_message; index++) {
247                         item_data = calloc(1, sizeof(CstGlItemData_t));
248                         ret_if(item_data == NULL);
249                         item_data->index = index;
250                         item_data->ugd = (void *)ugd;
251                         item_data->label = _cst_get_reject_message(index);
252
253                         item = elm_genlist_item_append(genlist, itc_1text,
254                                                                                    item_data, NULL, ELM_GENLIST_ITEM_NONE,
255                                                                                    __cst_edit_reject_message_list, item_data);
256                         item_data->gl_item = item;
257                 }
258                 edje_object_signal_emit(_EDJ(ugd->backup_layout), "show,content1", "code");
259         }
260 }
261
262 static Evas_Object *__cst_create_genlist_reject_msg(CstUgData_t *ugd)
263 {
264         ENTER(__cst_create_genlist_reject_msg);
265         Evas_Object *genlist;
266
267         genlist = elm_genlist_add(ugd->nf);
268
269         elm_genlist_tree_effect_enabled_set(genlist, EINA_TRUE);
270         evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
271         evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
272
273         _cst_genlist_append_reject_list_item(ugd, genlist);
274         return genlist;
275 }
276
277 static void __cst_click_reject_msg_edit_cancel(void *data, Evas_Object *obj, void *event_info)
278 {
279         ENTER(__cst_click_reject_msg_edit_cancel);
280         ret_if(!data);
281         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
282         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
283         memset(ugd->c_item, 0, sizeof(ugd->c_item));
284         __cst_reject_msg_back_to_prev(ugd);
285         b_edit_mode = EINA_FALSE;
286 }
287
288 static void __cst_click_reject_msg_create_cancel(void *data, Evas_Object *obj, void *event_info)
289 {
290         ENTER(__cst_click_reject_msg_create_cancel);
291         ret_if(!data);
292         CstUgData_t *ugd = (CstUgData_t *)data;
293         memset(ugd->c_item, 0, sizeof(ugd->c_item));
294         __cst_reject_msg_back_to_prev(ugd);
295 }
296
297 static void __cst_click_reject_msg_edit_done(void *data, Evas_Object *obj, void *event_info)
298 {
299         ENTER(__cst_click_reject_msg_edit_done);
300         ret_if(!data);
301
302         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
303         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
304         ret_if(!ugd);
305
306         const char *new_message = elm_entry_entry_get(ugd->dg_entry);
307
308         DBG("item_data->label = %s", item_data->label);
309
310         if (NULL == new_message) {
311                 DBG("No new message");
312                 return;
313         } else if (0 == strlen(new_message)) {
314                 Evas_Object *error;
315                 DBG("No Message");
316                 error = _cst_create_error_popup(ugd->nf, CST_ERROR_ENTER_MESSAGE);
317                 ugd->popup = error;
318                 evas_object_show(error);
319                 return;
320         } else if (strcmp(item_data->label, new_message) == 0) {
321                 __cst_reject_msg_back_to_prev(ugd);
322                 return;
323         } else if ((__cst_rejectcall_message_check_same_data((void *)ugd, new_message)) == EINA_FALSE) {
324                 DBG("Duplicate message");
325                 return;
326         }
327
328         g_free(item_data->label);
329         item_data->label = strdup(new_message);
330         _cst_set_reject_message(item_data->index, (char *)new_message);
331         elm_genlist_item_update(item_data->gl_item);
332
333         memset(ugd->c_item, 0, sizeof(ugd->c_item));
334         __cst_reject_msg_back_to_prev(ugd);
335         b_edit_mode = EINA_FALSE;
336 }
337
338 static void __cst_click_reject_msg_create_done(void *data, Evas_Object *obj, void *event_info)
339 {
340         ENTER(__cst_click_reject_msg_create_done);
341         ret_if(!data);
342
343         CstUgData_t *ugd = (CstUgData_t *)data;
344         int num_of_reject_message;
345
346         num_of_reject_message = _cst_get_num_of_reject_message();
347         const char *new_message = elm_entry_entry_get(ugd->dg_entry);
348
349         if (NULL == new_message) {
350                 DBG("No new message");
351                 return;
352         } else if (0 == strlen(new_message)) {
353                 Evas_Object *error;
354                 DBG("No Message");
355                 error = _cst_create_error_popup(ugd->nf, CST_ERROR_ENTER_MESSAGE);
356                 ugd->popup = error;
357                 evas_object_show(error);
358                 return;
359         } else if ((__cst_rejectcall_message_check_same_data((void *)ugd, new_message)) == EINA_FALSE) {
360                 DBG("Duplicate message");
361                 return;
362         }
363
364         _cst_set_reject_message(num_of_reject_message, (char *)new_message);
365         _cst_set_num_of_reject_message(num_of_reject_message + 1);
366         elm_genlist_clear(ugd->backup_genlist);
367         _cst_genlist_append_reject_list_item(ugd, ugd->backup_genlist);
368
369         memset(ugd->c_item, 0, sizeof(ugd->c_item));
370         __cst_reject_msg_back_to_prev(ugd);
371 }
372
373 void _cst_reject_msg_changed_editfield_cb(void *data, Evas_Object *obj, void *event_info)
374 {
375         ret_if(NULL == data);
376         CstUgData_t *ugd = (CstUgData_t *)data;
377         const char *entry_str = elm_entry_entry_get(obj);
378
379         DBG("entry_str = %s",entry_str);
380         Elm_Object_Item *navi_it = elm_naviframe_top_item_get(ugd->nf);
381         ret_if(!navi_it);
382         Evas_Object *btn = elm_object_item_part_content_get(navi_it,
383                                            "title_left_btn");
384
385         if (NULL == entry_str || '\0' == entry_str[0]) {
386                 if (btn != NULL) {
387                         elm_object_disabled_set(btn, EINA_TRUE);
388                 }
389                 elm_object_disabled_set(ec_item[0], EINA_TRUE);
390         } else {
391                 if (btn != NULL) {
392                         elm_object_disabled_set(btn, EINA_FALSE);
393                 }
394                 elm_object_disabled_set(ec_item[0], EINA_FALSE);
395         }
396 }
397
398 static void __cst_edit_reject_message_list(void *data, Evas_Object *obj, void *event_info)
399 {
400         ENTER(__cst_edit_reject_message_list);
401         ret_if(!data);
402         CstGlItemData_t *item_data = (CstGlItemData_t *)data;
403         CstUgData_t *ugd = (CstUgData_t *)item_data->ugd;
404         Evas_Object *eo;
405         Elm_Object_Item *navi_it;
406         Evas_Object *scroller, *main_box;
407         Evas_Object *layout;
408
409         if (ugd->ticker_noti_timer) {
410                 _cst_hide_selectinfo_cb(ugd);
411                 ecore_timer_del(ugd->ticker_noti_timer);
412                 ugd->ticker_noti_timer = NULL;
413         }
414
415         b_edit_mode = EINA_TRUE;
416         g_item_data = item_data;
417
418         elm_genlist_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
419         ugd->popup = NULL;
420
421         scroller = elm_scroller_add(ugd->nf);
422         elm_object_style_set(scroller, "dialogue");
423         elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
424         elm_scroller_policy_set(scroller,ELM_SCROLLER_POLICY_OFF,ELM_SCROLLER_POLICY_AUTO);
425         evas_object_show(scroller);
426
427         main_box = elm_box_add(scroller);
428         evas_object_size_hint_weight_set(main_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
429         evas_object_size_hint_align_set(main_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
430         elm_object_content_set(scroller, main_box);
431         evas_object_show(main_box);
432 #ifdef _CALL_SET_OLD_SEPERATOR
433         layout = elm_layout_add(main_box);
434         elm_layout_theme_set(layout, "layout", "dialogue", "separator/hd33/with_line");
435         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
436         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
437         elm_box_pack_end(main_box, layout);
438         evas_object_show(layout);
439 #endif
440         layout = elm_layout_add(main_box);
441         elm_layout_theme_set(layout, "layout", "dialogue", "1icon");
442         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
443         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
444         elm_box_pack_end(main_box, layout);
445         evas_object_show(layout);
446
447         _cst_remove_naviframe(ugd->nf);
448         navi_it = elm_naviframe_item_push(ugd->nf,
449                                                                           T_(CST_STR_REJECT_MESSAGE), NULL, NULL, scroller, NULL);
450         if (navi_it == NULL) {
451                 DBG("elm_naviframe_item_push fail...");
452         }
453
454         eo = _cst_create_reject_message_ime(layout, item_data->label, ugd);
455         elm_object_part_content_set(layout, "elm.icon", eo);
456         evas_object_show(eo);
457 }
458
459 static void __cst_on_click_reject_message_add_button(void *data, Evas_Object *obj, void *event_info)
460 {
461         ENTER(__cst_on_click_reject_message_add_button);
462         ret_if(!data);
463         CstUgData_t *ugd = (CstUgData_t *)data;
464         Evas_Object *eo;
465         Elm_Object_Item *navi_it;
466         Evas_Object *scroller, *main_box;
467         Evas_Object *layout;
468
469         if (ugd->ticker_noti_timer) {
470                 _cst_hide_selectinfo_cb(ugd);
471                 ecore_timer_del(ugd->ticker_noti_timer);
472                 ugd->ticker_noti_timer = NULL;
473         }
474
475         ugd->popup = NULL;
476
477         scroller = elm_scroller_add(ugd->nf);
478         elm_object_style_set(scroller, "dialogue");
479         elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_TRUE);
480         elm_scroller_policy_set(scroller,ELM_SCROLLER_POLICY_OFF,ELM_SCROLLER_POLICY_AUTO);
481         evas_object_show(scroller);
482
483         main_box = elm_box_add(scroller);
484         evas_object_size_hint_weight_set(main_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
485         evas_object_size_hint_align_set(main_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
486         elm_object_content_set(scroller, main_box);
487         evas_object_show(main_box);
488 #ifdef _CALL_SET_OLD_SEPERATOR
489         layout = elm_layout_add(main_box);
490         elm_layout_theme_set(layout, "layout", "dialogue", "separator/hd33/with_line");
491         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, 0.0);
492         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
493         elm_box_pack_end(main_box, layout);
494         evas_object_show(layout);
495 #endif
496         layout = elm_layout_add(main_box);
497         elm_layout_theme_set(layout, "layout", "dialogue", "1icon");
498         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
499         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, 0.0);
500         elm_box_pack_end(main_box, layout);
501         evas_object_show(layout);
502
503         _cst_remove_naviframe(ugd->nf);
504         navi_it = elm_naviframe_item_push(ugd->nf,
505                                                                           T_(CST_STR_REJECT_MESSAGE), NULL, NULL, scroller, NULL);
506         if (navi_it == NULL) {
507                 DBG("elm_naviframe_item_push fail...");
508         }
509
510         eo = _cst_create_reject_message_ime(layout, NULL, ugd);
511         elm_object_part_content_set(layout, "elm.icon", eo);
512         evas_object_show(eo);
513 }
514
515 static Evas_Object *__cst_create_nocontents_layout(CstUgData_t *ugd)
516 {
517         ENTER(__cst_create_nocontents_layout);
518         Evas_Object *layout;
519
520         layout = elm_layout_add(ugd->nf);
521         elm_layout_file_set(layout, EDJ_NAME, "nocontents");
522         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
523         elm_layout_theme_set(layout, "layout", "nocontents", "text");
524         elm_object_part_text_set(layout, "elm.text", (char *)T_(CST_STR_NO_MESSAGE));
525
526         return layout;
527 }
528
529 static void __cst_create_reject_message(Evas_Object *parent, void *data)
530 {
531         ENTER(_cst_on_click_reject_message);
532         Evas_Object *back_btn, *layout, *nocontent;
533         CstUgData_t *ugd = data;
534         ret_if(ugd == NULL);
535
536         __cst_set_genlist_item_styles_reject_msg();
537         ugd->kind_of_delete_list = CST_DL_REJECT_CALL_WITH_MSG;
538
539         /*Create layout */
540         layout = elm_layout_add(ugd->nf);
541         ugd->backup_layout = layout;
542         elm_layout_file_set(layout, EDJ_NAME, "toolbar");
543         evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
544         evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
545         nocontent = __cst_create_nocontents_layout(ugd);
546         ugd->backup_genlist = __cst_create_genlist_reject_msg(ugd);
547
548         elm_object_part_content_set(layout, "elm.swallow.contents", ugd->backup_genlist);
549         elm_object_part_content_set(layout, "elm.swallow.contents2", nocontent);
550
551         header = (char *)malloc(sizeof(char)*256);
552         memset(header, 0x0, 256);
553
554         snprintf(header, sizeof(char)*256, "%s (%d/6)", T_(CST_STR_REJECT_MESSAGES), _cst_get_num_of_reject_message());
555
556         DBG("header = %s",header);
557         g_navi_it = elm_naviframe_item_push(ugd->nf,
558                                                                                 header, NULL, NULL, layout, NULL);
559         back_btn = elm_object_item_part_content_get(g_navi_it, "prev_btn");
560         evas_object_smart_callback_add(back_btn, "clicked",
561                                                                    _back_btn_clicked_reject_msg_cb, ugd);
562
563         _cst_create_navi_control_bar(ugd->nf,
564                                                                                 (char *)T_(CST_STR_ADD), CST_CTRL_ICON_CREATE,
565                                                                                 __cst_on_click_reject_message_add_button,
566                                                                                 (char *)T_(CST_STR_DELETE), CST_CTRL_ICON_EDIT,
567                                                                                 _cst_create_delete_list,
568                                                                                 (void *)ugd, g_navi_it,
569                                                                                 ec_item);
570         _cst_set_reject_msg_button_status(_cst_get_num_of_reject_message());
571 }
572
573 void _cst_on_click_reject_message(void *data, Evas *evas, Evas_Object *obj, void *event_info)
574 {
575         ENTER(_cst_on_click_reject_message);
576         ret_if(NULL == data);
577         CstUgData_t *ugd = (CstUgData_t *)data;
578         __cst_create_reject_message(ugd->nf, ugd);
579 }
580
581 void _cst_reject_msg_input_panel_event_callback(void *data, Ecore_IMF_Context *imf_context, int value)
582 {
583         ENTER(_cst_reject_msg_input_panel_event_callback);
584         ret_if(!data);
585         CstUgData_t *ugd = (CstUgData_t *)data;
586         Evas_Object *btn;
587         void (*save_cb_func)();
588         void (*cancel_cb_func)();
589         void *evnt_data;
590         const char *entry_input = NULL;
591
592         if (b_edit_mode) {
593                 save_cb_func = __cst_click_reject_msg_edit_done;
594                 cancel_cb_func = __cst_click_reject_msg_edit_cancel;
595                 evnt_data = g_item_data;
596         } else {
597                 save_cb_func = __cst_click_reject_msg_create_done;
598                 cancel_cb_func = __cst_click_reject_msg_create_cancel;
599                 evnt_data = data;
600         }
601
602         Elm_Object_Item *top_it = elm_naviframe_top_item_get(ugd->nf);
603
604         entry_input = elm_entry_entry_get(ugd->dg_entry);
605         if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
606                 DBG("ECORE_IMF_INPUT_PANEL_STATE_SHOW");
607
608                 elm_object_item_part_content_set(top_it, "toolbar_button1", NULL);
609                 elm_object_item_part_content_set(top_it, "toolbar_button2", NULL);
610
611                 btn = _cst_create_title_btn(ugd->nf, (char *)T_(CST_STR_CANCEL),
612                                                                         cancel_cb_func, evnt_data);
613                 elm_object_item_part_content_set(top_it, "title_right_btn", btn);
614
615                 btn = _cst_create_title_btn(ugd->nf, (char *)T_(CST_STR_SAVE),
616                                                                         save_cb_func, evnt_data);
617                 elm_object_item_part_content_set(top_it, "title_left_btn", btn);
618
619                 if (entry_input && strlen(entry_input) > 0) {
620                         elm_object_disabled_set(btn, EINA_FALSE);
621                 } else {
622                         elm_object_disabled_set(btn, EINA_TRUE);
623                 }
624         } else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
625                 DBG("ECORE_IMF_INPUT_PANEL_STATE_HIDE");
626                 elm_object_item_part_content_set(top_it, "title_right_btn", NULL);
627                 elm_object_item_part_content_set(top_it, "title_left_btn", NULL);
628                 _cst_create_navi_control_bar(ugd->nf,
629                                                                                         (char *)T_(CST_STR_SAVE), NULL,
630                                                                                         save_cb_func,
631                                                                                         (char *)T_(CST_STR_CANCEL), NULL,
632                                                                                         cancel_cb_func,
633                                                                                         (void *)evnt_data, top_it,
634                                                                                         ec_item);
635
636                 if (entry_input && strlen(entry_input) > 0) {
637                         elm_object_disabled_set(ec_item[0], EINA_FALSE);
638                 } else {
639                         elm_object_disabled_set(ec_item[0], EINA_TRUE);
640                 }
641         }
642 }
643
644 static Eina_Bool _cst_reject_msg_naviframe_item_pop_cb(void *data)
645 {
646         CstUgData_t *ugd = (CstUgData_t *)data;
647         Elm_Object_Item *top_it = NULL;
648
649         elm_naviframe_item_pop(ugd->nf);
650
651         top_it = elm_naviframe_top_item_get(ugd->nf);
652
653         _cst_create_navi_control_bar(ugd->nf,
654                                                                                 (char *)T_(CST_STR_ADD), CST_CTRL_ICON_CREATE,
655                                                                                 __cst_on_click_reject_message_add_button,
656                                                                                 (char *)T_(CST_STR_DELETE), CST_CTRL_ICON_EDIT,
657                                                                                 _cst_create_delete_list,
658                                                                                 (void *)ugd, top_it,
659                                                                                 ec_item);
660
661         _cst_set_reject_msg_button_status(_cst_get_num_of_reject_message());
662
663         return ECORE_CALLBACK_CANCEL;
664 }
665
666 static void __cst_reject_msg_back_to_prev(CstUgData_t *ugd)
667 {
668         ret_if(!ugd);
669         Ecore_IMF_Context *imf_context = elm_entry_imf_context_get(ugd->dg_entry);
670
671         if (imf_context) {
672                 ecore_imf_context_input_panel_event_callback_del(imf_context, ECORE_IMF_INPUT_PANEL_STATE_EVENT, _cst_reject_msg_input_panel_event_callback);
673                 ecore_imf_context_input_panel_enabled_set(imf_context, EINA_FALSE);
674         }
675
676         evas_object_smart_callback_del(ugd->dg_entry, "changed", _cst_reject_msg_changed_editfield_cb);
677         evas_object_smart_callback_del(ugd->dg_entry, "preedit,changed", _cst_reject_msg_changed_editfield_cb);
678
679 /*      ecore_timer_add(CST_NAVIFRAME_ITEM_POP_TIMER, _cst_reject_msg_naviframe_item_pop_cb, ugd);
680 */
681         _cst_reject_msg_naviframe_item_pop_cb(ugd);
682 }
683
684 void _cst_destroy_reject_message(CstUgData_t *ugd)
685 {
686         ENTER(_cst_destroy_reject_message);
687         ret_if(!ugd);
688
689         __cst_destroy_genlist_item_styles();
690
691         if (header) {
692                 free(header);
693                 header = NULL;
694         }
695
696         if (ugd->backup_genlist) {
697                 elm_genlist_clear(ugd->backup_genlist);
698                 ugd->backup_genlist = NULL;
699         }
700
701         if (ugd->backup_layout) {
702                 evas_object_del(ugd->backup_layout);
703                 ugd->backup_layout = NULL;
704         }
705
706         if (ugd->ticker_noti_timer) {
707                 _cst_hide_selectinfo_cb(ugd);
708                 ecore_timer_del(ugd->ticker_noti_timer);
709                 ugd->ticker_noti_timer = NULL;
710         }
711 }
712