break;
case SMS_MESSAGE_BOX_TYPE_ALL:
{
- int spamCount = 0;
- int draftCount = 0;
- err = msg_count_msg_by_type(__msgHandle, MSG_TYPE_SMS, &msgCount);
+ int inbox = 0;
+ int outbox = 0;
+ int sentbox =0;
- if (err != MSG_SUCCESS)
- {
- r = ConvertException(err);
- SysLogException(NID_MSG, r, "[%s] Failed to get the message count", GetErrorMessage(r));
- SetLastResult(r);
- return -1;
- }
countInfo = msg_create_struct(MSG_STRUCT_COUNT_INFO);
- err = msg_count_message(__msgHandle, MSG_SPAMBOX_ID , countInfo);
+ err = msg_count_message(__msgHandle, MSG_INBOX_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);
+ msg_get_int_value(countInfo, MSG_COUNT_INFO_SMS_INT, &inbox);
- err = msg_count_message(__msgHandle, MSG_DRAFT_ID , countInfo);
+ err = msg_count_message(__msgHandle, MSG_OUTBOX_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, &outbox);
+
+ err = msg_count_message(__msgHandle, MSG_SENTBOX_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_get_int_value(countInfo, MSG_COUNT_INFO_SMS_INT, &sentbox);
msg_release_struct(&countInfo);
- msgCount = msgCount - spamCount - draftCount;
- SysLog(NID_MSG, "Total count of messages is [%d] , spam[%d], draft[%d]",msgCount, spamCount, draftCount);
+ msgCount = inbox + outbox + sentbox;
+ SysLog(NID_MSG, "Total count of messages is [%d] , inbox[%d], outbox[%d], sentbox[%d]",msgCount, inbox, outbox, sentbox);
return msgCount;
}
{
_SmsMmsCallbackHandler* _SmsMmsCallbackHandler::__pMessageCallbackHandler = 0;
+bool _SmsMmsCallbackHandler::__destroyed = false;
_SmsMmsCallbackHandler::_SmsMmsCallbackHandler(void)
: __msgHandle(0)
SysTryReturnResult(NID_MSG, __pTempCbsChannelList != null, E_OUT_OF_MEMORY, "memory allocation failed");
r = __pTempCbsChannelList->Construct();
SysTryReturnResult(NID_MSG, r == E_SUCCESS, r, "Failed to construct an ArrayList");
+ std::atexit(CloseCbsSettingsHandle);
return r;
}
_SmsMmsCallbackHandler::~_SmsMmsCallbackHandler(void)
{
+
if (__msgHandle)
{
msg_close_msg_handle(&__msgHandle);
_SmsMmsCallbackHandler*
_SmsMmsCallbackHandler::GetInstance(void)
{
+ SysTryReturn(NID_MSG, __destroyed == false, null, E_SYSTEM, "Instance Dead");
+
result r = E_SUCCESS;
-
+
if (!__pMessageCallbackHandler)
{
__pMessageCallbackHandler = new (std::nothrow) _SmsMmsCallbackHandler();
return err;
}
-int
+void
_SmsMmsCallbackHandler::CloseCbsSettingsHandle()
{
- int err = MSG_SUCCESS;
-
- if (__cbsSettingsHandle)
- {
- err = msg_release_struct(&__cbsSettingsHandle);
- __cbsSettingsHandle = 0;
- }
- if (__pTempCbsChannelList)
+ if (__pMessageCallbackHandler)
{
- if (__pTempCbsChannelList->GetCount() > 0)
- {
- __pTempCbsChannelList->RemoveAll(true);
- }
- delete __pTempCbsChannelList;
- __pTempCbsChannelList = null;
+ delete __pMessageCallbackHandler;
+ __pMessageCallbackHandler = null;
}
+ __destroyed = true;
- return err;
}
void