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 int res = __pNotiImpl->GetBadgeNumber();
87 if (GetLastResult() == E_OPERATION_FAILED)
89 SetLastResult(E_SUCCESS);
97 _NotificationManagerImpl::Notify(int badgeNumber) const
99 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
100 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
102 String messageText = String(L"");
103 String appMessage = String(L"");
105 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
110 _NotificationManagerImpl::Notify(const String& messageText) const
112 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
114 String appMessage = String(L"");
116 return __pNotiImpl->Notify(messageText, -1, appMessage);
121 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
123 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
124 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
126 String appMessage = String(L"");
128 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
133 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
135 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
136 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
138 return __pNotiImpl->Notify(messageText, badgeNumber, launchArguments);
142 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
144 SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
147 const int ret = __pNotiImpl->GetBadgeNumber(appId);
148 result r = GetLastResult();
149 if (r == E_APP_NOT_INSTALLED)
151 SetLastResult(E_OBJ_NOT_FOUND);
154 if (GetLastResult() == E_OPERATION_FAILED)
156 SetLastResult(E_SUCCESS);
164 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, int badgeNumber) const
166 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
167 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
169 String messageText = String(L"");
170 String appMessage = String(L"");
172 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, appMessage);
177 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText) const
179 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
181 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, String(L""));
186 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber) const
188 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
189 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
191 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, String(L""));
196 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const
198 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
199 SysTryReturnResult(NID_APP, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
200 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
202 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, launchArguments);
207 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber,
208 const String& launchArguments) const
210 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
211 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
213 SysTryReturnResult(NID_APP, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
214 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
216 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, launchArguments);
221 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
223 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
225 return __pNotiImpl->NotifyOngoingActivity(messageText);
230 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
232 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
233 SysTryReturnResult(NID_APP, launchArguments.GetLength() <= MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH, E_INVALID_ARG,
234 "launchArguments is greater than MAX_NOTIFICATION_LAUNCH_ARGUMENTS_LENGTH.");
236 return __pNotiImpl->NotifyOngoingActivity(messageText, launchArguments);
241 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText) 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, String(L""));
251 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText,
252 const String& launchArguments) const
254 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
255 SysTryReturnResult(NID_APP, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0.");
257 return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, launchArguments);
262 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
264 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
266 return __pNotiImpl->RemoveOngoingActivityNotification();
271 _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
273 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
275 return __pNotiImpl->RemoveOngoingActivityNotificationByAppId(appId);
280 _NotificationManagerImpl::RemoveNotification(void)
282 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
284 return __pNotiImpl->RemoveNotification();
289 _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId)
291 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
293 return __pNotiImpl->RemoveNotificationByAppId(appId);