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.");
93 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
95 String messageText = String(L"");
96 String appMessage = String(L"");
98 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
103 _NotificationManagerImpl::Notify(const String& messageText) const
105 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
107 String appMessage = String(L"");
109 return __pNotiImpl->Notify(messageText, -1, appMessage);
114 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
116 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
117 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
119 String appMessage = String(L"");
121 return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
126 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
128 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
129 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
131 return __pNotiImpl->Notify(messageText, badgeNumber, launchArguments);
135 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
137 SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
140 const int ret = __pNotiImpl->GetBadgeNumber(appId);
141 result r = GetLastResult();
142 if (r == E_APP_NOT_INSTALLED)
144 SetLastResult(E_OBJ_NOT_FOUND);
152 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, int badgeNumber) const
154 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
155 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
157 String messageText = String(L"");
158 String appMessage = String(L"");
160 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, appMessage);
165 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText) const
167 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
169 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, String(L""));
174 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber) const
176 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
177 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
179 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, String(L""));
184 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const
186 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
188 return __pNotiImpl->NotifyByAppId(appId, messageText, -1, launchArguments);
193 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber,
194 const String& launchArguments) const
196 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
197 SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "BadgeNumber is less than 0.");
199 return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, launchArguments);
204 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
206 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
208 return __pNotiImpl->NotifyOngoingActivity(messageText, String(L""));
213 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
215 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
217 return __pNotiImpl->NotifyOngoingActivity(messageText, launchArguments);
222 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText) const
224 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
225 SysTryReturnResult(NID_APP, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0.");
227 return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, String(L""));
232 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText,
233 const String& launchArguments) const
235 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
236 SysTryReturnResult(NID_APP, !messageText.IsEmpty(), E_INVALID_ARG, "MessageText is less than 0.");
238 return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, launchArguments);
243 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
245 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
247 return __pNotiImpl->RemoveOngoingActivityNotification();
252 _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
254 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
256 return __pNotiImpl->RemoveOngoingActivityNotificationByAppId(appId);
261 _NotificationManagerImpl::RemoveNotification(void)
263 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
265 return __pNotiImpl->RemoveNotification();
270 _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId)
272 SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
274 return __pNotiImpl->RemoveNotificationByAppId(appId);