summaryrefslogtreecommitdiff
path: root/email-core/email-core-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'email-core/email-core-utils.c')
-rwxr-xr-xemail-core/email-core-utils.c980
1 files changed, 656 insertions, 324 deletions
diff --git a/email-core/email-core-utils.c b/email-core/email-core-utils.c
index b942f70..001017f 100755
--- a/email-core/email-core-utils.c
+++ b/email-core/email-core-utils.c
@@ -50,13 +50,13 @@
#include <notification.h>
#include <notification_type.h>
#include <notification_internal.h>
+#include <notification_text_domain.h>
#include <badge.h>
#include <badge_internal.h>
#ifdef __FEATURE_USE_DRM_API__
#include <drm_client_types.h>
#include <drm_client.h>
#endif /* __FEATURE_USE_DRM_API__ */
-#include <feedback.h>
#include <storage.h>
#include <bundle.h>
#include <curl/curl.h>
@@ -73,20 +73,21 @@
#include "email-core-account.h"
#include "email-core-mailbox-sync.h"
#include "email-core-mime.h"
+#include "email-core-gmime.h"
#include "email-core-signal.h"
#include "email-daemon.h"
#include "email-utilities.h"
#include "email-convert.h"
#include "email-internal-types.h"
#include "email-device.h"
+#include "email-core-container.h"
#include <gio/gio.h>
#include "email-dbus-activation.h"
-#ifdef __FEATURE_DRIVING_MODE__
#include <app_control.h>
-#endif /* __FEATURE_DRIVING_MODE__ */
+#include <app_control_internal.h>
#define LED_TIMEOUT_SECS 12
#define G_DISPLAY_LENGTH 256
@@ -102,7 +103,7 @@
#define EMAIL_CH_SQUARE_BRACKET_S '['
#define EMAIL_CH_SQUARE_BRACKET_E ']'
#define EMAIL_CH_SPACE ' '
-#define EMAIL_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/noti_email.png"
+#define EMAIL_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/E-mail/noti_email.png"
#define EMAIL_NOTI_INDICATOR_ICON_PATH "/usr/apps/org.tizen.indicator/res/icons/Event/B03_Event_email.png"
#define EMAIL_NOTI_MAX_MAIL_ID 100
@@ -126,7 +127,6 @@ struct emcore_account_list_t {
#include <gmime/gmime.h>
-
INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
{
EM_DEBUG_FUNC_BEGIN("mailbox_name[%p]", mailbox_name);
@@ -150,7 +150,7 @@ INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
return NULL;
}
-
+
for (; *cursor; ++cursor)
switch (*cursor) {
case '+':
@@ -194,7 +194,7 @@ INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
}
}
else {
- result_mailbox_name = (char *)utf8_from_mutf7 ((unsigned char *)mailbox_name);
+ result_mailbox_name = (char *)utf8_from_mutf7((unsigned char *)mailbox_name);
EM_DEBUG_LOG_SEC("result_mailbox_name[%s]", result_mailbox_name);
if (result_mailbox_name == NULL)
result_mailbox_name = EM_SAFE_STRDUP(mutf7_text);
@@ -212,7 +212,7 @@ INTERNAL_FUNC char *emcore_convert_mutf7_to_utf8(char *mailbox_name)
}
/* in smtp case, path argument must be ENCODED_PATH_SMTP */
-int emcore_get_long_encoded_path_with_account_info(email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code)
+int emcore_get_long_encoded_path_with_account_info(char *multi_user_name, email_account_t *account, char *path, int delimiter, char **long_enc_path, int *err_code)
{
EM_PROFILE_BEGIN(emCorelongEncodedpath);
EM_DEBUG_FUNC_BEGIN_SEC("account[%p], path[%s], delimiter[%d], long_enc_path[%p], err_code[%p]", account, path, delimiter, long_enc_path, err_code);
@@ -247,10 +247,21 @@ int emcore_get_long_encoded_path_with_account_info(email_account_t *account, cha
/* ex:"{mai.test.com:143/imap} or {mai.test.com:143/imap/tls}my-mailbox" */
- SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d",
- account->incoming_server_address,
- account->incoming_server_port_number,
- account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap", account->account_id);
+ if (multi_user_name) {
+ SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d%s%s",
+ account->incoming_server_address,
+ account->incoming_server_port_number,
+ account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
+ account->account_id,
+ TOKEN_FOR_MULTI_USER,
+ multi_user_name);
+ } else {
+ SNPRINTF(p, long_enc_path_len, "{%s:%d/%s/user=%d",
+ account->incoming_server_address,
+ account->incoming_server_port_number,
+ account->incoming_server_type == EMAIL_SERVER_TYPE_POP3 ? "pop3" : "imap",
+ account->account_id);
+ }
if (account->incoming_server_secure_connection & 0x01) {
strncat(p, "/ssl", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
@@ -286,7 +297,16 @@ int emcore_get_long_encoded_path_with_account_info(email_account_t *account, cha
"smtp");
if (account->outgoing_server_need_authentication > 0) {
- SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d", account->account_id);
+ if (multi_user_name) {
+ SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d%s%s",
+ account->account_id,
+ TOKEN_FOR_MULTI_USER,
+ multi_user_name);
+ } else {
+ SNPRINTF(p + EM_SAFE_STRLEN(p), long_enc_path_len-(EM_SAFE_STRLEN(p)), "/user=%d",
+ account->account_id);
+ }
+
if (account->outgoing_server_need_authentication == EMAIL_AUTHENTICATION_METHOD_XOAUTH2) {
strncat(p, "/xoauth2", long_enc_path_len-(EM_SAFE_STRLEN(p)+1));
}
@@ -344,7 +364,7 @@ FINISH_OFF:
return ret;
}
-int emcore_get_long_encoded_path(int account_id, char *path, int delimiter, char **long_enc_path, int *err_code)
+int emcore_get_long_encoded_path(char *multi_user_name, int account_id, char *path, int delimiter, char **long_enc_path, int *err_code)
{
EM_PROFILE_BEGIN(emCorelongEncodedpath);
EM_DEBUG_FUNC_BEGIN("account_id[%d], delimiter[%d], long_enc_path[%p], err_code[%p]", account_id, delimiter, long_enc_path, err_code);
@@ -353,14 +373,14 @@ int emcore_get_long_encoded_path(int account_id, char *path, int delimiter, char
int error = EMAIL_ERROR_NONE;
email_account_t *ref_account = NULL;
- ref_account = emcore_get_account_reference(account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, account_id, false);
if (!ref_account) {
EM_DEBUG_EXCEPTION("emcore_get_account_reference failed [%d]", account_id);
error = EMAIL_ERROR_INVALID_ACCOUNT;
goto FINISH_OFF;
}
- if (emcore_get_long_encoded_path_with_account_info(ref_account, path, delimiter, long_enc_path, &error) == false) {
+ if (emcore_get_long_encoded_path_with_account_info(multi_user_name, ref_account, path, delimiter, long_enc_path, &error) == false) {
EM_DEBUG_EXCEPTION("emcore_get_long_encoded_path_with_account_info failed [%d]", error);
goto FINISH_OFF;
}
@@ -763,7 +783,7 @@ INTERNAL_FUNC int emcore_get_current_session(email_session_t **session)
return true;
}
-INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_type, int priority_sender, int *total_mail, int *unread_mail, int *err_code)
+INTERNAL_FUNC int emcore_get_mail_count_by_query(char *multi_user_name, int account_id, int mailbox_type, int priority_sender, int *total_mail, int *unread_mail, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("account_id : [%d], mailbox_type : [%d], priority_sender : [%d]", account_id, mailbox_type, priority_sender);
@@ -784,7 +804,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_typ
/* Get rule list */
if (priority_sender) {
- if (!emstorage_get_rule(ALL_ACCOUNT, type, 0, &rule_count, &is_completed, &rule, true, &err)) {
+ if (!emstorage_get_rule(multi_user_name, ALL_ACCOUNT, type, 0, &rule_count, &is_completed, &rule, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_rule failed");
goto FINISH_OFF;
}
@@ -892,8 +912,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_typ
filter_list[k++].list_filter_item.rule.key_value.integer_type_value = mailbox_type;
}
-
- if ((err = emstorage_write_conditional_clause_for_getting_mail_list(filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_write_conditional_clause_for_getting_mail_list(multi_user_name, filter_list, filter_count, NULL, 0, -1, -1, &conditional_clause_string)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_write_conditional_clause_for_getting_mail_list failed[%d]", err);
goto FINISH_OFF;
}
@@ -901,7 +920,7 @@ INTERNAL_FUNC int emcore_get_mail_count_by_query(int account_id, int mailbox_typ
EM_DEBUG_LOG_DEV ("conditional_clause_string[%s]", conditional_clause_string);
/* Search the mail of priority sender in DB */
- if ((err = emstorage_query_mail_count(conditional_clause_string, true, &total_count, &unread_count)) != EMAIL_ERROR_NONE) {
+ if ((err = emstorage_query_mail_count(multi_user_name, conditional_clause_string, true, &total_count, &unread_count)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emstorage_query_mail_count failed:[%d]", err);
goto FINISH_OFF;
}
@@ -930,13 +949,19 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_display_badge_count(int count)
+INTERNAL_FUNC int emcore_display_badge_count(char *multi_user_name, int count)
{
EM_DEBUG_FUNC_BEGIN();
/* Use badge API */
int err = EMAIL_ERROR_NONE;
badge_error_e badge_err = BADGE_ERROR_NONE;
bool exist;
+ void *join_zone = NULL;
+
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
if((badge_err = badge_is_existing("org.tizen.email", &exist)) != BADGE_ERROR_NONE) {
EM_DEBUG_EXCEPTION("badge_is_existing failed [%d]", badge_err);
@@ -971,6 +996,9 @@ INTERNAL_FUNC int emcore_display_badge_count(int count)
FINISH_OFF:
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_DEBUG_FUNC_END();
return err;
}
@@ -984,7 +1012,10 @@ void emcore_display_unread_in_badge(void *data)
int total_mail_count = 0;
int unseen = 0;
- if (!emcore_get_mail_count_by_query(ALL_ACCOUNT, EMAIL_MAILBOX_TYPE_INBOX, 0, &total_mail_count, &total_unread_count, &err)) {
+ if (!emcore_get_mail_count_by_query((char *)data, ALL_ACCOUNT,
+ EMAIL_MAILBOX_TYPE_INBOX, 0,
+ &total_mail_count, &total_unread_count,
+ &err)) {
EM_DEBUG_EXCEPTION("emcore_get_mail_count_by_query failed");
goto FINISH_OFF;
}
@@ -994,11 +1025,11 @@ void emcore_display_unread_in_badge(void *data)
FINISH_OFF:
if (unseen <= 0) {
- if ((err = emcore_display_badge_count(0)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_display_badge_count((char *)data, 0)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_display_badge_count failed : [%d]", err);
}
} else {
- if ((err = emcore_display_badge_count(unseen)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_display_badge_count((char *)data, unseen)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_display_badge_count failed : [%d]", err);
}
}
@@ -1018,7 +1049,7 @@ static int emcore_layout_multi_noti(notification_h noti, int unread_mail, char *
goto FINISH_OFF;
}
- noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New email", dgettext(NATIVE_EMAIL_DOMAIN,"IDS_EMAIL_TPOP_NEW_EMAIL_RECEIVED_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
+ noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "New emails", dgettext(NATIVE_EMAIL_DOMAIN,"IDS_EMAIL_MBODY_NEW_EMAILS_ABB"), NOTIFICATION_VARIABLE_TYPE_NONE);
if (noti_err != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_TITLE failed");
goto FINISH_OFF;
@@ -1156,7 +1187,9 @@ static int emcore_get_alert_type(int vibrate_status)
int email_vibe_status = 0;
int call_state = 0;
int alert_type = EMAIL_ALERT_TYPE_MUTE;
+#ifdef __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__
int voicerecoder_state = 0;
+#endif /* __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__ */
if (vconf_get_bool(VCONFKEY_SETAPPL_SOUND_STATUS_BOOL, &global_sound_status) != 0) {
EM_DEBUG_LOG("vconf_get_bool for VCONFKEY_SETAPPL_SOUND_STATUS_BOOL failed");
@@ -1171,26 +1204,28 @@ static int emcore_get_alert_type(int vibrate_status)
EM_DEBUG_LOG("global_sound_status [%d] global_vibe_status [%d]", global_sound_status, global_vibe_status);
if (global_sound_status || global_vibe_status) {
-
+#ifdef __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__
if (vconf_get_int(VCONFKEY_VOICERECORDER_STATE, &voicerecoder_state) != 0) {
EM_DEBUG_LOG("vconf_get_int for VCONFKEY_VOICERECORDER_STATE failed");
}
EM_DEBUG_LOG("voicerecoder_state [%d]", voicerecoder_state);
+#endif /* __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__ */
- if (vconf_get_int(VCONFKEY_CALL_STATE, &call_state) != 0) {
- EM_DEBUG_LOG("vconf_get_int for VCONFKEY_CALL_STATE failed");
- }
+ call_state = emcore_get_call_status();
EM_DEBUG_LOG("call_state [%d] ", call_state);
email_vibe_status = vibrate_status;
EM_DEBUG_LOG("email_vibe_status [%d] ", email_vibe_status);
-
+#ifdef __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__
if (voicerecoder_state == VCONFKEY_VOICERECORDER_RECORDING) {
alert_type = EMAIL_ALERT_TYPE_VIB;
EM_DEBUG_LOG("voice recorder is on recording...");
}
- else if (call_state > VCONFKEY_CALL_OFF && call_state < VCONFKEY_CALL_STATE_MAX) {
+/* else if (call_state > VCONFKEY_CALL_OFF && call_state < VCONFKEY_CALL_STATE_MAX) { */
+#endif /* __FEATURE_VOICERECORDER_STATUS_FOR_NOTI__ */
+
+ if (call_state > VCONFKEY_CALL_OFF && call_state < VCONFKEY_CALL_STATE_MAX) {
EM_DEBUG_LOG("Calling");
if (global_sound_status)
alert_type = EMAIL_ALERT_TYPE_MELODY;
@@ -1209,11 +1244,12 @@ static int emcore_get_alert_type(int vibrate_status)
}
FINISH_OFF:
+
EM_DEBUG_FUNC_END("alert_type [%d]", alert_type);
return alert_type;
}
-static char * emcore_get_sound_file_path(int default_ringtone_status, char *alert_ringtone_path)
+static char *emcore_get_sound_file_path(int default_ringtone_status, char *alert_ringtone_path)
{
EM_DEBUG_FUNC_BEGIN();
char *ret = NULL;
@@ -1253,7 +1289,7 @@ INTERNAL_FUNC int emcore_show_toast_popup(char *input_popup_string)
goto FINISH_OFF;
}
- ret = app_control_set_app_id(svc_handle, "com.samsung.email-tts-play");
+ ret = app_control_set_app_id(svc_handle, "org.tizen.email-tts-play");
if (ret != APP_CONTROL_ERROR_NONE) {
EM_DEBUG_LOG("app_control_set_app_id() failed! ret:[%d]", ret);
err = EMAIL_ERROR_SYSTEM_FAILURE;
@@ -1296,7 +1332,7 @@ FINISH_OFF:
#endif
-INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display)
+INTERNAL_FUNC int emcore_add_notification(char *multi_user_name, int account_id, int mail_id, int unread_mail_count, int vip_unread_mail_count, int input_play_alert_tone, int sending_error, unsigned long display)
{
EM_DEBUG_FUNC_BEGIN("account_id[%d] mail_id[%d] unread_mail_count[%d] input_play_alert_tone[%d]", account_id, mail_id, unread_mail_count, input_play_alert_tone );
int err = EMAIL_ERROR_NONE;
@@ -1317,6 +1353,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
int display_status = false;
EMAIL_ALERT_TYPE alert_type = EMAIL_ALERT_TYPE_NONE;
char *alert_tone_path = NULL;
+ void *join_zone = NULL;
/* For service bundle */
char buf[256] = {0,};
@@ -1324,7 +1361,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
app_control_h service = NULL;
bundle *b = NULL;
- if (!emstorage_get_account_by_id(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1335,7 +1372,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
/* Get the unread mail id */
- if (!emstorage_get_unread_mailid(account_id, 0, &p_mail_id, &unread_mail_count_t, &err)) {
+ if (!emstorage_get_unread_mailid(multi_user_name, account_id, 0, &p_mail_id, &unread_mail_count_t, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_unread_mailid failed [%d]", err);
goto FINISH_OFF;
}
@@ -1352,6 +1389,11 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
/* Turn display on to blink LED */
// emdevice_change_display_state(DISPLAY_STATE_ON);
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
noti = notification_load(NULL, private_id);
if(noti == NULL) {
EM_DEBUG_EXCEPTION("notification_load failed");
@@ -1392,7 +1434,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
goto FINISH_OFF;
}
- if ( (alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_MELODY) && EM_SAFE_STRLEN(alert_tone_path)) {
+ if ((alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_MELODY) && EM_SAFE_STRLEN(alert_tone_path)) {
if(strcmp(alert_tone_path, "silent") == 0) {
if ((noti_err = notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_DEFAULT, NULL)) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_sound failed [%d]", noti_err);
@@ -1409,7 +1451,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
}
- if ( alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_VIB)
+ if (alert_type == EMAIL_ALERT_TYPE_MELODY_AND_VIB || alert_type == EMAIL_ALERT_TYPE_VIB)
noti_vibe_type = NOTIFICATION_VIBRATION_TYPE_DEFAULT;
if ((noti_err = notification_set_vibration(noti, noti_vibe_type, NULL)) != NOTIFICATION_ERROR_NONE) {
@@ -1418,13 +1460,13 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
goto FINISH_OFF;
}
- if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/com.samsung.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
+ if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text_domain failed [%d]", noti_err);
err = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- if (!emstorage_get_mailbox_name_by_mailbox_type(account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
+ if (!emstorage_get_mailbox_name_by_mailbox_type(multi_user_name, account_id, EMAIL_MAILBOX_TYPE_INBOX, &mailbox_name, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mailbox_name_by_mailbox_type failed [%d]", err);
goto FINISH_OFF;
}
@@ -1438,7 +1480,7 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
if (unseen == 1) {
- if (!emstorage_get_mail_by_id(p_mail_id[0], &p_mail_data, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, p_mail_id[0], &p_mail_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1539,14 +1581,25 @@ INTERNAL_FUNC int emcore_add_notification(int account_id, int mail_id, int unrea
}
}
+#ifdef __FEATURE_DRIVING_MODE__
if (unseen) {
- err = emcore_start_driving_mode(p_mail_id[unseen - 1]);
+ err = emcore_start_driving_mode(multi_user_name, p_mail_id[unseen - 1]);
if (err != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_start_driving_mode failed : [%d]", err);
}
+#endif /* __FEATURE_DRIVING_MODE__ */
FINISH_OFF:
+ if (service)
+ app_control_destroy(service);
+
+ if (noti)
+ notification_free(noti);
+
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_SAFE_FREE(alert_tone_path);
EM_SAFE_FREE(p_mail_id); /* prevent */
@@ -1564,22 +1617,21 @@ FINISH_OFF:
EM_SAFE_FREE(mailbox_name);
- notification_free(noti);
-
- app_control_destroy(service);
#endif /* __FEATURE_NOTIFICATION_ENABLE__ */
EM_DEBUG_FUNC_END("ret [%d]", err);
return err;
}
-INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display)
+INTERNAL_FUNC int emcore_add_notification_for_send(char *multi_user_name, int account_id, int mail_id, email_action_t action, int sending_error, unsigned long display)
{
EM_DEBUG_FUNC_BEGIN("account_id: %d, mail_id: %d, action:%d", account_id, mail_id, action );
int err = EMAIL_ERROR_NONE;
-#ifdef __FEATURE_NOTIFICATION_ENABLE__
+#ifdef __FEATURE_NOTIFICATION_ENABLE__
int private_id = 0;
+ void *join_zone = NULL;
char *mailbox_name = NULL;
+ char *dgettext_string = NULL;
char vconf_private_id[MAX_PATH] = {0, };
notification_h noti = NULL;
notification_error_e noti_err = NOTIFICATION_ERROR_NONE;
@@ -1592,7 +1644,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
bundle *b = NULL;
/* get general noti status */
- if (!emstorage_get_account_by_id(account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
+ if (!emstorage_get_account_by_id(multi_user_name, account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account_tbl, true, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1608,19 +1660,24 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
}
/* Delete the previous noti */
- emcore_delete_notification_by_account(account_id, true);
+ emcore_delete_notification_by_account(multi_user_name, account_id, true);
if (g_sending_noti_handle) {
if((noti_err = notification_free(g_sending_noti_handle)) != NOTIFICATION_ERROR_NONE)
err = EMAIL_ERROR_NOTI;
g_sending_noti_handle = NULL;
}
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ goto FINISH_OFF;
+ }
+
if (action == EMAIL_ACTION_SENDING_MAIL)
noti = notification_create(NOTIFICATION_TYPE_ONGOING);
else
noti = notification_new(NOTIFICATION_TYPE_NOTI, NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE);
- if(noti == NULL) {
+ if (noti == NULL) {
EM_DEBUG_EXCEPTION("notification_new failed");
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
@@ -1632,7 +1689,7 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
goto FINISH_OFF;
}
- if (!emstorage_get_mail_by_id(mail_id, &p_mail_data, false, &err)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &p_mail_data, false, &err)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed [%d]", err);
goto FINISH_OFF;
}
@@ -1663,130 +1720,134 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
switch (action) {
case EMAIL_ACTION_SEND_MAIL :
-
+/*
setlocale(LC_MESSAGES, vconf_get_str(VCONFKEY_LANGSET));
bindtextdomain("sys_string", "/usr/share/locale");
textdomain("sys_string");
+*/
+ setlocale(LC_MESSAGES, vconf_get_str(VCONFKEY_LANGSET));
+ bindtextdomain(NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale");
+ textdomain(NATIVE_EMAIL_DOMAIN);
- if (sending_error == EMAIL_ERROR_NONE) {
- /*if ((noti_err = emcore_layout_single_noti(noti, account_tbl->account_name, 1, "IDS_COM_POP_SENT", p_mail_data->date_time, p_mail_data->subject)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_layout_single_noti failed [%d]", err);
- err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }*/
+ switch(sending_error) {
+ case EMAIL_ERROR_NONE:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_EMAIL_SENT");
+ break;
+ case EMAIL_ERROR_FLIGHT_MODE_ENABLE:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_FAILED_TO_CONNECT_TO_NETWORK");
+ break;
+ case EMAIL_ERROR_NETWORK_NOT_AVAILABLE:
+ case EMAIL_ERROR_NO_SIM_INSERTED:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_NETWORK_NOT_AVAILABLE_EMAIL_WILL_BE_SENT_WHEN_CONNECTED_TO_NETWORK");
+ break;
+ case EMAIL_ERROR_SERVER_STORAGE_FULL:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED_SERVER_STORAGE_FULL_ABB");
+ break;
+ default:
+ dgettext_string = dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED");
+ break;
+ }
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_EMAIL_SENT"))) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
+ if ((noti_err = notification_set_layout(noti,
+ NOTIFICATION_LY_NOTI_EVENT_SINGLE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_layout failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- } else {
- /*if ((noti_err = emcore_layout_single_noti(noti, account_tbl->account_name, 1, "IDS_COM_POP_SENDING_FAILED", p_mail_data->date_time, p_mail_data->subject)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_layout_single_noti failed [%d]", err);
- err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
- }*/
-
- switch(sending_error) {
- case EMAIL_ERROR_FLIGHT_MODE_ENABLE:
- EM_DEBUG_LOG("Flight mode enable");
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_FAILED_TO_CONNECT_TO_NETWORK"))) != NOTIFICATION_ERROR_NONE)
- {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- break;
+ if ((noti_err = notification_set_image(noti,
+ NOTIFICATION_IMAGE_TYPE_ICON,
+ EMAIL_NOTI_ICON_PATH)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_image failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- case EMAIL_ERROR_NETWORK_NOT_AVAILABLE:
- case EMAIL_ERROR_NO_SIM_INSERTED:
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_NETWORK_NOT_AVAILABLE_EMAIL_WILL_BE_SENT_WHEN_CONNECTED_TO_NETWORK"))) != NOTIFICATION_ERROR_NONE)
- {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- break;
- default:
- if ((noti_err = notification_status_message_post(dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED"))) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_status_message_post failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- }
- if ((noti_err = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_layout failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_TITLE,
+ p_mail_data->alias_recipient,
+ NULL,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- if ((noti_err = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, EMAIL_NOTI_ICON_PATH)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_image failed [%d]", noti_err);
+ switch (sending_error) {
+ case EMAIL_ERROR_NONE:
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_CONTENT,
+ "Email Sent",
+ dgettext_string,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
-
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "Sending failed", dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_TPOP_SENDING_FAILED"), NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ break;
+ case EMAIL_ERROR_SERVER_STORAGE_FULL:
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_CONTENT,
+ "Sending failed. Server storage full.",
+ dgettext_string,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
-
- if (p_mail_data->subject) {
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, p_mail_data->subject, NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- } else {
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "No subject", NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- }
-
- if (sending_error == EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE) {
- setlocale(LC_MESSAGES, vconf_get_str(VCONFKEY_LANGSET));
- bindtextdomain(NATIVE_EMAIL_DOMAIN, "/usr/apps/com.samsung.email/res/locale");
- textdomain(NATIVE_EMAIL_DOMAIN);
- if ((noti_err = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_INFO_1, dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_POP_THE_EMAIL_IS_TOO_LARGE"), NULL, NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_INFO_1 failed");
- err = EMAIL_ERROR_NOTI;
- goto FINISH_OFF;
- }
- }
-
- /*notification_set_execute_option(noti, NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, NULL, NULL, args);*/
-
- if ((noti_err = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ break;
+ default:
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_CONTENT,
+ "Sending failed",
+ dgettext_string,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
+ break;
+ }
- if ((noti_err = notification_insert(noti, &private_id)) != NOTIFICATION_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ if (sending_error == EMAIL_ERROR_SMTP_SEND_FAILURE_BY_OVERSIZE) {
+ if ((noti_err = notification_set_text(noti,
+ NOTIFICATION_TEXT_TYPE_INFO_1,
+ dgettext(NATIVE_EMAIL_DOMAIN, "IDS_EMAIL_POP_THE_EMAIL_IS_TOO_LARGE"),
+ NULL,
+ NOTIFICATION_VARIABLE_TYPE_NONE)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_set_text TEXT_TYPE_INFO_1 failed");
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
}
+ }
- EM_DEBUG_LOG("Private_id = [%d]", private_id);
+ if ((noti_err = notification_set_display_applist(noti,
+ NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | NOTIFICATION_DISPLAY_APP_TICKER)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
- SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
- if (vconf_set_int(vconf_private_id, private_id) != 0) {
- EM_DEBUG_EXCEPTION("vconf_set_int failed");
- err = EMAIL_ERROR_GCONF_FAILURE;
- goto FINISH_OFF;
- }
+ if ((noti_err = notification_insert(noti, &private_id)) != NOTIFICATION_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("notification_insert failed [%d]", noti_err);
+ err = EMAIL_ERROR_NOTI;
+ goto FINISH_OFF;
+ }
+
+ EM_DEBUG_LOG("Private_id = [%d]", private_id);
+
+ SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
+ if (vconf_set_int(vconf_private_id, private_id) != 0) {
+ EM_DEBUG_EXCEPTION("vconf_set_int failed");
+ err = EMAIL_ERROR_GCONF_FAILURE;
+ goto FINISH_OFF;
}
break;
case EMAIL_ACTION_SENDING_MAIL :
- if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/com.samsung.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
+ if ((noti_err = notification_set_text_domain(noti, NATIVE_EMAIL_DOMAIN, "/usr/apps/org.tizen.email/res/locale")) != NOTIFICATION_ERROR_NONE) {
EM_DEBUG_EXCEPTION("notification_set_text_domain failed [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
goto FINISH_OFF;
@@ -1834,8 +1895,8 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
EM_DEBUG_LOG("Private_id = [%d]", private_id);
SNPRINTF(vconf_private_id, sizeof(vconf_private_id), "%s/%d", VCONF_KEY_NOTI_PRIVATE_ID, account_id);
- if ((err = vconf_set_int (vconf_private_id, private_id)) != 0) {
- EM_DEBUG_EXCEPTION("vconf_set_int failed [%d]", err);
+ if (vconf_set_int (vconf_private_id, private_id) != 0) {
+ EM_DEBUG_EXCEPTION("vconf_set_int failed");
err = EMAIL_ERROR_GCONF_FAILURE;
goto FINISH_OFF;
}
@@ -1847,16 +1908,31 @@ INTERNAL_FUNC int emcore_add_notification_for_send(int account_id, int mail_id,
EM_DEBUG_EXCEPTION ("notification_free error [%d]", noti_err);
err = EMAIL_ERROR_NOTI;
}
+
break;
}
FINISH_OFF:
+ if (service)
+ app_control_destroy(service);
+
if ((action == EMAIL_ACTION_SEND_MAIL) && noti) {
- if( (noti_err = notification_free(noti)) != NOTIFICATION_ERROR_NONE)
+ if ((noti_err = notification_free(noti)) != NOTIFICATION_ERROR_NONE) {
err = EMAIL_ERROR_NOTI;
+ }
}
+ if ((action != EMAIL_ACTION_SEND_MAIL) && (err != EMAIL_ERROR_NONE)) {
+ if (noti) {
+ notification_free(noti);
+ g_sending_noti_handle = NULL;
+ }
+ }
+
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
if (p_mail_data)
emstorage_free_mail(&p_mail_data, 1, NULL);
@@ -1865,7 +1941,6 @@ FINISH_OFF:
EM_SAFE_FREE(mailbox_name);
- app_control_destroy(service);
#endif /* __FEATURE_NOTIFICATION_ENABLE__ */
EM_DEBUG_FUNC_END("ret [%d]", err);
@@ -1894,7 +1969,7 @@ INTERNAL_FUNC void emcore_update_notification_for_send(int account_id, int mail_
EM_DEBUG_FUNC_END();
}
-INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int error)
+INTERNAL_FUNC int emcore_show_user_message(char *multi_user_name, int id, email_action_t action, int error)
{
EM_DEBUG_FUNC_BEGIN("id[%d], action[%d], error[%d]", id, action, error);
@@ -1910,13 +1985,13 @@ INTERNAL_FUNC int emcore_show_user_message(int id, email_action_t action, int er
return false;
}
- if (!emstorage_get_mail_by_id(id, &mail_table_data, true, NULL)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, id, &mail_table_data, true, NULL)) {
EM_DEBUG_LOG("Mail not found");
return false;
}
EM_DEBUG_LOG ("smtp_stream : sent_end");
- if (emcore_add_notification_for_send(mail_table_data->account_id, id, action, error, display) != EMAIL_ERROR_NONE) {
+ if (emcore_add_notification_for_send(multi_user_name, mail_table_data->account_id, id, action, error, display) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_notification_set error");
goto FINISH_OFF;
}
@@ -1939,8 +2014,8 @@ int emcore_get_storage_status(void)
EM_DEBUG_FUNC_BEGIN();
int storage_status = 0, nError = 0;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
#ifdef STORAGE_STATUS
@@ -1985,7 +2060,7 @@ FINISH_OFF:
return err;
}
-int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, int *output_size)
+int emcore_calc_mail_size(char *multi_user_name, email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, int *output_size)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count[%d], output_size[%p]", input_mail_data, input_attachment_data_list, input_attachment_count, output_size);
@@ -1993,6 +2068,8 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
int mail_size = 0; /* size of the plain text body and attachments */
int err = EMAIL_ERROR_NONE;
int i = 0;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
if (!input_mail_data || (input_attachment_count && !input_attachment_data_list) || (!input_attachment_count &&input_attachment_data_list) || !output_size) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -2000,8 +2077,21 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
goto FINISH_OFF;
}
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
if (input_mail_data->file_path_plain != NULL) {
- if (stat(input_mail_data->file_path_plain, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_plain);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_plain : stat(\"%s\") failed...", input_mail_data->file_path_plain);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF;
@@ -2012,7 +2102,10 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
}
if (input_mail_data->file_path_html != NULL) {
- if (stat(input_mail_data->file_path_html, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_mail_data->file_path_html);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION_SEC("input_mail_data->file_path_html : stat(\"%s\") failed...", input_mail_data->file_path_html);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF;
@@ -2022,7 +2115,10 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
}
for(i = 0; i < input_attachment_count; i++) {
- if (stat(input_attachment_data_list[i].attachment_path, &st_buf) < 0) {
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_attachment_data_list[i].attachment_path);
+
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_attachment_data_list[i].attachment_path);
err = EMAIL_ERROR_FILE_NOT_FOUND;
goto FINISH_OFF;
@@ -2034,6 +2130,8 @@ int emcore_calc_mail_size(email_mail_data_t *input_mail_data, email_attachment_d
FINISH_OFF:
+ EM_SAFE_FREE(prefix_path);
+
EM_DEBUG_FUNC_END("mail_size [%d]", mail_size);
return err;
}
@@ -2050,8 +2148,9 @@ char *emcore_get_alias_of_mailbox(const char *mailbox_path)
gchar *mailbox = NULL, *name = NULL;
char *converted_name;
+
mailbox = g_strdup(mailbox_path);
- token_list = g_strsplit_set(mailbox, "/", -1);
+ token_list = g_strsplit_set(mailbox, "/\\", -1);
if(token_list == NULL) {
EM_DEBUG_LOG("g_strsplit_set failed.");
@@ -2139,7 +2238,7 @@ FINISH_OFF:
return err;
}
-void emcore_fill_address_information_of_mail_tbl(emstorage_mail_tbl_t *mail_data)
+void emcore_fill_address_information_of_mail_tbl(char *multi_user_name, emstorage_mail_tbl_t *mail_data)
{
EM_DEBUG_FUNC_BEGIN("mail_data [%p]", mail_data);
@@ -2154,7 +2253,7 @@ void emcore_fill_address_information_of_mail_tbl(emstorage_mail_tbl_t *mail_data
email_account_t *ref_account = NULL;
- ref_account = emcore_get_account_reference(mail_data->account_id);
+ ref_account = emcore_get_account_reference(multi_user_name, mail_data->account_id, false);
if (!ref_account) {
EM_DEBUG_LOG("emcore_get_account_reference failed [%d]", mail_data->account_id);
}
@@ -2346,7 +2445,7 @@ FINISH_OFF:
}
#ifdef __FEATURE_BODY_SEARCH__
-int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped_text, int *err_code)
+int emcore_strip_mail_body_from_file(char *multi_user_name, emstorage_mail_tbl_t *mail, char **stripped_text, int *err_code)
{
EM_DEBUG_FUNC_BEGIN("mail[%p]", mail);
@@ -2355,8 +2454,11 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
char *buf = NULL;
char *encoding_type = NULL;
char *utf8_encoded_string = NULL;
- unsigned int byte_read = 0;
- unsigned int byte_written = 0;
+ char *prefix_path = NULL;
+ char real_html_path[255] = {0};
+ char real_plain_path[255] = {0};
+ gsize byte_read = 0;
+ gsize byte_written = 0;
GError *glib_error = NULL;
FILE *fp_plain = NULL;
struct stat st_buf;
@@ -2367,23 +2469,34 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
goto FINISH_OFF;
}
- /* MAX_PREVIEW_TEXT_LENGTH */
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
/* read file to buf & strip if html text */
if (mail->file_path_html) {
char result_buffer[MAX_PREVIEW_TEXT_LENGTH] = { 0, };
+
if (mail->preview_text) {
*stripped_text = EM_SAFE_STRDUP(mail->preview_text);
ret = true;
goto FINISH_OFF;
}
+ SNPRINTF(real_html_path, sizeof(real_html_path), "%s%s", prefix_path, mail->file_path_html);
+
if ((err = em_get_encoding_type_from_file_path(mail->file_path_plain, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
goto FINISH_OFF;
}
- if ((err = emcore_strip_HTML_tag(mail->file_path_html, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_strip_HTML_tag(real_html_path, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_strip_HTML_tag failed");
goto FINISH_OFF;
}
@@ -2392,21 +2505,23 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
}
if (!buf && mail->file_path_plain) {
+ SNPRINTF(real_plain_path, sizeof(real_plain_path), "%s%s", prefix_path, mail->file_path_plain);
+
if ((err = em_get_encoding_type_from_file_path(mail->file_path_plain, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
goto FINISH_OFF;
}
memset(&st_buf, 0, sizeof(struct stat));
- if (stat(mail->file_path_plain, &st_buf) < 0) {
- EM_DEBUG_EXCEPTION_SEC("stat(\"%s\") failed...", mail->file_path_plain);
+ if (stat(real_plain_path, &st_buf) < 0) {
+ EM_DEBUG_EXCEPTION_SEC("stat(\"%s\") failed...", real_plain_path);
err = EMAIL_ERROR_INVALID_MAIL;
goto FINISH_OFF;
}
- err = em_fopen(mail->file_path_plain, "r", &fp_plain);
+ err = em_fopen(real_plain_path, "r", &fp_plain);
if (err != EMAIL_ERROR_NONE) {
- EM_DEBUG_EXCEPTION_SEC("em_fopen failed [%s]", mail->file_path_plain);
+ EM_DEBUG_EXCEPTION_SEC("em_fopen failed [%s]", real_plain_path);
goto FINISH_OFF;
}
@@ -2427,7 +2542,7 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
EM_SAFE_FREE(buf);
err = EMAIL_ERROR_NULL_VALUE;
if (ferror(fp_plain)) {
- EM_DEBUG_EXCEPTION_SEC("fread failed [%s]", mail->file_path_plain);
+ EM_DEBUG_EXCEPTION_SEC("fread failed [%s]", real_plain_path);
err = EMAIL_ERROR_SYSTEM_FAILURE;
}
goto FINISH_OFF;
@@ -2453,19 +2568,22 @@ int emcore_strip_mail_body_from_file(emstorage_mail_tbl_t *mail, char **stripped
if(utf8_encoded_string == NULL) {
if (!g_error_matches(glib_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) {
+ EM_SAFE_FREE(*stripped_text);
*stripped_text = EM_SAFE_STRDUP(buf);
goto FINISH_OFF;
}
EM_DEBUG_LOG("Extract the preview text, again");
- utf8_encoded_string = (char *)g_convert(buf, byte_read, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
+ utf8_encoded_string = (char *)g_convert(buf, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
if (utf8_encoded_string == NULL) {
+ EM_SAFE_FREE(*stripped_text);
*stripped_text = EM_SAFE_STRDUP(buf);
goto FINISH_OFF;
}
}
EM_SAFE_FREE(buf);
+ EM_SAFE_FREE(*stripped_text);
*stripped_text = EM_SAFE_STRDUP(utf8_encoded_string);
} else {
EM_SAFE_FREE(*stripped_text);
@@ -2481,6 +2599,7 @@ FINISH_OFF:
*err_code = err;
EM_SAFE_FREE(buf);
+ EM_SAFE_FREE(prefix_path);
EM_SAFE_FREE(encoding_type);
EM_SAFE_FREE(utf8_encoded_string);
@@ -2493,13 +2612,13 @@ FINISH_OFF:
#endif
-int emcore_get_preview_text_from_file(const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer)
+int emcore_get_preview_text_from_file(char *multi_user_name, const char *input_plain_path, const char *input_html_path, int input_preview_buffer_length, char **output_preview_buffer)
{
EM_DEBUG_FUNC_BEGIN("input_plain_path[%p], input_html_path[%p], input_preview_buffer_length [%d], output_preview_buffer[%p]", input_plain_path, input_html_path, input_preview_buffer_length, output_preview_buffer);
int err = EMAIL_ERROR_NONE;
- unsigned int byte_read = 0;
- unsigned int byte_written = 0;
+ gsize byte_read = 0;
+ gsize byte_written = 0;
int local_preview_buffer_length = 0;
char *local_preview_text = NULL;
char *encoding_type = NULL;
@@ -2507,6 +2626,8 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
FILE *fp_plain = NULL;
GError *glib_error = NULL;
struct stat st_buf;
+ char *prefix_path = NULL;
+ char real_file_path[255] = {0};
if (!output_preview_buffer) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_INVALID_PARAM");
@@ -2516,23 +2637,40 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
local_preview_buffer_length = input_preview_buffer_length * 2;
- if ( input_html_path ) { /*prevent 26249*/
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ err = emcore_get_container_path(multi_user_name, &prefix_path);
+ if (err != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_container_path failed :[%d]", err);
+ goto FINISH_OFF;
+ }
+ } else {
+ prefix_path = strdup("");
+ }
+
+ if (input_html_path) { /*prevent 26249*/
/* get preview text from html file */
char result_buffer[MAX_PREVIEW_TEXT_LENGTH] = { 0, };
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_html_path);
+
if( (err = em_get_encoding_type_from_file_path(input_html_path, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
goto FINISH_OFF;
}
- if ((err = emcore_strip_HTML_tag(input_html_path, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_strip_HTML_tag(real_file_path, encoding_type, result_buffer, MAX_PREVIEW_TEXT_LENGTH)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_strip_HTML_tag failed");
goto FINISH_OFF;
}
local_preview_text = EM_SAFE_STRDUP(result_buffer);
}
- if ( !local_preview_text && input_plain_path) { /*prevent 26249*/
+ if (!local_preview_text && input_plain_path) { /*prevent 26249*/
+
+ memset(real_file_path, 0x00, sizeof(real_file_path));
+ SNPRINTF(real_file_path, sizeof(real_file_path), "%s%s", prefix_path, input_plain_path);
+
/* get preview text from plain text file */
if( (err = em_get_encoding_type_from_file_path(input_plain_path, &encoding_type)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_get_encoding_type_from_file_path failed [%d]", err);
@@ -2540,13 +2678,13 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
}
memset(&st_buf, 0, sizeof(struct stat));
- if (stat(input_plain_path, &st_buf) < 0) {
+ if (stat(real_file_path, &st_buf) < 0) {
EM_DEBUG_EXCEPTION("stat(\"%s\") failed...", input_plain_path);
err = EMAIL_ERROR_INVALID_MAIL;
goto FINISH_OFF;
}
- err = em_fopen(input_plain_path, "r", &fp_plain);
+ err = em_fopen(real_file_path, "r", &fp_plain);
if (err != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("em_fopen failed [%s]", input_plain_path);
goto FINISH_OFF;
@@ -2590,7 +2728,7 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
encoding_type = EM_SAFE_STRDUP("EUC-KR");
}
- utf8_encoded_string = (char*)g_convert (local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
+ utf8_encoded_string = (char *)g_convert(local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
if(utf8_encoded_string == NULL) {
if (!g_error_matches (glib_error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE)) {
@@ -2598,7 +2736,7 @@ int emcore_get_preview_text_from_file(const char *input_plain_path, const char *
}
EM_DEBUG_LOG("Extract the preview text, again");
- utf8_encoded_string = (char *)g_convert(local_preview_text, byte_read, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
+ utf8_encoded_string = (char *)g_convert(local_preview_text, -1, "UTF-8", encoding_type, &byte_read, &byte_written, &glib_error);
if (utf8_encoded_string == NULL) {
EM_DEBUG_LOG("g_convert fail, again");
goto FINISH_OFF;
@@ -2621,6 +2759,7 @@ FINISH_OFF:
EM_SAFE_FREE(local_preview_text);
EM_SAFE_FREE(encoding_type);
+ EM_SAFE_FREE(prefix_path);
if (fp_plain != NULL)
fclose(fp_plain);
@@ -2816,41 +2955,46 @@ FINISH_OFF:
}
-INTERNAL_FUNC int reg_replace_new (char **input_source_text, char *input_old_pattern_string, char *input_new_string)
+INTERNAL_FUNC char *reg_replace_new(char *input_source_text, char *input_old_pattern_string, char *input_new_string)
{
char *replaced_str = NULL;
- int error_code = EMAIL_ERROR_NONE;
GRegex *regex = NULL;
GError *error = NULL;
- if (input_source_text == NULL || *input_source_text == NULL) {
- return EMAIL_ERROR_INVALID_PARAM;
+ if (input_source_text == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid parameter");
+ return NULL;
}
regex = g_regex_new(input_old_pattern_string, G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, &error);
-
if (!regex) {
EM_DEBUG_LOG("g_regex_new failed");
- error_code = EMAIL_ERROR_SYSTEM_FAILURE;
goto FINISH_OFF;
}
- replaced_str = g_regex_replace_literal(regex, *input_source_text, EM_SAFE_STRLEN(*input_source_text), 0, input_new_string, 0, &error);
-
- EM_SAFE_FREE(*input_source_text);
-
- *input_source_text = replaced_str;
+ replaced_str = g_regex_replace_literal(regex,
+ input_source_text,
+ strlen(input_source_text),
+ 0,
+ input_new_string,
+ 0,
+ &error);
+ if (replaced_str == NULL) {
+ EM_DEBUG_EXCEPTION("g_regex_replace_literal failed : [%s][%d]", error->message, error->code);
+ goto FINISH_OFF;
+ }
FINISH_OFF:
+
+ if (regex) g_regex_unref(regex);
- g_regex_unref(regex);
- return error_code;
+ return replaced_str;
}
#include <libxml/HTMLparser.h>
-static void emcore_get_content_string(xmlNode *input_node, char *input_result_buffer, int input_result_buffer_legnth, int *input_exit_flag)
+static void emcore_get_content_string(xmlNode *input_node, char *input_result_buffer, int input_result_buffer_length, int *input_exit_flag)
{
xmlNode *cur_node = NULL;
char *temp_content_string = NULL;
@@ -2864,41 +3008,60 @@ static void emcore_get_content_string(xmlNode *input_node, char *input_result_bu
if (cur_node->name && (strcasecmp((const char *)cur_node->name, "head") == 0 || strcasecmp((const char *)cur_node->name, "title") == 0))
continue;
+ if (cur_node->name && (strcasecmp((const char *)cur_node->name, "BR") == 0)) {
+ if (EM_SAFE_STRLEN(input_result_buffer) + 1 >= input_result_buffer_length) {
+ *input_exit_flag = 1;
+ break;
+ } else {
+ EM_SAFE_STRCAT(input_result_buffer, " ");
+ continue;
+ }
+ }
+
if (cur_node->type == XML_TEXT_NODE && cur_node->content) {
- if ((EM_SAFE_STRLEN(cur_node->content) + EM_SAFE_STRLEN(input_result_buffer)) >= input_result_buffer_legnth) {
+ if ((EM_SAFE_STRLEN(cur_node->content) + EM_SAFE_STRLEN(input_result_buffer)) >= input_result_buffer_length) {
int len1 = EM_SAFE_STRLEN(input_result_buffer);
- if (len1 >= 0 && len1 < input_result_buffer_legnth) {
- int remain_size = input_result_buffer_legnth - len1 - 2;
- char *remain_str = em_malloc(remain_size);
- if (remain_str && cur_node->content) {
- snprintf(remain_str, remain_size, "%s", (char*)(cur_node->content));
- }
+ if (len1 >= 0 && len1 < input_result_buffer_length) {
+ int remain_size = input_result_buffer_length - len1 - 2;
+ EM_DEBUG_LOG("remain_size : [%d], len1 : [%d]", remain_size, len1);
+ char *remain_str = NULL;
- if (remain_str)
- EM_SAFE_STRCAT(input_result_buffer, remain_str);
+ if (remain_size > 0)
+ remain_str = g_strndup((char *)(cur_node->content), remain_size);
- EM_SAFE_FREE(remain_str);
+ if (remain_str) {
+ char *replaced_string = NULL;
+ replaced_string = reg_replace_new(remain_str, "[ \t\r\n\v\f]+", " ");
+ EM_SAFE_STRCAT(input_result_buffer, replaced_string);
+ EM_SAFE_FREE(replaced_string);
+ free(remain_str);
+ }
}
*input_exit_flag = 1;
break;
}
+
temp_content_string = EM_SAFE_STRDUP((const char *)cur_node->content);
if (temp_content_string) {
- reg_replace_new(&temp_content_string, "[ \t\r\n\v\f]+", " ");
- EM_SAFE_STRCAT(input_result_buffer, temp_content_string);
- EM_SAFE_FREE(temp_content_string);
+ char *replaced_string = NULL;
+ replaced_string = reg_replace_new(temp_content_string, "[ \t\r\n\v\f]+", " ");
+ EM_SAFE_STRCAT(input_result_buffer, replaced_string);
+ EM_SAFE_FREE(replaced_string);
+ free(temp_content_string);
}
}
if (cur_node->children)
- emcore_get_content_string(cur_node->children, input_result_buffer, input_result_buffer_legnth, input_exit_flag);
+ emcore_get_content_string(cur_node->children, input_result_buffer, input_result_buffer_length, input_exit_flag);
if (*input_exit_flag == 1)
break;
}
+
FINISH_OFF:
+
return;
}
@@ -2925,7 +3088,6 @@ int emcore_strip_HTML_tag(const char *input_html_file_path, char *input_encoding
}
result_string = em_malloc(sizeof(char) * input_result_buffer_legnth);
-
if (result_string == NULL) {
EM_DEBUG_EXCEPTION("EMAIL_ERROR_OUT_OF_MEMORY");
err = EMAIL_ERROR_OUT_OF_MEMORY;
@@ -2954,11 +3116,11 @@ int emcore_strip_HTML_tag(const char *input_html_file_path, char *input_encoding
root_element = xmlDocGetRootElement(result_html_document);
-
emcore_get_content_string(root_element, result_string, input_result_buffer_legnth, &exit_flag);
- reg_replace_new(&result_string, "[ \t\r\n\v\f]+", " ");
- EM_SAFE_STRCPY(output_result_buffer, result_string);
- // em_trim_left(output_result_buffer);
+ char *replaced_string = reg_replace_new(result_string, "[ \t\r\n\v\f]+", " ");
+ EM_SAFE_STRCPY(output_result_buffer, replaced_string);
+ EM_SAFE_FREE(replaced_string);
+ em_trim_left(output_result_buffer);
FINISH_OFF:
if (result_html_document) {
@@ -3035,10 +3197,9 @@ int convert_app_err_to_email_err(int app_error)
return err;
}
-INTERNAL_FUNC int emcore_start_driving_mode(int mail_id)
+INTERNAL_FUNC int emcore_start_driving_mode(char *multi_user_name, int mail_id)
{
EM_DEBUG_FUNC_BEGIN();
-
int err = APP_CONTROL_ERROR_NONE;
int tts_enable = 0;
char string_mail[10] = { 0 };
@@ -3066,7 +3227,7 @@ INTERNAL_FUNC int emcore_start_driving_mode(int mail_id)
if (!tts_enable)
goto FINISH_OFF;
- if (!emstorage_get_mail_by_id(mail_id, &p_mail_data, false, NULL)) {
+ if (!emstorage_get_mail_by_id(multi_user_name, mail_id, &p_mail_data, false, NULL)) {
EM_DEBUG_EXCEPTION("emstorage_get_mail_by_id failed");
goto FINISH_OFF;
}
@@ -3113,30 +3274,30 @@ FINISH_OFF:
}
#endif /* __FEATURE_DRIVING_MODE__ */
-INTERNAL_FUNC int emcore_clear_notifications(int account_id)
+INTERNAL_FUNC int emcore_clear_notifications(char *multi_user_name, int account_id)
{
int account_count = 0, i;
emstorage_account_tbl_t *account_list;
int error_code = EMAIL_ERROR_NONE;
if (account_id == ALL_ACCOUNT) {
- if(!emstorage_get_account_list(&account_count, &account_list, true, false, &error_code)) {
+ if(!emstorage_get_account_list(multi_user_name, &account_count, &account_list, true, false, &error_code)) {
EM_DEBUG_EXCEPTION("emstorage_get_account_list failed");
goto FINISH_OFF;
}
for(i = 0; i < account_count; i++) {
- error_code = emcore_delete_notification_by_account(account_list[i].account_id, true);
+ error_code = emcore_delete_notification_by_account(multi_user_name, account_list[i].account_id, true);
if (error_code != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
}
} else {
- error_code = emcore_delete_notification_by_account(account_id, true);
+ error_code = emcore_delete_notification_by_account(multi_user_name, account_id, true);
if (error_code != EMAIL_ERROR_NONE)
EM_DEBUG_EXCEPTION("emcore_delete_notification_by_account failed");
}
- if (!emstorage_update_save_status(account_id, &error_code)) {
+ if (!emstorage_update_save_status(multi_user_name, account_id, &error_code)) {
EM_DEBUG_EXCEPTION("emstorage_update_save_status failed : [%d]", error_code);
goto FINISH_OFF;
}
@@ -3153,7 +3314,7 @@ FINISH_OFF:
#define EAS_EXECUTABLE_PATH "/usr/bin/eas-engine"
-INTERNAL_FUNC int emcore_delete_notification_by_account(int account_id, int with_noti_tray)
+INTERNAL_FUNC int emcore_delete_notification_by_account(char *multi_user_name, int account_id, int with_noti_tray)
{
EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id);
int error_code = EMAIL_ERROR_NONE;
@@ -3950,7 +4111,7 @@ static int emcore_get_next_peak_start_time(emstorage_account_tbl_t *input_accoun
if (time_info == NULL) {
EM_DEBUG_EXCEPTION("localtime failed");
err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
+ goto FINISH_OFF;
}
EM_DEBUG_LOG("input time and date: %s", asctime(time_info));
@@ -4024,7 +4185,7 @@ static int emcore_check_time_in_peak_schedule(emstorage_account_tbl_t *input_acc
if (time_info == NULL) {
EM_DEBUG_EXCEPTION("localtime failed");
err = EMAIL_ERROR_SYSTEM_FAILURE;
- goto FINISH_OFF;
+ goto FINISH_OFF;
}
EM_DEBUG_LOG("input time and date: %s", asctime(time_info));
@@ -4061,7 +4222,7 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_calc_next_time_to_sync(int input_account_id, time_t input_current_time, time_t *output_time)
+INTERNAL_FUNC int emcore_calc_next_time_to_sync(char *multi_user_name, int input_account_id, time_t input_current_time, time_t *output_time)
{
EM_DEBUG_FUNC_BEGIN("input_account_id[%d] input_current_time[%d] output_time[%p]", input_account_id, input_current_time, output_time);
int err = EMAIL_ERROR_NONE;
@@ -4071,7 +4232,7 @@ INTERNAL_FUNC int emcore_calc_next_time_to_sync(int input_account_id, time_t inp
time_t result_time = 0;
int is_time_in_peak_schedule = 0;
- emstorage_get_account_by_id(input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account, true, &err);
+ emstorage_get_account_by_id(multi_user_name, input_account_id, EMAIL_ACC_GET_OPT_DEFAULT, &account, true, &err);
if (account == NULL) {
EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed [%d]",err);
goto FINISH_OFF;
@@ -4171,14 +4332,14 @@ static int convert_contact_err_to_email_err(int contact_err)
return err;
}
-int emcore_get_mail_contact_info(email_mail_contact_info_t *contact_info, char *full_address, int *err_code)
+int emcore_get_mail_contact_info(char *multi_user_name, email_mail_contact_info_t *contact_info, char *full_address, int *err_code)
{
EM_DEBUG_FUNC_BEGIN_SEC("contact_info[%p], full_address[%s], err_code[%p]", contact_info, full_address, err_code);
int ret = false;
int err = EMAIL_ERROR_NONE;
- if (!emcore_get_mail_contact_info_with_update(contact_info, full_address, 0, &err))
+ if (!emcore_get_mail_contact_info_with_update(multi_user_name, contact_info, full_address, 0, &err))
EM_DEBUG_EXCEPTION("emcore_get_mail_contact_info_with_update failed [%d]", err);
else
ret = true;
@@ -4189,7 +4350,7 @@ int emcore_get_mail_contact_info(email_mail_contact_info_t *contact_info, char *
return ret;
}
-int emcore_search_contact_info(const char *contact_uri, int address_property_id, char *address, int favorite_property_id, bool is_favorite, int limit, contacts_record_h *contacts_record)
+int emcore_search_contact_info(char *multi_user_name, const char *contact_uri, int address_property_id, char *address, int favorite_property_id, bool is_favorite, int limit, contacts_record_h *contacts_record)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = CONTACTS_ERROR_NONE;
@@ -4198,6 +4359,15 @@ int emcore_search_contact_info(const char *contact_uri, int address_property_id,
contacts_filter_h filter = NULL;
contacts_list_h list = NULL;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if (emcore_set_join_zone(multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ goto FINISH_OFF;
+ }
+ }
+
if ((contact_err = contacts_query_create(contact_uri, &query)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_query_create failed");
goto FINISH_OFF;
@@ -4249,10 +4419,13 @@ FINISH_OFF:
if (list != NULL)
contacts_list_destroy(list, false);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
return contact_err;
}
-int emcore_search_contact_info_by_address(const char *contact_uri, int property_id, char *address, int limit, contacts_record_h *contacts_record)
+int emcore_search_contact_info_by_address(char *multi_user_name, const char *contact_uri, int property_id, char *address, int limit, contacts_record_h *contacts_record)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = CONTACTS_ERROR_NONE;
@@ -4261,6 +4434,15 @@ int emcore_search_contact_info_by_address(const char *contact_uri, int property_
contacts_filter_h filter = NULL;
contacts_list_h list = NULL;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if (emcore_set_join_zone(multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ goto FINISH_OFF;
+ }
+ }
+
if ((contact_err = contacts_query_create(contact_uri, &query)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_query_create failed");
goto FINISH_OFF;
@@ -4303,6 +4485,9 @@ FINISH_OFF:
if (list != NULL)
contacts_list_destroy(list, false);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
return contact_err;
}
@@ -4310,6 +4495,7 @@ typedef struct {
int account_id;
char *email_address;
char *subject;
+ char *multi_user_name;
time_t date_time;
email_action_t action;
} set_contacts_log_internal_t;
@@ -4326,6 +4512,7 @@ gboolean emcore_set_contacts_log_internal (void* arg)
char *subject = tmp->subject;
time_t date_time = tmp->date_time;
email_action_t action = tmp->action;
+ char *multi_user_name = tmp->multi_user_name;
int contacts_error = CONTACTS_ERROR_NONE;
int person_id = 0;
@@ -4334,12 +4521,15 @@ gboolean emcore_set_contacts_log_internal (void* arg)
contacts_record_h phone_record = NULL;
contacts_record_h person_record = NULL;
-/*
- if ((contacts_error = contacts_connect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- goto FINISH_OFF;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if (emcore_set_join_zone(multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ goto FINISH_OFF;
+ }
}
-*/
+
if ((contacts_error = contacts_record_create(_contacts_phone_log._uri, &phone_record)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_query_create failed [%d]", contacts_error);
goto FINISH_OFF;
@@ -4352,7 +4542,7 @@ gboolean emcore_set_contacts_log_internal (void* arg)
}
/* Search contact person info */
- if ((contacts_error = emcore_search_contact_info_by_address(_contacts_person_email._uri, _contacts_person_email.email, email_address, 1, &person_record)) != CONTACTS_ERROR_NONE) {
+ if ((contacts_error = emcore_search_contact_info_by_address(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, email_address, 1, &person_record)) != CONTACTS_ERROR_NONE) {
if (contacts_error != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contacts_error);
} else {
@@ -4419,12 +4609,9 @@ FINISH_OFF:
if (person_record != NULL)
contacts_record_destroy(person_record, false);
-/*
- if ((contacts_error = contacts_disconnect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- err = convert_contact_err_to_email_err(contacts_error);
- }
-*/
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_SAFE_FREE (email_address);
EM_SAFE_FREE (subject);
EM_SAFE_FREE (tmp);
@@ -4433,11 +4620,12 @@ FINISH_OFF:
return FALSE;
}
-int emcore_set_contacts_log (int account_id,
- char *email_address,
- char *subject,
- time_t date_time,
- email_action_t action)
+int emcore_set_contacts_log (char *multi_user_name,
+ int account_id,
+ char *email_address,
+ char *subject,
+ time_t date_time,
+ email_action_t action)
{
/* arg shall be destroyed in emcore_set_contacts_log_internal */
set_contacts_log_internal_t *arg = em_malloc (sizeof(set_contacts_log_internal_t));
@@ -4447,18 +4635,19 @@ int emcore_set_contacts_log (int account_id,
}
/* deep copy */
- arg->account_id = account_id;
- arg->email_address = EM_SAFE_STRDUP (email_address);
- arg->subject = EM_SAFE_STRDUP (subject);
- arg->date_time = date_time;
- arg->action = action;
+ arg->account_id = account_id;
+ arg->email_address = EM_SAFE_STRDUP (email_address);
+ arg->subject = EM_SAFE_STRDUP (subject);
+ arg->date_time = date_time;
+ arg->action = action;
+ arg->multi_user_name = EM_SAFE_STRDUP (multi_user_name);
g_main_context_invoke (NULL, emcore_set_contacts_log_internal, arg);
return EMAIL_ERROR_NONE;
}
-INTERNAL_FUNC int emcore_set_sent_contacts_log(emstorage_mail_tbl_t *input_mail_data)
+INTERNAL_FUNC int emcore_set_sent_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p]", input_mail_data);
@@ -4474,7 +4663,12 @@ INTERNAL_FUNC int emcore_set_sent_contacts_log(emstorage_mail_tbl_t *input_mail_
rfc822_parse_adrlist(&addr, address_array[i], NULL);
for (p_addr = addr ; p_addr ;p_addr = p_addr->next) {
SNPRINTF(email_address, MAX_EMAIL_ADDRESS_LENGTH, "%s@%s", addr->mailbox, addr->host);
- if ((err = emcore_set_contacts_log(input_mail_data->account_id, email_address, input_mail_data->subject, input_mail_data->date_time, EMAIL_ACTION_SEND_MAIL)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_set_contacts_log(multi_user_name,
+ input_mail_data->account_id,
+ email_address,
+ input_mail_data->subject,
+ input_mail_data->date_time,
+ EMAIL_ACTION_SEND_MAIL)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_contacts_log failed : [%d]", err);
goto FINISH_OFF;
}
@@ -4497,12 +4691,17 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_set_received_contacts_log(emstorage_mail_tbl_t *input_mail_data)
+INTERNAL_FUNC int emcore_set_received_contacts_log(char *multi_user_name, emstorage_mail_tbl_t *input_mail_data)
{
EM_DEBUG_FUNC_BEGIN("input_mail_data : [%p]", input_mail_data);
int err = EMAIL_ERROR_NONE;
- if ((err = emcore_set_contacts_log(input_mail_data->account_id, input_mail_data->email_address_sender, input_mail_data->subject, input_mail_data->date_time, EMAIL_ACTION_SYNC_HEADER)) != EMAIL_ERROR_NONE) {
+ if ((err = emcore_set_contacts_log(multi_user_name,
+ input_mail_data->account_id,
+ input_mail_data->email_address_sender,
+ input_mail_data->subject,
+ input_mail_data->date_time,
+ EMAIL_ACTION_SYNC_HEADER)) != EMAIL_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_set_contacts_log failed [%d]", err);
}
@@ -4510,45 +4709,63 @@ INTERNAL_FUNC int emcore_set_received_contacts_log(emstorage_mail_tbl_t *input_m
return err;
}
+typedef struct _contacts_delete_data
+{
+ int account_id;
+ char *multi_user_name;
+} contacts_delete_data;
+
gboolean emcore_delete_contacts_log_internal(void* arg)
{
EM_DEBUG_FUNC_BEGIN();
-
- int account_id = (int) arg; /* it is not a pointer */
+ contacts_delete_data *data = (contacts_delete_data *)arg;
int contacts_error = CONTACTS_ERROR_NONE;
-/*
- if ((contacts_error = contacts_connect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- goto FINISH_OFF;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(data->multi_user_name) > 0) {
+ if (emcore_set_join_zone(data->multi_user_name, &join_zone) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed");
+ return FALSE;
+ }
}
-*/
+
/* Delete record of the account id */
- if ((contacts_error = contacts_phone_log_delete(CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1, account_id)) != CONTACTS_ERROR_NONE) {
+ if ((contacts_error = contacts_phone_log_delete(CONTACTS_PHONE_LOG_DELETE_BY_EMAIL_EXTRA_DATA1, data->account_id)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_phone_log_delete failed [%d]", contacts_error);
}
-
/* err = convert_contact_err_to_email_err(contacts_error); */
-/*
- if ((contacts_error = contacts_disconnect_on_thread()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("Open connect service failed [%d]", contacts_error);
- err = convert_contact_err_to_email_err(contacts_error);
- }
-*/
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
+ EM_SAFE_FREE(data->multi_user_name);
+ EM_SAFE_FREE(data);
+
EM_DEBUG_FUNC_END();
return FALSE;
}
-INTERNAL_FUNC int emcore_delete_contacts_log(int account_id)
+INTERNAL_FUNC int emcore_delete_contacts_log(char *multi_user_name, int account_id)
{
- g_main_context_invoke (NULL, emcore_delete_contacts_log_internal, (void*) account_id);
+ contacts_delete_data *data = NULL;
+
+ data = (contacts_delete_data *)em_malloc(sizeof(contacts_delete_data));
+ if (data == NULL) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ return EMAIL_ERROR_OUT_OF_MEMORY;
+ }
+
+ data->account_id = account_id;
+ data->multi_user_name = EM_SAFE_STRDUP(multi_user_name);
+
+ g_main_context_invoke (NULL, emcore_delete_contacts_log_internal, (void*) data);
return EMAIL_ERROR_NONE;
}
-INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **contact_display_name)
+INTERNAL_FUNC int emcore_get_mail_display_name (char *multi_user_name, char *email_address, char **contact_display_name)
{
if (!email_address || !contact_display_name) {
EM_DEBUG_EXCEPTION ("NULL_PARAM email_address[%p] contact_display_name[%p]",
@@ -4560,8 +4777,8 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **cont
GVariant *result = NULL;
int ret = EMAIL_ERROR_NONE;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
@@ -4581,7 +4798,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **cont
result = g_dbus_proxy_call_sync (bproxy,
"GetDisplayName",
- g_variant_new ("(s)", email_address),
+ g_variant_new ("(ss)", email_address, multi_user_name),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
@@ -4589,7 +4806,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name (char *email_address, char **cont
if (!result) {
- EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'SetContactsLog' error [%s]",
+ EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'GetDisplayName' error [%s]",
gerror->message);
ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
@@ -4614,8 +4831,9 @@ FINISH_OFF:
}
-INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *email_address,
- char **contact_display_name)
+INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *multi_user_name,
+ char *email_address,
+ char **contact_display_name)
{
EM_DEBUG_FUNC_BEGIN_SEC("contact_name_value[%s], contact_display_name[%p]", email_address, contact_display_name);
@@ -4632,7 +4850,7 @@ INTERNAL_FUNC int emcore_get_mail_display_name_internal (char *email_address,
goto FINISH_OFF;
}
*/
- if ((contact_err = emcore_search_contact_info_by_address(_contacts_contact_email._uri, _contacts_contact_email.email, email_address, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_err = emcore_search_contact_info_by_address(multi_user_name, _contacts_contact_email._uri, _contacts_contact_email.email, email_address, 1, &record)) != CONTACTS_ERROR_NONE) {
if (contact_err != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contact_err);
goto FINISH_OFF;
@@ -4680,34 +4898,58 @@ FINISH_OFF:
return err;
}
-INTERNAL_FUNC int emcore_connect_contacts_service()
+INTERNAL_FUNC int emcore_connect_contacts_service(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = 0;
int err = EMAIL_ERROR_NONE;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ return err;
+ }
+ }
+
if ((contact_err = contacts_connect()) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("contacts_connect failed : [%d]", contact_err);
}
err = convert_contact_err_to_email_err(contact_err);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_DEBUG_FUNC_END();
return err;
}
-INTERNAL_FUNC int emcore_disconnect_contacts_service()
+INTERNAL_FUNC int emcore_disconnect_contacts_service(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int contact_err = 0;
int err = EMAIL_ERROR_NONE;
+ void *join_zone = NULL;
+
+ if (EM_SAFE_STRLEN(multi_user_name) > 0) {
+ if ((err = emcore_set_join_zone(multi_user_name, &join_zone)) != EMAIL_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_set_join_zone failed : [%d]", err);
+ return err;
+ }
+ }
+
if ((contact_err = contacts_disconnect()) != CONTACTS_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("contacts_connect failed : [%d]", contact_err);
+ EM_DEBUG_EXCEPTION("contacts_disconnect failed : [%d]", contact_err);
}
err = convert_contact_err_to_email_err(contact_err);
+ if (join_zone)
+ emcore_unset_join_zone(join_zone);
+
EM_DEBUG_FUNC_END();
return err;
}
@@ -4740,7 +4982,7 @@ INTERNAL_FUNC void emcore_set_blocking_mode_status(int blocking_mode)
blocking_mode_status = blocking_mode;
}
-INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blocking_status)
+INTERNAL_FUNC int emcore_check_blocking_mode (char *multi_user_name, char *sender_address, int *blocking_status)
{
if ( !sender_address || !blocking_status ) {
EM_DEBUG_EXCEPTION ("NULL_PARAM sender_address[%p] blocking_status[%p]",
@@ -4748,12 +4990,13 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blockin
return EMAIL_ERROR_INVALID_PARAM;
}
+
GError *gerror = NULL;
GVariant *result = NULL;
int ret = EMAIL_ERROR_NONE;
-#if !GLIB_CHECK_VERSION(2, 36, 0)
- g_type_init();
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
#endif
GDBusProxy* bproxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
@@ -4773,7 +5016,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blockin
result = g_dbus_proxy_call_sync (bproxy,
"CheckBlockingMode",
- g_variant_new ("(s)", sender_address),
+ g_variant_new ("(ss)", sender_address, multi_user_name),
G_DBUS_CALL_FLAGS_NONE,
-1,
NULL,
@@ -4781,7 +5024,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode (char *sender_address, int *blockin
if (!result) {
- EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'SetContactsLog' error [%s]",
+ EM_DEBUG_EXCEPTION ("g_dbus_proxy_call_sync 'CheckBlockingMode' error [%s]",
gerror->message);
ret = EMAIL_ERROR_IPC_PROTOCOL_FAILURE;
goto FINISH_OFF;
@@ -4800,7 +5043,7 @@ FINISH_OFF:
return ret;
}
-INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int *blocking_status)
+INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *multi_user_name, char *sender_address, int *blocking_status)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
@@ -4813,7 +5056,6 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
contacts_record_h record = NULL;
if (!blocking_mode_of_setting) {
-
return err;
}
@@ -4837,7 +5079,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
case ALLOWED_CONTACT_TYPE_ALL :
EM_DEBUG_LOG("allowed_contact_type is ALL");
/* Search the allowed contact type in contact DB */
- if ((contact_error = emcore_search_contact_info_by_address(_contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_error = emcore_search_contact_info_by_address(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
if (contact_error != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contact_error);
goto FINISH_OFF;
@@ -4852,7 +5094,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
break;
case ALLOWED_CONTACT_TYPE_FAVORITES :
- if ((contact_error = emcore_search_contact_info(_contacts_person_email._uri, _contacts_person_email.email, sender_address, _contacts_person_email.is_favorite, true, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_error = emcore_search_contact_info(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, _contacts_person_email.is_favorite, true, 1, &record)) != CONTACTS_ERROR_NONE) {
EM_DEBUG_EXCEPTION("emcore_search_contact_info failed : [%d]", contact_error);
goto FINISH_OFF;
}
@@ -4872,7 +5114,7 @@ INTERNAL_FUNC int emcore_check_blocking_mode_internal (char *sender_address, int
goto FINISH_OFF;
}
- if ((contact_error = emcore_search_contact_info_by_address(_contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
+ if ((contact_error = emcore_search_contact_info_by_address(multi_user_name, _contacts_person_email._uri, _contacts_person_email.email, sender_address, 1, &record)) != CONTACTS_ERROR_NONE) {
if (contact_error != CONTACTS_ERROR_NO_DATA) /* no matching record found */
EM_DEBUG_EXCEPTION("emcore_search_contact_info_by_address failed [%d]", contact_error);
goto FINISH_OFF;
@@ -4976,31 +5218,6 @@ FINISH_OFF:
return mime_entity_path;
}
-/* Feedback LED api */
-INTERNAL_FUNC void emcore_set_flash_noti()
-{
- EM_DEBUG_FUNC_BEGIN();
- int flash_error = FEEDBACK_ERROR_NONE;
-
- flash_error = feedback_initialize();
- if (flash_error != FEEDBACK_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("feedback_initialize failed : [%d]", flash_error);
- return;
- }
-
- flash_error = feedback_play_type(FEEDBACK_TYPE_LED, FEEDBACK_PATTERN_EMAIL);
- if (flash_error != FEEDBACK_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("feedback_play_type failed : [%d]", flash_error);
- }
-
- flash_error = feedback_deinitialize();
- if (flash_error != FEEDBACK_ERROR_NONE) {
- EM_DEBUG_EXCEPTION("feedback_play_type failed : [%d]", flash_error);
- }
-
- EM_DEBUG_FUNC_END();
-}
-
INTERNAL_FUNC int emcore_get_content_from_file(char *filename, char **contents, int *length)
{
EM_DEBUG_FUNC_BEGIN("filename[%s], contents[%p], length[%p]", filename, contents, length);
@@ -5152,12 +5369,12 @@ FINISH_OFF:
#ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__
-INTERNAL_FUNC int emcore_update_db_table_schema()
+INTERNAL_FUNC int emcore_update_db_table_schema(char *multi_user_name)
{
EM_DEBUG_FUNC_BEGIN();
int err = EMAIL_ERROR_NONE;
- err = emstorage_update_db_table_schema();
+ err = emstorage_update_db_table_schema(multi_user_name);
EM_DEBUG_FUNC_END("err[%d]", err);
return err;
@@ -5361,4 +5578,119 @@ FINISH_OFF:
EM_DEBUG_FUNC_END("err [%d]", err);
return err;
}
+
+/* Replace the VCONFKEY_CALL_STATE to dbus */
+#ifdef __FEATURE_DBUS_CALL_STATUS__
+
+static pthread_mutex_t call_status_mutex = PTHREAD_MUTEX_INITIALIZER;
+static int call_status = 0;
+static guint g_dbus_return_id = 0;
+GDBusConnection *call_status_connection = NULL;
+
+static void call_status_dbus_callback(GDBusConnection *connection,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int call_status_t = 0;
+ int call_type_t = 0;
+ char *phone_number_t = NULL;
+
+ if (strncasecmp(interface_name, "org.tizen.callmgr", strlen("org.tizen.callmgr")) &&
+ strncasecmp(sender_name, "CallStatus", strlen("CallStatus"))) {
+ EM_DEBUG_EXCEPTION("Invalid interface : [%s]", interface_name);
+ return;
+ }
+
+ g_variant_get(parameters, "(iis)",
+ &call_status_t,
+ &call_type_t,
+ &phone_number_t);
+
+ EM_DEBUG_LOG("Call status : [%d], Call type : [%d], Phone_number : [%s]", call_status_t, call_type_t, phone_number_t);
+
+ ENTER_CRITICAL_SECTION(call_status_mutex);
+ call_status = call_status_t;
+ LEAVE_CRITICAL_SECTION(call_status_mutex);
+
+ EM_SAFE_FREE(phone_number_t);
+
+ EM_DEBUG_FUNC_END();
+}
+
+INTERNAL_FUNC int emcore_init_dbus_call_status()
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMAIL_ERROR_NONE;
+ GError *error = NULL;
+
+ call_status_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (call_status_connection == NULL) {
+ EM_DEBUG_EXCEPTION("g_bus_get_sync failed : [%s]", error->message);
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ g_dbus_return_id = g_dbus_connection_signal_subscribe(call_status_connection,
+ NULL,
+ "org.tizen.callmgr",
+ "CallStatus",
+ "/org/tizen/callmgr",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ call_status_dbus_callback,
+ NULL,
+ NULL);
+ if (g_dbus_return_id == -1) {
+ EM_DEBUG_EXCEPTION("DBus connection failed");
+ err = EMAIL_ERROR_SYSTEM_FAILURE;
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ if (error)
+ g_error_free(error);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+INTERNAL_FUNC void emcore_shutdown_dbus_call_status()
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ if (g_dbus_return_id) {
+ g_dbus_connection_signal_unsubscribe(call_status_connection, g_dbus_return_id);
+ g_dbus_return_id = 0;
+ }
+
+ if (call_status_connection) {
+ g_object_unref(call_status_connection);
+ call_status_connection = NULL;
+ }
+
+ EM_DEBUG_FUNC_END();
+}
+
+INTERNAL_FUNC int emcore_get_call_status()
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int call_status_t = 0;
+
+ ENTER_CRITICAL_SECTION(call_status_mutex);
+ call_status_t = call_status;
+ LEAVE_CRITICAL_SECTION(call_status_mutex);
+
+ EM_DEBUG_FUNC_END();
+ return call_status_t;
+}
+
+#endif /* __FEATURE_DBUS_CALL_STATUS__ */
+
/* EOF */