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, EmailSpDesc *desc);
37 static void _read_all_entries(struct viewdata *vd);
38 /*static void _set_help_string(Evas_Object *eo, struct viewdata *vd);*/
39 static void _set_domain_string(struct viewdata *vd);
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 _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source);
59 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value);
60 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info);
61 static char *_gl_group_text_get(void *data, Evas_Object *obj, const char *part);
62 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part);
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;
89 Evas_Object *scroller;
91 Evas_Object *l_button;
92 Evas_Object *r_button;
93 Evas_Object *r_button2;
94 Evas_Object *tool_btn;
95 Evas_Object *manual_btn;
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;
105 Elm_Genlist_Item_Class itc3;
108 Elm_Object_Item * c_item[4];
109 Elm_Object_Item *navi_it;
113 int set_default_account;
116 void setting_init_account_setup_view(struct viewdata *vd)
119 vd->type = VIEW_ACCOUNT_SETUP;
120 vd->create = _create;
121 vd->update = _update;
122 vd->destroy = _destroy;
125 vd->grp_nm = "setting_account_setup";
128 void setting_account_validation_success_cb(EmailSettingUGD *ugd)
133 top = ugd->view_st[ugd->view_top];
137 debug_log("vd is NULL");
143 if (ugd->popup_one) {
144 evas_object_del(ugd->popup_one);
145 ugd->popup_one = NULL;
147 if (ugd->popup_validate) {
148 evas_object_del(ugd->popup_validate);
149 ugd->popup_validate = NULL;
152 ugd->preset_vc_timer = ecore_timer_add(0.5, _after_validation_cb, vd);
155 void setting_account_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled)
161 top = ugd->view_st[ugd->view_top];
165 debug_log("vd is NULL");
169 account_id = ugd->account_id;
171 if (ugd->popup_one) {
172 evas_object_del(ugd->popup_one);
173 ugd->popup_one = NULL;
175 /*if (ugd->popup_validate) {
176 evas_object_del(ugd->popup_validate);
177 ugd->popup_validate = NULL;
180 if (canceled || ugd->err_code == EMAIL_ERROR_CANCELLED) {
181 ugd->popup_one = setting_get_notify(vd,
182 dgettext("sys_string", "IDS_COM_POP_WARNING"),
183 _("IDS_EMAIL_POP_ACCOUNT_CREATION_CANCELLED"),
184 1, dgettext("sys_string", "IDS_COM_SK_OK"),
185 _popup_ok_cb, NULL, NULL);
187 char *type = setting_get_service_fail_type(ugd->err_code);
188 ugd->popup_one = setting_get_notify(vd,
189 dgettext("sys_string", "IDS_COM_POP_WARNING"),
190 type, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
191 _popup_ok_cb, NULL, NULL);
196 static int _create(struct viewdata *vd)
201 debug_log("vd is NULL");
206 EmailSettingUGD *ugd = vd->ugd;
210 p = vd->priv = calloc(1, sizeof(struct priv_data));
213 p->layout = setting_add_inner_layout(vd);
217 p->scroller = elm_scroller_add(ugd->navi_bar);
218 evas_object_propagate_events_set(p->scroller, EINA_FALSE);
219 elm_scroller_bounce_set(p->scroller, EINA_FALSE, EINA_FALSE);
220 elm_scroller_policy_set(p->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
221 evas_object_show(p->scroller);
223 elm_object_part_content_set(p->layout, "elm.swallow.content", p->scroller);
227 ugd->wds_account_creation = 0;
229 if (vd->ugd->account_info != NULL) {
230 _set_domain_string(vd);
233 ugd->focus_timer = ecore_timer_add(0.5, _startup_focus_cb, (void *)vd);
241 static int _update(struct viewdata *vd)
248 static int _destroy(struct viewdata *vd)
251 struct priv_data *p = vd->priv;
252 EmailSettingUGD *ugd = vd->ugd;
254 Ecore_IMF_Context *imf_context = NULL;
255 imf_context = elm_entry_imf_context_get(p->clicked_object);
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);
262 evas_object_del(p->l_button);
263 evas_object_del(p->r_button);
264 evas_object_del(p->genlist);
265 evas_object_del(p->tool_btn);
267 if (ugd->password_timer) {
268 ecore_timer_del(ugd->password_timer);
269 ugd->password_timer = NULL;
272 if (ugd->focus_timer) {
273 ecore_timer_del(ugd->focus_timer);
274 ugd->focus_timer = NULL;
277 if (ugd->preset_vc_timer) {
278 ecore_timer_del(ugd->preset_vc_timer);
279 ugd->preset_vc_timer = NULL;
282 if (ugd->popup_one) {
283 evas_object_del(ugd->popup_one);
284 ugd->popup_one = NULL;
286 if (ugd->popup_validate) {
287 evas_object_del(ugd->popup_validate);
288 ugd->popup_validate = NULL;
291 ugd->account_info = NULL;
293 setting_new_acct_final(vd);
297 static int _show(struct viewdata *vd)
302 debug_log("vd is NULL");
306 evas_object_show(vd->ly);
311 static int _hide(struct viewdata *vd)
316 debug_log("vd is NULL");
320 evas_object_hide(vd->ly);
325 static void _push_naviframe(struct viewdata *vd)
328 struct priv_data *p = vd->priv;
330 p->l_button = elm_button_add(vd->ugd->navi_bar);
331 elm_object_style_set(p->l_button, "naviframe/toolbar/default");
332 elm_object_focus_allow_set(p->l_button, EINA_FALSE);
333 evas_object_show(p->l_button);
335 if (vd->ugd->account_info == NULL) {
336 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_SK_NEXT"));
337 evas_object_smart_callback_add(p->l_button, "clicked", _next_cb, vd);
339 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
340 evas_object_smart_callback_add(p->l_button, "clicked", _save_cb, vd);
343 elm_object_disabled_set(p->l_button, EINA_TRUE);
345 p->r_button = elm_button_add(vd->ugd->navi_bar);
346 elm_object_style_set(p->r_button, "naviframe/end_btn/default");
347 /*elm_object_text_set(p->r_button, dgettext("sys_string", "IDS_COM_SK_CANCEL"));*/
348 evas_object_smart_callback_add(p->r_button, "clicked", _back_cb, vd);
349 evas_object_show(p->r_button);
351 p->r_button2 = elm_button_add(vd->ugd->navi_bar);
352 elm_object_style_set(p->r_button2, "naviframe/end_btn/default");
353 evas_object_smart_callback_add(p->r_button2, "clicked", _back_cb, vd);
354 evas_object_show(p->r_button2);
356 p->tool_btn = elm_button_add(vd->ugd->navi_bar);
357 elm_object_style_set(p->tool_btn, "naviframe/toolbar/default");
358 elm_object_text_set(p->tool_btn, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
359 if (vd->ugd->account_info == NULL) {
360 evas_object_smart_callback_add(p->tool_btn, "clicked", _next_cb, vd);
362 evas_object_smart_callback_add(p->tool_btn, "clicked", _save_cb, vd);
365 Elm_Object_Item *navi_it = NULL;
366 navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, _("IDS_EMAIL_HEADER_ADD_ACCOUNT"), NULL, NULL, p->layout, NULL);
367 elm_object_item_part_content_set(navi_it, "title_toolbar_button1", p->l_button);
368 elm_object_item_part_content_set(navi_it, "title_prev_btn", p->r_button);
369 elm_object_item_part_content_set(navi_it, "toolbar_button1", p->tool_btn);
370 elm_object_item_part_content_set(navi_it, "prev_btn", p->r_button2);
371 p->navi_it = navi_it;
372 evas_object_show(vd->ugd->navi_bar);
375 static void _create_view(struct viewdata *vd)
379 EmailSettingUGD *ugd;
382 debug_log("vd is null!");
390 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
391 debug_log("WINDOW W[%d] H[%d]", w, h);
393 Evas_Object *sub_ly = elm_layout_add(ugd->navi_bar);
396 if (vd->ugd->account_info == NULL)
397 elm_layout_file_set(sub_ly, EV_THEME_PATH, "other_account_add_wvga");
399 elm_layout_file_set(sub_ly, EV_THEME_PATH, "account_add_wvga");
401 if (vd->ugd->account_info == NULL)
402 elm_layout_file_set(sub_ly, EV_THEME_PATH, "other_account_add");
404 elm_layout_file_set(sub_ly, EV_THEME_PATH, "account_add");
406 evas_object_size_hint_weight_set(sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
407 evas_object_show(sub_ly);
410 elm_object_part_content_set(sub_ly, "list", p->genlist);
412 Evas_Object *checkbox_set = elm_layout_add(sub_ly);
414 elm_layout_file_set(checkbox_set, EV_THEME_PATH, "account_add_checkbox_set_wvga");
416 elm_layout_file_set(checkbox_set, EV_THEME_PATH, "account_add_checkbox_set");
418 evas_object_size_hint_weight_set(checkbox_set, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
419 evas_object_show(checkbox_set);
421 Evas_Object *check1 = elm_check_add(checkbox_set);
422 elm_check_state_set(check1, EINA_FALSE);
423 evas_object_smart_callback_add(check1, "changed", _check1_clicked_cb, (void *)vd);
424 elm_object_part_content_set(checkbox_set, "checkbox.1", check1);
425 elm_object_focus_allow_set(check1, EINA_FALSE);
426 p->default_account_check = check1;
428 Evas_Object *check2 = elm_check_add(checkbox_set);
429 elm_check_state_set(check2, EINA_FALSE);
430 evas_object_smart_callback_add(check2, "changed", _check2_clicked_cb, (void *)vd);
431 elm_object_part_content_set(checkbox_set, "checkbox.2", check2);
432 elm_object_focus_allow_set(check2, EINA_FALSE);
433 p->show_passwd_check = check2;
435 char *desc = g_strdup(_("IDS_EMAIL_BODY_SEND_EMAIL_FROM_THIS_ACCOUNT_BY_DEFAULT"));
436 Evas_Object *label1 = elm_label_add(checkbox_set);
437 elm_label_wrap_width_set(label1, 600*elm_config_scale_get());
438 elm_label_line_wrap_set(label1, ELM_WRAP_WORD);
439 char *text = g_strconcat("<color=#838B8BFF><font_size=32><align=left>",
440 desc, "</align></font_size></color>", NULL);
441 edje_object_signal_callback_add(elm_layout_edje_get(checkbox_set),
442 "elm,action,text1_clicked", "elm", _check1_clicked_cb2, (void *)vd);
443 elm_object_text_set(label1, text);
444 evas_object_show(label1);
447 elm_object_part_content_set(checkbox_set, "text.1", label1);
449 desc = g_strdup(_("IDS_EMAIL_BODY_SHOW_PASSWORD"));
450 Evas_Object *label2 = elm_label_add(checkbox_set);
451 elm_label_wrap_width_set(label2, 600*elm_config_scale_get());
452 elm_label_line_wrap_set(label2, ELM_WRAP_WORD);
453 text = g_strconcat("<color=#838B8BFF><font_size=32><align=left>",
454 desc, "</align></font_size></color>", NULL);
455 edje_object_signal_callback_add(elm_layout_edje_get(checkbox_set),
456 "elm,action,text2_clicked", "elm", _check2_clicked_cb2, (void *)vd);
457 elm_object_text_set(label2, text);
458 evas_object_show(label2);
461 elm_object_part_content_set(checkbox_set, "text.2", label2);
463 elm_object_part_content_set(sub_ly, "checkbox_set", checkbox_set);
465 Evas_Object *button_set = elm_layout_add(sub_ly);
467 elm_layout_file_set(button_set, EV_THEME_PATH, "account_add_manual_button_wvga");
469 elm_layout_file_set(button_set, EV_THEME_PATH, "account_add_manual_button");
471 evas_object_size_hint_weight_set(button_set, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
472 evas_object_show(button_set);
474 Evas_Object *btn = elm_button_add(button_set);
475 elm_object_text_set(btn, _("IDS_EMAIL_BODY_MANUAL_SETUP"));
476 evas_object_smart_callback_add(btn, "clicked", _manual_cb, (void *)vd);
477 elm_object_style_set(btn, "text_only/style2");
478 evas_object_show(btn);
480 elm_object_part_content_set(button_set, "btn", btn);
481 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
483 elm_object_part_content_set(sub_ly, "button_set", button_set);
485 elm_object_content_set(p->scroller, sub_ly);
488 static void _create_list(struct viewdata *vd)
493 debug_critical("vd is null!");
498 EmailSettingUGD *ugd;
504 Elm_Object_Item *item = NULL;
505 Elm_Object_Item *git = NULL;
507 p->genlist = elm_genlist_add(ugd->navi_bar);
508 elm_object_style_set(p->genlist, "dialogue");
509 evas_object_show(p->genlist);
511 p->itc1.item_style = "dialogue/separator";
512 p->itc1.func.text_get = NULL;
513 p->itc1.func.content_get = NULL;
514 p->itc1.func.state_get = NULL;
515 p->itc1.func.del = NULL;
517 p->itc2.item_style = "dialogue/1icon";
518 p->itc2.func.text_get = NULL;
519 p->itc2.func.content_get = _gl_ef_content_get_cb;
520 p->itc2.func.state_get = NULL;
521 p->itc2.func.del = NULL;
523 p->itc3.item_style = "dialogue/grouptitle";
524 p->itc3.func.text_get = _gl_group_text_get;
525 p->itc3.func.content_get = NULL;
526 p->itc3.func.state_get = NULL;
527 p->itc3.func.del = NULL;
529 git = elm_genlist_item_append(p->genlist, &(p->itc3), NULL, NULL,
530 ELM_GENLIST_ITEM_NONE, NULL, NULL);
531 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
533 if (ugd->account_info == NULL) {
534 /* Account name for OTHER */
536 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
537 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
538 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE);
542 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
543 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
548 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
549 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
553 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
554 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
555 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE);
559 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
560 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
561 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE);
564 static void _create_validation_popup(struct viewdata *vd, int account_id)
569 debug_critical("vd is null!");
573 email_account_t *account = vd->ugd->new_account;
575 debug_log("account id:%d", account_id);
576 debug_log("account name:%s", account->account_name);
577 debug_log("email address:%s", account->user_email_address);
579 vd->ugd->account_id = account_id;
581 EmailSettingUGD *ugd = vd->ugd;
582 struct priv_data *p = vd->priv;
584 if (ugd->popup_one) {
585 evas_object_del(ugd->popup_one);
586 ugd->popup_one = NULL;
588 if (ugd->popup_validate) {
589 evas_object_del(ugd->popup_validate);
590 ugd->popup_validate = NULL;
593 vd->ugd->cancel_event = 0;
594 elm_object_disabled_set(p->l_button, EINA_TRUE);
595 elm_object_disabled_set(p->r_button, EINA_TRUE);
596 elm_object_disabled_set(p->r_button2, EINA_TRUE);
597 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
598 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
600 debug_log("Start Account Validation");
601 ugd->popup_validate = setting_get_pb_process_notify(vd,
602 _("IDS_EMAIL_POP_VALIDATING_ACCOUNT_ING"), 1,
603 dgettext("sys_string", "IDS_COM_SK_CANCEL"),
604 _popup_cancel_validation_cb, NULL, NULL);
607 static void _create_account(void *data)
611 struct viewdata *vd = (struct viewdata *)data;
614 debug_critical("vd is null!");
618 EmailSettingUGD *ugd = vd->ugd;
620 struct priv_data *p = vd->priv;
623 if (email_engine_add_account_with_validation(vd->ugd->new_account,
624 &account_id, &(p->handle), &error_code)) {
625 debug_log("Account added to Email Service DB");
626 vd->ugd->start_account_validation = 1;
627 ugd->handle = p->handle;
628 _create_validation_popup(vd, account_id);
630 debug_log("Fail to make account");
632 if (ugd->popup_one) {
633 evas_object_del(ugd->popup_one);
634 ugd->popup_one = NULL;
636 if (ugd->popup_validate) {
637 evas_object_del(ugd->popup_validate);
638 ugd->popup_validate = NULL;
641 if (error_code == EMAIL_ERROR_ALREADY_EXISTS)
642 ugd->popup_one = setting_get_notify(vd,
643 dgettext("sys_string", "IDS_COM_POP_WARNING"),
644 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 1,
645 dgettext("sys_string", "IDS_COM_SK_OK"),
646 _popup_ok_cb, NULL, NULL);
648 ugd->popup_one = setting_get_notify(vd,
649 dgettext("sys_string", "IDS_COM_POP_WARNING"),
650 _("IDS_EMAIL_POP_UNABLE_TO_ADD_ACCOUNT"), 1,
651 dgettext("sys_string", "IDS_COM_SK_OK"),
652 _popup_ok_cb, NULL, NULL);
657 static int _check_null_field(struct viewdata *vd)
661 if (vd->ugd->new_account == NULL) {
662 debug_log("new_account is NULL");
666 email_account_t *account = vd->ugd->new_account;
668 if (account->account_name == NULL || strlen(account->account_name) == 0 ||
669 /*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
670 account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
671 /*account->incoming_server_user_name == NULL || strlen(account->incoming_server_user_name) == 0 ||*/
672 account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
678 static int _check_preset_null_field(struct viewdata *vd)
682 if (vd->ugd->new_account == NULL) {
683 debug_log("new_account is NULL");
687 email_account_t *account = vd->ugd->new_account;
689 if (/*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
690 account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
691 account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
697 static int _check_preset_isp_name(char *addr, EmailSpDesc *desc)
702 if (g_strcmp0(desc->id, "Hotmail") == 0) {
705 ptr1 = g_strrstr(addr, "@hotmail.");
706 ptr2 = g_strrstr(addr, "@live.");
708 if (ptr1 != NULL || ptr2 != NULL)
710 } /*else if (g_strcmp0(desc->id, "Gmail") == 0) {
711 ret = g_str_has_suffix(addr, "@gmail.com") ||
712 g_str_has_suffix(addr, "@googlemail.com");
713 }*/ else if (g_strcmp0(desc->id, "AOL") == 0) {
716 ptr1 = g_strrstr(addr, "@aol.");
717 ptr2 = g_strrstr(addr, "@aim.");
719 if (ptr1 != NULL || ptr2 != NULL)
728 static void _read_all_entries(struct viewdata *vd)
736 debug_log("priv is NULL");
740 if (vd->ugd->new_account)
741 setting_new_acct_final(vd);
743 setting_new_acct_init(vd);
744 email_account_t *account = vd->ugd->new_account;
746 if (vd->ugd->account_info == NULL) {
747 /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_account_name));*/
748 if (p->entry_account_name) {
749 /*buf = (char *)elm_entry_entry_get(p->entry_account_name);
750 debug_log("account name : %s", buf);
752 account->account_name = g_strdup(buf);*/
753 account->account_name = g_strdup(p->str_account_name);
757 /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_email_address));*/
758 if (p->entry_email_address) {
759 /*buf = (char *)elm_entry_entry_get(p->entry_email_address);
760 debug_log("email addr : %s", buf);
762 account->user_email_address = g_strdup(buf);*/
763 account->user_email_address = g_strdup(p->str_email_address);
766 if (p->entry_password) {
767 /*buf = (char *)elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_password));
768 debug_log("password : %s", buf);
770 account->incoming_server_password = g_strdup(buf);
774 account->incoming_server_password = g_strdup(p->str_password);
778 static void _set_domain_string(struct viewdata *vd)
781 EmailSettingUGD *ugd = vd->ugd;
785 if (g_strcmp0(ugd->account_info->id, "Hotmail") == 0) {
786 p->str_email_address = g_strdup("@hotmail.com");
787 } else if (g_strcmp0(ugd->account_info->id, "Yahoomail") == 0) {
788 p->str_email_address = g_strdup("@yahoo.com");
789 } else if (g_strcmp0(ugd->account_info->id, "Gmail") == 0) {
790 p->str_email_address = g_strdup("@gmail.com");
791 } else if (g_strcmp0(ugd->account_info->id, "AOL") == 0) {
792 p->str_email_address = g_strdup("@aol.com");
794 debug_log("Unknown account type");
798 static void _next_cb(void *data, Evas_Object *obj, void *event_info)
802 struct viewdata *vd = (struct viewdata *)data;
805 debug_log("vd is NULL");
809 struct priv_data *p = NULL;
810 EmailSettingUGD *ugd = NULL;
817 Ecore_IMF_Context *imf_context = NULL;
818 imf_context = elm_entry_imf_context_get(p->clicked_object);
820 ecore_imf_context_input_panel_hide(imf_context);
823 /* Save the Account Data */
824 _read_all_entries(vd);
825 email_account_t *account = vd->ugd->new_account;
827 debug_log("accountStructure Info");
828 debug_log("Account Name:%s", account->account_name);
829 debug_log("Display Name:%s", account->user_display_name);
830 debug_log("Email Addr:%s", account->user_email_address);
831 debug_log("User Name:%s", account->incoming_server_user_name);
832 debug_log("User Password:%s", account->incoming_server_password);
834 if (ugd->popup_one) {
835 evas_object_del(ugd->popup_one);
836 ugd->popup_one = NULL;
838 if (ugd->popup_validate) {
839 evas_object_del(ugd->popup_validate);
840 ugd->popup_validate = NULL;
843 /* check Null field */
844 ret = _check_null_field(vd);
846 ugd->popup_one = setting_get_notify(vd,
847 dgettext("sys_string", "IDS_COM_POP_WARNING"),
848 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
849 dgettext("sys_string", "IDS_COM_SK_OK"),
850 _popup_ok_cb, NULL, NULL);
854 /* check character validation */
855 buf = g_strdup(account->user_email_address);
857 ret = email_get_address_validation(buf);
859 ugd->popup_one = setting_get_notify(vd,
860 dgettext("sys_string", "IDS_COM_POP_WARNING"),
861 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
862 dgettext("sys_string", "IDS_COM_SK_OK"),
863 _popup_ok_cb, NULL, NULL);
870 setting_change_view(VIEW_MANUAL_SETUP, ugd);
875 static void _save_cb(void *data, Evas_Object *obj, void *event_info)
878 struct viewdata *vd = (struct viewdata *)data;
881 debug_log("vd is NULL");
885 struct priv_data *p = NULL;
886 EmailSettingUGD *ugd = NULL;
893 Ecore_IMF_Context *imf_context = NULL;
894 imf_context = elm_entry_imf_context_get(p->clicked_object);
896 ecore_imf_context_input_panel_hide(imf_context);
900 _read_all_entries(vd);
901 email_account_t *account = vd->ugd->new_account;
903 debug_log("accountStructure Info");
904 debug_log("Display Name:%s", account->user_display_name);
905 debug_log("Email Addr:%s", account->user_email_address);
906 debug_log("User Password:%s", account->incoming_server_password);
908 if (ugd->popup_one) {
909 evas_object_del(ugd->popup_one);
910 ugd->popup_one = NULL;
912 if (ugd->popup_validate) {
913 evas_object_del(ugd->popup_validate);
914 ugd->popup_validate = NULL;
917 /* check Null field */
918 ret = _check_preset_null_field(vd);
920 debug_log("empty space in account info");
921 ugd->popup_one = setting_get_notify(vd,
922 dgettext("sys_string", "IDS_COM_POP_WARNING"),
923 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"),
924 1, dgettext("sys_string", "IDS_COM_SK_OK"),
925 _popup_ok_cb, NULL, NULL);
930 buf = g_strdup(account->user_email_address);
931 ret = _check_preset_isp_name(buf, ugd->account_info);
933 debug_log("wrong ISP server name for preset accounts");
934 ugd->popup_one = setting_get_notify(vd,
935 dgettext("sys_string", "IDS_COM_POP_WARNING"),
936 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
937 1, dgettext("sys_string", "IDS_COM_SK_OK"),
938 _popup_ok_cb, NULL, NULL);
944 /* check character validation */
945 buf = g_strdup(account->user_email_address);
947 ret = email_get_address_validation(buf);
949 debug_log("Wrong character in email address");
950 ugd->popup_one = setting_get_notify(vd,
951 dgettext("sys_string", "IDS_COM_POP_WARNING"),
952 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
953 1, dgettext("sys_string", "IDS_COM_SK_OK"),
954 _popup_ok_cb, NULL, NULL);
960 /* account info setting */
961 setting_set_account(vd);
966 static void _manual_cb(void *data, Evas_Object *obj, void *event_info)
970 struct viewdata *vd = (struct viewdata *)data;
973 debug_log("vd is NULL");
977 EmailSettingUGD *ugd = NULL;
983 /* Save the Account Data */
984 _read_all_entries(vd);
985 email_account_t *account = vd->ugd->new_account;
987 debug_log("accountStructure Info");
988 debug_log("Account Name:%s", account->account_name);
989 debug_log("Display Name:%s", account->user_display_name);
990 debug_log("Email Addr:%s", account->user_email_address);
991 debug_log("User Name:%s", account->incoming_server_user_name);
992 debug_log("User Password:%s", account->incoming_server_password);
994 if (ugd->popup_one) {
995 evas_object_del(ugd->popup_one);
996 ugd->popup_one = NULL;
998 if (ugd->popup_validate) {
999 evas_object_del(ugd->popup_validate);
1000 ugd->popup_validate = NULL;
1003 /* check Null field */
1004 if (vd->ugd->account_info == NULL) {
1005 ret = _check_null_field(vd);
1007 ret = _check_preset_null_field(vd);
1011 ugd->popup_one = setting_get_notify(vd,
1012 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1013 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
1014 dgettext("sys_string", "IDS_COM_SK_OK"),
1015 _popup_ok_cb, NULL, NULL);
1020 if (ugd->account_info) {
1021 buf = g_strdup(account->user_email_address);
1022 ret = _check_preset_isp_name(buf, ugd->account_info);
1024 debug_log("wrong ISP server name for preset accounts");
1025 ugd->popup_one = setting_get_notify(vd,
1026 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1027 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
1028 1, dgettext("sys_string", "IDS_COM_SK_OK"),
1029 _popup_ok_cb, NULL, NULL);
1036 /* check character validation */
1037 buf = g_strdup(account->user_email_address);
1039 ret = email_get_address_validation(buf);
1041 ugd->popup_one = setting_get_notify(vd,
1042 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1043 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
1044 dgettext("sys_string", "IDS_COM_SK_OK"),
1045 _popup_ok_cb, NULL, NULL);
1053 /* account info setting */
1054 if (ugd->account_info)
1055 setting_set_account(vd);
1057 setting_change_view(VIEW_MANUAL_SETUP, ugd);
1062 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
1066 struct viewdata *vd = (struct viewdata *)data;
1067 struct priv_data *p = vd->priv;
1069 if (vd->ugd->atomic_pop) {
1070 debug_log("During atomic poping");
1074 if (p->entry_account_name) {
1075 elm_object_focus_allow_set(p->entry_account_name, EINA_FALSE);
1078 if (p->entry_email_address) {
1079 elm_object_focus_allow_set(p->entry_email_address, EINA_FALSE);
1082 if (p->entry_password) {
1083 elm_object_focus_allow_set(p->entry_password, EINA_FALSE);
1086 Ecore_IMF_Context *imf_context = NULL;
1087 imf_context = elm_entry_imf_context_get(p->clicked_object);
1089 ecore_imf_context_input_panel_hide(imf_context);
1090 ecore_imf_context_input_panel_event_callback_del(imf_context,
1091 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1094 elm_object_disabled_set(p->l_button, EINA_TRUE);
1095 elm_object_disabled_set(p->r_button, EINA_TRUE);
1096 elm_object_disabled_set(p->r_button2, EINA_TRUE);
1097 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1098 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1100 if (!strcmp(vd->ugd->start_view_type, "account-add")) {
1101 ug_destroy_me(vd->ugd->ug);
1103 setting_back_to_prev_view(vd);
1107 static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1110 struct viewdata *vd = (struct viewdata *)data;
1113 debug_log("vd is NULL");
1117 struct priv_data *p = vd->priv;
1118 Eina_Bool state = elm_check_state_get(obj);
1121 p->set_default_account = 1;
1123 p->set_default_account = 0;
1126 static void _check1_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1129 struct viewdata *vd = (struct viewdata *)data;
1132 debug_log("vd is NULL");
1136 struct priv_data *p = vd->priv;
1137 Eina_Bool state = elm_check_state_get(p->default_account_check);
1140 elm_check_state_set(p->default_account_check, EINA_FALSE);
1141 p->set_default_account = 0;
1143 elm_check_state_set(p->default_account_check, EINA_TRUE);
1144 p->set_default_account = 1;
1148 static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1151 struct viewdata *vd = (struct viewdata *)data;
1154 debug_log("vd is NULL");
1158 struct priv_data *p = vd->priv;
1159 EmailSettingUGD *ugd = NULL;
1162 Eina_Bool state = elm_check_state_get(obj);
1165 elm_entry_password_set(p->entry_password, EINA_FALSE);
1167 elm_entry_password_set(p->entry_password, EINA_TRUE);
1169 if (elm_object_focus_get(p->entry_password)) {
1170 if (ugd->password_timer) {
1171 ecore_timer_del(ugd->password_timer);
1172 ugd->password_timer = NULL;
1174 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1176 Ecore_IMF_Context *imf_context = NULL;
1177 imf_context = elm_entry_imf_context_get(p->entry_password);
1178 int state = ecore_imf_context_input_panel_state_get(imf_context);
1180 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1181 debug_log("input panel show");
1182 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1187 static void _check2_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1190 struct viewdata *vd = (struct viewdata *)data;
1193 debug_log("vd is NULL");
1197 struct priv_data *p = vd->priv;
1198 EmailSettingUGD *ugd = NULL;
1201 Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1204 elm_check_state_set(p->show_passwd_check, EINA_FALSE);
1205 elm_entry_password_set(p->entry_password, EINA_TRUE);
1207 elm_check_state_set(p->show_passwd_check, EINA_TRUE);
1208 elm_entry_password_set(p->entry_password, EINA_FALSE);
1211 if (elm_object_focus_get(p->entry_password)) {
1212 if (ugd->password_timer) {
1213 ecore_timer_del(ugd->password_timer);
1214 ugd->password_timer = NULL;
1216 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1218 Ecore_IMF_Context *imf_context = NULL;
1219 imf_context = elm_entry_imf_context_get(p->entry_password);
1220 int state = ecore_imf_context_input_panel_state_get(imf_context);
1222 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1223 debug_log("input panel show");
1224 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1229 static Eina_Bool _after_validation_cb(void *data)
1233 struct viewdata *vd = (struct viewdata *)data;
1236 debug_log("vd is NULL");
1237 return ECORE_CALLBACK_CANCEL;
1240 EmailSettingUGD *ugd = NULL;
1241 struct priv_data *p = NULL;
1246 if (ugd->preset_vc_timer) {
1247 ecore_timer_del(ugd->preset_vc_timer);
1248 ugd->preset_vc_timer = NULL;
1251 if (ugd->popup_one) {
1252 evas_object_del(ugd->popup_one);
1253 ugd->popup_one = NULL;
1255 if (ugd->popup_validate) {
1256 evas_object_del(ugd->popup_validate);
1257 ugd->popup_validate = NULL;
1260 if (p->set_default_account) {
1261 if (email_engine_set_default_account(vd->ugd->account_id)) {
1262 debug_log("new default account is %d", vd->ugd->account_id);
1266 status_message_post(_("IDS_EMAIL_POP_SUCCEEDED"));
1268 setting_change_view(VIEW_SYNC_SETUP, ugd);
1270 setting_get_small_notify(vd, _("IDS_EMAIL_POP_SUCCEEDED"));
1272 /*debug_log("_after_validation_cb %s", vd->ugd->start_view_type);
1274 if (vd->ugd->start_view_type != NULL &&
1275 strcmp(vd->ugd->start_view_type, "first-setup") == 0) {
1276 ug_destroy_me(vd->ugd->ug);
1277 } else if (vd->ugd->start_view_type != NULL &&
1278 strcmp(vd->ugd->start_view_type, "account-add") == 0) {
1279 ug_destroy_me(vd->ugd->ug);
1280 } else if (vd->ugd->start_view_type != NULL &&
1281 strcmp(vd->ugd->start_view_type, "select-account") == 0) {
1282 service_h service = NULL;
1283 service_create(&service);
1285 service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT);
1286 ug_send_result(vd->ugd->ug, service);
1287 service_destroy(service);
1290 setting_update_acct_list(vd);
1291 setting_back_to_prev_nth_view(vd, 2, vd->ugd->navi_main_it);
1292 vd->ugd->atomic_pop = 0;
1295 return ECORE_CALLBACK_CANCEL;
1298 static Eina_Bool _password_state_cb(void *data)
1302 struct viewdata *vd = (struct viewdata *)data;
1305 debug_log("vd is NULL");
1306 return ECORE_CALLBACK_CANCEL;
1309 struct priv_data *p = NULL;
1311 EmailSettingUGD *ugd = NULL;
1314 if (ugd->password_timer) {
1315 ecore_timer_del(ugd->password_timer);
1316 ugd->password_timer = NULL;
1319 Ecore_IMF_Context *imf_context = NULL;
1320 imf_context = elm_entry_imf_context_get(p->entry_password);
1322 ecore_imf_context_input_panel_event_callback_del(imf_context,
1323 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1324 ecore_imf_context_input_panel_event_callback_add(imf_context,
1325 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1326 _input_panel_state_changed_cb, (void *)vd);
1329 return ECORE_CALLBACK_CANCEL;
1332 static Eina_Bool _startup_focus_cb(void *data)
1336 struct viewdata *vd = (struct viewdata *)data;
1339 debug_log("vd is NULL");
1340 return ECORE_CALLBACK_CANCEL;
1343 struct priv_data *p = NULL;
1346 EmailSettingUGD *ugd = NULL;
1349 if (ugd->focus_timer) {
1350 ecore_timer_del(ugd->focus_timer);
1351 ugd->focus_timer = NULL;
1354 if (ugd->account_info == NULL) {
1355 p->clicked_object = p->entry_account_name;
1356 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1358 p->clicked_object = p->entry_email_address;
1359 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1360 elm_entry_cursor_begin_set(p->entry_email_address);
1363 return ECORE_CALLBACK_CANCEL;
1366 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1370 debug_log("data is NULL");
1374 struct viewdata *vd = (struct viewdata *)data;
1375 EmailSettingUGD *ugd = vd->ugd;
1376 struct priv_data *p = vd->priv;
1378 if (ugd->popup_one) {
1379 evas_object_del(ugd->popup_one);
1380 ugd->popup_one = NULL;
1382 if (ugd->popup_validate) {
1383 evas_object_del(ugd->popup_validate);
1384 ugd->popup_validate = NULL;
1387 elm_object_disabled_set(p->l_button, EINA_FALSE);
1388 elm_object_disabled_set(p->r_button, EINA_FALSE);
1389 elm_object_disabled_set(p->r_button2, EINA_FALSE);
1390 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1391 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1394 static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info)
1398 debug_log("data is NULL");
1402 struct viewdata *vd = (struct viewdata *)data;
1403 EmailSettingUGD *ugd = vd->ugd;
1404 struct priv_data *p = vd->priv;
1406 if (ugd->popup_one) {
1407 evas_object_del(ugd->popup_one);
1408 ugd->popup_one = NULL;
1410 if (ugd->popup_validate) {
1411 evas_object_del(ugd->popup_validate);
1412 ugd->popup_validate = NULL;
1415 int account_id = vd->ugd->account_id;
1416 vd->ugd->cancel_event = 1;
1417 email_engine_stop_working(account_id, p->handle);
1418 email_engine_delete_account(account_id);
1420 elm_object_disabled_set(p->l_button, EINA_FALSE);
1421 elm_object_disabled_set(p->r_button, EINA_FALSE);
1422 elm_object_disabled_set(p->r_button2, EINA_FALSE);
1423 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1424 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1427 static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info)
1430 Evas_Object *eo = (Evas_Object *)obj;
1431 struct viewdata *vd = g_vd;
1435 struct priv_data *p = vd->priv;
1439 EmailSettingUGD *ugd = vd->ugd;
1443 if (elm_object_focus_get(data)) {
1444 if (elm_entry_is_empty(obj))
1445 elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1447 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1450 if (eo == p->entry_account_name) {
1451 debug_log("entry_account_name");
1452 if (p->str_account_name) {
1453 g_free(p->str_account_name);
1454 p->str_account_name = NULL;
1457 p->str_account_name = g_strdup(elm_entry_entry_get(eo));
1458 } else if (eo == p->entry_user_id) {
1459 debug_log("entry_user_id");
1460 if (p->str_user_id) {
1461 g_free(p->str_user_id);
1462 p->str_user_id = NULL;
1465 p->str_user_id = g_strdup(elm_entry_entry_get(eo));
1466 } else if (eo == p->entry_display_name) {
1467 debug_log("entry_display_name");
1468 if (p->str_display_name) {
1469 g_free(p->str_display_name);
1470 p->str_display_name = NULL;
1473 p->str_display_name = g_strdup(elm_entry_entry_get(eo));
1474 } else if (eo == p->entry_email_address) {
1475 debug_log("entry_email_address");
1476 if (p->str_email_address) {
1477 g_free(p->str_email_address);
1478 p->str_email_address = NULL;
1481 p->str_email_address = g_strdup(elm_entry_entry_get(eo));
1482 } else if (eo == p->entry_password) {
1483 debug_log("entry_password");
1484 if (p->str_password) {
1485 g_free(p->str_password);
1486 p->str_password = NULL;
1489 p->str_password = g_strdup((char *)elm_entry_markup_to_utf8(elm_entry_entry_get(eo)));
1492 if (ugd->account_info == NULL) {
1493 if (p->str_account_name == NULL) {
1494 elm_object_disabled_set(p->l_button, EINA_TRUE);
1495 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1496 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1500 if (g_strcmp0(p->str_account_name, "") == 0) {
1501 elm_object_disabled_set(p->l_button, EINA_TRUE);
1502 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1503 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1508 if (p->str_email_address == NULL || p->str_password == NULL) {
1509 elm_object_disabled_set(p->l_button, EINA_TRUE);
1510 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1511 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1515 if (g_strcmp0(p->str_email_address, "") == 0 || g_strcmp0(p->str_password, "") == 0) {
1516 elm_object_disabled_set(p->l_button, EINA_TRUE);
1517 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1518 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1520 elm_object_disabled_set(p->l_button, EINA_FALSE);
1521 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1522 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1526 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
1531 debug_log("obj is NULL");
1535 struct viewdata *vd = g_vd;
1536 struct priv_data *p = vd->priv;
1538 if (obj == p->entry_password) {
1539 Ecore_IMF_Context *imf_context = NULL;
1540 imf_context = elm_entry_imf_context_get(p->entry_password);
1542 ecore_imf_context_input_panel_event_callback_del(imf_context,
1543 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1544 ecore_imf_context_input_panel_event_callback_add(imf_context,
1545 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1546 _input_panel_state_changed_cb, (void *)vd);
1550 if (!elm_entry_is_empty(obj))
1551 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1552 elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
1555 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
1560 debug_log("obj is NULL");
1564 if (elm_entry_is_empty(obj))
1565 elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
1566 elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1569 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1574 debug_log("obj is NULL");
1578 elm_entry_entry_set(data, "");
1581 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
1586 debug_log("data is NULL");
1590 struct viewdata *vd = (struct viewdata *)data;
1591 struct priv_data *p = vd->priv;
1593 int state = ecore_imf_context_input_panel_state_get(ctx);
1595 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1596 debug_log("state:SHOW");
1597 else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1598 debug_log("state HIDE");
1600 if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1601 debug_log("value:SHOW");
1602 else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1603 debug_log("value HIDE");
1605 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
1606 debug_log("input panel show");
1607 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1608 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1609 debug_log("input panel hide");
1610 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,hidden", "");
1614 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info)
1617 int index = (int)data;
1618 struct viewdata *vd = g_vd;
1619 struct priv_data *p = vd->priv;
1621 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1622 elm_genlist_item_selected_set(item, EINA_FALSE);
1625 p->clicked_object = p->entry_account_name;
1626 } else if (index == 2) {
1627 p->clicked_object = p->entry_user_id;
1628 } else if (index == 3) {
1629 p->clicked_object = p->entry_display_name;
1630 } else if (index == 4) {
1631 p->clicked_object = p->entry_email_address;
1632 } else if (index == 5) {
1633 p->clicked_object = p->entry_password;
1637 static char *_gl_group_text_get(void *data, Evas_Object *obj, const char *part)
1641 struct viewdata *vd = g_vd;
1643 if (!strcmp(part, "elm.text")) {
1644 char title_str[MAX_STR_LEN] = { 0, };
1645 if (vd->ugd->account_info) {
1646 if (g_str_has_prefix(vd->ugd->account_info->name_str_id, "IDS_EMAIL"))
1647 snprintf(title_str, sizeof(title_str), "%s", _(vd->ugd->account_info->name_str_id));
1649 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", vd->ugd->account_info->name_str_id));
1651 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_OTHERS"));
1654 return g_strdup(title_str);
1660 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part)
1663 int index = (int)data;
1664 struct viewdata *vd = g_vd;
1665 struct priv_data *p = vd->priv;
1666 EmailSettingUGD *ugd = vd->ugd;
1667 Ecore_IMF_Context *imf_context = NULL;
1669 if (!strcmp(part, "elm.icon")) {
1674 p->ef_account_name = elm_layout_add(p->genlist);
1675 elm_layout_theme_set(p->ef_account_name, "layout", "editfield", "title");
1676 p->entry_account_name = elm_entry_add(p->genlist);
1677 elm_entry_scrollable_set(p->entry_account_name, EINA_TRUE);
1678 elm_entry_single_line_set(p->entry_account_name, EINA_TRUE);
1679 elm_entry_input_panel_return_key_disabled_set(p->entry_account_name, EINA_TRUE);
1680 elm_entry_cnp_mode_set(p->entry_account_name, ELM_CNP_MODE_PLAINTEXT);
1681 elm_entry_input_panel_layout_set(p->entry_account_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1682 elm_entry_editable_set(p->entry_account_name, TRUE);
1683 evas_object_smart_callback_add(p->entry_account_name, "changed", _backup_input_cb, p->ef_account_name);
1684 evas_object_smart_callback_add(p->entry_account_name, "focused", _entry_focused_cb, p->ef_account_name);
1685 evas_object_smart_callback_add(p->entry_account_name, "unfocused", _entry_unfocused_cb, p->ef_account_name);
1686 evas_object_show(p->entry_account_name);
1688 imf_context = elm_entry_imf_context_get(p->entry_account_name);
1690 ecore_imf_context_input_panel_event_callback_add(imf_context,
1691 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1692 _input_panel_state_changed_cb, (void *)vd);
1694 elm_object_part_content_set(p->ef_account_name, "elm.swallow.content", p->entry_account_name);
1695 /*elm_object_part_text_set(p->ef_account_name, "elm.guidetext", str);*/
1696 elm_object_part_text_set(p->ef_account_name, "elm.text", _("IDS_EMAIL_BODY_ACCOUNT_NAME"));
1697 elm_object_signal_callback_add(p->ef_account_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_account_name);
1699 evas_object_size_hint_weight_set(p->ef_account_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1700 evas_object_show(p->ef_account_name);
1702 if (p->str_account_name)
1703 elm_entry_entry_set(p->entry_account_name, p->str_account_name);
1705 if (ugd->account_info == NULL && p->icon_get_cnt1 == 2 &&
1706 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1707 p->clicked_object = p->entry_account_name;
1708 evas_object_show(p->entry_account_name);
1709 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1712 if (ugd->account_info == NULL && p->icon_get_cnt1 == 3 &&
1713 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1714 p->clicked_object = p->entry_account_name;
1715 evas_object_show(p->entry_account_name);
1716 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1719 return p->ef_account_name;
1720 } else if (index == 2) {
1722 p->ef_user_id = elm_layout_add(p->genlist);
1723 elm_layout_theme_set(p->ef_user_id, "layout", "editfield", "title");
1724 p->entry_user_id = elm_entry_add(p->genlist);
1725 elm_entry_scrollable_set(p->entry_user_id, EINA_TRUE);
1726 elm_entry_single_line_set(p->entry_user_id, EINA_TRUE);
1727 elm_entry_input_panel_return_key_disabled_set(p->entry_user_id, EINA_TRUE);
1728 elm_entry_cnp_mode_set(p->entry_user_id, ELM_CNP_MODE_PLAINTEXT);
1729 elm_entry_input_panel_layout_set(p->entry_user_id, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1730 elm_entry_editable_set(p->entry_user_id, TRUE);
1731 evas_object_smart_callback_add(p->entry_user_id, "changed", _backup_input_cb, p->ef_user_id);
1732 evas_object_smart_callback_add(p->entry_user_id, "focused", _entry_focused_cb, p->ef_user_id);
1733 evas_object_smart_callback_add(p->entry_user_id, "unfocused", _entry_unfocused_cb, p->ef_user_id);
1734 evas_object_show(p->entry_user_id);
1736 imf_context = elm_entry_imf_context_get(p->entry_user_id);
1738 ecore_imf_context_input_panel_event_callback_add(imf_context,
1739 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1740 _input_panel_state_changed_cb, (void *)vd);
1742 elm_object_part_content_set(p->ef_user_id, "elm.swallow.content", p->entry_user_id);
1743 /*elm_object_part_text_set(p->ef_user_id, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));*/
1744 elm_object_part_text_set(p->ef_user_id, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));
1745 elm_object_signal_callback_add(p->ef_user_id, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_user_id);
1747 evas_object_size_hint_weight_set(p->ef_user_id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1748 evas_object_show(p->ef_user_id);
1751 elm_entry_entry_set(p->entry_user_id, p->str_user_id);
1753 return p->ef_user_id;
1754 } else if (index == 3) {
1756 p->ef_display_name = elm_layout_add(p->genlist);
1757 elm_layout_theme_set(p->ef_display_name, "layout", "editfield", "title");
1758 p->entry_display_name = elm_entry_add(p->genlist);
1759 elm_entry_scrollable_set(p->entry_display_name, EINA_TRUE);
1760 elm_entry_single_line_set(p->entry_display_name, EINA_TRUE);
1761 elm_entry_input_panel_return_key_disabled_set(p->entry_display_name, EINA_TRUE);
1762 elm_entry_cnp_mode_set(p->entry_display_name, ELM_CNP_MODE_PLAINTEXT);
1763 elm_entry_input_panel_layout_set(p->entry_display_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1764 elm_entry_editable_set(p->entry_display_name, TRUE);
1765 evas_object_smart_callback_add(p->entry_display_name, "changed", _backup_input_cb, p->ef_display_name);
1766 evas_object_smart_callback_add(p->entry_display_name, "focused", _entry_focused_cb, p->ef_display_name);
1767 evas_object_smart_callback_add(p->entry_display_name, "unfocused", _entry_unfocused_cb, p->ef_display_name);
1768 evas_object_show(p->entry_display_name);
1770 imf_context = elm_entry_imf_context_get(p->entry_display_name);
1772 ecore_imf_context_input_panel_event_callback_add(imf_context,
1773 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1774 _input_panel_state_changed_cb, (void *)vd);
1776 elm_object_part_content_set(p->ef_display_name, "elm.swallow.content", p->entry_display_name);
1777 /*elm_object_part_text_set(p->ef_display_name, "elm.guidetext", _("IDS_EMAIL_BODY_YOUR_NAME"));*/
1778 elm_object_part_text_set(p->ef_display_name, "elm.text", dgettext("sys_string", "IDS_COM_BODY_DETAILS_NAME"));
1779 elm_object_signal_callback_add(p->ef_display_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_display_name);
1781 evas_object_size_hint_weight_set(p->ef_display_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1782 evas_object_show(p->ef_display_name);
1784 if (p->str_display_name)
1785 elm_entry_entry_set(p->entry_display_name, p->str_display_name);
1787 return p->ef_display_name;
1788 } else if (index == 4) {
1792 p->ef_email_address = elm_layout_add(p->genlist);
1793 elm_layout_theme_set(p->ef_email_address, "layout", "editfield", "title");
1794 p->entry_email_address = elm_entry_add(p->genlist);
1795 elm_entry_scrollable_set(p->entry_email_address, EINA_TRUE);
1796 elm_entry_single_line_set(p->entry_email_address, EINA_TRUE);
1797 elm_entry_input_panel_return_key_disabled_set(p->entry_email_address, EINA_TRUE);
1798 elm_entry_cnp_mode_set(p->entry_email_address, ELM_CNP_MODE_PLAINTEXT);
1799 elm_entry_input_panel_layout_set(p->entry_email_address, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1800 elm_entry_editable_set(p->entry_email_address, TRUE);
1801 evas_object_smart_callback_add(p->entry_email_address, "changed", _backup_input_cb, p->ef_email_address);
1802 evas_object_smart_callback_add(p->entry_email_address, "focused", _entry_focused_cb, p->ef_email_address);
1803 evas_object_smart_callback_add(p->entry_email_address, "unfocused", _entry_unfocused_cb, p->ef_email_address);
1804 evas_object_show(p->entry_email_address);
1806 imf_context = elm_entry_imf_context_get(p->entry_email_address);
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_email_address, "elm.swallow.content", p->entry_email_address);
1813 /*_set_help_string(p->ef_email_address, vd);*/
1814 elm_object_part_text_set(p->ef_email_address, "elm.text", dgettext("sys_string", "IDS_COM_BODY_EMAIL_ADDRESS"));
1815 elm_object_signal_callback_add(p->ef_email_address, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_email_address);
1817 evas_object_size_hint_weight_set(p->ef_email_address, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1818 evas_object_show(p->ef_email_address);
1820 if (p->str_email_address)
1821 elm_entry_entry_set(p->entry_email_address, p->str_email_address);
1823 if (ugd->account_info != NULL && p->icon_get_cnt2 == 2 &&
1824 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1825 p->clicked_object = p->entry_email_address;
1826 evas_object_show(p->entry_email_address);
1827 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1828 elm_entry_cursor_begin_set(p->entry_email_address);
1831 if (ugd->account_info != NULL && p->icon_get_cnt2 == 3 &&
1832 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1833 p->clicked_object = p->entry_email_address;
1834 evas_object_show(p->entry_email_address);
1835 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1836 elm_entry_cursor_begin_set(p->entry_email_address);
1839 return p->ef_email_address;
1840 } else if (index == 5) {
1842 p->ef_password = elm_layout_add(p->genlist);
1843 elm_layout_theme_set(p->ef_password, "layout", "editfield", "title");
1844 p->entry_password = elm_entry_add(p->genlist);
1845 elm_entry_scrollable_set(p->entry_password, EINA_TRUE);
1846 elm_entry_single_line_set(p->entry_password, EINA_TRUE);
1847 elm_entry_input_panel_return_key_disabled_set(p->entry_password, EINA_TRUE);
1848 elm_entry_cnp_mode_set(p->entry_password, ELM_CNP_MODE_PLAINTEXT);
1849 elm_entry_input_panel_layout_set(p->entry_password, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1850 elm_entry_editable_set(p->entry_password, EINA_TRUE);
1851 elm_entry_password_set(p->entry_password, EINA_TRUE);
1853 evas_object_smart_callback_add(p->entry_password, "changed", _backup_input_cb, p->ef_password);
1854 evas_object_smart_callback_add(p->entry_password, "focused", _entry_focused_cb, p->ef_password);
1855 evas_object_smart_callback_add(p->entry_password, "unfocused", _entry_unfocused_cb, p->ef_password);
1856 //evas_object_smart_callback_add(p->entry_password, "theme,changed", _entry_theme_changed_cb, (void *)vd);
1857 evas_object_show(p->entry_password);
1859 imf_context = elm_entry_imf_context_get(p->entry_password);
1861 ecore_imf_context_input_panel_event_callback_add(imf_context,
1862 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1863 _input_panel_state_changed_cb, (void *)vd);
1865 elm_object_part_content_set(p->ef_password, "elm.swallow.content", p->entry_password);
1866 /*elm_object_part_text_set(p->ef_password, "elm.guidetext", _("IDS_EMAIL_BODY_USER_PASSWORD"));*/
1867 elm_object_part_text_set(p->ef_password, "elm.text", dgettext("sys_string", "IDS_COM_BODY_PASSWORD"));
1868 elm_object_signal_callback_add(p->ef_password, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_password);
1870 evas_object_size_hint_weight_set(p->ef_password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1871 evas_object_show(p->ef_password);
1873 if (p->str_password)
1874 elm_entry_entry_set(p->entry_password, p->str_password);
1876 Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1879 elm_entry_password_set(p->entry_password, EINA_FALSE);
1881 elm_entry_password_set(p->entry_password, EINA_TRUE);
1883 return p->ef_password;