3 * Copyright (c) 2000-2012 Samsung Electronics Co., Ltd. All Rights Reserved.
5 * This file is part of msg-service.
7 * Contact: Jaeyun Jeong <jyjeong@samsung.com>
8 * Sangkoo Kim <sangkoo.kim@samsung.com>
9 * Seunghwan Lee <sh.cat.lee@samsung.com>
10 * SoonMin Jung <sm0415.jung@samsung.com>
11 * Jae-Young Lee <jy4710.lee@samsung.com>
12 * KeeBum Kim <keebum.kim@samsung.com>
14 * PROPRIETARY/CONFIDENTIAL
16 * This software is the confidential and proprietary information of
17 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
18 * disclose such Confidential Information and shall use it only in
19 * accordance with the terms of the license agreement you entered
20 * into with SAMSUNG ELECTRONICS.
22 * SAMSUNG make no representations or warranties about the suitability
23 * of the software, either express or implied, including but not limited
24 * to the implied warranties of merchantability, fitness for a particular
25 * purpose, or non-infringement. SAMSUNG shall not be liable for any
26 * damages suffered by licensee as a result of using, modifying or
27 * distributing this software or its derivatives.
32 /*==================================================================================================
34 ==================================================================================================*/
41 #include "MsgMmsTypes.h"
43 #include "MapiStorage.h"
44 #include "MapiSetting.h"
45 #include "MapiMessage.h"
46 #include "MsgTestStorage.h"
47 #include "MsgTestTransport.h"
48 #include "MsgTestThreadView.h"
52 #define MSG_PROFILE_BEGIN(pfid) \
53 unsigned int __prf_l1_##pfid = __LINE__; \
54 struct timeval __prf_1_##pfid; \
55 struct timeval __prf_2_##pfid; \
57 gettimeofday(&__prf_1_##pfid, 0); \
60 #define MSG_PROFILE_END(pfid) \
61 unsigned int __prf_l2_##pfid = __LINE__;\
63 gettimeofday(&__prf_2_##pfid, 0);\
64 long __ds = __prf_2_##pfid.tv_sec - __prf_1_##pfid.tv_sec;\
65 long __dm = __prf_2_##pfid.tv_usec - __prf_1_##pfid.tv_usec;\
66 if ( __dm < 0 ) { __ds--; __dm = 1000000 + __dm; } \
67 printf("**PROFILE** [MSGFW: %s: %s() %u ~ %u] " #pfid " -> Elapsed Time: %u.%06u seconds\n", \
68 rindex(__FILE__, '/')+1, \
72 (unsigned int)(__ds), \
73 (unsigned int)(__dm)); \
77 /*==================================================================================================
78 FUNCTION IMPLEMENTATION
79 ==================================================================================================*/
80 void MsgThreadViewMain(MSG_HANDLE_T hMsgHandle)
82 if (hMsgHandle == NULL)
84 MSG_DEBUG("Handle is NULL");
90 MSG_ERROR_T err = MSG_SUCCESS;
92 MSG_SORT_RULE_S sortRule = {0};
95 sortRule.sortType = MSG_SORT_BY_THREAD_DATE;
96 sortRule.bAscending = false;
98 MSG_THREAD_VIEW_LIST_S threadViewList;
100 char displayTime[32];
104 err = msg_get_thread_view_list(hMsgHandle, NULL, &threadViewList);
106 if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
108 print("Get Message List is failed!");
114 print("======================================");
115 print("============ Thread View =============");
116 print("======================================");
118 if (threadViewList.nCount <= 0)
124 MSG_PROFILE_BEGIN(1);
126 for (int i = 0; i < threadViewList.nCount; i++)
128 memset(displayTime, 0x00, sizeof(displayTime));
130 MsgConvertTime(msg_thread_view_get_time(threadViewList.msgThreadInfo[i]), displayTime);
132 printf("[%04d]\tUnread Msg [%d]\t[%s] [%s] [%s]\n[%s]\tType [%s]\tMessage Text [%s]\n",
133 msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]),
134 msg_thread_view_get_unread_cnt(threadViewList.msgThreadInfo[i]),
135 msg_thread_view_get_address(threadViewList.msgThreadInfo[i]),
136 msg_thread_view_get_name(threadViewList.msgThreadInfo[i]),
138 MsgConvertDirection(msg_thread_view_get_direction(threadViewList.msgThreadInfo[i])),
139 MsgConvertType(msg_thread_view_get_message_type(threadViewList.msgThreadInfo[i])),
140 msg_thread_view_get_data(threadViewList.msgThreadInfo[i]));
142 printf("--------------------------------------------------------\n");
147 print("======================================");
148 print("================ Menu ================");
149 print("======================================");
150 print("[C] Create Message");
151 print("[D] Delete Thread");
153 print("======================================");
157 memset(menu, 0x00, sizeof(menu));
158 cin.getline(menu, 5);
160 if (!strcmp(menu, "C") || !strcmp(menu, "c")) // Add Message
162 MsgTestAddMessage(hMsgHandle);
164 else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
166 print("Choose Thread ID : ");
170 memset(id, 0x00, sizeof(id));
173 print("Do you really wanna delete messages in thread [Y or N] ?");
177 memset(select, 0x00, sizeof(select));
178 cin.getline(select, 2);
180 MSG_PROFILE_BEGIN(3);
181 if (!strcmp(select, "Y") || !strcmp(select, "y"))
182 msg_delete_thread_message_list(hMsgHandle, (MSG_THREAD_ID_T)atoi(id));
185 else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
187 msg_release_thread_view_list(&threadViewList);
188 MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
193 MSG_THREAD_ID_T threadId = atoi(menu);
195 for (int i = 0; i < threadViewList.nCount; i++)
197 if ((MSG_THREAD_ID_T)msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]) == threadId)
199 MsgRunConversationView(hMsgHandle, threadId, msg_thread_view_get_address(threadViewList.msgThreadInfo[i]), msg_thread_view_get_name(threadViewList.msgThreadInfo[i]));
206 msg_release_thread_view_list(&threadViewList);
207 MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
209 while (strcmp(menu, "B"));
213 void MsgSearchViewMain(MSG_HANDLE_T hMsgHandle)
215 if (hMsgHandle == NULL)
217 MSG_DEBUG("Handle is NULL");
221 char menu[5], displayTime[32], searchString[1024];
223 MSG_ERROR_T err = MSG_SUCCESS;
227 print("Search Mode 0:Message 1:Thread :");
229 memset(menu, 0x00, sizeof(menu));
230 cin.getline(menu, 4);
232 int searchType = atoi(menu);
235 print("Input String to Search :");
237 memset(searchString, 0x00, sizeof(searchString));
239 cin.getline(searchString, 1024);
247 print("Target folder (0:ALLBOX 1:INBOX 2:OUTBOX 3:SENTBOX) :");
249 memset(menu, 0x00, sizeof(menu));
250 cin.getline(menu, 4);
252 int folderId = atoi(menu);
255 print("Target message type (0:ALLTYPE 1:SMS 9:MMS) :");
257 memset(menu, 0x00, sizeof(menu));
258 cin.getline(menu, 4);
260 int msgType = atoi(menu);
263 print("Search Result offset (0~) :");
265 memset(menu, 0x00, sizeof(menu));
266 cin.getline(menu, 4);
268 int offset = atoi(menu);
271 print("Search Result limit (0~) :");
273 memset(menu, 0x00, sizeof(menu));
274 cin.getline(menu, 4);
276 int limit = atoi(menu);
278 MSG_SEARCH_CONDITION_S searchCon;
279 memset(&searchCon, 0x00, sizeof(MSG_SEARCH_CONDITION_S));
281 searchCon.msgType = msgType;
282 searchCon.folderId = folderId;
283 searchCon.pSearchVal = searchString;
284 searchCon.pAddressVal = searchString;
286 MSG_PROFILE_BEGIN(_msg_search_message_);
287 err = msg_search_message(hMsgHandle, &searchCon, offset, limit, &msgList);
288 MSG_PROFILE_END(_msg_search_message_);
290 if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
292 print("Get Message List is failed!");
299 print("======================================");
300 print("============ Search View =============");
301 print("======================================");
303 if (msgList.nCount <= 0)
310 for (int i = 0; i < msgList.nCount; i++)
312 memset(displayTime, 0x00, sizeof(displayTime));
314 MsgConvertTime(msg_get_time(msgList.msgInfo[i]), displayTime);
316 const char* msgText = NULL;
318 int msgType = msg_get_message_type(msgList.msgInfo[i]);
320 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
321 msgText = msg_mms_get_text_contents(msgList.msgInfo[i]);
323 msgText = msg_sms_get_message_body(msgList.msgInfo[i]);
325 printf("[%02d]\t[%s %s %s %s] [%s]\t[%s]\nDate [%s]\nMessage Text [%s] \tMessage data size [%d]\n",
326 msg_get_message_id(msgList.msgInfo[i]),
327 MsgConvertMsgType(msg_get_message_type(msgList.msgInfo[i])),
328 MsgConvertStorageId(msg_get_storage_id(msgList.msgInfo[i])),
329 MsgConvertReadStatus(msg_is_read(msgList.msgInfo[i])),
330 MsgConvertProtectedStatus(msg_is_protected(msgList.msgInfo[i])),
331 MsgConvertNetworkStatus(msg_get_network_status(msgList.msgInfo[i])),
332 msg_get_ith_address(msgList.msgInfo[i], 0),
335 msg_get_message_body_size(msgList.msgInfo[i]));
336 printf("--------------------------------------------------------\n");
340 print("======================================");
341 print("================ Menu ================");
342 print("======================================");
343 print("[S] Search Again");
345 print("======================================");
349 memset(menu, 0x00, sizeof(menu));
350 cin.getline(menu, 5);
352 if (!strcmp(menu, "S") || !strcmp(menu, "s"))
356 else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
358 msg_release_message_list(&msgList);
359 MSG_DEBUG("release msg list [%d]", msgList.nCount);
364 int msgId = atoi(menu);
366 MsgTestGetMessage(hMsgHandle, msgId);
370 msg_release_message_list(&msgList);
371 MSG_DEBUG("release msg list [%d]", msgList.nCount);
373 else if(searchType == 1)
376 MSG_THREAD_VIEW_LIST_S threadViewList;
378 MSG_PROFILE_BEGIN(1);
380 err = msg_search_message_for_thread_view(hMsgHandle, searchString, &threadViewList);
384 if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
386 print("Get Message List is failed!");
392 print("======================================");
393 print("============ Search View =============");
394 print("======================================");
396 if (threadViewList.nCount <= 0)
403 for (int i = 0; i < threadViewList.nCount; i++)
405 memset(displayTime, 0x00, sizeof(displayTime));
407 MsgConvertTime(msg_thread_view_get_time(threadViewList.msgThreadInfo[i]), displayTime);
409 printf("[%04d]\tUnread Msg [%d]\t[%s] [%s] [%s] [%s]\n[%s]\tMessage Text [%s]\n",
410 msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]),
411 msg_thread_view_get_unread_cnt(threadViewList.msgThreadInfo[i]),
412 msg_thread_view_get_address(threadViewList.msgThreadInfo[i]),
413 msg_thread_view_get_name(threadViewList.msgThreadInfo[i]),
414 msg_thread_view_get_image_path(threadViewList.msgThreadInfo[i]),
416 MsgConvertDirection(msg_thread_view_get_direction(threadViewList.msgThreadInfo[i])),
417 msg_thread_view_get_data(threadViewList.msgThreadInfo[i]));
419 printf("--------------------------------------------------------\n");
423 print("======================================");
424 print("================ Menu ================");
425 print("======================================");
426 print("[C] Create Message");
427 print("[D] Delete Thread");
428 print("[S] Search Again");
430 print("======================================");
434 memset(menu, 0x00, sizeof(menu));
435 cin.getline(menu, 5);
437 if (!strcmp(menu, "C") || !strcmp(menu, "c")) // Add Message
439 MsgTestAddMessage(hMsgHandle);
441 else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
443 print("Choose Thread ID : ");
447 memset(id, 0x00, sizeof(id));
450 print("Do you really wanna delete messages in thread [Y or N] ?");
454 memset(select, 0x00, sizeof(select));
455 cin.getline(select, 2);
457 if (!strcmp(select, "Y") || !strcmp(select, "y"))
458 msg_delete_thread_message_list(hMsgHandle, (MSG_THREAD_ID_T)atoi(id));
460 else if (!strcmp(menu, "S") || !strcmp(menu, "s"))
464 else if (!strcmp(menu, "B") || !strcmp(menu, "b"))
466 msg_release_thread_view_list(&threadViewList);
467 MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
472 MSG_THREAD_ID_T threadId = atoi(menu);
474 for (int i = 0; i < threadViewList.nCount; i++)
476 if ((MSG_THREAD_ID_T)msg_thread_view_get_thread_id(threadViewList.msgThreadInfo[i]) == threadId)
478 MsgRunConversationView(hMsgHandle, threadId, msg_thread_view_get_address(threadViewList.msgThreadInfo[i]), msg_thread_view_get_name(threadViewList.msgThreadInfo[i]));
485 msg_release_thread_view_list(&threadViewList);
486 MSG_DEBUG("release thread view list [%d]", threadViewList.nCount);
489 while (strcmp(menu, "B"));
493 void MsgRunConversationView(MSG_HANDLE_T hMsgHandle, MSG_THREAD_ID_T ThreadId, const char *pAddress, const char *pName)
497 char displayTime[32];
499 MSG_ERROR_T err = MSG_SUCCESS;
501 MSG_LIST_S convViewList;
505 err = msg_get_conversation_view_list(hMsgHandle, ThreadId, &convViewList);
507 if (err != MSG_SUCCESS && err != MSG_ERR_DB_NORECORD)
509 print("Get Message List is failed!");
515 printf("======================================\n");
516 printf("============ %s ============\n", pAddress);
517 printf("============ %s ============\n", pName);
518 printf("======================================\n");
520 if (convViewList.nCount <= 0)
526 for (int i = 0; i < convViewList.nCount; i++)
528 memset(displayTime, 0x00, sizeof(displayTime));
530 MsgConvertTime(msg_get_time(convViewList.msgInfo[i]), displayTime);
532 const char* msgText = NULL;
534 int msgType = msg_get_message_type(convViewList.msgInfo[i]);
536 if(msgType==MSG_TYPE_MMS_NOTI || msgType==MSG_TYPE_MMS_JAVA || msgType==MSG_TYPE_MMS)
537 msgText = msg_mms_get_text_contents(convViewList.msgInfo[i]);
539 msgText = msg_sms_get_message_body(convViewList.msgInfo[i]);
541 printf("[%04d]\t[%s] [%s]\tText [%s] Attachment count [%d] Date [%s]\n",
542 msg_get_message_id(convViewList.msgInfo[i]),
543 MsgConvertDirection(msg_get_direction_info(convViewList.msgInfo[i])),
544 MsgConvertMsgType(msg_get_message_type(convViewList.msgInfo[i])),
546 msg_get_attachment_count(convViewList.msgInfo[i]),
549 printf("--------------------------------------------------------\n");
553 print("======================================");
554 print("================ Menu ================");
555 print("======================================");
557 print("[D] Delete Message");
559 print("======================================");
563 memset(menu, 0x00, sizeof(menu));
564 cin.getline(menu, 5);
566 if (!strcmp(menu, "R") || !strcmp(menu, "r"))
570 else if (!strcmp(menu, "D") || !strcmp(menu, "d"))
575 msg_release_message_list(&convViewList);
576 MSG_DEBUG("release conversation view list [%d]", convViewList.nCount);
578 while (strcmp(menu, "B") && strcmp(menu, "b"));
582 const char* MsgConvertDirection(MSG_DIRECTION_TYPE_T Direction)
584 if (Direction == MSG_DIRECTION_TYPE_MO)
586 else if (Direction == MSG_DIRECTION_TYPE_MT)
593 const char* MsgConvertType(MSG_MESSAGE_TYPE_T MsgType)
595 if (MsgType == MSG_TYPE_SMS)
597 else if (MsgType == MSG_TYPE_SMS_CB ||MsgType == MSG_TYPE_SMS_JAVACB)
599 else if (MsgType == MSG_TYPE_SMS_WAPPUSH)
601 else if (MsgType == MSG_TYPE_SMS_MWI)
603 else if (MsgType == MSG_TYPE_SMS_SYNCML)
605 else if (MsgType == MSG_TYPE_SMS_REJECT)
607 else if (MsgType == MSG_TYPE_MMS)
609 else if (MsgType == MSG_TYPE_MMS_NOTI)
611 else if (MsgType == MSG_TYPE_MMS_JAVA)