summaryrefslogtreecommitdiff
path: root/email-api
diff options
context:
space:
mode:
authorKim Kibum <kb0929.kim@samsung.com>2012-04-29 17:00:22 +0900
committerKim Kibum <kb0929.kim@samsung.com>2012-04-29 17:00:22 +0900
commit328e0f651f27a1c11ca81f19a2ba54b720ef1359 (patch)
tree13919877947a51a69e6b63c9e04846942e4e480e /email-api
parent0a019153217b1e27bc7ada4a27ef2930cb671191 (diff)
downloademail-service-328e0f651f27a1c11ca81f19a2ba54b720ef1359.tar.gz
email-service-328e0f651f27a1c11ca81f19a2ba54b720ef1359.tar.bz2
email-service-328e0f651f27a1c11ca81f19a2ba54b720ef1359.zip
upload tizen1.0 source
Diffstat (limited to 'email-api')
-rwxr-xr-xemail-api/CMakeLists.txt77
-rwxr-xr-xemail-api/email-api-account.c705
-rwxr-xr-xemail-api/email-api-init.c132
-rwxr-xr-xemail-api/email-api-mail.c2225
-rwxr-xr-xemail-api/email-api-mailbox.c593
-rwxr-xr-xemail-api/email-api-network.c1503
-rwxr-xr-xemail-api/email-api-rule.c236
-rwxr-xr-xemail-api/include/email-api-account.h415
-rwxr-xr-xemail-api/include/email-api-init.h174
-rwxr-xr-xemail-api/include/email-api-mail.h1869
-rwxr-xr-xemail-api/include/email-api-mailbox.h353
-rwxr-xr-xemail-api/include/email-api-network.h403
-rwxr-xr-xemail-api/include/email-api-rule.h218
-rwxr-xr-xemail-api/include/email-api.h74
14 files changed, 8977 insertions, 0 deletions
diff --git a/email-api/CMakeLists.txt b/email-api/CMakeLists.txt
new file mode 100755
index 0000000..15ce59c
--- /dev/null
+++ b/email-api/CMakeLists.txt
@@ -0,0 +1,77 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(email-api)
+
+SET(CMAKE_SKIP_BUILD_RPATH TRUE)
+
+IF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+ SET(CMAKE_BUILD_TYPE "Debug")
+ENDIF("${CMAKE_BUILD_TYPE}" STREQUAL "")
+
+MESSAGE("")
+MESSAGE(">>> current directory: ${CMAKE_CURRENT_SOURCE_DIR}")
+MESSAGE(">>> Build type: ${CMAKE_BUILD_TYPE}")
+
+
+SET(VISIBILITY "-DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\"")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${VISIBILITY} -fvisibility=hidden")
+
+##########################################################
+# Define Email API
+##########################################################
+
+SET(API-LIB "email-api")
+SET(API-SRCS
+ ${CMAKE_SOURCE_DIR}/email-api/email-api-account.c
+ ${CMAKE_SOURCE_DIR}/email-api/email-api-mail.c
+ ${CMAKE_SOURCE_DIR}/email-api/email-api-network.c
+ ${CMAKE_SOURCE_DIR}/email-api/email-api-rule.c
+ ${CMAKE_SOURCE_DIR}/email-api/email-api-mailbox.c
+ ${CMAKE_SOURCE_DIR}/email-api/email-api-init.c
+)
+
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/email-daemon/include
+ ${CMAKE_SOURCE_DIR}/email-api/include
+ ${CMAKE_SOURCE_DIR}/email-api/socket/include
+ ${CMAKE_SOURCE_DIR}/email-ipc/include
+ ${CMAKE_SOURCE_DIR}/email-core/include
+ ${CMAKE_SOURCE_DIR}/email-core/email-storage/include
+ ${CMAKE_SOURCE_DIR}/email-common-use/include
+)
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(api_pkgs REQUIRED glib-2.0 dlog dbus-1 vconf heynoti db-util contacts-service uw-imap-toolkit)
+
+FOREACH(flag ${api_pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
+
+ADD_LIBRARY(${API-LIB} SHARED ${API-SRCS})
+
+TARGET_LINK_LIBRARIES(${API-LIB} ${api_pkgs_LDFLAGS} email-ipc email-storage email-core email-common-use email-network)
+#${NETWORK-LIB} ${CORE-LIB} ${STORAGE-LIB} ${IPC-LIB} ${COMMON-LIB})
+
+SET_TARGET_PROPERTIES(${API-LIB} PROPERTIES SOVERSION ${VERSION_MAJOR})
+SET_TARGET_PROPERTIES(${API-LIB} PROPERTIES VERSION ${VERSION})
+
+#INSTALL(TARGETS ${API-LIB} LIBRARY DESTINATION lib)
+INSTALL(TARGETS ${API-LIB} DESTINATION lib COMPONENT RuntimeLibraries)
+
+SET(EMAIL-API-HEADERS
+ ${CMAKE_SOURCE_DIR}/email-api/include/email-api.h
+ ${CMAKE_SOURCE_DIR}/email-api/include/email-api-account.h
+ ${CMAKE_SOURCE_DIR}/email-api/include/email-api-init.h
+ ${CMAKE_SOURCE_DIR}/email-api/include/email-api-mail.h
+ ${CMAKE_SOURCE_DIR}/email-api/include/email-api-mailbox.h
+ ${CMAKE_SOURCE_DIR}/email-api/include/email-api-network.h
+ ${CMAKE_SOURCE_DIR}/email-api/include/email-api-rule.h
+ ${CMAKE_SOURCE_DIR}/email-common-use/include/email-types.h
+ ${CMAKE_SOURCE_DIR}/email-common-use/include/email-errors.h
+)
+
+INSTALL(FILES ${EMAIL-API-HEADERS} DESTINATION include/email-service)
+
diff --git a/email-api/email-api-account.c b/email-api/email-api-account.c
new file mode 100755
index 0000000..3962e70
--- /dev/null
+++ b/email-api/email-api-account.c
@@ -0,0 +1,705 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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.
+*
+*/
+
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-account.c
+ * @brief This file contains the data structures and interfaces of Account related Functionality provided by
+ * email-service .
+ */
+
+#include "email-api.h"
+#include "string.h"
+#include "email-convert.h"
+#include "email-api-account.h"
+#include "email-storage.h"
+#include "email-core-mail.h"
+#include "email-core-account.h"
+#include "email-core-utils.h"
+#include "email-utilities.h"
+#include "email-ipc.h"
+
+/* API - Adds the Email Account */
+EXPORT_API int email_add_account(emf_account_t* account)
+{
+ EM_DEBUG_FUNC_BEGIN("account[%p]", account);
+ char* local_account_stream = NULL;
+ int ret = -1;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+
+ if ( !account ) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ local_account_stream = em_convert_account_to_byte_stream(account, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_SAFE_FREE(local_account_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ EM_DEBUG_LOG("APPID[%d], APIID [%d]", emipc_get_app_id(hAPI), emipc_get_api_id(hAPI));
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(local_account_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+ if(ret == EMF_ERROR_NONE) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &account->account_id);
+ } else { /* get error code */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ }
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_SAFE_FREE(local_account_stream);
+ EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err);
+ return err;
+}
+
+
+EXPORT_API int email_free_account(emf_account_t** account_list, int count)
+{
+ EM_DEBUG_FUNC_BEGIN("account_list[%p], count[%d]", account_list, count);
+
+ /* default variable */
+ int err = EMF_ERROR_NONE;
+
+ if (count > 0) {
+ if (!account_list || !*account_list) {
+ err = EMF_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+ emf_account_t* p = *account_list;
+ int i;
+
+ for (i = 0; i < count; i++) {
+ EM_SAFE_FREE(p[i].account_name);
+ EM_SAFE_FREE(p[i].receiving_server_addr);
+ EM_SAFE_FREE(p[i].email_addr);
+ EM_SAFE_FREE(p[i].user_name);
+ EM_SAFE_FREE(p[i].password);
+ EM_SAFE_FREE(p[i].sending_server_addr);
+ EM_SAFE_FREE(p[i].sending_user);
+ EM_SAFE_FREE(p[i].sending_password);
+ EM_SAFE_FREE(p[i].display_name);
+ EM_SAFE_FREE(p[i].reply_to_addr);
+ EM_SAFE_FREE(p[i].return_addr);
+ EM_SAFE_FREE(p[i].logo_icon_path);
+ EM_SAFE_FREE(p[i].options.display_name_from);
+ EM_SAFE_FREE(p[i].options.signature);
+ }
+ free(p); *account_list = NULL;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("ERROR CODE [%d]", err);
+ return err;
+}
+
+
+/* API - Delete the Email Account */
+EXPORT_API int email_delete_account(int account_id)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
+
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+
+ if (account_id < 0 || account_id == 0) {
+ EM_DEBUG_EXCEPTION(" account_id[%d]", account_id);
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ACCOUNT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+ if(ret != EMF_ERROR_NONE) { /* get error code */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ }
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err);
+ return err;
+}
+
+/* API - Update the Email Account */
+EXPORT_API int email_update_account(int account_id, emf_account_t* new_account)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p]", account_id, new_account);
+
+ int ret = 0;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ int with_validation = false;
+ char* new_account_stream = NULL;
+
+ if ((account_id <= 0) || !new_account || (with_validation != false && with_validation != true)) {
+ EM_DEBUG_EXCEPTION("account_id[%d], new_account[%p], with_validation[%d]", account_id, new_account, with_validation);
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_ACCOUNT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed ");
+ goto FINISH_OFF;
+ }
+
+ /* new_account */
+ new_account_stream = em_convert_account_to_byte_stream(new_account, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter new_account failed ");
+ goto FINISH_OFF;
+ }
+
+ /* with_validation */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter with_validation failed ");
+ goto FINISH_OFF;
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(new_account_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+
+ if(ret != EMF_ERROR_NONE) {
+ /* get error code */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ }
+
+FINISH_OFF:
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_SAFE_FREE(new_account_stream);
+ EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err);
+ return err;
+}
+
+/* API - Update the Email Account */
+EXPORT_API int email_update_account_with_validation(int account_id, emf_account_t* new_account)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], new_account[%p]", account_id, new_account);
+
+ int ret = 0;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ int with_validation = true;
+ char* new_account_stream = NULL;
+
+ if ((account_id <= 0) || !new_account || (with_validation != false && with_validation != true)) {
+ EM_DEBUG_EXCEPTION(" account_id[%d], new_account[%p], with_validation[%d]", account_id, new_account, with_validation);
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_ACCOUNT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* new_account */
+ new_account_stream = em_convert_account_to_byte_stream(new_account, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(new_account_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, new_account_stream, size)) {
+ EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter new_account failed ");
+ EM_SAFE_FREE(new_account_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* with_validation */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_validation, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("email_update_account--emipc_add_parameter with_validation failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("email_update_account--emipc_execute_proxy_api failed ");
+ /* Prevent defect 18624 */
+ EM_SAFE_FREE(new_account_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+ if(ret != EMF_ERROR_NONE) { /* get error code */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ }
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_SAFE_FREE(new_account_stream);
+ EM_DEBUG_FUNC_END("RETURN VALUE [%d], ERROR CODE [%d]", ret, err);
+ return err;
+
+
+}
+
+
+/* API - Get the account Information based on the account ID */
+EXPORT_API int email_get_account(int account_id, int pulloption, emf_account_t** account)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+ emstorage_account_tbl_t *account_tbl = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(account, EMF_ERROR_INVALID_PARAM);
+
+ if (pulloption == GET_FULL_DATA)
+ pulloption = EMF_ACC_GET_OPT_FULL_DATA;
+
+ if (pulloption & EMF_ACC_GET_OPT_PASSWORD) {
+ pulloption = pulloption & (~(EMF_ACC_GET_OPT_PASSWORD)); /* disable password -Can't obtain password by MAPI */
+ EM_DEBUG_LOG("change pulloption : disable password");
+ }
+
+ if (!emstorage_get_account_by_id(account_id, pulloption, &account_tbl, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_by_id failed - %d", err);
+ goto FINISH_OFF;
+ }
+
+ *account = em_malloc(sizeof(emf_account_t));
+ if (!*account) {
+ EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ memset((void*)*account, 0, sizeof(emf_account_t));
+ em_convert_account_tbl_to_account(account_tbl, *account);
+
+
+ ret = true;
+
+FINISH_OFF:
+ if (account_tbl)
+ emstorage_free_account(&account_tbl, 1, NULL);
+
+ EM_DEBUG_FUNC_END();
+ return err;
+}
+
+EXPORT_API int email_get_account_list(emf_account_t** account_list, int* count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE, i = 0;
+ emstorage_account_tbl_t *temp_account_tbl = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(account_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_account_list(count, &temp_account_tbl , true, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ if(temp_account_tbl && (*count) > 0) {
+ *account_list = em_malloc(sizeof(emf_account_t) * (*count));
+ if(!*account_list) {
+ EM_DEBUG_EXCEPTION("allocation failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ memset((void*)*account_list, 0, sizeof(emf_account_t) * (*count));
+ for(i = 0; i < (*count); i++)
+ em_convert_account_tbl_to_account(temp_account_tbl + i, (*account_list) + i);
+ }
+
+FINISH_OFF:
+
+
+ if(temp_account_tbl)
+ emstorage_free_account(&temp_account_tbl, (*count), NULL);
+ EM_DEBUG_FUNC_END("err[%d]", err);
+ return err;
+
+}
+
+EXPORT_API int email_validate_account(int account_id, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], handle[%p]", account_id, handle);
+
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+ if (account_id <= 0) {
+ EM_DEBUG_EXCEPTION("account_id[%d]", account_id);
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_VALIDATE_ACCOUNT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret); /* return */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err); /* error code */
+
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), handle);
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("err[%d]", err);
+ return err;
+
+}
+
+
+EXPORT_API int email_add_account_with_validation(emf_account_t* account, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("account[%p]", account);
+ char* local_account_stream = NULL;
+ int ret = -1;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(account, false);
+
+ if(emstorage_check_duplicated_account(account, true, &err) == false) {
+ EM_DEBUG_EXCEPTION("emstorage_check_duplicated_account failed (%d) ", err);
+
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_ACCOUNT_WITH_VALIDATION);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ EM_DEBUG_LOG("Before em_convert_account_to_byte_stream");
+ local_account_stream = em_convert_account_to_byte_stream(account, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(local_account_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_account_stream, size)) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter failed ");
+ EM_SAFE_FREE(local_account_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+ if(ret == EMF_ERROR_NONE) {
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ } else {
+ /* get error code */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ }
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_SAFE_FREE(local_account_stream);
+ EM_DEBUG_FUNC_END("err[%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name)
+{
+ EM_DEBUG_FUNC_BEGIN("file_name[%s]", file_name);
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+
+ if (!file_name) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_BACKUP_ACCOUNTS);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* file_name */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, strlen(file_name))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+
+ if(0 == ret) { /* get error code */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ }
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("err[%d]", err);
+ return err;
+}
+
+EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name)
+{
+ EM_DEBUG_FUNC_BEGIN("file_name[%s]", file_name);
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+
+ if (!file_name) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_RESTORE_ACCOUNTS);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* file_name */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)file_name, strlen(file_name))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+
+ if(0==ret) { /* get error code */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ }
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("err[%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_password_length_of_account(const int account_id, int *password_length)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], password_length[%p]", account_id, password_length);
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+
+ if (account_id <= 0 || password_length == NULL) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_PASSWORD_LENGTH_OF_ACCOUNT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &ret);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &err);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), password_length);
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("*password_length[%d]", *password_length);
+ return err;
+}
+
+EXPORT_API int email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info)
+{
+ EM_DEBUG_FUNC_BEGIN("domain_name [%s], result_server_info [%p]", domain_name, result_server_info);
+ int err = EMF_ERROR_NONE;
+
+ if (!domain_name || !result_server_info) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ err = emcore_query_server_info(domain_name, result_server_info);
+
+ EM_DEBUG_FUNC_END("err[%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_free_server_info(emf_server_info_t **result_server_info)
+{
+ EM_DEBUG_FUNC_BEGIN("result_server_info [%p]", result_server_info);
+ int err = EMF_ERROR_NONE;
+
+ if (!result_server_info) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ err = emcore_free_server_info(result_server_info);
+
+ EM_DEBUG_FUNC_END("ret[%d]", err);
+ return err;
+}
+
+EXPORT_API int email_update_notification_bar(int account_id)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id [%d]", account_id);
+ int err = EMF_ERROR_NONE;
+
+ if (account_id == 0) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_NOTIFICATION_BAR_FOR_UNREAD_MAIL);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter account_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION(" emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("ret[%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_clear_all_notification_bar()
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+
+ ret = emcore_clear_all_notifications();
+
+ EM_DEBUG_FUNC_END("ret[%d]", ret);
+ return err;
+}
+
+EXPORT_API int email_save_default_account_id(int input_account_id)
+{
+ EM_DEBUG_FUNC_BEGIN("input_account_id [%d]", input_account_id);
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+
+ ret = emcore_save_default_account_id(input_account_id);
+
+ EM_DEBUG_FUNC_END("ret[%d]", ret);
+ return err;
+}
+
+EXPORT_API int email_load_default_account_id(int *output_account_id)
+{
+ EM_DEBUG_FUNC_BEGIN("output_account_id [%p]", output_account_id);
+ int ret = 0;
+ int err = EMF_ERROR_NONE;
+
+ ret = emcore_load_default_account_id(output_account_id);
+
+ EM_DEBUG_FUNC_END("ret[%d]", ret);
+ return err;
+}
diff --git a/email-api/email-api-init.c b/email-api/email-api-init.c
new file mode 100755
index 0000000..000ddc0
--- /dev/null
+++ b/email-api/email-api-init.c
@@ -0,0 +1,132 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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.
+*
+*/
+
+
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-init.c
+ * @brief This file contains the data structures and interfaces of Email FW intialization related Functionality provided by
+ * email-service .
+ */
+
+#include "email-api.h"
+#include "string.h"
+#include "email-convert.h"
+#include "email-storage.h"
+#include "email-ipc.h"
+#include <sqlite3.h>
+
+
+EXPORT_API int email_open_db(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMF_ERROR_NONE;
+
+ if (emstorage_db_open(&error) == NULL)
+ EM_DEBUG_EXCEPTION("emstorage_db_open failed [%d]", error);
+
+
+ EM_DEBUG_FUNC_END("error [%d]", error);
+
+ return error;
+}
+
+EXPORT_API int email_close_db(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMF_ERROR_NONE;
+
+ if ( !emstorage_db_close(&error))
+ EM_DEBUG_EXCEPTION("emstorage_db_close failed [%d]", error);
+
+ EM_DEBUG_FUNC_END("error [%d]", error);
+ return error;
+}
+
+
+EXPORT_API int email_service_begin(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int ret = -1;
+
+ signal(SIGPIPE, SIG_IGN); /* to ignore signal 13(SIGPIPE) */
+
+ ret = emipc_initialize_proxy();
+ if (ret != EMF_ERROR_NONE)
+ EM_DEBUG_FUNC_END("err[%d]", ret);
+
+ return ret;
+}
+
+
+EXPORT_API int email_service_end(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int ret = -1;
+
+ ret = emipc_finalize_proxy();
+ if (ret != EMF_ERROR_NONE)
+ EM_DEBUG_FUNC_END("err[%d]", ret);
+
+ return ret;
+}
+
+/* API - Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL] */
+
+
+EXPORT_API int email_init_storage(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMF_ERROR_NONE;
+
+ if (!emstorage_create_table(EMF_CREATE_DB_CHECK, &error)) {
+ EM_DEBUG_EXCEPTION("emstorage_create_table failed [%d]", error);
+ }
+
+ EM_DEBUG_FUNC_END("error[%d]", error);
+ return error;
+}
+
+EXPORT_API int email_ping_service(void)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int error = EMF_ERROR_NONE;
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_PING_SERVICE);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &error);
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+
+ EM_DEBUG_FUNC_END("err[%d]", error);
+ return error;
+}
diff --git a/email-api/email-api-mail.c b/email-api/email-api-mail.c
new file mode 100755
index 0000000..fd82130
--- /dev/null
+++ b/email-api/email-api-mail.c
@@ -0,0 +1,2225 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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.
+*
+*/
+
+
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-mail.c
+ * @brief This file contains the data structures and interfaces of Message related Functionality provided by
+ * email-service .
+ */
+
+#include <stdlib.h>
+#include <time.h>
+#include <string.h>
+#include "email-api.h"
+#include "email-ipc.h"
+#include "email-convert.h"
+#include "email-core-utils.h"
+#include "email-core-mail.h"
+#include "email-core-smtp.h"
+#include "email-storage.h"
+#include "email-utilities.h"
+#include "db-util.h"
+
+#define DIR_SEPERATOR_CH '/'
+
+#define _DIRECT_TO_DB
+
+EXPORT_API int email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count [%d], input_meeting_request [%p], input_from_eas [%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
+
+ EM_IF_NULL_RETURN_VALUE(input_mail_data, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_name, EMF_ERROR_INVALID_PARAM);
+
+ if(input_attachment_count > 0 && !input_attachment_data_list) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+ char *mail_data_stream = NULL;
+ char *attachment_data_list_stream = NULL;
+ char *meeting_request_stream = NULL;
+ HIPC_API hAPI = NULL;
+
+ if(input_from_eas == 0) {
+ hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAIL);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* emf_mail_data_t */
+ mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size);
+
+ if(!mail_data_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter for head failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* emf_attachment_data_t */
+ attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size);
+
+ if(!attachment_data_list_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* emf_meeting_request_t */
+ if ( input_mail_data->meeting_request_status != EMF_MAIL_TYPE_NORMAL ) {
+ meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size);
+
+ if(!meeting_request_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ }
+
+ /* input_from_eas */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if(err == EMF_ERROR_NONE) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &input_mail_data->mail_id); /* result mail_id */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &input_mail_data->thread_id); /* result thread_id */
+ }
+ }
+ else {
+ if((err = emcore_add_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_add_mail failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_SAFE_FREE(mail_data_stream);
+ EM_SAFE_FREE(attachment_data_list_stream);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id)
+{
+ EM_DEBUG_FUNC_BEGIN("input_read_mail_id [%d], output_receipt_mail_id [%p]", input_read_mail_id, output_receipt_mail_id);
+
+ EM_IF_NULL_RETURN_VALUE(output_receipt_mail_id, EMF_ERROR_INVALID_PARAM);
+
+ int err = EMF_ERROR_NONE;
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_READ_RECEIPT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &input_read_mail_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("Add Param mail body Fail");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ EM_DEBUG_LOG("err [%d]", err);
+
+ if(err == EMF_ERROR_NONE) {
+ /* Get receipt mail id */
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_receipt_mail_id);
+ EM_DEBUG_LOG("output_receipt_mail_id [%d]", *output_receipt_mail_id);
+ }
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+int email_create_db_full()
+{
+ int mailbox_index, mail_index, mailbox_count, mail_slot_size;
+ emstorage_mail_tbl_t mail_table_data = {0};
+ emf_mailbox_t *mailbox_list = NULL;
+ int err = EMF_ERROR_NONE;
+
+ if ( (err = email_open_db()) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("email_open_db failed [%d]", err);
+ return err;
+ }
+
+ mail_table_data.subject = (char*) em_malloc(50);
+ mail_table_data.full_address_from = strdup("<dummy_from@nowhere.com>");
+ mail_table_data.full_address_to = strdup("<dummy_to@nowhere.com>");
+ mail_table_data.account_id =1;
+ mail_table_data.mailbox_name = (char*) em_malloc(250);
+
+ if( (err = email_get_mailbox_list_ex(1, -1, 0, &mailbox_list, &mailbox_count)) < EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("email_get_mailbox_list_ex failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ for(mailbox_index = 0; mailbox_index < mailbox_count; mailbox_index++) {
+ mail_slot_size= mailbox_list[mailbox_index].mail_slot_size;
+ for(mail_index = 0; mail_index < mail_slot_size; mail_index++) {
+ sprintf(mail_table_data.subject, "Subject #%d",mail_index);
+ strncpy(mail_table_data.mailbox_name, mailbox_list[mailbox_index].name, 250 - 1);
+ mail_table_data.mailbox_type = mailbox_list[mailbox_index].mailbox_type;
+ if( !emstorage_add_mail(&mail_table_data, 1, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_add_mail failed [%d]",err);
+
+ goto FINISH_OFF;
+ }
+ }
+ }
+
+FINISH_OFF:
+ if ( (err = email_close_db()) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("email_close_db failed [%d]", err);
+ }
+
+ if(mailbox_list)
+ email_free_mailbox(&mailbox_list, mailbox_count);
+
+ EM_SAFE_FREE(mail_table_data.subject);
+ EM_SAFE_FREE(mail_table_data.mailbox_name);
+ EM_SAFE_FREE(mail_table_data.full_address_from);
+ EM_SAFE_FREE(mail_table_data.full_address_to);
+
+ return err;
+}
+
+EXPORT_API int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mail_data[%p], input_attachment_data_list[%p], input_attachment_count [%d], input_meeting_request [%p], input_from_eas [%d]", input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas);
+
+ EM_IF_NULL_RETURN_VALUE(input_mail_data, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_mail_data->account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_mail_data->mailbox_name, EMF_ERROR_INVALID_PARAM);
+
+ if(input_attachment_count > 0 && !input_attachment_data_list) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+ char *mail_data_stream = NULL;
+ char *attachment_data_list_stream = NULL;
+ char *meeting_request_stream = NULL;
+
+ HIPC_API hAPI = NULL;
+
+ if(input_from_eas == 0) {
+ hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_MAIL);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* emf_mail_data_t */
+ mail_data_stream = em_convert_mail_data_to_byte_stream(input_mail_data, 1, &size);
+
+ if(!mail_data_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_data_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mail_data_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter for head failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* emf_attachment_data_t */
+ attachment_data_list_stream = em_convert_attachment_data_to_byte_stream(input_attachment_data_list, input_attachment_count, &size);
+
+ if(!attachment_data_list_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_attachment_data_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, attachment_data_list_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* emf_meeting_request_t */
+ if ( input_mail_data->meeting_request_status != EMF_MAIL_TYPE_NORMAL ) {
+ meeting_request_stream = em_convert_meeting_req_to_byte_stream(input_meeting_request, &size);
+
+ if(!meeting_request_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_meeting_req_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, meeting_request_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ }
+
+ /* input_from_eas */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&input_from_eas, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if(err == EMF_ERROR_NONE) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &input_mail_data->mail_id);
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 2, sizeof(int), &input_mail_data->thread_id);
+ }
+ }
+ else {
+ if( (err = emcore_update_mail(input_mail_data, input_attachment_data_list, input_attachment_count, input_meeting_request, input_from_eas)) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_update_mail failed [%d]", err);
+ goto FINISH_OFF;
+ }
+ }
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_SAFE_FREE(mail_data_stream);
+ EM_SAFE_FREE(attachment_data_list_stream);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+EXPORT_API int email_clear_mail_data()
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMF_ERROR_NONE;
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_CLEAR_DATA);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Fail");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen);
+
+ int total_count = 0;
+ int unread = 0;
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(unseen, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_mail_count(mailbox->account_id, mailbox->name, &total_count, &unread, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
+
+ } else {
+ *total = total_count;
+ *unseen = unread;
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+
+EXPORT_API int email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p], unseen[%p]", mailbox, total, unseen);
+
+ int total_count = 0;
+ int unread = 0;
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(unseen, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_mail_count(mailbox->account_id, NULL, &total_count, &unread, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
+
+ } else {
+ *total = total_count;
+ *unseen = unread;
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+EXPORT_API int email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%p], num[%d], from_server[%d]", mailbox, mail_ids, num, from_server);
+
+ char* mailbox_stream = NULL;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ HIPC_API hAPI = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ if (num <= 0) {
+ EM_DEBUG_EXCEPTION("num = %d", num);
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAIL);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ if(!mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Number of mail_ids */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* set of mail_ids */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* from-server */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&from_server, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_SAFE_FREE(mailbox_stream);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], from_server[%d]", mailbox, from_server);
+
+ char* mailbox_stream = NULL;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ HIPC_API hAPI = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ hAPI =emipc_create_email_api(_EMAIL_API_DELETE_ALL_MAIL);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ if(!mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&from_server, sizeof(int))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int),&err );
+
+FINISH_OFF:
+
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_SAFE_FREE(mailbox_stream);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+EXPORT_API int email_add_attachment( emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment[%p]", mailbox, mail_id, attachment);
+ int err = EMF_ERROR_NONE;
+ char* mailbox_stream = NULL;
+ char* pAttchStream = NULL;
+ int size = 0;
+ HIPC_API hAPI = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(attachment, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ hAPI = emipc_create_email_api(_EMAIL_API_ADD_ATTACHMENT);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ if(!mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* mail_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Attachment */
+ pAttchStream = em_convert_attachment_info_to_byte_stream(attachment, &size);
+
+ if(!pAttchStream) {
+ EM_DEBUG_EXCEPTION("em_convert_attachment_info_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pAttchStream, size)){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if(EMF_ERROR_NONE == err) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &attachment->attachment_id);
+ }
+
+FINISH_OFF:
+ EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(pAttchStream);
+
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+ }
+
+
+EXPORT_API int email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char *attachment_id)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s]", mailbox, mail_id, attachment_id);
+ int err = EMF_ERROR_NONE;
+ char* mailbox_stream = NULL;
+ int size = 0;
+
+ HIPC_API hAPI = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(attachment_id, EMF_ERROR_INVALID_PARAM);
+
+ hAPI = emipc_create_email_api(_EMAIL_API_DELETE_ATTACHMENT);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ if(!mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* mail_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* attachment_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)attachment_id, strlen(attachment_id))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_SAFE_FREE(mailbox_stream);
+
+ return err;
+}
+
+/* -----------------------------------------------------------
+ Mail Search API
+ -----------------------------------------------------------*/
+
+EXPORT_API int email_query_mails(char *conditional_clause_string, emf_mail_data_t** mail_list, int *result_count)
+{
+ EM_DEBUG_FUNC_BEGIN("conditional_clause_string [%s], mail_list [%p], result_count [%p]", conditional_clause_string, mail_list, result_count);
+
+ int err = EMF_ERROR_NONE;
+ emstorage_mail_tbl_t *result_mail_tbl;
+
+ EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_query_mail_tbl(conditional_clause_string, true, &result_mail_tbl, result_count, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_query_mail_list failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ if(!em_convert_mail_tbl_to_mail_data(result_mail_tbl, *result_count, mail_list, &err)) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ if(result_mail_tbl && !emstorage_free_mail(&result_mail_tbl, *result_count, &err))
+ EM_DEBUG_EXCEPTION("emstorage_free_mail failed [%d]", err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_query_message_ex(char *conditional_clause_string, emf_mail_list_item_t** mail_list, int *result_count)
+{
+ EM_DEBUG_FUNC_BEGIN("conditional_clause_string [%s], mail_list [%p], result_count [%p]", conditional_clause_string, mail_list, result_count);
+
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(conditional_clause_string, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_query_mail_list(conditional_clause_string, true, mail_list, result_count, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_query_mail_list failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+/* -----------------------------------------------------------
+ Mail Get Info API
+ -----------------------------------------------------------*/
+EXPORT_API int email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], attachment_id[%s], attachment[%p]", mailbox, mail_id, attachment_id, attachment);
+
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+ int nSize = 0;
+ char* mailbox_stream = NULL;
+ char* pAttchStream = NULL;
+ emf_attachment_info_t* pAttch = NULL;
+
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(attachment_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(attachment, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_ATTACHMENT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ if(!mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* mail_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+
+ /* attachment_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)attachment_id, strlen(attachment_id))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if(EMF_ERROR_NONE == err) {
+ nSize = emipc_get_parameter_length(hAPI, ePARAMETER_OUT, 1);
+ if(nSize > 0) {
+ pAttchStream = (char*)em_malloc(nSize+1);
+
+ if(!pAttchStream) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, nSize, pAttchStream);
+ em_convert_byte_stream_to_attachment_info(pAttchStream, 1, &pAttch);
+ }
+
+ if(!pAttch) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_NULL_VALUE");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ *attachment = pAttch;
+ }
+
+FINISH_OFF:
+ EM_SAFE_FREE(pAttchStream);
+
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+EXPORT_API int email_get_attachment_data_list(int input_mail_id, emf_attachment_data_t **output_attachment_data, int *output_attachment_count)
+{
+ EM_DEBUG_FUNC_BEGIN("input_mail_id[%d], output_attachment_data[%p], output_attachment_count[%p]", input_mail_id, output_attachment_data, output_attachment_count);
+ int err = EMF_ERROR_NONE;
+
+ if((err = emcore_get_attachment_data_list(input_mail_id, output_attachment_data, output_attachment_count)) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_attachment_data_list failed [%d]", err);
+ }
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_free_attachment_info(emf_attachment_info_t** atch_info)
+{
+ EM_DEBUG_FUNC_BEGIN("atch_info[%p]", atch_info);
+
+ int err = EMF_ERROR_NONE;
+
+ if (!atch_info || !*atch_info)
+ return EMF_ERROR_INVALID_PARAM;
+
+ emf_attachment_info_t* p = *atch_info;
+ emf_attachment_info_t* t;
+
+ while (p) {
+ EM_SAFE_FREE(p->name);
+ EM_SAFE_FREE(p->savename);
+ t = p->next;
+ EM_SAFE_FREE(p);
+ p = t;
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_free_attachment_data(emf_attachment_data_t **attachment_data_list, int attachment_data_count)
+{
+ EM_DEBUG_FUNC_BEGIN("attachment_data_list[%p], attachment_data_count[%d]", attachment_data_list, attachment_data_count);
+
+ int err = EMF_ERROR_NONE;
+
+ emcore_free_attachment_data(attachment_data_list, attachment_data_count, &err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_get_mails(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_data_t** mail_list, int* result_count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+ emstorage_mail_tbl_t *mail_tbl_list = NULL;
+ EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
+
+ if( account_id < ALL_ACCOUNT) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM ;
+ goto FINISH_OFF;
+ }
+
+ if (!emstorage_get_mails(account_id, (char*)mailbox_name, NULL, thread_id, start_index, limit_count, sorting, true, &mail_tbl_list, result_count, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mails failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ if(!em_convert_mail_tbl_to_mail_data(mail_tbl_list, *result_count, mail_list, &err)) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ if(mail_tbl_list && !emstorage_free_mail(&mail_tbl_list, *result_count, &err))
+ EM_DEBUG_EXCEPTION("emstorage_free_mail failed [%d]", err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_mail_list_ex(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
+
+ if( account_id < ALL_ACCOUNT) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ if (!emstorage_get_mail_list(account_id, (char*) mailbox_name, NULL, thread_id, start_index, limit_count, 0, NULL, sorting, true, mail_list, result_count, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_find_mail (int account_id , const char *mailbox_name, int thread_id,
+ int search_type, char *search_value, int start_index, int limit_count,
+ emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+ int search_num = 0;
+ emf_mail_list_item_t* mail_list_item = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(mail_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(search_value, EMF_ERROR_INVALID_PARAM);
+
+ switch ( search_type ) {
+ case EMF_SEARCH_FILTER_SUBJECT:
+ case EMF_SEARCH_FILTER_SENDER:
+ case EMF_SEARCH_FILTER_RECIPIENT:
+ case EMF_SEARCH_FILTER_ALL:
+ break;
+ default:
+ EM_DEBUG_EXCEPTION("Invalid search filter type[%d]", search_type);
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ if (!emstorage_get_searched_mail_list(account_id, (char*)mailbox_name, thread_id, search_type, search_value, start_index, limit_count, sorting, true, &mail_list_item, &search_num, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_search_mails -- Failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ *mail_list = mail_list_item;
+ *result_count = search_num;
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_mail_by_address(int account_id , const char *mailbox_name, emf_email_address_list_t* addr_list,
+ int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMF_ERROR_NONE;
+
+ emf_mail_list_item_t* mail_list_item = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(mail_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(result_count, EMF_ERROR_INVALID_PARAM);
+
+ if( account_id < ALL_ACCOUNT) {
+ EM_DEBUG_EXCEPTION("Invalid account id param");
+ err = EMF_ERROR_INVALID_PARAM ;
+ return err;
+ }
+
+ if (!emstorage_get_mail_list(account_id, (char*)mailbox_name, addr_list, EMF_LIST_TYPE_NORMAL, start_index, limit_count, search_type, search_value, sorting, true, &mail_list_item, result_count, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_list failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ *mail_list = mail_list_item;
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, emf_mail_data_t** thread_info)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMF_ERROR_NONE;
+ emstorage_mail_tbl_t *mail_table_data = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(thread_info, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_thread_information failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if(!em_convert_mail_tbl_to_mail_data(mail_table_data, 1, thread_info, &err)) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_tbl_to_mail_data failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+FINISH_OFF:
+
+ if(mail_table_data && !emstorage_free_mail(&mail_table_data, 1, &err))
+ EM_DEBUG_EXCEPTION("emstorage_free_mail failed [%d]", err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_thread_information_ex(int thread_id, emf_mail_list_item_t** thread_info)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMF_ERROR_NONE;
+ emstorage_mail_tbl_t *mail_table_data = NULL;
+ emf_mail_list_item_t *temp_thread_info = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(thread_info, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_thread_information(thread_id, &mail_table_data , true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_thread_information -- failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ temp_thread_info = em_malloc(sizeof(emf_mail_list_item_t));
+
+ if(!temp_thread_info) {
+ EM_DEBUG_EXCEPTION("em_malloc failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ EM_SAFE_STRNCPY(temp_thread_info->mailbox_name , mail_table_data->mailbox_name, STRING_LENGTH_FOR_DISPLAY);
+ EM_SAFE_STRNCPY(temp_thread_info->from , mail_table_data->full_address_from, STRING_LENGTH_FOR_DISPLAY);
+ EM_SAFE_STRNCPY(temp_thread_info->from_email_address , mail_table_data->email_address_sender, MAX_EMAIL_ADDRESS_LENGTH);
+ EM_SAFE_STRNCPY(temp_thread_info->recipients , mail_table_data->email_address_recipient, STRING_LENGTH_FOR_DISPLAY);
+ EM_SAFE_STRNCPY(temp_thread_info->subject , mail_table_data->subject, STRING_LENGTH_FOR_DISPLAY);
+ EM_SAFE_STRNCPY(temp_thread_info->previewBodyText , mail_table_data->preview_text, MAX_PREVIEW_TEXT_LENGTH);
+ temp_thread_info->mail_id = mail_table_data->mail_id;
+ temp_thread_info->account_id = mail_table_data->account_id;
+ temp_thread_info->date_time = mail_table_data->date_time;
+ temp_thread_info->is_text_downloaded = mail_table_data->body_download_status;
+ temp_thread_info->flags_seen_field = mail_table_data->flags_seen_field;
+ temp_thread_info->priority = mail_table_data->priority;
+ temp_thread_info->save_status = mail_table_data->save_status;
+ temp_thread_info->is_locked = mail_table_data->lock_status;
+ temp_thread_info->is_report_mail = mail_table_data->report_status;
+ temp_thread_info->has_attachment = mail_table_data->attachment_count;
+ temp_thread_info->has_drm_attachment = mail_table_data->DRM_status;
+ temp_thread_info->thread_id = mail_table_data->thread_id;
+ temp_thread_info->thread_item_count = mail_table_data->thread_item_count;
+ temp_thread_info->is_meeting_request = mail_table_data->meeting_request_status;
+
+ *thread_info = temp_thread_info;
+
+FINISH_OFF:
+
+ if(mail_table_data)
+ emstorage_free_mail(&mail_table_data, 1, NULL);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMF_ERROR_NONE;
+
+ if ( ((err = emcore_get_mail_data(input_mail_id, output_mail_data)) != EMF_ERROR_NONE) || !output_mail_data)
+ EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+/* -----------------------------------------------------------
+ Mail Flag API
+ -----------------------------------------------------------*/
+EXPORT_API int email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver)
+{
+ EM_DEBUG_FUNC_BEGIN("mail_id[%d], on_server [ %d] ", mail_id, onserver);
+
+ int err = EMF_ERROR_NONE;
+
+ int i_flag, sticky = 0;
+
+ if ( mail_id <= 0 || (onserver != 0 && onserver != 1) ) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_MAIL_FLAG);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Mail ID */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* new_flag */
+ if(!em_convert_mail_flag_to_int(new_flag, &i_flag, &err)) {
+ EM_DEBUG_EXCEPTION("em_convert_mail_flag_to_int failed ");
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(i_flag), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ sticky = new_flag.sticky;
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(sticky), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* onserver */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+
+EXPORT_API int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver)
+{
+ EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num[%d],seen_flag[%d], on_server [ %d]", mail_ids, num, seen_flag, onserver);
+ EM_DEBUG_FUNC_END("EMF_ERROR_NOT_IMPLEMENTED");
+ return EMF_ERROR_NOT_IMPLEMENTED;
+}
+
+EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, emf_flags_field_type field_type, int value, int onserver)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id [%d], mail_ids[%p], num[%d], field_type [%d], seen_flag[%d], on_server [ %d]", account_id, mail_ids, num, field_type, value, onserver);
+
+ int err = EMF_ERROR_NONE;
+
+
+ EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM);
+ if (account_id == 0 || num <= 0 || (onserver != 0 && onserver != 1)) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_FLAGS_FIELD);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* account_id*/
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Number of mail_ids */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* set of mail_ids */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* field_type */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&field_type, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* value */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&value, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* onserver */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(onserver), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag)
+{
+ EM_DEBUG_FUNC_BEGIN("mail_id[%d]", mail_id);
+
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ char* pMailExtraFlagsStream = NULL;
+
+
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+
+ pMailExtraFlagsStream = em_convert_extra_flags_to_byte_stream(new_flag, &size);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_MAIL_EXTRA_FLAG);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Mail ID */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ /* Flag */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pMailExtraFlagsStream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ EM_SAFE_FREE(pMailExtraFlagsStream);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+
+
+/* -----------------------------------------------------------
+ Mail Move API
+ -----------------------------------------------------------*/
+EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* mailbox)
+{
+ EM_DEBUG_FUNC_BEGIN("mail_ids[%p], num [%d], mailbox[%p]", mail_ids, num, mailbox);
+
+ int size = 0;
+ char* mailbox_stream = NULL;
+ int err = EMF_ERROR_NONE;
+ HIPC_API hAPI = NULL;
+
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mail_ids, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ if (num <= 0) {
+ EM_DEBUG_LOG("num = %d", num);
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ hAPI = emipc_create_email_api(_EMAIL_API_MOVE_MAIL);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Number of mail_ids */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&num, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* set of mail_ids */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)mail_ids, num * sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ if(!mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ EM_SAFE_FREE(mailbox_stream);
+
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox)
+{
+ EM_DEBUG_FUNC_BEGIN("src_mailbox[%p] , new_mailbox[%p]", src_mailbox, new_mailbox);
+
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ char *dest_mailbox_stream = NULL;
+ char *source_mailbox_stream = NULL;
+ HIPC_API hAPI = NULL;
+
+
+ EM_IF_NULL_RETURN_VALUE(src_mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(new_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(src_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ hAPI = emipc_create_email_api(_EMAIL_API_MOVE_ALL_MAIL);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Src Mailbox Information */
+ source_mailbox_stream = em_convert_mailbox_to_byte_stream(src_mailbox, &size);
+
+ if(!source_mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, source_mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ size = 0;
+
+ /* Dst Mailbox Information */
+ dest_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size);
+
+ if(!dest_mailbox_stream) {
+ EM_DEBUG_EXCEPTION("em_convert_mailbox_to_byte_stream failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, dest_mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ EM_SAFE_FREE(source_mailbox_stream);
+ EM_SAFE_FREE(dest_mailbox_stream);
+
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+EXPORT_API int email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p]", mailbox, total);
+
+ int err = EMF_ERROR_NONE;
+ int total_count = 0;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_mail_count_with_draft_flag(mailbox->account_id, mailbox->name, &total_count, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
+
+ } else {
+ *total = total_count;
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_count_message_on_sending(emf_mailbox_t* mailbox, int* total)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], total[%p]", mailbox, total);
+ int err = EMF_ERROR_NONE;
+ int total_count = 0;
+
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(total, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_mail_count_on_sending(mailbox->account_id, mailbox->name, &total_count, false, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mail_count Failed");
+
+ } else
+ *total = total_count;
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+/**
+
+ * @open
+ * @fn email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag)
+ * @brief Get the Mail Flag information based on the account id and Mail Id.
+ *
+ * @param[in] account_id Specifies the Account ID
+ * @param[in] mail_id Specifies the Mail id for which Flag details need to be fetched
+ * @param[in/out] mail_flag Specifies the Pointer to the structure emf_mail_flag_t.
+ * @remarks N/A
+ * @return True on Success, False on Failure.
+ */
+EXPORT_API int email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+
+ if (account_id < FIRST_ACCOUNT_ID|| mail_id < 1 || mail_flag == NULL) {
+ EM_DEBUG_EXCEPTION("Invalid Param");
+ err = EMF_ERROR_INVALID_PARAM ;
+ goto FINISH_OFF;
+ }
+
+ /* Fetch the flag Information */
+ if (!emcore_fetch_flags(account_id, mail_id, mail_flag, &err)) {
+ EM_DEBUG_EXCEPTION("emcore_fetch_flags Failed [%d]", err);
+ goto FINISH_OFF;
+ }
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+
+EXPORT_API int email_free_mail_data(emf_mail_data_t** mail_list, int count)
+{
+ EM_DEBUG_FUNC_BEGIN("mail_list[%p], count[%d]", mail_list, count);
+ int err = EMF_ERROR_NONE;
+ emcore_free_mail_data(mail_list, count, &err);
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+/* Convert Modified UTF-7 mailbox name to UTF-8 */
+/* returns modified UTF-8 Name if success else NULL */
+
+EXPORT_API int email_cancel_send_mail( int mail_id)
+{
+ EM_DEBUG_FUNC_BEGIN("Mail ID [ %d]", mail_id);
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+
+ int err = EMF_ERROR_NONE;
+ int account_id = 0;
+ emf_mail_data_t* mail_data = NULL;
+
+ HIPC_API hAPI = NULL;
+
+
+ if ((err = emcore_get_mail_data(mail_id, &mail_data)) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emcore_get_mail_data failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if (!mail_data) {
+ EM_DEBUG_EXCEPTION("mail_data is null");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ account_id = mail_data->account_id;
+
+ hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL_CANCEL_JOB);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Mail ID */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ if ( !emcore_free_mail_data(&mail_data, 1, &err))
+ EM_DEBUG_EXCEPTION("emcore_free_mail_data Failed [%d ] ", err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+/**
+ * EmfSendCancel - Callback function for cm popup. We set the status as EMF_MAIL_STATUS_NONE
+ *
+ **/
+
+
+EXPORT_API int email_retry_send_mail( int mail_id, int timeout_in_sec)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+
+
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+ if( timeout_in_sec < 0 ) {
+ EM_DEBUG_EXCEPTION("Invalid timeout_in_sec");
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_RETRY);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* Mail ID */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* timeout */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(timeout_in_sec), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+ }
+
+EXPORT_API int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+ char* mailbox_name = NULL;
+ emstorage_mail_tbl_t* mail_table_data = NULL;
+
+ if(mail_id <= 0) {
+ EM_DEBUG_EXCEPTION("mail_id is not valid");
+ err= EMF_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+ EM_IF_NULL_RETURN_VALUE(pMailbox_name, EMF_ERROR_INVALID_PARAM);
+
+ if(!emstorage_get_mail_by_id(mail_id, &mail_table_data, true, &err)) {
+ EM_DEBUG_EXCEPTION("Failed to get mail by mail_id [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ if(mail_table_data->mailbox_name)
+ mailbox_name = strdup(mail_table_data->mailbox_name);
+
+ *pMailbox_name = mailbox_name;
+
+FINISH_OFF:
+ if(mail_table_data) {
+ emstorage_free_mail(&mail_table_data, 1, &err);
+
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_get_latest_unread_mail_id(int account_id, int *pMailID)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+
+ if( (!pMailID) ||(account_id <= 0 && account_id != -1)) {
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+ if(!emstorage_get_latest_unread_mailid(account_id,pMailID, &err)) {
+ EM_DEBUG_LOG("emstorage_get_latest_unread_mailid - failed");
+
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_max_mail_count(int *Count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMF_ERROR_NONE;
+ EM_IF_NULL_RETURN_VALUE(Count, EMF_ERROR_INVALID_PARAM);
+ *Count = emstorage_get_max_mail_count();
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+/* for setting application,disk usage of email in KB */
+EXPORT_API int email_get_disk_space_usage(unsigned long *total_size)
+{
+ EM_DEBUG_FUNC_BEGIN("total_size[%p]", total_size);
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(total_size, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_mail_get_total_diskspace_usage(total_size,true,&err)) {
+ EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+FINISH_OFF :
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_recipients_list(int account_id, const char *mailbox_name, emf_sender_list_t **recipients_list)
+{
+ EM_DEBUG_FUNC_BEGIN("recipients_list[%p]", recipients_list);
+
+ int number_of_mails, index;
+ int number_of_recipients;
+ int ret=0, err = 0;
+
+ emf_sender_list_t *temp_recipients_list = NULL;
+ emf_sender_list_t *p_recipients_list = NULL;
+ GList *addr_list = NULL, *temp_addr_list = NULL;
+ emstorage_mail_tbl_t *mail_table_data = NULL;
+
+ if (!emstorage_get_mails(account_id, (char*)mailbox_name, NULL, EMF_LIST_TYPE_NORMAL, -1, -1, EMF_SORT_SENDER_HIGH, true, &mail_table_data, &number_of_mails, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mails failed");
+
+ goto FINISH_OFF;
+ }
+
+ for (index = 0; index < number_of_mails; index++) {
+ addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_to, &err);
+ addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_cc, &err);
+ addr_list = emcore_get_recipients_list(addr_list, mail_table_data[index].full_address_bcc, &err);
+ }
+
+ number_of_recipients = g_list_length(addr_list);
+
+ p_recipients_list = (emf_sender_list_t *)malloc(sizeof(emf_sender_list_t) * number_of_recipients);
+ if (p_recipients_list == NULL) {
+ EM_DEBUG_EXCEPTION("malloc for emf_sender_list_t failed...");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ ret = err;
+ goto FINISH_OFF;
+ }
+ memset(p_recipients_list, 0x00, sizeof(emf_sender_list_t) * number_of_recipients);
+
+ temp_addr_list = g_list_first(addr_list);
+ index = 0;
+ while (temp_addr_list != NULL) {
+ temp_recipients_list = (emf_sender_list_t *)temp_addr_list->data;
+ p_recipients_list[index].address = temp_recipients_list->address;
+ p_recipients_list[index].display_name = temp_recipients_list->display_name;
+ p_recipients_list[index].total_count = temp_recipients_list->total_count + 1;
+ EM_DEBUG_LOG("address[%s], display_name[%s], total_count[%d]", p_recipients_list[index].address, p_recipients_list[index].display_name, p_recipients_list[index].total_count);
+ temp_addr_list = g_list_next(temp_addr_list);
+ index++;
+ }
+
+ ret = true;
+FINISH_OFF:
+ if (ret == true && recipients_list)
+ *recipients_list = p_recipients_list; else if (p_recipients_list != NULL) {
+ email_free_sender_list(&p_recipients_list, number_of_recipients);
+ }
+
+ EM_DEBUG_FUNC_END();
+ return ret;
+}
+
+EXPORT_API int email_get_sender_list(int account_id, const char *mailbox_name, int search_type, const char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count)
+{
+ EM_DEBUG_FUNC_BEGIN("sender_list[%p],sender_count[%p], sorting[%d]", sender_list, sender_count, sorting);
+
+ int err = EMF_ERROR_NONE;
+
+ emf_sender_list_t *temp_sender_list = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(sender_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(sender_count, EMF_ERROR_INVALID_PARAM);
+ if( account_id < ALL_ACCOUNT) {
+ EM_DEBUG_EXCEPTION(" Invalid Account Id Param ");
+ err = EMF_ERROR_INVALID_PARAM ;
+ return err;
+ }
+
+ if ( !emstorage_get_sender_list(account_id, mailbox_name, search_type, search_value, sorting, &temp_sender_list, sender_count, &err) ) {
+ EM_DEBUG_EXCEPTION("emstorage_get_sender_list failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ if ( sender_list )
+ *sender_list = temp_sender_list;
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_sender_list_ex(int account_id, const char *mailbox_name, int start_index, int limit_count, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count)
+{
+ return EMF_ERROR_NONE;
+}
+
+EXPORT_API int email_free_sender_list(emf_sender_list_t **sender_list, int count)
+{
+ EM_DEBUG_FUNC_BEGIN("sender_list[%p], count[%d]", sender_list, count);
+
+ int err = EMF_ERROR_NONE;
+
+ if (count > 0) {
+ if (!sender_list || !*sender_list) {
+ EM_DEBUG_EXCEPTION("sender_list[%p], count[%d]", sender_list, count);
+ err = EMF_ERROR_INVALID_PARAM;
+ return err;
+ }
+
+ emf_sender_list_t* p = *sender_list;
+ int i = 0;
+
+ for (; i < count; i++) {
+ EM_SAFE_FREE(p[i].address);
+ EM_SAFE_FREE(p[i].display_name);
+ }
+
+ EM_SAFE_FREE(p);
+ *sender_list = NULL;
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_address_info_list(int mail_id, emf_address_info_list_t** address_info_list)
+{
+ EM_DEBUG_FUNC_BEGIN("mail_id[%d], address_info_list[%p]", mail_id, address_info_list);
+
+ int err = EMF_ERROR_NONE;
+
+ emf_address_info_list_t *temp_address_info_list = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(address_info_list, EMF_ERROR_INVALID_PARAM);
+ if( mail_id <= 0) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM ;
+ return err;
+ }
+
+ if ( !emcore_get_mail_address_info_list(mail_id, &temp_address_info_list, &err) ) {
+ EM_DEBUG_EXCEPTION("emcore_get_mail_address_info_list failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ if ( address_info_list ) {
+ *address_info_list = temp_address_info_list;
+ temp_address_info_list = NULL;
+ }
+
+FINISH_OFF:
+ if ( temp_address_info_list )
+ emstorage_free_address_info_list(&temp_address_info_list);
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_free_address_info_list(emf_address_info_list_t **address_info_list)
+{
+ EM_DEBUG_FUNC_BEGIN("address_info_list[%p]", address_info_list);
+
+ int err = EMF_ERROR_NONE;
+
+ if ( (err = emstorage_free_address_info_list(address_info_list)) != EMF_ERROR_NONE ) {
+ EM_DEBUG_EXCEPTION("address_info_list[%p] free failed.", address_info_list);
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, emf_convert_struct_type_e type)
+{
+ EM_DEBUG_FUNC_BEGIN("encoded_string[%s], struct_var[%p], type[%d]", encoded_string, struct_var, type);
+
+ int err = EMF_ERROR_NONE;
+ void * temp_struct = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(encoded_string, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(struct_var, EMF_ERROR_INVALID_PARAM);
+
+ if ( (err = emcore_convert_string_to_structure((char*)encoded_string, &temp_struct, type)) != EMF_ERROR_NONE ) {
+ EM_DEBUG_EXCEPTION("emcore_convert_string_to_structure failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ( struct_var )
+ *struct_var = temp_struct;
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req)
+{
+ EM_DEBUG_FUNC_BEGIN("mail_id[%d],meeting_req[%p]", mail_id, meeting_req);
+
+ int err = EMF_ERROR_NONE;
+
+ emf_meeting_request_t *temp_meeting_req = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(meeting_req, EMF_ERROR_INVALID_PARAM);
+ if( mail_id <= 0 ) {
+ EM_DEBUG_EXCEPTION(" Invalid Mail Id Param ");
+ err = EMF_ERROR_INVALID_PARAM ;
+ return err;
+ }
+
+ if ( !emstorage_get_meeting_request(mail_id, &temp_meeting_req, 1, &err) ) {
+ EM_DEBUG_EXCEPTION("emstorage_get_meeting_request -- Failed [%d]", err);
+
+ goto FINISH_OFF;
+ }
+
+ if ( meeting_req )
+ *meeting_req = temp_meeting_req;
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_free_meeting_request(emf_meeting_request_t** meeting_req, int count)
+{
+ EM_DEBUG_FUNC_BEGIN("meeting_req[%p], count[%d]", meeting_req, count);
+
+ int err = EMF_ERROR_NONE;
+
+ emstorage_free_meeting_request(meeting_req, count, &err);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_move_thread_to_mailbox(int thread_id, char *target_mailbox_name, int move_always_flag)
+{
+ EM_DEBUG_FUNC_BEGIN("thread_id[%d], target_mailbox_name[%p], move_always_flag[%d]", thread_id, target_mailbox_name, move_always_flag);
+ int err = EMF_ERROR_NONE;
+
+
+ EM_IF_NULL_RETURN_VALUE(target_mailbox_name, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MOVE_THREAD_TO_MAILBOX);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* thread_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* target mailbox information */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, target_mailbox_name, strlen(target_mailbox_name))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* move_always_flag */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&move_always_flag, sizeof(int))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag)
+{
+ EM_DEBUG_FUNC_BEGIN("thread_id[%d], delete_always_flag[%d]", thread_id, delete_always_flag);
+ int err = EMF_ERROR_NONE;
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_THREAD);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* thread_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* delete_always_flag */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&delete_always_flag, sizeof(int))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server)
+{
+ EM_DEBUG_FUNC_BEGIN("thread_id[%d], seen_flag[%d], on_server[%d]", thread_id, seen_flag, on_server);
+ int err = EMF_ERROR_NONE;
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_MODIFY_SEEN_FLAG_OF_THREAD);
+
+ if(!hAPI) {
+ EM_DEBUG_EXCEPTION("emipc_create_email_api failed");
+ err = EMF_ERROR_NULL_VALUE;
+ goto FINISH_OFF;
+ }
+
+ /* thread_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&thread_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* seen_flag */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&seen_flag, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* on_server */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&on_server, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ err = EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ err = EMF_ERROR_IPC_SOCKET_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+FINISH_OFF:
+ if(hAPI)
+ emipc_destroy_email_api(hAPI);
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
diff --git a/email-api/email-api-mailbox.c b/email-api/email-api-mailbox.c
new file mode 100755
index 0000000..3527b43
--- /dev/null
+++ b/email-api/email-api-mailbox.c
@@ -0,0 +1,593 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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.
+*
+*/
+
+
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email_api_mailbox.c
+ * @brief This file contains the data structures and interfaces of mailbox related Functionality provided by
+ * email-service .
+ */
+
+#include "email-api.h"
+#include "string.h"
+#include "email-convert.h"
+#include "email-storage.h"
+#include "email-core-utils.h"
+#include "email-utilities.h"
+#include "email-ipc.h"
+#include "db-util.h"
+
+/* API - Create a mailbox */
+
+EXPORT_API int email_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ char* local_mailbox_stream = NULL;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_MAILBOX);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_SAFE_FREE(local_mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ EM_DEBUG_LOG(" >>>>> error VALUE [%d]", err);
+
+ if(handle) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ EM_DEBUG_LOG(" >>>>> Handle [%d]", *handle);
+ }
+
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+/* API - Delete a mailbox */
+
+EXPORT_API int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p]", mailbox);
+
+ char* local_mailbox_stream = NULL;
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mailbox->account_id, EMF_ERROR_INVALID_PARAM) ;
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_MAILBOX);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ local_mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_SAFE_FREE(local_mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ EM_DEBUG_LOG("error VALUE [%d]", err);
+
+ if(handle) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ EM_DEBUG_LOG("Handle [%d]", handle);
+ }
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+/* API - Update a mailbox */
+
+
+EXPORT_API int email_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ char* local_mailbox_stream = NULL;
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+ int on_server = 0;
+ EM_DEBUG_LOG(" old_mailbox[%p], new_mailbox[%p]", old_mailbox, new_mailbox);
+
+ EM_IF_NULL_RETURN_VALUE(old_mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(old_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(new_mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(new_mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_MAILBOX);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+
+ local_mailbox_stream = em_convert_mailbox_to_byte_stream(old_mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_SAFE_FREE(local_mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ local_mailbox_stream = em_convert_mailbox_to_byte_stream(new_mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(local_mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, local_mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_SAFE_FREE(local_mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &on_server, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ EM_DEBUG_LOG("error VALUE [%d]", err);
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_get_sync_mailbox_list(int account_id, emf_mailbox_t** mailbox_list, int* count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int counter = 0;
+ emstorage_mailbox_tbl_t* mailbox = NULL;
+ int err = EMF_ERROR_NONE ;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_mailbox(account_id, 0, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &counter, &mailbox, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
+
+
+ goto FINISH_OFF;
+ } else
+ err = EMF_ERROR_NONE;
+
+ if (counter > 0) {
+ if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * counter))) {
+ EM_DEBUG_EXCEPTION("malloc failed...");
+ err= EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+ } else
+ *mailbox_list = NULL;
+
+ *count = counter;
+
+ FINISH_OFF:
+ if (mailbox != NULL)
+ emstorage_free_mailbox(&mailbox, counter, NULL);
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, emf_mailbox_t** mailbox_list, int* count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int mailbox_count = 0;
+ emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
+ int err =EMF_ERROR_NONE;
+ int i;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_mailbox(account_id, mailbox_sync_type, EMAIL_MAILBOX_SORT_BY_NAME_ASC, &mailbox_count, &mailbox_tbl_list, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox failed [%d]", err);
+
+ goto FINISH_OFF;
+ } else
+ err = EMF_ERROR_NONE;
+
+ if (mailbox_count > 0) {
+ if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * mailbox_count))) {
+ EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
+ err= EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ for (i = 0; i < mailbox_count; i++) {
+ (*mailbox_list)[i].mailbox_id = mailbox_tbl_list[i].mailbox_id;
+ (*mailbox_list)[i].account_id = account_id;
+ (*mailbox_list)[i].name = mailbox_tbl_list[i].mailbox_name;
+ mailbox_tbl_list[i].mailbox_name = NULL;
+ (*mailbox_list)[i].alias = mailbox_tbl_list[i].alias;
+ mailbox_tbl_list[i].alias = NULL;
+ (*mailbox_list)[i].local = mailbox_tbl_list[i].local_yn;
+ (*mailbox_list)[i].mailbox_type = mailbox_tbl_list[i].mailbox_type;
+ (*mailbox_list)[i].synchronous = mailbox_tbl_list[i].sync_with_server_yn;
+ (*mailbox_list)[i].unread_count = mailbox_tbl_list[i].unread_count;
+ (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl_list[i].total_mail_count_on_local;
+ (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl_list[i].total_mail_count_on_server;
+ (*mailbox_list)[i].has_archived_mails = mailbox_tbl_list[i].has_archived_mails;
+ (*mailbox_list)[i].mail_slot_size = mailbox_tbl_list[i].mail_slot_size;
+ }
+ } else
+ *mailbox_list = NULL;
+
+ *count = mailbox_count;
+
+FINISH_OFF:
+ if (mailbox_tbl_list != NULL)
+ emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, emf_mailbox_t** mailbox_list, int* count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int mailbox_count = 0;
+ emstorage_mailbox_tbl_t* mailbox_tbl_list = NULL;
+ int err =EMF_ERROR_NONE;
+ int i;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_mailbox_ex(account_id, mailbox_sync_type, with_count, &mailbox_count, &mailbox_tbl_list, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_ex failed [%d]", err);
+
+ goto FINISH_OFF;
+ } else
+ err = EMF_ERROR_NONE;
+
+ if (mailbox_count > 0) {
+ if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * mailbox_count))) {
+ EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
+ err= EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ for (i = 0; i < mailbox_count; i++) {
+ (*mailbox_list)[i].mailbox_id = mailbox_tbl_list[i].mailbox_id;
+ (*mailbox_list)[i].account_id = account_id;
+ (*mailbox_list)[i].name = mailbox_tbl_list[i].mailbox_name;
+ mailbox_tbl_list[i].mailbox_name = NULL;
+ (*mailbox_list)[i].alias = mailbox_tbl_list[i].alias;
+ mailbox_tbl_list[i].alias = NULL;
+ (*mailbox_list)[i].local = mailbox_tbl_list[i].local_yn;
+ (*mailbox_list)[i].mailbox_type = mailbox_tbl_list[i].mailbox_type;
+ (*mailbox_list)[i].synchronous = mailbox_tbl_list[i].sync_with_server_yn;
+ (*mailbox_list)[i].unread_count = mailbox_tbl_list[i].unread_count;
+ (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl_list[i].total_mail_count_on_local;
+ (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl_list[i].total_mail_count_on_server;
+ (*mailbox_list)[i].has_archived_mails = mailbox_tbl_list[i].has_archived_mails;
+ (*mailbox_list)[i].mail_slot_size = mailbox_tbl_list[i].mail_slot_size;
+ }
+ } else
+ *mailbox_list = NULL;
+
+ if ( count )
+ *count = mailbox_count;
+
+FINISH_OFF:
+ if (mailbox_tbl_list != NULL)
+ emstorage_free_mailbox(&mailbox_tbl_list, mailbox_count, NULL);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+ emf_mailbox_t* curr_mailbox = NULL;
+ emstorage_mailbox_tbl_t* local_mailbox = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(pMailbox, EMF_ERROR_INVALID_PARAM);
+ if(!pMailboxName)
+ return EMF_ERROR_INVALID_PARAM;
+
+ if (!emstorage_get_mailbox_by_name(account_id, -1, (char*)pMailboxName, &local_mailbox, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_name failed [%d]", err);
+ return err;
+ } else {
+ curr_mailbox = em_malloc(sizeof(emf_mailbox_t));
+ memset(curr_mailbox, 0x00, sizeof(emf_mailbox_t));
+
+ curr_mailbox->account_id = local_mailbox->account_id;
+ if(local_mailbox->mailbox_name)
+ curr_mailbox->name = strdup(local_mailbox->mailbox_name);
+ curr_mailbox->local = local_mailbox->local_yn;
+ if(local_mailbox->alias)
+ curr_mailbox->alias= strdup(local_mailbox->alias);
+ curr_mailbox->synchronous = local_mailbox->sync_with_server_yn;
+ curr_mailbox->mailbox_type = local_mailbox->mailbox_type;
+ curr_mailbox->unread_count = local_mailbox->unread_count;
+ curr_mailbox->total_mail_count_on_local= local_mailbox->total_mail_count_on_local;
+ curr_mailbox->total_mail_count_on_server= local_mailbox->total_mail_count_on_server;
+ curr_mailbox->has_archived_mails = local_mailbox->has_archived_mails;
+ curr_mailbox->mail_slot_size = local_mailbox->mail_slot_size;
+ }
+
+ *pMailbox = curr_mailbox;
+
+ emstorage_free_mailbox(&local_mailbox, 1, &err);
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], parent_mailbox[%p], mailbox_list[%p], count[%p]", account_id, parent_mailbox, mailbox_list, count);
+
+ int err = EMF_ERROR_NONE;
+ int counter = 0;
+ emstorage_mailbox_tbl_t* mailbox_tbl = NULL;
+ int i =0;
+
+ EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mailbox_list, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
+
+ *mailbox_list = NULL;
+ *count = 0;
+
+ if (!emstorage_get_child_mailbox_list(account_id,(char*)parent_mailbox, &counter, &mailbox_tbl, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_child_mailbox_list failed[%d]", err);
+
+
+ goto FINISH_OFF;
+ } else
+ err = EMF_ERROR_NONE;
+
+ if (counter > 0) {
+ if (!(*mailbox_list = em_malloc(sizeof(emf_mailbox_t) * counter))) {
+ EM_DEBUG_EXCEPTION("malloc failed for mailbox_list");
+
+ err= EMF_ERROR_OUT_OF_MEMORY;
+ goto FINISH_OFF;
+ }
+
+ memset(*mailbox_list, 0x00, (sizeof(emf_mailbox_t) * counter));
+
+ for (i = 0; i < counter; i++) {
+ (*mailbox_list)[i].mailbox_id = mailbox_tbl[i].mailbox_id;
+ (*mailbox_list)[i].account_id = account_id;
+ (*mailbox_list)[i].name = mailbox_tbl[i].mailbox_name; mailbox_tbl[i].mailbox_name = NULL;
+ (*mailbox_list)[i].alias = mailbox_tbl[i].alias; mailbox_tbl[i].alias = NULL;
+ (*mailbox_list)[i].local = mailbox_tbl[i].local_yn;
+ (*mailbox_list)[i].mailbox_type = mailbox_tbl[i].mailbox_type;
+ (*mailbox_list)[i].synchronous = mailbox_tbl[i].sync_with_server_yn;
+ (*mailbox_list)[i].unread_count = mailbox_tbl[i].unread_count;
+ (*mailbox_list)[i].total_mail_count_on_local = mailbox_tbl[i].total_mail_count_on_local;
+ (*mailbox_list)[i].total_mail_count_on_server = mailbox_tbl[i].total_mail_count_on_server;
+ (*mailbox_list)[i].has_archived_mails = mailbox_tbl[i].has_archived_mails;
+ (*mailbox_list)[i].mail_slot_size = mailbox_tbl[i].mail_slot_size;
+ }
+ } else
+ *mailbox_list = NULL;
+
+ *count = counter;
+
+FINISH_OFF:
+ if (mailbox_tbl != NULL)
+ emstorage_free_mailbox(&mailbox_tbl, counter, NULL);
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+/* sowmya.kr, 05-Apr-2010, new MAPI*/
+
+EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+ emf_mailbox_t* curr_mailbox = NULL;
+ emstorage_mailbox_tbl_t* local_mailbox = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM) ;
+
+
+ if(mailbox_type < EMF_MAILBOX_TYPE_INBOX || mailbox_type > EMF_MAILBOX_TYPE_ALL_EMAILS)
+ return EMF_ERROR_INVALID_PARAM;
+ if (!emstorage_get_mailbox_by_mailbox_type(account_id, mailbox_type, &local_mailbox, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_mailbox_by_mailbox_type failed [%d]", err);
+
+ goto FINISH_OFF;
+ } else {
+ err = EMF_ERROR_NONE;
+ curr_mailbox = em_malloc(sizeof(emf_mailbox_t));
+ memset(curr_mailbox, 0x00, sizeof(emf_mailbox_t));
+
+ curr_mailbox->account_id = local_mailbox->account_id;
+ if(local_mailbox->mailbox_name)
+ curr_mailbox->name = strdup(local_mailbox->mailbox_name);
+ curr_mailbox->local = local_mailbox->local_yn;
+ if(local_mailbox->alias)
+ curr_mailbox->alias= strdup(local_mailbox->alias);
+ curr_mailbox->synchronous = 1;
+ curr_mailbox->mailbox_type = local_mailbox->mailbox_type;
+ curr_mailbox->unread_count = local_mailbox->unread_count;
+ curr_mailbox->total_mail_count_on_local = local_mailbox->total_mail_count_on_local;
+ curr_mailbox->total_mail_count_on_server = local_mailbox->total_mail_count_on_server;
+ curr_mailbox->has_archived_mails = local_mailbox->has_archived_mails;
+ curr_mailbox->mail_slot_size = local_mailbox->mail_slot_size;
+ }
+
+ *mailbox = curr_mailbox;
+FINISH_OFF:
+
+ if(local_mailbox)
+ emstorage_free_mailbox(&local_mailbox, 1, NULL);
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_set_mail_slot_size(int account_id, char* mailbox_name, int new_slot_size/*, unsigned* handle*/)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], mailbox_name[%p], new_slot_size[%d]", account_id, mailbox_name, new_slot_size);
+
+ int err = EMF_ERROR_NONE, *handle = NULL;
+
+ if(new_slot_size < 0) {
+ EM_DEBUG_EXCEPTION("new_slot_size should be greater than 0 or should be equal to 0");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SET_MAIL_SLOT_SIZE);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if (hAPI) {
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter for account_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &new_slot_size, sizeof(int))) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter for new_slot_size failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(mailbox_name) {
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_name, strlen(mailbox_name) )) {
+ EM_DEBUG_EXCEPTION(" emipc_add_parameter for mailbox_name failed");
+ EM_SAFE_FREE(mailbox_name);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ EM_DEBUG_LOG("email_set_mail_slot_size error VALUE [%d]", err);
+ if(handle) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ EM_DEBUG_LOG("email_set_mail_slot_size handle VALUE [%d]", handle);
+ }
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ }
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_free_mailbox(emf_mailbox_t** mailbox_list, int count)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox_list[%p], count[%d]", mailbox_list, count);
+ int err = EMF_ERROR_NONE;
+
+ if (count <= 0 || !mailbox_list || !*mailbox_list) {
+ EM_DEBUG_EXCEPTION("EMF_ERROR_INVALID_PARAM");
+ err = EMF_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ emf_mailbox_t *p = *mailbox_list;
+ int i;
+
+ for (i = 0; i < count; i++) {
+ EM_SAFE_FREE(p[i].name);
+ EM_SAFE_FREE(p[i].alias);
+ EM_SAFE_FREE(p[i].account_name);
+ }
+
+ EM_SAFE_FREE(p);
+ *mailbox_list = NULL;
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
diff --git a/email-api/email-api-network.c b/email-api/email-api-network.c
new file mode 100755
index 0000000..d1e9451
--- /dev/null
+++ b/email-api/email-api-network.c
@@ -0,0 +1,1503 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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.
+*
+*/
+
+
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-network.c
+ * @brief This file contains the data structures and interfaces of Network related Functionality provided by
+ * email-service .
+ */
+
+#include "email-api.h"
+#include "string.h"
+#include "email-convert.h"
+#include "email-api-mailbox.h"
+#include "email-types.h"
+#include "email-utilities.h"
+#include "email-ipc.h"
+#include "email-storage.h"
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+#include <vconf.h>
+#include <dbus/dbus.h>
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+
+
+#define ACTIVE_SYNC_HANDLE_INIT_VALUE (-1)
+#define ACTIVE_SYNC_HANDLE_BOUNDARY (-100000000)
+
+
+static int email_get_account_server_type_by_account_id(int account_id, emf_account_server_t* account_server_type, int flag, int *error)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ emf_account_t *account=NULL;
+ int ret = false;
+ int err= EMF_ERROR_NONE;
+
+ if (account_server_type == NULL ) {
+ EM_DEBUG_EXCEPTION("account_server_type is NULL");
+ err = EMF_ERROR_INVALID_PARAM;
+ ret = false;
+ goto FINISH_OFF;
+ }
+
+ if( (err = email_get_account(account_id,WITHOUT_OPTION,&account)) < 0) {
+ EM_DEBUG_EXCEPTION ("email_get_account failed [%d] ", err);
+ ret = false;
+ goto FINISH_OFF;
+ }
+
+ if ( flag == false ) { /* sending server */
+ *account_server_type = account->sending_server_type;
+ } else if ( flag == true ) { /* receiving server */
+ *account_server_type = account->receiving_server_type;
+ }
+
+ ret = true;
+
+FINISH_OFF:
+ if ( account != NULL ) {
+ email_free_account(&account, 1);
+ }
+ if ( error != NULL ) {
+ *error = err;
+ }
+
+ return ret;
+}
+
+static int email_get_handle_for_activesync(int *handle, int *error)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ static int next_handle = 0;
+ int ret = false;
+ int err = EMF_ERROR_NONE;
+
+ if ( handle == NULL ) {
+ EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed : handle is NULL");
+ err = EMF_ERROR_INVALID_PARAM;
+ goto FINISH_OFF;
+ }
+
+ if ( vconf_get_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, &next_handle) != 0 ) {
+ EM_DEBUG_EXCEPTION("vconf_get_int failed");
+ if ( next_handle != 0 ) {
+ err = EMF_ERROR_GCONF_FAILURE;
+ goto FINISH_OFF;
+ }
+ }
+
+ EM_DEBUG_LOG(">>>>>> VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE : get lastest handle[%d]", next_handle);
+
+ /* set the value of the handle for active sync */
+ next_handle--;
+ if ( next_handle < ACTIVE_SYNC_HANDLE_BOUNDARY ) {
+ next_handle = ACTIVE_SYNC_HANDLE_INIT_VALUE;
+ }
+ if ( vconf_set_int(VCONFKEY_EMAIL_SERVICE_ACTIVE_SYNC_HANDLE, next_handle) != 0) {
+ EM_DEBUG_EXCEPTION("vconf_set_int failed");
+ err = EMF_ERROR_GCONF_FAILURE;
+ goto FINISH_OFF;
+ }
+ ret = true;
+ *handle = next_handle;
+ EM_DEBUG_LOG(">>>>>> return next handle[%d]", *handle);
+
+FINISH_OFF:
+ if ( error != NULL ) {
+ *error = err;
+ }
+
+ return ret;
+}
+
+static int email_send_notification_to_active_sync_engine(int subType, ASNotiData *data)
+{
+ EM_DEBUG_FUNC_BEGIN("subType [%d], data [%p]", subType, data);
+
+ DBusConnection *connection;
+ DBusMessage *signal = NULL;
+ DBusError error;
+ const char *nullString = "";
+ int i = 0;
+ dbus_int32_t array_for_time_type[9] = { 0 , };
+
+ dbus_error_init (&error);
+ connection = dbus_bus_get(DBUS_BUS_SYSTEM, &error);
+
+ if(connection == NULL)
+ goto FINISH_OFF;
+
+ signal = dbus_message_new_signal("/User/Email/ActiveSync", EMF_ACTIVE_SYNC_NOTI, "email");
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &subType, DBUS_TYPE_INVALID);
+ switch ( subType ) {
+ case ACTIVE_SYNC_NOTI_SEND_MAIL:
+ EM_DEBUG_LOG("handle:[%d]", data->send_mail.handle);
+ EM_DEBUG_LOG("account_id:[%d]", data->send_mail.account_id);
+ EM_DEBUG_LOG("mailbox_name:[%s]", data->send_mail.mailbox_name);
+ EM_DEBUG_LOG("mail_id:[%d]", data->send_mail.mail_id);
+ EM_DEBUG_LOG("options.priority:[%d]", data->send_mail.options.priority);
+ EM_DEBUG_LOG("options.keep_local_copy:[%d]", data->send_mail.options.keep_local_copy);
+ EM_DEBUG_LOG("options.req_delivery_receipt:[%d]", data->send_mail.options.req_delivery_receipt);
+ EM_DEBUG_LOG("options.req_read_receipt:[%d]", data->send_mail.options.req_read_receipt);
+ /* download_limit, block_address, block_subject might not be needed */
+ EM_DEBUG_LOG("options.download_limit:[%d]", data->send_mail.options.download_limit);
+ EM_DEBUG_LOG("options.block_address:[%d]", data->send_mail.options.block_address);
+ EM_DEBUG_LOG("options.block_subject:[%d]", data->send_mail.options.block_subject);
+ EM_DEBUG_LOG("options.display_name_from:[%s]", data->send_mail.options.display_name_from);
+ EM_DEBUG_LOG("options.reply_with_body:[%d]", data->send_mail.options.reply_with_body);
+ EM_DEBUG_LOG("options.forward_with_files:[%d]", data->send_mail.options.forward_with_files);
+ EM_DEBUG_LOG("options.add_myname_card:[%d]", data->send_mail.options.add_myname_card);
+ EM_DEBUG_LOG("options.add_signature:[%d]", data->send_mail.options.add_signature);
+ EM_DEBUG_LOG("options.signature:[%s]", data->send_mail.options.signature);
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.handle), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.account_id), DBUS_TYPE_INVALID);
+ if ( data->send_mail.mailbox_name == NULL )
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.mailbox_name), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.mail_id), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.priority), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.keep_local_copy), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_delivery_receipt), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.req_read_receipt), DBUS_TYPE_INVALID);
+ if ( data->send_mail.options.display_name_from == NULL )
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.display_name_from), DBUS_TYPE_INVALID);
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.reply_with_body), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.forward_with_files), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_myname_card), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->send_mail.options.add_signature), DBUS_TYPE_INVALID);
+ if ( data->send_mail.options.signature == NULL )
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->send_mail.options.signature), DBUS_TYPE_INVALID);
+
+ break;
+ case ACTIVE_SYNC_NOTI_SEND_SAVED: /* publish a send notification to ASE (active sync engine) */
+ EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_SAVED]", subType);
+ break;
+ case ACTIVE_SYNC_NOTI_SEND_REPORT:
+ EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_SEND_REPORT]", subType);
+ break;
+ case ACTIVE_SYNC_NOTI_SYNC_HEADER:
+ EM_DEBUG_LOG("handle:[%d]", data->sync_header.handle);
+ EM_DEBUG_LOG("account_id:[%d]", data->sync_header.account_id);
+ EM_DEBUG_LOG("mailbox_name:[%s]", data->sync_header.mailbox_name);
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.handle ), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->sync_header.account_id ), DBUS_TYPE_INVALID);
+ if ( data->sync_header.mailbox_name == NULL )
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->sync_header.mailbox_name), DBUS_TYPE_INVALID);
+ break;
+ case ACTIVE_SYNC_NOTI_DOWNLOAD_BODY: /* publish a download body notification to ASE */
+ EM_DEBUG_LOG("handle:[%d]", data->download_body.handle);
+ EM_DEBUG_LOG("account_id:[%d]", data->download_body.account_id);
+ EM_DEBUG_LOG("mail_id:[%d]", data->download_body.mail_id);
+ EM_DEBUG_LOG("with_attachment:[%d]", data->download_body.with_attachment);
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.handle ), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.account_id ), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.mail_id ), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_body.with_attachment ), DBUS_TYPE_INVALID);
+ break;
+ case ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT:
+ EM_DEBUG_LOG("handle:[%d]", data->download_attachment.handle);
+ EM_DEBUG_LOG("account_id:[%d]", data->download_attachment.account_id );
+ EM_DEBUG_LOG("mail_id:[%d]", data->download_attachment.mail_id);
+ EM_DEBUG_LOG("with_attachment:[%s]", data->download_attachment.attachment_order );
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.handle ), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.account_id ), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->download_attachment.mail_id ), DBUS_TYPE_INVALID);
+ if ( data->download_attachment.attachment_order == NULL )
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(nullString), DBUS_TYPE_INVALID);
+ else
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->download_attachment.attachment_order), DBUS_TYPE_INVALID);
+ break;
+ case ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT:
+ EM_DEBUG_EXCEPTION("Not support yet : subType[ACTIVE_SYNC_NOTI_VALIDATE_ACCOUNT]", subType);
+ break;
+ case ACTIVE_SYNC_NOTI_CANCEL_JOB:
+ EM_DEBUG_LOG("account_id:[%d]", data->cancel_job.account_id );
+ EM_DEBUG_LOG("handle to cancel:[%d]", data->cancel_job.handle);
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.account_id ), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->cancel_job.handle ), DBUS_TYPE_INVALID);
+ break;
+ case ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER:
+ EM_DEBUG_LOG("account_id:[%d]", data->search_mail_on_server.account_id );
+ EM_DEBUG_LOG("mailbox_name:[%s]", data->search_mail_on_server.mailbox_name );
+ EM_DEBUG_LOG("search_filter_count:[%d]", data->search_mail_on_server.search_filter_count );
+ EM_DEBUG_LOG("handle to cancel:[%d]", data->search_mail_on_server.handle);
+
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.account_id), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.mailbox_name), DBUS_TYPE_INVALID);
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_count), DBUS_TYPE_INVALID);
+ for(i = 0; i < data->search_mail_on_server.search_filter_count; i++) {
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_type), DBUS_TYPE_INVALID);
+ switch(data->search_mail_on_server.search_filter_list[i].search_filter_type) {
+ case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_NO :
+ case EMAIL_SEARCH_FILTER_TYPE_UID :
+ case EMAIL_SEARCH_FILTER_TYPE_SIZE_LARSER :
+ case EMAIL_SEARCH_FILTER_TYPE_SIZE_SMALLER :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_ANSWERED :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DELETED :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_DRAFT :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_FLAGED :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_RECENT :
+ case EMAIL_SEARCH_FILTER_TYPE_FLAGS_SEEN :
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.integer_type_key_value), DBUS_TYPE_INVALID);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_BCC :
+ case EMAIL_SEARCH_FILTER_TYPE_CC :
+ case EMAIL_SEARCH_FILTER_TYPE_FROM :
+ case EMAIL_SEARCH_FILTER_TYPE_KEYWORD :
+ case EMAIL_SEARCH_FILTER_TYPE_SUBJECT :
+ case EMAIL_SEARCH_FILTER_TYPE_TO :
+ case EMAIL_SEARCH_FILTER_TYPE_MESSAGE_ID :
+ dbus_message_append_args(signal, DBUS_TYPE_STRING, &(data->search_mail_on_server.search_filter_list[i].search_filter_key_value.string_type_key_value), DBUS_TYPE_INVALID);
+ break;
+
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_BEFORE :
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_ON :
+ case EMAIL_SEARCH_FILTER_TYPE_SENT_DATE_SINCE : {
+ array_for_time_type[0] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_sec;
+ array_for_time_type[1] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_min;
+ array_for_time_type[2] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_hour;
+ array_for_time_type[3] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_mday;
+ array_for_time_type[4] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_mon;
+ array_for_time_type[5] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_year;
+ array_for_time_type[6] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_wday;
+ array_for_time_type[7] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_yday;
+ array_for_time_type[8] = data->search_mail_on_server.search_filter_list[i].search_filter_key_value.time_type_key_value.tm_isdst;
+ dbus_message_append_args(signal, DBUS_TYPE_ARRAY, DBUS_TYPE_INT32, array_for_time_type, 9, DBUS_TYPE_INVALID);
+ }
+ break;
+ default :
+ EM_DEBUG_EXCEPTION("Invalid filter type [%d]", data->search_mail_on_server.search_filter_list[i].search_filter_type);
+ break;
+ }
+ }
+ dbus_message_append_args(signal, DBUS_TYPE_INT32, &(data->search_mail_on_server.handle), DBUS_TYPE_INVALID);
+ break;
+ default:
+ EM_DEBUG_EXCEPTION("Invalid Notification type of Active Sync : subType[%d]", subType);
+ return FAILURE;
+ }
+
+ if(!dbus_connection_send (connection, signal, NULL)) {
+ EM_DEBUG_EXCEPTION("dbus_connection_send is failed");
+ return FAILURE;
+ } else
+ EM_DEBUG_LOG("dbus_connection_send is successful");
+
+ dbus_connection_flush(connection);
+
+FINISH_OFF:
+
+ if(signal)
+ dbus_message_unref(signal);
+
+ EM_DEBUG_FUNC_END();
+ return true;
+}
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+
+
+EXPORT_API int email_send_mail( emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], sending_option[%p], handle[%p]", mailbox, mail_id, sending_option, handle);
+
+ char* mailbox_stream = NULL;
+ char* pSendingOption = NULL;
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mailbox->name, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+ EM_DEBUG_LOG("Account ID [ %d],mailbox->name[%s], mailbox->account_id[%d] ", mailbox->account_id, mailbox->name, mailbox->account_id);
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ emf_account_server_t account_server_type;
+ HIPC_API hAPI = NULL;
+ ASNotiData as_noti_data;
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+
+ /* check account bind type and branch off */
+ if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, false, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err);
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ int as_handle;
+ if ( email_get_handle_for_activesync(&as_handle, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err);
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ /* noti to active sync */
+ as_noti_data.send_mail.handle = as_handle;
+ as_noti_data.send_mail.account_id = mailbox->account_id;
+ as_noti_data.send_mail.mailbox_name = strdup(mailbox->name);
+ as_noti_data.send_mail.mail_id = mail_id;
+
+ memcpy(&as_noti_data.send_mail.options, sending_option, sizeof(emf_option_t));
+
+ if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEND_MAIL, &as_noti_data) == false) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(handle)
+ *handle = as_handle;
+ } else {
+ hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)){
+ EM_DEBUG_EXCEPTION("email_send_mail--Add Param mailbox failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* mail_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))){
+ EM_DEBUG_EXCEPTION("email_send_mail--Add Param mail_id failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* sending options */
+ pSendingOption = em_convert_option_to_byte_stream(sending_option, &size);
+
+ if ( NULL == pSendingOption) {
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pSendingOption, size)){
+ EM_DEBUG_EXCEPTION("email_send_mail--Add Param Sending_Option failed ");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(pSendingOption);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("email_send_mail--emipc_execute_proxy_api failed ");
+ EM_SAFE_FREE(pSendingOption);
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_CRASH);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ if (err == EMF_ERROR_NONE) {
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ }
+ }
+
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ hAPI = (HIPC_API)NULL;
+ EM_SAFE_FREE(pSendingOption);
+ EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(as_noti_data.send_mail.mailbox_name);
+#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_MAIL);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)){
+ EM_DEBUG_EXCEPTION("Add Param mailbox failed ");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* mail_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))){
+ EM_DEBUG_EXCEPTION("Add Param mail_id failed ");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* sending options */
+ pSendingOption = em_convert_option_to_byte_stream(sending_option, &size);
+
+ if ( NULL == pSendingOption)
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pSendingOption, size)){
+ EM_DEBUG_EXCEPTION("Add Param Sending_Option failed ");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(pSendingOption);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_execute_proxy_api(hAPI, NULL)) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed ");
+ EM_SAFE_FREE(pSendingOption);
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ err emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), );
+ if (err == EMF_ERROR_NONE)
+ {
+ if(handle)
+ handle = *(unsigned int*)emipc_get_parameter(hAPI, ePARAMETER_OUT, 1); /* Warning removal changes */
+ }
+
+ EM_DEBUG_LOG(" >>>>>> ERROR CODE : %d ", err);
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(pSendingOption);
+ EM_SAFE_FREE(mailbox_stream);
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d], sending_option[%p], handle[%p]", account_id, sending_option, handle);
+
+ char* pOptionStream = NULL;
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+
+ EM_IF_NULL_RETURN_VALUE(account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(sending_option, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SEND_SAVED);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* Account ID */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(account_id), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Sending Option */
+ pOptionStream = em_convert_option_to_byte_stream(sending_option, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(pOptionStream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pOptionStream, size)) {
+ EM_DEBUG_EXCEPTION("Add Param sending option failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(pOptionStream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_SAFE_FREE(pOptionStream);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_sync_local_activity(int account_id)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id[%d]", account_id);
+
+ int err = EMF_ERROR_NONE;
+
+ if (account_id < 0 || account_id == 0) {
+ EM_DEBUG_EXCEPTION("account_id[%d]", account_id);
+
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SYNC_LOCAL_ACTIVITY);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+int EmfMailboxSyncHeader(emf_mailbox_t* mailbox, unsigned* handle, int* err_code)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], handle[%p], err_code[%p]", mailbox, handle, err_code);
+ int err = EMF_ERROR_NONE;
+
+ err = email_sync_header(mailbox,handle);
+
+ if (err_code != NULL)
+ *err_code = err;
+
+ return (err >= 0);
+}
+
+EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], handle[%p]", mailbox, handle);
+ char* mailbox_stream = NULL;
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+ /* int total_count = 0; */
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ emf_account_server_t account_server_type;
+ HIPC_API hAPI = NULL;
+ ASNotiData as_noti_data;
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+
+ /* 2010/02/12 ch715.lee : check account bind type and branch off */
+ if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, true, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ int as_handle;
+ if ( email_get_handle_for_activesync(&as_handle, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err);
+ goto FINISH_OFF;
+ }
+
+ /* noti to active sync */
+ as_noti_data.sync_header.handle = as_handle;
+ as_noti_data.sync_header.account_id = mailbox->account_id;
+ /* In case that Mailbox is NULL, SYNC ALL MAILBOX */
+ as_noti_data.sync_header.mailbox_name = (mailbox && mailbox->name) ? strdup(mailbox->name) : NULL;
+
+ if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(handle)
+ *handle = as_handle;
+
+ }
+ else {
+ hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if (err != EMF_ERROR_NONE)
+ goto FINISH_OFF;
+
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ }
+
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(as_noti_data.sync_header.mailbox_name);
+#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ EM_DEBUG_LOG("RETURN VALUE : %d ", err);
+
+ if (err != EMF_ERROR_NONE)
+ goto FINISH_OFF;
+
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(mailbox_stream);
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_sync_header_for_all_account(unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("handle[%p]", handle);
+ char* mailbox_stream = NULL;
+ emf_mailbox_t mailbox;
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+ HIPC_API hAPI = NULL;
+ int return_handle;
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ ASNotiData as_noti_data;
+ int i, account_count = 0;
+ emstorage_account_tbl_t *account_tbl_array = NULL;
+ int as_err;
+#endif
+
+ hAPI = emipc_create_email_api(_EMAIL_API_SYNC_HEADER);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ mailbox.account_id = ALL_ACCOUNT;
+ mailbox.name = NULL;
+ mailbox.alias = NULL;
+ mailbox.account_name = NULL;
+
+ mailbox_stream = em_convert_mailbox_to_byte_stream(&mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if (err != EMF_ERROR_NONE)
+ goto FINISH_OFF;
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), &return_handle);
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+
+ /* Get all accounts for sending notification to active sync engine. */
+ if (!emstorage_get_account_list(&account_count, &account_tbl_array , true, false, &as_err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_account_list failed [ %d ] ", as_err);
+
+ goto FINISH_OFF;
+ }
+
+ for(i = 0; i < account_count; i++) {
+ if ( account_tbl_array[i].receiving_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ /* use returned handle value for a active sync handle */
+ /* int as_handle; */
+ /*
+ if ( email_get_handle_for_activesync(&as_handle, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err);
+ goto FINISH_OFF;
+ }
+ */
+
+ /* noti to active sync */
+ as_noti_data.sync_header.handle = return_handle;
+ as_noti_data.sync_header.account_id = account_tbl_array[i].account_id;
+ /* In case that Mailbox is NULL, SYNC ALL MAILBOX */
+ as_noti_data.sync_header.mailbox_name = NULL;
+
+ if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SYNC_HEADER, &as_noti_data) == false) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+ }
+ }
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+
+
+ if(handle)
+ *handle = return_handle;
+
+FINISH_OFF:
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(mailbox_stream);
+ if ( account_tbl_array )
+ emstorage_free_account(&account_tbl_array, account_count, NULL);
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d],with_attachment[%d]", mailbox, mail_id, with_attachment);
+ char* mailbox_stream = NULL;
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ emf_account_server_t account_server_type;
+ HIPC_API hAPI = NULL;
+ ASNotiData as_noti_data;
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+
+ /* 2010/02/12 ch715.lee : check account bind type and branch off */
+ if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, true, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ int as_handle;
+ if ( email_get_handle_for_activesync(&as_handle, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err);
+ goto FINISH_OFF;
+ }
+
+ /* noti to active sync */
+ as_noti_data.download_body.handle = as_handle;
+ as_noti_data.download_body.account_id = mailbox->account_id;
+ as_noti_data.download_body.mail_id = mail_id;
+ as_noti_data.download_body.with_attachment = with_attachment;
+
+ if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_BODY, &as_noti_data) == false) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(handle)
+ *handle = as_handle;
+ } else {
+ hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_BODY);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* MailBox Information */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Mail Id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* with_attachment */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_attachment, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ if (err != EMF_ERROR_NONE)
+ goto FINISH_OFF;
+
+ if(handle)
+ {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ EM_DEBUG_LOG("RETURN VALUE : %d handle %d", err, *handle);
+
+ }
+ }
+
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(mailbox_stream);
+#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_BODY);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* MailBox Information */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Mail Id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&mail_id, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* with_attachment */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&with_attachment, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ if (err != EMF_ERROR_NONE)
+ goto FINISH_OFF;
+
+ /* Download handle */
+ if(handle) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+ EM_DEBUG_LOG("RETURN VALUE : %d handle %d", err, *handle);
+
+ }
+FINISH_OFF:
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(mailbox_stream);
+
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+
+
+
+
+/* API - Downloads the Email Attachment Information [ INTERNAL ] */
+
+EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox,int mail_id, const char* nth,unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN("mailbox[%p], mail_id[%d], nth[%p], handle[%p]", mailbox, mail_id, nth, handle);
+ char* mailbox_stream = NULL;
+ int err = EMF_ERROR_NONE;
+ int size = 0;
+
+ EM_IF_NULL_RETURN_VALUE(mailbox, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(mail_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_ACCOUNT_ID_NULL(mailbox->account_id, EMF_ERROR_INVALID_PARAM);
+ /* EM_IF_NULL_RETURN_VALUE(nth, EMF_ERROR_INVALID_PARAM); */
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ emf_account_server_t account_server_type;
+ HIPC_API hAPI = NULL;
+ ASNotiData as_noti_data;
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+
+ if ( email_get_account_server_type_by_account_id(mailbox->account_id, &account_server_type, true, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ int as_handle;
+ if ( email_get_handle_for_activesync(&as_handle, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err);
+ goto FINISH_OFF;
+ }
+
+ /* noti to active sync */
+ as_noti_data.download_attachment.handle = as_handle;
+ as_noti_data.download_attachment.account_id = mailbox->account_id;
+ as_noti_data.download_attachment.mail_id = mail_id;
+ as_noti_data.download_attachment.attachment_order = strdup(nth);
+ if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_DOWNLOAD_ATTACHMENT, &as_noti_data) == false) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(handle)
+ *handle = as_handle;
+ } else {
+ hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_ATTACHMENT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Mail ID */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* nth */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*) nth, sizeof(nth))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ if (err != EMF_ERROR_NONE)
+ goto FINISH_OFF;
+
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+
+ }
+
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(mailbox_stream);
+ EM_SAFE_FREE(as_noti_data.download_attachment.attachment_order);
+#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DOWNLOAD_ATTACHMENT);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* Mailbox */
+ mailbox_stream = em_convert_mailbox_to_byte_stream(mailbox, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(mailbox_stream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, mailbox_stream, size)) {
+ EM_DEBUG_EXCEPTION("Add Param mailbox failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Mail ID */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &(mail_id), sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* nth */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, nth, sizeof(nth))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter mail_id failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("EmfDownloadAttachment--emipc_execute_proxy_api failed");
+ EM_SAFE_FREE(mailbox_stream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ EM_DEBUG_LOG(" >>>>> EmfDownloadAttachment RETURN VALUE : %d ", err);
+
+ if (err != EMF_ERROR_NONE)
+ goto FINISH_OFF;
+
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+
+ /* Prevent defect 36700 */
+ /* EM_DEBUG_LOG(" >>>>> Handle_proxy : %d ", *handle); */
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_SAFE_FREE(mailbox_stream);
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+
+EXPORT_API int email_cancel_job(int account_id, int handle)
+{
+ EM_DEBUG_FUNC_BEGIN("account_id [%d], handle [%d]", account_id, handle);
+ int err = EMF_ERROR_NONE;
+
+ if(account_id < 0)
+ return EMF_ERROR_INVALID_PARAM;
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ emf_account_server_t account_server_type;
+ HIPC_API hAPI = NULL;
+ ASNotiData as_noti_data;
+ emstorage_account_tbl_t *account_list = NULL;
+ int i, account_count = 0;
+
+ if ( account_id == ALL_ACCOUNT ) { /* this means that job is executed with all account */
+ /* Get all accounts for sending notification to active sync engine. */
+ if (!emstorage_get_account_list(&account_count, &account_list , true, false, &err)) {
+ EM_DEBUG_EXCEPTION("email_get_account_list-- Failed [ %d ] ", err);
+
+ goto FINISH_OFF;
+ }
+
+ for(i = 0; i < account_count; i++) {
+ if ( email_get_account_server_type_by_account_id(account_list[i].account_id, &account_server_type, true, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+ as_noti_data.cancel_job.account_id = account_list[i].account_id;
+ as_noti_data.cancel_job.handle = handle;
+
+ if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+ }
+ }
+
+ /* request canceling to stub */
+ hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) { /* account_id == 0 */
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &handle, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ }
+ else {
+ if ( email_get_account_server_type_by_account_id(account_id, &account_server_type, true, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ memset(&as_noti_data, 0x00, sizeof(ASNotiData));
+ as_noti_data.cancel_job.account_id = account_id;
+ as_noti_data.cancel_job.handle = handle;
+
+ if ( email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_CANCEL_JOB, &as_noti_data) == false) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+ } else {
+ hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &handle, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ }
+ }
+
+FINISH_OFF:
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ if ( account_list )
+ emstorage_free_account(&account_list, account_count, NULL);
+
+#else /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_CANCEL_JOB);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &handle, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ EM_DEBUG_LOG(" >>>>> EmfCancelJob RETURN VALUE : %d ", err);
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+
+
+EXPORT_API int email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status)
+{
+ EM_DEBUG_FUNC_BEGIN("action[%d], account_id[%d], mail_id[%d], status[%p]", action, account_id, mail_id, status);
+
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_ACCOUNT_ID_NULL(account_id, EMF_ERROR_NULL_VALUE);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_PENDING_JOB);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &action, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter action failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, &mail_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter account_id failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if(status) {
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), status);
+ EM_DEBUG_LOG("status : %d ", *status);
+ }
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+
+}
+
+
+
+EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving)
+{
+ EM_DEBUG_FUNC_BEGIN("on_sending[%p], on_receiving[%p]", on_sending, on_receiving);
+ int err = EMF_ERROR_NONE;
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_NETWORK_GET_STATUS);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* Execute API */
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ err = EMF_ERROR_IPC_SOCKET_FAILURE ;
+ EM_DEBUG_FUNC_END("err [%d]", err); return err;
+ }
+
+ if(on_sending)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), on_sending );
+ if(on_receiving)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), on_receiving);
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+
+ if(account_id <= 0 || !mailbox) {
+ EM_DEBUG_LOG("invalid parameters");
+ return EMF_ERROR_INVALID_PARAM;
+ }
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_GET_IMAP_MAILBOX_LIST);
+
+ /* account_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&account_id, sizeof(int))) {
+ EM_DEBUG_LOG("emipc_add_parameter failed ");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_execute_proxy_api(hAPI)) {
+ EM_DEBUG_LOG("ipcProxy_ExecuteAsyncAPI failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ if(handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), handle);
+
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_search_mail_on_server(int input_account_id, const char *input_mailbox_name, email_search_filter_t *input_search_filter_list, int input_search_filter_count, unsigned *output_handle)
+{
+ EM_DEBUG_FUNC_BEGIN("input_account_id [%d], input_mailbox_name [%p], input_search_filter_list [%p], input_search_filter_count [%d], output_handle [%p]", input_account_id, input_mailbox_name, input_search_filter_list, input_search_filter_count, output_handle);
+
+ int err = EMF_ERROR_NONE;
+ int return_value = 0;
+ int stream_size_for_search_filter_list = 0;
+ char *stream_for_search_filter_list = NULL;
+ HIPC_API hAPI = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(input_account_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_mailbox_name, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(input_search_filter_list, EMF_ERROR_INVALID_PARAM);
+
+#ifdef __FEATURE_SUPPORT_ACTIVE_SYNC__
+ emf_account_server_t account_server_type = EMF_SERVER_TYPE_NONE;
+ ASNotiData as_noti_data;
+
+ memset(&as_noti_data, 0, sizeof(ASNotiData)); /* initialization of union members */
+
+ if ( email_get_account_server_type_by_account_id(input_account_id, &account_server_type, true, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_account_server_type_by_account_id failed[%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if ( account_server_type == EMF_SERVER_TYPE_ACTIVE_SYNC ) {
+ int as_handle = 0;
+
+ if ( email_get_handle_for_activesync(&as_handle, &err) == false ) {
+ EM_DEBUG_EXCEPTION("email_get_handle_for_activesync failed[%d].", err);
+ goto FINISH_OFF;
+ }
+
+ /* noti to active sync */
+ as_noti_data.search_mail_on_server.handle = as_handle;
+ as_noti_data.search_mail_on_server.account_id = input_account_id;
+ as_noti_data.search_mail_on_server.mailbox_name = EM_SAFE_STRDUP(input_mailbox_name);
+ as_noti_data.search_mail_on_server.search_filter_list = input_search_filter_list;
+ as_noti_data.search_mail_on_server.search_filter_count = input_search_filter_count;
+
+ return_value = email_send_notification_to_active_sync_engine(ACTIVE_SYNC_NOTI_SEARCH_ON_SERVER, &as_noti_data);
+
+ EM_SAFE_FREE(as_noti_data.search_mail_on_server.mailbox_name);
+
+ if ( return_value == false ) {
+ EM_DEBUG_EXCEPTION("email_send_notification_to_active_sync_engine failed.");
+ err = EMF_ERROR_ACTIVE_SYNC_NOTI_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(output_handle)
+ *output_handle = as_handle;
+ }
+ else
+#endif /* __FEATURE_SUPPORT_ACTIVE_SYNC__ */
+ {
+ hAPI = emipc_create_email_api(_EMAIL_API_SEARCH_MAIL_ON_SERVER);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)&input_account_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMF_ERROR_IPC_PROTOCOL_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (void*)input_mailbox_name, strlen(input_mailbox_name))){
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMF_ERROR_IPC_PROTOCOL_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ stream_for_search_filter_list = em_convert_search_filter_to_byte_stream(input_search_filter_list, input_search_filter_count, &stream_size_for_search_filter_list);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(stream_for_search_filter_list, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, stream_for_search_filter_list, stream_size_for_search_filter_list)) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed ");
+ err = EMF_ERROR_IPC_PROTOCOL_FAILURE;
+ goto FINISH_OFF;
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ if (err != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("_EMAIL_API_SEARCH_MAIL_ON_SERVER failed [%d]", err);
+ goto FINISH_OFF;
+ }
+
+ if(output_handle)
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 1, sizeof(int), output_handle);
+ }
+
+FINISH_OFF:
+ if(hAPI) {
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ }
+
+ EM_DEBUG_FUNC_END("err [%d]", err);
+ return err;
+}
diff --git a/email-api/email-api-rule.c b/email-api/email-api-rule.c
new file mode 100755
index 0000000..73c6389
--- /dev/null
+++ b/email-api/email-api-rule.c
@@ -0,0 +1,236 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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.
+*
+*/
+
+
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-rule.c
+ * @brief This file contains the data structures and interfaces of Rule related Functionality provided by
+ * email-service .
+ */
+
+#include "email-api.h"
+#include "string.h"
+#include "email-convert.h"
+#include "email-storage.h"
+#include "email-utilities.h"
+#include "email-ipc.h"
+
+EXPORT_API int email_get_rule(int filter_id, emf_rule_t** filtering_set)
+{
+ EM_DEBUG_FUNC_BEGIN("filter_id[%d], filtering_set[%p]", filter_id, filtering_set);
+
+ int err = 0;
+
+ EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(filter_id, EMF_ERROR_INVALID_PARAM);
+
+ if (!emstorage_get_rule_by_id(0, filter_id, (emstorage_rule_tbl_t**)filtering_set, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_rule_by_id failed [%d]", err);
+
+ goto FINISH_OFF;
+ } else
+ err = EMF_ERROR_NONE;
+
+FINISH_OFF:
+ EM_DEBUG_FUNC_END("error value [%d]", err);
+ return err;
+}
+
+
+EXPORT_API int email_get_rule_list(emf_rule_t** filtering_set, int* count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+
+ int err = EMF_ERROR_NONE;
+ int is_completed = 0;
+
+ EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
+
+ *count = 1000;
+
+ if (!emstorage_get_rule(0, 0, 0, count, &is_completed, (emstorage_rule_tbl_t**)filtering_set, true, &err)) {
+ EM_DEBUG_EXCEPTION("emstorage_get_rule failed [%d]", err);
+
+
+ goto FINISH_OFF;
+ } else
+ err = EMF_ERROR_NONE;
+
+
+FINISH_OFF:
+
+ return err;
+
+}
+
+EXPORT_API int email_add_rule(emf_rule_t* filtering_set)
+{
+ EM_DEBUG_FUNC_BEGIN("filtering_set[%p]", filtering_set);
+
+ int size = 0;
+ int err = EMF_ERROR_NONE;
+ char* pRuleStream = NULL;
+
+ EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_ADD_RULE);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ pRuleStream = em_convert_rule_to_byte_stream(filtering_set, &size);
+
+ EM_PROXY_IF_NULL_RETURN_VALUE(pRuleStream, hAPI, EMF_ERROR_NULL_VALUE);
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pRuleStream, size)) {
+ EM_DEBUG_EXCEPTION("Add Param Failed");
+ EM_SAFE_FREE(pRuleStream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Failed");
+ EM_SAFE_FREE(pRuleStream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ EM_SAFE_FREE(pRuleStream);
+ emipc_destroy_email_api(hAPI);
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("error value [%d]", err);
+ return err;
+}
+
+
+
+EXPORT_API int email_update_rule(int filter_id, emf_rule_t* new_set)
+{
+ EM_DEBUG_FUNC_BEGIN("filter_id[%d], new_set[%p]", filter_id, new_set);
+
+ int size = 0;
+ char* pFilterStream = NULL;
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(filter_id, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(new_set, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_UPDATE_RULE);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* filter_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("Add Param filter_id Failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ /* new_set */
+ pFilterStream = em_convert_rule_to_byte_stream(new_set, &size);
+
+ if(NULL == pFilterStream) {
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, pFilterStream, size)){
+ EM_DEBUG_EXCEPTION("Add Param new_set Failed");
+ EM_SAFE_FREE(pFilterStream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api Failed");
+ EM_SAFE_FREE(pFilterStream);
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+
+ EM_SAFE_FREE(pFilterStream);
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("error value [%d]", err);
+ return err;
+}
+
+
+
+
+EXPORT_API int email_delete_rule(int filter_id)
+{
+ EM_DEBUG_FUNC_BEGIN("filter_id[%d]", filter_id);
+
+ int err = EMF_ERROR_NONE;
+
+ EM_IF_NULL_RETURN_VALUE(filter_id, EMF_ERROR_INVALID_PARAM);
+
+ HIPC_API hAPI = emipc_create_email_api(_EMAIL_API_DELETE_RULE);
+
+ EM_IF_NULL_RETURN_VALUE(hAPI, EMF_ERROR_NULL_VALUE);
+
+ /* filter_id */
+ if(!emipc_add_parameter(hAPI, ePARAMETER_IN, (char*)&filter_id, sizeof(int))) {
+ EM_DEBUG_EXCEPTION("emipc_add_parameter failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_NULL_VALUE);
+ }
+
+ if(emipc_execute_proxy_api(hAPI) != EMF_ERROR_NONE) {
+ EM_DEBUG_EXCEPTION("emipc_execute_proxy_api failed");
+ EM_PROXY_IF_NULL_RETURN_VALUE(0, hAPI, EMF_ERROR_IPC_SOCKET_FAILURE);
+ }
+
+ emipc_get_parameter(hAPI, ePARAMETER_OUT, 0, sizeof(int), &err);
+ emipc_destroy_email_api(hAPI);
+
+ hAPI = NULL;
+ EM_DEBUG_FUNC_END("error value [%d]", err);
+ return err;
+}
+
+EXPORT_API int email_free_rule (emf_rule_t** filtering_set, int count)
+{
+ EM_DEBUG_FUNC_BEGIN();
+ int err = EMF_ERROR_NONE, i;
+
+ EM_IF_NULL_RETURN_VALUE(filtering_set, EMF_ERROR_INVALID_PARAM);
+ EM_IF_NULL_RETURN_VALUE(count, EMF_ERROR_INVALID_PARAM);
+
+ if (count > 0) {
+ emf_rule_t* p = *filtering_set;
+
+ for (i = 0; i < count; i++) {
+ EM_SAFE_FREE(p[i].value);
+ EM_SAFE_FREE(p[i].mailbox);
+ }
+
+ EM_SAFE_FREE(p); *filtering_set = NULL;
+ }
+
+ EM_DEBUG_FUNC_END("error value [%d]", err);
+ return err;
+}
+
+
diff --git a/email-api/include/email-api-account.h b/email-api/include/email-api-account.h
new file mode 100755
index 0000000..49c68e6
--- /dev/null
+++ b/email-api/include/email-api-account.h
@@ -0,0 +1,415 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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 __EMAIL_API_ACCOUNT_H__
+#define __EMAIL_API_ACCOUNT_H__
+
+#include "email-types.h"
+
+/**
+* @defgroup EMAIL_SERVICE Email Service
+* @{
+*/
+
+
+/**
+* @ingroup EMAIL_SERVICE
+* @defgroup EMAIL_API_ACCOUNT Email Account API
+* @{
+*/
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-account.h
+ * @author Kyuho Jo <kyuho.jo@samsung.com>
+ * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
+ * @version 0.1
+ * @brief This file contains the data structures and interfaces of Accounts provided by
+ * email-service .
+ *
+* @{
+
+* @code
+* #include "emf_mapi_account.h"
+* bool
+* other_app_invoke_uniform_api_sample(int* error_code)
+* {
+* emf_account_t *account = NULL;
+* emf_account_t *new_account = NULL;
+*
+* account = malloc(sizeof(emf_account_t));
+* memset(account, 0x00, sizeof(emf_account_t));
+*
+* account->account_bind_type = 1;
+* account->retrieval_mode = 1;
+* account->use_security = 1;
+* account->sending_server_type = EMF_SERVER_TYPE_SMTP;
+* account->sending_port_num = EMF_SMTP_PORT;
+* account->sending_auth = 1;
+* account->flag1 = 2;
+* account->account_bind_type = 1;
+* account->account_name = strdup("gmail");
+* account->display_name = strdup("Tom");
+* account->email_addr = strdup("tom@gmail.com");
+* account->reply_to_addr = strdup("tom@gmail.com");
+* account->return_addr = strdup("tom@gmail.com");
+* account->receiving_server_type = EMF_SERVER_TYPE_POP3;
+* account->receiving_server_addr = strdup("pop3.gmail.com");
+* account->port_num = 995;
+* account->use_security = 1;
+* account->retrieval_mode = EMF_IMAP4_RETRIEVAL_MODE_ALL;
+* account->user_name = strdup("tom");
+* account->password = strdup("password");
+* account->sending_server_type = EMF_SERVER_TYPE_SMTP;
+* account->sending_server_addr = strdup("smtp.gmail.com");
+* account->sending_port_num = 587;
+* account->sending_security = 0x02;
+* account->sending_auth = 1;
+* account->sending_user = strdup("tom@gmail.com");
+* account->sending_password = strdup("password");
+* account->pop_before_smtp = 0;
+* account->apop = 0;
+* account->flag1 = 2;
+* account->flag2 = 1;
+* account->preset_account = 1;
+* account->logo_icon_path = strdup("Logo Icon Path");
+* account->target_storage = 0;
+* account->options.priority = 3;
+* account->options.keep_local_copy = 0;
+* account->options.req_delivery_receipt = 0;
+* account->options.req_read_receipt = 0;
+* account->options.download_limit = 0;
+* account->options.block_address = 0;
+* account->options.block_subject = 0;
+* account->options.display_name_from = strdup("Display name from");
+* account->options.reply_with_body = 0;
+* account->options.forward_with_files = 0;
+* account->options.add_myname_card = 0;
+* account->options.add_signature = 0;
+* account->options.signature= strdup("Signature");
+* account->check_interval = 0;
+* // Add account
+* if(EMF_ERROR_NONE != email_add_account(account))
+* //failure
+* //else
+* {
+* //success
+* if(account_id)
+* *account_id = account->account_id;
+* }
+* if(EMF_ERROR_NONE != email_validate_account(account_id,&account_handle))
+* //failure
+* else
+* //success
+* if(EMF_ERROR_NONE != email_delete_account(account_id))
+* //failure
+* else
+* //success
+* new_account = malloc(sizeof(emf_account_t));
+* memset(new_account, 0x00, sizeof(emf_account_t));
+* new_account->flag1 = 1;
+* new_account->account_name = strdup("samsung001");
+* new_account->display_name = strdup("Tom001");
+* new_account->options.keep_local_copy = 1;
+* new_account->check_interval = 55;
+* // Update account
+* if(EMF_ERROR_NONE != email_update_account(acount_id,new_account))
+* //failure
+* else
+* //success
+* // Get account
+* if(EMF_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account))
+* //failure
+* else
+* //success
+* // Get list of accounts
+* if(EMF_ERROR_NONE != email_get_account_list(&account_list,&count))
+* //failure
+* else
+* //success
+* // free account
+* email_free_account(&account, 1);
+* }
+ *
+ * @endcode
+ * @}
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @open
+ * @fn email_add_account(emf_account_t* account)
+ * @brief Create a new email account.This function is invoked when user wants to add new email account
+ *
+ * @param[in] account Specifies the structure pointer of account.
+ * @exception none
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see emf_account_t
+ * @remarks N/A
+ */
+EXPORT_API int email_add_account(emf_account_t* account);
+
+/**
+ * @open
+ * @fn email_delete_account(int account_id)
+ * @brief Delete a email account.This function is invoked when user wants to delete an existing email account
+ *
+ * @param[in] account_id Specifies the account ID.
+ * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see
+ * @remarks N/A
+ */
+EXPORT_API int email_delete_account(int account_id);
+
+/**
+ * @open
+ * @fn email_update_account(int account_id, emf_account_t* new_account)
+ * @brief Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account.
+ *
+ * @param[in] account_id Specifies the orignal account ID.
+ * @param[in] new_account Specifies the information of new account.
+ * @param[in] with_validation If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation.
+ * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see emf_account_t
+ * @remarks N/A
+ */
+EXPORT_API int email_update_account(int account_id, emf_account_t* new_account);
+
+/**
+ * @open
+ * @fn email_update_account_with_validation(int account_id, emf_account_t* new_account)
+ * @brief Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account.
+ *
+ * @param[in] account_id Specifies the orignal account ID.
+ * @param[in] new_account Specifies the information of new account.
+ * @param[in] with_validation If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation.
+ * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see emf_account_t
+ * @remarks N/A
+ */
+EXPORT_API int email_update_account_with_validation(int account_id, emf_account_t* new_account);
+
+/**
+ * @open
+ * @fn email_get_account(int account_id, int pulloption, emf_account_t** account)
+ * @brief Get an email account by ID. This function is getting invoked when user wants to get the account informantion based on account id and option (GET_FULL_DATA/WITHOUT_OPTION/ONLY_OPTION).<br>
+ * Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account().
+ *
+ * @param[in] account_id Specifies the account ID.This function is invoked when user
+ * @param[in] pulloption Option to specify to get full details or partial, see definition of EMF_ACC_GET_OPT_XXX
+ * @param[out] account The returned account is saved here.
+ * @exception #EMF_ERR_INVALID_PARAM -Invalid argument
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see emf_account_t
+ * @remarks N/A
+ */
+
+EXPORT_API int email_get_account(int account_id, int pulloption, emf_account_t** account);
+
+/**
+ * @open
+ * @fn email_get_account_list(emf_account_t** account_list, int* count);
+ * @brief Get Account List.This function is getting invoked when user wants to get all account information based on the count of accounts provided by user.<br>
+ * Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account().
+ *
+ * @param[in] account_list Specifies the structure pointer of account.
+ * @param[out] count Specifies the count of accounts.
+ * @exception #EMF_ERR_INVALID_PARAM -Invalid argument
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see emf_account_t
+ * @remarks N/A
+ */
+EXPORT_API int email_get_account_list(emf_account_t** account_list, int* count);
+
+ /**
+ * @open
+ * @fn email_free_account(emf_account_t** account_list, int count);
+ * @brief Free allocated memory.This function is getting invoked when user wants to delete all account information.
+ *
+ * @param[in] account_list Specifies the structure pointer of account.
+ * @param[out] count Specifies the count of accounts.
+ * @exception #EMF_ERR_INVALID_PARAM -Invalid argument
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see emf_account_t
+ * @remarks N/A
+ */
+EXPORT_API int email_free_account(emf_account_t** account_list, int count);
+
+
+/**
+ * @open
+ * @fn email_validate_account(int account_id, unsigned* handle)
+ * @brief Validate account.This function is getting invoked after adding one account to validate it.If account is not validated then user should retry once again to add the account .
+ *
+ * @param[in] account_id Specifies the account Id to validate.
+ * @param[out] handle Specifies the sending handle.
+ * @remarks N/A
+ * @exception #EMF_ERR_INVALID_PARAM -Invalid argument
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_validate_account(int account_id, unsigned* handle);
+
+/**
+ * @open
+ * @fn email_add_account_with_validation(emf_account_t* account, unsigned* handle)
+ * @brief Add an account when the account is validated. This function is getting invoked when user want to validate an account. If account is not validated then user should retry once again to add the account.<br>
+ * Validation is executed without saving an account to DB
+ *
+ * @param[in] account Specifies the structure pointer of account.
+ * @param[out] handle Specifies the sending handle.
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_add_account_with_validation(emf_account_t* account, unsigned* handle);
+
+
+/**
+ * @open
+ * @fn email_backup_accounts_into_secure_storage(const char *file_name)
+ * @brief Back up information of all accounts into secure storage.
+ * This function is getting invoked when user want to backup account information safely.
+ *
+ * @param[in] file_name Specifies the file name in secure storage
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name);
+
+/**
+ * @open
+ * @fn email_restore_accounts_from_secure_storage(const char *file_name)
+ * @brief Restore accounts from stored file in secure storage.
+ * This function is getting invoked when user want to restore accounts.
+ *
+ * @param[in] file_name Specifies the file name in secure storage
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name);
+
+/**
+ * @open
+ * @fn email_get_password_length_of_account(const int account_id, int *password_length)
+ * @brief Get password length of an account.
+ * This function is getting invoked when user want to know the length of an account.
+ *
+ * @param[in] account_id Specifies the account id
+ * @param[out] handle Specifies the password length.
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_get_password_length_of_account(const int account_id, int *password_length);
+
+
+/**
+ * @open
+ * @fn email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info)
+ * @brief Query email server information.
+ * This function is getting invoked when user want to get email server information.
+ *
+ * @param[in] domain_name Specifies the domain name of server
+ * @param[out] result_server_info Specifies the information of email server.
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info);
+
+/**
+ * @open
+ * @fn email_free_server_info(emf_server_info_t **result_server_info)
+ * @brief Free emf_server_info_t.
+ * This function is getting invoked when user want to free emf_server_info_t.
+ *
+ * @param[in] result_server_info Specifies the pointer of in secure storage
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_free_server_info(emf_server_info_t **result_server_info);
+
+/**
+ * @open
+ * @fn email_update_notification_bar(int account_id)
+ * @brief Update notifications on notification bar.
+ * This function is getting invoked when user want to update notification bar.
+ *
+ * @param[in] account_id Specifies the id of account.
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_update_notification_bar(int account_id);
+
+/**
+ * @open
+ * @fn email_clear_all_notification_bar()
+ * @brief Clear all notification on notification bar.
+ * This function is getting invoked when user want to clear notification bar.
+ *
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_clear_all_notification_bar();
+
+
+/**
+ * @open
+ * @fn email_save_default_account_id()
+ * @brief Save default account id to vconf storage.
+ * This function is getting invoked when user want to save default account id.
+ *
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_save_default_account_id(int input_account_id);
+
+/**
+ * @open
+ * @fn email_load_default_account_id()
+ * @brief Load default account id to vconf storage.
+ * This function is getting invoked when user want to load default account id.
+ *
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_load_default_account_id(int *output_account_id);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @} @}
+*/
+
+#endif /* __EMAIL_API_ACCOUNT_H__ */
+
+
diff --git a/email-api/include/email-api-init.h b/email-api/include/email-api-init.h
new file mode 100755
index 0000000..cd4e00c
--- /dev/null
+++ b/email-api/include/email-api-init.h
@@ -0,0 +1,174 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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 __EMAIL_API_INTI_H__
+#define __EMAIL_API_INTI_H__
+
+#include "email-types.h"
+
+/**
+* @defgroup EMAIL_SERVICE Email Service
+* @{
+*/
+
+
+/**
+* @ingroup EMAIL_SERVICE
+* @defgroup EMAIL_API_INIT Email Initialization API
+* @{
+*/
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-init.h
+ * @author Kyuho Jo <kyuho.jo@samsung.com>
+ * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
+ * @version 0.1
+ * @brief This file contains the data structures and interfaces of Email FW Initialization provided by
+ * email-service .
+ *@{
+ *@code
+ *
+ * #include "emf_mapi_init.h"
+ *
+ * bool
+ * other_app_invoke_uniform_api_sample(int* error_code)
+ * {
+ * int err = EMF_ERROR_NONE;
+ *
+ * // Open connections to email-service and DB
+ * // The connections will be maintain throughout application's execution
+ * if(EMF_ERROR_NONE == email_service_begin())
+ * {
+ * If(EMF_ERROR_NONE != email_open_db())
+ * {
+ * return false;
+ * }
+ *
+ * // Execute email_init_storage() if and only if there is no db file.
+ * // This fuction will create db file and tables for email service
+ * If(EMF_ERROR_NONE !=email_init_storage())
+ * {
+ * return false;
+ * }
+ * }
+ *
+ * ......
+ *
+ * // Work with calling MAPI functions
+ *
+ * ......
+ *
+ * // Close the connections to email-service and DB after all email job is finished. (ex. close an email application)
+ * // DO NOT have to call these funtions until the connections is not needed any more.
+ * err =email_close_db();
+ * err =email_service_end();
+ * }
+ *
+ * @endcode
+ * @}
+ */
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+
+ * @open
+ * @fn email_init_storage(void)
+ * @brief Create all table for email. Exposed to External Application- core team.Creates all Email DB tables [ EXTERNAL]
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_init_storage(void);
+
+/**
+
+ * @open
+ * @fn email_open_db(void)
+ * @brief This function Open the email DB and register busy handler
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_open_db(void);
+
+
+/**
+
+ * @open
+ * @fn email_close_db(void)
+ * @brief This function closes the connection of the email DB
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_close_db(void);
+
+/**
+
+ * @open
+ * @fn email_service_begin(void)
+ * @brief Does the IPC Proxy Initialization by the Application which used the Email FW API's
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_service_begin(void);
+
+/**
+
+ * @open
+ * @fn email_service_end(void)
+ * @brief This function does the IPC Proxy Finaization by the Application which used the Email FW API's
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_service_end(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @} @}
+*/
+
+
+#endif /* __EMAIL_API_INTI_H__ */
diff --git a/email-api/include/email-api-mail.h b/email-api/include/email-api-mail.h
new file mode 100755
index 0000000..e6d4048
--- /dev/null
+++ b/email-api/include/email-api-mail.h
@@ -0,0 +1,1869 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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 __EMAIL_API_MESSAGE_H__
+#define __EMAIL_API_MESSAGE_H__
+
+#include "email-types.h"
+
+#include <time.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+/**
+* @defgroup EMAIL_SERVICE Email Service
+* @{
+*/
+
+
+/**
+* @ingroup EMAIL_SERVICE
+* @defgroup EMAIL_API_MAIL Email Mail API
+* @{
+*/
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-mail.h
+ * @author Kyuho Jo <kyuho.jo@samsung.com>
+ * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
+ * @version 0.1
+ * @brief This file contains the data structures and interfaces of Messages provided by
+ * email-service .
+ */
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @open
+ * @fn email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas)
+ * @brief Save a mail. This function is invoked when user wants to add a mail.
+ * If the option from_eas is 1 then this will save the message on server as well as on locally.
+ * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_eas value will be 0
+ * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_eas value will be 1/0
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] input_mail_data Specifies the saving mail.
+ * @param[in] input_attachment_data_list Specifies the mailbox structure for saving email.
+ * @param[in] input_attachment_count Specifies if the mail comes from composer.
+ * @param[in] input_meeting_request Specifies if the mail comes from composer.
+ * @param[in] input_from_eas Specifies if the mail will be saved on server.
+
+ * @exception none
+ * @see emf_mail_data_t and emf_mailbox_t
+ * @remarks N/A
+ * @code
+ * #include "email-api-mail.h"
+ * int _test_add_mail ()
+ * {
+ * int i = 0;
+ * int account_id = 0;
+ * int from_eas = 0;
+ * int attachment_count = 0;
+ * int err = EMF_ERROR_NONE;
+ * char arg[50] = { 0 , };
+ * char *body_file_path = "/opt/data/email/.emfdata/tmp/mail.txt";
+ * emf_mailbox_t *mailbox_data = NULL;
+ * emf_mail_data_t *test_mail_data = NULL;
+ * emf_attachment_data_t *attachment_data = NULL;
+ * emf_meeting_request_t *meeting_req = NULL;
+ * FILE *body_file;
+ *
+ * printf("\n > Enter account id : ");
+ * scanf("%d", &account_id);
+ *
+ *
+ * memset(arg, 0x00, 50);
+ * printf("\n > Enter mailbox name : ");
+ * scanf("%s", arg);
+ *
+ * email_get_mailbox_by_name(account_id, arg, &mailbox_data);
+ *
+ * test_mail_data = malloc(sizeof(emf_mail_data_t));
+ * memset(test_mail_data, 0x00, sizeof(emf_mail_data_t));
+ *
+ * printf("\n From EAS? [0/1]> ");
+ * scanf("%d", &from_eas);
+ *
+ * test_mail_data->account_id = account_id;
+ * test_mail_data->save_status = 1;
+ * test_mail_data->flags_seen_field = 1;
+ * test_mail_data->file_path_plain = strdup(body_file_path);
+ * test_mail_data->mailbox_name = strdup(mailbox_data->name);
+ * test_mail_data->mailbox_type = mailbox_data->mailbox_type;
+ * test_mail_data->full_address_from = strdup("<test1@test.com>");
+ * test_mail_data->full_address_to = strdup("<test2@test.com>");
+ * test_mail_data->full_address_cc = strdup("<test3@test.com>");
+ * test_mail_data->full_address_bcc = strdup("<test4@test.com>");
+ * test_mail_data->subject = strdup("Meeting request mail");
+ *
+ * body_file = fopen(body_file_path, "w");
+ *
+ * for(i = 0; i < 500; i++)
+ * fprintf(body_file, "X2 X2 X2 X2 X2 X2 X2");
+ * fflush(body_file);
+ * fclose(body_file);
+ *
+ * printf(" > Attach file? [0/1] : ");
+ * scanf("%d",&attachment_count);
+ *
+ * if ( attachment_count ) {
+ * memset(arg, 0x00, 50);
+ * printf("\n > Enter attachment name : ");
+ * scanf("%s", arg);
+ *
+ * attachment_data = malloc(sizeof(emf_attachment_data_t));
+ *
+ * attachment_data->attachment_name = strdup(arg);
+ *
+ * memset(arg, 0x00, 50);
+ * printf("\n > Enter attachment absolute path : ");
+ * scanf("%s",arg);
+ *
+ * attachment_data->attachment_path = strdup(arg);
+ * attachment_data->save_status = 1;
+ * test_mail_data->attachment_count = attachment_count;
+ * }
+ *
+ * printf("\n > Meeting Request? [0: no, 1: yes (request from server), 2: yes (response from local)]");
+ * scanf("%d", &(test_mail_data->meeting_request_status));
+ *
+ * if ( test_mail_data->meeting_request_status == 1
+ * || test_mail_data->meeting_request_status == 2 ) {
+ * time_t current_time;
+ * meeting_req = malloc(sizeof(emf_meeting_request_t));
+ * memset(meeting_req, 0x00, sizeof(emf_meeting_request_t));
+ *
+ * meeting_req->meeting_response = 1;
+ * current_time = time(NULL);
+ * gmtime_r(&current_time, &(meeting_req->start_time));
+ * gmtime_r(&current_time, &(meeting_req->end_time));
+ * meeting_req->location = malloc(strlen("Seoul") + 1);
+ * memset(meeting_req->location, 0x00, strlen("Seoul") + 1);
+ * strcpy(meeting_req->location, "Seoul");
+ * strcpy(meeting_req->global_object_id, "abcdef12345");
+ *
+ * meeting_req->time_zone.offset_from_GMT = 9;
+ * strcpy(meeting_req->time_zone.standard_name, "STANDARD_NAME");
+ * gmtime_r(&current_time, &(meeting_req->time_zone.standard_time_start_date));
+ * meeting_req->time_zone.standard_bias = 3;
+ *
+ * strcpy(meeting_req->time_zone.daylight_name, "DAYLIGHT_NAME");
+ * gmtime_r(&current_time, &(meeting_req->time_zone.daylight_time_start_date));
+ * meeting_req->time_zone.daylight_bias = 7;
+ *
+ * }
+ *
+ * if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meeting_req, from_eas)) != EMF_ERROR_NONE)
+ * printf("email_add_mail failed. [%d]\n", err);
+ * else
+ * printf("email_add_mail success.\n");
+ *
+ * if(attachment_data)
+ * email_free_attachment_data(&attachment_data, attachment_count);
+ *
+ * if(meeting_req)
+ * email_free_meeting_request(&meeting_req, 1);
+ *
+ * email_free_mail_data(&test_mail_data, 1);
+ * email_free_mailbox(&mailbox_data, 1);
+ *
+ * printf("saved mail id = [%d]\n", test_mail_data->mail_id);
+ *
+ * return 0;
+ * }
+ * @endcode
+ */
+EXPORT_API int email_add_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas);
+
+ /**
+ * @open
+ * @fn email_add_read_receipt(int input_read_mail_id, unsigned *output_handle)
+ * @brief Add a read receipt mail. This function is invoked when user receives a mail with read report enable and wants to send a read report for the same.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] input_read_mail_id Specifies the id of mail which has been read.
+ * @param[out] output_receipt_mail_id Specifies the receipt mail id .
+ * @exception none
+ * @see
+ * @remarks N/A
+ */
+EXPORT_API int email_add_read_receipt(int input_read_mail_id, int *output_receipt_mail_id);
+
+/**
+ * @open
+ * @fn email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_composer)
+ * @brief Update a existing email information. This function is invoked when user wants to change some existing email information with new email information.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] input_mail_data Specifies the mail ID.
+ * @param[in] input_attachment_data_list Specifies the pointer of attachment data.
+ * @param[in] input_attachment_count Specifies the number of attachment data.
+ * @param[in] input_meeting_request Specifies the meeting request data.
+ * @param[in] input_from_eas Specifies whether sync server.
+
+ * @exception none
+ * @see emf_mail_data_t
+ * @code
+ * #include "email-api-account.h"
+ * int email_test_update_mail()
+ * {
+ * int mail_id = 0;
+ * int err = EMF_ERROR_NONE;
+ * int test_attachment_data_count = 0;
+ * char arg[50];
+ * emf_mail_data_t *test_mail_data = NULL;
+ * emf_attachment_data_t *test_attachment_data_list = NULL;
+ * emf_meeting_request_t *meeting_req = NULL;
+ *
+ * printf("\n > Enter mail id : ");
+ * scanf("%d", &mail_id);
+ *
+ * email_get_mail_data(mail_id, &test_mail_data);
+ *
+ * printf("\n > Enter Subject: ");
+ * scanf("%s", arg);
+ *
+ * test_mail_data->subject= strdup(arg);
+ *
+ *
+ *
+ * if (test_mail_data->attachment_count > 0) {
+ * if ( (err = email_get_attachment_data_list(mail_id, &test_attachment_data_list, &test_attachment_data_count)) != EMF_ERROR_NONE ) {
+ * printf("email_get_meeting_request() failed [%d]\n", err);
+ * return -1;
+ * }
+ * }
+ *
+ * if ( test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_REQUEST
+ * || test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_RESPONSE
+ * || test_mail_data->meeting_request_status == EMF_MAIL_TYPE_MEETING_ORIGINATINGREQUEST) {
+ *
+ * if ( (err = email_get_meeting_request(mail_id, &meeting_req)) != EMF_ERROR_NONE ) {
+ * printf("email_get_meeting_request() failed [%d]\n", err);
+ * return -1;
+ * }
+ *
+ * printf("\n > Enter meeting response: ");
+ * scanf("%d", (int*)&(meeting_req->meeting_response));
+ * }
+ *
+ * if ( (err = email_update_mail(test_mail_data, test_attachment_data_list, test_attachment_data_count, meeting_req, 0)) != EMF_ERROR_NONE)
+ * printf("email_update_mail failed.[%d]\n", err);
+ * else
+ * printf("email_update_mail success\n");
+ *
+ * if(test_mail_data)
+ * email_free_mail_data(&test_mail_data, 1);
+ *
+ * if(test_attachment_data_list)
+ * email_free_attachment_data(&test_attachment_data_list, test_attachment_data_count);
+ *
+ * if(meeting_req)
+ * email_free_meeting_request(&meeting_req, 1);
+ *
+ * return 0;
+ * }
+
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_update_mail(emf_mail_data_t *input_mail_data, emf_attachment_data_t *input_attachment_data_list, int input_attachment_count, emf_meeting_request_t* input_meeting_request, int input_from_eas);
+
+/**
+ * @open
+ * @fn email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen)
+ * @brief Get mail count from mailbox.This function is invoked when user wants to know how many toatl mails and out of that
+ * how many unseen mails are there in a given mailbox.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the pointer of mailbox structure.
+ * @param[out] total Total email count is saved here.
+ * @param[out] unseen Unread email count is saved here.
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_count_message()
+ * {
+ * emf_mailbox_t mailbox;
+ * int account_id = 0;
+ * int total = 0;
+ * int unseen = 0;
+ *
+ * memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+ * printf("\n > Enter account_id (0 means all accounts) : ");
+ * scanf("%d", &account_id);
+ * if(account_id == 0)
+ * {
+ * mailbox.name = NULL;
+ * }
+ * else
+ * {
+ * printf("\n > Enter maibox name: ");
+ * mailbox.name = strdup("SENTBOX");
+ * }
+ * mailbox.account_id = account_id;
+ * if(EMF_ERROR_NONE == email_count_message(&mailbox, &total, &unseen))
+ * printf("\n Total: %d, Unseen: %d \n", total, unseen);
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_count_message(emf_mailbox_t* mailbox, int* total, int* unseen);
+
+
+/**
+ * @open
+ * @fn email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server)
+ * @brief Delete a mail or multiple mails.Based on from_server value this function will delte a mail or multiple mails from server or loaclly.
+ * @param[in] mailbox Reserved.
+ * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0
+ * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0
+ *
+ * @param[in] mail_ids[] Specifies the arrary of mail id.
+ * @param[in] num Specifies the number of mail id.
+ * @param[in] from_server Specifies whether mails are deleted from server.
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @exception none
+ * @see emf_mailbox_t
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_delete_all_messages_in_mailbox()
+ * {
+ * int count, i, mail_id=0, account_id =0;
+ * emf_mailbox_t mbox = {0};
+ *
+ * printf("\n > Enter Account_id: ");
+ * scanf("%d",&account_id);
+ * printf("\n > Enter Mail_id: ");
+ * scanf("%d",&mail_id);
+ * printf("\n > Enter Mailbox name: ");
+ * mbox.account_id = account_id;
+ * mbox.name = strdup("INBOX");
+ * if(EMF_ERROR_NONE == email_delete_message(&mbox, &mail_id, 1, 1))
+ * printf("\n email_delete_message success");
+ * else
+ * printf("\n email_delete_message failed");
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_delete_message(emf_mailbox_t* mailbox, int *mail_ids, int num, int from_server);
+
+
+/**
+ * @open
+ * @fn email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server)
+ * @brief Delete all mail from a mailbox.
+ * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0
+ * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the structure of mailbox.
+ * @param[in] from_server Specifies whether mails are also deleted from server.
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_delete_all_messages_in_mailbox()
+ * {
+ * int count, account_id =0;
+ * emf_mailbox_t mbox = {0};
+ *
+ * printf("\n > Enter Account_id: ");
+ * scanf("%d",&account_id);
+ * printf("\n > Enter Mailbox name: ");
+ * mbox.account_id = account_id;
+ * mbox.name = strdup("INBOX");
+ *
+ * if (EMF_ERROR_NONE != email_delete_all_message_in_mailbox(&mbox, 0))
+ * printf("email_delete_all_message_in_mailbox failed");
+ * else
+ * printf("email_delete_all_message_in_mailbox Success");
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_delete_all_message_in_mailbox(emf_mailbox_t* mailbox, int from_server);
+
+
+
+/**
+ * @open
+ * @fn email_clear_mail_data()
+ * @brief delete email data from storage. This API will be used by the Settings Application
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @exception none
+ * @see none
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_clear_mail_data()
+ * {
+ * if(EMF_ERROR_NONE == email_clear_mail_data())
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_clear_mail_data();
+
+
+/**
+ * @open
+ * @fn email_add_attachment( emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment)
+ * @brief Append a attachment to email.This function is invoked when user wants to add attachment to existing mail.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] attachment Specifies the structure of attachment.
+ * @exception none
+ * @see emf_mailbox_t and emf_attachment_info_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_mail_add_attachment()
+ * {
+ * int account_id = 0;
+ * int mail_id = 0;
+ * emf_mailbox_t mbox;
+ * emf_attachment_info_t attachment;
+ *
+ * printf("\n > Enter Mail Id: ");
+ * scanf("%d", &mail_id);
+ * printf("\n > Enter Account_id: ");
+ * scanf("%d",&account_id);
+ * memset(&mbox, 0x00, sizeof(emf_attachment_info_t));
+ * mbox.account_id = account_id;
+ * mbox.name = strdup("INBOX");
+ * memset(&attachment, 0x00, sizeof(emf_attachment_info_t));
+ * printf("\n > Enter attachment name: ");
+ * attachment.name = strdup("Test");
+ * printf("\n > Enter attachment absolute path: ");
+ * attachment.savename = strdup("/tmp/test.txt");
+ * attachment.next = NULL;
+ * if(EMF_ERROR_NONE != email_add_attachment( &mbox, mail_id, &attachment))
+ * printf("email_add_attachment failed\n");
+ * else
+ * printf(email_add_attachment success\n");
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_add_attachment( emf_mailbox_t* mailbox, int mail_id, emf_attachment_info_t* attachment);
+
+
+/**
+ * @open
+ * @fn email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char * attachment_id)
+ * @brief delete a attachment from email.This function is invoked when user wants to delete a attachment from existing mailbased on mail Id and attachment Id
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the structure of mailbox.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] attachment_id Specifies the attachment id.
+ * @exception none
+ * @see emf_mailbox_t
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_mail_delete_attachment()
+ * {
+ * int account_id = 0;
+ * int mail_id = 0;
+ * char *attchment_id;
+ * emf_mailbox_t mbox;
+ *
+ * mail_id = 1; // mail id in the DB
+ * mbox.account_id = 1; // account id in the DB
+ * mbox.name = strdup("INBOX"); // mailbox name
+ * attachment_id = strdup("1"); // the first attachment item in a attachment list
+ *
+ * if(EMF_ERROR_NONE != email_delete_attachment(&mbox,mail_id,attachment_id))
+ * //failure
+ * else
+ * //success
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_delete_attachment(emf_mailbox_t * mailbox, int mail_id, const char *attachment_id);
+
+
+/* -----------------------------------------------------------
+ Mail Search API
+ -----------------------------------------------------------*/
+
+/**
+ * @open
+ * @fn email_query_mails(char *conditional_clause_string, emf_mail_data_t** mail_list, int *result_count)
+ * @brief Query the mail list information from DB based on the mailbox name.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] conditional_clause_string Specifies the where clause string.
+ * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_data_t.
+ * @param[in/out] result_count Specifies the number of mails returned.
+ * @exception None
+ * @see emf_mail_list_item_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_query_mail()
+ * {
+ * emf_mail_data_t *mail_list = NULL;
+ * char conditional_clause_string[500];
+ * int result_count = 0;
+ *
+ * memset(mailbox_name, 0x00, 10);
+ * printf("\n > Enter where clause: ");
+ * scanf("%s", conditional_clause_string);
+ *
+ *
+ * if (EMF_ERROR_NONE != email_query_mails(conditional_clause_string, &mail_list, &result_count))
+ * printf("email_query_message_ex failed \n");
+ * else {
+ * printf("Success\n");
+ * //do something
+ * free(mail_list);
+ * }
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_query_mails(char *conditional_clause_string, emf_mail_data_t** mail_list, int *result_count);
+
+/**
+ * @open
+ * @fn email_query_message_ex(char *conditional_clause_string, emf_mail_list_item_t** mail_list, int *result_count)
+ * @brief Query the mail list information from DB based on the mailbox name.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] conditional_clause_string Specifies the where clause string.
+ * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_list_item_t.
+ * @param[in/out] result_count Specifies the number of mails returned.
+ * @exception None
+ * @see emf_mail_list_item_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_query_mail()
+ * {
+ * emf_mail_list_item_t *mail_list = NULL;
+ * char conditional_clause_string[500];
+ * int result_count = 0;
+ *
+ * memset(mailbox_name, 0x00, 10);
+ * printf("\n > Enter where clause: ");
+ * scanf("%s", conditional_clause_string);
+ *
+ *
+ * if (EMF_ERROR_NONE != email_query_message_ex(conditional_clause_string, &mail_list, &result_count))
+ * printf("email_query_message_ex failed \n");
+ * else {
+ * printf("Success\n");
+ * //do something
+ * free(mail_list);
+ * }
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_query_message_ex(char *conditional_clause_string, emf_mail_list_item_t** mail_list, int *result_count);
+
+
+/**
+ * @open
+ * @fn email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment)
+ * @brief Get a mail attachment.This function is invoked when user wants to get the attachment information based on attachment id for the specified mail Id.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Reserved.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] attachment_id Specifies the buffer that a attachment ID been saved.
+ * @param[out] attachment The returned attachment is save here.
+ * @exception none
+ * @see emf_mailbox_t and emf_mail_attachment_info_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_mail_get_attachment_info()
+ * {
+ * emf_mailbox_t mailbox;
+ * emf_mail_attachment_info_t *mail_attach_info = NULL;
+ * int mail_id = 0,account_id = 0;
+ * char arg[10];
+ * int err = EMF_ERROR_NONE;
+ *
+ * memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+ *
+ * printf("\n > Enter Mail Id: ");
+ * scanf("%d", &mail_id);
+ * printf("\n > Enter account Id: ");
+ * scanf("%d", &account_id);
+ * printf("> attachment Id\n");
+ * scanf("%s",arg);
+ * mailbox.account_id = account_id;
+ * if (EMF_ERROR_NONE != email_get_attachment_info(&mailbox, mail_id, &mail_attach_info))
+ * printf("email_get_attachment_info failed\n");
+ * else
+ * {
+ * printf("email_get_attachment_info SUCCESS\n");
+ * //do something
+ * email_free_attachment_info(&mail_attach_info,1);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_attachment_info(emf_mailbox_t* mailbox, int mail_id, const char* attachment_id, emf_attachment_info_t** attachment);
+
+EXPORT_API int email_get_attachment_data_list(int input_mail_id, emf_attachment_data_t **output_attachment_data, int *output_attachment_count);
+
+/**
+ * @open
+ * @fn email_free_attachment_info(emf_attachment_info_t** atch_info)
+ * @brief Free allocated memroy for email attachment.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] atch_info Specifies the pointer of mail attachment structure pointer.
+ * @exception none
+ * @see emf_mail_attachment_info_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_mail_free_attachment_info()
+ * {
+ * emf_mailbox_t mailbox;
+ * emf_mail_attachment_info_t *mail_attach_info = NULL;
+ * int mail_id = 0,account_id = 0;
+ * char arg[10];
+ * int err = EMF_ERROR_NONE;
+ *
+ * memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+ *
+ * printf("\n > Enter Mail Id: ");
+ * scanf("%d", &mail_id);
+ * printf("\n > Enter account Id: ");
+ * scanf("%d", &account_id);
+ * printf("> attachment Id\n");
+ * scanf("%s",arg);
+ * mailbox.account_id = account_id;
+ * if (EMF_ERROR_NONE != email_get_attachment_info(&mailbox, mail_id, &mail_attach_info))
+ * printf("email_get_attachment_info failed\n");
+ * else
+ * {
+ * printf("email_get_attachment_info SUCCESS\n");
+ * //do something
+ * email_free_attachment_info(&mail_attach_info,1);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_free_attachment_info(emf_attachment_info_t** atch_info);
+
+EXPORT_API int email_free_attachment_data(emf_attachment_data_t **attachment_data_list, int attachment_data_count);
+
+/**
+ * @open
+ * @fn email_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data)
+ * @brief Get a mail by its mail id. This function is invoked when user wants to get a mail based on mail id existing in DB.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] input_mail_id specifies the mail id.
+ * @param[out] output_mail_data The returned mail is save here.
+ * @exception none
+ * @see emf_mail_data_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_mail_data()
+ * {
+ * emf_mail_data_t *mail = NULL;
+ * int mail_id = 0 ;
+ * int err = EMF_ERROR_NONE;
+ *
+ * printf("\n > Enter mail id: ");
+ * scanf("%d", &mail_id);
+ *
+ * if (EMF_ERROR_NONE != email_get_mail_data(mail_id, &mail))
+ * printf("email_get_mail_data failed\n");
+ * else
+ * {
+ * printf("email_get_mail_data SUCCESS\n");
+ * //do something
+ * email_free_mail_data(&mail,1);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+EXPORT_API int email_get_mail_data(int input_mail_id, emf_mail_data_t **output_mail_data);
+
+
+/* -----------------------------------------------------------
+ Mail Flag API
+ -----------------------------------------------------------*/
+
+/**
+ * @open
+ * @fn email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver)
+ * @brief Change email flag.[ Seen,Deleted,flagged,answered,recent,draft,has_attachment,reserved_1]
+ * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0
+ * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] new_flag Specifies the new email flag.
+ * @param[in] onserver Specifies whether mail Flag updation in server
+ * @exception none
+ * @see emf_mail_flag_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_modify_mail_flag()
+ * {
+ * emf_mail_flag_t newflag;
+ * int mail_id = 0;
+ * int err = EMF_ERROR_NONE;
+ *
+ * memset(&newflag, 0x00, sizeof(emf_mail_flag_t));
+ * newflag.seen = 1;
+ * newflag.answered = 0;
+ * newflag.sticky = 1;
+ *
+ * printf("\n > Enter Mail Id: ");
+ * scanf("%d", &mail_id);
+ * if (EMF_ERROR_NONE != email_modify_mail_flag(mail_id, newflag, 1))
+ * printf("email_modify_mail_flag failed\n");
+ * else
+ * {
+ * printf("email_modify_mail_flag SUCCESS\n");
+ * //do something
+ *
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_modify_mail_flag(int mail_id, emf_mail_flag_t new_flag, int onserver);
+
+/**
+ * @open
+ * @fn email_set_flags_field(int *mail_ids, int num, emf_flags_field_type field_type, int value, int onserver)
+ * @brief Change email flags field.
+ * If the receiving_server_type is EMF_SERVER_TYPE_POP3 then from_server value will be 0
+ * If the receiving_server_type is EMF_SERVER_TYPE_IMAP4 then from_server value will be 1/0
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies account ID.
+ * @param[in] mail_ids Specifies the array of mail ID.
+ * @param[in] num Specifies the number of mail ID.
+ * @param[in] field_type Specifies the field type what you want to set. Refer emf_flags_field_type.
+ * @param[in] value Specifies the value what you want to set.
+ * @param[in] onserver Specifies whether mail Flag updation in server
+ * @exception none
+ * @see none
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_set_flags_field()
+ * {
+ * int mail_id = 0;
+ * int err = EMF_ERROR_NONE;
+ *
+ * printf("\n > Enter Mail Id: ");
+ * scanf("%d", &mail_id);
+ * if (EMF_ERROR_NONE != email_set_flags_field(&mail_id, EMFF_LAGS_SEEN_FIELD, 1, 0))
+ * printf("email_set_flags_field failed\n");
+ * else
+ * {
+ * printf("email_set_flags_field SUCCESS\n");
+ * //do something
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+EXPORT_API int email_set_flags_field(int account_id, int *mail_ids, int num, emf_flags_field_type field_type, int value, int onserver);
+
+/**
+ * @open
+ * @fn email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag)
+ * @brief Change email extra flag.[priority,Delivery report status, Drm, Protection etc]
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] new_flag Specifies the new email extra flag.
+ * @exception none
+ * @see emf_extra_flag_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_modify_extra_mail_flag()
+ * {
+ * emf_extra_flag_t newflag;
+ * int mail_id = 0;
+ * int err = EMF_ERROR_NONE;
+ *
+ * memset(&newflag, 0x00, sizeof(emf_extra_flag_t));
+ *
+ * printf("\n > Enter Mail Id: ");
+ * scanf("%d", &mail_id);
+ *
+ * if(EMF_ERROR_NONE != email_modify_extra_mail_flag(mail_id, newflag))
+ * printf("email_modify_extra_mail_flag failed");
+ * else
+ * printf("email_modify_extra_mail_flag success");
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_modify_extra_mail_flag(int mail_id, emf_extra_flag_t new_flag);
+
+
+
+/* -----------------------------------------------------------
+ Mail Move API
+ -----------------------------------------------------------*/
+
+/**
+ * @open
+ * @fn email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* new_mailbox)
+ * @brief Move a email to another mailbox.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the array of mail ID.
+ * @param[in] num Specifies the count of mail IDs.
+ * @param[in] new_mailbox Specifies the mailbox structure for moving email.
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_move_mail_to_mailbox()
+ * {
+ * int mail_id = 1;
+ * int account_id =0;
+ * emf_mailbox_t mbox;
+ * char arg[10];
+ * int err = EMF_ERROR_NONE;
+ * int i = 0;
+ *
+ * printf("\n > Enter Account_id: ");
+ * scanf("%d",&account_id);
+ *
+ * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
+ *
+ * mbox.account_id = account_id;
+ * mbox.name = strdup("Test");
+ * if(EMF_ERROR_NONE == email_move_mail_to_mailbox(mail_id, 1, &mbox))
+ * printf("Success\n");
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_move_mail_to_mailbox(int *mail_ids, int num, emf_mailbox_t* new_mailbox);
+
+
+/**
+ * @open
+ * @fn email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox)
+ * @brief Move all email to another mailbox.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] src_mailbox Specifies the source mailbox structure for moving email.
+ * @param[in] new_mailbox Specifies the destination mailbox structure for moving email.
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_move_all_mails_to_mailbox()
+ * {
+ * emf_mailbox_t src_mailbox;
+ * emf_mailbox_t dest_mailbox;
+ * int total_count;
+ * int err = EMF_ERROR_NONE;
+ * char temp[128];
+ *
+ * memset(&src_mailbox, 0x00, sizeof(emf_mailbox_t));
+ * memset(&dest_mailbox, 0x00, sizeof(emf_mailbox_t));
+ *
+ * // input mailbox information : need account_id and name (src & dest)
+ * printf("src mail account id(0: All account)> ");
+ * scanf("%d", &src_mailbox.account_id);
+ * printf("src mailbox_name(0 : NULL)> ");
+ * src_mailbox = strdup("INBOX");
+ * // Destination mailbox
+ * printf("dest mail account id> ");
+ * scanf("%d", &dest_mailbox.account_id);
+ * printf("dest_mailbox_name(0 : NULL)> ");
+ * dest_mailbox = strdup("INBOX");
+ *
+ * ( EMF_ERROR_NONE == email_move_all_mails_to_mailbox(&src_mailbox, &dest_mailbox))
+ * {
+ * printf(" fail email_move_all_mails_to_mailbox: \n");
+ * }
+ * else
+ * //success
+ * if ( src_mailbox)
+ * {
+ * free(src_mailbox);
+ * }
+ * if ( dest_mailbox )
+ * {
+ * free(dest_mailbox);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_move_all_mails_to_mailbox(emf_mailbox_t* src_mailbox, emf_mailbox_t* new_mailbox);
+
+
+/**
+ * @open
+ * @fn email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total)
+ * @brief Get mail count from mailbox having draft flag.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the pointer of mailbox structure.
+ * @param[out] total Total email count is saved with draft flag enabled.
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_count_message_with_draft_flag()
+ * {
+ * emf_mailbox_t mailbox;
+ * int total_count;
+ * int err = EMF_ERROR_NONE;
+ *
+ * memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+ * // input mailbox information : need account_id and name
+ * printf("mail account id(0: All account)> ");
+ * scanf("%d", &mailbox.account_id);
+ * mailbox.name = strdup("Inbox");
+ * if ( EMF_ERROR_NONE != email_count_message_with_draft_flag(&mailbox, &total_count))
+ * {
+ * printf(" fail email_count_message_with_draft_flag:\n);
+ * }
+ * else
+ * {
+ * printf(" success email_count_message_with_draft_flag:\n);
+ * }
+ * if ( mailbox.name )
+ * {
+ * free(mailbox.name);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_count_message_with_draft_flag(emf_mailbox_t* mailbox, int* total);
+
+
+/**
+ * @open
+ * @fn email_count_message_on_sending(emf_mailbox_t* mailbox, int* total)
+ * @brief Get the number of mails which are being sent in specific mailbox.This function gives the list of mails having on sending status for a given mailbox.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the pointer of mailbox structure.
+ * @param[out] total Total email count is saved with draft flag enabled.
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_count_message_on_sending()
+ * {
+ * emf_mailbox_t mailbox;
+ * int total_count;
+ * int err = EMF_ERROR_NONE;
+ *
+ * memset(&mailbox, 0x00, sizeof(emf_mailbox_t));
+ * // input mailbox information : need account_id and name
+ * printf("mail account id(0: All account)> ");
+ * scanf("%d", &mailbox.account_id);
+ * mailbox.name = strdup("Draft");
+ * if (EMF_ERROR_NONE != email_count_message_on_sending(&mailbox, &total_count))
+ * {
+ * printf(" fail email_count_message_on_sending: \n");
+ * }
+ * else
+ * {
+ * printf(" success email_count_message_on_sending:\n");
+ * }
+ * if ( mailbox.name )
+ * {
+ * free(mailbox.name);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_count_message_on_sending(emf_mailbox_t* mailbox, int* total);
+
+/**
+ * @open
+ * @fn email_free_mail_data(emf_mail_data_t** mail_list, int count)
+ * @brief Free allocated memroy for emails.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_list Specifies the pointer of mail structure pointer.
+ * @param[in] count Specifies the count of mails.
+ * @exception none
+ * @see emf_mail_data_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_free_mail()
+ * {
+ * emf_mail_data_t *mail;
+ *
+ * //fill the mail structure
+ * //count - number of mail structure user want to free
+ * if(EMF_ERROR_NONE == email_free_mail_data(&mail,count))
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_free_mail_data(emf_mail_data_t** mail_list, int count);
+
+/**
+ * @open
+ * @fn email_get_mails(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_data_t** mail_list, int* result_count)
+ * @brief Get the Mail List information from DB based on the mailbox name.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID
+ * @param[in] mailbox_name Specifies the mailbox name
+ * @param[in] thread_id Specifies the thread id. It can be EMF_LIST_TYPE_THREAD, EMF_LIST_TYPE_NORMAL or thread id.
+ * @param[in] start_index Specifies start index for LIMIT clause of SQL query.
+ * @param[in] limit_count Specifies limit count for LIMIT clause of SQL query.
+ * @param[in] sorting Specifies the sorting type.
+ * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_data_t.
+ * @param[in/out] result_count Specifies the number of mails returned.
+ * @exception none
+ * @see emf_mail_data_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_mail()
+ * {
+ * emf_mail_data_t *mail_list = NULL;
+ * char mailbox_name[50];
+ * int result_count = 0;
+ * int account_id = 0;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * memset(mailbox_name, 0x00, 10);
+ * printf("\n > Enter Mailbox name: ");
+ * scanf("%s", mailbox_name);
+ *
+ * printf("\n > Enter Account_id: ");
+ * scanf("%d",&account_id);
+ *
+ * if (EMF_ERROR_NONE != email_get_mails(account_id, mailbox_name, EMF_LIST_TYPE_NORMAL, 0, 100, EMF_SORT_DATETIME_HIGH, &mail_list, &result_count)) {
+ * printf("email_get_mails failed \n");
+ * }
+ * else {
+ * printf("Success\n");
+ * //do something
+ * free(mail_list);
+ * }
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+EXPORT_API int email_get_mails(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_data_t** mail_list, int* result_count);
+
+/**
+ * @open
+ * @fn email_get_mail_list_ex(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
+ * @brief Get the Mail List information from DB based on the mailbox name.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID
+ * @param[in] mailbox_name Specifies the mailbox name
+ * @param[in] thread_id Specifies the thread id. It can be EMF_LIST_TYPE_THREAD, EMF_LIST_TYPE_NORMAL or thread id.
+ * @param[in] start_index Specifies start index for LIMIT clause of SQL query.
+ * @param[in] limit_count Specifies limit count for LIMIT clause of SQL query.
+ * @param[in] sorting Specifies the sorting type.
+ * @param[in/out] mail_list Specifies the pointer to the structure emf_mail_list_item_t.
+ * @param[in/out] result_count Specifies the number of mails returned.
+ * @exception none
+ * @see emf_mail_list_item_t
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_mail()
+ * {
+ * emf_mail_list_item_t *mail_list = NULL;
+ * char mailbox_name[50];
+ * int result_count = 0;
+ * int account_id = 0;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * memset(mailbox_name, 0x00, 10);
+ * printf("\n > Enter Mailbox name: ");
+ * scanf("%s", mailbox_name);
+ *
+ * printf("\n > Enter Account_id: ");
+ * scanf("%d",&account_id);
+ *
+ * if (EMF_ERROR_NONE != email_get_mail_list_ex(account_id, mailbox_name, EMF_LIST_TYPE_NORMAL, 0, 100, EMF_SORT_DATETIME_HIGH, &mail_list, &result_count))
+ * {
+ * printf("email_get_mail_list failed \n");
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * //do something
+ * free(mail_list);
+ * }
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_mail_list_ex(int account_id , const char *mailbox_name, int thread_id, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count);
+
+/**
+ * @open
+ * @fn email_find_mail(int account_id , const char *mailbox_name, int thread_id,
+ int search_type, char *search_value, int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
+ * @brief Get the Searched Mail List information from the DB based on the mailbox name account_id, type and value of searching.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the Account ID
+ * @param[in] mailbox_name Specifies the Mailbox Name
+ * @param[in] thread_id Specifies the thread_id. If thread_id = EMF_LIST_TYPE_NORMAL, search a mail without regarding thread. The case of thread_id > 0 is for getting mail list of specific thread.
+ * @param[in] search_type Specifies the searching type(EMF_SEARCH_FILTER_SUBJECT, EMF_SEARCH_FILTER_SENDER, EMF_SEARCH_FILTER_RECIPIENT, EMF_SEARCH_FILTER_ALL)
+ * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name)
+ * @param[in] start_index Specifies the first mail index of searched mail. This function will return mails whose index in the result list are from start_index to start_index + limit_count. The first start index is 0.
+ * @param[in] limit_count Specifies the max number of returned mails.
+ * @param[in] sorting Specifies the sorting order. see emf_sort_type_t
+ * @param[in/out] mail_list Specifies the Pointer to the structure emf_mail_list_item_t.
+ * @param[in/out] result_count Specifies the Number of searched Mails
+ * @exception none
+ * @see emf_sort_type_t, emf_mail_list_item_t
+ * @code
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_find_mail(int account_id , const char *mailbox_name, int thread_id,
+ int search_type, char *search_value,
+ int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count);
+
+/**
+ * @open
+ * @fn email_get_mail_by_address(int account_id , const char *mailbox_name, emf_email_address_list_t* addr_list,
+ int start_index, int limit_count, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count)
+ * @brief Get the Mail List information from the DB based on the mailbox name account_id and sender address.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the Account ID
+ * @param[in] mailbox_name Specifies the Mailbox Name
+ * @param[in] addr_list Specifies the addresses of senders. see emf_email_address_list_t
+ * @param[in] start_index Specifies the first mail index of searched mail. This function will return mails whose index in the result list are from start_index to start_index + limit_count
+ * @param[in] limit_count Specifies the max number of returned mails.
+ * @param[in] search_type Specifies the search type.
+ * @param[in] search_value Specifies the search value.
+ * @param[in] sorting Specifies the sorting order. see emf_sort_type_t
+ * @param[in/out] mail_list Specifies the Pointer to the structure emf_mail_list_item_t.
+ * @param[in/out] result_count Specifies the Number of searched Mails
+ * @exception none
+ * @see emf_email_address_list_t, emf_sort_type_t, emf_mail_list_item_t
+ * @code
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_mail_by_address(int account_id , const char *mailbox_name, emf_email_address_list_t* addr_list,
+ int start_index, int limit_count, int search_type, const char *search_value, emf_sort_type_t sorting, emf_mail_list_item_t** mail_list, int* result_count);
+
+/**
+ * @open
+ * @fn email_get_thread_information_by_thread_id(int thread_id, emf_mail_data_t** thread_info)
+ * @brief Get the thread information for specific thread from DB based on the mailbox name.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] thread_id Specifies the thread_id
+ * @param[in/out] thread_info Specifies the Pointer to the structure emf_mail_data_t.
+ * @exception none
+ * @see emf_mail_data_t
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_thread_information()
+ * {
+ * emf_mail_data_t *thread_info = NULL;
+ * int thread_id = 0;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * printf("\n > Enter thread_id: ");
+ * scanf("%d",&thread_id);
+ *
+ * if ( EMF_ERROR_NONE != email_get_thread_information_by_thread_id(thread_id, &thread_info))
+ * {
+ * printf("email_get_thread_information_by_thread_id failed :\n"); *
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * //do something
+ * }
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+
+EXPORT_API int email_get_thread_information_by_thread_id(int thread_id, emf_mail_data_t** thread_info);
+
+/**
+ * @open
+ * @fn email_get_thread_information_ex(int thread_id, emf_mail_list_item_t** thread_info)
+ * @brief Get the Mail List information for specific thread from DB based on the mailbox name.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] thread_id Specifies the thread_id
+ * @param[in/out] thread_info Specifies the Pointer to the structure emf_mail_list_item_t.
+ * @exception none
+ * @see emf_mail_list_item_t
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_thread_information_ex()
+ * {
+ * emf_mail_list_item_t *thread_info = NULL;
+ * int thread_id = 0;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * printf("\n > Enter thread_id: ");
+ * scanf("%d",&thread_id);
+ *
+ * if ( EMF_ERROR_NONE != email_get_thread_information_ex(thread_id, &thread_info))
+ * {
+ * printf("email_get_mail_list_of_thread failed :\n"); *
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * //do something
+ * }
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_thread_information_ex(int thread_id, emf_mail_list_item_t** thread_info);
+
+/**
+ * @open
+ * @fn email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag)
+ * @brief Get the Mail Flag information based on the account id and Mail Id.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the Account ID
+ * @param[in] mail_id Specifies the Mail id for which Flag details need to be fetched
+ * @param[in/out] mail_flag Specifies the Pointer to the structure emf_mail_flag_t.
+ * @exception none
+ * @see emf_mail_flag_t
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_mail_flag()
+ * {
+ * emf_mail_flag_t *mail_flag = NULL;
+ * int account_id = 0;
+ * int mail_id = 0;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * printf("\n > Enter account_id: ");
+ * scanf("%d",&account_id);
+ * printf("\n > Enter mail_id: ");
+ * scanf("%d",&mail_id);
+ *
+ * if ( EMF_ERROR_NONE != email_get_mail_flag(account_id,mail_id, &mail_flag))
+ * {
+ * printf("email_get_mail_flag failed :\n");
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * //do something
+ * }
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_mail_flag(int account_id, int mail_id, emf_mail_flag_t* mail_flag);
+
+/**
+ * @open
+ * @fn email_retry_send_mail( int mail_id, int timeout_in_sec)
+ * @brief Retry mail send
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the mail id for the mail to resend
+ * @param[in] timeout_in_sec Specifies the timeout value in seconds
+ * @exception none
+ * @see none
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_retry_send_mail()
+ * {
+ * int mail_id = 1;
+ * int timeout_in_sec = 2;
+ *
+ * if(EMF_ERROR_NONE == email_retry_send_mail(mail_id,timeout_in_sec))
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_retry_send_mail( int mail_id, int timeout_in_sec);
+
+
+/**
+ * @open
+ * @fn email_create_db_full()
+ * @brief Create DB full
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @exception none
+ * @see none
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_create_db_full()
+ * {
+ *
+ * if(EMF_ERROR_NONE == email_create_db_full())
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+EXPORT_API int email_create_db_full();
+
+/**
+ * @open
+ * @fn email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)
+ * @brief get mailBox naem by mailID
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the mailID
+ * @param[out] pMailbox_name Specifies the mailbox name
+ * @exception none
+ * @see none
+
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_mailbox_name_by_mail_id()
+ * {
+ * char *mailbox_name =NULL;
+ * int mail_id = 10;
+ *
+ *
+ * if(EMF_ERROR_NONE == email_get_mailbox_name_by_mail_id(mail_id,&mailbox_name))
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+EXPORT_API int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name);
+
+/**
+ * @open
+ * @fn email_cancel_send_mail( int mail_id)
+ * @brief Callback function for cm popup. We set the status as EMF_MAIL_STATUS_SEND_CANCELED
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the mailID
+ * @exception none
+ * @see none
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_cancel_send_mail()
+ * {
+ * int mail_id = 10;
+ *
+ *
+ * if(EMF_ERROR_NONE == email_cancel_send_mail(mail_id,))
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_cancel_send_mail( int mail_id) ;
+
+
+/**
+ * @open
+ * @fn email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen)
+ * @brief Get the Total count and Unread count of all mailboxes
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the mailbox structure
+ * @param[out] total Specifies the total count
+ * @param[out] seen Specifies the unseen mail count
+ * @exception none
+ * @see emf_mailbox_t
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_count_message_all_mailboxes()
+ * {
+ * emf_mailbox_t mailbox;
+ * int total =0;
+ * int unseen = 0;
+ *
+ * memset(&mailbox,0x00,sizeof(emf_mailbox_t));
+ * mailbox.account_id = 0;
+ * mailbox.name = strdup("INBOX");
+ *
+ * if(EMF_ERROR_NONE == email_count_message_all_mailboxes(&mailbox,&total,&unseen))
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+EXPORT_API int email_count_message_all_mailboxes(emf_mailbox_t* mailbox, int* total, int* unseen);
+
+
+/* sowmya.kr@samsung.com, 01282010 - Changes to get latest unread mail id for given account */
+/**
+ * @open
+ * @fn email_get_latest_unread_mail_id(int account_id, int *pMailID)
+ * @brief Gets the latest unread MailId for given account. If account_id passed is -1, returns latest unread mail Id.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account id for which latest unread mail has to be fetched
+ * @param[out] pMailID Specifies the latest unread mail
+ * @exception none
+ * @see none
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_latest_unread_mail_id()
+ * {
+ * int mail_id = 0,account_id = 0;
+ * int err = EMF_ERROR_NONE;
+ *
+ *
+ * printf("Enter account Id to get latest unread mail Id,<-1 to get latest irrespective of account id> ");
+ * scanf("%d", &account_id);
+ *
+ *
+ * if ( EMF_ERROR_NONE != email_get_latest_unread_mail_id(account_id, &mail_id) )
+ * {
+ * printf(" fail email_get_latest_unread_mail_id: err[%d]\n", err);
+ * }
+ * else
+ * {
+ * printf(" success email_get_latest_unread_mail_id: Latest unread mail id : %d\n", mail_id);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_latest_unread_mail_id(int account_id, int *pMailID);
+
+/**
+ * @open
+ * @fn email_get_max_mail_count(int *Count)
+ * @brief Gets the max count of mails which can be supported by email-service
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[out] Count max count of mails which can be supported by email-service
+ * @exception none
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_max_mail_count()
+ * {
+ * int max_count = -1;
+ *
+ * if(EMF_ERROR_NONE == email_get_max_mail_count(&max_count))
+ * printf("\n\t>>>>> email_get_max_mail_count() return [%d]\n\n", max_count);
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_max_mail_count(int *Count);
+
+
+ /**
+ * @open
+ * @fn email_get_disk_space_usage(unsigned long *total_size)
+ * @brief Gets the total disk usage of emails in KB.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[out] total_size total disk usage of emails
+ * @exception none
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_disk_space_usage()
+ * {
+ * unsigned long total_size = 0;
+ *
+ * if ( EMF_ERROR_NONE != email_get_disk_space_usage(&total_size))
+ * printf("email_get_disk_space_usage failed err : %d\n",err_code);
+ * else
+ * printf("email_get_disk_space_usage SUCCESS, total disk usage in KB : %ld \n", total_size);
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_disk_space_usage(unsigned long *total_size);
+
+
+EXPORT_API int email_get_recipients_list(int account_id, const char *mailbox_name, emf_sender_list_t **sender_list);
+/**
+ * @open
+ * @fn email_get_sender_list(int account_id, const char *mailbox_name, int search_type, char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count)
+ * @brief Get the sender list with the total number of sender's mails and the number of sender's unread mails.
+ * This is used to show email address and display name of each sender with the number of mails (unread and total).
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account id to get the list. If this is 0, a sender list of "All Account" will be returned.
+ * @param[in] mailbox_name Specifies the mailbox name to get the list. If this is NULL, a sender list of "All Mailbox" will be returned.
+ * @param[in] search_type Specifies the search type
+ * @param[in] search_value Specifies the search value
+ * @param[in] sorting Specifies the sorting order.
+ * @param[out] sender_list Specifies the Pointer to the structure emf_sender_list_t. Memory for a new sender list will be allocated to this. Call email_free_sender_list() to free the memory allocated to this.
+ * @param[out] sender_count Specifies the number of senders in a sender list.
+ * @exception none
+ * @see emf_sort_type_t, emf_sender_list_t, email_free_sender_list()
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_sender_list()
+ * {
+ * emf_sender_list_t *sender_list = NULL;
+ * int sender_count = 0;
+ * int account_id = 0;
+ * int sorting = 0;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * account_id = 0; // For All accounts
+ * mailbox_name = NULL; // For All mail boxes
+ * sorting = EMF_SORT_DATETIME_HIGH;
+ *
+ *
+ * if ( EMF_ERROR_NONE != (err_code = email_get_sender_list(account_id, mailbox_name, EMF_SEARCH_FILTER_NONE, NULL, sorting, &sender_list, &sender_count)) )
+ * {
+ * printf("email_get_sender_list failed :\n"); *
+ * return false;
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * //do something
+ * }
+ *
+ * // Free sender list
+ * if ( sender_list )
+ * {
+ * email_free_sender_list(&sender_list, sender_count);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_sender_list(int account_id, const char *mailbox_name, int search_type, const char *search_value, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count);
+
+/**
+ * @open
+ * @fn email_get_sender_list_ex(int account_id, const char *mailbox_name, int start_index, int limit_count, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count)
+ * @brief Get the sender list with the total number of sender's mails and the number of sender's unread mails.
+ * This is used to show email address and display name of each sender with the number of mails (unread and total).
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account id to get the list. If this is 0, a sender list of "All Account" will be returned.
+ * @param[in] mailbox_name Specifies the mailbox name to get the list. If this is NULL, a sender list of "All Mailbox" will be returned.
+ * @param[in] start_index Specifies the start index in the sender list. This function will return a partial sender list from start_index to (start_index + limit_count - 1) in the sender list. negative value means "from the first sender". start_index is zero-based value.
+ * @param[in] limit_count Specifies the max number of sender list. negative value means "All senders from the start_index in sender list"
+ * @param[in] sorting Specifies the sorting order.
+ * @param[out] sender_list Specifies the Pointer to the structure emf_sender_list_t. Memory for a new sender list will be allocated to this. Call email_free_sender_list() to free the memory allocated to this.
+ * @param[out] sender_count Specifies the number of senders in a sender list.
+ * @exception none
+ * @see emf_sort_type_t, emf_sender_list_t, email_free_sender_list()
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_sender_list()
+ * {
+ * emf_sender_list_t *sender_list = NULL;
+ * int sender_count = 0;
+ * int account_id = 0;
+ * int start_index = 10; // from the 11th sender in sender list
+ * int limit_count = 5; // to the (11 + 5)th sender in sender list
+ * int sorting = 0;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * account_id = 0; // For All accounts
+ * mailbox_name = NULL; // For All mail boxes
+ * sorting = EMF_SORT_DATETIME_HIGH;
+ *
+ *
+ * if ( EMF_ERROR_NONE != (err_code = email_get_sender_list_ex(account_id, mailbox_name, start_index, limit_count, sorting, &sender_list, &sender_count)) )
+ * {
+ * printf("email_get_sender_list_ex failed :\n"); *
+ * return false;
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * //do something
+ * }
+ *
+ * // Free sender list
+ * if ( sender_list )
+ * {
+ * email_free_sender_list(&sender_list, sender_count);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_sender_list_ex(int account_id, const char *mailbox_name, int start_index, int limit_count, emf_sort_type_t sorting, emf_sender_list_t** sender_list, int *sender_count);
+
+
+/**
+ * @open
+ * @fn email_free_sender_list(emf_sender_list_t **sender_list, int count)
+ * @brief Free the sender list allocated by email_get_sender_list(). This function will free the memory which is allocated to sender_list itself.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] sender_list Specifies the Pointer to the structure emf_sender_list_t to be freed.
+ * @param[in] count Specifies the number of senders in a sender list.
+ * @exception none
+ * @see emf_sender_list_t, email_get_sender_list()
+ */
+EXPORT_API int email_free_sender_list(emf_sender_list_t **sender_list, int count);
+
+
+/**
+ * @open
+ * @fn email_get_address_info_list(int mail_id, emf_address_info_list_t** address_info_list)
+ * @brief Get the address info list. The address info list contains from, to, cc, bcc addresses and their display name, contact id and etc. (see emf_address_info_list_t)
+ * Each GList (from, to, cc, bcc) is the list of emf_address_info_t data.
+ * "data" variable of GList structure contains emf_address_info_t data. <br>
+ * To get emf_address_info_t data from GList, Use type casting from GList node.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the mail id to get the list.
+ * @param[out] address_info_list Specifies the Pointer to the structure emf_address_info_list_t. Memory for a new address info list will be allocated to this. Call email_free_address_info_list() to free the memory allocated to this.
+ * @exception none
+ * @see emf_address_info_list_t, emf_address_info_t, email_free_address_info_list()
+ * @code
+ * #include "email-api-account.h"
+ * bool
+ * _api_sample_get_address_info_list()
+ * {
+ * emf_address_info_list_t *p_address_info_list= NULL;
+ * emf_address_info_t *p_address_info = NULL;
+ * int mai_id;
+ * int err_code = EMF_ERROR_NONE;
+ *
+ * mail_id = 1;
+ *
+ * if ( EMF_ERROR_NONE != (err_code = email_get_address_info_list(mail_id, &p_address_info_list)) )
+ * {
+ * printf("email_get_address_info_list failed :\n"); *
+ * return false;
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * //do something with p_address_info_list
+ * GList *list = p_address_info_list->from;
+ * GList *node = g_list_first(list);
+ * while ( node != NULL )
+ * {
+ * p_address_info = (emf_address_info_t*)node->data;
+ * printf("%d, %s, %s, %d\n", p_address_info->address_type, p_address_info->address, p_address_info->display_name, p_address_info->contact_id);
+ *
+ * node = g_list_next(node);
+ * }
+ * }
+ *
+ * // Free sender list
+ * if ( p_address_info_list )
+ * {
+ * email_free_address_info_list(&p_address_info_list);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_address_info_list(int mail_id, emf_address_info_list_t** address_info_list);
+
+/**
+ * @open
+ * @fn email_free_address_info_list(emf_address_info_list_t **address_info_list)
+ * @brief Free the address info list allocated by email_get_address_info_list(). This function will free the memory which is allocated to address_info_list itself.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] address_info_list Specifies the Pointer to the structure emf_address_info_list_t to be freed.
+ * @exception none
+ * @see emf_address_info_list_t, email_get_address_info_list()
+ */
+EXPORT_API int email_free_address_info_list(emf_address_info_list_t **address_info_list);
+
+/**
+ * @open
+ * @fn email_get_structure(const char*encoded_string, void **struct_var, emf_convert_struct_type_e type)
+ * @brief This function returns the structure of the type which is indicated by 'type' variable. This function will allocate new memory to 'struct_var' for structure.<br>
+ * Some notifications such as NOTI_DOWNLOAD_NEW_MAIL are published with string parameter. The string contains various values that might be divided by delimiter.<br>
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] encoded_string Specifies the Pointer to the string from notification.
+ * @param[out] struct_var Specifies the Pointer to the structure to be returned. If success, new memory for structure will be allocated.
+ * @param[in] type Specifies the converting type. see emf_convert_struct_type_e
+ * @exception none
+ * @see emf_convert_struct_type_e
+ */
+EXPORT_API int email_get_structure(const char*encoded_string, void **struct_var, emf_convert_struct_type_e type);
+
+/**
+ * @open
+ * @fn email_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req)
+ * @brief Get the information of meeting request. The information of meeting request is based on Mail Id. <br>
+ * The information of meeting request is corresponding to only one mail.
+ * For this reason, the information of meeting request can be added by using email_add_message_with_meeting_request() with a matched mail information.
+ *
+ * @return This function returns EMF_ERROR_NONE on success. This function returns EMF_ERROR_DATA_NOT_FOUND if there isn't a matched mail. Otherwise it returns error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mail_id Specifies the Mail id for which meeting request details need to be fetched
+ * @param[in/out] meeting_req Specifies the Pointer to the structure emf_meeting_request_t.
+ * @exception none
+ * @see emf_meeting_request_t
+ */
+EXPORT_API int email_get_meeting_request(int mail_id, emf_meeting_request_t **meeting_req);
+
+
+/**
+ * @open
+ * @fn email_free_meeting_request(emf_meeting_request_t** meeting_req, int count)
+ * @brief Free the meeting request allocated by email_get_meeting_request() or alloacted to add. This function will free the memory which is allocated to meeting_req (= *meeting_req) itself.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] emf_meeting_request_t Specifies the Pointer to the structure emf_meeting_request_t to be freed.
+ * @param[in] count Specifies the number of elements in meeting_req array. this is usually 1.
+ * @exception none
+ * @see emf_meeting_request_t, email_get_meeting_request()
+ */
+EXPORT_API int email_free_meeting_request(emf_meeting_request_t** meeting_req, int count);
+
+EXPORT_API int email_move_thread_to_mailbox(int thread_id, char *target_mailbox_name, int move_always_flag);
+
+EXPORT_API int email_delete_thread(int thread_id, int delete_always_flag);
+
+EXPORT_API int email_modify_seen_flag_of_thread(int thread_id, int seen_flag, int on_server);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @} @}
+*/
+
+
+#endif /* __EMAIL_API_MESSAGE_H__ */
diff --git a/email-api/include/email-api-mailbox.h b/email-api/include/email-api-mailbox.h
new file mode 100755
index 0000000..a1a23b6
--- /dev/null
+++ b/email-api/include/email-api-mailbox.h
@@ -0,0 +1,353 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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 __EMAIL_API_MAILBOX_H__
+#define __EMAIL_API_MAILBOX_H__
+
+#include "email-types.h"
+
+/**
+* @defgroup EMAIL_SERVICE Email Service
+* @{
+*/
+
+
+/**
+* @ingroup EMAIL_SERVICE
+* @defgroup EMAIL_API_MAILBOX Email Mailbox API
+* @{
+*/
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-mailbox.h
+ * @author Kyuho Jo <kyuho.jo@samsung.com>
+ * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
+ * @version 0.1
+ * @brief This file contains the data structures and interfaces of mailbox provided by
+ * email-service .
+ * @{
+ * @code
+ *
+ * #include "email_api_mailbox.h"
+ *
+ * bool other_app_invoke_uniform_api_sample(int *error_code)
+ * {
+ * emf_mailbox_t mbox;
+ * emf_mailbox_t *new_mailbox =NULL;
+ * emf_mailbox_t *mailbox_list = NULL;
+ * int count = 0;
+ * int mailbox_type;
+ * unsigned handle = 0;
+ * char *pMaiboxName;
+ * char *pParentMailbox;
+ *
+ * memset(&mbox,0x00,sizeof(emf_mailbox_t));
+ * mbox.name = strdup("test");
+ * mbox.alias = strdup("Personal");
+ * mbox.account_id = 1;
+ * printf("Enter local_yn(1/0)");
+ * scanf("%d",&local_yn);
+ * mbox.local=local_yn;
+ * mbox.mailbox_type = 7;
+ *
+ * //create new mailbox
+ *
+ * if(EMF_ERR_NONE != email_add_mailbox(&mbox,local_yn,&handle))
+ * printf("email_add_mailbox failed\n");
+ * else
+ * printf("email_add_mailbox success");
+ *
+ * //update mailbox
+ * new_mailbox = malloc(sizeof(emf_mailbox_t));
+ * memset(new_mailbox,0x00,sizeof(emf_mailbox_t));
+ *
+ * new_mailbox->name = strdup("PersonalUse");
+ *
+ * if(EMF_ERROR_NONE != email_update_mailbox(&mbox,new_mailbox))
+ * printf("email_update_mailbox failed\n");
+ * else
+ * printf("email_update_mailbox success\n");
+ * //delete mailbox
+ *
+ * if(EMF_ERROR_NONE != email_delete_mailbox(mbox,local_yn,&handle))
+ * printf("email_delete_mailbox failed\n");
+ * else
+ * printf("email_delete_mailbox success\n");
+ *
+ * //free mailbox
+ * email_free_mailbox("new_mailbox,1");
+ *
+ * //Get mailbox list
+ * if(EMF_ERROR_NONE != email_get_mailbox_list(account_id,local_yn,&mailbox_list,&count))
+ * //failure
+ * else
+ * //success
+ *
+ * //Get mailbox by name
+ * pMailboxName = strdup("test");
+ * if(EMF_ERROR_NONE != email_get_mailbox_by_name(account_id,pMailboxName,&mailbox_list))
+ * //failure
+ * else
+ * //success
+ *
+ * //Get child mailbox list
+ * pParentMailbox = strdup("test");
+ * if(EMF_ERROR_NONE != email_get_child_mailbox_list(account_id, paerent_mailbox,&mailbox_list,&count))
+ * //failure
+ * else
+ * //success
+ *
+ * //Get mailbox by mailbox_type
+ * printf("Enter mailbox_type\n");
+ * scanf("%d",&mailbox_type);
+ * if(EMF_ERROR_NONE != email_get_mailbox_by_mailbox_type(account_id,mailbox_type,&mailbox_list))
+ * //failure
+ * else
+ * //success
+ *
+ * }
+ *
+ * @endcode
+ * @}
+ */
+
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+
+/**
+
+ * @open
+ * @fn EXPORT_API int email_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle)
+ * @brief Create a new mailbox or mailbox.This function is invoked when user wants to create a new mailbox for the specified account.
+ * If On_server is true then it will create the mailbox on server as well as in local also.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] new_mailbox Specifies the pointer of creating mailbox information.
+* @param[in] on_server Specifies the creating mailbox information on server.
+ * @param[out] handle Specifies the sending handle.
+ * @exception none
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+EXPORT_API int email_add_mailbox(emf_mailbox_t* new_mailbox, int on_server, unsigned* handle);
+
+
+/**
+
+ * @open
+ * @fn EXPORT_API int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle)
+ * @brief Delete a mailbox or mailbox.This function deletes the existing mailbox for specified account based on the option on_server.
+ * If the on_server is true then it deletes mailbox from server as well as locally.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the pointer of deleting mailbox information.
+ * @param[in] on_server Specifies the creating mailbox information on server.
+ * @param[out] handle Specifies the sending handle.
+ * @exception #EMF_ERROR_INVALID_PARAM -Invaid argument
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+EXPORT_API int email_delete_mailbox(emf_mailbox_t* mailbox, int on_server, unsigned* handle);
+
+
+/**
+
+ * @fn EXPORT_API int email_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox)
+ * @brief Change mailbox or mailbox information.This function is invoked when user wants to change the existing mail box information.
+ * This supports ONLY updating mailbox_type in local db. This can be used to match a specific mail box and a specific mailbox_type.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] old_mailbox Specifies the information of previous mailbox. <br>mandatory field : account_id, name
+ * @param[in] new_mailbox Specifies the information of new mailbox. <br
+ * @exception #EMF_ERROR_INVALID_PARAM -Invaid argument
+ * @see emf_mailbox_t, emf_mailbox_type_e
+ * @remarks N/A
+ */
+EXPORT_API int email_update_mailbox(emf_mailbox_t* old_mailbox, emf_mailbox_t* new_mailbox);
+
+/**
+
+ * @open
+ * @fn email_get_mailbox_list(int account_id, int mailbox_sync_type, emf_mailbox_t** mailbox_list, int* count)
+ * @brief Get all mailboxes from account.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] mailbox_sync_type Specifies the sync type.
+ * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL)
+ * @param[out] count The mailbox count is saved here.(possibly 0)
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-mailbox.h"
+ * bool
+ * _api_sample_get_mailbox_list()
+ * {
+ * int account_id =0,count = 0;
+ * int mailbox_sync_type;
+ * int error_code = EMF_ERROR_NONE;
+ * emf_mailbox_t *mailbox_list=NULL;
+ *
+ * printf("\n > Enter account id: ");
+ * scanf("%d", &account_id);
+ * printf("\n > Enter mailbox_sync_type: ");
+ * scanf("%d", &mailbox_sync_type);
+ *
+ * if((EMF_ERROR_NONE != email_get_mailbox_list(account_id, mailbox_sync_type, &mailbox_list, &count)))
+ * {
+ * printf(" Error\n");
+ * }
+ * else
+ * {
+ * printf("Success\n");
+ * email_free_mailbox(&mailbox_list,count);
+ * }
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_get_mailbox_list(int account_id, int mailbox_sync_type, emf_mailbox_t** mailbox_list, int* count);
+
+EXPORT_API int email_get_mailbox_list_ex(int account_id, int mailbox_sync_type, int with_count, emf_mailbox_t** mailbox_list, int* count);
+
+/**
+
+ * @open
+ * @fn EXPORT_API int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox);
+ * @brief Get the mailbox information by name.This function gets the mailbox by given mailbox name for a specified account.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the information of account Id.
+ * @param[in] pMailboxName Specifies the mailbox name.
+ * @param[out] pMailbox Specifies the information of mailbox
+ * @exception none
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+
+EXPORT_API int email_get_mailbox_by_name(int account_id, const char *pMailboxName, emf_mailbox_t **pMailbox);
+
+// Belows are for A Project
+
+/**
+
+ * @open
+ * @fn email_get_child_mailbox_list(int account_id, char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count)
+ * @brief Get all sub mailboxes for given parent mailbox.This function gives all the child mailbox list for a given parent mailbox for specified account.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] parent_mailbox Specifies the parent mailbox
+ * @param[out] mailbox_list Specifies the pointer of mailbox structure pointer.(possibly NULL)
+ * @param[out] count The mailbox count
+ * @exception #EMF_ERROR_INVALID_PARAM -Invalid argument
+ * @see emf_mailbox_t
+ * @remarks N/A
+ * @return This function returns true on success or false on failure.
+ */
+EXPORT_API int email_get_child_mailbox_list(int account_id, const char *parent_mailbox, emf_mailbox_t** mailbox_list, int* count);
+
+
+/**
+ * @open
+ * @fn email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox)
+ * @brief Get mailbox by mailbox_type.This function is invoked when user wants to know the mailbox information by mailbox_type for the given account.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] mailbox_type Specifies the mailbox type.
+ * @param[out] mailbox Specifies the pointer of mailbox structure pointer.(possibly NULL)
+ * @exception none
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+EXPORT_API int email_get_mailbox_by_mailbox_type(int account_id, emf_mailbox_type_e mailbox_type, emf_mailbox_t** mailbox);
+
+/**
+ * @open
+ * @fn email_set_mail_slot_size(int account_id, char* mailbox_name, int new_slot_size, unsigned* handle)
+ * @brief Set mail slot size.This function is invoked when user wants to set the size of mail slot.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code(refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] mailbox_name Specifies the mailbox name.
+ * @param[in] new_slot_size Specifies the mail slot size.
+ * @exception none
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+EXPORT_API int email_set_mail_slot_size(int account_id, char* mailbox_name, int new_slot_size/*, unsigned* handle*/);
+
+/**
+ * @open
+ * @fn email_free_mailbox(emf_mailbox_t** mailbox_list, int count)
+ * @brief Free allocated memory for mailbox information.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox_list Specifies the pointer for searching mailbox structure pointer.
+ * @param[in] count Specifies the count of mailboxes.
+ * @exception none
+ * @see emf_mailbox_t
+
+ * @code
+ * #include "email-api-mailbox.h"
+ * bool
+ * _api_sample_free_mailbox_info()
+ * {
+ * emf_mailbox_t *mailbox;
+ *
+ * //fill the mailbox structure
+ * //count - number of mailbox structure user want to free
+ * if(EMF_ERROR_NONE == email_free_mailbox(&mailbox,count))
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ * @endcode
+ * @remarks N/A
+ */
+
+EXPORT_API int email_free_mailbox(emf_mailbox_t** mailbox_list, int count);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @} @}
+*/
+
+
+
+#endif /* __EMAIL_API_MAILBOX_H__ */
+
+
diff --git a/email-api/include/email-api-network.h b/email-api/include/email-api-network.h
new file mode 100755
index 0000000..462e66b
--- /dev/null
+++ b/email-api/include/email-api-network.h
@@ -0,0 +1,403 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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 __EMAIL_API_NETWORK_H__
+#define __EMAIL_API_NETWORK_H__
+
+#include "email-types.h"
+
+/**
+* @defgroup EMAIL_SERVICE Email Service
+* @{
+*/
+
+/**
+* @ingroup EMAIL_SERVICE
+* @defgroup EMAIL_API_NETWORK Email Network API
+* @{
+*/
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-network.h
+ * @author Kyuho Jo <kyuho.jo@samsung.com>
+ * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
+ * @version 0.1
+ * @brief This file contains the data structures and interfaces of Network related Functionality provided by
+ * email-service .
+ *
+ * @{
+
+ * @code
+
+ * #include "email-api.h"
+ *
+ * bool
+ * other_app_invoke_uniform_api_sample(int* error_code)
+ * {
+ *
+ * // Send a mail
+ * emf_mailbox_t mbox;
+ * emf_attachment_info_t attachment;
+ * emf_option_t option;
+ * int account_id = 1;
+ * int err = EMF_ERROR_NONE;
+ * int mail_id = 0;
+ * char arg[50]; //Input attachment number need to be download
+ * emf_event_status_type_t status;
+ * int action = -1;
+ * int on_sending = 0;
+ * int on_receiving = 0;
+ *
+* printf("Enter mailbox name\n");
+ * scanf("%s",&mbox.mailbox_name);
+ * printf("Enter mail id\n");
+ * scanf("%d",&mail_id);
+ * option.keep_local_copy = 1;
+ *
+ * if(EMF_ERROR_NONE == email_send_mail(&mbox, mail_id, &option, &handle))
+ * //success
+ * else
+ * //failure
+ *
+ * // Download header of new emails from mail server
+ * unsigned handle = 0;
+ *
+ * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
+ *
+ * mbox.account_id = account_id;
+ * mbox.name = strdup("INBOX");
+ * if(EMF_ERROR_NONE == email_sync_header (&mbox,&handle))
+ * //success
+ * else
+ * //failure
+ *
+ * //Sync mail header for all accounts
+ * if(EMF_ERROR_NONE == email_sync_header_for_all_account(&handle))
+ * //success
+ * else
+ * //failure
+ *
+ * //Download email body from server
+ *
+ * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
+ * mbox.account_id = account_id;
+ * mbox.name = strdup("INBOX");
+ * if(EMF_ERROR_NONE == email_download_body (&mbox,mail_id,0,&handle))
+ * //success
+ * else
+ * //failure
+ *
+ * //Download a email nth-attachment from server
+ * prinf("Enter attachment number\n");
+ * scanf("%s",arg);
+ * memset(&mbox, 0x00, sizeof(emf_mailbox_t));
+ * mbox.name = strdup("INBOX");
+ * mbox.account_id = account_id;
+ * if(EMF_ERROR_NONE == email_download_attachment(&mailbox,mail_id,arg,&handle))
+ * //success
+ * else
+ * //failure
+ *
+ * //Cancel job
+ * if(EMF_ERROR_NONE == email_cancel_job(account_id,handle))//canceling download email nth attachment from server job.
+ * //so this handle contains the value return by the email_download_attachment()
+ * //success
+ * else
+ * //failure
+ * //Get pending job listfor an account
+ *
+ * printf( " Enter Action \n SEND_MAIL = 0 \n SYNC_HEADER = 1 \n" \
+ * " DOWNLOAD_BODY,= 2 \n DOWNLOAD_ATTACHMENT = 3 \n" \
+ * " DELETE_MAIL = 4 \n SEARCH_MAIL = 5 \n SAVE_MAIL = 6 \n" \
+ * " NUM = 7 \n");
+ * scanf("%d",&action);
+ * if(EMF_ERROR_NONE == email_get_pending_job(action,account_id,mail_id,&status))
+ * //success
+ * else
+ * //error
+ *
+ * //Get Network status
+ * if(EMF_ERROR_NONE == email_get_network_status(&sending,&receiving))
+ * //success
+ * else
+ * //failure
+ *
+ * //Send read report
+ * if(EMF_ERROR_NONE == email_send_report(mail ,&handle))
+ * //success
+ * else
+ * //failure
+ * //Save and send
+ *
+ * mbox.account_id = account_id;
+ * mbox.name = strdup("DRAFTBOX");
+ *
+ * if(EMF_ERROR_NONE == email_add_message(mail,&mbox,1))
+ * {
+ * if(EMF_ERROR_NONE == email_send_saved(account_id,&option,&handle))
+ * //success
+ * else
+ * //failure
+ * }
+ * //Get Imap mailbox list
+ * printf("\n > Enter server name:\n");
+ * scanf("%s",arg);
+ * if(EMF_ERROR_NONE == email_get_imap_mailbox_list(account_id , arg , &handle))
+ * //success
+ * else
+ * //failure
+ *
+ * //sync local activity
+ * if(EMF_ERROR_NONE == email_sync_local_activity(account_id))
+ * //success
+ * else
+ * //failure
+ * }
+ *
+ * @endcode
+ * @}
+
+ */
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @open
+ * @fn email_send_mail( emf_mailbox_t* mailbox, int mail_id, emf_option_t* sending_option, unsigned* handle)
+ * @brief Send a mail.This function is invoked when user wants to send a composed mail.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the mailbox to consist a sending email.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] sending_option Specifies the sending option.
+ * @param[out] handle Specifies the sending handle.
+ * @exception none
+ * @see emf_mailbox_t and emf_option_t
+ * @remarks N/A
+ */
+EXPORT_API int email_send_mail( emf_mailbox_t* mailbox,
+ int mail_id,
+ emf_option_t* sending_option,
+ unsigned* handle);
+
+
+/**
+ * @open
+ * @fn email_sync_header(emf_mailbox_t* mailbox, unsigned* handle)
+ * @brief Download header of new emails from mail server.This function is invoked when user wants to download only header of new mails.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the structure of mailbox.
+ * @param[out] handle Specifies the handle for stopping downloading.
+ * @exception none
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+EXPORT_API int email_sync_header(emf_mailbox_t* mailbox, unsigned* handle);
+
+
+/**
+ * @open
+ * @fn email_sync_header_for_all_account(unsigned* handle)
+ * @brief Download header of new emails from mail server for all emails.This function is invoked when user wants to download header of new mails for all accounts.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[out] handle Specifies the handle for stopping downloading.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_sync_header_for_all_account(unsigned* handle);
+
+
+/**
+ * @open
+ * @fn email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle)
+ * @brief Download email body from server.This function is invoked when user wants to download email body with/without attachment based on the option with_attachment
+ * from the server.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Specifies the structure of mailbox.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] with_attachment Specifies the whether attachment is there or not.
+ * @param[out] handle Specifies the handle for stopping downloading.
+ * @exception none
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+EXPORT_API int email_download_body(emf_mailbox_t* mailbox, int mail_id, int with_attachment, unsigned* handle);
+
+
+
+
+
+
+/**
+ * @open
+ * @fn email_download_attachment(emf_mailbox_t* mailbox, int mail_id, char* nth, unsigned* handle);
+ * @brief Download a email nth-attachment from server.This function is invoked if user wants to download only specific attachment of a mail whose body is already downloaded.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] mailbox Reserved.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[in] nth Specifies the buffer that a attachment number been saved. the minimum number is "1".
+ * @param[out] handle Specifies the handle for stopping downloading.
+ * @exception none
+ * @see emf_mailbox_t
+ * @remarks N/A
+ */
+EXPORT_API int email_download_attachment(emf_mailbox_t* mailbox,
+ int mail_id,
+ const char* nth,
+ unsigned* handle);
+
+
+/**
+ * @open
+ * @fn email_cancel_job(int account_id, int handle);
+ * @brief cancel the ongoing job.This function is invoked if user wants to cancel any ongoing job of a specified account.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] handle Specifies the handle for stopping the operation.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+
+EXPORT_API int email_cancel_job(int account_id, int handle);
+
+
+/**
+ * @open
+ * @fn email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status);
+ * @brief get pending job list.This function is invoked if user wants to get the pending job list with status information .
+ * Based on action item of a mail is for a specific account this will give all pending job list.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the action of the job.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] mail_id Specifies the mail ID.
+ * @param[out]status Specifies the status of the job.
+ * @exception none
+ * @see emf_action_t and emf_event_status_type_t
+ * @remarks N/A
+ */
+EXPORT_API int email_get_pending_job(emf_action_t action, int account_id, int mail_id, emf_event_status_type_t * status);
+
+
+/**
+ * @open
+ * @fn email_get_network_status(int* on_sending, int* on_receiving)
+ * @brief This function gives the current network status.This gives the information to the user whether sending operation is in progress or receiving operation.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[out] on_sending True if sending is in progress.
+ * @param[out] on_receiving True if receivng is in progress.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_get_network_status(int* on_sending, int* on_receiving);
+
+/**
+ * @open
+ * @fn email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle)
+ * @brief Send all mails to been saved in Offline-mode.This function is invoked when user wants to send an email and after saving it.
+ * This will save the email in draft mailbox and then sends.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] sending_option Specifies the sending option.
+ * @param[out] handle Specifies the handle for stopping sending.
+ * @exception none
+ * @see emf_option_t
+ * @remarks N/A
+ */
+EXPORT_API int email_send_saved(int account_id, emf_option_t* sending_option, unsigned* handle);
+
+/**
+ * @open
+ * @fn email_get_imap_mailbox_list(int account_id, char* mailbox, unsigned* handle)
+ * @brief fetch all the mailbox names from server and store the non-existing mailboxes in DB.This function is invoked when user wants to download all server mailboxes from IMAP server
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @param[in] mailbox Specifies the mailbox name.
+ * @param[out] handle Specifies the handle for stopping Network operation.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_get_imap_mailbox_list(int account_id, const char* mailbox, unsigned* handle);
+
+
+
+/**
+ * @open
+ * @fn email_sync_local_activity(int account_id)
+ * @brief sync local activity
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the account ID.
+ * @exception none
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_sync_local_activity(int account_id);
+
+
+/**
+ * @open
+ * @fn email_search_mail_on_server(int account_id, const char *mailbox_name, int search_type, char *search_value)
+ * @brief Search the mails on server.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] account_id Specifies the Account ID
+ * @param[in] mailbox_name Specifies the Mailbox Name
+ * @param[in] search_type Specifies the searching type(EMF_SEARCH_FILTER_SUBJECT, EMF_SEARCH_FILTER_SENDER, EMF_SEARCH_FILTER_RECIPIENT, EMF_SEARCH_FILTER_ALL)
+ * @param[in] search_value Specifies the value to use for searching. (ex : Subject, email address, display name)
+ * @exception none
+ * @see
+ * @code
+ * @endcode
+ * @remarks N/A
+ */
+EXPORT_API int email_search_mail_on_server(int input_account_id, const char *input_mailbox_name, email_search_filter_t *input_search_filter_list, int input_search_filter_count, unsigned *output_handle);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @}
+*/
+
+
+#endif /* __EMAIL_API_NETWORK_H__ */
diff --git a/email-api/include/email-api-rule.h b/email-api/include/email-api-rule.h
new file mode 100755
index 0000000..71a1ca2
--- /dev/null
+++ b/email-api/include/email-api-rule.h
@@ -0,0 +1,218 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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 __EMAIL_API_RULE_H__
+#define __EMAIL_API_RULE_H__
+
+#include "email-types.h"
+
+/**
+* @defgroup EMAIL_SERVICE Email Service
+* @{
+*/
+
+/**
+* @ingroup EMAIL_SERVICE
+* @defgroup EMAIL_API_RULE Email Rule API
+* @{
+*/
+
+ /**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api-rule.h
+ * @author Kyuho Jo <kyuho.jo@samsung.com>
+ * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
+ * @version 0.1
+ * @brief This file contains the data structures and interfaces of Rule related Functionality provided by
+ * email-service .
+ * @{
+
+ * @code
+ * #include "email-api-rule.h"
+ * bool
+ * other_app_invoke_uniform_api_sample(int* error_code)
+ * {
+ * int err = EMF_ERROR_NONE;
+ * emf_rule_t* rule = NULL;
+ * int filter_id = 1;
+ * int count = 0;
+ *
+ * // Get a information of filtering
+ * printf("Enter filter Id:\n");
+ * scanf("%d",&filter_id);
+ *
+ * if(EMF_ERROR_NONE == email_get_rule (filter_id,&rule))
+ * //success
+ * else
+ * //failure
+ *
+ * // Get all filterings
+ * if(EMF_ERROR_NONE == email_get_rule_list(&rule,&count))
+ * //success
+ * else
+ * //failure
+ *
+ *
+ * // Add a filter information
+ * if(EMF_ERROR_NONE == email_add_rule (rule))
+ * //success
+ * else
+ * //failure
+ * err = email_free_rule (&rule,1);
+ *
+ * // Change a filter information
+ * if(EMF_ERROR_NONE == email_update_rule (filter_id,rule))
+ * //success
+ * else
+ * //failure
+ * err = email_free_rule (&rule,1);
+ *
+ * // Delete a filter information
+ * printf("Enter filter Id:\n");
+ * scanf("%d",&filter_id);
+ *
+ * if(EMF_ERROR_NONE == email_delete_rule (filter_id))
+ * //success
+ * else
+ * //failure
+ *
+ * // Free allocated memory
+ * if(EMF_ERROR_NONE == email_free_rule (&rule,1))
+ * //success
+ * else
+ * //failure
+ *
+ * }
+ *
+ * @endcode
+ * @}
+ */
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+
+ * @open
+ * @fn email_get_rule(int filter_id, emf_rule_t** filtering_set)
+ * @brief Get a information of filtering.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure
+ * @param[in] filter_id Specifies the filter ID.
+ * @param[out] filtering_set The returned information of filter are saved here.
+ * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument
+ * @see emf_rule_t
+ * @remarks N/A
+ */
+EXPORT_API int email_get_rule(int filter_id, emf_rule_t** filtering_set);
+
+/**
+
+ * @open
+ * @fn email_get_rule_list(emf_rule_t** filtering_set, int* count)
+ * @brief Get all filterings.This function gives all the filter rules already set before by user.
+ * This will provide total number of filter rules available and information of all rules.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure
+ * @param[out] filtering_set The returned filterings are saved here.(possibly NULL)
+ * @param[out] count The count of returned filters is saved here.(possibly 0)
+ * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument
+ * @see emf_rule_t
+ * @remarks N/A
+ */
+EXPORT_API int email_get_rule_list(emf_rule_t** filtering_set, int* count);
+
+/**
+
+ * @open
+ * @fn email_add_rule(emf_rule_t* filtering_set)
+ * @brief Add a filter information.This function is invoked if user wants to add a new filter rule.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] filtering_set Specifies the pointer of adding filter structure.
+ * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument
+ * @see emf_rule_t
+ * @remarks N/A
+ */
+EXPORT_API int email_add_rule(emf_rule_t* filtering_set);
+
+/**
+
+ * @open
+ * @fn email_update_rule(int filter_id, emf_rule_t* new_set)
+ * @brief Change a filter information.This function will update the existing filter rule with new information.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
+ * @param[in] filter_id Specifies the original filter ID.
+ * @param[in] new_set Specifies the information of new filter.
+ * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument
+ * @see emf_rule_t
+ * @remarks N/A
+ */
+EXPORT_API int email_update_rule(int filter_id, emf_rule_t* new_set);
+
+/**
+
+ * @open
+ * @fn email_delete_rule(int filter_id)
+ * @brief Delete a filter information.This function will delete the exsting filter information by specified filter Id.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure
+ * @param[in] filter_id Specifies the filter ID.
+ * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument
+ * @see none
+ * @remarks N/A
+ */
+EXPORT_API int email_delete_rule(int filter_id);
+
+
+
+/**
+
+ * @open
+ * @fn email_free_rule (emf_rule_t** filtering_set, int count)
+ * @brief Free allocated memory.
+ *
+ * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure
+ * @param[in] filtering_set Specifies the pointer of pointer of filter structure for memory free.
+ * @param[in] count Specifies the count of filter.
+ * @exception #EMF_ERROR-INVALID_PARAM -Invalid argument
+ * @see emf_rule_t
+ * @remarks N/A
+ */
+EXPORT_API int email_free_rule (emf_rule_t** filtering_set, int count);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+/**
+* @} @}
+*/
+
+
+#endif /* __EMAIL_API_RULE_H__ */
diff --git a/email-api/include/email-api.h b/email-api/include/email-api.h
new file mode 100755
index 0000000..67e7f2d
--- /dev/null
+++ b/email-api/include/email-api.h
@@ -0,0 +1,74 @@
+/*
+* email-service
+*
+* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+*
+* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
+*
+* 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 __EMAIL_API_H__
+#define __EMAIL_API_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "email-types.h"
+#include "email-api-account.h"
+#include "email-api-init.h"
+#include "email-api-mail.h"
+#include "email-api-mailbox.h"
+#include "email-api-network.h"
+#include "email-api-rule.h"
+
+
+/**
+* @defgroup EMAIL_SERVICE Email Service
+* @{
+*/
+
+/**
+* @{
+*/
+
+/**
+ *
+ * This file contains the data structures and interfaces needed for application,
+ * to interact with email-service.
+ * @file email-api.h
+ * @author Kyuho Jo <kyuho.jo@samsung.com>
+ * @author Sunghyun Kwon <sh0701.kwon@samsung.com>
+ * @version 0.1
+ * @brief This file contains the data structures and interfaces provided by
+ * email-service.
+ */
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/**
+* @} @}
+*/
+
+#endif /* __EMAIL_MAPI_H__ */
+
+