4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
23 /******************************************************************************
24 * File : email-storage.h
25 * Desc : email-core Storage Library Header
30 * 2006.07.28 : created
31 *****************************************************************************/
32 #ifndef __EMAIL_STORAGE_H__
33 #define __EMAIL_STORAGE_H__
34 #include <tzplatform_config.h>
39 #endif /* __cplusplus */
43 #include "email-types.h"
44 #include "email-core-tasks.h"
45 #include "email-internal-types.h"
46 #ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
47 #include "email-core-auto-download.h"
50 #define FIRST_ACCOUNT_ID 1
51 #define EMAIL_SERVICE_CREATE_TABLE_QUERY_FILE_PATH tzplatform_mkpath(TZ_USER_DATA,"email/res/email-service.sql")
54 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
55 #define QUERY_SIZE 8192
56 #define MAX_INTEGER_LENGTH 5 /* 32767 -> 5 bytes */
57 #define FILE_MAX_BUFFER_SIZE 16 * 1024 /* 16 Kbyte */
59 #define DB_STMT sqlite3_stmt *
64 unsigned long server_mail_id;
67 #endif /* __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__ */
72 /* Account information */
73 int account_id; /* Account id */
74 char *account_name; /* Account name */
75 char *logo_icon_path; /* Account logo icon path */
76 int account_svc_id; /* Specifies id from account-svc */
77 int sync_status; /* Sync Status. SYNC_STATUS_FINISHED, SYNC_STATUS_SYNCING, SYNC_STATUS_HAVE_NEW_MAILS */
78 int sync_disabled; /* If this attriube is set as true, email-service will not synchronize this account. */
79 int default_mail_slot_size;
80 email_roaming_option_t roaming_option; /* roaming option */
81 int color_label; /* Account color label */
82 void *user_data; /* binary user data */
83 int user_data_length; /* user data length */
85 /* User information */
86 char *user_display_name; /* User's display name */
87 char *user_email_address; /* User's email address */
88 char *reply_to_address; /* Email address for reply */
89 char *return_address; /* Email address for error from server*/
91 /* Configuration for incoming server */
92 email_account_server_t incoming_server_type; /* Incoming server type */
93 char *incoming_server_address; /* Incoming server address */
94 int incoming_server_port_number; /* Incoming server port number */
95 char *incoming_server_user_name; /* Incoming server user name */
96 char *incoming_server_password; /* Incoming server password */
97 int incoming_server_secure_connection; /* Does incoming server requires secured connection? */
99 /* Options for incoming server */
100 email_imap4_retrieval_mode_t retrieval_mode; /* Retrieval mode : EMAIL_IMAP4_RETRIEVAL_MODE_NEW or EMAIL_IMAP4_RETRIEVAL_MODE_ALL */
101 int keep_mails_on_pop_server_after_download; /* Keep mails on POP server after download */
102 int check_interval; /* Specifies the interval for checking new mail periodically */
103 int auto_download_size; /* Specifies the size for auto download in bytes. -1 means entire mails body */
104 int peak_interval; /* Specifies the interval for checking new mail periodically of peak schedule */
105 int peak_days; /* Specifies the weekdays of peak schedule */
106 int peak_start_time; /* Specifies the start time of peak schedule */
107 int peak_end_time; /* Specifies the end time of peak schedule */
109 /* Configuration for outgoing server */
110 email_account_server_t outgoing_server_type;
111 char *outgoing_server_address;
112 int outgoing_server_port_number;
113 char *outgoing_server_user_name;
114 char *outgoing_server_password;
115 int outgoing_server_secure_connection; /* Does outgoing server requires secured connection? */
116 int outgoing_server_need_authentication; /* Does outgoing server requires authentication? */
117 int outgoing_server_use_same_authenticator; /* Use same authenticator for outgoing server */
119 /* Options for outgoing server */
120 email_option_t options;
121 int auto_resend_times; /* Auto retry count for sending a email */
122 int outgoing_server_size_limit; /* Mail size limitation for SMTP sending*/
125 int wifi_auto_download; /* auto attachment download in wifi connection */
127 /* Authentication Options */
128 int pop_before_smtp; /* POP before SMTP Authentication */
129 int incoming_server_requires_apop; /* APOP authentication */
130 email_authentication_method_t incoming_server_authentication_method; /* authentication method */
133 email_smime_type smime_type; /* Sepeifies the smime type 0=Normal 1=Clear signed 2=encrypted 3=Signed + encrypted */
134 char *certificate_path; /* Sepeifies the certificate path of private*/
135 email_cipher_type cipher_type; /* Sepeifies the encryption algorithm*/
136 email_digest_type digest_type; /* Sepeifies the digest algorithm*/
138 /* Multi user and KNOX options */
139 char *user_name; /* Specifies the container name */
140 } emstorage_account_tbl_t;
149 int expiration_month;
151 char *issue_organization_name;
156 } emstorage_certificate_tbl_t;
160 int account_id; /* MUST BE '0' : currently, only global rule supported. */
163 int type; /* from/subject/body */
165 char *value2; /* from address */
166 int action_type; /* move/block/delete */
167 int target_mailbox_id; /* destination mailbox */
168 int flag1; /* for rule ON/OFF */
169 int flag2; /* For rule type INCLUDE/Exactly SAME AS */
170 } emstorage_rule_tbl_t;
172 /* mail_box_tbl table entity */
179 email_mailbox_type_e mailbox_type;
181 int modifiable_yn; /* whether mailbox is able to be deleted/modified */
182 int unread_count; /* Removed. 16-Dec-2010, count unread mails at the moment it is required. not store in the DB */
183 int total_mail_count_on_local; /* Specifies the total number of mails in the mailbox in the local DB. count unread mails at the moment it is required. not store in the DB */
184 int total_mail_count_on_server; /* Specifies the total number of mails in the mailbox in the mail server */
185 int has_archived_mails;
188 time_t last_sync_time; /* The last synchronization time */
189 int deleted_flag; /* whether mailbox is deleted */
190 int eas_data_length; /* Specifies the length of eas_data. */
191 char *eas_data; /* Specifies the data for eas engine. */
192 } emstorage_mailbox_tbl_t;
194 /* mail_read_uid_tbl table entity */
199 char *mailbox_name; /* server mailbox */
201 char *server_uid; /* uid on server */
202 int rfc822_size; /* rfc822 size */
204 char flags_seen_field; /* SEEN flag */
205 char flags_flagged_field; /* Favorite flag */
206 } emstorage_read_mail_uid_tbl_t;
208 #ifdef __FEATURE_BODY_SEARCH__
215 } emstorage_mail_text_tbl_t;
226 int server_mail_status;
227 char *server_mailbox_name;
228 char *server_mail_id;
230 int reference_mail_id;
231 char *full_address_from;
232 char *full_address_reply;
233 char *full_address_to;
234 char *full_address_cc;
235 char *full_address_bcc;
236 char *full_address_return;
237 char *email_address_sender;
238 char *email_address_recipient;
240 char *alias_recipient;
241 int body_download_status;
242 char *file_path_plain;
243 char *file_path_html;
244 char *file_path_mime_entity;
246 char flags_seen_field;
247 char flags_deleted_field;
248 char flags_flagged_field;
249 char flags_answered_field;
250 char flags_recent_field;
251 char flags_draft_field;
252 char flags_forwarded_field;
254 email_mail_priority_t priority;
255 email_mail_status_t save_status;
257 email_mail_report_t report_status;
258 int attachment_count;
259 int inline_content_count;
261 int thread_item_count;
263 email_mail_type_t meeting_request_status;
264 email_message_class message_class;
265 email_digest_type digest_type;
266 email_smime_type smime_type;
267 time_t scheduled_sending_time;
268 int remaining_resend_times;
271 time_t forwarded_time;
272 char *default_charset;
277 } emstorage_mail_tbl_t;
279 /* mail_attachment_tbl entity */
283 char *attachment_name;
284 char *attachment_path;
290 int attachment_save_status; /* 1 : existing, 0 : not existing */
291 int attachment_drm_type; /* 0 : none, 1 : object, 2 : rights, 3 : dcf */
292 int attachment_drm_method; /* 0 : none, 1 : FL, 2 : CD, 3 : SSD, 4 : SD */
293 int attachment_inline_content_status; /* 1 : inline content , 0 : not inline content */
294 char *attachment_mime_type;
295 #ifdef __ATTACHMENT_OPTI__
299 } emstorage_attachment_tbl_t;
303 RETRIEVE_ALL = 1, /* mail */
304 RETRIEVE_ENVELOPE, /* mail envelope */
305 RETRIEVE_SUMMARY, /* mail summary */
306 RETRIEVE_FIELDS_FOR_DELETE, /* account_id, mail_id, server_mail_yn, server_mailbox, server_mail_id */
307 RETRIEVE_ACCOUNT, /* account_id */
308 RETRIEVE_FLAG, /* mailbox, flag1, thread_id */
309 RETRIEVE_ID, /* mail_id */
310 RETRIEVE_ADDRESS, /* mail_id, contact_info */
311 } emstorage_mail_field_type_t;
313 typedef struct _emstorage_search_filter_t {
316 struct _emstorage_search_filter_t *next;
317 } emstorage_search_filter_t;
320 EMAIL_CREATE_DB_NORMAL = 0,
321 EMAIL_CREATE_DB_CHECK,
322 } emstorage_create_db_type_t;
325 /*****************************************************************************
327 *****************************************************************************/
328 #define MAX_PW_FILE_NAME_LENGTH 128 /* password file name for secure storage */
330 #ifdef __FEATURE_LOCAL_ACTIVITY__
334 ACTIVITY_FETCHIMAPFOLDER = 1, /* Fetch Mail server Activity */
335 ACTIVITY_DELETEMAIL, /* Delete Mail Activity */
336 ACTIVITY_MODIFYFLAG, /* Modify Mail flag Activity */
337 ACTIVITY_MODIFYSEENFLAG, /* Modify Mail seen flag Activity */
338 ACTIVITY_MOVEMAIL, /* Move Mail Activity */
339 ACTIVITY_DELETEALLMAIL, /* Delete All Mails activity */
340 ACTIVITY_COPYMAIL, /* Copy Mail Activity */
341 ACTIVITY_SAVEMAIL, /* Save Mail activity */
342 ACTIVITY_DELETEMAIL_SEND, /* New Delete Mail Activity added to be processed by send thread */
347 * emstorage_activity_tbl_t - Email Local activity Structure
352 int activity_id; /* Activity ID */
353 int account_id; /* Account ID */
354 int mail_id; /* Mail ID */
355 int activity_type; /* Local Activity Type */
356 char *server_mailid; /* Server Mail ID or Mailbox name */
357 char *src_mbox; /* Source Mailbox in case of mail_move */
358 char *dest_mbox; /* Destination Mailbox name in case of Mail move operation */
360 } emstorage_activity_tbl_t;
364 INTERNAL_FUNC int emstorage_shm_file_init(const char *shm_file_name);
367 /************** Database Management ***************/
370 * description : open db and register busy handler
372 INTERNAL_FUNC int em_db_open(char *db_file_path, sqlite3 **sqlite_handle, int *err_code);
377 * description : open db and set global variable sqlite_emmb
381 INTERNAL_FUNC sqlite3* emstorage_db_open(char *multi_user_name, int *err_code);
386 * description : close db with global variable sqlite_emmb
390 INTERNAL_FUNC int emstorage_db_close(char *multi_user_name, int *err_code);
395 * description : initialize storage manager
399 INTERNAL_FUNC int emstorage_open(char *multi_user_name, int *err_code);
404 * description : cleanup storage manager
408 INTERNAL_FUNC int emstorage_close(int *err_code);
411 * emstorage_create_table
413 * description : create account/address table in database.
417 INTERNAL_FUNC int emstorage_create_table(char *multi_user_name, emstorage_create_db_type_t type, int *err_code);
419 INTERNAL_FUNC int emstorage_initialize_field_count();
422 * Check whether there is the same account information in the db
424 * @param[in] account account that
425 * @param[in] transaction If the argument is true, engine commits transaction or executes rollback.
426 * @param[out] err_code Error code.
428 * @return This function returns true if there is no duplicated account. returns false and set error code if there are duplicated accounts or error
430 INTERNAL_FUNC int emstorage_check_duplicated_account(char *multi_user_name, email_account_t *account, int transaction, int *err_code);
433 * Get number of accounts from account table.
435 * @param[out] count The number of accounts is saved here.
436 * @param[in] transaction If the argument is true, engine commits transaction or executes rollback.
438 * @return This function returns 0 on success or error code on failure.
440 INTERNAL_FUNC int emstorage_get_account_count(char *multi_user_name, int *count, int transaction, int *err_code);
443 * Get account from account table.
445 * @param[in, out] select_num Upon entry, the argument contains the number of accounts to select.
446 Upon exit, it is set to the number of accounts to been selected.
447 * @param[out] account_list The selected accounts is saved here. this pointer must be freed after being used.
448 * @param[in] transaction If the argument is true, engine commits transaction or executes rollback.
450 * @return This function returns 0 on success or error code on failure.
452 INTERNAL_FUNC int emstorage_get_account_list(char *multi_user_name, int *select_num, emstorage_account_tbl_t **account_list, int transaction, int with_password, int *err_code);
455 * emstorage_get_account_by_name
457 * description : get account from account table by account name
459 * db : database pointer
460 * account_id : account id
461 * pulloption : option to specify fetching full or partial data
462 * account : buffer to hold selected account
463 * this buffer must be free after it has been used.
466 /* sowmya.kr, 281209 Adding signature to options in email_account_t changes */
467 INTERNAL_FUNC int emstorage_get_account_by_id(char *multi_user_name, int account_id, int pulloption, emstorage_account_tbl_t **account, int transaction, int *err_code);
470 * emstorage_get_password_length_of_account
472 * description: get password length of account.
474 * account_id : account id
475 * password_length : password length
479 INTERNAL_FUNC int emstorage_get_password_length_of_account(char *multi_user_name, int account_id, int password_type, int *password_length, int* err_code);
481 INTERNAL_FUNC int emstorage_update_account_password(char *multi_user_name, int input_account_id, char *input_incoming_server_password, char *input_outgoing_server_password);
484 * emstorage_update_account
486 * description : change a account from account table
488 * account_id : account id
489 * account : buffer to hold selected account
492 INTERNAL_FUNC int emstorage_update_account(char *multi_user_name, int account_id, emstorage_account_tbl_t *account, int transaction, int *err_code);
494 INTERNAL_FUNC int emstorage_set_field_of_accounts_with_integer_value(char *multi_user_name, int account_id, char *field_name, int value, int transaction);
496 * emstorage_get_sync_status_of_account
498 * description : get a sync status field from account table
500 * account_id : account id
501 * result_sync_status : sync status value
504 INTERNAL_FUNC int emstorage_get_sync_status_of_account(char *multi_user_name, int account_id, int *result_sync_status,int *err_code);
507 * emstorage_update_sync_status_of_account
509 * description : update a sync status field from account table
511 * account_id : account id
512 * set_operator : set operater. refer email_set_type_t
513 * sync_status : sync status value
516 INTERNAL_FUNC int emstorage_update_sync_status_of_account(char *multi_user_name, int account_id, email_set_type_t set_operator, int sync_status, int transaction, int *err_code);
520 * emstorage_add_account
522 * description : add a account to account table
526 INTERNAL_FUNC int emstorage_add_account(char *multi_user_name, emstorage_account_tbl_t *account, int transaction, int *err_code);
529 * emstorage_delete_account
531 * description : delete a account from account table
533 * db : database pointer
534 * account_id : account id to be deteted
537 INTERNAL_FUNC int emstorage_delete_account(char *multi_user_name, int account_id, int transaction, int *err_code);
540 * emstorage_free_account
542 * description : free local accout memory
544 * account_list : double pointer
545 * count : count of local account
548 INTERNAL_FUNC int emstorage_free_account(emstorage_account_tbl_t **account_list, int count, int *err_code);
551 /************** Mailbox(Local box And Imap mailbox) Management ******************/
554 * emstorage_get_mailbox_count
556 * description : get number of mailbox from local mailbox table
558 * db : database pointer
559 * count : number of accounts
562 INTERNAL_FUNC int emstorage_get_mailbox_count(char *multi_user_name, int account_id, int local_yn, int *count, int transaction, int *err_code);
565 * emstorage_get_mailbox
567 * description : get local mailbox from local mailbox table
569 * db : database pointer
570 * sort_type : in - sorting type.
571 * select_num : in - number of selected account
572 * out - number to been selected
573 * mailbox_list : buffer to hold selected account
574 * this buffer must be free after it has been used.
577 INTERNAL_FUNC int emstorage_get_mailbox_list(char *multi_user_name, int account_id, int local_yn, email_mailbox_sort_type_t sort_type, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
580 * emstorage_get_child_mailbox_list
582 * description : get child mailbox list from given mailbox
584 * account_id : in - account id
585 * parent_mailbox_name : in - parent_mailbox_name to fetch child list
586 * local_yn - in - local mailbox or not
587 * select_num - out : count of mailboxes
588 * mailbox_list - out : list of mailboxes
589 * err_code - out : error code, if any
591 INTERNAL_FUNC int emstorage_get_child_mailbox_list(char *multi_user_name, int account_id, char *parent_mailbox_name, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
594 * emstorage_get_mailbox_by_name
596 * description : get local mailbox from local mailbox table by mailbox name
598 * db : database pointer
599 * mailbox_name : mailbox name
600 * mailbox : buffer to hold selected local mailbox
601 * this buffer must be free after it has been used.
604 INTERNAL_FUNC int emstorage_get_mailbox_by_name(char *multi_user_name, int account_id, int local_yn, char *mailbox_name, emstorage_mailbox_tbl_t **mailbox, int transaction, int *err_code);
606 INTERNAL_FUNC int emstorage_get_mailbox_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, emstorage_mailbox_tbl_t **mailbox, int transaction, int *err_code);
608 INTERNAL_FUNC int emstorage_get_mailbox_by_id(char *multi_user_name, int input_mailbox_id, emstorage_mailbox_tbl_t** output_mailbox);
610 INTERNAL_FUNC int emstorage_get_mailbox_by_keyword(char *multi_user_name, int account_id, char *keyword, emstorage_mailbox_tbl_t** result_mailbox, int * result_count, int transaction, int *err_code);
612 INTERNAL_FUNC int emstorage_get_mailbox_list_ex(char *multi_user_name, int account_id, int local_yn, int with_count, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
614 INTERNAL_FUNC int emstorage_get_mailbox_id_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, int *mailbox_id, int transaction, int *err_code);
616 INTERNAL_FUNC int emstorage_get_mailbox_name_by_mailbox_type(char *multi_user_name, int account_id, email_mailbox_type_e mailbox_type, char **mailbox_name, int transaction, int *err_code);
618 INTERNAL_FUNC int emstorage_update_mailbox_modifiable_yn(char *multi_user_name, int account_id, int local_yn, char *mailbox_name, int modifiable_yn, int transaction, int *err_code);
620 INTERNAL_FUNC int emstorage_update_mailbox_total_count(char *multi_user_name, int account_id, int input_mailbox_id, int total_count_on_server, int transaction, int *err_code);
624 * emstorage_update_mailbox
626 * description : change a account from account table
628 * db : database pointer
629 * mailbox_name : mailbox name
630 * mailbox : buffer to hold selected local mailbox
633 INTERNAL_FUNC int emstorage_update_mailbox(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
636 * emstorage_update_mailbox_type
638 * description : change a mailbox from mailbox tbl
642 INTERNAL_FUNC int emstorage_update_mailbox_type(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, email_mailbox_type_e new_mailbox_type, int transaction, int *err_code);
645 * emstorage_set_local_mailbox
647 * description : change 'local' field on mailbox table.
651 INTERNAL_FUNC int emstorage_set_local_mailbox(char *multi_user_name, int input_mailbox_id, int input_is_local_mailbox, int transaction);
653 INTERNAL_FUNC int emstorage_set_field_of_mailbox_with_integer_value(char *multi_user_name, int input_account_id, int *input_mailbox_id_array, int input_mailbox_id_count, char *input_field_name, int input_value, int transaction);
656 * emstorage_add_mailbox
658 * description : add a local mailbox to local mailbox table
662 INTERNAL_FUNC int emstorage_add_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
665 * emstorage_delete_mailbox
667 * description : delete a local mailbox from local mailbox table
669 * db : database pointer
670 * mailbox_name : mailbox name of record to be deteted
673 INTERNAL_FUNC int emstorage_delete_mailbox(char *multi_user_name, int account_id, int local_yn, int input_mailbox_id, int transaction, int *err_code);
675 INTERNAL_FUNC int emstorage_rename_mailbox(char *multi_user_name, int input_mailbox_id, char *input_new_mailbox_name, char *input_new_mailbox_alias, void *input_eas_data, int input_eas_data_length, int input_transaction);
677 INTERNAL_FUNC int emstorage_get_overflowed_mail_id_list(char *multi_user_name, int account_id, int input_mailbox_id, int mail_slot_size, int **mail_id_list, int *mail_id_count, int transaction, int *err_code);
679 INTERNAL_FUNC int emstorage_set_mail_slot_size(char *multi_user_name, int account_id, int mailbox_id, int new_slot_size, int transaction, int *err_code);
681 INTERNAL_FUNC int emstorage_set_all_mailbox_modifiable_yn(char *multi_user_name, int account_id, int modifiable_yn, int transaction, int *err_code);
683 INTERNAL_FUNC int emstorage_get_mailbox_by_modifiable_yn(char *multi_user_name, int account_id, int modifiable_yn, int *select_num, emstorage_mailbox_tbl_t **mailbox_list, int transaction, int *err_code);
685 INTERNAL_FUNC int emstorage_stamp_last_sync_time_of_mailbox(char *multi_user_name, int input_mailbox_id, int input_transaction);
688 * emstorage_free_mailbox
690 * description : free local mailbox memory
692 * mailbox_list : double pointer
693 * count : count of local mailbox
696 INTERNAL_FUNC int emstorage_free_mailbox(emstorage_mailbox_tbl_t **mailbox_list, int count, int *err_code);
699 /************** Read Mail UID Management ******************/
700 INTERNAL_FUNC int emstorage_get_count_read_mail_uid(char *multi_user_name, int account_id, char *mailbox_name, int *count, int transaction, int *err_code);
704 * emstorage_check_read_mail_uid
706 * description : check that this uid exists in uid table
708 * db : database pointer
709 * mailbox_name : mailbox name
710 * uid : uid string to be checked
711 * exist : variable to hold checking result. (0 : not exist, 1 : exist)
714 INTERNAL_FUNC int emstorage_check_read_mail_uid(char *multi_user_name, int account_id, char *mailbox_name, char *uid, int *exist, int transaction, int *err_code);
717 * emstorage_get_read_mail_size
719 * description : get mail size from read mail uid
721 * db : database pointer
722 * mailbox_id : local mailbox id
723 * local_uid : mail uid of local mailbox
724 * mailbox_name : server mailbox name
725 * uid : mail uid string of server mail
726 * read_mail_uid : variable to hold read mail uid information
729 INTERNAL_FUNC int emstorage_get_downloaded_list(char *multi_user_name, int account_id, int mailbox_id, emstorage_read_mail_uid_tbl_t **read_mail_uid, int *count, int transaction, int *err_code);
731 INTERNAL_FUNC int emstorage_get_downloaded_mail(char *multi_user_name, int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
734 * emstorage_get_read_mail_size
736 * description : get mail size from read mail uid
738 * db : database pointer
739 * mailbox_name : mailbox name
740 * s_uid : mail uid string
741 * size : variable to hold mail size
744 INTERNAL_FUNC int emstorage_get_downloaded_mail_size(char *multi_user_name, int account_id, char *local_mbox, int local_uid, char *mailbox_name, char *uid, int *mail_size, int transaction, int *err_code);
747 * emstorage_add_downloaded_mail
749 * description : add read mail uid
753 INTERNAL_FUNC int emstorage_add_downloaded_mail(char *multi_user_name, emstorage_read_mail_uid_tbl_t *read_mail_uid, int transaction, int *err_code);
755 #ifdef __FEATURE_BODY_SEARCH__
757 * emstorage_add_mail_text
759 * description : add stripped text of mail body to mail_text_tbl
763 INTERNAL_FUNC int emstorage_add_mail_text(char *multi_user_name, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code);
767 * emstorage_change_read_mail_uid
769 * description : modify read mail uid
773 INTERNAL_FUNC int emstorage_change_read_mail_uid(char *multi_user_name, int account_id, int local_mailbox_id, int local_uid, char *mailbox_name, char *uid,
774 emstorage_read_mail_uid_tbl_t *read_mail_uid, int transaction, int *err_code);
777 * emstorage_remove_downloaded_mail
783 INTERNAL_FUNC int emstorage_remove_downloaded_mail(char *multi_user_name, int account_id, char *mailbox_name, char *uid, int transaction, int *err_code);
785 INTERNAL_FUNC int emstorage_update_read_mail_uid(char *multi_user_name, int mail_id, char *new_server_uid, char *mbox_name, int *err_code);
790 INTERNAL_FUNC int emstorage_free_read_mail_uid(emstorage_read_mail_uid_tbl_t **read_mail_uid, int count, int *err_code);
794 /************** Rules(Filtering) Management ******************/
797 * emstorage_get_rule_count_by_account_id
799 * description : get number of rules from rule table
801 * db : database pointer
802 * count : number of accounts
805 INTERNAL_FUNC int emstorage_get_rule_count_by_account_id(char *multi_user_name, int account_id, int *count, int transaction, int *err_code);
810 * description : get rules from rule table
812 * db : database pointer
813 * start_idx : the first index to be selected (min : 0)
814 * select_num : in - number of selected account
815 * out - number to been selected
816 * is_completed : is completed ?
819 INTERNAL_FUNC int emstorage_get_rule(char *multi_user_name, int account_id, int type, int start_idx, int *select_num, int *is_completed, emstorage_rule_tbl_t **rule_list, int transaction, int *err_code);
824 * description : get rules from rule table
828 INTERNAL_FUNC int emstorage_get_rule_by_id(char *multi_user_name, int rule_id, emstorage_rule_tbl_t **rule, int transaction, int *err_code);
831 * emstorage_change_rule
833 * description : change a account from account table
835 * db : database pointer
836 * mailbox_name : mailbox name
837 * rule : buffer to hold selected rule
840 INTERNAL_FUNC int emstorage_change_rule(char *multi_user_name, int rule_id, emstorage_rule_tbl_t *rule, int transaction, int *err_code);
843 * emstorage_find_rule
845 * description : find a rule already exists
849 INTERNAL_FUNC int emstorage_find_rule(char *multi_user_name, emstorage_rule_tbl_t *rule, int transaction, int *err_code);
854 * description : add a rule to rule table
858 INTERNAL_FUNC int emstorage_add_rule(char *multi_user_name, emstorage_rule_tbl_t *rule, int transaction, int *err_code);
861 * emstorage_delete_rule
863 * description : delete a rule from rule table
865 * db : database pointer
866 * rule : rule to be deteted
869 INTERNAL_FUNC int emstorage_delete_rule(char *multi_user_name, int rule_id, int transaction, int *err_code);
872 * emstorage_free_rule
874 * description : free rule memory
876 * count : count of rule
879 INTERNAL_FUNC int emstorage_free_rule(emstorage_rule_tbl_t **rule_list, int count, int *err_code);
882 /************** Mail Management ******************/
885 * emstorage_get_mail_count
887 * description : get mail total and unseen count from mail table
889 * total : total count
890 * unseen : unseen mail count
893 INTERNAL_FUNC int emstorage_get_mail_count(char *multi_user_name, int account_id, int mailbox_id, int *total, int *unseen, int transaction, int *err_code);
896 * emstorage_get_mail_by_id
898 * description : get mail from mail table by mail id
901 * mail : double pointer to hold mail
904 INTERNAL_FUNC int emstorage_get_mail_by_id(char *multi_user_name, int mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
906 #ifdef __FEATURE_BODY_SEARCH__
908 * emstorage_get_mail_text_by_id
910 * description : get mail_text from mail_text table by mail id
913 * mail_text : double pointer to hold mail_text
916 INTERNAL_FUNC int emstorage_get_mail_text_by_id(char *multi_user_name, int mail_id, emstorage_mail_text_tbl_t **mail_text, int transaction, int *err_code);
922 * description : get mail from mail table by mail sequence
924 * account_id : account id
925 * mailbox : mailbox name
926 * mail_no : mail sequence number (not mail id)
927 * mail : double pointer to hold mail
930 INTERNAL_FUNC int emstorage_get_mail_field_by_id(char *multi_user_name, int mail_id, int type, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
933 * emstorage_get_mail_field_by_multiple_mail_id
945 INTERNAL_FUNC int emstorage_get_mail_field_by_multiple_mail_id(char *multi_user_name, int mail_ids[], int number_of_mails, int type, emstorage_mail_tbl_t** mail, int transaction, int *err_code);
948 * emstorage_query_mail_count
950 * description : query mail count
952 INTERNAL_FUNC int emstorage_query_mail_count(char *multi_user_name, const char *input_conditional_clause, int input_transaction, int *output_total_mail_count, int *output_unseen_mail_count);
954 * emstorage_query_mail_list
956 * description : query mail id list
958 INTERNAL_FUNC int emstorage_query_mail_id_list(char *multi_user_name, const char *input_conditional_clause, int input_transaction, int **output_mail_id_list, int *output_mail_id_count);
962 * emstorage_query_mail_list
964 * description : query mail list information
966 INTERNAL_FUNC int emstorage_query_mail_list(char *multi_user_name, const char *conditional_clause, int transaction, email_mail_list_item_t** result_mail_list, int *result_count, int *err_code);
970 * emstorage_query_mail_tbl
972 * description : query mail table information
974 INTERNAL_FUNC int emstorage_query_mail_tbl(char *multi_user_name, const char *conditional_clause, int transaction, emstorage_mail_tbl_t** result_mail_tbl, int *result_count, int *err_code);
977 #ifdef __FEATURE_BODY_SEARCH__
979 * emstorage_query_mail_text_tbl
981 * description : query mail_text table information
983 INTERNAL_FUNC int emstorage_query_mail_text_tbl(char *multi_user_name, const char *conditional_clause, int transaction, emstorage_mail_text_tbl_t** result_mail_text_tbl, int *result_count, int *err_code);
987 * emstorage_query_mailbox_tbl
989 * description : query mail box table information
991 INTERNAL_FUNC int emstorage_query_mailbox_tbl(char *multi_user_name, const char *input_conditional_clause, const char *input_ordering_clause, int input_get_mail_count, int input_transaction, emstorage_mailbox_tbl_t **output_mailbox_list, int *output_mailbox_count);
994 * emstorage_get_mail_list
996 * description : search mail list information
998 INTERNAL_FUNC int emstorage_get_mail_list(char *multi_user_name, int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, int search_type, const char *search_value, email_sort_type_t sorting, int transaction, email_mail_list_item_t** mail_list, int *result_count, int *err_code);
1001 * emstorage_get_mails
1003 * description : search mail list information
1005 INTERNAL_FUNC int emstorage_get_mails(char *multi_user_name, int account_id, int mailbox_id, email_email_address_list_t* addr_list, int thread_id, int start_index, int limit_count, email_sort_type_t sorting, int transaction, emstorage_mail_tbl_t** mail_list, int *result_count, int *err_code);
1007 INTERNAL_FUNC int emstorage_get_searched_mail_list(char *multi_user_name, int account_id, int mailbox_id, int thread_id, int search_type, const char *search_value, int start_index, int limit_count, email_sort_type_t sorting, int transaction, email_mail_list_item_t **mail_list, int *result_count, int *err_code);
1009 INTERNAL_FUNC int emstorage_get_maildata_by_servermailid(char *multi_user_name, int mailbox_id, char *server_mail_id, emstorage_mail_tbl_t **mail, int transaction, int *err_code);
1011 INTERNAL_FUNC int emstorage_get_unread_mailid(char *multi_user_name, int account_id, int vip_mode, int **mail_ids, int *mail_number, int *err_code);
1013 INTERNAL_FUNC int emstorage_update_save_status(char *multi_user_name, int account_id, int *err_code);
1017 * Prepare mail search.
1019 * @param[in] search Specifies the searching condition.
1020 * @param[in] account_id Specifies the account id. if 0, all accounts.
1021 * @param[in] mailbox_id Specifies the mailbox ID. if NULL, all mailboxes.
1022 * @param[in] sorting Specifies the sorting condition.
1023 * @param[out] search_handle the searching handle is saved here.
1024 * @param[out] searched the result count is saved here.
1026 * @return This function returns 0 on success or error code on failure.
1028 INTERNAL_FUNC int emstorage_mail_search_start(char *multi_user_name,
1029 emstorage_search_filter_t *search,
1033 DB_STMT *search_handle,
1039 * emstorage_mail_search_result
1041 * description : retrieve mail as searching result
1043 * search_handle : handle to been gotten from emstorage_mail_search_start
1044 * mail : double pointer to hold mail
1047 INTERNAL_FUNC int emstorage_mail_search_result(DB_STMT search_handle,
1048 emstorage_mail_field_type_t type,
1054 * emstorage_mail_search_end
1056 * description : finish searching
1058 * search_handle : handle to be finished
1061 INTERNAL_FUNC int emstorage_mail_search_end(DB_STMT search_handle, int transaction, int *err_code);
1064 * emstorage_set_field_of_mails_with_integer_value
1066 * description : update a filed of mail
1068 * account_id : Specifies the account id.
1069 * mail_ids : mail id list to be changed
1070 * mail_ids_count : count of mail list
1071 * field_name : specified field name
1072 * value : specified value
1075 INTERNAL_FUNC int emstorage_set_field_of_mails_with_integer_value(char *multi_user_name, int account_id, int mail_ids[], int mail_ids_count, char *field_name, int value, int transaction, int *err_code);
1077 #ifdef __FEATURE_BODY_SEARCH__
1079 * emstorage_change_mail_text_field
1081 * description : update mail_text data
1084 * mail_text : mail_text pointer
1087 INTERNAL_FUNC int emstorage_change_mail_text_field(char *multi_user_name, int mail_id, emstorage_mail_text_tbl_t* mail_text, int transaction, int *err_code);
1091 * emstorage_change_mail_field
1093 * description : update partial mail data
1096 * type : changing type
1097 * mail : mail pointer
1100 INTERNAL_FUNC int emstorage_change_mail_field(char *multi_user_name, int mail_id, email_mail_change_type_t type, emstorage_mail_tbl_t *mail, int transaction, int *err_code);
1103 * emstorage_increase_mail_id
1105 * description : increase unique mail id
1107 * mail_id : pointer to store the unique id
1112 * emstorage_change_mail
1114 * description : update mail
1116 * mail_id : mail id to be changed
1117 * mail : mail pointer
1120 INTERNAL_FUNC int emstorage_change_mail(char *multi_user_name, int mail_id, emstorage_mail_tbl_t *mail, int transaction, int *err_code);
1122 INTERNAL_FUNC int emstorage_clean_save_status(char *multi_user_name, int save_status, int *err_code);
1124 INTERNAL_FUNC int emstorage_update_server_uid(char *multi_user_name, char *old_server_uid, char *new_server_uid, int *err_code);
1126 INTERNAL_FUNC int emstorage_increase_mail_id(char *multi_user_name, int *mail_id, int transaction, int *err_code);
1129 * emstorage_add_mail
1131 * description : add a mail to mail table
1133 * mail : mail pointer to be inserted
1134 * get_id : must get uinque id in function
1137 INTERNAL_FUNC int emstorage_add_mail(char *multi_user_name, emstorage_mail_tbl_t *mail, int get_id, int transaction, int *err_code);
1140 * emstorage_move_multiple_mails_on_db
1145 * input_mailbox_id :
1152 INTERNAL_FUNC int emstorage_move_multiple_mails_on_db(char *multi_user_name, int account_id, int input_mailbox_id, int mail_ids[], int number_of_mails, int transaction, int *err_code);
1155 * emstorage_delete_mail
1157 * description : delete mail from mail table
1159 * mail_id : mail id to be deleted. if 0, all mail will be deleted.
1160 * from_server : delete mail on server.
1163 INTERNAL_FUNC int emstorage_delete_mail(char *multi_user_name, int mail_id, int from_server, int transaction, int *err_code);
1166 * emstorage_delete_mail_by_account
1168 * description : delete mail from mail table by account id
1170 * account_id : account id.
1173 INTERNAL_FUNC int emstorage_delete_mail_by_account(char *multi_user_name, int account_id, int transaction, int *err_code);
1176 * emstorage_delete_mail_by_mailbox
1178 * description : delete mail from mail table
1183 INTERNAL_FUNC int emstorage_delete_mail_by_mailbox(char *multi_user_name, emstorage_mailbox_tbl_t *mailbox, int transaction, int *err_code);
1186 * emstorage_delete_multiple_mails
1196 INTERNAL_FUNC int emstorage_delete_multiple_mails(char *multi_user_name, int mail_ids[], int number_of_mails, int transaction, int *err_code);
1199 * emstorage_free_mail
1201 * description : free memory
1203 * mail_list : mail array
1204 * count : the number of array element
1207 INTERNAL_FUNC int emstorage_free_mail(emstorage_mail_tbl_t **mail_list, int count, int *err_code);
1209 #ifdef __FEATURE_BODY_SEARCH__
1211 * emstorage_free_mail_text
1213 * description : free memory
1215 * mail_list : mail_text array
1216 * count : the number of array element
1219 INTERNAL_FUNC void emstorage_free_mail_text(emstorage_mail_text_tbl_t** mail_text_list, int count, int *err_code);
1223 * emstorage_get_attachment
1225 * description : get attachment from attachment table
1228 * no : attachment sequence
1229 * attachment : double pointer to hold attachment data
1232 INTERNAL_FUNC int emstorage_get_attachment_count(char *multi_user_name, int mail_id, int *count, int transaction, int *err_code);
1235 * emstorage_get_attachment_list
1237 * description : get attachment list from attachment table
1239 * input_mail_id : mail id
1240 * input_transaction : transaction option
1241 * attachment_list : result attachment list
1242 * output_attachment_count : result attachment count
1243 * return : This function returns EMAIL_ERROR_NONE on success or error code (refer to EMAIL_ERROR__XXX) on failure.
1246 INTERNAL_FUNC int emstorage_get_attachment_list(char *multi_user_name, int input_mail_id, int input_transaction, emstorage_attachment_tbl_t** output_attachment_list, int *output_attachment_count);
1250 * emstorage_get_attachment
1252 * description : get attachment from attachment table
1254 * attachment_id : attachment id
1255 * attachment : double pointer to hold attachment data
1258 INTERNAL_FUNC int emstorage_get_attachment(char *multi_user_name, int attachment_id, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
1261 * emstorage_get_attachment
1263 * description : get nth-attachment from attachment table
1266 * nth : index of the desired attachment (min : 1)
1267 * attachment : double pointer to hold attachment data
1270 INTERNAL_FUNC int emstorage_get_attachment_nth(char *multi_user_name, int mail_id, int nth, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
1273 * emstorage_get_attachment
1275 * description : get attachment from attachment table
1277 * attachment_path : attachment path
1278 * attachment : double pointer to hold attachment data
1281 INTERNAL_FUNC int emstorage_get_attachment_by_attachment_path(char *multi_user_name, char *attachment_path, emstorage_attachment_tbl_t **attachment, int transaction, int *err_code);
1284 * emstorage_change_attachment_field
1286 * description : update partial mail attachment data
1289 * type : changing type
1290 * mail : mail pointer
1293 INTERNAL_FUNC int emstorage_change_attachment_field(char *multi_user_name, int mail_id, email_mail_change_type_t type, emstorage_attachment_tbl_t *attachment, int transaction, int *err_code);
1295 /* Get new attachment id */
1297 * emstorage_get_new_attachment_no
1299 * description : Get new attachment id
1301 * attachment_no : attachment id pointer
1304 INTERNAL_FUNC int emstorage_get_new_attachment_no(char *multi_user_name, int *attachment_no, int *err_code);
1306 /* insert attachment to mail attachment table */
1308 * emstorage_add_attachment
1310 * description : insert a attachment to attachment table
1312 * attachment : attachment pointer
1315 INTERNAL_FUNC int emstorage_add_attachment(char *multi_user_name, emstorage_attachment_tbl_t *attachment, int iscopy, int transaction, int *err_code);
1317 INTERNAL_FUNC int emstorage_update_attachment(char *multi_user_name, emstorage_attachment_tbl_t *attachment, int transaction, int *err_code);
1319 /* delete a mail from mail table */
1321 * emstorage_delete_attachment_on_db
1323 * description : delete attachment from attachment table
1325 * attachment_id : attachment id
1328 INTERNAL_FUNC int emstorage_delete_attachment_on_db(char *multi_user_name, int attachment_id, int transaction, int *err_code);
1330 INTERNAL_FUNC int emstorage_delete_all_attachments_of_mail(char *multi_user_name, int mail_id, int transaction, int *err_code);
1333 * emstorage_delete_attachment_all_on_db
1335 * description : delete attachment from mail table
1337 * account_id : account id.
1338 * mailbox : mail box
1341 INTERNAL_FUNC int emstorage_delete_attachment_all_on_db(char *multi_user_name, int account_id, char *mailbox, int transaction, int *err_code);
1344 * emstorage_free_attachment
1346 * description : free memory
1348 * mail_list : mail array
1349 * count : the number of array element
1352 INTERNAL_FUNC int emstorage_free_attachment(emstorage_attachment_tbl_t **attachment_list, int count, int *err_code);
1354 INTERNAL_FUNC int emstorage_is_mailbox_full(char *multi_user_name, int account_id, email_mailbox_t *mailbox, int *result, int *err_code);
1356 INTERNAL_FUNC int emstorage_get_max_mail_count();
1358 INTERNAL_FUNC int emstorage_mail_get_total_diskspace_usage(unsigned long *total_usage, int transaction, int *err_code);
1362 * begin a transaction.
1364 * @param[in] d1 Reserved.
1365 * @param[in] d2 Reserved.
1366 * @remarks emstorage_commit_transaction or emstorage_commit_transaction must be called after this function.
1367 * @return This function returns 0 on success or error code on failure.
1369 INTERNAL_FUNC int emstorage_begin_transaction(char *multi_user_name, void *d1, void *d2, int *err_code);
1372 * commit a transaction.
1374 * @param[in] d1 Reserved.
1375 * @param[in] d2 Reserved.
1377 * @return This function returns 0 on success or error code on failure.
1379 INTERNAL_FUNC int emstorage_commit_transaction(char *multi_user_name, void *d1, void *d2, int *err_code);
1384 * @param[in] d1 Reserved.
1385 * @param[in] d2 Reserved.
1387 * @return This function returns 0 on success or error code on failure.
1389 INTERNAL_FUNC int emstorage_rollback_transaction(char *multi_user_name, void *d1, void *d2, int *err_code);
1392 * clear mail data from db.
1394 * @param[in] transaction
1395 * @param[out] err_code
1397 * @return This function returns 0 on success or error code on failure.
1399 INTERNAL_FUNC int emstorage_clear_mail_data(char *multi_user_name, int transaction, int *err_code);
1402 INTERNAL_FUNC char *emstorage_make_directory_path_from_file_path(char *file_name);
1405 * emstorage_get_save_name
1407 * description : get file name for saving data
1409 * account_id : account id
1411 * atch_id : attachment id
1413 * name_buf : buffer to hold file name. (MAX : 512Bytes)
1416 INTERNAL_FUNC int emstorage_get_save_name(char *multi_user_name, int account_id, int mail_id, int atch_id, char *fname, char *move_buf, char *path_buf, int maxlen, int *err_code);
1419 * emstorage_get_dele_name
1421 * description : get a name for deleting contents from file system.
1423 * account_id : account id
1425 * atch_id : attachment id
1427 * name_buf : buffer to hold file name. (MAX : 512Bytes)
1430 INTERNAL_FUNC int emstorage_get_dele_name(char *multi_user_name, int account_id, int mail_id, int atch_id, char *fname, char *name_buf, int *err_code);
1433 * emstorage_create_dir
1435 * description : create directory
1437 * name_buf : buffer to hold file name. (MAX : 512Bytes)
1438 * no : attachment no.
1441 INTERNAL_FUNC int emstorage_create_dir(char *multi_user_name, int account_id, int mail_id, int atch_id, int *err_code);
1444 * emstorage_copy_file
1446 * description : copy a attachment file
1448 * src_file : source file
1449 * dst_file : destination file
1452 INTERNAL_FUNC int emstorage_copy_file(char *src_file, char *dst_file, int sync_file, int *err_code);
1455 * emstorage_move_file
1457 * description : move a file
1459 * src_file : source file
1460 * dst_file : destination file
1463 INTERNAL_FUNC int emstorage_move_file(char *src_file, char *dst_file, int sync_status, int *err_code);
1466 * emstorage_move_file
1468 * description : delete a file
1470 * src_file : file to be deleted
1473 INTERNAL_FUNC int emstorage_delete_file(char *src_file, int *err_code);
1476 * emstorage_delete_dir
1478 * description : delete a directory
1480 * src_dir : directory to be deleted
1483 INTERNAL_FUNC int emstorage_delete_dir(char *src_dir, int *err_code);
1487 INTERNAL_FUNC void emstorage_flush_db_cache();
1489 INTERNAL_FUNC int emstorage_test(char *multi_user_name, int mail_id, int account_id, char *full_address_to, char *full_address_cc, char *full_address_bcc, int *err_code);
1491 INTERNAL_FUNC int emstorage_get_sender_list(char *multi_user_name, int account_id, int mailbox_id, int search_type, const char *search_value, email_sort_type_t sorting, email_sender_list_t** sender_list, int *sender_count, int *err_code);
1493 INTERNAL_FUNC int emstorage_free_sender_list(email_sender_list_t **sender_list, int count);
1495 /* Handling Thread mail */
1496 INTERNAL_FUNC int emstorage_get_thread_information(char *multi_user_name, int thread_id, emstorage_mail_tbl_t **mail_table_data, int transaction, int *err_code);
1498 INTERNAL_FUNC int emstorage_get_thread_id_of_thread_mails(char *multi_user_name, emstorage_mail_tbl_t *mail_table_data, int *thread_id, int *result_latest_mail_id_in_thread, int *thread_item_count);
1500 INTERNAL_FUNC int emstorage_get_thread_id_by_mail_id(char *multi_user_name, int mail_id, int *thread_id, int *err_code);
1502 INTERNAL_FUNC int emstorage_update_latest_thread_mail(char *multi_user_name, int account_id, int mailbox_id, int thread_id, int *updated_thread_id, int latest_mail_id, int thread_item_count, int noti_type, int transaction, int *err_code);
1504 INTERNAL_FUNC int emstorage_get_thread_id_from_mailbox(char *multi_user_name, int account_id, int mailbox_id, char *mail_subject, int *thread_id, int *thread_item_count);
1506 INTERNAL_FUNC int emstorage_update_thread_id_of_mail(char *multi_user_name, int account_id, int mailbox_id, int mail_id, int thread_id, int thread_item_count, int transaction, int *err_code);
1508 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
1510 #define BULK_PARTIAL_BODY_DOWNLOAD_COUNT 10
1513 ACCOUNT_IDX_MAIL_PARTIAL_BODY_ACTIVITY_TBL = 0,
1514 MAIL_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
1515 SERVER_MAIL_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
1516 ACTIVITY_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
1517 ACTIVITY_TYPE_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
1518 MAILBOX_ID_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
1519 MAILBOX_NAME_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL,
1520 MULTI_USER_NAME_IDX_IN_MAIL_PARTIAL_BODY_ACTIVITY_TBL
1523 INTERNAL_FUNC int emstorage_get_pbd_activity_data(char *multi_user_name, int account_id, int input_mailbox_id, email_event_partial_body_thd** event_start, int *count, int transaction, int *err_code);
1525 INTERNAL_FUNC int emstorage_add_pbd_activity(char *multi_user_name, email_event_partial_body_thd *local_activity, int *activity_id, int transaction, int *err_code);
1527 INTERNAL_FUNC int emstorage_get_pbd_mailbox_list(char *multi_user_name, int account_id, int **mailbox_list, int *count, int transaction, int *err_code);
1529 INTERNAL_FUNC int emstorage_get_pbd_account_list(char *multi_user_name, int **account_list, int *count, int transaction, int *err_code);
1531 INTERNAL_FUNC int emstorage_get_pbd_activity_count(char *multi_user_name, int *activity_id_count, int transaction, int *err_code);
1533 INTERNAL_FUNC int emstorage_delete_full_pbd_activity_data(char *multi_user_name, int account_id, int transaction, int *err_code);
1535 INTERNAL_FUNC int emstorage_delete_pbd_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int transaction, int *err_code);
1537 INTERNAL_FUNC int emstorage_get_mailbox_pbd_activity_count(char *multi_user_name, int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code);
1539 INTERNAL_FUNC int emstorage_update_pbd_activity(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code);
1541 INTERNAL_FUNC int emstorage_create_file(char *buf, size_t file_size, char *dst_file, int *err_code);
1545 INTERNAL_FUNC int emstorage_free_address_info_list(email_address_info_list_t **address_info_list);
1547 INTERNAL_FUNC void emstorage_create_dir_if_delete();
1549 #ifdef __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
1550 INTERNAL_FUNC int emstorage_update_read_mail_uid_by_server_uid(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mbox_name, int *err_code);
1553 * @fn emstorage_get_id_set_from_mail_ids(int mail_ids[], int mail_id_count, email_id_set_t **server_uids, int *id_set_count, int *err_code);
1554 * Prepare an array of mail_id and corresponding server mail id.
1556 *@author h.gahlaut@samsung.com
1557 * @param[in] mail_ids Specifies the comma separated string of mail_ids. Maximaum size of string should be less than or equal to (QUERY_SIZE - 88)
1558 * where 88 is the length of fixed keywords including ending null character in the QUERY to be formed
1559 * @param[out] idset Returns the array of mail_id and corresponding server_mail_id sorted by server_mail_ids in ascending order
1560 * @param[out] id_set_count Returns the no. of cells in idset array i.e. no. of sets of mail_ids and server_mail_ids
1561 * @param[out] err_code Returns the error code.
1562 * @remarks An Example of Query to be exexuted in this API :
1563 * SELECT local_uid, server_uid from mail_read_mail_uid_tbl where local_uid in (12, 13, 56, 78);
1564 * @return This function returns true on success or false on failure.
1566 INTERNAL_FUNC int emstorage_get_id_set_from_mail_ids(char *multi_user_name, char *mail_ids, email_id_set_t **idset, int *id_set_count, int *err_code);
1571 * @fn emstorage_filter_mails_by_rule(int account_id, int dest_mailbox_id, int dst_mailbox_type, int reset, email_rule_t *rule, int **filtered_mail_id_list, int *count_of_mails, int err_code)
1572 * Move mails by specified rule for spam filtering.
1574 * @author kyuho.jo@samsung.com
1575 * @param[in] account_id Account id of the mails and the mailboxes.
1576 * @param[in] dest_mailbox_id Mailbox id of spam mailbox.
1577 * @param[in] dest_mailbox_type Mailbox id of spam mailbox.
1578 * @param[in] reset Tag id reset which when deleting the rule
1579 * @param[in] rule Filtering rule.
1580 * @param[out] filtered_mail_id_list Mail id list which are filtered by the rule.
1581 * @param[out] count_of_mails Count of mails which are filtered by the rule.
1582 * @param[out] err_code Returns the error code.
1585 * @return This function returns true on success or false on failure.
1587 INTERNAL_FUNC int emstorage_filter_mails_by_rule(char *multi_user_name, int account_id, int dest_mailbox_id, int dest_mailbox_type, int reset, emstorage_rule_tbl_t *rule, int **filtered_mail_id_list, int *count_of_mails, int *err_code);
1589 INTERNAL_FUNC int emstorage_update_tag_id(char *multi_user_name, int old_filter_id, int new_filter_id, int *err_code);
1591 INTERNAL_FUNC int emstorage_add_meeting_request(char *multi_user_name, int account_id, int input_mailbox_id, email_meeting_request_t *meeting_req, int transaction, int *err_code);
1593 INTERNAL_FUNC int emstorage_query_meeting_request(char *multi_user_name, const char *conditional_clause, email_meeting_request_t **output_meeting_req, int *output_result_count, int transaction);
1595 INTERNAL_FUNC int emstorage_get_meeting_request(char *multi_user_name, int mail_id, email_meeting_request_t **meeting_req, int transaction, int *err_code);
1597 INTERNAL_FUNC int emstorage_update_meeting_request(char *multi_user_name, email_meeting_request_t *meeting_req, int transaction, int *err_code);
1599 INTERNAL_FUNC int emstorage_delete_meeting_request(char *multi_user_name, int account_id, int mail_id, int input_mailbox_id, int transaction, int *err_code);
1601 INTERNAL_FUNC void emstorage_free_meeting_request(email_meeting_request_t *meeting_req);
1603 INTERNAL_FUNC int emstorage_write_conditional_clause_for_getting_mail_list(char *multi_user_name, email_list_filter_t *input_filter_list, int input_filter_count, email_list_sorting_rule_t *input_sorting_rule_list, int input_sorting_rule_count, int input_start_index, int input_limit_count, char **output_conditional_clause);
1605 INTERNAL_FUNC int emstorage_free_list_filter(email_list_filter_t **input_filter_list, int input_filter_count);
1607 #ifdef __FEATURE_LOCAL_ACTIVITY__
1609 *emstorage_get_next_activity_id
1611 *description : get an activity id for a new activity
1613 INTERNAL_FUNC int emstorage_get_next_activity_id(int *activity_id, int *err_code);
1616 *emstorage_get_activity_id_list
1617 *description : get the list of activity ids
1622 INTERNAL_FUNC int emstorage_get_activity_id_list(int account_id, int **activity_id_list, int *activity_count, int lowest_activity_type, int highest_activity_type, int transaction, int*err_code);
1624 * emstorage_add_activity
1626 * description : add an activity to activity table
1630 INTERNAL_FUNC int emstorage_add_activity(emstorage_activity_tbl_t *local_activity, int transaction, int *err_code);
1633 * emstorage_get_activity - Get the Local activity from the Mail activity table
1636 INTERNAL_FUNC int emstorage_get_activity(int account_id, int activity_id, emstorage_activity_tbl_t **activity_list, int *select_num, int transaction, int *err_code);
1639 * emstorage_delete_local_activity - Deletes the Local acitivity Generated based on activity_type
1640 * or based on server mail id
1643 INTERNAL_FUNC int emstorage_delete_local_activity(emstorage_activity_tbl_t *local_activity, int transaction, int *err_code);
1646 * emstorage_free_local_activity - Free the allocated Activity data
1650 INTERNAL_FUNC int emstorage_free_local_activity(emstorage_activity_tbl_t **local_activity_list, int count, int *err_code);
1653 * emstorage_free_activity_id_list - Free the allocated Activity List data
1657 INTERNAL_FUNC int emstorage_free_activity_id_list(int *activity_id_list, int *error_code);
1661 INTERNAL_FUNC int emstorage_add_certificate(char *multi_user_name, emstorage_certificate_tbl_t *certificate, int transaction, int *err_code);
1663 INTERNAL_FUNC int emstorage_free_certificate(emstorage_certificate_tbl_t **certificate_list, int count, int *err_code);
1665 INTERNAL_FUNC int emstorage_get_certificate_list(char *multi_user_name, int *select_num, emstorage_certificate_tbl_t **certificate_list, int transaction, int with_password, int *err_code);
1667 INTERNAL_FUNC int emstorage_get_certificate_by_email_address(char *multi_user_name, char *email_address, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code);
1669 INTERNAL_FUNC int emstorage_get_certificate_by_index(char *multi_user_name, int index, emstorage_certificate_tbl_t **certificate, int transaction, int with_password, int *err_code);
1671 INTERNAL_FUNC int emstorage_delete_certificate(char *multi_user_name, int index, int transaction, int *err_code);
1674 INTERNAL_FUNC int emstorage_add_task(char *multi_user_name, email_task_type_t input_task_type, email_task_priority_t input_task_priority, char *input_task_parameter, int input_task_parameter_length, int input_transaction, int *output_task_id);
1676 INTERNAL_FUNC int emstorage_delete_task(char *multi_user_name, int task_id, int transaction);
1678 INTERNAL_FUNC int emstorage_update_task_status(char *multi_user_name, int task_id, email_task_status_type_t task_status, int transaction);
1680 INTERNAL_FUNC int emstorage_query_task(char *multi_user_name, const char *input_conditional_clause, const char *input_ordering_clause, email_task_t **output_task_list, int *output_task_count);
1683 INTERNAL_FUNC int emstorage_check_and_update_server_uid_by_message_id(char *multi_user_name, int account_id, email_mailbox_type_e input_mailbox_type, char *message_id, char *server_uid, int *searched_mail_id);
1685 #ifdef __FEATURE_WIFI_AUTO_DOWNLOAD__
1686 INTERNAL_FUNC int emstorage_add_auto_download_activity(char *multi_user_name, email_event_auto_download *local_activity, int *activity_id, int transaction, int *err_code);
1687 INTERNAL_FUNC int emstorage_delete_auto_download_activity(char *multi_user_name, int account_id, int mail_id, int activity_id, int transaction, int *err_code);
1688 INTERNAL_FUNC int emstorage_delete_all_auto_download_activity(char *multi_user_name, int account_id, int transaction, int *err_code);
1689 INTERNAL_FUNC int emstorage_delete_auto_download_activity_by_mailbox(char *multi_user_name, int account_id, int mailbox_id, int transaction, int *err_code);
1690 INTERNAL_FUNC int emstorage_get_auto_download_activity(char *multi_user_name, int account_id, int input_mailbox_id, email_event_auto_download **event_start, int *count, int transaction, int *err_code);
1691 INTERNAL_FUNC int emstorage_get_auto_download_activity_count(char *multi_user_name, int *activity_count, int transaction, int *err_code);
1692 INTERNAL_FUNC int emstorage_get_auto_download_account_list(char *multi_user_name, int **account_list, int *count, int transaction, int *err_code);
1693 INTERNAL_FUNC int emstorage_get_auto_download_mailbox_list(char *multi_user_name, int account_id, int **mailbox_list, int *count, int transaction, int *err_code);
1694 INTERNAL_FUNC int emstorage_get_auto_download_activity_count_by_mailbox(char *multi_user_name, int account_id, int input_mailbox_id, int *activity_count, int transaction, int *err_code);
1695 INTERNAL_FUNC int emstorage_update_auto_download_activity(char *multi_user_name, char *old_server_uid, char *new_server_uid, char *mailbox_name, int mailbox_id, int *err_code);
1698 #ifdef __FEATURE_UPDATE_DB_TABLE_SCHEMA__
1699 INTERNAL_FUNC int emstorage_update_db_table_schema(char *multi_user_name);
1700 #endif /* __FEATURE_UPDATE_DB_TABLE_SCHEMA__ */
1704 #endif /* __cplusplus */
1706 #endif /* __EMAIL_STORAGE_H__ */