From 96e4fff05d89cf411d484dca012c141441e7e634 Mon Sep 17 00:00:00 2001 From: Jaemin Ahn Date: Tue, 27 Aug 2013 10:31:07 +0900 Subject: [PATCH] Set badgeNumber or badgeOffset correctly. Change-Id: I316409bdb424796ac8226024b045009fc49797ed Signed-off-by: Jaemin Ahn --- src/FMsg_PushMessageImpl.cpp | 48 +++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/src/FMsg_PushMessageImpl.cpp b/src/FMsg_PushMessageImpl.cpp index 56cd859..10df019 100755 --- a/src/FMsg_PushMessageImpl.cpp +++ b/src/FMsg_PushMessageImpl.cpp @@ -216,8 +216,11 @@ _PushMessageImpl::ConvertMessageToNotification(const String& message) { result r = E_SUCCESS; int badgeNumber = 0; + String badgeValue; String alertText; + SysLog(NID_MSG, "Set notification with message[%ls]", message.GetPointer()); + r = __notiMessage.SetAppMessage(__text); StringTokenizer tokens(message, _PUSH_MESSAGE_TOKEN_DELIMITER); @@ -227,7 +230,6 @@ _PushMessageImpl::ConvertMessageToNotification(const String& message) String token; String key; String value; - String badgeValue; int delimiterIndex; tokens.GetNextToken(token); @@ -257,29 +259,16 @@ _PushMessageImpl::ConvertMessageToNotification(const String& message) if (IsFailed(r)) continue; - if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_SET, false) == true) - { - r = __notiMessage.SetBadgeNumber(badgeNumber); - if (IsFailed(r)) - continue; - } - else if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_INCREASE, false) == true) - { - r = __notiMessage.SetBadgeOffset(badgeNumber); - if (IsFailed(r)) - continue; - } - else if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_DECREASE, false) == true) + if (badgeNumber < 0) { - r = __notiMessage.SetBadgeOffset(badgeNumber); - if (IsFailed(r)) - continue; + SysLog(NID_MSG, "badgeNumber[%d] is negative, so treat it as '0'", badgeNumber); + badgeNumber = 0; } - else + + if (badgeNumber > MAX_NOTIFICATION_BADGE_NUMBER) { - r = __notiMessage.SetBadgeOffset(0); - if (IsFailed(r)) - continue; + SysLog(NID_MSG, "badgeNumber[%d] is out of range, so treat it as '%d'", badgeNumber, MAX_NOTIFICATION_BADGE_NUMBER); + badgeNumber = MAX_NOTIFICATION_BADGE_NUMBER; } } else if (key.Equals(_PUSH_MESSAGE_KEY_ACTION, false) == true) @@ -323,6 +312,23 @@ _PushMessageImpl::ConvertMessageToNotification(const String& message) } } + + if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_SET, false) == true) + { + r = __notiMessage.SetBadgeNumber(badgeNumber); + SysLog(NID_MSG, "Set badgeNumber[%d] result[%s]", badgeNumber, GetErrorMessage(r)); + } + else if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_INCREASE, false) == true) + { + r = __notiMessage.SetBadgeOffset(badgeNumber); + SysLog(NID_MSG, "Set badgeOffset[%d] result[%s]", badgeNumber, GetErrorMessage(r)); + } + else if (badgeValue.Equals(_PUSH_MESSAGE_VALUE_BADGE_DECREASE, false) == true) + { + r = __notiMessage.SetBadgeOffset(-badgeNumber); + SysLog(NID_MSG, "Set badgeOffset[%d] result[%s]", badgeNumber, GetErrorMessage(r)); + } + SysLog(NID_MSG, "The converted value of action is [%d].", __pushAction); SysLog(NID_MSG, "The converted value of badgeOffset is [%d], badgeNumber is [%d].", __notiMessage.GetBadgeOffset(), __notiMessage.GetBadgeNumber()); SysLog(NID_MSG, "The converted value of alertText is [%ls], appMessage is [%ls].", (__notiMessage.GetAlertText()).GetPointer(), (__notiMessage.GetAppMessage()).GetPointer()); -- 2.7.4