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 FShellNotificationManager.cpp
20 * @brief This is the placeholder for NotificationManager class.
25 #include <FBaseSysLog.h>
26 #include <FShellNotificationManager.h>
27 #include <FShellIBadgeEventListener.h>
28 #include <FSec_AccessController.h>
29 #include "FShell_NotificationManagerImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::App;
33 using namespace Tizen::Security;
35 namespace Tizen { namespace Shell
38 NotificationManager::NotificationManager()
39 : __pNotificationManagerImpl(null)
44 NotificationManager::~NotificationManager()
46 delete __pNotificationManagerImpl;
50 NotificationManager::Construct(void)
52 SysAssertf(__pNotificationManagerImpl == null,
53 "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class.");
55 __pNotificationManagerImpl = new (std::nothrow) _NotificationManagerImpl();
56 SysTryReturnResult(NID_SHELL, __pNotificationManagerImpl != null, E_OUT_OF_MEMORY, "Allocation failed.");
58 return __pNotificationManagerImpl->Construct();
62 NotificationManager::GetBadgeNumber(void)
64 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
66 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
67 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
69 return __pNotificationManagerImpl->GetBadgeNumber();
73 NotificationManager::Notify(int badgeNumber)
75 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
77 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
78 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
80 return __pNotificationManagerImpl->Notify(badgeNumber);
84 NotificationManager::Notify(const String& messageText)
86 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
88 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
89 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
91 return __pNotificationManagerImpl->Notify(messageText);
95 NotificationManager::Notify(const String& messageText, int badgeNumber)
97 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
99 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
100 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
102 return __pNotificationManagerImpl->Notify(messageText, badgeNumber);
106 NotificationManager::Notify(const String& messageText, int badgeNumber, const String& launchArguments)
108 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
110 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
111 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
113 return __pNotificationManagerImpl->Notify(messageText, badgeNumber, launchArguments);
117 NotificationManager::Notify(const NotificationRequest& notiMessage)
119 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
121 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
122 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
124 return __pNotificationManagerImpl->NotifyMessageImpl(notiMessage);
128 NotificationManager::NotifyByAppId(const AppId& appId,const NotificationRequest& notiMessage)
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_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
135 return __pNotificationManagerImpl->NotifyMessageImpl(appId, notiMessage);
139 NotificationManager::GetBadgeNumberByAppId(const AppId& appId)
141 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
143 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
144 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
146 return __pNotificationManagerImpl->GetBadgeNumber(appId);
150 NotificationManager::NotifyOngoingActivity(const String& messageText)
152 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
154 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
155 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
157 return __pNotificationManagerImpl->NotifyOngoingActivity(messageText);
161 NotificationManager::NotifyOngoingActivity(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);
166 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
169 return __pNotificationManagerImpl->NotifyOngoingActivity(messageText, launchArguments);
173 NotificationManager::NotifyOngoingActivity(const NotificationRequest& notiMessage)
175 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
177 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
178 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
180 return __pNotificationManagerImpl->NotifyMessageImpl(notiMessage, true);
184 NotificationManager::NotifyOngoingActivityByAppId(const AppId& appId,const NotificationRequest& notiMessage)
186 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
188 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION, _PRV_NOTIFICATIONMANAGER);
189 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
191 return __pNotificationManagerImpl->NotifyMessageImpl(appId, notiMessage, true);
195 NotificationManager::RemoveOngoingActivityNotification(void)
197 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
199 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
200 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
202 return __pNotificationManagerImpl->RemoveOngoingActivityNotification();
206 NotificationManager::RemoveOngoingActivityNotificationByAppId(const AppId& appId)
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_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
213 return __pNotificationManagerImpl->RemoveOngoingActivityNotificationByAppId(appId);
217 NotificationManager::RemoveNotification(void)
219 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
221 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
222 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
224 return __pNotificationManagerImpl->RemoveNotification();
228 NotificationManager::RemoveNotificationByAppId(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_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
235 return __pNotificationManagerImpl->RemoveNotificationByAppId(appId);
240 NotificationManager::NotifyTextMessage(const String& messageText)
242 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
244 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
245 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
247 return __pNotificationManagerImpl->NotifyTextMessage(messageText);
251 NotificationManager::NotifyByAppControl(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType,
252 const Tizen::Base::Collection::IMap* pExtraData, const NotificationRequest& request)
254 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
256 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
257 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
259 return __pNotificationManagerImpl->NotifyByAppControl(operationId, pUriData, pDataType, pExtraData, request);
263 NotificationManager::NotifyOngoingActivityByAppControl(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType,
264 const Tizen::Base::Collection::IMap* pExtraData, const NotificationRequest& request)
266 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
268 result r = _AccessController::CheckUserPrivilege(_PRV_NOTIFICATION);
269 SysTryReturnResult(NID_SHELL, !IsFailed(r), E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
271 return __pNotificationManagerImpl->NotifyOngoingActivityByAppControl(operationId, pUriData, pDataType, pExtraData, request);
275 NotificationManager::AddBadgeEventListener(IBadgeEventListener& listener)
277 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
279 return __pNotificationManagerImpl->AddBadgeEventListener(listener);
283 NotificationManager::RemoveBadgeEventListener(IBadgeEventListener& listener)
285 SysAssertf(__pNotificationManagerImpl != null, "Not yet constructed. Construct() should be called before use.");
287 return __pNotificationManagerImpl->RemoveBadgeEventListener(listener);