update tizen source
[framework/messaging/msg-service.git] / test_app / main.h
1 /*
2 *
3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
4 *
5 * This file is part of msg-service.
6 *
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 *          Sangkoo Kim <sangkoo.kim@samsung.com>
9 *          Seunghwan Lee <sh.cat.lee@samsung.com>
10 *          SoonMin Jung <sm0415.jung@samsung.com>
11 *          Jae-Young Lee <jy4710.lee@samsung.com>
12 *          KeeBum Kim <keebum.kim@samsung.com>
13 *
14 * PROPRIETARY/CONFIDENTIAL
15 *
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
21 *
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
28 *
29 */
30
31
32 /**
33  *      @file           Main.h
34  *      @brief          Defines function for test application of messaging framework
35  *      @version                1.0
36  */
37
38 #ifndef MSG_TEST_MAIN_H
39 #define MSG_TEST_MAIN_H
40
41 /**
42  *      @mainpage
43  *      @section                Introduction
44  *      - This document includes as follows : \n
45  *      What is Messaging API \n
46  *      What are included in Messaging API, such as data types, functions, and so on \n
47  *      @section                Contents
48  *      - Modules
49  *      - Structure
50  *      - MessageHandle
51  *      - Request
52  *      - Callback
53  *      - Filter
54  *      - Storage
55  *      - Extendability
56  *      @section                Modules
57  *      MAPI provides a service to send, receive, parse and assemble messages over arbitrary message delivery mechanisms such as SMS, MMS, and E-mail.
58  *      Messaging Service consists of a collection of common functionality and sets of service specific functionality.
59  *      Use of particular messaging service specific functionality shall be possible.
60  *      MAPI provides a collection of data structures as well as functions to implement the functionality. \n\n
61  *      The data structures and functions are grouped into modules, as listed below:
62  *      - Message sending and reception
63  *      - Storage management
64  *      - Message storage
65  *      - Folder storage
66  *      @section                Structure
67  *      Message \n\n
68  *      A message represents a generic data collection of SMS, MMS, and E-mail.
69  *      This is not specific to any service, but supports the extension of this structure.
70  *      For service specific message, please refer to extendability of common structure.
71  *      Each message has a unique message ID in the entire messaging framework.
72  *      The message information can be retrieved from the storage by its message ID. \n\n
73  *      This concept is defined in MsgTypes.h. \n\n
74  *      Folder \n
75  *      A folder represents a container of messages.
76  *      Each folder has a unique folder ID in the entire messaging framework.
77  *      The folder information can be retrieved from the storage by its folder ID.
78  *      A folder can specify where it is stored.
79  *      The storage where a folder is stored can be different from the storage where its containing messages are stored. \n\n
80  *      This concept is defined in MsgStorageTypes.h. \n\n
81  *      @section                MessageHandle
82  *      MessageHandle is the connection between application and MAPI.
83  *      When an application wants to send, receive, add, or get a message, it must open a MessageHandle first.
84  *      To know how to use asynchronous callback for communication between application and framework, please refer to Callback. \n\n
85  *      A MessageHandle can be assigned with following information: \n
86  *      - Register MsgOnMessageIncomingCallback function.
87  *      - Register MsgOnStatusChangedCallback function.
88  *      - Set filter rule.
89  *      @section                Request
90  *      A request contains the information that is used to command framework for services, such as sending a message.
91  *      A request is sent to Messaging Framework via a MessageHandle, and Messaging Framework chooses proper plugin to handle the request.
92  *      A common usage for the request is to send a message. \n\n
93  *      This concept is defined in MsgTypes.h. \n\n
94  *      @section                Callback
95  *      Callback is used by application to detect incoming message and underlayer status change.
96  *      Two callback functions are implemented by applications and should be bound to a MessageHandle.
97  *      Both prototypes are provided: \n
98  *      - One is MsgOnMessageIncomingCallback, which is to listen incoming message.
99  *      - The other is MsgOnStatusChangedCallback, which is to listen underlayer status change.
100  *      @section                Filter
101  *      When an application is only interested in some kinds of messages, filter list is used to filter these specific messages and return them to the application.
102  *      Noted that filter is for filtering incoming messages, not a storage concept.
103  *      Filter is the basic unit to set the rules, it tells the filter service how to filter the message.
104  *      Filter list is composed of various filters. \n\n
105  *      They are defined in MsgFilterTypes.h. \n\n
106  *      Application can set a filter list for a MessageHandle to get the interesting message.
107  *      Please refer to MSG_FILTER_S and MSG_FILTER_LIST_S for details.
108  *      MAPI does NOT define any filters.
109  *      Application developers should refer to the specific implementation of filter service to get the supported filters.
110  *      @section                Storage
111  *      Storage is a collection of messages and related information that are stored on one storage media.
112  *      Storage media is the physical data storage device, such as SD card and Flash.
113  *      One storage media can have more than one storages.
114  *      Since storage media can be removable, the storages on the media can be detached and attached dynamically.
115  *      For instance, user plugs out SD card from UE 1 and plugs in this card into UE 2, all the messages stored in this card will be hidden from UE 1 and be visible to UE 2.
116  *      For details information, please refer to MSG_STORAGE_LIST_S.
117  *      Application can query supported storages by MAPI method MsgGetStorageList.
118  *      @section                Extendability
119  *      There are several structures in LiMo Messageing designed to be extended. They are: \n
120  *      - MSG_FOLDER_INFO_S
121  *      - msg_message_t
122  *      - MSG_REQUEST_S
123  */
124
125 /*==================================================================================================
126                                          INCLUDE FILES
127 ==================================================================================================*/
128
129 #include <sys/types.h>
130 #include <unistd.h>
131 #include <string.h>
132 #include <sys/time.h>
133 #include <time.h>
134
135 #include "MsgTypes.h"
136
137 #define TEST_APP_PIRNT_STR_LEN                  128
138
139 /**
140  *      @ingroup                MESSAGING_FRAMEWORK
141  *      @defgroup       MESSAGING_TEST_APPLICATION_BASIC_FUNCTION       Messaging Test Application Basic Function
142  *      @{
143  */
144
145
146 /*==================================================================================================
147                                          DEFINES
148 ==================================================================================================*/
149 #define MSG_FATAL(fmt, ...) \
150         do \
151         {\
152                 printf("\n[%d] [MSGFW: %s: %s(): %d] *FAILED* << " fmt" >>\n", get_tid(), rindex(__FILE__, '/')+1,  __FUNCTION__, __LINE__,  ##__VA_ARGS__);\
153         } while (0)
154
155 #define MSG_DEBUG(fmt, ...) \
156         do\
157         {\
158                 printf("\n[%d] [MSGFW: %s: %s(): %d] " fmt"\n", get_tid(), rindex(__FILE__, '/')+1, __FUNCTION__, __LINE__, ##__VA_ARGS__);\
159         } while (0)
160
161 #define MSG_BEGIN() \
162         do\
163     {\
164         printf("\n[%d] BEGIN >>>> %s() at [MSGFW: %s: %d]\n", get_tid(),__FUNCTION__, rindex(__FILE__, '/')+1,  __LINE__ );\
165     } while( 0 )
166
167 #define MSG_END() \
168         do\
169     {\
170         printf("\n[%d] END   <<<< %s() at [MSGFW: %s: %d]\n", get_tid(), __FUNCTION__, rindex(__FILE__, '/')+1,  __LINE__); \
171     } \
172     while( 0 )
173
174
175 /*==================================================================================================
176                                      FUNCTION PROTOTYPES
177 ==================================================================================================*/
178
179 void print(const char* string);
180
181
182 void print(int i);
183
184
185 int get_tid();
186
187
188 /**     @fn             MSG_ERROR_T init_app()
189  *      @brief  Initializes a test application.
190  *      @return MSG_ERROR_T
191  *      @retval MSG_SUCCESS                             Success in operation. \n
192  *      @retval MSG_ERR_NULL_POINTER            pMsg is NULL. \n
193  *      @retval MSG_ERR_MEMORY_ERROR            Memory is error. \n
194  *      @retval MSG_ERR_INVALID_MSGHANDLE       Message handle is invalid. \n
195  *      @retval MSG_ERR_INVALID_PARAMETER       Parameter is invalid. \n
196  */
197 MSG_ERROR_T init_app();
198
199
200 /**     @fn             void show_menu()
201  *      @brief  Shows folder information and the test menu list.
202  */
203 void* show_menu(void*);
204
205
206 /**     @fn             void run_app(char menu)
207  *      @brief  Runs a selected menu in the test menu list.
208  *      @param[in]      Menu indicates which menu is selected.
209  */
210 void run_app(char *pMenu);
211
212 /**
213  *      @}
214  */
215
216 #endif //MSG_TEST_MAIN_H
217