summaryrefslogtreecommitdiff
path: root/email-api/include/email-api-account.h
blob: 49c68e6dd64a091859b48973c2df5727d3f68a20 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
/*
*  email-service
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
* Contact: Kyuho Jo <kyuho.jo@samsung.com>, Sunghyun Kwon <sh0701.kwon@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/


#ifndef __EMAIL_API_ACCOUNT_H__
#define __EMAIL_API_ACCOUNT_H__

#include "email-types.h"

/**
* @defgroup EMAIL_SERVICE Email Service
* @{
*/


/**
* @ingroup EMAIL_SERVICE
* @defgroup EMAIL_API_ACCOUNT Email Account API
* @{
*/

/**
 *
 * This file contains the data structures and interfaces needed for application,
 * to interact with email-service.
 * @file		email-api-account.h
 * @author	Kyuho Jo <kyuho.jo@samsung.com>
 * @author	Sunghyun Kwon <sh0701.kwon@samsung.com>
 * @version	0.1
 * @brief 		This file contains the data structures and interfaces of Accounts provided by
 *			email-service .
 *
* @{

* @code
*	#include "emf_mapi_account.h"
*	 bool
*      	other_app_invoke_uniform_api_sample(int* error_code)
*	{
*	emf_account_t *account = NULL;
*	emf_account_t *new_account = NULL;
*
*	account = malloc(sizeof(emf_account_t));
*	memset(account, 0x00, sizeof(emf_account_t));
*
* 	account->account_bind_type      = 1;
*	account->retrieval_mode         = 1;
*	account->use_security           = 1;
*	account->sending_server_type    = EMF_SERVER_TYPE_SMTP;
*	account->sending_port_num       = EMF_SMTP_PORT;
*	account->sending_auth           = 1;
*	account->flag1 = 2;
*	account->account_bind_type      = 1;
*	account->account_name           = strdup("gmail");
*	account->display_name           = strdup("Tom");
*	account->email_addr             = strdup("tom@gmail.com");
*	account->reply_to_addr          = strdup("tom@gmail.com");
*	account->return_addr            = strdup("tom@gmail.com");
*	account->receiving_server_type  = EMF_SERVER_TYPE_POP3;
*	account->receiving_server_addr  = strdup("pop3.gmail.com");
*	account->port_num               = 995;
*	account->use_security           = 1;
*	account->retrieval_mode         = EMF_IMAP4_RETRIEVAL_MODE_ALL;
*	account->user_name              = strdup("tom");
*	account->password               = strdup("password");
*	account->sending_server_type    = EMF_SERVER_TYPE_SMTP;
*	account->sending_server_addr    = strdup("smtp.gmail.com");
*	account->sending_port_num       = 587;
*	account->sending_security       = 0x02;
*	account->sending_auth           = 1;
*	account->sending_user           = strdup("tom@gmail.com");
*	account->sending_password       = strdup("password");
*	account->pop_before_smtp        = 0;
*	account->apop                   = 0;
*	account->flag1                  = 2;
*	account->flag2                  = 1;
*	account->preset_account         = 1;
*	account->logo_icon_path         = strdup("Logo Icon Path");
*	account->target_storage         = 0;
*	account->options.priority = 3;
*	account->options.keep_local_copy = 0;
*	account->options.req_delivery_receipt = 0;
*	account->options.req_read_receipt = 0;
*	account->options.download_limit = 0;
*	account->options.block_address = 0;
*	account->options.block_subject = 0;
*	account->options.display_name_from = strdup("Display name from");
*	account->options.reply_with_body = 0;
*	account->options.forward_with_files = 0;
*	account->options.add_myname_card = 0;
*    	account->options.add_signature = 0;
*	account->options.signature= strdup("Signature");
*	account->check_interval = 0;
*	// Add account
*	if(EMF_ERROR_NONE != email_add_account(account))
*		//failure
*	//else
*	{
*		//success
*		if(account_id)
*			*account_id = account->account_id;
*	}
*	if(EMF_ERROR_NONE != email_validate_account(account_id,&account_handle))
*		//failure
*	else
*	      //success
*	if(EMF_ERROR_NONE != email_delete_account(account_id))
*		//failure
*	else
*		//success
*	new_account = malloc(sizeof(emf_account_t));
*	memset(new_account, 0x00, sizeof(emf_account_t));
*	new_account->flag1 = 1;
*	new_account->account_name           = strdup("samsung001");
*	new_account->display_name           = strdup("Tom001");
*	new_account->options.keep_local_copy = 1;
*	new_account->check_interval = 55;
*	// Update account
*	if(EMF_ERROR_NONE != email_update_account(acount_id,new_account))
*		//failure
*	else
*		//success
*	// Get account
*	if(EMF_ERROR_NONE != email_get_account(account_id,GET_FULL_DATA,&account))
*		//failure
*	else
*		//success
*	// Get list of accounts
*	if(EMF_ERROR_NONE != email_get_account_list(&account_list,&count))
*		//failure
*	else
*		//success
*	// free account
*	email_free_account(&account, 1);
*	}
 *
 * @endcode
 * @}
 */


