2 * Copyright 2012 Samsung Electronics Co., Ltd
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
8 * http://www.tizenopensource.org/license
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.
18 /*==================================================================================================
20 ==================================================================================================*/
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"
37 MSG_FOLDER_LIST_S g_folderList;
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; \
44 gettimeofday(&__prf_1_##pfid, 0); \
47 #define MSG_PROFILE_END(pfid) \
48 unsigned int __prf_l2_##pfid = __LINE__;\
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, \
59 (unsigned int)(__ds), \
60 (unsigned int)(__dm)); \
63 /*==================================================================================================
64 FUNCTION IMPLEMENTATION
65 ==================================================================================================*/
66 void MsgTestAddMessage(MSG_HANDLE_T hMsgHandle)
68 if (hMsgHandle == NULL)
70 MSG_DEBUG("Handle is NULL");
75 msg_message_t msgInfo = msg_new_message();
76 MSG_SENDINGOPT_S sendOpt = {0, };
78 print("\n===== Input Message =====");
79 print("Input Message Type 0:SMS 1:MMS :");
81 msgType = cin.get(); //&msgType, 1);
82 cin.get(); // consume "enter key"
86 msg_set_message_type(msgInfo, MSG_TYPE_SMS);
88 else if ( msgType == '1' )
90 msg_set_message_type(msgInfo, MSG_TYPE_MMS);
94 MSG_DEBUG("Msg Type input error %d", msgType);
97 print("\nInput Message Sending Option ?. 'Y' : Yes 'N' : No ");
99 char bSendOpt = 0, ch = 0;
103 if( bSendOpt == 'Y' || bSendOpt == 'y')
105 sendOpt.bSetting = true;
107 /* EX : Set SendingOption */
108 if( msg_is_sms(msgInfo) ) //msgInfo.msgType.mainType == MSG_SMS_TYPE)
110 print("\nRequest Delivery Report? Press 'Y' or 'N' :");
116 if( bDelivery == 'Y' || bDelivery == 'y')
117 sendOpt.bDeliverReq = true;
119 sendOpt.bDeliverReq = false;
121 print("\nKeep a Copy? Press 'Y' or 'N' :");
127 if( bKeepCopy == 'Y' || bKeepCopy == 'y')
128 sendOpt.bKeepCopy = true;
130 sendOpt.bKeepCopy = false;
132 print("\nSet Reply Path? Press 'Y' or 'N' :");
138 if( bReplyPath == 'Y' || bReplyPath == 'y')
139 sendOpt.option.smsSendOpt.bReplyPath = true;
141 sendOpt.option.smsSendOpt.bReplyPath = false;
143 else if( msg_is_mms(msgInfo) )//msgInfo.msgType.mainType == MSG_MMS_TYPE)
145 print("\nRequest Delivery Report? Press 'Y' or 'N' :");
151 if( bDelivery == 'Y' || bDelivery == 'y')
152 sendOpt.bDeliverReq = true;
154 sendOpt.bDeliverReq = false;
156 print("\nKeep a Copy? Press 'Y' or 'N' :");
162 if( bKeepCopy == 'Y' || bKeepCopy == 'y')
163 sendOpt.bKeepCopy = true;
165 sendOpt.bKeepCopy = false;
167 print("\nRequest Read Report? Press 'Y' or 'N' :");
173 if( bRead == 'Y' || bRead == 'y')
174 sendOpt.option.mmsSendOpt.bReadReq = true;
176 sendOpt.option.mmsSendOpt.bReadReq = false;
178 print("\nSet Priority? 'U' : Ugent, 'N' : Normal, 'L' : Low");
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;
191 print("\nSet Expiry Time? '0' : Max '1' : 1 Day, '2' : 2 Days, '3' : 1 Week, '4' : 2 Weeks ");
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;
208 print("\nSet Delivery Time? '0' : Immediately '1' : 1 Hour, '2' : 1 Day, '3' : 1 Week ");
209 char deliveryTime = 0;
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;
223 MSG_DEBUG("sendOpt.option.mmsSendOpt.deliveryTime = %lu", sendOpt.option.mmsSendOpt.deliveryTime);
226 else /* In case of No setting per Message, Set Message option with Global Setting value */
228 sendOpt.bSetting = false;
231 MSG_DEBUG("### bSetting = %d ###", sendOpt.bSetting);
232 MSG_DEBUG("MsgType [%d]", msg_get_message_type(msgInfo));
234 if(msg_is_sms(msgInfo)) //msgInfo.msgType.mainType == MSG_SMS_TYPE)
236 print("\n===== Input Message =====");
237 print("Input Message Text :");
240 memset(strMsg, 0x00, sizeof(strMsg));
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");
247 cin.getline(strMsg, 1024);
249 if (msg_sms_set_message_body(msgInfo, strMsg, strlen(strMsg)) != MSG_SUCCESS)
255 else if(msg_is_mms(msgInfo)) //msgInfo.msgType.mainType == MSG_MMS_TYPE)
257 // Compose MMS Message Body (Text, Image, Sound, Video)
258 //MMS_MESSAGE_DATA_S msgData ={0, };
259 MMS_MESSAGE_DATA_S* mms_data;//msgHandle;
261 MMS_MEDIA_S* media[5];
262 MMS_ATTACH_S* attachment[5];
265 print("\n===== Input Subject =====");
267 char strSubject[120];
269 memset(strSubject, 0x00, sizeof(strSubject));
271 cin.getline(strSubject, 120);
272 subjectLen = strlen(strSubject);
274 msg_set_subject(msgInfo, strSubject);
276 mms_data = msg_mms_create_message();
278 print("\n===== Input Message =====");
279 print("Input Multipart type 0: Multiprat Related, 1:Multipart Mixed");
281 unsigned int multipartType;
282 multipartType = cin.get();
283 cin.get(); // consume "enter key"
285 if(multipartType == '0')
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);
291 //------------> 1st Slide Composing
292 page[0] = msg_mms_add_page(mms_data, 5440);
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;
301 //------------> 2nd Slide Composing
302 page[1] = msg_mms_add_page(mms_data, 4544);
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);
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");
320 MSG_DEBUG("nSize = %d", nSize);
322 msg_mms_set_message_body(msgInfo, mms_data);
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);
330 msg_mms_destroy_message(mms_data);
335 char strNumber[MAX_ADDRESS_VAL_LEN];
336 memset(strNumber, 0x00, MAX_ADDRESS_VAL_LEN);
338 print("\n===== Add Recipient =====");
340 while (nToCnt < MAX_TO_ADDRESS_CNT)
342 print("\nInput Recipient Number. Press 'N' if you don't want : ");
344 cin.getline(strNumber, 1024);
346 if (!strcmp(strNumber, "N")) break;
348 MSG_DEBUG("strNumber [%s]", strNumber);
350 if(msg_is_mms(msgInfo)) // in case of MMS
352 print("\n===== Input Recipient Type =====");
353 print("Input Message Type 0:To 1:Cc 2: Bcc :");
355 unsigned int recipientType;
356 recipientType = cin.get(); //&msgType, 1);
357 cin.get(); // consume "enter key"
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);
366 MSG_DEBUG("Recipient Type input error %d", recipientType);
368 else // in case of SMS
369 msg_add_address(msgInfo, strNumber, MSG_RECIPIENTS_TYPE_TO);
374 MSG_DEBUG("nToContactCnt [%d]", msg_get_address_count(msgInfo));
376 if(msg_is_sms(msgInfo))
378 char strReplyAddr[MAX_PHONE_NUMBER_LEN];
379 memset(strReplyAddr, 0x00, MAX_PHONE_NUMBER_LEN);
381 print("\n===== Set Reply Address =====");
383 print("\nInput Reply Number. Press 'N' if you don't want : ");
385 cin.getline(strReplyAddr, 1024);
387 if (!strcmp(strReplyAddr, "N"))
389 print("\nReply Number is not set.");
393 MSG_DEBUG("strReplyAddr [%s]", strReplyAddr);
395 msg_set_reply_address(msgInfo, strReplyAddr);
399 // msg_set_backup_status(msgInfo, true);
403 // msg_set_port(msgInfo, 4010, 0);
405 print("\n======================================");
406 print("[1] Send Message");
407 print("[2] Save Message into Draft");
408 print("[3] Scheduled Message Send");
409 print("======================================");
420 MsgTestSubmitReq(hMsgHandle, msgInfo, &sendOpt);
422 else if (select == 2)
424 print("Start Saving Message...");
428 MsgId = msg_add_message(hMsgHandle, msgInfo, &sendOpt);
430 MSG_DEBUG("Saving Message is Finished![%d]", MsgId);
433 else if (select == 3)
435 MsgTestScheduledSubmitReq(hMsgHandle, msgInfo, &sendOpt);
438 msg_release_message(&msgInfo);
441 void MsgTestMsgGen(MSG_HANDLE_T hMsgHandle)
443 if (hMsgHandle == NULL)
445 MSG_DEBUG("Handle is NULL");
451 print("Input Message Count: ");
453 memset(menu, 0x00, sizeof(menu));
454 cin.getline(menu, 5);
456 unsigned int count = atoi(menu);
458 print("Input Message Type(SMS[1], MMS[2]): ");
460 memset(menu, 0x00, sizeof(menu));
461 cin.getline(menu, 5);
463 MSG_MESSAGE_TYPE_T msgType = MSG_TYPE_INVALID;
466 msgType = MSG_TYPE_SMS;
467 else if (atoi(menu) == 2)
468 msgType = MSG_TYPE_MMS;
470 print("Input folder(INBOX[1], OUTBOX[2], SENTBOX[3], DRAFTBOX[4]): ");
472 memset(menu, 0x00, sizeof(menu));
473 cin.getline(menu, 5);
475 MSG_FOLDER_ID_T folderId = atoi(menu);
477 MSG_ERROR_T err = msg_generate_message(hMsgHandle, msgType, folderId, count);
479 if (err != MSG_SUCCESS)
481 MSG_DEBUG("err [%d]", err);
486 void MsgTestGetMessage(MSG_HANDLE_T hMsgHandle, int MsgId)
488 if (hMsgHandle == NULL)
490 MSG_DEBUG("Handle is NULL");
494 MSG_ERROR_T err = MSG_SUCCESS;
496 msg_message_t msg = msg_new_message();
497 MSG_SENDINGOPT_S sendOpt = {0, };
499 err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)MsgId, msg, &sendOpt);
501 if (err != MSG_SUCCESS)
503 msg_release_message(&msg);
507 // Update Read Status
508 msg_update_read_status(hMsgHandle, MsgId, true);
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);
519 MsgPrintMessage(hMsgHandle, msg, &sendOpt);
521 msg_release_message(&msg);
525 void MsgTestGetMessageList(MSG_HANDLE_T hMsgHandle, int FolderId)
527 if (hMsgHandle == NULL)
529 MSG_DEBUG("Handle is NULL");
535 MSG_ERROR_T err = MSG_SUCCESS;
537 MSG_SORT_RULE_S sortRule = {0};
539 sortRule.sortType = MSG_SORT_BY_READ_STATUS;
540 sortRule.bAscending = false;
542 MSG_LIST_S folderViewList;
544 MSG_MESSAGE_TYPE_T MsgType;
545 MSG_NETWORK_STATUS_T NetworkStatus;
547 char displayTime[32];
548 memset(displayTime, 0x00, sizeof(displayTime));
552 err = msg_get_folder_view_list(hMsgHandle, (MSG_FOLDER_ID_T)FolderId, NULL, &folderViewList);
554 if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
556 print("Get Message List is failed!");
562 printf("======================================\n");
563 for (int i = 0; i < g_folderList.nCount; i++)
565 if (FolderId == g_folderList.folderInfo[i].folderId)
567 printf("=============== %s ===============\n", g_folderList.folderInfo[i].folderName);
571 printf("======================================\n");
573 if (folderViewList.nCount <= 0)
575 printf("Empty...\n");
579 MSG_PROFILE_BEGIN(2);
581 for (int i = 0; i < folderViewList.nCount; i++)
583 memset(displayTime, 0x00, sizeof(displayTime));
585 MsgConvertTime(msg_get_time(folderViewList.msgInfo[i]), displayTime);
587 const char* msgText = NULL;
589 int msgType = msg_get_message_type(folderViewList.msgInfo[i]);
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]);
594 msgText = msg_sms_get_message_body(folderViewList.msgInfo[i]);
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),
606 msg_get_message_body_size(folderViewList.msgInfo[i]));
607 printf("--------------------------------------------------------\n");
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");
623 memset(menu, 0x00, sizeof(menu));
624 cin.getline(menu, 5);
626 if (!strcmp(menu, "C") || !strcmp(menu, "c")) // Add Message
628 MsgTestAddMessage(hMsgHandle);
630 else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
634 printf("Do you really wanna delete all messages [Y or N] ?\n");
636 memset(menu, 0x00, sizeof(menu));
637 cin.getline(menu, 2);
639 if (!strcmp(menu, "Y"))
640 msg_delete_all_msgs_in_folder(hMsgHandle, (MSG_FOLDER_ID_T)FolderId, false);
642 else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
648 int msgId = atoi(menu);
650 for (int i = 0; i < folderViewList.nCount; i++)
652 if ( msg_get_message_id( folderViewList.msgInfo[i] ) == msgId)
654 MsgType = msg_get_message_type(folderViewList.msgInfo[i]);
655 NetworkStatus = msg_get_network_status(folderViewList.msgInfo[i]);
657 MsgRunMsgListMenu(hMsgHandle, msgId, FolderId, MsgType, NetworkStatus);
664 msg_release_message_list(&folderViewList);
665 printf("release folderview list [%d]\n", folderViewList.nCount);
667 while (strcmp(menu, "B"));
671 void MsgTestUpdateMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg)
673 if (hMsgHandle == NULL)
675 MSG_DEBUG("Handle is NULL");
679 MSG_ERROR_T err = MSG_SUCCESS;
681 MSG_SENDINGOPT_S sendOpt = {0, };
683 print("\n===== Input Message =====");
684 print("Input Message Text :");
686 char strMsg[1024] = {0};
688 // strcpy(strMsg, "ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ ABCDEFGHIGKLMNOPQRSTUVWXYZ");
689 cin.getline(strMsg, 1024);
691 msg_sms_set_message_body(pMsg, strMsg, strlen(strMsg));
693 int nToCnt = msg_get_address_count(pMsg);
695 char strNumber[MAX_ADDRESS_VAL_LEN] = {0};
697 printf("\n===== Add Recipient =====\n");
699 MSG_DEBUG("address count [%d]", nToCnt);
703 msg_reset_address(pMsg);
706 printf("\nInput Recipient Number. Press 'N' if you don't want : \n");
708 cin.getline(strNumber, 1024);
710 if (strcmp(strNumber, "N"))
712 MSG_DEBUG("strNumber [%s]", strNumber);
714 msg_add_address(pMsg, strNumber, MSG_RECIPIENTS_TYPE_TO);
716 MSG_DEBUG("contactVal [%s]", msg_get_ith_address(pMsg, 0));
718 MSG_DEBUG("nToContactCnt [%d]", msg_get_address_count(pMsg));
721 print("\nInput Message Sending Option ?. 'Y' : Yes 'N' : No ");
723 char bSendOpt = 0, ch = 0;
727 if( bSendOpt == 'Y' || bSendOpt == 'y')
729 sendOpt.bSetting = true;
731 /* EX : Set SendingOption */
732 if( msg_is_sms(pMsg) )
734 printf("\nRequest Delivery Report? Press 'Y' or 'N' :\n");
740 if( bDelivery == 'Y' || bDelivery == 'y')
741 sendOpt.bDeliverReq = true;
743 sendOpt.bDeliverReq = false;
745 print("\nKeep a Copy? Press 'Y' or 'N' :");
751 if( bKeepCopy == 'Y' || bKeepCopy == 'y')
752 sendOpt.bKeepCopy = true;
754 sendOpt.bKeepCopy = false;
756 print("\nSet Reply Path? Press 'Y' or 'N' :");
762 if( bReplyPath == 'Y' || bReplyPath == 'y')
763 sendOpt.option.smsSendOpt.bReplyPath = true;
765 sendOpt.option.smsSendOpt.bReplyPath = false;
767 else if( msg_is_mms(pMsg) )
769 print("\nRequest Delivery Report? Press 'Y' or 'N' :");
775 if( bDelivery == 'Y' || bDelivery == 'y')
776 sendOpt.bDeliverReq = true;
778 sendOpt.bDeliverReq = false;
780 print("\nKeep a Copy? Press 'Y' or 'N' :");
786 if( bKeepCopy == 'Y' || bKeepCopy == 'y')
787 sendOpt.bKeepCopy = true;
789 sendOpt.bKeepCopy = false;
791 print("\nRequest Read Report? Press 'Y' or 'N' :");
797 if( bRead == 'Y' || bRead == 'y')
798 sendOpt.option.mmsSendOpt.bReadReq = true;
800 sendOpt.option.mmsSendOpt.bReadReq = false;
802 print("\nSet Priority? 'U' : Ugent, 'N' : Normal, 'L' : Low");
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;
815 print("\nSet Expiry Time? '0' : Max '1' : 1 Day, '2' : 2 Days, '3' : 1 Week, '4' : 2 Weeks ");
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;
832 print("\nSet Delivery Time? '0' : Immediately '1' : 1 Hour, '2' : 1 Day, '3' : 1 Week ");
833 char deliveryTime = 0;
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;
849 else /* In case of No setting per Message, Set Message option with Global Setting value */
851 sendOpt.bSetting = false;
854 err = msg_update_message(hMsgHandle, pMsg, &sendOpt);
856 if (err == MSG_SUCCESS)
857 print("Update Message is OK!");
859 print("Update Message is failed!");
863 void MsgTestMoveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T MsgId)
865 if (hMsgHandle == NULL)
867 MSG_DEBUG("Handle is NULL");
871 MSG_ERROR_T err = MSG_SUCCESS;
875 print("======================================");
877 for (int i = 3; i < g_folderList.nCount; i++)
878 printf("[%d] %s", g_folderList.folderInfo[i].folderId, g_folderList.folderInfo[i].folderName);
880 print("======================================");
882 print("Select Folder :");
884 memset(strFolder, 0x00, sizeof(strFolder));
885 cin.getline(strFolder, 3);
887 int nFolder = atoi(strFolder);
889 if (nFolder <= 3 || nFolder > g_folderList.nCount)
891 print("Select Wrong Folder!!!");
895 err = msg_move_msg_to_folder(hMsgHandle, MsgId, nFolder);
897 if (err == MSG_SUCCESS)
898 print("Moving Message is OK!");
900 print("Moving Message is failed!");
904 void MsgTestMoveStorageMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pmsg)
906 if (hMsgHandle == NULL)
908 MSG_DEBUG("Handle is NULL");
912 MSG_ERROR_T err = MSG_SUCCESS;
914 if(msg_is_in_sim(pmsg))
915 err = msg_move_msg_to_storage( hMsgHandle, msg_get_message_id(pmsg), MSG_STORAGE_PHONE);
917 err = msg_move_msg_to_storage( hMsgHandle, msg_get_message_id(pmsg), MSG_STORAGE_SIM);
919 if (err == MSG_SUCCESS)
920 print("Moving Message is OK!");
922 print("Moving Message is failed!");
926 void MsgTestAddFolder(MSG_HANDLE_T hMsgHandle)
928 if (hMsgHandle == NULL)
930 MSG_DEBUG("Handle is NULL");
934 MSG_ERROR_T err = MSG_SUCCESS;
937 MSG_FOLDER_INFO_S folderInfo = {};
939 folderInfo.folderId = 0;
940 folderInfo.folderType = MSG_FOLDER_TYPE_USER_DEF;
942 print("Input Folder Name :");
944 char strName[MAX_FOLDER_NAME_SIZE+1];
945 memset(strName, 0x00, sizeof(strName));
947 cin.getline(strName, MAX_FOLDER_NAME_SIZE);
949 strncpy(folderInfo.folderName, strName, MAX_FOLDER_NAME_SIZE);
951 MSG_DEBUG("folderId [%d]", folderInfo.folderId);
952 MSG_DEBUG("folderType [%d]", folderInfo.folderType);
953 MSG_DEBUG("folderName [%s]", folderInfo.folderName);
955 print("Start Creating New Folder...");
957 err = msg_add_folder(hMsgHandle, &folderInfo);
959 if (err == MSG_SUCCESS)
960 print("Creating New Folder is OK!");
962 print("Creating New Folder is failed!");
966 void MsgTestUpdateFolder(MSG_HANDLE_T hMsgHandle)
968 if (hMsgHandle == NULL)
970 MSG_DEBUG("Handle is NULL");
974 MSG_ERROR_T err = MSG_SUCCESS;
977 MSG_FOLDER_INFO_S folderInfo;
979 print("Select Folder to Update :");
982 memset(strId, 0x00, sizeof(strId));
984 cin.getline(strId, 3);
986 folderInfo.folderId = atoi(strId);
988 if (folderInfo.folderId <= MSG_DRAFT_ID)
990 print("Wrong Folder ID!!");
994 folderInfo.folderType = g_folderList.folderInfo[folderInfo.folderId-1].folderType;
996 print("Input New Folder Name :");
998 char strName[MAX_FOLDER_NAME_SIZE+1];
999 memset(strName, 0x00, sizeof(strName));
1001 cin.getline(strName, MAX_FOLDER_NAME_SIZE);
1003 strncpy(folderInfo.folderName, strName, MAX_FOLDER_NAME_SIZE);
1005 MSG_DEBUG("folderId [%d]", folderInfo.folderId);
1006 MSG_DEBUG("folderType [%d]", folderInfo.folderType);
1007 MSG_DEBUG("folderName [%s]", folderInfo.folderName);
1009 print("Start Updating Folder...");
1011 err = msg_update_folder(hMsgHandle, &folderInfo);
1013 if (err == MSG_SUCCESS)
1014 print("Updating Folder is OK!");
1016 print("Updating Folder is failed!");
1020 void MsgTestDeleteFolder(MSG_HANDLE_T hMsgHandle)
1022 if (hMsgHandle == NULL)
1024 MSG_DEBUG("Handle is NULL");
1028 MSG_ERROR_T err = MSG_SUCCESS;
1030 print("Select Folder to Delete :");
1033 memset(strId, 0x00, sizeof(strId));
1035 cin.getline(strId, 3);
1037 MSG_FOLDER_ID_T folderId = atoi(strId);
1039 if (folderId <= MSG_DRAFT_ID)
1041 print("Wrong Folder ID!!");
1045 print("Start Deleting Folder...");
1047 err = msg_delete_folder(hMsgHandle, folderId);
1049 if (err == MSG_SUCCESS)
1050 print("Deleting Folder is OK!");
1052 print("Deleting Folder is failed!");
1056 void MsgTestDeleteMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1058 msg_mms_send_read_report(hMsgHandle, nMsgId, MSG_READ_REPORT_IS_DELETED);
1060 if (msg_delete_message(hMsgHandle, nMsgId) != MSG_SUCCESS)
1061 print("Failed to delete Message");
1065 void MsgTestForwardMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1067 msg_message_t msg = msg_new_message();
1069 MSG_SENDINGOPT_S sendOpt = {0};
1071 if (msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt) != MSG_SUCCESS)
1073 print("Failed to get Message");
1074 msg_release_message(&msg);
1078 // Update Read Status
1079 msg_update_read_status(hMsgHandle, msg_get_message_id(msg), true);
1082 msg_mms_send_read_report(hMsgHandle, nMsgId, MSG_READ_REPORT_IS_READ);
1084 // read address from stdin
1085 char strNumber[MAX_ADDRESS_VAL_LEN];
1087 memset(strNumber, 0x00, sizeof(strNumber));
1089 printf("\nInput Recipient Number. Press 'N' if you don't want : \n");
1091 cin.getline(strNumber, 1024);
1093 if (!strcmp(strNumber, "N"))
1095 msg_release_message(&msg);
1100 msg_reset_address(msg);
1101 msg_add_address(msg, strNumber, MSG_RECIPIENTS_TYPE_TO);
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);
1108 // forward the message
1109 MSG_REQUEST_S req = {0};
1111 req.sendOpt = sendOpt;
1113 if (msg_mms_forward_message(hMsgHandle, &req) != MSG_SUCCESS)
1114 printf("Failed to Forward Message\n");
1116 msg_release_message(&msg);
1120 void MsgTestRetrieveMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1122 if (hMsgHandle == NULL)
1124 MSG_DEBUG("Handle is NULL");
1128 MSG_ERROR_T err = MSG_SUCCESS;
1130 msg_message_t msg = msg_new_message();
1131 MSG_SENDINGOPT_S sendOpt = {0};
1133 err = msg_get_message(hMsgHandle, nMsgId, msg, &sendOpt);
1135 msg_update_read_status(hMsgHandle, msg_get_message_id(msg), true);
1137 if( err != MSG_SUCCESS)
1138 print("Get Message Failed!");
1140 MSG_REQUEST_S req = {0, msg, sendOpt};
1142 err = msg_mms_retrieve_message(hMsgHandle, &req);
1144 if( err != MSG_SUCCESS)
1145 print("Retrieve MMS Message Failed!");
1148 /* reject_msg_support */
1149 void MsgTestRejectMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1151 if (hMsgHandle == NULL)
1153 MSG_DEBUG("Handle is NULL");
1157 MSG_ERROR_T err = MSG_SUCCESS;
1159 msg_message_t msg = msg_new_message();
1160 MSG_SENDINGOPT_S sendOpt = {0, };
1162 err = msg_get_message(hMsgHandle, nMsgId, msg, &sendOpt);
1164 if( err != MSG_SUCCESS)
1165 print("Get Message Failed!");
1167 MSG_REQUEST_S req = {0};
1169 req.sendOpt = sendOpt;
1171 err = msg_mms_reject_message(hMsgHandle, &req);
1173 if( err != MSG_SUCCESS)
1174 print("Retrieve MMS Message Failed!");
1176 msg_release_message(&msg);
1178 /* reject_msg_support */
1180 void MsgTestUpdateMMSMessage(MSG_HANDLE_T hMsgHandle, MSG_MESSAGE_ID_T nMsgId)
1182 MSG_DEBUG("Update MMS Message");
1184 if (hMsgHandle == NULL)
1186 MSG_DEBUG("Handle is NULL");
1190 MSG_ERROR_T err = MSG_SUCCESS;
1192 msg_message_t msg = msg_new_message();
1194 MSG_SENDINGOPT_S sendOpt = {0};
1196 err = msg_get_message(hMsgHandle, (MSG_MESSAGE_ID_T)nMsgId, msg, &sendOpt);
1198 if (err != MSG_SUCCESS)
1200 print("Get Message Failed!");
1201 msg_release_message(&msg);
1206 MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
1208 msg_mms_get_message_body(msg, msgBody);
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");
1213 msg_mms_set_message_body(msg, msgBody);
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);
1222 err= msg_update_message(hMsgHandle, msg, &sendOpt);
1224 msg_mms_destroy_message(msgBody);
1226 msg_release_message(&msg);
1230 void MsgPrintMMSBody(msg_message_t pMsg)
1232 MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
1233 msg_mms_get_message_body(pMsg, msgBody);
1236 if (msgBody->pageCnt)
1238 printf("multipart type: Multipart Related\n");
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);
1245 // Print Region Info
1246 printf("\n** REGION INFO **\n");
1247 printf("Region Count: %d\n", msgBody->regionCnt);
1249 for(int i = 0; i < msgBody->regionCnt; ++i)
1251 MMS_SMIL_REGION *pRegion = msg_mms_get_smil_region(msgBody, i);
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");
1259 printf("\n** PAGES & CONTENTS INFO **\n");
1260 printf("PAGE Count: %d\n", msgBody->pageCnt);
1263 for(int i = 0; i< msgBody->pageCnt; ++i)
1265 MMS_PAGE_S *pPage = msg_mms_get_page(msgBody, i);
1267 printf("%d page's duration: %d msec \n%d page's media count: %d\n", i, pPage->nDur, i, pPage->mediaCnt);
1269 // Print Contents Info
1270 for(int j = 0; j < pPage->mediaCnt; ++j)
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);
1275 if (pMedia->drmType != MSG_DRM_TYPE_NONE)
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);
1285 printf("multipart type: Multipart Mixed\n");
1288 printf("Attachment Count: %d\n", msgBody->attachCnt);
1290 for(int i = 0; i < msgBody->attachCnt; ++i)
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);
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);
1301 /*destroy and free message data*/
1302 msg_mms_destroy_message(msgBody);
1307 void MsgPrintMessage(MSG_HANDLE_T hMsgHandle, msg_message_t pMsg, MSG_SENDINGOPT_S* pSendOpt)
1309 MSG_FOLDER_ID_T folderId = msg_get_folder_id(pMsg);
1313 printf("======================================\n");
1314 printf("============== Message ==============\n");
1315 printf("======================================\n");
1317 if (msg_is_mms(pMsg) && msg_get_message_type(pMsg) == MSG_TYPE_MMS_NOTI)
1319 MMS_MESSAGE_DATA_S *msgBody = msg_mms_create_message();
1321 msg_mms_get_message_body(pMsg, msgBody);
1324 if (msgBody->pageCnt)
1326 printf("multipart type: Multipart Related\n");
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);
1333 // Print Region Info
1334 printf("\n** REGION INFO **\n");
1335 printf("Region Count: %d\n", msgBody->regionCnt);
1337 for(int i = 0; i < msgBody->regionCnt; ++i)
1339 MMS_SMIL_REGION* pRegion = msg_mms_get_smil_region(msgBody, i);
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");
1347 printf("\n** PAGES & CONTENTS INFO **\n");
1348 printf("PAGE Count: %d\n", msgBody->pageCnt);
1351 for(int i = 0; i< msgBody->pageCnt; ++i)
1353 MMS_PAGE_S* pPage = msg_mms_get_page(msgBody, i);
1355 printf("%d page's duration: %d msec \n%d page's media count: %d\n", i, pPage->nDur, i, pPage->mediaCnt);
1357 // Print Contents Info
1358 for(int j = 0; j < pPage->mediaCnt; ++j)
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);
1363 if(pMedia->drmType != MSG_DRM_TYPE_NONE)
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);
1375 printf("multipart type: Multipart Mixed\n");
1378 for(int i = 0; i < msgBody->attachCnt; ++i)
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);
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);
1389 char displayTime[32];
1390 memset(displayTime, 0x00, sizeof(displayTime));
1392 MsgConvertTime(msg_get_time(pMsg), displayTime);
1394 printf("date & time: %s\n", displayTime);
1395 printf("from address: %s\n", msg_get_ith_address(pMsg, 0));
1397 if(msg_is_sms(pMsg))
1399 printf("*** SMS Setting Value ***\n");
1400 printf("Delivery Request : %d\n", pSendOpt->bDeliverReq);
1401 printf("Reply Path : %d\n", pSendOpt->option.smsSendOpt.bReplyPath);
1403 else if(msg_is_mms(pMsg))
1405 printf("Subject: %s\n", msg_get_subject(pMsg));
1407 char expiryTime[32];
1408 memset(expiryTime, 0x00, sizeof(expiryTime));
1410 MsgConvertTime(&(pSendOpt->option.mmsSendOpt.expiryTime), expiryTime);
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);
1416 MSG_REPORT_STATUS_INFO_S reportStatus = {};
1418 msg_get_report_status(hMsgHandle, msg_get_message_id(pMsg), &reportStatus);
1420 memset(expiryTime, 0x00, sizeof(expiryTime));
1421 MsgConvertTime(&(reportStatus.deliveryStatusTime), expiryTime);
1423 printf("Delivery Report Status : %d\n Delivery Report Status Time: %s\n ",
1424 reportStatus.deliveryStatus, expiryTime);
1426 memset(expiryTime, 0x00, sizeof(expiryTime));
1427 MsgConvertTime(&(reportStatus.readStatusTime), expiryTime);
1429 printf("Read Report Status : %d\n Read Report Status Time: %s\n ",
1430 reportStatus.readStatus, expiryTime);
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");
1436 /*destroy and free message data*/
1437 msg_mms_destroy_message(msgBody);
1439 else if (folderId == MSG_INBOX_ID)
1441 char displayTime[32];
1442 memset(displayTime, 0x00, sizeof(displayTime));
1444 MsgConvertTime(msg_get_time(pMsg), displayTime);
1446 const char* msgText = NULL;
1448 int msgType = msg_get_message_type(pMsg);
1450 if (msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS) {
1451 msgText = msg_mms_get_text_contents(pMsg);
1453 msgText = msg_sms_get_message_body(pMsg);
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));
1459 if (msg_is_mms(pMsg)) {
1460 printf("Subject: %s\n", msg_get_subject(pMsg));
1461 MsgPrintMMSBody(pMsg);
1464 if(msg_is_in_sim(pMsg))
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");
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");
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");
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");
1482 else if (folderId == MSG_OUTBOX_ID)
1484 char displayTime[32];
1485 memset(displayTime, 0x00, sizeof(displayTime));
1487 MsgConvertTime(msg_get_time(pMsg), displayTime);
1489 const char* msgText = NULL;
1491 int msgType = msg_get_message_type(pMsg);
1493 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
1494 msgText = msg_mms_get_text_contents(pMsg);
1496 msgText = msg_sms_get_message_body(pMsg);
1498 printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
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) );
1505 if(msg_is_in_sim(pMsg))
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");
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");
1517 else if (folderId == MSG_DRAFT_ID)
1519 char displayTime[32];
1520 memset(displayTime, 0x00, sizeof(displayTime));
1522 MsgConvertTime(msg_get_time(pMsg), displayTime);
1524 const char* msgText = NULL;
1526 int msgType = msg_get_message_type(pMsg);
1528 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
1529 msgText = msg_mms_get_text_contents(pMsg);
1531 msgText = msg_sms_get_message_body(pMsg);
1533 printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
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));
1539 printf("======================================\n");
1540 printf("[S] Send\n[E] Edit\n[D] Delete\n[C] Change Folder\n[P] Protect\n[B] Back");
1544 char displayTime[32];
1545 memset(displayTime, 0x00, sizeof(displayTime));
1547 MsgConvertTime(msg_get_time(pMsg), displayTime);
1549 const char* msgText = NULL;
1551 int msgType = msg_get_message_type(pMsg);
1553 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
1554 msgText = msg_mms_get_text_contents(pMsg);
1556 msgText = msg_sms_get_message_body(pMsg);
1558 printf("message text\n[%s]\n\ndate & time : [%s]\n\n", msgText, displayTime);
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));
1564 if(msg_is_sms(pMsg))
1566 printf("*** SMS Setting Value ***\n");
1567 printf("Delivery Requeset : %d\nReply Path : %d\n", pSendOpt->bDeliverReq, pSendOpt->option.smsSendOpt.bReplyPath);
1569 else if(msg_is_mms(pMsg))
1571 printf("Subject: %s\n", msg_get_subject(pMsg));
1573 char expiryTime[32];
1574 memset(expiryTime, 0x00, sizeof(expiryTime));
1576 MsgConvertTime(&(pSendOpt->option.mmsSendOpt.expiryTime), expiryTime);
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);
1582 MSG_REPORT_STATUS_INFO_S reportStatus = {};
1584 msg_get_report_status(hMsgHandle, msg_get_message_id(pMsg), &reportStatus);
1586 memset(expiryTime, 0x00, sizeof(expiryTime));
1587 MsgConvertTime(&(reportStatus.deliveryStatusTime), expiryTime);
1589 printf("Delivery Report Status : %d\n Delivery Report Status Time: %s\n ",
1590 reportStatus.deliveryStatus, expiryTime);
1592 memset(expiryTime, 0x00, sizeof(expiryTime));
1593 MsgConvertTime(&(reportStatus.readStatusTime), expiryTime);
1595 printf("Read Report Status : %d\n Read Report Status Time: %s\n ",
1596 reportStatus.readStatus, expiryTime);
1598 MsgPrintMMSBody(pMsg);
1602 printf("======================================\n");
1603 printf("[D] Delete\n[P] Protect\n[B] Back");
1606 printf("\n======================================\n");
1609 char select = 0, ch = 0;
1614 MsgRunMsgMenu(hMsgHandle, select, pMsg, pSendOpt);
1618 void MsgRunMsgMenu(MSG_HANDLE_T hMsgHandle, char Menu, msg_message_t pMsg, MSG_SENDINGOPT_S *pSendOpt)
1641 case 'D' : // Delete Message
1643 if ( msg_is_protected(pMsg))
1644 print("The message is protected. You cannot delete.");
1646 msg_delete_message(hMsgHandle, msg_get_message_id(pMsg));
1650 case 'C' : // Move Message to other folder
1652 MsgTestMoveMessage(hMsgHandle, msg_get_message_id(pMsg));
1656 case 'M' : // Move to Sim
1658 MsgTestMoveStorageMessage(hMsgHandle, pMsg);
1662 case 'P' : // Set Protect
1664 if (msg_is_protected(pMsg))
1665 msg_update_protected_status(hMsgHandle, msg_get_message_id(pMsg), false);
1667 msg_update_protected_status(hMsgHandle, msg_get_message_id(pMsg), true);
1673 MsgTestSubmitReq(hMsgHandle, pMsg, NULL); // fuction call to "MsgTestTransport.cpp"
1679 MsgTestUpdateMessage(hMsgHandle, pMsg);
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));
1695 print("Not Supported Menu");
1702 void MsgRunMsgListMenu(MSG_HANDLE_T hMsgHandle, int MsgId, int FolderId, MSG_MESSAGE_TYPE_T MsgType, MSG_NETWORK_STATUS_T NetworkStatus)
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)
1707 if (MsgId > 0 && MsgId <= 9999)
1709 MsgTestGetMessage(hMsgHandle, MsgId);
1713 print("Not Supported Msg Id");
1717 else if (MsgType == MSG_TYPE_MMS || MsgType == MSG_TYPE_MMS_JAVA || MsgType == MSG_TYPE_MMS_NOTI)
1721 if(NetworkStatus == MSG_NETWORK_RETRIEVE_SUCCESS ||NetworkStatus == MSG_NETWORK_SEND_SUCCESS ||
1722 NetworkStatus == MSG_NETWORK_SEND_FAIL || NetworkStatus == MSG_NETWORK_SENDING)
1724 print("======== Select ========");
1725 print("[R] Read MMS Message");
1726 print("[F] Forward MMS Message");
1727 print("[D] Delete MMS Message");
1729 print("====================");
1732 else if(NetworkStatus == MSG_NETWORK_RETRIEVE_FAIL || NetworkStatus == MSG_NETWORK_RECEIVED)
1734 print("======== Select ========");
1735 print("[T] Retrieve MMS Message");
1736 print("[J] Reject MMS Message");
1737 print("[D] Delete MMS Message");
1739 print("====================");
1742 else if(NetworkStatus == MSG_NETWORK_NOT_SEND)
1744 print("======== Select ========");
1745 print("[R] Read MMS Message");
1746 print("[U] Update MMS Message");
1748 print("====================");
1752 memset(menu, 0x00, sizeof(menu));
1753 cin.getline(menu, 2);
1755 if (MsgId <= 0 || MsgId > 9999)
1757 print("Not Supported Msg Id");
1761 if (!strcmp(menu, "R"))
1763 MsgTestGetMessage(hMsgHandle, MsgId);
1765 else if (!strcmp(menu, "D"))
1767 MsgTestDeleteMessage(hMsgHandle, MsgId);
1769 else if(!strcmp(menu, "F"))
1771 MsgTestForwardMMSMessage(hMsgHandle, MsgId);
1773 else if(!strcmp(menu, "T"))
1775 MsgTestRetrieveMessage(hMsgHandle, MsgId);
1777 /* reject_msg_support */
1778 else if(!strcmp(menu, "J"))
1780 MsgTestRejectMessage(hMsgHandle, MsgId);
1782 /* reject_msg_support */
1783 else if(!strcmp(menu, "U"))
1785 MsgTestUpdateMMSMessage(hMsgHandle, MsgId);
1787 else if (!strcmp(menu, "B"))
1795 void MsgGetCurrentTime(time_t *pTime)
1800 //struct tm timeStruct = {0};
1801 //localtime_r(&curTime, &timeStruct);
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);
1809 MSG_DEBUG("Current time is %s", ctime(&curTime));
1813 const char* MsgConvertMsgType(MSG_MESSAGE_TYPE_T MsgType)
1815 if (MsgType == MSG_TYPE_SMS)
1817 else if (MsgType == MSG_TYPE_SMS_CB || MsgType == MSG_TYPE_SMS_JAVACB)
1819 else if (MsgType == MSG_TYPE_SMS_WAPPUSH)
1821 else if (MsgType == MSG_TYPE_SMS_MWI)
1823 else if (MsgType == MSG_TYPE_MMS || MsgType == MSG_TYPE_MMS_NOTI)
1830 const char* MsgConvertStorageId(MSG_STORAGE_ID_T StorageId)
1832 if (StorageId == MSG_STORAGE_PHONE)
1834 else if (StorageId == MSG_STORAGE_SIM)
1841 const char* MsgConvertNetworkStatus(MSG_NETWORK_STATUS_T status)
1845 case MSG_NETWORK_NOT_SEND :
1847 case MSG_NETWORK_SENDING :
1849 case MSG_NETWORK_SEND_SUCCESS :
1851 case MSG_NETWORK_SEND_FAIL :
1852 return "FAIL TO SEND";
1853 case MSG_NETWORK_DELIVER_SUCCESS :
1855 case MSG_NETWORK_DELIVER_FAIL :
1856 return "FAIL TO DELIVER";
1857 case MSG_NETWORK_RECEIVED :
1859 case MSG_NETWORK_RETRIEVE_FAIL:
1860 return "NOT YET RETRIEVED";
1861 case MSG_NETWORK_RETRIEVE_SUCCESS :
1863 case MSG_NETWORK_RETRIEVING:
1864 return "RETRIEVING";
1873 const char* MsgConvertReadStatus(bool ReadStatus)
1875 if (ReadStatus == true)
1877 else if (ReadStatus == false)
1884 const char* MsgConvertProtectedStatus(bool ProtectedStatus)
1886 if (ProtectedStatus == true)
1888 else if (ProtectedStatus == false)
1889 return "UNPROTECTED";
1895 void MsgConvertTime(time_t *pTime, char *pDisplayTme)
1897 struct tm * timeinfo;
1901 timeinfo = localtime(pTime);
1903 // MSG_DEBUG("time zone is %s", timeinfo->tm_zone);
1905 memset(pDisplayTme, 0x00, sizeof(pDisplayTme));
1907 // strftime(timeBuff, 32, "%c", timeinfo);
1909 strftime(pDisplayTme, 32, "%Y-%02m-%02d %T %z", timeinfo);