apply FSL(Flora Software License)
[framework/messaging/msg-service.git] / test_app / MsgTestStorage.cpp
1  /*
2   * Copyright 2012  Samsung Electronics Co., Ltd
3   *
4   * Licensed under the Flora License, Version 1.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.tizenopensource.org/license
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
18 /*==================================================================================================
19                                          INCLUDE FILES
20 ==================================================================================================*/
21 #include <time.h>
22 #include <iostream>
23 #include <string>
24 #include <stdlib.h>
25 using namespace std;
26
27 #include "MsgMmsTypes.h"
28 #include "MsgSettingTypes.h"
29 #include "MapiStorage.h"
30 #include "MapiSetting.h"
31 #include "MapiMessage.h"
32 #include "MapiTransport.h"
33 #include "MsgTestStorage.h"
34 #include "MsgTestTransport.h"
35 #include "main.h"
36
37 MSG_FOLDER_LIST_S g_folderList;
38
39 #define MSG_PROFILE_BEGIN(pfid) \
40         unsigned int __prf_l1_##pfid = __LINE__;    \
41         struct timeval __prf_1_##pfid;              \
42         struct timeval __prf_2_##pfid;              \
43         do {                                        \
44                 gettimeofday(&__prf_1_##pfid, 0);       \
45         } while (0)
46
47 #define MSG_PROFILE_END(pfid) \
48         unsigned int __prf_l2_##pfid = __LINE__;\
49         do { \
50                 gettimeofday(&__prf_2_##pfid, 0);\
51                 long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
52                 long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
53                 if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
54                 printf("**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid " -> Elapsed Time: %u.%06u seconds\n",                    \
55                 rindex(__FILE__, '/')+1,                \
56                 __FUNCTION__, \
57                 __prf_l1_##pfid,                                         \
58                 __prf_l2_##pfid,                                         \
59                 (unsigned int)(__ds),                                    \
60                 (unsigned int)(__dm));                                   \
61         } while (0)
62
63 /*==================================================================================================
64                                      FUNCTION IMPLEMENTATION
65 ==================================================================================================*/
66 void MsgTestAddMessage(MSG_HANDLE_T hMsgHandle)
67 {
68         if (hMsgHandle == NULL)
69         {
70                 MSG_DEBUG("Handle is NULL");
71                 return;
72         }
73
74         // Make Message
75         msg_message_t msgInfo = msg_new_message();
76         MSG_SENDINGOPT_S sendOpt = {0, };
77
78         print("\n===== Input Message =====");
79         print("Input Message Type 0:SMS 1:MMS :");
80         unsigned int msgType;
81         msgType = cin.get();    //&msgType, 1);
82         cin.get(); // consume "enter key"
83
84         if( msgType == '0' )
85         {
86                 msg_set_message_type(msgInfo, MSG_TYPE_SMS);
87         }
88         else if ( msgType == '1' )
89         {
90                 msg_set_message_type(msgInfo, MSG_TYPE_MMS);
91         }
92         else
93         {
94                 MSG_DEBUG("Msg Type input error %d", msgType);
95         }
96
97         print("\nInput Message Sending Option ?. 'Y' : Yes 'N' : No  ");
98
99         char bSendOpt = 0, ch = 0;
100         cin >> bSendOpt;
101         ch = cin.get();
102
103         if( bSendOpt == 'Y' || bSendOpt == 'y')
104         {
105                 sendOpt.bSetting = true;
106
107                 /* EX : Set SendingOption */
108                 if( msg_is_sms(msgInfo) ) //msgInfo.msgType.mainType == MSG_SMS_TYPE)
109                 {
110                         print("\nRequest Delivery Report? Press 'Y' or 'N' :");
111                         char bDelivery = 0;
112                         ch = 0;
113                         cin >> bDelivery;
114                         ch = cin.get();
115
116                         if( bDelivery == 'Y' || bDelivery == 'y')
117                                 sendOpt.bDeliverReq = true;
118                         else
119                                 sendOpt.bDeliverReq = false;
120
121                         print("\nKeep a Copy? Press 'Y' or 'N' :");
122                         char bKeepCopy = 0;
123                         ch = 0;
124                         cin >> bKeepCopy;
125                         ch = cin.get();
126
127                         if( bKeepCopy == 'Y' || bKeepCopy == 'y')
128                                 sendOpt.bKeepCopy = true;
129                         else
130                                 sendOpt.bKeepCopy = false;
131
132                         print("\nSet Reply Path? Press 'Y' or 'N' :");
133                         char bReplyPath = 0;
134                         ch = 0;
135                         cin >> bReplyPath;
136                         ch = cin.get();
137
138                         if( bReplyPath == 'Y' || bReplyPath == 'y')
139                                 sendOpt.option.smsSendOpt.bReplyPath = true;
140                         else
141                                 sendOpt.option.smsSendOpt.bReplyPath = false;
142                 }
143                 else if( msg_is_mms(msgInfo) )//msgInfo.msgType.mainType == MSG_MMS_TYPE)
144                 {
145                         print("\nRequest Delivery Report? Press 'Y' or 'N' :");
146                         char bDelivery = 0;
147                         ch = 0;
148                         cin >> bDelivery;
149                         ch = cin.get();
150
151                         if( bDelivery == 'Y' || bDelivery == 'y')
152                                 sendOpt.bDeliverReq = true;
153                         else
154                                 sendOpt.bDeliverReq = false;
155
156                         print("\nKeep a Copy? Press 'Y' or 'N' :");
157                         char bKeepCopy = 0;
158                         ch = 0;
159                         cin >> bKeepCopy;
160                         ch = cin.get();
161
162                         if( bKeepCopy == 'Y' || bKeepCopy == 'y')
163                                 sendOpt.bKeepCopy = true;
164                         else
165                                 sendOpt.bKeepCopy = false;
166
167                         print("\nRequest Read Report? Press 'Y' or 'N' :");
168                         char bRead = 0;
169                         ch = 0;
170                         cin >> bRead;
171                         ch = cin.get();
172
173                         if( bRead == 'Y' || bRead == 'y')
174                                 sendOpt.option.mmsSendOpt.bReadReq = true;
175                         else
176                                 sendOpt.option.mmsSendOpt.bReadReq = false;
177
178                         print("\nSet Priority? 'U' : Ugent, 'N' : Normal, 'L' : Low");
179                         char priority = 0;
180                         ch = 0;
181                         cin >> priority;
182                         ch = cin.get();
183
184                         if( priority == 'U' || priority == 'u')
185                                 sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_HIGH;
186                         else if( priority == 'N' || priority == 'n')
187                                 sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_NORMAL;
188                         else if( priority == 'L' || priority == 'l')
189                                 sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_LOW;
190
191                         print("\nSet Expiry Time? '0' : Max '1' : 1 Day, '2' : 2 Days, '3' : 1 Week, '4' : 2 Weeks ");
192                         char expiryTime = 0;
193                         ch = 0;
194                         cin >> expiryTime;
195                         ch = cin.get();
196
197                         if( expiryTime == '0')
198                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_MAXIMUM;
199                         else if( expiryTime == '1')
200                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1DAY;
201                         else if( expiryTime == '2')
202                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2DAYS;
203                         else if( expiryTime == '3')
204                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1WEEK;
205                         else if( expiryTime == '4')
206                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2WEEKS;
207
208                         print("\nSet Delivery Time? '0' : Immediately '1' : 1 Hour, '2' : 1 Day, '3' : 1 Week ");
209                         char deliveryTime = 0;
210                         ch = 0;
211                         cin >> deliveryTime;
212                         ch = cin.get();
213
214                         if( deliveryTime == '0')
215                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_IMMEDIATLY;
216                         else if( deliveryTime == '1')
217                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1HOUR;
218                         else if( deliveryTime == '2')
219                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1DAY;
220                         else if( deliveryTime == '3')
221                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1WEEK;
222
223                         MSG_DEBUG("sendOpt.option.mmsSendOpt.deliveryTime = %lu", sendOpt.option.mmsSendOpt.deliveryTime);
224                 }
225         }
226         else            /* In case of No setting per Message, Set Message option with Global Setting value */
227         {
228                 sendOpt.bSetting = false;
229         }
230
231         MSG_DEBUG("### bSetting = %d ###", sendOpt.bSetting);
232         MSG_DEBUG("MsgType [%d]", msg_get_message_type(msgInfo));
233
234         if(msg_is_sms(msgInfo)) //msgInfo.msgType.mainType == MSG_SMS_TYPE)
235         {
236                 print("\n===== Input Message =====");
237                 print("Input Message Text :");
238
239                 char strMsg[1200];
240                 memset(strMsg, 0x00, sizeof(strMsg));
241
242 //              strcpy(strMsg, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
243 //              strcpy(strMsg, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNO");
244 //              strcpy(strMsg, "ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNOPQRSTUVWXYZ ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO ABCDEFGHIJKLMNO");
245 //              strcpy(strMsg, "AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAA");
246
247                 cin.getline(strMsg, 1024);
248
249                 if (msg_sms_set_message_body(msgInfo, strMsg, strlen(strMsg)) != MSG_SUCCESS)
250                 {
251                         return;
252                 }
253         }
254
255         else if(msg_is_mms(msgInfo)) //msgInfo.msgType.mainType == MSG_MMS_TYPE)
256         {
257                 // Compose MMS Message Body (Text, Image, Sound, Video)
258                 //MMS_MESSAGE_DATA_S    msgData ={0, };
259                 MMS_MESSAGE_DATA_S*      mms_data;//msgHandle;
260                 MMS_PAGE_S* page[2];
261                 MMS_MEDIA_S* media[5];
262                 MMS_ATTACH_S* attachment[5];
263                 int nSize = 0;
264
265                 print("\n===== Input Subject =====");
266
267                 char                                    strSubject[120];
268                 int                                             subjectLen;
269                 memset(strSubject, 0x00, sizeof(strSubject));
270
271                 cin.getline(strSubject, 120);
272                 subjectLen = strlen(strSubject);
273
274                 msg_set_subject(msgInfo, strSubject);
275
276                 mms_data = msg_mms_create_message();
277
278                 print("\n===== Input Message =====");
279                 print("Input Multipart type 0: Multiprat Related, 1:Multipart Mixed");
280
281                 unsigned int multipartType;
282                 multipartType = cin.get();
283                 cin.get(); // consume "enter key"
284
285                 if(multipartType == '0')
286                 {
287                         msg_mms_set_rootlayout(mms_data, 100, 100, 0xffffff);
288                         msg_mms_add_region(mms_data, "Image", 0, 50, 100, 50, 0xffffff);
289                         msg_mms_add_region(mms_data, "Text", 0, 0, 100, 50, 0xffffff);
290
291                         //------------>  1st Slide Composing
292                         page[0] = msg_mms_add_page(mms_data, 5440);
293
294                         media[0] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_IMG, "Image", (char*)"/opt/etc/msg-service/P091120_104633.jpg");
295                         media[1] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_AUDIO, NULL, (char*)"/opt/etc/msg-service/audio.amr");
296                         media[2] = msg_mms_add_media(page[0], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp0_2.txt");
297                         media[2]->sMedia.sText.nColor = 0x000000;
298                         media[2]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
299                         media[2]->sMedia.sText.bBold = true;
300
301                         //------------>  2nd Slide Composing
302                         page[1] = msg_mms_add_page(mms_data, 4544);
303
304                         media[3] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_TEXT, "Text", (char*)"/opt/etc/msg-service/Temp1_0.txt");
305                         media[3]->sMedia.sText.nColor = 0x000000;
306                         media[3]->sMedia.sText.nSize = MMS_SMIL_FONT_SIZE_NORMAL;
307                         media[3]->sMedia.sText.bItalic = true;
308                         media[4] = msg_mms_add_media(page[1], MMS_SMIL_MEDIA_VIDEO, "Text", (char*)"/opt/etc/msg-service/V091120_104905.3gp");
309                         strncpy(media[4]->szAlt, "Video Load Fail", MAX_SMIL_ALT_LEN-1);
310                 }
311                 else
312                 {
313                         attachment[0] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/P091120_104633.jpg");
314                         attachment[1] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/audio.amr");
315                         attachment[2] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/Temp0_2.txt");
316                         attachment[3] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/Temp1_0.txt");
317                         attachment[4] = msg_mms_add_attachment(mms_data, (char*)"/opt/etc/msg-service/V091120_104905.3gp");
318                 }
319
320                 MSG_DEBUG("nSize = %d",  nSize);
321
322                 msg_mms_set_message_body(msgInfo, mms_data);
323
324                 msg_mms_release_page_list(mms_data);
325                 msg_mms_release_region_list(mms_data);
326                 msg_mms_release_attachment_list(mms_data);
327                 msg_mms_release_transition_list(mms_data);
328                 msg_mms_release_meta_list(mms_data);
329
330                 msg_mms_destroy_message(mms_data);
331         }
332
333         int nToCnt = 0;
334
335         char strNumber[MAX_ADDRESS_VAL_LEN];
336         memset(strNumber, 0x00, MAX_ADDRESS_VAL_LEN);
337
338         print("\n===== Add Recipient =====");
339
340         while (nToCnt < MAX_TO_ADDRESS_CNT)
341         {
342                 print("\nInput Recipient Number. Press 'N' if you don't want : ");
343
344                 cin.getline(strNumber, 1024);
345
346                 if (!strcmp(strNumber, "N")) break;
347
348                 MSG_DEBUG("strNumber [%s]", strNumber);
349
350                 if(msg_is_mms(msgInfo)) // in case of MMS
351                 {
352                         print("\n===== Input Recipient Type =====");
353                         print("Input Message Type 0:To 1:Cc 2: Bcc :");
354
355                         unsigned int recipientType;
356                         recipientType = cin.get();      //&msgType, 1);
357                         cin.get(); // consume "enter key"
358
359                         if(recipientType == '0')
360                                 msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_TO);
361                         else if(recipientType == '1')
362                                 msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_CC);
363                         else if(recipientType == '2')
364                                 msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_BCC);
365                         else
366                                 MSG_DEBUG("Recipient Type input error %d", recipientType);
367                 }
368                 else // in case of SMS
369                         msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_TO);
370
371                 nToCnt++;
372         }
373
374         MSG_DEBUG("nToContactCnt [%d]", msg_get_address_count(msgInfo));
375
376         if(msg_is_sms(msgInfo))
377         {
378                 char strReplyAddr[MAX_PHONE_NUMBER_LEN];
379                 memset(strReplyAddr, 0x00, MAX_PHONE_NUMBER_LEN);
380
381                 print("\n===== Set Reply Address =====");
382
383                 print("\nInput Reply Number. Press 'N' if you don't want : ");
384
385                 cin.getline(strReplyAddr, 1024);
386
387                 if (!strcmp(strReplyAddr, "N"))
388                 {
389                         print("\nReply Number is not set.");
390                 }
391                 else
392                 {
393                         MSG_DEBUG("strReplyAddr [%s]", strReplyAddr);
394
395                         msg_set_reply_address(msgInfo, strReplyAddr);
396                 }
397
398                 // for test
399 //              msg_set_backup_status(msgInfo, true);
400         }
401
402         // Port Number Test
403 //      msg_set_port(msgInfo, 4010, 0);
404
405         print("\n======================================");
406         print("[1] Send Message");
407         print("[2] Save Message into Draft");
408         print("[3] Scheduled Message Send");
409         print("======================================");
410         print("Input : ");
411
412         int select = 0;
413         char ch1 = 0;
414
415         cin >> select;
416         ch1 = cin.get();
417
418         if (select == 1)
419         {
420                 MsgTestSubmitReq(hMsgHandle, msgInfo, &sendOpt);
421         }
422         else if (select == 2)
423         {
424                 print("Start Saving Message...");
425
426                 int MsgId = 0;
427
428                 MsgId = msg_add_message(hMsgHandle, msgInfo, &sendOpt);
429
430                 MSG_DEBUG("Saving Message is Finished![%d]", MsgId);
431         }
432
433         else if (select == 3)
434         {
435                 MsgTestScheduledSubmitReq(hMsgHandle, msgInfo, &sendOpt);
436         }
437
438         msg_release_message(&msgInfo);
439 }
440
441 void MsgTestMsgGen(MSG_HANDLE_T hMsgHandle)
442 {
443         if (hMsgHandle == NULL)
444         {
445                 MSG_DEBUG("Handle is NULL");
446                 return;
447         }
448
449         char menu[5];
450
451         print("Input Message Count: ");
452
453         memset(menu, 0x00, sizeof(menu));
454         cin.getline(menu, 5);
455
456         unsigned int count = atoi(menu);
457
458         print("Input Message Type(SMS[1], MMS[2]): ");
459
460         memset(menu, 0x00, sizeof(menu));
461         cin.getline(menu, 5);
462
463         MSG_MESSAGE_TYPE_T msgType = MSG_TYPE_INVALID;
464
465         if (atoi(menu) == 1)
466                 msgType = MSG_TYPE_SMS;
467         else if (atoi(menu) == 2)
468                 msgType = MSG_TYPE_MMS;
469
470         print("Input folder(INBOX[1], OUTBOX[2], SENTBOX[3], DRAFTBOX[4]): ");
471
472         memset(menu, 0x00, sizeof(menu));
473         cin.getline(menu, 5);
474
475         MSG_FOLDER_ID_T folderId = atoi(menu);
476
477         MSG_ERROR_T err = msg_generate_message(hMsgHandle, msgType, folderId, count);
478
479         if (err != MSG_SUCCESS)
480         {
481                 MSG_DEBUG("err [%d]", err);
482         }
483 }
484
485
486 void MsgTestGetMessage(MSG_HANDLE_T hMsgHandle, int MsgId)
487 {
488         if (hMsgHandle == NULL)
489         {
490                 MSG_DEBUG("Handle is NULL");
491                 return;
492         }
493
494         MSG_ERROR_T err = MSG_SUCCESS;
495
496         msg_message_t msg = msg_new_message();
497         MSG_SENDINGOPT_S sendOpt = {0, };
498
499         err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)MsgId, msg, &sendOpt);
500
501         if (err != MSG_SUCCESS)
502         {
503                 msg_release_message(&msg);
504                 return;
505         }
506
507         // Update Read Status
508         msg_update_read_status(hMsgHandle, MsgId, true);
509
510         // Send Read Report
511         if (msg_is_mms(msg))
512         {
513                 int folder_id = msg_get_folder_id(msg);
514                 if (folder_id == MSG_INBOX_ID) {
515                         msg_mms_send_read_report(hMsgHandle, MsgId, MSG_READ_REPORT_IS_READ);
516                 }
517         }
518
519         MsgPrintMessage(hMsgHandle, msg, &sendOpt);
520
521         msg_release_message(&msg);
522 }
523
524
525 void MsgTestGetMessageList(MSG_HANDLE_T hMsgHandle, int FolderId)
526 {
527         if (hMsgHandle == NULL)
528         {
529                 MSG_DEBUG("Handle is NULL");
530                 return;
531         }
532
533         char menu[5];
534
535         MSG_ERROR_T err = MSG_SUCCESS;
536
537         MSG_SORT_RULE_S sortRule = {0};
538
539         sortRule.sortType               = MSG_SORT_BY_READ_STATUS;
540         sortRule.bAscending     = false;
541
542         MSG_LIST_S folderViewList;
543
544         MSG_MESSAGE_TYPE_T MsgType;
545         MSG_NETWORK_STATUS_T NetworkStatus;
546
547         char displayTime[32];
548         memset(displayTime, 0x00, sizeof(displayTime));
549
550         do
551         {
552                 err = msg_get_folder_view_list(hMsgHandle, (MSG_FOLDER_ID_T)FolderId, NULL, &folderViewList);
553
554                 if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
555                 {
556                         print("Get Message List is failed!");
557                         return;
558                 }
559
560                 system ("clear" );
561
562                 printf("======================================\n");
563                 for (int i = 0; i < g_folderList.nCount; i++)
564                 {
565                         if (FolderId == g_folderList.folderInfo[i].folderId)
566                         {
567                                 printf("=============== %s ===============\n", g_folderList.folderInfo[i].folderName);
568                                 break;
569                         }
570                 }
571                 printf("======================================\n");
572
573                 if (folderViewList.nCount <= 0)
574                 {
575                         printf("Empty...\n");
576                 }
577                 else
578                 {
579                         MSG_PROFILE_BEGIN(2);
580
581                         for (int i = 0; i < folderViewList.nCount; i++)
582                         {
583                                 memset(displayTime, 0x00, sizeof(displayTime));
584
585                                 MsgConvertTime(msg_get_time(folderViewList.msgInfo[i]), displayTime);
586
587                                 const char* msgText = NULL;
588
589                                 int msgType = msg_get_message_type(folderViewList.msgInfo[i]);
590
591                                 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
592                                         msgText = msg_mms_get_text_contents(folderViewList.msgInfo[i]);
593                                 else
594                                         msgText = msg_sms_get_message_body(folderViewList.msgInfo[i]);
595
596                                 printf("[%02d]\t[%s %s %s %s] [%s]\t[%s]\nDate [%s]\nMessage Text [%s] \tMessage data size [%d]\n",
597                                                 msg_get_message_id(folderViewList.msgInfo[i]),
598                                                 MsgConvertMsgType(msg_get_message_type(folderViewList.msgInfo[i])),
599                                                 MsgConvertStorageId(msg_get_storage_id(folderViewList.msgInfo[i])),
600                                                 MsgConvertReadStatus(msg_is_read(folderViewList.msgInfo[i])),
601                                                 MsgConvertProtectedStatus(msg_is_protected(folderViewList.msgInfo[i])),
602                                                 MsgConvertNetworkStatus(msg_get_network_status(folderViewList.msgInfo[i])),
603                                                 msg_get_ith_address(folderViewList.msgInfo[i], 0),
604                                                 displayTime,
605                                                 msgText,
606                                                 msg_get_message_body_size(folderViewList.msgInfo[i]));
607                                 printf("--------------------------------------------------------\n");
608                         }
609
610                         MSG_PROFILE_END(2);
611                 }
612
613                 printf("======================================\n");
614                 printf("================ Menu ================\n");
615                 printf("======================================\n");
616                 printf("[C] Create Message\n");
617                 printf("[D] Delete All Messages\n");
618                 printf("[B] Back\n");
619                 printf("======================================\n");
620
621                 printf("Input : ");
622
623                 memset(menu, 0x00, sizeof(menu));
624                 cin.getline(menu, 5);
625
626                 if (!strcmp(menu, "C") || !strcmp(menu, "c")) // Add Message
627                 {
628                         MsgTestAddMessage(hMsgHandle);
629                 }
630                 else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
631                 {
632                         char menu[2];
633
634                         printf("Do you really wanna delete all messages [Y or N] ?\n");
635
636                         memset(menu, 0x00, sizeof(menu));
637                         cin.getline(menu, 2);
638
639                         if (!strcmp(menu, "Y"))
640                                 msg_delete_all_msgs_in_folder(hMsgHandle, (MSG_FOLDER_ID_T)FolderId, false);
641                 }
642                 else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
643                 {
644                         break;
645                 }
646                 else
647                 {
648                         int msgId = atoi(menu);
649
650                         for (int i = 0; i < folderViewList.nCount; i++)
651                         {
652                                 if ( msg_get_message_id( folderViewList.msgInfo[i] ) == msgId)
653                                 {
654                                         MsgType = msg_get_message_type(folderViewList.msgInfo[i]);
655                                         NetworkStatus = msg_get_network_status(folderViewList.msgInfo[i]);
656
657                                         MsgRunMsgListMenu(hMsgHandle, msgId, FolderId, MsgType, NetworkStatus);
658
659                                         break;
660                                 }
661                         }
662                 }
663
664                 msg_release_message_list(&folderViewList);
665                 printf("release folderview list [%d]\n", folderViewList.nCount);
666         }
667         while (strcmp(menu, "B"));
668 }
669
670
671 void MsgTestUpdateMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg)
672 {
673         if (hMsgHandle == NULL)
674         {
675                 MSG_DEBUG("Handle is NULL");
676                 return;
677         }
678
679         MSG_ERROR_T err = MSG_SUCCESS;
680
681         MSG_SENDINGOPT_S sendOpt = {0, };
682
683         print("\n===== Input Message =====");
684         print("Input Message Text :");
685
686         char strMsg[1024] = {0};
687
688 //      strcpy(strMsg, "ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ");
689         cin.getline(strMsg, 1024);
690
691         msg_sms_set_message_body(pMsg, strMsg, strlen(strMsg));
692
693         int nToCnt = msg_get_address_count(pMsg);
694
695         char strNumber[MAX_ADDRESS_VAL_LEN] = {0};
696
697         printf("\n===== Add Recipient =====\n");
698
699         MSG_DEBUG("address count [%d]", nToCnt);
700
701         if (nToCnt > 0)
702         {
703                 msg_reset_address(pMsg);
704         }
705
706         printf("\nInput Recipient Number. Press 'N' if you don't want : \n");
707
708         cin.getline(strNumber, 1024);
709
710         if (strcmp(strNumber, "N"))
711         {
712                 MSG_DEBUG("strNumber [%s]", strNumber);
713
714                 msg_add_address(pMsg, strNumber, MSG_RECIPIENTS_TYPE_TO);
715
716                 MSG_DEBUG("contactVal [%s]", msg_get_ith_address(pMsg, 0));
717
718                 MSG_DEBUG("nToContactCnt [%d]", msg_get_address_count(pMsg));
719         }
720
721         print("\nInput Message Sending Option ?. 'Y' : Yes 'N' : No  ");
722
723         char bSendOpt = 0, ch = 0;
724         cin >> bSendOpt;
725         ch = cin.get();
726
727         if( bSendOpt == 'Y' || bSendOpt == 'y')
728         {
729                 sendOpt.bSetting = true;
730
731                 /* EX : Set SendingOption */
732                 if( msg_is_sms(pMsg) )
733                 {
734                         printf("\nRequest Delivery Report? Press 'Y' or 'N' :\n");
735                         char bDelivery = 0;
736                         ch = 0;
737                         cin >> bDelivery;
738                         ch = cin.get();
739
740                         if( bDelivery == 'Y' || bDelivery == 'y')
741                                 sendOpt.bDeliverReq = true;
742                         else
743                                 sendOpt.bDeliverReq = false;
744
745                         print("\nKeep a Copy? Press 'Y' or 'N' :");
746                         char bKeepCopy = 0;
747                         ch = 0;
748                         cin >> bKeepCopy;
749                         ch = cin.get();
750
751                         if( bKeepCopy == 'Y' || bKeepCopy == 'y')
752                                 sendOpt.bKeepCopy = true;
753                         else
754                                 sendOpt.bKeepCopy = false;
755
756                         print("\nSet Reply Path? Press 'Y' or 'N' :");
757                         char bReplyPath = 0;
758                         ch = 0;
759                         cin >> bReplyPath;
760                         ch = cin.get();
761
762                         if( bReplyPath == 'Y' || bReplyPath == 'y')
763                                 sendOpt.option.smsSendOpt.bReplyPath = true;
764                         else
765                                 sendOpt.option.smsSendOpt.bReplyPath = false;
766                 }
767                 else if( msg_is_mms(pMsg) )
768                 {
769                         print("\nRequest Delivery Report? Press 'Y' or 'N' :");
770                         char bDelivery = 0;
771                         ch = 0;
772                         cin >> bDelivery;
773                         ch = cin.get();
774
775                         if( bDelivery == 'Y' || bDelivery == 'y')
776                                 sendOpt.bDeliverReq = true;
777                         else
778                                 sendOpt.bDeliverReq = false;
779
780                         print("\nKeep a Copy? Press 'Y' or 'N' :");
781                         char bKeepCopy = 0;
782                         ch = 0;
783                         cin >> bKeepCopy;
784                         ch = cin.get();
785
786                         if( bKeepCopy == 'Y' || bKeepCopy == 'y')
787                                 sendOpt.bKeepCopy = true;
788                         else
789                                 sendOpt.bKeepCopy = false;
790
791                         print("\nRequest Read Report? Press 'Y' or 'N' :");
792                         char bRead = 0;
793                         ch = 0;
794                         cin >> bRead;
795                         ch = cin.get();
796
797                         if( bRead == 'Y' || bRead == 'y')
798                                 sendOpt.option.mmsSendOpt.bReadReq = true;
799                         else
800                                 sendOpt.option.mmsSendOpt.bReadReq = false;
801
802                         print("\nSet Priority? 'U' : Ugent, 'N' : Normal, 'L' : Low");
803                         char priority = 0;
804                         ch = 0;
805                         cin >> priority;
806                         ch = cin.get();
807
808                         if( priority == 'U' || priority == 'u')
809                                 sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_HIGH;
810                         else if( priority == 'N' || priority == 'n')
811                                 sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_NORMAL;
812                         else if( priority == 'L' || priority == 'l')
813                                 sendOpt.option.mmsSendOpt.priority = MSG_MESSAGE_PRIORITY_LOW;
814
815                         print("\nSet Expiry Time? '0' : Max '1' : 1 Day, '2' : 2 Days, '3' : 1 Week, '4' : 2 Weeks ");
816                         char expiryTime = 0;
817                         ch = 0;
818                         cin >> expiryTime;
819                         ch = cin.get();
820
821                         if( expiryTime == '0')
822                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_MAXIMUM;
823                         else if( expiryTime == '1')
824                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1DAY;
825                         else if( expiryTime == '2')
826                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2DAYS;
827                         else if( expiryTime == '3')
828                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_1WEEK;
829                         else if( expiryTime == '4')
830                                 sendOpt.option.mmsSendOpt.expiryTime = MSG_EXPIRY_TIME_2WEEKS;
831
832                         print("\nSet Delivery Time? '0' : Immediately '1' : 1 Hour, '2' : 1 Day, '3' : 1 Week ");
833                         char deliveryTime = 0;
834                         ch = 0;
835                         cin >> deliveryTime;
836                         ch = cin.get();
837
838                         if( expiryTime == '0')
839                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_IMMEDIATLY;
840                         else if( expiryTime == '1')
841                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1HOUR;
842                         else if( expiryTime == '2')
843                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1DAY;
844                         else if( expiryTime == '3')
845                                 sendOpt.option.mmsSendOpt.deliveryTime = MSG_DELIVERY_TIME_1WEEK;
846
847                 }
848         }
849         else            /* In case of No setting per Message, Set Message option with Global Setting value */
850         {
851                 sendOpt.bSetting = false;
852         }
853
854         err = msg_update_message(hMsgHandle, pMsg, &sendOpt);
855
856         if (err == MSG_SUCCESS)
857                 print("Update Message is OK!");
858         else
859                 print("Update Message is failed!");
860 }
861
862
863 void MsgTestMoveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T MsgId)
864 {
865         if (hMsgHandle == NULL)
866         {
867                 MSG_DEBUG("Handle is NULL");
868                 return;
869         }
870
871         MSG_ERROR_T err = MSG_SUCCESS;
872
873         char strFolder[3];
874
875         print("======================================");
876
877         for (int i = 3; i < g_folderList.nCount; i++)
878                 printf("[%d] %s", g_folderList.folderInfo[i].folderId, g_folderList.folderInfo[i].folderName);
879
880         print("======================================");
881
882         print("Select Folder :");
883
884         memset(strFolder, 0x00, sizeof(strFolder));
885         cin.getline(strFolder, 3);
886
887         int nFolder = atoi(strFolder);
888
889         if (nFolder <= 3 || nFolder > g_folderList.nCount)
890         {
891                 print("Select Wrong Folder!!!");
892         }
893         else
894         {
895                 err = msg_move_msg_to_folder(hMsgHandle, MsgId, nFolder);
896
897                 if (err == MSG_SUCCESS)
898                         print("Moving Message is OK!");
899                 else
900                         print("Moving Message is failed!");
901         }
902 }
903
904 void MsgTestMoveStorageMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pmsg)
905 {
906         if (hMsgHandle == NULL)
907         {
908                 MSG_DEBUG("Handle is NULL");
909                 return;
910         }
911
912         MSG_ERROR_T err = MSG_SUCCESS;
913
914         if(msg_is_in_sim(pmsg))
915                 err = msg_move_msg_to_storage( hMsgHandle, msg_get_message_id(pmsg), MSG_STORAGE_PHONE);
916         else
917                 err = msg_move_msg_to_storage( hMsgHandle, msg_get_message_id(pmsg), MSG_STORAGE_SIM);
918
919         if (err == MSG_SUCCESS)
920                 print("Moving Message is OK!");
921         else
922                 print("Moving Message is failed!");
923 }
924
925
926 void MsgTestAddFolder(MSG_HANDLE_T hMsgHandle)
927 {
928         if (hMsgHandle == NULL)
929         {
930                 MSG_DEBUG("Handle is NULL");
931                 return;
932         }
933
934         MSG_ERROR_T err = MSG_SUCCESS;
935
936         // Make Folder
937         MSG_FOLDER_INFO_S folderInfo = {};
938
939         folderInfo.folderId = 0;
940         folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
941
942         print("Input Folder Name :");
943
944         char strName[MAX_FOLDER_NAME_SIZE+1];
945         memset(strName, 0x00, sizeof(strName));
946
947         cin.getline(strName, MAX_FOLDER_NAME_SIZE);
948
949         strncpy(folderInfo.folderName, strName, MAX_FOLDER_NAME_SIZE);
950
951         MSG_DEBUG("folderId [%d]", folderInfo.folderId);
952         MSG_DEBUG("folderType [%d]", folderInfo.folderType);
953         MSG_DEBUG("folderName [%s]", folderInfo.folderName);
954
955         print("Start Creating New Folder...");
956
957         err = msg_add_folder(hMsgHandle, &folderInfo);
958
959         if (err == MSG_SUCCESS)
960                 print("Creating New Folder is OK!");
961         else
962                 print("Creating New Folder is failed!");
963 }
964
965
966 void MsgTestUpdateFolder(MSG_HANDLE_T hMsgHandle)
967 {
968         if (hMsgHandle == NULL)
969         {
970                 MSG_DEBUG("Handle is NULL");
971                 return;
972         }
973
974         MSG_ERROR_T err = MSG_SUCCESS;
975
976         // Make Folder
977         MSG_FOLDER_INFO_S folderInfo;
978
979         print("Select Folder to Update :");
980
981         char strId[3];
982         memset(strId, 0x00, sizeof(strId));
983
984         cin.getline(strId, 3);
985
986         folderInfo.folderId = atoi(strId);
987
988         if (folderInfo.folderId <= MSG_DRAFT_ID)
989         {
990                 print("Wrong Folder ID!!");
991                 return;
992         }
993
994         folderInfo.folderType = g_folderList.folderInfo[folderInfo.folderId-1].folderType;
995
996         print("Input New Folder Name :");
997
998         char strName[MAX_FOLDER_NAME_SIZE+1];
999         memset(strName, 0x00, sizeof(strName));
1000
1001         cin.getline(strName, MAX_FOLDER_NAME_SIZE);
1002
1003         strncpy(folderInfo.folderName, strName, MAX_FOLDER_NAME_SIZE);
1004
1005         MSG_DEBUG("folderId [%d]", folderInfo.folderId);
1006         MSG_DEBUG("folderType [%d]", folderInfo.folderType);
1007         MSG_DEBUG("folderName [%s]", folderInfo.folderName);
1008
1009         print("Start Updating Folder...");
1010
1011         err = msg_update_folder(hMsgHandle, &folderInfo);
1012
1013         if (err == MSG_SUCCESS)
1014                 print("Updating Folder is OK!");
1015         else
1016                 print("Updating Folder is failed!");
1017 }
1018
1019
1020 void MsgTestDeleteFolder(MSG_HANDLE_T hMsgHandle)
1021 {
1022         if (hMsgHandle == NULL)
1023         {
1024                 MSG_DEBUG("Handle is NULL");
1025                 return;
1026         }
1027
1028         MSG_ERROR_T err = MSG_SUCCESS;
1029
1030         print("Select Folder to Delete :");
1031
1032         char strId[3];
1033         memset(strId, 0x00, sizeof(strId));
1034
1035         cin.getline(strId, 3);
1036
1037         MSG_FOLDER_ID_T folderId = atoi(strId);
1038
1039         if (folderId <= MSG_DRAFT_ID)
1040         {
1041                 print("Wrong Folder ID!!");
1042                 return;
1043         }
1044
1045         print("Start Deleting Folder...");
1046
1047         err = msg_delete_folder(hMsgHandle, folderId);
1048
1049         if (err == MSG_SUCCESS)
1050                 print("Deleting Folder is OK!");
1051         else
1052                 print("Deleting Folder is failed!");
1053 }
1054
1055
1056 void MsgTestDeleteMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1057 {
1058         msg_mms_send_read_report(hMsgHandle, nMsgId, MSG_READ_REPORT_IS_DELETED);
1059
1060         if (msg_delete_message(hMsgHandle, nMsgId) != MSG_SUCCESS)
1061                 print("Failed to delete Message");
1062 }
1063
1064
1065 void MsgTestForwardMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1066 {
1067         msg_message_t msg = msg_new_message();
1068
1069         MSG_SENDINGOPT_S sendOpt = {0};
1070
1071         if (msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt) != MSG_SUCCESS)
1072         {
1073                 print("Failed to get Message");
1074                 msg_release_message(&msg);
1075                 return;
1076         }
1077
1078         // Update Read Status
1079         msg_update_read_status(hMsgHandle, msg_get_message_id(msg), true);
1080
1081         // send read report
1082         msg_mms_send_read_report(hMsgHandle, nMsgId, MSG_READ_REPORT_IS_READ);
1083
1084         // read address from stdin
1085         char strNumber[MAX_ADDRESS_VAL_LEN];
1086
1087         memset(strNumber, 0x00, sizeof(strNumber));
1088
1089         printf("\nInput Recipient Number. Press 'N' if you don't want : \n");
1090
1091         cin.getline(strNumber, 1024);
1092
1093         if (!strcmp(strNumber, "N"))
1094         {
1095                 msg_release_message(&msg);
1096                 return;
1097         }
1098
1099         // write address
1100         msg_reset_address(msg);
1101         msg_add_address(msg, strNumber, MSG_RECIPIENTS_TYPE_TO);
1102
1103         // write subject for forward msg
1104         char strSubject[MAX_SUBJECT_LEN] = {0};
1105         snprintf(strSubject, MAX_SUBJECT_LEN, "FW: %s", msg_get_subject(msg));
1106         msg_set_subject(msg, strSubject);
1107
1108         // forward the message
1109         MSG_REQUEST_S req = {0};
1110         req.msg = msg;
1111         req.sendOpt = sendOpt;
1112
1113         if (msg_mms_forward_message(hMsgHandle, &req) != MSG_SUCCESS)
1114                 printf("Failed to Forward Message\n");
1115
1116         msg_release_message(&msg);
1117 }
1118
1119
1120 void MsgTestRetrieveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1121 {
1122         if (hMsgHandle == NULL)
1123         {
1124                 MSG_DEBUG("Handle is NULL");
1125                 return;
1126         }
1127
1128         MSG_ERROR_T err = MSG_SUCCESS;
1129
1130         msg_message_t msg = msg_new_message();
1131         MSG_SENDINGOPT_S sendOpt = {0};
1132
1133         err = msg_get_message(hMsgHandle, nMsgId, msg, &sendOpt);
1134
1135         msg_update_read_status(hMsgHandle, msg_get_message_id(msg), true);
1136
1137         if( err != MSG_SUCCESS)
1138                 print("Get Message Failed!");
1139
1140         MSG_REQUEST_S req = {0, msg, sendOpt};
1141
1142         err = msg_mms_retrieve_message(hMsgHandle, &req);
1143
1144         if( err != MSG_SUCCESS)
1145                 print("Retrieve MMS Message Failed!");
1146 }
1147
1148 /* reject_msg_support */
1149 void MsgTestRejectMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1150 {
1151         if (hMsgHandle == NULL)
1152         {
1153                 MSG_DEBUG("Handle is NULL");
1154                 return;
1155         }
1156
1157         MSG_ERROR_T err = MSG_SUCCESS;
1158
1159         msg_message_t msg = msg_new_message();
1160         MSG_SENDINGOPT_S sendOpt = {0, };
1161
1162         err = msg_get_message(hMsgHandle, nMsgId, msg, &sendOpt);
1163
1164         if( err != MSG_SUCCESS)
1165                 print("Get Message Failed!");
1166
1167         MSG_REQUEST_S req = {0};
1168         req.msg = msg;
1169         req.sendOpt = sendOpt;
1170
1171         err = msg_mms_reject_message(hMsgHandle, &req);
1172
1173         if( err != MSG_SUCCESS)
1174                 print("Retrieve MMS Message Failed!");
1175
1176         msg_release_message(&msg);
1177 }
1178 /* reject_msg_support */
1179
1180 void MsgTestUpdateMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1181 {
1182         MSG_DEBUG("Update MMS Message");
1183
1184         if (hMsgHandle == NULL)
1185         {
1186                 MSG_DEBUG("Handle is NULL");
1187                 return;
1188         }
1189
1190         MSG_ERROR_T err = MSG_SUCCESS;
1191
1192         msg_message_t msg = msg_new_message();
1193
1194         MSG_SENDINGOPT_S sendOpt = {0};
1195
1196         err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt);
1197
1198         if (err != MSG_SUCCESS)
1199         {
1200                 print("Get Message Failed!");
1201                 msg_release_message(&msg);
1202
1203                 return;
1204         }
1205
1206         MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
1207
1208         msg_mms_get_message_body(msg, msgBody);
1209
1210         msg_mms_add_attachment(msgBody, (char*)"/opt/etc/msg-service/P091120_104633.jpg");
1211         msg_mms_add_attachment(msgBody, (char*)"/opt/etc/msg-service/audio.amr");
1212
1213         msg_mms_set_message_body(msg, msgBody);
1214
1215         time_t curTime = time(NULL);
1216         msg_set_time(msg, curTime);
1217         msg_set_network_status(msg, MSG_NETWORK_NOT_SEND);
1218         msg_set_read_status(msg, false);
1219         msg_set_protect_status(msg, false);
1220         msg_set_direction_info(msg, MSG_DIRECTION_TYPE_MO);
1221
1222         err= msg_update_message(hMsgHandle, msg, &sendOpt);
1223
1224         msg_mms_destroy_message(msgBody);
1225
1226         msg_release_message(&msg);
1227 }
1228
1229
1230 void MsgPrintMMSBody(msg_message_t pMsg)
1231 {
1232         MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
1233         msg_mms_get_message_body(pMsg, msgBody);
1234
1235         //Multipart Related
1236         if (msgBody->pageCnt)
1237         {
1238                 printf("multipart type: Multipart Related\n");
1239
1240                 //Print root-layout info
1241                 printf("\n** ROOT LAYOUT INFO **\n");
1242                 printf("width: %d %s\nheight: %d %s\nbgColor:%x\n", msgBody->rootlayout.width.value, msgBody->rootlayout.width.bUnitPercent ? "%" : "",
1243                          msgBody->rootlayout.height.value,  msgBody->rootlayout.height.bUnitPercent ? "%" : "", msgBody->rootlayout.bgColor);
1244
1245                 // Print Region Info
1246                 printf("\n** REGION INFO **\n");
1247                 printf("Region Count: %d\n", msgBody->regionCnt);
1248
1249                 for(int i = 0; i < msgBody->regionCnt; ++i)
1250                 {
1251                         MMS_SMIL_REGION *pRegion = msg_mms_get_smil_region(msgBody, i);
1252
1253                         printf("%d region id: %s\n%d region left : %d %s\n%d region top : %d %s\n%d region width : %d %s\n%d region height : %d %s\n%d region bgColor : %x\n%d region fit : %s\n",
1254                                 i, pRegion->szID, i, pRegion->nLeft.value, pRegion->nLeft.bUnitPercent ? "%": "", i, pRegion->nTop.value, pRegion->nTop.bUnitPercent ? "%": "",
1255                                 i, pRegion->width.value, pRegion->width.bUnitPercent ? "%": "", i, pRegion->height.value, pRegion->height.bUnitPercent ? "%": "",
1256                                 i, pRegion->bgColor, i, (pRegion->fit == MMSUI_IMAGE_REGION_FIT_MEET) ? "MEET" : "HIDDEN");
1257                 }
1258
1259                 printf("\n** PAGES & CONTENTS INFO **\n");
1260                 printf("PAGE Count: %d\n", msgBody->pageCnt);
1261
1262                 // Print Page info
1263                 for(int i = 0; i< msgBody->pageCnt; ++i)
1264                 {
1265                         MMS_PAGE_S *pPage = msg_mms_get_page(msgBody, i);
1266
1267                         printf("%d page's duration: %d msec \n%d page's media count: %d\n", i, pPage->nDur, i, pPage->mediaCnt);
1268
1269                         // Print Contents Info
1270                         for(int j = 0; j < pPage->mediaCnt; ++j)
1271                         {
1272                                 MMS_MEDIA_S *pMedia = msg_mms_get_media(pPage, j);
1273                                 printf("%d media's filename: %s\n%d media's filepath: %s\n%d media's regionId: %s\n Bold: %d\n Italic: %d\n", j, pMedia->szFileName, j, pMedia->szFilePath, j, pMedia->regionId, pMedia->sMedia.sText.bBold, pMedia->sMedia.sText.bItalic);
1274
1275                                 if (pMedia->drmType != MSG_DRM_TYPE_NONE)
1276                                 {
1277                                         printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", j, pMedia->drmType, j, pMedia->szDrm2FullPath);
1278                                 }
1279                         }
1280                         printf("\n");
1281                 }
1282         }
1283         else
1284         {
1285                 printf("multipart type: Multipart Mixed\n");
1286         }
1287
1288         printf("Attachment Count: %d\n", msgBody->attachCnt);
1289
1290         for(int i = 0; i < msgBody->attachCnt; ++i)
1291         {
1292                 MMS_ATTACH_S *pAttach = msg_mms_get_attachment(msgBody, i);
1293                 printf("Attachment file Name: %s\n", pAttach->szFileName);
1294                 printf("Attachment file Path: %s\n", pAttach->szFilePath);
1295                 printf("Attached file size: %d\n", pAttach->fileSize);
1296
1297                 if (pAttach->drmType != MSG_DRM_TYPE_NONE)
1298                         printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", i, pAttach->drmType, i, pAttach->szDrm2FullPath);
1299         }
1300
1301         /*destroy and free message data*/
1302         msg_mms_destroy_message(msgBody);
1303
1304 }
1305
1306
1307 void MsgPrintMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt)
1308 {
1309         MSG_FOLDER_ID_T folderId = msg_get_folder_id(pMsg);
1310
1311         system ("clear" );
1312
1313         printf("======================================\n");
1314         printf("============== Message ==============\n");
1315         printf("======================================\n");
1316
1317         if (msg_is_mms(pMsg) && msg_get_message_type(pMsg) == MSG_TYPE_MMS_NOTI)
1318         {
1319                 MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
1320
1321                 msg_mms_get_message_body(pMsg, msgBody);
1322
1323                 //Multipart Related
1324                 if (msgBody->pageCnt)
1325                 {
1326                         printf("multipart type: Multipart Related\n");
1327
1328                         //Print root-layout info
1329                         printf("\n** ROOT LAYOUT INFO **\n");
1330                         printf("width: %d %s\nheight: %d %s\nbgColor:%x\n", msgBody->rootlayout.width.value, msgBody->rootlayout.width.bUnitPercent ? "%" : "",
1331                                  msgBody->rootlayout.height.value,  msgBody->rootlayout.height.bUnitPercent ? "%" : "", msgBody->rootlayout.bgColor);
1332
1333                         // Print Region Info
1334                         printf("\n** REGION INFO **\n");
1335                         printf("Region Count: %d\n", msgBody->regionCnt);
1336
1337                         for(int i = 0; i < msgBody->regionCnt; ++i)
1338                         {
1339                                 MMS_SMIL_REGION* pRegion = msg_mms_get_smil_region(msgBody, i);
1340
1341                                 printf("%d region id: %s\n%d region left : %d %s\n%d region top : %d %s\n%d region width : %d %s\n%d region height : %d %s\n%d region bgColor : %x\n %d region fit : %s\n",
1342                                         i, pRegion->szID, i, pRegion->nLeft.value, pRegion->nLeft.bUnitPercent ? "%": "", i, pRegion->nTop.value, pRegion->nTop.bUnitPercent ? "%": "",
1343                                         i, pRegion->width.value, pRegion->width.bUnitPercent ? "%": "", i, pRegion->height.value, pRegion->height.bUnitPercent ? "%": "",
1344                                         i, pRegion->bgColor, i, (pRegion->fit == MMSUI_IMAGE_REGION_FIT_MEET) ? "MEET" : "HIDDEN");
1345                         }
1346
1347                         printf("\n** PAGES & CONTENTS INFO **\n");
1348                         printf("PAGE Count: %d\n", msgBody->pageCnt);
1349
1350                         // Print Page info
1351                         for(int i = 0; i< msgBody->pageCnt; ++i)
1352                         {
1353                                 MMS_PAGE_S* pPage = msg_mms_get_page(msgBody, i);
1354
1355                                 printf("%d page's duration: %d msec \n%d page's media count: %d\n", i, pPage->nDur, i, pPage->mediaCnt);
1356
1357                                 // Print Contents Info
1358                                 for(int j = 0; j < pPage->mediaCnt; ++j)
1359                                 {
1360                                         MMS_MEDIA_S* pMedia = msg_mms_get_media(pPage, j);
1361                                         printf("%d media's filename: %s\n%d media's filepath: %s\n%d media's regionId: %s\n Bold: %d\n Italic: %d\n", j, pMedia->szFileName, j, pMedia->szFilePath, j, pMedia->regionId, pMedia->sMedia.sText.bBold, pMedia->sMedia.sText.bItalic);
1362
1363                                         if(pMedia->drmType != MSG_DRM_TYPE_NONE)
1364                                         {
1365                                                 printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", j, pMedia->drmType, j, pMedia->szDrm2FullPath);
1366                                         }
1367
1368                                 }
1369                                 printf("\n");
1370                         }
1371                 }
1372
1373                 else
1374                 {
1375                         printf("multipart type: Multipart Mixed\n");
1376                 }
1377
1378                 for(int i = 0; i < msgBody->attachCnt; ++i)
1379                 {
1380                         MMS_ATTACH_S*   pAttach = msg_mms_get_attachment(msgBody, i);
1381                         printf("Attachment file Name: %s\n", pAttach->szFileName);
1382                         printf("Attachment file Path: %s\n", pAttach->szFilePath);
1383                         printf("Attached file size: %d\n", pAttach->fileSize);
1384
1385                         if(pAttach->drmType != MSG_DRM_TYPE_NONE)
1386                                 printf("%d media's drmtype: %d (1: Fowward Lock, 2:Combined Delivery, 3: Separated Delivery\n%d media's drmpath: %s\n", i, pAttach->drmType, i, pAttach->szDrm2FullPath);
1387                 }
1388
1389                 char displayTime[32];
1390                 memset(displayTime, 0x00, sizeof(displayTime));
1391
1392                 MsgConvertTime(msg_get_time(pMsg), displayTime);
1393
1394                 printf("date & time: %s\n", displayTime);
1395                 printf("from address: %s\n", msg_get_ith_address(pMsg, 0));
1396
1397                 if(msg_is_sms(pMsg))
1398                 {
1399                         printf("*** SMS Setting Value ***\n");
1400                         printf("Delivery Request : %d\n", pSendOpt->bDeliverReq);
1401                         printf("Reply Path : %d\n", pSendOpt->option.smsSendOpt.bReplyPath);
1402                 }
1403                 else if(msg_is_mms(pMsg))
1404                 {
1405                         printf("Subject: %s\n", msg_get_subject(pMsg));
1406
1407                         char expiryTime[32];
1408                         memset(expiryTime, 0x00, sizeof(expiryTime));
1409
1410                         MsgConvertTime(&(pSendOpt->option.mmsSendOpt.expiryTime), expiryTime);
1411
1412                         printf("*** MMS Setting Value ***\n ");
1413                         printf("Delivery Requeset : %d\n Read Report Request : %d\n Priority : %d\n ExpiryTime : %s\n\n",
1414                                 pSendOpt->bDeliverReq, pSendOpt->option.mmsSendOpt.bReadReq, pSendOpt->option.mmsSendOpt.priority, expiryTime);
1415
1416                         MSG_REPORT_STATUS_INFO_S reportStatus = {};
1417
1418                         msg_get_report_status(hMsgHandle, msg_get_message_id(pMsg), &reportStatus);
1419
1420                         memset(expiryTime, 0x00, sizeof(expiryTime));
1421                         MsgConvertTime(&(reportStatus.deliveryStatusTime), expiryTime);
1422
1423                         printf("Delivery Report Status : %d\n Delivery Report Status Time: %s\n ",
1424                                 reportStatus.deliveryStatus, expiryTime);
1425
1426                         memset(expiryTime, 0x00, sizeof(expiryTime));
1427                         MsgConvertTime(&(reportStatus.readStatusTime), expiryTime);
1428
1429                         printf("Read Report Status : %d\n Read Report Status Time: %s\n ",
1430                                 reportStatus.readStatus, expiryTime);
1431                 }
1432
1433                 printf("======================================\n");
1434                 printf("[R] Reply\n[T] rTreive MMS\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back");
1435
1436                 /*destroy and free message data*/
1437                 msg_mms_destroy_message(msgBody);
1438         }
1439         else if (folderId == MSG_INBOX_ID)
1440         {
1441                 char displayTime[32];
1442                 memset(displayTime, 0x00, sizeof(displayTime));
1443
1444                 MsgConvertTime(msg_get_time(pMsg), displayTime);
1445
1446                 const char* msgText = NULL;
1447
1448                 int msgType = msg_get_message_type(pMsg);
1449
1450                 if (msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS) {
1451                         msgText = msg_mms_get_text_contents(pMsg);
1452                 } else {
1453                         msgText = msg_sms_get_message_body(pMsg);
1454                 }
1455
1456                 printf("message text\n[%s]\n\ndate & time : [%s]\n\naddress : [%s]\nname : [%s]\ncontact ID : [%d]\n",
1457                                            msgText, displayTime, msg_get_ith_address(pMsg, 0), msg_get_ith_name(pMsg, 0), msg_get_ith_contact_id(pMsg, 0));
1458
1459                 if (msg_is_mms(pMsg)) {
1460                         printf("Subject: %s\n", msg_get_subject(pMsg));
1461                         MsgPrintMMSBody(pMsg);
1462                 }
1463
1464                 if(msg_is_in_sim(pMsg))
1465                 {
1466                         printf("\nstorage : [Sim Card]\n");
1467                         printf("======================================\n");
1468 //                      if(msg_get_message_type(pMsg) == MSG_TYPE_SMS_SYNCML)
1469                                 printf("[R] Reply\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Phone\n[P] Protect\n[B] Back\n[I] Install CP Message");
1470 //                      else
1471 //                              printf("[R] Reply\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Phone\n[P] Protect\n[B] Back");
1472                 }
1473                 else
1474                 {
1475                         printf("======================================\n");
1476 //                      if(msg_get_message_type(pMsg) == MSG_TYPE_SMS_SYNCML)
1477                                 printf("[R] Reply\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back\n[I] Install CP Message");
1478 //                      else
1479 //                              printf("[R] Reply\n[T] rTreive MMS\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back");
1480                 }
1481         }
1482         else if (folderId == MSG_OUTBOX_ID)
1483         {
1484                 char displayTime[32];
1485                 memset(displayTime, 0x00, sizeof(displayTime));
1486
1487                 MsgConvertTime(msg_get_time(pMsg), displayTime);
1488
1489                 const char* msgText = NULL;
1490
1491                 int msgType = msg_get_message_type(pMsg);
1492
1493                 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
1494                         msgText = msg_mms_get_text_contents(pMsg);
1495                 else
1496                         msgText = msg_sms_get_message_body(pMsg);
1497
1498                 printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
1499
1500                 int addr_count = msg_get_address_count(pMsg);
1501                 for (int i = 0; i < addr_count; i++)
1502                         printf("address : [%s]\nname : [%s]\ncontact ID : [%d]\n\n", msg_get_ith_address(pMsg, i), msg_get_ith_name (pMsg, i), msg_get_ith_contact_id(pMsg, i) );
1503
1504
1505                 if(msg_is_in_sim(pMsg))
1506                 {
1507                         printf("\nstorage : [Sim Card]\n");
1508                         printf("======================================\n");
1509                         printf("[S] Send\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Phone\n[P] Protect\n[B] Back");
1510                 }
1511                 else
1512                 {
1513                         printf("======================================\n");
1514                         printf("[S] Send\n[F] Forward\n[D] Delete\n[C] Change Folder\n[M] Move to Sim\n[P] Protect\n[B] Back");
1515                 }
1516         }
1517         else if (folderId == MSG_DRAFT_ID)
1518         {
1519                 char displayTime[32];
1520                 memset(displayTime, 0x00, sizeof(displayTime));
1521
1522                 MsgConvertTime(msg_get_time(pMsg), displayTime);
1523
1524                 const char* msgText = NULL;
1525
1526                 int msgType = msg_get_message_type(pMsg);
1527
1528                 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
1529                         msgText = msg_mms_get_text_contents(pMsg);
1530                 else
1531                         msgText = msg_sms_get_message_body(pMsg);
1532
1533                 printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
1534
1535                 int addr_count = msg_get_address_count(pMsg);
1536                 for (int i = 0; i < addr_count; i++)
1537                         printf("address : [%s]\nname : [%s]\ncontact ID : [%d]\n\n", msg_get_ith_address(pMsg, i), msg_get_ith_name (pMsg, i), msg_get_ith_contact_id(pMsg, i));
1538
1539                 printf("======================================\n");
1540                 printf("[S] Send\n[E] Edit\n[D] Delete\n[C] Change Folder\n[P] Protect\n[B] Back");
1541         }
1542         else
1543         {
1544                 char displayTime[32];
1545                 memset(displayTime, 0x00, sizeof(displayTime));
1546
1547                 MsgConvertTime(msg_get_time(pMsg), displayTime);
1548
1549                 const char* msgText = NULL;
1550
1551                 int msgType = msg_get_message_type(pMsg);
1552
1553                 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
1554                         msgText = msg_mms_get_text_contents(pMsg);
1555                 else
1556                         msgText = msg_sms_get_message_body(pMsg);
1557
1558                 printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
1559
1560                 int addr_count = msg_get_address_count(pMsg);
1561                 for (int i = 0; i < addr_count; i++)
1562                         printf("address : [%s]\nname : [%s]\ncontact ID : [%d]\n\n", msg_get_ith_address(pMsg, i), msg_get_ith_name(pMsg, i), msg_get_ith_contact_id(pMsg, i));
1563
1564                 if(msg_is_sms(pMsg))
1565                 {
1566                         printf("*** SMS Setting Value ***\n");
1567                         printf("Delivery Requeset : %d\nReply Path : %d\n", pSendOpt->bDeliverReq, pSendOpt->option.smsSendOpt.bReplyPath);
1568                 }
1569                 else if(msg_is_mms(pMsg))
1570                 {
1571                         printf("Subject: %s\n", msg_get_subject(pMsg));
1572
1573                         char expiryTime[32];
1574                         memset(expiryTime, 0x00, sizeof(expiryTime));
1575
1576                         MsgConvertTime(&(pSendOpt->option.mmsSendOpt.expiryTime), expiryTime);
1577
1578                         printf("*** MMS Setting Value ***\n ");
1579                         printf("Delivery Requeset : %d\n Read Report Request : %d\n Priority : %d\n ExpiryTime : %s\n\n",
1580                                 pSendOpt->bDeliverReq, pSendOpt->option.mmsSendOpt.bReadReq, pSendOpt->option.mmsSendOpt.priority, expiryTime);
1581
1582                         MSG_REPORT_STATUS_INFO_S reportStatus = {};
1583
1584                         msg_get_report_status(hMsgHandle, msg_get_message_id(pMsg), &reportStatus);
1585
1586                         memset(expiryTime, 0x00, sizeof(expiryTime));
1587                         MsgConvertTime(&(reportStatus.deliveryStatusTime), expiryTime);
1588
1589                         printf("Delivery Report Status : %d\n Delivery Report Status Time: %s\n ",
1590                                 reportStatus.deliveryStatus, expiryTime);
1591
1592                         memset(expiryTime, 0x00, sizeof(expiryTime));
1593                         MsgConvertTime(&(reportStatus.readStatusTime), expiryTime);
1594
1595                         printf("Read Report Status : %d\n Read Report Status Time: %s\n ",
1596                                 reportStatus.readStatus, expiryTime);
1597
1598                         MsgPrintMMSBody(pMsg);
1599                 }
1600
1601
1602                 printf("======================================\n");
1603                 printf("[D] Delete\n[P] Protect\n[B] Back");
1604         }
1605
1606         printf("\n======================================\n");
1607         print("Input : ");
1608
1609         char select = 0, ch = 0;
1610
1611         cin >> select;
1612         ch = cin.get();
1613
1614         MsgRunMsgMenu(hMsgHandle, select, pMsg, pSendOpt);
1615 }
1616
1617
1618 void MsgRunMsgMenu(MSG_HANDLE_T hMsgHandle, char Menu, msg_message_t pMsg, MSG_SENDINGOPT_S *pSendOpt)
1619 {
1620         switch (Menu)
1621         {
1622                 case 'R' :
1623                 {
1624
1625
1626                 }
1627                 break;
1628
1629                 case 'T' :
1630                 {
1631
1632                 }
1633
1634                 case 'F' :
1635                 {
1636
1637
1638                 }
1639                 break;
1640
1641                 case 'D' : // Delete Message
1642                 {
1643                         if ( msg_is_protected(pMsg))
1644                                 print("The message is protected. You cannot delete.");
1645                         else
1646                                 msg_delete_message(hMsgHandle, msg_get_message_id(pMsg));
1647                 }
1648                 break;
1649
1650                 case 'C' : // Move Message to other folder
1651                 {
1652                         MsgTestMoveMessage(hMsgHandle, msg_get_message_id(pMsg));
1653                 }
1654                 break;
1655
1656                 case 'M' : // Move to Sim
1657                 {
1658                         MsgTestMoveStorageMessage(hMsgHandle, pMsg);
1659                 }
1660                 break;
1661
1662                 case 'P' :  // Set Protect
1663                 {
1664                         if (msg_is_protected(pMsg))
1665                                 msg_update_protected_status(hMsgHandle, msg_get_message_id(pMsg), false);
1666                         else
1667                                 msg_update_protected_status(hMsgHandle, msg_get_message_id(pMsg), true);
1668                 }
1669                 break;
1670
1671                 case 'S' :
1672                 {
1673                         MsgTestSubmitReq(hMsgHandle, pMsg, NULL); // fuction call to "MsgTestTransport.cpp"
1674                 }
1675                 break;
1676
1677                 case 'E' :
1678                 {
1679                         MsgTestUpdateMessage(hMsgHandle, pMsg);
1680                 }
1681                 break;
1682
1683                 case 'B' :
1684                 break;
1685
1686                 case 'I' :
1687                 {
1688                         //if(msg_get_message_type(pMsg) == MSG_TYPE_SMS_SYNCML)
1689                                 msg_syncml_message_operation(hMsgHandle, (MSG_MESSAGE_ID_T)msg_get_message_id(pMsg));
1690                 }
1691                 break;
1692
1693                 default :
1694                 {
1695                         print("Not Supported Menu");
1696                 }
1697                 break;
1698         }
1699 }
1700
1701
1702 void MsgRunMsgListMenu(MSG_HANDLE_T hMsgHandle, int MsgId, int FolderId, MSG_MESSAGE_TYPE_T MsgType, MSG_NETWORK_STATUS_T NetworkStatus)
1703 {
1704         if (MsgType == MSG_TYPE_SMS || MsgType == MSG_TYPE_SMS_CB || MsgType == MSG_TYPE_SMS_JAVACB ||
1705                 MsgType == MSG_TYPE_SMS_MWI || MsgType == MSG_TYPE_SMS_SYNCML || MsgType == MSG_TYPE_SMS_WAPPUSH)
1706         {
1707                 if (MsgId > 0 && MsgId <= 9999)
1708                 {
1709                         MsgTestGetMessage(hMsgHandle, MsgId);
1710                 }
1711                 else
1712                 {
1713                         print("Not Supported Msg Id");
1714                         return;
1715                 }
1716         }
1717         else if (MsgType == MSG_TYPE_MMS || MsgType == MSG_TYPE_MMS_JAVA || MsgType == MSG_TYPE_MMS_NOTI)
1718         {
1719                 char menu[2];
1720
1721                 if(NetworkStatus == MSG_NETWORK_RETRIEVE_SUCCESS  ||NetworkStatus == MSG_NETWORK_SEND_SUCCESS ||
1722                         NetworkStatus == MSG_NETWORK_SEND_FAIL || NetworkStatus == MSG_NETWORK_SENDING)
1723                 {
1724                         print("======== Select ========");
1725                         print("[R] Read MMS Message");
1726                         print("[F] Forward MMS Message");
1727                         print("[D] Delete MMS Message");
1728                         print("[B] BACK");
1729                         print("====================");
1730                         print("Input : ");
1731                 }
1732                 else if(NetworkStatus == MSG_NETWORK_RETRIEVE_FAIL || NetworkStatus == MSG_NETWORK_RECEIVED)
1733                 {
1734                         print("======== Select ========");
1735                         print("[T] Retrieve MMS Message");
1736                         print("[J] Reject MMS Message");
1737                         print("[D] Delete MMS Message");
1738                         print("[B] BACK");
1739                         print("====================");
1740                         print("Input : ");
1741                 }
1742                 else if(NetworkStatus == MSG_NETWORK_NOT_SEND)
1743                 {
1744                         print("======== Select ========");
1745                         print("[R] Read MMS Message");
1746                         print("[U] Update MMS Message");
1747                         print("[B] BACK");
1748                         print("====================");
1749                         print("Input : ");
1750                 }
1751
1752                 memset(menu, 0x00, sizeof(menu));
1753                 cin.getline(menu, 2);
1754
1755                 if (MsgId <= 0 || MsgId > 9999)
1756                 {
1757                         print("Not Supported Msg Id");
1758                         return;
1759                 }
1760
1761                 if (!strcmp(menu, "R"))
1762                 {
1763                         MsgTestGetMessage(hMsgHandle, MsgId);
1764                 }
1765                 else if (!strcmp(menu, "D"))
1766                 {
1767                         MsgTestDeleteMessage(hMsgHandle, MsgId);
1768                 }
1769                 else if(!strcmp(menu, "F"))
1770                 {
1771                         MsgTestForwardMMSMessage(hMsgHandle, MsgId);
1772                 }
1773                 else if(!strcmp(menu, "T"))
1774                 {
1775                         MsgTestRetrieveMessage(hMsgHandle, MsgId);
1776                 }
1777                 /* reject_msg_support */
1778                 else if(!strcmp(menu, "J"))
1779                 {
1780                         MsgTestRejectMessage(hMsgHandle, MsgId);
1781                 }
1782                 /* reject_msg_support */
1783                 else if(!strcmp(menu, "U"))
1784                 {
1785                         MsgTestUpdateMMSMessage(hMsgHandle, MsgId);
1786                 }
1787                 else if (!strcmp(menu, "B"))
1788                 {
1789                         return;
1790                 }
1791         }
1792 }
1793
1794
1795 void MsgGetCurrentTime(time_t *pTime)
1796 {
1797
1798         time_t curTime;
1799         time(&curTime);
1800         //struct tm timeStruct = {0};
1801         //localtime_r(&curTime, &timeStruct);
1802
1803         //memset(pTime, 0x00, sizeof(pTime));
1804         //sprintf(pTime, "%04d-%02d-%02d %02d:%02d:%02d",
1805         //      timeStruct.tm_year+1900, timeStruct.tm_mon+1, timeStruct.tm_mday,
1806         //      timeStruct.tm_hour, timeStruct.tm_min, timeStruct.tm_sec);
1807
1808         *pTime = curTime;
1809         MSG_DEBUG("Current time is %s", ctime(&curTime));
1810 }
1811
1812
1813 const char* MsgConvertMsgType(MSG_MESSAGE_TYPE_T MsgType)
1814 {
1815         if (MsgType == MSG_TYPE_SMS)
1816                         return "SMS";
1817         else if (MsgType == MSG_TYPE_SMS_CB || MsgType == MSG_TYPE_SMS_JAVACB)
1818                         return "CB";
1819         else if (MsgType == MSG_TYPE_SMS_WAPPUSH)
1820                         return "WAP";
1821         else if (MsgType == MSG_TYPE_SMS_MWI)
1822                         return "MWI";
1823         else if (MsgType == MSG_TYPE_MMS || MsgType == MSG_TYPE_MMS_NOTI)
1824                 return "MMS";
1825
1826         return "UNKNOWN";
1827 }
1828
1829
1830 const char* MsgConvertStorageId(MSG_STORAGE_ID_T StorageId)
1831 {
1832         if (StorageId == MSG_STORAGE_PHONE)
1833                 return "PHONE";
1834         else if (StorageId == MSG_STORAGE_SIM)
1835                 return "SIM";
1836
1837         return "PHONE";
1838 }
1839
1840
1841 const char* MsgConvertNetworkStatus(MSG_NETWORK_STATUS_T status)
1842 {
1843         switch (status)
1844         {
1845                 case MSG_NETWORK_NOT_SEND :
1846                         return "NOT SEND";
1847                 case MSG_NETWORK_SENDING :
1848                         return "SENDING";
1849                 case MSG_NETWORK_SEND_SUCCESS :
1850                         return "SENT";
1851                 case MSG_NETWORK_SEND_FAIL :
1852                         return "FAIL TO SEND";
1853                 case MSG_NETWORK_DELIVER_SUCCESS :
1854                         return "DELIVERED";
1855                 case MSG_NETWORK_DELIVER_FAIL :
1856                         return "FAIL TO DELIVER";
1857                 case MSG_NETWORK_RECEIVED :
1858                         return "RECEIVED";
1859                 case MSG_NETWORK_RETRIEVE_FAIL:
1860                         return "NOT YET RETRIEVED";
1861                 case MSG_NETWORK_RETRIEVE_SUCCESS :
1862                         return "RETRIEVED";
1863                 case MSG_NETWORK_RETRIEVING:
1864                         return "RETRIEVING";
1865                 default :
1866                         return "NOT SEND";
1867         }
1868
1869         return "NOT SEND";
1870 }
1871
1872
1873 const char* MsgConvertReadStatus(bool ReadStatus)
1874 {
1875         if (ReadStatus == true)
1876                 return "READ";
1877         else if (ReadStatus == false)
1878                 return "UNREAD";
1879
1880         return "UNREAD";
1881 }
1882
1883
1884 const char* MsgConvertProtectedStatus(bool ProtectedStatus)
1885 {
1886         if (ProtectedStatus == true)
1887                 return "PROTECTED";
1888         else if (ProtectedStatus == false)
1889                 return "UNPROTECTED";
1890
1891         return "PROTECTED";
1892 }
1893
1894
1895 void MsgConvertTime(time_t *pTime, char *pDisplayTme)
1896 {
1897         struct tm * timeinfo;
1898
1899         tzset();
1900
1901         timeinfo = localtime(pTime);
1902
1903 //      MSG_DEBUG("time  zone is %s", timeinfo->tm_zone);
1904
1905         memset(pDisplayTme, 0x00, sizeof(pDisplayTme));
1906
1907 //      strftime(timeBuff, 32, "%c", timeinfo);
1908
1909         strftime(pDisplayTme, 32, "%Y-%02m-%02d %T %z", timeinfo);
1910 }
1911