Add permission check for open handle
[platform/core/messaging/msg-service.git] / include / mapi / msg_storage.h
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd. All rights reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15 */
16
17 #ifndef MAPI_STORAGE_H
18 #define MAPI_STORAGE_H
19
20 /*==================================================================================================
21                                          INCLUDE FILES
22 ==================================================================================================*/
23
24 #include "msg_storage_types.h"
25
26 #ifdef __cplusplus
27 extern "C"
28 {
29 #endif
30
31
32 /**
33  * @ingroup MSG_SERVICE_FRAMEWORK
34  * @defgroup MSG_SERVICE_FRAMEWORK_STORAGE_MODULE Storage API
35  * @brief The Storage API provides functions to get message information with multiple types.
36  *
37  * @addtogroup MSG_SERVICE_FRAMEWORK_STORAGE_MODULE
38  * @{
39  *
40  * @section MSG_SERVICE_FRAMEWORK_STORAGE_MODULE_HEADER Required Header
41  *   \#include <msg_storage.h>
42  *
43  * @section MSG_SERVICE_FRAMEWORK_STORAGE_MODULE_OVERVIEW Overview
44  *
45  * The Storage API provides the following functionalities:
46  *
47  * - Get message information
48  *
49  * @section MSG_SERVICE_FRAMEWORK_STORAGE_MODULE_FEATURE Related Features
50  * This API is related with the following features:\n
51  *  - http://tizen.org/feature/network.telephony\n
52  *  - http://tizen.org/feature/network.telephony.sms\n
53  *
54  * It is recommended to design feature related codes in your application for reliability.\n
55  *
56  * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
57  *
58  * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n
59  *
60  * More details on featuring your application can be found from <a href="../org.tizen.mobile.native.appprogramming/html/ide_sdk_tools/feature_element.htm"><b>Feature Element</b>.</a>
61  *
62  */
63
64
65 /*==================================================================================================
66                                      FUNCTION PROTOTYPES
67 ==================================================================================================*/
68
69 /**
70  * @brief Saves a message to the database.
71  *
72  * @since_tizen 2.3
73  * @privlevel public
74  * @privilege %http://tizen.org/privilege/message.write
75  *
76  * @remarks Mandatory fields of a message structure MUST be valid, otherwise the function will fail.
77  *
78  * @param[in] handle    The Message handle
79  * @param[in] msg       A pointer to a message structure
80  * @param[in] send_opt  A pointer to a message structure for sending option
81  *
82  * @return  The message ID on success,
83  *       otherwise a negative error value
84  *
85  * @retval MESSAGE_ID                    Success in operation
86  * @retval MSG_ERR_INVALID_PARAMETER(-9) Invalid parameter
87  * @retval MSG_ERR_STORAGE_ERROR         Storage error
88  * @retval MSG_ERR_PERMISSION_DENIED     The application does not have the privilege to call this method
89  * @retval MSG_ERR_NOT_SUPPORTED         Not supported
90  */
91
92 int msg_add_message(msg_handle_t handle, const msg_struct_t msg, const msg_struct_t send_opt);
93
94
95 /**
96  * @brief Adds a SyncML message to the database.
97  *
98  * @since_tizen 2.3
99  * @privlevel public
100  * @privilege %http://tizen.org/privilege/message.write
101  *
102  * @remarks Mandatory fields of a message structure MUST be valid, otherwise the function will fail.
103  *
104  * @param[in] handle      The Message handle
105  * @param[in] syncml_msg  A pointer to a syncml message structure
106  *
107  * @return  @c 0 on success,
108  *        otherwise a negative error value
109  *
110  * @retval MSG_SUCCESS               Success in operation
111  * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid
112  * @retval MSG_ERR_STORAGE_ERROR     Storage error
113  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
114  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
115  */
116
117 int msg_add_syncml_message(msg_handle_t handle, const msg_struct_t syncml_msg);
118
119
120 /**
121  * @brief Updates a message in the database.
122  *
123  * @since_tizen 2.3
124  * @privlevel public
125  * @privilege %http://tizen.org/privilege/message.write
126  *
127  * @remarks The function is to update message data for the message identified by the given msgId as long as the given values are valid.
128  * @remarks Message ID MUST NOT be updated because that is a unique ID on platform.
129  * @remarks If applications want to move a message between folders, applications SHOULD call msg_move_to_folder().
130  * @remarks Storage ID MUST NOT be updated.
131  * @remarks If applications want to move the message between storages, applications SHOULD call msg_move_to_storage().
132  *
133  * @param[in] handle   The Message handle
134  * @param[in] msg      A pointer to a message structure
135  * @param[in] send_opt A pointer to a message sending option structure
136  *
137  * @return  @c 0 on success,
138  *        otherwise a negative error value
139  *
140  * @retval MSG_SUCCESS               Success in operation
141  * @retval MSG_ERR_INVALID_PARAMETER Input parameter is invalid
142  * @retval MSG_ERR_STORAGE_ERROR     Storage error
143  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
144  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
145  */
146
147 int msg_update_message(msg_handle_t handle, const msg_struct_t msg, const msg_struct_t send_opt);
148
149
150 /**
151  * @brief Updates a message's read status in the database.
152  *
153  * @since_tizen 2.3
154  * @privlevel public
155  * @privilege %http://tizen.org/privilege/message.write
156  *
157  * @param[in] handle  The message handle
158  * @param[in] msg_id  The message ID
159  * @param[in] read    Set @c true if the message is read,
160  *                    otherwise set @c false if the message is not read
161  *
162  * @return  @c 0 on success,
163  *        otherwise a negative error value
164  *
165  * @retval MSG_SUCCESS               Success in operation
166  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
167  * @retval MSG_ERR_STORAGE_ERROR     Storage error
168  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
169  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
170  */
171
172 int msg_update_read_status(msg_handle_t handle, msg_message_id_t msg_id, bool read);
173
174
175 /**
176  * @brief Updates a message's protected status in the database.
177  *
178  * @since_tizen 2.3
179  * @privlevel public
180  * @privilege %http://tizen.org/privilege/message.write
181  *
182  * @param[in] handle        The message handle
183  * @param[in] msg_id        The message ID
184  * @parem[in] is_protected  Set @c true if a message is protected,
185  *                          otherwise set @c false if message is not protected
186  *
187  * @return  @c 0 on success,
188  *        otherwise a negative error value
189  *
190  * @retval MSG_SUCCESS               Success in operation
191  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
192  * @retval MSG_ERR_STORAGE_ERROR     Storage error
193  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
194  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
195  */
196
197 int msg_update_protected_status(msg_handle_t handle, msg_message_id_t msg_id, bool is_protected);
198
199
200 /**
201  * @brief Deletes a message by Message ID from the database.
202  *
203  * @since_tizen 2.3
204  * @privlevel public
205  * @privilege %http://tizen.org/privilege/message.write
206  *
207  * @param[in] handle  The message handle
208  * @param[in] msg_id  The message ID of the message to be deleted
209  *
210  * @return  @c 0 on success,
211  *        otherwise a negative error value
212  *
213  * @retval MSG_SUCCESS               Success in operation
214  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
215  * @retval MSG_ERR_STORAGE_ERROR     Storage error
216  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
217  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
218  */
219
220 int msg_delete_message(msg_handle_t handle, msg_message_id_t msg_id);
221
222
223 /**
224  * @brief Deletes all messages in the specified folder from the database.
225  *
226  * @since_tizen 2.3
227  * @privlevel public
228  * @privilege %http://tizen.org/privilege/message.write
229  *
230  * @param[in] handle   Message handle
231  * @param[in] msg_id   Message ID of the message to be deleted
232  * @param[in] bOnlyDB  Set @c true to not delete messages in SIM,
233  *                     otherwise set @c false to delete messages in SIM
234  *
235  * @return  @c 0 on success,
236  *        otherwise a negative error value
237  *
238  * @retval MSG_SUCCESS               Success in operation
239  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
240  * @retval MSG_ERR_STORAGE_ERROR     Storage error
241  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
242  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
243  */
244
245 int msg_delete_all_msgs_in_folder(msg_handle_t handle, msg_folder_id_t folder_id, bool bOnlyDB);
246
247
248
249 /**
250  * @brief Moves a message to the specified folder in the database.
251  *
252  * @since_tizen 2.3
253  * @privlevel public
254  * @privilege %http://tizen.org/privilege/message.write
255  *
256  * @param[in] handle         The message handle
257  * @param[in] msg_id         The message ID of the message to be moved
258  * @param[in] dest_folder_id The ID of the destination folder
259  *
260  * @return  @c 0 on success,
261  *        otherwise a negative error value
262  *
263  * @retval MSG_SUCCESS               Success in operation
264  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
265  * @retval MSG_ERR_STORAGE_ERROR     Storage error
266  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
267  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
268  */
269
270 int msg_move_msg_to_folder(msg_handle_t handle, msg_message_id_t msg_id, msg_folder_id_t dest_folder_id);
271
272
273 /**
274  * @brief Moves a message to the other storage.
275  *
276  * @since_tizen 2.3
277  * @privlevel public
278  * @privilege %http://tizen.org/privilege/message.write
279  *
280  * @param[in] handle      The message handle
281  * @param[in] msg_id      The message ID of the message to be moved
282  * @param[in] storage_id  The ID of the destination storage
283  *
284  * @return  @c 0 on success,
285  *        otherwise a negative error value
286  *
287  * @retval MSG_SUCCESS               Success in operation
288  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
289  * @retval MSG_ERR_STORAGE_ERROR     Storage error
290  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
291  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
292  */
293
294 int msg_move_msg_to_storage(msg_handle_t handle, msg_message_id_t msg_id, msg_storage_id_t storage_id);
295
296
297 /**
298  * @brief Gets the number of messages in the specified folder from the database.
299  *
300  * @since_tizen 2.3
301  * @privlevel public
302  * @privilege %http://tizen.org/privilege/message.read
303  *
304  * @param[in]  handle      The message handle
305  * @param[in]  msg_id      The message ID of the message to be counted
306  * @param[out] count_info  A pointer to an #MSG_COUNT_INFO_S structure
307  *
308  * @return  @c 0 on success,
309  *        otherwise a negative error value
310  *
311  * @retval MSG_SUCCESS               Success in operation
312  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
313  * @retval MSG_ERR_STORAGE_ERROR     Storage error
314  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
315  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
316  */
317
318 int msg_count_message(msg_handle_t handle, msg_folder_id_t folder_id, msg_struct_t count_info);
319
320
321 /**
322  * @brief Gets the number of messages of specific message type.
323  *
324  * @since_tizen 2.3
325  * @privlevel public
326  * @privilege %http://tizen.org/privilege/message.read
327  *
328  * @param[in]  handle     The message handle
329  * @param[in]  msg_type   The message type to be counted
330  * @param[out] msg_count  A pointer to the number of message
331  *
332  * @return  @c 0 on success,
333  *        otherwise a negative error value
334  *
335  * @retval MSG_SUCCESS               Success in operation
336  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
337  * @retval MSG_ERR_STORAGE_ERROR     Storage error
338  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
339  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
340  */
341
342 int msg_count_msg_by_type(msg_handle_t handle, msg_message_type_t msg_type, int *msg_count);
343
344
345 /**
346  * @brief Gets the number of messages of specific address.
347  *
348  * @since_tizen 2.3
349  * @privlevel public
350  * @privilege %http://tizen.org/privilege/message.read
351  *
352  * @remarks If @a addr_info is @c NULL, nothing happens.
353  *
354  * @param[in] handle                 The message handle
355  * @param[in] addr_info              A pointer to an address list information structure
356  * @param[in] msg_thread_count_list  A pointer to an thread count information structure
357  *
358  * @return  @c 0 on success,
359  *        otherwise a negative error value
360  *
361  * @retval MSG_SUCCESS               Success in operation
362  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
363  * @retval MSG_ERR_STORAGE_ERROR     Storage error
364  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
365  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
366  */
367
368 int msg_count_msg_by_contact(msg_handle_t handle, const msg_struct_t addr_info, msg_struct_t msg_thread_count_list);
369
370
371 /**
372  * @brief Gets the detail information of a message from the database.
373  * @details This API is used to get the detail information of message by message ID.
374  *
375  * @since_tizen 2.3
376  * @privlevel public
377  * @privilege %http://tizen.org/privilege/message.read
378  *
379  * @remarks Applications need to call msg_release_struct() to free the memory.
380  * @remarks However, if this function fails, the memory for the message is NOT allocated in this function.
381  *
382  * @param[in]  handle    The Message handle
383  * @param[in]  msg_id    The ID of the Message to be returned
384  * @param[out] msg       A pointer to a #msg_struct_t message structure
385  * @param[in]  send_opt  A pointer to a #msg_struct_t sending option structure
386  *
387  * @return  @c 0 on success,
388  *        otherwise a negative error value
389  *
390  * @retval MSG_SUCCESS               Success in operation
391  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
392  * @retval MSG_ERR_STORAGE_ERROR     Storage error
393  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
394  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
395  */
396
397 int msg_get_message(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t msg, msg_struct_t send_opt);
398
399
400 /**
401  * @brief Gets the detail information of a message on conversation list.
402  * @details This API is used to get the conversation informations of message by message ID.
403  *
404  * @since_tizen 2.3
405  * @privlevel public
406  * @privilege %http://tizen.org/privilege/message.read
407  *
408  * @param[in]  handle  The Message handle
409  * @param[in]  msg_id  The ID of the Message to be returned
410  * @param[out] conv    A pointer to a #msg_struct_t of message structure
411  *
412  * @return  @c 0 on success,
413  *        otherwise a negative error value
414  *
415  * @retval MSG_SUCCESS               Success in operation
416  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
417  * @retval MSG_ERR_STORAGE_ERROR     Storage error
418  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
419  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
420  */
421
422 int msg_get_conversation(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_t conv);
423
424
425 /**
426  * @brief Gets the v-object data of message.
427  * @details This API is used to get the v-object data of message by message ID.
428  *
429  * @since_tizen 2.3
430  * @privlevel public
431  * @privilege %http://tizen.org/privilege/message.read
432  *
433  * @param[in]  handle        The Message handle
434  * @param[in]  msg_id        The ID of the Message to be returned
435  * @param[out] encoded_data  A pointer to a encoded v-object data of message
436  *
437  * @return  @c 0 on success,
438  *        otherwise a negative error value
439  *
440  * @retval MSG_SUCCESS               Success in operation
441  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
442  * @retval MSG_ERR_STORAGE_ERROR     Storage error
443  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
444  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
445  */
446
447 int msg_get_vobject_data(msg_handle_t handle, msg_message_id_t msg_id, void** encoded_data);
448
449
450 /**
451  * @brief Gets the information of all peers to whom messages have been sent or received.
452  *
453  * @since_tizen 2.3
454  * @privlevel public
455  * @privilege %http://tizen.org/privilege/message.read
456  *
457  * @remarks The memory for a list will be allocated in this function.
458  * @remarks Applications need to call msg_release_thread_view_list() to free the memory.
459  * @remarks However, if this function fails, the memory for a list is NOT allocated in this function.
460  *
461  * @param[in]  handle                The Message handle
462  * @param[in]  sourt_rule            This indicates a sort type and sort order for querying messages
463  * @param[out] msg_thread_view_list  A pointer to an #msg_struct_list_s structure
464  *
465  * @return  @c 0 on success,
466  *        otherwise a negative error value
467  *
468  * @retval MSG_SUCCESS               Success in operation
469  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
470  * @retval MSG_ERR_STORAGE_ERROR     Storage error
471  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
472  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
473  */
474
475 int msg_get_thread_view_list(msg_handle_t handle, const msg_struct_t sort_rule, msg_struct_list_s *msg_thread_view_list);
476
477
478 /**
479  * @briefs Gets the common information list of messages with the selected thread ID.
480  *
481  * @since_tizen 2.3
482  * @privlevel public
483  * @privilege %http://tizen.org/privilege/message.read
484  *
485  * @remarks The memory for a list will be allocated in this function.
486  * @remarks Applications need to call msg_release_conversation_view_list() to free the memory.
487  * @remarks However, if this function is failed, the memory for a list is NOT allocated in this function.
488  *
489  * @param[in]  hMsgHandle          The Message handle
490  * @param[in]  thread_id           The ID of the thread to be returned
491  * @param[out] msg_conv_view_list  A pointer to a structure of conversational message list
492  *
493  * @return  @c 0 on success,
494  *        otherwise a negative error value
495  *
496  * @retval MSG_SUCCESS               Success in operation
497  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
498  * @retval MSG_ERR_STORAGE_ERROR     Storage error
499  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
500  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
501  */
502
503 int msg_get_conversation_view_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_conv_view_list);
504
505
506 /**
507  * @brief Deletes all the Messages Sent/Received from the selected list.
508  *
509  * @since_tizen 2.3
510  * @privlevel public
511  * @privilege %http://tizen.org/privilege/message.write
512  *
513  * @param[in] handle                 The Message handle
514  * @param[in] thread_id              The ID of the thread to be deleted
515  * @param[in] include_protected_msg  Set @c true to delete protected messages,
516  *                                   otherwise @c false to not delete protected messages
517  *
518  * @return  @c 0 on success,
519  *        otherwise a negative error value
520  *
521  * @retval MSG_SUCCESS               Success in operation
522  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
523  * @retval MSG_ERR_STORAGE_ERROR     Storage error
524  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
525  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
526  */
527
528 int msg_delete_thread_message_list(msg_handle_t handle, msg_thread_id_t thread_id, bool include_protected_msg);
529
530
531 /**
532  * @brief Adds a new folder.
533  *
534  * @since_tizen 2.3
535  * @privlevel public
536  * @privilege %http://tizen.org/privilege/message.write
537  *
538  * @param[in] handle      The Message handle
539  * @param[in] folder_info A pointer to an #MSG_FOLDER_INFO_S structure
540  *
541  * @return  @c 0 on success,
542  *        otherwise a negative error value
543  *
544  * @retval MSG_SUCCESS               Success in operation
545  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
546  * @retval MSG_ERR_STORAGE_ERROR     Storage error
547  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
548  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
549  */
550
551 int msg_add_folder(msg_handle_t handle, const msg_struct_t folder_info);
552
553
554 /**
555  * @brief Updates the folder info.
556  *
557  * @since_tizen 2.3
558  * @privlevel public
559  * @privilege %http://tizen.org/privilege/message.write
560  *
561  * @param[in] handle       The Message handle
562  * @param[in] folder_info  A pointer to an #MSG_FOLDER_INFO_S structure
563  *
564  * @return  @c 0 on success,
565  *        otherwise a negative error value
566  *
567  * @retval MSG_SUCCESS               Success in operation
568  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
569  * @retval MSG_ERR_STORAGE_ERROR     Storage error
570  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
571  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
572  */
573
574 int msg_update_folder(msg_handle_t handle, const msg_struct_t folder_info);
575
576
577 /**
578  * @brief Deletes an existing folder.
579  *
580  * @since_tizen 2.3
581  * @privlevel public
582  * @privilege %http://tizen.org/privilege/message.write
583  *
584  * @param[in] handle    The Message handle
585  * @param[in] folder_id The ID of the folder to be deleted
586  *
587  * @return  @c 0 on success,
588  *        otherwise a negative error value
589  *
590  * @retval MSG_SUCCESS               Success in operation
591  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
592  * @retval MSG_ERR_STORAGE_ERROR     Storage error
593  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
594  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
595  */
596
597 int msg_delete_folder(msg_handle_t handle, msg_folder_id_t folder_id);
598
599
600 /**
601  * @brief Gets the information list of folders.
602  *
603  * @since_tizen 2.3
604  * @privlevel public
605  * @privilege %http://tizen.org/privilege/message.read
606  *
607  * @param[in]  handle       The Message handle
608  * @param[out] folder_list  A pointer to a #msg_struct_list_s structure
609  *
610  * @return  @c 0 on success,
611  *        otherwise a negative error value
612  *
613  * @retval MSG_SUCCESS               Success in operation
614  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
615  * @retval MSG_ERR_STORAGE_ERROR     Storage error
616  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
617  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
618  */
619
620 int msg_get_folder_list(msg_handle_t handle, msg_struct_list_s *folder_list);
621
622
623 /**
624  * @brief Creates the specified number of messages in database.
625  * @details This API is used to generate specified number of messages in the database
626  *
627  * @since_tizen 2.3
628  * @privlevel public
629  * @privilege %http://tizen.org/privilege/message.write
630  *
631  * @param[in] handle     The Message handle
632  * @param[in] msg_type   The message type \n
633  *                       One of enum _MSG_MESSAGE_TYPE_E.
634  * @param[in] folder_id  The folder for the test messages
635  * @param[in] num_msg    The number of messages
636  *
637  * @return  @c 0 on success,
638  *        otherwise a negative error value
639  *
640  * @retval MSG_SUCCESS               Success in operation
641  * @retval MSG_ERR_INVALID_MSGHANDLE Parameter is invalid
642  * @retval MSG_ERR_STORAGE_ERROR     Storage error
643  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
644  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
645  */
646
647 int msg_generate_message(msg_handle_t handle, msg_message_type_t msg_type, msg_folder_id_t folder_id, unsigned int num_msg);
648
649
650 /**
651  * @brief Returns the Message Data to be used by the Quick Panel.
652  *
653  * @since_tizen 2.3
654  * @privlevel public
655  * @privilege %http://tizen.org/privilege/message.read
656  *
657  * @param[in]  handle  The Message handle
658  * @param[in]  type    The type of message that Quick Panel needs
659  * @param[out] msg     A pointer to a #msg_struct_t structure
660  *
661  * @return  @c 0 on success,
662  *        otherwise a negative error value
663  *
664  * @retval MSG_SUCCESS                   Success in operation
665  * @retval MSG_ERR_DB_STEP               There is no Quick Panel message
666  * @retval MSG_ERR_INVALID_PARAMETER(-9) Parameter is invalid
667  * @retval MSG_ERR_STORAGE_ERROR         Storage  error
668  * @retval MSG_ERR_PERMISSION_DENIED     The application does not have the privilege to call this method
669  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
670  */
671
672 int msg_get_quick_panel_data(msg_handle_t handle, msg_quickpanel_type_t type, msg_struct_t msg);
673
674
675 /**
676  * @brief Resets the Messaging database.
677  *
678  * @since_tizen 2.3
679  * @privlevel public
680  * @privilege %http://tizen.org/privilege/message.write
681  *
682  * @param[in] handle The Message handle
683  *
684  * @return  @c 0 on success,
685  *        otherwise a negative error value
686  *
687  * @retval MSG_SUCCESS               Success in operation
688  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
689  * @retval MSG_ERR_STORAGE_ERROR     Storage error
690  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
691  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
692  */
693
694 int msg_reset_database(msg_handle_t handle);
695
696
697 /**
698  * @brief Gets the total size used for message contents.
699  *
700  * @since_tizen 2.3
701  * @privlevel public
702  * @privilege %http://tizen.org/privilege/message.read
703  *
704  * @param[in]  handle    The Message handle
705  * @param[out] memsize   A pointer to the size
706  *
707  * @return  @c 0 on success,
708  *        otherwise a negative error value
709  *
710  * @retval MSG_SUCCESS               Success in operation
711  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
712  * @retval MSG_ERR_STORAGE_ERROR     Storage error
713  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
714  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
715  */
716
717 int msg_get_mem_size(msg_handle_t handle, unsigned int* memsize);
718
719 /**
720  * @brief Backs up messages to storage.
721  *
722  * @since_tizen 2.3
723  * @privlevel public
724  * @privilege %http://tizen.org/privilege/message.read
725  *
726  * @param[in] handle          The Message handle
727  * @param[in] type            The backup type
728  * @param[in] backup_filepath The path to backup message
729  *
730  * @return  @c 0 on success,
731  *        otherwise a negative error value
732  *
733  * @retval MSG_SUCCESS               Success in operation
734  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
735  * @retval MSG_ERR_STORAGE_ERROR     Storage error
736  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
737  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
738  */
739
740 int msg_backup_message(msg_handle_t handle, msg_message_backup_type_t type, const char *backup_filepath);
741
742
743 /**
744  * @brief Restores messages from backed up messages.
745  *
746  * @since_tizen 2.3
747  * @privlevel public
748  * @privilege %http://tizen.org/privilege/message.write
749  *
750  * @param[in] handle          The Message handle
751  * @param[in] backup_filepath The path to backup message
752  *
753  * @return  @c 0 on success,
754  *        otherwise a negative error value
755  *
756  * @retval MSG_SUCCESS               Success in operation
757  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
758  * @retval MSG_ERR_STORAGE_ERROR     Storage error
759  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
760  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
761  */
762
763 int msg_restore_message(msg_handle_t handle, const char *backup_filepath);
764
765
766 /**
767  * @brief Searches messages or addresses for the specified string.
768  * @details This API is used to search messages or addresses from storage.
769  *
770  * @since_tizen 2.3
771  * @privlevel public
772  * @privilege %http://tizen.org/privilege/message.read
773  *
774  * @param[in]  handle               The Message handle
775  * @param[in]  search_string        The string to search
776  * @param[out] msg_thread_view_list A pointer to an #msg_struct_list_s structure
777  *
778  * @return  @c 0 on success,
779  *        otherwise a negative error value
780  *
781  * @retval MSG_SUCCESS               Success in operation
782  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
783  * @retval MSG_ERR_STORAGE_ERROR     Storage error
784  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
785  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
786  */
787
788 int msg_search_message_for_thread_view(msg_handle_t handle, const char *search_string, msg_struct_list_s *msg_thread_view_list);
789
790
791 /**
792  * @brief Gets reject message list by phone number.
793  * @details This API is used to get reject message list from storage.
794  *
795  * @since_tizen 2.3
796  * @privlevel public
797  * @privilege %http://tizen.org/privilege/message.read
798  *
799  * @param[in]  handle               The Message handle
800  * @param[in]  phone_num            The string of phone number to find
801  * @param[out] msg_reject_msg_list  A pointer to a #msg_struct_list_s structure
802  *
803  * @return  @c 0 on success,
804  *        otherwise a negative error value
805  *
806  * @retval MSG_SUCCESS               Success in operation
807  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
808  * @retval MSG_ERR_STORAGE_ERROR     Storage error
809  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
810  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
811  */
812
813 int msg_get_reject_msg_list(msg_handle_t handle, const char* phone_num, msg_struct_list_s *msg_reject_msg_list);
814
815
816 /**
817  * @brief Registers a callback function about the change of storage status to Message handle.
818  * @details This API is used to register a callback function about the change of storage status "msg_storage_change_cb" to Message handle.
819  *
820  * @since_tizen 2.3
821  * @privlevel public
822  * @privilege %http://tizen.org/privilege/message.read
823  *
824  * @remarks This function MUST be called after Message handle is opened.
825  *
826  * @param[in] handle      The Message handle
827  * @param[in] cb          The function to be called
828  * @param[in] user_param  A pointer to user data
829  *
830  * @return  @c 0 on success,
831  *        otherwise a negative error value
832  *
833  * @retval MSG_SUCCESS               Success in operation
834  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
835  * @retval MSG_ERR_MSGHANDLE_NOT_CONNECTED Message handle is not connected
836  * @retval MSG_ERR_MEMORY_ERROR  Memory is error
837  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
838  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
839  */
840
841 int msg_reg_storage_change_callback(msg_handle_t handle, msg_storage_change_cb cb, void *user_param);
842
843
844 /**
845  * @brief Gets the report status information of message.
846  *
847  * @since_tizen 2.3
848  * @privlevel public
849  * @privilege %http://tizen.org/privilege/message.read
850  *
851  * @param[in]  handle        The Message handle
852  * @param[in]  msg_id        The ID of the message
853  * @param[out] report_status A pointer to a #msg_struct_list_s structure
854  *
855  * @return  @c 0 on success,
856  *        otherwise a negative error value
857  *
858  * @retval MSG_SUCCESS               Success in operation
859  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
860  * @retval MSG_ERR_STORAGE_ERROR     Storage error
861  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
862  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
863  */
864
865 int msg_get_report_status(msg_handle_t handle, msg_message_id_t msg_id, msg_struct_list_s *report_list);
866
867
868 /**
869  * @brief Gets the address list for specific thread ID.
870  *
871  * @since_tizen 2.3
872  * @privlevel public
873  * @privilege %http://tizen.org/privilege/message.read
874  *
875  * @param[in]  handle           The Message handle
876  * @param[in]  msg_id           The ID of the message
877  * @param[out] msg_address_list A pointer to a #msg_struct_list_s structure
878  *
879  * @return  @c 0 on success,
880  *        otherwise a negative error value
881  *
882  * @retval MSG_SUCCESS               Success in operation
883  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
884  * @retval MSG_ERR_STORAGE_ERROR     Storage error
885  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
886  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
887  */
888
889 int msg_get_address_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_list_s *msg_address_list);
890
891
892 /**
893  * @brief Gets the thread ID by address.
894  *
895  * @since_tizen 2.3
896  * @privlevel public
897  * @privilege %http://tizen.org/privilege/message.read
898  *
899  * @param[in]  handle           The Message handle
900  * @param[in]  msg_address_list A pointer to a #msg_struct_list_s structure
901  * @param[out] thread_id        The thread ID of the message
902  *
903  * @return  @c 0 on success,
904  *        otherwise a negative error value
905  *
906  * @retval MSG_SUCCESS               Success in operation
907  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
908  * @retval MSG_ERR_STORAGE_ERROR     Storage error
909  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
910  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
911  */
912
913 int msg_get_thread_id_by_address(msg_handle_t handle, msg_struct_list_s *msg_address_list, msg_thread_id_t *thread_id);
914
915 /**
916  * @brief Gets the thread ID by address.
917  *
918  * @since_tizen 2.3
919  * @privlevel public
920  * @privilege %http://tizen.org/privilege/message.read
921  *
922  * @param[in]  handle            The Message handle
923  * @param[in]  msg_address_list  A pointer to a #msg_list_handle structure
924  * @param[out] thread_id         The thread ID of the message
925  *
926  * @return  @c 0 on success,
927  *        otherwise a negative error value
928  *
929  * @retval MSG_SUCCESS               Success in operation
930  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
931  * @retval MSG_ERR_STORAGE_ERROR     Storage error
932  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
933  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
934  */
935
936 int msg_get_thread_id_by_address2(msg_handle_t handle, msg_list_handle_t msg_address_list, msg_thread_id_t *thread_id);
937
938
939
940 /**
941  * @brief Gets the thread information.
942  *
943  * @since_tizen 2.3
944  * @privlevel public
945  * @privilege %http://tizen.org/privilege/message.read
946  *
947  * @param[in]  handle      The Message handle
948  * @param[in]  thread_id   The ID of the thread
949  * @param[out] msg_thread  A pointer to a #msg_struct_t structure
950  *
951  * @return  @c 0 on success,
952  *        otherwise a negative error value
953  *
954  * @retval MSG_SUCCESS               Success in operation
955  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
956  * @retval MSG_ERR_STORAGE_ERROR     Storage error
957  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
958  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
959  */
960
961 int msg_get_thread(msg_handle_t handle, msg_thread_id_t thread_id, msg_struct_t msg_thread);
962
963
964 /**
965  * @brief Gets the information list of messages.
966  *
967  * @since_tizen 2.3
968  * @privlevel public
969  * @privilege %http://tizen.org/privilege/message.read
970  *
971  * @param[in]  handle               The Message handle
972  * @param[in]  msg_list_conditions  A pointer to a #msg_struct_t structure for getting conditions
973  * @param[out] msg_list             A pointer to a #msg_struct_list_s structure
974  *
975  * @return  @c 0 on success,
976  *        otherwise a negative error value
977  *
978  * @retval MSG_SUCCESS               Success in operation
979  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
980  * @retval MSG_ERR_STORAGE_ERROR     Storage error
981  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
982  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
983  */
984
985 int msg_get_message_list2(msg_handle_t handle, const msg_struct_t msg_list_conditions, msg_struct_list_s *msg_list);
986
987
988 /**
989  * @brief A function to get media list of a chat room.
990  *
991  * @since_tizen 2.3.1
992  * @privlevel public
993  * @privilege %http://tizen.org/privilege/message.read
994  *
995  * @remarks This function MUST be called after Message handle is opened.
996  *
997  * @param[in] handle        The Message handle
998  * @param[in] thread_id     The thread id of conversation to get media list
999  * @param[out] msg_list     The media file list in a conversation
1000  *
1001  * @return  @c 0 on success,
1002  *          otherwise a negative error value
1003  *
1004  * @retval MSG_SUCCESS               Success in operation
1005  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1006  * @retval MSG_ERR_CALLBACK_ERROR    Callback registration error
1007  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1008  */
1009
1010 int msg_get_media_list(msg_handle_t handle, msg_thread_id_t thread_id, msg_list_handle_t *msg_list);
1011
1012
1013 /**
1014  * @brief Adds a new push event.
1015  *
1016  * @since_tizen 2.3
1017  * @privlevel public
1018  * @privilege %http://tizen.org/privilege/message.write
1019  *
1020  * @param[in] handle     The Message handle
1021  * @param[in] push_event A pointer to a #msg_struct_t structure for push event
1022  *
1023  * @return  @c 0 on success,
1024  *        otherwise a negative error value
1025  *
1026  * @retval MSG_SUCCESS               Success in operation
1027  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1028  * @retval MSG_ERR_STORAGE_ERROR     Storage error
1029  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1030  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
1031  */
1032
1033 int msg_add_push_event(msg_handle_t handle, const msg_struct_t push_event);
1034
1035
1036 /**
1037  * @brief Deletes a push event.
1038  *
1039  * @since_tizen 2.3
1040  * @privlevel public
1041  * @privilege %http://tizen.org/privilege/message.write
1042  *
1043  * @param[in] handle     The Message handle
1044  * @param[in] push_event A pointer to a #msg_struct_t structure for push event
1045  *
1046  * @return  @c 0 on success,
1047  *        otherwise a negative error value
1048  *
1049  * @retval MSG_SUCCESS               Success in operation
1050  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1051  * @retval MSG_ERR_STORAGE_ERROR     Storage error
1052  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1053  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
1054  */
1055
1056 int msg_delete_push_event(msg_handle_t handle, const msg_struct_t push_event);
1057
1058
1059 /**
1060  * @brief Updates a push event.
1061  *
1062  * @since_tizen 2.3
1063  * @privlevel public
1064  * @privilege %http://tizen.org/privilege/message.write
1065  *
1066  * @param[in] handle    The Message handle
1067  * @param[in] src_event A pointer to a #msg_struct_t structure for source push event
1068  * @param[in] dst_event A pointer to a #msg_struct_t structure for destination push event
1069  *
1070  * @return  @c 0 on success,
1071  *        otherwise a negative error value
1072  *
1073  * @retval MSG_SUCCESS               Success in operation
1074  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1075  * @retval MSG_ERR_STORAGE_ERROR     Storage error
1076  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1077  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
1078  */
1079
1080 int msg_update_push_event(msg_handle_t handle, const msg_struct_t src_event, const msg_struct_t dst_event);
1081
1082
1083 /**
1084  * @brief Deletes messages by Message ID list from the database.
1085  *
1086  * @since_tizen 2.3
1087  * @privlevel public
1088  * @privilege %http://tizen.org/privilege/message.write
1089  *
1090  * @param[in] handle      sThe Message handle
1091  * @param[in] msg_id_list The message ID list to be deleted
1092  *
1093  * @return  @c 0 on success,
1094  *        otherwise a negative error value
1095  *
1096  * @retval MSG_SUCCESS               Success in operation
1097  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1098  * @retval MSG_ERR_STORAGE_ERROR     Storage error
1099  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1100  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
1101  */
1102
1103 int msg_delete_msgs_by_list(msg_handle_t handle, msg_id_list_s *msg_id_list);
1104
1105
1106 /**
1107  * @brief Marks a conversation given by thread ID as read.
1108  *
1109  * @since_tizen 2.3
1110  * @privlevel public
1111  * @privilege %http://tizen.org/privilege/message.write
1112  *
1113  * @param[in] handle    The Message handle
1114  * @param[in] thread_id The thread ID to be updated
1115  *
1116  * @return  @c 0 on success,
1117  *        otherwise a negative error value
1118  *
1119  * @retval MSG_SUCCESS               Success in operation
1120  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1121  * @retval MSG_ERR_STORAGE_ERROR     Storage error
1122  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1123  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
1124  */
1125
1126 int msg_set_conversation_to_read(msg_handle_t handle,  msg_thread_id_t thread_id);
1127
1128
1129 /**
1130  * @brief Gets a DB records with specified query.
1131  *
1132  * @since_tizen 3.0
1133  * @privlevel public
1134  * @privilege %http://tizen.org/privilege/message.read
1135  *
1136  * @remarks You must release @a db_res using msg_db_free().
1137  * @remarks You should set @a query with SQL query string after 'SELECT'.
1138  *
1139  * @param[in] handle     The Message handle
1140  * @param[in] query      The SQL SELECT query
1141  * @param[out] db_res    The result of SQL SELECT query
1142  * @param[out] row_count The row count of result
1143  * @param[out] col_count The column count of result
1144  *
1145  * @return  @c 0 on success,
1146  *        otherwise a negative error value
1147  *
1148  * @retval MSG_SUCCESS               Success in operation
1149  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1150  * @retval MSG_ERR_STORAGE_ERROR     Storage error
1151  * @retval MSG_ERR_DB_BUSY           DB operation is busy
1152  * @retval MSG_ERR_DB_GETTABLE       DB get table operation is failed
1153  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1154  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
1155  *
1156  * @see msg_db_free()
1157  */
1158 int msg_db_select_with_query(msg_handle_t handle, const char *query, char ***db_res, int *row_count, int *col_count);
1159
1160 /**
1161  * @brief Release memory for result of SQL query.
1162  *
1163  * @since_tizen 3.0
1164  *
1165  * @param[in] handle     The Message handle
1166  * @param[in] db_res     The DB result pointer to release
1167  *
1168  * @return  @c 0 on success,
1169  *        otherwise a negative error value
1170  *
1171  * @retval MSG_SUCCESS               Success in operation
1172  * @retval MSG_ERR_INVALID_PARAMETER Parameter is invalid
1173  * @retval MSG_ERR_STORAGE_ERROR     Storage error
1174  * @retval MSG_ERR_PERMISSION_DENIED The application does not have the privilege to call this method
1175  * @retval MSG_ERR_NOT_SUPPORTED     Not supported
1176  *
1177  * @see msg_db_select_with_query()
1178  */
1179 int msg_db_free(msg_handle_t handle, char **db_res);
1180 /**
1181  *      @}
1182  */
1183
1184 #ifdef __cplusplus
1185 }
1186 #endif
1187
1188 #endif // MAPI_STORAGE_H
1189