fix db and sql file permission for security 58/111158/1
authorintae, jeon <intae.jeon@samsung.com>
Thu, 8 Dec 2016 05:23:47 +0000 (14:23 +0900)
committerintae jeon <intae.jeon@samsung.com>
Fri, 20 Jan 2017 00:35:17 +0000 (16:35 -0800)
Change-Id: I1399d7d85e16ae3236d5f2fb64ad49c70778241d
Signed-off-by: intae, jeon <intae.jeon@samsung.com>
(cherry picked from commit fef661560a5fdc109919a522cd45a4ad30ed5d29)

email-api/include/email-api-mail.h
email-common-use/include/email-internal-types.h
email-core/email-core-mail.c
email-core/email-core-mime.c
email-core/email-core-pgp.c
email-core/email-core-smime.c
email-core/email-core-utils.c
email-core/email-storage/email-storage.c
email-daemon/main.c
email-service_PG.h
packaging/email-service.spec

index c1fbc40..b37d14f 100755 (executable)
@@ -86,7 +86,7 @@ extern "C" {
  *  int                    attachment_count = 0;
  *  int                    err = EMAIL_ERROR_NONE;
  *  char                   arg[50] = { 0 , };
- *  char                  *body_file_path = MAILHOME"/tmp/mail.txt";
+ *  char                  *body_file_path = MAIL_HOME"/tmp/mail.txt";
  *  email_mailbox_t         *mailbox_data = NULL;
  *  email_mail_data_t       *test_mail_data = NULL;
  *  email_attachment_data_t *attachment_data = NULL;
index 176762f..a9d839a 100755 (executable)
@@ -140,11 +140,13 @@ extern "C"
 #define DATA_PATH                           tzplatform_getenv(TZ_USER_DATA)
 #define DB_PATH                             tzplatform_getenv(TZ_USER_DB)
 #define EMAIL_SERVICE_DB_FILE_PATH          tzplatform_mkpath(TZ_USER_DB, ".email-service.db")
+#define EMAIL_SERVICE_DB_JOURNAL_FILE_PATH  tzplatform_mkpath(TZ_USER_DB, ".email-service.db-journal")
 
-#define EMAILPATH                                              tzplatform_mkpath(TZ_USER_DATA, "email")
-#define MAILHOME                                               tzplatform_mkpath(TZ_USER_DATA, "email/.email_data")
-#define MAILTEMP                            tzplatform_mkpath(TZ_USER_DATA, "email/.email_data/tmp")
-#define TEMPMIME                           tzplatform_mkpath(TZ_USER_SHARE, "email/.email_data/tmp")
+#define EMAIL_PATH                         tzplatform_mkpath(TZ_USER_DATA, "email")
+#define EMAIL_SQL_PATH                             tzplatform_mkpath(TZ_USER_DATA, "email/res/email-service.sql")
+#define MAIL_HOME                          tzplatform_mkpath(TZ_USER_DATA, "email/.email_data")
+#define MAIL_TEMP                           tzplatform_mkpath(TZ_USER_DATA, "email/.email_data/tmp")
+#define TEMP_MIME                           tzplatform_mkpath(TZ_USER_SHARE, "email/.email_data/tmp")
 #define DIRECTORY_PERMISSION                0775
 
 #define MIME_SUBTYPE_DRM_OBJECT             "vnd.oma.drm.message"
index 8fa9146..2b9fb15 100755 (executable)
@@ -4598,7 +4598,7 @@ int emcore_delete_mail_attachment(char *multi_user_name, int attachment_id, int
        }
 
        if (attachment_tbl->attachment_inline_content_status != INLINE_ATTACHMENT) {
-               SNPRINTF(attachment_folder_path, sizeof(attachment_folder_path), "%s/%d/%d/%d", MAILHOME, attachment_tbl->account_id, attachment_tbl->mail_id, attachment_id);
+               SNPRINTF(attachment_folder_path, sizeof(attachment_folder_path), "%s/%d/%d/%d", MAIL_HOME, attachment_tbl->account_id, attachment_tbl->mail_id, attachment_id);
 
                if (!emstorage_delete_dir(attachment_folder_path, NULL)) {
                        EM_DEBUG_EXCEPTION("emstorage_delete_dir failed");
index 6ca95a8..3762393 100755 (executable)
@@ -309,7 +309,7 @@ char *emcore_mime_get_save_file_name(int *err_code)
 
        memset(tempname, 0x00, sizeof(tempname));
        unsigned int seed = time(NULL);
-       SNPRINTF(tempname, sizeof(tempname), "%s%s%d", MAILTEMP, DIR_SEPERATOR, rand_r(&seed));
+       SNPRINTF(tempname, sizeof(tempname), "%s%s%d", MAIL_TEMP, DIR_SEPERATOR, rand_r(&seed));
        EM_DEBUG_FUNC_END();
        return EM_SAFE_STRDUP(tempname);
 }
@@ -1566,15 +1566,15 @@ INTERNAL_FUNC int emcore_delete_parsed_data(char *multi_user_name, email_mail_da
        }
 
        if (!input_mail_data->mail_id) {
-               SNPRINTF(buf, sizeof(buf), "%s%s%s%d", prefix_path, MAILHOME, DIR_SEPERATOR, input_mail_data->account_id);
+               SNPRINTF(buf, sizeof(buf), "%s%s%s%d", prefix_path, MAIL_HOME, DIR_SEPERATOR, input_mail_data->account_id);
        } else {
-               SNPRINTF(buf, sizeof(buf), "%s%s%s%d%s%d", prefix_path, MAILHOME, DIR_SEPERATOR, input_mail_data->account_id, DIR_SEPERATOR, input_mail_data->mail_id);
+               SNPRINTF(buf, sizeof(buf), "%s%s%s%d%s%d", prefix_path, MAIL_HOME, DIR_SEPERATOR, input_mail_data->account_id, DIR_SEPERATOR, input_mail_data->mail_id);
        }
 
        if (!emstorage_delete_dir(buf, &err)) {
                EM_DEBUG_LOG("emstorage_delete_dir failed : buf[%s]", buf);
                        memset(buf, 0x00, sizeof(buf));
-               SNPRINTF(buf, sizeof(buf), "%s%s%d", MAILHOME, DIR_SEPERATOR, input_mail_data->account_id);
+               SNPRINTF(buf, sizeof(buf), "%s%s%d", MAIL_HOME, DIR_SEPERATOR, input_mail_data->account_id);
 
                        if (!emstorage_delete_dir(buf, &err)) {
                           EM_DEBUG_EXCEPTION("emstorage_delete_dir failed : buf[%s]", buf);
index 70ebd4f..4705ca8 100644 (file)
@@ -223,7 +223,7 @@ INTERNAL_FUNC int emcore_pgp_set_signed_message(char *certificate,
 #endif
        g_mime_init(0);
 
-       SNPRINTF(temp_pgp_filepath, sizeof(temp_pgp_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, PGP_SIGNED_FILE);
+       SNPRINTF(temp_pgp_filepath, sizeof(temp_pgp_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, PGP_SIGNED_FILE);
        EM_DEBUG_LOG_SEC("attachment file path of pgp : [%s]", temp_pgp_filepath);
 
        err = em_open(temp_pgp_filepath, O_CREAT|O_TRUNC|O_RDWR, S_IRUSR|S_IWUSR|S_IWGRP|S_IRGRP|S_IROTH, &gpg_fd);
@@ -338,7 +338,7 @@ INTERNAL_FUNC int emcore_pgp_set_encrypted_message(char *recipient_list,
 #endif
        g_mime_init(0);
 
-       SNPRINTF(temp_pgp_filepath, sizeof(temp_pgp_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, PGP_ENCRYPTED_FILE);
+       SNPRINTF(temp_pgp_filepath, sizeof(temp_pgp_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, PGP_ENCRYPTED_FILE);
        EM_DEBUG_LOG_SEC("attachment file path of pgp : [%s]", temp_pgp_filepath);
 
        err = em_open(temp_pgp_filepath, O_CREAT|O_TRUNC|O_RDWR, S_IRUSR|S_IWUSR|S_IWGRP|S_IRGRP|S_IROTH, &gpg_fd);
@@ -466,7 +466,7 @@ INTERNAL_FUNC int emcore_pgp_set_signed_and_encrypted_message(char *recipient_li
 #endif
        g_mime_init(0);
 
-       SNPRINTF(temp_pgp_filepath, sizeof(temp_pgp_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, PGP_ENCRYPTED_FILE);
+       SNPRINTF(temp_pgp_filepath, sizeof(temp_pgp_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, PGP_ENCRYPTED_FILE);
        EM_DEBUG_LOG_SEC("attachment file path of pgp : [%s]", temp_pgp_filepath);
 
        err = em_open(temp_pgp_filepath, O_CREAT|O_TRUNC|O_RDWR, S_IRUSR|S_IWUSR|S_IWGRP|S_IRGRP|S_IROTH, &gpg_fd);
@@ -727,7 +727,7 @@ INTERNAL_FUNC int emcore_pgp_get_decrypted_message(char *encrypted_message,
        }
 
        /* Initialized the output stream (signed stream) */
-       SNPRINTF(temp_decrypt_filepath, sizeof(temp_decrypt_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, DECRYPTED_TEMP_FILE);
+       SNPRINTF(temp_decrypt_filepath, sizeof(temp_decrypt_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, DECRYPTED_TEMP_FILE);
        EM_DEBUG_LOG_SEC("tmp decrypt file path : [%s]", temp_decrypt_filepath);
 
        err = em_open(temp_decrypt_filepath, O_CREAT|O_TRUNC|O_RDWR, S_IRUSR|S_IWUSR|S_IWGRP|S_IRGRP|S_IROTH, &decrypted_fd);
index b21be72..3ee8862 100755 (executable)
@@ -294,7 +294,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_message(char *certificate,
        PKCS7 *signed_message = NULL;
        int flags = PKCS7_DETACHED | PKCS7_PARTIAL;
 
-       SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, SMIME_SIGNED_FILE);
+       SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, SMIME_SIGNED_FILE);
        EM_DEBUG_LOG_SEC("attachment file path of smime : [%s]", temp_smime_filepath);
 
        smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE);
@@ -392,7 +392,7 @@ INTERNAL_FUNC int emcore_smime_set_encrypt_message(char *multi_user_name,
        PKCS7 *encrypt_message = NULL;
        const EVP_CIPHER *cipher = NULL;
 
-       SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, SMIME_ENCRYPT_FILE);
+       SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, SMIME_ENCRYPT_FILE);
        EM_DEBUG_LOG_SEC("attachment file path of smime : [%s]", temp_smime_filepath);
 
        smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE);
@@ -483,7 +483,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_n
        EVP_PKEY *private_key = NULL;
        X509 *cert = NULL;
 
-       SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, SMIME_ENCRYPT_FILE);
+       SNPRINTF(temp_smime_filepath, sizeof(temp_smime_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, SMIME_ENCRYPT_FILE);
        EM_DEBUG_LOG_SEC("attachment file path of smime : [%s]", temp_smime_filepath);
 
        smime_attachment = BIO_new_file(temp_smime_filepath, OUTMODE);
@@ -529,7 +529,7 @@ INTERNAL_FUNC int emcore_smime_set_signed_and_encrypt_message(char *multi_user_n
        }
 
        /* 6. Create signing message */
-       SNPRINTF(temp_mime_entity_path, sizeof(temp_mime_entity_path), "%s%smime_entity", MAILTEMP, DIR_SEPERATOR);
+       SNPRINTF(temp_mime_entity_path, sizeof(temp_mime_entity_path), "%s%smime_entity", MAIL_TEMP, DIR_SEPERATOR);
        EM_DEBUG_LOG_SEC("attachment file path of smime : [%s]", temp_mime_entity_path);
 
        bio_signed_message = BIO_new_file(temp_mime_entity_path, WRITEMODE);
@@ -646,7 +646,7 @@ INTERNAL_FUNC int emcore_smime_get_decrypt_message(char *encrypt_message,
        }
 
        /* Initialize the output file for decrypted message */
-       SNPRINTF(temp_decrypt_filepath, sizeof(temp_decrypt_filepath), "%s%s%s", MAILTEMP, DIR_SEPERATOR, DECRYPT_TEMP_FILE);
+       SNPRINTF(temp_decrypt_filepath, sizeof(temp_decrypt_filepath), "%s%s%s", MAIL_TEMP, DIR_SEPERATOR, DECRYPT_TEMP_FILE);
        EM_DEBUG_LOG_SEC("attachment file path of smime : [%s]", temp_decrypt_filepath);
 
        out_buf = BIO_new_file(temp_decrypt_filepath, OUTMODE);
index 845df27..3013423 100755 (executable)
@@ -497,7 +497,7 @@ int emcore_get_temp_file_name(char **filename, int *err_code)
        /* Create Directory If deleted by user*/
        emstorage_create_dir_if_delete();
 
-       SNPRINTF(tempname, sizeof(tempname), "%s%c%d", MAILTEMP, DIR_SEPERATOR_CH, rand_r(&seed));
+       SNPRINTF(tempname, sizeof(tempname), "%s%c%d", MAIL_TEMP, DIR_SEPERATOR_CH, rand_r(&seed));
 
        char *p = EM_SAFE_STRDUP(tempname);
        if (p == NULL) {
@@ -540,7 +540,7 @@ int emcore_get_temp_mime_file_name(char **filename, int *err_code)
        /* Create Directory If deleted by user*/
        emstorage_create_dir_if_delete();
 
-       SNPRINTF(tempname, sizeof(tempname), "%s%c%d", TEMPMIME, DIR_SEPERATOR_CH, rand_r(&seed));
+       SNPRINTF(tempname, sizeof(tempname), "%s%c%d", TEMP_MIME, DIR_SEPERATOR_CH, rand_r(&seed));
 
        char *p = EM_SAFE_STRDUP(tempname);
        if (p == NULL) {
index 250fe2a..a4d2293 100755 (executable)
@@ -51,6 +51,8 @@
 #define __USE_UNIX98
 #define __USE_GNU
 #include <pthread.h>
+#include <grp.h>
+#include <pwd.h>
 
 #include "email-internal-types.h"
 #include "email-convert.h"
 #define DAYLIGHT_NAME_LEN_IN_MAIL_MEETING_TBL           32
 #define PREVIEWBODY_LEN_IN_MAIL_TBL                     512
 #define CERTIFICATE_PATH_LEN_IN_MAIL_ACCOUNT_TBL        256
+#define UID                                            "root"          /* UID = root */
+#define UID_DEFAULT                                    0               /* UID = root */
+#define GID                                            "priv_email"    /* GID = priv_email */
+#define GID_DEFAULT                                    10901           /* GID = priv_email */
 
 /*  this define is used for query to change data (delete, insert, update) */
 #define EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction_flag, error_code) \
@@ -1555,26 +1561,26 @@ static void *_emstorage_open_once(char *multi_user_name, int *err_code)
                }
 
         memset(buf, 0x00, sizeof(buf));
-        SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, EMAILPATH);
+        SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, EMAIL_PATH);
         mkdir(buf, DIRECTORY_PERMISSION);
 
         memset(buf, 0x00, sizeof(buf));
-        SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, MAILHOME);
+        SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, MAIL_HOME);
         mkdir(buf, DIRECTORY_PERMISSION);
 
         memset(buf, 0x00, sizeof(buf));
-        SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, MAILTEMP);
+        SNPRINTF(buf, sizeof(buf), "%s%s", prefix_path, MAIL_TEMP);
         mkdir(buf, DIRECTORY_PERMISSION);
 
         _delete_temp_file(buf);
                EM_SAFE_FREE(prefix_path);
     } else {
         mkdir(DATA_PATH, DIRECTORY_PERMISSION);
-        mkdir(EMAILPATH, DIRECTORY_PERMISSION);
-        mkdir(MAILHOME, DIRECTORY_PERMISSION);
-        mkdir(MAILTEMP, DIRECTORY_PERMISSION);
+        mkdir(EMAIL_PATH, DIRECTORY_PERMISSION);
+        mkdir(MAIL_HOME, DIRECTORY_PERMISSION);
+        mkdir(MAIL_TEMP, DIRECTORY_PERMISSION);
 
-        _delete_temp_file(MAILTEMP);
+        _delete_temp_file(MAIL_TEMP);
     }
 
        if (!emstorage_create_table(multi_user_name, EMAIL_CREATE_DB_NORMAL, &error)) {
@@ -1649,7 +1655,7 @@ static int _delete_all_files_and_directories(char *db_file_path, int *err_code)
                }
        }
 
-       if (!emstorage_delete_dir((char *)MAILHOME, &error)) {
+       if (!emstorage_delete_dir((char *)MAIL_HOME, &error)) {
                EM_DEBUG_EXCEPTION("emstorage_delete_dir failed");
                goto FINISH_OFF;
        }
@@ -1739,6 +1745,10 @@ INTERNAL_FUNC int emstorage_init_db(char *multi_user_name)
        char *prefix_path = NULL;
        char *output_file_path = NULL;
        char temp_file_path[MAX_PATH] = {0};
+       gid_t email_gid = -1;
+       uid_t email_uid = -1;
+       struct group *gr;
+       struct passwd *pw;
 
        if (EM_SAFE_STRLEN(multi_user_name) > 0) {
                err = emcore_get_container_path(multi_user_name, &prefix_path);
@@ -1774,7 +1784,28 @@ INTERNAL_FUNC int emstorage_init_db(char *multi_user_name)
                if (ret == -1) {
                        EM_DEBUG_EXCEPTION("_xsystem failed");
                        err = EMAIL_ERROR_SYSTEM_FAILURE;
+
                }
+
+               if ((gr = getgrnam(GID)) != NULL)
+                       email_gid = gr->gr_gid;
+               else
+                       email_gid = GID_DEFAULT;
+
+
+               if ((pw = getpwnam(UID)) != NULL)
+                       email_uid = pw->pw_uid;
+               else
+                       email_uid = UID_DEFAULT;
+
+               chmod(EMAIL_SERVICE_DB_FILE_PATH, 0660);
+               chmod(EMAIL_SERVICE_DB_JOURNAL_FILE_PATH, 0660);
+               chmod(EMAIL_SQL_PATH, 0660);
+
+               chown(EMAIL_SERVICE_DB_FILE_PATH, email_uid, email_gid);
+               chown(EMAIL_SERVICE_DB_JOURNAL_FILE_PATH, email_uid, email_gid);
+               chown(EMAIL_SQL_PATH, email_uid, email_gid);
+
        }
 
 FINISH_OFF:
@@ -11450,15 +11481,15 @@ INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transacti
        sqlite3 *local_db_handle = emstorage_get_db_connection(multi_user_name);
        EMSTORAGE_START_WRITE_TRANSACTION(multi_user_name, transaction, error);
 
-       if (!emstorage_delete_dir((char *)MAILHOME, &error)) {
+       if (!emstorage_delete_dir((char *)MAIL_HOME, &error)) {
                EM_DEBUG_EXCEPTION(" emstorage_delete_dir failed - %d", error);
 
                goto FINISH_OFF;
        }
 
-       mkdir(MAILHOME, DIRECTORY_PERMISSION);
-       mkdir(MAILTEMP, DIRECTORY_PERMISSION);
-       chmod(MAILTEMP, 0777);
+       mkdir(MAIL_HOME, DIRECTORY_PERMISSION);
+       mkdir(MAIL_TEMP, DIRECTORY_PERMISSION);
+       chmod(MAIL_TEMP, 0777);
 
        /*  first clear index. */
        while (indexes->object_name) {
@@ -11541,7 +11572,7 @@ INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id,
                goto FINISH_OFF;
        }
 
-       snprintf(path_buf, 512, "%s", MAILHOME);
+       snprintf(path_buf, 512, "%s", MAIL_HOME);
        snprintf(path_buf+EM_SAFE_STRLEN(path_buf), 512 - EM_SAFE_STRLEN(path_buf), "%s%d", DIR_SEPERATOR, account_id);
 
        if (mail_id > 0)
@@ -11704,7 +11735,7 @@ INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, in
        if (account_id >= FIRST_ACCOUNT_ID) {
                SNPRINTF(buf, sizeof(buf), "%s%s%s%s%d", prefix_path,
                                                                                                DIR_SEPERATOR,
-                                                                                               MAILHOME,
+                                                                                               MAIL_HOME,
                                                                                                DIR_SEPERATOR,
                                                                                                account_id);
 
@@ -11914,10 +11945,10 @@ INTERNAL_FUNC void emstorage_create_dir_if_delete()
        EM_DEBUG_FUNC_BEGIN();
 
        mkdir(DATA_PATH, DIRECTORY_PERMISSION);
-       mkdir(EMAILPATH, DIRECTORY_PERMISSION);
-       mkdir(MAILHOME, DIRECTORY_PERMISSION);
-       mkdir(MAILTEMP, DIRECTORY_PERMISSION);
-       chmod(MAILTEMP, 0777);
+       mkdir(EMAIL_PATH, DIRECTORY_PERMISSION);
+       mkdir(MAIL_HOME, DIRECTORY_PERMISSION);
+       mkdir(MAIL_TEMP, DIRECTORY_PERMISSION);
+       chmod(MAIL_TEMP, 0777);
 
        EM_DEBUG_FUNC_END();
 }
@@ -11941,7 +11972,7 @@ static int _get_temp_file_name(char **filename, int *err_code)
        gettimeofday(&tv, NULL);
        srand(tv.tv_usec);
        unsigned int seed = time(NULL);
-       SNPRINTF(tempname, sizeof(tempname), "%s%c%d", MAILTEMP, '/', rand_r(&seed));
+       SNPRINTF(tempname, sizeof(tempname), "%s%c%d", MAIL_TEMP, '/', rand_r(&seed));
 
        char *p = EM_SAFE_STRDUP(tempname);
        if (p == NULL) {
@@ -12604,7 +12635,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_
                goto FINISH_OFF;
        }
 
-       SNPRINTF(syscmd, sizeof(syscmd), "du -hsk %s > %s", EMAILPATH, SETTING_MEMORY_TEMP_FILE_PATH);
+       SNPRINTF(syscmd, sizeof(syscmd), "du -hsk %s > %s", EMAIL_PATH, SETTING_MEMORY_TEMP_FILE_PATH);
        EM_DEBUG_LOG(" cmd : %s", syscmd);
        if (setting_system_command(syscmd) == -1) {
                EM_DEBUG_EXCEPTION("emstorage_mail_get_total_diskspace_usage : Setting > Memory] System Command [%s] is failed", syscmd);
@@ -12636,7 +12667,7 @@ INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_
                goto FINISH_OFF;
        }
 
-       EM_DEBUG_LOG("[Setting > Memory] @@@@@ Size of Directory [%s] is %ld KB", EMAILPATH, total_diskusage);
+       EM_DEBUG_LOG("[Setting > Memory] @@@@@ Size of Directory [%s] is %ld KB", EMAIL_PATH, total_diskusage);
 
        ret = true;
 
index db963b0..69efe47 100755 (executable)
@@ -4327,13 +4327,10 @@ INTERNAL_FUNC int main(int argc, char *argv[])
        g_type_init();
 #endif
 
-
-
        emcore_dpm_instance_create();
 
-
     /* Init container for daemon */
-    emcore_create_container();
+       emcore_create_container();
 
        EM_DEBUG_LOG("ipcEmailStub_Initialize Start");
 
index f29981a..f926537 100755 (executable)
@@ -10,17 +10,17 @@ Electronic mail, most commonly abbreviated email or e-mail, is a method of excha
        <h2 class="pg">Purpose of Programming Guide</h2>
 This document is mainly aimed at the core functionality of the Email Service.  The EMail Service component is implemented by Samsung to provide EMail service to applications that make use of EMail Engine. Email Engine provides functionality for the user like composing mail, saving mail, sending mail, and creating user mailbox according to the settings. Mobile subscribers can use the Email Engine to perform storage opearations such as save, update, get, delete and transport operations such as send, download and other email operations.
 
-This programming guide is prepared for application developers who will use the email-service. It contains: 
+This programming guide is prepared for application developers who will use the email-service. It contains:
 - List of features offered by email-service
 - Information on How to use APIs provided by the email-service
-- Examples 
+- Examples
 
        <h2 class="pg">Target Domain / Application</h2>
 The Email Service Layer can be utilized by any component in the application layer which allow the end user to perform the email related operations such as save, send, download email message and others.
 
-For Example, the Email Service APIs shall be invoked by 
-@li Multimedia application when user opts to send media file through email 
-@li Email application when user tries to send an email message 
+For Example, the Email Service APIs shall be invoked by
+@li Multimedia application when user opts to send media file through email
+@li Email application when user tries to send an email message
 
        <h2 class="pg">Terminology & Acronyms</h2>
 <table>
@@ -31,7 +31,7 @@ For Example, the Email Service APIs shall be invoked by
 <tr><td>POP3</td><td>Post office protocol for receiving mails</td></tr>
 <tr><td>RFC822</td><td>Describes mail header, to address, cc, bcc etc. formats and decoding and encoding standards. </td></tr>
 <tr><td>OMA </td><td>Open Moblie Alliance</td></tr>
-</table> 
+</table>
 
 
 @}
@@ -42,7 +42,7 @@ For Example, the Email Service APIs shall be invoked by
 <h1 class="pg">Email-service Architecture</h1>
        <h2 class="pg">System Architecture</h2>
 @image html email_image001.png
+
        <h2 class="pg">Process Architecture</h2>
 @image html email_image002.png email-service Process view
 
@@ -60,14 +60,14 @@ Whenever an application wants to use email-service, it will call APIs from Email
 <tr><td>Account Operation</td>
 <td>
 @n email_add_account()
-@n email_delete_account() 
-@n email_update_account() 
-@n email_get_account() 
-@n email_get_account_list() 
-@n email_free_account() 
+@n email_delete_account()
+@n email_update_account()
+@n email_get_account()
+@n email_get_account_list()
+@n email_free_account()
 @n email_validate_account()
 </td></tr>
+
 <tr><td>mailbox Operation </td>
 <td>
 @n email_add_mailbox()
@@ -78,26 +78,26 @@ Whenever an application wants to use email-service, it will call APIs from Email
 @n email_get_child_mailbox_list()
 @n email_get_mailbox_by_mailbox_type()
 </td></tr>
+
 <tr><td>Message Operation </td>
 <td>
-@n email_add_message()  
+@n email_add_message()
 @n email_update_message()
-@n email_count_mail()  
-@n email_delete_mail()  
+@n email_count_mail()
+@n email_delete_mail()
 @n email_delete_all_mails_in_mailbox()
 @n email_clear_mail_data()
 @n email_add_attachment()
-@n email_delete_attachment() 
+@n email_delete_attachment()
 @n email_get_info()
 @n email_free_mail_info()
-@n email_get_header_info()  
-@n email_free_header_info()  
+@n email_get_header_info()
+@n email_free_header_info()
 @n email_get_body_info()
 @n email_free_body_info()
-@n email_get_attachment_data() 
-@n email_free_attachment_info()  
-@n email_get_mail() 
+@n email_get_attachment_data()
+@n email_free_attachment_info()
+@n email_get_mail()
 @n email_modify_mail_flag()
 @n email_modify_seen_flag()
 @n email_modify_extra_mail_flag()
@@ -120,7 +120,7 @@ Whenever an application wants to use email-service, it will call APIs from Email
 @n email_get_max_mail_count()
 @n email_get_disk_space_usage()
 </td></tr>
+
 <tr><td>Network Operation </td>
 <td>
 @n email_send_mail()
@@ -135,7 +135,7 @@ Whenever an application wants to use email-service, it will call APIs from Email
 @n email_sync_imap_mailbox_list()
 @n email_sync_local_activity()
 </td></tr>
+
 <tr><td>Rule Operation </td>
 <td>
 @n email_get_rule()
@@ -145,7 +145,7 @@ Whenever an application wants to use email-service, it will call APIs from Email
 @n email_delete_rule()
 @n email_free_rule()
 </td></tr>
+
 <tr><td>Control Operation </td>
 <td>
 @n email_init_storage()
@@ -176,34 +176,34 @@ email_account_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
 
 <tr><td>int email_delete_account(int account_id) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
-  
+
 <tr><td>int email_update_account(int account_id , email_account_t* new_account) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:  - Memory for param email_account_t* new_account should be allocated and deallocated by Application</td></tr>
-  
+
 <tr><td>int email_get_account(int account_id, int pulloption, email_account_t** account) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param account will happen in email_get_account (). To free this memory, application should call email_free_account ()</td></tr>
-  
+
 <tr><td>int email_get_account_list(email_account_t** account_list, int* count) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: Memory allocation for param ccount_list will happen in email_get_account_list (). To free this memory, application should call email_free_account () </td></tr>
-  
+
 <tr><td>int email_free_account(email_account_t** account_list, int count) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
-  
+
 <tr><td>int email_validate_account(int account_id, int *handle)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
-</table> 
+</table>
 
 <b>Sample Code</b>
 @li Add account
 @code
-/* Add account */       
+/* Add account */
 
 /*  Assign values for new account */
 email_account_t *account = NULL;
+
 account = malloc(sizeof(email_account_t));
 memset(account, 0x00, sizeof(email_account_t));
+
 account->retrieval_mode               = 1;
 account->incoming_server_secure_connection                 = 1;
 account->outgoing_server_type          = EMAIL_SERVER_TYPE_SMTP;
@@ -236,7 +236,7 @@ account->is_preset_account            = 1;
 account->logo_icon_path               = strdup("Logo Icon Path");
 account->options.priority             = 3;
 account->options.keep_local_copy      = 0;
-account->options.req_delivery_receipt = 0;   
+account->options.req_delivery_receipt = 0;
 account->options.req_read_receipt     = 0;
 account->options.download_limit       = 0;
 account->options.block_address        = 0;
@@ -248,7 +248,7 @@ account->options.add_myname_card      = 0;
 account->options.add_signature        = 0;
 account->options.signature            = strdup("Signature");
 account->check_interval               = 0;
-      
+
 if(EMAIL_ERROR_NONE != email_add_account(account))
        /* failure */
 else
@@ -260,67 +260,67 @@ else
 
 /* free account */
 email_free_account(&account, 1);
-@endcode 
+
+@endcode
 
 @li Get account
 @code
 /* Get account */
+
 email_account_t *account = NULL;
 int account_id = 1;            /*  account id to be gotten */
+
 if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account))
        /* failure */
 else
        /* success */
+
 /* free account */
 email_free_account(&account, 1);
+
 @endcode
 
 @li Update account
 @code
-/* Update account */               
+/* Update account */
 
 email_account_t *new_account = NULL;
 int account_id = 1;            /*  account id to be updated */
+
 /*  Get account to be updated */
 if(EMAIL_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&new_account))
        /* failure */
 else
        /* success */
+
 /*  Set the new values */
 new_account->flag1                   = 1;
 new_account->account_name            = strdup("gmail");
 new_account->display_name            = strdup("Tom001");
-new_account->options.keep_local_copy = 1;   
+new_account->options.keep_local_copy = 1;
 new_account->check_interval          = 55;
+
 if(EMAIL_ERROR_NONE != email_update_account(account_id,new_account))
        /* failure */
 else
        /* success */
+
 /* free account */
 email_free_account(&new_account, 1);
 
 @endcode
 
 @li Delete account
-@code 
+@code
 /* Delete account */
 
 int account_id = 1;            /*  account id to be deleted */
+
 if(EMAIL_ERROR_NONE != email_delete_account(account_id))
       /* failure */
 else
       /* success */
+
 @endcode
 
 
@@ -329,9 +329,9 @@ else
 /* Get list of accounts */
 
 email_account_t *account_list = NULL;
-int count = 0;         
+int count = 0;
 int i;
+
 if(EMAIL_ERROR_NONE != email_get_account_list(&account_list,&count))
        /* failure */
 else
@@ -342,8 +342,8 @@ else
                /*  Do something with each account */
                printf("account id : %d\n", account_list[i].account_id);
        }
-}      
+}
+
 /* free account */
 email_free_account(&account_list,count);
 
