From: Jeesun Kim Date: Fri, 16 Jun 2017 06:10:29 +0000 (+0900) Subject: refactoring code X-Git-Tag: submit/tizen/20170630.043055^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a1525cb2d830851640aa53afb3cbd708bb4f6e52;p=platform%2Fcore%2Fapi%2Femail.git refactoring code Signed-off-by: Jeesun Kim Change-Id: I88d48dba70b3da1af7674a321d4915d851007f9b --- diff --git a/CMakeLists.txt b/CMakeLists.txt index fb617e1..a60f9c5 100644 --- 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 capi-base-common email-service capi-appfw-app-common") +SET(dependents "dlog glib-2.0 capi-base-common email-service capi-appfw-app-common capi-system-info") INCLUDE(FindPkgConfig) pkg_check_modules(${fw_name} REQUIRED ${dependents}) @@ -66,10 +66,10 @@ IF(UNIX) ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) ADD_CUSTOM_COMMAND( - DEPENDS clean + DEPENDS clean COMMENT "distribution clean" COMMAND find - ARGS . + ARGS . -not -name config.cmake -and \( -name tester.c -or -name Testing -or diff --git a/doc/email_doc.h b/doc/email_doc.h index f0c5c78..6ca2310 100755 --- a/doc/email_doc.h +++ b/doc/email_doc.h @@ -19,23 +19,19 @@ #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 - * + * @defgroup CAPI_MESSAGING_EMAIL_MODULE Email * @addtogroup CAPI_MESSAGING_EMAIL_MODULE - * + * @brief The Email API provides functions to create, set properties and send email. * @section CAPI_MESSAGING_EMAIL_MODULE_HEADER Required Header * \#include * - * * @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. @@ -47,6 +43,14 @@ * - Register/unregister a callback function to be called when the sending process is complete, * whether it is sent successfully or not * + * @section CAPI_MESSAGING_EMAIL_MODULE_FEATURE Related Features + * This API is related with the following features:\n + * - http://tizen.org/feature/email\n + * It is recommended to design feature related codes in your application for reliability.\n + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n + * More details on featuring your application can be found from Feature Element. + * * 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. diff --git a/include/email.h b/include/email.h index b18aac3..929ba26 100755 --- a/include/email.h +++ b/include/email.h @@ -14,18 +14,21 @@ * limitations under the License. */ + #ifndef __MESSAGING_EMAIL_H__ #define __MESSAGING_EMAIL_H__ + /** * @addtogroup CAPI_MESSAGING_EMAIL_MODULE * @{ */ + /** - * @file email.h - * @ingroup CAPI_MESSAGING_EMAIL_MODULE - * @brief Messaging API file, support for sending email messages. + * @file email.h + * @ingroup CAPI_MESSAGING_EMAIL_MODULE + * @brief Messaging API file, support for sending email messages. */ @@ -38,209 +41,173 @@ extern "C" { #endif /* __cplusplus */ + /** - * @brief Creates an email message handle for sending an email message. + * @brief Creates an email message handle for sending an email message. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif * @privlevel public * @privilege %http://tizen.org/privilege/email - * - * @remarks You must release @a email using email_destroy_message(). - * - * @param[out] email A handle to the email message - * - * @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 - * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method - * - * @pre At least one email account should be set up on the device. - * + * @remarks You must release @a email using email_destroy_message(). + * @param[out] email A handle to the email message + * @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 + * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @pre At least one email account should be set up on the device. * @see email_destroy_message() */ int email_create_message(email_h *email); + /** - * @brief Destroys the email message handle and releases all its resources. + * @brief Destroys the email message handle and releases all its resources. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * @param[in] email The handle to 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_OPERATION_FAILED Operation failed - * + * @param[in] email The handle to 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_OPERATION_FAILED Operation failed + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported * @see email_create_message() */ int email_destroy_message(email_h email); + /** - * @brief Sets a subject of the email message. + * @brief Sets a subject of the email message. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * * @privlevel public * @privilege %http://tizen.org/privilege/email - - * @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 - * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method - * - * @pre An email message handle is created using email_create_message(). - * - * @see email_create_message() + * @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 + * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @pre An email message handle is created using email_create_message(). + * @see email_create_message() */ int email_set_subject(email_h email, const char *subject); + /** - * @brief Populates a body of the email message. + * @brief Populates a body of the email message. * @details Email message body means the text data to be delivered. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * * @privlevel public * @privilege %http://tizen.org/privilege/mediastorage - * - * @param[in] email The handle to the email message - * @param[in] body The message body - * - * @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 - * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method - * - * @pre An email message handle is created using email_create_message(). - * - * @see email_create_message() + * @param[in] email The handle to the email message + * @param[in] body The message body + * @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 + * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @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); + /** - * @brief Adds a recipient to the email message. + * @brief Adds a recipient to the email message. * @details The email API supports sending an email message to multiple recipients. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * * @remarks Email address should be in standard format (as described in * Internet standards RFC 5321 and RFC 5322). - * - * @param[in] email The handle to the email message - * @param[in] type The recipient type - * @param[in] address The recipient email address - * - * @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(). - * + * @param[in] email The handle to the email message + * @param[in] type The recipient type + * @param[in] address The recipient email address + * @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 + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @pre An email message handle is created using email_create_message(). * @see email_create_message() * @see email_remove_all_recipients() */ int email_add_recipient(email_h email, email_recipient_type_e type, const char *address); + /** - * @brief Removes all recipients for the email message. + * @brief Removes all recipients for the email message. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * @param[in] email The handle to 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 - * - * @pre An email message handle is created using email_create_message(). - * + * @param[in] email The handle to 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_NOT_SUPPORTED Not supported + * @pre An email message handle is created using email_create_message(). * @see email_add_recipient() */ int email_remove_all_recipients(email_h email); + /** - * @brief Adds a file as an attachment to the email message. + * @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. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * @remarks The maximum attachment file size is 10MB. - * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage - * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. - * - * @param[in] email The handle to the email message - * @param[in] filepath The absolute full path of the file to be attached - * - * @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 - * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method - * - * @pre An email message handle is created using email_create_message(). - * + * @remarks The maximum attachment file size is 10MB. + * http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage + * http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. + * @param[in] email The handle to the email message + * @param[in] filepath The absolute full path of the file to be attached + * @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 + * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @pre An email message handle is created using email_create_message(). * @see email_remove_all_attachments() - * */ int email_add_attach(email_h email, const char *filepath); + /** - * @brief Clears all attachments of the email message. + * @brief Clears all attachments of the email message. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * @param[in] email The handle to 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 - * - * @pre An email message handle is created using email_create_message(). - * + * @param[in] email The handle to 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_NOT_SUPPORTED Not supported + * @pre An email message handle is created using email_create_message(). * @see email_create_message() * @see email_add_attach() */ int email_remove_all_attachments(email_h email); + /** - * @brief Saves the email message at outbox. + * @brief Saves the email message at outbox. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * * @privlevel public * @privilege %http://tizen.org/privilege/email - * - * @param[in] email The handle to the email message - * - * @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 - * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method - * - * @pre An email message handle is created using email_create_message(). - * + * @param[in] email The handle to the email message + * @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 + * @retval #EMAILS_ERROR_PERMISSION_DENIED The application does not have the privilege to call this method + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @pre An email message handle is created using email_create_message(). * @see email_create_message() * @see email_add_recipient() * @see email_set_body() @@ -250,26 +217,20 @@ int email_save_message(email_h email); /** - * @brief Sends the email message. + * @brief Sends the email message. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * * @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(). - * + * @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 + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @pre An email message is stored using email_save_message(). * @see email_save_message() * @see email_set_message_sent_cb() */ @@ -277,73 +238,66 @@ int email_send_message(email_h email, bool save_to_sentbox); /** - * @brief Called when the process of sending an email finishes. + * @brief Called when the process of sending an email finishes. * @details You can check whether sending an email succeeds using this function. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * @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 - * + * @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(). - * * @see email_send_message() * @see email_set_message_sent_cb() * @see email_unset_message_sent_cb() */ typedef void (*email_message_sent_cb)(email_h email, email_sending_e result, void *user_data); + /** - * @brief Registers a callback function to be invoked when an email message is sent. + * @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. - * * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * @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(). - * + * @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 + * @retval #EMAILS_ERROR_NOT_SUPPORTED Not supported + * @post It will invoke email_message_sent_cb(). * @see email_message_sent_cb() * @see email_unset_message_sent_cb() * @see email_send_message() */ int email_set_message_sent_cb(email_h email, email_message_sent_cb callback, void *user_data); + /** - * @brief Unregisters the callback function. + * @brief Unregisters the callback function. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif - * - * @param[in] msg The handle to 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 - * + * @param[in] msg The handle to 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_NOT_SUPPORTED Not supported * @see email_message_sent_cb() * @see email_set_message_sent_cb() * @see email_send_message() */ int email_unset_message_sent_cb(email_h msg); + #ifdef __cplusplus } #endif + /** * @} */ + #endif /* __MESSAGING_EMAIL_H__ */ diff --git a/include/email_error.h b/include/email_error.h index 89e1d24..ee2dcc1 100755 --- a/include/email_error.h +++ b/include/email_error.h @@ -18,47 +18,55 @@ #ifndef __EMAILAPI_ERROR_H__ #define __EMAILAPI_ERROR_H__ + #include + #ifdef __cplusplus extern "C" { #endif + /** * @addtogroup CAPI_MESSAGING_EMAIL_MODULE * @{ */ + /** - * @file email_error.h - * @brief Email error definitions. + * @file email_error.h + * @brief Email error definitions. */ + /** - * @brief Enumeration for error codes for email API. + * @brief Enumeration for error codes for email API. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif */ typedef enum { - 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 */ + 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 */ + EMAILS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported (Since 3.0) */ } email_error_e; + /** * @} */ + #ifdef __cplusplus } #endif + #endif /* __EMAILAPI_ERROR_H__*/ diff --git a/include/email_private.h b/include/email_private.h index 755c0c9..6a9d498 100644 --- a/include/email_private.h +++ b/include/email_private.h @@ -19,14 +19,51 @@ #define __TIZEN_EMAIL_PRIVATE_TYPES_H__ #include +#include + #ifdef __cplusplus extern "C" { #endif -#define MAX_ATTACHEMENT_COUNT 50 +#define DBG(fmt, arg...) SLOGD(fmt, ##arg) + +#define FUNC_START() DBG(">>>>>>>> START") +#define FUNC_END() DBG("<<<<<<<< END") + +#define SEC_INFO(fmt, arg...) SECURE_LOGI(fmt, ##arg) +#define SEC_ERR(fmt, arg...) SECURE_LOGE(fmt, ##arg) +#define SEC_DBG(fmt, arg...) SECURE_LOGD(fmt, ##arg) + +#define RET_IF(expr) do { \ + if (expr) { \ + SEC_ERR("(%s)", #expr); \ + return; \ + } \ +} while (0) +#define RETV_IF(expr, val) do { \ + if (expr) { \ + SEC_ERR("(%s)", #expr); \ + return (val); \ + } \ +} while (0) -#define MAX_RECIPIENT_ADDRESS_LEN 234 +#define MAX_ATTACHEMENT_COUNT 50 +#define MAX_RECIPIENT_ADDRESS_LEN 234 +#define EMAIL_FEATURE "http://tizen.org/feature/email" +#define CHECK_EMAILS_SUPPORTED(feature_name) \ + do { \ + bool is_supported = false; \ + if (!system_info_get_platform_bool(feature_name, &is_supported)) { \ + if (is_supported == false) { \ + LOGE("[%s] feature is disabled", feature_name); \ + return EMAILS_ERROR_NOT_SUPPORTED; \ + } \ + } else { \ + LOGE("Error - Feature getting from System Info"); \ + return EMAILS_ERROR_OPERATION_FAILED; \ + } \ + } while (0) typedef struct _email_s { email_mailbox_t *mbox; diff --git a/include/email_types.h b/include/email_types.h index e88f809..ff81af8 100755 --- a/include/email_types.h +++ b/include/email_types.h @@ -18,11 +18,13 @@ #ifndef __TIZEN_EMAIL_TYPES_H__ #define __TIZEN_EMAIL_TYPES_H__ + #ifdef __cplusplus extern "C" { #endif + /** * @addtogroup CAPI_MESSAGING_EMAIL_MODULE * @{ @@ -30,47 +32,50 @@ extern "C" /** - * @file email_types.h - * @ingroup CAPI_MESSAGING_EMAIL_MODULE - * @brief This file defines common types and enums of EMAIL. + * @file email_types.h + * @ingroup CAPI_MESSAGING_EMAIL_MODULE + * @brief This file defines common types and enums of EMAIL. */ /** - * @brief The email message handle. + * @brief The email message handle. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif */ typedef struct email_s *email_h; /** - * @brief Enumeration for the result values of email transport. + * @brief Enumeration for the result values of email transport. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif */ 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 Enumeration for the email recipient types. + * @brief Enumeration for the email recipient types. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 3.0 @endif */ 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; /** * @} */ + + #ifdef __cplusplus } #endif + #endif /* __TIZEN_EMAIL_TYPES_H__*/ diff --git a/packaging/capi-messaging-email.spec b/packaging/capi-messaging-email.spec index 3d8d3e4..611bf6e 100644 --- a/packaging/capi-messaging-email.spec +++ b/packaging/capi-messaging-email.spec @@ -1,6 +1,6 @@ Name: capi-messaging-email Summary: Email library in Tizen Native API -Version: 0.1.16 +Version: 0.1.17 Release: 3 Group: Messaging/API License: Apache-2.0 @@ -14,7 +14,8 @@ BuildRequires: pkgconfig(email-service) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(capi-appfw-app-common) BuildRequires: pkgconfig(capi-appfw-application) -Requires(post): /sbin/ldconfig +BuildRequires: pkgconfig(capi-system-info) +Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig %description @@ -36,8 +37,8 @@ cp %{SOURCE1001} . %build -MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} +MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` +%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} diff --git a/src/email.c b/src/email.c index 762c43a..f09d1cb 100755 --- a/src/email.c +++ b/src/email.c @@ -33,17 +33,8 @@ #endif #define LOG_TAG "CAPI_EMAIL" -#define EM_SAFE_STRDUP(s) \ -({\ - char* _s = (char*)s;\ - (_s) ? strdup(_s) : NULL;\ -}) - -#define EM_SAFE_STRLEN(s) \ -({\ - char* _s = (char*)s;\ - (_s) ? strlen(_s) : 0;\ -}) +#define EM_SAFE_STRDUP(s) (s ? strdup(s) : NULL) +#define EM_SAFE_STRLEN(s) (s ? strlen(s) : 0) static guint g_dbus_return_id = 0; @@ -66,62 +57,69 @@ void _email_free_cb_context(email_cb_context *cbcontext); #define CONVERT_ERROR(err) _email_error_converter(err, __FUNCTION__, __LINE__); - int email_create_message(email_h *msg) { - LOGD("START\n"); - int ret; + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); + + int ret = 0; email_s * msg_s = NULL; email_account_t* account = NULL; int len; - if (msg == NULL) { - 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(); if (ret != EMAIL_ERROR_NONE && ret != EMAIL_ERROR_IPC_ALREADY_INITIALIZED) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] email_service_begin failed : [%d]", __FUNCTION__, ret); return CONVERT_ERROR(ret); + /* LCOV_EXCL_STOP */ } 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) { - SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mail", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); - free(msg_s); - return EMAILS_ERROR_OUT_OF_MEMORY; - } + if (NULL == msg_s) { + /* LCOV_EXCL_START */ + SECURE_SLOGE("[%s] calloc failed", __FUNCTION__); + return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ + } - msg_s->mbox = (email_mailbox_t *)calloc(1, sizeof(email_mailbox_t)); - if (msg_s->mbox == NULL) { - 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 EMAILS_ERROR_OUT_OF_MEMORY; - } - } else { - SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + msg_s->mail = (email_mail_data_t *)calloc(1, sizeof(email_mail_data_t)); + if (msg_s->mail == NULL) { + /* LCOV_EXCL_START */ + SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create msg_s->mail", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + free(msg_s); return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } + msg_s->mbox = (email_mailbox_t *)calloc(1, sizeof(email_mailbox_t)); + if (msg_s->mbox == NULL) { + /* LCOV_EXCL_START */ + 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 EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ + } /* return error from F/W */ /* 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_ERROR_NONE) { + /* LCOV_EXCL_START */ 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); + /* LCOV_EXCL_STOP */ } ret = email_get_account(default_account_id, GET_FULL_DATA_WITHOUT_PASSWORD, &account); if (ret != EMAIL_ERROR_NONE) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] email_get_account failed : [%d]", __FUNCTION__, ret); if (account) email_free_account(&account, 1); @@ -130,6 +128,7 @@ int email_create_message(email_h *msg) email_free_mailbox(&msg_s->mbox, 1); free(msg_s); return CONVERT_ERROR(ret); + /* LCOV_EXCL_STOP */ } SECURE_LOGD("account address = %s", account->user_email_address); @@ -150,11 +149,14 @@ int email_create_message(email_h *msg) email_mailbox_t *mbox = msg_s->mbox; if ((ret = email_get_mailbox_by_mailbox_type(default_account_id, EMAIL_MAILBOX_TYPE_OUTBOX, &mbox)) != EMAIL_ERROR_NONE) { + + /* LCOV_EXCL_START */ 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); + /* LCOV_EXCL_STOP */ } /* info */ @@ -167,19 +169,17 @@ int email_create_message(email_h *msg) msg_s->mail->attachment_count = 0; *msg = (email_h)msg_s; - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int email_destroy_message(email_h msg) { - LOGD("START\n"); - int ret; + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); - if (msg == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + int ret; email_s* msg_s = (email_s*)msg; @@ -194,52 +194,46 @@ int email_destroy_message(email_h msg) } ret = email_service_end(); - if (ret != EMAIL_ERROR_NONE) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] OPERATION_FAILED(0x%08x) : Finishing email service failed", __FUNCTION__, EMAILS_ERROR_OPERATION_FAILED); return EMAILS_ERROR_OPERATION_FAILED; + /* LCOV_EXCL_STOP */ } gEmailcbList = NULL; - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int email_set_subject(email_h msg, const char *subject) { - LOGD("START\n"); - int len; - if (msg == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == subject, EMAILS_ERROR_INVALID_PARAMETER); email_s* msg_s = (email_s*)msg; - - msg_s->mail->subject = (char *)calloc(1, sizeof(char) * strlen(subject) + 1); - + msg_s->mail->subject = strdup(subject); if (msg_s->mail->subject == NULL) { + /* LCOV_EXCL_START */ 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; + /* LCOV_EXCL_STOP */ } - len = strlen(subject) + 1; - snprintf(msg_s->mail->subject, len, "%s", subject); - - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int email_set_body(email_h msg, const char *body) { - LOGD("START\n"); - int len; - - if (msg == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == body, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF('\0' == *body, EMAILS_ERROR_INVALID_PARAMETER); char *prefix_path = NULL; char *file_path = NULL; @@ -247,149 +241,113 @@ int email_set_body(email_h msg, const char *body) FILE* file = NULL; prefix_path = app_get_data_path(); - if (prefix_path) { - LOGD("Prefix_path : [%s]", prefix_path); - file_path = g_strconcat(prefix_path, "/", "utf-8", NULL); - free(prefix_path); - } else { - SECURE_SLOGE("[%s] OPERATION_FAILED(0x%08x) : fail to get data path.", - __FUNCTION__, EMAILS_ERROR_OPERATION_FAILED); + if (NULL == prefix_path) { + /* LCOV_EXCL_START */ + SECURE_SLOGE("app_get_data_path() Fail(%d)", EMAILS_ERROR_OPERATION_FAILED); return EMAILS_ERROR_OPERATION_FAILED; + /* LCOV_EXCL_STOP */ } + LOGD("Prefix_path : [%s]", prefix_path); + file_path = g_strconcat(prefix_path, "/", "utf-8", NULL); if (file_path == NULL) { - SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to allocate file_path.", - __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + /* LCOV_EXCL_START */ + SECURE_SLOGE("g_strconcat() Fail(%d)", EMAILS_ERROR_OUT_OF_MEMORY); + free(prefix_path); return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } + free(prefix_path); file = fopen(file_path, "w"); - if (file != NULL) { - fputs(body, file); - fclose(file); - } else { - free(file_path); - SECURE_SLOGE("[%s] OPERATION_FAILED(0x%08x) : opening file for email body failed.", - __FUNCTION__, EMAILS_ERROR_OPERATION_FAILED); + if (NULL == file) { + /* LCOV_EXCL_START */ + SECURE_SLOGE("fopen() Fail(%d)", EMAILS_ERROR_OPERATION_FAILED); return EMAILS_ERROR_OPERATION_FAILED; + /* LCOV_EXCL_STOP */ } - len = strlen(file_path) + 1; - - msg_s->mail->file_path_plain = (char *)calloc(1, sizeof(char) * len); - if (msg_s->mail->file_path_plain == NULL) { - free(file_path); - 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; - } + fputs(body, file); + fclose(file); - snprintf(msg_s->mail->file_path_plain, len, "%s", file_path); + msg_s->mail->file_path_plain = file_path; - free(file_path); - - LOGD("END\n"); + FUNC_END(); 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 EMAILS_ERROR_INVALID_PARAMETER; - + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(type < EMAIL_RECIPIENT_TYPE_TO, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(EMAIL_RECIPIENT_TYPE_BCC < type, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == address, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(MAX_RECIPIENT_ADDRESS_LEN < strlen(address), EMAILS_ERROR_INVALID_PARAMETER); email_s* msg_s = (email_s*)msg; - - if (strlen(address) > MAX_RECIPIENT_ADDRESS_LEN) { - 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) { if (msg_s->mail->full_address_to == NULL) { - msg_s->mail->full_address_to = (char *)calloc(1, sizeof(char) * strlen(address) + 2 + 1 + 1);/* <>+;+end of string */ + /* <> + ; + end of string */ + msg_s->mail->full_address_to = g_strconcat("<", address, ">", NULL); if (msg_s->mail->full_address_to == NULL) { - SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->to.", - __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + /* LCOV_EXCL_START */ + SECURE_SLOGE("g_strconcat() Fail(%d)", EMAILS_ERROR_OUT_OF_MEMORY); return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } - len = strlen(address) + 2 + 1 + 1; - snprintf(msg_s->mail->full_address_to, len, "%s%s%s", "<", address, ">"); + } else { - in_len = strlen(address); - pre_len = strlen(msg_s->mail->full_address_to); - total_len = pre_len + in_len + 3 + 1;/* length of ",<>" + NULL */ - - /* add new address */ - tmp = msg_s->mail->full_address_to; - msg_s->mail->full_address_to = (char *)calloc(1, sizeof(char) * total_len); - snprintf(msg_s->mail->full_address_to, total_len, "%s%s%s%s", tmp, ",<", address, ">"); - free(tmp); + /* length of ",<>" + NULL */ + char *temp = g_strconcat(msg_s->mail->full_address_to, ",<", address, ">", NULL); + free(msg_s->mail->full_address_to); + msg_s->mail->full_address_to = temp; } } else if (type == EMAIL_RECIPIENT_TYPE_CC) { - /* MESSAGING_RECIPIENT_TYPE_CC */ if (msg_s->mail->full_address_cc == NULL) { - msg_s->mail->full_address_cc = (char *)calloc(1, sizeof(char) * strlen(address) + 2 + 1 + 1);/* <>+;+end of string */ + msg_s->mail->full_address_cc = g_strconcat("<", address, ">", NULL); if (msg_s->mail->full_address_cc == NULL) { - SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->cc.", - __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + /* LCOV_EXCL_START */ + SECURE_SLOGE("g_strconcat() Fail(%d)", EMAILS_ERROR_OUT_OF_MEMORY); return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } - len = strlen(address) + 2 + 1 + 1; - snprintf(msg_s->mail->full_address_cc, len, "%s%s%s", "<", address, ">"); + } else { - in_len = strlen(address); - pre_len = strlen(msg_s->mail->full_address_cc); - total_len = pre_len + in_len + 3 + 1;/* length of ",<>" + NULL */ - - /* add new address */ - tmp = msg_s->mail->full_address_cc; - msg_s->mail->full_address_cc = (char *)calloc(1, sizeof(char) * total_len); - snprintf(msg_s->mail->full_address_cc, total_len, "%s%s%s%s", tmp, ",<", address, ">"); - free(tmp); + char *temp = g_strconcat(msg_s->mail->full_address_cc, ",<", address, ">", NULL); + free(msg_s->mail->full_address_cc); + msg_s->mail->full_address_cc = temp; } } else {/* MESSAGING_RECIPIENT_TYPE_BCC */ if (msg_s->mail->full_address_bcc == NULL) { - msg_s->mail->full_address_bcc = (char *)calloc(1, sizeof(char) * strlen(address) + 2 + 1 + 1);/* <>+;+end of string */ + msg_s->mail->full_address_bcc = g_strconcat("<", address, ">", NULL); if (msg_s->mail->full_address_bcc == NULL) { - SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create head->bcc.", - __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); + /* LCOV_EXCL_START */ + SECURE_SLOGE("g_strconcat() Fail(%d)", EMAILS_ERROR_OUT_OF_MEMORY); return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } - len = strlen(address) + 2 + 1 + 1; - snprintf(msg_s->mail->full_address_bcc, len, "%s%s%s", "<", address, ">"); + } else { - in_len = strlen(address); - pre_len = strlen(msg_s->mail->full_address_bcc); - total_len = pre_len+in_len + 3 + 1;/* length of ",<>" + NULL */ - - /* add new address */ - tmp = msg_s->mail->full_address_bcc; - msg_s->mail->full_address_bcc = (char *)calloc(1, sizeof(char) * total_len); - snprintf(msg_s->mail->full_address_bcc, total_len, "%s%s%s%s", tmp, ",<", address, ">"); - free(tmp); + char *temp = g_strconcat(msg_s->mail->full_address_bcc, ",<", address, ">", NULL); + free(msg_s->mail->full_address_bcc); + msg_s->mail->full_address_bcc = temp; + } } - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int email_remove_all_recipients(email_h msg) { - LOGD("START\n"); - if (msg == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : fail to create tmp memory.", - __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); email_s *msg_s = (email_s *)msg; @@ -407,131 +365,125 @@ int email_remove_all_recipients(email_h msg) free(msg_s->mail->full_address_bcc); msg_s->mail->full_address_bcc = NULL; } - LOGD("END\n"); + + FUNC_END(); 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) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg or filepath is null.", - __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == filepath, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF('\0' == *filepath, EMAILS_ERROR_INVALID_PARAMETER); email_s *msg_s = (email_s *)msg; int attachment_count = msg_s->mail->attachment_count; email_attachment_data_t *new_attach = msg_s->attachment; + struct stat st; stat(filepath, &st); if (st.st_size > 10*1024*1024) { + + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : the size of attachment file is beyond the limit(MAX:10M).", - __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); return EMAILS_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } if (!S_ISREG(st.st_mode)) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : the filepath is not regular file.", - __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); + __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); return EMAILS_ERROR_INVALID_PARAMETER; + /* LCOV_EXCL_STOP */ } + char *pos = (char *)filepath; + char *last = pos; + while ((pos = (strpbrk(pos, "//")))) { + last = pos; + pos++; + } + new_attach[attachment_count].attachment_name = strdup(last); + if (NULL == new_attach[attachment_count].attachment_name) { + /* LCOV_EXCL_START */ + SECURE_SLOGE("strdup() Fail(%d)", EMAILS_ERROR_OUT_OF_MEMORY); + return EMAILS_ERROR_OUT_OF_MEMORY; + } - pos = strpbrk(filepath, "//"); - len = strlen(filepath); - if (pos == NULL) { - new_attach[attachment_count].attachment_name = (char *)calloc(1, sizeof(char)*len+1); - snprintf(new_attach[attachment_count].attachment_name, len+1, "%s", filepath); - } else { - while (pos != NULL) { - last = pos; - pos = strpbrk(pos, "//"); - if (pos != NULL) pos++; - } - - new_attach[attachment_count].attachment_name = strdup(last); + new_attach[attachment_count].attachment_path = strdup(filepath); + if (NULL == new_attach[attachment_count].attachment_path) { + /* LCOV_EXCL_START */ + SECURE_SLOGE("strdup() Fail(%d)", EMAILS_ERROR_OUT_OF_MEMORY); + free(new_attach[attachment_count].attachment_name); + new_attach[attachment_count].attachment_name = NULL; + return EMAILS_ERROR_OUT_OF_MEMORY; } - new_attach[attachment_count].attachment_path = (char *)calloc(1, sizeof(char)*len+1); - 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; new_attach[attachment_count].save_status = 1; - msg_s->mail->attachment_count++; - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; - } int email_remove_all_attachments(email_h msg) { - LOGD("START\n"); - if (msg == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); email_s* msg_s = (email_s*)msg; + if (msg_s->mail) { + msg_s->mail->attachment_count = 0; + } - msg_s->mail->attachment_count = 0; - - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int email_save_message(email_h msg) { - LOGD("START\n"); - int ret; - - if (msg == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); + int ret = 0; email_s *msg_s = (email_s *)msg; ret = email_add_mail(msg_s->mail, msg_s->attachment, msg_s->mail->attachment_count, NULL, 0); ret = CONVERT_ERROR(ret); - LOGD("END\n"); + FUNC_END(); return ret; } int email_send_message(email_h msg, bool save_to_sentbox) { - LOGD("START\n"); - int ret; - int handle; + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); - if (msg == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is null.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return EMAILS_ERROR_INVALID_PARAMETER; - } + int ret = 0; + int handle; email_s *msg_s = (email_s *)msg; - ret = email_send_mail(msg_s->mail->mail_id, &handle); - ret = CONVERT_ERROR(ret); - LOGD("END\n"); + FUNC_END(); return ret; } - email_cb_context *_email_search_callback_by_emailid(int mailid) { - LOGD("START\n"); + FUNC_START(); + int count; int ntmp = 0; GSList *node; @@ -548,19 +500,22 @@ email_cb_context *_email_search_callback_by_emailid(int mailid) if (cbContext->handle->mail->mail_id == mailid) return cbContext; - ntmp++; count--; } - LOGD("END\n"); + FUNC_END(); return NULL; } - int email_set_message_sent_cb(email_h handle, email_message_sent_cb cb, void *user_data) { - LOGD("START\n"); + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == handle, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == ((email_s *)handle)->mail, EMAILS_ERROR_INVALID_PARAMETER); + RETV_IF(NULL == cb, EMAILS_ERROR_INVALID_PARAMETER); + int count; int ntmp = 0; int ret = EMAILS_ERROR_NONE; @@ -571,9 +526,6 @@ int email_set_message_sent_cb(email_h handle, email_message_sent_cb cb, void *us 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) { @@ -596,15 +548,18 @@ int email_set_message_sent_cb(email_h handle, email_message_sent_cb cb, void *us } if ((ret = _email_copy_handle(&msg_s, p_handle)) != EMAILS_ERROR_NONE) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] _email_copy_handle failed", __FUNCTION__); return ret; + /* LCOV_EXCL_STOP */ } email_cb_context *cbcontext = (email_cb_context *)calloc(1, sizeof(email_cb_context)); if (cbcontext == NULL) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] calloc failed", __FUNCTION__); - ret = EMAIL_ERROR_OUT_OF_MEMORY; - return ret; + return EMAIL_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } SECURE_LOGD("mail_id : [%d]\n", msg_s->mail->mail_id); @@ -620,13 +575,16 @@ int email_set_message_sent_cb(email_h handle, email_message_sent_cb cb, void *us /* Set the dbus filter */ _email_add_dbus_filter(); - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int email_unset_message_sent_cb(email_h msg) { - LOGD("START\n"); + FUNC_START(); + CHECK_EMAILS_SUPPORTED(EMAIL_FEATURE); + RETV_IF(NULL == msg, EMAILS_ERROR_INVALID_PARAMETER); + int i, count; count = g_slist_length(gEmailcbList); GSList * node; @@ -634,11 +592,6 @@ int email_unset_message_sent_cb(email_h msg) 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++) { node = g_slist_nth(gEmailcbList, i); @@ -659,72 +612,75 @@ int email_unset_message_sent_cb(email_h msg) /* Remove the dbus filter */ _email_remove_dbus_filter(); - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int _email_error_converter(int err, const char *func, int line) { - LOGD("START\n"); + FUNC_START(); + + /* LCOV_EXCL_START */ switch (err) { case EMAIL_ERROR_INVALID_PARAM: - 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; + 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: - 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; + 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_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; + 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_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; + 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: - 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; + 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: - 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; + 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_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; + 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; + return EMAILS_ERROR_NONE; default: - 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; + 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"); + /* LCOV_EXCL_STOP */ + FUNC_END(); } static void _monitorSendStatusCb(GDBusConnection *connection, - const gchar *sender_name, - const gchar *object_path, - const gchar *interface_name, - const gchar *signal_name, - GVariant *parameters, - gpointer data) + const gchar *sender_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *signal_name, + GVariant *parameters, + gpointer data) { - LOGD("START\n"); + FUNC_START(); int status = 0; int account_id = 0; char *file_id = NULL; @@ -734,17 +690,17 @@ static void _monitorSendStatusCb(GDBusConnection *connection, email_cb_context *cbContext = NULL; if (strncasecmp(interface_name, "USER.EMAIL.NETWORKSTATUS", strlen("USER.EMAIL.NETWORKSTATUS")) && - strncasecmp(sender_name, "EMAIL", strlen("EMAIL"))) { + strncasecmp(sender_name, "EMAIL", strlen("EMAIL"))) { LOGE("Invalid interface : [%s]", interface_name); return; } g_variant_get(parameters, "(iisii)", - &status, - &account_id, - &file_id, - &mail_id, - &error_code); + &status, + &account_id, + &file_id, + &mail_id, + &error_code); SECURE_LOGD("status:[%d], account_id:[%d], file_id:[%s], mail_id:[%d], error_code:[%d]", status, @@ -756,39 +712,40 @@ static void _monitorSendStatusCb(GDBusConnection *connection, cbContext = _email_search_callback_by_emailid(mail_id); if (cbContext == NULL) { SECURE_LOGD("no callback matched!\n"); - } else { - SECURE_LOGD("Address : [%p]\n", cbContext->callback); - switch (status) { - case NOTI_SEND_START: - break; - - case NOTI_SEND_FAIL: - switch (error_code) { - 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; - } + return; + } - cbContext->callback((email_h)cbContext->handle, - (email_sending_e)EMAIL_SENDING_FAILED, - cbContext->user_data); + SECURE_LOGD("Address : [%p]\n", cbContext->callback); + switch (status) { + case NOTI_SEND_START: + break; + + case NOTI_SEND_FAIL: + switch (error_code) { + 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; - case NOTI_SEND_FINISH: - cbContext->callback((email_h)cbContext->handle, - (email_sending_e)EMAIL_SENDING_SUCCEEDED, - cbContext->user_data); + default: break; } + + cbContext->callback((email_h)cbContext->handle, + (email_sending_e)EMAIL_SENDING_FAILED, + cbContext->user_data); + break; + + case NOTI_SEND_FINISH: + cbContext->callback((email_h)cbContext->handle, + (email_sending_e)EMAIL_SENDING_SUCCEEDED, + cbContext->user_data); + break; } LOGE("END\n"); @@ -796,35 +753,33 @@ static void _monitorSendStatusCb(GDBusConnection *connection, void _email_add_dbus_filter(void) { - LOGD("START\n"); - - if (connection != NULL) - return; + FUNC_START(); + RET_IF(NULL != connection); GError *error = NULL; - connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error); if (NULL == connection) { + /* LCOV_EXCL_START */ SECURE_SLOGE("g_bus_get_sync failed : [%s]", error->message); g_error_free(error); return; + /* LCOV_EXCL_STOP */ } LOGD("connection [%p]", connection); g_dbus_return_id = g_dbus_connection_signal_subscribe(connection, - NULL, - "User.Email.NetworkStatus", - "email", - "/User/Email/NetworkStatus", - NULL, - G_DBUS_SIGNAL_FLAGS_NONE, - _monitorSendStatusCb, - NULL, - NULL); + NULL, + "User.Email.NetworkStatus", + "email", + "/User/Email/NetworkStatus", + NULL, + G_DBUS_SIGNAL_FLAGS_NONE, + _monitorSendStatusCb, + NULL, + NULL); if (g_dbus_return_id == -1) LOGE("g_dbus_connection_signal_subscribe failed"); - LOGE("END\n"); } @@ -838,138 +793,145 @@ void _email_remove_dbus_filter(void) int _email_copy_mail_data(email_mail_data_t **dst_mail_data, email_mail_data_t *src_mail_data) { - LOGD("START\n"); + FUNC_START(); 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) { + /* LCOV_EXCL_START */ 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; + /* LCOV_EXCL_STOP */ } - 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; - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int _email_copy_mailbox(email_mailbox_t **dst_mailbox, email_mailbox_t *src_mailbox) { - LOGD("START\n"); + FUNC_START(); email_mailbox_t *temp_mailbox = NULL; temp_mailbox = (email_mailbox_t *)calloc(1, sizeof(email_mailbox_t)); if (temp_mailbox == NULL) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] OUT_OF_MEMORY(0x%08x) : fail to create mailbox", __FUNCTION__, EMAILS_ERROR_OUT_OF_MEMORY); return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } - 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->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; *dst_mailbox = temp_mailbox; - LOGD("END\n"); + FUNC_END(); return EMAILS_ERROR_NONE; } int _email_copy_handle(email_s **dst_handle, email_s *src_handle) { - LOGD("START\n"); + FUNC_START(); int ret = EMAILS_ERROR_NONE; email_s *msg_s = NULL; msg_s = (email_s *)calloc(1, sizeof(email_s)); if (msg_s == NULL) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] calloc failed", __FUNCTION__); - ret = EMAILS_ERROR_OUT_OF_MEMORY; - return ret; + return EMAILS_ERROR_OUT_OF_MEMORY; + /* LCOV_EXCL_STOP */ } - if ((ret = _email_copy_mail_data(&msg_s->mail, src_handle->mail)) != EMAILS_ERROR_NONE) { + ret = _email_copy_mail_data(&msg_s->mail, src_handle->mail); + if (ret != EMAILS_ERROR_NONE) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] _email_copy_mail_data failed", __FUNCTION__); email_destroy_message((email_h)msg_s); /*prevent 25431*/ return ret; + /* LCOV_EXCL_STOP */ } - if ((ret = _email_copy_mailbox(&msg_s->mbox, src_handle->mbox)) != EMAILS_ERROR_NONE) { + ret = _email_copy_mailbox(&msg_s->mbox, src_handle->mbox); + if (ret != EMAILS_ERROR_NONE) { + /* LCOV_EXCL_START */ SECURE_SLOGE("[%s] _email_copy_mailbox failed", __FUNCTION__); email_destroy_message((email_h)msg_s); /*prevent 25431*/ return ret; + /* LCOV_EXCL_STOP */ } *dst_handle = msg_s; - LOGD("END\n"); + FUNC_END(); return ret; } void _email_free_cb_context(email_cb_context *cbcontext) { - LOGD("START\n"); - if (cbcontext == NULL) { - SECURE_SLOGE("[%s] INVALID_PARAMETER(0x%08x) : msg is NULL.", __FUNCTION__, EMAILS_ERROR_INVALID_PARAMETER); - return; - } + FUNC_START(); + RET_IF(NULL == cbcontext); email_s* msg_s = cbcontext->handle; - if (msg_s) { if (msg_s->mail) email_free_mail_data(&msg_s->mail, 1); @@ -981,5 +943,5 @@ void _email_free_cb_context(email_cb_context *cbcontext) } cbcontext = NULL; - LOGD("END\n"); + FUNC_END(); }