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 FApp_NotificationManagerImpl.cpp
19 * @brief This is the placeholder for _NotificationManagerImpl class.
22 #include <FBaseSysLog.h>
24 #include <FBaseRt_LibraryImpl.h>
26 #include "FApp_NotificationManagerImpl.h"
27 #include "FApp_INotificationManagerImpl.h"
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
35 const wchar_t OSP_SHELL_SONAME[] = L"libosp-shell-core.so.1";
39 namespace Tizen { namespace App
42 _NotificationManagerImpl::_NotificationManagerImpl(void)
48 _NotificationManagerImpl::~_NotificationManagerImpl(void)
52 typedef void (*NotificationDeletor)(_INotificationManagerImpl*);
54 NotificationDeletor pDeleter = reinterpret_cast<NotificationDeletor>(__lib.GetProcAddress(L"DeleteNotificationManagerInstance"));
57 (*pDeleter)(__pNotiImpl);
58 SysLog(NID_APP, "NotificationManager stub deleted.");
65 _NotificationManagerImpl::Construct(void)
67 result r = __lib.Construct(OSP_SHELL_SONAME, _LIBRARY_LOAD_OPTION_NODELETE | _LIBRARY_LOAD_OPTION_LAZY);
68 SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "A system error has occurred : %s.", GetErrorMessage(r));
70 typedef _INotificationManagerImpl* (*NotificationCreator)(void);
71 NotificationCreator pCreator = reinterpret_cast<NotificationCreator>(__lib.GetProcAddress(L"CreateNotificationManagerInstance"));
72 SysTryReturnResult(NID_APP, pCreator != null, E_SYSTEM, "No notification instance factory found.");
74 __pNotiImpl = (*pCreator)();
81 _NotificationManagerImpl::GetBadgeNumber(void) const
83 SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
85 return __pNotiImpl->GetBadgeNumber();
90 _NotificationManagerImpl::Notify(int badgeNumber) const
92 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
94 String messageText = String(L"");
95 String appMessage = String(L"");
97 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
102 _NotificationManagerImpl::Notify(const String& messageText) const
104 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
106 String appMessage = String(L"");
108 return __pNotiImpl->Notify(messageText, -1, appMessage);
113 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
115 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
117 String appMessage = String(L"");
119 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
124 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
126 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
128 return __pNotiImpl->Notify(messageText, badgeNumber, launchArguments);
132 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
134 SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
136 return __pNotiImpl->GetBadgeNumber(appId);
141 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, int badgeNumber) const
143 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
144 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
146 String messageText = String(L"");
147 String appMessage = String(L"");
149 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, appMessage);
154 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText) const
156 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
158 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, String(L""));
163 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber) const
165 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
166 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
168 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, String(L""));
173 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const
175 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
177 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, launchArguments);
182 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber,
183 const String& launchArguments) const
185 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
186 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
188 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, launchArguments);
193 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
195 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
197 return __pNotiImpl->NotifyOngoingActivity(messageText, String(L""));
202 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
204 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
206 return __pNotiImpl->NotifyOngoingActivity(messageText, launchArguments);
211 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText) const
213 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
215 return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, String(L""));
220 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText,
221 const String& launchArguments) const
223 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
225 return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, launchArguments);
230 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
232 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
234 return __pNotiImpl->RemoveOngoingActivityNotification();
239 _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
241 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
243 return __pNotiImpl->RemoveOngoingActivityNotificationByAppId(appId);
248 _NotificationManagerImpl::RemoveNotification(void)
250 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
252 return __pNotiImpl->RemoveNotification();
257 _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId)
259 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
261 return __pNotiImpl->RemoveNotificationByAppId(appId);