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