From: Byounghui Date: Fri, 19 Apr 2013 09:16:39 +0000 (+0900) Subject: Nabi_SE N_SE-35137 X-Git-Tag: accepted/tizen_2.1/20130425.034728^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b492e0364be2011f32c36e1945855112c1650bd;p=framework%2Fosp%2Fmessaging.git Nabi_SE N_SE-35137 Change-Id: I1a569ee4de62602a207382751b93a31351e5ef1f Signed-off-by: Byounghui --- diff --git a/src/FMsg_SmsManagerImpl.cpp b/src/FMsg_SmsManagerImpl.cpp index 84e8dce..b6f52cd 100644 --- a/src/FMsg_SmsManagerImpl.cpp +++ b/src/FMsg_SmsManagerImpl.cpp @@ -383,6 +383,8 @@ _SmsManagerImpl::GetTotalMessageCount(SmsMessageBoxType type) const break; case SMS_MESSAGE_BOX_TYPE_ALL: { + int spamCount = 0; + int draftCount = 0; err = msg_count_msg_by_type(__msgHandle, MSG_TYPE_SMS, &msgCount); if (err != MSG_SUCCESS) @@ -393,7 +395,23 @@ _SmsManagerImpl::GetTotalMessageCount(SmsMessageBoxType type) const return -1; } - SysLog(NID_MSG, "Total count of messages is [%d]", msgCount); + countInfo = msg_create_struct(MSG_STRUCT_COUNT_INFO); + + err = msg_count_message(__msgHandle, MSG_SPAMBOX_ID , countInfo); + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to get the message count of the message box (%d)", GetErrorMessage(r), (int) type); + msg_get_int_value(countInfo, MSG_COUNT_INFO_SMS_INT, &spamCount); + + err = msg_count_message(__msgHandle, MSG_DRAFT_ID , countInfo); + r = ConvertException(err); + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to get the message count of the message box (%d)", GetErrorMessage(r), (int) type); + msg_get_int_value(countInfo, MSG_COUNT_INFO_SMS_INT, &draftCount); + + msg_release_struct(&countInfo); + + msgCount = msgCount - spamCount - draftCount; + SysLog(NID_MSG, "Total count of messages is [%d] , spam[%d], draft[%d]",msgCount, spamCount, draftCount); + return msgCount; } break; @@ -406,21 +424,21 @@ _SmsManagerImpl::GetTotalMessageCount(SmsMessageBoxType type) const // get the count of corresponding message box countInfo = msg_create_struct(MSG_STRUCT_COUNT_INFO); err = msg_count_message(__msgHandle, folderType, countInfo); - - if (err != MSG_SUCCESS) - { r = ConvertException(err); - SysLogException(NID_MSG, r, "[%s] Failed to get the message count of the message box (%d)", GetErrorMessage(r), (int) type); - msg_release_struct(&countInfo); - SetLastResult(r); - return -1; - } + SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] Failed to get the message count of the message box (%d)", GetErrorMessage(r), (int) type); msg_get_int_value(countInfo, MSG_COUNT_INFO_SMS_INT, &msgCount); msg_release_struct(&countInfo); SysLog(NID_MSG, "Total count of messages is [%d]", msgCount); return msgCount; + + +CATCH: + + msg_release_struct(&countInfo); + return -1; + } Tizen::Base::Collection::IList* @@ -547,7 +565,7 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St ArrayList* pList = NULL; msg_struct_list_s msgList = {0}; msg_struct_t searchCon = NULL; - + int tempCount = 0; ClearLastResult(); pList = new (std::nothrow) ArrayList(); @@ -559,6 +577,7 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St // type folderId = _MsgUtil::GetMsgFolderId(type); + SysLog(NID_MSG, "box type [%d]", (int)type); // Set Condition searchCon = msg_create_struct(MSG_STRUCT_SEARCH_CONDITION); @@ -579,17 +598,16 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St r = ConvertException(err); SysTryCatch(NID_MSG, r == E_SUCCESS, , r, "[%s] msg_search_message call failed.", GetErrorMessage(r)); - totalResultCount = msgList.nCount; - - SysLog(NID_MSG, "Total Search count of messages is [%d]", totalResultCount); - for (int index = 0; index < totalResultCount; index++) + for (int index = 0; index < msgList.nCount; index++) { SmsMessage* pSmsMessage = null; + if (type == SMS_MESSAGE_BOX_TYPE_ALL) { err = msg_get_int_value(msgList.msg_struct_info[index], MSG_MESSAGE_FOLDER_ID_INT, &folderId); + SysLog(NID_MSG, "Folder [%d]", folderId); switch (folderId) { @@ -605,24 +623,29 @@ _SmsManagerImpl::SearchMessageBoxN(SmsMessageBoxType type, const Tizen::Base::St pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList.msg_struct_info[index]); break; - case MSG_DRAFT_ID: - //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList.msg_struct_info[index]); - break; - - case MSG_ALLBOX_ID: - //pSmsMessage = _MsgUtil::ConvertSmsMessageN(SMS_MESSAGE_BOX_TYPE_SENTBOX, msgList.msg_struct_info[index]); + default: break; } - // add the item to the list + if (pSmsMessage) + { + tempCount++; pList->Add(*pSmsMessage); } + } else { pSmsMessage = _MsgUtil::ConvertSmsMessageN(type, msgList.msg_struct_info[index]); + if (pSmsMessage) + { + tempCount++; pList->Add(*pSmsMessage); } + + } } + totalResultCount = tempCount; + SysLog(NID_MSG, "Total Search count of messages is [%d] original [%d]", totalResultCount , msgList.nCount ); if (pSearchString) { @@ -654,6 +677,7 @@ CATCH: msg_release_struct(&searchCon); msg_release_list_struct(&msgList); + totalResultCount = 0; return null; }