fix RSA JIRA issue N_SE-24607
[apps/core/preloaded/email.git] / setting / src / email-view-account-setup.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://www.tizenopensource.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 "email-setting.h"
18 #include "email-view-account-setup.h"
19 #include "email-setting-utils.h"
20 #include "email-setting-account-set.h"
21
22 static int _create(struct viewdata *vd);
23 static int _update(struct viewdata *vd);
24 static int _destroy(struct viewdata *vd);
25 static int _show(struct viewdata *vd);
26 static int _hide(struct viewdata *vd);
27
28 static void _push_naviframe(struct viewdata *vd);
29 static void _create_view(struct viewdata *vd);
30 static void _create_list(struct viewdata *vd);
31 static void _create_validation_popup(struct viewdata *vd, int account_id);
32 static void _create_account(void *data);
33
34 static int _check_null_field(struct viewdata *vd);
35 static int _check_preset_null_field(struct viewdata *vd);
36 static int _check_preset_isp_name(char *addr, EmailSpDesc *desc);
37 static void _read_all_entries(struct viewdata *vd);
38 /*static void _set_help_string(Evas_Object *eo, struct viewdata *vd);*/
39 static void _set_domain_string(struct viewdata *vd);
40
41 static void _next_cb(void *data, Evas_Object *obj, void *event_info);
42 static void _save_cb(void *data, Evas_Object *obj, void *event_info);
43 static void _manual_cb(void *data, Evas_Object *obj, void *event_info);
44 static void _back_cb(void *data, Evas_Object *obj, void *event_info);
45 static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info);
46 static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info);
47 static void _check1_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source);
48 static void _check2_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source);
49 static Eina_Bool _after_validation_cb(void *data);
50 static Eina_Bool _password_state_cb(void *data);
51 static Eina_Bool _startup_focus_cb(void *data);
52
53 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info);
54 static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info);
55 static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info);
56 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info);
57 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
58 static void _entry_theme_changed_cb(void *data, Evas_Object *obj, void *event_info);
59 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
60 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value);
61 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info);
62 static char *_gl_group_text_get(void *data, Evas_Object *obj, const char *part);
63 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part);
64 static void _gl_realized_cb(void *data, Evas_Object *obj, void *event_info);
65
66 static struct viewdata *g_vd = NULL;
67
68 struct priv_data {
69         struct viewdata *vd;
70         int handle;
71
72         char *str_account_name;
73         char *str_display_name;
74         char *str_email_address;
75         char *str_user_id;
76         char *str_password;
77
78         Evas_Object *entry_account_name;
79         Evas_Object *entry_display_name;
80         Evas_Object *entry_email_address;
81         Evas_Object *entry_user_id;
82         Evas_Object *entry_password;
83
84         Evas_Object *ef_account_name;
85         Evas_Object *ef_display_name;
86         Evas_Object *ef_email_address;
87         Evas_Object *ef_user_id;
88         Evas_Object *ef_password;
89
90         Evas_Object *layout;
91         Evas_Object *scroller;
92
93         Evas_Object *l_button;
94         Evas_Object *r_button;
95         Evas_Object *r_button2;
96         Evas_Object *tool_btn;
97         Evas_Object *manual_btn;
98         Evas_Object *icon;
99         Evas_Object *show_passwd_check;
100         Evas_Object *default_account_check;
101
102         Evas_Object *clicked_object;
103
104         Evas_Object *genlist;
105         Elm_Genlist_Item_Class itc1;
106         Elm_Genlist_Item_Class itc2;
107         Elm_Genlist_Item_Class itc3;
108
109         Evas_Object *cbar;
110         Elm_Object_Item *gl_email_address_item;
111         Elm_Object_Item *gl_pw_item;
112         Elm_Object_Item * c_item[4];
113         Elm_Object_Item *navi_it;
114
115         int icon_get_cnt1;
116         int icon_get_cnt2;
117         int set_default_account;
118 };
119
120 void setting_init_account_setup_view(struct viewdata *vd)
121 {
122         debug_log("");
123         vd->type = VIEW_ACCOUNT_SETUP;
124         vd->create = _create;
125         vd->update = _update;
126         vd->destroy = _destroy;
127         vd->show = _show;
128         vd->hide = _hide;
129         vd->grp_nm = "setting_account_setup";
130 }
131
132 void setting_account_validation_success_cb(EmailSettingUGD *ugd)
133 {
134         debug_log("");
135         struct viewdata *vd;
136         Viewtype top;
137         top = ugd->view_st[ugd->view_top];
138         vd = ugd->vd[top];
139
140         if (!vd) {
141                 debug_log("vd is NULL");
142                 return;
143         }
144
145         ugd->atomic_pop = 1;
146
147         if (ugd->popup_one) {
148                 evas_object_del(ugd->popup_one);
149                 ugd->popup_one = NULL;
150         }
151         if (ugd->popup_validate) {
152                 evas_object_del(ugd->popup_validate);
153                 ugd->popup_validate = NULL;
154         }
155
156         ugd->preset_vc_timer = ecore_timer_add(0.5, _after_validation_cb, vd);
157 }
158
159 void setting_account_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled)
160 {
161         debug_log("");
162         struct viewdata *vd;
163         Viewtype top;
164         int account_id;
165         top = ugd->view_st[ugd->view_top];
166         vd = ugd->vd[top];
167
168         if (!vd) {
169                 debug_log("vd is NULL");
170                 return;
171         }
172
173         account_id = ugd->account_id;
174
175         if (ugd->popup_one) {
176                 evas_object_del(ugd->popup_one);
177                 ugd->popup_one = NULL;
178         }
179         /*if (ugd->popup_validate) {
180                 evas_object_del(ugd->popup_validate);
181                 ugd->popup_validate = NULL;
182         }*/
183
184         if (canceled || ugd->err_code == EMAIL_ERROR_CANCELLED) {
185                 ugd->popup_one = setting_get_notify(vd,
186                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
187                                 _("IDS_EMAIL_POP_ACCOUNT_CREATION_CANCELLED"),
188                                 1, dgettext("sys_string", "IDS_COM_SK_OK"),
189                                 _popup_ok_cb, NULL, NULL);
190         } else {
191                 char *type = setting_get_service_fail_type(ugd->err_code);
192                 ugd->popup_one = setting_get_notify(vd,
193                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
194                                 type, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
195                                 _popup_ok_cb, NULL, NULL);
196                 g_free(type);
197         }
198 }
199
200 static int _create(struct viewdata *vd)
201 {
202         debug_log("");
203
204         if (!vd) {
205                 debug_log("vd is NULL");
206                 return FALSE;
207         }
208
209         struct priv_data *p;
210         EmailSettingUGD *ugd = vd->ugd;
211         p = vd->priv;
212
213         if (p == NULL) {
214                 p = vd->priv = calloc(1, sizeof(struct priv_data));
215                 p->vd = vd;
216
217                 p->layout = setting_add_inner_layout(vd);
218                 _push_naviframe(vd);
219
220                 /*create scroller*/
221                 p->scroller = elm_scroller_add(ugd->navi_bar);
222                 evas_object_propagate_events_set(p->scroller, EINA_FALSE);
223                 elm_scroller_bounce_set(p->scroller, EINA_FALSE, EINA_FALSE);
224                 elm_scroller_policy_set(p->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
225                 evas_object_show(p->scroller);
226
227                 elm_object_part_content_set(p->layout, "elm.swallow.content", p->scroller);
228         }
229
230         g_vd = vd;
231         ugd->wds_account_creation = 0;
232
233         if (vd->ugd->account_info != NULL) {
234                 _set_domain_string(vd);
235         }
236
237         ugd->focus_timer = ecore_timer_add(0.5, _startup_focus_cb, (void *)vd);
238
239         _create_view(vd);
240         vd->refresh = 1;
241
242         return TRUE;
243 }
244
245 static int _update(struct viewdata *vd)
246 {
247         debug_log("");
248
249         return TRUE;
250 }
251
252 static int _destroy(struct viewdata *vd)
253 {
254         debug_log("");
255         struct priv_data *p = vd->priv;
256         EmailSettingUGD *ugd = vd->ugd;
257
258         Ecore_IMF_Context *imf_context = NULL;
259         imf_context = elm_entry_imf_context_get(p->clicked_object);
260         if (imf_context) {
261                 ecore_imf_context_input_panel_hide(imf_context);
262                 ecore_imf_context_input_panel_event_callback_del(imf_context,
263                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
264         }
265
266         evas_object_del(p->l_button);
267         evas_object_del(p->r_button);
268         evas_object_del(p->genlist);
269         evas_object_del(p->tool_btn);
270
271         if (p->str_password) {
272                 g_free(p->str_password);
273                 p->str_password = NULL;
274         }
275
276         if (ugd->password_timer) {
277                 ecore_timer_del(ugd->password_timer);
278                 ugd->password_timer = NULL;
279         }
280
281         if (ugd->focus_timer) {
282                 ecore_timer_del(ugd->focus_timer);
283                 ugd->focus_timer = NULL;
284         }
285
286         if (ugd->preset_vc_timer) {
287                 ecore_timer_del(ugd->preset_vc_timer);
288                 ugd->preset_vc_timer = NULL;
289         }
290
291         if (ugd->popup_one) {
292                 evas_object_del(ugd->popup_one);
293                 ugd->popup_one = NULL;
294         }
295         if (ugd->popup_validate) {
296                 evas_object_del(ugd->popup_validate);
297                 ugd->popup_validate = NULL;
298         }
299
300         ugd->account_info = NULL;
301
302         setting_new_acct_final(vd);
303         return TRUE;
304 }
305
306 static int _show(struct viewdata *vd)
307 {
308         debug_log("");
309
310         if (!vd) {
311                 debug_log("vd is NULL");
312                 return FALSE;
313         }
314
315         evas_object_show(vd->ly);
316
317         return TRUE;
318 }
319
320 static int _hide(struct viewdata *vd)
321 {
322         debug_log("");
323
324         if (!vd) {
325                 debug_log("vd is NULL");
326                 return FALSE;
327         }
328
329         evas_object_hide(vd->ly);
330
331         return TRUE;
332 }
333
334 static void _push_naviframe(struct viewdata *vd)
335 {
336         debug_log("");
337         struct priv_data *p = vd->priv;
338
339         p->l_button = elm_button_add(vd->ugd->navi_bar);
340         elm_object_style_set(p->l_button, "naviframe/toolbar/default");
341         elm_object_focus_allow_set(p->l_button, EINA_FALSE);
342         evas_object_show(p->l_button);
343
344         if (vd->ugd->account_info == NULL) {
345                 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
346                 evas_object_smart_callback_add(p->l_button, "clicked", _next_cb, vd);
347         } else {
348                 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
349                 evas_object_smart_callback_add(p->l_button, "clicked", _save_cb, vd);
350         }
351
352         elm_object_disabled_set(p->l_button, EINA_TRUE);
353
354         p->r_button = elm_button_add(vd->ugd->navi_bar);
355         elm_object_style_set(p->r_button, "naviframe/end_btn/default");
356         /*elm_object_text_set(p->r_button, dgettext("sys_string", "IDS_COM_SK_CANCEL"));*/
357         evas_object_smart_callback_add(p->r_button, "clicked", _back_cb, vd);
358         evas_object_show(p->r_button);
359
360         p->r_button2 = elm_button_add(vd->ugd->navi_bar);
361         elm_object_style_set(p->r_button2, "naviframe/end_btn/default");
362         evas_object_smart_callback_add(p->r_button2, "clicked", _back_cb, vd);
363         evas_object_show(p->r_button2);
364
365         p->tool_btn = elm_button_add(vd->ugd->navi_bar);
366         elm_object_style_set(p->tool_btn, "naviframe/toolbar/default");
367         elm_object_text_set(p->tool_btn, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
368         if (vd->ugd->account_info == NULL) {
369                 evas_object_smart_callback_add(p->tool_btn, "clicked", _next_cb, vd);
370         } else {
371                 evas_object_smart_callback_add(p->tool_btn, "clicked", _save_cb, vd);
372         }
373
374         elm_object_disabled_set(p->tool_btn, EINA_TRUE);
375
376         Elm_Object_Item *navi_it = NULL;
377         navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, _("IDS_EMAIL_HEADER_ADD_ACCOUNT"), NULL, NULL, p->layout, NULL);
378         elm_object_item_part_content_set(navi_it, "title_toolbar_button1", p->l_button);
379         elm_object_item_part_content_set(navi_it, "title_prev_btn", p->r_button);
380         elm_object_item_part_content_set(navi_it, "toolbar_button1", p->tool_btn);
381         elm_object_item_part_content_set(navi_it, "prev_btn", p->r_button2);
382         p->navi_it = navi_it;
383         evas_object_show(vd->ugd->navi_bar);
384 }
385
386 static void _create_view(struct viewdata *vd)
387 {
388         debug_log("");
389         struct priv_data *p;
390         EmailSettingUGD *ugd;
391
392         if (!vd) {
393                 debug_log("vd is null!");
394                 return;
395         }
396
397         ugd = vd->ugd;
398         p = vd->priv;
399
400         int w, h;
401         ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
402         debug_log("WINDOW W[%d] H[%d]", w, h);
403
404         Evas_Object *sub_ly = elm_layout_add(ugd->navi_bar);
405         elm_layout_file_set(sub_ly, EV_THEME_PATH, "add_account");
406
407         evas_object_size_hint_weight_set(sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
408         evas_object_show(sub_ly);
409
410         _create_list(vd);
411         elm_object_part_content_set(sub_ly, "add_account/layout", p->genlist);
412
413         Evas_Object *check1 = elm_check_add(sub_ly);
414         elm_check_state_set(check1, EINA_FALSE);
415         evas_object_smart_callback_add(check1, "changed", _check1_clicked_cb, (void *)vd);
416         elm_object_part_content_set(sub_ly, "add_account/check1", check1);
417         elm_object_focus_allow_set(check1, EINA_FALSE);
418         p->default_account_check = check1;
419
420         Evas_Object *check2 = elm_check_add(sub_ly);
421         elm_check_state_set(check2, EINA_FALSE);
422         evas_object_smart_callback_add(check2, "changed", _check2_clicked_cb, (void *)vd);
423         elm_object_part_content_set(sub_ly, "add_account/check2", check2);
424         elm_object_focus_allow_set(check2, EINA_FALSE);
425         p->show_passwd_check = check2;
426
427         char *desc = g_strdup(_("IDS_EMAIL_BODY_SEND_EMAIL_FROM_THIS_ACCOUNT_BY_DEFAULT"));
428         Evas_Object *label1 = elm_label_add(sub_ly);
429         elm_label_wrap_width_set(label1, 600*elm_config_scale_get());
430         elm_label_line_wrap_set(label1, ELM_WRAP_WORD);
431         char *text = g_strconcat("<font_size=30><color=#7C7C7CFF><align=left>",
432                         desc, "</align></color></font_size>", NULL);
433         edje_object_signal_callback_add(elm_layout_edje_get(sub_ly),
434                         "elm,action,text1_clicked", "elm", _check1_clicked_cb2, (void *)vd);
435         elm_object_text_set(label1, text);
436         evas_object_show(label1);
437         g_free(desc);
438         g_free(text);
439         elm_object_part_content_set(sub_ly, "add_account/text1", label1);
440
441         desc = g_strdup(_("IDS_EMAIL_BODY_SHOW_PASSWORD"));
442         Evas_Object *label2 = elm_label_add(sub_ly);
443         elm_label_wrap_width_set(label2, 600*elm_config_scale_get());
444         elm_label_line_wrap_set(label2, ELM_WRAP_WORD);
445         text = g_strconcat("<font_size=30><color=#7C7C7CFF><align=left>",
446                         desc, "</align></color></font_size>", NULL);
447         edje_object_signal_callback_add(elm_layout_edje_get(sub_ly),
448                         "elm,action,text2_clicked", "elm", _check2_clicked_cb2, (void *)vd);
449         elm_object_text_set(label2, text);
450         evas_object_show(label2);
451         g_free(desc);
452         g_free(text);
453         elm_object_part_content_set(sub_ly, "add_account/text2", label2);
454
455         Evas_Object *btn = elm_button_add(sub_ly);
456         elm_object_text_set(btn, _("IDS_EMAIL_BODY_MANUAL_SETUP"));
457         evas_object_smart_callback_add(btn, "clicked", _manual_cb, (void *)vd);
458         elm_object_style_set(btn, "text_only/style2");
459         evas_object_show(btn);
460         p->manual_btn = btn;
461         elm_object_part_content_set(sub_ly, "add_account/button", btn);
462         elm_object_disabled_set(p->manual_btn, EINA_TRUE);
463
464         elm_object_content_set(p->scroller, sub_ly);
465         elm_scroller_policy_set(p->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
466 }
467
468 static void _create_list(struct viewdata *vd)
469 {
470         debug_log("");
471
472         if (!vd) {
473                 debug_critical("vd is null!");
474                 return;
475         }
476
477         struct priv_data *p;
478         EmailSettingUGD *ugd;
479         int i = 0;
480
481         ugd = vd->ugd;
482         p = vd->priv;
483
484         Elm_Object_Item *item = NULL;
485         Elm_Object_Item *git = NULL;
486
487         p->genlist = elm_genlist_add(ugd->navi_bar);
488         elm_object_style_set(p->genlist, "dialogue");
489         evas_object_show(p->genlist);
490
491         p->itc1.item_style = "dialogue/separator";
492         p->itc1.func.text_get = NULL;
493         p->itc1.func.content_get = NULL;
494         p->itc1.func.state_get = NULL;
495         p->itc1.func.del = NULL;
496
497         p->itc2.item_style = "dialogue/1icon";
498         p->itc2.func.text_get = NULL;
499         p->itc2.func.content_get = _gl_ef_content_get_cb;
500         p->itc2.func.state_get = NULL;
501         p->itc2.func.del = NULL;
502
503         p->itc3.item_style = "dialogue/grouptitle";
504         p->itc3.func.text_get = _gl_group_text_get;
505         p->itc3.func.content_get = NULL;
506         p->itc3.func.state_get = NULL;
507         p->itc3.func.del = NULL;
508
509         git = elm_genlist_item_append(p->genlist, &(p->itc3), NULL, NULL,
510                         ELM_GENLIST_ITEM_NONE, NULL, NULL);
511         elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
512
513         if (ugd->account_info == NULL) {
514                 /* Account name for OTHER */
515                 /* i = 1;
516                 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
517                                 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
518                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE); */
519
520                 /* User name */
521                 /*i = 2;
522                 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
523                 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
524         }
525
526         /* Display name */
527         /*i = 3;
528         item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
529         ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
530
531         /* Email address */
532         i = 4;
533         p->gl_email_address_item = item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL,
534                         ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
535         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
536
537         /* Password */
538         i = 5;
539         p->gl_pw_item = item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL,
540                         ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
541         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
542
543         evas_object_smart_callback_add(p->genlist, "realized", _gl_realized_cb, (void *)vd);
544 }
545
546 static void _create_validation_popup(struct viewdata *vd, int account_id)
547 {
548         debug_log("");
549
550         if (!vd) {
551                 debug_critical("vd is null!");
552                 return;
553         }
554
555         email_account_t *account = vd->ugd->new_account;
556
557         debug_log("account id:%d", account_id);
558         debug_log("account name:%s", account->account_name);
559         debug_log("email address:%s", account->user_email_address);
560
561         vd->ugd->account_id = account_id;
562
563         EmailSettingUGD *ugd = vd->ugd;
564         struct priv_data *p = vd->priv;
565
566         if (ugd->popup_one) {
567                 evas_object_del(ugd->popup_one);
568                 ugd->popup_one = NULL;
569         }
570         if (ugd->popup_validate) {
571                 evas_object_del(ugd->popup_validate);
572                 ugd->popup_validate = NULL;
573         }
574
575         vd->ugd->cancel_event = 0;
576         elm_object_disabled_set(p->l_button, EINA_TRUE);
577         elm_object_disabled_set(p->r_button, EINA_TRUE);
578         elm_object_disabled_set(p->r_button2, EINA_TRUE);
579         elm_object_disabled_set(p->manual_btn, EINA_TRUE);
580         elm_object_disabled_set(p->tool_btn, EINA_TRUE);
581
582         debug_log("Start Account Validation");
583         ugd->popup_validate = setting_get_pb_process_notify(vd,
584                         _("IDS_EMAIL_POP_VALIDATING_ACCOUNT_ING"), 1,
585                         dgettext("sys_string", "IDS_COM_SK_CANCEL"),
586                         _popup_cancel_validation_cb, NULL, NULL);
587 }
588
589 static void _create_account(void *data)
590 {
591         debug_log("");
592
593         struct viewdata *vd = (struct viewdata *)data;
594
595         if (!vd) {
596                 debug_critical("vd is null!");
597                 return;
598         }
599
600         EmailSettingUGD *ugd = vd->ugd;
601         int account_id;
602         struct priv_data *p = vd->priv;
603         int error_code = 0;
604
605         if (email_engine_add_account_with_validation(vd->ugd->new_account,
606                         &account_id, &(p->handle), &error_code)) {
607                 debug_log("Account added to Email Service DB");
608                 vd->ugd->start_account_validation = 1;
609                 ugd->handle = p->handle;
610                 _create_validation_popup(vd, account_id);
611         } else {
612                 debug_log("Fail to make account");
613
614                 if (ugd->popup_one) {
615                         evas_object_del(ugd->popup_one);
616                         ugd->popup_one = NULL;
617                 }
618                 if (ugd->popup_validate) {
619                         evas_object_del(ugd->popup_validate);
620                         ugd->popup_validate = NULL;
621                 }
622
623                 if (error_code == EMAIL_ERROR_ALREADY_EXISTS)
624                         ugd->popup_one = setting_get_notify(vd,
625                                         dgettext("sys_string", "IDS_COM_POP_WARNING"),
626                                         dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 1,
627                                         dgettext("sys_string", "IDS_COM_SK_OK"),
628                                         _popup_ok_cb, NULL, NULL);
629                 else
630                         ugd->popup_one = setting_get_notify(vd,
631                                         dgettext("sys_string", "IDS_COM_POP_WARNING"),
632                                         _("IDS_EMAIL_POP_UNABLE_TO_ADD_ACCOUNT"), 1,
633                                         dgettext("sys_string", "IDS_COM_SK_OK"),
634                                         _popup_ok_cb, NULL, NULL);
635         }
636         return;
637 }
638
639 static int _check_null_field(struct viewdata *vd)
640 {
641         debug_log("");
642
643         if (vd->ugd->new_account == NULL) {
644                 debug_log("new_account is NULL");
645                 return FALSE;
646         }
647
648         email_account_t *account = vd->ugd->new_account;
649
650         if (account->account_name == NULL || strlen(account->account_name) == 0 ||
651             /*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
652             account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
653             /*account->incoming_server_user_name == NULL || strlen(account->incoming_server_user_name) == 0 ||*/
654             account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
655                 return FALSE;
656         else
657                 return TRUE;
658 }
659
660 static int _check_preset_null_field(struct viewdata *vd)
661 {
662         debug_log("");
663
664         if (vd->ugd->new_account == NULL) {
665                 debug_log("new_account is NULL");
666                 return FALSE;
667         }
668
669         email_account_t *account = vd->ugd->new_account;
670
671         if (/*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
672                 account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
673                 account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
674                 return FALSE;
675         else
676                 return TRUE;
677 }
678
679 static int _check_preset_isp_name(char *addr, EmailSpDesc *desc)
680 {
681         debug_log("");
682         int ret = FALSE;
683
684         if (g_strcmp0(desc->id, "Hotmail") == 0) {
685                 char *ptr1 = NULL;
686                 char *ptr2 = NULL;
687                 ptr1 = g_strrstr(addr, "@hotmail.");
688                 ptr2 = g_strrstr(addr, "@live.");
689
690                 if (ptr1 != NULL || ptr2 != NULL)
691                         ret = TRUE;
692         } /*else if (g_strcmp0(desc->id, "Gmail") == 0) {
693                 ret = g_str_has_suffix(addr, "@gmail.com") ||
694                                 g_str_has_suffix(addr, "@googlemail.com");
695         }*/ else if (g_strcmp0(desc->id, "AOL") == 0) {
696                 char *ptr1 = NULL;
697                 char *ptr2 = NULL;
698                 ptr1 = g_strrstr(addr, "@aol.");
699                 ptr2 = g_strrstr(addr, "@aim.");
700
701                 if (ptr1 != NULL || ptr2 != NULL)
702                         ret = TRUE;
703         } else {
704                 ret = TRUE;
705         }
706
707         return ret;
708 }
709
710 static void _read_all_entries(struct viewdata *vd)
711 {
712         debug_log("");
713
714         struct priv_data *p;
715         p = vd->priv;
716         /*char *buf;*/
717
718         if (!p) {
719                 debug_log("priv is NULL");
720                 return;
721         }
722
723         if (vd->ugd->new_account)
724                 setting_new_acct_final(vd);
725
726         setting_new_acct_init(vd);
727         email_account_t *account = vd->ugd->new_account;
728
729         /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_email_address));*/
730         if (p->entry_email_address) {
731                 /*buf = (char *)elm_entry_entry_get(p->entry_email_address);
732                 debug_log("email addr : %s", buf);
733                 if (buf)
734                         account->user_email_address = g_strdup(buf);*/
735                 account->user_email_address = g_strdup(p->str_email_address);
736         }
737
738         if (vd->ugd->account_info == NULL) {
739                 if (p->entry_email_address) {
740                         gchar **token1 = NULL;
741                         gchar **token2 = NULL;
742
743                         token1 = g_strsplit(p->str_email_address, "@", -1);
744                         if (token1[1])
745                                 token2 = g_strsplit(token1[1], ".", -1);
746
747                         if (token2)
748                                 account->account_name = g_strdup(token2[0] ? token2[0] : "Other");
749
750                         g_strfreev(token1);
751                         g_strfreev(token2);
752                 }
753                 else
754                         account->account_name = g_strdup("Other");
755         }
756
757         if (p->entry_password) {
758                 /*buf = (char *)elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_password));
759                 debug_log("password : %s", buf);
760                 if (buf) {
761                         account->incoming_server_password = g_strdup(buf);
762                         g_free(buf);
763                 }*/
764
765                 account->incoming_server_password = g_strdup(p->str_password);
766         }
767 }
768
769 static void _set_domain_string(struct viewdata *vd)
770 {
771         debug_log("");
772         EmailSettingUGD *ugd = vd->ugd;
773         struct priv_data *p;
774         p = vd->priv;
775
776         if (g_strcmp0(ugd->account_info->id, "Hotmail") == 0) {
777                 p->str_email_address = g_strdup("@hotmail.com");
778         } else if (g_strcmp0(ugd->account_info->id, "Yahoomail") == 0) {
779                 p->str_email_address = g_strdup("@yahoo.com");
780         } else if (g_strcmp0(ugd->account_info->id, "Gmail") == 0) {
781                 p->str_email_address = g_strdup("@gmail.com");
782         } else if (g_strcmp0(ugd->account_info->id, "AOL") == 0) {
783                 p->str_email_address = g_strdup("@aol.com");
784         } else {
785                 debug_log("Unknown account type");
786         }
787 }
788
789 static void _next_cb(void *data, Evas_Object *obj, void *event_info)
790 {
791         debug_log("");
792
793         struct viewdata *vd = (struct viewdata *)data;
794
795         if (vd == NULL) {
796                 debug_log("vd is NULL");
797                 return;
798         }
799
800         struct priv_data *p = NULL;
801         EmailSettingUGD *ugd = NULL;
802         char *buf = NULL;
803         int ret = 0;
804
805         p = vd->priv;
806         ugd = vd->ugd;
807
808         Ecore_IMF_Context *imf_context = NULL;
809         imf_context = elm_entry_imf_context_get(p->clicked_object);
810         if (imf_context) {
811                 ecore_imf_context_input_panel_hide(imf_context);
812         }
813
814         /* Save the Account Data */
815         _read_all_entries(vd);
816         email_account_t *account = vd->ugd->new_account;
817
818         debug_log("accountStructure Info");
819         debug_log("Account Name:%s", account->account_name);
820         debug_log("Display Name:%s", account->user_display_name);
821         debug_log("Email Addr:%s", account->user_email_address);
822         debug_log("User Name:%s", account->incoming_server_user_name);
823         debug_log("User Password:%s", account->incoming_server_password);
824
825         if (ugd->popup_one) {
826                 evas_object_del(ugd->popup_one);
827                 ugd->popup_one = NULL;
828         }
829         if (ugd->popup_validate) {
830                 evas_object_del(ugd->popup_validate);
831                 ugd->popup_validate = NULL;
832         }
833
834         /* check Null field */
835         ret = _check_null_field(vd);
836         if (!ret) {
837                 ugd->popup_one = setting_get_notify(vd,
838                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
839                                 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
840                                 dgettext("sys_string", "IDS_COM_SK_OK"),
841                                 _popup_ok_cb, NULL, NULL);
842                 return;
843         }
844
845         /* check character validation */
846         buf = g_strdup(account->user_email_address);
847
848         ret = email_get_address_validation(buf);
849         if (!ret) {
850                 ugd->popup_one = setting_get_notify(vd,
851                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
852                                 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
853                                 dgettext("sys_string", "IDS_COM_SK_OK"),
854                                 _popup_ok_cb, NULL, NULL);
855
856                 free(buf);
857                 return;
858         }
859         g_free(buf);
860
861         setting_change_view(VIEW_MANUAL_SETUP, ugd);
862
863         return;
864 }
865
866 static void _save_cb(void *data, Evas_Object *obj, void *event_info)
867 {
868         debug_log("");
869         struct viewdata *vd = (struct viewdata *)data;
870
871         if (vd == NULL) {
872                 debug_log("vd is NULL");
873                 return;
874         }
875
876         struct priv_data *p = NULL;
877         EmailSettingUGD *ugd = NULL;
878         char *buf = NULL;
879         int ret = 0;
880
881         p = vd->priv;
882         ugd = vd->ugd;
883
884         Ecore_IMF_Context *imf_context = NULL;
885         imf_context = elm_entry_imf_context_get(p->clicked_object);
886         if (imf_context) {
887                 ecore_imf_context_input_panel_hide(imf_context);
888         }
889
890         /* Save the data */
891         _read_all_entries(vd);
892         email_account_t *account = vd->ugd->new_account;
893
894         debug_log("accountStructure Info");
895         debug_log("Display Name:%s", account->user_display_name);
896         debug_log("Email Addr:%s", account->user_email_address);
897         debug_log("User Password:%s", account->incoming_server_password);
898
899         if (ugd->popup_one) {
900                 evas_object_del(ugd->popup_one);
901                 ugd->popup_one = NULL;
902         }
903         if (ugd->popup_validate) {
904                 evas_object_del(ugd->popup_validate);
905                 ugd->popup_validate = NULL;
906         }
907
908         /* check Null field */
909         ret = _check_preset_null_field(vd);
910         if (!ret) {
911                 debug_log("empty space in account info");
912                 ugd->popup_one = setting_get_notify(vd,
913                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
914                                 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"),
915                                 1, dgettext("sys_string", "IDS_COM_SK_OK"),
916                                 _popup_ok_cb, NULL, NULL);
917                 return;
918         }
919
920         /* check ISP */
921         buf = g_strdup(account->user_email_address);
922         ret = _check_preset_isp_name(buf, ugd->account_info);
923         if (ret == FALSE) {
924                 debug_log("wrong ISP server name for preset accounts");
925                 ugd->popup_one = setting_get_notify(vd,
926                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
927                                 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
928                                 1, dgettext("sys_string", "IDS_COM_SK_OK"),
929                                 _popup_ok_cb, NULL, NULL);
930                 free(buf);
931                 return;
932         }
933         g_free(buf);
934
935         /* check character validation */
936         buf = g_strdup(account->user_email_address);
937
938         ret = email_get_address_validation(buf);
939         if (!ret) {
940                 debug_log("Wrong character in email address");
941                 ugd->popup_one = setting_get_notify(vd,
942                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
943                                 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
944                                 1, dgettext("sys_string", "IDS_COM_SK_OK"),
945                                 _popup_ok_cb, NULL, NULL);
946                 free(buf);
947                 return;
948         }
949         g_free(buf);
950
951         /* account info setting */
952         setting_set_account(vd);
953
954         _create_account(vd);
955 }
956
957 static void _manual_cb(void *data, Evas_Object *obj, void *event_info)
958 {
959         debug_log("");
960
961         struct viewdata *vd = (struct viewdata *)data;
962
963         if (vd == NULL) {
964                 debug_log("vd is NULL");
965                 return;
966         }
967
968         EmailSettingUGD *ugd = NULL;
969         char *buf = NULL;
970         int ret = 0;
971
972         ugd = vd->ugd;
973
974         /* Save the Account Data */
975         _read_all_entries(vd);
976         email_account_t *account = vd->ugd->new_account;
977
978         debug_log("accountStructure Info");
979         debug_log("Account Name:%s", account->account_name);
980         debug_log("Display Name:%s", account->user_display_name);
981         debug_log("Email Addr:%s", account->user_email_address);
982         debug_log("User Name:%s", account->incoming_server_user_name);
983         debug_log("User Password:%s", account->incoming_server_password);
984
985         if (ugd->popup_one) {
986                 evas_object_del(ugd->popup_one);
987                 ugd->popup_one = NULL;
988         }
989         if (ugd->popup_validate) {
990                 evas_object_del(ugd->popup_validate);
991                 ugd->popup_validate = NULL;
992         }
993
994         /* check Null field */
995         ret = _check_preset_null_field(vd);
996         if (!ret) {
997                 ugd->popup_one = setting_get_notify(vd,
998                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
999                                 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
1000                                 dgettext("sys_string", "IDS_COM_SK_OK"),
1001                                 _popup_ok_cb, NULL, NULL);
1002                 return;
1003         }
1004
1005         /* check ISP */
1006         if (ugd->account_info) {
1007                 buf = g_strdup(account->user_email_address);
1008                 ret = _check_preset_isp_name(buf, ugd->account_info);
1009                 if (ret == FALSE) {
1010                         debug_log("wrong ISP server name for preset accounts");
1011                         ugd->popup_one = setting_get_notify(vd,
1012                                         dgettext("sys_string", "IDS_COM_POP_WARNING"),
1013                                         _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
1014                                         1, dgettext("sys_string", "IDS_COM_SK_OK"),
1015                                         _popup_ok_cb, NULL, NULL);
1016                         free(buf);
1017                         return;
1018                 }
1019                 g_free(buf);
1020         }
1021
1022         /* check character validation */
1023         buf = g_strdup(account->user_email_address);
1024
1025         ret = email_get_address_validation(buf);
1026         if (!ret) {
1027                 ugd->popup_one = setting_get_notify(vd,
1028                                 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1029                                 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
1030                                 dgettext("sys_string", "IDS_COM_SK_OK"),
1031                                 _popup_ok_cb, NULL, NULL);
1032
1033                 free(buf);
1034                 return;
1035         }
1036
1037         g_free(buf);
1038
1039         /* account info setting */
1040         setting_set_account(vd);
1041
1042         setting_change_view(VIEW_MANUAL_SETUP, ugd);
1043
1044         return;
1045 }
1046
1047 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
1048 {
1049         debug_log("");
1050
1051         struct viewdata *vd = (struct viewdata *)data;
1052         struct priv_data *p = vd->priv;
1053
1054         if (vd->ugd->atomic_pop) {
1055                 debug_log("During atomic poping");
1056                 return;
1057         }
1058
1059         if (!strcmp(vd->ugd->start_view_type, "account-add")) {
1060                 ug_destroy_me(vd->ugd->ug);
1061         } else if (!strcmp(vd->ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP)) {
1062                 elm_win_lower(vd->ugd->win);
1063     } else if (!strcmp(vd->ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_SELECT_ACCOUNT)) {
1064                 ug_destroy_me(vd->ugd->ug);
1065         } else {
1066                 setting_back_to_prev_view(vd);
1067         }
1068 }
1069
1070 static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1071 {
1072         debug_log("");
1073         struct viewdata *vd = (struct viewdata *)data;
1074
1075         if (vd == NULL) {
1076                 debug_log("vd is NULL");
1077                 return;
1078         }
1079
1080         struct priv_data *p = vd->priv;
1081         Eina_Bool state = elm_check_state_get(obj);
1082
1083         if (state) {
1084                 p->set_default_account = 1;
1085         } else
1086                 p->set_default_account = 0;
1087 }
1088
1089 static void _check1_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1090 {
1091         debug_log("");
1092         struct viewdata *vd = (struct viewdata *)data;
1093
1094         if (vd == NULL) {
1095                 debug_log("vd is NULL");
1096                 return;
1097         }
1098
1099         struct priv_data *p = vd->priv;
1100         Eina_Bool state = elm_check_state_get(p->default_account_check);
1101
1102         if (state) {
1103                 elm_check_state_set(p->default_account_check, EINA_FALSE);
1104                 p->set_default_account = 0;
1105         } else {
1106                 elm_check_state_set(p->default_account_check, EINA_TRUE);
1107                 p->set_default_account = 1;
1108         }
1109 }
1110
1111 static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1112 {
1113         debug_log("");
1114         struct viewdata *vd = (struct viewdata *)data;
1115
1116         if (vd == NULL) {
1117                 debug_log("vd is NULL");
1118                 return;
1119         }
1120
1121         struct priv_data *p = vd->priv;
1122         EmailSettingUGD *ugd = NULL;
1123         ugd = vd->ugd;
1124
1125         Eina_Bool state = elm_check_state_get(obj);
1126
1127         if (state)
1128                 elm_entry_password_set(p->entry_password, EINA_FALSE);
1129         else
1130                 elm_entry_password_set(p->entry_password, EINA_TRUE);
1131
1132         if (elm_object_focus_get(p->entry_password)) {
1133                 if (ugd->password_timer) {
1134                         ecore_timer_del(ugd->password_timer);
1135                         ugd->password_timer = NULL;
1136                 }
1137                 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1138
1139                 Ecore_IMF_Context *imf_context = NULL;
1140                 imf_context = elm_entry_imf_context_get(p->entry_password);
1141                 int state = ecore_imf_context_input_panel_state_get(imf_context);
1142
1143                 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1144                         debug_log("input panel show");
1145                         elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1146                 }
1147         }
1148 }
1149
1150 static void _check2_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1151 {
1152         debug_log("");
1153         struct viewdata *vd = (struct viewdata *)data;
1154
1155         if (vd == NULL) {
1156                 debug_log("vd is NULL");
1157                 return;
1158         }
1159
1160         struct priv_data *p = vd->priv;
1161         EmailSettingUGD *ugd = NULL;
1162         ugd = vd->ugd;
1163
1164         Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1165
1166         if (state) {
1167                 elm_check_state_set(p->show_passwd_check, EINA_FALSE);
1168                 elm_entry_password_set(p->entry_password, EINA_TRUE);
1169         } else {
1170                 elm_check_state_set(p->show_passwd_check, EINA_TRUE);
1171                 elm_entry_password_set(p->entry_password, EINA_FALSE);
1172         }
1173
1174         if (elm_object_focus_get(p->entry_password)) {
1175                 if (ugd->password_timer) {
1176                         ecore_timer_del(ugd->password_timer);
1177                         ugd->password_timer = NULL;
1178                 }
1179                 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1180
1181                 Ecore_IMF_Context *imf_context = NULL;
1182                 imf_context = elm_entry_imf_context_get(p->entry_password);
1183                 int state = ecore_imf_context_input_panel_state_get(imf_context);
1184
1185                 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1186                         debug_log("input panel show");
1187                         elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1188                 }
1189         }
1190 }
1191
1192 static Eina_Bool _after_validation_cb(void *data)
1193 {
1194         debug_log("");
1195
1196         struct viewdata *vd = (struct viewdata *)data;
1197
1198         if (vd == NULL) {
1199                 debug_log("vd is NULL");
1200                 return ECORE_CALLBACK_CANCEL;
1201         }
1202
1203         EmailSettingUGD *ugd = NULL;
1204         struct priv_data *p = NULL;
1205
1206         ugd = vd->ugd;
1207         p = vd->priv;
1208
1209         if (ugd->preset_vc_timer) {
1210                 ecore_timer_del(ugd->preset_vc_timer);
1211                 ugd->preset_vc_timer = NULL;
1212         }
1213
1214         if (ugd->popup_one) {
1215                 evas_object_del(ugd->popup_one);
1216                 ugd->popup_one = NULL;
1217         }
1218         if (ugd->popup_validate) {
1219                 evas_object_del(ugd->popup_validate);
1220                 ugd->popup_validate = NULL;
1221         }
1222
1223         if (p->set_default_account) {
1224                 if (email_engine_set_default_account(vd->ugd->account_id)) {
1225                         debug_log("new default account is %d", vd->ugd->account_id);
1226                 }
1227         }
1228
1229         status_message_post(_("IDS_EMAIL_POP_SUCCEEDED"));
1230
1231         setting_change_view(VIEW_SYNC_SETUP, ugd);
1232
1233
1234         /*debug_log("_after_validation_cb %s", vd->ugd->start_view_type);
1235
1236         if (vd->ugd->start_view_type != NULL &&
1237                         strcmp(vd->ugd->start_view_type, "first-setup") == 0) {
1238                 ug_destroy_me(vd->ugd->ug);
1239         } else if (vd->ugd->start_view_type != NULL &&
1240                         strcmp(vd->ugd->start_view_type, "account-add") == 0) {
1241                 ug_destroy_me(vd->ugd->ug);
1242         } else if (vd->ugd->start_view_type != NULL &&
1243                         strcmp(vd->ugd->start_view_type, "select-account") == 0) {
1244                 service_h service = NULL;
1245                 service_create(&service);
1246                 if (service) {
1247                         service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT);
1248                         ug_send_result(vd->ugd->ug, service);
1249                         service_destroy(service);
1250                 }
1251         } else {
1252                 setting_update_acct_list(vd);
1253                 setting_back_to_prev_nth_view(vd, 2, vd->ugd->navi_main_it);
1254                 vd->ugd->atomic_pop = 0;
1255         }*/
1256
1257         return ECORE_CALLBACK_CANCEL;
1258 }
1259
1260 static Eina_Bool _password_state_cb(void *data)
1261 {
1262         debug_log("");
1263
1264         struct viewdata *vd = (struct viewdata *)data;
1265
1266         if (vd == NULL) {
1267                 debug_log("vd is NULL");
1268                 return ECORE_CALLBACK_CANCEL;
1269         }
1270
1271         struct priv_data *p = NULL;
1272         p = vd->priv;
1273         EmailSettingUGD *ugd = NULL;
1274         ugd = vd->ugd;
1275
1276         if (ugd->password_timer) {
1277                 ecore_timer_del(ugd->password_timer);
1278                 ugd->password_timer = NULL;
1279         }
1280
1281         Ecore_IMF_Context *imf_context = NULL;
1282         imf_context = elm_entry_imf_context_get(p->entry_password);
1283         if (imf_context) {
1284                 ecore_imf_context_input_panel_event_callback_del(imf_context,
1285                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1286                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1287                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1288                                 _input_panel_state_changed_cb, (void *)vd);
1289         }
1290
1291         return ECORE_CALLBACK_CANCEL;
1292 }
1293
1294 static Eina_Bool _startup_focus_cb(void *data)
1295 {
1296         debug_log("");
1297
1298         struct viewdata *vd = (struct viewdata *)data;
1299
1300         if (vd == NULL) {
1301                 debug_log("vd is NULL");
1302                 return ECORE_CALLBACK_CANCEL;
1303         }
1304
1305         struct priv_data *p = NULL;
1306         p = vd->priv;
1307
1308         EmailSettingUGD *ugd = NULL;
1309         ugd = vd->ugd;
1310
1311         if (ugd->focus_timer) {
1312                 ecore_timer_del(ugd->focus_timer);
1313                 ugd->focus_timer = NULL;
1314         }
1315
1316         p->clicked_object = p->entry_email_address;
1317         elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1318         elm_entry_cursor_begin_set(p->entry_email_address);
1319
1320         return ECORE_CALLBACK_CANCEL;
1321 }
1322
1323 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1324 {
1325         debug_log("");
1326         if (!data) {
1327                 debug_log("data is NULL");
1328                 return;
1329         }
1330
1331         struct viewdata *vd = (struct viewdata *)data;
1332         EmailSettingUGD *ugd = vd->ugd;
1333         struct priv_data *p = vd->priv;
1334
1335         if (ugd->popup_one) {
1336                 evas_object_del(ugd->popup_one);
1337                 ugd->popup_one = NULL;
1338         }
1339         if (ugd->popup_validate) {
1340                 evas_object_del(ugd->popup_validate);
1341                 ugd->popup_validate = NULL;
1342         }
1343
1344         elm_object_disabled_set(p->l_button, EINA_FALSE);
1345         elm_object_disabled_set(p->r_button, EINA_FALSE);
1346         elm_object_disabled_set(p->r_button2, EINA_FALSE);
1347         elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1348         elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1349 }
1350
1351 /*static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1352 {
1353         debug_log("");
1354         if (!data) {
1355                 debug_log("data is NULL");
1356                 return;
1357         }
1358
1359         struct viewdata *vd = (struct viewdata *)data;
1360         EmailSettingUGD *ugd = vd->ugd;
1361         struct priv_data *p = vd->priv;
1362
1363         if (ugd->popup_one) {
1364                 evas_object_del(ugd->popup_one);
1365                 ugd->popup_one = NULL;
1366         }
1367         if (ugd->popup_validate) {
1368                 evas_object_del(ugd->popup_validate);
1369                 ugd->popup_validate = NULL;
1370         }
1371
1372         elm_object_disabled_set(p->r_button, EINA_FALSE);
1373         elm_object_disabled_set(p->r_button2, EINA_FALSE);
1374 }*/
1375
1376 static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info)
1377 {
1378         debug_log("");
1379         if (!data) {
1380                 debug_log("data is NULL");
1381                 return;
1382         }
1383
1384         struct viewdata *vd = (struct viewdata *)data;
1385         EmailSettingUGD *ugd = vd->ugd;
1386         struct priv_data *p = vd->priv;
1387
1388         if (ugd->popup_one) {
1389                 evas_object_del(ugd->popup_one);
1390                 ugd->popup_one = NULL;
1391         }
1392         if (ugd->popup_validate) {
1393                 evas_object_del(ugd->popup_validate);
1394                 ugd->popup_validate = NULL;
1395         }
1396
1397         int account_id = vd->ugd->account_id;
1398         vd->ugd->cancel_event = 1;
1399         email_engine_stop_working(account_id, p->handle);
1400         email_engine_delete_account(account_id);
1401
1402         elm_object_disabled_set(p->l_button, EINA_FALSE);
1403         elm_object_disabled_set(p->r_button, EINA_FALSE);
1404         elm_object_disabled_set(p->r_button2, EINA_FALSE);
1405         elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1406         elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1407 }
1408
1409 static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info)
1410 {
1411         debug_log("");
1412         Evas_Object *eo = (Evas_Object *)obj;
1413         struct viewdata *vd = g_vd;
1414         if (vd == NULL)
1415                 return;
1416
1417         struct priv_data *p = vd->priv;
1418         if (p == NULL)
1419                 return;
1420
1421         EmailSettingUGD *ugd = vd->ugd;
1422         if (ugd == NULL)
1423                 return;
1424
1425         if (elm_object_focus_get(data)) {
1426                 if (elm_entry_is_empty(obj))
1427                         elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1428                 else
1429                         elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1430         }
1431
1432         if (eo == p->entry_user_id) {
1433                 debug_log("entry_user_id");
1434                 if (p->str_user_id) {
1435                         g_free(p->str_user_id);
1436                         p->str_user_id = NULL;
1437                 }
1438
1439                 p->str_user_id = g_strdup(elm_entry_entry_get(eo));
1440         } else if (eo == p->entry_display_name) {
1441                 debug_log("entry_display_name");
1442                 if (p->str_display_name) {
1443                         g_free(p->str_display_name);
1444                         p->str_display_name = NULL;
1445                 }
1446
1447                 p->str_display_name = g_strdup(elm_entry_entry_get(eo));
1448         } else if (eo == p->entry_email_address) {
1449                 debug_log("entry_email_address");
1450                 if (p->str_email_address) {
1451                         g_free(p->str_email_address);
1452                         p->str_email_address = NULL;
1453                 }
1454
1455                 p->str_email_address = g_strdup(elm_entry_entry_get(eo));
1456         } else if (eo == p->entry_password) {
1457                 debug_log("entry_password");
1458                 if (p->str_password) {
1459                         g_free(p->str_password);
1460                         p->str_password = NULL;
1461                 }
1462
1463                 p->str_password = g_strdup(elm_entry_entry_get(eo));
1464         }
1465
1466         if (p->str_email_address == NULL || p->str_password == NULL) {
1467                 elm_object_disabled_set(p->l_button, EINA_TRUE);
1468                 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1469                 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1470                 return;
1471         }
1472
1473         if (g_strcmp0(p->str_email_address, "") == 0 || g_strcmp0(p->str_password, "") == 0) {
1474                 elm_object_disabled_set(p->l_button, EINA_TRUE);
1475                 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1476                 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1477         } else {
1478                 elm_object_disabled_set(p->l_button, EINA_FALSE);
1479                 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1480                 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1481         }
1482 }
1483
1484 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
1485 {
1486         debug_log("");
1487
1488         if (!obj) {
1489                 debug_log("obj is NULL");
1490                 return;
1491         }
1492
1493         struct viewdata *vd = g_vd;
1494         struct priv_data *p = vd->priv;
1495
1496         if (obj == p->entry_password) {
1497                 Ecore_IMF_Context *imf_context = NULL;
1498                 imf_context = elm_entry_imf_context_get(p->entry_password);
1499                 if (imf_context) {
1500                         ecore_imf_context_input_panel_event_callback_del(imf_context,
1501                                         ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1502                         ecore_imf_context_input_panel_event_callback_add(imf_context,
1503                                         ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1504                                         _input_panel_state_changed_cb, (void *)vd);
1505                 }
1506         }
1507
1508         if (!elm_entry_is_empty(obj))
1509                 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1510         elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
1511 }
1512
1513 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
1514 {
1515         debug_log("");
1516
1517         if (!obj) {
1518                 debug_log("obj is NULL");
1519                 return;
1520         }
1521
1522         if (elm_entry_is_empty(obj))
1523                 elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
1524         elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1525 }
1526
1527 static void _entry_theme_changed_cb(void *data, Evas_Object *obj, void *event_info)
1528 {
1529         debug_log("");
1530
1531         if (!obj) {
1532                 debug_log("obj is NULL");
1533                 return;
1534         }
1535
1536         struct viewdata *vd = (struct viewdata *)data;
1537
1538         if (vd == NULL) {
1539                 debug_log("vd is NULL");
1540                 return;
1541         }
1542
1543         struct priv_data *p = NULL;
1544         p = vd->priv;
1545
1546         Ecore_IMF_Context *imf_context = NULL;
1547         imf_context = elm_entry_imf_context_get(p->entry_password);
1548         if (imf_context) {
1549                 ecore_imf_context_input_panel_event_callback_del(imf_context,
1550                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1551                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1552                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1553                                 _input_panel_state_changed_cb, (void *)vd);
1554         }
1555 }
1556
1557 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1558 {
1559         debug_log("");
1560
1561         if (!obj) {
1562                 debug_log("obj is NULL");
1563                 return;
1564         }
1565
1566         elm_entry_entry_set(data, "");
1567 }
1568
1569 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
1570 {
1571         debug_log("");
1572
1573         if (!data) {
1574                 debug_log("data is NULL");
1575                 return;
1576         }
1577
1578         struct viewdata *vd = (struct viewdata *)data;
1579         struct priv_data *p = vd->priv;
1580
1581         int state = ecore_imf_context_input_panel_state_get(ctx);
1582
1583         if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1584                 debug_log("state:SHOW");
1585         else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1586                 debug_log("state HIDE");
1587
1588         if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1589                 debug_log("value:SHOW");
1590         else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1591                 debug_log("value HIDE");
1592
1593         if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
1594                 debug_log("input panel show");
1595                 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1596         } else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1597                 debug_log("input panel hide");
1598                 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,hidden", "");
1599         }
1600 }
1601
1602 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info)
1603 {
1604         debug_log("");
1605         int index = (int)data;
1606         struct viewdata *vd = g_vd;
1607         struct priv_data *p = vd->priv;
1608
1609         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1610         elm_genlist_item_selected_set(item, EINA_FALSE);
1611
1612         if (index == 1) {
1613                 p->clicked_object = p->entry_account_name;
1614         } else if (index == 2) {
1615                 p->clicked_object = p->entry_user_id;
1616         } else if (index == 3) {
1617                 p->clicked_object = p->entry_display_name;
1618         } else if (index == 4) {
1619                 p->clicked_object = p->entry_email_address;
1620         } else if (index == 5) {
1621                 p->clicked_object = p->entry_password;
1622         }
1623 }
1624
1625 static char *_gl_group_text_get(void *data, Evas_Object *obj, const char *part)
1626 {
1627         debug_log("");
1628
1629         struct viewdata *vd = g_vd;
1630
1631         if (!strcmp(part, "elm.text")) {
1632                 char title_str[MAX_STR_LEN] = { 0, };
1633                 if (vd->ugd->account_info) {
1634                         if (g_str_has_prefix(vd->ugd->account_info->name_str_id, "IDS_EMAIL"))
1635                                 snprintf(title_str, sizeof(title_str), "%s", _(vd->ugd->account_info->name_str_id));
1636                         else
1637                                 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", vd->ugd->account_info->name_str_id));
1638                 } else {
1639                         snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_OTHERS"));
1640                 }
1641
1642                 return g_strdup(title_str);
1643         }
1644
1645         return NULL;
1646 }
1647
1648 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part)
1649 {
1650         debug_log("");
1651         int index = (int)data;
1652         struct viewdata *vd = g_vd;
1653         struct priv_data *p = vd->priv;
1654         //EmailSettingUGD *ugd = vd->ugd;
1655         Ecore_IMF_Context *imf_context = NULL;
1656
1657         if (!strcmp(part, "elm.icon")) {
1658                 if (index == 1) {
1659                         //p->icon_get_cnt1++;
1660
1661                         debug_log("");
1662                         p->ef_account_name = elm_layout_add(p->genlist);
1663                         elm_layout_theme_set(p->ef_account_name, "layout", "editfield", "title");
1664                         p->entry_account_name = elm_entry_add(p->genlist);
1665                         elm_entry_scrollable_set(p->entry_account_name, EINA_TRUE);
1666                         elm_entry_single_line_set(p->entry_account_name, EINA_TRUE);
1667                         elm_entry_input_panel_return_key_disabled_set(p->entry_account_name, EINA_TRUE);
1668                         elm_entry_cnp_mode_set(p->entry_account_name, ELM_CNP_MODE_PLAINTEXT);
1669                         elm_entry_input_panel_layout_set(p->entry_account_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1670                         elm_entry_editable_set(p->entry_account_name, TRUE);
1671                         evas_object_smart_callback_add(p->entry_account_name, "changed", _backup_input_cb, p->ef_account_name);
1672                         evas_object_smart_callback_add(p->entry_account_name, "focused", _entry_focused_cb, p->ef_account_name);
1673                         evas_object_smart_callback_add(p->entry_account_name, "unfocused", _entry_unfocused_cb, p->ef_account_name);
1674                         evas_object_show(p->entry_account_name);
1675
1676                         imf_context = elm_entry_imf_context_get(p->entry_account_name);
1677                         if (imf_context)
1678                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1679                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1680                                                 _input_panel_state_changed_cb, (void *)vd);
1681
1682                         elm_object_part_content_set(p->ef_account_name, "elm.swallow.content", p->entry_account_name);
1683                         /*elm_object_part_text_set(p->ef_account_name, "elm.guidetext", str);*/
1684                         elm_object_part_text_set(p->ef_account_name, "elm.text", _("IDS_EMAIL_BODY_ACCOUNT_NAME"));
1685                         elm_object_signal_callback_add(p->ef_account_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_account_name);
1686
1687                         evas_object_size_hint_weight_set(p->ef_account_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1688                         evas_object_show(p->ef_account_name);
1689
1690                         if (p->str_account_name)
1691                                 elm_entry_entry_set(p->entry_account_name, p->str_account_name);
1692
1693                         /*if (ugd->account_info == NULL && p->icon_get_cnt1 == 2 &&
1694                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1695                                 p->clicked_object = p->entry_account_name;
1696                                 evas_object_show(p->entry_account_name);
1697                                 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1698                         }
1699
1700                         if (ugd->account_info == NULL && p->icon_get_cnt1 == 3 &&
1701                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1702                                 p->clicked_object = p->entry_account_name;
1703                                 evas_object_show(p->entry_account_name);
1704                                 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1705                         }*/
1706
1707                         return p->ef_account_name;
1708                 } else if (index == 2) {
1709                         debug_log("");
1710                         p->ef_user_id = elm_layout_add(p->genlist);
1711                         elm_layout_theme_set(p->ef_user_id, "layout", "editfield", "title");
1712                         p->entry_user_id = elm_entry_add(p->genlist);
1713                         elm_entry_scrollable_set(p->entry_user_id, EINA_TRUE);
1714                         elm_entry_single_line_set(p->entry_user_id, EINA_TRUE);
1715                         elm_entry_input_panel_return_key_disabled_set(p->entry_user_id, EINA_TRUE);
1716                         elm_entry_cnp_mode_set(p->entry_user_id, ELM_CNP_MODE_PLAINTEXT);
1717                         elm_entry_input_panel_layout_set(p->entry_user_id, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1718                         elm_entry_editable_set(p->entry_user_id, TRUE);
1719                         evas_object_smart_callback_add(p->entry_user_id, "changed", _backup_input_cb, p->ef_user_id);
1720                         evas_object_smart_callback_add(p->entry_user_id, "focused", _entry_focused_cb, p->ef_user_id);
1721                         evas_object_smart_callback_add(p->entry_user_id, "unfocused", _entry_unfocused_cb, p->ef_user_id);
1722                         evas_object_show(p->entry_user_id);
1723
1724                         imf_context = elm_entry_imf_context_get(p->entry_user_id);
1725                         if (imf_context)
1726                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1727                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1728                                                 _input_panel_state_changed_cb, (void *)vd);
1729
1730                         elm_object_part_content_set(p->ef_user_id, "elm.swallow.content", p->entry_user_id);
1731                         /*elm_object_part_text_set(p->ef_user_id, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));*/
1732                         elm_object_part_text_set(p->ef_user_id, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));
1733                         elm_object_signal_callback_add(p->ef_user_id, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_user_id);
1734
1735                         evas_object_size_hint_weight_set(p->ef_user_id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1736                         evas_object_show(p->ef_user_id);
1737
1738                         if (p->str_user_id)
1739                                 elm_entry_entry_set(p->entry_user_id, p->str_user_id);
1740
1741                         return p->ef_user_id;
1742                 } else if (index == 3) {
1743                         debug_log("");
1744                         p->ef_display_name = elm_layout_add(p->genlist);
1745                         elm_layout_theme_set(p->ef_display_name, "layout", "editfield", "title");
1746                         p->entry_display_name = elm_entry_add(p->genlist);
1747                         elm_entry_scrollable_set(p->entry_display_name, EINA_TRUE);
1748                         elm_entry_single_line_set(p->entry_display_name, EINA_TRUE);
1749                         elm_entry_input_panel_return_key_disabled_set(p->entry_display_name, EINA_TRUE);
1750                         elm_entry_cnp_mode_set(p->entry_display_name, ELM_CNP_MODE_PLAINTEXT);
1751                         elm_entry_input_panel_layout_set(p->entry_display_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1752                         elm_entry_editable_set(p->entry_display_name, TRUE);
1753                         evas_object_smart_callback_add(p->entry_display_name, "changed", _backup_input_cb, p->ef_display_name);
1754                         evas_object_smart_callback_add(p->entry_display_name, "focused", _entry_focused_cb, p->ef_display_name);
1755                         evas_object_smart_callback_add(p->entry_display_name, "unfocused", _entry_unfocused_cb, p->ef_display_name);
1756                         evas_object_show(p->entry_display_name);
1757
1758                         imf_context = elm_entry_imf_context_get(p->entry_display_name);
1759                         if (imf_context)
1760                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1761                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1762                                                 _input_panel_state_changed_cb, (void *)vd);
1763
1764                         elm_object_part_content_set(p->ef_display_name, "elm.swallow.content", p->entry_display_name);
1765                         /*elm_object_part_text_set(p->ef_display_name, "elm.guidetext", _("IDS_EMAIL_BODY_YOUR_NAME"));*/
1766                         elm_object_part_text_set(p->ef_display_name, "elm.text", dgettext("sys_string", "IDS_COM_BODY_DETAILS_NAME"));
1767                         elm_object_signal_callback_add(p->ef_display_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_display_name);
1768
1769                         evas_object_size_hint_weight_set(p->ef_display_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1770                         evas_object_show(p->ef_display_name);
1771
1772                         if (p->str_display_name)
1773                                 elm_entry_entry_set(p->entry_display_name, p->str_display_name);
1774
1775                         return p->ef_display_name;
1776                 } else if (index == 4) {
1777                         //p->icon_get_cnt2++;
1778
1779                         debug_log("");
1780                         p->ef_email_address = elm_layout_add(p->genlist);
1781                         elm_layout_theme_set(p->ef_email_address, "layout", "editfield", "title");
1782                         p->entry_email_address = elm_entry_add(p->genlist);
1783                         elm_entry_scrollable_set(p->entry_email_address, EINA_TRUE);
1784                         elm_entry_single_line_set(p->entry_email_address, EINA_TRUE);
1785                         //elm_entry_input_panel_return_key_disabled_set(p->entry_email_address, EINA_TRUE);
1786                         elm_entry_cnp_mode_set(p->entry_email_address, ELM_CNP_MODE_PLAINTEXT);
1787                         elm_entry_input_panel_layout_set(p->entry_email_address, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1788                         elm_entry_editable_set(p->entry_email_address, TRUE);
1789                         evas_object_smart_callback_add(p->entry_email_address, "changed", _backup_input_cb, p->ef_email_address);
1790                         evas_object_smart_callback_add(p->entry_email_address, "focused", _entry_focused_cb, p->ef_email_address);
1791                         evas_object_smart_callback_add(p->entry_email_address, "unfocused", _entry_unfocused_cb, p->ef_email_address);
1792                         evas_object_show(p->entry_email_address);
1793
1794                         imf_context = elm_entry_imf_context_get(p->entry_email_address);
1795                         if (imf_context)
1796                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1797                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1798                                                 _input_panel_state_changed_cb, (void *)vd);
1799
1800                         elm_object_part_content_set(p->ef_email_address, "elm.swallow.content", p->entry_email_address);
1801                         /*_set_help_string(p->ef_email_address, vd);*/
1802                         elm_object_part_text_set(p->ef_email_address, "elm.text", dgettext("sys_string", "IDS_COM_BODY_EMAIL_ADDRESS"));
1803                         elm_object_signal_callback_add(p->ef_email_address, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_email_address);
1804
1805                         evas_object_size_hint_weight_set(p->ef_email_address, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1806                         evas_object_show(p->ef_email_address);
1807
1808                         if (p->str_email_address)
1809                                 elm_entry_entry_set(p->entry_email_address, p->str_email_address);
1810
1811                         /*if (ugd->account_info != NULL && p->icon_get_cnt2 == 2 &&
1812                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1813                                 p->clicked_object = p->entry_email_address;
1814                                 evas_object_show(p->entry_email_address);
1815                                 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1816                                 elm_entry_cursor_begin_set(p->entry_email_address);
1817                         }
1818
1819                         if (ugd->account_info != NULL && p->icon_get_cnt2 == 3 &&
1820                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1821                                 p->clicked_object = p->entry_email_address;
1822                                 evas_object_show(p->entry_email_address);
1823                                 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1824                                 elm_entry_cursor_begin_set(p->entry_email_address);
1825                         }*/
1826
1827                         return p->ef_email_address;
1828                 } else if (index == 5) {
1829                         debug_log("");
1830                         p->ef_password = elm_layout_add(p->genlist);
1831                         elm_layout_theme_set(p->ef_password, "layout", "editfield", "title");
1832                         p->entry_password = elm_entry_add(p->genlist);
1833                         elm_entry_scrollable_set(p->entry_password, EINA_TRUE);
1834                         elm_entry_single_line_set(p->entry_password, EINA_TRUE);
1835                         //elm_entry_input_panel_return_key_disabled_set(p->entry_password, EINA_TRUE);
1836                         elm_entry_cnp_mode_set(p->entry_password, ELM_CNP_MODE_PLAINTEXT);
1837                         elm_entry_input_panel_layout_set(p->entry_password, ELM_INPUT_PANEL_LAYOUT_NORMAL);
1838                         elm_entry_editable_set(p->entry_password, EINA_TRUE);
1839                         elm_entry_password_set(p->entry_password, EINA_TRUE);
1840
1841                         evas_object_smart_callback_add(p->entry_password, "changed", _backup_input_cb, p->ef_password);
1842                         evas_object_smart_callback_add(p->entry_password, "focused", _entry_focused_cb, p->ef_password);
1843                         evas_object_smart_callback_add(p->entry_password, "unfocused", _entry_unfocused_cb, p->ef_password);
1844                         //evas_object_smart_callback_add(p->entry_password, "theme,changed", _entry_theme_changed_cb, (void *)vd);
1845                         evas_object_show(p->entry_password);
1846
1847                         imf_context = elm_entry_imf_context_get(p->entry_password);
1848                         if (imf_context)
1849                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1850                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1851                                                 _input_panel_state_changed_cb, (void *)vd);
1852
1853                         elm_object_part_content_set(p->ef_password, "elm.swallow.content", p->entry_password);
1854                         /*elm_object_part_text_set(p->ef_password, "elm.guidetext", _("IDS_EMAIL_BODY_USER_PASSWORD"));*/
1855                         elm_object_part_text_set(p->ef_password, "elm.text", dgettext("sys_string", "IDS_COM_BODY_PASSWORD"));
1856                         elm_object_signal_callback_add(p->ef_password, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_password);
1857
1858                         evas_object_size_hint_weight_set(p->ef_password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1859                         evas_object_show(p->ef_password);
1860
1861                         if (p->str_password)
1862                                 elm_entry_entry_set(p->entry_password, p->str_password);
1863
1864                         Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1865
1866                         if (state)
1867                                 elm_entry_password_set(p->entry_password, EINA_FALSE);
1868                         else
1869                                 elm_entry_password_set(p->entry_password, EINA_TRUE);
1870
1871                         return p->ef_password;
1872                 }
1873         }
1874
1875         return NULL;
1876 }
1877
1878 static void _gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
1879 {
1880         Elm_Object_Item *it = event_info;
1881         struct viewdata *vd = (struct viewdata *)data;
1882         struct priv_data *p = vd->priv;
1883
1884         if (p->gl_email_address_item == it)
1885                 elm_object_item_signal_emit(it, "elm,state,top", "");
1886         else if (p->gl_pw_item == it)
1887                 elm_object_item_signal_emit(it, "elm,state,bottom", "");
1888         else
1889                 elm_object_item_signal_emit(it, "elm,state,center", "");
1890 }
1891
1892 /* EOF */