#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */

/**
 * @open
 * @fn email_add_account(emf_account_t* account)
 * @brief	Create a new email account.This function is invoked when user wants to add new email account
 *
 * @param[in] account	Specifies the structure pointer of account.
 * @exception  none
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see         emf_account_t
 * @remarks N/A
 */
EXPORT_API int email_add_account(emf_account_t* account);

/**
 * @open
 * @fn email_delete_account(int account_id)
 * @brief	 Delete a email account.This function is invoked when user wants to delete an existing email account
 *
 * @param[in] account_id	Specifies the account ID.
 * @exception  #EMF_ERROR_INVALID_PARAM		-Invalid argument
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see
 * @remarks N/A
 */
EXPORT_API int email_delete_account(int account_id);

/**
 * @open
 * @fn email_update_account(int account_id, emf_account_t* new_account)
 * @brief	Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account.
 *
 * @param[in] account_id	Specifies the orignal account ID.
 * @param[in] new_account	Specifies the information of new account.
 * @param[in] with_validation	If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation.
 * @exception #EMF_ERROR_INVALID_PARAM      	-Invalid argument
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see emf_account_t
 * @remarks N/A
 */
EXPORT_API int email_update_account(int account_id, emf_account_t* new_account);

/**
 * @open
 * @fn email_update_account_with_validation(int account_id, emf_account_t* new_account)
 * @brief	Change the information of a email account.This function is getting invoked when user wants to change some information of existing email account.
 *
 * @param[in] account_id	Specifies the orignal account ID.
 * @param[in] new_account	Specifies the information of new account.
 * @param[in] with_validation	If this is 1, email-service will validate the account before updating. If this is 0, email-service will update the account without validation.
 * @exception #EMF_ERROR_INVALID_PARAM      	-Invalid argument
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see emf_account_t
 * @remarks N/A
 */
EXPORT_API int email_update_account_with_validation(int account_id, emf_account_t* new_account);

/**
 * @open
 * @fn  email_get_account(int account_id, int pulloption, emf_account_t** account)
 * @brief	Get an email account by ID. This function is getting invoked when user wants to get the account informantion based on account id and option (GET_FULL_DATA/WITHOUT_OPTION/ONLY_OPTION).<br>
 * 			Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account().
 *
 * @param[in] account_id	Specifies the account ID.This function is invoked when user
 * @param[in] pulloption	Option to specify to get full details or partial, see definition of EMF_ACC_GET_OPT_XXX
 * @param[out] account		The returned account is saved here.
 * @exception #EMF_ERR_INVALID_PARAM     	-Invalid argument
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see emf_account_t
 * @remarks N/A
 */

EXPORT_API int email_get_account(int account_id, int pulloption, emf_account_t** account);

/**
 * @open
 * @fn email_get_account_list(emf_account_t** account_list, int* count);
 * @brief	Get Account List.This function is getting invoked when user wants to get all account information based on the count of accounts provided by user.<br>
 * 			Memory for account information will be allocated to 3rd param(account). The allocated memory should be freed by email_free_account().
 *
 * @param[in] account_list	Specifies the structure pointer of account.
 * @param[out] count			Specifies the count of accounts.
 * @exception #EMF_ERR_INVALID_PARAM     	-Invalid argument
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see emf_account_t
 * @remarks N/A
 */
EXPORT_API int email_get_account_list(emf_account_t** account_list, int* count);

 /**
 * @open
 * @fn   email_free_account(emf_account_t** account_list, int count);
 * @brief	Free allocated memory.This function is getting invoked when user wants to delete all account information.
 *
 * @param[in] account_list	Specifies the structure pointer of account.
 * @param[out] count			Specifies the count of accounts.
 * @exception #EMF_ERR_INVALID_PARAM     	-Invalid argument
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see emf_account_t
 * @remarks N/A
 */
