2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FAppNotificationManager.cpp
19 * @brief This is the placeholder for NotificationManager class.
24 #include <FAppNotificationManager.h>
26 #include <FBaseSysLog.h>
27 #include <FSec_AccessController.h>
28 #include "FApp_NotificationManagerImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Security;
33 namespace Tizen { namespace App
36 NotificationManager::NotificationManager()
37 : __pNotificationManagerImpl(null)
42 NotificationManager::~NotificationManager()
44 delete __pNotificationManagerImpl;
48 NotificationManager::Construct(void)
50 SysAssertf(__pNotificationManagerImpl == null,
51 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
53 __pNotificationManagerImpl = new (std::nothrow) _NotificationManagerImpl();
54 SysTryReturnResult(NID_APP, __pNotificationManagerImpl != null, E_OUT_OF_MEMORY, "Allocation failed.");
56 return __pNotificationManagerImpl->Construct();
60 NotificationManager::GetBadgeNumber(void)
62 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
64 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
65 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
67 return __pNotificationManagerImpl->GetBadgeNumber();
71 NotificationManager::Notify(int badgeNumber)
73 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
75 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
76 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
78 return __pNotificationManagerImpl->Notify(badgeNumber);
82 NotificationManager::Notify(const String& messageText)
84 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
86 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
87 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
89 return __pNotificationManagerImpl->Notify(messageText);
93 NotificationManager::Notify(const String& messageText, int badgeNumber)
95 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
97 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
98 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
100 return __pNotificationManagerImpl->Notify(messageText, badgeNumber);
104 NotificationManager::Notify(const String& messageText, int badgeNumber, const String& launchArguments)
106 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
108 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
109 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
111 return __pNotificationManagerImpl->Notify(messageText, badgeNumber, launchArguments);
115 NotificationManager::GetBadgeNumber(const AppId& appId)
117 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
119 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
120 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
122 return __pNotificationManagerImpl->GetBadgeNumber(appId);
127 NotificationManager::NotifyOnBehalf(const AppId& appId, int badgeNumber)
129 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
131 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
132 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
134 return __pNotificationManagerImpl->NotifyOnBehalf(appId, badgeNumber);
138 NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageText)
140 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
142 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
143 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
145 return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText);
149 NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber)
151 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
153 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
154 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
156 return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText, badgeNumber);
160 NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments)
162 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
164 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
165 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
167 return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText, launchArguments);
171 NotificationManager::NotifyOngoingActivity(const String& messageText)
173 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
175 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
176 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
178 return __pNotificationManagerImpl->NotifyOngoingActivity(messageText);
182 NotificationManager::NotifyOngoingActivity(const String& messageText, const String& launchArguments)
184 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
186 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
187 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
190 return __pNotificationManagerImpl->NotifyOngoingActivity(messageText, launchArguments);
194 NotificationManager::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText)
196 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
198 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
199 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
202 return __pNotificationManagerImpl->NotifyOngoingActivityOnBehalf(appId, messageText);
206 NotificationManager::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments)
208 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
210 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
211 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
213 return __pNotificationManagerImpl->NotifyOngoingActivityOnBehalf(appId, messageText, launchArguments);
217 NotificationManager::RemoveOngoingActivityNotification(void)
219 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
221 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
222 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
224 return __pNotificationManagerImpl->RemoveOngoingActivityNotification();
228 NotificationManager::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
230 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
232 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
233 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
235 return __pNotificationManagerImpl->RemoveOngoingActivityNotificationOnBehalf(appId);
239 NotificationManager::RemoveNotification(void)
241 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
243 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
244 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
246 return __pNotificationManagerImpl->RemoveNotification();
250 NotificationManager::RemoveNotificationOnBehalf(const AppId& appId)
252 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
254 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
255 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
257 return __pNotificationManagerImpl->RemoveNotificationOnBehalf(appId);