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 _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 char *_gl_group_text_get(void *data, Evas_Object *obj, const char *part);
63 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part);
64 static void _gl_realized_cb(void *data, Evas_Object *obj, void *event_info);
66 static struct viewdata *g_vd = NULL;
72 char *str_account_name;
73 char *str_display_name;
74 char *str_email_address;
78 Evas_Object *entry_account_name;
79 Evas_Object *entry_display_name;
80 Evas_Object *entry_email_address;
81 Evas_Object *entry_user_id;
82 Evas_Object *entry_password;
84 Evas_Object *ef_account_name;
85 Evas_Object *ef_display_name;
86 Evas_Object *ef_email_address;
87 Evas_Object *ef_user_id;
88 Evas_Object *ef_password;
91 Evas_Object *scroller;
93 Evas_Object *l_button;
94 Evas_Object *r_button;
95 Evas_Object *r_button2;
96 Evas_Object *tool_btn;
97 Evas_Object *manual_btn;
99 Evas_Object *show_passwd_check;
100 Evas_Object *default_account_check;
102 Evas_Object *clicked_object;
104 Evas_Object *genlist;
105 Elm_Genlist_Item_Class itc1;
106 Elm_Genlist_Item_Class itc2;
107 Elm_Genlist_Item_Class itc3;
110 Elm_Object_Item *gl_email_address_item;
111 Elm_Object_Item *gl_pw_item;
112 Elm_Object_Item * c_item[4];
113 Elm_Object_Item *navi_it;
117 int set_default_account;
120 void setting_init_account_setup_view(struct viewdata *vd)
123 vd->type = VIEW_ACCOUNT_SETUP;
124 vd->create = _create;
125 vd->update = _update;
126 vd->destroy = _destroy;
129 vd->grp_nm = "setting_account_setup";
132 void setting_account_validation_success_cb(EmailSettingUGD *ugd)
137 top = ugd->view_st[ugd->view_top];
141 debug_log("vd is NULL");
147 if (ugd->popup_one) {
148 evas_object_del(ugd->popup_one);
149 ugd->popup_one = NULL;
151 if (ugd->popup_validate) {
152 evas_object_del(ugd->popup_validate);
153 ugd->popup_validate = NULL;
156 ugd->preset_vc_timer = ecore_timer_add(0.5, _after_validation_cb, vd);
159 void setting_account_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled)
165 top = ugd->view_st[ugd->view_top];
169 debug_log("vd is NULL");
173 account_id = ugd->account_id;
175 if (ugd->popup_one) {
176 evas_object_del(ugd->popup_one);
177 ugd->popup_one = NULL;
179 /*if (ugd->popup_validate) {
180 evas_object_del(ugd->popup_validate);
181 ugd->popup_validate = NULL;
184 if (canceled || ugd->err_code == EMAIL_ERROR_CANCELLED) {
185 ugd->popup_one = setting_get_notify(vd,
186 dgettext("sys_string", "IDS_COM_POP_WARNING"),
187 _("IDS_EMAIL_POP_ACCOUNT_CREATION_CANCELLED"),
188 1, dgettext("sys_string", "IDS_COM_SK_OK"),
189 _popup_ok_cb, NULL, NULL);
191 char *type = setting_get_service_fail_type(ugd->err_code);
192 ugd->popup_one = setting_get_notify(vd,
193 dgettext("sys_string", "IDS_COM_POP_WARNING"),
194 type, 1, dgettext("sys_string", "IDS_COM_SK_OK"),
195 _popup_ok_cb, NULL, NULL);
200 static int _create(struct viewdata *vd)
205 debug_log("vd is NULL");
210 EmailSettingUGD *ugd = vd->ugd;
214 p = vd->priv = calloc(1, sizeof(struct priv_data));
217 p->layout = setting_add_inner_layout(vd);
221 p->scroller = elm_scroller_add(ugd->navi_bar);
222 evas_object_propagate_events_set(p->scroller, EINA_FALSE);
223 elm_scroller_bounce_set(p->scroller, EINA_FALSE, EINA_FALSE);
224 elm_scroller_policy_set(p->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
225 evas_object_show(p->scroller);
227 elm_object_part_content_set(p->layout, "elm.swallow.content", p->scroller);
231 ugd->wds_account_creation = 0;
233 if (vd->ugd->account_info != NULL) {
234 _set_domain_string(vd);
237 ugd->focus_timer = ecore_timer_add(0.5, _startup_focus_cb, (void *)vd);
245 static int _update(struct viewdata *vd)
252 static int _destroy(struct viewdata *vd)
255 struct priv_data *p = vd->priv;
256 EmailSettingUGD *ugd = vd->ugd;
258 Ecore_IMF_Context *imf_context = NULL;
259 imf_context = elm_entry_imf_context_get(p->clicked_object);
261 ecore_imf_context_input_panel_hide(imf_context);
262 ecore_imf_context_input_panel_event_callback_del(imf_context,
263 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
266 evas_object_del(p->l_button);
267 evas_object_del(p->r_button);
268 evas_object_del(p->genlist);
269 evas_object_del(p->tool_btn);
271 if (p->str_password) {
272 g_free(p->str_password);
273 p->str_password = NULL;
276 if (ugd->password_timer) {
277 ecore_timer_del(ugd->password_timer);
278 ugd->password_timer = NULL;
281 if (ugd->focus_timer) {
282 ecore_timer_del(ugd->focus_timer);
283 ugd->focus_timer = NULL;
286 if (ugd->preset_vc_timer) {
287 ecore_timer_del(ugd->preset_vc_timer);
288 ugd->preset_vc_timer = NULL;
291 if (ugd->popup_one) {
292 evas_object_del(ugd->popup_one);
293 ugd->popup_one = NULL;
295 if (ugd->popup_validate) {
296 evas_object_del(ugd->popup_validate);
297 ugd->popup_validate = NULL;
300 ugd->account_info = NULL;
302 setting_new_acct_final(vd);
306 static int _show(struct viewdata *vd)
311 debug_log("vd is NULL");
315 evas_object_show(vd->ly);
320 static int _hide(struct viewdata *vd)
325 debug_log("vd is NULL");
329 evas_object_hide(vd->ly);
334 static void _push_naviframe(struct viewdata *vd)
337 struct priv_data *p = vd->priv;
339 p->l_button = elm_button_add(vd->ugd->navi_bar);
340 elm_object_style_set(p->l_button, "naviframe/toolbar/default");
341 elm_object_focus_allow_set(p->l_button, EINA_FALSE);
342 evas_object_show(p->l_button);
344 if (vd->ugd->account_info == NULL) {
345 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
346 evas_object_smart_callback_add(p->l_button, "clicked", _next_cb, vd);
348 elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
349 evas_object_smart_callback_add(p->l_button, "clicked", _save_cb, vd);
352 elm_object_disabled_set(p->l_button, EINA_TRUE);
354 p->r_button = elm_button_add(vd->ugd->navi_bar);
355 elm_object_style_set(p->r_button, "naviframe/end_btn/default");
356 /*elm_object_text_set(p->r_button, dgettext("sys_string", "IDS_COM_SK_CANCEL"));*/
357 evas_object_smart_callback_add(p->r_button, "clicked", _back_cb, vd);
358 evas_object_show(p->r_button);
360 p->r_button2 = elm_button_add(vd->ugd->navi_bar);
361 elm_object_style_set(p->r_button2, "naviframe/end_btn/default");
362 evas_object_smart_callback_add(p->r_button2, "clicked", _back_cb, vd);
363 evas_object_show(p->r_button2);
365 p->tool_btn = elm_button_add(vd->ugd->navi_bar);
366 elm_object_style_set(p->tool_btn, "naviframe/toolbar/default");
367 elm_object_text_set(p->tool_btn, dgettext("sys_string", "IDS_COM_BUTTON_LOGIN"));
368 if (vd->ugd->account_info == NULL) {
369 evas_object_smart_callback_add(p->tool_btn, "clicked", _next_cb, vd);
371 evas_object_smart_callback_add(p->tool_btn, "clicked", _save_cb, vd);
374 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
376 Elm_Object_Item *navi_it = NULL;
377 navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, _("IDS_EMAIL_HEADER_ADD_ACCOUNT"), NULL, NULL, p->layout, NULL);
378 elm_object_item_part_content_set(navi_it, "title_toolbar_button1", p->l_button);
379 elm_object_item_part_content_set(navi_it, "title_prev_btn", p->r_button);
380 elm_object_item_part_content_set(navi_it, "toolbar_button1", p->tool_btn);
381 elm_object_item_part_content_set(navi_it, "prev_btn", p->r_button2);
382 p->navi_it = navi_it;
383 evas_object_show(vd->ugd->navi_bar);
386 static void _create_view(struct viewdata *vd)
390 EmailSettingUGD *ugd;
393 debug_log("vd is null!");
401 ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h);
402 debug_log("WINDOW W[%d] H[%d]", w, h);
404 Evas_Object *sub_ly = elm_layout_add(ugd->navi_bar);
405 elm_layout_file_set(sub_ly, EV_THEME_PATH, "add_account");
407 evas_object_size_hint_weight_set(sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
408 evas_object_show(sub_ly);
411 elm_object_part_content_set(sub_ly, "add_account/layout", p->genlist);
413 Evas_Object *check1 = elm_check_add(sub_ly);
414 elm_check_state_set(check1, EINA_FALSE);
415 evas_object_smart_callback_add(check1, "changed", _check1_clicked_cb, (void *)vd);
416 elm_object_part_content_set(sub_ly, "add_account/check1", check1);
417 elm_object_focus_allow_set(check1, EINA_FALSE);
418 p->default_account_check = check1;
420 Evas_Object *check2 = elm_check_add(sub_ly);
421 elm_check_state_set(check2, EINA_FALSE);
422 evas_object_smart_callback_add(check2, "changed", _check2_clicked_cb, (void *)vd);
423 elm_object_part_content_set(sub_ly, "add_account/check2", check2);
424 elm_object_focus_allow_set(check2, EINA_FALSE);
425 p->show_passwd_check = check2;
427 char *desc = g_strdup(_("IDS_EMAIL_BODY_SEND_EMAIL_FROM_THIS_ACCOUNT_BY_DEFAULT"));
428 Evas_Object *label1 = elm_label_add(sub_ly);
429 elm_label_wrap_width_set(label1, 600*elm_config_scale_get());
430 elm_label_line_wrap_set(label1, ELM_WRAP_WORD);
431 char *text = g_strconcat("<font_size=30><color=#7C7C7CFF><align=left>",
432 desc, "</align></color></font_size>", NULL);
433 edje_object_signal_callback_add(elm_layout_edje_get(sub_ly),
434 "elm,action,text1_clicked", "elm", _check1_clicked_cb2, (void *)vd);
435 elm_object_text_set(label1, text);
436 evas_object_show(label1);
439 elm_object_part_content_set(sub_ly, "add_account/text1", label1);
441 desc = g_strdup(_("IDS_EMAIL_BODY_SHOW_PASSWORD"));
442 Evas_Object *label2 = elm_label_add(sub_ly);
443 elm_label_wrap_width_set(label2, 600*elm_config_scale_get());
444 elm_label_line_wrap_set(label2, ELM_WRAP_WORD);
445 text = g_strconcat("<font_size=30><color=#7C7C7CFF><align=left>",
446 desc, "</align></color></font_size>", NULL);
447 edje_object_signal_callback_add(elm_layout_edje_get(sub_ly),
448 "elm,action,text2_clicked", "elm", _check2_clicked_cb2, (void *)vd);
449 elm_object_text_set(label2, text);
450 evas_object_show(label2);
453 elm_object_part_content_set(sub_ly, "add_account/text2", label2);
455 Evas_Object *btn = elm_button_add(sub_ly);
456 elm_object_text_set(btn, _("IDS_EMAIL_BODY_MANUAL_SETUP"));
457 evas_object_smart_callback_add(btn, "clicked", _manual_cb, (void *)vd);
458 elm_object_style_set(btn, "text_only/style2");
459 evas_object_show(btn);
461 elm_object_part_content_set(sub_ly, "add_account/button", btn);
462 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
464 elm_object_content_set(p->scroller, sub_ly);
465 elm_scroller_policy_set(p->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
468 static void _create_list(struct viewdata *vd)
473 debug_critical("vd is null!");
478 EmailSettingUGD *ugd;
484 Elm_Object_Item *item = NULL;
485 Elm_Object_Item *git = NULL;
487 p->genlist = elm_genlist_add(ugd->navi_bar);
488 elm_object_style_set(p->genlist, "dialogue");
489 evas_object_show(p->genlist);
491 p->itc1.item_style = "dialogue/separator";
492 p->itc1.func.text_get = NULL;
493 p->itc1.func.content_get = NULL;
494 p->itc1.func.state_get = NULL;
495 p->itc1.func.del = NULL;
497 p->itc2.item_style = "dialogue/1icon";
498 p->itc2.func.text_get = NULL;
499 p->itc2.func.content_get = _gl_ef_content_get_cb;
500 p->itc2.func.state_get = NULL;
501 p->itc2.func.del = NULL;
503 p->itc3.item_style = "dialogue/grouptitle";
504 p->itc3.func.text_get = _gl_group_text_get;
505 p->itc3.func.content_get = NULL;
506 p->itc3.func.state_get = NULL;
507 p->itc3.func.del = NULL;
509 git = elm_genlist_item_append(p->genlist, &(p->itc3), NULL, NULL,
510 ELM_GENLIST_ITEM_NONE, NULL, NULL);
511 elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
513 if (ugd->account_info == NULL) {
514 /* Account name for OTHER */
516 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
517 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
518 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_NONE); */
522 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
523 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
528 item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git,
529 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/
533 p->gl_email_address_item = item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL,
534 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
535 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
539 p->gl_pw_item = item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL,
540 ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);
541 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
543 evas_object_smart_callback_add(p->genlist, "realized", _gl_realized_cb, (void *)vd);
546 static void _create_validation_popup(struct viewdata *vd, int account_id)
551 debug_critical("vd is null!");
555 email_account_t *account = vd->ugd->new_account;
557 debug_log("account id:%d", account_id);
558 debug_log("account name:%s", account->account_name);
559 debug_log("email address:%s", account->user_email_address);
561 vd->ugd->account_id = account_id;
563 EmailSettingUGD *ugd = vd->ugd;
564 struct priv_data *p = vd->priv;
566 if (ugd->popup_one) {
567 evas_object_del(ugd->popup_one);
568 ugd->popup_one = NULL;
570 if (ugd->popup_validate) {
571 evas_object_del(ugd->popup_validate);
572 ugd->popup_validate = NULL;
575 vd->ugd->cancel_event = 0;
576 elm_object_disabled_set(p->l_button, EINA_TRUE);
577 elm_object_disabled_set(p->r_button, EINA_TRUE);
578 elm_object_disabled_set(p->r_button2, EINA_TRUE);
579 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
580 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
582 debug_log("Start Account Validation");
583 ugd->popup_validate = setting_get_pb_process_notify(vd,
584 _("IDS_EMAIL_POP_VALIDATING_ACCOUNT_ING"), 1,
585 dgettext("sys_string", "IDS_COM_SK_CANCEL"),
586 _popup_cancel_validation_cb, NULL, NULL);
589 static void _create_account(void *data)
593 struct viewdata *vd = (struct viewdata *)data;
596 debug_critical("vd is null!");
600 EmailSettingUGD *ugd = vd->ugd;
602 struct priv_data *p = vd->priv;
605 if (email_engine_add_account_with_validation(vd->ugd->new_account,
606 &account_id, &(p->handle), &error_code)) {
607 debug_log("Account added to Email Service DB");
608 vd->ugd->start_account_validation = 1;
609 ugd->handle = p->handle;
610 _create_validation_popup(vd, account_id);
612 debug_log("Fail to make account");
614 if (ugd->popup_one) {
615 evas_object_del(ugd->popup_one);
616 ugd->popup_one = NULL;
618 if (ugd->popup_validate) {
619 evas_object_del(ugd->popup_validate);
620 ugd->popup_validate = NULL;
623 if (error_code == EMAIL_ERROR_ALREADY_EXISTS)
624 ugd->popup_one = setting_get_notify(vd,
625 dgettext("sys_string", "IDS_COM_POP_WARNING"),
626 dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 1,
627 dgettext("sys_string", "IDS_COM_SK_OK"),
628 _popup_ok_cb, NULL, NULL);
630 ugd->popup_one = setting_get_notify(vd,
631 dgettext("sys_string", "IDS_COM_POP_WARNING"),
632 _("IDS_EMAIL_POP_UNABLE_TO_ADD_ACCOUNT"), 1,
633 dgettext("sys_string", "IDS_COM_SK_OK"),
634 _popup_ok_cb, NULL, NULL);
639 static int _check_null_field(struct viewdata *vd)
643 if (vd->ugd->new_account == NULL) {
644 debug_log("new_account is NULL");
648 email_account_t *account = vd->ugd->new_account;
650 if (account->account_name == NULL || strlen(account->account_name) == 0 ||
651 /*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
652 account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
653 /*account->incoming_server_user_name == NULL || strlen(account->incoming_server_user_name) == 0 ||*/
654 account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
660 static int _check_preset_null_field(struct viewdata *vd)
664 if (vd->ugd->new_account == NULL) {
665 debug_log("new_account is NULL");
669 email_account_t *account = vd->ugd->new_account;
671 if (/*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/
672 account->user_email_address == NULL || strlen(account->user_email_address) == 0 ||
673 account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0)
679 static int _check_preset_isp_name(char *addr, EmailSpDesc *desc)
684 if (g_strcmp0(desc->id, "Hotmail") == 0) {
687 ptr1 = g_strrstr(addr, "@hotmail.");
688 ptr2 = g_strrstr(addr, "@live.");
690 if (ptr1 != NULL || ptr2 != NULL)
692 } /*else if (g_strcmp0(desc->id, "Gmail") == 0) {
693 ret = g_str_has_suffix(addr, "@gmail.com") ||
694 g_str_has_suffix(addr, "@googlemail.com");
695 }*/ else if (g_strcmp0(desc->id, "AOL") == 0) {
698 ptr1 = g_strrstr(addr, "@aol.");
699 ptr2 = g_strrstr(addr, "@aim.");
701 if (ptr1 != NULL || ptr2 != NULL)
710 static void _read_all_entries(struct viewdata *vd)
719 debug_log("priv is NULL");
723 if (vd->ugd->new_account)
724 setting_new_acct_final(vd);
726 setting_new_acct_init(vd);
727 email_account_t *account = vd->ugd->new_account;
729 /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_email_address));*/
730 if (p->entry_email_address) {
731 /*buf = (char *)elm_entry_entry_get(p->entry_email_address);
732 debug_log("email addr : %s", buf);
734 account->user_email_address = g_strdup(buf);*/
735 account->user_email_address = g_strdup(p->str_email_address);
738 if (vd->ugd->account_info == NULL) {
739 if (p->entry_email_address) {
740 gchar **token1 = NULL;
741 gchar **token2 = NULL;
743 token1 = g_strsplit(p->str_email_address, "@", -1);
745 token2 = g_strsplit(token1[1], ".", -1);
748 account->account_name = g_strdup(token2[0] ? token2[0] : "Other");
754 account->account_name = g_strdup("Other");
757 if (p->entry_password) {
758 /*buf = (char *)elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_password));
759 debug_log("password : %s", buf);
761 account->incoming_server_password = g_strdup(buf);
765 account->incoming_server_password = g_strdup(p->str_password);
769 static void _set_domain_string(struct viewdata *vd)
772 EmailSettingUGD *ugd = vd->ugd;
776 if (g_strcmp0(ugd->account_info->id, "Hotmail") == 0) {
777 p->str_email_address = g_strdup("@hotmail.com");
778 } else if (g_strcmp0(ugd->account_info->id, "Yahoomail") == 0) {
779 p->str_email_address = g_strdup("@yahoo.com");
780 } else if (g_strcmp0(ugd->account_info->id, "Gmail") == 0) {
781 p->str_email_address = g_strdup("@gmail.com");
782 } else if (g_strcmp0(ugd->account_info->id, "AOL") == 0) {
783 p->str_email_address = g_strdup("@aol.com");
785 debug_log("Unknown account type");
789 static void _next_cb(void *data, Evas_Object *obj, void *event_info)
793 struct viewdata *vd = (struct viewdata *)data;
796 debug_log("vd is NULL");
800 struct priv_data *p = NULL;
801 EmailSettingUGD *ugd = NULL;
808 Ecore_IMF_Context *imf_context = NULL;
809 imf_context = elm_entry_imf_context_get(p->clicked_object);
811 ecore_imf_context_input_panel_hide(imf_context);
814 /* Save the Account Data */
815 _read_all_entries(vd);
816 email_account_t *account = vd->ugd->new_account;
818 debug_log("accountStructure Info");
819 debug_log("Account Name:%s", account->account_name);
820 debug_log("Display Name:%s", account->user_display_name);
821 debug_log("Email Addr:%s", account->user_email_address);
822 debug_log("User Name:%s", account->incoming_server_user_name);
823 debug_log("User Password:%s", account->incoming_server_password);
825 if (ugd->popup_one) {
826 evas_object_del(ugd->popup_one);
827 ugd->popup_one = NULL;
829 if (ugd->popup_validate) {
830 evas_object_del(ugd->popup_validate);
831 ugd->popup_validate = NULL;
834 /* check Null field */
835 ret = _check_null_field(vd);
837 ugd->popup_one = setting_get_notify(vd,
838 dgettext("sys_string", "IDS_COM_POP_WARNING"),
839 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
840 dgettext("sys_string", "IDS_COM_SK_OK"),
841 _popup_ok_cb, NULL, NULL);
845 /* check character validation */
846 buf = g_strdup(account->user_email_address);
848 ret = email_get_address_validation(buf);
850 ugd->popup_one = setting_get_notify(vd,
851 dgettext("sys_string", "IDS_COM_POP_WARNING"),
852 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
853 dgettext("sys_string", "IDS_COM_SK_OK"),
854 _popup_ok_cb, NULL, NULL);
861 setting_change_view(VIEW_MANUAL_SETUP, ugd);
866 static void _save_cb(void *data, Evas_Object *obj, void *event_info)
869 struct viewdata *vd = (struct viewdata *)data;
872 debug_log("vd is NULL");
876 struct priv_data *p = NULL;
877 EmailSettingUGD *ugd = NULL;
884 Ecore_IMF_Context *imf_context = NULL;
885 imf_context = elm_entry_imf_context_get(p->clicked_object);
887 ecore_imf_context_input_panel_hide(imf_context);
891 _read_all_entries(vd);
892 email_account_t *account = vd->ugd->new_account;
894 debug_log("accountStructure Info");
895 debug_log("Display Name:%s", account->user_display_name);
896 debug_log("Email Addr:%s", account->user_email_address);
897 debug_log("User Password:%s", account->incoming_server_password);
899 if (ugd->popup_one) {
900 evas_object_del(ugd->popup_one);
901 ugd->popup_one = NULL;
903 if (ugd->popup_validate) {
904 evas_object_del(ugd->popup_validate);
905 ugd->popup_validate = NULL;
908 /* check Null field */
909 ret = _check_preset_null_field(vd);
911 debug_log("empty space in account info");
912 ugd->popup_one = setting_get_notify(vd,
913 dgettext("sys_string", "IDS_COM_POP_WARNING"),
914 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"),
915 1, dgettext("sys_string", "IDS_COM_SK_OK"),
916 _popup_ok_cb, NULL, NULL);
921 buf = g_strdup(account->user_email_address);
922 ret = _check_preset_isp_name(buf, ugd->account_info);
924 debug_log("wrong ISP server name for preset accounts");
925 ugd->popup_one = setting_get_notify(vd,
926 dgettext("sys_string", "IDS_COM_POP_WARNING"),
927 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
928 1, dgettext("sys_string", "IDS_COM_SK_OK"),
929 _popup_ok_cb, NULL, NULL);
935 /* check character validation */
936 buf = g_strdup(account->user_email_address);
938 ret = email_get_address_validation(buf);
940 debug_log("Wrong character in email address");
941 ugd->popup_one = setting_get_notify(vd,
942 dgettext("sys_string", "IDS_COM_POP_WARNING"),
943 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
944 1, dgettext("sys_string", "IDS_COM_SK_OK"),
945 _popup_ok_cb, NULL, NULL);
951 /* account info setting */
952 setting_set_account(vd);
957 static void _manual_cb(void *data, Evas_Object *obj, void *event_info)
961 struct viewdata *vd = (struct viewdata *)data;
964 debug_log("vd is NULL");
968 EmailSettingUGD *ugd = NULL;
974 /* Save the Account Data */
975 _read_all_entries(vd);
976 email_account_t *account = vd->ugd->new_account;
978 debug_log("accountStructure Info");
979 debug_log("Account Name:%s", account->account_name);
980 debug_log("Display Name:%s", account->user_display_name);
981 debug_log("Email Addr:%s", account->user_email_address);
982 debug_log("User Name:%s", account->incoming_server_user_name);
983 debug_log("User Password:%s", account->incoming_server_password);
985 if (ugd->popup_one) {
986 evas_object_del(ugd->popup_one);
987 ugd->popup_one = NULL;
989 if (ugd->popup_validate) {
990 evas_object_del(ugd->popup_validate);
991 ugd->popup_validate = NULL;
994 /* check Null field */
995 ret = _check_preset_null_field(vd);
997 ugd->popup_one = setting_get_notify(vd,
998 dgettext("sys_string", "IDS_COM_POP_WARNING"),
999 _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1,
1000 dgettext("sys_string", "IDS_COM_SK_OK"),
1001 _popup_ok_cb, NULL, NULL);
1006 if (ugd->account_info) {
1007 buf = g_strdup(account->user_email_address);
1008 ret = _check_preset_isp_name(buf, ugd->account_info);
1010 debug_log("wrong ISP server name for preset accounts");
1011 ugd->popup_one = setting_get_notify(vd,
1012 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1013 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"),
1014 1, dgettext("sys_string", "IDS_COM_SK_OK"),
1015 _popup_ok_cb, NULL, NULL);
1022 /* check character validation */
1023 buf = g_strdup(account->user_email_address);
1025 ret = email_get_address_validation(buf);
1027 ugd->popup_one = setting_get_notify(vd,
1028 dgettext("sys_string", "IDS_COM_POP_WARNING"),
1029 _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1,
1030 dgettext("sys_string", "IDS_COM_SK_OK"),
1031 _popup_ok_cb, NULL, NULL);
1039 /* account info setting */
1040 setting_set_account(vd);
1042 setting_change_view(VIEW_MANUAL_SETUP, ugd);
1047 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
1051 struct viewdata *vd = (struct viewdata *)data;
1052 struct priv_data *p = vd->priv;
1054 if (vd->ugd->atomic_pop) {
1055 debug_log("During atomic poping");
1059 if (p->entry_account_name) {
1060 elm_object_focus_allow_set(p->entry_account_name, EINA_FALSE);
1063 if (p->entry_email_address) {
1064 elm_object_focus_allow_set(p->entry_email_address, EINA_FALSE);
1067 if (p->entry_password) {
1068 elm_object_focus_allow_set(p->entry_password, EINA_FALSE);
1071 Ecore_IMF_Context *imf_context = NULL;
1072 imf_context = elm_entry_imf_context_get(p->clicked_object);
1074 ecore_imf_context_input_panel_hide(imf_context);
1075 ecore_imf_context_input_panel_event_callback_del(imf_context,
1076 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1079 elm_object_disabled_set(p->l_button, EINA_TRUE);
1080 elm_object_disabled_set(p->r_button, EINA_TRUE);
1081 elm_object_disabled_set(p->r_button2, EINA_TRUE);
1082 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1083 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1085 if (!strcmp(vd->ugd->start_view_type, "account-add")) {
1086 ug_destroy_me(vd->ugd->ug);
1088 setting_back_to_prev_view(vd);
1092 static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1095 struct viewdata *vd = (struct viewdata *)data;
1098 debug_log("vd is NULL");
1102 struct priv_data *p = vd->priv;
1103 Eina_Bool state = elm_check_state_get(obj);
1106 p->set_default_account = 1;
1108 p->set_default_account = 0;
1111 static void _check1_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1114 struct viewdata *vd = (struct viewdata *)data;
1117 debug_log("vd is NULL");
1121 struct priv_data *p = vd->priv;
1122 Eina_Bool state = elm_check_state_get(p->default_account_check);
1125 elm_check_state_set(p->default_account_check, EINA_FALSE);
1126 p->set_default_account = 0;
1128 elm_check_state_set(p->default_account_check, EINA_TRUE);
1129 p->set_default_account = 1;
1133 static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info)
1136 struct viewdata *vd = (struct viewdata *)data;
1139 debug_log("vd is NULL");
1143 struct priv_data *p = vd->priv;
1144 EmailSettingUGD *ugd = NULL;
1147 Eina_Bool state = elm_check_state_get(obj);
1150 elm_entry_password_set(p->entry_password, EINA_FALSE);
1152 elm_entry_password_set(p->entry_password, EINA_TRUE);
1154 if (elm_object_focus_get(p->entry_password)) {
1155 if (ugd->password_timer) {
1156 ecore_timer_del(ugd->password_timer);
1157 ugd->password_timer = NULL;
1159 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1161 Ecore_IMF_Context *imf_context = NULL;
1162 imf_context = elm_entry_imf_context_get(p->entry_password);
1163 int state = ecore_imf_context_input_panel_state_get(imf_context);
1165 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1166 debug_log("input panel show");
1167 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1172 static void _check2_clicked_cb2(void *data, Evas_Object *obj, const char *emission, const char *source)
1175 struct viewdata *vd = (struct viewdata *)data;
1178 debug_log("vd is NULL");
1182 struct priv_data *p = vd->priv;
1183 EmailSettingUGD *ugd = NULL;
1186 Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1189 elm_check_state_set(p->show_passwd_check, EINA_FALSE);
1190 elm_entry_password_set(p->entry_password, EINA_TRUE);
1192 elm_check_state_set(p->show_passwd_check, EINA_TRUE);
1193 elm_entry_password_set(p->entry_password, EINA_FALSE);
1196 if (elm_object_focus_get(p->entry_password)) {
1197 if (ugd->password_timer) {
1198 ecore_timer_del(ugd->password_timer);
1199 ugd->password_timer = NULL;
1201 ugd->password_timer = ecore_timer_add(0.1, _password_state_cb, (void *)vd);
1203 Ecore_IMF_Context *imf_context = NULL;
1204 imf_context = elm_entry_imf_context_get(p->entry_password);
1205 int state = ecore_imf_context_input_panel_state_get(imf_context);
1207 if (state == ECORE_IMF_INPUT_PANEL_STATE_WILL_SHOW || state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1208 debug_log("input panel show");
1209 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1214 static Eina_Bool _after_validation_cb(void *data)
1218 struct viewdata *vd = (struct viewdata *)data;
1221 debug_log("vd is NULL");
1222 return ECORE_CALLBACK_CANCEL;
1225 EmailSettingUGD *ugd = NULL;
1226 struct priv_data *p = NULL;
1231 if (ugd->preset_vc_timer) {
1232 ecore_timer_del(ugd->preset_vc_timer);
1233 ugd->preset_vc_timer = NULL;
1236 if (ugd->popup_one) {
1237 evas_object_del(ugd->popup_one);
1238 ugd->popup_one = NULL;
1240 if (ugd->popup_validate) {
1241 evas_object_del(ugd->popup_validate);
1242 ugd->popup_validate = NULL;
1245 if (p->set_default_account) {
1246 if (email_engine_set_default_account(vd->ugd->account_id)) {
1247 debug_log("new default account is %d", vd->ugd->account_id);
1251 status_message_post(_("IDS_EMAIL_POP_SUCCEEDED"));
1253 setting_change_view(VIEW_SYNC_SETUP, ugd);
1256 /*debug_log("_after_validation_cb %s", vd->ugd->start_view_type);
1258 if (vd->ugd->start_view_type != NULL &&
1259 strcmp(vd->ugd->start_view_type, "first-setup") == 0) {
1260 ug_destroy_me(vd->ugd->ug);
1261 } else if (vd->ugd->start_view_type != NULL &&
1262 strcmp(vd->ugd->start_view_type, "account-add") == 0) {
1263 ug_destroy_me(vd->ugd->ug);
1264 } else if (vd->ugd->start_view_type != NULL &&
1265 strcmp(vd->ugd->start_view_type, "select-account") == 0) {
1266 service_h service = NULL;
1267 service_create(&service);
1269 service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT);
1270 ug_send_result(vd->ugd->ug, service);
1271 service_destroy(service);
1274 setting_update_acct_list(vd);
1275 setting_back_to_prev_nth_view(vd, 2, vd->ugd->navi_main_it);
1276 vd->ugd->atomic_pop = 0;
1279 return ECORE_CALLBACK_CANCEL;
1282 static Eina_Bool _password_state_cb(void *data)
1286 struct viewdata *vd = (struct viewdata *)data;
1289 debug_log("vd is NULL");
1290 return ECORE_CALLBACK_CANCEL;
1293 struct priv_data *p = NULL;
1295 EmailSettingUGD *ugd = NULL;
1298 if (ugd->password_timer) {
1299 ecore_timer_del(ugd->password_timer);
1300 ugd->password_timer = NULL;
1303 Ecore_IMF_Context *imf_context = NULL;
1304 imf_context = elm_entry_imf_context_get(p->entry_password);
1306 ecore_imf_context_input_panel_event_callback_del(imf_context,
1307 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1308 ecore_imf_context_input_panel_event_callback_add(imf_context,
1309 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1310 _input_panel_state_changed_cb, (void *)vd);
1313 return ECORE_CALLBACK_CANCEL;
1316 static Eina_Bool _startup_focus_cb(void *data)
1320 struct viewdata *vd = (struct viewdata *)data;
1323 debug_log("vd is NULL");
1324 return ECORE_CALLBACK_CANCEL;
1327 struct priv_data *p = NULL;
1330 EmailSettingUGD *ugd = NULL;
1333 if (ugd->focus_timer) {
1334 ecore_timer_del(ugd->focus_timer);
1335 ugd->focus_timer = NULL;
1338 p->clicked_object = p->entry_email_address;
1339 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1340 elm_entry_cursor_begin_set(p->entry_email_address);
1342 return ECORE_CALLBACK_CANCEL;
1345 static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
1349 debug_log("data is NULL");
1353 struct viewdata *vd = (struct viewdata *)data;
1354 EmailSettingUGD *ugd = vd->ugd;
1355 struct priv_data *p = vd->priv;
1357 if (ugd->popup_one) {
1358 evas_object_del(ugd->popup_one);
1359 ugd->popup_one = NULL;
1361 if (ugd->popup_validate) {
1362 evas_object_del(ugd->popup_validate);
1363 ugd->popup_validate = NULL;
1366 elm_object_disabled_set(p->l_button, EINA_FALSE);
1367 elm_object_disabled_set(p->r_button, EINA_FALSE);
1368 elm_object_disabled_set(p->r_button2, EINA_FALSE);
1369 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1370 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1373 /*static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
1377 debug_log("data is NULL");
1381 struct viewdata *vd = (struct viewdata *)data;
1382 EmailSettingUGD *ugd = vd->ugd;
1383 struct priv_data *p = vd->priv;
1385 if (ugd->popup_one) {
1386 evas_object_del(ugd->popup_one);
1387 ugd->popup_one = NULL;
1389 if (ugd->popup_validate) {
1390 evas_object_del(ugd->popup_validate);
1391 ugd->popup_validate = NULL;
1394 elm_object_disabled_set(p->r_button, EINA_FALSE);
1395 elm_object_disabled_set(p->r_button2, EINA_FALSE);
1398 static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info)
1402 debug_log("data is NULL");
1406 struct viewdata *vd = (struct viewdata *)data;
1407 EmailSettingUGD *ugd = vd->ugd;
1408 struct priv_data *p = vd->priv;
1410 if (ugd->popup_one) {
1411 evas_object_del(ugd->popup_one);
1412 ugd->popup_one = NULL;
1414 if (ugd->popup_validate) {
1415 evas_object_del(ugd->popup_validate);
1416 ugd->popup_validate = NULL;
1419 int account_id = vd->ugd->account_id;
1420 vd->ugd->cancel_event = 1;
1421 email_engine_stop_working(account_id, p->handle);
1422 email_engine_delete_account(account_id);
1424 elm_object_disabled_set(p->l_button, EINA_FALSE);
1425 elm_object_disabled_set(p->r_button, EINA_FALSE);
1426 elm_object_disabled_set(p->r_button2, EINA_FALSE);
1427 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1428 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1431 static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info)
1434 Evas_Object *eo = (Evas_Object *)obj;
1435 struct viewdata *vd = g_vd;
1439 struct priv_data *p = vd->priv;
1443 EmailSettingUGD *ugd = vd->ugd;
1447 if (elm_object_focus_get(data)) {
1448 if (elm_entry_is_empty(obj))
1449 elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1451 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1454 if (eo == p->entry_user_id) {
1455 debug_log("entry_user_id");
1456 if (p->str_user_id) {
1457 g_free(p->str_user_id);
1458 p->str_user_id = NULL;
1461 p->str_user_id = g_strdup(elm_entry_entry_get(eo));
1462 } else if (eo == p->entry_display_name) {
1463 debug_log("entry_display_name");
1464 if (p->str_display_name) {
1465 g_free(p->str_display_name);
1466 p->str_display_name = NULL;
1469 p->str_display_name = g_strdup(elm_entry_entry_get(eo));
1470 } else if (eo == p->entry_email_address) {
1471 debug_log("entry_email_address");
1472 if (p->str_email_address) {
1473 g_free(p->str_email_address);
1474 p->str_email_address = NULL;
1477 p->str_email_address = g_strdup(elm_entry_entry_get(eo));
1478 } else if (eo == p->entry_password) {
1479 debug_log("entry_password");
1480 if (p->str_password) {
1481 g_free(p->str_password);
1482 p->str_password = NULL;
1485 p->str_password = (char *)elm_entry_markup_to_utf8(elm_entry_entry_get(eo));
1488 if (p->str_email_address == NULL || p->str_password == NULL) {
1489 elm_object_disabled_set(p->l_button, EINA_TRUE);
1490 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1491 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1495 if (g_strcmp0(p->str_email_address, "") == 0 || g_strcmp0(p->str_password, "") == 0) {
1496 elm_object_disabled_set(p->l_button, EINA_TRUE);
1497 elm_object_disabled_set(p->manual_btn, EINA_TRUE);
1498 elm_object_disabled_set(p->tool_btn, EINA_TRUE);
1500 elm_object_disabled_set(p->l_button, EINA_FALSE);
1501 elm_object_disabled_set(p->manual_btn, EINA_FALSE);
1502 elm_object_disabled_set(p->tool_btn, EINA_FALSE);
1506 static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info)
1511 debug_log("obj is NULL");
1515 struct viewdata *vd = g_vd;
1516 struct priv_data *p = vd->priv;
1518 if (obj == p->entry_password) {
1519 Ecore_IMF_Context *imf_context = NULL;
1520 imf_context = elm_entry_imf_context_get(p->entry_password);
1522 ecore_imf_context_input_panel_event_callback_del(imf_context,
1523 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1524 ecore_imf_context_input_panel_event_callback_add(imf_context,
1525 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1526 _input_panel_state_changed_cb, (void *)vd);
1530 if (!elm_entry_is_empty(obj))
1531 elm_object_signal_emit(data, "elm,state,eraser,show", "elm");
1532 elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm");
1535 static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info)
1540 debug_log("obj is NULL");
1544 if (elm_entry_is_empty(obj))
1545 elm_object_signal_emit(data, "elm,state,guidetext,show", "elm");
1546 elm_object_signal_emit(data, "elm,state,eraser,hide", "elm");
1549 static void _entry_theme_changed_cb(void *data, Evas_Object *obj, void *event_info)
1554 debug_log("obj is NULL");
1558 struct viewdata *vd = (struct viewdata *)data;
1561 debug_log("vd is NULL");
1565 struct priv_data *p = NULL;
1568 Ecore_IMF_Context *imf_context = NULL;
1569 imf_context = elm_entry_imf_context_get(p->entry_password);
1571 ecore_imf_context_input_panel_event_callback_del(imf_context,
1572 ECORE_IMF_INPUT_PANEL_STATE_EVENT, _input_panel_state_changed_cb);
1573 ecore_imf_context_input_panel_event_callback_add(imf_context,
1574 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1575 _input_panel_state_changed_cb, (void *)vd);
1579 static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
1584 debug_log("obj is NULL");
1588 elm_entry_entry_set(data, "");
1591 static void _input_panel_state_changed_cb(void *data, Ecore_IMF_Context *ctx, int value)
1596 debug_log("data is NULL");
1600 struct viewdata *vd = (struct viewdata *)data;
1601 struct priv_data *p = vd->priv;
1603 int state = ecore_imf_context_input_panel_state_get(ctx);
1605 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1606 debug_log("state:SHOW");
1607 else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1608 debug_log("state HIDE");
1610 if (value == ECORE_IMF_INPUT_PANEL_STATE_SHOW)
1611 debug_log("value:SHOW");
1612 else if (value == ECORE_IMF_INPUT_PANEL_STATE_HIDE)
1613 debug_log("value HIDE");
1615 if (state == ECORE_IMF_INPUT_PANEL_STATE_SHOW) {
1616 debug_log("input panel show");
1617 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,shown", "");
1618 } else if (state == ECORE_IMF_INPUT_PANEL_STATE_HIDE) {
1619 debug_log("input panel hide");
1620 elm_object_item_signal_emit(p->navi_it, "elm,state,sip,hidden", "");
1624 static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info)
1627 int index = (int)data;
1628 struct viewdata *vd = g_vd;
1629 struct priv_data *p = vd->priv;
1631 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
1632 elm_genlist_item_selected_set(item, EINA_FALSE);
1635 p->clicked_object = p->entry_account_name;
1636 } else if (index == 2) {
1637 p->clicked_object = p->entry_user_id;
1638 } else if (index == 3) {
1639 p->clicked_object = p->entry_display_name;
1640 } else if (index == 4) {
1641 p->clicked_object = p->entry_email_address;
1642 } else if (index == 5) {
1643 p->clicked_object = p->entry_password;
1647 static char *_gl_group_text_get(void *data, Evas_Object *obj, const char *part)
1651 struct viewdata *vd = g_vd;
1653 if (!strcmp(part, "elm.text")) {
1654 char title_str[MAX_STR_LEN] = { 0, };
1655 if (vd->ugd->account_info) {
1656 if (g_str_has_prefix(vd->ugd->account_info->name_str_id, "IDS_EMAIL"))
1657 snprintf(title_str, sizeof(title_str), "%s", _(vd->ugd->account_info->name_str_id));
1659 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", vd->ugd->account_info->name_str_id));
1661 snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_OTHERS"));
1664 return g_strdup(title_str);
1670 static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part)
1673 int index = (int)data;
1674 struct viewdata *vd = g_vd;
1675 struct priv_data *p = vd->priv;
1676 //EmailSettingUGD *ugd = vd->ugd;
1677 Ecore_IMF_Context *imf_context = NULL;
1679 if (!strcmp(part, "elm.icon")) {
1681 //p->icon_get_cnt1++;
1684 p->ef_account_name = elm_layout_add(p->genlist);
1685 elm_layout_theme_set(p->ef_account_name, "layout", "editfield", "title");
1686 p->entry_account_name = elm_entry_add(p->genlist);
1687 elm_entry_scrollable_set(p->entry_account_name, EINA_TRUE);
1688 elm_entry_single_line_set(p->entry_account_name, EINA_TRUE);
1689 elm_entry_input_panel_return_key_disabled_set(p->entry_account_name, EINA_TRUE);
1690 elm_entry_cnp_mode_set(p->entry_account_name, ELM_CNP_MODE_PLAINTEXT);
1691 elm_entry_input_panel_layout_set(p->entry_account_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1692 elm_entry_editable_set(p->entry_account_name, TRUE);
1693 evas_object_smart_callback_add(p->entry_account_name, "changed", _backup_input_cb, p->ef_account_name);
1694 evas_object_smart_callback_add(p->entry_account_name, "focused", _entry_focused_cb, p->ef_account_name);
1695 evas_object_smart_callback_add(p->entry_account_name, "unfocused", _entry_unfocused_cb, p->ef_account_name);
1696 evas_object_show(p->entry_account_name);
1698 imf_context = elm_entry_imf_context_get(p->entry_account_name);
1700 ecore_imf_context_input_panel_event_callback_add(imf_context,
1701 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1702 _input_panel_state_changed_cb, (void *)vd);
1704 elm_object_part_content_set(p->ef_account_name, "elm.swallow.content", p->entry_account_name);
1705 /*elm_object_part_text_set(p->ef_account_name, "elm.guidetext", str);*/
1706 elm_object_part_text_set(p->ef_account_name, "elm.text", _("IDS_EMAIL_BODY_ACCOUNT_NAME"));
1707 elm_object_signal_callback_add(p->ef_account_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_account_name);
1709 evas_object_size_hint_weight_set(p->ef_account_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1710 evas_object_show(p->ef_account_name);
1712 if (p->str_account_name)
1713 elm_entry_entry_set(p->entry_account_name, p->str_account_name);
1715 /*if (ugd->account_info == NULL && p->icon_get_cnt1 == 2 &&
1716 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1717 p->clicked_object = p->entry_account_name;
1718 evas_object_show(p->entry_account_name);
1719 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1722 if (ugd->account_info == NULL && p->icon_get_cnt1 == 3 &&
1723 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1724 p->clicked_object = p->entry_account_name;
1725 evas_object_show(p->entry_account_name);
1726 elm_object_focus_set(p->entry_account_name, EINA_TRUE);
1729 return p->ef_account_name;
1730 } else if (index == 2) {
1732 p->ef_user_id = elm_layout_add(p->genlist);
1733 elm_layout_theme_set(p->ef_user_id, "layout", "editfield", "title");
1734 p->entry_user_id = elm_entry_add(p->genlist);
1735 elm_entry_scrollable_set(p->entry_user_id, EINA_TRUE);
1736 elm_entry_single_line_set(p->entry_user_id, EINA_TRUE);
1737 elm_entry_input_panel_return_key_disabled_set(p->entry_user_id, EINA_TRUE);
1738 elm_entry_cnp_mode_set(p->entry_user_id, ELM_CNP_MODE_PLAINTEXT);
1739 elm_entry_input_panel_layout_set(p->entry_user_id, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1740 elm_entry_editable_set(p->entry_user_id, TRUE);
1741 evas_object_smart_callback_add(p->entry_user_id, "changed", _backup_input_cb, p->ef_user_id);
1742 evas_object_smart_callback_add(p->entry_user_id, "focused", _entry_focused_cb, p->ef_user_id);
1743 evas_object_smart_callback_add(p->entry_user_id, "unfocused", _entry_unfocused_cb, p->ef_user_id);
1744 evas_object_show(p->entry_user_id);
1746 imf_context = elm_entry_imf_context_get(p->entry_user_id);
1748 ecore_imf_context_input_panel_event_callback_add(imf_context,
1749 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1750 _input_panel_state_changed_cb, (void *)vd);
1752 elm_object_part_content_set(p->ef_user_id, "elm.swallow.content", p->entry_user_id);
1753 /*elm_object_part_text_set(p->ef_user_id, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));*/
1754 elm_object_part_text_set(p->ef_user_id, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));
1755 elm_object_signal_callback_add(p->ef_user_id, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_user_id);
1757 evas_object_size_hint_weight_set(p->ef_user_id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1758 evas_object_show(p->ef_user_id);
1761 elm_entry_entry_set(p->entry_user_id, p->str_user_id);
1763 return p->ef_user_id;
1764 } else if (index == 3) {
1766 p->ef_display_name = elm_layout_add(p->genlist);
1767 elm_layout_theme_set(p->ef_display_name, "layout", "editfield", "title");
1768 p->entry_display_name = elm_entry_add(p->genlist);
1769 elm_entry_scrollable_set(p->entry_display_name, EINA_TRUE);
1770 elm_entry_single_line_set(p->entry_display_name, EINA_TRUE);
1771 elm_entry_input_panel_return_key_disabled_set(p->entry_display_name, EINA_TRUE);
1772 elm_entry_cnp_mode_set(p->entry_display_name, ELM_CNP_MODE_PLAINTEXT);
1773 elm_entry_input_panel_layout_set(p->entry_display_name, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1774 elm_entry_editable_set(p->entry_display_name, TRUE);
1775 evas_object_smart_callback_add(p->entry_display_name, "changed", _backup_input_cb, p->ef_display_name);
1776 evas_object_smart_callback_add(p->entry_display_name, "focused", _entry_focused_cb, p->ef_display_name);
1777 evas_object_smart_callback_add(p->entry_display_name, "unfocused", _entry_unfocused_cb, p->ef_display_name);
1778 evas_object_show(p->entry_display_name);
1780 imf_context = elm_entry_imf_context_get(p->entry_display_name);
1782 ecore_imf_context_input_panel_event_callback_add(imf_context,
1783 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1784 _input_panel_state_changed_cb, (void *)vd);
1786 elm_object_part_content_set(p->ef_display_name, "elm.swallow.content", p->entry_display_name);
1787 /*elm_object_part_text_set(p->ef_display_name, "elm.guidetext", _("IDS_EMAIL_BODY_YOUR_NAME"));*/
1788 elm_object_part_text_set(p->ef_display_name, "elm.text", dgettext("sys_string", "IDS_COM_BODY_DETAILS_NAME"));
1789 elm_object_signal_callback_add(p->ef_display_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_display_name);
1791 evas_object_size_hint_weight_set(p->ef_display_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1792 evas_object_show(p->ef_display_name);
1794 if (p->str_display_name)
1795 elm_entry_entry_set(p->entry_display_name, p->str_display_name);
1797 return p->ef_display_name;
1798 } else if (index == 4) {
1799 //p->icon_get_cnt2++;
1802 p->ef_email_address = elm_layout_add(p->genlist);
1803 elm_layout_theme_set(p->ef_email_address, "layout", "editfield", "title");
1804 p->entry_email_address = elm_entry_add(p->genlist);
1805 elm_entry_scrollable_set(p->entry_email_address, EINA_TRUE);
1806 elm_entry_single_line_set(p->entry_email_address, EINA_TRUE);
1807 //elm_entry_input_panel_return_key_disabled_set(p->entry_email_address, EINA_TRUE);
1808 elm_entry_cnp_mode_set(p->entry_email_address, ELM_CNP_MODE_PLAINTEXT);
1809 elm_entry_input_panel_layout_set(p->entry_email_address, ELM_INPUT_PANEL_LAYOUT_EMAIL);
1810 elm_entry_editable_set(p->entry_email_address, TRUE);
1811 evas_object_smart_callback_add(p->entry_email_address, "changed", _backup_input_cb, p->ef_email_address);
1812 evas_object_smart_callback_add(p->entry_email_address, "focused", _entry_focused_cb, p->ef_email_address);
1813 evas_object_smart_callback_add(p->entry_email_address, "unfocused", _entry_unfocused_cb, p->ef_email_address);
1814 evas_object_show(p->entry_email_address);
1816 imf_context = elm_entry_imf_context_get(p->entry_email_address);
1818 ecore_imf_context_input_panel_event_callback_add(imf_context,
1819 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1820 _input_panel_state_changed_cb, (void *)vd);
1822 elm_object_part_content_set(p->ef_email_address, "elm.swallow.content", p->entry_email_address);
1823 /*_set_help_string(p->ef_email_address, vd);*/
1824 elm_object_part_text_set(p->ef_email_address, "elm.text", dgettext("sys_string", "IDS_COM_BODY_EMAIL_ADDRESS"));
1825 elm_object_signal_callback_add(p->ef_email_address, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_email_address);
1827 evas_object_size_hint_weight_set(p->ef_email_address, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1828 evas_object_show(p->ef_email_address);
1830 if (p->str_email_address)
1831 elm_entry_entry_set(p->entry_email_address, p->str_email_address);
1833 /*if (ugd->account_info != NULL && p->icon_get_cnt2 == 2 &&
1834 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) != 0) {
1835 p->clicked_object = p->entry_email_address;
1836 evas_object_show(p->entry_email_address);
1837 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1838 elm_entry_cursor_begin_set(p->entry_email_address);
1841 if (ugd->account_info != NULL && p->icon_get_cnt2 == 3 &&
1842 strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) {
1843 p->clicked_object = p->entry_email_address;
1844 evas_object_show(p->entry_email_address);
1845 elm_object_focus_set(p->entry_email_address, EINA_TRUE);
1846 elm_entry_cursor_begin_set(p->entry_email_address);
1849 return p->ef_email_address;
1850 } else if (index == 5) {
1852 p->ef_password = elm_layout_add(p->genlist);
1853 elm_layout_theme_set(p->ef_password, "layout", "editfield", "title");
1854 p->entry_password = elm_entry_add(p->genlist);
1855 elm_entry_scrollable_set(p->entry_password, EINA_TRUE);
1856 elm_entry_single_line_set(p->entry_password, EINA_TRUE);
1857 //elm_entry_input_panel_return_key_disabled_set(p->entry_password, EINA_TRUE);
1858 elm_entry_cnp_mode_set(p->entry_password, ELM_CNP_MODE_PLAINTEXT);
1859 elm_entry_input_panel_layout_set(p->entry_password, ELM_INPUT_PANEL_LAYOUT_NORMAL);
1860 elm_entry_editable_set(p->entry_password, EINA_TRUE);
1861 elm_entry_password_set(p->entry_password, EINA_TRUE);
1863 evas_object_smart_callback_add(p->entry_password, "changed", _backup_input_cb, p->ef_password);
1864 evas_object_smart_callback_add(p->entry_password, "focused", _entry_focused_cb, p->ef_password);
1865 evas_object_smart_callback_add(p->entry_password, "unfocused", _entry_unfocused_cb, p->ef_password);
1866 //evas_object_smart_callback_add(p->entry_password, "theme,changed", _entry_theme_changed_cb, (void *)vd);
1867 evas_object_show(p->entry_password);
1869 imf_context = elm_entry_imf_context_get(p->entry_password);
1871 ecore_imf_context_input_panel_event_callback_add(imf_context,
1872 ECORE_IMF_INPUT_PANEL_STATE_EVENT,
1873 _input_panel_state_changed_cb, (void *)vd);
1875 elm_object_part_content_set(p->ef_password, "elm.swallow.content", p->entry_password);
1876 /*elm_object_part_text_set(p->ef_password, "elm.guidetext", _("IDS_EMAIL_BODY_USER_PASSWORD"));*/
1877 elm_object_part_text_set(p->ef_password, "elm.text", dgettext("sys_string", "IDS_COM_BODY_PASSWORD"));
1878 elm_object_signal_callback_add(p->ef_password, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_password);
1880 evas_object_size_hint_weight_set(p->ef_password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1881 evas_object_show(p->ef_password);
1883 if (p->str_password)
1884 elm_entry_entry_set(p->entry_password, p->str_password);
1886 Eina_Bool state = elm_check_state_get(p->show_passwd_check);
1889 elm_entry_password_set(p->entry_password, EINA_FALSE);
1891 elm_entry_password_set(p->entry_password, EINA_TRUE);
1893 return p->ef_password;
1900 static void _gl_realized_cb(void *data, Evas_Object *obj, void *event_info)
1902 Elm_Object_Item *it = event_info;
1903 struct viewdata *vd = (struct viewdata *)data;
1904 struct priv_data *p = vd->priv;
1906 if (p->gl_email_address_item == it)
1907 elm_object_item_signal_emit(it, "elm,state,top", "");
1908 else if (p->gl_pw_item == it)
1909 elm_object_item_signal_emit(it, "elm,state,bottom", "");
1911 elm_object_item_signal_emit(it, "elm,state,center", "");