remove unnecessary codes
[framework/osp/appwidget-service.git] / src / FShell_AppWidgetManagerStub.cpp
1 //
2 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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        FShell_AppWidgetManagerStub.cpp
19  * @brief       This is the implementation for the _AppWidgetManagerStub class.
20  */
21
22 #include <FBaseSysLog.h>
23 #include <FIo_IpcServer.h>
24 #include "FShell_AppWidgetManagerIpcMessage.h"
25 #include "FShell_AppWidgetManagerStub.h"
26
27 namespace Tizen { namespace Shell  { namespace App {
28
29 namespace
30 {
31 const char IPC_SERVER_NAME[] = "osp.shell.ipcserver.appwidgetmanager";
32 const int INVALID_CLIENT_ID = -1;
33 };
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Io;
37 using namespace Tizen::Text;
38 using namespace Tizen::Security;
39
40 _AppWidgetManagerStub::_AppWidgetManagerStub(void)
41 :__pIpcServer(null)
42 {
43         SysLog(NID_SHELL, "Enter\n");
44
45         SysLog(NID_SHELL, "Exit\n");
46 }
47
48 _AppWidgetManagerStub::~_AppWidgetManagerStub(void)
49 {
50         SysLog(NID_SHELL, "Enter\n");
51
52         if ( __pIpcServer != null)
53         {
54                 __pIpcServer->Stop();
55                 delete __pIpcServer;
56         }
57
58         SysLog(NID_SHELL, "Exit\n");
59 }
60
61 result
62 _AppWidgetManagerStub::StartIpcServer(void)
63 {
64         SysLog(NID_SHELL, "Enter.");
65         __pIpcServer = new (std::nothrow) _IpcServer();
66         SysTryReturn(NID_SHELL, __pIpcServer != null, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Not enough memory.");
67
68         result r = __pIpcServer->Construct( IPC_SERVER_NAME, *this, false);
69         SysTryCatch(NID_SHELL, !IsFailed(r), , r, "[%s] Failed to create IPC server(%s)", GetErrorMessage(r), "osp.app.ipcserver.appmanager");
70         SysLog(NID_SHELL, "Exit.");
71
72         return E_SUCCESS;
73
74 CATCH:
75         delete __pIpcServer;
76         __pIpcServer = null;
77         return r;
78 }
79
80 bool
81 _AppWidgetManagerStub::OnRequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument, result* pRes)
82 {
83         SysLog(NID_SHELL, "");
84         *pRes = RequestUpdate(appId, providerName, argument);
85         return true;
86 }
87
88 bool
89 _AppWidgetManagerStub::OnRequestUpdateInstance(const Tizen::Base::String& instanceId, const Tizen::Base::String& argument, result* pRes)
90 {
91         SysLog(NID_SHELL, "");
92         *pRes = RequestUpdateInstance(instanceId, argument);
93         return true;
94 }
95
96 bool
97 _AppWidgetManagerStub::OnRequestSharedMemoryId(const String& instanceId, int w, int h, int* pShmId)
98 {
99         SysLog(NID_SHELL, "(instanceId:%d)xxx", instanceId.GetPointer());
100
101         RequestSharedMemoryId(__pIpcServer->GetClientPackageId(), instanceId, w, h, *pShmId);
102
103         return true;
104 }
105
106 bool
107 _AppWidgetManagerStub::OnRequestSharedMemoryIdForPD(const String& instanceId, int w, int h, int* pShmId)
108 {
109         SysLog(NID_SHELL, "(instanceId:%d)", instanceId.GetPointer());
110
111         RequestSharedMemoryIdForPD(__pIpcServer->GetClientPackageId(), instanceId, w, h, *pShmId);
112
113         return true;
114 }
115
116 bool
117 _AppWidgetManagerStub::OnRequestSyncSharedMemory(const String& instanceId, int w, int h, result* pRes)
118 {
119         SysLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer());
120
121         *pRes = RequestSyncSharedMemory(__pIpcServer->GetClientPackageId(), instanceId, w, h);
122
123         return true;
124 }
125
126 bool
127 _AppWidgetManagerStub::OnRequestSyncSharedMemoryForPD(const String& instanceId, result* pRes)
128 {
129         SysLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer());
130
131         *pRes = RequestSyncSharedMemoryForPD(__pIpcServer->GetClientPackageId(), instanceId);
132
133         return true;
134 }
135
136 bool
137 _AppWidgetManagerStub::OnRequestReleaseSharedMemory(const String& instanceId, result* pRes)
138 {
139         SysLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer());
140
141         *pRes = RequestReleaseSharedMemory(__pIpcServer->GetClientPackageId(), instanceId);
142
143         return true;
144 }
145
146 bool
147 _AppWidgetManagerStub::OnRequestReleaseSharedMemoryForPD(const String& instanceId, result* pRes)
148 {
149         SysLog(NID_SHELL, "(instanceId:%ls)", instanceId.GetPointer());
150
151         *pRes = RequestReleaseSharedMemoryForPD(__pIpcServer->GetClientPackageId(), instanceId);
152
153         return true;
154 }
155
156 bool
157 _AppWidgetManagerStub::SendTouchEvent(const int clientId, const String& instanceId, int eventType, double timestamp, double x, double y)
158 {
159         SysLog(NID_SHELL,"");
160         result r = __pIpcServer->SendResponse(clientId, new AppWidgetManager_SendTouchEvent(instanceId, eventType, timestamp, x, y));
161         SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
162         return true;
163 }
164
165 bool
166 _AppWidgetManagerStub::SendTouchEventForPD(const int clientId, const String& instanceId, int eventType, double timestamp, double x, double y)
167 {
168         SysLog(NID_SHELL,"");
169         result r = __pIpcServer->SendResponse(clientId, new AppWidgetManager_SendTouchEventForPD(instanceId, eventType, timestamp, x, y));
170         SysTryReturn(NID_SHELL, !IsFailed(r), r, r, "[%s] Propagated.", GetErrorMessage(r));
171
172         return true;
173 }
174
175 void
176 _AppWidgetManagerStub::OnIpcRequestReceived(_IpcServer& server, const IPC::Message& message)
177 {
178         SysLog(NID_SHELL, "(appId:%ls, clientId:%d)\n", server.GetClientApplicationId().GetPointer(), server.GetClientId());
179
180         SysAssertf(__pIpcServer, "__pIpcServer is null!");
181
182         IPC_BEGIN_MESSAGE_MAP(_AppWidgetManagerStub, message)
183                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdate, &server, OnRequestUpdate)
184                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestUpdateInstance, &server, OnRequestUpdateInstance)
185                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSharedMemoryId, &server, OnRequestSharedMemoryId)
186                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSharedMemoryIdForPD, &server, OnRequestSharedMemoryIdForPD)
187                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSyncSharedMemory, &server, OnRequestSyncSharedMemory)
188                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestSyncSharedMemoryForPD, &server, OnRequestSyncSharedMemoryForPD)
189                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestReleaseSharedMemory, &server, OnRequestReleaseSharedMemory)
190                 IPC_MESSAGE_HANDLER_EX(AppWidgetManager_RequestReleaseSharedMemoryForPD, &server, OnRequestReleaseSharedMemoryForPD)
191         IPC_END_MESSAGE_MAP()
192 }
193
194 void
195 _AppWidgetManagerStub::OnIpcServerStarted(const _IpcServer& server)
196 {
197         SysLog(NID_SHELL, "\n");
198 }
199
200 void
201 _AppWidgetManagerStub::OnIpcServerStopped(const _IpcServer& server)
202 {
203         SysLog(NID_SHELL, "\n");
204 }
205
206 void
207 _AppWidgetManagerStub::OnIpcClientConnected(const _IpcServer& server, int clientId)
208 {
209         SysLog(NID_SHELL, "(clientId:%d)\n", clientId);
210
211 }
212
213 void
214 _AppWidgetManagerStub::OnIpcClientDisconnected(const _IpcServer& server, int clientId)
215 {
216         SysLog(NID_SHELL, "(appId:%ls, clientId:%d)\n", server.GetClientApplicationId().GetPointer(), clientId);
217 }
218
219 }}}     // Tizen::Shell::App