2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
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"
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);
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);
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);
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);
53 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info);
54 static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info);
55 static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info);
56 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info);
57 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info);
58 static void _entry_theme_changed_cb(void *data, Evas_Object *obj, void *event_info);
59 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
60 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value);
61 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info);
62 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part);
64 static struct viewdata *g_vd = NULL;
70 char *str_account_name;
71 char *str_display_name;
72 char *str_email_address;
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;
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;
90 Evas_Object *scroller;
92 Evas_Object *l_button;
93 Evas_Object *r_button;
94 Evas_Object *r_button2;
95 Evas_Object *manual_btn;
97 Evas_Object *show_passwd_check;
98 Evas_Object *default_account_check;
100 Evas_Object *clicked_object;
102 Evas_Object *genlist;
103 Elm_Genlist_Item_Class itc1;
104 Elm_Genlist_Item_Class itc2;
107 Elm_Object_Item * c_item[4];
108 Elm_Object_Item *navi_it;
112 int set_default_account;
115 void setting_init_account_setup_view(struct viewdata *vd)
118 vd->type = VIEW_ACCOUNT_SETUP;
119 vd->create = _create;
120 vd->update = _update;
121 vd->destroy = _destroy;
124 vd->grp_nm = "setting_account_setup";
127 void setting_account_validation_success_cb(EmailSettingUGD *ugd)
132 top = ugd->view_st[ugd->view_top];
136 debug_log("vd is NULL");
142 if (ugd->popup_one) {
143 evas_object_del(ugd->popup_one);
144 ugd->popup_one = NULL;
146 if (ugd->popup_validate) {
147 evas_object_del(ugd->popup_validate);
148 ugd->popup_validate = NULL;
151 ugd->preset_vc_timer = ecore_timer_add(0.5, _after_validation_cb, vd);
154 void setting_account_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled)
160 top = ugd->view_st[ugd->view_top];
164 debug_log("vd is NULL");
168 account_id = ugd->account_id;
170 if (ugd->popup_one) {
171 evas_object_del(ugd->popup_one);
172 ugd->popup_one = NULL;
174 /*if (ugd->popup_validate) {
175 evas_object_del(ugd->popup_validate);
176 ugd->popup_validate = NULL;
179 if (canceled || ugd->err_code == EMAIL_ERROR_CANCELLED) {
180 ugd->popup_one = setting_get_notify(vd,
181 dgettext("sys_string", "IDS_COM_POP_WARNING"),
182 _("IDS_EMAIL_POP_ACCOUNT_CREATION_CANCELLED"),
183 1, dgettext("sys_string", "IDS_COM_SK_OK"),
184 _popup_ok_cb, NULL, NULL);
186 char *type = setting_get_service_fail_type(ugd->err_code);
187 ugd->popup_one = setting_get_notify(vd,
188 dgettext("sys_string", "IDS_COM_POP_WARNING"),
189 type, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
190 _popup_ok_cb, NULL, NULL);
195 static int _create(struct viewdata *vd)
200 debug_log("vd is NULL");
205 EmailSettingUGD *ugd = vd->ugd;
209 p = vd->priv = calloc(1, sizeof(struct priv_data));
212 p->layout = setting_add_inner_layout(vd);
216 p->scroller = elm_scroller_add(ugd->navi_bar);
217 evas_object_propagate_events_set(p->scroller, EINA_FALSE);
218 elm_scroller_bounce_set(p->scroller, EINA_FALSE, EINA_FALSE);
219 elm_scroller_policy_set(p->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
220 evas_object_show(p->scroller);
222 elm_win_conformant_set(ugd->win, EINA_TRUE);
223 p->conform = elm_conformant_add(ugd->win);
224 elm_object_style_set(p->conform, "internal_layout");
225 elm_object_content_set(p->conform, p->scroller);
226 evas_object_show(p->conform);
228 elm_object_part_content_set(p->layout, "elm.swallow.content", p->conform);
232 ugd->wds_account_creation = 0;
234 if (vd->ugd->account_info != OTHERS) {
235 _set_domain_string(vd);
238 ugd->focus_timer = ecore_timer_add(0.5, _startup_focus_cb, (void *)vd);
246 static int _update(struct viewdata *vd)
253 static int _destroy(struct viewdata *vd)
256 struct priv_data *p = vd->priv;
257 EmailSettingUGD *ugd = vd->ugd;
259 Ecore_IMF_Context *imf_context = NULL;
260 imf_context = elm_entry_imf_context_get(p->clicked_object);
262 ecore_imf_context_input_panel_hide(imf_context);
263 ecore_imf_context_input_panel_event_callback_del(imf_context,
264 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
267 evas_object_del(p->l_button);
268 evas_object_del(p->r_button);
269 evas_object_del(p->genlist);
270 evas_object_del(p->cbar);
272 if (ugd->password_timer) {
273 ecore_timer_del(ugd->password_timer);
274 ugd->password_timer = NULL;
277 if (ugd->focus_timer) {
278 ecore_timer_del(ugd->focus_timer);
279 ugd->focus_timer = NULL;
282 if (ugd->preset_vc_timer) {
283 ecore_timer_del(ugd->preset_vc_timer);
284 ugd->preset_vc_timer = NULL;
287 if (ugd->popup_one) {
288 evas_object_del(ugd->popup_one);
289 ugd->popup_one = NULL;
291 if (ugd->popup_validate) {
292 evas_object_del(ugd->popup_validate);
293 ugd->popup_validate = NULL;
296 ugd->account_info = 0;
298 setting_new_acct_final(vd);
302 static int _show(struct viewdata *vd)
307 debug_log("vd is NULL");
311 evas_object_show(vd->ly);
316 static int _hide(struct viewdata *vd)
321 debug_log("vd is NULL");
325 evas_object_hide(vd->ly);
330 static void _push_naviframe(struct viewdata *vd)
333 struct priv_data *p = vd->priv;
335 p->cbar = elm_toolbar_add(vd->ugd->navi_bar);
336 elm_toolbar_shrink_mode_set(p->cbar, ELM_TOOLBAR_SHRINK_EXPAND);
337 elm_object_style_set(p->cbar, "naviframe");
338 evas_object_show(p->cbar);
340 if (vd->ugd->account_info == OTHERS) {
341 p->c_item[0] = elm_toolbar_item_append(p->cbar, NULL,
342 dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"), _next_cb, vd);
344 p->c_item[0] = elm_toolbar_item_append(p->cbar, NULL,
345 dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"), _save_cb, vd);
347 elm_object_item_disabled_set(p->c_item[0], EINA_TRUE);
348 elm_object_item_disabled_set(elm_toolbar_item_append(p->cbar, NULL, "", NULL, NULL), EINA_TRUE);
349 elm_object_item_disabled_set(elm_toolbar_item_append(p->cbar, NULL, "", NULL, NULL), EINA_TRUE);
351 p->l_button = elm_button_add(vd->ugd->navi_bar);
352 elm_object_style_set(p->l_button, "naviframe/title/default");
353 elm_object_focus_allow_set(p->l_button, EINA_FALSE);
354 evas_object_show(p->l_button);
356 if (vd->ugd->account_info == OTHERS) {
357 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
358 evas_object_smart_callback_add(p->l_button, "clicked", _next_cb, vd);
360 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
361 evas_object_smart_callback_add(p->l_button, "clicked", _save_cb, vd);
364 elm_object_disabled_set(p->l_button, EINA_TRUE);
366 p->r_button = elm_button_add(vd->ugd->navi_bar);
367 elm_object_style_set(p->r_button, "naviframe/title/default");
368 elm_object_text_set(p->r_button, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
369 evas_object_smart_callback_add(p->r_button, "clicked", _back_cb, vd);
370 evas_object_show(p->r_button);
372 p->r_button2 = elm_button_add(vd->ugd->navi_bar);
373 elm_object_style_set(p->r_button2, "naviframe/title/default");
374 elm_object_text_set(p->r_button2, dgettext("sys_string", "IDS_COM_SK_CANCEL"));
375 evas_object_smart_callback_add(p->r_button2, "clicked", _back_cb, vd);
376 /*elm_object_style_set(p->r_button2, "naviframe/back_btn/default");*/
377 evas_object_show(p->r_button2);
380 Evas_Object *title_ic = elm_icon_add(vd->ugd->navi_bar);
381 evas_object_size_hint_aspect_set(title_ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
382 elm_icon_resizable_set(title_ic, EINA_TRUE, EINA_TRUE);
384 Elm_Object_Item *navi_it = NULL;
385 char title_str[50] = { 0, };
386 if (vd->ugd->account_info == GMAIL) {
387 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_GOOGLE"));
388 elm_icon_file_set(title_ic, ACCOUNT_ICON_GMAIL, NULL);
389 } else if (vd->ugd->account_info == HOTMAIL) {
390 snprintf(title_str, sizeof(title_str), "%s", _("IDS_EMAIL_BODY_WINDOWS_LIVE_HOTMAIL"));
391 elm_icon_file_set(title_ic, ACCOUNT_ICON_HOTMAIL, NULL);
392 } else if (vd->ugd->account_info == YAHOOMAIL) {
393 snprintf(title_str, sizeof(title_str), "%s", _("IDS_EMAIL_BODY_YAHOO_E_MAIL"));
394 elm_icon_file_set(title_ic, ACCOUNT_ICON_YAHOO, NULL);
395 } else if (vd->ugd->account_info == AOL) {
396 snprintf(title_str, sizeof(title_str), "%s", _("IDS_EMAIL_BODY_AOL"));
397 elm_icon_file_set(title_ic, ACCOUNT_ICON_AOL, NULL);
399 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_OTHERS"));
401 navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, title_str, p->r_button2, NULL, p->layout, NULL);
402 if (vd->ugd->account_info != OTHERS) {
403 elm_object_item_part_content_set(navi_it, "icon", title_ic);
405 elm_object_item_part_content_set(navi_it, "title_left_btn", p->l_button);
406 elm_object_item_part_content_set(navi_it, "title_right_btn", p->r_button);
407 elm_object_item_part_content_set(navi_it, "controlbar", p->cbar);
408 p->navi_it = navi_it;
409 evas_object_show(vd->ugd->navi_bar);
412 static void _create_view(struct viewdata *vd)
416 EmailSettingUGD *ugd;
419 debug_log("vd is null!");
427 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
428 debug_log("WINDOW W[%d] H[%d]", w, h);
430 Evas_Object *sub_ly = elm_layout_add(ugd->navi_bar);
433 if (vd->ugd->account_info == OTHERS)
434 elm_layout_file_set(sub_ly, EV_THEME_PATH, "other_account_add_wvga");
436 elm_layout_file_set(sub_ly, EV_THEME_PATH, "account_add_wvga");
438 if (vd->ugd->account_info == OTHERS)
439 elm_layout_file_set(sub_ly, EV_THEME_PATH, "other_account_add");
441 elm_layout_file_set(sub_ly, EV_THEME_PATH, "account_add");
443 evas_object_size_hint_weight_set(sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
444 evas_object_show(sub_ly);
447 elm_object_part_content_set(sub_ly, "list", p->genlist);
449 Evas_Object *checkbox_set = elm_layout_add(sub_ly);
450 elm_layout_file_set(checkbox_set, EV_THEME_PATH, "account_add_checkbox_set");
451 evas_object_size_hint_weight_set(checkbox_set, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
452 evas_object_show(checkbox_set);
454 Evas_Object *check1 = elm_check_add(checkbox_set);
455 elm_check_state_set(check1, EINA_FALSE);
456 evas_object_smart_callback_add(check1, "changed", _check1_clicked_cb, (void *)vd);
457 elm_object_part_content_set(checkbox_set, "checkbox.1", check1);
458 elm_object_focus_allow_set(check1, EINA_FALSE);
459 p->default_account_check = check1;
461 Evas_Object *check2 = elm_check_add(checkbox_set);
462 elm_check_state_set(check2, EINA_FALSE);
463 evas_object_smart_callback_add(check2, "changed", _check2_clicked_cb, (void *)vd);
464 elm_object_part_content_set(checkbox_set, "checkbox.2", check2);
465 elm_object_focus_allow_set(check2, EINA_FALSE);
466 p->show_passwd_check = check2;
468 char *desc = g_strdup(_("IDS_EMAIL_BODY_SEND_EMAIL_FROM_THIS_ACCOUNT_BY_DEFAULT"));
469 Evas_Object *label1 = elm_label_add(checkbox_set);
470 elm_label_wrap_width_set(label1, 600*elm_scale_get());
471 elm_label_line_wrap_set(label1, ELM_WRAP_WORD);
472 char *text = g_strconcat("<color=#838B8BFF><font_size=32><align=left>",
473 desc, "</align></font_size></color>", NULL);
474 edje_object_signal_callback_add(elm_layout_edje_get(checkbox_set),
475 "elm,action,text1_clicked", "elm", _check1_clicked_cb2, (void *)vd);
476 elm_object_text_set(label1, text);
477 evas_object_show(label1);
480 elm_object_part_content_set(checkbox_set, "text.1", label1);
482 desc = g_strdup(_("IDS_EMAIL_BODY_SHOW_PASSWORD"));
483 Evas_Object *label2 = elm_label_add(checkbox_set);
484 elm_label_wrap_width_set(label2, 600*elm_scale_get());
485 elm_label_line_wrap_set(label2, ELM_WRAP_WORD);
486 text = g_strconcat("<color=#838B8BFF><font_size=32><align=left>",
487 desc, "</align></font_size></color>", NULL);
488 edje_object_signal_callback_add(elm_layout_edje_get(checkbox_set),
489 "elm,action,text2_clicked", "elm", _check2_clicked_cb2, (void *)vd);
490 elm_object_text_set(label2, text);
491 evas_object_show(label2);
494 elm_object_part_content_set(checkbox_set, "text.2", label2);
496 elm_object_part_content_set(sub_ly, "checkbox_set", checkbox_set);
498 Evas_Object *button_set = elm_layout_add(sub_ly);
499 elm_layout_file_set(button_set, EV_THEME_PATH, "account_add_manual_button");
500 evas_object_size_hint_weight_set(button_set, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
501 evas_object_show(button_set);
503 Evas_Object *btn = elm_button_add(button_set);
504 elm_object_text_set(btn, _("IDS_EMAIL_BODY_MANUAL_SETUP"));
505 evas_object_smart_callback_add(btn, "clicked", _manual_cb, (void *)vd);
506 elm_object_style_set(btn, "text_only/style2");
507 evas_object_show(btn);
509 elm_object_part_content_set(button_set, "btn", btn);
510 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
512 elm_object_part_content_set(sub_ly, "button_set", button_set);
514 elm_object_content_set(p->scroller, sub_ly);
517 static void _create_list(struct viewdata *vd)
522 debug_critical("vd is null!");
527 EmailSettingUGD *ugd;
533 Elm_Object_Item *item = NULL;
534 Elm_Object_Item *git = NULL;
536 p->genlist = elm_genlist_add(ugd->navi_bar);
537 elm_object_style_set(p->genlist, "dialogue");
538 evas_object_show(p->genlist);
540 p->itc1.item_style = "dialogue/separator";
541 p->itc1.func.text_get = NULL;
542 p->itc1.func.content_get = NULL;
543 p->itc1.func.state_get = NULL;
544 p->itc1.func.del = NULL;
546 p->itc2.item_style = "dialogue/1icon";
547 p->itc2.func.text_get = NULL;
548 p->itc2.func.content_get = _gl_ef_content_get_cb;
549 p->itc2.func.state_get = NULL;
550 p->itc2.func.del = NULL;
552 git = elm_genlist_item_append(p->genlist, &(p->itc1), NULL, NULL,
553 ELM_GENLIST_ITEM_GROUP, NULL, NULL);
554 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
556 if (ugd->account_info == OTHERS) {
557 /* Account name for OTHER */
559 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
560 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
564 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
565 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
570 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
571 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
575 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
576 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
580 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
581 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
584 static void _create_validation_popup(struct viewdata *vd, int account_id)
589 debug_critical("vd is null!");
593 email_account_t *account = vd->ugd->new_account;
595 debug_log("account id:%d", account_id);
596 debug_log("account name:%s", account->account_name);
597 debug_log("email address:%s", account->user_email_address);
599 vd->ugd->account_id = account_id;
601 EmailSettingUGD *ugd = vd->ugd;
602 struct priv_data *p = vd->priv;
604 if (ugd->popup_one) {
605 evas_object_del(ugd->popup_one);
606 ugd->popup_one = NULL;
608 if (ugd->popup_validate) {
609 evas_object_del(ugd->popup_validate);
610 ugd->popup_validate = NULL;
613 vd->ugd->cancel_event = 0;
614 elm_object_disabled_set(p->l_button, EINA_TRUE);
615 elm_object_disabled_set(p->r_button, EINA_TRUE);
616 elm_object_disabled_set(p->r_button2, EINA_TRUE);
617 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
618 elm_object_item_disabled_set(p->c_item[0], EINA_TRUE);
620 debug_log("Start Account Validation");
621 ugd->popup_validate = setting_get_pb_notify(vd,
622 _("IDS_EMAIL_POP_VALIDATING_ACCOUNT_ING"), 1,
623 dgettext("sys_string", "IDS_COM_SK_CANCEL"),
624 _popup_cancel_validation_cb, NULL, NULL);
627 static void _create_account(void *data)
631 struct viewdata *vd = (struct viewdata *)data;
634 debug_critical("vd is null!");
638 EmailSettingUGD *ugd = vd->ugd;
640 struct priv_data *p = vd->priv;
643 if (email_engine_add_account_with_validation(vd->ugd->new_account,
644 &account_id, &(p->handle), &error_code)) {
645 debug_log("Account added to Email Service DB");
646 vd->ugd->start_account_validation = 1;
647 ugd->handle = p->handle;
648 _create_validation_popup(vd, account_id);
650 debug_log("Fail to make account");
652 if (ugd->popup_one) {
653 evas_object_del(ugd->popup_one);
654 ugd->popup_one = NULL;
656 if (ugd->popup_validate) {
657 evas_object_del(ugd->popup_validate);
658 ugd->popup_validate = NULL;
661 if (error_code == EMAIL_ERROR_ALREADY_EXISTS)
662 ugd->popup_one = setting_get_notify(vd,
663 dgettext("sys_string", "IDS_COM_POP_WARNING"),
664 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 1,
665 dgettext("sys_string", "IDS_COM_SK_OK"),
666 _popup_ok_cb, NULL, NULL);
668 ugd->popup_one = setting_get_notify(vd,
669 dgettext("sys_string", "IDS_COM_POP_WARNING"),
670 _("IDS_EMAIL_POP_UNABLE_TO_ADD_ACCOUNT"), 1,
671 dgettext("sys_string", "IDS_COM_SK_OK"),
672 _popup_ok_cb, NULL, NULL);
677 static int _check_null_field(struct viewdata *vd)
681 if (vd->ugd->new_account == NULL) {
682 debug_log("new_account is NULL");
686 email_account_t *account = vd->ugd->new_account;
688 if (account->account_name == NULL || strlen(account->account_name) == 0 ||
689 /*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
690 account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
691 /*account->incoming_server_user_name == NULL || strlen(account->incoming_server_user_name) == 0 ||*/
692 account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
698 static int _check_preset_null_field(struct viewdata *vd)
702 if (vd->ugd->new_account == NULL) {
703 debug_log("new_account is NULL");
707 email_account_t *account = vd->ugd->new_account;
709 if (/*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
710 account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
711 account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
717 static int _check_preset_isp_name(char *addr, int isp_type)
722 if (isp_type == HOTMAIL) {
725 ptr1 = g_strrstr(addr, "@hotmail.");
726 ptr2 = g_strrstr(addr, "@live.");
728 if (ptr1 != NULL || ptr2 != NULL)
730 } else if (isp_type == GMAIL) {
731 ret = g_str_has_suffix(addr, "@gmail.com") ||
732 g_str_has_suffix(addr, "@googlemail.com");
733 } else if (isp_type == AOL) {
736 ptr1 = g_strrstr(addr, "@aol.");
737 ptr2 = g_strrstr(addr, "@aim.");
739 if (ptr1 != NULL || ptr2 != NULL)
748 static void _read_all_entries(struct viewdata *vd)
757 debug_log("priv is NULL");
761 if (vd->ugd->new_account)
762 setting_new_acct_final(vd);
764 setting_new_acct_init(vd);
765 email_account_t *account = vd->ugd->new_account;
767 if (vd->ugd->account_info == OTHERS) {
768 /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_account_name));*/
769 if (p->entry_account_name) {
770 buf = (char *)elm_entry_entry_get(p->entry_account_name);
771 debug_log("account name : %s", buf);
773 account->account_name = g_strdup(buf);
777 /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_email_address));*/
778 if (p->entry_email_address) {
779 buf = (char *)elm_entry_entry_get(p->entry_email_address);
780 debug_log("email addr : %s", buf);
782 account->user_email_address = g_strdup(buf);
785 if (p->entry_password) {
786 buf = (char *)elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_password));
787 debug_log("password : %s", buf);
789 account->incoming_server_password = g_strdup(buf);
795 static void _set_domain_string(struct viewdata *vd)
798 EmailSettingUGD *ugd = vd->ugd;
802 if (ugd->account_info == HOTMAIL) {
803 p->str_email_address = g_strdup("@hotmail.com");
804 } else if (ugd->account_info == YAHOOMAIL) {
805 p->str_email_address = g_strdup("@yahoo.com");
806 } else if (ugd->account_info == GMAIL) {
807 p->str_email_address = g_strdup("@gmail.com");
808 } else if (ugd->account_info == AOL) {
809 p->str_email_address = g_strdup("@aol.com");
811 debug_log("Unknown account type");
815 static void _next_cb(void *data, Evas_Object *obj, void *event_info)
819 struct viewdata *vd = (struct viewdata *)data;
822 debug_log("vd is NULL");
826 struct priv_data *p = NULL;
827 EmailSettingUGD *ugd = NULL;
834 Ecore_IMF_Context *imf_context = NULL;
835 imf_context = elm_entry_imf_context_get(p->clicked_object);
837 ecore_imf_context_input_panel_hide(imf_context);
840 /* Save the Account Data */
841 _read_all_entries(vd);
842 email_account_t *account = vd->ugd->new_account;
844 debug_log("accountStructure Info");
845 debug_log("Account Name:%s", account->account_name);
846 debug_log("Display Name:%s", account->user_display_name);
847 debug_log("Email Addr:%s", account->user_email_address);
848 debug_log("User Name:%s", account->incoming_server_user_name);
849 debug_log("User Password:%s", account->incoming_server_password);
851 if (ugd->popup_one) {
852 evas_object_del(ugd->popup_one);
853 ugd->popup_one = NULL;
855 if (ugd->popup_validate) {
856 evas_object_del(ugd->popup_validate);
857 ugd->popup_validate = NULL;
860 /* check Null field */
861 ret = _check_null_field(vd);
863 ugd->popup_one = setting_get_notify(vd,
864 dgettext("sys_string", "IDS_COM_POP_WARNING"),
865 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
866 dgettext("sys_string", "IDS_COM_SK_OK"),
867 _popup_ok_cb, NULL, NULL);
871 /* check character validation */
872 buf = g_strdup(account->user_email_address);
874 ret = email_get_address_validation(buf);
876 ugd->popup_one = setting_get_notify(vd,
877 dgettext("sys_string", "IDS_COM_POP_WARNING"),
878 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
879 dgettext("sys_string", "IDS_COM_SK_OK"),
880 _popup_ok_cb, NULL, NULL);
887 setting_change_view(VIEW_MANUAL_SETUP, ugd);
892 static void _save_cb(void *data, Evas_Object *obj, void *event_info)
895 struct viewdata *vd = (struct viewdata *)data;
898 debug_log("vd is NULL");
902 struct priv_data *p = NULL;
903 EmailSettingUGD *ugd = NULL;
910 Ecore_IMF_Context *imf_context = NULL;
911 imf_context = elm_entry_imf_context_get(p->clicked_object);
913 ecore_imf_context_input_panel_hide(imf_context);
917 _read_all_entries(vd);
918 email_account_t *account = vd->ugd->new_account;
920 debug_log("accountStructure Info");
921 debug_log("Display Name:%s", account->user_display_name);
922 debug_log("Email Addr:%s", account->user_email_address);
923 debug_log("User Password:%s", account->incoming_server_password);
925 if (ugd->popup_one) {
926 evas_object_del(ugd->popup_one);
927 ugd->popup_one = NULL;
929 if (ugd->popup_validate) {
930 evas_object_del(ugd->popup_validate);
931 ugd->popup_validate = NULL;
934 /* check Null field */
935 ret = _check_preset_null_field(vd);
937 debug_log("empty space in account info");
938 ugd->popup_one = setting_get_notify(vd,
939 dgettext("sys_string", "IDS_COM_POP_WARNING"),
940 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"),
941 1, dgettext("sys_string", "IDS_COM_SK_OK"),
942 _popup_ok_cb, NULL, NULL);
947 buf = g_strdup(account->user_email_address);
948 ret = _check_preset_isp_name(buf, ugd->account_info);
950 debug_log("wrong ISP server name for preset accounts");
951 ugd->popup_one = setting_get_notify(vd,
952 dgettext("sys_string", "IDS_COM_POP_WARNING"),
953 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
954 1, dgettext("sys_string", "IDS_COM_SK_OK"),
955 _popup_ok_cb, NULL, NULL);
961 /* check character validation */
962 buf = g_strdup(account->user_email_address);
964 ret = email_get_address_validation(buf);
966 debug_log("Wrong character in email address");
967 ugd->popup_one = setting_get_notify(vd,
968 dgettext("sys_string", "IDS_COM_POP_WARNING"),
969 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
970 1, dgettext("sys_string", "IDS_COM_SK_OK"),
971 _popup_ok_cb, NULL, NULL);
977 /* account info setting */
978 setting_set_account(vd);
983 static void _manual_cb(void *data, Evas_Object *obj, void *event_info)
987 struct viewdata *vd = (struct viewdata *)data;
990 debug_log("vd is NULL");
994 EmailSettingUGD *ugd = NULL;
1000 /* Save the Account Data */
1001 _read_all_entries(vd);
1002 email_account_t *account = vd->ugd->new_account;
1004 debug_log("accountStructure Info");
1005 debug_log("Account Name:%s", account->account_name);
1006 debug_log("Display Name:%s", account->user_display_name);
1007 debug_log("Email Addr:%s", account->user_email_address);
1008 debug_log("User Name:%s", account->incoming_server_user_name);
1009 debug_log("User Password:%s", account->incoming_server_password);
1011 if (ugd->popup_one) {
1012 evas_object_del(ugd->popup_one);
1013 ugd->popup_one = NULL;
1015 if (ugd->popup_validate) {
1016 evas_object_del(ugd->popup_validate);
1017 ugd->popup_validate = NULL;
1020 /* check Null field */
1021 if (vd->ugd->account_info == OTHERS) {
1022 ret = _check_null_field(vd);
1024 ret = _check_preset_null_field(vd);
1028 ugd->popup_one = setting_get_notify(vd,
1029 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1030 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
1031 dgettext("sys_string", "IDS_COM_SK_OK"),
1032 _popup_ok_cb, NULL, NULL);
1037 if (ugd->account_info != OTHERS) {
1038 buf = g_strdup(account->user_email_address);
1039 ret = _check_preset_isp_name(buf, ugd->account_info);
1041 debug_log("wrong ISP server name for preset accounts");
1042 ugd->popup_one = setting_get_notify(vd,
1043 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1044 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
1045 1, dgettext("sys_string", "IDS_COM_SK_OK"),
1046 _popup_ok_cb, NULL, NULL);
1053 /* check character validation */
1054 buf = g_strdup(account->user_email_address);
1056 ret = email_get_address_validation(buf);
1058 ugd->popup_one = setting_get_notify(vd,
1059 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1060 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
1061 dgettext("sys_string", "IDS_COM_SK_OK"),
1062 _popup_ok_cb, NULL, NULL);
1070 /* account info setting */
1071 if (ugd->account_info != OTHERS)
1072 setting_set_account(vd);
1074 setting_change_view(VIEW_MANUAL_SETUP, ugd);
1079 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
1083 struct viewdata *vd = (struct viewdata *)data;
1084 struct priv_data *p = vd->priv;
1086 if (vd->ugd->atomic_pop) {
1087 debug_log("During atomic poping");
1091 if (p->entry_account_name) {
1092 elm_object_focus_allow_set(p->entry_account_name, EINA_FALSE);
1095 if (p->entry_email_address) {
1096 elm_object_focus_allow_set(p->entry_email_address, EINA_FALSE);
1099 if (p->entry_password) {
1100 elm_object_focus_allow_set(p->entry_password, EINA_FALSE);
1103 Ecore_IMF_Context *imf_context = NULL;
1104 imf_context = elm_entry_imf_context_get(p->clicked_object);
1106 ecore_imf_context_input_panel_hide(imf_context);
1107 ecore_imf_context_input_panel_event_callback_del(imf_context,
1108 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1111 elm_object_disabled_set(p->l_button, EINA_TRUE);
1112 elm_object_disabled_set(p->r_button, EINA_TRUE);
1113 elm_object_disabled_set(p->r_button2, EINA_TRUE);
1114 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1115 elm_object_item_disabled_set(p->c_item[0], EINA_TRUE);
1117 if (!strcmp(vd->ugd->start_view_type, "account-add")) {
1118 ug_destroy_me(vd->ugd->ug);
1120 setting_back_to_prev_view(vd);
1124 static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1127 struct viewdata *vd = (struct viewdata *)data;
1130 debug_log("vd is NULL");
1134 struct priv_data *p = vd->priv;
1135 Eina_Bool state = elm_check_state_get(obj);
1138 p->set_default_account = 1;
1140 p->set_default_account = 0;
1143 static void _check1_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1146 struct viewdata *vd = (struct viewdata *)data;
1149 debug_log("vd is NULL");
1153 struct priv_data *p = vd->priv;
1154 Eina_Bool state = elm_check_state_get(p->default_account_check);
1157 elm_check_state_set(p->default_account_check, EINA_FALSE);
1158 p->set_default_account = 0;
1160 elm_check_state_set(p->default_account_check, EINA_TRUE);
1161 p->set_default_account = 1;
1165 static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1168 struct viewdata *vd = (struct viewdata *)data;
1171 debug_log("vd is NULL");
1175 struct priv_data *p = vd->priv;
1176 EmailSettingUGD *ugd = NULL;
1179 Eina_Bool state = elm_check_state_get(obj);
1182 elm_entry_password_set(p->entry_password, EINA_FALSE);
1184 elm_entry_password_set(p->entry_password, EINA_TRUE);
1186 if (elm_object_focus_get(p->entry_password)) {
1187 if (ugd->password_timer) {
1188 ecore_timer_del(ugd->password_timer);
1189 ugd->password_timer = NULL;
1191 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1193 Ecore_IMF_Context *imf_context = NULL;
1194 imf_context = elm_entry_imf_context_get(p->entry_password);
1195 int state = ecore_imf_context_input_panel_state_get(imf_context);
1197 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1198 debug_log("input panel show");
1199 evas_object_show(p->l_button);
1200 evas_object_show(p->r_button);
1201 elm_object_item_part_content_set(p->navi_it, "title_left_btn", p->l_button);
1202 elm_object_item_part_content_set(p->navi_it, "title_right_btn", p->r_button);
1207 static void _check2_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1210 struct viewdata *vd = (struct viewdata *)data;
1213 debug_log("vd is NULL");
1217 struct priv_data *p = vd->priv;
1218 EmailSettingUGD *ugd = NULL;
1221 Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1224 elm_check_state_set(p->show_passwd_check, EINA_FALSE);
1225 elm_entry_password_set(p->entry_password, EINA_TRUE);
1227 elm_check_state_set(p->show_passwd_check, EINA_TRUE);
1228 elm_entry_password_set(p->entry_password, EINA_FALSE);
1231 if (elm_object_focus_get(p->entry_password)) {
1232 if (ugd->password_timer) {
1233 ecore_timer_del(ugd->password_timer);
1234 ugd->password_timer = NULL;
1236 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1238 Ecore_IMF_Context *imf_context = NULL;
1239 imf_context = elm_entry_imf_context_get(p->entry_password);
1240 int state = ecore_imf_context_input_panel_state_get(imf_context);
1242 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1243 debug_log("input panel show");
1244 evas_object_show(p->l_button);
1245 evas_object_show(p->r_button);
1246 elm_object_item_part_content_set(p->navi_it, "title_left_btn", p->l_button);
1247 elm_object_item_part_content_set(p->navi_it, "title_right_btn", p->r_button);
1252 static Eina_Bool _after_validation_cb(void *data)
1256 struct viewdata *vd = (struct viewdata *)data;
1259 debug_log("vd is NULL");
1260 return ECORE_CALLBACK_CANCEL;
1263 EmailSettingUGD *ugd = NULL;
1264 struct priv_data *p = NULL;
1269 if (ugd->preset_vc_timer) {
1270 ecore_timer_del(ugd->preset_vc_timer);
1271 ugd->preset_vc_timer = NULL;
1274 if (ugd->popup_one) {
1275 evas_object_del(ugd->popup_one);
1276 ugd->popup_one = NULL;
1278 if (ugd->popup_validate) {
1279 evas_object_del(ugd->popup_validate);
1280 ugd->popup_validate = NULL;
1283 if (p->set_default_account) {
1284 if (email_engine_set_default_account(vd->ugd->account_id)) {
1285 debug_log("new default account is %d", vd->ugd->account_id);
1289 status_message_post(_("IDS_EMAIL_POP_SUCCEEDED"));
1291 setting_change_view(VIEW_SYNC_SETUP, ugd);
1293 setting_get_small_notify(vd, _("IDS_EMAIL_POP_SUCCEEDED"));
1295 /*debug_log("_after_validation_cb %s", vd->ugd->start_view_type);
1297 if (vd->ugd->start_view_type != NULL &&
1298 strcmp(vd->ugd->start_view_type, "first-setup") == 0) {
1299 ug_destroy_me(vd->ugd->ug);
1300 } else if (vd->ugd->start_view_type != NULL &&
1301 strcmp(vd->ugd->start_view_type, "account-add") == 0) {
1302 ug_destroy_me(vd->ugd->ug);
1303 } else if (vd->ugd->start_view_type != NULL &&
1304 strcmp(vd->ugd->start_view_type, "select-account") == 0) {
1305 service_h service = NULL;
1306 service_create(&service);
1308 service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT);
1309 ug_send_result(vd->ugd->ug, service);
1310 service_destroy(service);
1313 setting_update_acct_list(vd);
1314 setting_back_to_prev_nth_view(vd, 2, vd->ugd->navi_main_it);
1315 vd->ugd->atomic_pop = 0;
1318 return ECORE_CALLBACK_CANCEL;
1321 static Eina_Bool _password_state_cb(void *data)
1325 struct viewdata *vd = (struct viewdata *)data;
1328 debug_log("vd is NULL");
1329 return ECORE_CALLBACK_CANCEL;
1332 struct priv_data *p = NULL;
1334 EmailSettingUGD *ugd = NULL;
1337 if (ugd->password_timer) {
1338 ecore_timer_del(ugd->password_timer);
1339 ugd->password_timer = NULL;
1342 Ecore_IMF_Context *imf_context = NULL;
1343 imf_context = elm_entry_imf_context_get(p->entry_password);
1345 ecore_imf_context_input_panel_event_callback_del(imf_context,
1346 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1347 ecore_imf_context_input_panel_event_callback_add(imf_context,
1348 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1349 _input_panel_state_changed_cb, (void *)vd);
1352 return ECORE_CALLBACK_CANCEL;
1355 static Eina_Bool _startup_focus_cb(void *data)
1359 struct viewdata *vd = (struct viewdata *)data;
1362 debug_log("vd is NULL");
1363 return ECORE_CALLBACK_CANCEL;
1366 struct priv_data *p = NULL;
1369 EmailSettingUGD *ugd = NULL;
1372 if (ugd->focus_timer) {
1373 ecore_timer_del(ugd->focus_timer);
1374 ugd->focus_timer = NULL;
1377 if (ugd->account_info == OTHERS) {
1378 p->clicked_object = p->entry_account_name;
1379 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1381 p->clicked_object = p->entry_email_address;
1382 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1383 elm_entry_cursor_begin_set(p->entry_email_address);
1386 return ECORE_CALLBACK_CANCEL;
1389 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1393 debug_log("data is NULL");
1397 struct viewdata *vd = (struct viewdata *)data;
1398 EmailSettingUGD *ugd = vd->ugd;
1399 struct priv_data *p = vd->priv;
1401 if (ugd->popup_one) {
1402 evas_object_del(ugd->popup_one);
1403 ugd->popup_one = NULL;
1405 if (ugd->popup_validate) {
1406 evas_object_del(ugd->popup_validate);
1407 ugd->popup_validate = NULL;
1410 elm_object_disabled_set(p->l_button, EINA_FALSE);
1411 elm_object_disabled_set(p->r_button, EINA_FALSE);
1412 elm_object_disabled_set(p->r_button2, EINA_FALSE);
1413 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1414 elm_object_item_disabled_set(p->c_item[0], EINA_FALSE);
1417 static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info)
1421 debug_log("data is NULL");
1425 struct viewdata *vd = (struct viewdata *)data;
1426 EmailSettingUGD *ugd = vd->ugd;
1427 struct priv_data *p = vd->priv;
1429 if (ugd->popup_one) {
1430 evas_object_del(ugd->popup_one);
1431 ugd->popup_one = NULL;
1433 if (ugd->popup_validate) {
1434 evas_object_del(ugd->popup_validate);
1435 ugd->popup_validate = NULL;
1438 int account_id = vd->ugd->account_id;
1439 vd->ugd->cancel_event = 1;
1440 email_engine_stop_working(account_id, p->handle);
1441 email_engine_delete_account(account_id);
1443 elm_object_disabled_set(p->l_button, EINA_FALSE);
1444 elm_object_disabled_set(p->r_button, EINA_FALSE);
1445 elm_object_disabled_set(p->r_button2, EINA_FALSE);
1446 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1447 elm_object_item_disabled_set(p->c_item[0], EINA_FALSE);
1450 static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info)
1453 Evas_Object *eo = (Evas_Object *)obj;
1454 struct viewdata *vd = g_vd;
1458 struct priv_data *p = vd->priv;
1462 EmailSettingUGD *ugd = vd->ugd;
1466 if (elm_object_focus_get(data)) {
1467 if (elm_entry_is_empty(obj))
1468 elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1470 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1473 if (eo == p->entry_account_name) {
1474 debug_log("entry_account_name");
1475 if (p->str_account_name) {
1476 g_free(p->str_account_name);
1477 p->str_account_name = NULL;
1480 p->str_account_name = g_strdup(elm_entry_entry_get(eo));
1481 } else if (eo == p->entry_user_id) {
1482 debug_log("entry_user_id");
1483 if (p->str_user_id) {
1484 g_free(p->str_user_id);
1485 p->str_user_id = NULL;
1488 p->str_user_id = g_strdup(elm_entry_entry_get(eo));
1489 } else if (eo == p->entry_display_name) {
1490 debug_log("entry_display_name");
1491 if (p->str_display_name) {
1492 g_free(p->str_display_name);
1493 p->str_display_name = NULL;
1496 p->str_display_name = g_strdup(elm_entry_entry_get(eo));
1497 } else if (eo == p->entry_email_address) {
1498 debug_log("entry_email_address");
1499 if (p->str_email_address) {
1500 g_free(p->str_email_address);
1501 p->str_email_address = NULL;
1504 p->str_email_address = g_strdup(elm_entry_entry_get(eo));
1505 } else if (eo == p->entry_password) {
1506 debug_log("entry_password");
1507 if (p->str_password) {
1508 g_free(p->str_password);
1509 p->str_password = NULL;
1512 p->str_password = g_strdup(elm_entry_entry_get(eo));
1515 if (ugd->account_info == OTHERS) {
1516 if (p->str_account_name == NULL) {
1517 elm_object_disabled_set(p->l_button, EINA_TRUE);
1518 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1519 elm_object_item_disabled_set(p->c_item[0], EINA_TRUE);
1523 if (g_strcmp0(p->str_account_name, "") == 0) {
1524 elm_object_disabled_set(p->l_button, EINA_TRUE);
1525 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1526 elm_object_item_disabled_set(p->c_item[0], EINA_TRUE);
1531 if (p->str_email_address == NULL || p->str_password == NULL) {
1532 elm_object_disabled_set(p->l_button, EINA_TRUE);
1533 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1534 elm_object_item_disabled_set(p->c_item[0], EINA_TRUE);
1538 if (g_strcmp0(p->str_email_address, "") == 0 || g_strcmp0(p->str_password, "") == 0) {
1539 elm_object_disabled_set(p->l_button, EINA_TRUE);
1540 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1541 elm_object_item_disabled_set(p->c_item[0], EINA_TRUE);
1543 elm_object_disabled_set(p->l_button, EINA_FALSE);
1544 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1545 elm_object_item_disabled_set(p->c_item[0], EINA_FALSE);
1549 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
1554 debug_log("obj is NULL");
1558 struct viewdata *vd = g_vd;
1559 struct priv_data *p = vd->priv;
1561 if (obj == p->entry_password) {
1562 Ecore_IMF_Context *imf_context = NULL;
1563 imf_context = elm_entry_imf_context_get(p->entry_password);
1565 ecore_imf_context_input_panel_event_callback_del(imf_context,
1566 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1567 ecore_imf_context_input_panel_event_callback_add(imf_context,
1568 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1569 _input_panel_state_changed_cb, (void *)vd);
1573 if (!elm_entry_is_empty(obj))
1574 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1575 elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
1578 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
1583 debug_log("obj is NULL");
1587 if (elm_entry_is_empty(obj))
1588 elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
1589 elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1592 static void _entry_theme_changed_cb(void *data, Evas_Object *obj, void *event_info)
1597 debug_log("obj is NULL");
1601 struct viewdata *vd = (struct viewdata *)data;
1604 debug_log("vd is NULL");
1608 struct priv_data *p = NULL;
1611 Ecore_IMF_Context *imf_context = NULL;
1612 imf_context = elm_entry_imf_context_get(p->entry_password);
1614 ecore_imf_context_input_panel_event_callback_del(imf_context,
1615 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1616 ecore_imf_context_input_panel_event_callback_add(imf_context,
1617 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1618 _input_panel_state_changed_cb, (void *)vd);
1622 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1627 debug_log("obj is NULL");
1631 elm_entry_entry_set(data, "");
1634 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
1639 debug_log("data is NULL");
1643 struct viewdata *vd = (struct viewdata *)data;
1644 struct priv_data *p = vd->priv;
1646 int state = ecore_imf_context_input_panel_state_get(ctx);
1648 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1649 debug_log("state:SHOW");
1650 else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1651 debug_log("state HIDE");
1653 if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1654 debug_log("value:SHOW");
1655 else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1656 debug_log("value HIDE");
1658 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
1659 debug_log("input panel show");
1660 evas_object_show(p->l_button);
1661 evas_object_show(p->r_button);
1662 elm_object_item_part_content_set(p->navi_it, "title_left_btn", p->l_button);
1663 elm_object_item_part_content_set(p->navi_it, "title_right_btn", p->r_button);
1664 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1665 debug_log("input panel hide");
1666 elm_object_item_part_content_unset(p->navi_it, "title_left_btn");
1667 elm_object_item_part_content_unset(p->navi_it, "title_right_btn");
1668 evas_object_hide(p->l_button);
1669 evas_object_hide(p->r_button);
1673 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info)
1676 int index = (int)data;
1677 struct viewdata *vd = g_vd;
1678 struct priv_data *p = vd->priv;
1680 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1681 elm_genlist_item_selected_set(item, EINA_FALSE);
1684 p->clicked_object = p->entry_account_name;
1685 } else if (index == 2) {
1686 p->clicked_object = p->entry_user_id;
1687 } else if (index == 3) {
1688 p->clicked_object = p->entry_display_name;
1689 } else if (index == 4) {
1690 p->clicked_object = p->entry_email_address;
1691 } else if (index == 5) {
1692 p->clicked_object = p->entry_password;
1696 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part)
1699 int index = (int)data;
1700 struct viewdata *vd = g_vd;
1701 struct priv_data *p = vd->priv;
1702 //EmailSettingUGD *ugd = vd->ugd;
1703 Ecore_IMF_Context *imf_context = NULL;
1705 if (!strcmp(part, "elm.icon")) {
1707 //p->icon_get_cnt1++;
1710 p->ef_account_name = elm_layout_add(p->genlist);
1711 elm_layout_theme_set(p->ef_account_name, "layout", "editfield", "title");
1712 p->entry_account_name = elm_entry_add(p->genlist);
1713 elm_entry_scrollable_set(p->entry_account_name, EINA_TRUE);
1714 elm_entry_single_line_set(p->entry_account_name, EINA_TRUE);
1715 elm_entry_input_panel_return_key_disabled_set(p->entry_account_name, EINA_TRUE);
1716 elm_entry_cnp_mode_set(p->entry_account_name, ELM_CNP_MODE_PLAINTEXT);
1717 elm_entry_input_panel_layout_set(p->entry_account_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1718 elm_entry_editable_set(p->entry_account_name, TRUE);
1719 evas_object_smart_callback_add(p->entry_account_name, "changed", _backup_input_cb, p->ef_account_name);
1720 evas_object_smart_callback_add(p->entry_account_name, "focused", _entry_focused_cb, p->ef_account_name);
1721 evas_object_smart_callback_add(p->entry_account_name, "unfocused", _entry_unfocused_cb, p->ef_account_name);
1722 evas_object_show(p->entry_account_name);
1724 imf_context = elm_entry_imf_context_get(p->entry_account_name);
1726 ecore_imf_context_input_panel_event_callback_add(imf_context,
1727 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1728 _input_panel_state_changed_cb, (void *)vd);
1730 elm_object_part_content_set(p->ef_account_name, "elm.swallow.content", p->entry_account_name);
1731 /*elm_object_part_text_set(p->ef_account_name, "elm.guidetext", str);*/
1732 elm_object_part_text_set(p->ef_account_name, "elm.text", _("IDS_EMAIL_BODY_ACCOUNT_NAME"));
1733 elm_object_signal_callback_add(p->ef_account_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_account_name);
1735 evas_object_size_hint_weight_set(p->ef_account_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1736 evas_object_show(p->ef_account_name);
1738 if (p->str_account_name)
1739 elm_entry_entry_set(p->entry_account_name, p->str_account_name);
1741 /*if (ugd->account_info == OTHERS && p->icon_get_cnt1 == 2 &&
1742 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1743 p->clicked_object = p->entry_account_name;
1744 evas_object_show(p->entry_account_name);
1745 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1748 if (ugd->account_info == OTHERS && p->icon_get_cnt1 == 3 &&
1749 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1750 p->clicked_object = p->entry_account_name;
1751 evas_object_show(p->entry_account_name);
1752 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1755 return p->ef_account_name;
1756 } else if (index == 2) {
1758 p->ef_user_id = elm_layout_add(p->genlist);
1759 elm_layout_theme_set(p->ef_user_id, "layout", "editfield", "title");
1760 p->entry_user_id = elm_entry_add(p->genlist);
1761 elm_entry_scrollable_set(p->entry_user_id, EINA_TRUE);
1762 elm_entry_single_line_set(p->entry_user_id, EINA_TRUE);
1763 elm_entry_input_panel_return_key_disabled_set(p->entry_user_id, EINA_TRUE);
1764 elm_entry_cnp_mode_set(p->entry_user_id, ELM_CNP_MODE_PLAINTEXT);
1765 elm_entry_input_panel_layout_set(p->entry_user_id, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1766 elm_entry_editable_set(p->entry_user_id, TRUE);
1767 evas_object_smart_callback_add(p->entry_user_id, "changed", _backup_input_cb, p->ef_user_id);
1768 evas_object_smart_callback_add(p->entry_user_id, "focused", _entry_focused_cb, p->ef_user_id);
1769 evas_object_smart_callback_add(p->entry_user_id, "unfocused", _entry_unfocused_cb, p->ef_user_id);
1770 evas_object_show(p->entry_user_id);
1772 imf_context = elm_entry_imf_context_get(p->entry_user_id);
1774 ecore_imf_context_input_panel_event_callback_add(imf_context,
1775 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1776 _input_panel_state_changed_cb, (void *)vd);
1778 elm_object_part_content_set(p->ef_user_id, "elm.swallow.content", p->entry_user_id);
1779 /*elm_object_part_text_set(p->ef_user_id, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));*/
1780 elm_object_part_text_set(p->ef_user_id, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));
1781 elm_object_signal_callback_add(p->ef_user_id, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_user_id);
1783 evas_object_size_hint_weight_set(p->ef_user_id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1784 evas_object_show(p->ef_user_id);
1787 elm_entry_entry_set(p->entry_user_id, p->str_user_id);
1789 return p->ef_user_id;
1790 } else if (index == 3) {
1792 p->ef_display_name = elm_layout_add(p->genlist);
1793 elm_layout_theme_set(p->ef_display_name, "layout", "editfield", "title");
1794 p->entry_display_name = elm_entry_add(p->genlist);
1795 elm_entry_scrollable_set(p->entry_display_name, EINA_TRUE);
1796 elm_entry_single_line_set(p->entry_display_name, EINA_TRUE);
1797 elm_entry_input_panel_return_key_disabled_set(p->entry_display_name, EINA_TRUE);
1798 elm_entry_cnp_mode_set(p->entry_display_name, ELM_CNP_MODE_PLAINTEXT);
1799 elm_entry_input_panel_layout_set(p->entry_display_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1800 elm_entry_editable_set(p->entry_display_name, TRUE);
1801 evas_object_smart_callback_add(p->entry_display_name, "changed", _backup_input_cb, p->ef_display_name);
1802 evas_object_smart_callback_add(p->entry_display_name, "focused", _entry_focused_cb, p->ef_display_name);
1803 evas_object_smart_callback_add(p->entry_display_name, "unfocused", _entry_unfocused_cb, p->ef_display_name);
1804 evas_object_show(p->entry_display_name);
1806 imf_context = elm_entry_imf_context_get(p->entry_display_name);
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);
1812 elm_object_part_content_set(p->ef_display_name, "elm.swallow.content", p->entry_display_name);
1813 /*elm_object_part_text_set(p->ef_display_name, "elm.guidetext", _("IDS_EMAIL_BODY_YOUR_NAME"));*/
1814 elm_object_part_text_set(p->ef_display_name, "elm.text", dgettext("sys_string", "IDS_COM_BODY_DETAILS_NAME"));
1815 elm_object_signal_callback_add(p->ef_display_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_display_name);
1817 evas_object_size_hint_weight_set(p->ef_display_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1818 evas_object_show(p->ef_display_name);
1820 if (p->str_display_name)
1821 elm_entry_entry_set(p->entry_display_name, p->str_display_name);
1823 return p->ef_display_name;
1824 } else if (index == 4) {
1825 //p->icon_get_cnt2++;
1828 p->ef_email_address = elm_layout_add(p->genlist);
1829 elm_layout_theme_set(p->ef_email_address, "layout", "editfield", "title");
1830 p->entry_email_address = elm_entry_add(p->genlist);
1831 elm_entry_scrollable_set(p->entry_email_address, EINA_TRUE);
1832 elm_entry_single_line_set(p->entry_email_address, EINA_TRUE);
1833 elm_entry_input_panel_return_key_disabled_set(p->entry_email_address, EINA_TRUE);
1834 elm_entry_cnp_mode_set(p->entry_email_address, ELM_CNP_MODE_PLAINTEXT);
1835 elm_entry_input_panel_layout_set(p->entry_email_address, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1836 elm_entry_editable_set(p->entry_email_address, TRUE);
1837 evas_object_smart_callback_add(p->entry_email_address, "changed", _backup_input_cb, p->ef_email_address);
1838 evas_object_smart_callback_add(p->entry_email_address, "focused", _entry_focused_cb, p->ef_email_address);
1839 evas_object_smart_callback_add(p->entry_email_address, "unfocused", _entry_unfocused_cb, p->ef_email_address);
1840 evas_object_show(p->entry_email_address);
1842 imf_context = elm_entry_imf_context_get(p->entry_email_address);
1844 ecore_imf_context_input_panel_event_callback_add(imf_context,
1845 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1846 _input_panel_state_changed_cb, (void *)vd);
1848 elm_object_part_content_set(p->ef_email_address, "elm.swallow.content", p->entry_email_address);
1849 /*_set_help_string(p->ef_email_address, vd);*/
1850 elm_object_part_text_set(p->ef_email_address, "elm.text", dgettext("sys_string", "IDS_COM_BODY_EMAIL_ADDRESS"));
1851 elm_object_signal_callback_add(p->ef_email_address, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_email_address);
1853 evas_object_size_hint_weight_set(p->ef_email_address, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1854 evas_object_show(p->ef_email_address);
1856 if (p->str_email_address)
1857 elm_entry_entry_set(p->entry_email_address, p->str_email_address);
1859 /*if (ugd->account_info != OTHERS && p->icon_get_cnt2 == 2 &&
1860 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1861 p->clicked_object = p->entry_email_address;
1862 evas_object_show(p->entry_email_address);
1863 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1864 elm_entry_cursor_begin_set(p->entry_email_address);
1867 if (ugd->account_info != OTHERS && p->icon_get_cnt2 == 3 &&
1868 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1869 p->clicked_object = p->entry_email_address;
1870 evas_object_show(p->entry_email_address);
1871 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1872 elm_entry_cursor_begin_set(p->entry_email_address);
1875 return p->ef_email_address;
1876 } else if (index == 5) {
1878 p->ef_password = elm_layout_add(p->genlist);
1879 elm_layout_theme_set(p->ef_password, "layout", "editfield", "title");
1880 p->entry_password = elm_entry_add(p->genlist);
1881 elm_entry_scrollable_set(p->entry_password, EINA_TRUE);
1882 elm_entry_single_line_set(p->entry_password, EINA_TRUE);
1883 elm_entry_input_panel_return_key_disabled_set(p->entry_password, EINA_TRUE);
1884 elm_entry_cnp_mode_set(p->entry_password, ELM_CNP_MODE_PLAINTEXT);
1885 elm_entry_input_panel_layout_set(p->entry_password, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1886 elm_entry_editable_set(p->entry_password, EINA_TRUE);
1887 elm_entry_password_set(p->entry_password, EINA_TRUE);
1889 evas_object_smart_callback_add(p->entry_password, "changed", _backup_input_cb, p->ef_password);
1890 evas_object_smart_callback_add(p->entry_password, "focused", _entry_focused_cb, p->ef_password);
1891 evas_object_smart_callback_add(p->entry_password, "unfocused", _entry_unfocused_cb, p->ef_password);
1892 //evas_object_smart_callback_add(p->entry_password, "theme,changed", _entry_theme_changed_cb, (void *)vd);
1893 evas_object_show(p->entry_password);
1895 imf_context = elm_entry_imf_context_get(p->entry_password);
1897 ecore_imf_context_input_panel_event_callback_add(imf_context,
1898 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1899 _input_panel_state_changed_cb, (void *)vd);
1901 elm_object_part_content_set(p->ef_password, "elm.swallow.content", p->entry_password);
1902 /*elm_object_part_text_set(p->ef_password, "elm.guidetext", _("IDS_EMAIL_BODY_USER_PASSWORD"));*/
1903 elm_object_part_text_set(p->ef_password, "elm.text", dgettext("sys_string", "IDS_COM_BODY_PASSWORD"));
1904 elm_object_signal_callback_add(p->ef_password, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_password);
1906 evas_object_size_hint_weight_set(p->ef_password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1907 evas_object_show(p->ef_password);
1909 if (p->str_password)
1910 elm_entry_entry_set(p->entry_password, p->str_password);
1912 Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1915 elm_entry_password_set(p->entry_password, EINA_FALSE);
1917 elm_entry_password_set(p->entry_password, EINA_TRUE);
1919 return p->ef_password;