/* * Copyright 2012 Samsung Electronics Co., Ltd * * Licensed under the Flora License, Version 1.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.tizenopensource.org/license * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "email-setting.h" #include "email-setting-utils.h" static email_account_t *account_data = NULL; static int _create(struct viewdata *vd); static int _update(struct viewdata *vd); static int _destroy(struct viewdata *vd); static int _show(struct viewdata *vd); static int _hide(struct viewdata *vd); static void _push_naviframe(struct viewdata *vd); static void _create_list(struct viewdata *vd); static void _get_selected_account_details(struct viewdata *vd); static int _check_null_field(struct viewdata *vd); static void _read_all_entries(struct viewdata *vd); static void _free_all_entries(struct viewdata *vd); static void _update_account_info(struct viewdata *vd); static void _validate_account(struct viewdata *vd, int account_id); static void _save_cb(void *data, Evas_Object *obj, void *event_info); static void _onoff_cb(void *data, Evas_Object *obj, void *event_info); static void _back_cb(void *data, Evas_Object *obj, void *event_info); static Eina_Bool _after_save_cb(void *data); static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info); static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info); static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info); static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info); static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info); static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source); static void _password_focused_cb(void *data, Evas_Object *obj, void *event_info); static void _sending_password_focused_cb(void *data, Evas_Object *obj, void *event_info); static char *_gl_secure_text_get_cb(void *data, Evas_Object *obj, const char *part); static char *_gl_ex_secure_text_get_cb(void *data, Evas_Object *obj, const char *part); static char *_gl_server_type_text_get_cb(void *data, Evas_Object *obj, const char *part); static char *_gl_onoff_text_get_cb(void *data, Evas_Object *obj, const char *part); static char *_gl_sp_text_get_cb(void *data, Evas_Object *obj, const char *part); static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part); static Evas_Object *_gl_ex_sending_secure_content_get_cb(void *data, Evas_Object *obj, const char *part); static Evas_Object *_gl_ex_incoming_secure_content_get_cb(void *data, Evas_Object *obj, const char *part); static Evas_Object *_gl_onoff_content_get_cb(void *data, Evas_Object *obj, const char *part); static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info); static void _gl_secure_sel_cb(void *data, Evas_Object *obj, void *event_info); static void _gl_ex_sending_secure_sel_cb(void *data, Evas_Object *obj, void *event_info); static void _gl_ex_incoming_secure_sel_cb(void *data, Evas_Object *obj, void *event_info); static void _gl_onoff_sel_cb(void *data, Evas_Object *obj, void *event_info); static void _gl_exp_cb(void *data, Evas_Object *obj, void *event_info); static void _gl_con_cb(void *data, Evas_Object *obj, void *event_info); static struct viewdata *g_vd = NULL; struct priv_data { struct viewdata *vd; Evas_Object *entry_account_name; Evas_Object *entry_email_address; Evas_Object *entry_user_name; Evas_Object *entry_password; Evas_Object *entry_smtp_server; Evas_Object *entry_smtp_port; Evas_Object *entry_incoming_server; Evas_Object *entry_incoming_port; Evas_Object *entry_sending_username; Evas_Object *entry_sending_password; Evas_Object *ef_account_name; Evas_Object *ef_email_address; Evas_Object *ef_user_name; Evas_Object *ef_password; Evas_Object *ef_smtp_server; Evas_Object *ef_smtp_port; Evas_Object *ef_incoming_server; Evas_Object *ef_incoming_port; Evas_Object *ef_sending_username; Evas_Object *ef_sending_password; Evas_Object *layout; Evas_Object *conform; Evas_Object *sending_secure_radio_grp; Evas_Object *incoming_secure_radio_grp; Evas_Object *genlist; Evas_Object *l_button; Evas_Object *r_button1; Evas_Object *r_button2; Evas_Object *clicked_object; Evas_Object *cbar; Evas_Object *onoff[3]; Elm_Genlist_Item_Class itc_sep; Elm_Genlist_Item_Class itc_sep2; Elm_Genlist_Item_Class itc_ef; Elm_Genlist_Item_Class itc_secure; Elm_Genlist_Item_Class itc_ex_sending; Elm_Genlist_Item_Class itc_ex_incoming; Elm_Genlist_Item_Class itc_title; Elm_Genlist_Item_Class itc_type; Elm_Genlist_Item_Class itc_onoff; Elm_Object_Item *gl_ex_item1; Elm_Object_Item *gl_ex_item2; Elm_Object_Item *gl_same_item; Elm_Object_Item *gl_sending_user_item; Elm_Object_Item *gl_sending_pw_item; Elm_Object_Item * c_item[4]; char *str_account_name; char *str_user_name; char *str_email_address; char *str_password; char *str_smtp_server; char *str_smtp_port; char *str_incoming_server; char *str_incoming_port; char *str_password_backup; char *str_sending_password_backup; char *str_sending_username; char *str_sending_password; int account_deleted; int b_first_focus_on_pw; int b_first_focus_on_sending_pw; unsigned int handle; }; void setting_init_account_edit_view(struct viewdata *vd) { debug_log(""); vd->type = VIEW_ACCOUNT_EDIT; vd->create = _create; vd->update = _update; vd->destroy = _destroy; vd->show = _show; vd->hide = _hide; vd->grp_nm = "setting_account_edit"; } void setting_edit_validation_success_cb(EmailSettingUGD *ugd) { debug_log(""); struct viewdata *vd; Viewtype top; top = ugd->view_st[ugd->view_top]; vd = ugd->vd[top]; if (!vd) { debug_log("vd is NULL"); return; } if (ugd->popup_one) { evas_object_del(ugd->popup_one); ugd->popup_one = NULL; } if (ugd->popup_validate) { evas_object_del(ugd->popup_validate); ugd->popup_validate = NULL; } ugd->edit_vc_timer = ecore_timer_add(0.5, _after_save_cb, vd); } void setting_edit_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled) { debug_log(""); struct viewdata *vd; Viewtype top; int account_id; top = ugd->view_st[ugd->view_top]; vd = ugd->vd[top]; if (!vd) { debug_log("vd is NULL"); return; } account_id = ugd->account_id; if (ugd->popup_one) { evas_object_del(ugd->popup_one); ugd->popup_one = NULL; } if (ugd->popup_validate) { evas_object_del(ugd->popup_validate); ugd->popup_validate = NULL; } char fail_msg[MAX_STR_LEN] = { 0, }; char *err_msg = setting_get_service_fail_type(ugd->err_code); if (canceled) { snprintf(fail_msg, sizeof(fail_msg), "%s", _("IDS_EMAIL_POP_ACCOUNT_CREATION_CANCELLED")); ugd->popup_one = setting_get_notify(vd, dgettext("sys_string", "IDS_COM_POP_WARNING"), fail_msg, 1, dgettext("sys_string", "IDS_COM_SK_OK"), _popup_ok_cb, NULL, NULL); } else { snprintf(fail_msg, sizeof(fail_msg), "%s
%s", _("IDS_EMAIL_POP_VALIDATION_FAILED"), err_msg); ugd->popup_one = setting_get_notify(vd, dgettext("sys_string", "IDS_COM_POP_WARNING"), fail_msg, 1, dgettext("sys_string", "IDS_COM_SK_OK"), _popup_ok_cb, NULL, NULL); } g_free(err_msg); } static int _create(struct viewdata *vd) { debug_log(""); if (!vd) { debug_log("vd is NULL"); return FALSE; } EmailSettingUGD *ugd = vd->ugd; struct priv_data *p; p = vd->priv; if (p == NULL) { p = vd->priv = calloc(1, sizeof(struct priv_data)); p->vd = vd; _get_selected_account_details(vd); if (account_data == NULL) { debug_log("Can't get account info"); return FALSE; } p->layout = setting_add_inner_layout(vd); _push_naviframe(vd); elm_win_conformant_set(ugd->win, 1); p->conform = elm_conformant_add(ugd->win); elm_object_style_set(p->conform, "internal_layout"); evas_object_show(p->conform); elm_object_part_content_set(p->layout, "elm.swallow.content", p->conform); } p->b_first_focus_on_pw = 1; p->b_first_focus_on_sending_pw = 1; g_vd = vd; _create_list(vd); return TRUE; } static int _update(struct viewdata *vd) { debug_log(""); return TRUE; } static int _destroy(struct viewdata *vd) { debug_log(""); struct priv_data *p = vd->priv; EmailSettingUGD *ugd = vd->ugd; if (!p) { debug_log("priv is NULL"); return FALSE; } Ecore_IMF_Context *imf_context = NULL; imf_context = elm_entry_imf_context_get(p->clicked_object); if (imf_context) ecore_imf_context_input_panel_hide(imf_context); evas_object_del(p->l_button); evas_object_del(p->r_button1); evas_object_del(p->r_button2); evas_object_del(p->genlist); if (ugd->del_timer) { ecore_timer_del(ugd->del_timer); ugd->del_timer = NULL; } if (ugd->edit_vc_timer) { ecore_timer_del(ugd->edit_vc_timer); ugd->edit_vc_timer = NULL; } if (ugd->popup_one) { evas_object_del(ugd->popup_one); ugd->popup_one = NULL; } if (ugd->popup_validate) { evas_object_del(ugd->popup_validate); ugd->popup_validate = NULL; } if (p->str_account_name) { g_free(p->str_account_name); p->str_account_name = NULL; } if (p->str_user_name) { g_free(p->str_user_name); p->str_user_name = NULL; } if (p->str_email_address) { g_free(p->str_email_address); p->str_email_address = NULL; } if (p->str_password) { g_free(p->str_password); p->str_password = NULL; } if (p->str_smtp_server) { g_free(p->str_smtp_server); p->str_smtp_server = NULL; } if (p->str_smtp_port) { g_free(p->str_smtp_port); p->str_smtp_port = NULL; } if (p->str_incoming_server) { g_free(p->str_incoming_server); p->str_incoming_server = NULL; } if (p->str_incoming_port) { g_free(p->str_incoming_port); p->str_incoming_port = NULL; } if (p->str_password_backup) { g_free(p->str_password_backup); p->str_password_backup = NULL; } if (p->str_sending_password_backup) { g_free(p->str_sending_password_backup); p->str_sending_password_backup = NULL; } if (p->str_sending_username) { g_free(p->str_sending_username); p->str_sending_username = NULL; } if (p->str_sending_password) { g_free(p->str_sending_password); p->str_sending_password = NULL; } if (account_data) { email_engine_free_account_list(&account_data, 1); account_data = NULL; } return TRUE; } static int _show(struct viewdata *vd) { debug_log(""); if (!vd) { debug_log("vd is NULL"); return FALSE; } evas_object_show(vd->ly); return TRUE; } static int _hide(struct viewdata *vd) { debug_log(""); if (!vd) { debug_log("vd is NULL"); return FALSE; } evas_object_hide(vd->ly); return TRUE; } static void _push_naviframe(struct viewdata *vd) { debug_log(""); struct priv_data *p = vd->priv; p->cbar = elm_toolbar_add(vd->ugd->navi_bar); elm_toolbar_shrink_mode_set(p->cbar, ELM_TOOLBAR_SHRINK_EXPAND); elm_object_style_set(p->cbar, "naviframe"); evas_object_show(p->cbar); p->c_item[0] = elm_toolbar_item_append(p->cbar, NULL, dgettext("sys_string", "IDS_COM_SK_SAVE"), _save_cb, vd); elm_object_item_disabled_set(elm_toolbar_item_append(p->cbar, NULL, "", NULL, NULL), EINA_TRUE); elm_object_item_disabled_set(elm_toolbar_item_append(p->cbar, NULL, "", NULL, NULL), EINA_TRUE); p->l_button = elm_button_add(vd->ugd->navi_bar); evas_object_smart_callback_add(p->l_button, "clicked", _back_cb, vd); elm_object_style_set(p->l_button, "naviframe/back_btn/default"); evas_object_show(p->l_button); /*p->r_button1 = elm_button_add(vd->ugd->navi_bar); elm_object_style_set(p->r_button1, "naviframe/title/default"); elm_object_text_set(p->r_button1, dgettext("sys_string", "IDS_COM_SK_DELETE")); evas_object_smart_callback_add(p->r_button1, "clicked", _delete_cb, vd); evas_object_show(p->r_button1);*/ /*p->r_button2 = elm_button_add(vd->ugd->navi_bar); elm_object_style_set(p->r_button2, "naviframe/title/default"); elm_object_text_set(p->r_button2, dgettext("sys_string", "IDS_COM_SK_SAVE")); evas_object_smart_callback_add(p->r_button2, "clicked", _save_cb, vd); evas_object_show(p->r_button2);*/ Elm_Object_Item *navi_it = NULL; navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, p->str_account_name, p->l_button, NULL, p->layout, NULL); /*elm_object_item_part_content_set(navi_it, "title_left_btn", p->r_button1); elm_object_item_part_content_set(navi_it, "title_right_btn", p->r_button2);*/ elm_object_item_part_content_set(navi_it, "controlbar", p->cbar); evas_object_show(vd->ugd->navi_bar); } static void _create_list(struct viewdata *vd) { debug_log(""); struct priv_data *p; EmailSettingUGD *ugd; int i = 0; if (!vd) { debug_critical("vd is null!"); return; } ugd = vd->ugd; p = vd->priv; Elm_Object_Item *item = NULL; Elm_Object_Item *git = NULL; p->genlist = elm_genlist_add(ugd->navi_bar); elm_object_style_set(p->genlist, "dialogue"); p->sending_secure_radio_grp = elm_radio_add(p->genlist); elm_radio_value_set(p->sending_secure_radio_grp, 0); evas_object_hide(p->sending_secure_radio_grp); p->incoming_secure_radio_grp = elm_radio_add(p->genlist); elm_radio_value_set(p->incoming_secure_radio_grp, 0); evas_object_hide(p->incoming_secure_radio_grp); p->itc_ef.item_style = "dialogue/1icon"; p->itc_ef.func.text_get = NULL; p->itc_ef.func.content_get = _gl_ef_content_get_cb; p->itc_ef.func.state_get = NULL; p->itc_ef.func.del = NULL; p->itc_secure.item_style = "dialogue/2text.3/expandable"; p->itc_secure.func.text_get = _gl_secure_text_get_cb; p->itc_secure.func.content_get = NULL; p->itc_secure.func.state_get = NULL; p->itc_secure.func.del = NULL; p->itc_ex_sending.item_style = "dialogue/1text.1icon/expandable2"; p->itc_ex_sending.func.text_get = _gl_ex_secure_text_get_cb; p->itc_ex_sending.func.content_get = _gl_ex_sending_secure_content_get_cb; p->itc_ex_sending.func.state_get = NULL; p->itc_ex_sending.func.del = NULL; p->itc_ex_incoming.item_style = "dialogue/1text.1icon/expandable2"; p->itc_ex_incoming.func.text_get = _gl_ex_secure_text_get_cb; p->itc_ex_incoming.func.content_get = _gl_ex_incoming_secure_content_get_cb; p->itc_ex_incoming.func.state_get = NULL; p->itc_ex_incoming.func.del = NULL; p->itc_type.item_style = "dialogue/2text.3"; p->itc_type.func.text_get = _gl_server_type_text_get_cb; p->itc_type.func.content_get = NULL; p->itc_type.func.state_get = NULL; p->itc_type.func.del = NULL; p->itc_onoff.item_style = "dialogue/1text.1icon"; p->itc_onoff.func.text_get = _gl_onoff_text_get_cb; p->itc_onoff.func.content_get = _gl_onoff_content_get_cb; p->itc_onoff.func.state_get = NULL; p->itc_onoff.func.del = NULL; p->itc_title.item_style = "dialogue/title"; p->itc_title.func.text_get = _gl_sp_text_get_cb; p->itc_title.func.content_get = NULL; p->itc_title.func.state_get = NULL; p->itc_title.func.del = NULL; p->itc_sep.item_style = "dialogue/separator"; p->itc_sep.func.text_get = NULL; p->itc_sep.func.content_get = NULL; p->itc_sep.func.state_get = NULL; p->itc_sep.func.del = NULL; p->itc_sep2.item_style = "dialogue/separator/end"; p->itc_sep2.func.text_get = NULL; p->itc_sep2.func.content_get = NULL; p->itc_sep2.func.state_get = NULL; p->itc_sep2.func.del = NULL; git = elm_genlist_item_append(p->genlist, &(p->itc_sep), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); /* account name */ i = 1; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); /* email address */ i = 2; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); elm_object_item_disabled_set(item, EINA_TRUE); /* user name */ i = 3; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); elm_object_item_disabled_set(item, EINA_TRUE); /* password */ i = 4; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); git = elm_genlist_item_append(p->genlist, &(p->itc_sep), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); /* smtp server */ i = 5; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); /* smtp port */ i = 6; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); /* sending security */ i = 1; p->gl_ex_item1 = elm_genlist_item_append(p->genlist, &(p->itc_secure), (void *)i, NULL, ELM_GENLIST_ITEM_TREE, _gl_secure_sel_cb, (void *)vd); git = elm_genlist_item_append(p->genlist, &(p->itc_sep), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); /* incoming server type */ item = elm_genlist_item_append(p->genlist, &(p->itc_type), NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL); elm_object_item_disabled_set(item, EINA_TRUE); /* incoming server */ i = 7; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); /* incoming port */ i = 8; item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); /* secure connection */ i = 2; p->gl_ex_item2 = elm_genlist_item_append(p->genlist, &(p->itc_secure), (void *)i, NULL, ELM_GENLIST_ITEM_TREE, _gl_secure_sel_cb, (void *)vd); git = elm_genlist_item_append(p->genlist, &(p->itc_sep), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); /* SMTP Authentication */ /* POP before SMTP */ i = 0; item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, git, ELM_GENLIST_ITEM_NONE, _gl_onoff_sel_cb, (void *)i); /* SMTP Auth */ i = 1; item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, git, ELM_GENLIST_ITEM_NONE, _gl_onoff_sel_cb, (void *)i); /* Same as POP3/IMAP4 */ i = 2; p->gl_same_item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_onoff_sel_cb, (void *)i); /* user name */ i = 9; p->gl_sending_user_item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); /* password */ i = 10; p->gl_sending_pw_item = elm_genlist_item_append(p->genlist, &(p->itc_ef), (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); if (account_data->outgoing_server_use_same_authenticator) { elm_object_item_disabled_set(p->gl_sending_user_item, EINA_TRUE); elm_object_item_disabled_set(p->gl_sending_pw_item, EINA_TRUE); } git = elm_genlist_item_append(p->genlist, &(p->itc_sep2), NULL, NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); evas_object_smart_callback_add(p->genlist, "expanded", _gl_exp_cb, (void *)vd); evas_object_smart_callback_add(p->genlist, "contracted", _gl_con_cb, (void *)vd); elm_object_content_set(p->conform, p->genlist); } static void _get_selected_account_details(struct viewdata *vd) { debug_log(""); struct priv_data *p; EmailSettingUGD *ugd = vd->ugd; p = vd->priv; if (account_data) { email_engine_free_account_list(&account_data, 1); account_data = NULL; } if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { debug_log("setting_get_acct_full_data failed"); return; } char buf[30] = { 0, }; char password_buf[MAX_STR_LEN] = { 0, }; char sending_password_buf[MAX_STR_LEN] = { 0, }; int pass_len = 0; int i = 0; email_get_password_length_of_account(account_data->account_id, &pass_len); debug_log("password length:%d", pass_len); memset(password_buf, 0, sizeof(password_buf)); memset(sending_password_buf, 0, sizeof(sending_password_buf)); if (pass_len > 0 && pass_len < MAX_STR_LEN) { for (i = 0; i < pass_len; i++) { password_buf[i] = '*'; } } //TODO get length of sending password p->str_account_name = g_strdup(account_data->account_name); p->str_user_name = g_strdup(account_data->incoming_server_user_name); p->str_email_address = g_strdup(account_data->user_email_address); p->str_password = g_strdup(password_buf); p->str_password_backup = g_strdup(password_buf); p->str_smtp_server = g_strdup(account_data->outgoing_server_address); snprintf(buf, sizeof(buf), "%d", account_data->outgoing_server_port_number); p->str_smtp_port = g_strdup(buf); p->str_incoming_server = g_strdup(account_data->incoming_server_address); snprintf(buf, sizeof(buf), "%d", account_data->incoming_server_port_number); p->str_incoming_port = g_strdup(buf); if (account_data->outgoing_server_use_same_authenticator) { p->str_sending_username = g_strdup(account_data->incoming_server_user_name); p->str_sending_password = g_strdup(password_buf); p->str_sending_password_backup = g_strdup(password_buf); } else { p->str_sending_username = g_strdup(account_data->outgoing_server_user_name); p->str_sending_password = g_strdup(sending_password_buf); p->str_sending_password_backup = g_strdup(sending_password_buf); } } static int _check_null_field(struct viewdata *vd) { debug_log(""); struct priv_data *p; p = vd->priv; if (account_data->account_name == NULL || strlen(account_data->account_name) == 0 || account_data->user_email_address == NULL || strlen(account_data->user_email_address) == 0 || account_data->incoming_server_user_name == NULL || strlen(account_data->incoming_server_user_name) == 0 || p->str_password == NULL || strlen(p->str_password) == 0 || account_data->incoming_server_address == NULL || strlen(account_data->incoming_server_address) == 0 || account_data->incoming_server_port_number == 0 || account_data->outgoing_server_address == NULL || strlen(account_data->outgoing_server_address) == 0 || account_data->outgoing_server_port_number == 0) { return FALSE; } else { if (account_data->outgoing_server_use_same_authenticator == 0) { if (account_data->outgoing_server_user_name == NULL || strlen(account_data->outgoing_server_user_name) == 0 || p->str_sending_password == NULL || strlen(p->str_sending_password) == 0) return FALSE; } return TRUE; } } static void _read_all_entries(struct viewdata *vd) { debug_log(""); struct priv_data *p; p = vd->priv; _free_all_entries(vd); debug_log("account name %s", p->str_account_name); account_data->account_name = g_strdup(p->str_account_name); debug_log("email addr %s", p->str_email_address); account_data->user_email_address = g_strdup(p->str_email_address); debug_log("user name %s", p->str_user_name); account_data->incoming_server_user_name = g_strdup(p->str_user_name); if (g_strcmp0(p->str_password, p->str_password_backup) == 0) account_data->incoming_server_password = NULL; else account_data->incoming_server_password = g_strdup(p->str_password); debug_log("display name %s", p->str_user_name); account_data->user_display_name = g_strdup(p->str_user_name); debug_log("incoming server %s", p->str_incoming_server); account_data->incoming_server_address = g_strdup(p->str_incoming_server); debug_log("outgoing server %s", p->str_smtp_server); account_data->outgoing_server_address = g_strdup(p->str_smtp_server); debug_log("incoming port %s", p->str_incoming_port); if (p->str_incoming_port != NULL && strlen(p->str_incoming_port) > 0) { account_data->incoming_server_port_number = atoi(p->str_incoming_port); } else { account_data->incoming_server_port_number = 0; } debug_log("outgoing port %s", p->str_smtp_port); if (p->str_smtp_port != NULL && strlen(p->str_smtp_port) > 0) { account_data->outgoing_server_port_number = atoi(p->str_smtp_port); } else { account_data->outgoing_server_port_number = 0; } if (account_data->outgoing_server_use_same_authenticator == 0) { account_data->outgoing_server_user_name = g_strdup(p->str_sending_username); if (g_strcmp0(p->str_sending_password, p->str_sending_password_backup) == 0) account_data->outgoing_server_password = NULL; else account_data->outgoing_server_password = g_strdup(p->str_sending_password); debug_log("sending_password %s", account_data->outgoing_server_password); } } static void _free_all_entries(struct viewdata *vd) { debug_log(""); struct priv_data *p; p = vd->priv; if (account_data->account_name) { g_free(account_data->account_name); account_data->account_name = NULL; } if (account_data->user_email_address) { g_free(account_data->user_email_address); account_data->user_email_address = NULL; } if (account_data->user_display_name) { g_free(account_data->user_display_name); account_data->user_display_name = NULL; } if (account_data->incoming_server_user_name) { g_free(account_data->incoming_server_user_name); account_data->incoming_server_user_name = NULL; } if (account_data->incoming_server_password) { g_free(account_data->incoming_server_password); account_data->incoming_server_password = NULL; } if (account_data->incoming_server_address) { g_free(account_data->incoming_server_address); account_data->incoming_server_address = NULL; } if (account_data->outgoing_server_address) { g_free(account_data->outgoing_server_address); account_data->outgoing_server_address = NULL; } if (account_data->outgoing_server_user_name) { g_free(account_data->outgoing_server_user_name); account_data->outgoing_server_user_name = NULL; } if (account_data->outgoing_server_password) { g_free(account_data->outgoing_server_password); account_data->outgoing_server_password = NULL; } } static void _update_account_info(struct viewdata *vd) { debug_log(""); struct priv_data *p = NULL; if (!vd) { debug_log("vd is NULL"); return; } if (!vd->priv) { debug_log("priv is NULL"); return; } p = vd->priv; if (account_data == NULL) { debug_log("account_data is NULL"); return; } if (email_engine_update_account(account_data->account_id, account_data) == TRUE) debug_log("Account updated successfully"); } static void _validate_account(struct viewdata *vd, int account_id) { debug_log(""); if (!vd) { debug_log("vd is NULL"); return; } gboolean ret; struct priv_data *p = vd->priv; EmailSettingUGD *ugd = vd->ugd; ret = email_engine_update_account_with_validation(account_id, account_data); if (ugd->popup_one) { evas_object_del(ugd->popup_one); ugd->popup_one = NULL; } if (ugd->popup_validate) { evas_object_del(ugd->popup_validate); ugd->popup_validate = NULL; } elm_object_disabled_set(p->l_button, EINA_TRUE); elm_object_item_disabled_set(p->c_item[0], EINA_TRUE); if (ret) { debug_log("Start Account Validation"); ugd->popup_validate = setting_get_pb_notify(vd, _("IDS_EMAIL_POP_VALIDATING_ACCOUNT_ING"), 1, dgettext("sys_string", "IDS_COM_SK_CANCEL"), _popup_cancel_validation_cb, NULL, NULL); } else { setting_edit_validation_failed_cb(vd->ugd, FALSE); } } static void _save_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); struct viewdata *vd = (struct viewdata *)data; struct priv_data *p = NULL; EmailSettingUGD *ugd = NULL; if (vd == NULL) { debug_log("vd is NULL"); return; } ugd = vd->ugd; p = vd->priv; vd->ugd->account_id = account_data->account_id; _read_all_entries(vd); if (ugd->popup_one) { evas_object_del(ugd->popup_one); ugd->popup_one = NULL; } if (ugd->popup_validate) { evas_object_del(ugd->popup_validate); ugd->popup_validate = NULL; } if (!_check_null_field(vd)) { debug_log("Please dont leave empty fields"); ugd->popup_one = setting_get_notify(vd, dgettext("sys_string", "IDS_COM_POP_WARNING"), _("IDS_EMAIL_POP_PLEASE_FILL_ALL_THE_MANDATORY_FIELDS"), 1, dgettext("sys_string", "IDS_COM_SK_OK"), _popup_ok_cb, NULL, NULL); return; } _validate_account(vd, vd->ugd->account_id); return; } static void _onoff_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); struct viewdata *vd = (struct viewdata *)data; struct priv_data *p = vd->priv; Eina_Bool state = elm_check_state_get(obj); if (obj == p->onoff[0]) { account_data->pop_before_smtp = state; debug_log("pop before smtp %d", account_data->pop_before_smtp); } if (obj == p->onoff[1]) { account_data->outgoing_server_need_authentication = state; debug_log("smtp auth %d", account_data->outgoing_server_need_authentication); } if (obj == p->onoff[2]) { account_data->outgoing_server_use_same_authenticator = state; debug_log("same as pop3/imap4 %d", account_data->outgoing_server_use_same_authenticator); if (account_data->outgoing_server_use_same_authenticator) { /* user name */ if (p->gl_sending_user_item) { elm_object_item_disabled_set(p->gl_sending_user_item, EINA_TRUE); } /* password */ if (p->gl_sending_pw_item) { elm_object_item_disabled_set(p->gl_sending_pw_item, EINA_TRUE); } } else { /* user name */ if (p->gl_sending_user_item) { elm_object_item_disabled_set(p->gl_sending_user_item, EINA_FALSE); } /* password */ if (p->gl_sending_pw_item) { elm_object_item_disabled_set(p->gl_sending_pw_item, EINA_FALSE); } } } _update_account_info(vd); } static void _back_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); struct viewdata *vd = data; struct priv_data *p = vd->priv; Ecore_IMF_Context *imf_context = NULL; imf_context = elm_entry_imf_context_get(p->clicked_object); ecore_imf_context_input_panel_hide(imf_context); setting_back_to_prev_view(vd); } static Eina_Bool _after_save_cb(void *data) { debug_log(""); struct viewdata *vd = (struct viewdata *)data; retv_if(vd == NULL, -1); EmailSettingUGD *ugd = vd->ugd; if (ugd->edit_vc_timer) { ecore_timer_del(ugd->edit_vc_timer); ugd->edit_vc_timer = NULL; } setting_back_to_prev_view(vd); setting_get_small_notify(vd, _("IDS_EMAIL_POP_ACCOUNT_EDITED")); return TRUE; } static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); if (!data) { debug_log("data is NULL"); return; } struct viewdata *vd = (struct viewdata *)data; struct priv_data *p = vd->priv; EmailSettingUGD *ugd = vd->ugd; if (ugd->popup_one) { evas_object_del(ugd->popup_one); ugd->popup_one = NULL; } if (ugd->popup_validate) { evas_object_del(ugd->popup_validate); ugd->popup_validate = NULL; } elm_object_disabled_set(p->l_button, EINA_FALSE); elm_object_item_disabled_set(p->c_item[0], EINA_FALSE); } static void _popup_cancel_validation_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); if (!data) { debug_log("data is NULL"); return; } struct viewdata *vd = (struct viewdata *)data; struct priv_data *p = vd->priv; EmailSettingUGD *ugd = vd->ugd; if (ugd->popup_one) { evas_object_del(ugd->popup_one); ugd->popup_one = NULL; } if (ugd->popup_validate) { evas_object_del(ugd->popup_validate); ugd->popup_validate = NULL; } /*int account_id = vd->ugd->account_id;*/ vd->ugd->cancel_event = 1; elm_object_disabled_set(p->l_button, EINA_FALSE); elm_object_item_disabled_set(p->c_item[0], EINA_FALSE); /*email_engine_stop_working(account_id,p->handle);*/ } static void _backup_input_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); Evas_Object *eo = (Evas_Object *)obj; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; if (elm_object_focus_get(data)) { if (elm_entry_is_empty(obj)) elm_object_signal_emit(data, "elm,state,eraser,hide", "elm"); else elm_object_signal_emit(data, "elm,state,eraser,show", "elm"); } if (eo == p->entry_account_name) { debug_log("entry_account_name"); if (p->str_account_name) { g_free(p->str_account_name); p->str_account_name = NULL; } char *account_name = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_account_name = g_strdup(account_name); g_free(account_name); } else if (eo == p->entry_email_address) { debug_log("entry_email_address"); if (p->str_email_address) { g_free(p->str_email_address); p->str_email_address = NULL; } char *email_address = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_email_address = g_strdup(email_address); g_free(email_address); } else if (eo == p->entry_user_name) { debug_log("entry_user_name"); if (p->str_user_name) { g_free(p->str_user_name); p->str_user_name = NULL; } char *user_name = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_user_name = g_strdup(user_name); g_free(user_name); } else if (eo == p->entry_password) { debug_log("entry_password"); if (p->str_password) { g_free(p->str_password); p->str_password = NULL; } char *password = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_password = g_strdup(password); g_free(password); } else if (eo == p->entry_smtp_server) { debug_log("entry_smtp_server"); if (p->str_smtp_server) { g_free(p->str_smtp_server); p->str_smtp_server = NULL; } char *smtp_server = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_smtp_server = g_strdup(smtp_server); g_free(smtp_server); } else if (eo == p->entry_smtp_port) { debug_log("entry_smtp_port"); if (p->str_smtp_port) { g_free(p->str_smtp_port); p->str_smtp_port = NULL; } p->str_smtp_port = g_strdup(elm_entry_entry_get(eo)); } else if (eo == p->entry_incoming_server) { debug_log("entry_incoming_server"); if (p->str_incoming_server) { g_free(p->str_incoming_server); p->str_incoming_server = NULL; } char *incoming_server = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_incoming_server = g_strdup(incoming_server); g_free(incoming_server); } else if (eo == p->entry_incoming_port) { debug_log("entry_incoming_port"); if (p->str_incoming_port) { g_free(p->str_incoming_port); p->str_incoming_port = NULL; } p->str_incoming_port = g_strdup(elm_entry_entry_get(eo)); } else if (eo == p->entry_sending_username) { debug_log("entry_sending_username"); if (p->str_sending_username) { g_free(p->str_sending_username); p->str_sending_username = NULL; } char *user_name = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_sending_username = g_strdup(user_name); g_free(user_name); } else if (eo == p->entry_sending_password) { debug_log("entry_sending_password"); if (p->str_sending_password) { g_free(p->str_sending_password); p->str_sending_password = NULL; } char *password = elm_entry_markup_to_utf8(elm_entry_entry_get(eo)); p->str_sending_password = g_strdup(password); g_free(password); } else debug_warning("No corresponding item"); } static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); if (!data || !obj) { debug_log("data is NULL"); return; } if (!elm_entry_is_empty(obj)) elm_object_signal_emit(data, "elm,state,eraser,show", "elm"); elm_object_signal_emit(data, "elm,state,guidetext,hide", "elm"); } static void _entry_unfocused_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); if (!data || !obj) { debug_log("data is NULL"); return; } if (elm_entry_is_empty(obj)) elm_object_signal_emit(data, "elm,state,guidetext,show", "elm"); elm_object_signal_emit(data, "elm,state,eraser,hide", "elm"); } static void _eraser_clicked_cb(void *data, Evas_Object *obj, const char *emission, const char *source) { debug_log(""); if (!data || !obj) { debug_log("data is NULL"); return; } elm_entry_entry_set(data, ""); } static void _password_focused_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); Evas_Object *eo = (Evas_Object *)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; if (p->b_first_focus_on_pw) { elm_entry_entry_set(eo, ""); p->b_first_focus_on_pw = 0; } } static void _sending_password_focused_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); Evas_Object *eo = (Evas_Object *)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; if (p->b_first_focus_on_sending_pw) { elm_entry_entry_set(eo, ""); p->b_first_focus_on_sending_pw = 0; } } static char *_gl_secure_text_get_cb(void *data, Evas_Object *obj, const char *part) { debug_enter(); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; email_account_t *account = account_data; char buf[MAX_STR_LEN] = { 0, }; if (!g_strcmp0(part, "elm.text.1")) { switch (index) { case 1: snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SECURE_CONNECTION")); break; case 2: snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SECURE_CONNECTION")); break; default: debug_log("No corresponding label for index(%d)", index); return NULL; } return g_strdup(buf); } else if (!g_strcmp0(part, "elm.text.2")) { switch (index) { case 1: if (account->outgoing_server_secure_connection == 0) snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_OFF")); else if (account->outgoing_server_secure_connection == 1) snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SSL")); else if (account->outgoing_server_secure_connection == 2) snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_TLS")); else debug_warning("No corresponding label for index(%d) outgoing_server_secure_connection(%d)", index, account->outgoing_server_secure_connection); break; case 2: if (account->incoming_server_secure_connection == 0) snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_OFF")); else if (account->incoming_server_secure_connection == 1) snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SSL")); else if (account->incoming_server_secure_connection == 2) snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_TLS")); else debug_warning("No corresponding label for index(%d) incoming_server_secure_connection(%d)", index, account->incoming_server_secure_connection); break; default: debug_warning("No corresponding label for index(%d)", index); return NULL; } return g_strdup(buf); } return NULL; } static char *_gl_ex_secure_text_get_cb(void *data, Evas_Object *obj, const char *part) { debug_enter(); int index = (int)data; if (!g_strcmp0(part, "elm.text")) { char buf[MAX_STR_LEN] = { 0, }; switch (index) { case 0: snprintf(buf, MAX_STR_LEN, "%s", dgettext("sys_string", "IDS_COM_BODY_OFF")); break; case 1: snprintf(buf, MAX_STR_LEN, "%s", _("IDS_EMAIL_BODY_SSL")); break; case 2: snprintf(buf, MAX_STR_LEN, "%s", _("IDS_EMAIL_BODY_TLS")); break; default: debug_warning("No correspoding label"); return NULL; } return g_strdup(buf); } return NULL; } static char *_gl_server_type_text_get_cb(void *data, Evas_Object *obj, const char *part) { debug_enter(); struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; email_account_t *account = account_data; char buf[MAX_STR_LEN] = { 0, }; if (!g_strcmp0(part, "elm.text.1")) { snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_INCOMING_MAIL_SERVER_TYPE")); return g_strdup(buf); } else if (!g_strcmp0(part, "elm.text.2")) { if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_POP3")); else if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_IMAP4")); else debug_log("unsupported server type"); return g_strdup(buf); } return NULL; } static char *_gl_onoff_text_get_cb(void *data, Evas_Object *obj, const char *part) { debug_log(""); int index = (int)data; if (!g_strcmp0(part, "elm.text")) { char buf[MAX_STR_LEN] = { 0, }; if (index == 0) { snprintf(buf, sizeof(buf), "%s", N_("POP before SMTP")); } if (index == 1) { snprintf(buf, sizeof(buf), "%s", N_("SMTP Auth.")); } if (index == 2) { snprintf(buf, sizeof(buf), "%s", N_("Same as POP3/IMAP4")); } return g_strdup(buf); } return NULL; } static char *_gl_sp_text_get_cb(void *data, Evas_Object *obj, const char *part) { debug_log(""); int index = (int)data; if (!g_strcmp0(part, "elm.text")) { if (index == 1) { char buf[MAX_STR_LEN] = { 0, }; snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ACCOUNT")); return g_strdup(buf); } if (index == 2) { char buf[MAX_STR_LEN] = { 0, }; snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_OUTGOING")); return g_strdup(buf); } if (index == 3) { char buf[MAX_STR_LEN] = { 0, }; snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_INCOMING")); return g_strdup(buf); } } return NULL; } static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part) { debug_enter(); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; email_account_t *account = account_data; if (!g_strcmp0(part, "elm.icon")) { switch (index) { case 1: p->ef_account_name = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_account_name, "layout", "editfield", "title"); p->entry_account_name = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_account_name, EINA_TRUE); elm_entry_single_line_set(p->entry_account_name, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_account_name, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_account_name, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_account_name, ELM_INPUT_PANEL_LAYOUT_EMAIL); elm_entry_editable_set(p->entry_account_name, TRUE); evas_object_smart_callback_add(p->entry_account_name, "changed", _backup_input_cb, p->ef_account_name); evas_object_smart_callback_add(p->entry_account_name, "focused", _entry_focused_cb, p->ef_account_name); evas_object_smart_callback_add(p->entry_account_name, "unfocused", _entry_unfocused_cb, p->ef_account_name); evas_object_show(p->entry_account_name); elm_object_part_content_set(p->ef_account_name, "elm.swallow.content", p->entry_account_name); elm_object_part_text_set(p->ef_account_name, "elm.text", _("IDS_EMAIL_BODY_ACCOUNT_NAME")); elm_object_signal_callback_add(p->ef_account_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_account_name); evas_object_size_hint_weight_set(p->ef_account_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_account_name); if (p->str_account_name) elm_entry_entry_set(p->entry_account_name, p->str_account_name); return p->ef_account_name; case 2: p->ef_email_address = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_email_address, "layout", "editfield", "title"); p->entry_email_address = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_email_address, EINA_TRUE); elm_entry_single_line_set(p->entry_email_address, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_email_address, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_email_address, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_email_address, ELM_INPUT_PANEL_LAYOUT_EMAIL); elm_entry_editable_set(p->entry_email_address, FALSE); evas_object_smart_callback_add(p->entry_email_address, "changed", _backup_input_cb, p->ef_email_address); evas_object_smart_callback_add(p->entry_email_address, "focused", _entry_focused_cb, p->ef_email_address); evas_object_smart_callback_add(p->entry_email_address, "unfocused", _entry_unfocused_cb, p->ef_email_address); evas_object_show(p->entry_email_address); elm_object_part_content_set(p->ef_email_address, "elm.swallow.content", p->entry_email_address); elm_object_part_text_set(p->ef_email_address, "elm.text", dgettext("sys_string", "IDS_COM_BODY_EMAIL_ADDRESS")); elm_object_signal_callback_add(p->ef_email_address, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_email_address); evas_object_size_hint_weight_set(p->ef_email_address, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_email_address); if (p->str_email_address) elm_entry_entry_set(p->entry_email_address, p->str_email_address); return p->ef_email_address; case 3: p->ef_user_name = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_user_name, "layout", "editfield", "title"); p->entry_user_name = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_user_name, EINA_TRUE); elm_entry_single_line_set(p->entry_user_name, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_user_name, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_user_name, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_user_name, ELM_INPUT_PANEL_LAYOUT_EMAIL); elm_entry_editable_set(p->entry_user_name, FALSE); evas_object_smart_callback_add(p->entry_user_name, "changed", _backup_input_cb, p->ef_user_name); evas_object_smart_callback_add(p->entry_user_name, "focused", _entry_focused_cb, p->ef_user_name); evas_object_smart_callback_add(p->entry_user_name, "unfocused", _entry_unfocused_cb, p->ef_user_name); evas_object_show(p->entry_user_name); elm_object_part_content_set(p->ef_user_name, "elm.swallow.content", p->entry_user_name); elm_object_part_text_set(p->ef_user_name, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME")); elm_object_signal_callback_add(p->ef_user_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_user_name); evas_object_size_hint_weight_set(p->ef_user_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_user_name); if (p->str_user_name) elm_entry_entry_set(p->entry_user_name, p->str_user_name); return p->ef_user_name; case 4: p->ef_password = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_password, "layout", "editfield", "title"); p->entry_password = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_password, EINA_TRUE); elm_entry_single_line_set(p->entry_password, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_password, EINA_TRUE); elm_entry_password_set(p->entry_password, 1); elm_entry_cnp_mode_set(p->entry_password, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_password, ELM_INPUT_PANEL_LAYOUT_EMAIL); elm_entry_editable_set(p->entry_password, TRUE); evas_object_smart_callback_add(p->entry_password, "changed", _backup_input_cb, p->ef_password); evas_object_smart_callback_add(p->entry_password, "focused", _entry_focused_cb, p->ef_password); evas_object_smart_callback_add(p->entry_password, "unfocused", _entry_unfocused_cb, p->ef_password); evas_object_smart_callback_add(p->entry_password, "focused", _password_focused_cb, p->entry_password); evas_object_show(p->entry_password); elm_object_part_content_set(p->ef_password, "elm.swallow.content", p->entry_password); elm_object_part_text_set(p->ef_password, "elm.text", dgettext("sys_string", "IDS_COM_BODY_PASSWORD")); elm_object_signal_callback_add(p->ef_password, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_password); evas_object_size_hint_weight_set(p->ef_password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_password); if (p->str_password) elm_entry_entry_set(p->entry_password, p->str_password); return p->ef_password; case 5: p->ef_smtp_server = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_smtp_server, "layout", "editfield", "title"); p->entry_smtp_server = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_smtp_server, EINA_TRUE); elm_entry_single_line_set(p->entry_smtp_server, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_smtp_server, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_smtp_server, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_smtp_server, ELM_INPUT_PANEL_LAYOUT_EMAIL); elm_entry_editable_set(p->entry_smtp_server, TRUE); evas_object_smart_callback_add(p->entry_smtp_server, "changed", _backup_input_cb, p->ef_smtp_server); evas_object_smart_callback_add(p->entry_smtp_server, "focused", _entry_focused_cb, p->ef_smtp_server); evas_object_smart_callback_add(p->entry_smtp_server, "unfocused", _entry_unfocused_cb, p->ef_smtp_server); evas_object_show(p->entry_smtp_server); elm_object_part_content_set(p->ef_smtp_server, "elm.swallow.content", p->entry_smtp_server); elm_object_part_text_set(p->ef_smtp_server, "elm.text", _("IDS_EMAIL_BODY_OUTGOING_SERVER")); elm_object_signal_callback_add(p->ef_smtp_server, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_smtp_server); evas_object_size_hint_weight_set(p->ef_smtp_server, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_smtp_server); if (p->str_smtp_server) elm_entry_entry_set(p->entry_smtp_server, p->str_smtp_server); return p->ef_smtp_server; case 6: p->ef_smtp_port = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_smtp_port, "layout", "editfield", "title"); p->entry_smtp_port = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_smtp_port, EINA_TRUE); elm_entry_single_line_set(p->entry_smtp_port, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_smtp_port, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_smtp_port, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_smtp_port, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY); elm_entry_editable_set(p->entry_smtp_port, TRUE); evas_object_smart_callback_add(p->entry_smtp_port, "changed", _backup_input_cb, p->ef_smtp_port); evas_object_smart_callback_add(p->entry_smtp_port, "focused", _entry_focused_cb, p->ef_smtp_port); evas_object_smart_callback_add(p->entry_smtp_port, "unfocused", _entry_unfocused_cb, p->ef_smtp_port); evas_object_show(p->entry_smtp_port); elm_object_part_content_set(p->ef_smtp_port, "elm.swallow.content", p->entry_smtp_port); elm_object_part_text_set(p->ef_smtp_port, "elm.text", _("IDS_EMAIL_BODY_OUTGOING_PORT")); elm_object_signal_callback_add(p->ef_smtp_port, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_smtp_port); evas_object_size_hint_weight_set(p->ef_smtp_port, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_smtp_port); if (p->str_smtp_port) elm_entry_entry_set(p->entry_smtp_port, p->str_smtp_port); return p->ef_smtp_port; case 7: p->ef_incoming_server = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_incoming_server, "layout", "editfield", "title"); p->entry_incoming_server = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_incoming_server, EINA_TRUE); elm_entry_single_line_set(p->entry_incoming_server, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_incoming_server, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_incoming_server, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_incoming_server, ELM_INPUT_PANEL_LAYOUT_EMAIL); elm_entry_editable_set(p->entry_incoming_server, TRUE); evas_object_smart_callback_add(p->entry_incoming_server, "changed", _backup_input_cb, p->ef_incoming_server); evas_object_smart_callback_add(p->entry_incoming_server, "focused", _entry_focused_cb, p->ef_incoming_server); evas_object_smart_callback_add(p->entry_incoming_server, "unfocused", _entry_unfocused_cb, p->ef_incoming_server); evas_object_show(p->entry_incoming_server); elm_object_part_content_set(p->ef_incoming_server, "elm.swallow.content", p->entry_incoming_server); if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { elm_object_part_text_set(p->ef_incoming_server, "elm.text", _("IDS_EMAIL_BODY_IMAP4_SERVER")); } else if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { elm_object_part_text_set(p->ef_incoming_server, "elm.text", _("IDS_EMAIL_BODY_POP3_SERVER")); } else { elm_object_part_text_set(p->ef_incoming_server, "elm.text", _("IDS_EMAIL_BODY_INCOMING_SERVER")); } elm_object_signal_callback_add(p->ef_incoming_server, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_incoming_server); evas_object_size_hint_weight_set(p->ef_incoming_server, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_incoming_server); if (p->str_incoming_server) elm_entry_entry_set(p->entry_incoming_server, p->str_incoming_server); return p->ef_incoming_server; case 8: p->ef_incoming_port = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_incoming_port, "layout", "editfield", "title"); p->entry_incoming_port = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_incoming_port, EINA_TRUE); elm_entry_single_line_set(p->entry_incoming_port, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_incoming_port, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_incoming_port, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_incoming_port, ELM_INPUT_PANEL_LAYOUT_NUMBERONLY); elm_entry_editable_set(p->entry_incoming_port, TRUE); evas_object_smart_callback_add(p->entry_incoming_port, "changed", _backup_input_cb, p->ef_incoming_port); evas_object_smart_callback_add(p->entry_incoming_port, "focused", _entry_focused_cb, p->ef_incoming_port); evas_object_smart_callback_add(p->entry_incoming_port, "unfocused", _entry_unfocused_cb, p->ef_incoming_port); evas_object_show(p->entry_incoming_port); elm_object_part_content_set(p->ef_incoming_port, "elm.swallow.content", p->entry_incoming_port); if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { elm_object_part_text_set(p->ef_incoming_port, "elm.text", _("IDS_EMAIL_BODY_IMAP4_PORT")); } else if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { elm_object_part_text_set(p->ef_incoming_port, "elm.text", _("IDS_EMAIL_BODY_POP3_PORT")); } else { elm_object_part_text_set(p->ef_incoming_port, "elm.text", _("IDS_EMAIL_BODY_INCOMING_PORT")); } elm_object_signal_callback_add(p->ef_incoming_port, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_incoming_port); evas_object_size_hint_weight_set(p->ef_incoming_port, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_incoming_port); if (p->str_incoming_port) elm_entry_entry_set(p->entry_incoming_port, p->str_incoming_port); return p->ef_incoming_port; case 9: p->ef_sending_username = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_sending_username, "layout", "editfield", "title"); p->entry_sending_username = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_sending_username, EINA_TRUE); elm_entry_single_line_set(p->entry_sending_username, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_sending_username, EINA_TRUE); elm_entry_cnp_mode_set(p->entry_sending_username, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_sending_username, ELM_INPUT_PANEL_LAYOUT_EMAIL); evas_object_smart_callback_add(p->entry_sending_username, "changed", _backup_input_cb, p->ef_sending_username); evas_object_smart_callback_add(p->entry_sending_username, "focused", _entry_focused_cb, p->ef_sending_username); evas_object_smart_callback_add(p->entry_sending_username, "unfocused", _entry_unfocused_cb, p->ef_sending_username); evas_object_show(p->entry_sending_username); elm_object_part_content_set(p->ef_sending_username, "elm.swallow.content", p->entry_sending_username); elm_object_part_text_set(p->ef_sending_username, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME")); elm_object_signal_callback_add(p->ef_sending_username, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_sending_username); evas_object_size_hint_weight_set(p->ef_sending_username, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_sending_username); if (p->str_sending_username) elm_entry_entry_set(p->entry_sending_username, p->str_sending_username); return p->ef_sending_username; case 10: p->ef_sending_password = elm_layout_add(p->genlist); elm_layout_theme_set(p->ef_sending_password, "layout", "editfield", "title"); p->entry_sending_password = elm_entry_add(p->genlist); elm_entry_scrollable_set(p->entry_sending_password, EINA_TRUE); elm_entry_single_line_set(p->entry_sending_password, EINA_TRUE); elm_entry_input_panel_return_key_disabled_set(p->entry_sending_password, EINA_TRUE); elm_entry_password_set(p->entry_sending_password, 1); elm_entry_cnp_mode_set(p->entry_sending_password, ELM_CNP_MODE_PLAINTEXT); elm_entry_input_panel_layout_set(p->entry_sending_password, ELM_INPUT_PANEL_LAYOUT_EMAIL); evas_object_smart_callback_add(p->entry_sending_password, "changed", _backup_input_cb, p->ef_sending_password); evas_object_smart_callback_add(p->entry_sending_password, "focused", _entry_focused_cb, p->ef_sending_password); evas_object_smart_callback_add(p->entry_sending_password, "unfocused", _entry_unfocused_cb, p->ef_sending_password); evas_object_smart_callback_add(p->entry_sending_password, "focused", _sending_password_focused_cb, p->entry_sending_password); evas_object_show(p->entry_sending_password); elm_object_part_content_set(p->ef_sending_password, "elm.swallow.content", p->entry_sending_password); elm_object_part_text_set(p->ef_sending_password, "elm.text", dgettext("sys_string", "IDS_COM_BODY_PASSWORD")); elm_object_signal_callback_add(p->ef_sending_password, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_sending_password); evas_object_size_hint_weight_set(p->ef_sending_password, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(p->ef_sending_password); if (p->str_sending_password) elm_entry_entry_set(p->entry_sending_password, p->str_sending_password); return p->ef_sending_password; default: debug_warning("No corresponding item for index(%d)", index); return NULL; } } return NULL; } static Evas_Object *_gl_ex_sending_secure_content_get_cb(void *data, Evas_Object *obj, const char *part) { debug_enter(); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; email_account_t *account = account_data; if (!g_strcmp0(part, "elm.icon")) { Evas_Object *radio = elm_radio_add(p->genlist); elm_radio_group_add(radio, p->sending_secure_radio_grp); elm_radio_state_value_set(radio, index); if (index == 0) { elm_radio_value_set(p->sending_secure_radio_grp, account->outgoing_server_secure_connection); } return radio; } return NULL; } static Evas_Object *_gl_ex_incoming_secure_content_get_cb(void *data, Evas_Object *obj, const char *part) { debug_log(""); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; email_account_t *account = account_data; if (!g_strcmp0(part, "elm.icon")) { Evas_Object *radio = elm_radio_add(p->genlist); elm_radio_group_add(radio, p->incoming_secure_radio_grp); elm_radio_state_value_set(radio, index); if (index == 0) { elm_radio_value_set(p->incoming_secure_radio_grp, account->incoming_server_secure_connection); } return radio; } return NULL; } static Evas_Object *_gl_onoff_content_get_cb(void *data, Evas_Object *obj, const char *part) { debug_log(""); int index = (int)data; struct viewdata *vd = g_vd; EmailSettingUGD *ugd = vd->ugd; struct priv_data *p = vd->priv; if (!g_strcmp0(part, "elm.icon")) { Evas_Object *check = elm_check_add(ugd->navi_bar); elm_object_style_set(check, "on&off"); evas_object_smart_callback_add(check, "changed", _onoff_cb, vd); evas_object_propagate_events_set(check, EINA_FALSE); if (index == 0) { elm_check_state_set(check, account_data->pop_before_smtp); p->onoff[index] = check; } if (index == 1) { elm_check_state_set(check, account_data->outgoing_server_need_authentication); p->onoff[index] = check; } if (index == 2) { elm_check_state_set(check, account_data->outgoing_server_use_same_authenticator); p->onoff[index] = check; } return check; } return NULL; } static void _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; Elm_Object_Item *item = (Elm_Object_Item *)event_info; elm_genlist_item_selected_set(item, EINA_FALSE); switch (index) { case 1: p->clicked_object = p->entry_account_name; break; case 2: p->clicked_object = p->entry_email_address; break; case 3: p->clicked_object = p->entry_user_name; break; case 4: p->clicked_object = p->entry_password; break; case 5: p->clicked_object = p->entry_smtp_server; break; case 6: p->clicked_object = p->entry_smtp_port; break; case 7: p->clicked_object = p->entry_incoming_server; break; case 8: p->clicked_object = p->entry_incoming_port; break; case 9: p->clicked_object = p->entry_sending_username; break; case 10: p->clicked_object = p->entry_sending_password; break; default: p->clicked_object = NULL; debug_warning("No corresponding item"); } } static void _gl_secure_sel_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; Ecore_IMF_Context *imf_context = NULL; imf_context = elm_entry_imf_context_get(p->clicked_object); if (imf_context) ecore_imf_context_input_panel_hide(imf_context); elm_object_focus_set(p->clicked_object, EINA_FALSE); Elm_Object_Item *item = (Elm_Object_Item *)event_info; elm_genlist_item_selected_set(item, EINA_FALSE); if (!elm_genlist_item_expanded_get(item)) { elm_genlist_item_expanded_set(item, 1); } else { elm_genlist_item_expanded_set(item, 0); } } static void _gl_ex_sending_secure_sel_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; email_account_t *account = account_data; int sel_radio = 0; Elm_Object_Item *item = (Elm_Object_Item *)event_info; elm_genlist_item_selected_set(item, EINA_FALSE); sel_radio = elm_radio_value_get(p->sending_secure_radio_grp); if (sel_radio == index) return; switch (index) { case 0: { account->outgoing_server_secure_connection = 0; /* Off */ break; } case 1: { account->outgoing_server_secure_connection = 1; /* SSL */ break; } case 2: { account->outgoing_server_secure_connection = 2; /* TLS */ break; } } elm_radio_value_set(p->sending_secure_radio_grp, index); elm_genlist_item_update(p->gl_ex_item1); } static void _gl_ex_incoming_secure_sel_cb(void *data, Evas_Object *obj, void *event_info) { debug_enter(); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; email_account_t *account = account_data; int sel_radio = 0; Elm_Object_Item *item = (Elm_Object_Item *)event_info; elm_genlist_item_selected_set(item, EINA_FALSE); sel_radio = elm_radio_value_get(p->incoming_secure_radio_grp); if (sel_radio == index) return; switch (index) { case 0: account->incoming_server_secure_connection = 0; /* Off */ break; case 1: account->incoming_server_secure_connection = 1; /* SSL */ break; case 2: account->incoming_server_secure_connection = 2; /* TLS */ break; } elm_radio_value_set(p->incoming_secure_radio_grp, index); elm_genlist_item_update(p->gl_ex_item2); } static void _gl_onoff_sel_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); int index = (int)data; struct viewdata *vd = g_vd; struct priv_data *p = vd->priv; Elm_Object_Item *item = (Elm_Object_Item *)event_info; elm_genlist_item_selected_set(item, EINA_FALSE); switch (index) { case 0: account_data->pop_before_smtp = !account_data->pop_before_smtp; elm_check_state_set(p->onoff[0], account_data->pop_before_smtp); debug_log("pop before smtp %d", account_data->pop_before_smtp); break; case 1: account_data->outgoing_server_need_authentication = !account_data->outgoing_server_need_authentication; elm_check_state_set(p->onoff[1], account_data->outgoing_server_need_authentication); debug_log("smtp auth %d", account_data->outgoing_server_need_authentication); break; case 2: account_data->outgoing_server_use_same_authenticator = !account_data->outgoing_server_use_same_authenticator; elm_check_state_set(p->onoff[2], account_data->outgoing_server_use_same_authenticator); debug_log("same as pop3/imap4 %d", account_data->outgoing_server_use_same_authenticator); if (account_data->outgoing_server_use_same_authenticator) { /* user name */ if (p->gl_sending_user_item) { elm_object_item_disabled_set(p->gl_sending_user_item, EINA_TRUE); } /* password */ if (p->gl_sending_pw_item) { elm_object_item_disabled_set(p->gl_sending_pw_item, EINA_TRUE); } } else { /* user name */ if (p->gl_sending_user_item) { elm_object_item_disabled_set(p->gl_sending_user_item, EINA_FALSE); } /* password */ if (p->gl_sending_pw_item) { elm_object_item_disabled_set(p->gl_sending_pw_item, EINA_FALSE); } } break; } _update_account_info(vd); } static void _gl_exp_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); Elm_Object_Item *it = event_info; struct viewdata *vd = (struct viewdata *)data; struct priv_data *p = vd->priv; int i = 0; Ecore_IMF_Context *imf_context = NULL; imf_context = elm_entry_imf_context_get(p->clicked_object); if (imf_context) ecore_imf_context_input_panel_hide(imf_context); elm_object_focus_set(p->clicked_object, EINA_FALSE); /* sending security */ if (it == p->gl_ex_item1) { for (i = 0; i < 3; i++) { elm_genlist_item_append(p->genlist, &(p->itc_ex_sending), (void *)i, it, ELM_GENLIST_ITEM_NONE, _gl_ex_sending_secure_sel_cb, (void *)i); } } /* incoming security */ if (it == p->gl_ex_item2) { for (i = 0; i < 3; i++) { elm_genlist_item_append(p->genlist, &(p->itc_ex_incoming), (void *)i, it, ELM_GENLIST_ITEM_NONE, _gl_ex_incoming_secure_sel_cb, (void *)i); } } } static void _gl_con_cb(void *data, Evas_Object *obj, void *event_info) { debug_log(""); Elm_Object_Item *item = event_info; elm_genlist_item_subitems_clear(item); } /* EOF */