2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FApp_NotificationMessageImpl.cpp
20 * @brief This is the placeholder for _NotificationMessageImpl class.
23 #include <FBaseBoolean.h>
24 #include <FBaseInteger.h>
25 #include <FBaseSysLog.h>
27 #include <FAppNotificationManager.h>
28 #include <FAppNotificationMessage.h>
30 #include <FBaseInternalTypes.h>
31 #include "FApp_NotificationMessageImpl.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Io;
37 namespace Tizen { namespace App
40 _NotificationMessageImpl::_NotificationMessageImpl(bool appBinding)
45 , __activityType(ONGOING_ACTIVITY_TYPE_TEXT)
49 _NotificationMessageImpl::_NotificationMessageImpl(const _NotificationMessageImpl& notificationMessage)
50 : __appBinding(notificationMessage.__appBinding)
51 , __badgeNumber(notificationMessage.__badgeNumber)
52 , __badgeOffset(notificationMessage.__badgeOffset)
53 , __progressValue(notificationMessage.__progressValue)
54 , __activityType(notificationMessage.__activityType)
55 , __alertText(notificationMessage.__alertText)
56 , __appMessage(notificationMessage.__appMessage)
57 , __titleText(notificationMessage.__titleText)
58 , __iconFilePath(notificationMessage.__iconFilePath)
59 , __soundFilePath(notificationMessage.__soundFilePath)
63 _NotificationMessageImpl::~_NotificationMessageImpl()
67 _NotificationMessageImpl&
68 _NotificationMessageImpl::operator =(const _NotificationMessageImpl& notificationMessage)
70 if (this != ¬ificationMessage)
72 __appBinding = notificationMessage.__appBinding;
73 __badgeNumber = notificationMessage.__badgeNumber;
74 __badgeOffset = notificationMessage.__badgeOffset;
75 __progressValue = notificationMessage.__progressValue;
76 __activityType = notificationMessage.__activityType;
77 __alertText = notificationMessage.__alertText;
78 __appMessage = notificationMessage.__appMessage;
79 __titleText = notificationMessage.__titleText;
80 __iconFilePath = notificationMessage.__iconFilePath;
81 __soundFilePath = notificationMessage.__soundFilePath;
87 _NotificationMessageImpl::Equals(const Object& rhs) const
89 const NotificationMessage* pMsg = dynamic_cast<const NotificationMessage*>(&rhs);
95 const _NotificationMessageImpl* pMsgImpl = pMsg->__pNotificationMessageImpl;
101 if (__appBinding != pMsgImpl->__appBinding)
106 if (__badgeNumber != pMsgImpl->__badgeNumber)
111 if (__badgeOffset != pMsgImpl->__badgeOffset)
116 if (__progressValue != pMsgImpl->__progressValue)
121 if (__activityType != pMsgImpl->__activityType)
126 if (GetHashCode() != pMsgImpl->GetHashCode())
131 if (__alertText != pMsgImpl->__alertText)
136 if (__appMessage != pMsgImpl->__appMessage)
141 if (__titleText != pMsgImpl->__titleText)
146 if (__iconFilePath != pMsgImpl->__iconFilePath)
151 if (__soundFilePath != __soundFilePath)
160 _NotificationMessageImpl::GetHashCode(void) const
162 return Boolean(__appBinding).GetHashCode()
163 ^ Integer(__badgeNumber).GetHashCode()
164 ^ Integer(__badgeOffset).GetHashCode()
165 ^ Integer(__progressValue).GetHashCode()
166 ^ Integer(__activityType).GetHashCode()
167 ^ __alertText.GetHashCode()
168 ^ __appMessage.GetHashCode()
169 ^ __titleText.GetHashCode()
170 ^ __iconFilePath.GetHashCode()
171 ^ __soundFilePath.GetHashCode();
175 _NotificationMessageImpl::GetBadgeNumber(void) const
177 return __badgeNumber;
181 _NotificationMessageImpl::SetBadgeNumber(int badgeNumber)
183 result r = E_SUCCESS;
184 SysTryReturnResult(NID_APP, badgeNumber >= 0 && badgeNumber <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG,
185 "BadgeNumber is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER.");
188 __badgeNumber = badgeNumber;
193 _NotificationMessageImpl::GetBadgeOffset() const
195 return __badgeOffset;
199 _NotificationMessageImpl::SetBadgeOffset(int badgeOffset)
201 result r = E_SUCCESS;
202 SysTryReturnResult(NID_APP, badgeOffset >= 0 && badgeOffset <= MAX_NOTIFICATION_BADGE_NUMBER, E_INVALID_ARG,
203 "BadgeOffset is less than 0 or greater than MAX_NOTIFICATION_BADGE_NUMBER.");
206 __badgeOffset = badgeOffset;
211 _NotificationMessageImpl::GetAlertText() const
217 _NotificationMessageImpl::SetAlertText(const String& alertText)
219 result r = E_SUCCESS;
220 SysTryReturnResult(NID_APP, alertText.GetLength() > 0 && alertText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
221 "AlertText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
223 __alertText = alertText;
228 _NotificationMessageImpl::GetAppMessage() const
235 _NotificationMessageImpl::SetAppMessage(const String& appMessage)
237 result r = E_SUCCESS;
238 SysTryReturnResult(NID_APP, appMessage.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
239 "AppMessage is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
240 SysTryReturnResult(NID_APP, __appBinding, E_INVALID_OPERATION,
241 "The Notification instance is not bound to Application");
243 __appMessage = appMessage;
248 _NotificationMessageImpl::GetTitleText() const
254 _NotificationMessageImpl::SetTitleText(const String& titleText)
256 result r = E_SUCCESS;
257 SysTryReturnResult(NID_APP, titleText.GetLength() <= MAX_NOTIFICATION_MESSAGE_LENGTH, E_INVALID_ARG,
258 "TitleText is greater than MAX_NOTIFICATION_MESSAGE_LENGTH.");
259 __titleText = titleText;
264 _NotificationMessageImpl::GetIconFilePath() const
266 return __iconFilePath;
270 _NotificationMessageImpl::SetIconFilePath(const String& iconFilePath)
272 result r = E_SUCCESS;
273 bool isExist = false;
275 isExist = File::IsFileExist(iconFilePath);
276 SysTryReturnResult(NID_APP, isExist, E_INVALID_ARG,"The Specified File is Invalid");
278 __iconFilePath = iconFilePath;
283 _NotificationMessageImpl::GetSoundFilePath() const
285 return __soundFilePath;
289 _NotificationMessageImpl::SetSoundFilePath(const String& soundFilePath)
291 result r = E_SUCCESS;
292 bool isExist = false;
294 isExist = File::IsFileExist(soundFilePath);
295 SysTryReturnResult(NID_APP, isExist, E_INVALID_ARG,"The Specified File is Invalid");
297 __soundFilePath = soundFilePath;
302 _NotificationMessageImpl::GetOngoingActivityType() const
304 return __activityType;
308 _NotificationMessageImpl::SetOngoingActivityType(OngoingActivityType activityType)
310 result r = E_SUCCESS;
312 // to prevent weired gcc optimization for enum type
313 int type = static_cast<int>(activityType);
317 case ONGOING_ACTIVITY_TYPE_TEXT:
319 case ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE:
320 SysTryReturnResult(NID_APP, __progressValue == -1 || (__progressValue >= 0 && __progressValue <= 100), E_INVALID_STATE, "Incompatible progress value %d.", __progressValue);
322 case ONGOING_ACTIVITY_TYPE_PROGRESS_BYTE:
325 SetLastResult(E_INVALID_STATE);
326 SysLogException(NID_APP, E_INVALID_STATE, "Invalid activity type %d.", type);
327 return E_INVALID_STATE;
330 __activityType = activityType;
335 _NotificationMessageImpl::GetOngoingActivityProgressValue() const
337 return __progressValue;
341 _NotificationMessageImpl::SetOngoingActivityProgressValue(int progressValue)
343 result r = E_SUCCESS;
344 SysTryReturnResult(NID_APP, progressValue >= 0, E_INVALID_ARG,"The progress value is less than 0");
346 // use int type instead of OngoingActivityType to evade weired gcc optimization
347 int activitytype = static_cast<int>(GetOngoingActivityType());
348 SysTryReturnResult(NID_APP, activitytype > ONGOING_ACTIVITY_TYPE_TEXT && activitytype <= ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE,
349 E_INVALID_STATE,"Invalid activity Type %d.", activitytype);
351 if (activitytype == ONGOING_ACTIVITY_TYPE_PROGRESS_PERCENTAGE)
353 SysTryReturnResult(NID_APP, progressValue <= 100, E_INVALID_ARG,"Invalid Progress value");
355 __progressValue = progressValue;
360 _NotificationMessageImpl::IsAppBinding()const