@@ -354,13 +354,13 @@ email_free_account(&account_list,count);
 /* Validate account - try to connect to server */
 unsigned account_handle = 0;
 int account_id = 1;
+
 if(EMAIL_ERROR_NONE != email_validate_account(account_id,&account_handle))
        /* failure */
 else
        /* success */
 @endcode
+
 <b>Flow Diagram</b>
 @image html email_image004.png
 @}
@@ -376,10 +376,10 @@ email_mailbox_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
 
 <table>
 <tr><td>API</td><td>Return Value / Exceptions</td></tr>
+
 <tr><td>int email_add_mailbox(email_mailbox_t* new_mailbox, int on_server, int *handle) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: -  Memory for param email_mailbox_t* new_mailbox should be allocated and deallocated by Application </td></tr>
+
 <tr><td>int email_delete_mailbox(email_mailbox_t* mailbox, int on_server,  int *handle) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
 
@@ -388,17 +388,17 @@ email_mailbox_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
 
 <tr><td>int email_get_mailbox_list(int account_id, int local_yn, email_mailbox_t** mailbox_list, int* count)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_list (). To free this memory application should call email_free_mailbox</td></tr>
+
 <tr><td>int email_get_mailbox_by_name(int account_id, const char *pMailboxName, email_mailbox_t **pMailbox)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param pMailbox will happen in email_get_mailbox_by_name (). To free this memory application should call email_free_mailbox</td></tr>
