diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-09-08 22:09:23 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-09-08 22:09:23 +0900 |
commit | be65e40bf1e0825e2fd36e76f21e2e0100e7129c (patch) | |
tree | ba76c4d745d161ed090ba29dd506c8a89e2888dc | |
parent | 936b87081ce4285c8825c08a7b009ab5b0559c2c (diff) | |
download | email-tizen_2.3.1.tar.gz email-tizen_2.3.1.tar.bz2 email-tizen_2.3.1.zip |
tizen 2.3.1 releasetizen_2.3.1_releasesubmit/tizen_2.3.1/20150915.075731tizen_2.3.1
-rw-r--r-- | .gitignore | 18 | ||||
-rwxr-xr-x | CMakeLists.txt | 2 | ||||
-rwxr-xr-x | LICENSE | 2 | ||||
-rw-r--r-- | TC/.gitignore | 3 | ||||
-rwxr-xr-x | TC/_export_env.sh | 8 | ||||
-rwxr-xr-x | TC/_export_target_env.sh | 7 | ||||
-rwxr-xr-x | TC/build.sh | 16 | ||||
-rwxr-xr-x | TC/clean.sh | 11 | ||||
-rw-r--r-- | TC/config | 3 | ||||
-rwxr-xr-x | TC/config.default | 2 | ||||
-rwxr-xr-x | TC/execute.sh | 17 | ||||
-rwxr-xr-x | TC/testcase/Makefile | 25 | ||||
-rwxr-xr-x | TC/testcase/tslist | 2 | ||||
-rwxr-xr-x | TC/testcase/utc_messaging_email.c | 776 | ||||
-rwxr-xr-x | TC/tet_scen | 7 | ||||
-rwxr-xr-x | TC/tetbuild.cfg | 5 | ||||
-rwxr-xr-x | TC/tetclean.cfg | 5 | ||||
-rwxr-xr-x | TC/tetexec.cfg | 5 | ||||
-rwxr-xr-x | doc/email_doc.h | 76 | ||||
-rwxr-xr-x | include/email.h | 237 | ||||
-rwxr-xr-x | include/email_error.h | 26 | ||||
-rwxr-xr-x | include/email_private.h | 2 | ||||
-rwxr-xr-x | include/email_types.h | 22 | ||||
-rwxr-xr-x | packaging/capi-messaging-email.spec | 8 | ||||
-rwxr-xr-x | src/email.c | 727 |
25 files changed, 1590 insertions, 422 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..430765c --- /dev/null +++ b/.gitignore @@ -0,0 +1,18 @@ +cmake_build_tmp/ +build-stamp +configure-stamp +capi-messaging-email.pc +debian/tmp/ +debian/substvars/ +debian/files +debian/capi-messaging-email-dbg.debhelper.log +debian/capi-messaging-email-dbg.substvars +debian/capi-messaging-email-dbg/ +debian/capi-messaging-email-dev.debhelper.log +debian/capi-messaging-email-dev.substvars +debian/capi-messaging-email-dev/ +debian/capi-messaging-email.debhelper.log +debian/capi-messaging-email.postinst.debhelper +debian/capi-messaging-email.postrm.debhelper +debian/capi-messaging-email.substvars +debian/capi-messaging-email/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d71d97..7ea16db 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,7 +10,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog glib-2.0 edbus capi-base-common email-service") +SET(dependents "dlog glib-2.0 dbus-1 capi-base-common email-service") INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) @@ -1,4 +1,4 @@ -Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
Apache License
Version 2.0, January 2004
diff --git a/TC/.gitignore b/TC/.gitignore new file mode 100644 index 0000000..6f6a5cc --- /dev/null +++ b/TC/.gitignore @@ -0,0 +1,3 @@ +results/ +testcase/tet_captured +testcase/utc_messaging_email diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..72a11ec --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target # tetware target path +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..5ddaa53 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,7 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..6be8d56 --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT
\ No newline at end of file diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config b/TC/config new file mode 100644 index 0000000..db0136b --- /dev/null +++ b/TC/config @@ -0,0 +1,3 @@ +TET_INSTALL_HOST_PATH=/home/zzervb/DTS/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/DTS/TETware + diff --git a/TC/config.default b/TC/config.default new file mode 100755 index 0000000..04684f0 --- /dev/null +++ b/TC/config.default @@ -0,0 +1,2 @@ +TET_INSTALL_HOST_PATH=/home/rookiejava/dts_tool/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/dts_tool/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..215ad6c --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +#grw -c 3 -f chtml -o $HTML_RESULT $JOURNAL_RESULT +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT + diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100755 index 0000000..977b55b --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,25 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-messaging-email dlog glib-2.0 + +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +#TARGETS = $(C_FILES:%.c=tc-%) +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100755 index 0000000..4cdf235 --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,2 @@ +/testcase/utc_messaging_email + diff --git a/TC/testcase/utc_messaging_email.c b/TC/testcase/utc_messaging_email.c new file mode 100755 index 0000000..e0e610e --- /dev/null +++ b/TC/testcase/utc_messaging_email.c @@ -0,0 +1,776 @@ +#include <tet_api.h> +#include <messaging/email.h> +#include <stdlib.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_messaging_email_create_message_p(void); +//static void utc_messaging_email_create_message_n(void); +static void utc_messaging_email_destroy_message_p(void); +static void utc_messaging_email_destroy_message_n(void); +static void utc_messaging_email_set_subject_p(void); +static void utc_messaging_email_set_subject_n(void); +static void utc_messaging_email_set_body_p(void); +static void utc_messaging_email_set_body_n(void); +//static void utc_messaging_email_get_body_p(void); +//static void utc_messaging_email_get_body_n(void); +static void utc_messaging_email_add_recipient_p(void); +static void utc_messaging_email_add_recipient_n(void); +static void utc_messaging_email_remove_all_recipients_p(void); +static void utc_messaging_email_remove_all_recipients_n(void); +static void utc_messaging_email_add_attach_p(void); +static void utc_messaging_email_add_attach_n(void); +static void utc_messaging_email_remove_all_attachment_p(void); +static void utc_messaging_email_remove_all_attachment_n(void); +static void utc_messaging_email_send_message_p(void); +static void utc_messaging_email_send_message_n(void); +static void utc_messaging_email_set_message_sent_cb(void); +static void utc_messaging_email_set_message_sent_cb_n(void); +static void utc_messaging_email_unset_message_sent_cb(void); +static void utc_messaging_email_unset_message_sent_cb_n(void); + + + +enum { + POSITIVE_TC_IDX = 0x01, + NEGATIVE_TC_IDX, +}; + +struct tet_testlist tet_testlist[] = { + + { utc_messaging_email_create_message_p, POSITIVE_TC_IDX }, + //{ utc_messaging_email_create_message_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_destroy_message_p, POSITIVE_TC_IDX }, + { utc_messaging_email_destroy_message_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_set_subject_p, POSITIVE_TC_IDX }, + { utc_messaging_email_set_subject_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_set_body_p, POSITIVE_TC_IDX }, + { utc_messaging_email_set_body_n, NEGATIVE_TC_IDX }, + //{ utc_messaging_email_get_body_p, POSITIVE_TC_IDX }, + //{ utc_messaging_email_get_body_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_add_recipient_p, POSITIVE_TC_IDX }, + { utc_messaging_email_add_recipient_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_remove_all_recipients_p, POSITIVE_TC_IDX }, + { utc_messaging_email_remove_all_recipients_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_add_attach_p, POSITIVE_TC_IDX }, + { utc_messaging_email_add_attach_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_remove_all_attachment_p, POSITIVE_TC_IDX }, + { utc_messaging_email_remove_all_attachment_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_send_message_p, POSITIVE_TC_IDX }, + { utc_messaging_email_send_message_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_set_message_sent_cb, POSITIVE_TC_IDX }, + { utc_messaging_email_set_message_sent_cb_n, NEGATIVE_TC_IDX }, + { utc_messaging_email_unset_message_sent_cb, POSITIVE_TC_IDX }, + { utc_messaging_email_unset_message_sent_cb_n, NEGATIVE_TC_IDX }, + + + { NULL, 0 }, +}; + + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); +} + + +/** + * @brief Positive test case of utc_messaging_email_create_message_p() + */ +static void utc_messaging_email_create_message_p(void) +{ + int ret = EMAIL_ERROR_NONE; + + email_h msg; + // Invalid parameter test + ret = email_create_message(&msg); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_create_message"); + } + else { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } +} + + +/** + * @brief Positive test case of utc_messaging_email_destroy_message_p() + */ +static void utc_messaging_email_destroy_message_p(void) +{ + int ret = EMAIL_ERROR_NONE; + + email_h msg; + // Invalid parameter test + ret = email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + + ret=email_destroy_message(msg); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_destroy_message"); + } + else { + dts_message("email_destroy_message", "email_destroy_message ret : %d", ret); + dts_fail("email_destroy_message"); + } +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_destroy_message_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + + + ret=email_destroy_message(NULL); + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_destroy_message"); + } + else { + dts_message("email_destroy_message", "email_destroy_message ret : %d", ret); + dts_fail("email_destroy_message"); + } + +} + +/** + * @brief Positive test case of telephony_get_cell_id() + */ +static void utc_messaging_email_set_subject_p(void) +{ + int ret = EMAIL_ERROR_NONE; + + email_h msg; + // Invalid parameter test + ret = email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_set_subject(msg,"titel: First email!!!"); + + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_set_subject"); + } + else { + dts_message("email_set_subject", "email_set_subject ret : %d", ret); + dts_fail("email_set_subject"); + } + +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_set_subject_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + + ret=email_set_subject(NULL,"titel: First email!!!"); + + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_set_subject"); + } + else { + dts_message("email_set_subject", "email_set_subject ret : %d", ret); + dts_fail("email_set_subject"); + } + +} + +/** + * @brief Positive test case of telephony_get_cell_id() + */ +static void utc_messaging_email_set_body_p(void) +{ + int ret = EMAIL_ERROR_NONE; + + email_h msg; + // Invalid parameter test + ret = email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_set_body(msg,"First SMS message!!!"); + + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_set_body"); + } + else { + dts_message("email_set_body", "email_set_body ret : %d", ret); + dts_fail("email_set_body"); + } + +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_set_body_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + + ret=email_set_body(NULL,"First SMS message!!!"); + + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_set_body"); + } + else { + dts_message("email_set_body", "email_set_body ret : %d", ret); + dts_fail("email_set_body"); + } + +} +#if 0 +/** + * @brief Positive test case of telephony_get_cell_id() + */ +static void utc_messaging_email_get_body_p(void) +{ + int ret = EMAIL_ERROR_NONE; + email_h msg; + const char *str; + + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_set_body(msg,"First SMS message!!!"); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_set_body", "email_set_body ret : %d", ret); + dts_fail("email_set_body"); + } + + ret=email_get_body(msg,str); + + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_get_body"); + } + else { + dts_message("email_get_body", "email_get_body ret : %d", ret); + dts_fail("email_get_body"); + } + + +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_get_body_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + const char *str; + ret=email_get_body(NULL,str); + + + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_get_body"); + } + else { + dts_message("email_get_body", "email_get_body ret : %d", ret); + dts_fail("email_get_body"); + } + +} + +#endif + +/** + * @brief Positive test case of telephony_get_cell_id() + */ +static void utc_messaging_email_add_recipient_p(void) +{ + + int ret = EMAIL_ERROR_NONE; + email_h msg; + + + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + ret=email_add_recipient(msg,EMAIL_RECIPIENT_TYPE_TO,"qqaappp@gmail.com"); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_add_recipien"); + } + else { + dts_message("email_add_recipien", "email_add_recipien ret : %d", ret); + dts_fail("email_add_recipien"); + } +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_add_recipient_n(void) +{ + + email_h msg; + int ret = EMAIL_ERROR_NONE; + ret=email_add_recipient(msg,EMAIL_RECIPIENT_TYPE_TO,"qqaappp@gmail.com"); + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_add_recipien"); + } + else { + dts_message("email_add_recipien", "email_add_recipien ret : %d", ret); + dts_fail("email_add_recipien"); + } + + +} + +/** + * @brief Positive test case of telephony_get_cell_id() + */ + //TODO: need to do multiple test +static void utc_messaging_email_remove_all_recipients_p(void) +{ + int ret = EMAIL_ERROR_NONE; + + email_h msg; + + + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + ret=email_add_recipient(msg,EMAIL_RECIPIENT_TYPE_TO,"qqaappp@gmail.com"); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_add_recipien", "email_add_recipien ret : %d", ret); + dts_fail("email_add_recipien"); + } + + ret=email_remove_all_recipients(msg); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_remove_all_recipients"); + } + else { + dts_message("email_remove_all_recipients", "email_remove_all_recipients ret : %d", ret); + dts_fail("email_remove_all_recipients"); + } + +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_remove_all_recipients_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + + ret=email_remove_all_recipients(NULL); + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_remove_all_recipients"); + } + else { + dts_message("email_remove_all_recipients", "email_remove_all_recipients ret : %d", ret); + dts_fail("email_remove_all_recipients"); + } + + +} + + +/** + * @brief Positive test case of telephony_get_cell_id() + */ + //TODO: need to do multiple test +static void utc_messaging_email_add_attach_p(void) +{ + int ret = EMAIL_ERROR_NONE; + + email_h msg; + + FILE* file = NULL; + + + file= fopen("/tmp/emaildtstest_.txt", "w"); + if(file ==NULL) + { + dts_message("email_add_attach", "temporary file for test(/tmp/emaildtstest_.txt) is not created"); + dts_fail("email_add_attach"); + } + else + { + fclose(file); + } + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_add_attach(msg,"/tmp/emaildtstest_.txt"); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_add_attach"); + } + else { + dts_message("email_add_attach", "email_add_attach ret : %d", ret); + dts_fail("email_add_attach"); + } + +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_add_attach_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + + ret=email_add_attach(NULL,NULL); + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_add_attach"); + } + else { + dts_message("email_add_attach", "email_add_attach ret : %d", ret); + dts_fail("email_add_attach"); + } + + +} + +/** + * @brief Positive test case of telephony_get_cell_id() + */ + //TODO: need to do multiple test +static void utc_messaging_email_remove_all_attachment_p(void) +{ + int ret = EMAIL_ERROR_NONE; + + email_h msg; + + FILE* file = NULL; + + + file= fopen("/tmp/emaildtstest_.txt", "w"); + if(file ==NULL) + { + dts_message("email_add_attach", "temporary file for test(/tmp/emaildtstest_.txt) is not created"); + dts_fail("email_add_attach"); + } + else + { + fclose(file); + } + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_add_attach(msg,"/tmp/emaildtstest_.txt"); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_add_attach", "email_add_attach ret : %d", ret); + dts_fail("email_add_attach"); + } + + ret=email_remove_all_attachments(msg); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_remove_all_attachment"); + } + else { + dts_message("email_remove_all_attachment", "email_remove_all_attachment ret : %d", ret); + dts_fail("email_remove_all_attachment"); + } + +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_remove_all_attachment_n(void) +{ + + email_h msg; + int ret = EMAIL_ERROR_NONE; + + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_remove_all_attachments(msg); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_remove_all_attachment"); + } + else { + dts_message("email_remove_all_attachment", "email_remove_all_attachment ret : %d", ret); + dts_fail("email_remove_all_attachment"); + } + + +} +/** + * @brief Positive test case of telephony_get_cell_id() + */ +static void utc_messaging_email_send_message_p(void) +{ + int ret = EMAIL_ERROR_NONE; + email_h msg; + + + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + ret=email_add_recipient(msg,EMAIL_RECIPIENT_TYPE_TO,"qqaappp@gmail.com"); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_add_recipient", "email_add_recipient ret : %d", ret); + dts_fail("email_add_recipient"); + } + + ret=email_set_body(msg,"First SMS message!!!"); + + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_set_body"); + } + else { + dts_message("email_set_body", "email_set_body ret : %d", ret); + dts_fail("email_set_body"); + } + + + ret=email_send_message(msg, false); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_send_message"); + } + else { + dts_message("email_send_message", "email_send_message ret : %d", ret); + dts_fail("email_send_message"); + } + +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ + //TODO: add the case where one of what shold be set is missing + // for example, recipient ,attachment or body is not set. +static void utc_messaging_email_send_message_n(void) +{ + int ret = EMAIL_ERROR_NONE; + + ret=email_send_message(NULL, false); + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_send_message"); + } + else { + dts_message("email_send_message", "email_send_message ret : %d", ret); + dts_fail("email_send_message"); + } + +} + +/** + * @brief Positive test case of telephony_get_cell_id() + */ + +void email_cb(email_h handle, email_sending_e result, void *user_data) +{ + printf("CALLBACK EXECUTED\n"); + printf("transport status = %d\n", result); + + +} +static void utc_messaging_email_set_message_sent_cb(void) +{ + int ret = EMAIL_ERROR_NONE; + email_h msg; + + + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_set_message_sent_cb(msg,email_cb,NULL); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_set_message_sent_cb"); + } + else { + dts_message("email_set_message_sent_cb", "email_set_message_sent_cb ret : %d", ret); + dts_fail("email_set_message_sent_cb"); + } +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_set_message_sent_cb_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + + ret=email_set_message_sent_cb(NULL,NULL,NULL); + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_set_message_sent_cb"); + } + else { + dts_message("email_set_message_sent_cb", "email_set_message_sent_cb ret : %d", ret); + dts_fail("email_set_message_sent_cb"); + } + +} + +/** + * @brief Positive test case of telephony_get_cell_id() + */ +static void utc_messaging_email_unset_message_sent_cb(void) +{ + int ret = EMAIL_ERROR_NONE; + email_h msg; + + + ret =email_create_message(&msg); + + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_create_message", "email_create_message ret : %d", ret); + dts_fail("email_create_message"); + } + + ret=email_set_message_sent_cb(msg,email_cb,NULL); + if(ret != EMAIL_ERROR_NONE) + { + dts_message("email_set_message_sent_cb", "email_set_message_sent_cb ret : %d", ret); + dts_fail("email_set_message_sent_cb"); + } + + ret=email_unset_message_sent_cb(msg ); + + if(ret == EMAIL_ERROR_NONE) { + dts_pass("email_set_message_sent_cb"); + } + else { + dts_message("email_unset_message_sent_cb", "email_unset_message_sent_cb ret : %d", ret); + dts_fail("email_unset_message_sent_cb"); + } +} + + +/** + * @brief Negative test case of telephony_get_cell_id() + */ +static void utc_messaging_email_unset_message_sent_cb_n(void) +{ + + + int ret = EMAIL_ERROR_NONE; + ret=email_unset_message_sent_cb(NULL ); + + if(ret == EMAIL_ERROR_INVALID_PARAMETER) { + dts_pass("email_unset_message_sent_cb"); + } + else { + dts_message("email_unset_message_sent_cb", "email_unset_message_sent_cb ret : %d", ret); + dts_fail("email_unset_message_sent_cb"); + } + + +} + diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100755 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100755 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option for build operation checking +TET_BUILD_TOOL=make # build with using make command +TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build +TET_API_COMPLIANT=True # use TET API in Test Case ? +TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100755 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option +TET_CLEAN_TOOL= make clean # clean tool +TET_CLEAN_FILE= Makefile # file for clean +TET_API_COMPLIANT=True # TET API useage +TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100755 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capturing execution or not +TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional +TET_EXEC_FILE= # ex) exectool : execution file/ Optional +TET_API_COMPLIANT=True # Test case or Tool usesTET API? +TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/doc/email_doc.h b/doc/email_doc.h new file mode 100755 index 0000000..03c071e --- /dev/null +++ b/doc/email_doc.h @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.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.apache.org/licenses/LICENSE-2.0 + * + * 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 __TIZEN_EMAIL_DOC_H__ +#define __TIZEN_EMAIL_DOC_H__ + +/** + * @defgroup CAPI_MESSAGING_EMAIL_MODULE Email + * @brief The Email API provides functions to create, set properties and send email. + * @ingroup CAPI_MESSAGING_FRAMEWORK + * + * @addtogroup CAPI_MESSAGING_EMAIL_MODULE + * + * @section CAPI_MESSAGING_EMAIL_MODULE_HEADER Required Header + * \#include <email.h> + * + * + * @section CAPI_MESSAGING_EMAIL_MODULE_OVERVIEW Overview + * + * The @ref CAPI_MESSAGING_EMAIL_MODULE API provides functions that prepare and send email messages. + * This API allows email message creation, setting message properties + * and sending as well setting up to be notified when the email message has been sent. + * + * + * Email, short for electronic mail, is a method of exchanging digital messages. + * This API allows you to send email using SMTP. + * Simple Mail Transfer Protocol (SMTP) used for sending email via Internet is described in RFC5321/5322 standards. + * + * The Email API consists of functions that: + * - Set the subject, body and recipients of an email message + * - Set the file path for attaching files to an email message + * - Send an email message + * - Register/unregister a callback function to be called when the sending process is complete, + * whether it is sent successfully or not + * + * Email sending is asynchronous and the application should not wait for the result. + * Not only may the process be slow (connections to be established and so on), + * but even if the mail server is not available a message send may not be a failure, if there is a spooling mechanism. + * Instead, the callback function is used to receive status. In addition, note that once email_send_message() is called, + * the message contents are out of the application's hands. + * Even if the message appears not to have finished sending, it can no longer be modified. + * + * @subsection CAPI_MESSAGING_EMAIL_CALLBACK_OPERATIONS Callback(Event) Operations + * <div><table class="doxtable" > + * <tr> + * <th><b>REGISTER</b></th> + * <th><b>UNREGISTER</b></th> + * <th><b>CALLBACK</b></th> + * <th><b>DESCRIPTION</b></th> + * </tr> + * <tr> + * <td>email_set_message_sent_cb()</td> + * <td>email_unset_message_sent_cb()</td> + * <td>email_message_sent_cb()</td> + * <td>Registering/unregistering a callback function to check whether an email message is sent successfully or not </td> + * </tr> + *</table></div> + * <BR> + */ + + +#endif /* __TIZEN_EMAIL_DOC_H__ */ diff --git a/include/email.h b/include/email.h index 96d35a3..fa6164d 100755 --- a/include/email.h +++ b/include/email.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -24,7 +24,7 @@ /** * @file email.h - * @ingroup CAPI_MESSAGING_FRAMEWORK + * @ingroup CAPI_MESSAGING_EMAIL_MODULE * @brief Messaging API file, support for sending email messages. */ @@ -40,15 +40,22 @@ extern "C" /** * @brief Creates an email message handle for sending an email message. + * @since_tizen 2.3 + * @privlevel public + * @privilege %http://tizen.org/privilege/email * - * @remarks a email must be released with email_destroy_message() by you. + * @remarks You must release @a email using email_destroy_message(). * - * @param[out] email A handle to the email message + * @param[out] email A handle to the email message * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory - * @retval #EMAIL_ERROR_ACCOUNT_NOT_FOUND Email account not found + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #EMAILS_ERROR_ACCOUNT_NOT_FOUND Email account not found + * + * @pre At least one email account should be set up on the device. * * @see email_destroy_message() */ @@ -56,13 +63,16 @@ int email_create_message(email_h *email); /** * @brief Destroys the email message handle and releases all its resources. + * @since_tizen 2.3 + * + * @param[in] email The handle to the email message * - * @param[in] email The handle to the email message + * @return @c 0 on success, + * otherwise a negative error value * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #EMAIL_ERROR_OPERATION_FAILED Operation failed + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EMAILS_ERROR_OPERATION_FAILED Operation failed * * @see email_create_message() */ @@ -70,15 +80,21 @@ int email_destroy_message(email_h email); /** * @brief Sets a subject of the email message. + * @since_tizen 2.3 + * + * @param[in] email The handle to the email message + * @param[in] subject The subject of the email message + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory * - * @param[in] email The handle to the email message - * @param[in] subject The subject of the email message - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory + * @pre An email message handle is created using email_create_message(). * - * @see email_create_message() + * @see email_create_message() */ int email_set_subject(email_h email, const char *subject); @@ -86,14 +102,21 @@ int email_set_subject(email_h email, const char *subject); * @brief Populates a body of the email message. * @details Email message body means the text data to be delivered. * - * @param[in] email The handle to the email message + * @since_tizen 2.3 + * + * @param[in] email The handle to the email message * @param[in] body The message body - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval # EMAIL_ERROR_OPERATION_FAILED Operation failed - * @pre An email message handle is created using #email_create_message(). - * @see email_create_message() + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EMAILS_ERROR_OPERATION_FAILED Operation failed + * + * @pre An email message handle is created using email_create_message(). + * + * @see email_create_message() */ int email_set_body(email_h email, const char *body); @@ -101,17 +124,23 @@ int email_set_body(email_h email, const char *body); * @brief Adds a recipient to the email message. * @details The email API supports sending an email message to multiple recipients. * + * @since_tizen 2.3 + * * @remarks Email address should be in standard format (as described in - * Internet standards RFC 5321 and RFC 5322).\n + * Internet standards RFC 5321 and RFC 5322). * - * @param[in] email The handle to the email message + * @param[in] email The handle to the email message * @param[in] type The recipient type * @param[in] address The recipient email address * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory + * + * @pre An email message handle is created using email_create_message(). * * @see email_create_message() * @see email_remove_all_recipients() @@ -120,12 +149,17 @@ int email_add_recipient(email_h email, email_recipient_type_e type, const char * /** * @brief Removes all recipients for the email message. + * @since_tizen 2.3 + * + * @param[in] email The handle to the email message * - * @param[in] email The handle to the email message + * @return @c 0 on success, + * otherwise a negative error value * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre An email message handle is created using email_create_message(). * * @see email_add_recipient() */ @@ -134,17 +168,23 @@ int email_remove_all_recipients(email_h email); /** * @brief Adds a file as an attachment to the email message. * @details It should be used to add a file to the attachment list - * of the email message. + * of the email message. + * + * @since_tizen 2.3 * * @remarks The maximum attachment file size is 10MB. * - * @param[in] email The handle to the email message + * @param[in] email The handle to the email message * @param[in] filepath The absolute full path of the file to be attached * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #EMAIL_ERROR_OUT_OF_MEMORY Out of memory + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #EMAILS_ERROR_OUT_OF_MEMORY Out of memory + * + * @pre An email message handle is created using email_create_message(). * * @see email_remove_all_attachments() * @@ -153,12 +193,17 @@ int email_add_attach(email_h email, const char *filepath); /** * @brief Clears all attachments of the email message. + * @since_tizen 2.3 + * + * @param[in] email The handle to the email message + * + * @return @c 0 on success, + * otherwise a negative error value * - * @param[in] email The handle to the email message + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter + * @pre An email message handle is created using email_create_message(). * * @see email_create_message() * @see email_add_attach() @@ -166,21 +211,58 @@ int email_add_attach(email_h email, const char *filepath); int email_remove_all_attachments(email_h email); /** - * @brief Sends the email message. + * @brief Saves the email message at outbox. + * @since_tizen 2.3 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/email * - * @remarks In order to check whether sending a message succeeds, \n you should register email_message_sent_cb() using #email_set_message_sent_cb(). + * @remarks Get the ID of mail. * + * @param[in] email The handle to the email message * - * @param[in] email The handle to the email message - * @param[in] save_to_sentbox Set to true to save the message in the sentbox, else false - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED Communication with server failed. - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED Communication with server failed. + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre An email message handle is created using email_create_message(). * * @see email_create_message() - * @see email_set_message_sent_cb() * @see email_add_recipient() + * @see email_set_body() + * @see email_save_message + */ +int email_save_message(email_h email); + + +/** + * @brief Sends the email message. + * @since_tizen 2.3 + * + * @privlevel public + * @privilege %http://tizen.org/privilege/email + * + * @remarks In order to check whether sending a message succeeds, + * you should register email_message_sent_cb() using email_set_message_sent_cb(). + * + * @param[in] email The handle to the email message + * @param[in] save_to_sentbox Set to @c true to save the message in the sentbox, + * otherwise set to @c false to not save the message in the sentbox + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED Communication with server failed + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * + * @pre An email message is stored using email_save_message(). + * + * @see email_save_message() + * @see email_set_message_sent_cb() */ int email_send_message(email_h email, bool save_to_sentbox); @@ -188,12 +270,13 @@ int email_send_message(email_h email, bool save_to_sentbox); /** * @brief Called when the process of sending an email finishes. * @details You can check whether sending an email succeeds using this function. - * * - * @param[in] email The handle to the email message - * @param[in] result The result of email message sending\n - * #EMAIL_SENDING_FAILED or #EMAIL_SENDING_SUCCEEDED - * @param[in] user_data The user data passed from the callback registration function + * @since_tizen 2.3 + * + * @param[in] email The handle to the email message + * @param[in] result The result of email message sending \n + * #EMAIL_SENDING_FAILED or #EMAIL_SENDING_SUCCEEDED + * @param[in] user_data The user data passed from the callback registration function * * @pre email_send_message() will invoke this callback if you register this callback using email_set_message_sent_cb(). * @@ -207,14 +290,20 @@ typedef void (* email_message_sent_cb)(email_h email, email_sending_e result, vo * @brief Registers a callback function to be invoked when an email message is sent. * @details You will be notified when sending a message finishes and check whether it succeeds using this function. * - * @param[in] email The handle to the email message - * @param[in] callback The callback function to register - * @param[in] user_data The user data to be passed to the callback function + * @since_tizen 2.3 + * + * @param[in] email The handle to the email message + * @param[in] callback The callback function to register + * @param[in] user_data The user data to be passed to the callback function + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter + * + * @post It will invoke email_message_sent_cb(). * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter - * @post It will invoke email_message_sent_cb(). * @see email_message_sent_cb() * @see email_unset_message_sent_cb() * @see email_send_message() @@ -223,12 +312,15 @@ int email_set_message_sent_cb(email_h email, email_message_sent_cb callback, voi /** * @brief Unregisters the callback function. + * @since_tizen 2.3 * - * @param[in] email The handle to the email message + * @param[in] msg The handle to the email message * - * @return 0 on success, otherwise a negative error value. - * @retval #EMAIL_ERROR_NONE Successful - * @retval #EMAIL_ERROR_INVALID_PARAMETER Invalid parameter + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #EMAILS_ERROR_NONE Successful + * @retval #EMAILS_ERROR_INVALID_PARAMETER Invalid parameter * * @see email_message_sent_cb() * @see email_set_message_sent_cb() @@ -245,3 +337,4 @@ int email_unset_message_sent_cb(email_h msg); */ #endif /* __MESSAGING_EMAIL_H__ */ + diff --git a/include/email_error.h b/include/email_error.h index 157886d..88a5fea 100755 --- a/include/email_error.h +++ b/include/email_error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -35,21 +35,22 @@ extern "C" * @brief Email error definitions. */ - /** - * @brief Enumerations of error codes for email API. + * @brief Enumeration for error codes for email API. + * @since_tizen 2.3 */ typedef enum { - EMAIL_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - EMAIL_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Memory cannot be allocated */ - EMAIL_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - - EMAIL_ERROR_SERVER_NOT_READY = TIZEN_ERROR_MESSAGING_CLASS|0x200, /**< Server not ready */ - EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED = TIZEN_ERROR_MESSAGING_CLASS|0x201, /**< Communication with server failed */ - EMAIL_ERROR_OPERATION_FAILED = TIZEN_ERROR_MESSAGING_CLASS|0x202, /**< Operation failed */ - EMAIL_ERROR_ACCOUNT_NOT_FOUND = TIZEN_ERROR_MESSAGING_CLASS|0x203, /**< Email account not found */ - EMAIL_ERROR_DB_FAILED = TIZEN_ERROR_MESSAGING_CLASS|0x204, /**< Email database failed */ + EMAILS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + EMAILS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Memory cannot be allocated */ + EMAILS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + + EMAILS_ERROR_SERVER_NOT_READY = TIZEN_ERROR_EMAIL_SERVICE|0x200, /**< Server not ready */ + EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED = TIZEN_ERROR_EMAIL_SERVICE|0x201, /**< Communication with server failed */ + EMAILS_ERROR_OPERATION_FAILED = TIZEN_ERROR_EMAIL_SERVICE|0x202, /**< Operation failed */ + EMAILS_ERROR_ACCOUNT_NOT_FOUND = TIZEN_ERROR_EMAIL_SERVICE|0x203, /**< Email account not found */ + EMAILS_ERROR_DB_FAILED = TIZEN_ERROR_EMAIL_SERVICE|0x204, /**< Email database failed */ + EMAILS_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ } email_error_e; /** @@ -61,3 +62,4 @@ typedef enum #endif #endif /* __EMAILAPI_ERROR_H__*/ + diff --git a/include/email_private.h b/include/email_private.h index ae22bd8..c4bd56b 100755 --- a/include/email_private.h +++ b/include/email_private.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. diff --git a/include/email_types.h b/include/email_types.h index 95f79d7..337ac34 100755 --- a/include/email_types.h +++ b/include/email_types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -31,35 +31,38 @@ extern "C" /** * @file email_types.h - * @ingroup CAPI_MESSAGING_FRAMEWORK + * @ingroup CAPI_MESSAGING_EMAIL_MODULE * @brief This file defines common types and enums of EMAIL. */ /** - * @brief Email message handle type. + * @brief The email message handle. + * @since_tizen 2.3 */ typedef struct email_s *email_h; /** - * @brief Enumerations for the result values of email transport. + * @brief Enumeration for the result values of email transport. + * @since_tizen 2.3 */ typedef enum { - EMAIL_SENDING_FAILED = -1, /**< Email sending failed */ - EMAIL_SENDING_SUCCEEDED = 0, /**< Email sending succeeded */ + EMAIL_SENDING_FAILED = -1, /**< Email sending failed */ + EMAIL_SENDING_SUCCEEDED = 0, /**< Email sending succeeded */ } email_sending_e; /** - * @brief Enumerations of the email recipient types. + * @brief Enumeration for the email recipient types. + * @since_tizen 2.3 */ typedef enum { EMAIL_RECIPIENT_TYPE_TO = 1, /**< Normal recipient */ - EMAIL_RECIPIENT_TYPE_CC , /**< CC(carbon copy) recipient */ - EMAIL_RECIPIENT_TYPE_BCC , /**< BCC(blind carbon copy) recipient */ + EMAIL_RECIPIENT_TYPE_CC , /**< CC(carbon copy) recipient */ + EMAIL_RECIPIENT_TYPE_BCC , /**< BCC(blind carbon copy) recipient */ } email_recipient_type_e; @@ -72,3 +75,4 @@ typedef enum #endif /* __TIZEN_EMAIL_TYPES_H__*/ + diff --git a/packaging/capi-messaging-email.spec b/packaging/capi-messaging-email.spec index b42dce0..1819491 100755 --- a/packaging/capi-messaging-email.spec +++ b/packaging/capi-messaging-email.spec @@ -1,14 +1,14 @@ Name: capi-messaging-email Summary: Email library in Tizen Native API -Version: 0.1.6 +Version: 0.1.24 Release: 3 -Group: TO_BE/FILLED_IN -License: TO BE FILLED IN +License: Apache-2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(glib-2.0) -BuildRequires: pkgconfig(edbus) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(dbus-glib-1) BuildRequires: pkgconfig(email-service) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-appfw-application) diff --git a/src/email.c b/src/email.c index e879ce8..537f459 100755 --- a/src/email.c +++ b/src/email.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd All Rights Reserved * * Licensed under the Apache License, Version 2.0 (the License); * you may not use this file except in compliance with the License. @@ -17,7 +17,9 @@ #include <memory.h> #include <dlog.h> -#include <E_DBus.h> +#include <dbus/dbus.h> +#include <dbus/dbus-glib.h> +#include <dbus/dbus-glib-lowlevel.h> #include <email-api-mail.h> #include <email-api-account.h> #include <email-api-network.h> @@ -25,14 +27,6 @@ #include <email-api-init.h> #include <email-api.h> -#define EMAIL_API_ERROR_NONE 1 -#define EMAIL_API_ERROR_OUT_OF_MEMORY -1028 -#define EMAIL_API_ERROR_ACCOUNT_NOT_FOUND -1014 - -#undef EMAIL_ERROR_NONE -#undef EMAIL_ERROR_OUT_OF_MEMORY -#undef EMAIL_ERROR_ACCOUNT_NOT_FOUND - #include<email.h> #include<email_private.h> #include<email_types.h> @@ -42,7 +36,6 @@ #undef LOG_TAG #endif #define LOG_TAG "CAPI_EMAIL" -#define DBG_MODE (1) #define EM_SAFE_STRDUP(s) \ ({\ @@ -50,6 +43,12 @@ (_s)? strdup(_s) : NULL;\ }) +#define EM_SAFE_STRLEN(s) \ + ({\ + char* _s = (char*)s;\ + (_s)? strlen(_s) : 0;\ + }) + typedef struct { email_message_sent_cb callback; email_s *handle; @@ -57,6 +56,8 @@ typedef struct { } email_cb_context; GSList *gEmailcbList= NULL; + +DBusConnection* connection=NULL; //------------- Utility Or Miscellaneous void _email_add_dbus_filter(void); int _email_error_converter(int err, const char *func, int line); @@ -69,73 +70,98 @@ void _email_free_cb_context(email_cb_context *cbcontext); int email_create_message(email_h *msg) { + LOGD("START\n"); int ret; email_s * msg_s = NULL; email_account_t* account = NULL; int len; if(msg == NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } // 1. create service for ipc - ret=email_service_begin(); + ret = email_service_begin(); + if (ret != EMAIL_ERROR_NONE && ret != EMAIL_ERROR_IPC_ALREADY_INITIALIZED) { + SECURE_SLOGE("[%s] email_service_begin failed : [%d]",__FUNCTION__, ret); + return CONVERT_ERROR(ret); + } + msg_s= (email_s*)calloc(1,sizeof(email_s)); if (msg_s != NULL) { msg_s->mail = (email_mail_data_t *)calloc(1,sizeof(email_mail_data_t)); if (msg_s->mail == NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mail", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mail", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); free(msg_s); - return EMAIL_ERROR_OUT_OF_MEMORY; + return EMAILS_ERROR_OUT_OF_MEMORY; } msg_s->mbox = (email_mailbox_t *)calloc(1,sizeof(email_mailbox_t)); if (msg_s->mbox == NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mbox", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mbox", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + email_free_mail_data(&msg_s->mail, 1); free(msg_s); - return EMAIL_ERROR_OUT_OF_MEMORY; + return EMAILS_ERROR_OUT_OF_MEMORY; } } else { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; } //return error from F/W - //EMAIL_ERROR_INVALID_PARAM/EMAIL_API_ERROR_NONE/EMAIL_ERROR_DB_FAILURE/EMAIL_ERROR_ACCOUNT_NOT_FOUND/EMAIL_ERROR_OUT_OF_MEMORY + //EMAILS_ERROR_INVALID_PARAM/EMAIL_ERROR_NONE/EMAILS_ERROR_DB_FAILURE/EMAILS_ERROR_ACCOUNT_NOT_FOUND/EMAILS_ERROR_OUT_OF_MEMORY int default_account_id = 0; - if ((ret = email_load_default_account_id(&default_account_id)) != EMAIL_API_ERROR_NONE) { - LOGE("[%s] email_load_default_account_id failed : [%d]",__FUNCTION__, ret); + if ((ret = email_load_default_account_id(&default_account_id)) != EMAIL_ERROR_NONE) { + SECURE_SLOGE("[%s] email_load_default_account_id failed : [%d]",__FUNCTION__, ret); + email_free_mail_data(&msg_s->mail, 1); + email_free_mailbox(&msg_s->mbox, 1); + free(msg_s); return CONVERT_ERROR(ret); } ret = email_get_account(default_account_id, GET_FULL_DATA, &account); - if(ret!=EMAIL_API_ERROR_NONE) return CONVERT_ERROR(ret); + if(ret!=EMAIL_ERROR_NONE) { + SECURE_SLOGE("[%s] email_get_account failed : [%d]",__FUNCTION__, ret); + if (account) { + email_free_account(&account, 1); + } + email_free_mail_data(&msg_s->mail, 1); + email_free_mailbox(&msg_s->mbox, 1); + free(msg_s); + return CONVERT_ERROR(ret); + } - LOGD_IF(DBG_MODE,"account address = %s",account->user_email_address); - LOGD_IF(DBG_MODE,"account id = %d",account->account_id); - LOGD_IF(DBG_MODE,"account name = %s",account->account_name); - LOGD_IF(DBG_MODE,"account user_name = %s",account->incoming_server_user_name); + SECURE_LOGD("account address = %s",account->user_email_address); + SECURE_LOGD("account id = %d",account->account_id); + SECURE_LOGD("account name = %s",account->account_name); + SECURE_LOGD("account user_name = %s",account->incoming_server_user_name); - msg_s->mail->full_address_from = (char *)calloc(1,sizeof(char)*(strlen(account->incoming_server_user_name)+strlen(account->user_email_address)+1+1+1+1+1));//"++"+<+ address +> + NULL - len= (strlen(account->incoming_server_user_name)+strlen(account->user_email_address)+1+1+1+1+1); + len= EM_SAFE_STRLEN(account->incoming_server_user_name)+EM_SAFE_STRLEN(account->user_email_address)+1+1+1+1+1; + msg_s->mail->full_address_from = (char *)calloc(1,sizeof(char)*(len));//"++"+<+ address +> + NULL char *strfrom = msg_s->mail->full_address_from; - snprintf(strfrom,len,"%s%s%s%s%s%s","\"",account->incoming_server_user_name,"\"","<",account->user_email_address,">"); + if (account->incoming_server_user_name) + snprintf(strfrom, len, "%s%s%s%s%s%s", "\"", account->incoming_server_user_name, "\"", "<", account->user_email_address, ">"); + else + snprintf(strfrom, len, "%s%s%s", "<", account->user_email_address, ">"); //mbox - email_mailbox_t *mbox =msg_s->mbox; + email_mailbox_t *mbox = msg_s->mbox; - if ( (ret = email_get_mailbox_by_mailbox_type(default_account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mbox)) != EMAIL_API_ERROR_NONE) { - LOGE("[%s] email_get_mailbox_by_mailbox_type failed %d", __FUNCTION__, ret); - return EMAIL_ERROR_DB_FAILED; + if ((ret = email_get_mailbox_by_mailbox_type(default_account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mbox)) != EMAIL_ERROR_NONE) { + SECURE_SLOGE("[%s] email_get_mailbox_by_mailbox_type failed %d", __FUNCTION__, ret); + email_free_mail_data(&msg_s->mail, 1); + email_free_mailbox(&msg_s->mbox, 1); + free(msg_s); + return CONVERT_ERROR(ret); } //info @@ -148,17 +174,19 @@ int email_create_message(email_h *msg) msg_s->mail->attachment_count = 0; *msg = (email_h)msg_s; - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_destroy_message(email_h msg) { + LOGD("START\n"); int ret; if(msg == NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } email_s* msg_s = (email_s* )msg; @@ -173,27 +201,29 @@ int email_destroy_message(email_h msg) free(msg_s); } - ret=email_service_end(); - if(ret!=EMAIL_API_ERROR_NONE){ - LOGE("[%s] OPERATION_FAILED(0x%08x) : Finishing email service failed", __FUNCTION__, EMAIL_ERROR_OPERATION_FAILED); - return EMAIL_ERROR_OPERATION_FAILED; - } - - - return EMAIL_ERROR_NONE; + if(ret!=EMAIL_ERROR_NONE){ + SECURE_SLOGE("[%s] OPERATION_FAILED(0x%08x) : Finishing email service failed", __FUNCTION__, EMAILS_ERROR_OPERATION_FAILED); + return EMAILS_ERROR_OPERATION_FAILED; + } + + gEmailcbList= NULL; + + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_set_subject (email_h msg, const char *subject) { + LOGD("START\n"); int len; if(msg ==NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; - } + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; + } email_s* msg_s = (email_s* )msg; @@ -201,24 +231,26 @@ int email_set_subject (email_h msg, const char *subject) if(msg_s->mail->subject ==NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mail->head->subject", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; - } + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mail->head->subject", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; + } len =strlen(subject)+1; snprintf(msg_s->mail->subject ,len,"%s",subject); - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_set_body (email_h msg, const char *body) { + LOGD("START\n"); int len; if (msg == NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } email_s* msg_s = (email_s* )msg; @@ -227,48 +259,50 @@ int email_set_body (email_h msg, const char *body) FILE* file = NULL; - file = fopen("/tmp/capimail.txt", "w"); + file = fopen("/tmp/capimail.txt", "w"); if (file != NULL) { fputs(body, file); fclose(file); } else { - LOGE("[%s] OPERATION_FAILED(0x%08x) : opening file for email body failed.", __FUNCTION__, EMAIL_ERROR_OPERATION_FAILED); - return EMAIL_ERROR_OPERATION_FAILED; + SECURE_SLOGE("[%s] OPERATION_FAILED(0x%08x) : opening file for email body failed.", __FUNCTION__, EMAILS_ERROR_OPERATION_FAILED); + return EMAILS_ERROR_OPERATION_FAILED; } msg_s->mail->file_path_plain =(char *)calloc(1,sizeof(char)*strlen("/tmp/capimail.txt")+1); if(msg_s->mail->file_path_plain == NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to allocate body(plain).", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to allocate body(plain).", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; } len =strlen("/tmp/capimail.txt")+1; snprintf(msg_s->mail->file_path_plain,len,"%s","/tmp/capimail.txt"); - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_add_recipient (email_h msg, email_recipient_type_e type, const char *address) { + LOGD("START\n"); char *tmp; int total_len,in_len,pre_len,len; if(msg == NULL || type < EMAIL_RECIPIENT_TYPE_TO || type > EMAIL_RECIPIENT_TYPE_BCC ) { - return EMAIL_ERROR_INVALID_PARAMETER; + return EMAILS_ERROR_INVALID_PARAMETER; } email_s* msg_s = (email_s* )msg; if(strlen(address) > MAX_RECIPIENT_ADDRESS_LEN) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : The length of address should be less than 234.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : The length of address should be less than 234.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } if(type == EMAIL_RECIPIENT_TYPE_TO) @@ -278,8 +312,8 @@ int email_add_recipient (email_h msg, email_recipient_type_e type, const char *a msg_s->mail->full_address_to = (char*)calloc(1,sizeof(char)*strlen(address)+2+1+1);//<>+;+end of string if(msg_s->mail->full_address_to == NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->to.", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->to.", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; } len =strlen(address)+2+1+1; snprintf(msg_s->mail->full_address_to,len,"%s%s%s","<",address,">"); @@ -303,8 +337,8 @@ int email_add_recipient (email_h msg, email_recipient_type_e type, const char *a msg_s->mail->full_address_cc = (char*)calloc(1,sizeof(char)*strlen(address)+2+1+1);//<>+;+end of string if(msg_s->mail->full_address_cc == NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->cc.", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->cc.", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; } len =strlen(address)+2+1+1; snprintf(msg_s->mail->full_address_cc,len,"%s%s%s","<",address,">"); @@ -329,13 +363,12 @@ int email_add_recipient (email_h msg, email_recipient_type_e type, const char *a msg_s->mail->full_address_bcc = (char*)calloc(1,sizeof(char)*strlen(address)+2+1+1);//<>+;+end of string if(msg_s->mail->full_address_bcc==NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->bcc.", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->bcc.", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; } len =strlen(address)+2+1+1; snprintf(msg_s->mail->full_address_bcc,len,"%s%s%s","<",address,">"); - } - else{ + } else { in_len = strlen(address); pre_len = strlen(msg_s->mail->full_address_bcc); @@ -349,15 +382,17 @@ int email_add_recipient (email_h msg, email_recipient_type_e type, const char *a } } - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_remove_all_recipients(email_h msg) { + LOGD("START\n"); if(msg ==NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : fail to create tmp memory.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : fail to create tmp memory.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } email_s *msg_s = (email_s *)msg; @@ -379,20 +414,22 @@ int email_remove_all_recipients(email_h msg) free(msg_s->mail->full_address_bcc); msg_s->mail->full_address_bcc = NULL; } - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_add_attach (email_h msg, const char *filepath) { + LOGD("START\n"); int len; char *pos,*last; struct stat st; if(msg ==NULL || filepath == NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg or filepath is null.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg or filepath is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } email_s *msg_s = (email_s *)msg; @@ -403,14 +440,14 @@ int email_add_attach (email_h msg, const char *filepath) stat(filepath, &st); if(st.st_size > 10*1024*1024) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : the size of attachment file is beyond the limit(MAX:10M).", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : the size of attachment file is beyond the limit(MAX:10M).", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } if (!S_ISREG(st.st_mode)) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : the filepath is not regular file.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : the filepath is not regular file.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } @@ -430,10 +467,10 @@ int email_add_attach (email_h msg, const char *filepath) if(pos != NULL) pos++; } - new_attach[attachment_count].attachment_name =last; + new_attach[attachment_count].attachment_name = strdup(last); } new_attach[attachment_count].attachment_path =(char*)calloc(1,sizeof(char)*len+1); - if (new_attach[attachment_count].attachment_path == NULL) return EMAIL_ERROR_OUT_OF_MEMORY; + if (new_attach[attachment_count].attachment_path == NULL) return EMAILS_ERROR_OUT_OF_MEMORY; snprintf(new_attach[attachment_count].attachment_path, len+1, "%s", filepath); new_attach[attachment_count].attachment_size = st.st_size; @@ -441,124 +478,135 @@ int email_add_attach (email_h msg, const char *filepath) msg_s->mail->attachment_count++; - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_remove_all_attachments (email_h msg) { + LOGD("START\n"); if (msg ==NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } email_s* msg_s = (email_s* )msg; msg_s->mail->attachment_count = 0; - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } - -int email_send_message (email_h msg, bool save_to_sentbox) +int email_save_message (email_h msg) { - int i, ret; - email_option_t option; - unsigned handle; + LOGD("START\n"); + int ret; +/* + int i; + email_mailbox_t *box = NULL; email_attachment_data_t *tmp_attach = NULL; struct tm *struct_time; - +*/ if (msg == NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; } email_s *msg_s = (email_s *)msg; - - { - /*--------- head ----------*/ - LOGD_IF(DBG_MODE, " ----------head---------"); - LOGD_IF(DBG_MODE, " mid: %s\n",msg_s->mail->message_id); - LOGD_IF(DBG_MODE, " subject: %s\n",msg_s->mail->subject); - LOGD_IF(DBG_MODE, " to: %s\n",msg_s->mail->full_address_to); - LOGD_IF(DBG_MODE, " from: %s\n",msg_s->mail->full_address_from); - LOGD_IF(DBG_MODE, " cc: %s\n",msg_s->mail->full_address_cc); - LOGD_IF(DBG_MODE, " bcc: %s\n",msg_s->mail->full_address_bcc); - LOGD_IF(DBG_MODE, " reply_to: %s\n",msg_s->mail->full_address_reply); - LOGD_IF(DBG_MODE, " return_path: %s\n",msg_s->mail->full_address_return); - LOGD_IF(DBG_MODE, " previewBodyText: %s\n",msg_s->mail->preview_text); - - struct_time = localtime(&msg_s->mail->date_time); - - LOGD_IF(DBG_MODE, " %4d year\n", struct_time->tm_year+1900); - LOGD_IF(DBG_MODE, " %2d month\n", struct_time->tm_mon+1); - LOGD_IF(DBG_MODE, " %2d day\n", struct_time->tm_mday); - LOGD_IF(DBG_MODE, " %2d:%2d:%2d \n", struct_time->tm_hour, struct_time->tm_min, struct_time->tm_sec); - - /*--------- body ----------*/ - LOGD_IF(DBG_MODE, " ----------body---------"); - LOGD_IF(DBG_MODE, " body\n"); - LOGD_IF(DBG_MODE, " plain: %s\n",msg_s->mail->file_path_plain); - LOGD_IF(DBG_MODE, " html: %s\n",msg_s->mail->file_path_html); - LOGD_IF(DBG_MODE, " attachment_num: %d\n",msg_s->mail->attachment_count); - tmp_attach = msg_s->attachment; - for (i=0; i < msg_s->mail->attachment_count; i++) { - LOGD_IF(DBG_MODE, " ----------attachment[%d]---------", i+1); - LOGD_IF(DBG_MODE, " name: %s\n",tmp_attach[i].attachment_name); - LOGD_IF(DBG_MODE, " savename: %s\n",tmp_attach[i].attachment_path); - LOGD_IF(DBG_MODE, " downloaded: %d\n",tmp_attach[i].save_status); - LOGD_IF(DBG_MODE, " size: %d\n",tmp_attach[i].attachment_size); - } - } - - { - /*--------- info ----------*/ - LOGD_IF(DBG_MODE, " ----------info---------"); - LOGD_IF(DBG_MODE, " account_id: %d\n",msg_s->mail->account_id); - LOGD_IF(DBG_MODE, " mail_id: %d\n",msg_s->mail->mail_id); - LOGD_IF(DBG_MODE, " mail_size: %d\n",msg_s->mail->mail_size); - LOGD_IF(DBG_MODE, " body_download_status: %d\n",msg_s->mail->body_download_status); - LOGD_IF(DBG_MODE, " server_id: %s\n",msg_s->mail->server_mail_id); - LOGD_IF(DBG_MODE, " meeting_request_status: %d\n",msg_s->mail->meeting_request_status); - } +#if 0 + /*--------- head ----------*/ + SECURE_LOGD(" ----------head---------"); + SECURE_LOGD(" mid: %s\n",msg_s->mail->message_id); + SECURE_LOGD(" subject: %s\n",msg_s->mail->subject); + SECURE_LOGD(" to: %s\n",msg_s->mail->full_address_to); + SECURE_LOGD(" from: %s\n",msg_s->mail->full_address_from); + SECURE_LOGD(" cc: %s\n",msg_s->mail->full_address_cc); + SECURE_LOGD(" bcc: %s\n",msg_s->mail->full_address_bcc); + SECURE_LOGD(" reply_to: %s\n",msg_s->mail->full_address_reply); + SECURE_LOGD(" return_path: %s\n",msg_s->mail->full_address_return); + SECURE_LOGD(" previewBodyText: %s\n",msg_s->mail->preview_text); + + struct_time = localtime(&msg_s->mail->date_time); + + SECURE_LOGD(" %4d year\n", struct_time->tm_year+1900); + SECURE_LOGD(" %2d month\n", struct_time->tm_mon+1); + SECURE_LOGD(" %2d day\n", struct_time->tm_mday); + SECURE_LOGD(" %2d:%2d:%2d \n", struct_time->tm_hour, struct_time->tm_min, struct_time->tm_sec); + + /*--------- body ----------*/ + SECURE_LOGD(" ----------body---------"); + SECURE_LOGD(" body\n"); + SECURE_LOGD(" plain: %s\n",msg_s->mail->file_path_plain); + SECURE_LOGD(" html: %s\n",msg_s->mail->file_path_html); + SECURE_LOGD(" attachment_num: %d\n",msg_s->mail->attachment_count); + tmp_attach = msg_s->attachment; + for (i=0; i < msg_s->mail->attachment_count; i++) { + SECURE_LOGD(" ----------attachment[%d]---------", i+1); + SECURE_LOGD(" name: %s\n",tmp_attach[i].attachment_name); + SECURE_LOGD(" savename: %s\n",tmp_attach[i].attachment_path); + SECURE_LOGD(" downloaded: %d\n",tmp_attach[i].save_status); + SECURE_LOGD(" size: %d\n",tmp_attach[i].attachment_size); + } + + /*--------- info ----------*/ + SECURE_LOGD(" ----------info---------"); + SECURE_LOGD(" account_id: %d\n",msg_s->mail->account_id); + SECURE_LOGD(" mail_id: %d\n",msg_s->mail->mail_id); + SECURE_LOGD(" mail_size: %d\n",msg_s->mail->mail_size); + SECURE_LOGD(" body_download_status: %d\n",msg_s->mail->body_download_status); + SECURE_LOGD(" server_id: %s\n",msg_s->mail->server_mail_id); + SECURE_LOGD(" meeting_request_status: %d\n",msg_s->mail->meeting_request_status); + + /*---------- box info -----*/ + box = msg_s->mbox; + SECURE_LOGD(" ----------box---------"); + SECURE_LOGD(" email_mailbox_t \n"); + SECURE_LOGD(" name: %s\n",box->mailbox_name); + SECURE_LOGD(" mailbox_type: %d\n",box->mailbox_type); + SECURE_LOGD(" alias: %s\n",box->alias); + SECURE_LOGD(" unread_count: %d\n",box->unread_count); + SECURE_LOGD(" total_mail_count_on_local: %d\n",box->total_mail_count_on_local); + SECURE_LOGD(" total_mail_count_on_server: %d\n",box->total_mail_count_on_server); + SECURE_LOGD(" local: %d\n",box->local); + SECURE_LOGD(" account_id: %d\n",box->account_id); + SECURE_LOGD(" mail_slot_size: %d\n",box->mail_slot_size); +#endif + ret=email_add_mail(msg_s->mail, msg_s->attachment, msg_s->mail->attachment_count, NULL, 0); + ret=CONVERT_ERROR(ret); - - { - email_mailbox_t * box; - box=msg_s->mbox; - LOGD_IF(DBG_MODE, " ----------box---------"); - LOGD_IF(DBG_MODE, " email_mailbox_t \n"); - LOGD_IF(DBG_MODE, " name: %s\n",box->mailbox_name); - LOGD_IF(DBG_MODE, " mailbox_type: %d\n",box->mailbox_type); - LOGD_IF(DBG_MODE, " alias: %s\n",box->alias); - LOGD_IF(DBG_MODE, " unread_count: %d\n",box->unread_count); - LOGD_IF(DBG_MODE, " total_mail_count_on_local: %d\n",box->total_mail_count_on_local); - LOGD_IF(DBG_MODE, " total_mail_count_on_server: %d\n",box->total_mail_count_on_server); - LOGD_IF(DBG_MODE, " local: %d\n",box->local); - LOGD_IF(DBG_MODE, " account_id: %d\n",box->account_id); - LOGD_IF(DBG_MODE, " mail_slot_size: %d\n",box->mail_slot_size); - } + LOGD("END\n"); + return ret; +} +int email_send_message (email_h msg, bool save_to_sentbox) +{ + LOGD("START\n"); + int ret; + int handle; - ret=email_add_mail(msg_s->mail, msg_s->attachment, msg_s->mail->attachment_count, NULL, 0); - ret=CONVERT_ERROR(ret); - + if (msg == NULL) { + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; + } - memset(&option, 0x00, sizeof(email_option_t)); - option.keep_local_copy = save_to_sentbox ? 1 : 0; - + email_s *msg_s = (email_s *)msg; - ret=email_send_mail(msg_s->mail->mail_id, &option, &handle); + _email_add_dbus_filter(); + ret=email_send_mail(msg_s->mail->mail_id, &handle); ret=CONVERT_ERROR(ret); - _email_add_dbus_filter(); + + LOGD("END\n"); return ret; } email_cb_context * _email_search_callback_by_emailid(int mailid) { + LOGD("START\n"); int count; int ntmp=0; GSList * node; @@ -569,49 +617,52 @@ email_cb_context * _email_search_callback_by_emailid(int mailid) { node = g_slist_nth( gEmailcbList, ntmp ); - if( node == NULL ) - break; - - cbContext= (email_cb_context *)node->data; - if(cbContext->handle->mail->mail_id == mailid) - { - return cbContext; - } - + if(node == NULL || node->data == NULL) + break; + + cbContext = (email_cb_context *)node->data; + if (cbContext->handle->mail->mail_id == mailid) { + return cbContext; + } ntmp++; count--; } + LOGD("END\n"); return NULL; } int email_set_message_sent_cb (email_h handle, email_message_sent_cb cb, void *user_data) { + LOGD("START\n"); int count; int ntmp=0; - int ret = EMAIL_ERROR_NONE; + int ret = EMAILS_ERROR_NONE; GSList * node; + email_s *p_handle = (email_s *)handle; email_cb_context *cbContext; count = g_slist_length( gEmailcbList ); - if(handle ==NULL || cb == NULL)return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_LOGD("count : [%d]\n", count); + + if (handle == NULL || p_handle->mail == NULL || cb == NULL) return EMAILS_ERROR_INVALID_PARAMETER; - email_s* msg_s = NULL; - while( count ) - { + while (count) { node = g_slist_nth( gEmailcbList, ntmp ); - if( node == NULL ) + if (node == NULL) break; - cbContext= (email_cb_context *)node->data; - if(cbContext->handle == (email_s*)handle) + cbContext= (email_cb_context *)node->data; + SECURE_LOGD("mail_id : [%d]\n", cbContext->handle->mail->mail_id); + + if (cbContext->handle->mail->mail_id == p_handle->mail->mail_id) { - gEmailcbList=g_slist_remove(gEmailcbList,node); + gEmailcbList = g_slist_delete_link(gEmailcbList, node); _email_free_cb_context(cbContext); break; } @@ -620,102 +671,119 @@ int email_set_message_sent_cb (email_h handle, email_message_sent_cb cb, void *u count--; } - if ((ret = _email_copy_handle(&msg_s, (email_s *)handle)) != EMAIL_ERROR_NONE) { - LOGE("[%s] _email_copy_handle failed", __FUNCTION__); + if ((ret = _email_copy_handle(&msg_s, p_handle)) != EMAILS_ERROR_NONE) { + SECURE_SLOGE("[%s] _email_copy_handle failed", __FUNCTION__); return ret; } - email_cb_context * cbcontext= (email_cb_context*)calloc(1, sizeof(email_cb_context) ); + email_cb_context *cbcontext = (email_cb_context *)calloc(1, sizeof(email_cb_context)); + if (cbcontext == NULL) { + SECURE_SLOGE("[%s] calloc failed", __FUNCTION__); + ret = EMAIL_ERROR_OUT_OF_MEMORY; + return ret; + } + SECURE_LOGD("mail_id : [%d]\n", msg_s->mail->mail_id); + SECURE_LOGD("Callback : [%p]\n", cb); + SECURE_LOGD("User Data : [%p]\n", user_data); + cbcontext->handle = msg_s; - cbcontext->callback=cb; - cbcontext->user_data =user_data; + cbcontext->callback = cb; + cbcontext->user_data = user_data; - gEmailcbList = g_slist_append(gEmailcbList,cbcontext); + gEmailcbList = g_slist_append(gEmailcbList, cbcontext); - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int email_unset_message_sent_cb (email_h msg) { - + LOGD("START\n"); int i,count; count = g_slist_length( gEmailcbList ); GSList * node; email_cb_context *cbContext; - if(msg ==NULL ) - { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); - return EMAIL_ERROR_INVALID_PARAMETER; - } + SECURE_LOGD("count : [%d]\n", count); + + if (msg == NULL) { + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + return EMAILS_ERROR_INVALID_PARAMETER; + } + email_s* msg_s = (email_s* )msg; - for( i=0;i<count;i++) + for(i=0;i<count;i++) { node = g_slist_nth( gEmailcbList, i ); if( node == NULL ) - break; - + break; cbContext= (email_cb_context *)node->data; - if(cbContext->handle == msg_s) + SECURE_LOGD("mail_id : [%d]\n", cbContext->handle->mail->mail_id); + SECURE_LOGD("mail_id : [%d]\n", msg_s->mail->mail_id); + + if(cbContext->handle->mail->mail_id == msg_s->mail->mail_id) { - gEmailcbList= g_slist_remove(gEmailcbList,node); + gEmailcbList = g_slist_delete_link(gEmailcbList, node); _email_free_cb_context(cbContext); break; } - - - } - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int _email_error_converter(int err, const char *func, int line) { + LOGD("START\n"); switch(err) { case EMAIL_ERROR_INVALID_PARAM : - LOGE("[%s:%d] INVALID_PARAM(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAIL_ERROR_INVALID_PARAMETER, err); - return EMAIL_ERROR_INVALID_PARAMETER; + SECURE_SLOGE("[%s:%d] INVALID_PARAM(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_INVALID_PARAMETER, err); + return EMAILS_ERROR_INVALID_PARAMETER; case EMAIL_ERROR_DB_FAILURE : - LOGE("[%s:%d] DB_FAILURE(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAIL_ERROR_DB_FAILED, err); - return EMAIL_ERROR_DB_FAILED; + SECURE_SLOGE("[%s:%d] DB_FAILURE(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_DB_FAILED, err); + return EMAILS_ERROR_DB_FAILED; - case EMAIL_API_ERROR_ACCOUNT_NOT_FOUND : - LOGE("[%s:%d] ACCOUNT_NOT_FOUND(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAIL_ERROR_ACCOUNT_NOT_FOUND,err); - return EMAIL_ERROR_ACCOUNT_NOT_FOUND; + case EMAIL_ERROR_ACCOUNT_NOT_FOUND : + SECURE_SLOGE("[%s:%d] ACCOUNT_NOT_FOUND(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_ACCOUNT_NOT_FOUND,err); + return EMAILS_ERROR_ACCOUNT_NOT_FOUND; - case EMAIL_API_ERROR_OUT_OF_MEMORY : - LOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAIL_ERROR_OUT_OF_MEMORY,err); - return EMAIL_ERROR_OUT_OF_MEMORY; + case EMAIL_ERROR_OUT_OF_MEMORY : + SECURE_SLOGE("[%s:%d] OUT_OF_MEMORY(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_OUT_OF_MEMORY,err); + return EMAILS_ERROR_OUT_OF_MEMORY; // Tizen email F/W is often using this error type when it gets a null value from server //It could be caused from server or IPC. case EMAIL_ERROR_NULL_VALUE : - LOGE("[%s:%d] NULL_VALUE(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED,err); - return EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED; + SECURE_SLOGE("[%s:%d] NULL_VALUE(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED,err); + return EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED; case EMAIL_ERROR_IPC_SOCKET_FAILURE : - LOGE("[%s:%d] IPC_SOCKET_FAILURE(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED,err); - return EMAIL_ERROR_COMMUNICATION_WITH_SERVER_FAILED; + SECURE_SLOGE("[%s:%d] IPC_SOCKET_FAILURE(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED,err); + return EMAILS_ERROR_COMMUNICATION_WITH_SERVER_FAILED; - case EMAIL_API_ERROR_NONE : - return EMAIL_ERROR_NONE; + case EMAIL_ERROR_PERMISSION_DENIED : + SECURE_SLOGE("[%s:%d] PERMISSION_DENIED(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_PERMISSION_DENIED,err); + return EMAILS_ERROR_PERMISSION_DENIED; + + case EMAIL_ERROR_NONE : + return EMAILS_ERROR_NONE; default : - LOGE("[%s:%d] OPERATION_FAILED(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAIL_ERROR_OPERATION_FAILED,err); - return EMAIL_ERROR_OPERATION_FAILED; + SECURE_SLOGE("[%s:%d] OPERATION_FAILED(0x%08x) : Error from Email F/W. ret: (0x%08x) ", func, line, EMAILS_ERROR_OPERATION_FAILED,err); + return EMAILS_ERROR_OPERATION_FAILED; } + LOGD("END\n"); } - - -static void _monitorSendStatusCb(void* data, DBusMessage *message) +DBusHandlerResult _monitorSendStatusCb(DBusConnection *connection, DBusMessage *message, void *user_data) { + LOGD("START\n"); DBusError error; email_cb_context *cbContext = NULL; if(dbus_message_is_signal(message, "User.Email.NetworkStatus", "email")) @@ -736,13 +804,12 @@ static void _monitorSendStatusCb(void* data, DBusMessage *message) DBUS_TYPE_INVALID)) { - + SECURE_LOGD("status:[%d], account_id:[%d], file_id:[%s], mail_id:[%d], error_code:[%d]", status, accountid, fileid, mailid, errorcode); cbContext = _email_search_callback_by_emailid(mailid); - if(cbContext == NULL) - { - LOGD_IF(DBG_MODE, "no callback matched!\n"); + if (cbContext == NULL) { + SECURE_LOGD("no callback matched!\n"); }else{ - + SECURE_LOGD("Address : [%p]\n", cbContext->callback); switch (status) { case NOTI_SEND_START: break; @@ -750,23 +817,23 @@ static void _monitorSendStatusCb(void* data, DBusMessage *message) case NOTI_SEND_FAIL: switch(errorcode) - { - case EMAIL_ERROR_NO_SIM_INSERTED: - case EMAIL_ERROR_FLIGHT_MODE: - case EMAIL_ERROR_SMTP_SEND_FAILURE: - case EMAIL_ERROR_NO_SUCH_HOST: - case EMAIL_ERROR_CONNECTION_FAILURE: - case EMAIL_ERROR_CONNECTION_BROKEN: - case EMAIL_ERROR_INVALID_SERVER: - case EMAIL_ERROR_NO_RESPONSE: - - break; - - default: + { + case EMAIL_ERROR_NO_SIM_INSERTED: + case EMAIL_ERROR_FLIGHT_MODE: + case EMAIL_ERROR_SMTP_SEND_FAILURE: + case EMAIL_ERROR_NO_SUCH_HOST: + case EMAIL_ERROR_CONNECTION_FAILURE: + case EMAIL_ERROR_CONNECTION_BROKEN: + case EMAIL_ERROR_INVALID_SERVER: + case EMAIL_ERROR_NO_RESPONSE: + + break; + + default: break; - } + } - cbContext->callback((email_h)cbContext->handle,(email_sending_e)EMAIL_SENDING_FAILED ,cbContext->user_data); + cbContext->callback((email_h)cbContext->handle,(email_sending_e)EMAIL_SENDING_FAILED ,cbContext->user_data); break; case NOTI_SEND_FINISH: @@ -777,161 +844,176 @@ static void _monitorSendStatusCb(void* data, DBusMessage *message) } } } + + LOGD("END\n"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } void _email_add_dbus_filter(void) { + LOGD("START\n"); + + if (connection != NULL) + return; - E_DBus_Connection* connection=NULL; - DBusError error; - E_DBus_Signal_Handler *handler = NULL; - + DBusError error; dbus_error_init(&error); - connection = e_dbus_bus_get(DBUS_BUS_SYSTEM); + connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error); + if (NULL == connection) { + SECURE_SLOGE("dbus_bus_get failed"); + return; + } + LOGD("connection [%p]", connection); - if (NULL == connection) { - - } + char *rule = "type='signal',interface='User.Email.NetworkStatus'"; + LOGD("Signal match rule: %s", rule); + dbus_bus_add_match(connection, rule, &error); - if(e_dbus_request_name(connection, "User.Email.NetworkStatus", - 0, - NULL, - NULL) == NULL) - { - LOGD_IF(DBG_MODE, "Failed in e_dbus_request_name()\n"); + if (dbus_error_is_set(&error)) { + LOGD("Cannot add D-BUS match rule, cause: %s", error.message); + dbus_error_free(&error); + return; } - handler = e_dbus_signal_handler_add(connection, - NULL, - "/User/Email/NetworkStatus", - "User.Email.NetworkStatus", - "email", - _monitorSendStatusCb, - NULL); + dbus_connection_setup_with_g_main(connection, NULL); - if(handler == NULL) - { - LOGD_IF(DBG_MODE, "Failed in e_dbus_signal_handler_add()"); - } + dbus_connection_add_filter(connection, _monitorSendStatusCb, NULL, NULL); + + LOGD("END\n"); } int _email_copy_mail_data(email_mail_data_t **dst_mail_data, email_mail_data_t *src_mail_data) { + LOGD("START\n"); email_mail_data_t *temp_mail_data = NULL; temp_mail_data = (email_mail_data_t *)calloc(1, sizeof(email_mail_data_t)); if (temp_mail_data == NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create email_mail_data_t", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create email_mail_data_t", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; } - temp_mail_data->mail_id = src_mail_data->mail_id; - temp_mail_data->account_id = src_mail_data->account_id; - temp_mail_data->mailbox_id = src_mail_data->mailbox_id; - temp_mail_data->mailbox_type = src_mail_data->mailbox_type; - temp_mail_data->subject = EM_SAFE_STRDUP(src_mail_data->subject); - temp_mail_data->date_time = src_mail_data->date_time; + temp_mail_data->mail_id = src_mail_data->mail_id; + temp_mail_data->account_id = src_mail_data->account_id; + temp_mail_data->mailbox_id = src_mail_data->mailbox_id; + temp_mail_data->mailbox_type = src_mail_data->mailbox_type; + temp_mail_data->subject = EM_SAFE_STRDUP(src_mail_data->subject); + temp_mail_data->date_time = src_mail_data->date_time; temp_mail_data->server_mail_status = src_mail_data->server_mail_status; temp_mail_data->server_mailbox_name = EM_SAFE_STRDUP(src_mail_data->server_mailbox_name); - temp_mail_data->server_mail_id = EM_SAFE_STRDUP(src_mail_data->server_mail_id); - temp_mail_data->message_id = EM_SAFE_STRDUP(src_mail_data->message_id); + temp_mail_data->server_mail_id = EM_SAFE_STRDUP(src_mail_data->server_mail_id); + temp_mail_data->message_id = EM_SAFE_STRDUP(src_mail_data->message_id); temp_mail_data->full_address_from = EM_SAFE_STRDUP(src_mail_data->full_address_from); temp_mail_data->full_address_reply = EM_SAFE_STRDUP(src_mail_data->full_address_reply); - temp_mail_data->full_address_to = EM_SAFE_STRDUP(src_mail_data->full_address_to); - temp_mail_data->full_address_cc = EM_SAFE_STRDUP(src_mail_data->full_address_cc); - temp_mail_data->full_address_bcc = EM_SAFE_STRDUP(src_mail_data->full_address_bcc); + temp_mail_data->full_address_to = EM_SAFE_STRDUP(src_mail_data->full_address_to); + temp_mail_data->full_address_cc = EM_SAFE_STRDUP(src_mail_data->full_address_cc); + temp_mail_data->full_address_bcc = EM_SAFE_STRDUP(src_mail_data->full_address_bcc); temp_mail_data->full_address_return = EM_SAFE_STRDUP(src_mail_data->full_address_return); temp_mail_data->email_address_sender = EM_SAFE_STRDUP(src_mail_data->email_address_sender); temp_mail_data->email_address_recipient = EM_SAFE_STRDUP(src_mail_data->email_address_recipient); - temp_mail_data->alias_sender = EM_SAFE_STRDUP(src_mail_data->alias_sender); - temp_mail_data->alias_recipient = EM_SAFE_STRDUP(src_mail_data->alias_recipient); + temp_mail_data->alias_sender = EM_SAFE_STRDUP(src_mail_data->alias_sender); + temp_mail_data->alias_recipient = EM_SAFE_STRDUP(src_mail_data->alias_recipient); temp_mail_data->body_download_status = src_mail_data->body_download_status; - temp_mail_data->file_path_plain = EM_SAFE_STRDUP(src_mail_data->file_path_plain); - temp_mail_data->file_path_html = EM_SAFE_STRDUP(src_mail_data->file_path_html); + temp_mail_data->file_path_plain = EM_SAFE_STRDUP(src_mail_data->file_path_plain); + temp_mail_data->file_path_html = EM_SAFE_STRDUP(src_mail_data->file_path_html); temp_mail_data->file_path_mime_entity = EM_SAFE_STRDUP(src_mail_data->file_path_mime_entity); - temp_mail_data->mail_size = src_mail_data->mail_size; - temp_mail_data->flags_seen_field = src_mail_data->flags_seen_field; + temp_mail_data->mail_size = src_mail_data->mail_size; + temp_mail_data->flags_seen_field = src_mail_data->flags_seen_field; temp_mail_data->flags_deleted_field = src_mail_data->flags_deleted_field; temp_mail_data->flags_flagged_field = src_mail_data->flags_flagged_field; temp_mail_data->flags_answered_field = src_mail_data->flags_answered_field; temp_mail_data->flags_recent_field = src_mail_data->flags_recent_field; temp_mail_data->flags_draft_field = src_mail_data->flags_draft_field; temp_mail_data->flags_forwarded_field = src_mail_data->flags_forwarded_field; - temp_mail_data->DRM_status = src_mail_data->DRM_status; - temp_mail_data->priority = src_mail_data->priority; - temp_mail_data->save_status = src_mail_data->save_status; - temp_mail_data->lock_status = src_mail_data->lock_status; - temp_mail_data->report_status = src_mail_data->report_status; - temp_mail_data->attachment_count = src_mail_data->attachment_count; + temp_mail_data->DRM_status = src_mail_data->DRM_status; + temp_mail_data->priority = src_mail_data->priority; + temp_mail_data->save_status = src_mail_data->save_status; + temp_mail_data->lock_status = src_mail_data->lock_status; + temp_mail_data->report_status = src_mail_data->report_status; + temp_mail_data->attachment_count = src_mail_data->attachment_count; temp_mail_data->inline_content_count = src_mail_data->inline_content_count; - temp_mail_data->thread_id = src_mail_data->thread_id; + temp_mail_data->thread_id = src_mail_data->thread_id; temp_mail_data->thread_item_count = src_mail_data->thread_item_count; - temp_mail_data->preview_text = EM_SAFE_STRDUP(src_mail_data->preview_text); + temp_mail_data->preview_text = EM_SAFE_STRDUP(src_mail_data->preview_text); temp_mail_data->meeting_request_status = src_mail_data->meeting_request_status; - temp_mail_data->message_class = src_mail_data->message_class; - temp_mail_data->digest_type = src_mail_data->digest_type; - temp_mail_data->smime_type = src_mail_data->smime_type; + temp_mail_data->message_class = src_mail_data->message_class; + temp_mail_data->digest_type = src_mail_data->digest_type; + temp_mail_data->smime_type = src_mail_data->smime_type; *dst_mail_data = temp_mail_data; - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int _email_copy_mailbox(email_mailbox_t **dst_mailbox, email_mailbox_t *src_mailbox) { + LOGD("START\n"); email_mailbox_t *temp_mailbox = NULL; temp_mailbox = (email_mailbox_t *)calloc(1,sizeof(email_mailbox_t)); if (temp_mailbox == NULL) { - LOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create mailbox", __FUNCTION__, EMAIL_ERROR_OUT_OF_MEMORY); - return EMAIL_ERROR_OUT_OF_MEMORY; + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create mailbox", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; } - temp_mailbox->mailbox_id = src_mailbox->mailbox_id; - temp_mailbox->mailbox_name = EM_SAFE_STRDUP(src_mailbox->mailbox_name); - temp_mailbox->mailbox_type = src_mailbox->mailbox_type; - temp_mailbox->alias = EM_SAFE_STRDUP(src_mailbox->alias); - temp_mailbox->unread_count = src_mailbox->unread_count; + temp_mailbox->mailbox_id = src_mailbox->mailbox_id; + temp_mailbox->mailbox_name = EM_SAFE_STRDUP(src_mailbox->mailbox_name); + temp_mailbox->mailbox_type = src_mailbox->mailbox_type; + temp_mailbox->alias = EM_SAFE_STRDUP(src_mailbox->alias); + temp_mailbox->unread_count = src_mailbox->unread_count; temp_mailbox->total_mail_count_on_local = src_mailbox->total_mail_count_on_local; temp_mailbox->total_mail_count_on_server = src_mailbox->total_mail_count_on_server; - temp_mailbox->local = src_mailbox->local; - temp_mailbox->account_id = src_mailbox->account_id; - temp_mailbox->mail_slot_size = src_mailbox->mail_slot_size; - temp_mailbox->last_sync_time = src_mailbox->last_sync_time; + temp_mailbox->local = src_mailbox->local; + temp_mailbox->account_id = src_mailbox->account_id; + temp_mailbox->mail_slot_size = src_mailbox->mail_slot_size; + temp_mailbox->last_sync_time = src_mailbox->last_sync_time; *dst_mailbox = temp_mailbox; - return EMAIL_ERROR_NONE; + LOGD("END\n"); + return EMAILS_ERROR_NONE; } int _email_copy_handle(email_s **dst_handle, email_s *src_handle) { - int ret = EMAIL_ERROR_NONE; + LOGD("START\n"); + int ret = EMAILS_ERROR_NONE; email_s *msg_s = NULL; msg_s = (email_s *)calloc(1,sizeof(email_s)); - if ((ret = _email_copy_mail_data(&msg_s->mail, src_handle->mail)) != EMAIL_ERROR_NONE) { - LOGE("[%s] _email_copy_mail_data failed", __FUNCTION__); + if (msg_s == NULL) { + SECURE_SLOGE("[%s] calloc failed", __FUNCTION__); + ret = EMAILS_ERROR_OUT_OF_MEMORY; + return ret; + } + + if ((ret = _email_copy_mail_data(&msg_s->mail, src_handle->mail)) != EMAILS_ERROR_NONE) { + SECURE_SLOGE("[%s] _email_copy_mail_data failed", __FUNCTION__); + email_destroy_message((email_h)msg_s); /*prevent 25431*/ return ret; } - if ((ret = _email_copy_mailbox(&msg_s->mbox, src_handle->mbox)) != EMAIL_ERROR_NONE) { - LOGE("[%s] _email_copy_mailbox failed", __FUNCTION__); + if ((ret = _email_copy_mailbox(&msg_s->mbox, src_handle->mbox)) != EMAILS_ERROR_NONE) { + SECURE_SLOGE("[%s] _email_copy_mailbox failed", __FUNCTION__); + email_destroy_message((email_h)msg_s); /*prevent 25431*/ return ret; } *dst_handle = msg_s; + LOGD("END\n"); return ret; } void _email_free_cb_context(email_cb_context *cbcontext) { + LOGD("START\n"); if(cbcontext == NULL) { - LOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAIL_ERROR_INVALID_PARAMETER); + SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); return; } @@ -949,4 +1031,5 @@ void _email_free_cb_context(email_cb_context *cbcontext) } cbcontext = NULL; + LOGD("END\n"); } |