4 * Copyright (c) 2000 - 2011 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-internal-types.h
25 * Desc : defines data structures and macros
30 * 2011.04.05 : created
31 *****************************************************************************/
32 #ifndef __EMAIL_INTERNAL_TYPES_H__
33 #define __EMAIL_INTERNAL_TYPES_H__
35 #include "email-types.h"
40 #endif /* __cplusplus */
43 #define INTERNAL_FUNC __attribute__((visibility("default")))
46 /* ----------------------------------------------------------------------------- */
47 /* Feature definitions */
48 #define __FEATURE_BACKUP_ACCOUNT__
49 #define __FEATURE_MOVE_TO_OUTBOX_FIRST__
50 /* #define __FEATURE_PARTIAL_BODY_FOR_POP3__ */
51 /* #define __FEATURE_KEEP_CONNECTION__ */
52 #define __FEATURE_DRM__
53 #define __FEATURE_PARTIAL_BODY_DOWNLOAD__
54 #define __FEATURE_HEADER_OPTIMIZATION__
55 #define __FEATURE_SEND_OPTMIZATION__
56 #define __FEATURE_DOWNLOAD_BODY_ATTACHMENT_OPTIMIZATION__
57 #define __FEATURE_BULK_DELETE_MOVE_UPDATE_REQUEST_OPTI__
58 #define __FEATURE_SYNC_CLIENT_TO_SERVER__
59 #define __FEATURE_AUTO_POLLING__
60 #define __FEATURE_DEBUG_LOG__
61 #define __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__
62 #define __FEATURE_XLIST_SUPPORT__
63 /* #define __FEATURE_USE_SHARED_MUTEX_FOR_PROTECTED_FUNC_CALL__ */
64 /* #define __FEATURE_IMAP_IDLE__ */
66 /* ----------------------------------------------------------------------------- */
69 #define NULL (char *)0
73 #define IMAP_2004_LOG 1
75 #define MAILBOX_COUNT 6
76 #define PARTIAL_DOWNLOAD_SIZE 1024
77 #define PARTIAL_BODY_SIZE_IN_BYTES 15360 /* Partial Body download - 15K */
78 #define NO_LIMITATION 0
79 #define MAX_MAILBOX_TYPE 100
80 #define EMAIL_SYNC_ALL_MAILBOX 1
81 #define EMAIL_ATTACHMENT_MAX_COUNT 512
82 #define DOWNLOAD_MAX_BUFFER_SIZE 8000
83 #define LOCAL_MAX_BUFFER_SIZE 1000000
84 #define IMAP_MAX_COMMAND_LENGTH 1000
85 #define DOWNLOAD_NOTI_INTERVAL_PERCENT 5 /* notify every 5% */
86 #define DOWNLOAD_NOTI_INTERVAL_SIZE 51200 /* notify every 50k */
87 #define MAX_PATH 4096 /* /usr/src/linux-2.4.20-8/include/linux/limits.h */
88 #define DATETIME_LENGTH 16
89 #define MAIL_ID_STRING_LENGTH 10
90 #define EMAIL_LIMITATION_FREE_SPACE (5) /* This value is 5MB */
91 #define EMAIL_MAIL_MAX_COUNT 5000
92 #define HTML_EXTENSION_STRING ".htm"
93 #define MAX_PATH_HTML 256
95 #define DIR_SEPERATOR "/"
97 #define DATA_PATH "/opt/data"
98 #define DB_PATH "/opt/dbspace"
99 #define EMAIL_SERVICE_DB_FILE_PATH "/opt/dbspace/.email-service.db"
101 #define EMAILPATH DATA_PATH"/email"
102 #define MAILHOME DATA_PATH"/email/.emfdata"
103 #define DIRECTORY_PERMISSION 0755
105 #define MIME_SUBTYPE_DRM_OBJECT "vnd.oma.drm.message"
106 #define MIME_SUBTYPE_DRM_RIGHTS "vnd.oma.drm.rights+xml"
107 #define MIME_SUBTYPE_DRM_DCF "vnd.oma.drm.dcf"
109 #define SHM_FILE_FOR_DB_LOCK "/.email_shm_db_lock"
111 #define NATIVE_EMAIL_APPLICATION_PKG "org.tizen.email"
113 #ifdef __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__
114 #define SHM_FILE_FOR_MAIL_ID_LOCK "/.email_shm_mail_id_lock"
115 #endif /* __FEATURE_USE_SHARED_MUTEX_FOR_GENERATING_MAIL_ID__ */
121 #define NULL_CHAR '\0'
122 #define TAB_STRING "\t"
123 #define CR_STRING "\r"
124 #define LF_STRING "\n"
125 #define CRLF_STRING "\r\n"
127 #define GRAB_TYPE_TEXT 1 /* retrieve text and attachment list */
128 #define GRAB_TYPE_ATTACHMENT 2 /* retrieve attachment */
130 #define SAVE_TYPE_SIZE 1 /* only get content size */
131 #define SAVE_TYPE_BUFFER 2 /* save content to buffer */
132 #define SAVE_TYPE_FILE 3 /* save content to temporary file */
134 #define FINISH_OFF_IF_CANCELED if (!emcore_check_thread_status()) { err = EMAIL_ERROR_CANCELLED; goto FINISH_OFF; }
135 #define CHECK_JOB_CANCELED() {if (!emcore_check_thread_status()) goto JOB_CANCEL; }
137 #define SNPRINTF(buff, size, format, args...) snprintf(buff, size, format, ##args)
138 #define SNPRINTF_OFFSET(base_buf, offset, base_size, format, args...) \
140 int _offset = offset;\
141 snprintf(base_buf + _offset, base_size - _offset - 1, format, ##args);\
144 #define THREAD_CREATE(tv, func, param, err) { EM_DEBUG_LOG("THREAD_CREATE "#tv); err = pthread_create(&tv, NULL, func, param); }
145 #define THREAD_CREATE_JOINABLE(tv, func, err) { pthread_attr_t attr; EM_DEBUG_LOG("THREAD_CREATE_JOINABLE "#tv); \
146 pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);\
147 err = pthread_create(&tv, &attr, func, NULL); pthread_attr_destroy(&attr); }
148 #define THREAD_JOIN(tv) {EM_DEBUG_LOG("THREAD_JOIN "#tv); pthread_join(tv, NULL); }
149 #define THREAD_SELF() pthread_self()
150 #define THREAD_DETACH(tv) pthread_detach(tv)
151 #define INITIALIZE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("INITIALIZE_CRITICAL_SECTION "#cs); pthread_mutex_init(&cs, NULL); }
152 #define ENTER_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("ENTER_CRITICAL_SECTION "#cs); pthread_mutex_lock(&cs); }
153 #define TRY_ENTER_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("TRY_ENTER_CRITICAL_SECTION "#cs); pthread_mutex_trylock(&cs); }
154 #define LEAVE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("LEAVE_CRITICAL_SECTION "#cs); pthread_mutex_unlock(&cs); }
155 #define DELETE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("DELETE_CRITICAL_SECTION "#cs); pthread_mutex_destroy(&cs); }
157 #define INITIALIZE_CONDITION_VARIABLE(cv) {EM_DEBUG_LOG("INITIALIZE_CONDITION_VARIABLE "#cv); pthread_cond_init(&cv, NULL); }
158 #define SLEEP_CONDITION_VARIABLE(cv, cs) {EM_DEBUG_LOG("SLEEP_CONDITION_VARIABLE "#cv); pthread_cond_wait(&cv, &cs); }
159 #define WAKE_CONDITION_VARIABLE(cv) {EM_DEBUG_LOG("WAKE_CONDITION_VARIABLE "#cv); pthread_cond_signal(&cv); }
160 #define DELETE_CONDITION_VARIABLE(cv) {EM_DEBUG_LOG("DELETE_CONDITION_VARIABLE "#cv); pthread_cond_destroy(&cv); }
162 #define INITIALIZE_RECURSIVE_CRITICAL_SECTION(cs) { EM_DEBUG_LOG("INITIALIZE_RECURSIVE_CRITICAL_SECTION "#cs); \
163 if (cs == NULL) {pthread_mutex_lock(&_send_event_available_lock); pthread_mutexattr_t attr; cs = (pthread_mutex_t *)malloc(sizeof(pthread_mutex_t));\
164 pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP);\
165 pthread_mutex_init(cs, &attr);pthread_mutexattr_destroy(&attr); pthread_mutex_unlock(&_send_event_available_lock);}}
166 #define ENTER_RECURSIVE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("ENTER_RECURSIVE_CRITICAL_SECTION "#cs); if(cs) pthread_mutex_lock(cs);}
167 #define TRY_ENTER_RECURSIVE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("TRY_ENTER_RECURSIVE_CRITICAL_SECTION "#cs); if(cs) pthread_mutex_trylock(cs);}
168 #define LEAVE_RECURSIVE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("LEAVE_RECURSIVE_CRITICAL_SECTION "#cs); if(cs) pthread_mutex_unlock(cs);}
169 #define DELETE_RECURSIVE_CRITICAL_SECTION(cs) {EM_DEBUG_LOG("DELETE_RECURSIVE_CRITICAL_SECTION "#cs); if(cs) pthread_mutex_destroy(cs);}
170 typedef pthread_t thread_t;
172 #define SMTP_RESPONSE_OK 250
173 #define SMTP_RESPONSE_READY 354
174 #define SMTP_RESPONSE_WANT_AUTH 505
175 #define SMTP_RESPONSE_WANT_AUTH2 530
176 #define SMTP_RESPONSE_UNAVAIL 550
178 #define VCONF_KEY_DEFAULT_SLOT_SIZE "db/private/email-service/slot_size"
179 #define VCONF_KEY_LATEST_MAIL_ID "db/private/email-service/latest_mail_id"
180 #define VCONF_KEY_DEFAULT_ACCOUNT_ID "db/private/email-service/default_account_id"
182 /* ----------------------------------------------------------------------------- */
186 _SERVICE_THREAD_TYPE_NONE = 0,
187 _SERVICE_THREAD_TYPE_RECEIVING = 1,
188 _SERVICE_THREAD_TYPE_SENDING = 2,
189 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
190 _SERVICE_THREAD_TYPE_PBD = 3,
191 #endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */
192 } email_service_thread_type;
197 EMAIL_PROTOCOL_NONE = 0,
198 EMAIL_PROTOCOL_POP3 = 1,
199 EMAIL_PROTOCOL_IMAP = 2,
200 EMAIL_PROTOCOL_SMTP = 3,
201 } email_protocol_type_t;
205 ACCOUNT_SVC_SYNC_STATUS_RUNNING = 0,
206 ACCOUNT_SVC_SYNC_STATUS_IDLE = 1,
207 ACCOUNT_SVC_SYNC_STATUS_OFF = 2,
208 } email_account_svc_sync_status;
214 SET_TYPE_INTERSECT = 4 /* Not supported */
217 #ifdef __FEATURE_KEEP_CONNECTION__
220 EMAIL_STREAM_STATUS_DISCONNECTED = 0,
221 EMAIL_STREAM_STATUS_CONNECTED = 1
223 #endif /* __FEATURE_KEEP_CONNECTION__ */
225 /* event information */
228 int account_id; /* in general, account id */
229 email_event_type_t type;
230 email_event_status_type_t status;
231 char *event_param_data_1; /* in general, mailbox name (exception in emcore_send_mail, emcore_send_saved_mail it is email_option_t **/
232 char *event_param_data_2;
233 char *event_param_data_3;
234 int event_param_data_4;
235 int event_param_data_5;
236 int event_param_data_6; /* in general, notification parameter #1 */
237 int event_param_data_7; /* in general, notification parameter #2 */
238 int event_param_data_8;
246 } email_callback_holder_t;
249 typedef struct email_search_key_t email_search_key_t;
250 struct email_search_key_t
254 email_search_key_t *next;
260 email_protocol_type_t protocol;
270 int mailbox_id; /**< Unique id on mailbox table.*/
271 char *mailbox_name; /**< Specifies the path of mailbox.*/
272 email_mailbox_type_e mailbox_type; /**< Specifies the type of mailbox */
273 char *alias; /**< Specifies the display name of mailbox.*/
274 int unread_count; /**< Specifies the Unread Mail count in the mailbox.*/
275 int total_mail_count_on_local; /**< Specifies the total number of mails in the mailbox in the local DB.*/
276 int total_mail_count_on_server; /**< Specifies the total number of mails in the mailbox in the mail server.*/
277 int local; /**< Specifies the local mailbox.*/
278 int synchronous; /**< Specifies the mailbox with synchronized the server.*/
279 int account_id; /**< Specifies the account ID for mailbox.*/
280 int has_archived_mails; /**< Specifies the archived mails.*/
281 int mail_slot_size; /**< Specifies how many mails can be stored in local mailbox.*/
282 void *user_data; /**< Specifies the internal data.*/
283 void *mail_stream; /**< Specifies the internal data.*/
284 } email_internal_mailbox_t;
286 #ifdef __FEATURE_KEEP_CONNECTION__
287 typedef struct email_connection_info
290 int sending_server_stream_status;
291 void *sending_server_stream;
292 int receiving_server_stream_status;
293 void *receiving_server_stream;
294 struct email_connection_info *next;
295 } email_connection_info_t;
296 #endif /* __FEATURE_KEEP_CONNECTION__ */
305 } email_mail_contact_info_t;
307 /* global account lis */
308 typedef struct email_account_list
310 email_account_t *account;
311 struct email_account_list *next;
312 } email_account_list_t;
314 typedef void (*email_event_callback)(int total, int done, int status, int account_id, int mail_id, int handle, void *user_data, int error);
316 /* ----------------------------------------------------------------------------- */
317 /* Please contact Himanshu [h.gahlaut@samsung.com] for any explanation in code here under __FEATURE_PARTIAL_BODY_DOWNLOAD__ MACRO */
318 #ifdef __FEATURE_PARTIAL_BODY_DOWNLOAD__
321 ACTIVITY_PARTIAL_BODY_DOWNLOAD_IMAP4 = 1,
322 ACTIVITY_PARTIAL_BODY_DOWNLOAD_POP3_WAIT,
323 ACTIVITY_PARTIAL_BODY_DOWNLOAD_POP3_ACTIVE
324 } email_pdb_activity_type_e;
330 unsigned long server_mail_id;
334 email_event_type_t event_type; /* Event Type Null means event is created from local activitys */
335 int activity_type; /* Activity Type Null means event is created from event queue */
337 } email_event_partial_body_thd;
338 #endif /* __FEATURE_PARTIAL_BODY_DOWNLOAD__ */
342 #endif /* __cplusplus */
344 #endif /* __EMAIL_INTERNAL_TYPES_H__ */