+
 <tr><td>int email_get_child_mailbox_list(int account_id, const char *parent_mailbox,  email_mailbox_t** mailbox_list, int* count)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_child_mailbox_list (). To free this memory application should call email_free_mailbox</td></tr>
+
 <tr><td>int email_get_mailbox_by_mailbox_type(int account_id, email_mailbox_type_e mailbox_type,  email_mailbox_t** mailbox)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param mailbox_list will happen in email_get_mailbox_by_mailbox_type (). To free this memory application should call email_free_mailbox</td></tr>
 </table>
+
 <b>Sample Code</b>
 
 @li Create new mailbox
@@ -406,17 +406,17 @@ email_mailbox_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
 email_mailbox_t *mailbox = NULL, *new_mailbox = NULL;
 int handle = 0;
 int on_server = 0;
+
 mailbox = malloc(sizeof(email_mailbox_t));
 memset(mailbox, 0x00, sizeof(email_mailbox_t));
-mailbox->mailbox_name           = strdup("Personal"); 
-mailbox->alias          = strdup("selfuse");            
-mailbox->account_id     = 1; 
-mailbox->local          = on_server; 
-mailbox->mailbox_type    = 7;  
-      
-/* create new mailbox */           
+
+mailbox->mailbox_name           = strdup("Personal");
+mailbox->alias          = strdup("selfuse");
+mailbox->account_id     = 1;
+mailbox->local          = on_server;
+mailbox->mailbox_type    = 7;
+
+/* create new mailbox */
 if(EMAIL_ERROR_NONE != email_add_mailbox(mailbox,on_server,&handle))
       /* failure */
 else
