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"
28 #include "FAppNotificationManager.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Runtime;
36 const wchar_t OSP_SHELL_SONAME[] = L"libosp-shell-core.so.1";
40 namespace Tizen { namespace App
43 _NotificationManagerImpl::_NotificationManagerImpl(void)
49 _NotificationManagerImpl::~_NotificationManagerImpl(void)
53 typedef void (*NotificationDeletor)(_INotificationManagerImpl*);
55 NotificationDeletor pDeleter = reinterpret_cast<NotificationDeletor>(__lib.GetProcAddress(L"DeleteNotificationManagerInstance"));
58 (*pDeleter)(__pNotiImpl);
59 SysLog(NID_APP, "NotificationManager stub deleted.");
66 _NotificationManagerImpl::Construct(void)
68 result r = __lib.Construct(OSP_SHELL_SONAME, _LIBRARY_LOAD_OPTION_NODELETE | _LIBRARY_LOAD_OPTION_LAZY);
69 SysTryReturnResult(NID_APP, !IsFailed(r), E_SYSTEM, "A system error has occurred : %s.", GetErrorMessage(r));
71 typedef _INotificationManagerImpl* (*NotificationCreator)(void);
72 NotificationCreator pCreator = reinterpret_cast<NotificationCreator>(__lib.GetProcAddress(L"CreateNotificationManagerInstance"));
73 SysTryReturnResult(NID_APP, pCreator != null, E_SYSTEM, "No notification instance factory found.");
75 __pNotiImpl = (*pCreator)();
82 _NotificationManagerImpl::GetBadgeNumber(void) const
84 SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
86 return __pNotiImpl->GetBadgeNumber();
91 _NotificationManagerImpl::Notify(int badgeNumber) const
93 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
94 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
96 String messageText = String(L"");
97 String appMessage = String(L"");
99 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
104 _NotificationManagerImpl::Notify(const String& messageText) const
106 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
108 String appMessage = String(L"");
110 return __pNotiImpl->Notify(messageText, -1, appMessage);
115 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
117 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
118 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
120 String appMessage = String(L"");
122 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
127 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
129 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
130 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
132 return __pNotiImpl->Notify(messageText, badgeNumber, launchArguments);
136 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
138 SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
141 const int ret = __pNotiImpl->GetBadgeNumber(appId);
142 result r = GetLastResult();
143 if (r == E_APP_NOT_INSTALLED)
145 SetLastResult(E_OBJ_NOT_FOUND);
153 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, int badgeNumber) const
155 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
156 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
158 String messageText = String(L"");
159 String appMessage = String(L"");
161 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, appMessage);
166 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText) const
168 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
170 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, String(L""));
175 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber) const
177 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
178 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
180 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, String(L""));
185 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const
187 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
188 SysTryReturnResult(NID_APP, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
189 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
191 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, launchArguments);
196 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber,
197 const String& launchArguments) const
199 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
200 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
202 SysTryReturnResult(NID_APP, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
203 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
205 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, launchArguments);
210 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
212 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
214 return __pNotiImpl->NotifyOngoingActivity(messageText, String(L""));
219 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
221 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
222 SysTryReturnResult(NID_APP, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
223 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
225 return __pNotiImpl->NotifyOngoingActivity(messageText, launchArguments);
230 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText) const
232 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
233 SysTryReturnResult(NID_APP, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0.");
235 return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, String(L""));
240 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText,
241 const String& launchArguments) const
243 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
244 SysTryReturnResult(NID_APP, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0.");
246 return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, launchArguments);
251 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
253 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
255 return __pNotiImpl->RemoveOngoingActivityNotification();
260 _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
262 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
264 return __pNotiImpl->RemoveOngoingActivityNotificationByAppId(appId);
269 _NotificationManagerImpl::RemoveNotification(void)
271 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
273 return __pNotiImpl->RemoveNotification();
278 _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId)
280 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
282 return __pNotiImpl->RemoveNotificationByAppId(appId);