remove badge dependency for legacy NotificationManager
[platform/framework/native/appfw.git] / src / app / FApp_NotificationManagerImpl.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file                FApp_NotificationManagerImpl.cpp
19  * @brief               This is the placeholder for _NotificationManagerImpl class.
20  */
21
22 #include <FBaseSysLog.h>
23
24 #include <FBaseRt_LibraryImpl.h>
25
26 #include "FApp_NotificationManagerImpl.h"
27 #include "FApp_INotificationManagerImpl.h"
28
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Runtime;
31
32 namespace
33 {
34
35 const wchar_t OSP_SHELL_SONAME[] = L"libosp-shell-core.so.1";
36
37 }
38
39 namespace Tizen { namespace App
40 {
41
42 _NotificationManagerImpl::_NotificationManagerImpl(void)
43 : __pNotiImpl(null)
44 {
45 }
46
47
48 _NotificationManagerImpl::~_NotificationManagerImpl(void)
49 {
50         if (__pNotiImpl)
51         {
52                 typedef void (*NotificationDeletor)(_INotificationManagerImpl*);
53
54                 NotificationDeletor pDeleter = reinterpret_cast<NotificationDeletor>(__lib.GetProcAddress(L"DeleteNotificationManagerInstance"));
55                 if (pDeleter)
56                 {
57                         (*pDeleter)(__pNotiImpl);
58                         SysLog(NID_APP, "NotificationManager stub deleted.");
59                 }
60         }
61 }
62
63
64 result
65 _NotificationManagerImpl::Construct(void)
66 {
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));
69
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.");
73
74         __pNotiImpl = (*pCreator)();
75
76         return r;
77 }
78
79
80 int
81 _NotificationManagerImpl::GetBadgeNumber(void) const
82 {
83         SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
84
85         return __pNotiImpl->GetBadgeNumber();
86 }
87
88
89 result
90 _NotificationManagerImpl::Notify(int badgeNumber) const
91 {
92         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
93
94         String messageText = String(L"");
95         String appMessage = String(L"");
96
97         return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
98 }
99
100
101 result
102 _NotificationManagerImpl::Notify(const String& messageText) const
103 {
104         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
105
106         String appMessage = String(L"");
107
108         return __pNotiImpl->Notify(messageText, -1, appMessage);
109 }
110
111
112 result
113 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
114 {
115         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
116
117         String appMessage = String(L"");
118
119         return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
120 }
121
122
123 result
124 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
125 {
126         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
127
128         return __pNotiImpl->Notify(messageText, badgeNumber, launchArguments);
129 }
130
131 int
132 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
133 {
134         SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
135
136         return __pNotiImpl->GetBadgeNumber(appId);
137 }
138
139
140 result
141 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, int badgeNumber) const
142 {
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.");
145
146         String messageText = String(L"");
147         String appMessage = String(L"");
148
149         return __pNotiImpl->NotifyByAppId(appId, messageText, -1, appMessage);
150 }
151
152
153 result
154 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText) const
155 {
156         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
157
158         return __pNotiImpl->NotifyByAppId(appId, messageText, -1, String(L""));
159 }
160
161
162 result
163 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber) const
164 {
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.");
167
168         return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, String(L""));
169 }
170
171
172 result
173 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const
174 {
175         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
176
177         return __pNotiImpl->NotifyByAppId(appId, messageText, -1, launchArguments);
178 }
179
180
181 result
182 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber,
183                                                                                  const String& launchArguments) const
184 {
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.");
187
188         return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, launchArguments);
189 }
190
191
192 result
193 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
194 {
195         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
196
197         return __pNotiImpl->NotifyOngoingActivity(messageText, String(L""));
198 }
199
200
201 result
202 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
203 {
204         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
205
206         return __pNotiImpl->NotifyOngoingActivity(messageText, launchArguments);
207 }
208
209
210 result
211 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText) const
212 {
213         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
214
215         return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, String(L""));
216 }
217
218
219 result
220 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText,
221                                                                                                                 const String& launchArguments) const
222 {
223         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
224
225         return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, launchArguments);
226 }
227
228
229 result
230 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
231 {
232         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
233
234         return __pNotiImpl->RemoveOngoingActivityNotification();
235 }
236
237
238 result
239 _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
240 {
241         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
242
243         return __pNotiImpl->RemoveOngoingActivityNotificationByAppId(appId);
244 }
245
246
247 result
248 _NotificationManagerImpl::RemoveNotification(void)
249 {
250         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
251
252         return __pNotiImpl->RemoveNotification();
253 }
254
255
256 result
257 _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId)
258 {
259         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
260
261         return __pNotiImpl->RemoveNotificationByAppId(appId);
262 }
263
264 };
265 };    // Tizen::App