@@ -433,24 +433,24 @@ int handle = 0;
 
 new_mailbox = malloc(sizeof(email_mailbox_t));
 memset(new_mailbox, 0x00, sizeof(email_mailbox_t));
+
 new_mailbox->mailbox_name =  strdup("Personal001");
+
 /* update mailbox */
 if(EMAIL_ERROR_NONE != email_update_mailbox(mailbox,new_mailbox))
       /* failure */
 else
       /* success   */
+
 /* delete mailbox */
 if(EMAIL_ERROR_NONE != email_delete_mailbox(mailbox,on_server,&handle))
       /* failure */
 else
       /* success   */
+
 email_free_mailbox(&mailbox, 1);
 email_free_mailbox(&new_mailbox, 1);
+
 @endcode
 
 @li Get list of mailboxes
@@ -459,7 +459,7 @@ int account_id = 1;
 int local_yn = 0;
 email_mailbox_t* mailbox_list = NULL;
 int count = 0;
+
 /*get list of mailboxes */
 if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id, local_yn, &mailbox_list, &count))
       /* failure */
@@ -485,85 +485,85 @@ email_mail_data_t
 <table>
 <tr><td>API</td>
 <td>Return Value / Exceptions</td></tr>
+
 <tr><td>int email_add_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: -  Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_update_mail(email_mail_data_t *input_mail_data, email_attachment_data_t *input_attachment_data_list, int input_attachment_count, email_meeting_request_t* input_meeting_request, int input_from_eas)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: -  Memory for params email_mail_data_t* input_mail_data and email_attachment_data_t *input_attachment_data_list and email_meeting_request_t* input_meeting_request should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_count_mail(email_mailbox_t* mailbox, int* total, int* unseen)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
 
 <tr><td>int email_delete_mail(email_mailbox_t* mailbox, int *mail_ids, int num, int from_server)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and mf_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_delete_all_mails_in_mailbox(email_mailbox_t* mailbox, int from_server)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_clear_mail_data()  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
 
 <tr><td>int email_add_attachment(email_mailbox_t* mailbox, int mail_id, email_attachment_data_t* attachment)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param mf_mailbox_t* mailbox and mf_attachment_info_t* attachment hould be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_delete_attachment(email_mailbox_t * mailbox, int mail_id, const char * attachment_id)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_get_attachment_data(email_mailbox_t* mailbox, int mail_id, const char* attachment_id, email_attachment_data_t** attachment)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.@n Remarks:
--# Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application 
+-# Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application
 -# Memory allocation for param email_attachment_data_t** attachment will happen in email_get_attachment_data (). To free this memory, application should call email_free_attachment_info () </td></tr>
+
 <tr><td>int email_free_attachment_info(email_attachment_data_t** atch_info)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
+
 <tr><td>int email_modify_seen_flag(int *mail_ids, int num, int seen_flag, int onserver)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param int *mail_ids should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_move_mail_to_mailbox(int *mail_ids, int num, email_mailbox_t* new_mailbox)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params int *mail_ids and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_move_all_mails_to_mailbox(email_mailbox_t* src_mailbox, email_mailbox_t* new_mailbox)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for params email_mailbox_t* src_mailbox and email_mailbox_t* new_mailbox should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_count_message_with_draft_flag(email_mailbox_t* mailbox, int* total)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
+
 <tr><td>int email_count_message_on_sending(email_mailbox_t* mailbox, int* total)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory for param email_mailbox_t* mailbox should be allocated and deallocated by Application</td></tr>
-  
+
 <tr><td>int email_get_mailbox_list(int account_id, email_mailbox_t** mailbox_list, int* count ) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: - Memory allocation for param email_mailbox_t** mailbox_list will happen in email_get_mailbox_list (). To free this memory, application should call email_free_mailbox ()</td></tr>
