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