From 62818e9f6eb3f63d8deeda489bbe007760612c11 Mon Sep 17 00:00:00 2001 From: Sungbok Park Date: Mon, 3 Sep 2012 14:12:51 +0900 Subject: [PATCH] add setting --- CMakeLists.txt | 1 + common/include/email-common-types.h | 28 +- common/include/email-debug.h | 34 +- common/include/email-engine.h | 8 + common/include/email-utils.h | 1 + common/src/email-engine.c | 160 ++ common/src/email-utils.c | 37 + composer/CMakeLists.txt | 3 +- composer/include/email-composer-type.h | 2 +- composer/include/email-composer.h | 1 + composer/src/email-composer-attachment.c | 2 - composer/src/email-composer-callback.c | 35 +- composer/src/email-composer-contents.c | 7 +- composer/src/email-composer-predictive-search.c | 3 + composer/src/email-composer-recipient.c | 1 + composer/src/email-composer-util.c | 27 +- composer/src/email-composer.c | 116 +- images/menu_Email.png | Bin 0 -> 7537 bytes packaging/org.tizen.email.spec | 52 +- po/CMakeLists.txt | 3 +- po/ar.po | 2 +- po/az.po | 1392 ++++++++++++++++ po/bg.po | 2 +- po/ca.po | 2 +- po/da.po | 36 +- po/de_DE.po | 6 +- po/el_GR.po | 6 +- po/en.po | 4 +- po/{id.po => en_PH.po} | 866 +++++----- po/en_US.po | 2 +- po/es_ES.po | 8 +- po/es_US.po | 1392 ++++++++++++++++ po/{no.po => et.po} | 866 +++++----- po/eu.po | 1392 ++++++++++++++++ po/fi.po | 4 +- po/fr_CA.po | 1392 ++++++++++++++++ po/fr_FR.po | 4 +- po/{vi.po => ga.po} | 884 +++++----- po/gl.po | 1392 ++++++++++++++++ po/he.po | 1392 ---------------- po/hi.po | 88 +- po/hr.po | 2 +- po/hu.po | 2 +- po/hy.po | 1392 ++++++++++++++++ po/is.po | 1392 ++++++++++++++++ po/it_IT.po | 4 +- po/ja_JP.po | 20 +- po/ka.po | 1392 ++++++++++++++++ po/kk.po | 1392 ++++++++++++++++ po/ko_KR.po | 6 +- po/lt.po | 2 +- po/mk.po | 1392 ++++++++++++++++ po/pt_BR.po | 1392 ++++++++++++++++ po/pt_PT.po | 6 +- po/ru_RU.po | 6 +- po/sr.po | 2 +- po/th.po | 1392 ---------------- po/uk.po | 8 +- po/zh_CN.po | 10 +- po/{ms.po => zh_SG.po} | 894 +++++----- setting/CMakeLists.txt | 71 + setting/include/email-setting-account-set.h | 28 + setting/include/email-setting-defines.h | 33 + setting/include/email-setting-utils.h | 61 + setting/include/email-setting-view.h | 66 + setting/include/email-setting.h | 151 ++ setting/include/email-view-account-edit.h | 28 + setting/include/email-view-account-options.h | 26 + setting/include/email-view-account-setup.h | 28 + setting/include/email-view-initial.h | 26 + setting/include/email-view-mailbox-mapping.h | 26 + setting/include/email-view-manual-setup.h | 28 + setting/include/email-view-setting.h | 26 + setting/include/email-view-sp-select.h | 26 + setting/include/email-view-sync-schedule.h | 28 + setting/include/email-view-sync-setup.h | 28 + setting/src/email-setting-account-set.c | 629 +++++++ setting/src/email-setting-utils.c | 723 ++++++++ setting/src/email-setting-view.c | 324 ++++ setting/src/email-setting.c | 804 +++++++++ setting/src/email-view-account-edit.c | 2022 +++++++++++++++++++++++ setting/src/email-view-account-options.c | 1757 ++++++++++++++++++++ setting/src/email-view-account-setup.c | 1479 +++++++++++++++++ setting/src/email-view-initial.c | 390 +++++ setting/src/email-view-mailbox-mapping.c | 309 ++++ setting/src/email-view-manual-setup.c | 1696 +++++++++++++++++++ setting/src/email-view-setting.c | 971 +++++++++++ setting/src/email-view-sp-select.c | 325 ++++ setting/src/email-view-sync-schedule.c | 1139 +++++++++++++ setting/src/email-view-sync-setup.c | 1174 +++++++++++++ setting/theme/email-setting-theme-macro.edc | 1215 ++++++++++++++ setting/theme/email-setting-theme.edc | 1840 +++++++++++++++++++++ 92 files changed, 35094 insertions(+), 4742 deletions(-) create mode 100755 images/menu_Email.png create mode 100755 po/az.po rename po/{id.po => en_PH.po} (61%) create mode 100755 po/es_US.po rename po/{no.po => et.po} (61%) create mode 100755 po/eu.po create mode 100755 po/fr_CA.po rename po/{vi.po => ga.po} (57%) create mode 100755 po/gl.po delete mode 100755 po/he.po create mode 100755 po/hy.po create mode 100755 po/is.po create mode 100755 po/ka.po create mode 100755 po/kk.po create mode 100755 po/mk.po create mode 100755 po/pt_BR.po delete mode 100755 po/th.po rename po/{ms.po => zh_SG.po} (61%) create mode 100755 setting/CMakeLists.txt create mode 100755 setting/include/email-setting-account-set.h create mode 100755 setting/include/email-setting-defines.h create mode 100755 setting/include/email-setting-utils.h create mode 100755 setting/include/email-setting-view.h create mode 100755 setting/include/email-setting.h create mode 100755 setting/include/email-view-account-edit.h create mode 100755 setting/include/email-view-account-options.h create mode 100755 setting/include/email-view-account-setup.h create mode 100755 setting/include/email-view-initial.h create mode 100755 setting/include/email-view-mailbox-mapping.h create mode 100755 setting/include/email-view-manual-setup.h create mode 100755 setting/include/email-view-setting.h create mode 100755 setting/include/email-view-sp-select.h create mode 100755 setting/include/email-view-sync-schedule.h create mode 100755 setting/include/email-view-sync-setup.h create mode 100755 setting/src/email-setting-account-set.c create mode 100755 setting/src/email-setting-utils.c create mode 100755 setting/src/email-setting-view.c create mode 100755 setting/src/email-setting.c create mode 100755 setting/src/email-view-account-edit.c create mode 100755 setting/src/email-view-account-options.c create mode 100755 setting/src/email-view-account-setup.c create mode 100755 setting/src/email-view-initial.c create mode 100755 setting/src/email-view-mailbox-mapping.c create mode 100755 setting/src/email-view-manual-setup.c create mode 100755 setting/src/email-view-setting.c create mode 100755 setting/src/email-view-sp-select.c create mode 100755 setting/src/email-view-sync-schedule.c create mode 100755 setting/src/email-view-sync-setup.c create mode 100755 setting/theme/email-setting-theme-macro.edc create mode 100755 setting/theme/email-setting-theme.edc diff --git a/CMakeLists.txt b/CMakeLists.txt index e27a265..8212d10 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,5 +21,6 @@ ADD_DEFINITIONS("-DIMGDIR=\"${IMGDIR}\"") # Add your submodule directory name ADD_SUBDIRECTORY(common) +ADD_SUBDIRECTORY(setting) ADD_SUBDIRECTORY(composer) ADD_SUBDIRECTORY(po) diff --git a/common/include/email-common-types.h b/common/include/email-common-types.h index 8a06658..b531cdf 100755 --- a/common/include/email-common-types.h +++ b/common/include/email-common-types.h @@ -27,9 +27,10 @@ /* define bundle key */ #define EMAIL_BUNDLE_KEY_ACCOUNT_ID "ACCOUNT_ID" -#define EMAIL_BUNDLE_KEY_MAILBOX "MAILBOX" +#define EMAIL_BUNDLE_KEY_MAILBOX "MAILBOX_ID" #define EMAIL_BUNDLE_KEY_SAVE_ALL "SAVE_ALL" #define EMAIL_BUNDLE_KEY_CANCEL_ALL "CANCEL_ALL" +#define EMAIL_BUNDLE_KEY_VIEW_TYPE "VIEW_TYPE" #define EMAIL_BUNDLE_KEY_RUN_TYPE "RUN_TYPE" #define EMAIL_BUNDLE_KEY_MAIL_ID "MAIL_ID" #define EMAIL_BUNDLE_KEY_TO "TO" @@ -38,9 +39,26 @@ #define EMAIL_BUNDLE_KEY_SUBJECT "SUBJECT" #define EMAIL_BUNDLE_KEY_BODY "BODY" #define EMAIL_BUNDLE_KEY_ATTACHMENT "ATTACHMENT" +#define EMAIL_BUNDLE_KEY_ESP_NAME "ESP_NAME" +#define EMAIL_BUNDLE_KEY_INITIAL_RUN "INITIAL_RUN" +#define EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT "REFRESH_ACCOUNT" #define EMAIL_BUNDLE_KEY_VIDEO_PLAYER_LAUNCH_APP "launching_application" +/* define bundle value */ +#define EMAIL_BUNDLE_VAL_VIEW_SETTING_MAIN "main-view" +#define EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP "first-setup" +#define EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_EDIT "account-edit" +#define EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD "account-add" +#define EMAIL_BUNDLE_VAL_VIEW_SELECT_ACCOUNT "select-account" + +#define EMAIL_BUNDLE_VAL_ESP_GMAIL "gmail" +#define EMAIL_BUNDLE_VAL_ESP_YAHOO "yahoomail" +#define EMAIL_BUNDLE_VAL_ESP_AOL "aol" +#define EMAIL_BUNDLE_VAL_ESP_HOTMAIL "hotmail" +#define EMAIL_BUNDLE_VAL_ESP_MSN "msn" +#define EMAIL_BUNDLE_VAL_ESP_OTHERS "others" + typedef enum { RUN_TYPE_UNKNOWN = -1, RUN_COMPOSER_NEW, /*< Specific new type. this type is used to create new email */ @@ -52,6 +70,14 @@ typedef enum { RUN_TYPE_MAX } EmailRunType; +typedef struct { + int is_preset_account; + int index_color; + int show_images; + int send_read_report; + int pop3_deleting_option; +} account_user_data_t; + #endif /* _EMAIL_COMMON_TYPES_H_ */ /* EOF */ diff --git a/common/include/email-debug.h b/common/include/email-debug.h index 2114a91..59120cc 100755 --- a/common/include/email-debug.h +++ b/common/include/email-debug.h @@ -33,7 +33,7 @@ typedef enum { #undef debug_trace #undef debug_log -#undef debug_assert +#undef debug_error #undef debug_warning #undef debug_critical #undef debug_time @@ -54,17 +54,17 @@ typedef enum { #include "dlog.h" -#define MODULE_TAG "email_svc" +#define MODULE_TAG "email_app" -#define debug_trace(fmt, args...) SLOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) -#define debug_log(fmt, args...) SLOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) -#define debug_assert(fmt, args...) SLOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) -#define debug_warning(fmt, args...) SLOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] * Warning * " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) -#define debug_critical(fmt, args...) SLOG(LOG_ERROR, MODULE_TAG, "[%s:%s():#%d] * Critical * " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) -#define debug_enter() SLOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] *ENTER*" , (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__) -#define debug_leave() SLOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] *LEAVE*" , (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__) +#define debug_log(fmt, args...) LOG(LOG_VERBOSE, MODULE_TAG, "[%s:%s():#%d] " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) +#define debug_enter() LOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] *ENTER*" , (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__) +#define debug_leave() LOG(LOG_DEBUG, MODULE_TAG, "[%s:%s():#%d] *LEAVE*" , (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__) +#define debug_trace(fmt, args...) LOG(LOG_INFO, MODULE_TAG, "[%s:%s():#%d] " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) +#define debug_warning(fmt, args...) LOG(LOG_WARN, MODULE_TAG, "[%s:%s():#%d] < Warning > " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) +#define debug_error(fmt, args...) LOG(LOG_ERROR, MODULE_TAG, "[%s:%s():#%d] << Error >> " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) +#define debug_critical(fmt, args...) LOG(LOG_FATAL, MODULE_TAG, "[%s:%s():#%d] <<< Fatal >>> " fmt, (rindex(__FILE__, '/') ? rindex(__FILE__, '/')+1 : __FILE__), __func__, __LINE__, ##args) -# define debug_time() \ +#define debug_time() \ do { \ char *p = NULL; \ GET_FILE_NAME(p); \ @@ -75,7 +75,7 @@ typedef enum { #define debug_trace() #define debug_log(fmt, args...) -#define debug_assert(fmt, args...) +#define debug_error(fmt, args...) #define debug_warning(fmt, args...) #define debug_critical(fmt, args...) #define debug_time() @@ -114,7 +114,7 @@ typedef enum { #define RETURN_IF_FAIL(expr) \ do { \ if (!(expr)) { \ - debug_assert("expr : (%s) failed", #expr); \ + debug_error("expr : (%s) failed", #expr); \ return; \ } \ } while (0) @@ -122,7 +122,7 @@ typedef enum { #define RETURN_VAL_IF_FAIL(expr, val) \ do { \ if (!(expr)) { \ - debug_assert("expr : (%s) failed", #expr); \ + debug_error("expr : (%s) failed", #expr); \ return (val); \ } \ } while (0) @@ -132,25 +132,29 @@ typedef enum { debug_warning(fmt, ##arg); \ } \ } while (0) + #define ret_if(expr) do { \ if (expr) { \ return; \ } \ } while (0) + #define retv_if(expr, val) do { \ if (expr) { \ return (val); \ } \ } while (0) + #define retm_if(expr, fmt, arg...) do { \ if (expr) { \ - debug_assert(fmt, ##arg); \ + debug_error(fmt, ##arg); \ return; \ } \ } while (0) + #define retvm_if(expr, val, fmt, arg...) do { \ if (expr) { \ - debug_assert(fmt, ##arg); \ + debug_error(fmt, ##arg); \ return (val); \ } \ } while (0) diff --git a/common/include/email-engine.h b/common/include/email-engine.h index 9375880..0143c85 100755 --- a/common/include/email-engine.h +++ b/common/include/email-engine.h @@ -34,10 +34,18 @@ G_BEGIN_DECLS gboolean email_engine_initialize(void); void email_engine_finalize(void); +gboolean email_engine_add_account_with_validation(email_account_t *_account, int *account_id, unsigned *handle, int *error_code); +gboolean email_engine_add_account(email_account_t *_account, int *account_id); +gboolean email_engine_update_account_with_validation(gint account_id, email_account_t *_account); +gboolean email_engine_update_account(gint account_id, email_account_t *_account); +gboolean email_engine_delete_account(gint account_id); +gboolean email_engine_get_account_list(int *count, email_account_t **_account_list); +gboolean email_engine_free_account_list(email_account_t **_account_list, int count); gboolean email_engine_get_account_full_data(int acctid, email_account_t **account); gboolean email_engine_get_default_account(gint *account_id); gboolean email_engine_set_default_account(gint account_id); +gboolean email_engine_sync_folder(gint account_id, int mailbox_id, unsigned *handle); void email_engine_stop_working(gint account_id, unsigned handle); gboolean email_engine_delete_mail(gint account_id, int mailbox_id, gint mail_id, int sync); diff --git a/common/include/email-utils.h b/common/include/email-utils.h index cf2324e..7c0409f 100755 --- a/common/include/email-utils.h +++ b/common/include/email-utils.h @@ -63,6 +63,7 @@ void email_save_file(const gchar *path, const gchar *buf, gsize len); gchar *email_get_buff_from_file(const gchar *path, guint max_kbyte); /* g_free(). */ gchar *email_get_file_size_string(guint64 size); /* g_free(). */ guint64 email_get_file_size(const gchar *path); +gboolean email_get_address_validation(const char *address); char *email_get_date_text(const char *locale, char *skeleton, void *time); diff --git a/common/src/email-engine.c b/common/src/email-engine.c index 91d8eb9..0a09b39 100755 --- a/common/src/email-engine.c +++ b/common/src/email-engine.c @@ -90,6 +90,138 @@ void email_engine_finalize(void) } } +gboolean email_engine_add_account(email_account_t *_account, int *account_id) +{ + debug_log(""); + RETURN_VAL_IF_FAIL(_account != NULL, FALSE); + + int err = 0; + + err = email_add_account(_account); + if (err != EMAIL_ERROR_NONE) { + debug_critical("Fail to Create Account"); + debug_critical("Error code(%d)", err); + return FALSE; + } + debug_log("Create Succeed"); + *account_id = _account->account_id; + debug_log("account id is %d", _account->account_id); + + return TRUE; +} + +gboolean email_engine_add_account_with_validation(email_account_t *_account, int *account_id, unsigned *handle, int *error_code) +{ + debug_log(""); + RETURN_VAL_IF_FAIL(_account != NULL, FALSE); + + int err = 0; + + err = email_add_account_with_validation(_account, handle); + if (error_code != NULL) + *error_code = err; + if (err != EMAIL_ERROR_NONE) { + debug_critical("Fail to Create Account with validation"); + debug_critical("Error code(%d)", err); + return FALSE; + } + + debug_log("Create Succeed"); + *account_id = _account->account_id; + debug_log("account id is %d", _account->account_id); + + return TRUE; +} + +gboolean email_engine_update_account(gint account_id, email_account_t *_account) +{ + debug_log(""); + RETURN_VAL_IF_FAIL(account_id != 0, FALSE); + RETURN_VAL_IF_FAIL(_account != NULL, FALSE); + + int err = 0; + + err = email_update_account(account_id, _account); + if (err == EMAIL_ERROR_NONE) { + debug_log("email_update_account successful"); + return TRUE; + } else { + debug_critical("Failed to update account Err(%d)", err); + return FALSE; + } +} + +gboolean email_engine_update_account_with_validation(gint account_id, email_account_t *_account) +{ + debug_log(""); + RETURN_VAL_IF_FAIL(account_id != 0, FALSE); + RETURN_VAL_IF_FAIL(_account != NULL, FALSE); + + int err = 0; + + err = email_update_account_with_validation(account_id, _account); + if (err == EMAIL_ERROR_NONE) { + debug_log("email_update_account_with_validation successful"); + return TRUE; + } else { + debug_critical("Failed to update account with validation Err(%d)", err); + return FALSE; + } +} + +gboolean email_engine_delete_account(gint account_id) +{ + debug_log(""); + RETURN_VAL_IF_FAIL(account_id != 0, FALSE); + + int err = 0; + + err = email_delete_account(account_id); + if (err == EMAIL_ERROR_NONE) { + debug_log("Account is Successfully deleted"); + return TRUE; + } else { + debug_critical("Failed to delete account Err(%d)", err); + return FALSE; + } + +} + +gboolean email_engine_get_account_list(int *count, email_account_t **_account_list) +{ + debug_log(""); + int i, err = 0; + + err = email_get_account_list(_account_list, count); + if (err != EMAIL_ERROR_NONE) { + debug_critical("email_get_account_list error Err(%d)", err); + return FALSE; + } + debug_log("valid account count :(%d)", *count); + + for (i = 0; i < *count; i++) { + debug_log("%2d) %-15s %-30s\n", (*_account_list)[i].account_id, (*_account_list)[i].account_name, (*_account_list)[i].user_email_address); + } + debug_log("Get All Account List"); + + return TRUE; +} + +gboolean email_engine_free_account_list(email_account_t **_account_list, int count) +{ + debug_log(""); + int err = 0; + + err = email_free_account(_account_list, count); + if (err != EMAIL_ERROR_NONE) { + debug_critical("Fail to free account list Err(%d)", err); + return FALSE; + } else { + debug_log("Success to free account list"); + return TRUE; + } +} + gboolean email_engine_get_account_full_data(int acctid, email_account_t **account) { debug_log(""); @@ -180,6 +312,34 @@ gboolean email_engine_get_default_account(gint *account_id) return TRUE; } +gboolean email_engine_sync_folder(gint account_id, int mailbox_id, unsigned *handle) +{ + debug_log(""); + + debug_log("account id (%d)", account_id); + + gboolean res = FALSE; + unsigned email_handle = 0; + int err = 0; + + err = email_sync_header(account_id, mailbox_id, &email_handle); + debug_critical("email_handle: %d", email_handle); + + if (err != EMAIL_ERROR_NONE) { + debug_critical("fail to sync current folder - err (%d)", err); + res = FALSE; + } else { + res = TRUE; + } + + if (handle != NULL) { + debug_log("email_handle for folder sync: %d", email_handle); + *handle = email_handle; + } + + return res; +} + void email_engine_stop_working(gint account_id, unsigned handle) { debug_log(""); diff --git a/common/src/email-utils.c b/common/src/email-utils.c index 05a3902..741a5d1 100755 --- a/common/src/email-utils.c +++ b/common/src/email-utils.c @@ -294,6 +294,43 @@ guint64 email_get_file_size(const gchar *path) return size; } +#define EMAIL_ACCOUNT_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+[.])*[a-z0-9!#$%&'*+/=?^_`{|}~-]+" +#define EMAIL_DOMAIN_RGEX "([a-z0-9!#$%&'*+/=?^_`{|}~-]+[.])+[a-z0-9!#$%&'*+/=?^_`{|}~-]+" +#define EMAIL_ADDR_RGEX EMAIL_ACCOUNT_RGEX"@"EMAIL_DOMAIN_RGEX + +gboolean email_get_address_validation(const char *address) +{ + debug_log(""); + /* this following code verfies the email alias string using reg. exp. */ + regex_t alias_list_regex; + int ret = FALSE; + + if (regcomp(&alias_list_regex, EMAIL_ADDR_RGEX, REG_ICASE | REG_EXTENDED)) { + debug_log("email alias regex unrecognized"); + return FALSE; + } + + int nsub = alias_list_regex.re_nsub + 1; /* should be the number of parenthesized subexpressions (+1) */ + regmatch_t pmatch[nsub]; + memset(pmatch, 0, sizeof(regmatch_t) * nsub); + + if (regexec(&alias_list_regex, address, nsub, pmatch, 0) == REG_NOMATCH) + debug_log("failed : [%s]", address); + else { + debug_log("success : [%s]", address); + + /* + * remove sub-string match + */ + if ((int)(pmatch[0].rm_eo - pmatch[0].rm_so) == strlen(address)) + ret = TRUE; + } + + regfree(&alias_list_regex); + + return ret; +} + char *email_get_date_text(const char *locale, char *skeleton, void *time) { debug_log(""); diff --git a/composer/CMakeLists.txt b/composer/CMakeLists.txt index 42aa49f..4d8b6dd 100755 --- a/composer/CMakeLists.txt +++ b/composer/CMakeLists.txt @@ -49,10 +49,9 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DDEBUG") ADD_DEFINITIONS("-D_TEMPORARY_FIX_FOR_ROTATION_") ADD_DEFINITIONS("-D_POPUP_WITH_LIST") -##ADD_DEFINITIONS("-D_ALWAYS_CC_MYSELF") +ADD_DEFINITIONS("-D_ALWAYS_CC_MYSELF") ADD_DEFINITIONS("-D_CC_BCC") ##ADD_DEFINITIONS("-D_LAUNCH_APP") -##ADD_DEFINITIONS("-D_NO_ACCOUNT") ADD_LIBRARY(${PROJECT_NAME} SHARED ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} email-common ${CMAKE_LDFLAGS} ${pkgs-composer_LDFLAGS}) diff --git a/composer/include/email-composer-type.h b/composer/include/email-composer-type.h index 457c72d..0c72425 100755 --- a/composer/include/email-composer-type.h +++ b/composer/include/email-composer-type.h @@ -153,7 +153,7 @@ typedef enum { typedef enum { COMPOSER_FOCUS_STATUS_NONE = 1 << 0, - COMPOSER_FOCUS_STATUS_ATTACHMENT_REMOVED = 1 << 1, + COMPOSER_FOCUS_STATUS_SELECTED = 1 << 1, COMPOSER_FOCUS_STATUS_ON_PAUSE = 1 << 2, COMPOSER_FOCUS_STATUS_MAX = 1 << 3, } COMPOSER_FOCUS_STATUS_TYPE; diff --git a/composer/include/email-composer.h b/composer/include/email-composer.h index 28e9b93..dc4b1fd 100755 --- a/composer/include/email-composer.h +++ b/composer/include/email-composer.h @@ -144,6 +144,7 @@ struct ug_data { bool b_bcc_ps_open; bool ps_on; bool is_mbe_selected; + bool is_recipient_duplicated; /* Multibutton Entry */ Evas_Object *to_mbe_entry; diff --git a/composer/src/email-composer-attachment.c b/composer/src/email-composer-attachment.c index 66e6556..e0176e7 100755 --- a/composer/src/email-composer-attachment.c +++ b/composer/src/email-composer-attachment.c @@ -595,7 +595,6 @@ Evas_Object *_composer_attachment_make_thumbnail(EmailComposerUGD *ugd, char *fi debug_log("file path : %s", filePath); if (strncmp(type, ATTACHMENT_MEDIA_IMAGE, 5) == 0 || strncmp(type, ATTACHMENT_MEDIA_VIDEO, 5) == 0) { - int err = _composer_attachment_make_ethumb(filePath, thumb_path); if (err != COMPOSER_ERROR_NONE) @@ -995,7 +994,6 @@ static void _composer_attachment_delete_all_icon_clicked_cb(void *data, Evas_Obj } if (ugd->selected_entry == ugd->body_ewkview) { - ugd->focus_status = COMPOSER_FOCUS_STATUS_ATTACHMENT_REMOVED; // focus to body _composer_mbe_set_focus(ugd); } } diff --git a/composer/src/email-composer-callback.c b/composer/src/email-composer-callback.c index cb54ec5..dfafbd4 100755 --- a/composer/src/email-composer-callback.c +++ b/composer/src/email-composer-callback.c @@ -460,8 +460,6 @@ void _composer_mbe_focused_cb(void *data, Evas_Object *obj, void *event_info) elm_object_focus_set(ugd->cc_mbe, EINA_FALSE); else if (EINA_TRUE == elm_object_focus_get(ugd->bcc_mbe)) elm_object_focus_set(ugd->bcc_mbe, EINA_FALSE); - - evas_object_focus_set(ugd->body_ewkview, EINA_TRUE); } } } @@ -510,12 +508,17 @@ Eina_Bool _composer_mbe_verified_item_cb(Evas_Object *obj, const char *item_labe if (item_data) { debug_log("Normally Added"); - return EINA_TRUE; } debug_log("item_label = %s", item_label); + debug_log("is_recipient_duplicated:%d", ugd->is_recipient_duplicated); + if (ugd->is_recipient_duplicated == TRUE) { + ugd->is_recipient_duplicated = FALSE; + return EINA_FALSE; + } + if (_composer_is_valid_email(item_label)) { EmailRecpInfo *ri = (EmailRecpInfo *) calloc(1, sizeof(EmailRecpInfo)); ri->selected_email_idx = 0; @@ -720,12 +723,14 @@ void _composer_mbe_popup_move_to_to_cb(void *data, Evas_Object *obj, void *event } Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe); - if (item) - { + if (item) { ri = (EmailRecpInfo *) elm_object_item_data_get(item); if (ri) { elm_object_item_del(item); - elm_multibuttonentry_item_append(ugd->to_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri); + if (ri->display_name) + elm_multibuttonentry_item_append(ugd->to_mbe, ri->display_name, NULL, ri); + else + elm_multibuttonentry_item_append(ugd->to_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri); } else { debug_log("ri is NULL"); @@ -781,12 +786,14 @@ void _composer_mbe_popup_move_to_cc_cb(void *data, Evas_Object *obj, void *event } Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe); - if (item) - { + if (item) { ri = (EmailRecpInfo *) elm_object_item_data_get(item); if (ri) { elm_object_item_del(item); - elm_multibuttonentry_item_append(ugd->cc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri); + if (ri->display_name) + elm_multibuttonentry_item_append(ugd->cc_mbe, ri->display_name, NULL, ri); + else + elm_multibuttonentry_item_append(ugd->cc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri); } else { debug_log("ri is NULL"); @@ -842,12 +849,14 @@ void _composer_mbe_popup_move_to_bcc_cb(void *data, Evas_Object *obj, void *even } Elm_Object_Item *item = elm_multibuttonentry_selected_item_get(mbe); - if (item) - { + if (item) { ri = (EmailRecpInfo *) elm_object_item_data_get(item); if (ri) { elm_object_item_del(item); - elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri); + if (ri->display_name) + elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->display_name, NULL, ri); + else + elm_multibuttonentry_item_append(ugd->bcc_mbe, ri->email_list[ri->selected_email_idx].email_addr, NULL, ri); } else { debug_log("ri is NULL"); @@ -1259,8 +1268,6 @@ Eina_Bool _composer_mbe_create_change_addr_list(void *data) ugd->change_addr_noti = _composer_create_noti(ugd, false, _("IDS_EMAIL_OPT_CHANGE_EMAIL_ADDRESS_ABB"), NULL, 1, dgettext("sys_string", "IDS_COM_SK_CANCEL"), NULL, 0.0, _composer_mbe_change_addr_response_cb); - elm_object_focus_set(ugd->change_addr_noti, EINA_TRUE); - #ifdef _POPUP_WITH_LIST elm_object_style_set(ugd->change_addr_noti, "min_menustyle"); #else diff --git a/composer/src/email-composer-contents.c b/composer/src/email-composer-contents.c index ec0e0bd..442c321 100755 --- a/composer/src/email-composer-contents.c +++ b/composer/src/email-composer-contents.c @@ -84,9 +84,6 @@ static void _focused_cb(void *data, Evas_Object *obj, void *event_info) // Focus } else { if (ugd->selected_entry == ugd->body_ewkview) { elm_object_focus_set(ugd->subject_entry, EINA_FALSE); - - ugd->focus_status = COMPOSER_FOCUS_STATUS_NONE; - evas_object_focus_set(ugd->body_ewkview, EINA_TRUE); } } } @@ -421,8 +418,6 @@ static void _composer_webkit_unfocused_cb(void *data, Evas *e, Evas_Object *obj, if (ewk_view_script_execute(ugd->body_ewkview, COMPOSER_JS_SET_UNFOCUS, _composer_script_executed_cb, 0) == EINA_FALSE) debug_log("COMPOSER_JS_SET_UNFOCUS failed."); #endif - if (ewk_view_script_execute(ugd->body_ewkview, "deleteImgLayer()", _composer_script_executed_cb, 0) == EINA_FALSE) - debug_log("deleteImgLayer() failed."); } } @@ -571,7 +566,7 @@ static void _composer_webview_contextmenu_customize_cb(void *data, Evas_Object * count = ewk_context_menu_item_count(contextmenu); - for (i = 0 ; i < count ; i++) { + for (i = 0; i < count; i++) { Ewk_Context_Menu_Item_Tag menu_item_tag = EWK_CONTEXT_MENU_ITEM_TAG_NO_ACTION; menu_item = ewk_context_menu_nth_item_get(contextmenu, i); if (EWK_CONTEXT_MENU_ITEM_TYPE_ACTION != ewk_context_menu_item_type_get(menu_item)) diff --git a/composer/src/email-composer-predictive-search.c b/composer/src/email-composer-predictive-search.c index bd7a67a..8cd4ebb 100755 --- a/composer/src/email-composer-predictive-search.c +++ b/composer/src/email-composer-predictive-search.c @@ -557,6 +557,7 @@ static void _composer_ps_list_sel(void *data, Evas_Object *obj, void *event_info if (ugd->selected_entry == ugd->to_mbe_entry) { if (_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) { + ugd->is_recipient_duplicated = TRUE; if (ugd->composer_noti) { evas_object_del(ugd->composer_noti); ugd->composer_noti = NULL; @@ -593,6 +594,7 @@ static void _composer_ps_list_sel(void *data, Evas_Object *obj, void *event_info elm_entry_entry_set(ugd->to_mbe_entry, ""); } else if (ugd->selected_entry == ugd->cc_mbe_entry) { if (_composer_check_recipient_is_duplicated(ugd, ugd->cc_mbe, ri)) { + ugd->is_recipient_duplicated = TRUE; if (ugd->composer_noti) { evas_object_del(ugd->composer_noti); ugd->composer_noti = NULL; @@ -629,6 +631,7 @@ static void _composer_ps_list_sel(void *data, Evas_Object *obj, void *event_info elm_entry_entry_set(ugd->cc_mbe_entry, ""); } else if (ugd->selected_entry == ugd->bcc_mbe_entry) { if (_composer_check_recipient_is_duplicated(ugd, ugd->bcc_mbe, ri)) { + ugd->is_recipient_duplicated = TRUE; if (ugd->composer_noti) { evas_object_del(ugd->composer_noti); ugd->composer_noti = NULL; diff --git a/composer/src/email-composer-recipient.c b/composer/src/email-composer-recipient.c index 3980268..0ed5faf 100755 --- a/composer/src/email-composer-recipient.c +++ b/composer/src/email-composer-recipient.c @@ -22,6 +22,7 @@ #include "email-composer-util.h" #include "email-composer-predictive-search.h" + static void _composer_mbe_register_mbe_entry_callback(Evas_Object *parent, EmailComposerUGD *ugd); static void _composer_mbe_register_mbe_callback(Evas_Object *parent, EmailComposerUGD *ugd); static Evas_Object *_composer_mbe_create_mbe(Evas_Object *parent, COMPOSER_RECIPIENT_TYPE_E recp_type, EmailComposerUGD *ugd); diff --git a/composer/src/email-composer-util.c b/composer/src/email-composer-util.c index 8bb3215..bceb935 100755 --- a/composer/src/email-composer-util.c +++ b/composer/src/email-composer-util.c @@ -1818,9 +1818,7 @@ void _composer_add_to_address(EmailComposerUGD *ugd) Eina_Bool overflow_flag = TRUE; Eina_Bool invalid_address_flag = FALSE; -#ifdef _NO_ACCOUNT char *from_addr = NULL; -#endif if (ugd->existing_mail_info->mail_data != NULL && ugd->existing_mail_info->mail_data->full_address_from != NULL && (ugd->composer_type == RUN_COMPOSER_REPLY || ugd->composer_type == RUN_COMPOSER_REPLY_ALL)) { @@ -1921,15 +1919,10 @@ void _composer_add_to_address(EmailComposerUGD *ugd) debug_log("display_name = %s, email_address = %s", ri->display_name, ri->email_list[0].email_addr); debug_log("email_addr = %s", ri->email_list[0].email_addr); -#ifdef _NO_ACCOUNT debug_log("account.email_addr = %s", ugd->account_info->account->user_email_address); debug_log("from_addr = %s", from_addr); - if (g_strcmp0(ri->email_list[0].email_addr, ugd->account_info->account->user_email_address) != 0 || ugd->composer_type != RUN_COMPOSER_REPLY_ALL) -#else - if (ugd->composer_type != RUN_COMPOSER_REPLY_ALL) -#endif - { + if (g_strcmp0(ri->email_list[0].email_addr, ugd->account_info->account->user_email_address) != 0 || ugd->composer_type != RUN_COMPOSER_REPLY_ALL) { if (!_composer_check_recipient_is_duplicated(ugd, ugd->to_mbe, ri)) { if (!_composer_is_valid_email(ri->email_list[0].email_addr)) { @@ -2473,7 +2466,7 @@ void _composer_make_html_body(EmailComposerUGD *ugd) s = (char *)malloc(s_len); if (!s) { - debug_assert("memory allocation failed"); + debug_error("memory allocation failed"); if (ri->display_name) { free(ri->display_name); ri->display_name = NULL; @@ -2585,7 +2578,7 @@ void _composer_make_html_body(EmailComposerUGD *ugd) } strncpy(szMetaViewportInfo, HTML_META_INFORMATION, TEMP_BUFFER_SIZE); -#ifdef _NO_ACCOUNT + if (ugd->composer_type != RUN_COMPOSER_EDIT && (ugd->account_info->account->options).add_signature) { char signature_text[128] = { 0, }; @@ -2597,15 +2590,7 @@ void _composer_make_html_body(EmailComposerUGD *ugd) } else { full_text = g_strconcat(szMetaViewportInfo, text_for_original_info, html_text_for_body, NULL); } -#else - if (ugd->composer_type != RUN_COMPOSER_EDIT) { - char signature_text[128] = { 0, }; - snprintf(signature_text, sizeof(signature_text), "

%s

", DEFAULT_SIGNATURE); - full_text = g_strconcat(szMetaViewportInfo, text_for_original_info, html_text_for_body, signature_text, NULL); - } else { - full_text = g_strconcat(szMetaViewportInfo, text_for_original_info, html_text_for_body, NULL); - } -#endif + debug_log("text_for_original_info: %s", text_for_original_info); debug_log("html_text_for_body: %s", html_text_for_body); @@ -3226,6 +3211,8 @@ void _composer_noti_response_cb(void *data, Evas_Object *obj, void *event_info) EmailComposerUGD *ugd = (EmailComposerUGD *)data; + elm_object_tree_focus_allow_set(ugd->c_layout, EINA_TRUE); // block the focus not to open IME. + Evas_Object *mbe = NULL; if (ugd->selected_entry == ugd->to_mbe_entry) { @@ -3408,7 +3395,7 @@ Eina_Bool _composer_mbe_set_focus(void *data) debug_log("selected_entry = %x, to_mbe_entry = %x, cc_mbe_entry = %x, bcc_mbe_entry = %x, subject_entry = %x, body_ewkview = %x", ugd->selected_entry, ugd->to_mbe_entry, ugd->cc_mbe_entry, ugd->bcc_mbe_entry, ugd->subject_entry, ugd->body_ewkview); - if (ugd->selected_entry == ugd->to_mbe_entry) { + if ((ugd->selected_entry == ugd->to_mbe_entry) || (ugd->selected_entry == NULL)) { debug_log("TO MBE ENTRY FOCUS!!!"); elm_object_focus_set(ugd->to_mbe, EINA_TRUE); } else if (ugd->selected_entry == ugd->cc_mbe_entry) { diff --git a/composer/src/email-composer.c b/composer/src/email-composer.c index f00ddcd..ba8ae0a 100755 --- a/composer/src/email-composer.c +++ b/composer/src/email-composer.c @@ -175,13 +175,12 @@ static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h data, void * debug_log("def account_id = %d", ugd->account_info->account_id); -#ifdef _NO_ACCOUNT ugd->eComposerErrorType = _composer_get_account_list(ugd); if (ugd->eComposerErrorType == COMPOSER_ERROR_NO_ACCOUNT_LIST) { return ugd->main_layout; } -#endif + ugd->has_body_html = EINA_TRUE; ugd->saved_html_path = g_strconcat(EMAIL_TMP_FOLDER, SAVE_HTML_FILE_NAME, NULL); @@ -961,6 +960,7 @@ static void _composer_init_data(void *data) ugd->cc_added = false; ugd->bcc_added = false; ugd->isRotated = false; + ugd->is_recipient_duplicated = false; ugd->temporary_fix_for_rotation = false; ugd->is_main_scroller_scrolling = false; @@ -1386,10 +1386,16 @@ static int _composer_pre_parse_bundle(EmailComposerUGD *ugd, service_h data) debug_log("service_get_extra_data: %d", ret); debug_log("argv[0]:%s", argv[0]); } -#ifdef _NO_ACCOUNT + + int ret; + char *operation = NULL; + ret = service_get_operation(data, &operation); + debug_log("service_get_operation: %d", ret); + debug_log("operation = %s", operation); + if (email_engine_get_default_account(&ugd->account_info->account_id) == false) return COMPOSER_ERROR_NO_DEFAULT_ACCOUNT; -#endif + if (argv[0]) { debug_log("argv[0] = %s", argv[0]); @@ -1397,22 +1403,39 @@ static int _composer_pre_parse_bundle(EmailComposerUGD *ugd, service_h data) debug_log("composer type = %d", ugd->composer_type); if (ugd->composer_type == RUN_COMPOSER_EXTERNAL) { - int ret; - ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_TO, (char **)&argv[1]); - debug_log("service_get_extra_data: %d", ret); - debug_log("to:%s", argv[1]); - ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_CC, (char **)&argv[2]); - debug_log("service_get_extra_data: %d", ret); - debug_log("cc:%s", argv[2]); - ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_BCC, (char **)&argv[3]); - debug_log("service_get_extra_data: %d", ret); - debug_log("bcc:%s", argv[3]); - ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_SUBJECT, (char **)&argv[4]); - debug_log("service_get_extra_data: %d", ret); - debug_log("subject:%s", argv[4]); - ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_BODY, (char **)&argv[5]); - debug_log("service_get_extra_data: %d", ret); - debug_log("body:%s", argv[5]); + if (operation == NULL) { /* ug called by ug_create */ + ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_TO, (char **)&argv[1]); + debug_log("service_get_extra_data: %d", ret); + debug_log("to:%s", argv[1]); + ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_CC, (char **)&argv[2]); + debug_log("service_get_extra_data: %d", ret); + debug_log("cc:%s", argv[2]); + ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_BCC, (char **)&argv[3]); + debug_log("service_get_extra_data: %d", ret); + debug_log("bcc:%s", argv[3]); + ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_SUBJECT, (char **)&argv[4]); + debug_log("service_get_extra_data: %d", ret); + debug_log("subject:%s", argv[4]); + ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_BODY, (char **)&argv[5]); + debug_log("service_get_extra_data: %d", ret); + debug_log("body:%s", argv[5]); + } else { /* ug called by appcontrol request */ + ret = service_get_extra_data(data, SERVICE_DATA_TO, (char **)&argv[1]); + debug_log("service_get_extra_data: %d", ret); + debug_log("to:%s", argv[1]); + ret = service_get_extra_data(data, SERVICE_DATA_CC, (char **)&argv[2]); + debug_log("service_get_extra_data: %d", ret); + debug_log("cc:%s", argv[2]); + ret = service_get_extra_data(data, SERVICE_DATA_BCC, (char **)&argv[3]); + debug_log("service_get_extra_data: %d", ret); + debug_log("bcc:%s", argv[3]); + ret = service_get_extra_data(data, SERVICE_DATA_SUBJECT, (char **)&argv[4]); + debug_log("service_get_extra_data: %d", ret); + debug_log("subject:%s", argv[4]); + ret = service_get_extra_data(data, SERVICE_DATA_TEXT, (char **)&argv[5]); + debug_log("service_get_extra_data: %d", ret); + debug_log("body:%s", argv[5]); + } } else { int ret; ret = service_get_extra_data(data, EMAIL_BUNDLE_KEY_ACCOUNT_ID, (char **)&argv[1]); @@ -1464,7 +1487,6 @@ static int _composer_pre_parse_bundle(EmailComposerUGD *ugd, service_h data) } if (argv[4] != NULL && strlen(argv[4]) != 0) ugd->new_mail_info->mail_data->subject = g_strdup(argv[4]); - if (argv[5] != NULL && strlen(argv[5]) != 0) { ugd->new_mail_info->mail_data->file_path_plain = g_strdup(argv[5]); ugd->new_mail_info->mail_data->body_download_status = 1; @@ -1494,9 +1516,57 @@ static int _composer_pre_parse_bundle(EmailComposerUGD *ugd, service_h data) return COMPOSER_ERROR_NONE; } else { - debug_log("Invaild argument!!"); + if (operation == NULL) { /* ug called by ug_create */ + debug_log("Invaild argument!!"); + return COMPOSER_ERROR_INVALID_ARG; + } else { /* ug called by appcontrol request */ + + /* default run type: RUN_COMPOSER_EXTERNAL */ + ugd->composer_type = RUN_COMPOSER_EXTERNAL; - return COMPOSER_ERROR_INVALID_ARG; + int ret; + ret = service_get_extra_data(data, SERVICE_DATA_TO, (char **)&argv[1]); + debug_log("service_get_extra_data: %d", ret); + debug_log("to:%s", argv[1]); + ret = service_get_extra_data(data, SERVICE_DATA_CC, (char **)&argv[2]); + debug_log("service_get_extra_data: %d", ret); + debug_log("cc:%s", argv[2]); + ret = service_get_extra_data(data, SERVICE_DATA_BCC, (char **)&argv[3]); + debug_log("service_get_extra_data: %d", ret); + debug_log("bcc:%s", argv[3]); + ret = service_get_extra_data(data, SERVICE_DATA_SUBJECT, (char **)&argv[4]); + debug_log("service_get_extra_data: %d", ret); + debug_log("subject:%s", argv[4]); + ret = service_get_extra_data(data, SERVICE_DATA_TEXT, (char **)&argv[5]); + debug_log("service_get_extra_data: %d", ret); + debug_log("body:%s", argv[5]); + + if (argv[1] != NULL && strlen(argv[1]) != 0) { + ugd->new_mail_info->mail_data->full_address_to = _composer_parse_recipients_arg(ugd, argv[1]); + } + if (argv[2] != NULL && strlen(argv[2]) != 0) { + ugd->new_mail_info->mail_data->full_address_cc = _composer_parse_recipients_arg(ugd, argv[2]); + } + if (argv[3] != NULL && strlen(argv[3]) != 0) { + ugd->new_mail_info->mail_data->full_address_bcc = _composer_parse_recipients_arg(ugd, argv[3]); + } + if (argv[4] != NULL && strlen(argv[4]) != 0) + ugd->new_mail_info->mail_data->subject = g_strdup(argv[4]); + if (argv[5] != NULL && strlen(argv[5]) != 0) { + ugd->new_mail_info->mail_data->file_path_plain = g_strdup(argv[5]); + ugd->new_mail_info->mail_data->body_download_status = 1; + } + + ugd->save_drafts = 1; + + int i; + for (i = 0; i < 7;i++) { + if (argv[i]) + g_free(argv[i]); + } + + return COMPOSER_ERROR_NONE; + } } } diff --git a/images/menu_Email.png b/images/menu_Email.png new file mode 100755 index 0000000000000000000000000000000000000000..c10fbce4d20d40da1676fd2a3e727283e0033275 GIT binary patch literal 7537 zcmY*dWl&sAu)RodSsa2pfyF(zI|K{v9z1M_y-{Mg{1 z5mCP%H@$z_&$Zv~jlDF?i|&_SX4Op~ccWk=%X6#q24Iv(Qs8U^L;D9eci6-O(db+N z5K5gTwc9f-9B}6+EX+dFjob;qdCZ`r0NpAX-5g}$uh@r@X@+nCA#mN01OX+K0DM5) zD^{`y5SN7u$Vz3<1ac7p(-8~vZQuhdV9MyfHvTU7$pPfasc?&O8tVs0xQ6wpkpl$R5t%?G2OxR_rbD!}9zaMM zfG>NYBYe(M3EF3dA(d7u+(IWP6KH_K>WZwR!$!e0u0X_s&u0d2mM+fL>zPKv7083V zaXAVAxd{ZYuf2Ts7{{s{ALom0#4=$$>_U2_F*o0S*_|kJ5eI-xh~Lx;n7!_8fDlrE z<4ZpM38JkrdhVCoXzN;R@dhCGU`glF^5R<-7k77d78Ls>4a|P)_`cZmnsnM8Dj$SDjl1(I{hM2GH#mPN2p}#(n&(QQMn78OM<8Q0u zy2eVU$6Rt1(nLxoz8j#Qezn|M2R|Z+uJZ!bpG4uj6Ig#4Ss>gfF@kg<-CMT+aM9-6 z^M?rqA;30xbHe@gRP0$UmmUbPR!DRO0Ap!7Hm%=vVo($Skj@Qcu9hIZ>LCVqBa!vI zS?NK4GUW@Ar0egM1WBS<29SL=eODeN$rLtLP0nn}{zsggr(4}NEXf6ntyjAlOT-2H z!3-t4hp9af6;Wac1<#CnDFV(sN|!bkg(xlbj=D!45jUESYB&O4okl5vSDsTNN{dQc zp8P`OGrVB9p=@h{&=9~C^c2=E$N4?5R$b%|MuSw#FaEb7viazfmJrVLIKteF$v9+BeX?cTTIlr zBjN_ibffYix=T`-QAo(^D(k8)$p4}uqvOF@LghzA2vP54q)GavRL{_gbKg&F&czw7 zD-Wif!;QmZ2YE+G_4Cu=MoMupw#36L)D&n<<4(&?J894!fJ-uXR*CGpk z2UD>Oh3;hS^zCr(knT`l7@%dDi@O%wX>KuT{Qjg!vJ2Yf*+sHS<&x0;nXa+=D^ClD zH%?!&BCk=SNP(Lu$o)YDE zq43F@EZGVRi=4@a7$nl>duzrssx zemQH275M2rM*3z6A32Gt`VN`g~<>OMND9 zixw#@$rF^~R^-;H)42R@Erz_E>Ux(6QAOQnDo(ldi(11!eYf?Fw1`K!h11H=zBD-{ zS+`8SOubC*sDrQaxHzk*L#9pdF%U}vs>o=_C}$Hl{w8Z*b5V1(7_FF4MdbZ;C0nU| zA!%Nlw0oCR@kwfSr*S~GvUBm8XUF~nnJ@dZ*0bY7@wFU=E>ax^9nvz!II-{mudA~# zIXiUuTwThjPh6_d?1x#(W=KNIlAGgF?NH7+jQHGgN}ng8ITyL8I)8GRZh}1 zR9cGO6$vQ|DMQCb$MVPK(s(mOIOnSQajD(L6hD%y&1id$5ZRLipGZ2GFt8;2W9nnc&1}qx zY?=lt`%aQNl6+fzzdef}V}>tcm67X{`?=MB#()3u{aX5X=82f^z*X`AyN&JyXkvkT zyAf~XUB6wHX2y)14UtWYTkvH>bfi+y2wRFMTL$Ui>QKjyBIMfDXwz%@IxC|tqxbmN za@7gniQP%~O3o-x&bw?qZnw$4A*l`Z-6=8joF5$a>*aoGQfh%V4g0k07VHT+74y|i zh3=)dW~W4=H=>_&wnevv`PaDC^h`$iyPJlZM%4P8vrR(RrTl4MEnmG}r-0%BdN><| z$Uuoe1Ng@~FCXfzSh4rZRyVba#}YBQEfNG0aX}S9yFC@uwnP8oE2wYxQ^ym=?XW^W z`2C%mL^j(qi|+HoU@eb&1e@JH?s8>prz2<+d*UAe}6|mSMxGCRoL)$jdBR z%JxZkiNBSnRcw&WT5oh#H%nK+L5WO|jk%J~$)R)o>G(2yD{BjV+nXqreaOhgGjF{2 zDzuoegbf$`K3QBjLRH}VnFNUW7hw$j1)e*7EShI8d9Mu(`xM_)#DbI|GllAfJhO^d z;=hD;UQfCK?n3ZxO9*30e7iEH@@mHWY{K-fRE}IC?>jhy6BFWHB}=JQk{WFeZT76c zj+9%4*1illMK`fi{6HSIuZu5#qsNNYC|UGZOP^_;8M)TRO2@iuEb_Nta#=RZ*zsuH z@8x*@%+s9LW87Zc&BVsSFeM#Ua^1a-@=t=b!mggnXxjvDSi(Lcl?yjVH8MNSs+Aq< zq*VHKFnFoh2O9VM4(e%uvp+)DM%xYbJzAMRHd51N*IREedkD)S6(xv_s>EL=N+IxH zU|R9mB@K7}-IccTy}qQZzr}LGdfNJ6Z;dtE04upPWiJKG33G9&9&`O;{qgmU%rbk* z7}IiFaHCYq&o1HScB|sy@i8GWtpcqptp_c>lj+q4v-vxxsS{G~_8Xpmv&#nUx6h)( zoy*#A+A6cwvsRA^k9D_Vm64?fcgc^AMir`#uE$V>X@qBFTCB$TmOr!P(;`|LadRw3 za#&Ex&X=rHcUDY3Ozm%(gIlyN(w;j9x2Ws46qxUqzQ%Z$Zz9i7ekHddXa6LbevvMl zp_%?@U~bT=HYz$bcev*DB)3e7oyjAt=c#z9HEg$Z5Hyoyb1@N<^&`vIkL`ZNbUDA# zd*5Pw{S&tHX)6e_IW6-Vy)V=*G;Vm&47sRX-o?{t)=95=Z{m0eITU_Lno)zcWwxbP zwiw#CoOpFKcw65dkY@9buU>U{o)f;#&1MUVtae;_Io}T4Uau3b`h8}69v^92bZ0!N zXjf}Dxe`B?Sd>}~pA|EBSy?z;@&DBAo_jg9B6o`v8a(lma2?m76 zR8VkB?DO-%Q?b;9Qr9JMM_eaqfg=UVfPV9)$(BP zAVue}2REnj)yK!<9`_Y@^3$K|*lIgIRQ^n_w)ZvHnv=zkNhC>0uZRe#mroYltjnHGl&|m46esjg6k}(+R>`In2qwlmWaL)PF z>##qZ&ryvmXNi^AjdO^2fXYlF2E;@Ajsof7yUgYm zyUJGMUT>f9e(ih?`=Cw0w<1bMLU-R$lbOei zy(&Ne5W>4G<&(If!3m&k#1AgCxb4dTVf-C?govA`^OZ(zd*IE|r@jNX-r*PO2#nAi zopm^Vxr~zn23&cO+qj{JX9iK~sEwRgqIi0G20w0NE zmam-szKyOipyzmBA?LE_=-!<|GW&{R-3VX!iPnOu*i)@HZEpCepEFDhct3yPZ9aXf z2wfKi4Jc7&$uiiVWc^Ta-G;I#O5lb><{TeOl%5EJqTtOoC0$s2r}~`Ko?E{h`K>Q3 z-1(`fs2~BqT3g?@-|uCN93CEa)`{en`(1Y1F@O}rhfC$H@G~i5%m&I8ijYAV2&Fza z-#b(S!2UN{da{kj#I_~`C}H=b6F7*>MV_v?&M2sQ_YR57E(KySZAxexrejnyCVCjV z3!J~CsPRk$KO;gs1tWST@m^zx*)qvhH+*=kwsP7*eGXL-c5G|^yluwd=};GEibsPU z>(N6--h4VS#Oqq<>FJpiSfb=RN8Yk4_yPW1>@oWL?|A_DUEsFwzz$y!+YrFJ4ViWO zfL^J`?~>Yg<*X9Bnunrn&$Cn6?J}JwM4G0jsCx2%D5ppYddsrcfO8A;be80K-14>DX349(?(K)=- z=J0Qg=n>^1G~?Cz$Yuu$wGa3q&>TR}x7AZ}5v=k0!14?3Na*!?Ythqa&)Hxi-=4|r z&HV%gVu#PYP37tHZ8U0-3%tvL#9jVv^Iyf6d~+n-C~;*CWo!XT1!@MXjZs&EfAgJR zr@jZn)y2ce3WSRv7+`prHb6UDEp$5@HeI>E%?a6Ru9!62Qg_>z^!SHr8B5XlaJ~(d z&`IU>C{2QHk0?#8h}e?&*NescPD=v2DtYYb$uBqRp8D^gEIgjn^;bYsQp~qq#Xk4K zVdaoEj#2_4r@oYSRYaw9aCF0#&%XEoA%LQ-t!`lO_~+sJ$fObPM`T_&h1cJM$VIzhgB`}}YEDdashiliT4n~pSbxo3=_KtqPLz0nhlf)uRV z=s;p#LtML9&UzqB7eynP2TIS#xGtBQ@e1#QiKm;mwLe)hrt{C$w0YoOB2$zk%oW(7 zj}`iFw6(9-5>#^TA8&5H);Bd}JasG|hcQKg5G8KGo^TvNru6_VXv!9UxzRCrVqeP4 zj5=|6M}^%dD!=ig+s$wv-VXpJXcu_3vzVhI&&e(OXMm#GzGr@`-dy zOG_@By>GO%wW+gI*CDJJ>iC+LE{&;8&3DKSmhOEUX(CwS?zgg9nxnO zk^k$_J7uI0*&x|UMQ^*IlhL=sx`etiF!#Kk7$a5$L{be>X<T*z#gD`k)L4{B1|`ACwjSUDxya3c{Lo!4XOm6A;lrVDe*n!7nL zXcADqo~%TA2xF<^e;MO1O4F|%o1bYhBa9~{`g|0=GFsBmKoBSn%+AhIDO`j#ad>3Q z+1N1N{98nTF{>=+CZwNkHwqb)G`9EzcQ4NIakRy^ptDodVWAqXp`n2Z3~r~caD?Rm z4vd@Q0n1X#-FCVwd%e;@cRc#jcHF1 zs?kLO6Iw0U3>r&LOiTQq z+GsQMO_-U>i6Q0J<4*x}3Jja1I#u<`av4V+W6>09c=J#6P}gMr9%9n}q6?jfEw{)T zQ+kS%%{7n;#f2<9Ihl}5*aJkTaF`a$3578>$h@E`0JM-KPQ|^=@PcU-QDUPv6n&xj zoE)Y*v++zpi?>AezEuW|4zkWw|ApoBsE=c4BvhyZ%N<*UrztM3yEGkMy zx8cxOK9T3pQyo9Fr$@qJt)1imqEFO0wcBjSb|x(5ls1mp5a81z*z^$yaNvu!DL%(&C zu(1!3rCw(#?_%(=jV&rIp1ndM8XGU%U7h(p$=Q(N=Zqg?I6inz22D%G z`i9Bt*c8M$L#==tO{h%;`YQ*EzcgiQ$%?>irV2_5in#{k#Dew?O2^w!PF;JzHY1Zx zL6RY9N`m8LY4Wp=I=;$}ikf1#7Ukk*4>Sffwrm&sTt@w)s(LH>by2#g{43?Keb0g! zJ95OI*S4fXh!T_DLi$!h)3Yo=R3D5xQ3A!qo?ap&F)j9jF6?{-gkz?sr&&Hd?@nuN zi_&2Nu$;nQ0GE633oAzGlWf~_-S#*u-`{Df)bwn+#ANVJZWmtT%jDO79?))hQG6z~ z5T4XfRJoHSD$tAC3*#{nODFTsFAt<(ugKwZY#k?c+$`$gQJL8gz>3OG1;&hCMhTv5 z%MGG2p>a*rKNP>U@ESIu|DJu&1@nEX=+fUUhjSVYh_Q$fYK69Xv9qv1yTt*&*9B|E zs|8zM;>*2nS#xog-!^3@J#-O72=z}d?{iC;x6bcW&L3-pPQh)Km_Oq%X+KNc*Nft! zTCBBuw$80PKuL)!B+5wZ6<_qr13M`yitW%uO=eXJuXUm@drUzc9Ub!oq<`(NubbBW zE@4>MUhE7rF*8qF^fl;8853Fld4MU}md8us$QKCk5O$)pcS~CUVIXbZ-byC#;^-mx zYMW4ES*#sj!qPh{ET|gi;wIlNEyvMjsU9h1r_>=ml+id8R1S=*~ zNyFmFR?&0C8t)8_s*<9jqB!iP=^&8$qc6csQTK3@A4_;DbhNLhC0i=4e>Q}LqMu4L z@kE@QI7JJ80m3Ay4UV7*Xy}Z2xw#;6@?+SA`ZdvJXP<*uA;LXm(}HKOjKO3G@GnWt z31hMNVi8ziLjlf4Z=^gN27Hv=(32$+{7tY08NCn!j@tZ@`51oz-GdgZ3+{Zjn_{}6 z=s)Tz_D_ppe|9h9vgjtw?!5hvl+|Z(x7gcVSP=a?f+qYe_S4qc-if5<7o?mP0GVgV<6x1HtS%<7Nt;v)DQ{5kSz>mf1J`1L;`$6IdC4 zy&>jTh`m!lGxAK^^^9F$U{E2FQeq5F-Ktsf->z}`Cv5c`gKDG!znSd~zE$Jjcg5e${pJO%A0u>34-p*y(eDNK^Gpim_;YHr=AAM+-P| ze|K@a4oVYP5Qiqnw-#J!?&2-Hw*V64U#__?PSwYf#hUypL}v zY}K)}6rK$GbSWojR8U9r8C4X z`o(8ND8$6~&2$=f@;NqpdT7-+xHjfBr!U9c-+huR+r$X-{Aj&8=0BKyMyz4=xWoJQ zg&KrX04LvVLwQcJ*5&Wtb9+){y+6U6wzNfApb*sk5B_qV>Teo1oJ`<~Q!H}Y8U=_4 z^Xq2T-gs`3T;9-@_^BxtiX8?$9eBi3aC#SBQ$OlY_G&k147MGH*pir4u(!UYIq$dFQ^JagvdEFhvh3^%mdBJo3C9 zr6K# +#include +#include +#include +#include +#include +#undef _ +#include +#include +#include + +#include "email-types.h" +#include "email-api.h" + +#include "email-engine.h" +#include "email-debug.h" +#include "email-locale.h" +#include "email-utils.h" +#include "email-common-types.h" +#include "email-setting-defines.h" +#include "email-setting-view.h" + +#define SETTING_PACKAGE "email-setting" +#define EDJ_PATH EDJDIR +#define EV_THEME_PATH EDJ_PATH"/email-setting-theme.edj" +#define EFFECT_EDJ_PATH EDJ_PATH"/email-effect-layout.edj" + +#define VIEW_ST_MAX 20 /* Maximum View Stack */ + +#define _EDJ(o) elm_layout_edje_get(o) + +#define ACCOUNT_ICON_GMAIL IMGDIR"/M02_email_list_icon_gmail.png" +#define ACCOUNT_ICON_HOTMAIL IMGDIR"/M02_email_list_icon_hotmail.png" +#define ACCOUNT_ICON_YAHOO IMGDIR"/M02_email_list_icon_YahooMail.png" +#define ACCOUNT_ICON_AOL IMGDIR"/M02_email_list_icon_AOL.png" +#define ACCOUNT_ICON_OTHERS IMGDIR"/icon_email.png" + +#define CBAR_ICON_ADD IMGDIR"/01_controlbar_icon_create_folder.png" +#define TITLE_ICON_REFRESH IMGDIR"/M02_email_icon_title_refresh.png" + +typedef enum { + HOTMAIL = 1, + GMAIL, + YAHOOMAIL, + AOL, + OTHERS +} AccountInfo; + +typedef struct ug_data EmailSettingUGD; +struct ug_data { + ui_gadget_h ug; + ui_gadget_h ug_block; + ui_gadget_h ug_cert; + + struct ug_cbs block_cbs; + struct ug_cbs eas_cbs; + struct ug_cbs eas_edit_cbs; + struct ug_cbs cert_cbs; + + Evas *evas; + Evas_Object *win; + Evas_Object *layout_main; + Evas_Object *base; + Evas_Object *bg; + Evas_Object *popup_one; + Evas_Object *popup_validate; + Evas_Object *popup_color; + Evas_Object *small_noti; + Evas_Object *small_noti_ly; + Evas_Object *navi_bar; + Evas_Object *ly_accounts; + Evas_Object *effect_ly_block; + Evas_Object *effect_ly_eas; + Evas_Object *effect_ly_eas_edit; + + struct viewdata *vd[VIEW_END]; + Viewtype view_st[VIEW_ST_MAX]; + int view_top; + + char *start_view_type; + + /* view specified variables */ + AccountInfo account_info; + email_account_t *new_account; + email_account_t *account_list; + + int err_code; + int account_count; + int account_id; + int myaccount_id; + int check_interval; + int email_size; + int end_key_event; + int cancel_event; + int validation; + int account_selected; + int eas_validation_success; + int eas_account_deleted; + int eas_account_added; + int eas_account_validation; + int atomic_pop; + int setup_mailbox; + int navi_flag[16]; + int start_account_validation; + int b_exchange; + int change_view_ing; + int b_on_pause; + int wds_account_creation; + int manual_setup; + + unsigned int handle; + + Ecore_Timer *preset_vc_timer; + Ecore_Timer *other_vc_timer; + Ecore_Timer *edit_vc_timer; + Ecore_Timer *del_timer; + + Evas_Object *account_list_view; + Evas_Object *setting_main_view; + + Elm_Object_Item *selected_account_it; + Elm_Object_Item *navi_main_it; + Elm_Theme *theme; + + E_DBus_Connection *dbus_conn; + E_DBus_Signal_Handler *signal_handler_network; + E_DBus_Signal_Handler *signal_handler_storage; +}; + +#endif /* __EMAIL_SETTING_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-account-edit.h b/setting/include/email-view-account-edit.h new file mode 100755 index 0000000..3666ae5 --- /dev/null +++ b/setting/include/email-view-account-edit.h @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_ACCOUNT_EDIT_H__ +#define __EMAIL_VIEW_ACCOUNT_EDIT_H__ + +#include "email-setting-view.h" + +void setting_init_account_edit_view(struct viewdata *vd); +void setting_edit_validation_success_cb(EmailSettingUGD *ugd); +void setting_edit_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled); + +#endif /* __EMAIL_VIEW_ACCOUNT_EDIT_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-account-options.h b/setting/include/email-view-account-options.h new file mode 100755 index 0000000..125f95b --- /dev/null +++ b/setting/include/email-view-account-options.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_ACCOUNT_OPTIONS_H__ +#define __EMAIL_VIEW_ACCOUNT_OPTIONS_H__ + +#include "email-setting-view.h" + +void setting_init_account_options_view(struct viewdata *vd); + +#endif /* __EMAIL_VIEW_ACCOUNT_OPTIONS_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-account-setup.h b/setting/include/email-view-account-setup.h new file mode 100755 index 0000000..3cc4eac --- /dev/null +++ b/setting/include/email-view-account-setup.h @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_OTHER_ACCOUNT_H__ +#define __EMAIL_VIEW_OTHER_ACCOUNT_H__ + +#include "email-setting-view.h" + +void setting_init_account_setup_view(struct viewdata *vd); +void setting_account_validation_success_cb(EmailSettingUGD *ugd); +void setting_account_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled); + +#endif /* __EMAIL_VIEW_OTHER_ACCOUNT_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-initial.h b/setting/include/email-view-initial.h new file mode 100755 index 0000000..4a30a3c --- /dev/null +++ b/setting/include/email-view-initial.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_INITIAL_H__ +#define __EMAIL_VIEW_INITIAL_H__ + +#include "email-setting-view.h" + +void setting_init_initial_access_view(struct viewdata *vd); + +#endif /* __EMAIL_VIEW_INITIAL_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-mailbox-mapping.h b/setting/include/email-view-mailbox-mapping.h new file mode 100755 index 0000000..8062bba --- /dev/null +++ b/setting/include/email-view-mailbox-mapping.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_RECEIVING_OPTION_MAILBOX_SETUP_H__ +#define __EMAIL_VIEW_RECEIVING_OPTION_MAILBOX_SETUP_H__ + +#include "email-setting-view.h" + +void setting_init_mailbox_mapping_view(struct viewdata *vd); + +#endif /* __EMAIL_VIEW_RECEIVING_OPTION_MAILBOX_SETUP_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-manual-setup.h b/setting/include/email-view-manual-setup.h new file mode 100755 index 0000000..2f116ed --- /dev/null +++ b/setting/include/email-view-manual-setup.h @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_SERVER_TYPE_H__ +#define __EMAIL_VIEW_SERVER_TYPE_H__ + +#include "email-setting-view.h" + +void setting_init_manual_setup_view(struct viewdata *vd); +void setting_manual_validation_success_cb(EmailSettingUGD *ugd); +void setting_manual_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled); + +#endif /* __EMAIL_VIEW_SERVER_TYPE_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-setting.h b/setting/include/email-view-setting.h new file mode 100755 index 0000000..f300608 --- /dev/null +++ b/setting/include/email-view-setting.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_SETTING_H__ +#define __EMAIL_VIEW_SETTING_H__ + +#include "email-setting-view.h" + +void setting_init_setting_view(struct viewdata *vd); + +#endif /* __EMAIL_VIEW_SETTING_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-sp-select.h b/setting/include/email-view-sp-select.h new file mode 100755 index 0000000..28fcbf7 --- /dev/null +++ b/setting/include/email-view-sp-select.h @@ -0,0 +1,26 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_SELLECT_ACCOUNT_H__ +#define __EMAIL_VIEW_SELLECT_ACCOUNT_H__ + +#include "email-setting-view.h" + +void setting_init_sp_select_view(struct viewdata *vd); + +#endif /* __EMAIL_VIEW_SELLECT_ACCOUNT_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-sync-schedule.h b/setting/include/email-view-sync-schedule.h new file mode 100755 index 0000000..6a989df --- /dev/null +++ b/setting/include/email-view-sync-schedule.h @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_SYNC_SCHEDULE_H__ +#define __EMAIL_VIEW_SYNC_SCHEDULE_H__ + +#include "email-setting-view.h" + +void setting_init_sync_schedule_view(struct viewdata *vd); +void setting_schedule_sync_started(struct viewdata *vd, int account_id); +void setting_schedule_sync_finished(struct viewdata *vd, int account_id); + +#endif /* __EMAIL_VIEW_SYNC_SCHEDULE_H__ */ + +/* EOF */ diff --git a/setting/include/email-view-sync-setup.h b/setting/include/email-view-sync-setup.h new file mode 100755 index 0000000..05de0ab --- /dev/null +++ b/setting/include/email-view-sync-setup.h @@ -0,0 +1,28 @@ +/* + * 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. + */ + +#ifndef __EMAIL_VIEW_SYNC_SETUP_H__ +#define __EMAIL_VIEW_SYNC_SETUP_H__ + +#include "email-setting-view.h" + +void setting_init_sync_setup_view(struct viewdata *vd); +void setting_setup_sync_started(struct viewdata *vd, int account_id); +void setting_setup_sync_finished(struct viewdata *vd, int account_id); + +#endif /* __EMAIL_VIEW_SYNC_SETUP_H__ */ + +/* EOF */ diff --git a/setting/src/email-setting-account-set.c b/setting/src/email-setting-account-set.c new file mode 100755 index 0000000..a4e3066 --- /dev/null +++ b/setting/src/email-setting-account-set.c @@ -0,0 +1,629 @@ +/* + * 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-defines.h" +#include "email-view-setting.h" +#include "email-setting-account-set.h" + +#define DEFAULT_SIGNATURE _("IDS_EMAIL_BODY_SENT_FROM_SAMSUNG_MOBILE")//_("IDS_EMAIL_BODY_SENT_USING_TIZEN_MOBILE") + +static void _set_gmail(struct viewdata *vd); +static void _set_yahoomail(struct viewdata *vd); +static void _set_hotmail(struct viewdata *vd); +static void _set_aol(struct viewdata *vd); +static void _set_others(struct viewdata *vd); +static void _set_user_name_with_email_addr(char *email_addr, char **user_name); +static void _set_display_name_with_email_addr(char *email_addr, char **display_name); +static void _account_info_print(email_account_t *account); + + +void setting_set_account(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = vd->ugd; + + debug_log("%d", ugd->account_info); + int c = ugd->account_info; + switch (c) { + case GMAIL: + _set_gmail(vd); + break; + case YAHOOMAIL: + _set_yahoomail(vd); + break; + case HOTMAIL: + _set_hotmail(vd); + break; + case AOL: + _set_aol(vd); + break; + case OTHERS: + _set_others(vd); + break; + } + return; +} + +void setting_set_account_with_server_info(email_protocol_config_t *incomming, + email_protocol_config_t *outgoing, char *service_name, EmailSettingUGD *ugd) +{ + debug_log(""); + email_account_t *account = NULL; + account = ugd->new_account; + int preset_account = 0; + int rgb = 0x006400ff; + + debug_log("service_name (%s)", service_name); + if (!g_strcmp0(service_name, "Hotmail")) + account->incoming_server_user_name = g_strdup(account->user_email_address); + else + _set_user_name_with_email_addr(account->user_email_address, &(account->incoming_server_user_name)); + + _set_display_name_with_email_addr(account->user_email_address, &(account->user_display_name)); + + account->reply_to_address = g_strdup(account->user_email_address); + account->return_address = g_strdup(account->user_email_address); + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; /* EMAIL_IMAP4_RETRIEVAL_MODE_NEW; */ + + if (!g_strcmp0(service_name, "Gmail")) + preset_account = GMAIL; + else if (!g_strcmp0(service_name, "Hotmail")) + preset_account = HOTMAIL; + else if (!g_strcmp0(service_name, "Yahoo")) + preset_account = YAHOOMAIL; + else if (!g_strcmp0(service_name, "AOL")) + preset_account = AOL; + else + preset_account = 0; + + account->auto_download_size = 1024*10; /* downloading option, 0 is subject only, 1 is text body, 2 is normal. */ + account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3' */ + account->default_mail_slot_size = 25; + + account->pop_before_smtp = 0; + account->incoming_server_requires_apop = 0; + + account->options.priority = 3; + account->options.keep_local_copy = 1; + account->options.req_delivery_receipt = 0; + account->options.req_read_receipt = 0; + account->options.download_limit = 0; + account->options.block_address = 1; + account->options.block_subject = 1; + account->options.display_name_from = NULL; + account->options.reply_with_body = 1; + account->options.forward_with_files = 1; + account->options.add_myname_card = 0; + account->options.add_signature = 1; + account->options.signature = g_strdup(DEFAULT_SIGNATURE); + + if (!g_strcmp0(service_name, "Gmail")) + account->logo_icon_path = g_strdup(ACCOUNT_ICON_GMAIL); + else if (!g_strcmp0(service_name, "Hotmail")) + account->logo_icon_path = g_strdup(ACCOUNT_ICON_HOTMAIL); + else if (!g_strcmp0(service_name, "Yahoo")) + account->logo_icon_path = g_strdup(ACCOUNT_ICON_YAHOO); + else if (!g_strcmp0(service_name, "AOL")) + account->logo_icon_path = g_strdup(ACCOUNT_ICON_AOL); + else + account->logo_icon_path = g_strdup(ACCOUNT_ICON_OTHERS); + + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->outgoing_server_need_authentication = 1; + + account->incoming_server_type = incomming->protocol_type; + account->incoming_server_address = g_strdup(incomming->server_addr); + account->incoming_server_port_number = incomming->port_number; + account->incoming_server_secure_connection = incomming->security_type; + + account->outgoing_server_address = g_strdup(outgoing->server_addr); + account->outgoing_server_port_number = outgoing->port_number; + account->outgoing_server_secure_connection = outgoing->security_type; + account->outgoing_server_user_name = g_strdup(account->user_display_name); + account->outgoing_server_password = g_strdup(account->incoming_server_password); + + /*user data set*/ + account_user_data_t data; + data.index_color = rgb; + data.is_preset_account = preset_account; + data.show_images = 0; + data.send_read_report = 0; + data.pop3_deleting_option = 0; + + int data_len = sizeof(account_user_data_t); + account->user_data = calloc(1, data_len); + memcpy(account->user_data, (void *)&data, data_len); + account->user_data_length = data_len; + + _account_info_print(account); +} + +static void _set_gmail(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = vd->ugd; + email_account_t *account = NULL; + account = ugd->new_account; + + int rgb = 0x0000ffff; + + _set_user_name_with_email_addr(account->user_email_address, &(account->incoming_server_user_name)); + _set_display_name_with_email_addr(account->user_email_address, &(account->user_display_name)); + + account->account_name = g_strdup(dgettext("sys_string", "IDS_COM_BODY_GOOGLE")); + account->reply_to_address = g_strdup(account->user_email_address); + account->return_address = g_strdup(account->user_email_address); + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; /* EMAIL_IMAP4_RETRIEVAL_MODE_NEW; */ + + account->auto_download_size = 1024*10; /* downloading option, 0 is subject only, 1 is text body, 2 is normal. */ + account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3' */ + account->default_mail_slot_size = 25; + + account->pop_before_smtp = 0; + account->incoming_server_requires_apop = 0; + + account->options.priority = 3; + account->options.keep_local_copy = 1; + account->options.req_delivery_receipt = 0; + account->options.req_read_receipt = 0; + account->options.download_limit = 0; + account->options.block_address = 1; + account->options.block_subject = 1; + account->options.display_name_from = NULL; + account->options.reply_with_body = 1; + account->options.forward_with_files = 1; + account->options.add_myname_card = 0; + account->options.add_signature = 1; + account->options.signature = g_strdup(DEFAULT_SIGNATURE); + + account->logo_icon_path = g_strdup(ACCOUNT_ICON_GMAIL); + + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->outgoing_server_need_authentication = 1; + + /*account->user_display_name = g_strdup(account->user_display_name); + account->user_email_address = g_strdup("@gmail.com"); + account->incoming_server_password = g_strdup();*/ + + vconf_get_int("file/private/com.samsung.email/gmail_receiving_type", (int *)&(account->incoming_server_type)); + vconf_get_int("file/private/com.samsung.email/gmail_receiving_port", &(account->incoming_server_port_number)); + vconf_get_int("file/private/com.samsung.email/gmail_receiving_ssl", &(account->incoming_server_secure_connection)); + account->incoming_server_address = vconf_get_str("file/private/com.samsung.email/gmail_receiving_address"); + + vconf_get_int("file/private/com.samsung.email/gmail_sending_port", &(account->outgoing_server_port_number)); + vconf_get_int("file/private/com.samsung.email/gmail_sending_ssl", &(account->outgoing_server_secure_connection)); + account->outgoing_server_address = vconf_get_str("file/private/com.samsung.email/gmail_sending_address"); + account->outgoing_server_user_name = g_strdup(account->incoming_server_user_name); + account->outgoing_server_password = g_strdup(account->incoming_server_password); + + /*user data set*/ + account_user_data_t data; + data.index_color = rgb; + data.is_preset_account = GMAIL; + data.show_images = 0; + data.send_read_report = 0; + data.pop3_deleting_option = 0; + + int data_len = sizeof(account_user_data_t); + account->user_data = calloc(1, data_len); + memcpy(account->user_data, (void *)&data, data_len); + account->user_data_length = data_len; + + _account_info_print(account); +} + +static void _set_yahoomail(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = vd->ugd; + email_account_t *account = NULL; + account = ugd->new_account; + + int rgb = 0xdc143cff; + + _set_user_name_with_email_addr(account->user_email_address, &(account->incoming_server_user_name)); + _set_display_name_with_email_addr(account->user_email_address, &(account->user_display_name)); + + account->account_name = g_strdup(_("IDS_EMAIL_BODY_YAHOO_E_MAIL")); + account->reply_to_address = g_strdup(account->user_email_address); + account->return_address = g_strdup(account->user_email_address); + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; /* EMAIL_IMAP4_RETRIEVAL_MODE_NEW; */ + + account->auto_download_size = 1024*10; /* downloading option, 0 is subject only, 1 is text body, 2 is normal. */ + account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3' */ + account->default_mail_slot_size = 25; + + account->pop_before_smtp = 0; + account->incoming_server_requires_apop = 0; + + account->options.priority = 3; + account->options.keep_local_copy = 1; + account->options.req_delivery_receipt = 0; + account->options.req_read_receipt = 0; + account->options.download_limit = 0; + account->options.block_address = 1; + account->options.block_subject = 1; + account->options.display_name_from = NULL; + account->options.reply_with_body = 1; + account->options.forward_with_files = 1; + account->options.add_myname_card = 0; + account->options.add_signature = 1; + account->options.signature = g_strdup(DEFAULT_SIGNATURE); + + account->logo_icon_path = g_strdup(ACCOUNT_ICON_YAHOO); + + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->outgoing_server_need_authentication = 1; + + /*account->user_display_name = g_strdup(account->user_display_name); + account->user_email_address = g_strdup("@yahoo.com"); + account->incoming_server_password = g_strdup();*/ + + vconf_get_int("file/private/com.samsung.email/yahoo_receiving_type", (int *)&(account->incoming_server_type)); + vconf_get_int("file/private/com.samsung.email/yahoo_receiving_port", &(account->incoming_server_port_number)); + vconf_get_int("file/private/com.samsung.email/yahoo_receiving_ssl", &(account->incoming_server_secure_connection)); + account->incoming_server_address = vconf_get_str("file/private/com.samsung.email/yahoo_receiving_address"); + + account->outgoing_server_address = vconf_get_str("file/private/com.samsung.email/yahoo_sending_address"); + vconf_get_int("file/private/com.samsung.email/yahoo_sending_port", &(account->outgoing_server_port_number)); + vconf_get_int("file/private/com.samsung.email/yahoo_sending_ssl", &(account->outgoing_server_secure_connection)); + account->outgoing_server_user_name = g_strdup(account->incoming_server_user_name); + account->outgoing_server_password = g_strdup(account->incoming_server_password); + + /*user data set*/ + account_user_data_t data; + data.index_color = rgb; + data.is_preset_account = YAHOOMAIL; + data.show_images = 0; + data.send_read_report = 0; + data.pop3_deleting_option = 0; + + int data_len = sizeof(account_user_data_t); + account->user_data = calloc(1, data_len); + memcpy(account->user_data, (void *)&data, data_len); + account->user_data_length = data_len; + + _account_info_print(account); +} + +static void _set_hotmail(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = vd->ugd; + email_account_t *account = NULL; + account = ugd->new_account; + + int rgb = 0xdc143cff; + + /* hotmail use email address in user name field */ + account->incoming_server_user_name = g_strdup(account->user_email_address); + _set_display_name_with_email_addr(account->user_email_address, &(account->user_display_name)); + + account->account_name = g_strdup(_("IDS_EMAIL_BODY_WINDOWS_LIVE_HOTMAIL")); + account->reply_to_address = g_strdup(account->user_email_address); + account->return_address = g_strdup(account->user_email_address); + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; /* EMAIL_IMAP4_RETRIEVAL_MODE_NEW; */ + + account->auto_download_size = 1024*10; /* downloading option, 0 is subject only, 1 is text body, 2 is normal. */ + account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3' */ + account->default_mail_slot_size = 25; + + account->pop_before_smtp = 0; + account->incoming_server_requires_apop = 0; + + account->options.priority = 3; + account->options.keep_local_copy = 1; + account->options.req_delivery_receipt = 0; + account->options.req_read_receipt = 0; + account->options.download_limit = 0; + account->options.block_address = 1; + account->options.block_subject = 1; + account->options.display_name_from = NULL; + account->options.reply_with_body = 1; + account->options.forward_with_files = 1; + account->options.add_myname_card = 0; + account->options.add_signature = 1; + account->options.signature = g_strdup(DEFAULT_SIGNATURE); + + account->logo_icon_path = g_strdup(ACCOUNT_ICON_HOTMAIL); + + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->outgoing_server_need_authentication = 1; + + /*account->user_display_name = g_strdup(account->user_display_name); + account->user_email_address = g_strdup("@aol.com"); + account->incoming_server_password = g_strdup();*/ + + vconf_get_int("file/private/com.samsung.email/hotmail_receiving_type", (int *)&(account->incoming_server_type)); + vconf_get_int("file/private/com.samsung.email/hotmail_receiving_port", &(account->incoming_server_port_number)); + vconf_get_int("file/private/com.samsung.email/hotmail_receiving_ssl", &(account->incoming_server_secure_connection)); + account->incoming_server_address = vconf_get_str("file/private/com.samsung.email/hotmail_receiving_address"); + + account->outgoing_server_address = vconf_get_str("file/private/com.samsung.email/hotmail_sending_address"); + vconf_get_int("file/private/com.samsung.email/hotmail_sending_port", &(account->outgoing_server_port_number)); + vconf_get_int("file/private/com.samsung.email/hotmail_sending_ssl", &(account->outgoing_server_secure_connection)); + account->outgoing_server_user_name = g_strdup(account->incoming_server_user_name); + account->outgoing_server_password = g_strdup(account->incoming_server_password); + + /*user data set*/ + account_user_data_t data; + data.index_color = rgb; + data.is_preset_account = HOTMAIL; + data.show_images = 0; + data.send_read_report = 0; + data.pop3_deleting_option = 0; + + int data_len = sizeof(account_user_data_t); + account->user_data = calloc(1, data_len); + memcpy(account->user_data, (void *)&data, data_len); + account->user_data_length = data_len; + + _account_info_print(account); +} + +static void _set_aol(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = vd->ugd; + email_account_t *account = NULL; + account = ugd->new_account; + + int rgb = 0xdaa520ff; + + account->incoming_server_user_name = g_strdup(account->user_email_address); + _set_display_name_with_email_addr(account->user_email_address, &(account->user_display_name)); + + account->account_name = g_strdup(_("IDS_EMAIL_BODY_AOL")); + account->reply_to_address = g_strdup(account->user_email_address); + account->return_address = g_strdup(account->user_email_address); + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; /* EMAIL_IMAP4_RETRIEVAL_MODE_NEW; */ + + account->auto_download_size = 1024*10; /* downloading option, 0 is subject only, 1 is text body, 2 is normal. */ + account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3' */ + account->default_mail_slot_size = 25; + + account->pop_before_smtp = 0; + account->incoming_server_requires_apop = 0; + + account->options.priority = 3; + account->options.keep_local_copy = 1; + account->options.req_delivery_receipt = 0; + account->options.req_read_receipt = 0; + account->options.download_limit = 0; + account->options.block_address = 1; + account->options.block_subject = 1; + account->options.display_name_from = NULL; + account->options.reply_with_body = 1; + account->options.forward_with_files = 1; + account->options.add_myname_card = 0; + account->options.add_signature = 1; + account->options.signature = g_strdup(DEFAULT_SIGNATURE); + + account->logo_icon_path = g_strdup(ACCOUNT_ICON_AOL); + + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->outgoing_server_need_authentication = 1; + + /*account->user_display_name = g_strdup(account->user_display_name); + account->user_email_address = g_strdup("@aol.com"); + account->incoming_server_password = g_strdup();*/ + + vconf_get_int("file/private/com.samsung.email/aol_receiving_type", (int *)&(account->incoming_server_type)); + vconf_get_int("file/private/com.samsung.email/aol_receiving_port", &(account->incoming_server_port_number)); + vconf_get_int("file/private/com.samsung.email/aol_receiving_ssl", &(account->incoming_server_secure_connection)); + account->incoming_server_address = vconf_get_str("file/private/com.samsung.email/aol_receiving_address"); + + account->outgoing_server_address = vconf_get_str("file/private/com.samsung.email/aol_sending_address"); + vconf_get_int("file/private/com.samsung.email/aol_sending_port", &(account->outgoing_server_port_number)); + vconf_get_int("file/private/com.samsung.email/aol_sending_ssl", &(account->outgoing_server_secure_connection)); + account->outgoing_server_user_name = g_strdup(account->incoming_server_user_name); + account->outgoing_server_password = g_strdup(account->incoming_server_password); + + /*user data set*/ + account_user_data_t data; + data.index_color = rgb; + data.is_preset_account = AOL; + data.show_images = 0; + data.send_read_report = 0; + data.pop3_deleting_option = 0; + + int data_len = sizeof(account_user_data_t); + account->user_data = calloc(1, data_len); + memcpy(account->user_data, (void *)&data, data_len); + account->user_data_length = data_len; + + _account_info_print(account); +} + +static void _set_others(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = vd->ugd; + email_account_t *account = NULL; + account = ugd->new_account; + + int rgb = 0x006400ff; + + _set_display_name_with_email_addr(account->user_email_address, &(account->user_display_name)); + _set_user_name_with_email_addr(account->user_email_address, &(account->incoming_server_user_name)); + + account->reply_to_address = g_strdup(account->user_email_address); + account->return_address = g_strdup(account->user_email_address); + account->retrieval_mode = EMAIL_IMAP4_RETRIEVAL_MODE_ALL; /* EMAIL_IMAP4_RETRIEVAL_MODE_NEW; */ + + account->auto_download_size = 1024*10; /* downloading option, 0 is subject only, 1 is text body, 2 is normal. */ + account->outgoing_server_use_same_authenticator = 1; /* Specifies the 'Same as POP3' option, 0 is none, 1 is 'Same as POP3' */ + account->default_mail_slot_size = 25; + + account->pop_before_smtp = 0; + account->incoming_server_requires_apop = 0; + + account->options.priority = 3; + account->options.keep_local_copy = 1; + account->options.req_delivery_receipt = 0; + account->options.req_read_receipt = 0; + account->options.download_limit = 0; + account->options.block_address = 1; + account->options.block_subject = 1; + account->options.display_name_from = NULL; + account->options.reply_with_body = 1; + account->options.forward_with_files = 1; + account->options.add_myname_card = 0; + account->options.add_signature = 1; + account->options.signature = g_strdup(DEFAULT_SIGNATURE); + + account->logo_icon_path = g_strdup(ACCOUNT_ICON_OTHERS); + + account->outgoing_server_type = EMAIL_SERVER_TYPE_SMTP; + account->outgoing_server_need_authentication = 1; + + /*account->account_name = ; + account->user_display_name = g_strdup(account->user_display_name); + account->user_email_address = ; + account->incoming_server_password = ; + + account->incoming_server_type = ; + account->incoming_server_address = ; + account->incoming_server_port_number = ; + account->incoming_server_secure_connection = ; + + account->outgoing_server_address = ); + account->outgoing_server_port_number = ; + account->outgoing_server_secure_connection = ; + account->outgoing_server_user_name = g_strdup(account->user_display_name);*/ + account->outgoing_server_password = g_strdup(account->incoming_server_password); + account->outgoing_server_user_name = g_strdup(account->incoming_server_user_name); + + /*user data set*/ + account_user_data_t data; + data.index_color = rgb; + data.is_preset_account = 0; + data.show_images = 0; + data.send_read_report = 0; + data.pop3_deleting_option = 0; + + int data_len = sizeof(account_user_data_t); + account->user_data = calloc(1, data_len); + memcpy(account->user_data, (void *)&data, data_len); + account->user_data_length = data_len; + + _account_info_print(account); +} + +static void _set_user_name_with_email_addr(char *email_addr, char **user_name) +{ + debug_log(""); + + if (!email_addr) { + debug_log("email_addr is NULL"); + return; + } + + char *buf; + + buf = g_strdup(email_addr); + *user_name = g_strdup(strtok(buf, "@")); + debug_log("email address : %s", email_addr); + debug_log("buf email address :%s", buf); + debug_log("user_name :%s", *user_name); + free(buf); +} + +static void _set_display_name_with_email_addr(char *email_addr, char **display_name) +{ + debug_log(""); + + if (!email_addr) { + debug_log("email_addr is NULL"); + return; + } + + char *buf; + + buf = g_strdup(email_addr); + *display_name = g_strdup(strtok(buf, "@")); + debug_log("email address : %s", email_addr); + debug_log("buf email address :%s", buf); + debug_log("display_name :%s", *display_name); + free(buf); +} + +static void _account_info_print(email_account_t *account) +{ + debug_log(""); + + if (!account) { + debug_log("account is NULL"); + return; + } + + debug_log("account name: %s", account->account_name); + debug_log("incoming server user name: %s", account->incoming_server_user_name); + debug_log("user display name: %s", account->user_display_name); + debug_log("user email addr: %s", account->user_email_address); + + debug_log("incoming server address: %s", account->incoming_server_address); + debug_log("outgoing server address: %s", account->outgoing_server_address); + + debug_log("incoming server type: %d", account->incoming_server_type); + debug_log("incoming server port :%d", account->incoming_server_port_number); + debug_log("incoming server ssl : %d", account->incoming_server_secure_connection); + + debug_log("outgoing server port: %d", account->outgoing_server_port_number); + debug_log("outgoing server ssl: %d", account->outgoing_server_secure_connection); + debug_log("outgoing server user name: %s", account->outgoing_server_user_name); + debug_log("outgoing server password: %s", account->outgoing_server_password); + +} + +/* EOF */ diff --git a/setting/src/email-setting-utils.c b/setting/src/email-setting-utils.c new file mode 100755 index 0000000..e637358 --- /dev/null +++ b/setting/src/email-setting-utils.c @@ -0,0 +1,723 @@ +/* + * 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" +#include "email-view-manual-setup.h" +#include "email-view-account-setup.h" +#include "email-view-account-edit.h" +#include "email-view-sp-select.h" +#include "email-view-sync-schedule.h" +#include "email-view-sync-setup.h" +#include "stdarg.h" + + +Evas_Object *setting_get_notify(struct viewdata *vd, char *header, + char *content, int btn_num, char *btn1_lb, popup_cb resp_cb1, + char *btn2_lb, popup_cb resp_cb2) +{ + debug_log(""); + + Evas_Object *notify; + + notify = elm_popup_add(vd->ugd->win); + if (!notify) { + debug_log("elm_popup_add returns NULL"); + return NULL; + } + evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if (header) { + elm_object_part_text_set(notify, "title,text", header); + } + + if (content) { + elm_object_text_set(notify, content); + } + + if (btn_num == 1) { + Evas_Object *btn1 = elm_button_add(notify); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, btn1_lb); + elm_object_part_content_set(notify, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd); + } + if (btn_num == 2) { + Evas_Object *btn1 = elm_button_add(notify); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, btn1_lb); + elm_object_part_content_set(notify, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd); + + Evas_Object *btn2 = elm_button_add(notify); + elm_object_style_set(btn2, "popup_button/default"); + elm_object_text_set(btn2, btn2_lb); + elm_object_part_content_set(notify, "button2", btn2); + evas_object_smart_callback_add(btn2, "clicked", resp_cb2, vd); + } + + evas_object_show(notify); + + return notify; +} + +Evas_Object *setting_get_pb_notify(struct viewdata *vd, char *header, + int btn_num, char *btn1_lb, popup_cb resp_cb1, + char *btn2_lb, popup_cb resp_cb2) +{ + debug_log(""); + + Evas_Object *notify, *progressbar; + + notify = elm_popup_add(vd->ugd->win); + if (!notify) { + debug_log("elm_popup_add returns NULL"); + return NULL; + } + evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + if (header) { + elm_object_part_text_set(notify, "title,text", header); + } + + progressbar = elm_progressbar_add(notify); + elm_object_style_set(progressbar, "pending_list"); + elm_progressbar_horizontal_set(progressbar, EINA_TRUE); + evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(progressbar, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(progressbar); + elm_progressbar_pulse(progressbar, EINA_TRUE); + + elm_object_content_set(notify, progressbar); + + if (btn_num == 1) { + Evas_Object *btn1 = elm_button_add(notify); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, btn1_lb); + elm_object_part_content_set(notify, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd); + } + if (btn_num == 2) { + Evas_Object *btn1 = elm_button_add(notify); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, btn1_lb); + elm_object_part_content_set(notify, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd); + + Evas_Object *btn2 = elm_button_add(notify); + elm_object_style_set(btn2, "popup_button/default"); + elm_object_text_set(btn2, btn2_lb); + elm_object_part_content_set(notify, "button2", btn2); + evas_object_smart_callback_add(btn2, "clicked", resp_cb2, vd); + } + + evas_object_show(notify); + + return notify; +} + +Evas_Object *setting_get_list_notify(struct viewdata *vd, char *header, + int btn_num, char *btn1_lb, popup_cb resp_cb1, + char *btn2_lb, popup_cb resp_cb2, Evas_Object *content) +{ + debug_log(""); + + Evas_Object *notify; + + notify = elm_popup_add(vd->ugd->win); + if (!notify) { + debug_log("elm_popup_add returns NULL"); + return NULL; + } + evas_object_size_hint_weight_set(notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_style_set(notify, "menustyle"); + + if (header) { + elm_object_part_text_set(notify, "title,text", header); + } + + if (btn_num == 1) { + Evas_Object *btn1 = elm_button_add(notify); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, btn1_lb); + elm_object_part_content_set(notify, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd); + } + + if (btn_num == 2) { + Evas_Object *btn1 = elm_button_add(notify); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, btn1_lb); + elm_object_part_content_set(notify, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", resp_cb1, vd); + + Evas_Object *btn2 = elm_button_add(notify); + elm_object_style_set(btn2, "popup_button/default"); + elm_object_text_set(btn2, btn2_lb); + elm_object_part_content_set(notify, "button2", btn2); + evas_object_smart_callback_add(btn2, "clicked", resp_cb2, vd); + } + + elm_object_content_set(notify, content); + evas_object_show(notify); + + return notify; +} + +Evas_Object *setting_get_small_notify(struct viewdata *vd, char *label) +{ + debug_log(""); + + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->small_noti) { + evas_object_del(ugd->small_noti); + ugd->small_noti = NULL; + } + + if (ugd->small_noti_ly) { + evas_object_del(ugd->small_noti_ly); + ugd->small_noti_ly = NULL; + } + + ugd->small_noti = elm_notify_add(ugd->layout_main); + elm_notify_orient_set(ugd->small_noti, ELM_NOTIFY_ORIENT_BOTTOM); + ugd->small_noti_ly = elm_layout_add(ugd->layout_main); + elm_layout_theme_set(ugd->small_noti_ly, "standard", "selectioninfo", "vertical/bottom_64"); + elm_object_content_set(ugd->small_noti, ugd->small_noti_ly); + char text[128] = {0,}; + snprintf(text, sizeof(text), "%s", label); + edje_object_part_text_set(elm_layout_edje_get(ugd->small_noti_ly), "elm.text", text); + elm_notify_timeout_set(ugd->small_noti, 2); + evas_object_show(ugd->small_noti); + + return ugd->small_noti; +} + +Evas_Object *setting_add_inner_layout(struct viewdata *vd) +{ + debug_log(""); + + if (vd == NULL) { + debug_log("vd == NULL"); + return NULL; + } + + Evas_Object *ly = NULL; + + if (vd->ly == NULL) { + debug_log("vd->ly == NULL"); + return NULL; + } + + ly = elm_layout_add(vd->ugd->navi_bar); + elm_layout_theme_set(ly, "layout", "application", "noindicator"); + evas_object_size_hint_weight_set(ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + + return ly; +} + +gboolean setting_get_validation(char *email_addr) +{ + debug_log(""); + int count_at = 0, i = 0; + + setting_delete_enter(email_addr); + debug_log("email address is %s", email_addr); + + for (i = 0; email_addr[i]; i++) { + if (email_addr[i] == '.' || + (email_addr[i] >= '0' && email_addr[i] <= '9') || + (email_addr[i] >= 'A' && email_addr[i] <= 'Z') || + (email_addr[i] >= 'a' && email_addr[i] <= 'z')) { + debug_log("Valide ID %c", email_addr[i]); + } else if (email_addr[i] == '@') { + count_at++; + if (count_at > 1) { + debug_log("Invalid ID: '@' occurance more than once"); + return FALSE; + } + } else { + debug_log("Invalid ID: Special character present"); + return FALSE; + } + + } + + if (count_at != 1) { + debug_log("Invalid ID: '@' not present"); + return FALSE; + } + + return TRUE; +} + +gboolean setting_new_acct_init(struct viewdata *vd) +{ + debug_log(""); + retv_if(vd == NULL, FALSE); + EmailSettingUGD *ugd = vd->ugd; + + ugd->new_account = NULL; + ugd->new_account = malloc(sizeof(email_account_t)); + if (!ugd->new_account) + return FALSE; + memset(ugd->new_account, 0x00, sizeof(email_account_t)); + + return TRUE; + +} + +gboolean setting_new_acct_final(struct viewdata *vd) +{ + debug_log(""); + int r = 0; + + retv_if(vd == NULL, FALSE); + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->new_account != NULL) { + r = email_engine_free_account_list(&(ugd->new_account), 1); + retv_if(r == FALSE, FALSE); + } + ugd->new_account = NULL; + return TRUE; +} + +gboolean setting_update_acct_list(struct viewdata *vd) +{ + debug_log(""); + int r = 0; + + retv_if(vd == NULL, FALSE); + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->account_list != NULL) { + r = email_engine_free_account_list(&(ugd->account_list), ugd->account_count); + retv_if(r == FALSE, FALSE); + } + + ugd->account_list = NULL; + r = email_engine_get_account_list(&(ugd->account_count), &(ugd->account_list)); + retv_if(r == FALSE, FALSE); + + return TRUE; +} + +gboolean setting_get_acct_full_data(int acctid, email_account_t **_account) +{ + debug_log(""); + int r = 0; + + if (*_account != NULL) { + r = email_engine_free_account_list(_account, 1); + retv_if(r == FALSE, FALSE); + } + *_account = NULL; + r = email_engine_get_account_full_data(acctid, _account); + retv_if(r == FALSE, FALSE); + + return TRUE; +} + +void setting_edbus_event_receive(void *local_data, DBusMessage *message) +{ + debug_log(""); + + DBusError error; + EmailSettingUGD *ugd = (EmailSettingUGD *)local_data; + RETURN_IF_FAIL(ugd != NULL); + + if (dbus_message_is_signal(message, "User.Email.StorageChange", "email")) { + debug_log("User.Email.StorageChange"); + + int subtype = 0; + int data1 = 0; + int data2 = 0; + char *data3 = NULL; + dbus_error_init(&error); + + if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype, + DBUS_TYPE_INT32, &data1, DBUS_TYPE_INT32, &data2, + DBUS_TYPE_STRING, &data3, DBUS_TYPE_INVALID)) { + debug_log("subtype: %d, data1: %d, data2: %d, date3: %s", subtype, data1, data2, data3); + + switch (subtype) { + case NOTI_ACCOUNT_ADD: + debug_log("account added"); + if (g_strcmp0(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP) == 0) { + + if (ugd->account_info >= HOTMAIL && ugd->account_info <= OTHERS) { + if (!ugd->start_account_validation) { + ug_destroy_me(ugd->ug); + } + } else { + ug_destroy_me(ugd->ug); + } + } else { + if (ugd->b_on_pause) { + setting_refresh_view(ugd); + } + } + + break; + + case NOTI_ACCOUNT_UPDATE: + debug_log("account updated"); + if (ugd->b_on_pause) { + setting_refresh_view(ugd); + } + break; + + case NOTI_ACCOUNT_DELETE: + if (ugd->b_on_pause) { + debug_log("account deleted during pause status"); + setting_refresh_view(ugd); + } + + break; + + default: + debug_warning("unknown type"); + break; + } + } else { + debug_critical("receive data error: %s", error.message); + dbus_error_free(&error); + } + } else if (dbus_message_is_signal(message, "User.Email.NetworkStatus", "email")) { + debug_log("User.Email.NetworkStatus"); + + int subtype = 0; + int data1 = 0; + char *data2 = NULL; + int data3 = 0; + int data4 = 0; + char *type = NULL; + + dbus_error_init(&error); + + if (dbus_message_get_args(message, &error, DBUS_TYPE_INT32, &subtype, + DBUS_TYPE_INT32, &data1, DBUS_TYPE_STRING, &data2, + DBUS_TYPE_INT32, &data3, DBUS_TYPE_INT32, &data4, DBUS_TYPE_INVALID)) { + debug_log("subtype: %d, data1: %d, data2: %s, data3: %d, data4: %d", subtype, data1, data2, data3, data4); + struct viewdata *vd; + Viewtype top; + + switch (subtype) { + case NOTI_VALIDATE_ACCOUNT_FINISH: + /* Validation Success */ + debug_log("Validation Success"); + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + debug_log("Account edit view will be called"); + setting_edit_validation_success_cb(ugd); + } + break; + + case NOTI_VALIDATE_ACCOUNT_FAIL: + /* Validation Failed */ + debug_log("validation failed"); + ugd->err_code = data4; + type = setting_get_service_fail_type(ugd->err_code); + debug_log("%s", type); + g_free(type); + + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + debug_log("Account edit view will be called"); + setting_edit_validation_failed_cb(ugd, FALSE); + } + break; + + case NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FINISH: + debug_log("validation_and_update finish"); + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + debug_log("Account edit view will be called"); + setting_edit_validation_success_cb(ugd); + } + break; + + case NOTI_VALIDATE_AND_UPDATE_ACCOUNT_FAIL: + debug_log("validation_and_update fail"); + + /*if (ugd->handle != data3) { + debug_log("handle is different"); + break; + }*/ + + ugd->err_code = data4; + type = setting_get_service_fail_type(ugd->err_code); + debug_log("%s", type); + g_free(type); + + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + debug_log("Account edit view will be called"); + setting_edit_validation_failed_cb(ugd, FALSE); + } + break; + + case NOTI_VALIDATE_AND_UPDATE_ACCOUNT_CANCEL: + debug_log("validation_and_update cancel"); + + /*if (ugd->handle != data3) { + debug_log("handle is different"); + break; + }*/ + + ugd->err_code = data4; + type = setting_get_service_fail_type(ugd->err_code); + debug_log("%s", type); + g_free(type); + + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + debug_log("Account edit view will be called"); + setting_edit_validation_failed_cb(ugd, TRUE); + } + break; + + case NOTI_VALIDATE_AND_CREATE_ACCOUNT_FINISH: + debug_log("validation_and_create finish"); + ugd->account_id = data1; + + if (ugd->b_on_pause) { + debug_log("account added during pause status"); + if (g_strcmp0(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP) != 0) { + setting_refresh_view(ugd); + } + } + + if (!ugd->start_account_validation) { + break; + } + ugd->start_account_validation = 0; + + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + if (ugd->manual_setup == 1 && ugd->wds_account_creation != 1) { + debug_log("Server type view will be called"); + setting_manual_validation_success_cb(ugd); + } else { + debug_log("Other account view will be called"); + setting_account_validation_success_cb(ugd); + } + } + break; + + case NOTI_VALIDATE_AND_CREATE_ACCOUNT_FAIL: + debug_log("validation_and_create faild"); + + if (ugd->handle != data3) { + debug_log("handle is different"); + break; + } + + if (!ugd->start_account_validation) { + break; + } + ugd->start_account_validation = 0; + + ugd->err_code = data4; + type = setting_get_service_fail_type(ugd->err_code); + debug_log("%s", type); + g_free(type); + + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + if (ugd->manual_setup == 1 && ugd->wds_account_creation != 1) { + debug_log("Server type view will be called"); + setting_manual_validation_failed_cb(ugd, FALSE); + } else { + debug_log("Other account view will be called"); + setting_account_validation_failed_cb(ugd, FALSE); + } + } + break; + + case NOTI_VALIDATE_AND_CREATE_ACCOUNT_CANCEL: + debug_log("validation_and_create cancel"); + + if (ugd->handle != data3) { + debug_log("handle is different"); + break; + } + + if (!ugd->start_account_validation) { + break; + } + ugd->start_account_validation = 0; + + ugd->err_code = data4; + type = setting_get_service_fail_type(ugd->err_code); + debug_log("%s", type); + g_free(type); + + if (ugd->end_key_event != 1 && ugd->cancel_event != 1) { + if (ugd->manual_setup == 1 && ugd->wds_account_creation != 1) { + debug_log("Server type view will be called"); + setting_manual_validation_failed_cb(ugd, TRUE); + } else { + debug_log("Other account view will be called"); + setting_account_validation_failed_cb(ugd, TRUE); + } + } + break; + + case NOTI_DOWNLOAD_START: + top = ugd->view_st[ugd->view_top]; + vd = ugd->vd[top]; + if (vd->type == VIEW_SYNC_SETUP) + setting_setup_sync_started(vd, (int)data1); + else if (vd->type == VIEW_SYNC_SCHEDULE) + setting_schedule_sync_started(vd, (int)data1); + break; + case NOTI_DOWNLOAD_FINISH: + case NOTI_DOWNLOAD_FAIL: + case NOTI_DOWNLOAD_CANCEL: + top = ugd->view_st[ugd->view_top]; + vd = ugd->vd[top]; + if (vd->type == VIEW_SYNC_SETUP) + setting_setup_sync_finished(vd, (int)data1); + else if (vd->type == VIEW_SYNC_SCHEDULE) + setting_schedule_sync_finished(vd, (int)data1); + break; + + default: + debug_warning("unknown type"); + break; + } + } else { + debug_critical("receive data error: %s", error.message); + dbus_error_free(&error); + } + } else { + debug_warning("We receive dbus message, but we can't do anything"); + } +} + +void setting_delete_enter(char *string) +{ + debug_log(""); + int i = 0; + + for (i = 0; string[i]; i++) { + if (string[i] == 10) { + debug_log("find enter %d", i); + string[i] = 32; + } + } +} + +char *setting_get_service_fail_type(int type) +{ + debug_log(""); + + char *ret = NULL; + char str[MAX_STR_LEN] = { 0, }; + + if (type == EMAIL_ERROR_NETWORK_TOO_BUSY) { + ret = _("IDS_EMAIL_POP_NETWORK_BUSY"); + return strdup(ret); + } else if (type == EMAIL_ERROR_LOGIN_ALLOWED_EVERY_15_MINS) { + snprintf(str, sizeof(str), _("IDS_EMAIL_POP_YOU_CAN_ONLY_LOG_IN_ONCE_EVERY_PD_MINUTES"), 15); + return strdup(str); + } else if (type == EMAIL_ERROR_CONNECTION_FAILURE) { + ret = dgettext("sys_string", "IDS_COM_POP_CONNECTION_FAILED"); + return strdup(ret); + } else if (type == EMAIL_ERROR_LOGIN_FAILURE) { + ret = _("IDS_EMAIL_POP_INCORRECT_USER_NAME_OR_PASSWORD"); + return strdup(ret); + } else if (type == EMAIL_ERROR_AUTHENTICATE) { + ret = _("IDS_EMAIL_POP_AUTHENTICATION_FAILED"); + return strdup(ret); + } else if (type == EMAIL_ERROR_CANCELLED) { + ret = _("IDS_EMAIL_POP_DOWNLOAD_CANCELLED"); + return strdup(ret); + } else if (type == EMAIL_ERROR_MAIL_NOT_FOUND_ON_SERVER) { + ret = _("IDS_EMAIL_POP_EMAIL_DELETED_FROM_SERVER"); + return strdup(ret); + } else if (type == EMAIL_ERROR_NO_SUCH_HOST) { + ret = _("IDS_EMAIL_POP_HOST_NOT_FOUND"); + return strdup(ret); + } else if (type == EMAIL_ERROR_INVALID_SERVER) { + ret = _("IDS_EMAIL_POP_SERVER_NOT_AVAILABLE"); + return strdup(ret); + } else if (type == EMAIL_ERROR_MAIL_MEMORY_FULL) { + ret = _("IDS_EMAIL_POP_DEVICE_STORAGE_FULL"); + return strdup(ret); + } else if (type == EMAIL_ERROR_NETWORK_NOT_AVAILABLE) { + ret = N_("Network not available"); + return strdup(ret); + } else if (type == EMAIL_ERROR_SECURED_STORAGE_FAILURE) { + ret = N_("Secure storage failure"); + return strdup(ret); + } else if (type == EMAIL_ERROR_TOO_MANY_LOGIN_FAILURE) { + ret = N_("Too many login failure"); + return strdup(ret); + } else if (type == EMAIL_ERROR_FAILED_BY_SECURITY_POLICY) { + ret = N_("Failed by security policy"); + return strdup(ret); + } else if (type == EMAIL_ERROR_VALIDATE_ACCOUNT) { + ret = N_("Validate account failure"); + return strdup(ret); + } else if (type == EMAIL_ERROR_FLIGHT_MODE) { + ret = N_("Flight mode enabled"); + return strdup(ret); + } else if (type == EMAIL_ERROR_NO_SIM_INSERTED) { + ret = N_("No SIM inserted"); + return strdup(ret); + } else if (type == EMAIL_ERROR_AUTH_REQUIRED) { + ret = N_("Authentication required"); + return strdup(ret); + } else if (type == EMAIL_ERROR_SYSTEM_FAILURE) { + ret = N_("Sytem failure"); + return strdup(ret); + } else if (type == EMAIL_ERROR_CANCELLED) { + ret = N_("Canceled by user"); + return strdup(ret); + } else if (type == EMAIL_ERROR_CERTIFICATE_FAILURE) { + ret = N_("Certificate failure"); + return strdup(ret); + } else if (type == EMAIL_ERROR_AUTH_NOT_SUPPORTED) { + ret = N_("Authentication not supported"); + return strdup(ret); + } else if (type == EMAIL_ERROR_NO_RESPONSE) { + ret = N_("No server response"); + return strdup(ret); + } else if (type == EMAIL_ERROR_DISCONNECTED) { + ret = N_("Connection disconnected"); + return strdup(ret); + } else if (type == EMAIL_ERROR_CONNECTION_BROKEN) { + ret = N_("Connection was broken"); + return strdup(ret); + } else if (type == EMAIL_ERROR_SOCKET_FAILURE) { + ret = N_("Socket operation failed"); + return strdup(ret); + } else if (type == EMAIL_ERROR_DB_FAILURE) { + ret = N_("DB operation failed"); + return strdup(ret); + } else if (type == EMAIL_ERROR_ALREADY_EXISTS) { + ret = N_("Already exists"); + return strdup(ret); + } else if (type == EMAIL_ERROR_TLS_NOT_SUPPORTED) { + ret = N_("Server not support TLS"); + return strdup(ret); + } else if (type == EMAIL_ERROR_TLS_SSL_FAILURE) { + ret = N_("TLS/SSL failure"); + return strdup(ret); + } else { + snprintf(str, sizeof(str), "%s (%d)", dgettext("sys_string", "IDS_COM_POP_INTERNAL_ERROR"), type); + return strdup(str); + } +} + +/* EOF */ diff --git a/setting/src/email-setting-view.c b/setting/src/email-setting-view.c new file mode 100755 index 0000000..e152965 --- /dev/null +++ b/setting/src/email-setting-view.c @@ -0,0 +1,324 @@ +/* + * 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" + +static void _create_view(struct viewdata *vd, EmailSettingUGD *ugd); +static void _update_view(struct viewdata *vd); +static void _show_view(struct viewdata *vd); +static void _destroy_view(struct viewdata *vd); +/*static void _hide_view(struct viewdata *vd);*/ + +static int _get_backtype(Viewtype *p, Viewtype *c, EmailSettingUGD *ugd); +static int _get_viewtype(Viewtype v, Viewtype *p, Viewtype *c, EmailSettingUGD *ugd); +static int _update_view_stack(Viewtype v, Viewtype c, EmailSettingUGD *ugd); + +static void _create_view(struct viewdata *vd, EmailSettingUGD *ugd) +{ + debug_log(""); + + if (!ugd || !vd) { + debug_log("data is NULL"); + return; + } + + vd->ly = ugd->layout_main; + if (vd->ly == NULL) { + debug_log("layout is NULL"); + } + + evas_object_show(vd->ly); + + if (vd->create) { + vd->create(vd); + } +} + +static void _update_view(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + if (vd->update) { + vd->update(vd); + } +} + +static void _show_view(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + if (vd->show) + vd->show(vd); + + evas_object_show(vd->ly); +} + +static void _destroy_view(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + if (vd->destroy) + vd->destroy(vd); + + if (vd->priv) { + g_free(vd->priv); + vd->priv = NULL; + } +} + +static int _get_backtype(Viewtype *p, Viewtype *c, EmailSettingUGD *ugd) +{ + debug_log(""); + struct viewdata *vd; + Viewtype top; + + if (!ugd) { + debug_log("ugd is NULL"); + return FALSE; + } + + if (ugd->view_top < 0) { + debug_log("Stack is empty, exit"); + return FALSE; + } + + top = ugd->view_st[ugd->view_top]; + vd = ugd->vd[top]; + + /*_hide_view(vd);*/ + debug_log("backview id %d", top); + elm_naviframe_item_pop(ugd->navi_bar); + _destroy_view(vd); + + if (ugd->view_top == 0) { + ug_destroy_me(ugd->ug); + return FALSE; + } + + *p = ugd->view_st[ugd->view_top]; + *c = ugd->view_st[ugd->view_top - 1]; + + return TRUE; +} + +static int _get_viewtype(Viewtype v, Viewtype *p, Viewtype *c, EmailSettingUGD *ugd) +{ + debug_log(""); + + if (!ugd) { + debug_log("ugd is NULL"); + return FALSE; + } + + if (v == VIEW_BACK) + return _get_backtype(p, c, ugd); + + *c = v; + if (ugd->view_top == -1) + *p = v; + else + *p = ugd->view_st[ugd->view_top]; + + return TRUE; +} + +static int _update_view_stack(Viewtype v, Viewtype c, EmailSettingUGD *ugd) +{ + debug_log(""); + int flag = 0; + int count = 0; + int i = 0; + + if (!ugd) { + debug_log("ugd is NULL"); + return FALSE; + } + + if (v == VIEW_BACK) { + ugd->view_top--; + return TRUE; + } + + for (count = 0; count < ugd->view_top; count++) { + if (c == ugd->view_st[count]) { + flag = 1; + i = count; + while (i < ugd->view_top) { + ugd->view_st[i] = ugd->view_st[i + 1]; + debug_log("count %d, ugd->view_st[count] %d", i, ugd->view_st[i]); + i++; + } + ugd->view_st[ugd->view_top] = c; + return FALSE; + } + } + + if (!flag) { + ugd->view_top++; + ugd->view_st[ugd->view_top] = c; + } + + return TRUE; +} + +int setting_change_view(Viewtype vt, EmailSettingUGD *ugd) +{ + debug_log(""); + + struct viewdata *vd = NULL; + int r = 0; + Viewtype pre, cur; + + if (ugd == NULL) { + debug_log("ugd is NULL"); + return FALSE; + } + + ugd->change_view_ing = 1; + + /* Get Pre & Current view */ + r = _get_viewtype(vt, &pre, &cur, ugd); + if (!r) { + debug_log("_get_viewtype returns err"); + return FALSE; + } + + if (cur <= VIEW_BACK || cur >= VIEW_END) { + debug_log("Invalid viewtype: %d", cur); + return FALSE; + } + + if (ugd->vd[cur] == NULL) + debug_log("Current View is NULL"); + + if (ugd->vd[pre] == NULL) + debug_log("Pre View is NULL"); + + /* Update view stack */ + r = _update_view_stack(vt, cur, ugd); + vd = ugd->vd[cur]; + + /* Destroy view if it already created */ + if (!r) { + _destroy_view(vd); + } + + /* Create view */ + if (vd->priv == NULL) { + _create_view(vd, ugd); + } + + /* Update view if refresh flag is set */ + if (vd->refresh == 1) { + _update_view(vd); + } + + /* show up view */ + _show_view(vd); + + ugd->change_view_ing = 0; + + return TRUE; +} + +int setting_refresh_view(EmailSettingUGD *ugd) +{ + debug_log(""); + Viewtype top; + struct viewdata *vd = NULL; + + top = ugd->view_st[ugd->view_top]; + vd = ugd->vd[top]; + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + debug_log("Update view"); + _update_view(vd); + + return TRUE; +} + +int setting_back_to_prev_view(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + vd->refresh = 1; + setting_change_view(VIEW_BACK, vd->ugd); + + return TRUE; +} + +int setting_back_to_prev_nth_view(struct viewdata *vd, int back_n, Elm_Object_Item *navi_it) +{ + debug_log(""); + Viewtype top; + EmailSettingUGD *ugd = vd->ugd; + int nCount = 0; + + if (!ugd) { + debug_log("ugd is NULL"); + return FALSE; + } + + debug_log("ugd->view_top %d", ugd->view_top); + + if (ugd->view_top <= 0) { + debug_log("Stack is empty, exit"); + return FALSE; + } + + top = ugd->view_st[ugd->view_top]; + + while (nCount < back_n) { + _destroy_view(vd); + ugd->view_top--; + top = ugd->view_st[ugd->view_top]; + vd = ugd->vd[top]; + nCount++; + } + + elm_naviframe_item_pop_to(navi_it); + + _update_view(vd); + _show_view(vd); + + return TRUE; +} + +/* EOF */ diff --git a/setting/src/email-setting.c b/setting/src/email-setting.c new file mode 100755 index 0000000..db4b0c2 --- /dev/null +++ b/setting/src/email-setting.c @@ -0,0 +1,804 @@ +/* + * 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. + */ + +#ifndef UG_MODULE_API +#define UG_MODULE_API __attribute__ ((visibility("default"))) +#endif + +#include +#include +#include +#include + +#include "email-debug.h" +#include "email-setting.h" +#include "email-setting-utils.h" +#include "email-view-setting.h" +#include "email-view-sp-select.h" +#include "email-view-account-edit.h" +#include "email-view-account-setup.h" +#include "email-view-manual-setup.h" +#include "email-view-mailbox-mapping.h" +#include "email-view-account-options.h" +#include "email-view-initial.h" +#include "email-view-sync-schedule.h" +#include "email-view-sync-setup.h" + +static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv); +static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv); +static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv); +static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv); +static void on_destroy(ui_gadget_h ug, service_h service, void *priv); +static void on_resume(ui_gadget_h ug, service_h service, void *priv); +static void on_pause(ui_gadget_h ug, service_h service, void *priv); +static void on_start(ui_gadget_h ug, service_h service, void *priv); + +static void _init_data(struct ug_data *ugd); +static void _couple_data(struct ug_data *ugd, Viewtype t, struct viewdata *vd); +static void _dbus_receiver_setup(struct ug_data *ugd); +static void _remove_dbus_receiver(struct ug_data *ugd); +static int _account_init(struct ug_data *ugd); +static int _account_finalize(EmailSettingUGD *ugd); +static int _parse_option(service_h service, struct ug_data *ugd); +static void _dispatch_view(struct ug_data *ugd); +static void _create_navigationbar(struct ug_data *ugd); +static Evas_Object *_create_layout(Evas_Object *parent, struct ug_data *ugd); +static void _win_profile_changed_cb(void *data, Evas_Object *obj, void *event); + +static void _layout_block_cb(ui_gadget_h ug, enum ug_mode mode, void *priv); +static void _result_block_cb(ui_gadget_h ug, service_h service, void *priv); +static void _destroy_block_cb(ui_gadget_h ug, void *priv); + +static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info); + + +UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops) +{ + debug_log(""); + struct ug_data *ugd; + if (!ops) + return -1; + + ugd = calloc(1, sizeof(struct ug_data)); + if (!ugd) + return -1; + + ops->create = on_create; + ops->start = on_start; + ops->pause = on_pause; + ops->resume = on_resume; + ops->destroy = on_destroy; + ops->message = on_message; + ops->event = on_event; + ops->key_event = on_key_event; + ops->priv = ugd; + ops->opt = UG_OPT_INDICATOR_ENABLE; + + return 0; +} + +UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops) +{ + debug_log(""); + struct ug_data *ugd; + + if (!ops) + return; + + ugd = ops->priv; + if (ugd) + free(ugd); +} + +UG_MODULE_API int setting_plugin_reset(service_h service, void *priv) +{ + return 0; +} + +static void *on_create(ui_gadget_h ug, enum ug_mode mode, service_h service, void *priv) +{ + debug_log(""); + Evas_Object *parent; + struct ug_data *ugd; + + if (!ug || !priv) + return NULL; + + ugd = priv; + ugd->ug = ug; + + parent = ug_get_window(); + if (!parent) + return NULL; + + ugd->win = parent; + ugd->evas = evas_object_evas_get(ugd->win); + + bindtextdomain(PACKAGE, LOCALEDIR); + + ugd->block_cbs.layout_cb = _layout_block_cb; + ugd->block_cbs.result_cb = _result_block_cb; + ugd->block_cbs.destroy_cb = _destroy_block_cb; + ugd->block_cbs.priv = (void *)ugd; + + /* Init Setting View Data */ + _init_data(ugd); + + /* DBUS */ + _dbus_receiver_setup(ugd); + + /* theme extension */ + /*ugd->theme = elm_theme_new(); + elm_theme_ref_set(ugd->theme, NULL); + elm_theme_extension_add(ugd->theme, EV_THEME_PATH);*/ + + ugd->layout_main = _create_layout(parent, ugd); + evas_object_smart_callback_add(ugd->win, "profile,changed", _win_profile_changed_cb, ugd); + _create_navigationbar(ugd); + ugd->base = ugd->layout_main; + + return ugd->layout_main; +} + +static void on_event(ui_gadget_h ug, enum ug_event event, service_h service, void *priv) +{ + debug_log(""); + switch (event) { + case UG_EVENT_LOW_MEMORY: + break; + case UG_EVENT_LOW_BATTERY: + break; + case UG_EVENT_LANG_CHANGE: + break; + case UG_EVENT_ROTATE_PORTRAIT: + break; + case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN: + break; + case UG_EVENT_ROTATE_LANDSCAPE: + break; + case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN: + break; + case UG_EVENT_REGION_CHANGE: + break; + default: + break; + } + return; +} + +static void on_key_event(ui_gadget_h ug, enum ug_key_event event, service_h service, void *priv) +{ + debug_log(""); + + if (!ug || !priv) + return; + + EmailSettingUGD *ugd; + ugd = priv; + + switch (event) { + case UG_KEY_EVENT_END: + ugd->end_key_event = 1; + + if (elm_naviframe_top_item_get(ugd->navi_bar) == elm_naviframe_bottom_item_get(ugd->navi_bar)) { + if (ugd->popup_one != NULL || ugd->popup_validate != 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; + + ugd->cancel_event = 1; + email_engine_stop_working(ugd->account_id, ugd->handle); + } + } else { + ug_destroy_me(ug); + } + } else { + if (ugd->popup_one != NULL || ugd->popup_validate != 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; + + ugd->cancel_event = 1; + email_engine_stop_working(ugd->account_id, ugd->handle); + } + } else { + if (ugd->change_view_ing == 0) + setting_change_view(VIEW_BACK, ugd); + } + } + break; + + default: + break; + } +} + +static void on_message(ui_gadget_h ug, service_h msg, service_h service, void *priv) +{ + debug_log(""); + return; +} + +static void on_destroy(ui_gadget_h ug, service_h service, void *priv) +{ + debug_log(""); + EmailSettingUGD *ugd; + struct viewdata *vd = NULL; + int i, r = 0; + + if (!ug || !priv) + return; + + ugd = priv; + evas_object_del(ugd->base); + ugd->base = 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 (ugd->preset_vc_timer) { + ecore_timer_del(ugd->preset_vc_timer); + ugd->preset_vc_timer = NULL; + } + + if (ugd->other_vc_timer) { + ecore_timer_del(ugd->other_vc_timer); + ugd->other_vc_timer = NULL; + } + + if (ugd->edit_vc_timer) { + ecore_timer_del(ugd->edit_vc_timer); + ugd->edit_vc_timer = NULL; + } + + if (ugd->del_timer) { + ecore_timer_del(ugd->del_timer); + ugd->del_timer = NULL; + } + + /* theme extension */ + /*elm_theme_extension_del(ugd->theme, EV_THEME_PATH); + elm_theme_free(ugd->theme);*/ + + /* Free Viewdata's memory */ + for (i = VIEW_SETTING; i < VIEW_END; i++) { + vd = ugd->vd[i]; + if (vd != NULL) { + debug_log("Memory Free"); + free(vd); + } + } + + email_engine_finalize(); + r = _account_finalize(ugd); + _remove_dbus_receiver(ugd); +} + +static void on_resume(ui_gadget_h ug, service_h service, void *priv) +{ + debug_log(""); + + struct ug_data *ugd; + + if (!ug || !priv) + return; + + ugd = priv; + + ugd->b_on_pause = 0; + + return; +} + +static void on_pause(ui_gadget_h ug, service_h service, void *priv) +{ + debug_log(""); + + struct ug_data *ugd; + + if (!ug || !priv) + return; + + ugd = priv; + + ugd->b_on_pause = 1; + + return; +} + +static void on_start(ui_gadget_h ug, service_h service, void *priv) +{ + debug_log(""); + struct ug_data *ugd; + + if (!ug || !priv) + return; + + ugd = priv; + + /* Init Email Service */ + if (!email_engine_initialize()) { + Evas_Object *popup = elm_popup_add(ugd->layout_main); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_text_set(popup, "title,text", dgettext("sys_string", "IDS_COM_POP_WARNING")); + elm_object_text_set(popup, _("IDS_EMAIL_POP_FAILED_TO_START_EMAIL_APPLICATION")); + + Evas_Object *btn1 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_OK")); + elm_object_part_content_set(popup, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", _popup_ok_cb, ugd); + evas_object_show(popup); + return; + } + + /* Init Emf Account */ + if (!_account_init(ugd)) { + debug_log("Failed to get account list"); + } + + if (!_parse_option(service, ugd)) { + return; + } + + _dispatch_view(ugd); + + return; +} + +static void _init_data(struct ug_data *ugd) +{ + debug_log(""); + struct viewdata *view_setting = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_sp_select = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_account_setup = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_manual_setup = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_account_edit = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_mailbox_mapping = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_account_options = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_initial_access = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_sync_schedule = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + struct viewdata *view_sync_setup = (struct viewdata *)calloc(sizeof(struct viewdata), 1); + + setting_init_setting_view(view_setting); + setting_init_sp_select_view(view_sp_select); + setting_init_account_setup_view(view_account_setup); + setting_init_manual_setup_view(view_manual_setup); + setting_init_account_edit_view(view_account_edit); + setting_init_mailbox_mapping_view(view_mailbox_mapping); + setting_init_account_options_view(view_account_options); + setting_init_initial_access_view(view_initial_access); + setting_init_sync_schedule_view(view_sync_schedule); + setting_init_sync_setup_view(view_sync_setup); + + ugd->view_top = -1; + + _couple_data(ugd, VIEW_SETTING, view_setting); + _couple_data(ugd, VIEW_SP_SELECT, view_sp_select); + _couple_data(ugd, VIEW_ACCOUNT_SETUP, view_account_setup); + _couple_data(ugd, VIEW_MANUAL_SETUP, view_manual_setup); + _couple_data(ugd, VIEW_ACCOUNT_EDIT, view_account_edit); + _couple_data(ugd, VIEW_MAILBOX_MAPPING, view_mailbox_mapping); + _couple_data(ugd, VIEW_ACCOUNT_OPTIONS, view_account_options); + _couple_data(ugd, VIEW_INITIAL_ACCESS, view_initial_access); + _couple_data(ugd, VIEW_SYNC_SCHEDULE, view_sync_schedule); + _couple_data(ugd, VIEW_SYNC_SETUP, view_sync_setup); + + /* add more views... */ +} + +static void _couple_data(struct ug_data *ugd, Viewtype t, struct viewdata *vd) +{ + debug_log(""); + debug_log("View type number%d", t); + ugd->vd[t] = vd; + vd->ugd = ugd; +} + +static void _dbus_receiver_setup(struct ug_data *ugd) +{ + debug_log(""); + + if (!ugd) { + debug_log("ugd == NULL"); + return; + } + + int ret = e_dbus_init(); + debug_log("ret: %d", ret); + + DBusError derror; + + if (ugd->dbus_conn == NULL) { + debug_log(""); + dbus_error_init(&derror); + ugd->dbus_conn = e_dbus_bus_get(DBUS_BUS_SYSTEM); + + if (ugd->dbus_conn == NULL) { + debug_log("e_dbus_bus_get return NULL"); + } + + /* storage */ + if (e_dbus_request_name(ugd->dbus_conn, "User.Email.StorageChange", 0, NULL, NULL) == NULL) { + debug_critical("Failed to e_dbus_request_name()"); + return; + } + + if (ugd->signal_handler_storage != NULL) { + debug_log("_g_setting_signal_handler_storage != NULL"); + } + + ugd->signal_handler_storage = e_dbus_signal_handler_add(ugd->dbus_conn, NULL, + "/User/Email/StorageChange", + "User.Email.StorageChange", "email", + setting_edbus_event_receive, + (struct ug_data *)ugd); + + if (ugd->signal_handler_storage == NULL) { + debug_log("Failed to e_dbus_signal_handler_add()"); + return; + } + + /* network */ + if (e_dbus_request_name(ugd->dbus_conn, "User.Email.NetworkStatus", 0, NULL, NULL) == NULL) { + debug_critical("Failed to e_dbus_request_name()"); + return; + } + if (ugd->signal_handler_network != NULL) { + debug_log("_g_setting_signal_handler_network != NULL"); + } + ugd->signal_handler_network = e_dbus_signal_handler_add(ugd->dbus_conn, NULL, + "/User/Email/NetworkStatus", + "User.Email.NetworkStatus", "email", + setting_edbus_event_receive, + (struct ug_data *)ugd); + + if (ugd->signal_handler_network == NULL) { + debug_critical("Failed to e_dbus_signal_handler_add()"); + return; + } + } +} + +static void _remove_dbus_receiver(struct ug_data *ugd) +{ + debug_log(""); + + if (!ugd) { + debug_log("ugd == NULL"); + return; + } + + if (ugd->signal_handler_storage != NULL) { + e_dbus_signal_handler_del(ugd->dbus_conn, ugd->signal_handler_storage); + ugd->signal_handler_storage = NULL; + } + + if (ugd->signal_handler_network != NULL) { + e_dbus_signal_handler_del(ugd->dbus_conn, ugd->signal_handler_network); + ugd->signal_handler_network = NULL; + } + + if (e_dbus_release_name(ugd->dbus_conn, "User.Email.StorageChange", NULL, NULL) == NULL) { + debug_critical("e_dbus_release_name to failed"); + } + + if (e_dbus_release_name(ugd->dbus_conn, "User.Email.NetworkStatus", NULL, NULL) == NULL) { + debug_critical("e_dbus_release_name to failed"); + } + + if (ugd->dbus_conn != NULL) { + /*e_dbus_connection_close(ugd->dbus_conn);*/ + ugd->dbus_conn = NULL; + } +} + +static int _account_init(struct ug_data *ugd) +{ + debug_log(""); + int i = 0; + + /* Get Email Account List Info */ + ugd->account_list = NULL; + if (!email_engine_get_account_list(&ugd->account_count, &ugd->account_list)) { + return FALSE; + } + + for (i = 0; i < ugd->account_count; i++) { + debug_log("*************Sending Option Details*************"); + debug_log("Acct Id : %d", ugd->account_list[i].account_id); + debug_log("Email Addr : %s", ugd->account_list[i].user_email_address); + debug_log("1.Priority : %d", ugd->account_list[i].options.priority); + debug_log("2.Keep a copy : %d", ugd->account_list[i].options.keep_local_copy); + debug_log("3.Reply with body : %d", ugd->account_list[i].options.reply_with_body); + debug_log("4.Forward with files : %d", ugd->account_list[i].options.forward_with_files); + debug_log("5.Get read report : %d", ugd->account_list[i].options.req_read_receipt); + debug_log("6.Get delivery report: %d", ugd->account_list[i].options.req_delivery_receipt); + debug_log("7.Add my namecard : %d", ugd->account_list[i].options.add_myname_card); + debug_log("8.Add signature : %d", ugd->account_list[i].options.add_signature); + } + + return TRUE; +} + +static int _account_finalize(EmailSettingUGD *ugd) +{ + debug_log(""); + int r; + + /* Free Account List Info */ + if (ugd->account_list != NULL) { + r = email_engine_free_account_list(&(ugd->account_list), ugd->account_count); + retv_if(r == FALSE, -1); + } + ugd->account_list = NULL; + + return TRUE; +} + +static int _parse_option(service_h service, struct ug_data *ugd) +{ + debug_log(""); + + if (service) { + service_get_extra_data(service, EMAIL_BUNDLE_KEY_VIEW_TYPE, &(ugd->start_view_type)); + debug_log("VIEW TYPE:%s", ugd->start_view_type); + + if (strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_EDIT) == 0) { + /* account edit view */ + char *str = NULL; + int my_account_id = 0; + service_get_extra_data(service, EMAIL_BUNDLE_KEY_ACCOUNT_ID, &str); + my_account_id = atoi(str); + g_free(str); + debug_log("MY_ACCOUNT_ID:%d", my_account_id); + + int i = 0; + + if (ugd->account_list == NULL || ugd->account_count == 0) { + debug_critical("account info is @niL"); + Evas_Object *popup = elm_popup_add(ugd->layout_main); + evas_object_size_hint_weight_set(popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_object_part_text_set(popup, "title,text", dgettext("sys_string", "IDS_COM_POP_WARNING")); + elm_object_text_set(popup, _("IDS_EMAIL_POP_ACCOUNT_LIST_NOT_FOUND")); + + Evas_Object *btn1 = elm_button_add(popup); + elm_object_style_set(btn1, "popup_button/default"); + elm_object_text_set(btn1, dgettext("sys_string", "IDS_COM_SK_OK")); + elm_object_part_content_set(popup, "button1", btn1); + evas_object_smart_callback_add(btn1, "clicked", _popup_ok_cb, ugd); + evas_object_show(popup); + return FALSE; + } + + for (i = 0; i < ugd->account_count; i++) { + if (ugd->account_list[i].account_svc_id == my_account_id) { + ugd->account_id = ugd->account_list[i].account_id; + debug_log("ACCOUNT_ID:%d", ugd->account_id); + } + } + } else if (strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD) == 0) { + /* account add view */ + char *account_name = NULL; + service_get_extra_data(service, EMAIL_BUNDLE_KEY_ESP_NAME, &account_name); + if (!strcmp(account_name, EMAIL_BUNDLE_VAL_ESP_GMAIL)) { + debug_log("gmail"); + ugd->account_info = GMAIL; + } else if (!strcmp(account_name, EMAIL_BUNDLE_VAL_ESP_YAHOO)) { + debug_log("yahoomail"); + ugd->account_info = YAHOOMAIL; + } else if (!strcmp(account_name, EMAIL_BUNDLE_VAL_ESP_AOL)) { + debug_log("aol"); + ugd->account_info = AOL; + } else if (!strcmp(account_name, EMAIL_BUNDLE_VAL_ESP_HOTMAIL)) { + debug_log("hotmail"); + ugd->account_info = HOTMAIL; + } else if (!strcmp(account_name, EMAIL_BUNDLE_VAL_ESP_MSN)) { + debug_log("msn"); + ugd->account_info = HOTMAIL; + } else if (!strcmp(account_name, EMAIL_BUNDLE_VAL_ESP_OTHERS)) { + debug_log("others"); + ugd->account_info = OTHERS; + } else { + debug_log("Invalid account type!!(%s)", account_name); + } + + g_free(account_name); + } + } + + return TRUE; +} + +static void _dispatch_view(struct ug_data *ugd) +{ + debug_log(""); + + if (ugd->start_view_type) { + if (!strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_SETTING_MAIN)) { + debug_log("Setting mail is up"); + setting_change_view(VIEW_SETTING, ugd); + } else if (!strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_FIRST_SETUP)) { + debug_log("Setup wizard is up"); + setting_change_view(VIEW_INITIAL_ACCESS, ugd); + } else if (!strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_EDIT)) { + debug_log("Edit view is up"); + setting_change_view(VIEW_SYNC_SCHEDULE, ugd); + } else if (!strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_ACCOUNT_ADD)) { + debug_log("Add view is up"); + setting_change_view(VIEW_ACCOUNT_SETUP, ugd); + } else if (!strcmp(ugd->start_view_type, EMAIL_BUNDLE_VAL_VIEW_SELECT_ACCOUNT)) { + debug_log("select account view is up"); + setting_change_view(VIEW_SP_SELECT, ugd); + } else { + setting_change_view(VIEW_SETTING, ugd); + } + } else { + debug_log("No service value!"); + setting_change_view(VIEW_SETTING, ugd); + } + return; +} + +static void _create_navigationbar(struct ug_data *ugd) +{ + debug_log(""); + ugd->navi_bar = elm_naviframe_add(ugd->layout_main); + + elm_object_part_content_set(ugd->layout_main, "elm.swallow.content", ugd->navi_bar); + evas_object_show(ugd->navi_bar); +} + +static Evas_Object *_create_layout(Evas_Object *parent, struct ug_data *ugd) +{ + debug_log(""); + Evas_Object *base; + + ugd->bg = elm_bg_add(ugd->win); + evas_object_size_hint_weight_set(ugd->bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(ugd->win, ugd->bg); + /*elm_object_theme_set(ugd->bg, ugd->theme);*/ + evas_object_show(ugd->bg); + + base = elm_layout_add(parent); + if (base == NULL) { + debug_log("base == NULL"); + return NULL; + } + + elm_layout_theme_set(base, "layout", "application", "default"); + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(parent, base); + evas_object_show(base); + + elm_object_style_set(ugd->bg, "group_list"); + elm_object_part_content_set(base, "elm.swallow.bg", ugd->bg); + + return base; +} + +static void _win_profile_changed_cb(void *data, Evas_Object *obj, void *event) +{ + debug_log(""); + if (!data) { + debug_log("data is NULL"); + return; + } + + EmailSettingUGD *ugd = (EmailSettingUGD *)data; + + const char *profile = elm_config_profile_get(); + if (!g_strcmp0(profile, "desktop")) + elm_layout_theme_set(ugd->layout_main, "layout", "application", "noindicator"); + else + elm_layout_theme_set(ugd->layout_main, "layout", "application", "default"); + + evas_object_size_hint_weight_set(ugd->layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(ugd->win, ugd->layout_main); + evas_object_show(ugd->layout_main); +} + +static void _layout_block_cb(ui_gadget_h ug, enum ug_mode mode, void *priv) +{ + debug_log(""); + EmailSettingUGD *ugd; + Evas_Object *base; + + if (!ug || !priv) + return; + + ugd = (EmailSettingUGD *)priv; + + base = ug_get_layout(ug); + if (!base) + return; + + switch (mode) { + case UG_MODE_FULLVIEW: + evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + elm_win_resize_object_add(ugd->win, base); + evas_object_show(base); + break; + default: + break; + } +} + +static void _result_block_cb(ui_gadget_h ug, service_h service, void *priv) +{ + debug_log(""); + EmailSettingUGD *ugd; + + if (!ug || !priv) + return; + + ugd = (EmailSettingUGD *)priv; + + return; +} + +static void _destroy_block_cb(ui_gadget_h ug, void *priv) +{ + debug_log(""); + EmailSettingUGD *ugd; + + if (!ug || !priv) + return; + + ugd = (EmailSettingUGD *)priv; + + if (ug == ugd->ug_block) { + ug_destroy(ugd->ug_block); + ugd->ug_block = NULL; + } + + return; +} + +static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + if (!data) { + debug_log("data is NULL"); + return; + } + + if (obj) + evas_object_del(obj); + + EmailSettingUGD *ugd = (EmailSettingUGD *)data; + ug_destroy_me(ugd->ug); +} + +/* EOF */ diff --git a/setting/src/email-view-account-edit.c b/setting/src/email-view-account-edit.c new file mode 100755 index 0000000..a6efbdd --- /dev/null +++ b/setting/src/email-view-account-edit.c @@ -0,0 +1,2022 @@ +/* + * 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 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; + email_account_t *selected_account; + + 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 index; + 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 (p->selected_account == 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; + } + + 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 (p->selected_account->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; + int nCount; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + debug_log("selected account count %d", ugd->account_count); + + p->selected_account = NULL; + + for (nCount = 0; nCount < ugd->account_count; nCount++) { + if (ugd->account_list[nCount].account_id == ugd->account_id) { + debug_log("selected account index %d", ugd->account_list[nCount].account_id); + p->index = nCount; + p->selected_account = &ugd->account_list[nCount]; + + 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(p->selected_account->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(p->selected_account->account_name); + p->str_user_name = g_strdup(p->selected_account->incoming_server_user_name); + p->str_email_address = g_strdup(p->selected_account->user_email_address); + p->str_password = g_strdup(password_buf); + p->str_password_backup = g_strdup(password_buf); + p->str_smtp_server = g_strdup(p->selected_account->outgoing_server_address); + snprintf(buf, sizeof(buf), "%d", p->selected_account->outgoing_server_port_number); + p->str_smtp_port = g_strdup(buf); + p->str_incoming_server = g_strdup(p->selected_account->incoming_server_address); + snprintf(buf, sizeof(buf), "%d", p->selected_account->incoming_server_port_number); + p->str_incoming_port = g_strdup(buf); + + if (p->selected_account->outgoing_server_use_same_authenticator) { + p->str_sending_username = g_strdup(p->selected_account->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(p->selected_account->outgoing_server_user_name); + p->str_sending_password = g_strdup(sending_password_buf); + p->str_sending_password_backup = g_strdup(sending_password_buf); + } + + break; + } + } +} + +static int _check_null_field(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + p = vd->priv; + + if (p->selected_account->account_name == NULL || + strlen(p->selected_account->account_name) == 0 || + p->selected_account->user_email_address == NULL || + strlen(p->selected_account->user_email_address) == 0 || + p->selected_account->incoming_server_user_name == NULL || + strlen(p->selected_account->incoming_server_user_name) == 0 || + p->str_password == NULL || strlen(p->str_password) == 0 || + p->selected_account->incoming_server_address == NULL || + strlen(p->selected_account->incoming_server_address) == 0 || + p->selected_account->incoming_server_port_number == 0 || + p->selected_account->outgoing_server_address == NULL || + strlen(p->selected_account->outgoing_server_address) == 0 || + p->selected_account->outgoing_server_port_number == 0) { + return FALSE; + } else { + + if (p->selected_account->outgoing_server_use_same_authenticator == 0) { + if (p->selected_account->outgoing_server_user_name == NULL || + strlen(p->selected_account->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; + /*char *temp;*/ + + p = vd->priv; + + _free_all_entries(vd); + + debug_log("account name %s", p->str_account_name); + p->selected_account->account_name = g_strdup(p->str_account_name); + + debug_log("email addr %s", p->str_email_address); + p->selected_account->user_email_address = g_strdup(p->str_email_address); + + + debug_log("user name %s", p->str_user_name); + p->selected_account->incoming_server_user_name = g_strdup(p->str_user_name); + + if (g_strcmp0(p->str_password, p->str_password_backup) == 0) + p->selected_account->incoming_server_password = NULL; + else + p->selected_account->incoming_server_password = g_strdup(p->str_password); + + debug_log("display name %s", p->str_user_name); + p->selected_account->user_display_name = g_strdup(p->str_user_name); + + debug_log("incoming server %s", p->str_incoming_server); + p->selected_account->incoming_server_address = g_strdup(p->str_incoming_server); + + debug_log("outgoing server %s", p->str_smtp_server); + p->selected_account->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) { + p->selected_account->incoming_server_port_number = atoi(p->str_incoming_port); + } else { + p->selected_account->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) { + p->selected_account->outgoing_server_port_number = atoi(p->str_smtp_port); + } else { + p->selected_account->outgoing_server_port_number = 0; + } + + if (p->selected_account->outgoing_server_use_same_authenticator == 0) { + p->selected_account->outgoing_server_user_name = g_strdup(p->str_sending_username); + if (g_strcmp0(p->str_sending_password, p->str_sending_password_backup) == 0) + p->selected_account->outgoing_server_password = NULL; + else + p->selected_account->outgoing_server_password = g_strdup(p->str_sending_password); + debug_log("sending_password %s", p->selected_account->outgoing_server_password); + } +} + +static void _free_all_entries(struct viewdata *vd) +{ + debug_log(""); + + struct priv_data *p; + p = vd->priv; + + if (p->selected_account->account_name) { + g_free(p->selected_account->account_name); + p->selected_account->account_name = NULL; + } + if (p->selected_account->user_email_address) { + g_free(p->selected_account->user_email_address); + p->selected_account->user_email_address = NULL; + } + if (p->selected_account->user_display_name) { + g_free(p->selected_account->user_display_name); + p->selected_account->user_display_name = NULL; + } + if (p->selected_account->incoming_server_user_name) { + g_free(p->selected_account->incoming_server_user_name); + p->selected_account->incoming_server_user_name = NULL; + } + if (p->selected_account->incoming_server_password) { + g_free(p->selected_account->incoming_server_password); + p->selected_account->incoming_server_password = NULL; + } + + if (p->selected_account->incoming_server_address) { + g_free(p->selected_account->incoming_server_address); + p->selected_account->incoming_server_address = NULL; + } + if (p->selected_account->outgoing_server_address) { + g_free(p->selected_account->outgoing_server_address); + p->selected_account->outgoing_server_address = NULL; + } + if (p->selected_account->outgoing_server_user_name) { + g_free(p->selected_account->outgoing_server_user_name); + p->selected_account->outgoing_server_user_name = NULL; + } + if (p->selected_account->outgoing_server_password) { + g_free(p->selected_account->outgoing_server_password); + p->selected_account->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 (p->selected_account == NULL) { + debug_log("account_data is NULL"); + return; + } + + if (email_engine_update_account(p->selected_account->account_id, p->selected_account) == 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, p->selected_account); + + 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 = p->selected_account->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]) { + p->selected_account->pop_before_smtp = state; + debug_log("pop before smtp %d", p->selected_account->pop_before_smtp); + } + + if (obj == p->onoff[1]) { + p->selected_account->outgoing_server_need_authentication = state; + debug_log("smtp auth %d", p->selected_account->outgoing_server_need_authentication); + } + + if (obj == p->onoff[2]) { + p->selected_account->outgoing_server_use_same_authenticator = state; + debug_log("same as pop3/imap4 %d", p->selected_account->outgoing_server_use_same_authenticator); + + if (p->selected_account->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 = p->selected_account; + + 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 = p->selected_account; + + 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 = p->selected_account; + + 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_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_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_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_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_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_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_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_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_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_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 = p->selected_account; + + 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 = p->selected_account; + + 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, p->selected_account->pop_before_smtp); + p->onoff[index] = check; + } + + if (index == 1) { + elm_check_state_set(check, p->selected_account->outgoing_server_need_authentication); + p->onoff[index] = check; + } + + if (index == 2) { + elm_check_state_set(check, p->selected_account->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 = p->selected_account; + 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 = p->selected_account; + 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: + p->selected_account->pop_before_smtp = !p->selected_account->pop_before_smtp; + elm_check_state_set(p->onoff[0], p->selected_account->pop_before_smtp); + debug_log("pop before smtp %d", p->selected_account->pop_before_smtp); + break; + + case 1: + p->selected_account->outgoing_server_need_authentication = !p->selected_account->outgoing_server_need_authentication; + elm_check_state_set(p->onoff[1], p->selected_account->outgoing_server_need_authentication); + debug_log("smtp auth %d", p->selected_account->outgoing_server_need_authentication); + break; + + case 2: + p->selected_account->outgoing_server_use_same_authenticator = !p->selected_account->outgoing_server_use_same_authenticator; + elm_check_state_set(p->onoff[2], p->selected_account->outgoing_server_use_same_authenticator); + debug_log("same as pop3/imap4 %d", p->selected_account->outgoing_server_use_same_authenticator); + + if (p->selected_account->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 */ diff --git a/setting/src/email-view-account-options.c b/setting/src/email-view-account-options.c new file mode 100755 index 0000000..3920021 --- /dev/null +++ b/setting/src/email-view-account-options.c @@ -0,0 +1,1757 @@ +/* + * 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 struct viewdata *g_vd = 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 _update_account_info(struct viewdata *vd); +static void _print_option_details(void); +static int _get_mail_slot_size_index(struct viewdata *vd); + +static void _back_cb(void *data, Evas_Object *obj, void *event_info); +static void _account_edit_cb(void *data, Evas_Object *obj, void *event_info); +static void _setup_mailbox_cb(void *data, Evas_Object *obj, void *event_info); +static void _onoff_cb(void *data, Evas_Object *obj, void *event_info); +static void _backup_signature_cb(void *data, Evas_Object *obj, void *event_info); +static void _entry_changed_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 char *_gl_account_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_cc_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_size_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_recent_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_deleting_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_mailbox_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_cc_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_size_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_recent_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_deleting_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_account_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 Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_ex_cc_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_ex_size_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_ex_recent_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_ex_deleting_content_get_cb(void *data, Evas_Object *obj, const char *part); +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_cc_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_size_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_recent_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_deleting_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); + +struct priv_data { + struct viewdata *vd; + + Evas_Object *entry_sig; + Evas_Object *onoff[7]; + + Evas_Object *l_button; + Evas_Object *layout; + Evas_Object *conform; + Evas_Object *ef; + Evas_Object *ef_bk; + + Evas_Object *cc_radio_grp; + Evas_Object *size_radio_grp; + Evas_Object *recent_radio_grp; + Evas_Object *deleting_radio_grp; + Evas_Object *account_icon; + + Evas_Object *genlist; + Elm_Genlist_Item_Class itc_account; + Elm_Genlist_Item_Class itc_onoff; + Elm_Genlist_Item_Class itc_security; + Elm_Genlist_Item_Class itc_cc; + Elm_Genlist_Item_Class itc_size; + Elm_Genlist_Item_Class itc_recent; + Elm_Genlist_Item_Class itc_deleting; + Elm_Genlist_Item_Class itc_mailbox; + Elm_Genlist_Item_Class itc_ex_cc; + Elm_Genlist_Item_Class itc_ex_size; + Elm_Genlist_Item_Class itc_ex_recent; + Elm_Genlist_Item_Class itc_ex_deleting; + Elm_Genlist_Item_Class itc_sep; + Elm_Genlist_Item_Class itc_sep2; + Elm_Genlist_Item_Class itc_ef; + Elm_Genlist_Item_Class itc_title; + + Elm_Object_Item *gl_sig_item; + Elm_Object_Item *gl_onoff_sig_item; + Elm_Object_Item *gl_cc_item; + Elm_Object_Item *gl_size_item; + Elm_Object_Item *gl_recent_item; + Elm_Object_Item *gl_deleting_item; + Elm_Object_Item *gl_mailbox_item[4]; + + char *signature_backup; +}; + +void setting_init_account_options_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_ACCOUNT_OPTIONS; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_account_options"; +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("setting_get_acct_full_data failed"); + return FALSE; + } + + _print_option_details(); + 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); + } + + g_vd = vd; + + _create_list(vd); + + return TRUE; +} + +static int _update(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + + if (vd->refresh) { + if (ugd->setup_mailbox == EMAIL_MAILBOX_TYPE_SENTBOX) { + elm_genlist_item_update(p->gl_mailbox_item[0]); + } else if (ugd->setup_mailbox == EMAIL_MAILBOX_TYPE_DRAFT) { + elm_genlist_item_update(p->gl_mailbox_item[1]); + } else if (ugd->setup_mailbox == EMAIL_MAILBOX_TYPE_TRASH) { + elm_genlist_item_update(p->gl_mailbox_item[2]); + } else if (ugd->setup_mailbox == EMAIL_MAILBOX_TYPE_SPAMBOX) { + elm_genlist_item_update(p->gl_mailbox_item[3]); + } + } + return TRUE; +} + +static int _destroy(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + int i = 0; + + if (p == NULL) { + debug_log("priv is NULL"); + return FALSE; + } + + Ecore_IMF_Context *imf_context = NULL; + imf_context = elm_entry_imf_context_get(p->entry_sig); + if (imf_context) + ecore_imf_context_input_panel_hide(imf_context); + + evas_object_del(p->l_button); + evas_object_del(p->entry_sig); + + for (i = 0; i < 7; i++) + evas_object_del(p->onoff[i]); + + evas_object_del(p->genlist); + evas_object_del(p->cc_radio_grp); + evas_object_del(p->size_radio_grp); + evas_object_del(p->recent_radio_grp); + evas_object_del(p->deleting_radio_grp); + + 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; + } + + EmailSettingUGD *ugd = vd->ugd; + + 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"); + } + + debug_log("smime %d sync %d check interval %d", account_data->smime_type, account_data->sync_disabled, account_data->check_interval); + + 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->l_button = elm_button_add(vd->ugd->navi_bar); + evas_object_smart_callback_add(p->l_button, "clicked", _back_cb, vd); + + elm_naviframe_item_push(vd->ugd->navi_bar, _("IDS_EMAIL_HEADER_ACCOUNT_SETTINGS"), p->l_button, NULL, p->layout, NULL); + elm_object_style_set(p->l_button, "naviframe/back_btn/default"); + evas_object_show(vd->ugd->navi_bar); +} + +static void _create_list(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + Elm_Object_Item *item = NULL; + Elm_Object_Item *git = NULL; + int i = 0; + + p->cc_radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->cc_radio_grp, 0); + evas_object_hide(p->cc_radio_grp); + + p->size_radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->size_radio_grp, 0); + evas_object_hide(p->size_radio_grp); + + p->recent_radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->recent_radio_grp, 0); + evas_object_hide(p->recent_radio_grp); + + p->deleting_radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->deleting_radio_grp, 0); + evas_object_hide(p->deleting_radio_grp); + + p->genlist = elm_genlist_add(ugd->navi_bar); + elm_object_style_set(p->genlist, "dialogue"); + + p->itc_account.item_style = "dialogue/2text.3icon"; + p->itc_account.func.text_get = _gl_account_text_get_cb; + p->itc_account.func.content_get = _gl_account_content_get_cb; + p->itc_account.func.state_get = NULL; + p->itc_account.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_cc.item_style = "dialogue/2text.3/expandable"; + p->itc_cc.func.text_get = _gl_cc_text_get_cb; + p->itc_cc.func.content_get = NULL; + p->itc_cc.func.state_get = NULL; + p->itc_cc.func.del = NULL; + + p->itc_size.item_style = "dialogue/2text.3/expandable"; + p->itc_size.func.text_get = _gl_size_text_get_cb; + p->itc_size.func.content_get = NULL; + p->itc_size.func.state_get = NULL; + p->itc_size.func.del = NULL; + + p->itc_recent.item_style = "dialogue/2text.3/expandable"; + p->itc_recent.func.text_get = _gl_recent_text_get_cb; + p->itc_recent.func.content_get = NULL; + p->itc_recent.func.state_get = NULL; + p->itc_recent.func.del = NULL; + + p->itc_deleting.item_style = "dialogue/2text.3/expandable"; + p->itc_deleting.func.text_get = _gl_deleting_text_get_cb; + p->itc_deleting.func.content_get = NULL; + p->itc_deleting.func.state_get = NULL; + p->itc_deleting.func.del = NULL; + + p->itc_mailbox.item_style = "dialogue/2text.3"; + p->itc_mailbox.func.text_get = _gl_mailbox_text_get_cb; + p->itc_mailbox.func.content_get = NULL; + p->itc_mailbox.func.state_get = NULL; + p->itc_mailbox.func.del = NULL; + + p->itc_ex_cc.item_style = "dialogue/1text.1icon/expandable2"; + p->itc_ex_cc.func.text_get = _gl_ex_cc_text_get_cb; + p->itc_ex_cc.func.content_get = _gl_ex_cc_content_get_cb; + p->itc_ex_cc.func.state_get = NULL; + p->itc_ex_cc.func.del = NULL; + + p->itc_ex_size.item_style = "dialogue/1text.1icon/expandable2"; + p->itc_ex_size.func.text_get = _gl_ex_size_text_get_cb; + p->itc_ex_size.func.content_get = _gl_ex_size_content_get_cb; + p->itc_ex_size.func.state_get = NULL; + p->itc_ex_size.func.del = NULL; + + p->itc_ex_recent.item_style = "dialogue/1text.1icon/expandable2"; + p->itc_ex_recent.func.text_get = _gl_ex_recent_text_get_cb; + p->itc_ex_recent.func.content_get = _gl_ex_recent_content_get_cb; + p->itc_ex_recent.func.state_get = NULL; + p->itc_ex_recent.func.del = NULL; + + p->itc_ex_deleting.item_style = "dialogue/1text.1icon/expandable2"; + p->itc_ex_deleting.func.text_get = _gl_ex_deleting_text_get_cb; + p->itc_ex_deleting.func.content_get = _gl_ex_deleting_content_get_cb; + p->itc_ex_deleting.func.state_get = NULL; + p->itc_ex_deleting.func.del = NULL; + + 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_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; + + if (account_data->options.signature) + p->signature_backup = g_strdup(account_data->options.signature); + + /*seperator*/ + 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*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_account), NULL, git, + ELM_GENLIST_ITEM_NONE, _account_edit_cb, (void *)vd); + + /*title-sending option*/ + i = 0; + git = elm_genlist_item_append(p->genlist, &(p->itc_title), (void *)i, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + /*sending option*/ + /*--replay with body--*/ + i = 0; + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + + /*--forward with files--*/ + i = 1; + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + + /*--always cc/bcc myself--*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_cc), NULL, + git, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + p->gl_cc_item = item; + + /*--request read report--*/ + i = 2; + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + + /*--request delivery report--*/ + i = 3; + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + + /*--add signature--*/ + i = 4; + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + p->gl_onoff_sig_item = item; + + /*--signature--*/ + p->gl_sig_item = elm_genlist_item_append(p->genlist, &(p->itc_ef), NULL, + git, ELM_GENLIST_ITEM_NONE, NULL, NULL); + if (account_data->options.add_signature == FALSE) { + if (p->gl_sig_item) + elm_object_item_disabled_set(p->gl_sig_item, EINA_TRUE); + } + + /*title-receiving option*/ + i = 1; + git = elm_genlist_item_append(p->genlist, &(p->itc_title), (void *)i, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + /*receiving option*/ + /*--email size--*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_size), NULL, git, + ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + p->gl_size_item = item; + + /*--show images--*/ + i = 5; + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + + /*--recent emails for IMAP POP3--*/ + if (account_data->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 || + account_data->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { + item = elm_genlist_item_append(p->genlist, &(p->itc_recent), (void *)ugd, + git, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + p->gl_recent_item = item; + } + + /*--send read report for IMAP POP3--*/ + if (account_data->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4 || + account_data->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { + i = 6; + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + } + + /*--deleting option for POP3--*/ + if (account_data->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { + item = elm_genlist_item_append(p->genlist, &(p->itc_deleting), NULL, + git, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + p->gl_deleting_item = item; + } + + /*title-mailbox setup*/ + if (account_data->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { + i = 2; + git = elm_genlist_item_append(p->genlist, &(p->itc_title), (void *)i, + NULL, ELM_GENLIST_ITEM_GROUP, NULL, NULL); + } else { + 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); + + /*mailbox setup for IMAP*/ + if (account_data->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { + i = EMAIL_MAILBOX_TYPE_SENTBOX; + p->gl_mailbox_item[0] = elm_genlist_item_append(p->genlist, &(p->itc_mailbox), + (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _setup_mailbox_cb, (void *)vd); + + i = EMAIL_MAILBOX_TYPE_DRAFT; + p->gl_mailbox_item[1] = elm_genlist_item_append(p->genlist, &(p->itc_mailbox), + (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _setup_mailbox_cb, (void *)vd); + + i = EMAIL_MAILBOX_TYPE_TRASH; + p->gl_mailbox_item[2] = elm_genlist_item_append(p->genlist, &(p->itc_mailbox), + (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _setup_mailbox_cb, (void *)vd); + + i = EMAIL_MAILBOX_TYPE_SPAMBOX; + p->gl_mailbox_item[3] = elm_genlist_item_append(p->genlist, &(p->itc_mailbox), + (void *)i, NULL, ELM_GENLIST_ITEM_NONE, _setup_mailbox_cb, (void *)vd); + + 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 _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 _print_option_details(void) +{ + debug_log(""); + + if (account_data == NULL) { + debug_log("account_data is NULL"); + return; + } + + debug_log("*************Sending Option Details*************"); + debug_log("1. Priority : %d", account_data->options.priority); + debug_log("2. Keep a copy : %d", account_data->options.keep_local_copy); + debug_log("3. Reply with body : %d", account_data->options.reply_with_body); + debug_log("4. Forward with files : %d", account_data->options.forward_with_files); + debug_log("5. Get read report : %d", account_data->options.req_read_receipt); + debug_log("6. Get delivery report : %d", account_data->options.req_delivery_receipt); + debug_log("7. Add my namecard : %d", account_data->options.add_myname_card); + debug_log("8. Always BCC myself : %d", account_data->options.add_my_address_to_bcc); + debug_log("9. Add signature : %d", account_data->options.add_signature); + if (account_data->options.signature != NULL) + debug_log("10. Signature : %s", account_data->options.signature); + + debug_log("*************Receiving Option Details*************"); + debug_log("1. Check Interval: %d", account_data->check_interval); + debug_log("2. Email size : %d", account_data->options.download_limit); + debug_log("3. Downloadflag : %d", account_data->auto_download_size); + debug_log("4. Keep on server: %d", account_data->keep_mails_on_pop_server_after_download); +} + +static int _get_mail_slot_size_index(struct viewdata *vd) +{ + int slot_idx = 0; + + int slot_size = account_data->default_mail_slot_size; + debug_log("Current recent mail slot: [%d]", slot_size); + + switch (slot_size) { + case 25: + slot_idx = 0; + break; + case 50: + slot_idx = 1; + break; + case 75: + slot_idx = 2; + break; + case 100: + slot_idx = 3; + break; + case 150: + slot_idx = 4; + break; + case 200: + slot_idx = 5; + break; + default: + debug_log("Invalid initail mail slot count [%d]", slot_size); + slot_idx = 3; /* set default value */ + break; + } + + return slot_idx; +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = data; + struct priv_data *p = NULL; + Ecore_IMF_Context *imf_context = NULL; + p = vd->priv; + + imf_context = elm_entry_imf_context_get(p->entry_sig); + if (imf_context) + ecore_imf_context_input_panel_hide(imf_context); + + if (account_data->options.add_signature == TRUE && p->signature_backup) { + debug_log("signature %s", p->signature_backup); + account_data->options.signature = g_strdup(p->signature_backup); + g_free(p->signature_backup); + } + + _print_option_details(); + _update_account_info(vd); + setting_back_to_prev_view(vd); +} + +static void _account_edit_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(item, EINA_FALSE); + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_ACCOUNT_OPTIONS) { + debug_log("**double clicked**"); + return; + } + + debug_log("Selected account id:%d", account_data->account_id); + vd->ugd->account_id = account_data->account_id; + vd->ugd->myaccount_id = account_data->account_svc_id; + + setting_change_view(VIEW_SYNC_SCHEDULE, ugd); +} + +static void _setup_mailbox_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *it = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(it, EINA_FALSE); + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_ACCOUNT_OPTIONS) { + debug_log("**double clicked**"); + return; + } + + if (it == p->gl_mailbox_item[0]) { + ugd->setup_mailbox = EMAIL_MAILBOX_TYPE_SENTBOX; + debug_log("EMAIL_MAILBOX_TYPE_SENTBOX"); + } else if (it == p->gl_mailbox_item[1]) { + ugd->setup_mailbox = EMAIL_MAILBOX_TYPE_DRAFT; + debug_log("EMAIL_MAILBOX_TYPE_DRAFT"); + } else if (it == p->gl_mailbox_item[2]) { + ugd->setup_mailbox = EMAIL_MAILBOX_TYPE_TRASH; + debug_log("EMAIL_MAILBOX_TYPE_TRASH"); + } else if (it == p->gl_mailbox_item[3]) { + ugd->setup_mailbox = EMAIL_MAILBOX_TYPE_SPAMBOX; + debug_log("EMAIL_MAILBOX_TYPE_SPAMBOX"); + } + + setting_change_view(VIEW_MAILBOX_MAPPING, p->vd->ugd); +} + +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->options.reply_with_body = state; + debug_log("reply with body %d", account_data->options.reply_with_body); + } + + if (obj == p->onoff[1]) { + account_data->options.forward_with_files = state; + debug_log("Forward with files %d", account_data->options.forward_with_files); + } + + if (obj == p->onoff[2]) { + account_data->options.req_read_receipt = state; + debug_log("request read report %d", account_data->options.req_read_receipt); + } + + if (obj == p->onoff[3]) { + account_data->options.req_delivery_receipt = state; + debug_log("request delivery report %d", account_data->options.req_delivery_receipt); + } + + if (obj == p->onoff[4]) { + /*char *buf = NULL; + buf = (char *)elm_entry_entry_get(p->entry_sig);*/ + account_data->options.add_signature = state; + debug_log("add signature %d", account_data->options.add_signature); + + if (account_data->options.add_signature == TRUE) { + if (p->gl_sig_item) { + elm_object_item_disabled_set(p->gl_sig_item, EINA_FALSE); + } + } else { + if (p->gl_sig_item) { + elm_object_item_disabled_set(p->gl_sig_item, EINA_TRUE); + } + } + } + + if (obj == p->onoff[5]) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + user_data->show_images = state; + debug_log("show images %d", user_data->show_images); + } + + if (obj == p->onoff[6]) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + user_data->send_read_report = state; + debug_log("send read report %d", user_data->send_read_report); + } + + _update_account_info(vd); +} + +static void _backup_signature_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + struct priv_data *p = vd->priv; + + if (p->signature_backup) { + g_free(p->signature_backup); + p->signature_backup = NULL; + } + + p->signature_backup = g_strdup(elm_entry_entry_get(obj)); +} + +static void _entry_changed_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + if (!data || !obj) { + debug_log("data is NULL"); + return; + } + + 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"); + } +} + +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 char *_gl_account_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!g_strcmp0(part, "elm.text.1")) { + return g_strdup(account_data->account_name); + } + + if (!g_strcmp0(part, "elm.text.2")) { + return g_strdup(account_data->user_email_address); + } + + 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", _("IDS_EMAIL_BODY_REPLY_WITH_BODY")); + } + + if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_FORWARD_WITH_FILES")); + } + + if (index == 2) { + snprintf(buf, sizeof(buf), "%s", N_("Request read report")); + } + + if (index == 3) { + snprintf(buf, sizeof(buf), "%s", N_("Request delivery report")); + } + + if (index == 4) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ADD_SIGNATURE")); + } + + if (index == 5) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SHOW_IMAGES")); + } + + if (index == 6) { + snprintf(buf, sizeof(buf), "%s", N_("Send read report")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_cc_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ALWAYS_CC_BCC_MYSELF")); + return g_strdup(buf); + } + + if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + + /*TODO : check data flag*/ + if (account_data->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_DO_NOT_ADD) { + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_NONE")); + } else if (account_data->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ALWAYS_CC_MYSELF")); + } else if (account_data->options.add_my_address_to_bcc == EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ALWAYS_BCC_MYSELF")); + } + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_size_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_EMAIL_SIZE")); + return g_strdup(buf); + } + + if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + + if (account_data->auto_download_size == 0) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_HEADER_ONLY")); + } else if (account_data->auto_download_size == 512*1024) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ENTIRE_EMAIL")); + } else if (account_data->auto_download_size == 1024/2){ + snprintf(buf, sizeof(buf), "0.5KB"); + } else { + snprintf(buf, sizeof(buf), "%dKB", account_data->auto_download_size/1024); + } + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_recent_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + /*EmailSettingUGD *ugd = (EmailSettingUGD *)data;*/ + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_RECENT_EMAILS")); + return g_strdup(buf); + } + + if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + + snprintf(buf, sizeof(buf), _("IDS_EMAIL_OPT_PD_MOST_RECENT_EMAILS"), account_data->default_mail_slot_size); + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_deleting_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_DELETING_OPTIONS")); + return g_strdup(buf); + } + + if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + + /*TODO : check data flag*/ + if (user_data->pop3_deleting_option == 0) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_PHONE_ONLY")); + } else if (user_data->pop3_deleting_option == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_PHONE_AND_SERVER")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_mailbox_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + int type = (int)data; + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + if (type == EMAIL_MAILBOX_TYPE_SENTBOX) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SENTBOX")); + } + if (type == EMAIL_MAILBOX_TYPE_DRAFT) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_DRAFTS")); + } + if (type == EMAIL_MAILBOX_TYPE_TRASH) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_TRASH")); + } + if (type == EMAIL_MAILBOX_TYPE_SPAMBOX) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SPAMBOX")); + } + + return g_strdup(buf); + } + + if (!g_strcmp0(part, "elm.text.2")) { + email_mailbox_t *mailbox; + char buf[MAX_STR_LEN] = { 0, }; + + email_get_mailbox_by_mailbox_type(ugd->account_id, type, &mailbox); + snprintf(buf, sizeof(buf), "%s", mailbox->alias); + email_free_mailbox(&mailbox, 1); + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_ex_cc_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", dgettext("sys_string", "IDS_COM_BODY_NONE")); + } else if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ALWAYS_CC_MYSELF")); + } else if (index == 2) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ALWAYS_BCC_MYSELF")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_ex_size_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", _("IDS_EMAIL_BODY_HEADER_ONLY")); + } else if (index == 1){ + snprintf(buf, sizeof(buf), "0.5KB"); + } else if (index == 2){ + snprintf(buf, sizeof(buf), "1KB"); + } else if (index == 3){ + snprintf(buf, sizeof(buf), "2KB"); + } else if (index == 4){ + snprintf(buf, sizeof(buf), "5KB"); + } else if (index == 5){ + snprintf(buf, sizeof(buf), "10KB"); + } else if (index == 6){ + snprintf(buf, sizeof(buf), "20KB"); + } else if (index == 7){ + snprintf(buf, sizeof(buf), "50KB"); + } else if (index == 8){ + snprintf(buf, sizeof(buf), "100KB"); + } else if (index == 9) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ENTIRE_EMAIL")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_ex_recent_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 < 4) + snprintf(buf, sizeof(buf), _("IDS_EMAIL_OPT_PD_MOST_RECENT_EMAILS"), (index + 1) * 25); + else if (index >= 4) + snprintf(buf, sizeof(buf), _("IDS_EMAIL_OPT_PD_MOST_RECENT_EMAILS"), 100 + (index - 3) * 50); + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_ex_deleting_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", _("IDS_EMAIL_BODY_PHONE_ONLY")); + } else if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_PHONE_AND_SERVER")); + } + + 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")) { + char buf[MAX_STR_LEN] = { 0, }; + + if (index == 0) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SENDING_OPTIONS")); + } else if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_RECEIVING_OPTIONS")); + } else if (index == 2) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_MAILBOX_SETUP")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static Evas_Object *_gl_account_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + Evas_Object *color_bar = NULL; + + if (!g_strcmp0(part, "elm.icon.1")) { + Evas_Object *icon = elm_icon_add(ugd->navi_bar); + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + + debug_log("is_preset_account:%d", user_data->is_preset_account); + + switch (user_data->is_preset_account) { + case GMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_GMAIL, NULL); + break; + case HOTMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_HOTMAIL, NULL); + break; + case YAHOOMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_YAHOO, NULL); + break; + case AOL: + elm_icon_file_set(icon, ACCOUNT_ICON_AOL, NULL); + break; + case OTHERS: + default: + elm_icon_file_set(icon, ACCOUNT_ICON_OTHERS, NULL); + break; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + + p->account_icon = icon; + + return icon; + } + + if (!g_strcmp0(part, "elm.swallow.colorbar")) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + unsigned int val = user_data->index_color; + int r = (val & 0xff000000) >> 24; + int g = (val & 0x00ff0000) >> 16; + int b = (val & 0x0000ff00) >> 8; + int a = val & 0x000000ff; + + debug_log("R[%d] G[%d] B[%d] A[%d]", r, g, b, a); + + color_bar = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_size_hint_fill_set(color_bar, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_color_set(color_bar, r, g, b, a); + + return color_bar; + } + + /*if (!g_strcmp0(part, "elm.icon.2")) { + Evas_Object *icon = elm_button_add(ugd->navi_bar); + elm_object_style_set(icon, "reveal"); + + return icon; + }*/ + + 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->options.reply_with_body); + p->onoff[index] = check; + } + + if (index == 1) { + elm_check_state_set(check, account_data->options.forward_with_files); + p->onoff[index] = check; + } + + if (index == 2) { + elm_check_state_set(check, account_data->options.req_read_receipt); + p->onoff[index] = check; + } + + if (index == 3) { + elm_check_state_set(check, account_data->options.req_delivery_receipt); + p->onoff[index] = check; + } + + if (index == 4) { + elm_check_state_set(check, account_data->options.add_signature); + p->onoff[index] = check; + } + + if (index == 5) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + elm_check_state_set(check, user_data->show_images); + p->onoff[index] = check; + } + + if (index == 6) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + elm_check_state_set(check, user_data->send_read_report); + p->onoff[index] = check; + } + + return check; + } + + return NULL; +} + +static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + struct viewdata *vd = g_vd; + struct priv_data *p = vd->priv; + + if (!g_strcmp0(part, "elm.icon")) { + debug_log(""); + p->ef = elm_layout_add(p->genlist); + elm_layout_theme_set(p->ef, "layout", "editfield", "title"); + p->entry_sig = elm_entry_add(p->genlist); + elm_entry_scrollable_set(p->entry_sig, EINA_TRUE); + elm_entry_cnp_mode_set(p->entry_sig, ELM_CNP_MODE_PLAINTEXT); + elm_entry_input_panel_layout_set(p->entry_sig, ELM_INPUT_PANEL_LAYOUT_EMAIL); + if (account_data->options.add_signature) { + elm_entry_editable_set(p->entry_sig, TRUE); + } else { + elm_entry_editable_set(p->entry_sig, FALSE); + } + evas_object_smart_callback_add(p->entry_sig, "cursor,changed", _backup_signature_cb, vd); + evas_object_smart_callback_add(p->entry_sig, "changed", _entry_changed_cb, p->ef); + evas_object_smart_callback_add(p->entry_sig, "focused", _entry_focused_cb, p->ef); + evas_object_smart_callback_add(p->entry_sig, "unfocused", _entry_unfocused_cb, p->ef); + evas_object_show(p->entry_sig); + + elm_object_part_content_set(p->ef, "elm.swallow.content", p->entry_sig); + elm_object_part_text_set(p->ef, "elm.text", _("IDS_EMAIL_BODY_SIGNATURE")); + elm_object_signal_callback_add(p->ef, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_sig); + + evas_object_size_hint_weight_set(p->ef, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(p->ef); + + if (account_data->options.signature) + elm_entry_entry_set(p->entry_sig, p->signature_backup); + + return p->ef; + } + + return NULL; +} + +static Evas_Object *_gl_ex_cc_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 *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->cc_radio_grp); + elm_radio_state_value_set(radio, index); + + if (index == account_data->options.add_my_address_to_bcc) { + elm_radio_value_set(p->cc_radio_grp, + account_data->options.add_my_address_to_bcc); + } + return radio; + } + + return NULL; +} + +static Evas_Object *_gl_ex_size_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 *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->size_radio_grp); + elm_radio_state_value_set(radio, index); + + if (index == 0) { + if (account_data->auto_download_size == 0) { + elm_radio_value_set(p->size_radio_grp, 0); + } else if (account_data->auto_download_size == 1024/2) { + elm_radio_value_set(p->size_radio_grp, 1); + } else if (account_data->auto_download_size == 1024) { + elm_radio_value_set(p->size_radio_grp, 2); + } else if (account_data->auto_download_size == 1024*2) { + elm_radio_value_set(p->size_radio_grp, 3); + } else if (account_data->auto_download_size == 1024*5) { + elm_radio_value_set(p->size_radio_grp, 4); + } else if (account_data->auto_download_size == 1024*10) { + elm_radio_value_set(p->size_radio_grp, 5); + } else if (account_data->auto_download_size == 1024*20) { + elm_radio_value_set(p->size_radio_grp, 6); + } else if (account_data->auto_download_size == 1024*50) { + elm_radio_value_set(p->size_radio_grp, 7); + } else if (account_data->auto_download_size == 1024*100) { + elm_radio_value_set(p->size_radio_grp, 8); + } else if (account_data->auto_download_size == 1024*512) { + elm_radio_value_set(p->size_radio_grp, 9); + } + } + return radio; + } + + return NULL; +} + +static Evas_Object *_gl_ex_recent_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 *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->recent_radio_grp); + elm_radio_state_value_set(radio, index); + + if (_get_mail_slot_size_index(vd) == index) + elm_radio_value_set(p->recent_radio_grp, index); + return radio; + } + + return NULL; +} + +static Evas_Object *_gl_ex_deleting_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 *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->deleting_radio_grp); + elm_radio_state_value_set(radio, index); + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + + if (user_data->pop3_deleting_option == index) { + elm_radio_value_set(p->deleting_radio_grp, user_data->pop3_deleting_option); + } + return radio; + } + + return NULL; +} + +static void _gl_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; + /*char *buf = NULL;*/ + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(item, EINA_FALSE); + account_user_data_t *user_data = NULL; + + switch (index) { + case 0: + account_data->options.reply_with_body = !account_data->options.reply_with_body; + elm_check_state_set(p->onoff[0], account_data->options.reply_with_body); + debug_log("reply with body %d", account_data->options.reply_with_body); + break; + + case 1: + account_data->options.forward_with_files = !account_data->options.forward_with_files; + elm_check_state_set(p->onoff[1], account_data->options.forward_with_files); + debug_log("Forward with files %d", account_data->options.forward_with_files); + break; + + case 2: + account_data->options.req_read_receipt = !account_data->options.req_read_receipt; + elm_check_state_set(p->onoff[2], account_data->options.req_read_receipt); + debug_log("request read report %d", account_data->options.req_read_receipt); + break; + + case 3: + account_data->options.req_delivery_receipt = !account_data->options.req_delivery_receipt; + elm_check_state_set(p->onoff[3], account_data->options.req_delivery_receipt); + debug_log("request delivery report %d", account_data->options.req_delivery_receipt); + break; + + case 4: + /*buf = (char *)elm_entry_entry_get(p->entry_sig);*/ + account_data->options.add_signature = !account_data->options.add_signature; + elm_check_state_set(p->onoff[4], account_data->options.add_signature); + debug_log("add signature %d", account_data->options.add_signature); + + if (account_data->options.add_signature == TRUE) { + if (p->gl_sig_item) { + elm_object_item_disabled_set(p->gl_sig_item, EINA_FALSE); + } + } else { + if (p->gl_sig_item) { + elm_object_item_disabled_set(p->gl_sig_item, EINA_TRUE); + } + } + break; + + case 5: + user_data = (account_user_data_t *)account_data->user_data; + user_data->show_images = !user_data->show_images; + elm_check_state_set(p->onoff[5], user_data->show_images); + break; + + case 6: + user_data = (account_user_data_t *)account_data->user_data; + user_data->send_read_report = !user_data->send_read_report; + elm_check_state_set(p->onoff[6], user_data->send_read_report); + break; + } + _update_account_info(vd); +} + +static void _gl_ex_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + /*struct viewdata *vd = (struct viewdata *)data; + struct priv_data *p = vd->priv;*/ + + 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_cc_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; + 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->cc_radio_grp); + + if (sel_radio == index) + return; + + switch (index) { + case 0: + account_data->options.add_my_address_to_bcc = + EMAIL_ADD_MY_ADDRESS_OPTION_DO_NOT_ADD; + break; + case 1: + account_data->options.add_my_address_to_bcc = + EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_CC; + break; + case 2: + account_data->options.add_my_address_to_bcc = + EMAIL_ADD_MY_ADDRESS_OPTION_ALWAYS_ADD_TO_BCC; + break; + + default: + { + debug_log("Unknown value: %d", sel_radio); + break; + } + } + + elm_radio_value_set(p->cc_radio_grp, index); + + _update_account_info(vd); + + elm_genlist_item_update(p->gl_cc_item); +} + +static void _gl_ex_size_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; + 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->size_radio_grp); + + if (sel_radio == index) + return; + + switch (index) { + case 0: + account_data->auto_download_size = 0; + break; + case 1: + account_data->auto_download_size = 1024/2; + break; + case 2: + account_data->auto_download_size = 1024; + break; + case 3: + account_data->auto_download_size = 1024*2; + break; + case 4: + account_data->auto_download_size = 1024*5; + break; + case 5: + account_data->auto_download_size = 1024*10; + break; + case 6: + account_data->auto_download_size = 1024*20; + break; + case 7: + account_data->auto_download_size = 1024*50; + break; + case 8: + account_data->auto_download_size = 1024*100; + break; + case 9: + account_data->auto_download_size = 1024*512; + break; + default: + debug_log("Unknown size value: %d", sel_radio); + break; + } + + elm_radio_value_set(p->size_radio_grp, index); + + _update_account_info(vd); + + elm_genlist_item_update(p->gl_size_item); +} + +static void _gl_ex_recent_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; + EmailSettingUGD *ugd = vd->ugd; + 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->recent_radio_grp); + + if (sel_radio == index) + return; + + elm_radio_value_set(p->recent_radio_grp, index); + + if (index < 4) + account_data->default_mail_slot_size = (index+1)*25; + else if (index >= 4) + account_data->default_mail_slot_size = 100 + (index-3)*50; + + _update_account_info(vd); + email_set_mail_slot_size(ugd->account_id, 0, account_data->default_mail_slot_size); + + elm_genlist_item_update(p->gl_recent_item); +} + +static void _gl_ex_deleting_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; + 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->deleting_radio_grp); + + if (sel_radio == index) + return; + + account_user_data_t *user_data = NULL; + + switch (index) { + case 0: + { + user_data = (account_user_data_t *)account_data->user_data; + user_data->pop3_deleting_option = 0; + break; + } + case 1: + { + user_data = (account_user_data_t *)account_data->user_data; + user_data->pop3_deleting_option = 1; + break; + } + default: + { + debug_log("Unknown value: %d", sel_radio); + break; + } + } + + elm_radio_value_set(p->deleting_radio_grp, index); + + _update_account_info(vd); + + elm_genlist_item_update(p->gl_deleting_item); +} + +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; + /*EmailSettingUGD *ugd = vd->ugd;*/ + int i = 0; + + if (it == p->gl_cc_item) { + for (i = 0; i < 3; i++) { + elm_genlist_item_append(p->genlist, &(p->itc_ex_cc), (void *)i, + it, ELM_GENLIST_ITEM_NONE, _gl_ex_cc_sel_cb, (void *)i); + } + } else if (it == p->gl_size_item) { + for (i = 0; i < 10; i++) { + elm_genlist_item_append(p->genlist, &(p->itc_ex_size), (void *)i, + it, ELM_GENLIST_ITEM_NONE, _gl_ex_size_sel_cb, (void *)i); + } + } else if (it == p->gl_recent_item) { + for (i = 0; i < 6; i++) { + elm_genlist_item_append(p->genlist, &(p->itc_ex_recent), (void *)i, + it, ELM_GENLIST_ITEM_NONE, _gl_ex_recent_sel_cb, (void *)i); + } + } else if (it == p->gl_deleting_item) { + for (i = 0; i < 2; i++) { + elm_genlist_item_append(p->genlist, &(p->itc_ex_deleting), (void *)i, + it, ELM_GENLIST_ITEM_NONE, _gl_ex_deleting_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 */ diff --git a/setting/src/email-view-account-setup.c b/setting/src/email-view-account-setup.c new file mode 100755 index 0000000..4a587b4 --- /dev/null +++ b/setting/src/email-view-account-setup.c @@ -0,0 +1,1479 @@ +/* + * 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-view-account-setup.h" +#include "email-setting-utils.h" +#include "email-setting-account-set.h" + +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_view(struct viewdata *vd); +static void _create_list(struct viewdata *vd); +static void _create_validation_popup(struct viewdata *vd, int account_id); +static void _create_account(void *data); + +static int _check_null_field(struct viewdata *vd); +static int _check_preset_null_field(struct viewdata *vd); +static int _check_preset_isp_name(char *addr, int isp_type); +static void _read_all_entries(struct viewdata *vd); + +static void _next_cb(void *data, Evas_Object *obj, void *event_info); +static void _save_cb(void *data, Evas_Object *obj, void *event_info); +static void _manual_cb(void *data, Evas_Object *obj, void *event_info); +static void _back_cb(void *data, Evas_Object *obj, void *event_info); +static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info); +static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info); +static Eina_Bool _after_validation_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 _gl_ef_sel_cb(void *data, Evas_Object *obj, void *event_info); +static Evas_Object *_gl_ef_content_get_cb(void *data, Evas_Object *obj, const char *part); + +static struct viewdata *g_vd = NULL; + +struct priv_data { + struct viewdata *vd; + unsigned int handle; + + char *str_account_name; + char *str_display_name; + char *str_email_address; + char *str_user_id; + char *str_password; + + Evas_Object *entry_account_name; + Evas_Object *entry_display_name; + Evas_Object *entry_email_address; + Evas_Object *entry_user_id; + Evas_Object *entry_password; + + Evas_Object *ef_account_name; + Evas_Object *ef_display_name; + Evas_Object *ef_email_address; + Evas_Object *ef_user_id; + Evas_Object *ef_password; + + Evas_Object *layout; + Evas_Object *conform; + Evas_Object *scroller; + + Evas_Object *l_button; + Evas_Object *r_button; + Evas_Object *r_button2; + Evas_Object *manual_btn; + Evas_Object *icon; + Evas_Object *show_passwd_check; + + Evas_Object *clicked_object; + + Evas_Object *genlist; + Elm_Genlist_Item_Class itc1; + Elm_Genlist_Item_Class itc2; + + Evas_Object *cbar; + Elm_Object_Item * c_item[4]; + + int icon_get_cnt1; + int icon_get_cnt2; + int set_default_account; +}; + +void setting_init_account_setup_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_ACCOUNT_SETUP; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_account_setup"; +} + +void setting_account_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; + } + + ugd->atomic_pop = 1; + + 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->preset_vc_timer = ecore_timer_add(0.5, _after_validation_cb, vd); +} + +void setting_account_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; + } + + if (canceled || ugd->err_code == EMAIL_ERROR_CANCELLED) { + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_ACCOUNT_CREATION_CANCELLED"), + 1, dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + } else { + char *type = setting_get_service_fail_type(ugd->err_code); + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + type, 1, dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + g_free(type); + } +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + + p->layout = setting_add_inner_layout(vd); + _push_naviframe(vd); + + /*create scroller*/ + p->scroller = elm_scroller_add(ugd->navi_bar); + evas_object_propagate_events_set(p->scroller, EINA_FALSE); + elm_scroller_bounce_set(p->scroller, EINA_FALSE, EINA_FALSE); + elm_scroller_policy_set(p->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + evas_object_show(p->scroller); + + elm_win_conformant_set(ugd->win, EINA_TRUE); + p->conform = elm_conformant_add(ugd->win); + elm_object_style_set(p->conform, "internal_layout"); + elm_object_content_set(p->conform, p->scroller); + evas_object_show(p->conform); + + elm_object_part_content_set(p->layout, "elm.swallow.content", p->conform); + } + + g_vd = vd; + ugd->wds_account_creation = 0; + + _create_view(vd); + vd->refresh = 1; + + 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; + + 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_button); + evas_object_del(p->genlist); + + if (ugd->preset_vc_timer) { + ecore_timer_del(ugd->preset_vc_timer); + ugd->preset_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; + } + + ugd->account_info = 0; + + setting_new_acct_final(vd); + 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->l_button = elm_button_add(vd->ugd->navi_bar); + elm_object_style_set(p->l_button, "naviframe/title/default"); + evas_object_show(p->l_button); + + if (vd->ugd->account_info == OTHERS) { + /*elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_SK_NEXT"));*/ + elm_object_text_set(p->l_button, _("IDS_EMAIL_OPT_LOG_IN")); + evas_object_smart_callback_add(p->l_button, "clicked", _next_cb, vd); + } else { + /*elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_SK_SAVE"));*/ + elm_object_text_set(p->l_button, _("IDS_EMAIL_OPT_LOG_IN")); + evas_object_smart_callback_add(p->l_button, "clicked", _save_cb, vd); + } + + elm_object_disabled_set(p->l_button, EINA_TRUE); + + p->r_button = elm_button_add(vd->ugd->navi_bar); + elm_object_style_set(p->r_button, "naviframe/title/default"); + elm_object_text_set(p->r_button, dgettext("sys_string", "IDS_COM_SK_CANCEL")); + evas_object_smart_callback_add(p->r_button, "clicked", _back_cb, vd); + evas_object_show(p->r_button); + + p->r_button2 = elm_button_add(vd->ugd->navi_bar); + evas_object_smart_callback_add(p->r_button2, "clicked", _back_cb, vd); + elm_object_style_set(p->r_button2, "naviframe/back_btn/default"); + evas_object_show(p->r_button2); + + Elm_Object_Item *navi_it = NULL; + char title_str[50] = { 0, }; + if (vd->ugd->account_info == GMAIL) + snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_GOOGLE")); + else if (vd->ugd->account_info == HOTMAIL) + snprintf(title_str, sizeof(title_str), "%s", _("IDS_EMAIL_BODY_WINDOWS_LIVE_HOTMAIL")); + else if (vd->ugd->account_info == YAHOOMAIL) + snprintf(title_str, sizeof(title_str), "%s", _("IDS_EMAIL_BODY_YAHOO_E_MAIL")); + else if (vd->ugd->account_info == AOL) + snprintf(title_str, sizeof(title_str), "%s", _("IDS_EMAIL_BODY_AOL")); + else + snprintf(title_str, sizeof(title_str), "%s", dgettext("sys_string", "IDS_COM_BODY_OTHERS")); + navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, title_str, p->r_button2, NULL, p->layout, NULL); + elm_object_item_part_content_set(navi_it, "title_left_btn", p->l_button); + elm_object_item_part_content_set(navi_it, "title_right_btn", p->r_button); + evas_object_show(vd->ugd->navi_bar); +} + +static void _create_view(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + EmailSettingUGD *ugd; + + if (!vd) { + debug_log("vd is null!"); + return; + } + + ugd = vd->ugd; + p = vd->priv; + + Evas_Object *sub_ly = elm_layout_add(ugd->navi_bar); + if (vd->ugd->account_info == OTHERS) + elm_layout_file_set(sub_ly, EV_THEME_PATH, "other_account_add"); + else + elm_layout_file_set(sub_ly, EV_THEME_PATH, "account_add"); + evas_object_size_hint_weight_set(sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(sub_ly); + + _create_list(vd); + elm_object_part_content_set(sub_ly, "list", p->genlist); + + Evas_Object *checkbox_set = elm_layout_add(sub_ly); + elm_layout_file_set(checkbox_set, EV_THEME_PATH, "account_add_checkbox_set"); + evas_object_size_hint_weight_set(checkbox_set, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(checkbox_set); + + Evas_Object *check1 = elm_check_add(checkbox_set); + elm_check_state_set(check1, EINA_FALSE); + evas_object_smart_callback_add(check1, "changed", _check1_clicked_cb, (void *)vd); + elm_object_part_content_set(checkbox_set, "checkbox.1", check1); + elm_object_focus_allow_set(check1, EINA_FALSE); + + Evas_Object *check2 = elm_check_add(checkbox_set); + elm_check_state_set(check2, EINA_FALSE); + evas_object_smart_callback_add(check2, "changed", _check2_clicked_cb, (void *)vd); + elm_object_part_content_set(checkbox_set, "checkbox.2", check2); + elm_object_focus_allow_set(check2, EINA_FALSE); + p->show_passwd_check = check2; + + char *desc = g_strdup(_("IDS_EMAIL_BODY_SEND_EMAIL_FROM_THIS_ACCOUNT_BY_DEFAULT")); + Evas_Object *label1 = elm_label_add(checkbox_set); + char *text = g_strconcat("", + desc, "", NULL); + + elm_object_text_set(label1, text); + evas_object_show(label1); + g_free(desc); + g_free(text); + elm_object_part_content_set(checkbox_set, "text.1", label1); + + desc = g_strdup(_("IDS_EMAIL_BODY_SHOW_PASSWORD")); + Evas_Object *label2 = elm_label_add(checkbox_set); + text = g_strconcat("", + desc, "", NULL); + + elm_object_text_set(label2, text); + evas_object_show(label2); + g_free(desc); + g_free(text); + elm_object_part_content_set(checkbox_set, "text.2", label2); + + elm_object_part_content_set(sub_ly, "checkbox_set", checkbox_set); + + Evas_Object *button_set = elm_layout_add(sub_ly); + elm_layout_file_set(button_set, EV_THEME_PATH, "account_add_manual_button"); + evas_object_size_hint_weight_set(button_set, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(button_set); + + desc = g_strdup(N_("Setup POP3 or IMAP4?")); + Evas_Object *label3 = elm_label_add(button_set); + text = g_strconcat("", + desc, "", NULL); + + elm_object_text_set(label3, text); + evas_object_show(label3); + g_free(desc); + g_free(text); + elm_object_part_content_set(button_set, "text", label3); + + Evas_Object *btn = elm_button_add(button_set); + elm_object_text_set(btn, _("IDS_EMAIL_BODY_MANUAL_SETUP")); + evas_object_smart_callback_add(btn, "clicked", _manual_cb, (void *)vd); + elm_object_style_set(btn, "text_only/style2"); + evas_object_show(btn); + p->manual_btn = btn; + elm_object_part_content_set(button_set, "btn", btn); + /*elm_object_disabled_set(btn, EINA_TRUE);*/ + + elm_object_part_content_set(sub_ly, "button_set", button_set); + + elm_object_content_set(p->scroller, sub_ly); +} + +static void _create_list(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_critical("vd is null!"); + return; + } + + struct priv_data *p; + EmailSettingUGD *ugd; + int i = 0; + + 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"); + evas_object_show(p->genlist); + + p->itc1.item_style = "dialogue/separator"; + p->itc1.func.text_get = NULL; + p->itc1.func.content_get = NULL; + p->itc1.func.state_get = NULL; + p->itc1.func.del = NULL; + + p->itc2.item_style = "dialogue/1icon"; + p->itc2.func.text_get = NULL; + p->itc2.func.content_get = _gl_ef_content_get_cb; + p->itc2.func.state_get = NULL; + p->itc2.func.del = NULL; + + git = elm_genlist_item_append(p->genlist, &(p->itc1), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + if (ugd->account_info == OTHERS) { + /* Account name for OTHER */ + i = 1; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + /* User name */ + /*i = 2; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/ + } + + /* Display name */ + /*i = 3; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i);*/ + + /* Email address */ + i = 4; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + /* Password */ + i = 5; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, git, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); +} + +static void _create_validation_popup(struct viewdata *vd, int account_id) +{ + debug_log(""); + + if (!vd) { + debug_critical("vd is null!"); + return; + } + + email_account_t *account = vd->ugd->new_account; + + debug_log("account id:%d", account_id); + debug_log("account name:%s", account->account_name); + debug_log("email address:%s", account->user_email_address); + + vd->ugd->account_id = account_id; + + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + 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; + } + + vd->ugd->cancel_event = 0; + elm_object_disabled_set(p->l_button, EINA_TRUE); + elm_object_disabled_set(p->r_button, EINA_TRUE); + elm_object_disabled_set(p->r_button2, EINA_TRUE); + elm_object_disabled_set(p->manual_btn, EINA_TRUE); + + 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); +} + +static void _create_account(void *data) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (!vd) { + debug_critical("vd is null!"); + return; + } + + EmailSettingUGD *ugd = vd->ugd; + int account_id; + struct priv_data *p = vd->priv; + int error_code = 0; + + if (email_engine_add_account_with_validation(vd->ugd->new_account, + &account_id, &(p->handle), &error_code)) { + debug_log("Account added to Email Service DB"); + vd->ugd->start_account_validation = 1; + ugd->handle = p->handle; + _create_validation_popup(vd, account_id); + } else { + debug_log("Fail to make account"); + + 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 (error_code == EMAIL_ERROR_ALREADY_EXISTS) + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + else + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_UNABLE_TO_ADD_ACCOUNT"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + } + return; +} + +static int _check_null_field(struct viewdata *vd) +{ + debug_log(""); + + if (vd->ugd->new_account == NULL) { + debug_log("new_account is NULL"); + return FALSE; + } + + email_account_t *account = vd->ugd->new_account; + + if (account->account_name == NULL || strlen(account->account_name) == 0 || + /*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/ + account->user_email_address == NULL || strlen(account->user_email_address) == 0 || + /*account->incoming_server_user_name == NULL || strlen(account->incoming_server_user_name) == 0 ||*/ + account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0) + return FALSE; + else + return TRUE; +} + +static int _check_preset_null_field(struct viewdata *vd) +{ + debug_log(""); + + if (vd->ugd->new_account == NULL) { + debug_log("new_account is NULL"); + return FALSE; + } + + email_account_t *account = vd->ugd->new_account; + + if (/*account->user_display_name == NULL || strlen(account->user_display_name) == 0 ||*/ + account->user_email_address == NULL || strlen(account->user_email_address) == 0 || + account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0) + return FALSE; + else + return TRUE; +} + +static int _check_preset_isp_name(char *addr, int isp_type) +{ + debug_log(""); + int ret = FALSE; + + if (isp_type == HOTMAIL) { + char *ptr1 = NULL; + char *ptr2 = NULL; + ptr1 = g_strrstr(addr, "@hotmail."); + ptr2 = g_strrstr(addr, "@live."); + + if (ptr1 != NULL || ptr2 != NULL) + ret = TRUE; + } else if (isp_type == GMAIL) { + ret = g_str_has_suffix(addr, "@gmail.com") || + g_str_has_suffix(addr, "@googlemail.com"); + } else if (isp_type == AOL) { + char *ptr1 = NULL; + char *ptr2 = NULL; + ptr1 = g_strrstr(addr, "@aol."); + ptr2 = g_strrstr(addr, "@aim."); + + if (ptr1 != NULL || ptr2 != NULL) + ret = TRUE; + } else { + ret = TRUE; + } + + return ret; +} + +static void _read_all_entries(struct viewdata *vd) +{ + debug_log(""); + + struct priv_data *p; + p = vd->priv; + char *buf; + + if (!p) { + debug_log("priv is NULL"); + return; + } + + if (vd->ugd->new_account) + setting_new_acct_final(vd); + + setting_new_acct_init(vd); + email_account_t *account = vd->ugd->new_account; + + if (vd->ugd->account_info == OTHERS) { + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_account_name));*/ + if (p->entry_account_name) { + buf = (char *)elm_entry_entry_get(p->entry_account_name); + debug_log("account name : %s", buf); + if (buf) + account->account_name = g_strdup(buf); + } + } + + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_email_address));*/ + if (p->entry_email_address) { + buf = (char *)elm_entry_entry_get(p->entry_email_address); + debug_log("email addr : %s", buf); + if (buf) + account->user_email_address = g_strdup(buf); + } + + if (p->entry_password) { + buf = (char *)elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_password)); + debug_log("password : %s ", buf); + if (buf) + account->incoming_server_password = g_strdup(buf); + } +} + +static void _next_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = NULL; + char *buf = NULL; + int ret = 0; + + ugd = vd->ugd; + + /* Save the Account Data */ + _read_all_entries(vd); + email_account_t *account = vd->ugd->new_account; + + debug_log("accountStructure Info"); + debug_log("Account Name:%s", account->account_name); + debug_log("Display Name:%s", account->user_display_name); + debug_log("Email Addr:%s", account->user_email_address); + debug_log("User Name:%s", account->incoming_server_user_name); + debug_log("User Password:%s", account->incoming_server_password); + + ret = _check_null_field(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 (!ret) { + 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; + } + + buf = g_strdup(account->user_email_address); + + ret = email_get_address_validation(buf); + + if (!ret) { + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + + free(buf); + return; + } + g_free(buf); + + setting_change_view(VIEW_MANUAL_SETUP, ugd); + + return; +} + +static void _save_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = NULL; + EmailSettingUGD *ugd = NULL; + char *buf = NULL; + int ret = 0; + + p = vd->priv; + ugd = vd->ugd; + + Ecore_IMF_Context *imf_context = NULL; + imf_context = elm_entry_imf_context_get(p->clicked_object); + ecore_imf_context_input_panel_hide(imf_context); + + /* Save the data */ + _read_all_entries(vd); + email_account_t *account = vd->ugd->new_account; + + debug_log("accountStructure Info"); + debug_log("Display Name:%s", account->user_display_name); + debug_log("Email Addr:%s", account->user_email_address); + debug_log("User Password:%s", account->incoming_server_password); + + 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; + } + + /* check Null field */ + ret = _check_preset_null_field(vd); + if (!ret) { + debug_log("empty space in account info"); + 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; + } + + /* check ISP */ + buf = g_strdup(account->user_email_address); + ret = _check_preset_isp_name(buf, ugd->account_info); + if (ret == FALSE) { + debug_log("wrong ISP server name for preset accounts"); + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), + 1, dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + free(buf); + return; + } + g_free(buf); + + /* check character validation */ + buf = g_strdup(account->user_email_address); + + ret = email_get_address_validation(buf); + if (!ret) { + debug_log("Wrong character in email address"); + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), + 1, dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + free(buf); + return; + } + g_free(buf); + + /* account info setting */ + setting_set_account(vd); + + _create_account(vd); +} + +static void _manual_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + EmailSettingUGD *ugd = NULL; + char *buf = NULL; + int ret = 0; + + ugd = vd->ugd; + + /* Save the Account Data */ + _read_all_entries(vd); + email_account_t *account = vd->ugd->new_account; + + debug_log("accountStructure Info"); + debug_log("Account Name:%s", account->account_name); + debug_log("Display Name:%s", account->user_display_name); + debug_log("Email Addr:%s", account->user_email_address); + debug_log("User Name:%s", account->incoming_server_user_name); + debug_log("User Password:%s", account->incoming_server_password); + + if (vd->ugd->account_info == OTHERS) { + ret = _check_null_field(vd); + } else { + ret = _check_preset_null_field(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 (!ret) { + 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; + } + + buf = g_strdup(account->user_email_address); + + ret = email_get_address_validation(buf); + + if (!ret) { + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + + free(buf); + return; + } + + g_free(buf); + + /* account info setting */ + if (vd->ugd->account_info != OTHERS) + setting_set_account(vd); + + setting_change_view(VIEW_MANUAL_SETUP, ugd); + + return; +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)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); + + if (vd->ugd->atomic_pop) { + debug_log("During atomic poping"); + return; + } + + elm_object_disabled_set(p->l_button, EINA_TRUE); + elm_object_disabled_set(p->r_button, EINA_TRUE); + elm_object_disabled_set(p->r_button2, EINA_TRUE); + elm_object_disabled_set(p->manual_btn, EINA_TRUE); + + if (!strcmp(vd->ugd->start_view_type, "account-add")) { + ug_destroy_me(vd->ugd->ug); + } else { + setting_back_to_prev_view(vd); + } +} + +static void _check1_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + Eina_Bool state = elm_check_state_get(obj); + + if (state) { + p->set_default_account = 1; + } else + p->set_default_account = 0; +} + +static void _check2_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + Eina_Bool state = elm_check_state_get(obj); + + if (state) + elm_entry_password_set(p->entry_password, EINA_FALSE); + else + elm_entry_password_set(p->entry_password, EINA_TRUE); +} + +static Eina_Bool _after_validation_cb(void *data) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return EINA_FALSE; + } + + EmailSettingUGD *ugd = NULL; + struct priv_data *p = NULL; + + ugd = vd->ugd; + p = vd->priv; + + if (ugd->preset_vc_timer) { + ecore_timer_del(ugd->preset_vc_timer); + ugd->preset_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->set_default_account) { + if (email_engine_set_default_account(vd->ugd->account_id)) { + debug_log("new default account is %d", vd->ugd->account_id); + } + } + + status_message_post(_("IDS_EMAIL_POP_SUCCEEDED")); + + setting_change_view(VIEW_SYNC_SETUP, ugd); + + setting_get_small_notify(vd, _("IDS_EMAIL_POP_SUCCEEDED")); + + /*debug_log("_after_validation_cb %s", vd->ugd->start_view_type); + + if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "first-setup") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "account-add") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "select-account") == 0) { + service_h service = NULL; + service_create(&service); + if (service) { + service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT); + ug_send_result(vd->ugd->ug, service); + service_destroy(service); + } + } else { + setting_update_acct_list(vd); + setting_back_to_prev_nth_view(vd, 2, vd->ugd->navi_main_it); + vd->ugd->atomic_pop = 0; + }*/ + + return EINA_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; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + 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_disabled_set(p->r_button, EINA_FALSE); + elm_object_disabled_set(p->r_button2, EINA_FALSE); + elm_object_disabled_set(p->manual_btn, 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; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + 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; + email_engine_stop_working(account_id, p->handle); + email_engine_delete_account(account_id); + + elm_object_disabled_set(p->l_button, EINA_FALSE); + elm_object_disabled_set(p->r_button, EINA_FALSE); + elm_object_disabled_set(p->r_button2, EINA_FALSE); + elm_object_disabled_set(p->manual_btn, EINA_FALSE); +} + +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; + if (vd == NULL) + return; + + struct priv_data *p = vd->priv; + if (p == NULL) + return; + + EmailSettingUGD *ugd = vd->ugd; + if (ugd == NULL) + return; + + 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; + } + + p->str_account_name = g_strdup(elm_entry_entry_get(eo)); + } else if (eo == p->entry_user_id) { + debug_log("entry_user_id"); + if (p->str_user_id) { + g_free(p->str_user_id); + p->str_user_id = NULL; + } + + p->str_user_id = g_strdup(elm_entry_entry_get(eo)); + } else if (eo == p->entry_display_name) { + debug_log("entry_display_name"); + if (p->str_display_name) { + g_free(p->str_display_name); + p->str_display_name = NULL; + } + + p->str_display_name = g_strdup(elm_entry_entry_get(eo)); + } 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; + } + + p->str_email_address = g_strdup(elm_entry_entry_get(eo)); + } else if (eo == p->entry_password) { + debug_log("entry_password"); + if (p->str_password) { + g_free(p->str_password); + p->str_password = NULL; + } + + p->str_password = g_strdup(elm_entry_entry_get(eo)); + } + + if (ugd->account_info == OTHERS) { + if (p->str_account_name == NULL) { + elm_object_disabled_set(p->l_button, EINA_TRUE); + return; + } + + if (g_strcmp0(p->str_account_name, "") == 0) { + elm_object_disabled_set(p->l_button, EINA_TRUE); + return; + } + } + + if (p->str_email_address == NULL || p->str_password == NULL) { + elm_object_disabled_set(p->l_button, EINA_TRUE); + return; + } + + if (g_strcmp0(p->str_email_address, "") == 0 || g_strcmp0(p->str_password, "") == 0) { + elm_object_disabled_set(p->l_button, EINA_TRUE); + } else { + elm_object_disabled_set(p->l_button, EINA_FALSE); + } +} + +static void _entry_focused_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + if (!obj) { + debug_log("obj 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 (!obj) { + debug_log("obj 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 (!obj) { + debug_log("obj is NULL"); + return; + } + + elm_entry_entry_set(data, ""); +} + +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); + + if (index == 1) { + p->clicked_object = p->entry_account_name; + } else if (index == 2) { + p->clicked_object = p->entry_user_id; + } else if (index == 3) { + p->clicked_object = p->entry_display_name; + } else if (index == 4) { + p->clicked_object = p->entry_email_address; + } else if (index == 5) { + p->clicked_object = p->entry_password; + } +} + +static Evas_Object *_gl_ef_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; + EmailSettingUGD *ugd = vd->ugd; + + if (!strcmp(part, "elm.icon")) { + if (index == 1) { + p->icon_get_cnt1++; + + debug_log(""); + 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_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.guidetext", str);*/ + 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); + + if (ugd->account_info == OTHERS && p->icon_get_cnt1 == 2) { + p->clicked_object = p->entry_account_name; + evas_object_show(p->entry_account_name); + elm_object_focus_set(p->entry_account_name, EINA_TRUE); + } + + return p->ef_account_name; + } else if (index == 2) { + debug_log(""); + p->ef_user_id = elm_layout_add(p->genlist); + elm_layout_theme_set(p->ef_user_id, "layout", "editfield", "title"); + p->entry_user_id = elm_entry_add(p->genlist); + elm_entry_scrollable_set(p->entry_user_id, EINA_TRUE); + elm_entry_single_line_set(p->entry_user_id, EINA_TRUE); + elm_entry_cnp_mode_set(p->entry_user_id, ELM_CNP_MODE_PLAINTEXT); + elm_entry_input_panel_layout_set(p->entry_user_id, ELM_INPUT_PANEL_LAYOUT_EMAIL); + elm_entry_editable_set(p->entry_user_id, TRUE); + evas_object_smart_callback_add(p->entry_user_id, "changed", _backup_input_cb, p->ef_user_id); + evas_object_smart_callback_add(p->entry_user_id, "focused", _entry_focused_cb, p->ef_user_id); + evas_object_smart_callback_add(p->entry_user_id, "unfocused", _entry_unfocused_cb, p->ef_user_id); + evas_object_show(p->entry_user_id); + + elm_object_part_content_set(p->ef_user_id, "elm.swallow.content", p->entry_user_id); + /*elm_object_part_text_set(p->ef_user_id, "elm.guidetext", dgettext("sys_string", "IDS_COM_BODY_USER_NAME"));*/ + elm_object_part_text_set(p->ef_user_id, "elm.text", dgettext("sys_string", "IDS_COM_BODY_USER_NAME")); + elm_object_signal_callback_add(p->ef_user_id, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_user_id); + + evas_object_size_hint_weight_set(p->ef_user_id, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(p->ef_user_id); + + if (p->str_user_id) + elm_entry_entry_set(p->entry_user_id, p->str_user_id); + + return p->ef_user_id; + } else if (index == 3) { + debug_log(""); + p->ef_display_name = elm_layout_add(p->genlist); + elm_layout_theme_set(p->ef_display_name, "layout", "editfield", "title"); + p->entry_display_name = elm_entry_add(p->genlist); + elm_entry_scrollable_set(p->entry_display_name, EINA_TRUE); + elm_entry_single_line_set(p->entry_display_name, EINA_TRUE); + elm_entry_cnp_mode_set(p->entry_display_name, ELM_CNP_MODE_PLAINTEXT); + elm_entry_input_panel_layout_set(p->entry_display_name, ELM_INPUT_PANEL_LAYOUT_EMAIL); + elm_entry_editable_set(p->entry_display_name, TRUE); + evas_object_smart_callback_add(p->entry_display_name, "changed", _backup_input_cb, p->ef_display_name); + evas_object_smart_callback_add(p->entry_display_name, "focused", _entry_focused_cb, p->ef_display_name); + evas_object_smart_callback_add(p->entry_display_name, "unfocused", _entry_unfocused_cb, p->ef_display_name); + evas_object_show(p->entry_display_name); + + elm_object_part_content_set(p->ef_display_name, "elm.swallow.content", p->entry_display_name); + /*elm_object_part_text_set(p->ef_display_name, "elm.guidetext", _("IDS_EMAIL_BODY_YOUR_NAME"));*/ + elm_object_part_text_set(p->ef_display_name, "elm.text", dgettext("sys_string", "IDS_COM_BODY_DETAILS_NAME")); + elm_object_signal_callback_add(p->ef_display_name, "elm,eraser,clicked", "elm", _eraser_clicked_cb, p->entry_display_name); + + evas_object_size_hint_weight_set(p->ef_display_name, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(p->ef_display_name); + + if (p->str_display_name) + elm_entry_entry_set(p->entry_display_name, p->str_display_name); + + return p->ef_display_name; + } else if (index == 4) { + p->icon_get_cnt2++; + + debug_log(""); + 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_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, TRUE); + 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); + /*_set_help_string(p->ef_email_address, vd);*/ + 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); + + if (ugd->account_info != OTHERS && p->icon_get_cnt2 == 2) { + p->clicked_object = p->entry_email_address; + evas_object_show(p->entry_email_address); + elm_object_focus_set(p->entry_email_address, EINA_TRUE); + } + + return p->ef_email_address; + } else if (index == 5) { + debug_log(""); + 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_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, EINA_TRUE); + elm_entry_password_set(p->entry_password, EINA_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_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.guidetext", _("IDS_EMAIL_BODY_USER_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); + + Eina_Bool state = elm_check_state_get(p->show_passwd_check); + + if (state) + elm_entry_password_set(p->entry_password, EINA_FALSE); + else + elm_entry_password_set(p->entry_password, EINA_TRUE); + + return p->ef_password; + } + } + + return NULL; +} + +/* EOF */ + diff --git a/setting/src/email-view-initial.c b/setting/src/email-view-initial.c new file mode 100755 index 0000000..3260683 --- /dev/null +++ b/setting/src/email-view-initial.c @@ -0,0 +1,390 @@ +/* + * 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 +#include "email-setting.h" +#include "email-setting-utils.h" + +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_view(struct viewdata *vd); +#ifndef INITIAL_VIEW_ADD_BTN +static void _create_list(struct viewdata *vd); +#endif +#ifdef INITIAL_VIEW_ADD_BTN +static void _add_account_cb(void *data, Evas_Object *obj, void *event_info); +#endif +#ifndef INITIAL_VIEW_ADD_BTN +static void _new_account_cb(void *data, Evas_Object *obj, void *event_info); +#endif +static void _back_cb(void *data, Evas_Object *obj, void *event_info); + +#ifndef INITIAL_VIEW_ADD_BTN +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part); +static void _gl_del_cb(void *data, Evas_Object *obj); +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_content_get_cb(void *data, Evas_Object *obj, const char *part); +#endif + +struct priv_data { + struct viewdata *vd; + + Evas_Object *layout; + Evas_Object *navi_bar; + Evas_Object *l_button; + + Evas_Object *list; + Evas_Object *b_btn2; + Evas_Object *b_btn; + + Elm_Genlist_Item_Class itc; + Elm_Genlist_Item_Class itc2; + Ecore_Timer *vc_timer; + int as_flag; +}; + +void setting_init_initial_access_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_INITIAL_ACCESS; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_initial_access"; +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + EmailSettingUGD *ugd; + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + p = vd->priv; + ugd = vd->ugd; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + p->layout = setting_add_inner_layout(vd); + _push_naviframe(vd); + } + + /*elm_object_style_set(ugd->bg, "email_default");*/ + _create_view(vd); + + return TRUE; +} + +static int _update(struct viewdata *vd) +{ + debug_log(""); + + return TRUE; +} + +static int _destroy(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + /*elm_object_style_set(vd->ugd->bg, "group_list");*/ + + return TRUE; +} + +static int _show(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + evas_object_show(vd->ly); + /*elm_object_style_set(vd->ugd->bg, "email_default");*/ + + 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->l_button = elm_button_add(vd->ugd->navi_bar); + evas_object_smart_callback_add(p->l_button, "clicked", _back_cb, vd); + evas_object_show(p->l_button); + + elm_naviframe_item_push(vd->ugd->navi_bar, _("IDS_EMAIL_HEADER_ADD_ACCOUNT"), + p->l_button, NULL, p->layout, NULL); + elm_object_style_set(p->l_button, "naviframe/end_btn/default"); + evas_object_show(vd->ugd->navi_bar); +} + +static void _create_view(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + EmailSettingUGD *ugd; + + if (!vd) { + debug_log("vd is null!"); + return; + } + + ugd = vd->ugd; + p = vd->priv; + + int w, h; + ecore_x_window_size_get(ecore_x_window_root_first_get(), &w, &h); + debug_log("WINDOW W[%d] H[%d]", w, h); + + Evas_Object *sub_ly = elm_layout_add(ugd->navi_bar); + + if (w == 480) + elm_layout_file_set(sub_ly, EV_THEME_PATH, "initial_access_pulbic"); + else + elm_layout_file_set(sub_ly, EV_THEME_PATH, "initial_access_hd_public"); + + evas_object_size_hint_weight_set(sub_ly, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_show(sub_ly); + +#ifdef INITIAL_VIEW_ADD_BTN + Evas_Object *btn = elm_button_add(ugd->navi_bar); + elm_object_text_set(btn, dgettext("sys_string", "IDS_COM_SK_ADD_ACCOUNT")); + evas_object_smart_callback_add(btn, "clicked", _add_account_cb, (void *)vd); + elm_object_style_set(btn, "text_only/style2"); + evas_object_show(btn); +#endif + + char *desc = g_strdup(_("IDS_EMAIL_BODY_YOU_CAN_USE_EMAIL_ON_YOUR_DEVICE_BY_ADDING_YOUR_ACCOUNT_IF_YOU_DO_NOT_HAVE_AN_EMAIL_ACCOUNT_SIGN_UP_FIRST")); + Evas_Object *label = elm_label_add(ugd->navi_bar); + elm_label_line_wrap_set(label, ELM_WRAP_WORD); + elm_label_wrap_width_set(label, 440); + + char *text = NULL; + if (w == 480) + text = g_strconcat("", + desc, "", NULL); + else + text = g_strconcat("", + desc, "", NULL); + + elm_object_text_set(label, text); + evas_object_show(label); + g_free(text); + +#ifndef INITIAL_VIEW_ADD_BTN + _create_list(vd); +#endif + +#ifdef INITIAL_VIEW_ADD_BTN + elm_object_part_content_set(sub_ly, "btn", btn); +#endif + elm_object_part_content_set(sub_ly, "label", label); +#ifndef INITIAL_VIEW_ADD_BTN + elm_object_part_content_set(sub_ly, "list", p->list); +#endif + + elm_object_part_content_set(p->layout, "elm.swallow.content", sub_ly); +} + +#ifndef INITIAL_VIEW_ADD_BTN +static void _create_list(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + int index; + Elm_Object_Item *git = NULL; + + p->list = elm_genlist_add(ugd->navi_bar); + elm_object_style_set(p->list, "dialogue"); + /*elm_object_theme_set(p->list, ugd->theme);*/ + evas_object_show(p->list); + + p->itc.item_style = "dialogue/1text.1icon.2"; + p->itc.func.text_get = _gl_text_get_cb; + p->itc.func.content_get = _gl_content_get_cb; + p->itc.func.state_get = _gl_state_get_cb; + p->itc.func.del = _gl_del_cb; + + p->itc2.item_style = "dialogue/separator"; + p->itc2.func.text_get = NULL; + p->itc2.func.content_get = NULL; + p->itc2.func.state_get = _gl_state_get_cb; + p->itc2.func.del = _gl_del_cb; + + /*git = elm_genlist_item_append(p->list, &(p->itc2), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_display_only_set(git, EINA_TRUE);*/ + + for (index = HOTMAIL; index <= OTHERS; index++) { + if (index != YAHOOMAIL) { + elm_genlist_item_append(p->list, &p->itc, (void *)index, git, + ELM_GENLIST_ITEM_NONE, _new_account_cb, vd); + } + } +} +#endif + +#ifdef INITIAL_VIEW_ADD_BTN +static void _add_account_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = data; + + /*elm_object_style_set(vd->ugd->bg, "group_list");*/ + setting_change_view(VIEW_SP_SELECT, vd->ugd); +} +#endif + +#ifndef INITIAL_VIEW_ADD_BTN +static void _new_account_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *it = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(it, EINA_FALSE); + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_INITIAL_ACCESS) { + debug_log("**double clicked**"); + return; + } + + ugd->account_info = (int)elm_object_item_data_get(it); + debug_log("ugd->account_info %d", ugd->account_info); + + setting_change_view(VIEW_ACCOUNT_SETUP, vd->ugd); +} +#endif + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = data; + + elm_win_lower(vd->ugd->win); +} + +#ifndef INITIAL_VIEW_ADD_BTN +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + return EINA_FALSE; +} + +static void _gl_del_cb(void *data, Evas_Object *obj) +{ + debug_log(""); + return; +} + +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + int index = (int)data; + char *str = NULL; + + switch (index) { + case GMAIL: + str = strdup(dgettext("sys_string", "IDS_COM_BODY_GOOGLE")); + break; + case HOTMAIL: + str = strdup(_("IDS_EMAIL_BODY_WINDOWS_LIVE_HOTMAIL")); + break; + case YAHOOMAIL: + str = strdup(_("IDS_EMAIL_BODY_YAHOO_E_MAIL")); + break; + case AOL: + str = strdup(_("IDS_EMAIL_BODY_AOL")); + break; + case OTHERS: + str = strdup(dgettext("sys_string", "IDS_COM_BODY_OTHERS")); + break; + } + + return str; +} + +static Evas_Object *_gl_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + Evas_Object *icon = elm_icon_add(obj); + int index = (int)data; + + switch (index) { + case GMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_GMAIL, NULL); + break; + case HOTMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_HOTMAIL, NULL); + break; + case YAHOOMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_YAHOO, NULL); + break; + case AOL: + elm_icon_file_set(icon, ACCOUNT_ICON_AOL, NULL); + break; + case OTHERS: + default: + elm_icon_file_set(icon, ACCOUNT_ICON_OTHERS, NULL); + break; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + return icon; +} +#endif + +/* EOF */ diff --git a/setting/src/email-view-mailbox-mapping.c b/setting/src/email-view-mailbox-mapping.c new file mode 100755 index 0000000..79bca8f --- /dev/null +++ b/setting/src/email-view-mailbox-mapping.c @@ -0,0 +1,309 @@ +/* + * 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" +#include "email-view-mailbox-mapping.h" + +static struct viewdata *g_vd = 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 _back_cb(void *data, Evas_Object *obj, void *event_data); +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part); +static void _gl_del_cb(void *data, Evas_Object *obj); +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info); + +struct priv_data { + struct viewdata *vd; + + int b_radio_changed; + + Evas_Object *layout; + Evas_Object *l_button; + Evas_Object *r_button; + Evas_Object *icon; + + Evas_Object *radio_grp; + Evas_Object *genlist; + Evas_Object *cbar; + + Elm_Object_Item * c_item[4]; + Elm_Genlist_Item_Class itc; + Elm_Genlist_Item_Class itc2; + Elm_Genlist_Item_Class itc3; + + email_mailbox_t *mailbox_list; + email_mailbox_t *mailbox_type; + + int mailbox_count; +}; + +void setting_init_mailbox_mapping_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_MAILBOX_MAPPING; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_mailbox_mapping"; +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p; + p = vd->priv; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + g_vd = vd; + p->layout = setting_add_inner_layout(vd); + _push_naviframe(vd); + } + + _create_list(vd); + + evas_object_show(p->layout); + + 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; + + evas_object_del(p->radio_grp); + evas_object_del(p->l_button); + evas_object_del(p->genlist); + + email_free_mailbox(&p->mailbox_list, p->mailbox_count); + email_free_mailbox(&p->mailbox_type, 1); + return TRUE; +} + +static int _show(struct viewdata *vd) +{ + debug_log(""); + + evas_object_show(vd->ly); + return TRUE; +} + +static int _hide(struct viewdata *vd) +{ + debug_log(""); + + 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->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); + + Elm_Object_Item *navi_it = NULL; + navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, + _("IDS_EMAIL_HEADER_MAILBOX_SETUP"), p->l_button, NULL, p->layout, NULL); + 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 = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + int count = 0; + int i = 0; + + Elm_Object_Item *git = NULL; + + email_get_mailbox_list(ugd->account_id, -1, &p->mailbox_list, &p->mailbox_count); + count = p->mailbox_count; + debug_log("folder count %d", count); + + email_get_mailbox_by_mailbox_type(ugd->account_id, ugd->setup_mailbox, &p->mailbox_type); + + p->radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->radio_grp, 0); + evas_object_hide(p->radio_grp); + + p->genlist = elm_genlist_add(ugd->navi_bar); + elm_object_style_set(p->genlist, "dialogue"); + + p->itc.item_style = "dialogue/1text.1icon.3"; + p->itc.func.text_get = _gl_text_get_cb; + p->itc.func.content_get = _gl_content_get_cb; + p->itc.func.state_get = _gl_state_get_cb; + p->itc.func.del = _gl_del_cb; + + p->itc2.item_style = "dialogue/separator"; + p->itc2.func.text_get = NULL; + p->itc2.func.content_get = NULL; + p->itc2.func.state_get = _gl_state_get_cb; + p->itc2.func.del = _gl_del_cb; + + p->itc3.item_style = "dialogue/separator/end"; + p->itc3.func.text_get = NULL; + p->itc3.func.content_get = NULL; + p->itc3.func.state_get = _gl_state_get_cb; + p->itc3.func.del = _gl_del_cb; + + git = elm_genlist_item_append(p->genlist, &(p->itc2), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + for (i = 0; i < count; i++) { + if ((p->mailbox_list[i]).mailbox_type == p->mailbox_type->mailbox_type || + (p->mailbox_list[i]).mailbox_type == EMAIL_MAILBOX_TYPE_USER_DEFINED) { + elm_genlist_item_append(p->genlist, &(p->itc), (void *)i, git, + ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + } + } + + git = elm_genlist_item_append(p->genlist, &(p->itc3), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + elm_object_part_content_set(p->layout, "elm.swallow.content", p->genlist); +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_data) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + EmailSettingUGD *ugd = vd->ugd; + struct viewdata *prev_vd = ugd->vd[VIEW_ACCOUNT_OPTIONS]; + + if (prev_vd) prev_vd->refresh = 1; + + setting_back_to_prev_view(vd); +} + +static char *_gl_text_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; + + if (!strcmp(part, "elm.text")) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", (p->mailbox_list[index]).alias); + return g_strdup(buf); + } + + return NULL; +} + +static Evas_Object *_gl_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 (!strcmp(part, "elm.icon")) { + debug_log("index %d", index); + Evas_Object *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->radio_grp); + elm_radio_state_value_set(radio, index); + + if (p->b_radio_changed == 0 && + g_strcmp0((p->mailbox_list[index]).mailbox_name, p->mailbox_type->mailbox_name) == 0) { + elm_radio_value_set(p->radio_grp, index); + } + + return radio; + } + + return NULL; +} + +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + return EINA_FALSE; +} + +static void _gl_del_cb(void *data, Evas_Object *obj) +{ + debug_log(""); + return; +} + +static void _gl_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; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(item, EINA_FALSE); + + elm_radio_value_set(p->radio_grp, index); + debug_log("index %d", index); + + email_set_mailbox_type(p->mailbox_type->mailbox_id, EMAIL_MAILBOX_TYPE_USER_DEFINED); + email_set_mailbox_type((p->mailbox_list[index]).mailbox_id, ugd->setup_mailbox); + + debug_log("new folder name is %s", (p->mailbox_list[index]).alias); + + p->b_radio_changed = 1; +} + +/* EOF */ diff --git a/setting/src/email-view-manual-setup.c b/setting/src/email-view-manual-setup.c new file mode 100755 index 0000000..90bc491 --- /dev/null +++ b/setting/src/email-view-manual-setup.c @@ -0,0 +1,1696 @@ +/* + * 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-account-set.h" +#include "email-setting-utils.h" + +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 int _create_account(void *data); +static void _validate_account(struct viewdata *vd, int account_id); +static int _check_null_field(struct viewdata *vd); +static void _set_preset_value(struct viewdata *vd); +static void _read_all_entries(struct viewdata *vd); + +static void _save_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_validation_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 char *_gl_text_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 Evas_Object *_gl_ef_content_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 Evas_Object *_gl_ex_sending_secure_content_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_incoming_type_text_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_ex_incoming_type_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 void _gl_ex_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_type_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_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; + unsigned int handle; + + int icon_get_cnt1; + + char *str_account_name; + char *str_user_name; + char *str_password; + char *str_smtp_server; + char *str_smtp_port; + char *str_incoming_server; + char *str_incoming_port; + + Evas_Object *entry_account_name; + 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_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 *icon; + Evas_Object *layout; + Evas_Object *conform; + + Evas_Object *sending_secure_radio_grp; + Evas_Object *incoming_type_radio_grp; + Evas_Object *incoming_secure_radio_grp; + + Evas_Object *r_button; + Evas_Object *l_button; + Evas_Object *l_button2; + Evas_Object *clicked_object; + Evas_Object *genlist; + Evas_Object *cbar; + + email_account_t *account; + + Elm_Genlist_Item_Class itc1; + Elm_Genlist_Item_Class itc2; + Elm_Genlist_Item_Class itc3; + Elm_Genlist_Item_Class itc4; + Elm_Genlist_Item_Class itc5; + Elm_Genlist_Item_Class itc6; + Elm_Genlist_Item_Class itc7; + + Elm_Object_Item *gl_ex_item1; + Elm_Object_Item *gl_ex_item2; + Elm_Object_Item *gl_ex_item3; + Elm_Object_Item * c_item[4]; +}; + +void setting_init_manual_setup_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_MANUAL_SETUP; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_manual_setup"; +} + +void setting_manual_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; + } + + ugd->atomic_pop = 1; + + 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->other_vc_timer = ecore_timer_add(0.5, _after_validation_cb, vd); +} + +void setting_manual_validation_failed_cb(EmailSettingUGD *ugd, gboolean canceled) +{ + debug_log(""); + struct viewdata *vd; + char fail_msg[MAX_STR_LEN] = { 0, }; + char *err_msg; + Viewtype top; + top = ugd->view_st[ugd->view_top]; + vd = ugd->vd[top]; + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + int account_id; + err_msg = setting_get_service_fail_type(ugd->err_code); + + account_id = ugd->account_id; + ugd->manual_setup = 0; + + 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 (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; + } + + struct priv_data *p; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + + p->account = ugd->new_account; + + if (ugd->account_info == OTHERS) { + p->account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + p->account->incoming_server_secure_connection = 0; + p->account->outgoing_server_secure_connection = 0; + + p->str_account_name = g_strdup(p->account->account_name); + p->str_user_name = g_strdup(p->account->incoming_server_user_name); + p->str_password = g_strdup(p->account->incoming_server_password); + } else { + _set_preset_value(vd); + } + + 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); + } + + g_vd = vd; + + _create_list(vd); + vd->refresh = 1; + + 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; + + 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_button); + evas_object_del(p->genlist); + + if (ugd->other_vc_timer) { + ecore_timer_del(ugd->other_vc_timer); + ugd->other_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; + } + + 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->r_button = elm_button_add(vd->ugd->navi_bar); + elm_object_style_set(p->r_button, "naviframe/title/default"); + elm_object_text_set(p->r_button, dgettext("sys_string", "IDS_COM_SK_SET")); + evas_object_smart_callback_add(p->r_button, "clicked", _save_cb, vd); + elm_object_disabled_set(p->r_button, EINA_TRUE); + evas_object_show(p->r_button); + + p->l_button = elm_button_add(vd->ugd->navi_bar); + elm_object_style_set(p->l_button, "naviframe/title/default"); + elm_object_text_set(p->l_button, dgettext("sys_string", "IDS_COM_SK_CANCEL")); + evas_object_smart_callback_add(p->l_button, "clicked", _back_cb, vd); + evas_object_show(p->l_button); + + p->l_button2 = elm_button_add(vd->ugd->navi_bar); + evas_object_smart_callback_add(p->l_button2, "clicked", _back_cb, vd); + elm_object_style_set(p->l_button2, "naviframe/back_btn/default"); + evas_object_show(p->l_button2); + + Elm_Object_Item *navi_it = NULL; + navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, + _("IDS_EMAIL_HEADER_ADD_ACCOUNT"), p->l_button2, NULL, p->layout, NULL); + elm_object_item_part_content_set(navi_it, "title_left_btn", p->r_button); + elm_object_item_part_content_set(navi_it, "title_right_btn", p->l_button); + evas_object_show(vd->ugd->navi_bar); +} + +static void _create_list(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_critical("vd is null!"); + return; + } + + struct priv_data *p; + EmailSettingUGD *ugd; + int i = 0; + + 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->incoming_type_radio_grp = elm_radio_add(p->genlist); + elm_radio_value_set(p->incoming_type_radio_grp, 0); + evas_object_hide(p->incoming_type_radio_grp); + + p->itc1.item_style = "dialogue/separator"; + p->itc1.func.text_get = NULL; + p->itc1.func.content_get = NULL; + p->itc1.func.state_get = NULL; + p->itc1.func.del = NULL; + + p->itc2.item_style = "dialogue/1icon"; + p->itc2.func.text_get = NULL; + p->itc2.func.content_get = _gl_ef_content_get_cb; + p->itc2.func.state_get = NULL; + p->itc2.func.del = NULL; + + p->itc3.item_style = "dialogue/2text.3/expandable"; + p->itc3.func.text_get = _gl_text_get_cb; + p->itc3.func.content_get = NULL; + p->itc3.func.state_get = NULL; + p->itc3.func.del = NULL; + + p->itc4.item_style = "dialogue/1text.1icon/expandable2"; + p->itc4.func.text_get = _gl_ex_secure_text_get_cb; + p->itc4.func.content_get = _gl_ex_sending_secure_content_get_cb; + p->itc4.func.state_get = NULL; + p->itc4.func.del = NULL; + + p->itc5.item_style = "dialogue/1text.1icon/expandable2"; + p->itc5.func.text_get = _gl_ex_incoming_type_text_get_cb; + p->itc5.func.content_get = _gl_ex_incoming_type_content_get_cb; + p->itc5.func.state_get = NULL; + p->itc5.func.del = NULL; + + p->itc6.item_style = "dialogue/1text.1icon/expandable2"; + p->itc6.func.text_get = _gl_ex_secure_text_get_cb; + p->itc6.func.content_get = _gl_ex_incoming_secure_content_get_cb; + p->itc6.func.state_get = NULL; + p->itc6.func.del = NULL; + + p->itc7.item_style = "dialogue/separator/end"; + p->itc7.func.text_get = NULL; + p->itc7.func.content_get = NULL; + p->itc7.func.state_get = NULL; + p->itc7.func.del = NULL; + + git = elm_genlist_item_append(p->genlist, &(p->itc1), 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->itc2), (void *)i, NULL, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + /* User name */ + i = 2; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + /* Password */ + i = 3; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + git = elm_genlist_item_append(p->genlist, &(p->itc1), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + /* smtp server */ + i = 4; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + /* smtp port */ + i = 5; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (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->itc3), (void *)i, + NULL, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + + git = elm_genlist_item_append(p->genlist, &(p->itc1), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + /* incoming server type */ + i = 2; + p->gl_ex_item2 = elm_genlist_item_append(p->genlist, &(p->itc3), (void *)i, + NULL, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + + /* incoming server */ + i = 6; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + /* incoming port */ + i = 7; + item = elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, NULL, + ELM_GENLIST_ITEM_NONE, _gl_ef_sel_cb, (void *)i); + + /* secure connection */ + i = 3; + p->gl_ex_item3 = elm_genlist_item_append(p->genlist, &(p->itc3), (void *)i, + NULL, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + + git = elm_genlist_item_append(p->genlist, &(p->itc7), 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, "expand,request", _gl_exp_req_cb, (void *)vd); + evas_object_smart_callback_add(p->genlist, "contract,request", _gl_con_req_cb, (void *)vd);*/ + 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 int _create_account(void *data) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + int account_id; + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + int error_code = 0; + + if (email_engine_add_account_with_validation(p->account, &account_id, + &(p->handle), &error_code)) { + debug_log("Account added to Email Service DB"); + vd->ugd->start_account_validation = 1; + vd->ugd->manual_setup = 1; + ugd->handle = p->handle; + _validate_account(vd, account_id); + } else { + debug_log("Fail to make account"); + + 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 (error_code == EMAIL_ERROR_ALREADY_EXISTS) + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + dgettext("sys_string", "IDS_COM_POP_ALREDY_EXISTS"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + else + ugd->popup_one = setting_get_notify(vd, + dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_UNABLE_TO_ADD_ACCOUNT"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + } + return TRUE; +} + +static void _validate_account(struct viewdata *vd, int account_id) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + email_account_t *account = p->account; + + debug_log("account id: %d", account_id); + debug_log("account name: %s", account->account_name); + debug_log("email address: %s", account->user_email_address); + + ugd->account_id = account_id; + + /* delete popup first */ + 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; + } + /*ret = email_engine_get_account_validation(account_id,&(p->handle));*/ + + ugd->cancel_event = 0; + + elm_object_disabled_set(p->r_button, EINA_TRUE); + elm_object_disabled_set(p->l_button, EINA_TRUE); + elm_object_disabled_set(p->l_button2, EINA_TRUE); + + 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); +} + +static int _check_null_field(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + p = vd->priv; + email_account_t *account = p->account; + + debug_log("account name:%s", account->account_name); + debug_log("user name:%s", account->incoming_server_user_name); + debug_log("password:%s", account->incoming_server_password); + debug_log("recv server:%s", account->incoming_server_address); + debug_log("recv port:%d", account->incoming_server_port_number); + debug_log("sending server:%s", account->outgoing_server_address); + debug_log("sending port:%d", account->outgoing_server_port_number); + debug_log("sending user:%s", account->outgoing_server_user_name); + debug_log("sending pass:%s", account->outgoing_server_password); + + if (account->account_name == NULL || strlen(account->account_name) == 0 || + account->incoming_server_user_name == NULL || strlen(account->incoming_server_user_name) == 0 || + account->incoming_server_password == NULL || strlen(account->incoming_server_password) == 0 || + account->incoming_server_address == NULL || strlen(account->incoming_server_address) == 0 || + account->outgoing_server_address == NULL || strlen(account->outgoing_server_address) == 0 || + account->incoming_server_port_number == 0 || account->outgoing_server_port_number == 0) { + return FALSE; + } else { + return TRUE; + } +} + +static void _set_preset_value(struct viewdata *vd) +{ + debug_log(""); + + struct priv_data *p = vd->priv; + email_account_t *account = p->account; + char buf[10] = { 0, }; + + p->str_account_name = g_strdup(account->account_name); + p->str_user_name = g_strdup(account->incoming_server_user_name); + p->str_password = g_strdup(account->incoming_server_password); + p->str_incoming_server = g_strdup(account->incoming_server_address); + p->str_smtp_server = g_strdup(account->outgoing_server_address); + + snprintf(buf, sizeof(buf), "%d", account->incoming_server_port_number); + p->str_incoming_port = g_strdup(buf); + + snprintf(buf, sizeof(buf), "%d", account->outgoing_server_port_number); + p->str_smtp_port = g_strdup(buf); +} + +static void _read_all_entries(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + char *buf; + + p = vd->priv; + email_account_t *account = p->account; + + if (account->account_name) { + g_free(account->account_name); + account->account_name = NULL; + } + + if (account->incoming_server_user_name) { + g_free(account->incoming_server_user_name); + account->incoming_server_user_name = NULL; + } + + if (account->incoming_server_password) { + g_free(account->incoming_server_password); + account->incoming_server_password = NULL; + } + + if (account->incoming_server_address) { + g_free(account->incoming_server_address); + account->incoming_server_address = NULL; + } + + if (account->outgoing_server_address) { + g_free(account->outgoing_server_address); + account->outgoing_server_address = NULL; + } + + /*if (account->outgoing_server_user_name) { + g_free(account->outgoing_server_user_name); + account->outgoing_server_user_name = NULL; + } + + if (account->outgoing_server_password) { + g_free(account->outgoing_server_password); + account->outgoing_server_password = NULL; + }*/ + + /* accout name get */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_account_name));*/ + buf = elm_entry_markup_to_utf8(p->str_account_name); + if (buf) { + account->account_name = g_strdup(buf); + g_free(buf); + } + + /* user name get */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_user_name));*/ + buf = elm_entry_markup_to_utf8(p->str_user_name); + if (buf) { + account->incoming_server_user_name = g_strdup(buf); + g_free(buf); + } + + /* password get */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_password));*/ + buf = elm_entry_markup_to_utf8(p->str_password); + if (buf) { + account->incoming_server_password = g_strdup(buf); + g_free(buf); + } + + /* incoming server get */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_incoming_server));*/ + buf = elm_entry_markup_to_utf8(p->str_incoming_server); + if (buf) { + account->incoming_server_address = g_strdup(buf); + g_free(buf); + } + + /* outgoing server get */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_smtp_server));*/ + buf = elm_entry_markup_to_utf8(p->str_smtp_server); + if (buf) { + account->outgoing_server_address = g_strdup(buf); + g_free(buf); + } + + /* receiving port num get */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_incoming_port));*/ + buf = elm_entry_markup_to_utf8(p->str_incoming_port); + if (buf) { + account->incoming_server_port_number = atoi(buf); + g_free(buf); + } + + /* sending port nom get */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_smtp_port));*/ + buf = elm_entry_markup_to_utf8(p->str_smtp_port); + if (buf) { + account->outgoing_server_port_number = atoi(buf); + g_free(buf); + } + + /* sending user name */ + /*buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_sending_username));*/ + /*account->outgoing_server_user_name = g_strdup(account->incoming_server_user_name);*/ + + /* sending password */ + /* buf = elm_entry_markup_to_utf8(elm_entry_entry_get(p->entry_sending_password));*/ + /*account->outgoing_server_password = g_strdup(account->incoming_server_password);*/ +} + +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; + email_account_t *account = NULL; + int ret = 0; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + p = vd->priv; + ugd = vd->ugd; + account = p->account; + + /* Save the data */ + _read_all_entries(vd); + debug_log("Account Structure Info\nEmail Addr:%s\nUser Dispname:%s\nUser Password:%s", + account->user_email_address, account->user_display_name, account->incoming_server_password); + + 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; + } + /* check Null field */ + ret = _check_null_field(vd); + if (!ret) { + debug_log("empty space in account info"); + 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; + } + /* account info setting */ + if (vd->ugd->account_info == OTHERS) + setting_set_account(vd); + + _create_account(vd); +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)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_validation_cb(void *data) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->other_vc_timer) { + ecore_timer_del(ugd->other_vc_timer); + ugd->other_vc_timer = NULL; + } + + status_message_post(_("IDS_EMAIL_POP_SUCCEEDED")); + + setting_change_view(VIEW_SYNC_SETUP, ugd); + + setting_get_small_notify(vd, _("IDS_EMAIL_POP_SUCCEEDED")); + + /*if (vd->ugd->start_view_type != NULL && + g_strcmp0(vd->ugd->start_view_type, "first-setup") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + g_strcmp0(vd->ugd->start_view_type, "account-add") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + g_strcmp0(vd->ugd->start_view_type, "select-account") == 0) { + service_h service = NULL; + service_create(&service); + if (service) { + service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, + EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT); + ug_send_result(vd->ugd->ug, service); + service_destroy(service); + } + } else { + setting_update_acct_list(vd); + setting_back_to_prev_nth_view(vd, 3, vd->ugd->navi_main_it); + vd->ugd->atomic_pop = 0; + }*/ + + 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; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + 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->r_button, EINA_FALSE); + elm_object_disabled_set(p->l_button, EINA_FALSE); + elm_object_disabled_set(p->l_button2, EINA_FALSE); +} + +/*static void _popup_cancel_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; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + 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_disabled_set(p->l_button2, 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; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + 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; + email_engine_stop_working(account_id, p->handle); + email_engine_delete_account(account_id); + + elm_object_disabled_set(p->r_button, EINA_FALSE); + elm_object_disabled_set(p->l_button, EINA_FALSE); + elm_object_disabled_set(p->l_button2, EINA_FALSE); +} + +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; + } + p->str_account_name = g_strdup(elm_entry_entry_get(eo)); + } 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; + } + p->str_user_name = g_strdup(elm_entry_entry_get(eo)); + } else if (eo == p->entry_password) { + debug_log("entry_password"); + if (p->str_password) { + g_free(p->str_password); + p->str_password = NULL; + } + p->str_password = g_strdup(elm_entry_entry_get(eo)); + } 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; + } + p->str_smtp_server = g_strdup(elm_entry_entry_get(eo)); + } 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; + } + p->str_incoming_server = g_strdup(elm_entry_entry_get(eo)); + } 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)); + } + + if (p->str_account_name == NULL || + p->str_user_name == NULL || + p->str_password == NULL || + p->str_smtp_server == NULL || + p->str_smtp_port == NULL || + p->str_incoming_server == NULL || + p->str_incoming_port == NULL) { + elm_object_disabled_set(p->r_button, EINA_TRUE); + return; + } + + if (g_strcmp0(p->str_account_name, "") == 0 || + g_strcmp0(p->str_user_name, "") == 0 || + g_strcmp0(p->str_password, "") == 0 || + g_strcmp0(p->str_smtp_server, "") == 0 || + g_strcmp0(p->str_smtp_port, "") == 0 || + g_strcmp0(p->str_incoming_server, "") == 0 || + g_strcmp0(p->str_incoming_port, "") == 0) { + elm_object_disabled_set(p->r_button, EINA_TRUE); + } else { + elm_object_disabled_set(p->r_button, EINA_FALSE); + } +} + +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 char *_gl_text_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 = p->account; + + if (!strcmp(part, "elm.text.1")) { + if (index == 1) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SECURE_CONNECTION")); + return g_strdup(buf); + } + + if (index == 2) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_INCOMING_MAIL_SERVER_TYPE")); + return g_strdup(buf); + } + + if (index == 3) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SECURE_CONNECTION")); + return g_strdup(buf); + } + } + + if (!strcmp(part, "elm.text.2")) { + if (index == 1) { + if (account->outgoing_server_secure_connection == 0) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_OFF")); + return g_strdup(buf); + } + if (account->outgoing_server_secure_connection == 1) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SSL")); + return g_strdup(buf); + } + if (account->outgoing_server_secure_connection == 2) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_TLS")); + return g_strdup(buf); + } + } + + if (index == 2) { + if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_POP3")); + return g_strdup(buf); + } + if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_IMAP4")); + return g_strdup(buf); + } + } + + if (index == 3) { + if (account->incoming_server_secure_connection == 0) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_OFF")); + return g_strdup(buf); + } + if (account->incoming_server_secure_connection == 1) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SSL")); + return g_strdup(buf); + } + if (account->incoming_server_secure_connection == 2) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_TLS")); + return g_strdup(buf); + } + } + } + + 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); + + if (index == 1) { + p->clicked_object = p->entry_account_name; + } else if (index == 2) { + p->clicked_object = p->entry_user_name; + } else if (index == 3) { + p->clicked_object = p->entry_password; + } else if (index == 4) { + p->clicked_object = p->entry_smtp_server; + } else if (index == 5) { + p->clicked_object = p->entry_smtp_port; + } else if (index == 6) { + p->clicked_object = p->entry_incoming_server; + } else if (index == 7) { + p->clicked_object = p->entry_incoming_port; + } +} + +static Evas_Object *_gl_ef_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; + + if (!strcmp(part, "elm.icon")) { + + if (index == 1) { + debug_log(""); + 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_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; + } else if (index == 2) { + debug_log(""); + 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_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, TRUE); + 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; + } else if (index == 3) { + debug_log(""); + 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_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, EINA_TRUE); + elm_entry_password_set(p->entry_password, EINA_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_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; + } else if (index == 4) { + /*p->icon_get_cnt1++;*/ + debug_log(""); + 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_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); + + /*if (p->icon_get_cnt1 < 4) { + p->clicked_object = p->entry_smtp_server; + evas_object_show(p->entry_smtp_server); + elm_object_focus_set(p->entry_smtp_server, EINA_TRUE); + }*/ + + return p->ef_smtp_server; + } else if (index == 5) { + debug_log(""); + 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_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; + } else if (index == 6) { + debug_log(""); + 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_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); + 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; + } else if (index == 7) { + debug_log(""); + 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_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); + 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; + } + } + + return NULL; +} + +static char *_gl_ex_secure_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + int index = (int)data; + + if (!strcmp(part, "elm.text")) { + char buf[MAX_STR_LEN] = { 0, }; + + if (index == 0) { + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_OFF")); + } + if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SSL")); + } + if (index == 2) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_TLS")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static Evas_Object *_gl_ex_sending_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 = p->account; + + if (!strcmp(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 char *_gl_ex_incoming_type_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + int index = (int)data; + + if (!strcmp(part, "elm.text")) { + char buf[MAX_STR_LEN] = { 0, }; + + if (index == 0) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_POP3")); + } + if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_IMAP4")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static Evas_Object *_gl_ex_incoming_type_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 = p->account; + + if (!strcmp(part, "elm.icon")) { + Evas_Object *radio = elm_radio_add(p->genlist); + elm_radio_group_add(radio, p->incoming_type_radio_grp); + elm_radio_state_value_set(radio, index); + + if (index == 0) { + if (account->incoming_server_type == EMAIL_SERVER_TYPE_POP3) + elm_radio_value_set(p->incoming_type_radio_grp, 0); + + if (account->incoming_server_type == EMAIL_SERVER_TYPE_IMAP4) + elm_radio_value_set(p->incoming_type_radio_grp, 1); + } + 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 = p->account; + + if (!strcmp(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 void _gl_ex_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 = p->account; + 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_type_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 = p->account; + 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_type_radio_grp); + + if (sel_radio == index) + return; + + switch (index) { + case 0: + { + account->incoming_server_type = EMAIL_SERVER_TYPE_POP3; + break; + } + case 1: + { + account->incoming_server_type = EMAIL_SERVER_TYPE_IMAP4; + break; + } + } + + elm_radio_value_set(p->incoming_type_radio_grp, index); + elm_genlist_item_update(p->gl_ex_item2); +} + +static void _gl_ex_incoming_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 = p->account; + 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_item3); +} + +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->itc4), (void *)i, it, ELM_GENLIST_ITEM_NONE, _gl_ex_sending_secure_sel_cb, (void *)i); + } + } + /* incoming server type */ + if (it == p->gl_ex_item2) { + for (i = 0; i < 2; i++) { + elm_genlist_item_append(p->genlist, &(p->itc5), (void *)i, it, ELM_GENLIST_ITEM_NONE, _gl_ex_incoming_type_sel_cb, (void *)i); + } + } + /* incoming security */ + if (it == p->gl_ex_item3) { + for (i = 0; i < 3; i++) { + elm_genlist_item_append(p->genlist, &(p->itc6), (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 */ diff --git a/setting/src/email-view-setting.c b/setting/src/email-view-setting.c new file mode 100755 index 0000000..fc25daa --- /dev/null +++ b/setting/src/email-view-setting.c @@ -0,0 +1,971 @@ +/* + * 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 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_default_account(struct viewdata *vd); +static void _back_cb(void *data, Evas_Object *obj, void *event_info); +static void _add_account_cb(void *data, Evas_Object *obj, void *event_info); +static void _color_rect_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info); +static void _colorselector_cb(void *data, Evas_Object *obj, void *event_info); +static void _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info); +static void _popup_ok_cb(void *data, Evas_Object *obj, void *event_info); + +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_account_text_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_ex_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_account_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part); +static void _gl_del_cb(void *data, Evas_Object *obj); +static void _gl_account_del_cb(void *data, Evas_Object *obj); +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_default_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_account_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; + + int color_r; + int color_g; + int color_b; + int color_a; + int def_acct_id; + char *def_acct_addr; + + Evas_Object *box; + Evas_Object *layout; + Evas_Object *navi_bar; + Evas_Object *cbar; + Evas_Object *icon; + Evas_Object *l_button; + Evas_Object *r_button; + Evas_Object *scroller; + Evas_Object *ly; + Evas_Object *sp1; + Evas_Object *sp2; + Evas_Object *sp3; + Evas_Object *di1; + Evas_Object *di2; + Evas_Object *di3; + Evas_Object *dg1; + Evas_Object *dg2; + Evas_Object *colorselector; + Evas_Object *rect; + Evas_Object *color_rect; + Evas_Object *color_bar; + Evas_Object *btn_color_save; + Evas_Object *btn_color_cancel; + Evas_Object **pdi; + Evas_Object *onoff; + Evas_Object *radio_grp; + + Evas_Object *genlist; + Elm_Genlist_Item_Class itc; + Elm_Genlist_Item_Class itc2; + Elm_Genlist_Item_Class itc3; + Elm_Genlist_Item_Class itc4; + Elm_Genlist_Item_Class itc5; + Elm_Genlist_Item_Class itc6; + Elm_Genlist_Item_Class itc7; + + Elm_Object_Item * c_item[10]; + Elm_Object_Item *color_item; + Elm_Object_Item *default_account_item; +}; + +typedef struct { + email_account_t *account_data; + Elm_Object_Item *it; + Evas_Object *color_rect; + Evas_Object *color_bar; +} ListItemData; + +void setting_init_setting_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_SETTING; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_main"; +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p; + p = vd->priv; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + p->layout = setting_add_inner_layout(vd); + _push_naviframe(vd); + vd->ugd->setting_main_view = p->layout; + } + + g_vd = vd; + vd->refresh = 1; + + return TRUE; +} + +static int _update(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + + if (vd->refresh) { + debug_log(""); + if (setting_update_acct_list(vd) == FALSE) { + vd->ugd->account_count = 0; + vd->ugd->account_list = NULL; + p->def_acct_id = 0; + p->def_acct_addr = g_strdup(dgettext("sys_string", "IDS_COM_BODY_NONE")); + } + _get_default_account(vd); + + if (p->genlist) { + elm_object_part_content_unset(p->layout, "elm.swallow.content"); + evas_object_del(p->genlist); + p->genlist = NULL; + } + + _create_list(vd); + } + + return TRUE; +} + +static int _destroy(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + + if (p == NULL) { + debug_log("priv is NULL"); + return FALSE; + } + + evas_object_del(vd->ugd->popup_one); + evas_object_del(p->l_button); + evas_object_del(p->r_button); + evas_object_del(p->genlist); + + vd->ugd->popup_one = 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); + evas_object_del(vd->ugd->popup_one); + + vd->ugd->popup_one = NULL; + + 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, CBAR_ICON_ADD, + dgettext("sys_string", "IDS_COM_SK_ADD"), _add_account_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); + evas_object_show(p->l_button); + elm_object_style_set(p->l_button, "naviframe/back_btn/default"); + + vd->ugd->navi_main_it = elm_naviframe_item_push(vd->ugd->navi_bar, + _("IDS_EMAIL_HEADER_EMAIL_SETTINGS"), p->l_button, NULL, p->layout, NULL); + elm_object_item_part_content_set(vd->ugd->navi_main_it, + "controlbar", p->cbar); + evas_object_show(vd->ugd->navi_bar); +} + +static void _create_list(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_critical("vd is null!"); + return; + } + + struct priv_data *p; + EmailSettingUGD *ugd; + email_account_t *account_data = NULL; + int i = 0; + + ugd = vd->ugd; + p = vd->priv; + + Elm_Object_Item *git = NULL; + + p->radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->radio_grp, 0); + evas_object_hide(p->radio_grp); + + p->genlist = elm_genlist_add(ugd->navi_bar); + elm_object_style_set(p->genlist, "dialogue"); + + /*default account*/ + p->itc.item_style = "dialogue/2text.3/expandable"; + p->itc.func.text_get = _gl_text_get_cb; + p->itc.func.content_get = NULL; + p->itc.func.state_get = _gl_state_get_cb; + p->itc.func.del = _gl_del_cb; + + /*subitem*/ + p->itc2.item_style = "dialogue/1text.1icon/expandable2"; + p->itc2.func.text_get = _gl_ex_text_get_cb; + p->itc2.func.content_get = _gl_ex_content_get_cb; + p->itc2.func.state_get = _gl_state_get_cb; + p->itc2.func.del = _gl_del_cb; + + /*block emails*/ + p->itc3.item_style = "dialogue/1text"; + p->itc3.func.text_get = _gl_text_get_cb; + p->itc3.func.content_get = NULL; + p->itc3.func.state_get = _gl_state_get_cb; + p->itc3.func.del = _gl_del_cb; + + /*accounts*/ + p->itc4.item_style = "dialogue/2text.3icon"; + p->itc4.func.text_get = _gl_account_text_get_cb; + p->itc4.func.content_get = _gl_account_content_get_cb; + p->itc4.func.state_get = _gl_state_get_cb; + p->itc4.func.del = _gl_account_del_cb; + + /*title*/ + p->itc5.item_style = "dialogue/title"; + p->itc5.func.text_get = _gl_text_get_cb; + p->itc5.func.content_get = NULL; + p->itc5.func.state_get = _gl_state_get_cb; + p->itc5.func.del = _gl_del_cb; + + /*default account - no account*/ + p->itc6.item_style = "dialogue/2text.3"; + p->itc6.func.text_get = _gl_text_get_cb; + p->itc6.func.content_get = NULL; + p->itc6.func.state_get = _gl_state_get_cb; + p->itc6.func.del = _gl_del_cb; + + p->itc7.item_style = "dialogue/separator/end"; + p->itc7.func.text_get = NULL; + p->itc7.func.content_get = NULL; + p->itc7.func.state_get = NULL; + p->itc7.func.del = NULL; + + i = 1; + git = elm_genlist_item_append(p->genlist, &(p->itc5), (void *)i, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + i = 2; + if (ugd->account_count > 0) + p->default_account_item = elm_genlist_item_append(p->genlist, &(p->itc), (void *)i, git, + ELM_GENLIST_ITEM_TREE, _gl_default_sel_cb, (void *)vd); + else + p->default_account_item = elm_genlist_item_append(p->genlist, &(p->itc6), (void *)i, git, + ELM_GENLIST_ITEM_NONE, _gl_sel_cb, NULL); + + i = 4; + git = elm_genlist_item_append(p->genlist, &(p->itc5), (void *)i, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + for (i = 0; i < ugd->account_count; i++) { + account_data = &(ugd->account_list[i]); + + if (account_data) { + ListItemData *item_data = calloc(1, sizeof(ListItemData)); + item_data->account_data = account_data; + item_data->it = elm_genlist_item_append(p->genlist, &(p->itc4), + (void *)item_data, git, ELM_GENLIST_ITEM_NONE, + _gl_account_sel_cb, (void *)account_data); + } + } + + git = elm_genlist_item_append(p->genlist, &(p->itc7), 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_part_content_set(p->layout, "elm.swallow.content", p->genlist); +} + +static void _get_default_account(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_critical("vd is null!"); + return; + } + + struct priv_data *p; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + int account_id = 0; + int err = 0; + int i = 0; + + if (ugd->account_count == 0) { + debug_log(""); + return; + } + + err = email_engine_get_default_account(&account_id); + if (err == FALSE) { + debug_log("failed to get default account"); + return; + } + debug_log("default account id (%d)", account_id); + p->def_acct_id = account_id; + + if (p->def_acct_addr) { + g_free(p->def_acct_addr); + p->def_acct_addr = NULL; + } + + for (i = 0; i < ugd->account_count; i++) { + if (ugd->account_list[i].account_id == p->def_acct_id) { + if (ugd->account_list[i].user_email_address != NULL) { + debug_log("Default account Addr : %s", ugd->account_list[i].user_email_address); + p->def_acct_addr = g_strdup(ugd->account_list[i].user_email_address); + } + } + } +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = data; + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->popup_color) { + evas_object_del(ugd->popup_color); + ugd->popup_color = NULL; + } + + setting_back_to_prev_view(vd); +} + +static void _add_account_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = data; + EmailSettingUGD *ugd = vd->ugd; + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_SETTING) { + debug_log("**double clicked**"); + return; + } + + if (ugd->popup_color) { + evas_object_del(ugd->popup_color); + ugd->popup_color = NULL; + } + + setting_change_view(VIEW_SP_SELECT, vd->ugd); +} + +static void _color_rect_cb(void *data, Evas * evas, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_SETTING) { + debug_log("**double clicked**"); + return; + } + + if (ugd->popup_color) { + evas_object_del(ugd->popup_color); + ugd->popup_color = NULL; + } + + ListItemData *item_data = NULL; + email_account_t *account_data = NULL; + + item_data = (ListItemData *) data; + if (item_data == NULL) { + debug_log("item_data == NULL"); + return; + } + + account_data = item_data->account_data; + + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + unsigned int val = user_data->index_color; + int r = (val & 0xff000000) >> 24; + int g = (val & 0x00ff0000) >> 16; + int b = (val & 0x0000ff00) >> 8; + int a = val & 0x000000ff; + + ugd->popup_color = elm_notify_add(ugd->navi_bar); + elm_notify_orient_set(ugd->popup_color, ELM_NOTIFY_ORIENT_BOTTOM); + evas_object_size_hint_weight_set(ugd->popup_color, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + /*elm_popup_buttons_add(ugd->popup_color, 2, dgettext("sys_string", "IDS_COM_SK_OK"), + ELM_POPUP_RESPONSE_OK, + dgettext("sys_string", "IDS_COM_SK_CANCEL"), + ELM_POPUP_RESPONSE_CANCEL, NULL);*/ + + p->ly = elm_layout_add(ugd->popup_color); + elm_layout_file_set(p->ly, EV_THEME_PATH, "color_palette"); + evas_object_size_hint_align_set(p->ly, EVAS_HINT_FILL, 0.0); + evas_object_show(p->ly); + + p->rect = evas_object_rectangle_add(evas_object_evas_get(ugd->popup_color)); + evas_object_size_hint_fill_set(p->rect, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_color_set(p->rect, r, g, b, a); + evas_object_show(p->rect); + elm_object_part_content_set(p->ly, "color_rect", p->rect); + + p->colorselector = elm_colorselector_add(ugd->popup_color); + elm_colorselector_mode_set(p->colorselector, ELM_COLORSELECTOR_PALETTE); + evas_object_size_hint_fill_set(p->colorselector, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(p->colorselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_smart_callback_add(p->colorselector, "color,item,selected", _colorselector_cb, vd); + + /* set new colors */ + elm_colorselector_palette_color_add(p->colorselector, 0x00, 0x80, 0x80, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0xff, 0xd7, 0x00, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0xad, 0xff, 0x2f, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0x00, 0x64, 0x00, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0x19, 0x19, 0x70, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0x80, 0x00, 0x80, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0x00, 0xbf, 0xff, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0x77, 0x88, 0x99, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0xdc, 0x14, 0x3c, 0xff); + elm_colorselector_palette_color_add(p->colorselector, 0x8c, 0x45, 0x13, 0xff); + + elm_object_part_content_set(p->ly, "palette", p->colorselector); + + p->btn_color_save = elm_button_add(ugd->popup_color); + elm_object_style_set(p->btn_color_save, "popup_button/default"); + elm_object_text_set(p->btn_color_save, dgettext("sys_string", "IDS_COM_SK_SAVE")); + elm_object_part_content_set(p->ly, "btn_save", p->btn_color_save); + evas_object_smart_callback_add(p->btn_color_save, "clicked", _btn_clicked_cb, data); + + p->btn_color_cancel = elm_button_add(ugd->popup_color); + elm_object_style_set(p->btn_color_cancel, "popup_button/default"); + elm_object_text_set(p->btn_color_cancel, dgettext("sys_string", "IDS_COM_SK_CANCEL")); + elm_object_part_content_set(p->ly, "btn_cancel", p->btn_color_cancel); + evas_object_smart_callback_add(p->btn_color_cancel, "clicked", _btn_clicked_cb, NULL); + + elm_object_content_set(ugd->popup_color, p->ly); + evas_object_show(ugd->popup_color); +} + +static void _colorselector_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + int r,g,b,a; + Elm_Object_Item *cs_it = (Elm_Object_Item *)event_info; + elm_colorselector_palette_item_color_get(cs_it, &r, &g, &b, &a); + + struct viewdata *vd = data; + struct priv_data *p = vd->priv; + evas_object_color_set(p->rect, r, g, b, a); + p->color_item = cs_it; + p->color_r = r; + p->color_g = g; + p->color_b = b; + p->color_a = a; +} + +static void _btn_clicked_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + ListItemData *item_data = (ListItemData *) data; + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + + if (!item_data) { + if (ugd->popup_color) { + evas_object_del(ugd->popup_color); + ugd->popup_color = NULL; + } + return; + } + + email_account_t *account_data = item_data->account_data; + + if (ugd->popup_color) { + evas_object_del(ugd->popup_color); + ugd->popup_color = NULL; + } + + if (p->color_item == NULL) { + debug_log("color_item is NULL"); + return; + } + + int r, g, b, a; + /*elm_colorselector_palette_item_color_get(p->color_item, &r, &g, &b, &a);*/ + r = p->color_r; + g = p->color_g; + b = p->color_b; + a = p->color_a; + + evas_object_color_set(item_data->color_rect, r, g, b, a); + evas_object_color_set(item_data->color_bar, r, g, b, a); + + r = (r << 24) & 0xff000000; + g = (g << 16) & 0x00ff0000; + b = (b << 8) & 0x0000ff00; + int rgb = ((r | g) | b) | a; + + debug_log("rgb: %d", rgb); + + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + user_data->index_color = rgb; + + if (email_engine_update_account(account_data->account_id, account_data) == TRUE) + debug_log("Account updated successfully"); +} + +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; + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->popup_one) { + evas_object_del(ugd->popup_one); + ugd->popup_one = NULL; + } +} + +static char *_gl_text_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 (!strcmp(part, "elm.text")) { + if (index == 1) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_GENERAL_SETTINGS")); + return g_strdup(buf); + } + + if (index == 3) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_BLOCK_EMAILS")); + return g_strdup(buf); + } + + if (index == 4) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_ACCOUNTS")); + return g_strdup(buf); + } + } + + if (!strcmp(part, "elm.text.1")) { + if (index == 2) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_DEFAULT_SENDING_ACCOUNT")); + return g_strdup(buf); + } + } + + if (!strcmp(part, "elm.text.2")) { + if (index == 2) { + return g_strdup(p->def_acct_addr); + } + } + + return NULL; +} + +static char *_gl_ex_text_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; + + email_account_t *account_data = &(ugd->account_list[index]); + + if (!strcmp(part, "elm.text")) { + return g_strdup(account_data->user_email_address); + } + + return NULL; +} + +static char *_gl_account_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + ListItemData *item_data = (ListItemData *) data; + email_account_t *account_data = item_data->account_data; + char buf[PATH_MAX] = { 0, }; + + if (!strcmp(part, "elm.text.1")) { + snprintf(buf, sizeof(buf), "%s", account_data->account_name); + return g_strdup(buf); + } + + if (!strcmp(part, "elm.text.2")) { + snprintf(buf, sizeof(buf), "%s", account_data->user_email_address); + return g_strdup(buf); + } + + return NULL; +} + +static Evas_Object *_gl_ex_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; + email_account_t *account_data = &(ugd->account_list[index]); + + if (!strcmp(part, "elm.icon")) { + Evas_Object *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->radio_grp); + elm_radio_state_value_set(radio, index); + + if (p->def_acct_id == account_data->account_id) { + elm_radio_value_set(p->radio_grp, index); + } + + return radio; + } + + return NULL; +} + +static Evas_Object *_gl_account_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + Evas_Object *icon = NULL; + Evas_Object *color_bar = NULL; + Evas_Object *color_rect = NULL; + + ListItemData *item_data = (ListItemData *) data; + email_account_t *account_data = item_data->account_data; + + if (!strcmp(part, "elm.icon.1")) { + icon = elm_icon_add(obj); + + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + debug_log("is_preset_account:%d", user_data->is_preset_account); + + switch (user_data->is_preset_account) { + case GMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_GMAIL, NULL); + break; + case HOTMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_HOTMAIL, NULL); + break; + case YAHOOMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_YAHOO, NULL); + break; + case AOL: + elm_icon_file_set(icon, ACCOUNT_ICON_AOL, NULL); + break; + case OTHERS: + default: + elm_icon_file_set(icon, ACCOUNT_ICON_OTHERS, NULL); + break; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + + return icon; + } + + if (!strcmp(part, "elm.swallow.colorbar")) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + unsigned int val = user_data->index_color; + int r = (val & 0xff000000) >> 24; + int g = (val & 0x00ff0000) >> 16; + int b = (val & 0x0000ff00) >> 8; + int a = val & 0x000000ff; + + debug_log("R[%d] G[%d] B[%d] A[%d]", r, g, b, a); + + color_bar = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_size_hint_fill_set(color_bar, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_color_set(color_bar, r, g, b, a); + item_data->color_bar = color_bar; + + return color_bar; + } + + if (!strcmp(part, "elm.icon.2")) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + unsigned int val = user_data->index_color; + int r = (val & 0xff000000) >> 24; + int g = (val & 0x00ff0000) >> 16; + int b = (val & 0x0000ff00) >> 8; + int a = val & 0x000000ff; + + debug_log("R[%d] G[%d] B[%d] A[%d]", r, g, b, a); + + color_rect = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_size_hint_fill_set(color_rect, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_color_set(color_rect, r, g, b, a); + evas_object_propagate_events_set(color_rect, EINA_FALSE); + evas_object_event_callback_add(color_rect, EVAS_CALLBACK_MOUSE_DOWN, _color_rect_cb, (void *)item_data); + item_data->color_rect = color_rect; + return color_rect; + } + + return NULL; +} + +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + return EINA_FALSE; +} + +static void _gl_del_cb(void *data, Evas_Object *obj) +{ + debug_log(""); + return; +} + +static void _gl_account_del_cb(void *data, Evas_Object *obj) +{ + debug_log(""); + ListItemData *item_data = (ListItemData *) data; + if (item_data) + free(item_data); + return; +} + +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(item, EINA_FALSE); +} + +static void _gl_default_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + 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_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + int index = (int)data; + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + email_account_t *account_data = &(ugd->account_list[index]); + + elm_genlist_item_selected_set(item, EINA_FALSE); + + if (elm_radio_value_get(p->radio_grp) != index) { + + elm_radio_value_set(p->radio_grp, index); + debug_log("Changed default account ID [%d]", account_data->account_id); + + if (email_engine_set_default_account(account_data->account_id)) { + debug_log("new default account is %d", account_data->account_id); + _get_default_account(vd); + } + + elm_genlist_item_update(p->default_account_item); + } + + return; +} + +static void _gl_account_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + email_account_t *account_data = (email_account_t *) data; + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(item, EINA_FALSE); + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_SETTING) { + debug_log("**double clicked**"); + return; + } + + if (ugd->popup_color) { + evas_object_del(ugd->popup_color); + ugd->popup_color = NULL; + } + + if (ugd->account_count == 0) { + ugd->popup_one = setting_get_notify(vd, dgettext("sys_string", "IDS_COM_POP_WARNING"), + _("IDS_EMAIL_POP_THERE_IS_NO_ACCOUNT_CREATE_A_NEW_ACCOUNT_FIRST"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_ok_cb, NULL, NULL); + } else { + ugd->account_id = account_data->account_id; + ugd->myaccount_id = account_data->account_svc_id; + debug_log("selected account id %d", ugd->account_id); + + setting_change_view(VIEW_ACCOUNT_OPTIONS, ugd); + } + + return; +} + +static void _gl_exp_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + Elm_Object_Item *it = event_info; + EmailSettingUGD *ugd; + email_account_t *account_data = NULL; + + struct viewdata *vd = (struct viewdata *)data; + struct priv_data *p = vd->priv; + + int i = 0; + int acct_cnt = 0; + ugd = vd->ugd; + + if (ugd->account_count > 0) { + acct_cnt = ugd->account_count; + } + + for (i = 0; i < acct_cnt; i++) { + account_data = &(ugd->account_list[i]); + + if (account_data) { + elm_genlist_item_append(p->genlist, &(p->itc2), (void *)i, + it, ELM_GENLIST_ITEM_NONE, _gl_ex_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 */ diff --git a/setting/src/email-view-sp-select.c b/setting/src/email-view-sp-select.c new file mode 100755 index 0000000..f318b4f --- /dev/null +++ b/setting/src/email-view-sp-select.c @@ -0,0 +1,325 @@ +/* + * 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 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 _add_account_cb(void *data, Evas_Object *obj, void *event_info); +static void _back_cb(void *data, Evas_Object *obj, void *event_info); +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_content_get_cb(void *data, Evas_Object *obj, const char *part); +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part); +static void _gl_del_cb(void *data, Evas_Object *obj); + +struct priv_data { + struct viewdata *vd; + + Evas_Object *list; + Evas_Object *layout; + Evas_Object *b_btn2; + Evas_Object *b_btn; + + Elm_Genlist_Item_Class itc; + Elm_Genlist_Item_Class itc2; + Elm_Genlist_Item_Class itc3; + Ecore_Timer *vc_timer; + int as_flag; +}; + +void setting_init_sp_select_view(struct viewdata *vd) +{ + debug_log(""); + + vd->type = VIEW_SP_SELECT; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_sp_select"; +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p; + p = vd->priv; + + if (p == NULL) { + debug_log("allocate priv"); + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + } + + p->layout = setting_add_inner_layout(vd); + evas_object_show(p->layout); + + _push_naviframe(vd); + _create_list(vd); + + return TRUE; +} + +static int _update(struct viewdata *vd) +{ + debug_log(""); + + return TRUE; +} + +static int _destroy(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + + if (p == NULL) { + debug_log("priv is NULL"); + return -1; + } + + evas_object_del(p->list); + evas_object_del(p->b_btn); + evas_object_del(p->b_btn2); + + return TRUE; +} + +static int _show(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + + evas_object_show(p->list); + evas_object_show(vd->ly); + return TRUE; +} + +static int _hide(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + + evas_object_hide(p->list); + evas_object_hide(vd->ly); + return TRUE; +} + +static void _push_naviframe(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p = vd->priv; + + debug_log("args are %s", vd->ugd->start_view_type); + + p->b_btn = elm_button_add(vd->ugd->navi_bar); + + evas_object_smart_callback_add(p->b_btn, "clicked", _back_cb, vd); + + elm_naviframe_item_push(vd->ugd->navi_bar, _("IDS_EMAIL_HEADER_ADD_ACCOUNT"), + p->b_btn, NULL, p->layout, NULL); + elm_object_style_set(p->b_btn, "naviframe/back_btn/default"); + evas_object_show(vd->ugd->navi_bar); +} + +static void _create_list(struct viewdata *vd) +{ + debug_log(""); + struct priv_data *p; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + int index; + Elm_Object_Item *git = NULL; + + p->list = elm_genlist_add(ugd->navi_bar); + elm_object_style_set(p->list, "dialogue"); + elm_object_part_content_set(p->layout, "elm.swallow.content", p->list); + evas_object_show(p->list); + + p->itc.item_style = "dialogue/1text.1icon.2"; + p->itc.func.text_get = _gl_text_get_cb; + p->itc.func.content_get = _gl_content_get_cb; + p->itc.func.state_get = _gl_state_get_cb; + p->itc.func.del = _gl_del_cb; + + p->itc2.item_style = "dialogue/separator"; + p->itc2.func.text_get = NULL; + p->itc2.func.content_get = NULL; + p->itc2.func.state_get = NULL; + p->itc2.func.del = NULL; + + p->itc3.item_style = "dialogue/separator/end"; + p->itc3.func.text_get = NULL; + p->itc3.func.content_get = NULL; + p->itc3.func.state_get = NULL; + p->itc3.func.del = NULL; + + git = elm_genlist_item_append(p->list, &(p->itc2), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); + + for (index = HOTMAIL; index <= OTHERS; index++) { + if (index != YAHOOMAIL) { + elm_genlist_item_append(p->list, &p->itc, (void *)index, git, + ELM_GENLIST_ITEM_NONE, _add_account_cb, vd); + } + } + + git = elm_genlist_item_append(p->list, &(p->itc3), NULL, NULL, + ELM_GENLIST_ITEM_GROUP, NULL, NULL); + elm_genlist_item_select_mode_set(git, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY); +} + +static void _add_account_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *it = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(it, EINA_FALSE); + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_SP_SELECT) { + debug_log("**double clicked**"); + return; + } + + ugd->account_info = (int)elm_object_item_data_get(it); + debug_log("ugd->account_info %d", ugd->account_info); + + setting_change_view(VIEW_ACCOUNT_SETUP, vd->ugd); +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (vd->ugd->atomic_pop) { + debug_log("During atomic poping"); + return; + } + + setting_back_to_prev_view(vd); + + return; +} + +static char *_gl_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + int index = (int)data; + char *str = NULL; + + switch (index) { + case GMAIL: + str = strdup(dgettext("sys_string", "IDS_COM_BODY_GOOGLE")); + break; + case HOTMAIL: + str = strdup(_("IDS_EMAIL_BODY_WINDOWS_LIVE_HOTMAIL")); + break; + case YAHOOMAIL: + str = strdup(_("IDS_EMAIL_BODY_YAHOO_E_MAIL")); + break; + case AOL: + str = strdup(_("IDS_EMAIL_BODY_AOL")); + break; + case OTHERS: + str = strdup(dgettext("sys_string", "IDS_COM_BODY_OTHERS")); + break; + } + + return str; +} + +static Evas_Object *_gl_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + Evas_Object *icon = elm_icon_add(obj); + int index = (int)data; + + switch (index) { + case GMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_GMAIL, NULL); + break; + case HOTMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_HOTMAIL, NULL); + break; + case YAHOOMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_YAHOO, NULL); + break; + case AOL: + elm_icon_file_set(icon, ACCOUNT_ICON_AOL, NULL); + break; + case OTHERS: + default: + elm_icon_file_set(icon, ACCOUNT_ICON_OTHERS, NULL); + break; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + return icon; +} + +static Eina_Bool _gl_state_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + return EINA_FALSE; +} + +static void _gl_del_cb(void *data, Evas_Object *obj) +{ + debug_log(""); + return; +} + +/* EOF */ diff --git a/setting/src/email-view-sync-schedule.c b/setting/src/email-view-sync-schedule.c new file mode 100755 index 0000000..a02df18 --- /dev/null +++ b/setting/src/email-view-sync-schedule.c @@ -0,0 +1,1139 @@ +/* + * 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" + +#include +#include +#include +#include +#include + +static email_account_t *account_data = NULL; +static struct viewdata *g_vd = NULL; + +static UDateTimePatternGenerator *icu_pg = NULL; +static UDateFormat *icu_formatter = NULL; +static enum appcore_time_format icu_timeformat; + +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 _update_account_info(struct viewdata *vd); +static void _get_icu_formatter(void); +static void _close_icu_formatter(void); +static void _get_date_text_with_formatter(time_t time, char *formatted_str); + +static void _account_edit_cb(void *data, Evas_Object *obj, void *event_info); +static void _onoff_cb(void *data, Evas_Object *obj, void *event_info); +static void _refresh_cb(void *data, Evas_Object *obj, void *event_info); +static void _delete_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_delete_cb(void *data); + +static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info); +static void _popup_delete_ok_cb(void *data, Evas_Object *obj, void *event_info); + +static char *_gl_account_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_sync_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_sync_text_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_account_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 Evas_Object *_gl_ex_sync_content_get_cb(void *data, Evas_Object *obj, const char *part); +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_sync_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 int sync_schedule[7] = { 0, 30, 60, 180, 360, 720, 1440 }; + +#define SYNC_STATUS_FINISHED 0 /* BIN 00000000 */ +#define SYNC_STATUS_SYNCING 1 /* BIN 00000001 */ +#define SYNC_STATUS_HAVE_NEW_MAILS 2 /* BIN 00000010 */ + +struct priv_data { + struct viewdata *vd; + + Evas_Object *cbar; + Evas_Object *onoff; + + Evas_Object *l_button; + Evas_Object *r_button; + Evas_Object *layout; + Evas_Object *conform; + + Evas_Object *sync_radio_grp; + Evas_Object *account_icon; + + Evas_Object *genlist; + Elm_Genlist_Item_Class itc_account; + Elm_Genlist_Item_Class itc_onoff; + Elm_Genlist_Item_Class itc_sync; + Elm_Genlist_Item_Class itc_ex_sync; + Elm_Genlist_Item_Class itc_sep; + Elm_Genlist_Item_Class itc_sep2; + + Elm_Object_Item * c_item[4]; + Elm_Object_Item *gl_sync_item; + Elm_Object_Item *gl_onoff_item; + Elm_Object_Item *gl_account_item; + + int account_deleted; + int syncing; +}; + +void setting_init_sync_schedule_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_SYNC_SCHEDULE; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_sync_schedule"; +} + +void setting_schedule_sync_started(struct viewdata *vd, int account_id) +{ + debug_log(""); + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (ugd->account_id != account_id) { + debug_log("not interested"); + return; + } + + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + p->syncing = 1; + elm_object_disabled_set(p->r_button, TRUE); + elm_genlist_item_update(p->gl_account_item); +} + +void setting_schedule_sync_finished(struct viewdata *vd, int account_id) +{ + debug_log(""); + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (ugd->account_id != account_id) { + debug_log("not interested"); + return; + } + + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + p->syncing = 0; + elm_object_disabled_set(p->r_button, FALSE); + elm_genlist_item_update(p->gl_account_item); +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + 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); + } + + _get_icu_formatter(); + + g_vd = vd; + + _create_list(vd); + + return TRUE; +} + +static int _update(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (vd->refresh) { + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + if (account_data->sync_status & SYNC_STATUS_SYNCING) { + p->syncing = 1; + elm_object_disabled_set(p->r_button, TRUE); + } else { + p->syncing = 0; + elm_object_disabled_set(p->r_button, FALSE); + } + elm_genlist_item_update(p->gl_account_item); + } + + return TRUE; +} + +static int _destroy(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + + if (p == NULL) { + debug_log("priv is NULL"); + return FALSE; + } + + evas_object_del(p->l_button); + evas_object_del(p->onoff); + evas_object_del(p->genlist); + evas_object_del(p->sync_radio_grp); + + if (account_data) { + email_engine_free_account_list(&account_data, 1); + account_data = NULL; + } + + _close_icu_formatter(); + + return TRUE; +} + +static int _show(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + EmailSettingUGD *ugd = vd->ugd; + + 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 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_DELETE"), _delete_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->r_button = elm_button_add(vd->ugd->navi_bar); + elm_object_style_set(p->r_button, "naviframe/title/default"); + /*elm_object_text_set(p->r_button, _("IDS_EMAIL_OPT_REFRESH"));*/ + Evas_Object *ic = elm_icon_add(p->r_button); + elm_icon_file_set(ic, TITLE_ICON_REFRESH, NULL); + elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE); + evas_object_image_smooth_scale_set(ic, 0); + elm_object_content_set(p->r_button, ic); + evas_object_smart_callback_add(p->r_button, "clicked", _refresh_cb, vd); + evas_object_show(p->r_button); + + if (account_data->sync_status & SYNC_STATUS_SYNCING) { + p->syncing = 1; + elm_object_disabled_set(p->r_button, 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"); + + Elm_Object_Item *navi_it = NULL; + navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, account_data->account_name, p->l_button, NULL, p->layout, NULL); + elm_object_item_part_content_set(navi_it, "title_right_btn", p->r_button); + 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(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + Elm_Object_Item *item = NULL; + Elm_Object_Item *git = NULL; + int i = 0; + + p->sync_radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->sync_radio_grp, 0); + evas_object_hide(p->sync_radio_grp); + + p->genlist = elm_genlist_add(ugd->navi_bar); + elm_object_style_set(p->genlist, "dialogue"); + + p->itc_account.item_style = "dialogue/2text.3icon"; + p->itc_account.func.text_get = _gl_account_text_get_cb; + p->itc_account.func.content_get = _gl_account_content_get_cb; + p->itc_account.func.state_get = NULL; + p->itc_account.func.del = NULL; + + p->itc_onoff.item_style = "dialogue/2text.1icon.6"; + 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_sync.item_style = "dialogue/2text.3/expandable"; + p->itc_sync.func.text_get = _gl_sync_text_get_cb; + p->itc_sync.func.content_get = NULL; + p->itc_sync.func.state_get = NULL; + p->itc_sync.func.del = NULL; + + p->itc_ex_sync.item_style = "dialogue/1text.1icon/expandable2"; + p->itc_ex_sync.func.text_get = _gl_ex_sync_text_get_cb; + p->itc_ex_sync.func.content_get = _gl_ex_sync_content_get_cb; + p->itc_ex_sync.func.state_get = NULL; + p->itc_ex_sync.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; + + /*seperator*/ + 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*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_account), NULL, git, + ELM_GENLIST_ITEM_NONE, _account_edit_cb, (void *)vd); + p->gl_account_item = item; + + /*sync schedule*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_sync), NULL, + git, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + p->gl_sync_item = item; + + /*seperator*/ + 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); + + /*sync on/off*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + p->gl_onoff_item = item; + + /*seperator*/ + 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 _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 _get_icu_formatter(void) +{ + debug_log(""); + UErrorCode status = U_ZERO_ERROR; + char *icu_locale = NULL; + + uloc_setDefault(getenv("LC_TIME"), &status); + if (U_FAILURE(status)) { + debug_critical("uloc_setDefault() failed: %s\n", u_errorName(status)); + return; + } + + icu_locale = (char *)uloc_getDefault(); + debug_log("uloc_getDefault: %s", icu_locale); + appcore_get_timeformat(&icu_timeformat); + + status = U_ZERO_ERROR; + icu_pg = udatpg_open(icu_locale, &status); + if (!icu_pg) { + debug_log("udatpg_open() failed: %s", u_errorName(status)); + return; + } + + char *skeleton = NULL; + if (icu_timeformat == APPCORE_TIME_FORMAT_12) { + skeleton = "EEEMMMddhmma"; + } else { + skeleton = "EEEMMMddHmm"; + } + + UChar bestPattern[64] = { 0, }; + UChar customSkeleton[64] = { 0, }; + int32_t bestPatternCapacity; + int32_t bestPatternLength; + int skeletonLength = strlen(skeleton); + + u_uastrncpy(customSkeleton, skeleton, skeletonLength); + + status = U_ZERO_ERROR; + bestPatternCapacity = (int32_t) (sizeof(bestPattern) / sizeof(bestPattern[0])); + bestPatternLength = udatpg_getBestPattern(icu_pg, customSkeleton, u_strlen(customSkeleton), bestPattern, bestPatternCapacity, &status); + + status = U_ZERO_ERROR; + icu_formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, icu_locale, NULL, -1, bestPattern, -1, &status); +} + +static void _close_icu_formatter(void) +{ + debug_log(""); + + if (icu_pg) { + udatpg_close(icu_pg); + icu_pg = NULL; + } + + if (icu_formatter) { + udat_close(icu_formatter); + icu_formatter = NULL; + } +} + +static void _get_date_text_with_formatter(time_t time, char *formatted_str) +{ + debug_log(""); + UErrorCode status = U_ZERO_ERROR; + UDate date = 0; + UChar formatted[64] = { 0, }; + int32_t formattedCapacity; + int32_t formattedLength; + + formattedCapacity = (int32_t) (sizeof(formatted) / sizeof(formatted[0])); + time_t msg_time = time; + date = (UDate)msg_time * 1000; + + formattedLength = udat_format(icu_formatter, date, formatted, formattedCapacity, NULL, &status); + u_austrncpy(formatted_str, formatted, 127); + debug_log("time_t: %d", time); + debug_log("formatted time: %s", formatted_str); +} + +static void _account_edit_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(item, EINA_FALSE); + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_SYNC_SCHEDULE) { + debug_log("**double clicked**"); + return; + } + + debug_log("Selected account id:%d", account_data->account_id); + vd->ugd->account_id = account_data->account_id; + vd->ugd->myaccount_id = account_data->account_svc_id; + + setting_change_view(VIEW_ACCOUNT_EDIT, ugd); +} + +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 (state) { + account_data->check_interval = abs(account_data->check_interval); + account_data->sync_disabled = 0; + + if (p->gl_sync_item) { + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_FALSE); + } + } else { + account_data->check_interval = -(abs(account_data->check_interval)); + account_data->sync_disabled = 1; + + if (p->gl_sync_item) { + if (elm_genlist_item_expanded_get(p->gl_sync_item)) { + elm_genlist_item_expanded_set(p->gl_sync_item, 0); + } + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_TRUE); + } + } + + _update_account_info(vd); +} + +static void _refresh_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + unsigned handle = 0; + int account_id = account_data->account_id; + + /* Inbox sync */ + int ret = 0; + gboolean res = FALSE; + email_mailbox_t *mailbox = NULL; + ret = email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox); + if (ret != EMAIL_ERROR_NONE || mailbox == NULL || mailbox->mailbox_name == NULL) { + debug_log("email_get_mailbox_by_mailbox_type failed"); + return; + } + + res = email_engine_sync_folder(account_id, mailbox->mailbox_id, &handle); + debug_log("handle: %d", handle); + email_free_mailbox(&mailbox, 1); + + p->syncing = 1; + elm_object_disabled_set(p->r_button, TRUE); + elm_genlist_item_update(p->gl_sync_item); + elm_genlist_item_update(p->gl_onoff_item); +} + +static void _delete_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + 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; + } + + vd->ugd->account_id = account_data->account_id; + + elm_object_disabled_set(p->l_button, EINA_TRUE); + elm_object_item_disabled_set(p->c_item[0], EINA_TRUE); + + ugd->popup_one = setting_get_notify(vd, NULL, dgettext("sys_string", "IDS_COM_POP_DELETE_Q"), 2, + dgettext("sys_string", "IDS_COM_SK_YES"), + _popup_delete_ok_cb, + dgettext("sys_string", "IDS_COM_SK_NO"), + _popup_cancel_cb); +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = data; + /*struct priv_data *p = vd->priv;*/ + + setting_back_to_prev_view(vd); +} + +static Eina_Bool _after_delete_cb(void *data) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->del_timer) { + ecore_timer_del(ugd->del_timer); + ugd->del_timer = NULL; + } + + status_message_post(dgettext("sys_string", "IDS_COM_POP_DELETED")); + + if (vd->ugd->start_view_type != NULL && g_strcmp0(vd->ugd->start_view_type, "account-edit") == 0) { + ug_destroy_me(vd->ugd->ug); + } else { + if (p->account_deleted) { + setting_update_acct_list(vd); + setting_back_to_prev_nth_view(vd, 2, vd->ugd->navi_main_it); + } else { + setting_back_to_prev_view(vd); + } + + setting_get_small_notify(vd, dgettext("sys_string", "IDS_COM_POP_DELETED")); + } + + return TRUE; +} + +static void _popup_cancel_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_delete_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; + } + + int account_id = vd->ugd->account_id; + int ret = email_engine_delete_account(account_id); + + if (ret) { + p->account_deleted = TRUE; + ugd->del_timer = ecore_timer_add(0.5, _after_delete_cb, vd); + debug_log("delete success"); + } else { + ugd->popup_one = setting_get_notify(vd, dgettext("sys_string", "IDS_COM_POP_WARNING"), + dgettext("sys_string", "IDS_COM_POP_UNABLE_TO_DELETE"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_cancel_cb, NULL, NULL); + debug_log("delete failed"); + } +} + +static char *_gl_account_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + if (!g_strcmp0(part, "elm.text.1")) { + return g_strdup(account_data->account_name); + } + + if (!g_strcmp0(part, "elm.text.2")) { + return g_strdup(account_data->user_email_address); + } + + return NULL; +} + +static char *_gl_onoff_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_EMAIL_SYNC")); + return g_strdup(buf); + } else if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + email_mailbox_t *mailbox = NULL; + email_get_mailbox_by_mailbox_type(account_data->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox); + if (mailbox) { + time_t req_time = time(NULL);//mailbox->last_sync_time; + _get_date_text_with_formatter(req_time, buf); + email_free_mailbox(&mailbox, 1); + } + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_sync_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SYNC_SCHEDULE")); + return g_strdup(buf); + } + + if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + + /*int period = abs(account_data->check_interval);*/ + int period = account_data->check_interval; + + if (period <= sync_schedule[0]) { + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_MANUAL")); + } else if (period == sync_schedule[1]) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_EVERY_30_MINUTES")); + } else if (period == sync_schedule[2]) { + snprintf(buf, sizeof(buf), "%s", N_("Every 1 hour")); + } else if (period == sync_schedule[3]) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 3); + } else if (period == sync_schedule[4]) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 6); + } else if (period == sync_schedule[5]) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 12); + } else if (period == sync_schedule[6]) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ONCE_A_DAY")); + } + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_ex_sync_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", dgettext("sys_string", "IDS_COM_BODY_MANUAL")); + } else if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_EVERY_30_MINUTES")); + } else if (index == 2) { + snprintf(buf, sizeof(buf), "%s", N_("Every 1 hour")); + } else if (index == 3) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 3); + } else if (index == 4) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 6); + } else if (index == 5) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 12); + } else if (index == 6) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ONCE_A_DAY")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static Evas_Object *_gl_account_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + Evas_Object *color_bar = NULL; + + if (!g_strcmp0(part, "elm.icon.1")) { + Evas_Object *icon = elm_icon_add(ugd->navi_bar); + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + + debug_log("is_preset_account:%d", user_data->is_preset_account); + + switch (user_data->is_preset_account) { + case GMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_GMAIL, NULL); + break; + case HOTMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_HOTMAIL, NULL); + break; + case YAHOOMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_YAHOO, NULL); + break; + case AOL: + elm_icon_file_set(icon, ACCOUNT_ICON_AOL, NULL); + break; + case OTHERS: + default: + elm_icon_file_set(icon, ACCOUNT_ICON_OTHERS, NULL); + break; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + p->account_icon = icon; + return icon; + } + + if (!g_strcmp0(part, "elm.icon.2")) { + if (p->syncing) { + Evas_Object *pb = elm_progressbar_add(ugd->navi_bar); + elm_object_style_set(pb, "list_process_small"); + elm_progressbar_horizontal_set(pb, EINA_TRUE); + elm_progressbar_pulse(pb, EINA_TRUE); + return pb; + } + } + + if (!g_strcmp0(part, "elm.swallow.colorbar")) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + unsigned int val = user_data->index_color; + int r = (val & 0xff000000) >> 24; + int g = (val & 0x00ff0000) >> 16; + int b = (val & 0x0000ff00) >> 8; + int a = val & 0x000000ff; + + debug_log("R[%d] G[%d] B[%d] A[%d]", r, g, b, a); + + color_bar = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_size_hint_fill_set(color_bar, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_color_set(color_bar, r, g, b, a); + + return color_bar; + } + + return NULL; +} + +static Evas_Object *_gl_onoff_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + 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 (account_data->sync_disabled) + elm_check_state_set(check, EINA_FALSE); + else + elm_check_state_set(check, EINA_TRUE); + + p->onoff = check; + + return check; + } + + return NULL; +} + +static Evas_Object *_gl_ex_sync_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + 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 *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->sync_radio_grp); + elm_radio_state_value_set(radio, index); + + if (sync_schedule[index] == abs(account_data->check_interval)) { + elm_radio_value_set(p->sync_radio_grp, index); + } + return radio; + } + + return NULL; +} + +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return; + } + + 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); + + Eina_Bool state = elm_check_state_get(p->onoff); + + if (state) { + account_data->check_interval = -(abs(account_data->check_interval)); + account_data->sync_disabled = 1; + elm_check_state_set(p->onoff, EINA_FALSE); + + if (p->gl_sync_item) { + if (elm_genlist_item_expanded_get(p->gl_sync_item)) { + elm_genlist_item_expanded_set(p->gl_sync_item, 0); + } + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_TRUE); + } + } else { + account_data->check_interval = abs(account_data->check_interval); + account_data->sync_disabled = 0; + elm_check_state_set(p->onoff, EINA_TRUE); + + if (p->gl_sync_item) { + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_FALSE); + } + } + + _update_account_info(vd); +} + +static void _gl_ex_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + 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_sync_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return; + } + + int index = (int)data; + struct viewdata *vd = g_vd; + struct priv_data *p = vd->priv; + 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->sync_radio_grp); + + if (sel_radio == index) + return; + + if (index >= 0 && index < 7) + account_data->check_interval = sync_schedule[index]; + + elm_radio_value_set(p->sync_radio_grp, index); + + _update_account_info(vd); + + elm_genlist_item_update(p->gl_sync_item); +} + +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; + + for (i = 0; i < 7; i++) { + elm_genlist_item_append(p->genlist, &(p->itc_ex_sync), (void *)i, + it, ELM_GENLIST_ITEM_NONE, _gl_ex_sync_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 */ diff --git a/setting/src/email-view-sync-setup.c b/setting/src/email-view-sync-setup.c new file mode 100755 index 0000000..01f057d --- /dev/null +++ b/setting/src/email-view-sync-setup.c @@ -0,0 +1,1174 @@ +/* + * 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" + +#include +#include +#include +#include +#include + +static email_account_t *account_data = NULL; +static struct viewdata *g_vd = NULL; + +static UDateTimePatternGenerator *icu_pg = NULL; +static UDateFormat *icu_formatter = NULL; +static enum appcore_time_format icu_timeformat; + +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 _update_account_info(struct viewdata *vd); +static void _get_icu_formatter(void); +static void _close_icu_formatter(void); +static void _get_date_text_with_formatter(time_t time, char *formatted_str); + +static void _account_edit_cb(void *data, Evas_Object *obj, void *event_info); +static void _onoff_cb(void *data, Evas_Object *obj, void *event_info); +static void _refresh_cb(void *data, Evas_Object *obj, void *event_info); +static void _delete_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_delete_cb(void *data); + +static void _popup_cancel_cb(void *data, Evas_Object *obj, void *event_info); +static void _popup_delete_ok_cb(void *data, Evas_Object *obj, void *event_info); + +static char *_gl_account_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_sync_text_get_cb(void *data, Evas_Object *obj, const char *part); +static char *_gl_ex_sync_text_get_cb(void *data, Evas_Object *obj, const char *part); +static Evas_Object *_gl_account_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 Evas_Object *_gl_ex_sync_content_get_cb(void *data, Evas_Object *obj, const char *part); +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_sel_cb(void *data, Evas_Object *obj, void *event_info); +static void _gl_ex_sync_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 int sync_schedule[7] = { 0, 30, 60, 180, 360, 720, 1440 }; + +#define SYNC_STATUS_FINISHED 0 /* BIN 00000000 */ +#define SYNC_STATUS_SYNCING 1 /* BIN 00000001 */ +#define SYNC_STATUS_HAVE_NEW_MAILS 2 /* BIN 00000010 */ + +struct priv_data { + struct viewdata *vd; + + Evas_Object *cbar; + Evas_Object *onoff; + + Evas_Object *l_button; + Evas_Object *r_button; + Evas_Object *layout; + Evas_Object *conform; + + Evas_Object *sync_radio_grp; + Evas_Object *account_icon; + + Evas_Object *genlist; + Elm_Genlist_Item_Class itc_account; + Elm_Genlist_Item_Class itc_onoff; + Elm_Genlist_Item_Class itc_sync; + Elm_Genlist_Item_Class itc_ex_sync; + Elm_Genlist_Item_Class itc_sep; + Elm_Genlist_Item_Class itc_sep2; + + Elm_Object_Item * c_item[4]; + Elm_Object_Item *gl_sync_item; + Elm_Object_Item *gl_onoff_item; + Elm_Object_Item *gl_account_item; + + int account_deleted; + int syncing; +}; + +void setting_init_sync_setup_view(struct viewdata *vd) +{ + debug_log(""); + vd->type = VIEW_SYNC_SETUP; + vd->create = _create; + vd->update = _update; + vd->destroy = _destroy; + vd->show = _show; + vd->hide = _hide; + vd->grp_nm = "setting_sync_setup"; +} + +void setting_setup_sync_started(struct viewdata *vd, int account_id) +{ + debug_log(""); + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (ugd->account_id != account_id) { + debug_log("not interested"); + return; + } + + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + p->syncing = 1; + elm_object_disabled_set(p->r_button, TRUE); + elm_genlist_item_update(p->gl_account_item); +} + +void setting_setup_sync_finished(struct viewdata *vd, int account_id) +{ + debug_log(""); + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (ugd->account_id != account_id) { + debug_log("not interested"); + return; + } + + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + p->syncing = 0; + elm_object_disabled_set(p->r_button, FALSE); + elm_genlist_item_update(p->gl_account_item); +} + +static int _create(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (p == NULL) { + p = vd->priv = calloc(1, sizeof(struct priv_data)); + p->vd = vd; + + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + 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); + } + + _get_icu_formatter(); + + g_vd = vd; + + _create_list(vd); + + return TRUE; +} + +static int _update(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = NULL; + EmailSettingUGD *ugd = vd->ugd; + p = vd->priv; + + if (vd->refresh) { + if (!setting_get_acct_full_data(ugd->account_id, &account_data)) { + debug_log("failed to get account data"); + } + + if (account_data->sync_status & SYNC_STATUS_SYNCING) { + p->syncing = 1; + elm_object_disabled_set(p->r_button, TRUE); + } else { + p->syncing = 0; + elm_object_disabled_set(p->r_button, FALSE); + } + elm_genlist_item_update(p->gl_account_item); + } + + return TRUE; +} + +static int _destroy(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + struct priv_data *p = vd->priv; + + if (p == NULL) { + debug_log("priv is NULL"); + return FALSE; + } + + evas_object_del(p->l_button); + evas_object_del(p->onoff); + evas_object_del(p->genlist); + evas_object_del(p->sync_radio_grp); + + if (account_data) { + email_engine_free_account_list(&account_data, 1); + account_data = NULL; + } + + _close_icu_formatter(); + + return TRUE; +} + +static int _show(struct viewdata *vd) +{ + debug_log(""); + + if (!vd) { + debug_log("vd is NULL"); + return FALSE; + } + + EmailSettingUGD *ugd = vd->ugd; + + 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 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_DELETE"), _delete_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->r_button = elm_button_add(vd->ugd->navi_bar); + elm_object_style_set(p->r_button, "naviframe/title/default"); + /*elm_object_text_set(p->r_button, _("IDS_EMAIL_OPT_REFRESH"));*/ + Evas_Object *ic = elm_icon_add(p->r_button); + elm_icon_file_set(ic, TITLE_ICON_REFRESH, NULL); + elm_icon_resizable_set(ic, EINA_TRUE, EINA_TRUE); + evas_object_image_smooth_scale_set(ic, 0); + elm_object_content_set(p->r_button, ic); + evas_object_smart_callback_add(p->r_button, "clicked", _refresh_cb, vd); + evas_object_show(p->r_button); + + if (account_data->sync_status & SYNC_STATUS_SYNCING) { + p->syncing = 1; + elm_object_disabled_set(p->r_button, 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"); + + Elm_Object_Item *navi_it = NULL; + navi_it = elm_naviframe_item_push(vd->ugd->navi_bar, account_data->account_name, p->l_button, NULL, p->layout, NULL); + elm_object_item_part_content_set(navi_it, "title_right_btn", p->r_button); + 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(""); + + if (!vd) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + Elm_Object_Item *item = NULL; + Elm_Object_Item *git = NULL; + int i = 0; + + p->sync_radio_grp = elm_radio_add(ugd->navi_bar); + elm_radio_value_set(p->sync_radio_grp, 0); + evas_object_hide(p->sync_radio_grp); + + p->genlist = elm_genlist_add(ugd->navi_bar); + elm_object_style_set(p->genlist, "dialogue"); + + p->itc_account.item_style = "dialogue/2text.3icon"; + p->itc_account.func.text_get = _gl_account_text_get_cb; + p->itc_account.func.content_get = _gl_account_content_get_cb; + p->itc_account.func.state_get = NULL; + p->itc_account.func.del = NULL; + + p->itc_onoff.item_style = "dialogue/2text.1icon.6"; + 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_sync.item_style = "dialogue/2text.3/expandable"; + p->itc_sync.func.text_get = _gl_sync_text_get_cb; + p->itc_sync.func.content_get = NULL; + p->itc_sync.func.state_get = NULL; + p->itc_sync.func.del = NULL; + + p->itc_ex_sync.item_style = "dialogue/1text.1icon/expandable2"; + p->itc_ex_sync.func.text_get = _gl_ex_sync_text_get_cb; + p->itc_ex_sync.func.content_get = _gl_ex_sync_content_get_cb; + p->itc_ex_sync.func.state_get = NULL; + p->itc_ex_sync.func.del = NULL; + + p->itc_sep.item_style = "dialogue/separator/21/with_line"; + 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; + + /*seperator*/ + 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*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_account), NULL, git, + ELM_GENLIST_ITEM_NONE, _account_edit_cb, (void *)vd); + p->gl_account_item = item; + + /*sync schedule*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_sync), NULL, + git, ELM_GENLIST_ITEM_TREE, _gl_ex_sel_cb, (void *)vd); + p->gl_sync_item = item; + + /*seperator*/ + 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); + + /*sync on/off*/ + item = elm_genlist_item_append(p->genlist, &(p->itc_onoff), (void *)i, + git, ELM_GENLIST_ITEM_NONE, _gl_sel_cb, (void *)i); + p->gl_onoff_item = item; + + /*seperator*/ + 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 _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 _get_icu_formatter(void) +{ + debug_log(""); + UErrorCode status = U_ZERO_ERROR; + char *icu_locale = NULL; + + uloc_setDefault(getenv("LC_TIME"), &status); + if (U_FAILURE(status)) { + debug_critical("uloc_setDefault() failed: %s\n", u_errorName(status)); + return; + } + + icu_locale = (char *)uloc_getDefault(); + debug_log("uloc_getDefault: %s", icu_locale); + appcore_get_timeformat(&icu_timeformat); + + status = U_ZERO_ERROR; + icu_pg = udatpg_open(icu_locale, &status); + if (!icu_pg) { + debug_log("udatpg_open() failed: %s", u_errorName(status)); + return; + } + + char *skeleton = NULL; + if (icu_timeformat == APPCORE_TIME_FORMAT_12) { + skeleton = "EEEMMMddhmma"; + } else { + skeleton = "EEEMMMddHmm"; + } + + UChar bestPattern[64] = { 0, }; + UChar customSkeleton[64] = { 0, }; + int32_t bestPatternCapacity; + int32_t bestPatternLength; + int skeletonLength = strlen(skeleton); + + u_uastrncpy(customSkeleton, skeleton, skeletonLength); + + status = U_ZERO_ERROR; + bestPatternCapacity = (int32_t) (sizeof(bestPattern) / sizeof(bestPattern[0])); + bestPatternLength = udatpg_getBestPattern(icu_pg, customSkeleton, u_strlen(customSkeleton), bestPattern, bestPatternCapacity, &status); + + status = U_ZERO_ERROR; + icu_formatter = udat_open(UDAT_IGNORE, UDAT_IGNORE, icu_locale, NULL, -1, bestPattern, -1, &status); +} + +static void _close_icu_formatter(void) +{ + debug_log(""); + + if (icu_pg) { + udatpg_close(icu_pg); + icu_pg = NULL; + } + + if (icu_formatter) { + udat_close(icu_formatter); + icu_formatter = NULL; + } +} + +static void _get_date_text_with_formatter(time_t time, char *formatted_str) +{ + debug_log(""); + UErrorCode status = U_ZERO_ERROR; + UDate date = 0; + UChar formatted[64] = { 0, }; + int32_t formattedCapacity; + int32_t formattedLength; + + formattedCapacity = (int32_t) (sizeof(formatted) / sizeof(formatted[0])); + time_t msg_time = time; + date = (UDate)msg_time * 1000; + + formattedLength = udat_format(icu_formatter, date, formatted, formattedCapacity, NULL, &status); + u_austrncpy(formatted_str, formatted, 127); + debug_log("time_t: %d", time); + debug_log("formatted time: %s", formatted_str); +} + +static void _account_edit_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + EmailSettingUGD *ugd = vd->ugd; + + Elm_Object_Item *item = (Elm_Object_Item *)event_info; + elm_genlist_item_selected_set(item, EINA_FALSE); + + Viewtype top = ugd->view_st[ugd->view_top]; + if (top != VIEW_SYNC_SETUP) { + debug_log("**double clicked**"); + return; + } + + debug_log("Selected account id:%d", account_data->account_id); + vd->ugd->account_id = account_data->account_id; + vd->ugd->myaccount_id = account_data->account_svc_id; + + setting_change_view(VIEW_ACCOUNT_EDIT, ugd); +} + +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 (state) { + account_data->check_interval = abs(account_data->check_interval); + account_data->sync_disabled = 0; + + if (p->gl_sync_item) { + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_FALSE); + } + } else { + account_data->check_interval = -(abs(account_data->check_interval)); + account_data->sync_disabled = 1; + + if (p->gl_sync_item) { + if (elm_genlist_item_expanded_get(p->gl_sync_item)) { + elm_genlist_item_expanded_set(p->gl_sync_item, 0); + } + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_TRUE); + } + } + + _update_account_info(vd); +} + +static void _refresh_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + struct priv_data *p = vd->priv; + unsigned handle = 0; + int account_id = account_data->account_id; + + /* Inbox sync */ + int ret = 0; + gboolean res = FALSE; + email_mailbox_t *mailbox = NULL; + ret = email_get_mailbox_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox); + if (ret != EMAIL_ERROR_NONE || mailbox == NULL || mailbox->mailbox_name == NULL) { + debug_log("email_get_mailbox_by_mailbox_type failed"); + return; + } + + res = email_engine_sync_folder(account_id, mailbox->mailbox_id, &handle); + debug_log("handle: %d", handle); + email_free_mailbox(&mailbox, 1); + + p->syncing = 1; + elm_object_disabled_set(p->r_button, TRUE); + elm_genlist_item_update(p->gl_sync_item); + elm_genlist_item_update(p->gl_onoff_item); +} + +static void _delete_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return; + } + + 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; + } + + vd->ugd->account_id = account_data->account_id; + + elm_object_disabled_set(p->l_button, EINA_TRUE); + elm_object_item_disabled_set(p->c_item[0], EINA_TRUE); + + ugd->popup_one = setting_get_notify(vd, NULL, dgettext("sys_string", "IDS_COM_POP_DELETE_Q"), 2, + dgettext("sys_string", "IDS_COM_SK_YES"), + _popup_delete_ok_cb, + dgettext("sys_string", "IDS_COM_SK_NO"), + _popup_cancel_cb); +} + +static void _back_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + struct viewdata *vd = data; + + debug_log("_after_validation_cb %s", vd->ugd->start_view_type); + + if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "first-setup") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "account-add") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "select-account") == 0) { + + service_h service = NULL; + service_create(&service); + if (service) { + service_add_extra_data(service, EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT, + EMAIL_BUNDLE_KEY_REFRESH_ACCOUNT); + ug_send_result(vd->ugd->ug, service); + service_destroy(service); + } + } else { + setting_update_acct_list(vd); + if (vd->ugd->manual_setup) { + setting_back_to_prev_nth_view(vd, 4, vd->ugd->navi_main_it); + vd->ugd->manual_setup = 0; + } else + setting_back_to_prev_nth_view(vd, 3, vd->ugd->navi_main_it); + vd->ugd->atomic_pop = 0; + } +} + +static Eina_Bool _after_delete_cb(void *data) +{ + debug_log(""); + + struct viewdata *vd = (struct viewdata *)data; + + if (vd == NULL) { + debug_log("vd is NULL"); + return FALSE; + } + + //struct priv_data *p = vd->priv; + EmailSettingUGD *ugd = vd->ugd; + + if (ugd->del_timer) { + ecore_timer_del(ugd->del_timer); + ugd->del_timer = NULL; + } + + status_message_post(dgettext("sys_string", "IDS_COM_POP_DELETED")); + + if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "first-setup") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "account-add") == 0) { + ug_destroy_me(vd->ugd->ug); + } else if (vd->ugd->start_view_type != NULL && + strcmp(vd->ugd->start_view_type, "select-account") == 0) { + ug_destroy_me(vd->ugd->ug); + } else { + setting_update_acct_list(vd); + if (vd->ugd->manual_setup) { + setting_back_to_prev_nth_view(vd, 4, vd->ugd->navi_main_it); + vd->ugd->manual_setup = 0; + } else { + setting_back_to_prev_nth_view(vd, 3, vd->ugd->navi_main_it); + } + vd->ugd->atomic_pop = 0; + + setting_get_small_notify(vd, dgettext("sys_string", "IDS_COM_POP_DELETED")); + } + + return TRUE; +} + +static void _popup_cancel_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_delete_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; + } + + int account_id = vd->ugd->account_id; + int ret = email_engine_delete_account(account_id); + + if (ret) { + p->account_deleted = TRUE; + ugd->del_timer = ecore_timer_add(0.5, _after_delete_cb, vd); + debug_log("delete success"); + } else { + ugd->popup_one = setting_get_notify(vd, dgettext("sys_string", "IDS_COM_POP_WARNING"), + dgettext("sys_string", "IDS_COM_POP_UNABLE_TO_DELETE"), 1, + dgettext("sys_string", "IDS_COM_SK_OK"), + _popup_cancel_cb, NULL, NULL); + debug_log("delete failed"); + } +} + +static char *_gl_account_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + if (!g_strcmp0(part, "elm.text.1")) { + return g_strdup(account_data->account_name); + } + + if (!g_strcmp0(part, "elm.text.2")) { + return g_strdup(account_data->user_email_address); + } + + return NULL; +} + +static char *_gl_onoff_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_EMAIL_SYNC")); + return g_strdup(buf); + } else if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + email_mailbox_t *mailbox = NULL; + email_get_mailbox_by_mailbox_type(account_data->account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox); + if (mailbox) { + time_t req_time = time(NULL);//mailbox->last_sync_time; + _get_date_text_with_formatter(req_time, buf); + email_free_mailbox(&mailbox, 1); + } + + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_sync_text_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + if (!g_strcmp0(part, "elm.text.1")) { + char buf[MAX_STR_LEN] = { 0, }; + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_SYNC_SCHEDULE")); + return g_strdup(buf); + } + + if (!g_strcmp0(part, "elm.text.2")) { + char buf[MAX_STR_LEN] = { 0, }; + + /*int period = abs(account_data->check_interval);*/ + int period = account_data->check_interval; + + if (period <= sync_schedule[0]) { + snprintf(buf, sizeof(buf), "%s", dgettext("sys_string", "IDS_COM_BODY_MANUAL")); + } else if (period == sync_schedule[1]) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_EVERY_30_MINUTES")); + } else if (period == sync_schedule[2]) { + snprintf(buf, sizeof(buf), "%s", N_("Every 1 hour")); + } else if (period == sync_schedule[3]) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 3); + } else if (period == sync_schedule[4]) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 6); + } else if (period == sync_schedule[5]) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 12); + } else if (period == sync_schedule[6]) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ONCE_A_DAY")); + } + return g_strdup(buf); + } + + return NULL; +} + +static char *_gl_ex_sync_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", dgettext("sys_string", "IDS_COM_BODY_MANUAL")); + } else if (index == 1) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_EVERY_30_MINUTES")); + } else if (index == 2) { + snprintf(buf, sizeof(buf), "%s", N_("Every 1 hour")); + } else if (index == 3) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 3); + } else if (index == 4) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 6); + } else if (index == 5) { + snprintf(buf, sizeof(buf), _("IDS_EMAIL_BODY_EVERY_PD_HOURS"), 12); + } else if (index == 6) { + snprintf(buf, sizeof(buf), "%s", _("IDS_EMAIL_BODY_ONCE_A_DAY")); + } + + return g_strdup(buf); + } + + return NULL; +} + +static Evas_Object *_gl_account_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + struct viewdata *vd = g_vd; + EmailSettingUGD *ugd = vd->ugd; + struct priv_data *p = vd->priv; + Evas_Object *color_bar = NULL; + + if (!g_strcmp0(part, "elm.icon.1")) { + Evas_Object *icon = elm_icon_add(ugd->navi_bar); + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + + debug_log("is_preset_account:%d", user_data->is_preset_account); + + switch (user_data->is_preset_account) { + case GMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_GMAIL, NULL); + break; + case HOTMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_HOTMAIL, NULL); + break; + case YAHOOMAIL: + elm_icon_file_set(icon, ACCOUNT_ICON_YAHOO, NULL); + break; + case AOL: + elm_icon_file_set(icon, ACCOUNT_ICON_AOL, NULL); + break; + case OTHERS: + default: + elm_icon_file_set(icon, ACCOUNT_ICON_OTHERS, NULL); + break; + } + + evas_object_size_hint_aspect_set(icon, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); + p->account_icon = icon; + return icon; + } + + if (!g_strcmp0(part, "elm.icon.2")) { + if (p->syncing) { + Evas_Object *pb = elm_progressbar_add(ugd->navi_bar); + elm_object_style_set(pb, "list_process_small"); + elm_progressbar_horizontal_set(pb, EINA_TRUE); + elm_progressbar_pulse(pb, EINA_TRUE); + return pb; + } + } + + if (!g_strcmp0(part, "elm.swallow.colorbar")) { + account_user_data_t *user_data = (account_user_data_t *)account_data->user_data; + unsigned int val = user_data->index_color; + int r = (val & 0xff000000) >> 24; + int g = (val & 0x00ff0000) >> 16; + int b = (val & 0x0000ff00) >> 8; + int a = val & 0x000000ff; + + debug_log("R[%d] G[%d] B[%d] A[%d]", r, g, b, a); + + color_bar = evas_object_rectangle_add(evas_object_evas_get(obj)); + evas_object_size_hint_fill_set(color_bar, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_color_set(color_bar, r, g, b, a); + + return color_bar; + } + + return NULL; +} + +static Evas_Object *_gl_onoff_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + 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 (account_data->sync_disabled) + elm_check_state_set(check, EINA_FALSE); + else + elm_check_state_set(check, EINA_TRUE); + + p->onoff = check; + + return check; + } + + return NULL; +} + +static Evas_Object *_gl_ex_sync_content_get_cb(void *data, Evas_Object *obj, const char *part) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return NULL; + } + + 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 *radio = elm_radio_add(ugd->navi_bar); + elm_radio_group_add(radio, p->sync_radio_grp); + elm_radio_state_value_set(radio, index); + + if (sync_schedule[index] == abs(account_data->check_interval)) { + elm_radio_value_set(p->sync_radio_grp, index); + } + return radio; + } + + return NULL; +} + +static void _gl_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return; + } + + 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); + + Eina_Bool state = elm_check_state_get(p->onoff); + + if (state) { + account_data->check_interval = -(abs(account_data->check_interval)); + account_data->sync_disabled = 1; + elm_check_state_set(p->onoff, EINA_FALSE); + + if (p->gl_sync_item) { + if (elm_genlist_item_expanded_get(p->gl_sync_item)) { + elm_genlist_item_expanded_set(p->gl_sync_item, 0); + } + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_TRUE); + } + } else { + account_data->check_interval = abs(account_data->check_interval); + account_data->sync_disabled = 0; + elm_check_state_set(p->onoff, EINA_TRUE); + + if (p->gl_sync_item) { + elm_genlist_item_update(p->gl_sync_item); + elm_object_item_disabled_set(p->gl_sync_item, EINA_FALSE); + } + } + + _update_account_info(vd); +} + +static void _gl_ex_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + 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_sync_sel_cb(void *data, Evas_Object *obj, void *event_info) +{ + debug_log(""); + + if (!account_data) { + debug_log("account_data is NULL"); + return; + } + + int index = (int)data; + struct viewdata *vd = g_vd; + struct priv_data *p = vd->priv; + 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->sync_radio_grp); + + if (sel_radio == index) + return; + + if (index >= 0 && index < 7) + account_data->check_interval = sync_schedule[index]; + + elm_radio_value_set(p->sync_radio_grp, index); + + _update_account_info(vd); + + elm_genlist_item_update(p->gl_sync_item); +} + +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; + + for (i = 0; i < 7; i++) { + elm_genlist_item_append(p->genlist, &(p->itc_ex_sync), (void *)i, + it, ELM_GENLIST_ITEM_NONE, _gl_ex_sync_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 */ diff --git a/setting/theme/email-setting-theme-macro.edc b/setting/theme/email-setting-theme-macro.edc new file mode 100755 index 0000000..fe2b56a --- /dev/null +++ b/setting/theme/email-setting-theme-macro.edc @@ -0,0 +1,1215 @@ +/* + * 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. + */ + +#define GENLIST_HEIGHT_1_INC 1 +#define GENLIST_HEIGHT_16_INC 16 +#define GENLIST_HEIGHT_33_INC 33 +#define GENLIST_HEIGHT_49_INC 49 +#define GENLIST_HEIGHT_62_INC 62 +#define GENLIST_HEIGHT_65_INC 65 +#define GENLIST_HEIGHT_73_INC 73 +#define GENLIST_HEIGHT_77_INC 77 +#define GENLIST_HEIGHT_89_INC 89 +#define GENLIST_HEIGHT_93_INC 93 +#define GENLIST_HEIGHT_97_INC 97 +#define GENLIST_HEIGHT_113_INC 113 +#define GENLIST_HEIGHT_129_INC 129 +#define GENLIST_HEIGHT_177_INC 177 +#define GENLIST_HEIGHT_182_INC 182 +#define GENLIST_HEIGHT_190_INC 190 +#define GENLIST_HEIGHT_207_INC 207 +#define GENLIST_HEIGHT_260_INC 260 +#define GENLIST_HEIGHT_291_INC 291 +#define GENLIST_HEIGHT_454_INC 454 +#define GENLIST_HEIGHT_566_INC 566 + +#define GENLIST_PADDING_4_INC 4 +#define GENLIST_PADDING_5_INC 5 +#define GENLIST_PADDING_6_INC 6 +#define GENLIST_PADDING_8_INC 8 +#define GENLIST_PADDING_10_INC 10 +#define GENLIST_PADDING_11_INC 11 +#define GENLIST_PADDING_12_INC 12 +#define GENLIST_PADDING_13_INC 13 +#define GENLIST_PADDING_14_INC 14 +#define GENLIST_PADDING_16_INC 16 +#define GENLIST_PADDING_18_INC 18 +#define GENLIST_PADDING_21_INC 21 +#define GENLIST_PADDING_22_INC 22 +#define GENLIST_PADDING_24_INC 24 +#define GENLIST_PADDING_27_INC 27 +#define GENLIST_PADDING_32_INC 32 +#define GENLIST_PADDING_34_INC 34 +#define GENLIST_PADDING_46_INC 46 +#define GENLIST_PADDING_48_INC 48 +#define GENLIST_PADDING_64_INC 64 +#define GENLIST_PADDING_74_INC 74 +#define GENLIST_PADDING_88_INC 88 +#define GENLIST_PADDING_124_INC 124 + +#define GENLIST_FONT_27_INC 27 +#define GENLIST_FONT_28_INC 28 +#define GENLIST_FONT_30_INC 30 +#define GENLIST_FONT_32_INC 32 +#define GENLIST_FONT_STYLE_32_INC "32" +#define GENLIST_FONT_36_INC 36 +#define GENLIST_FONT_STYLE_36_INC "36" +#define GENLIST_FONT_40_INC 40 +#define GENLIST_FONT_STYLE_40_INC "40" +#define GENLIST_FONT_42_INC 42 +#define GENLIST_FONT_STYLE_42_INC "42" +#define GENLIST_FONT_44_INC 44 +#define GENLIST_FONT_STYLE_44_INC "44" +#define GENLIST_FONT_48_INC 48 +#define GENLIST_FONT_STYLE_48_INC "48" + +#define GENLIST_SIZE_6_INC 6 +#define GENLIST_SIZE_8_INC 8 +#define GENLIST_SIZE_10_INC 10 +#define GENLIST_SIZE_13_INC 13 +#define GENLIST_SIZE_16_INC 16 +#define GENLIST_SIZE_18_INC 18 +#define GENLIST_SIZE_21_INC 21 +#define GENLIST_SIZE_32_INC 32 +#define GENLIST_SIZE_35_INC 35 +#define GENLIST_SIZE_38_INC 38 +#define GENLIST_SIZE_40_INC 40 +#define GENLIST_SIZE_42_INC 42 +#define GENLIST_SIZE_44_INC 44 +#define GENLIST_SIZE_45_INC 45 +#define GENLIST_SIZE_46_INC 46 +#define GENLIST_SIZE_48_INC 48 +#define GENLIST_SIZE_54_INC 54 +#define GENLIST_SIZE_56_INC 56 +#define GENLIST_SIZE_57_INC 57 +#define GENLIST_SIZE_61_INC 61 +#define GENLIST_SIZE_SLIDE_60_INC 60 +#define GENLIST_SIZE_64_INC 64 +#define GENLIST_SIZE_74_INC 74 +#define GENLIST_SIZE_SLIDE_74_INC 74 +#define GENLIST_SIZE_80_INC 80 +#define GENLIST_SIZE_90_INC 90 +#define GENLIST_SIZE_96_INC 96 +#define GENLIST_SIZE_112_INC 112 +#define GENLIST_SIZE_116_INC 116 +#define GENLIST_SIZE_128_INC 128 +#define GENLIST_SIZE_133_INC 133 +#define GENLIST_SIZE_141_INC 141 +#define GENLIST_SIZE_144_INC 144 +#define GENLIST_SIZE_154_INC 154 +#define GENLIST_SIZE_160_INC 160 +#define GENLIST_SIZE_163_INC 163 +#define GENLIST_SIZE_168_INC 168 +#define GENLIST_SIZE_174_INC 174 +#define GENLIST_SIZE_SLIDE_165_INC 165 +#define GENLIST_SIZE_176_INC 176 +#define GENLIST_SIZE_177_INC 177 +#define GENLIST_SIZE_192_INC 192 +#define GENLIST_SIZE_195_INC 195 +#define GENLIST_SIZE_197_INC 197 +#define GENLIST_SIZE_206_INC 206 +#define GENLIST_SIZE_234_INC 234 +#define GENLIST_SIZE_235_INC 235 +#define GENLIST_SIZE_SLIDE_220_INC 220 +#define GENLIST_SIZE_304_INC 304 +#define GENLIST_SIZE_390_INC 390 +#define GENLIST_SIZE_448_INC 448 +#define GENLIST_SIZE_560_INC 560 +#define GENLIST_SIZE_576_INC 576 +#define GENLIST_SIZE_672_INC 672 + +#define GENLIST_TREESIZE_16_INC 16 +#define GENLIST_TREESIZE_20_INC 20 +#define GENLIST_TREESIZE_32_INC 32 + +#define GENLIST_PART_FONT_LIST_MAIN_TEXT_READ_COLOR_INC 158 158 158 255 +#define GENLIST_PART_FONT_LIST_MAIN_TEXT_UNREAD_COLOR_INC 0 0 0 255 +#define GENLIST_PART_FONT_LIST_MAIN_TEXT_FOCUS_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_LIST_SUB_TEXT_COLOR_INC 100 100 100 255 +#define GENLIST_PART_FONT_LIST_SUB_TEXT_SETTINGS_COLOR_INC 0 140 210 255 +#define GENLIST_PART_FONT_LIST_SUB_TEXT_FOCUS_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_FLEXIBLE_TEXT_MAIN_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_FLEXIBLE_TEXT_SUB_COLOR_INC 149 149 149 255 +#define GENLIST_PART_FONT_INDEX_LIST_COLOR_INC 164 164 164 255 +#define GENLIST_PART_FONT_EDITFIELD_TEXT_COLOR_INC 70 70 70 255 +#define GENLIST_PART_FONT_EDITFIELD_TEXT_CURSOR_COLOR_INC 0 140 210 255 +#define GENLIST_PART_FONT_MULTILINE_TEXT_COLOR_INC 149 149 149 255 +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_READ_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_UNREAD_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_FOCUS_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_2_COLOR_INC 104 137 152 255 +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_2_FOCUS_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_CONVERTOR_STYLE_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_CONVERTOR_STYLE_FOCUS_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_UNREAD_EMAIL_COLOR_INC 249 249 249 255 +#define GENLIST_PART_FONT_CONTENTS_TEXT_COLOR_INC 210 210 210 255 +#define GENLIST_PART_FONT_NAME_TEXT_COLOR_INC 129 129 129 255 +#define GENLIST_PART_FONT_NAME_TEXT_DIM_COLOR_INC 0 140 210 255 +#define GENLIST_PART_FONT_BUBBLE_READ_MESSAGE_COLOR_INC 0 0 0 255 +#define GENLIST_PART_FONT_BUBBLE_MESSAGE_TIME_COLOR_INC 96 96 96 255 +#define GENLIST_PART_FONT_BUBBLE_SENT_MESSAGE_COLOR_INC 0 0 0 255 +#define GENLIST_PART_FONT_BUBBLE_SOS_MESSAGE_COLOR_INC 211 0 0 255 +#define GENLIST_PART_FONT_BUBBLE_MESSAGE_DATE_COLOR_INC 164 164 164 255 +#define GENLIST_PART_FONT_BUBBLE_LINK_MESSAGE_COLOR_INC 34 129 157 255 +#define GENLIST_PART_FONT_BUBBLE_MESSAGE_FAILED_COLOR_INC 211 0 0 255 +#define GENLIST_PART_FONT_BUBBLE_READ_MESSAGE_NAME_COLOR_INC 57 166 215 255 +#define GENLIST_PART_FONT_BUBBLE_MESSAGE_HELP_COLOR_INC 146 146 146 255 +#define GENLIST_PART_FONT_SWEEP_STYLE_COLOR_INC 118 118 118 255 + +#define GENLIST_PART_FONT_LIST_MAIN_TEXT_UNREAD_STYLE_COLOR_INC "#F9F9F9FF" +#define GENLIST_PART_FONT_LIST_SUB_TEXT_STYLE_COLOR_INC "#646464FF" +#define GENLIST_PART_FONT_FLEXIBLE_TEXT_MAIN_STYLE_COLOR_INC "#F9F9F9FF" +#define GENLIST_PART_FONT_FLEXIBLE_TEXT_SUB_STYLE_COLOR_INC "#959595FF" +#define GENLIST_PART_FONT_MULTILINE_TEXT_STYLE_COLOR_INC "#959595FF" +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_READ_STYLE_COLOR_INC "#F9F9F9FF" +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_UNREAD_STYLE_COLOR_INC "#F9F9F9FF" +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_FOCUS_STYLE_COLOR_INC "#F9F9F9FF" +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_2_STYLE_COLOR_INC "#688998FF" +#define GENLIST_PART_FONT_3LINE_MAIN_TEXT_2_FOCUS_STYLE_COLOR_INC "#F9F9F9FF" +#define GENLIST_PART_FONT_HELP_TEXT_STYLE_COLOR_INC "#929292FF" + +#define GENLIST_PART_DISCLIP_COLOR_INC 255 255 255 110 // alpha was 64 +#define GENLIST_PART_BG_COLOR_INC 230 230 230 255 +#define GENLIST_PART_LIST_BG_COLOR_INC 230 230 230 255 +#define GENLIST_PART_LIST_LINE_COLOR_INC 68 68 68 255 +#define GENLIST_PART_LIST_PRESS_COLOR_INC 0 140 210 255 +#define GENLIST_PART_TEXT_PRESS_COLOR_INC 0 0 0 255 +#define GENLIST_PART_EXPANDABLE_2ND_DEPTH_BG_COLOR_INC 31 31 31 255 +#define GENLIST_PART_EXPANDABLE_3ND_DEPTH_BG_COLOR_INC 46 46 46 255 +#define GENLIST_PART_EDIT_SELECT_ALL_BG_COLOR_INC 36 36 36 255 +#define GENLIST_PART_EDIT_REORDER_BG_COLOR_INC 36 36 36 255 +#define GENLIST_PART_EDIT_1PIXEL_LINE_COLOR_INC 68 68 68 255 +#define GENLIST_PART_BUBBLE_DATE_BG_COLOR_INC 66 66 66 255 +#define GENLIST_PART_BUBBLE_1PIXEL_LINE_COLOR_INC 153 153 153 255 +#define GENLIST_PART_INDEX_LIST_BASE_EVENT_INC \ + part { name: "base_event";\ + type: RECT;\ + repeat_events: 0;\ + description { state: "default" 0.0;\ + color: 0 0 0 0;\ + }\ + } +#define GENLIST_PART_INDEX_LIST_BASE_IMAGE_INC \ + part { name: "base_image";\ + repeat_events: 1;\ + description { state: "default" 0.0;\ + rel1.to: "rect";\ + rel2.to: "rect";\ + image {\ + normal: "00_index_list_bg.png";\ + }\ + }\ + } + +#define GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC "#F9F9F9FF" +#define GENLIST_PART_MATCH_TAG_COLOR_INC "+ color=#3F8DAD" + +#define GENLIST_DIALOGUE_FONT_SUB_TITLE_COLOR_INC 102 102 102 255 +#define GENLIST_DIALOGUE_FONT_EDIT_MODE_TEXT_01_COLOR_INC 153 153 153 255 +#define GENLIST_DIALOGUE_FONT_EDIT_MODE_TEXT_01_FOCUS_COLOR_INC 249 249 249 255 +#define GENLIST_DIALOGUE_FONT_EDIT_MODE_TEXT_02_COLOR_INC 63 141 173 255 +#define GENLIST_DIALOGUE_FONT_EDIT_MODE_TEXT_02_DIM_COLOR_INC 63 141 173 255 +#define GENLIST_DIALOGUE_FONT_EDIT_MODE_TEXT_02_FOCUS_COLOR_INC 249 249 249 255 +#define GENLIST_DIALOGUE_FONT_DETAIL_TEXT_MAIN_COLOR_INC 249 249 249 255 +#define GENLIST_DIALOGUE_FONT_DETAIL_TEXT_SUB_COLOR_INC 146 146 146 255 +#define GENLIST_DIALOGUE_FONT_APPS_NAME_COLOR_INC 249 249 249 255 +#define GENLIST_DIALOGUE_FONT_APPS_INC_COLOR_INC 146 146 146 255 +#define GENLIST_DIALOGUE_FONT_APPS_RATING_COLOR_INC 146 146 146 255 +#define GENLIST_DIALOGUE_FONT_APPS_PRICE_ORIGINAL_COLOR_INC 0 140 210 255 +#define GENLIST_DIALOGUE_FONT_APPS_PRICE_SALE_COLOR_INC 221 134 21 255 +#define GENLIST_DIALOGUE_FONT_APPS_PRICE_FREE_COLOR_INC 0 140 210 255 +#define GENLIST_DIALOGUE_FONT_PASSWORD_TITLE_COLOR_INC 153 153 153 255 +#define GENLIST_DIALOGUE_FONT_PASSWORD_INPUT_TEXT_COLOR_INC 249 249 249 255 +#define GENLIST_DIALOGUE_FONT_DETAIL_WORD_COLOR_INC 249 249 249 255 +#define GENLIST_DIALOGUE_FONT_DETAIL_PRONUNCIATION_COLOR_INC 152 89 0 255 +#define GENLIST_DIALOGUE_FONT_DETAIL_NATION_COLOR_INC 146 146 146 255 +#define GENLIST_DIALOGUE_FONT_DETAIL_INFO_01_COLOR_INC 249 249 249 255 +#define GENLIST_DIALOGUE_FONT_DETAIL_INFO_02_COLOR_INC 146 146 146 255 + +#define GENLIST_DIALOGUE_GROUP_BG_COLOR_INC 36 36 36 255 +#define GENLIST_DIALOGUE_GROUP_LIST_BG_COLOR_INC 36 36 36 255 +#define GENLIST_DIALOGUE_GROUP_LEFT_BG_COLOR_INC 68 68 68 255 +#define GENLIST_DIALOGUE_1PIXEL_LINE_COLOR_INC 68 68 68 255 +#define GENLIST_DIALOGUE_ICON_1PIXEL_LINE_COLOR_INC 68 68 68 255 +#define GENLIST_DIALOGUE_PHOTO_ID_1PIXEL_LINE_COLOR_INC 68 68 68 255 + +#define GENLIST_PART_BASE( param_item_height ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_item_height; \ + color: GENLIST_PART_BG_COLOR_INC; \ + } \ + } + +#define GENLIST_PART_BG \ + part { name: "bg"; \ + type: RECT; \ + clip_to: "disclip"; \ + mouse_events: 0; \ + description { state: "default" 0.0; \ + color: GENLIST_PART_BG_COLOR_INC; \ + } \ + description { state: "hide" 0.0; \ + inherit: "default" 0.0; \ + rel1 { relative: 0.025 0.0; } \ + rel2 { relative: 1.025 1.0; } \ + } \ + description { state: "hide" 0.1; \ + inherit: "default" 0.0; \ + rel1 { relative: 0.13 0.0; } \ + rel2 { relative: 1.13 1.0; } \ + } \ + description { state: "hide" 0.2; \ + inherit: "default" 0.0; \ + rel1 { relative: 0.5 0.0; } \ + rel2 { relative: 1.5 1.0; } \ + } \ + description { state: "hide" 0.3; \ + inherit: "default" 0.0; \ + rel1 { relative: 1.0 0.0; } \ + rel2 { relative: 2.0 1.0; } \ + } \ + } + +#define GENLIST_PART_BG_IMAGE \ + part { name: "bg_image"; \ + type: RECT; \ + clip_to: "disclip"; \ + mouse_events: 0; \ + description { state: "default" 0.0; \ + color: GENLIST_PART_LIST_BG_COLOR_INC; \ + } \ + description { state: "selected" 0.0; \ + inherit: "default" 0.0; \ + color: GENLIST_PART_LIST_PRESS_COLOR_INC; \ + } \ + } + +#define GENLIST_PART_BOTTOM_LINE \ + part { name: "bottom_line"; \ + type: RECT; \ + mouse_events: 0; \ + description { state: "default" 0.0; \ + min: 0 1; \ + fixed: 0 1; \ + visible: 1; \ + color: GENLIST_PART_LIST_LINE_COLOR_INC; \ + rel1 { \ + relative: 0.0 1.0; \ + offset: 0 -1; \ + } \ + } \ + } + +#define GENLIST_PART_BOTTOM_EFFECT_LINE \ + part { name: "bottom_line"; \ + type: RECT; \ + mouse_events: 0; \ + description { state: "default" 0.0; \ + min: 0 1; \ + fixed: 0 1; \ + visible: 1; \ + color: GENLIST_PART_LIST_LINE_COLOR_INC; \ + rel1 { \ + relative: 0.0 1.0; \ + offset: 0 -1; \ + } \ + } \ + GENLIST_PART_MAP_START(-90.0, 0.0, 0.0) \ + GENLIST_PART_MAP_FINISH(0.0, 0.0, 0.0) \ + } + +#define GENLIST_PART_PADDING_TOP( param_padding_size ) \ + part { name: "elm.padding.top"; \ + type: RECT; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + min: 0 param_padding_size; \ + fixed: 0 1; \ + visible: 0; \ + rel2.relative: 1.0 0.0; \ + align: 0.0 0.0; \ + } \ + } + +#define GENLIST_PART_PADDING_TEXT_TOP( param_padding_size ) \ + part { name: "elm.padding.text.top"; \ + type: RECT; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + min: 0 param_padding_size; \ + fixed: 0 1; \ + visible: 0; \ + rel2.relative: 1.0 0.0; \ + align: 0.0 0.0; \ + } \ + } + +#define GENLIST_PART_PADDING_BOTTOM( param_padding_size ) \ + part { name: "elm.padding.bottom"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_padding_size; \ + fixed: 0 1; \ + visible: 0; \ + rel1.relative: 0.0 1.0; \ + align: 0.0 1.0; \ + } \ + } + +#define GENLIST_PART_PADDING_LEFT( param_padding_size ) \ + part { name: "elm.padding.left"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: param_padding_size 0; \ + fixed: 1 0; \ + visible: 0; \ + rel2.relative: 0.0 1.0; \ + align: 0.0 0.0; \ + } \ + } + +#define GENLIST_PART_PADDING_RIGHT( param_padding_size ) \ + part { name: "elm.padding.right"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: param_padding_size 0; \ + fixed: 1 0; \ + visible: 0; \ + rel1.relative: 1.0 0.0; \ + align: 1.0 0.0; \ + } \ + } + +#define GENLIST_PART_DIALOGUE_BASE( param_item_height ) \ + part { name: "base"; \ + type: RECT; \ + clip_to: "disclip"; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_item_height; \ + color: LAYOUT_GROUP_LIST_BG_COLOR_INC; \ + } \ + } + +#define GENLIST_PART_DIALOGUE_ITEM \ + part { name: "elm.rect.dialogue"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: GENLIST_PADDING_12_INC 0; \ + fixed: 1 0; \ + color: GENLIST_DIALOGUE_GROUP_LEFT_BG_COLOR_INC; \ + rel2.relative: 0.0 1.0; \ + align: 0.0 0.0; \ + } \ + } + +#define GENLIST_PART_DIALOGUE_EXPANDABLE_ITEM \ + part { name: "elm.rect.dialogue"; \ + type: RECT; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: GENLIST_PADDING_12_INC 0; \ + fixed: 1 0; \ + color: GENLIST_DIALOGUE_GROUP_LEFT_BG_COLOR_INC; \ + rel2.relative: 0.0 1.0; \ + align: 0.0 0.0; \ + } \ + GENLIST_PART_MAP_START(-90.0, 0.0, 0.0) \ + GENLIST_PART_MAP_FINISH(0.0, 0.0, 0.0) \ + } + +#define GENLIST_PART_SWALLOW_END( param_padding_size ) \ + part { name: "elm.padding.left.swallow.end";\ + clip_to: "disclip"; \ + type: RECT;\ + scale: 1;\ + description { state: "default" 0.0;\ + min: param_padding_size 0;\ + fixed: 1 0;\ + visible: 0; \ + rel1.to_x: "elm.swallow.end";\ + rel2 {\ + relative: 0.0 1.0;\ + to_x: "elm.swallow.end";\ + }\ + align: 1.0 0.5;\ + }\ + }\ + part { name: "elm.swallow.end";\ + clip_to: "disclip"; \ + type: SWALLOW;\ + scale: 1;\ + description { state: "default" 0.0;\ + fixed: 1 0;\ + align: 1.0 0.5;\ + rel1.to_x: "elm.padding.right";\ + rel2 {\ + relative: 0.0 1.0;\ + to_x: "elm.padding.right";\ + }\ + }\ + } + +#define GENLIST_PART_DISCLIP \ + part { name: "disclip"; \ + type: RECT; \ + description { state: "default" 0.0; \ + } \ + description { state: "disabled" 0.0; \ + inherit: "default" 0.0; \ + color: GENLIST_PART_DISCLIP_COLOR_INC; \ + } \ + } + +#define GENLIST_EXPANDABLE_PART_PERSPECTIVE_POINT() \ + part { name: "point"; \ + type: RECT; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + color: 0 0 0 0; \ + rel1 { relative: 0.0 0.0; } \ + rel2 { relative: 1.0 0.0; } \ + } \ + } + +#define GENLIST_PART_MAP_START( param_x, param_y, param_z ) \ + description { state: "map_transition" 0.0; \ + inherit: "default" 0.0; \ + color: 50 50 50 100; \ + map { \ + perspective: "point"; \ + on: 1; \ + smooth: 1; \ + perspective_on: 1; \ + backface_cull: 1; \ + rotation { \ + center: "point"; \ + x: param_x; \ + y: param_y; \ + z: param_z; \ + } \ + } \ + } \ + description { \ + state: "hide" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } + +#define GENLIST_PART_MAP_FINISH( param_x, param_y, param_z ) \ + description { \ + state: "map_rotate" 0.0; \ + inherit: "default" 0.0; \ + map { \ + perspective: "point"; \ + on: 1; \ + smooth: 1; \ + perspective_on: 1; \ + backface_cull: 1; \ + rotation { \ + center: "point"; \ + x: param_x; \ + y: param_y; \ + z: param_z; \ + } \ + } \ + } \ + +#define GENLIST_PART_MAP_BASE( param_item_height ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_item_height; \ + color: GENLIST_PART_BG_COLOR_INC; \ + } \ + GENLIST_PART_MAP_START(-90.0, 0.0, 0.0) \ + GENLIST_PART_MAP_FINISH(0.0, 0.0, 0.0) \ + } + +#define GENLIST_EXPANDABLE_PART_BASE( GE_HEIGHT , GE_COLOR ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 GE_HEIGHT; \ + color: GE_COLOR; \ + } \ + description { state: "selected" 0.0; \ + inherit: "default" 0.0; \ + color: GENLIST_PART_LIST_PRESS_COLOR_INC; \ + } \ + GENLIST_PART_MAP_START(-90.0, 0.0, 0.0) \ + GENLIST_PART_MAP_FINISH(0.0, 0.0, 0.0) \ + } + +/* XXX: refactor expandable edc first. + and use GENLIST_EXPANDABLE_PART_BASE_NEW as GENLIST_EXPANDABLE_PART_BASE. +*/ +#define GENLIST_EXPANDABLE_PART_BASE_NEW( GE_HEIGHT , GE_COLOR ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 GE_HEIGHT; \ + color: GE_COLOR; \ + } \ + description { state: "selected" 0.0; \ + inherit: "default" 0.0; \ + color: GENLIST_PART_LIST_PRESS_COLOR_INC; \ + } \ + } + +#define GENLIST_PROGRAM_MAP_ROTATE_EXPAND_START() \ + name: "rotaion_transition"; \ + signal: "flip_item"; \ + action: STATE_SET "map_transition" 0.0; \ + after: "rotation"; + +#define GENLIST_PROGRAM_MAP_ROTATE_EXPAND_FINISH( second ) \ + name: "rotation"; \ + action: STATE_SET "map_rotate" 0.0; \ + transition: LINEAR second; \ + after: "rotation_end"; + +#define GENLIST_PROGRAM_MAP_EXPAND_END() \ + name: "rotation_end"; \ + action: STATE_SET "default" 0.0; + +#define GENLIST_PROGRAM_MAP_ROTATE_CONTRACT_START() \ + name: "rotation_transition2"; \ + signal: "elm,state,contract_flip"; \ + action: STATE_SET "map_rotate" 0.0; \ + after: "rotation2"; + +#define GENLIST_PROGRAM_MAP_ROTATE_CONTRACT_FINISH( second ) \ + name: "rotation2"; \ + action: STATE_SET "map_transition" 0.0; \ + transition: LINEAR second; \ + after: "rotation3"; + +#define GENLIST_PROGRAM_MAP_CONTRACT_END() \ + name: "rotation3"; \ + action: STATE_SET "hide" 0.0; + +#define GENLIST_PART_EXPANDABLE2_NOSHADOW_BASE( param_item_height ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_item_height; \ + color: GENLIST_PART_EXPANDABLE_2ND_DEPTH_BG_COLOR_INC; \ + } \ + GENLIST_PART_MAP_START(-90.0, 0.0, 0.0) \ + GENLIST_PART_MAP_FINISH(0.0, 0.0, 0.0) \ + } + +#define GENLIST_PART_EXPANDABLE_SWALLOW_PADDING \ + part { name: "elm.swallow.pad"; \ + type: SWALLOW; \ + description { state: "default" 0.0; \ + fixed: 1 0; \ + align: 0.0 0.5; \ + rel1 { \ + relative: 1.0 0.0;\ + to_x: "elm.padding.left"; \ + } \ + rel2.to_x: "elm.padding.left"; \ + } \ + GENLIST_PART_MAP_START(-90.0, 0.0, 0.0) \ + GENLIST_PART_MAP_FINISH(0.0, 0.0, 0.0) \ + } \ + +#define GENLIST_PART_PADDING_LEFT_SLIDE( param_padding_size ) \ + part { name: "elm.padding.left"; \ + type: RECT; \ + scale: 1; \ + description { \ + state: "default" 0.0; \ + min: param_padding_size 0; \ + fixed: 1 0; \ + visible: 0; \ + rel1 { relative: 0.0 0.0; to: "bg"; } \ + rel2 { relative: 0.0 1.0; to: "bg"; } \ + align: 0.0 0.0; \ + } \ + } + +/* only for demo */ +#define GENLIST_PART_BUTTON( param_name, param_text_name, param_text, param_left, param_right, param_top, param_bottom ) \ + part { name: param_name; \ + mouse_events: 1; \ + description { state: "default" 0.0; \ + visible: 1; \ + rel1 { relative: param_left param_top; offset: 0 0; } \ + rel2 { relative: param_right param_bottom; offset: -1 -1; } \ + image { \ + normal: "btn_normal.png"; \ + border: 10 10 10 10; \ + border_scale: 1; \ + } \ + image.middle: SOLID; \ + fill.smooth: 0; \ + } \ + description { state: "selected" 0.0; \ + inherit: "default" 0.0; \ + image { \ + normal: "btn_selected.png"; \ + } \ + } \ + } \ + part { name: param_text_name; \ + type: TEXT; \ + mouse_events: 0; \ + scale: 1; \ + description { \ + align: 0.0 0.0; \ + state: "default" 0.0; \ + color: 0 0 0 255; \ + rel1 { relative: 0.0 0.0; to: param_name; } \ + rel2 { relative: 1.0 1.0; to: param_name; } \ + text { \ + text: param_text; \ + font: "SLP:style=Roman"; \ + size: 24; \ + min: 1 1; \ + align: 0.5 0.5; \ + text_class: "list_item"; \ + } \ + } \ + } + +/* only for demo */ +#define GENLIST_PROGRAM_BUTTON( param_name_focused, param_name_normal, param_part_name ) \ + program { name: param_name_focused; \ + source: param_part_name; \ + signal: "mouse,down,1"; \ + action: STATE_SET "selected" 0.0; \ + target: param_part_name; \ + } \ + program { name: param_name_normal; \ + source: param_part_name; \ + signal: "mouse,up,1"; \ + action: STATE_SET "default" 0.0; \ + target: param_part_name; \ + } + +#define GENLIST_PROGRAM_SLIDE_WITH_AFTER( param_name, param_state, param_next ) \ + program { name: param_name; \ + action: STATE_SET "hide" param_state; \ + target: "bg"; \ + transition: LINEAR 0.3; \ + after: param_next; \ + } + +#define GENLIST_PROGRAM_SLIDE( param_name, param_state_name, param_state_value ) \ + program { name: param_name; \ + action: STATE_SET param_state_name param_state_value; \ + target: "bg"; \ + transition: LINEAR 0.3; \ + } + +#define DESC_FLIP_IMAGE( param_state_value, param_image_file_name ) \ + description { state: "flipping" param_state_value; \ + inherit: "default" 0.0; \ + image { normal: param_image_file_name; } \ + } + +#define DESC_TEXT_HIDE( param_state_value ) \ + description { state: "hide" param_state_value; \ + inherit: "default" 0.0; \ + color: 0 0 0 (255*(1-param_state_value/0.20)); \ + } + +#define GENLIST_EDIT_PART_BASE( param_item_height ) \ + part { name: "base"; \ + type: RECT; \ + repeat_events: 0; \ + scale: 1; \ + description { state: "default" 0.0; \ + min: 0 param_item_height; \ + color: 0 0 0 0; \ + } \ + } + +#define GENLIST_PART_FLIP \ + part { name: "elm.flip.content"; \ + clip_to: "disclip"; \ + type: SWALLOW; \ + mouse_events: 1; \ + scale: 1; \ + description { state: "default" 0.0; \ + visible: 0; \ + fixed: 1 1; \ + rel1 { \ + relative: 1.0 0.5; \ + to_x: "elm.padding.left"; \ + } \ + rel2 { \ + relative: 0.0 0.5; \ + to_x: "elm.padding.right"; \ + } \ + } \ + description { state: "flip_enabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 1; \ + } \ + } + +#define GENLIST_DESCRIPTION_INVISIBLE_SELECTED \ + description { state: "selected" 1.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } + +#define GENLIST_DESCRIPTION_FLIP_ENABLED \ + description { state: "flip_enabled" 0.0; \ + inherit: "default" 0.0; \ + visible: 0; \ + } + +#define GENLIST_PROGRAM_SCRIPT_FLIP_SELECT_1TEXT \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text", st, 30, vl); \ + set_state(PART:"bg_image", "selected", 0.0); \ + if (!strcmp(st, "flip_enabled")) \ + set_state(PART:"elm.text", "selected", 1.0); \ + else \ + set_state(PART:"elm.text", "selected", 0.0); \ + } + +#define GENLIST_PROGRAM_SCRIPT_FLIP_SELECT_2TEXT \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text.1", st, 30, vl); \ + set_state(PART:"bg_image", "selected", 0.0); \ + if (!strcmp(st, "flip_enabled")) { \ + set_state(PART:"elm.text.1", "selected", 1.0); \ + set_state(PART:"elm.text.2", "selected", 1.0); \ + } \ + else { \ + set_state(PART:"elm.text.1", "selected", 0.0); \ + set_state(PART:"elm.text.2", "selected", 0.0); \ + } \ + } + +#define GENLIST_PROGRAM_SCRIPT_FLIP_SELECT_3TEXT \ + script { \ + new st[31]; \ + new Float:vl; \ + get_state(PART:"elm.text.1", st, 30, vl); \ + set_state(PART:"bg_image", "selected", 0.0); \ + if (!strcmp(st, "flip_enabled")) { \ + set_state(PART:"elm.text.1", "selected", 1.0); \ + set_state(PART:"elm.text.2", "selected", 1.0); \ + set_state(PART:"elm.text.3", "selected", 1.0); \ + } \ + else { \ + set_state(PART:"elm.text.1", "selected", 0.0); \ + set_state(PART:"elm.text.2", "selected", 0.0); \ + set_state(PART:"elm.text.3", "selected", 0.0); \ + } \ + } + +#define GENLIST_PROGRAM_FLIP_1TEXT \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_1TEXT_1ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text"; \ + target: "elm.icon"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text"; \ + target: "elm.icon"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_1TEXT_2ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_1TEXT_3ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.icon.3"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.icon.3"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_2TEXT \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_2TEXT_1ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.icon"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.icon"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_2TEXT_2ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_2TEXT_3ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.icon.3"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.icon.3"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_3TEXT \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_3TEXT_1ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.icon"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.icon"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_3TEXT_2ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.flip.content"; \ + } + +#define GENLIST_PROGRAM_FLIP_3TEXT_3ICON \ + program { name: "flip_enabled"; \ + signal: "elm,state,flip,enabled"; \ + source: "elm"; \ + action: STATE_SET "flip_enabled" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.icon.3"; \ + target: "elm.flip.content"; \ + } \ + program { name: "flip_disabled"; \ + signal: "elm,state,flip,disabled"; \ + source: "elm"; \ + action: STATE_SET "default" 0.0; \ + target: "elm.text.1"; \ + target: "elm.text.2"; \ + target: "elm.text.3"; \ + target: "elm.icon.1"; \ + target: "elm.icon.2"; \ + target: "elm.icon.3"; \ + target: "elm.flip.content"; \ + } + +/* genlist multisense macro - start */ +#define GENLIST_PROGRAM_AFTER_PLAY_BUTTON_PRESS \ + after: "play_button_press"; + +#define GENLIST_PROGRAM_PLAY_BUTTON_PRESS \ + program { name: "play_button_press"; \ + action: PLAY_SAMPLE "button-pressed" 1.0; \ + } + + +#define TEXTBLOCK_TAG \ + tag: "br" "\n";\ + tag: "ps" "ps";\ + tag: "tab" "\t";\ + tag: "b" "+ font=SLP:style=Bold";\ + tag: "match" GENLIST_PART_MATCH_TAG_COLOR_INC; + +styles { + style { name: "text_style"; // TODO: remove this later + base: "font=SLP:style=Roman font_size=28 color=#000000 wrap=char ellipsis=1.0 text_class=list_item"; + tag: "br" "\n"; + tag: "ps" "ps"; + tag: "tab" "\t"; + tag: "b" "+ font=SLP:style=Bold"; + tag: "match" "+ color=#E58616FF"; + } + style { name: "genlist_default_textblock_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_44_INC" color="GENLIST_PART_FONT_LIST_MAIN_TEXT_UNREAD_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_default_textblock_selected_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_44_INC" color="GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_sub_textblock_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_STYLE_32_INC" color="GENLIST_PART_FONT_LIST_SUB_TEXT_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_sub_textblock_selected_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_STYLE_32_INC" color="GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_multiline_textblock_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_STYLE_32_INC" color="GENLIST_PART_FONT_MULTILINE_TEXT_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_multiline_textblock_selected_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_STYLE_32_INC" color="GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_42_INC" color="GENLIST_PART_FONT_3LINE_MAIN_TEXT_UNREAD_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_selected_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_42_INC" color="GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_sub_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_STYLE_36_INC" color="GENLIST_PART_FONT_3LINE_MAIN_TEXT_2_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_sub_selected_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_STYLE_36_INC" color="GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_flexible_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_48_INC" color="GENLIST_PART_FONT_FLEXIBLE_TEXT_MAIN_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_flexible_selected_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_48_INC" color="GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_flexible_sub_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_36_INC" color="GENLIST_PART_FONT_FLEXIBLE_TEXT_SUB_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_flexible_sub_selected_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_STYLE_36_INC" color="GENLIST_PART_TEXT_PRESS_STYLE_COLOR_INC" wrap=char text_class=list_item"; + TEXTBLOCK_TAG + } + style { name: "genlist_textblock_help_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_STYLE_32_INC" color="GENLIST_PART_FONT_HELP_TEXT_STYLE_COLOR_INC" wrap=mixed text_class=list_item"; + TEXTBLOCK_TAG + } + + /* email styles */ + style { name: "genlist_email_textblock_selected_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_44_INC" color="GENLIST_PART_TEXTBLOCK_STYLE_SELECTED_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_email_textblock_read_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_44_INC" color="GENLIST_PART_TEXTBLOCK_READ_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_email_textblock_unread_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_44_INC" color="GENLIST_PART_TEXTBLOCK_UNREAD_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_email_textblock_urgency_unread_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_44_INC" color="GENLIST_PART_TEXTBLOCK_URGENCY_UNREAD_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_email_textblock_urgency_read_style"; + base: "font=SLP:style=Roman font_size="GENLIST_FONT_44_INC" color="GENLIST_PART_TEXTBLOCK_URGENCY_READ_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_email_textblock2_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_32_INC" color="GENLIST_PART_TEXTBLOCK_STYLE_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } + style { name: "genlist_email_textblock2_selected_style"; + base: "font=SLP:style=Medium font_size="GENLIST_FONT_32_INC" color="GENLIST_PART_TEXTBLOCK_STYLE_SELECTED_COLOR_INC" text_class=list_item ellipsis=1.0"; + TEXTBLOCK_TAG + } +} +/* genlist multisense macro - end */ diff --git a/setting/theme/email-setting-theme.edc b/setting/theme/email-setting-theme.edc new file mode 100755 index 0000000..28ea8d7 --- /dev/null +++ b/setting/theme/email-setting-theme.edc @@ -0,0 +1,1840 @@ +/* + * 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 "../include/email-setting-defines.h" +#include "email-setting-theme-macro.edc" + +collections { + + group { name: "dg_email_colorbar"; + parts { + part { name: "bg"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + min: 0 90; + color: 0 0 0 0; + } + } + part { name: "top1"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 0 50; + fixed: 1 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + align: 0.5 0; + } + } + part { name: "top2"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 0 10; + fixed: 1 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + align: 0.5 0; + } + } + part { name: "left"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 15 0; + fixed: 1 1; + align: 0 0; + rel1.relative: 0.0 0.0; + rel2.relative: 0.0 1.0; + } + } + part { name: "right"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 15 0; + fixed: 1 1; + align: 1 0; + rel1.relative: 1.0 0.0; + rel2.relative: 1.0 1.0; + } + } + part { + name: "chooser_left_padding"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 65 0; + fixed: 1 1; + align: 1 0; + rel1.relative: 1.0 0.0; + rel2.relative: 1.0 1.0; + } + } + part { name: "icon.colorbar"; + type: SWALLOW; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + min: 5 60; + max: 5 60; + fixed: 1 1; + align: 0.0 0.5; + rel1 { to_x: "left"; relative: 1.0 0.0; } + rel2 { to_x: "left"; relative: 1.0 1.0; } + } + } + part { name: "colorbar_right_padding"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + min: 15 0; + fixed: 1 0; + visible: 0; + align: 0 0; + rel1 { to: "icon.colorbar"; relative: 1 0; } + rel2 { to: "icon.colorbar"; relative: 1 0; } + } + } + part { name: "icon.email"; + type: SWALLOW; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + min: 50 50; + max: 50 50; + fixed: 1 1; + align: 0.0 0.5; + rel1 { to_x: "colorbar_right_padding"; relative: 1.0 0.0; } + rel2 { to_x: "colorbar_right_padding"; relative: 1.0 1.0; } + } + } + part { + name: "icon_right_padding"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + min: 15 0; + fixed: 1 0; + visible: 0; + align: 0 0; + rel1 { to: "icon.email"; relative: 1 0; } + rel2 { to: "icon.email"; relative: 1 0; } + } + } + part { name: "top.text"; + type: TEXT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + align: 0.5 0.0; + min: 1 40; + fixed: 0 1; + rel1 { + relative: 1.0 1.0; + to_x: "icon_right_padding"; + to_y: "top2"; + } + rel2 { + relative: 0.0 1.0; + to_x: "chooser_left_padding"; + to_y: "top2"; + } + color: 0 0 0 255; + text { + font: "SLP:style=Roman"; + size: 32; + min: 0 1; + align: 0.0 0.5; + } + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + part { name: "bottom.text"; + type: TEXT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + align: 0.0 0.0; + rel1 { + relative: 0.0 1.0; + to: "top.text"; + } + color: 0 0 0 255; + text { + font: "SLP:style=Medium"; + size: 24; + min: 0 1; + align: 0.0 0.5; + } + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + part { name: "color_chooser"; + type: SWALLOW; + scale: 1; + ignore_flags: ON_HOLD; + mouse_events: 1; + description { + state: "default" 0.0; + align: 1.0 0.5; + min: 40 40; + max: 40 40; + fixed: 1 1; + rel1.relative: 0.0 0.5; + rel1.to_x: "right"; + rel2.relative: 0.0 0.5; + rel2.to_x: "right"; + } + } + part { name: "over"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { to: "left"; relative: 1 0; } + rel2 { to: "chooser_left_padding"; relative: 0 1; } + color: 0 0 0 0; + } + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + } + programs { + /*program { + name: "mouse_down"; + signal: "mouse,down,1"; + source: "over"; + action: STATE_SET "pressed" 0.0; + target: "top.text"; + target: "bottom.text"; + } + program { + name: "mouse_up"; + signal: "mouse,up,1"; + source: "over"; + action: STATE_SET "default" 0.0; + target: "top.text"; + target: "bottom.text"; + }*/ + program { + name: "highlight_off"; + signal: "elm,text,highlight,off"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "over"; + } + program { + name: "highlight_on"; + signal: "elm,text,highlight,on"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "over"; + } + program { + name: "account"; + signal: "mouse,up,1"; + source: "over"; + action: SIGNAL_EMIT "email,setting,account,open" ""; + } + program { + name: "select_color"; + signal: "mouse,up,1"; + source: "color_chooser"; + action: SIGNAL_EMIT "email,setting,colorchooser" ""; + } + } + } + + group { name: "dg_email"; + images { + image: "M02_arrow_expand.png" COMP; + image: "M02_arrow_expand_press.png" COMP; + } + parts { + part { name: "bg"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + min: 0 90; + color: 0 0 0 0; + } + } + part { name: "top1"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 0 50; + fixed: 1 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + align: 0.5 0; + } + } + part { name: "top2"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 0 10; + fixed: 1 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + align: 0.5 0; + } + } + part { name: "left"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 15 0; + fixed: 1 1; + align: 0 0; + rel1.relative: 0.0 0.0; + rel2.relative: 0.0 1.0; + } + } + part { name: "right"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + visible: 0; + min: 15 0; + fixed: 1 1; + align: 1 0; + rel1.relative: 1.0 0.0; + rel2.relative: 1.0 1.0; + } + } + part { name: "icon.email"; + type: SWALLOW; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + min: 50 50; + max: 50 50; + fixed: 1 1; + align: 0.0 0.5; + rel1 { to_x: "left"; relative: 1.0 0.0; } + rel2 { to_x: "left"; relative: 1.0 1.0; } + } + } + part { + name: "icon_right_padding"; + type: RECT; + scale: 1; + ignore_flags: ON_HOLD; + description { + min: 15 0; + fixed: 1 0; + visible: 0; + align: 0 0; + rel1 { to: "icon.email"; relative: 1 0; } + rel2 { to: "icon.email"; relative: 1 0; } + } + } + part { name: "top.text"; + type: TEXT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + align: 0.5 0.0; + min: 1 40; + fixed: 0 1; + rel1 { + relative: 1.0 1.0; + to_x: "icon_right_padding"; + to_y: "top2"; + } + rel2 { + relative: 1.0 0.5; + to_x: "arrow_image"; + } + color: 0 0 0 255; + text { + font: "SLP:style=Roman"; + size: 32; + min: 0 1; + align: 0.0 0.5; + } + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + part { name: "bottom.text"; + type: TEXT; + scale: 1; + ignore_flags: ON_HOLD; + description { + state: "default" 0.0; + align: 0.0 0.0; + rel1 { + relative: 1.0 1.0; + to_x: "icon_right_padding"; + to_y: "top1"; + } + rel2 { + relative: 1.0 1.0; + to_x: "arrow_image"; + } + color: 0 0 0 255; + text { + font: "SLP:style=Medium"; + size: 24; + min: 0 1; + align: 0.0 0.5; + } + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + color: 255 255 255 255; + } + } + part { name: "arrow_image"; + type: IMAGE; + scale: 1; + description { + state: "default" 0.0; + align: 1.0 0.5; + min: 15 28; + fixed: 1 1; + rel1.relative: 0.0 0.5; + rel1.to_x: "right"; + rel2.relative: 0.0 0.5; + rel2.to_x: "right"; + image.normal: "M02_arrow_expand.png"; + } + description { + state: "pressed" 0.0; + inherit: "default" 0.0; + image.normal: "M02_arrow_expand_press.png"; + } + } + part { name: "over"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + color: 0 0 0 0; + } + description { + state: "disabled" 0.0; + inherit: "default" 0.0; + visible: 0; + } + } + } + programs { + /*program { + name: "mouse_down"; + signal: "mouse,down,1"; + source: "over"; + action: STATE_SET "pressed" 0.0; + target: "top.text"; + target: "bottom.text"; + target: "arrow_image"; + } + program { + name: "mouse_up"; + signal: "mouse,up,1"; + source: "over"; + action: STATE_SET "default" 0.0; + target: "top.text"; + target: "bottom.text"; + target: "arrow_image"; + }*/ + program { + name: "highlight_off"; + signal: "elm,text,highlight,off"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "over"; + } + program { + name: "highlight_on"; + signal: "elm,text,highlight,on"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "over"; + } + } + } + + group { + name: "color_palette"; + + parts{ + part { + name: "bg"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 249 249 249 255; + min: 720 570; + } + } + part { + name: "head_rect"; + type: RECT; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + min: 0 90; + fixed: 0 1; + rel1.relative: 0.0 0.0; + rel2.relative: 1.0 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + align: 0.0 0.0; + color: 108 143 165 255; + } + } + part { + name: "btn_cancel"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + align: 1.0 0.5; + fixed: 0 0; + rel1 { to: "head_rect"; relative: 1 0; offset: -200 10;} + rel2 { to: "head_rect"; relative: 1 1; offset: -10 -10;} + } + } + part { + name: "btn_save"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + align: 0.0 0.5; + fixed: 0 0; + rel1 { to: "head_rect"; relative: 0 0; offset: 10 10;} + rel2 { to: "head_rect"; relative: 0 1; offset: 200 -10;} + } + } + part { + name: "top_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min: 0 40; + fixed: 0 1; + rel1.relative: 0.0 1.0; + rel2.relative: 1.0 1.0; + rel1.to: "head_rect"; + rel2.to: "head_rect"; + align: 0.0 0.0; + } + } + part{ + name: "left_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min: 45 0; + fixed: 1 0; + rel1.relative: 0.0 1.0; + rel2.relative: 0.0 1.0; + rel1.to: "head_rect"; + rel2.to: "head_rect"; + align: 0.0 0.0; + } + } + part{ + name: "right_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min: 45 0; + fixed: 1 0; + rel1.relative: 1.0 1.0; + rel2.relative: 1.0 1.0; + rel1.to: "head_rect"; + rel2.to: "head_rect"; + align: 1.0 0.0; + } + } + part { + name: "color_rect"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + min: 0 174; + fixed: 0 1; + rel1.relative: 0.2 1.0; + rel1.to_y: "top_padding"; + rel1.to_x: "bg"; + rel2.relative: 0.8 1.0; + rel2.to_x: "bg"; + rel2.to_y: "top_padding"; + align: 0.0 0.0; + } + } + part { + name: "bottom_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + min: 0 40; + fixed: 0 1; + rel1.relative: 0.0 1.0; + rel1.to: "color_rect"; + rel2.relative: 1.0 1.0; + rel2.to: "color_rect"; + align: 0.0 0.0; + } + } + part { + name: "palette"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 0 1; + rel1.relative: 1.0 1.0; + rel1.to_x: "left_padding"; + rel1.to_y: "bottom_padding"; + rel2.relative: 0.0 1.0; + rel2.to_x: "right_padding"; + rel2.to_y: "bottom_padding"; + align: 0.0 0.0; + } + } + } + } + + group { + name: "email_block_noc"; + parts { + part { name: "bg"; + mouse_events: 0; + type: RECT; + scale: 1; + description { state: "default" 0.0; + visible: 1; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + min: 480 700; + } + } + part { + name: "contents"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state: "default" 0.0; + } + } + } + } + + group { name: "initial_access"; + + images { + image: "M02_email_list_icon_exchange.png" COMP; + image: "M02_email_list_icon_gmail.png" COMP; + image: "M02_email_list_icon_hotmail.png" COMP; + image: "M02_email_list_icon_AOL.png" COMP; + } + + parts { + part { + name: "top_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 440 50; + max: 440 50; + fixed: 0 1; + rel1 { relative: 0 0; } + rel2 { relative: 1 0; } + color: 0 0 0 0; + align: 0.5 0; + } + } + + part { + name: "bg_for_sp"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 440 50; + max: 440 50; + rel1 { relative: 0 1.0; to_y: "top_padding"; } + align: 0.5 0; + color: 0 0 0 0; + } + } + + part { + name: "sp1"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 50 50; + max: 50 50; + rel1 { relative: 0 0; offset: 10 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 60 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_exchange.png"; + } + } + + part { + name: "sp2"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 50 50; + max: 50 50; + rel1 { relative: 0 0; offset: 84 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 134 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_gmail.png"; + } + } + + part { + name: "sp3"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 50 50; + max: 50 50; + rel1 { relative: 0 0; offset: 158 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 208 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_hotmail.png"; + } + } + + part { + name: "sp4"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 50 50; + max: 50 50; + rel1 { relative: 0 0; offset: 232 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 282 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_AOL.png"; + } + } + + part { + name: "middle_padding2"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 440 52; + max: 440 52; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "bg_for_sp"; } + rel2 { relative: 1 1.0; to_y: "bg_for_sp"; } + color: 0 0 0 0; + } + } + + part { + name: "label"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 440 150; + max: 440 150; + rel1 { relative: 0 1.0; to_y: "middle_padding2"; } + align: 0.5 0; + } + } + + part { + name: "list"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: 0 1.0; to_y: "label"; } + } + } + } + } + + group { name: "initial_access_public"; + + images { + image: "M02_email_list_icon_gmail.png" COMP; + image: "M02_email_list_icon_hotmail.png" COMP; + image: "M02_email_list_icon_AOL.png" COMP; + } + + parts { + part { + name: "top_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 440 50; + max: 440 50; + fixed: 0 1; + rel1 { relative: 0 0; } + rel2 { relative: 1 0; } + color: 0 0 0 0; + align: 0.5 0; + } + } + + part { + name: "btn"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 440 46; + max: 440 46; + rel1 { relative: 0 1.0; to_y: "top_padding"; } + align: 0.5 0; + } + } + + part { + name: "middle_padding1"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 440 54; + max: 440 54; + fixed: 0 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "btn"; } + rel2 { relative: 1 1.0; to_y: "btn"; } + color: 0 0 0 0; + } + } + + part { + name: "bg_for_sp"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 440 50; + max: 440 50; + rel1 { relative: 0 1.0; to_y: "middle_padding1"; } + align: 0.5 0; + color: 0 0 0 0; + } + } + + part { + name: "sp1"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 50 50; + max: 50 50; + rel1 { relative: 0 0; offset: 50 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 100 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_gmail.png"; + } + } + + part { + name: "sp2"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 50 50; + max: 50 50; + rel1 { relative: 0 0; offset: 125 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 175 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_hotmail.png"; + } + } + + part { + name: "sp3"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 50 50; + max: 50 50; + rel1 { relative: 0 0; offset: 200 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 250 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_AOL.png"; + } + } + + part { + name: "middle_padding2"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 440 52; + max: 440 52; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "bg_for_sp"; } + rel2 { relative: 1 1.0; to_y: "bg_for_sp"; } + color: 0 0 0 0; + } + } + + part { + name: "label"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 620 200; + max: 620 200; + rel1 { relative: 0 1.0; to_y: "middle_padding2"; } + align: 0.5 0; + } + } + } + } + + group { name: "initial_access_hd_public"; + + images { + image: "M02_email_list_icon_gmail.png" COMP; + image: "M02_email_list_icon_hotmail.png" COMP; + image: "M02_email_list_icon_AOL.png" COMP; + } + + parts { + part { + name: "top_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 720 80; + max: 720 80; + fixed: 0 1; + rel1 { relative: 0 0; } + rel2 { relative: 1 0; } + color: 0 0 0 0; + align: 0.5 0; + } + } + + part { + name: "bg_for_sp"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 720 80; + max: 720 80; + rel1 { relative: 0 1.0; to_y: "top_padding"; } + align: 0.5 0; + color: 0 0 0 0; + } + } + + part { + name: "sp1"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 80 80; + max: 80 80; + rel1 { relative: 0 0; offset: 180 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 260 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_gmail.png"; + } + } + + part { + name: "sp2"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 80 80; + max: 80 80; + rel1 { relative: 0 0; offset: 320 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 400 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_hotmail.png"; + } + } + + part { + name: "sp3"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 80 80; + max: 80 80; + rel1 { relative: 0 0; offset: 460 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 540 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_AOL.png"; + } + } + + part { + name: "middle_padding2"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 720 50; + max: 720 50; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "bg_for_sp"; } + rel2 { relative: 1 1.0; to_y: "bg_for_sp"; } + color: 0 0 0 0; + } + } + + part { + name: "label"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 620 160; + max: 620 160; + rel1 { relative: 0 1.0; to_y: "middle_padding2"; } + align: 0.5 0; + } + } + + part { + name: "list"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: 0 1.0; to_y: "label"; } + } + } + } + } + + group { name: "initial_access_hd"; + + images { + image: "M02_email_list_icon_exchange.png" COMP; + image: "M02_email_list_icon_gmail.png" COMP; + image: "M02_email_list_icon_hotmail.png" COMP; + image: "M02_email_list_icon_AOL.png" COMP; + } + + parts { + part { + name: "top_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 720 80; + max: 720 80; + fixed: 0 1; + rel1 { relative: 0 0; } + rel2 { relative: 1 0; } + color: 0 0 0 0; + align: 0.5 0; + } + } + + part { + name: "bg_for_sp"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 720 80; + max: 720 80; + rel1 { relative: 0 1.0; to_y: "top_padding"; } + align: 0.5 0; + color: 0 0 0 0; + } + } + + part { + name: "sp1"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 80 80; + max: 80 80; + rel1 { relative: 0 0; offset: 110 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 190 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_exchange.png"; + } + } + + part { + name: "sp2"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 80 80; + max: 80 80; + rel1 { relative: 0 0; offset: 250 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 330 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_gmail.png"; + } + } + + part { + name: "sp3"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 80 80; + max: 80 80; + rel1 { relative: 0 0; offset: 390 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 470 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_hotmail.png"; + } + } + + part { + name: "sp4"; + type: IMAGE; + description { + state: "default" 0.0; + fixed: 1 1; + min: 80 80; + max: 80 80; + rel1 { relative: 0 0; offset: 530 0; to: "bg_for_sp"; } + rel2 { relative: 0 1; offset: 610 0; to: "bg_for_sp"; } + align: 0.5 0; + image.normal: "M02_email_list_icon_AOL.png"; + } + } + + part { + name: "middle_padding2"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 720 50; + max: 720 50; + fixed: 1 1; + align: 0.5 0; + rel1 { relative: 0 1.0; to_y: "bg_for_sp"; } + rel2 { relative: 1 1.0; to_y: "bg_for_sp"; } + color: 0 0 0 0; + } + } + + part { + name: "label"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + fixed: 1 1; + min: 620 160; + max: 620 160; + rel1 { relative: 0 1.0; to_y: "middle_padding2"; } + align: 0.5 0; + } + } + + part { + name: "list"; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1 { relative: 0 1.0; to_y: "label"; } + } + } + } + } + + group { name: "account_add_checkbox_set"; + parts { + + part { name: "base"; + type: RECT; + repeat_events: 1; + scale: 1; + description { state: "default" 0.0; + min: 720 168; + max: 720 168; + color: 0 0 0 0; + align: 0.0 0.5; + } + } + + part { name: "top_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 0 16; + fixed: 0 1; + visible: 0; + rel1 { to: "base"; relative: 0 0; } + rel2 { to: "base"; relative: 1 0; offset: 0 16; } + align: 0.0 0.0; + } + } + + part { name: "bottom_padding"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 0 16; + fixed: 0 1; + visible: 0; + rel1 { to: "base"; relative: 0 1; offset: 0 -16; } + rel2 { to: "base"; relative: 1 1; } + align: 0.0 0.0; + } + } + + part { name: "left_padding"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 20 0; + fixed: 1 0; + visible: 0; + rel1 { to: "base"; relative: 0 0; } + rel2 { to: "base"; relative: 0 1; offset: 20 0; } + align: 0.0 0.0; + } + } + + part { name: "right_padding"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 20 0; + fixed: 1 0; + visible: 0; + rel1 { to: "base"; relative: 1 0; offset: -20 0; } + rel2 { to: "base"; relative: 1 1; } + align: 0.0 0.0; + } + } + + part { name: "subbox.1"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 0 68; + fixed: 1 0; + visible: 0; + align: 0.0 0.5; + rel1 { + relative: 1.0 1.0; + to_x: "left_padding"; + to_y: "top_padding"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 68; + to_x: "right_padding"; + to_y: "top_padding"; + } + } + } + + part { name: "subbox.2"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 0 68; + fixed: 1 0; + visible: 0; + align: 0.0 0.5; + rel1 { + relative: 1.0 1.0; + to_x: "left_padding"; + to_y: "subbox.1"; + } + rel2 { + relative: 0.0 0.0; + to_x: "right_padding"; + to_y: "bottom_padding"; + } + } + } + + part { name: "checkbox.1"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: 42 42; + max: 42 42; + fixed: 1 1; + align: 0.0 0.5; + visible: 1; + rel1 { + relative: 1.0 0.0; + to_x: "left_padding"; + to_y: "subbox.1"; + } + rel2 { + relative: 1.0 1.0; + offset: 42 0; + to_x: "left_padding"; + to_y: "subbox.1"; + } + } + } + + part { name: "text.1"; + type: SWALLOW; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 30; + fixed: 0 1; + align: 0 0.5; + rel1 { + relative: 1.0 0.0; + offset: 16 19; + to_x: "checkbox.1"; + to_y: "subbox.1"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 -19; + to_x: "right_padding"; + to_y: "subbox.1"; + } + } + } + + part { name: "checkbox.2"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: 42 42; + max: 42 42; + fixed: 1 1; + align: 0.0 0.5; + visible: 1; + rel1 { + relative: 1.0 0.0; + to_x: "left_padding"; + to_y: "subbox.2"; + } + rel2 { + relative: 1.0 1.0; + offset: 42 0; + to_x: "left_padding"; + to_y: "subbox.2"; + } + } + } + + part { name: "text.2"; + type: SWALLOW; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 30; + fixed: 0 1; + align: 0 0.5; + rel1 { + relative: 1.0 0.0; + offset: 16 19; + to_x: "checkbox.2"; + to_y: "subbox.2"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 -19; + to_x: "right_padding"; + to_y: "subbox.2"; + } + } + } + } + } + + group { name: "account_add_manual_button"; + parts { + part { name: "base"; + type: RECT; + repeat_events: 1; + scale: 1; + description { state: "default" 0.0; + min: 720 161; + max: 720 161; + color: 0 0 0 0; + align: 0.0 0.5; + } + } + + part { name: "top_padding"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 0 5; + fixed: 0 1; + visible: 0; + rel1 { to: "base"; relative: 0 0; } + rel2 { to: "base"; relative: 1 0; offset: 0 5; } + align: 0.0 0.0; + } + } + + part { name: "bottom_padding"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 0 16; + fixed: 0 1; + visible: 0; + rel1 { to: "base"; relative: 0 1; offset: 0 -16; } + rel2 { to: "base"; relative: 1 1; } + align: 0.0 0.0; + } + } + + part { name: "left_padding"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 78 0; + fixed: 1 0; + visible: 0; + rel1 { to: "base"; relative: 0 0; } + rel2 { to: "base"; relative: 0 1; offset: 78 0; } + align: 0.0 0.0; + } + } + + part { name: "right_padding"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: 78 0; + fixed: 1 0; + visible: 0; + rel1 { to: "base"; relative: 1 0; offset: -78 0; } + rel2 { to: "base"; relative: 1 1; } + align: 0.0 0.0; + } + } + + part { name: "text"; + type: SWALLOW; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + min: 0 30; + fixed: 0 1; + align: 0 0.5; + rel1 { + relative: 1.0 1.0; + offset: 0 19; + to_x: "left_padding"; + to_y: "top_padding"; + } + rel2 { + relative: 0.0 1.0; + offset: 0 49; + to_x: "right_padding"; + to_y: "top_padding"; + } + } + } + + part { name: "btn"; + type: SWALLOW; + mouse_events: 1; + scale: 1; + description { state: "default" 0.0; + min: 0 72; + fixed: 0 1; + align: 0 0; + rel1 { + relative: 1.0 1.0; + offset: 0 19; + to_x: "left_padding"; + to_y: "text"; + } + rel2 { + relative: 0.0 0.0; + to_x: "right_padding"; + to_y: "bottom_padding"; + } + } + } + } + } + + group { name: "account_add"; + parts { + + part { name: "list"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + align: 0 0; + rel1 { relative: 0 0; } + rel2 { relative: 1 0; offset: 0 295; } + } + } + + part { name: "checkbox_set"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: 720 168; + max: 720 168; + align: 0 0; + rel1 { relative: 0 1.0; to_y: "list"; } + rel2 { relative: 1 1.0; offset: 0 168; to_y: "list"; } + } + } + + part { name: "button_set"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: 720 161; + max: 720 161; + align: 0 0; + rel1 { relative: 0 1.0; to_y: "checkbox_set"; } + rel2 { relative: 1 1.0; offset: 0 161; to_y: "checkbox_set"; } + } + } + } + } + + group { name: "other_account_add"; + parts { + part { name: "bg"; + type: RECT; + repeat_events: 1; + scale: 1; + description { state: "default" 0.0; + min: 720 750; + max: 720 750; + rel1 { relative: 0.0 0.0;} + rel2 { relative: 1.0 1.0;} + color: 0 0 0 0; + align: 0.0 0.0; + } + } + + part { name: "list"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + align: 0 0; + rel1 { relative: 0 0; to: "bg"; } + rel2 { relative: 1 0; offset: 0 425; to: "bg"; } + } + } + + part { name: "checkbox_set"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: 720 168; + max: 720 168; + align: 0 0; + rel1 { relative: 0 1.0; to_y: "list"; } + rel2 { relative: 1 1.0; offset: 0 168; to_y: "list"; } + } + } + + part { name: "button_set"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: 720 161; + max: 720 161; + align: 0 0; + rel1 { relative: 0 1.0; to_y: "checkbox_set"; } + rel2 { relative: 1 1.0; offset: 0 161; to_y: "checkbox_set"; } + } + } + } + } + + group { name: "elm/genlist/item/dialogue/email.1text.1icon.2/default"; + alias: "elm/genlist/item_odd/dialogue/email.1text.1icon.2/default"; + alias: "elm/genlist/item_compress/dialogue/email.1text.1icon.2/default"; + alias: "elm/genlist/item_compress_odd/dialogue/email.1text.1icon.2/default"; + alias: "elm/layout/dialogue/email.1text.1icon.2"; + data.item: "stacking" "above"; + data.item: "selectraise" "on"; + data.item: "texts" "elm.text"; + data.item: "contents" "elm.icon"; + data.item: "flips" "elm.flip.content"; + parts { + GENLIST_PART_BASE( GENLIST_HEIGHT_113_INC ) + GENLIST_PART_BG_IMAGE + GENLIST_PART_BOTTOM_LINE + GENLIST_PART_PADDING_LEFT( GENLIST_PADDING_32_INC ) + GENLIST_PART_PADDING_RIGHT( GENLIST_PADDING_16_INC ) + GENLIST_PART_DIALOGUE_ITEM + part { name: "elm.icon"; + clip_to: "disclip"; + type: SWALLOW; + scale: 1; + description { state: "default" 0.0; + min: GENLIST_SIZE_64_INC GENLIST_SIZE_64_INC; + max: GENLIST_SIZE_64_INC GENLIST_SIZE_64_INC; + fixed: 1 1; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.left"; + } + rel2 { + relative: 1.0 1.0; + to_x: "elm.padding.left"; + } + align: 0.0 0.5; + } + GENLIST_DESCRIPTION_FLIP_ENABLED + } + + part { name: "elm.padding.icon.right"; + clip_to: "disclip"; + type: RECT; + scale: 1; + description { state: "default" 0.0; + min: GENLIST_PADDING_16_INC 0; + fixed: 1 0; + rel1 { + relative: 1.0 0.0; + to_x: "elm.icon"; + } + rel2.to_x: "elm.icon"; + align: 0.0 0.0; + visible: 0; + } + } + + part { name: "elm.text"; + clip_to: "disclip"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + rel1 { + relative: 1.0 0.0; + to_x: "elm.padding.icon.right"; + } + rel2 { + relative: 0.0 1.0; + to_x: "elm.padding.right"; + } + align: 0.0 0.0; + color: GENLIST_PART_FONT_LIST_MAIN_TEXT_UNREAD_COLOR_INC; + text { + font: "SLP:style=Roman"; + size: GENLIST_FONT_44_INC; + min: 0 1; + align: 0.0 0.5; + text_class: "list_item"; + } + } + description { state: "selected" 0.0; + inherit: "default" 0.0; + color: GENLIST_PART_TEXT_PRESS_COLOR_INC; + } + GENLIST_DESCRIPTION_INVISIBLE_SELECTED + GENLIST_DESCRIPTION_FLIP_ENABLED + } + GENLIST_PART_FLIP + GENLIST_PART_DISCLIP + } + + programs { + program { name: "go_active"; + signal: "elm,state,selected"; + source: "elm"; + action: STATE_SET "selected" 0.0; + GENLIST_PROGRAM_SCRIPT_FLIP_SELECT_1TEXT + //GENLIST_PROGRAM_AFTER_PLAY_BUTTON_PRESS + } + program { name: "go_passive"; + signal: "elm,state,unselected"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "bg_image"; + target: "elm.text"; + transition: LINEAR 0.1; + } + program { name: "go_disabled"; + signal: "elm,state,disabled"; + source: "elm"; + action: STATE_SET "disabled" 0.0; + target: "disclip"; + } + program { name: "go_enabled"; + signal: "elm,state,enabled"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "disclip"; + } + GENLIST_PROGRAM_FLIP_1TEXT_1ICON + //GENLIST_PROGRAM_PLAY_BUTTON_PRESS + } + } + + group { name: "elm/bg/base/email_default"; + parts { + part { name: "base"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + color: 210 210 210 255; + } + } + + part { name: "elm.swallow.rectangle"; + type: SWALLOW; + description { state: "default" 0.0; } + } + + part { name: "elm.swallow.background"; + type: SWALLOW; + description { state: "default" 0.0; } + } + + part { name: "elm.swallow.content"; + type: SWALLOW; + description { state: "default" 0.0; } + } + } + } +} + -- 2.7.4