+
 <tr><td>int email_free_mailbox(email_mailbox_t** mailbox_list, int count)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_retry_sending_mail( int mail_id, int timeout_in_sec)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_make_db_full()</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_get_mailbox_name_by_mail_id(int mail_id, char **pMailbox_name)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_cancel_sending_mail( int mail_id)  </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_count_message_all_mailboxes(email_mailbox_t* mailbox, int* total, int* unseen) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_get_latest_unread_mail_id(int account_id, int *pMailID) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_get_max_mail_count(int *Count) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_get_disk_space_usage(unsigned long *total_size)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
 </table>
+
 <b>Sample Code</b>
 
 @li Add, Update, Count and Delete message
@@ -577,7 +577,7 @@ int                    from_eas = 0;
 int                    attachment_count = 0;
 int                    err = EMAIL_ERROR_NONE;
 char                   arg[50] = { 0 , };
-char                  *body_file_path = MAILHOME"/tmp/mail.txt";
+char                  *body_file_path = MAIL_HOME"/tmp/mail.txt";
 email_mailbox_t         *mailbox_data = NULL;
 email_mail_data_t       *test_mail_data = NULL;
 email_attachment_data_t *attachment_data = NULL;
@@ -623,37 +623,37 @@ if((err = email_add_mail(test_mail_data, attachment_data, attachment_count, meet
        printf("email_add_mail failed. [%d]\n", err);
 else
        printf("email_add_mail success.\n");
+
 /* Update message */
 /*  variable 'mail' should be filled with data on DB. */
 /*  And change values you want to update. */
 mail->head->subject = strdup("save.mailbox again...");
+
 if(EMAIL_ERROR_NONE != email_update_message(mail_id,mail))
        /* failure */
 else
        /* success   */
+
 /* Count message */
 int total = 0, unseen = 0;
+
 /*  Get the total number of mails and the number of unseen mails */
 if(EMAIL_ERROR_NONE != email_count_mail(mailbox,&total,&unseen))
        /* failure */
 else
        /* success   */
+
 /* Delete message */
 int *mail_ids, num = 0;
+
 if(EMAIL_ERROR_NONE != email_delete_mail(mailbox,mail_ids,num,on_server))
        /* failure */
 else
        /* success   */
-@endcode 
+@endcode
+
 @li Delete all message in a specific mailbox
-@code 
+@code
 /* Delete all message in mailbox */
 email_mailbox_t *mailbox = NULL;
 int on_server = 0;
@@ -662,7 +662,7 @@ mailbox = malloc(sizeof(email_mailbox_t));
 memset(mailbox, 0x00, sizeof(email_mailbox_t));
 
 mailbox->account_id = 1;
-mailbox->mailbox_name = strdup("INBOX");               
+mailbox->mailbox_name = strdup("INBOX");
 
 if( EMAIL_ERROR_NONE != email_delete_all_mails_in_mailbox(mailbox, on_server))
       /* failure */
@@ -683,108 +683,108 @@ else
 
 
 @li Move mail
-@code 
+@code
 int mail_id[],account_id = 1;
 email_mailbox_t *mailbox = NULL;
 char *mailbox_name = "INBOX";
+
 mailbox = malloc(sizeof(email_mailbox_t));
 memset(mailbox, 0x00, sizeof(email_mailbox_t));
+
 mailbox->account_id = account_id;
 mailbox->mailbox_name = mailbox_name;
+
 /* Move mail to given mailbox*/
 if(EMAIL_ERROR_NONE !=  email_move_mail_to_mailbox(/*mail_id*/,/*num*/,mailbox))
       /* failure */
 else
       /* success   */
+
 /* free mailbox*/
 email_free_mailbox(&mailbox,1);
+
 email_mailbox_t *src_mailbox = NULL,*dest_mailbox = NULL;
 int src_account_id = 0, dest_account_id = 0;
 char * src_mailbox_name = NULL, *dest_mailbox_name = NULL;
+
 src_mailbox = malloc(sizeof(email_mailbox_t));
 memset(src_mailbox, 0x00, sizeof(email_mailbox_t));
+
 dest_mailbox = malloc(sizeof(email_mailbox_t));
 memset(dest_mailbox, 0x00, sizeof(email_mailbox_t));
+
 src_mailbox->account_id = /*src_account_id*/;
 src_mailbox->mailbox_name = /*src_mailbox_name*/
+
 dest_mailbox->account_id = /*dest_account_id*/;
 dest_mailbox->mailbox_name = /*dest_mailbox_name*/
+
 /*move all mails to given mailbox*/
 if(EMAIL_ERROR_NONE !=  email_move_all_mails_to_mailbox(src_mailbox,dest_mailbox))
       /* failure */
 else
       /* success   */
+
 /* free mailbox*/
 email_free_mailbox(&src_mailbox,1);
 email_free_mailbox(&dest_mailbox,1);
+
 int account_id = 0, total = 0;
 email_mailbox_t *mailbox = NULL;
 char *mailbox_name = NULL;
+
 mailbox = malloc(sizeof(email_mailbox_t));
 memset(mailbox, 0x00, sizeof(email_mailbox_t));
+
 mailbox->account_id = /*account_id*/;
 mailbox->mailbox_name = /*mailbox_name*/
+
 /*count of draft msgs*/
 if(EMAIL_ERROR_NONE !=  email_count_message_with_draft_flag(mailbox,&total))
       /* failure */
 else
       /* success   */
+
 /* free mailbox*/
 email_free_mailbox(&mailbox,1);
 @endcode
+
 @li Count of msgs sent from given folde
 @code
 int account_id = 0, total = 0;
 email_mailbox_t *mailbox = NULL;
 char *mailbox_name = NULL;
+
 mailbox = malloc(sizeof(email_mailbox_t));
 memset(mailbox, 0x00, sizeof(email_mailbox_t));
+
 mailbox->account_id = /*account_id*/;
 mailbox->mailbox_name = /*mailbox_name*/
+
 /*count of msgs sent from given mailbox*/
 if(EMAIL_ERROR_NONE != email_count_message_on_sending(mailbox,&total))
       /* failure */
 else
       /* success   */
+
 /* free mailbox*/
 email_free_mailbox(&mailbox,1);
 
 @endcode
 
 
-@li Get mailbox list 
+@li Get mailbox list
 @code
+
 email_mailbox_t* mailbox_list = NULL;
 int account_id = 1, count = 0;
+
 /* Get mailbox list*/
 if(EMAIL_ERROR_NONE != email_get_mailbox_list(account_id,&mailbox_list,&count))
       /* failure */
 else
       /* success   */
+
 /* free mailbox list*/
 email_free_mailbox(&mailbox,count);
 @endcode
@@ -803,39 +803,39 @@ free(pMailbox_name);
 
 
 @li Cancel sending mail
-@code 
+@code
+
 /* email_cancel_sending_mail*/
 int mail_id = 1;       /*  mail id of a mail which is on sending */
 err = email_cancel_sending_mail(mail_id);
+
 @endcode
 
 
 
 @li Get the Total count and Unread count of all mailboxes
-@code 
+@code
 /* Get the Total count and Unread count of all mailboxes */
 email_mailbox_t* mailbox = NULL;
 int account_id = 1, total = 0, unseen = 0;
 char *mailbox_name = NULL;
+
 mailbox = malloc(sizeof(email_mailbox_t));
 memset(mailbox, 0x00, sizeof(email_mailbox_t));
+
 mailbox->account_id = /*account_id*/;
 mailbox->mailbox_name = /*mailbox_name*/
+
 err = email_count_message_all_mailboxes(mailbox,&total,&unseen);
+
 @endcode
 
 <b>Flow Diagram</b>s
 @image html email_image006.png
 
 @image html email_image007.png
-@image html email_image008.png 
+
+@image html email_image008.png
 @}
 
 @defgroup Use_Case4_network Network Operation
@@ -849,38 +849,38 @@ email_option_t - refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
 <table>
 <tr><td>API</td>
 <td>Return Value / Exceptions</td></tr>
+
 <tr><td>int email_send_mail( email_mailbox_t* mailbox, int mail_id, int *handle)</td>
-<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: 
+<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
+
 <tr><td>int email_sync_header(email_mailbox_t* mailbox, int *handle)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
+
 <tr><td>int email_download_body(email_mailbox_t* mailbox, int mail_id, int with_attachment, int *handle) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
+
 <tr><td>int email_download_attachment(email_mailbox_t* mailbox, int mail_id, const char* nth,  int *handle)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
 
 <tr><td>int email_cancel_job(int account_id, int handle)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
+
 <tr><td>int email_get_pending_job(email_action_t action, int account_id, int mail_id, email_event_status_type_t * status)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
+
 <tr><td>void email_get_network_status(int* on_sending, int* on_receiving) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_send_saved(int account_id, email_option_t* sending_option, int *handle)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation and de-allocation for input param is to be done by application.</td></tr>
+
 <tr><td>int email_sync_imap_mailbox_list(int account_id, const char* mailbox, int *handle)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
+
 <tr><td>int email_sync_local_activity(int account_id)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
 </table>
@@ -898,9 +898,9 @@ email_mailbox_t mailbox;
 int account_id = 1;
 int err = EMAIL_ERROR_NONE;
 int handle = 0;
+
 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
+
 mailbox.account_id = account_id;
 mailbox.mailbox_name = strdup("INBOX");
 err = email_sync_header (&mailbox,&handle);
@@ -909,29 +909,29 @@ err = email_sync_header (&mailbox,&handle);
 
 @li Download email body from server
 @code
+
 /*Download email body from server*/
 email_mailbox_t mailbox;
 int mail_id = 1;
 int account_id = 1;
 int handle = 0;
 int err = EMAIL_ERROR_NONE;
+
 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
 mailbox.account_id = account_id;
 mailbox.mailbox_name = strdup("INBOX");
 err= email_download_body (&mailbox,mail_id,0,&handle);
+
 @li Download a email nth-attachment from server
 @code
 /*Download a email nth-attachment from server*/
 email_mailbox_t mailbox;
 int mail_id = 1;
-int account_id = 1;     
+int account_id = 1;
 char arg[50]; /* Input attachment number need to be download */
 int handle = 0;
 int err = EMAIL_ERROR_NONE;
+
 memset(&mailbox, 0x00, sizeof(email_mailbox_t));
 mailbox.mailbox_name = "INBOX";
 mailbox.account_id = account_id;
@@ -953,30 +953,30 @@ email_rule_t- refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
 <table>
 <tr><td>API</td>
 <td>Return Value / Exceptions</td></tr>
+
 <tr><td>int email_get_rule(int filter_id, email_rule_t** filtering_set)</td>
-<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks: 
+<td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation for the param email_rule_t** filtering_set will be done in this api.
 -# De-allocation is to be done by application.</td></tr>
+
 <tr><td>int email_get_rule_list(email_rule_t** filtering_set, int* count)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation for the param email_rule_t** filtering_set will be done in this api.
 -# De-allocation is to be done by application.</td></tr>
+
 <tr><td>int email_add_rule(email_rule_t* filtering_set) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation and de-allocation is to be done by application.
 -# Use email_free_rule to free allocated memory.</td></tr>
+
 <tr><td>int email_update_rule(int filter_id, email_rule_t* new_set) </td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure@n Remarks:
 -# Memory allocation and de-allocation is to be done by application.</td></tr>
 -# Use email_free_rule to free allocated memory.
+
 <tr><td>int email_delete_rule(int filter_id)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure.</td></tr>
+
 <tr><td>int email_free_rule(email_rule_t** filtering_set, int count)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
 </table>
@@ -987,27 +987,27 @@ email_rule_t- refer to doxygen (SLP-SDK: http:/* slp-sdk.sec.samsung.net) */
 int err = EMAIL_ERROR_NONE;
 email_rule_t*  rule = NULL;
 int filter_id = 1;
+
 /* Get a information of filtering*/
 err = email_get_rule (filter_id,&rule);
 err = email_free_rule (&rule,1);
+
 /* Get all filterings */
 int count = 0;
 err = email_get_rule_list(&rule,&count);
+
+
 /* Add a filter information */
 err = email_add_rule (rule);
 err = email_free_rule (&rule,1);
+
 /* Change a filter information */
 err = email_update_rule (filter_id,rule);
 err = email_free_rule (&rule,1);
+
 /* Delete a filter information*/
 err = email_delete_rule (filter_id);
+
 /* Free allocated memory */
 err = email_free_rule (&rule,1);
 @endcode
@@ -1027,34 +1027,34 @@ And it MUST finalize IPC proxy and disconnect to the DB if the application doesn
 <table>
 <tr><td>API</td>
 <td>Return Value / Exceptions</td></tr>
+
 <tr><td>int email_init_storage(void)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_open_db(void)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
 @n Remarks:
 @n Application should call email_close_db once db operation is over</td></tr>
+
 <tr><td>int email_close_db(void)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
-@n Remarks: - 
+@n Remarks: -
 @n This API should be called only if email_open_db () is called.</td></tr>
+
 <tr><td>int email_service_begin(void)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure</td></tr>
+
 <tr><td>int email_service_end(void)</td>
 <td>Returns EMAIL_ERROR_NONE on success or negative value on failure
 @n Remarks:
 @n This API should be called only if email_service_begin () is called.</td></tr>
 </table>
+
 <b>Sample Code</b>
 @li Initialize and Finalize Email MAPI Layer
 @code
 int err = EMAIL_ERROR_NONE;
+
 /*  Initialize Email MAPI Layer before calling other MAPIs */
 if(EMAIL_ERROR_NONE == email_service_begin())
 {
@@ -1062,7 +1062,7 @@ if(EMAIL_ERROR_NONE == email_service_begin())
        {
                return false;
        }
-       if(EMAIL_ERROR_NONE != email_init_storage())      
+       if(EMAIL_ERROR_NONE != email_init_storage())
        {
                return false;
        }
@@ -1090,7 +1090,7 @@ email-api.h
 
        <h2 class="pg">System Initialization and De-Initialization</h2>
 email_service_begin is used to initialize email-service at boot time.
-@n email_service_end is used to deinitialize email-service at shutdown. 
+@n email_service_end is used to deinitialize email-service at shutdown.
 @n These two are separate executables.
 
        <h2 class="pg">Variable Configuration</h2>
@@ -1115,8 +1115,8 @@ NA
 - Alice composed a message using MUA (Mail User Agent). Alice enters the e-mail address of her correspondent, and hits the "send" button.
 - MUA format the message using MIME and uses Simple mail Transfer Protocol to send the message to local MTA (Mail Transfer Agent) i,e smtp.a.org run by Alices ISP (Internet Service provider).
 - The MTA looks at the destination address provided in the SMTP protocol i,e bob@b.org. An Internet e-mail address is a string of the form localpart@exampledomain. The part before the @ sign is the local part of the address, often the username of the recipient, and the part after the @ sign is a domain name. The MTA resolves a domain name to determine the fully qualified domain name of the mail exchange server in the Domain Name System (DNS).
-- The DNS Server for the b.org domain, ns.b.org, responds with an MX Records listing the mail exchange servers for that domain, in this case mx.b.org, a server run by Bob's ISP. 
-- smtp.a.org sends the message to mx.b.org using SMTP, which delivers it to the mailbox of the user bob. 
+- The DNS Server for the b.org domain, ns.b.org, responds with an MX Records listing the mail exchange servers for that domain, in this case mx.b.org, a server run by Bob's ISP.
+- smtp.a.org sends the message to mx.b.org using SMTP, which delivers it to the mailbox of the user bob.
 - Bob presses the "get mail" button in his MUA, which picks up the message using the Post Office Protocol (POP3).
 
        <h2 class="pg">RFC</h2>
index c9bd06b..f805242 100755 (executable)
@@ -137,6 +137,7 @@ install -m 0775 %{SOURCE3} %{buildroot}%{_bindir}/
 # Set executin script
 #################################################################
 chgrp %TZ_SYS_USER_GROUP %{_bindir}/email-service_init_db.sh
+chsmack -a "User" %{TZ_SYS_DATA}/email/res/email-service.sql
 
 systemctl daemon-reload
 if [ $1 == 1 ]; then