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