Merge "fixed prevent issue"
[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 (p->entry_account_name) {
1060                 elm_object_focus_allow_set(p->entry_account_name, EINA_FALSE);
1061         }
1062
1063         if (p->entry_email_address) {
1064                 elm_object_focus_allow_set(p->entry_email_address, EINA_FALSE);
1065         }
1066
1067         if (p->entry_password) {
1068                 elm_object_focus_allow_set(p->entry_password, EINA_FALSE);
1069         }
1070
1071         Ecore_IMF_Context *imf_context = NULL;
1072         imf_context = elm_entry_imf_context_get(p->clicked_object);
1073         if (imf_context) {
1074                 ecore_imf_context_input_panel_hide(imf_context);
1075                 ecore_imf_context_input_panel_event_callback_del(imf_context,
1076                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1077         }
1078
1079         elm_object_disabled_set(p->l_button, EINA_TRUE);
1080         elm_object_disabled_set(p->r_button, EINA_TRUE);
1081         elm_object_disabled_set(p->r_button2, EINA_TRUE);
1082         elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1083         elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1084
1085         if (!strcmp(vd->ugd->start_view_type, "account-add")) {
1086                 ug_destroy_me(vd->ugd->ug);
1087         } else {
1088                 setting_back_to_prev_view(vd);
1089         }
1090 }
1091
1092 static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1093 {
1094         debug_log("");
1095         struct viewdata *vd = (struct viewdata *)data;
1096
1097         if (vd == NULL) {
1098                 debug_log("vd is NULL");
1099                 return;
1100         }
1101
1102         struct priv_data *p = vd->priv;
1103         Eina_Bool state = elm_check_state_get(obj);
1104
1105         if (state) {
1106                 p->set_default_account = 1;
1107         } else
1108                 p->set_default_account = 0;
1109 }
1110
1111 static void _check1_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
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         Eina_Bool state = elm_check_state_get(p->default_account_check);
1123
1124         if (state) {
1125                 elm_check_state_set(p->default_account_check, EINA_FALSE);
1126                 p->set_default_account = 0;
1127         } else {
1128                 elm_check_state_set(p->default_account_check, EINA_TRUE);
1129                 p->set_default_account = 1;
1130         }
1131 }
1132
1133 static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1134 {
1135         debug_log("");
1136         struct viewdata *vd = (struct viewdata *)data;
1137
1138         if (vd == NULL) {
1139                 debug_log("vd is NULL");
1140                 return;
1141         }
1142
1143         struct priv_data *p = vd->priv;
1144         EmailSettingUGD *ugd = NULL;
1145         ugd = vd->ugd;
1146
1147         Eina_Bool state = elm_check_state_get(obj);
1148
1149         if (state)
1150                 elm_entry_password_set(p->entry_password, EINA_FALSE);
1151         else
1152                 elm_entry_password_set(p->entry_password, EINA_TRUE);
1153
1154         if (elm_object_focus_get(p->entry_password)) {
1155                 if (ugd->password_timer) {
1156                         ecore_timer_del(ugd->password_timer);
1157                         ugd->password_timer = NULL;
1158                 }
1159                 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1160
1161                 Ecore_IMF_Context *imf_context = NULL;
1162                 imf_context = elm_entry_imf_context_get(p->entry_password);
1163                 int state = ecore_imf_context_input_panel_state_get(imf_context);
1164
1165                 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1166                         debug_log("input panel show");
1167                         elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1168                 }
1169         }
1170 }
1171
1172 static void _check2_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1173 {
1174         debug_log("");
1175         struct viewdata *vd = (struct viewdata *)data;
1176
1177         if (vd == NULL) {
1178                 debug_log("vd is NULL");
1179                 return;
1180         }
1181
1182         struct priv_data *p = vd->priv;
1183         EmailSettingUGD *ugd = NULL;
1184         ugd = vd->ugd;
1185
1186         Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1187
1188         if (state) {
1189                 elm_check_state_set(p->show_passwd_check, EINA_FALSE);
1190                 elm_entry_password_set(p->entry_password, EINA_TRUE);
1191         } else {
1192                 elm_check_state_set(p->show_passwd_check, EINA_TRUE);
1193                 elm_entry_password_set(p->entry_password, EINA_FALSE);
1194         }
1195
1196         if (elm_object_focus_get(p->entry_password)) {
1197                 if (ugd->password_timer) {
1198                         ecore_timer_del(ugd->password_timer);
1199                         ugd->password_timer = NULL;
1200                 }
1201                 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1202
1203                 Ecore_IMF_Context *imf_context = NULL;
1204                 imf_context = elm_entry_imf_context_get(p->entry_password);
1205                 int state = ecore_imf_context_input_panel_state_get(imf_context);
1206
1207                 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1208                         debug_log("input panel show");
1209                         elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1210                 }
1211         }
1212 }
1213
1214 static Eina_Bool _after_validation_cb(void *data)
1215 {
1216         debug_log("");
1217
1218         struct viewdata *vd = (struct viewdata *)data;
1219
1220         if (vd == NULL) {
1221                 debug_log("vd is NULL");
1222                 return ECORE_CALLBACK_CANCEL;
1223         }
1224
1225         EmailSettingUGD *ugd = NULL;
1226         struct priv_data *p = NULL;
1227
1228         ugd = vd->ugd;
1229         p = vd->priv;
1230
1231         if (ugd->preset_vc_timer) {
1232                 ecore_timer_del(ugd->preset_vc_timer);
1233                 ugd->preset_vc_timer = NULL;
1234         }
1235
1236         if (ugd->popup_one) {
1237                 evas_object_del(ugd->popup_one);
1238                 ugd->popup_one = NULL;
1239         }
1240         if (ugd->popup_validate) {
1241                 evas_object_del(ugd->popup_validate);
1242                 ugd->popup_validate = NULL;
1243         }
1244
1245         if (p->set_default_account) {
1246                 if (email_engine_set_default_account(vd->ugd->account_id)) {
1247                         debug_log("new default account is %d", vd->ugd->account_id);
1248                 }
1249         }
1250
1251         status_message_post(_("IDS_EMAIL_POP_SUCCEEDED"));
1252
1253         setting_change_view(VIEW_SYNC_SETUP, ugd);
1254
1255
1256         /*debug_log("_after_validation_cb %s", vd->ugd->start_view_type);
1257
1258         if (vd->ugd->start_view_type != NULL &&
1259                         strcmp(vd->ugd->start_view_type, "first-setup") == 0) {
1260                 ug_destroy_me(vd->ugd->ug);
1261         } else if (vd->ugd->start_view_type != NULL &&
1262                         strcmp(vd->ugd->start_view_type, "account-add") == 0) {
1263                 ug_destroy_me(vd->ugd->ug);
1264         } else if (vd->ugd->start_view_type != NULL &&
1265                         strcmp(vd->ugd->start_view_type, "select-account") == 0) {
1266                 service_h service = NULL;
1267                 service_create(&service);
1268                 if (service) {
1269                         service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT);
1270                         ug_send_result(vd->ugd->ug, service);
1271                         service_destroy(service);
1272                 }
1273         } else {
1274                 setting_update_acct_list(vd);
1275                 setting_back_to_prev_nth_view(vd, 2, vd->ugd->navi_main_it);
1276                 vd->ugd->atomic_pop = 0;
1277         }*/
1278
1279         return ECORE_CALLBACK_CANCEL;
1280 }
1281
1282 static Eina_Bool _password_state_cb(void *data)
1283 {
1284         debug_log("");
1285
1286         struct viewdata *vd = (struct viewdata *)data;
1287
1288         if (vd == NULL) {
1289                 debug_log("vd is NULL");
1290                 return ECORE_CALLBACK_CANCEL;
1291         }
1292
1293         struct priv_data *p = NULL;
1294         p = vd->priv;
1295         EmailSettingUGD *ugd = NULL;
1296         ugd = vd->ugd;
1297
1298         if (ugd->password_timer) {
1299                 ecore_timer_del(ugd->password_timer);
1300                 ugd->password_timer = NULL;
1301         }
1302
1303         Ecore_IMF_Context *imf_context = NULL;
1304         imf_context = elm_entry_imf_context_get(p->entry_password);
1305         if (imf_context) {
1306                 ecore_imf_context_input_panel_event_callback_del(imf_context,
1307                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1308                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1309                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1310                                 _input_panel_state_changed_cb, (void *)vd);
1311         }
1312
1313         return ECORE_CALLBACK_CANCEL;
1314 }
1315
1316 static Eina_Bool _startup_focus_cb(void *data)
1317 {
1318         debug_log("");
1319
1320         struct viewdata *vd = (struct viewdata *)data;
1321
1322         if (vd == NULL) {
1323                 debug_log("vd is NULL");
1324                 return ECORE_CALLBACK_CANCEL;
1325         }
1326
1327         struct priv_data *p = NULL;
1328         p = vd->priv;
1329
1330         EmailSettingUGD *ugd = NULL;
1331         ugd = vd->ugd;
1332
1333         if (ugd->focus_timer) {
1334                 ecore_timer_del(ugd->focus_timer);
1335                 ugd->focus_timer = NULL;
1336         }
1337
1338         p->clicked_object = p->entry_email_address;
1339         elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1340         elm_entry_cursor_begin_set(p->entry_email_address);
1341
1342         return ECORE_CALLBACK_CANCEL;
1343 }
1344
1345 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1346 {
1347         debug_log("");
1348         if (!data) {
1349                 debug_log("data is NULL");
1350                 return;
1351         }
1352
1353         struct viewdata *vd = (struct viewdata *)data;
1354         EmailSettingUGD *ugd = vd->ugd;
1355         struct priv_data *p = vd->priv;
1356
1357         if (ugd->popup_one) {
1358                 evas_object_del(ugd->popup_one);
1359                 ugd->popup_one = NULL;
1360         }
1361         if (ugd->popup_validate) {
1362                 evas_object_del(ugd->popup_validate);
1363                 ugd->popup_validate = NULL;
1364         }
1365
1366         elm_object_disabled_set(p->l_button, EINA_FALSE);
1367         elm_object_disabled_set(p->r_button, EINA_FALSE);
1368         elm_object_disabled_set(p->r_button2, EINA_FALSE);
1369         elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1370         elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1371 }
1372
1373 /*static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1374 {
1375         debug_log("");
1376         if (!data) {
1377                 debug_log("data is NULL");
1378                 return;
1379         }
1380
1381         struct viewdata *vd = (struct viewdata *)data;
1382         EmailSettingUGD *ugd = vd->ugd;
1383         struct priv_data *p = vd->priv;
1384
1385         if (ugd->popup_one) {
1386                 evas_object_del(ugd->popup_one);
1387                 ugd->popup_one = NULL;
1388         }
1389         if (ugd->popup_validate) {
1390                 evas_object_del(ugd->popup_validate);
1391                 ugd->popup_validate = NULL;
1392         }
1393
1394         elm_object_disabled_set(p->r_button, EINA_FALSE);
1395         elm_object_disabled_set(p->r_button2, EINA_FALSE);
1396 }*/
1397
1398 static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info)
1399 {
1400         debug_log("");
1401         if (!data) {
1402                 debug_log("data is NULL");
1403                 return;
1404         }
1405
1406         struct viewdata *vd = (struct viewdata *)data;
1407         EmailSettingUGD *ugd = vd->ugd;
1408         struct priv_data *p = vd->priv;
1409
1410         if (ugd->popup_one) {
1411                 evas_object_del(ugd->popup_one);
1412                 ugd->popup_one = NULL;
1413         }
1414         if (ugd->popup_validate) {
1415                 evas_object_del(ugd->popup_validate);
1416                 ugd->popup_validate = NULL;
1417         }
1418
1419         int account_id = vd->ugd->account_id;
1420         vd->ugd->cancel_event = 1;
1421         email_engine_stop_working(account_id, p->handle);
1422         email_engine_delete_account(account_id);
1423
1424         elm_object_disabled_set(p->l_button, EINA_FALSE);
1425         elm_object_disabled_set(p->r_button, EINA_FALSE);
1426         elm_object_disabled_set(p->r_button2, EINA_FALSE);
1427         elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1428         elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1429 }
1430
1431 static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info)
1432 {
1433         debug_log("");
1434         Evas_Object *eo = (Evas_Object *)obj;
1435         struct viewdata *vd = g_vd;
1436         if (vd == NULL)
1437                 return;
1438
1439         struct priv_data *p = vd->priv;
1440         if (p == NULL)
1441                 return;
1442
1443         EmailSettingUGD *ugd = vd->ugd;
1444         if (ugd == NULL)
1445                 return;
1446
1447         if (elm_object_focus_get(data)) {
1448                 if (elm_entry_is_empty(obj))
1449                         elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1450                 else
1451                         elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1452         }
1453
1454         if (eo == p->entry_user_id) {
1455                 debug_log("entry_user_id");
1456                 if (p->str_user_id) {
1457                         g_free(p->str_user_id);
1458                         p->str_user_id = NULL;
1459                 }
1460
1461                 p->str_user_id = g_strdup(elm_entry_entry_get(eo));
1462         } else if (eo == p->entry_display_name) {
1463                 debug_log("entry_display_name");
1464                 if (p->str_display_name) {
1465                         g_free(p->str_display_name);
1466                         p->str_display_name = NULL;
1467                 }
1468
1469                 p->str_display_name = g_strdup(elm_entry_entry_get(eo));
1470         } else if (eo == p->entry_email_address) {
1471                 debug_log("entry_email_address");
1472                 if (p->str_email_address) {
1473                         g_free(p->str_email_address);
1474                         p->str_email_address = NULL;
1475                 }
1476
1477                 p->str_email_address = g_strdup(elm_entry_entry_get(eo));
1478         } else if (eo == p->entry_password) {
1479                 debug_log("entry_password");
1480                 if (p->str_password) {
1481                         g_free(p->str_password);
1482                         p->str_password = NULL;
1483                 }
1484
1485                 p->str_password = (char *)elm_entry_markup_to_utf8(elm_entry_entry_get(eo));
1486         }
1487
1488         if (p->str_email_address == NULL || p->str_password == NULL) {
1489                 elm_object_disabled_set(p->l_button, EINA_TRUE);
1490                 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1491                 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1492                 return;
1493         }
1494
1495         if (g_strcmp0(p->str_email_address, "") == 0 || g_strcmp0(p->str_password, "") == 0) {
1496                 elm_object_disabled_set(p->l_button, EINA_TRUE);
1497                 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1498                 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1499         } else {
1500                 elm_object_disabled_set(p->l_button, EINA_FALSE);
1501                 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1502                 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1503         }
1504 }
1505
1506 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
1507 {
1508         debug_log("");
1509
1510         if (!obj) {
1511                 debug_log("obj is NULL");
1512                 return;
1513         }
1514
1515         struct viewdata *vd = g_vd;
1516         struct priv_data *p = vd->priv;
1517
1518         if (obj == p->entry_password) {
1519                 Ecore_IMF_Context *imf_context = NULL;
1520                 imf_context = elm_entry_imf_context_get(p->entry_password);
1521                 if (imf_context) {
1522                         ecore_imf_context_input_panel_event_callback_del(imf_context,
1523                                         ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1524                         ecore_imf_context_input_panel_event_callback_add(imf_context,
1525                                         ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1526                                         _input_panel_state_changed_cb, (void *)vd);
1527                 }
1528         }
1529
1530         if (!elm_entry_is_empty(obj))
1531                 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1532         elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
1533 }
1534
1535 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
1536 {
1537         debug_log("");
1538
1539         if (!obj) {
1540                 debug_log("obj is NULL");
1541                 return;
1542         }
1543
1544         if (elm_entry_is_empty(obj))
1545                 elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
1546         elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1547 }
1548
1549 static void _entry_theme_changed_cb(void *data, Evas_Object *obj, void *event_info)
1550 {
1551         debug_log("");
1552
1553         if (!obj) {
1554                 debug_log("obj is NULL");
1555                 return;
1556         }
1557
1558         struct viewdata *vd = (struct viewdata *)data;
1559
1560         if (vd == NULL) {
1561                 debug_log("vd is NULL");
1562                 return;
1563         }
1564
1565         struct priv_data *p = NULL;
1566         p = vd->priv;
1567
1568         Ecore_IMF_Context *imf_context = NULL;
1569         imf_context = elm_entry_imf_context_get(p->entry_password);
1570         if (imf_context) {
1571                 ecore_imf_context_input_panel_event_callback_del(imf_context,
1572                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1573                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1574                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1575                                 _input_panel_state_changed_cb, (void *)vd);
1576         }
1577 }
1578
1579 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1580 {
1581         debug_log("");
1582
1583         if (!obj) {
1584                 debug_log("obj is NULL");
1585                 return;
1586         }
1587
1588         elm_entry_entry_set(data, "");
1589 }
1590
1591 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
1592 {
1593         debug_log("");
1594
1595         if (!data) {
1596                 debug_log("data is NULL");
1597                 return;
1598         }
1599
1600         struct viewdata *vd = (struct viewdata *)data;
1601         struct priv_data *p = vd->priv;
1602
1603         int state = ecore_imf_context_input_panel_state_get(ctx);
1604
1605         if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1606                 debug_log("state:SHOW");
1607         else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1608                 debug_log("state HIDE");
1609
1610         if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1611                 debug_log("value:SHOW");
1612         else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1613                 debug_log("value HIDE");
1614
1615         if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
1616                 debug_log("input panel show");
1617                 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1618         } else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1619                 debug_log("input panel hide");
1620                 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,hidden", "");
1621         }
1622 }
1623
1624 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info)
1625 {
1626         debug_log("");
1627         int index = (int)data;
1628         struct viewdata *vd = g_vd;
1629         struct priv_data *p = vd->priv;
1630
1631         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1632         elm_genlist_item_selected_set(item, EINA_FALSE);
1633
1634         if (index == 1) {
1635                 p->clicked_object = p->entry_account_name;
1636         } else if (index == 2) {
1637                 p->clicked_object = p->entry_user_id;
1638         } else if (index == 3) {
1639                 p->clicked_object = p->entry_display_name;
1640         } else if (index == 4) {
1641                 p->clicked_object = p->entry_email_address;
1642         } else if (index == 5) {
1643                 p->clicked_object = p->entry_password;
1644         }
1645 }
1646
1647 static char *_gl_group_text_get(void *data, Evas_Object *obj, const char *part)
1648 {
1649         debug_log("");
1650
1651         struct viewdata *vd = g_vd;
1652
1653         if (!strcmp(part, "elm.text")) {
1654                 char title_str[MAX_STR_LEN] = { 0, };
1655                 if (vd->ugd->account_info) {
1656                         if (g_str_has_prefix(vd->ugd->account_info->name_str_id, "IDS_EMAIL"))
1657                                 snprintf(title_str, sizeof(title_str), "%s", _(vd->ugd->account_info->name_str_id));
1658                         else
1659                                 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", vd->ugd->account_info->name_str_id));
1660                 } else {
1661                         snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_OTHERS"));
1662                 }
1663
1664                 return g_strdup(title_str);
1665         }
1666
1667         return NULL;
1668 }
1669
1670 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part)
1671 {
1672         debug_log("");
1673         int index = (int)data;
1674         struct viewdata *vd = g_vd;
1675         struct priv_data *p = vd->priv;
1676         //EmailSettingUGD *ugd = vd->ugd;
1677         Ecore_IMF_Context *imf_context = NULL;
1678
1679         if (!strcmp(part, "elm.icon")) {
1680                 if (index == 1) {
1681                         //p->icon_get_cnt1++;
1682
1683                         debug_log("");
1684                         p->ef_account_name = elm_layout_add(p->genlist);
1685                         elm_layout_theme_set(p->ef_account_name, "layout", "editfield", "title");
1686                         p->entry_account_name = elm_entry_add(p->genlist);
1687                         elm_entry_scrollable_set(p->entry_account_name, EINA_TRUE);
1688                         elm_entry_single_line_set(p->entry_account_name, EINA_TRUE);
1689                         elm_entry_input_panel_return_key_disabled_set(p->entry_account_name, EINA_TRUE);
1690                         elm_entry_cnp_mode_set(p->entry_account_name, ELM_CNP_MODE_PLAINTEXT);
1691                         elm_entry_input_panel_layout_set(p->entry_account_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1692                         elm_entry_editable_set(p->entry_account_name, TRUE);
1693                         evas_object_smart_callback_add(p->entry_account_name, "changed", _backup_input_cb, p->ef_account_name);
1694                         evas_object_smart_callback_add(p->entry_account_name, "focused", _entry_focused_cb, p->ef_account_name);
1695                         evas_object_smart_callback_add(p->entry_account_name, "unfocused", _entry_unfocused_cb, p->ef_account_name);
1696                         evas_object_show(p->entry_account_name);
1697
1698                         imf_context = elm_entry_imf_context_get(p->entry_account_name);
1699                         if (imf_context)
1700                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1701                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1702                                                 _input_panel_state_changed_cb, (void *)vd);
1703
1704                         elm_object_part_content_set(p->ef_account_name, "elm.swallow.content", p->entry_account_name);
1705                         /*elm_object_part_text_set(p->ef_account_name, "elm.guidetext", str);*/
1706                         elm_object_part_text_set(p->ef_account_name, "elm.text", _("IDS_EMAIL_BODY_ACCOUNT_NAME"));
1707                         elm_object_signal_callback_add(p->ef_account_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_account_name);
1708
1709                         evas_object_size_hint_weight_set(p->ef_account_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1710                         evas_object_show(p->ef_account_name);
1711
1712                         if (p->str_account_name)
1713                                 elm_entry_entry_set(p->entry_account_name, p->str_account_name);
1714
1715                         /*if (ugd->account_info == NULL && p->icon_get_cnt1 == 2 &&
1716                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1717                                 p->clicked_object = p->entry_account_name;
1718                                 evas_object_show(p->entry_account_name);
1719                                 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1720                         }
1721
1722                         if (ugd->account_info == NULL && p->icon_get_cnt1 == 3 &&
1723                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1724                                 p->clicked_object = p->entry_account_name;
1725                                 evas_object_show(p->entry_account_name);
1726                                 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1727                         }*/
1728
1729                         return p->ef_account_name;
1730                 } else if (index == 2) {
1731                         debug_log("");
1732                         p->ef_user_id = elm_layout_add(p->genlist);
1733                         elm_layout_theme_set(p->ef_user_id, "layout", "editfield", "title");
1734                         p->entry_user_id = elm_entry_add(p->genlist);
1735                         elm_entry_scrollable_set(p->entry_user_id, EINA_TRUE);
1736                         elm_entry_single_line_set(p->entry_user_id, EINA_TRUE);
1737                         elm_entry_input_panel_return_key_disabled_set(p->entry_user_id, EINA_TRUE);
1738                         elm_entry_cnp_mode_set(p->entry_user_id, ELM_CNP_MODE_PLAINTEXT);
1739                         elm_entry_input_panel_layout_set(p->entry_user_id, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1740                         elm_entry_editable_set(p->entry_user_id, TRUE);
1741                         evas_object_smart_callback_add(p->entry_user_id, "changed", _backup_input_cb, p->ef_user_id);
1742                         evas_object_smart_callback_add(p->entry_user_id, "focused", _entry_focused_cb, p->ef_user_id);
1743                         evas_object_smart_callback_add(p->entry_user_id, "unfocused", _entry_unfocused_cb, p->ef_user_id);
1744                         evas_object_show(p->entry_user_id);
1745
1746                         imf_context = elm_entry_imf_context_get(p->entry_user_id);
1747                         if (imf_context)
1748                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1749                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1750                                                 _input_panel_state_changed_cb, (void *)vd);
1751
1752                         elm_object_part_content_set(p->ef_user_id, "elm.swallow.content", p->entry_user_id);
1753                         /*elm_object_part_text_set(p->ef_user_id, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));*/
1754                         elm_object_part_text_set(p->ef_user_id, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));
1755                         elm_object_signal_callback_add(p->ef_user_id, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_user_id);
1756
1757                         evas_object_size_hint_weight_set(p->ef_user_id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1758                         evas_object_show(p->ef_user_id);
1759
1760                         if (p->str_user_id)
1761                                 elm_entry_entry_set(p->entry_user_id, p->str_user_id);
1762
1763                         return p->ef_user_id;
1764                 } else if (index == 3) {
1765                         debug_log("");
1766                         p->ef_display_name = elm_layout_add(p->genlist);
1767                         elm_layout_theme_set(p->ef_display_name, "layout", "editfield", "title");
1768                         p->entry_display_name = elm_entry_add(p->genlist);
1769                         elm_entry_scrollable_set(p->entry_display_name, EINA_TRUE);
1770                         elm_entry_single_line_set(p->entry_display_name, EINA_TRUE);
1771                         elm_entry_input_panel_return_key_disabled_set(p->entry_display_name, EINA_TRUE);
1772                         elm_entry_cnp_mode_set(p->entry_display_name, ELM_CNP_MODE_PLAINTEXT);
1773                         elm_entry_input_panel_layout_set(p->entry_display_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1774                         elm_entry_editable_set(p->entry_display_name, TRUE);
1775                         evas_object_smart_callback_add(p->entry_display_name, "changed", _backup_input_cb, p->ef_display_name);
1776                         evas_object_smart_callback_add(p->entry_display_name, "focused", _entry_focused_cb, p->ef_display_name);
1777                         evas_object_smart_callback_add(p->entry_display_name, "unfocused", _entry_unfocused_cb, p->ef_display_name);
1778                         evas_object_show(p->entry_display_name);
1779
1780                         imf_context = elm_entry_imf_context_get(p->entry_display_name);
1781                         if (imf_context)
1782                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1783                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1784                                                 _input_panel_state_changed_cb, (void *)vd);
1785
1786                         elm_object_part_content_set(p->ef_display_name, "elm.swallow.content", p->entry_display_name);
1787                         /*elm_object_part_text_set(p->ef_display_name, "elm.guidetext", _("IDS_EMAIL_BODY_YOUR_NAME"));*/
1788                         elm_object_part_text_set(p->ef_display_name, "elm.text", dgettext("sys_string", "IDS_COM_BODY_DETAILS_NAME"));
1789                         elm_object_signal_callback_add(p->ef_display_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_display_name);
1790
1791                         evas_object_size_hint_weight_set(p->ef_display_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1792                         evas_object_show(p->ef_display_name);
1793
1794                         if (p->str_display_name)
1795                                 elm_entry_entry_set(p->entry_display_name, p->str_display_name);
1796
1797                         return p->ef_display_name;
1798                 } else if (index == 4) {
1799                         //p->icon_get_cnt2++;
1800
1801                         debug_log("");
1802                         p->ef_email_address = elm_layout_add(p->genlist);
1803                         elm_layout_theme_set(p->ef_email_address, "layout", "editfield", "title");
1804                         p->entry_email_address = elm_entry_add(p->genlist);
1805                         elm_entry_scrollable_set(p->entry_email_address, EINA_TRUE);
1806                         elm_entry_single_line_set(p->entry_email_address, EINA_TRUE);
1807                         //elm_entry_input_panel_return_key_disabled_set(p->entry_email_address, EINA_TRUE);
1808                         elm_entry_cnp_mode_set(p->entry_email_address, ELM_CNP_MODE_PLAINTEXT);
1809                         elm_entry_input_panel_layout_set(p->entry_email_address, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1810                         elm_entry_editable_set(p->entry_email_address, TRUE);
1811                         evas_object_smart_callback_add(p->entry_email_address, "changed", _backup_input_cb, p->ef_email_address);
1812                         evas_object_smart_callback_add(p->entry_email_address, "focused", _entry_focused_cb, p->ef_email_address);
1813                         evas_object_smart_callback_add(p->entry_email_address, "unfocused", _entry_unfocused_cb, p->ef_email_address);
1814                         evas_object_show(p->entry_email_address);
1815
1816                         imf_context = elm_entry_imf_context_get(p->entry_email_address);
1817                         if (imf_context)
1818                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1819                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1820                                                 _input_panel_state_changed_cb, (void *)vd);
1821
1822                         elm_object_part_content_set(p->ef_email_address, "elm.swallow.content", p->entry_email_address);
1823                         /*_set_help_string(p->ef_email_address, vd);*/
1824                         elm_object_part_text_set(p->ef_email_address, "elm.text", dgettext("sys_string", "IDS_COM_BODY_EMAIL_ADDRESS"));
1825                         elm_object_signal_callback_add(p->ef_email_address, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_email_address);
1826
1827                         evas_object_size_hint_weight_set(p->ef_email_address, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1828                         evas_object_show(p->ef_email_address);
1829
1830                         if (p->str_email_address)
1831                                 elm_entry_entry_set(p->entry_email_address, p->str_email_address);
1832
1833                         /*if (ugd->account_info != NULL && p->icon_get_cnt2 == 2 &&
1834                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1835                                 p->clicked_object = p->entry_email_address;
1836                                 evas_object_show(p->entry_email_address);
1837                                 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1838                                 elm_entry_cursor_begin_set(p->entry_email_address);
1839                         }
1840
1841                         if (ugd->account_info != NULL && p->icon_get_cnt2 == 3 &&
1842                                         strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1843                                 p->clicked_object = p->entry_email_address;
1844                                 evas_object_show(p->entry_email_address);
1845                                 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1846                                 elm_entry_cursor_begin_set(p->entry_email_address);
1847                         }*/
1848
1849                         return p->ef_email_address;
1850                 } else if (index == 5) {
1851                         debug_log("");
1852                         p->ef_password = elm_layout_add(p->genlist);
1853                         elm_layout_theme_set(p->ef_password, "layout", "editfield", "title");
1854                         p->entry_password = elm_entry_add(p->genlist);
1855                         elm_entry_scrollable_set(p->entry_password, EINA_TRUE);
1856                         elm_entry_single_line_set(p->entry_password, EINA_TRUE);
1857                         //elm_entry_input_panel_return_key_disabled_set(p->entry_password, EINA_TRUE);
1858                         elm_entry_cnp_mode_set(p->entry_password, ELM_CNP_MODE_PLAINTEXT);
1859                         elm_entry_input_panel_layout_set(p->entry_password, ELM_INPUT_PANEL_LAYOUT_NORMAL);
1860                         elm_entry_editable_set(p->entry_password, EINA_TRUE);
1861                         elm_entry_password_set(p->entry_password, EINA_TRUE);
1862
1863                         evas_object_smart_callback_add(p->entry_password, "changed", _backup_input_cb, p->ef_password);
1864                         evas_object_smart_callback_add(p->entry_password, "focused", _entry_focused_cb, p->ef_password);
1865                         evas_object_smart_callback_add(p->entry_password, "unfocused", _entry_unfocused_cb, p->ef_password);
1866                         //evas_object_smart_callback_add(p->entry_password, "theme,changed", _entry_theme_changed_cb, (void *)vd);
1867                         evas_object_show(p->entry_password);
1868
1869                         imf_context = elm_entry_imf_context_get(p->entry_password);
1870                         if (imf_context)
1871                                 ecore_imf_context_input_panel_event_callback_add(imf_context,
1872                                                 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1873                                                 _input_panel_state_changed_cb, (void *)vd);
1874
1875                         elm_object_part_content_set(p->ef_password, "elm.swallow.content", p->entry_password);
1876                         /*elm_object_part_text_set(p->ef_password, "elm.guidetext", _("IDS_EMAIL_BODY_USER_PASSWORD"));*/
1877                         elm_object_part_text_set(p->ef_password, "elm.text", dgettext("sys_string", "IDS_COM_BODY_PASSWORD"));
1878                         elm_object_signal_callback_add(p->ef_password, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_password);
1879
1880                         evas_object_size_hint_weight_set(p->ef_password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1881                         evas_object_show(p->ef_password);
1882
1883                         if (p->str_password)
1884                                 elm_entry_entry_set(p->entry_password, p->str_password);
1885
1886                         Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1887
1888                         if (state)
1889                                 elm_entry_password_set(p->entry_password, EINA_FALSE);
1890                         else
1891                                 elm_entry_password_set(p->entry_password, EINA_TRUE);
1892
1893                         return p->ef_password;
1894                 }
1895         }
1896
1897         return NULL;
1898 }
1899
1900 static void _gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
1901 {
1902         Elm_Object_Item *it = event_info;
1903         struct viewdata *vd = (struct viewdata *)data;
1904         struct priv_data *p = vd->priv;
1905
1906         if (p->gl_email_address_item == it)
1907                 elm_object_item_signal_emit(it, "elm,state,top", "");
1908         else if (p->gl_pw_item == it)
1909                 elm_object_item_signal_emit(it, "elm,state,bottom", "");
1910         else
1911                 elm_object_item_signal_emit(it, "elm,state,center", "");
1912 }
1913
1914 /* EOF */