fix legacy noti tc failure
[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         SysTryReturnResult(NID_APP, badgeNumber >= 0, E_INVALID_ARG, "badgeNumber is less than 0.");
94
95         String messageText = String(L"");
96         String appMessage = String(L"");
97
98         return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
99 }
100
101
102 result
103 _NotificationManagerImpl::Notify(const String& messageText) const
104 {
105         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
106
107         String appMessage = String(L"");
108
109         return __pNotiImpl->Notify(messageText, -1, appMessage);
110 }
111
112
113 result
114 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber) const
115 {
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.");
118
119         String appMessage = String(L"");
120
121         return __pNotiImpl->Notify(messageText, badgeNumber, appMessage);
122 }
123
124
125 result
126 _NotificationManagerImpl::Notify(const String& messageText, int badgeNumber, const String& launchArguments) const
127 {
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.");
130
131         return __pNotiImpl->Notify(messageText, badgeNumber, launchArguments);
132 }
133
134 int
135 _NotificationManagerImpl::GetBadgeNumber(const AppId& appId) const
136 {
137         SysTryReturn(NID_APP, __pNotiImpl != null, -1, E_SYSTEM, "[E_SYSTEM] Notification interface error.");
138
139
140         const int ret = __pNotiImpl->GetBadgeNumber(appId);
141         result r = GetLastResult();
142         if (r == E_APP_NOT_INSTALLED)
143         {
144                 SetLastResult(E_OBJ_NOT_FOUND);
145         }
146
147         return ret;
148 }
149
150
151 result
152 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, int badgeNumber) const
153 {
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.");
156
157         String messageText = String(L"");
158         String appMessage = String(L"");
159
160         return __pNotiImpl->NotifyByAppId(appId, messageText, -1, appMessage);
161 }
162
163
164 result
165 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText) const
166 {
167         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
168
169         return __pNotiImpl->NotifyByAppId(appId, messageText, -1, String(L""));
170 }
171
172
173 result
174 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber) const
175 {
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.");
178
179         return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, String(L""));
180 }
181
182
183 result
184 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, const String& launchArguments) const
185 {
186         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
187
188         return __pNotiImpl->NotifyByAppId(appId, messageText, -1, launchArguments);
189 }
190
191
192 result
193 _NotificationManagerImpl::NotifyOnBehalf(const AppId& appId, const String& messageText, int badgeNumber,
194                                                                                  const String& launchArguments) const
195 {
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.");
198
199         return __pNotiImpl->NotifyByAppId(appId, messageText, badgeNumber, launchArguments);
200 }
201
202
203 result
204 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText) const
205 {
206         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
207
208         return __pNotiImpl->NotifyOngoingActivity(messageText, String(L""));
209 }
210
211
212 result
213 _NotificationManagerImpl::NotifyOngoingActivity(const String& messageText, const String& launchArguments) const
214 {
215         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
216
217         return __pNotiImpl->NotifyOngoingActivity(messageText, launchArguments);
218 }
219
220
221 result
222 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText) const
223 {
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.");
226
227         return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, String(L""));
228 }
229
230
231 result
232 _NotificationManagerImpl::NotifyOngoingActivityOnBehalf(const AppId& appId, const String& messageText,
233                                                                                                                 const String& launchArguments) const
234 {
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.");
237
238         return __pNotiImpl->NotifyOngoingActivityByAppId(appId, messageText, launchArguments);
239 }
240
241
242 result
243 _NotificationManagerImpl::RemoveOngoingActivityNotification(void)
244 {
245         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
246
247         return __pNotiImpl->RemoveOngoingActivityNotification();
248 }
249
250
251 result
252 _NotificationManagerImpl::RemoveOngoingActivityNotificationOnBehalf(const AppId& appId)
253 {
254         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
255
256         return __pNotiImpl->RemoveOngoingActivityNotificationByAppId(appId);
257 }
258
259
260 result
261 _NotificationManagerImpl::RemoveNotification(void)
262 {
263         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
264
265         return __pNotiImpl->RemoveNotification();
266 }
267
268
269 result
270 _NotificationManagerImpl::RemoveNotificationOnBehalf(const AppId& appId)
271 {
272         SysTryReturnResult(NID_APP, __pNotiImpl != null, E_SYSTEM, "Notification interface error.");
273
274         return __pNotiImpl->RemoveNotificationByAppId(appId);
275 }
276
277 };
278 };    // Tizen::App