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 FAppNotificationManager.cpp
20 * @brief This is the placeholder for NotificationManager class.
25 #include <FAppNotificationManager.h>
27 #include <FBaseSysLog.h>
28 #include <FSec_AccessController.h>
29 #include "FApp_NotificationManagerImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Security;
34 namespace Tizen { namespace App
37 NotificationManager::NotificationManager()
38 : __pNotificationManagerImpl(null)
43 NotificationManager::~NotificationManager()
45 delete __pNotificationManagerImpl;
49 NotificationManager::Construct(void)
51 SysAssertf(__pNotificationManagerImpl == null,
52 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
54 __pNotificationManagerImpl = new (std::nothrow) _NotificationManagerImpl();
55 SysTryReturnResult(NID_APP, __pNotificationManagerImpl != null, E_OUT_OF_MEMORY, "Allocation failed.");
57 return __pNotificationManagerImpl->Construct();
61 NotificationManager::GetBadgeNumber(void)
63 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
65 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
66 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
68 return __pNotificationManagerImpl->GetBadgeNumber();
72 NotificationManager::Notify(int badgeNumber)
74 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
76 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
77 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
79 return __pNotificationManagerImpl->Notify(badgeNumber);
83 NotificationManager::Notify(const String& messageText)
85 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
87 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
88 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
90 return __pNotificationManagerImpl->Notify(messageText);
94 NotificationManager::Notify(const String& messageText, int badgeNumber)
96 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
98 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
99 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
101 return __pNotificationManagerImpl->Notify(messageText, badgeNumber);
105 NotificationManager::Notify(const String& messageText, int badgeNumber, const String& launchArguments)
107 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
109 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
110 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
112 return __pNotificationManagerImpl->Notify(messageText, badgeNumber, launchArguments);
116 NotificationManager::GetBadgeNumber(const AppId& appId)
118 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
120 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
121 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
123 return __pNotificationManagerImpl->GetBadgeNumber(appId);
128 NotificationManager::NotifyOnBehalf(const AppId& appId, int badgeNumber)
130 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
132 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
133 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
135 return __pNotificationManagerImpl->NotifyOnBehalf(appId, badgeNumber);
139 NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageText)
141 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
143 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
144 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
146 return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText);
150 NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber)
152 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
154 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
155 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
157 return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText, badgeNumber);
161 NotificationManager::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments)
163 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
165 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
166 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
168 return __pNotificationManagerImpl->NotifyOnBehalf(appId, messageText, launchArguments);
172 NotificationManager::NotifyOngoingActivity(const String& messageText)
174 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
176 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
177 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
179 return __pNotificationManagerImpl->NotifyOngoingActivity(messageText);
183 NotificationManager::NotifyOngoingActivity(const String& messageText, const String& launchArguments)
185 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
187 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
188 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
191 return __pNotificationManagerImpl->NotifyOngoingActivity(messageText, launchArguments);
195 NotificationManager::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText)
197 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
199 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
200 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
203 return __pNotificationManagerImpl->NotifyOngoingActivityOnBehalf(appId, messageText);
207 NotificationManager::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments)
209 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
211 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
212 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
214 return __pNotificationManagerImpl->NotifyOngoingActivityOnBehalf(appId, messageText, launchArguments);
218 NotificationManager::RemoveOngoingActivityNotification(void)
220 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
222 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
223 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
225 return __pNotificationManagerImpl->RemoveOngoingActivityNotification();
229 NotificationManager::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
231 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
233 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
234 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
236 return __pNotificationManagerImpl->RemoveOngoingActivityNotificationOnBehalf(appId);
240 NotificationManager::RemoveNotification(void)
242 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
244 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
245 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
247 return __pNotificationManagerImpl->RemoveNotification();
251 NotificationManager::RemoveNotificationOnBehalf(const AppId& appId)
253 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
255 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
256 SysTryReturnResult(NID_APP, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
258 return __pNotificationManagerImpl->RemoveNotificationOnBehalf(appId);