2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FApp_NotificationManagerStub.cpp
20 * @brief This is the implementation for the _NotificationManagerStub class.
25 #include <FBaseSysLog.h>
26 #include <FBase_StringConverter.h>
27 #include <FIo_IpcServer.h>
28 #include <FSec_AccessController.h>
29 #include <FShell_NotificationManagerIpcMessages.h>
31 #include "FApp_NotificationManagerService.h"
32 #include "FApp_NotificationManagerStub.h"
35 namespace Tizen { namespace App {
37 using namespace Tizen::Base;
38 using namespace Tizen::Base::Collection;
39 using namespace Tizen::Io;
40 using namespace Tizen::Security;
41 using namespace Tizen::Shell;
44 ///////////////////////////////////////////
45 // _NotificationManagerStub
46 ///////////////////////////////////////////
48 _NotificationManagerStub::_NotificationManagerStub()
50 ,__pNotificationManagerService(null)
52 SysLog(NID_APP, "_NotificationManagerStub - Enter\n");
55 _NotificationManagerStub::~_NotificationManagerStub()
57 if ( __pIpcServer != null)
63 SysLog(NID_APP, "_NotificationManagerStub - Exit\n");
67 _NotificationManagerStub::Construct(void)
69 SysLog(NID_APP, "Enter.");
71 __pNotificationManagerService = new (std::nothrow) _NotificationManagerService();
72 SysTryReturnResult(NID_APP, __pNotificationManagerService != null, E_OUT_OF_MEMORY, "Not enough memory.");
75 r = __pNotificationManagerService->Construct();
76 SysTryReturn(NID_APP, !IsFailed(r), r, r, "failed to __pNotificationManagerService->Construct.(%s)", GetErrorMessage(r) );
79 SysTryReturn(NID_APP, !IsFailed(r), r, r, "failed to StartIpcServer.(%s)", GetErrorMessage(r) );
81 SysLog(NID_APP, "Exit.");
86 _NotificationManagerStub::StartIpcServer(void)
88 SysLog(NID_APP, "_NotificationManagerStub - StartIpcServer");
90 __pIpcServer = new (std::nothrow) _IpcServer();
91 SysTryReturnResult(NID_APP, __pIpcServer != null, E_OUT_OF_MEMORY, "Not enough memory.");
93 result r = __pIpcServer->Construct( "osp.app.ipcserver.notificationmanager", *this);
94 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to create IPC server(%s)", GetErrorMessage(r), "osp.app.ipcserver.notificationmanager");
96 r = __pIpcServer->Start();
97 SysTryCatch(NID_APP, !IsFailed(r), , r, "[%s] Failed to Start IPC server(%s)", GetErrorMessage(r), "osp.app.ipcserver.notificationmanager");
108 _NotificationManagerStub::OnNotifyMessage(const AppId& appId, const NotificationRequest& notiMessage,bool Ongoing, result* pRes)
110 SysTryReturnVoidResult(NID_APP, __pNotificationManagerService != null, E_INVALID_STATE, "Invalid Notification manager state.");
112 *pRes = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_NOTIFICATIONMANAGER);
113 SysTryReturnVoidResult(NID_APP, !IsFailed(*pRes), *pRes = E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
115 *pRes = __pNotificationManagerService->NotifyMessage(appId, notiMessage,Ongoing);
119 _NotificationManagerStub::OnRemoveNotification(const AppId& appId, bool Ongoing, result* pRes)
121 SysTryReturnVoidResult(NID_APP, __pNotificationManagerService != null, E_INVALID_STATE, "Invalid Notification manager state.");
123 *pRes = _AccessController::CheckSystemPrivilege(__pIpcServer->GetClientAppId(), _PRV_NOTIFICATIONMANAGER);
124 SysTryReturnVoidResult(NID_APP, !IsFailed(*pRes), *pRes = E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method.");
126 *pRes = __pNotificationManagerService->RemoveNotification(appId, Ongoing);
129 ///////////////////////////////////////////
131 ///////////////////////////////////////////
133 _NotificationManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
135 SysLog(NID_APP, "(appId:%ls, pid:%d, clientId:%d)\n", server.GetClientAppId().GetPointer(), server.GetClientProcessId(), server.GetClientId());
137 IPC_BEGIN_MESSAGE_MAP(_NotificationManagerStub, message)
138 IPC_MESSAGE_HANDLER_EX(NotificationManager_NotifyMessage, &server, OnNotifyMessage)
139 IPC_MESSAGE_HANDLER_EX(NotificationManager_RemoveNotification, &server, OnRemoveNotification)
140 IPC_END_MESSAGE_MAP()
144 _NotificationManagerStub::OnIpcServerStarted(const _IpcServer& server)
146 SysLog(NID_APP, "_NotificationManagerStub::OnIpcServerStarted \n");
150 _NotificationManagerStub::OnIpcServerStopped(const _IpcServer& server)
152 SysLog(NID_APP, "_NotificationManagerStub::OnIpcServerStopped \n");
156 _NotificationManagerStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
158 SysLog(NID_APP, "_NotificationManagerStub::OnIpcClientConnected (clientId:%d)\n", clientId);
162 _NotificationManagerStub::OnIpcClientDisconnected(const _IpcServer&server, int clientId)
164 SysLog(NID_APP, "(appId:%ls, pid:%d, clientId:%d)\n", server.GetClientAppId().GetPointer(), server.GetClientProcessId(), clientId);
167 }} //namespace Tizen { namespace App {