EXPORT_API int email_free_account(emf_account_t** account_list, int count);


/**
 * @open
 * @fn email_validate_account(int account_id, unsigned* handle)
 * @brief	Validate account.This function is getting invoked  after adding one account to validate it.If account is not validated then user should retry once again to add the account .
 *
 * @param[in] account_id	       Specifies the account Id to validate.
 * @param[out] handle 		Specifies the sending handle.
 * @remarks N/A
 * @exception #EMF_ERR_INVALID_PARAM     	-Invalid argument
 * @return This function returns EMF_ERROR_NONE on success or error code (refer to EMF_ERROR_XXX) on failure.
 * @see		none
 * @remarks N/A
 */
EXPORT_API int email_validate_account(int account_id, unsigned* handle);

/**
 * @open
 * @fn email_add_account_with_validation(emf_account_t* account, unsigned* handle)
 * @brief	Add an account when the account is validated. This function is getting invoked when user want to validate an account. If account is not validated then user should retry once again to add the account.<br>
 *              Validation is executed without saving an account to DB
 *
 * @param[in] account	    Specifies the structure pointer of account.
 * @param[out] handle 		Specifies the sending handle.
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_add_account_with_validation(emf_account_t* account, unsigned* handle);


/**
 * @open
 * @fn email_backup_accounts_into_secure_storage(const char *file_name)
 * @brief	Back up information of all accounts into secure storage.
 *          This function is getting invoked when user want to backup account information safely.
 *
 * @param[in] file_name	    Specifies the file name in secure storage
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_backup_accounts_into_secure_storage(const char *file_name);

/**
 * @open
 * @fn email_restore_accounts_from_secure_storage(const char *file_name)
 * @brief	Restore accounts from stored file in secure storage.
 *          This function is getting invoked when user want to restore accounts.
 *
 * @param[in] file_name	    Specifies the file name in secure storage
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_restore_accounts_from_secure_storage(const char * file_name);

/**
 * @open
 * @fn email_get_password_length_of_account(const int account_id, int *password_length)
 * @brief	Get password length of an account.
 *          This function is getting invoked when user want to know the length of an account.
 *
 * @param[in] account_id    Specifies the account id
 * @param[out] handle 		Specifies the password length.
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_get_password_length_of_account(const int account_id, int *password_length);


/**
 * @open
 * @fn email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info)
 * @brief	Query email server information.
 *          This function is getting invoked when user want to get email server information.
 *
 * @param[in] domain_name	        Specifies the domain name of server
 * @param[out] result_server_info 	Specifies the information of email server.
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_query_server_info(const char* domain_name, emf_server_info_t **result_server_info);

/**
 * @open
 * @fn email_free_server_info(emf_server_info_t **result_server_info)
 * @brief	Free emf_server_info_t.
 *          This function is getting invoked when user want to free emf_server_info_t.
 *
 * @param[in] result_server_info	Specifies the pointer of  in secure storage
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_free_server_info(emf_server_info_t **result_server_info);

/**
 * @open
 * @fn email_update_notification_bar(int account_id)
 * @brief	Update notifications on notification bar.
 *          This function is getting invoked when user want to update notification bar.
 *
 * @param[in] account_id	        Specifies the id of account.
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_update_notification_bar(int account_id);

/**
 * @open
 * @fn email_clear_all_notification_bar()
 * @brief	Clear all notification on notification bar.
 *          This function is getting invoked when user want to clear notification bar.
 *
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_clear_all_notification_bar();


/**
 * @open
 * @fn email_save_default_account_id()
 * @brief	Save default account id to vconf storage.
 *          This function is getting invoked when user want to save default account id.
 *
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_save_default_account_id(int input_account_id);

/**
 * @open
 * @fn email_load_default_account_id()
 * @brief	Load default account id to vconf storage.
 *          This function is getting invoked when user want to load default account id.
 *
 * @remarks N/A
 * @return This function returns true on success or false on failure.
 */
EXPORT_API int email_load_default_account_id(int *output_account_id);

#ifdef __cplusplus
}
#endif /* __cplusplus */

/**
* @} @}
*/

#endif /* __EMAIL_API_ACCOUNT_H__ */