GenericCommunciator: improved logging of client names and pids
[profile/ivi/layer-management.git] / LayerManagerPlugins / Communicators / GenericCommunicator / src / GenericCommunicator.cpp
1 /***************************************************************************
2  * Copyright 2012 BMW Car IT GmbH
3  * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
4  *
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  ****************************************************************************/
19
20 #include "GenericCommunicator.h"
21 #include "ilm_types.h"
22 #include "Log.h"
23
24 #include "ICommandExecutor.h"
25 #include "CommitCommand.h"
26 #include "LayerCreateCommand.h"
27 #include "LayergroupCreateCommand.h"
28 #include "SurfaceCreateCommand.h"
29 #include "SurfacegroupCreateCommand.h"
30 #include "SurfaceGetDimensionCommand.h"
31 #include "LayerGetDimensionCommand.h"
32 #include "SurfaceGetOpacityCommand.h"
33 #include "LayerGetOpacityCommand.h"
34 #include "SurfaceGetPixelformatCommand.h"
35 #include "LayerGetVisibilityCommand.h"
36 #include "SurfaceGetVisibilityCommand.h"
37 #include "LayerAddSurfaceCommand.h"
38 #include "LayerRemoveSurfaceCommand.h"
39 #include "LayerRemoveCommand.h"
40 #include "SurfaceRemoveCommand.h"
41 #include "LayergroupRemoveCommand.h"
42 #include "SurfacegroupRemoveCommand.h"
43 #include "SurfaceGetOrientationCommand.h"
44 #include "LayerGetOrientationCommand.h"
45 #include "LayergroupAddLayerCommand.h"
46 #include "LayergroupRemoveLayerCommand.h"
47 #include "LayerSetDestinationRectangleCommand.h"
48 #include "SurfaceSetDestinationRectangleCommand.h"
49 #include "LayerSetOpacityCommand.h"
50 #include "LayergroupSetOpacityCommand.h"
51 #include "SurfaceSetOpacityCommand.h"
52 #include "SurfacegroupSetOpacityCommand.h"
53 #include "LayerSetSourceRectangleCommand.h"
54 #include "SurfaceSetSourceRectangleCommand.h"
55 #include "LayerSetOrientationCommand.h"
56 #include "SurfaceSetOrientationCommand.h"
57 #include "SurfacegroupAddSurfaceCommand.h"
58 #include "SurfacegroupRemoveSurfaceCommand.h"
59 #include "LayerSetVisibilityCommand.h"
60 #include "SurfaceSetVisibilityCommand.h"
61 #include "LayergroupSetVisibilityCommand.h"
62 #include "SurfacegroupSetVisibilityCommand.h"
63 #include "DebugCommand.h"
64 #include "ExitCommand.h"
65 #include "ScreenSetRenderOrderCommand.h"
66 #include "LayerSetRenderOrderCommand.h"
67 #include "LayerSetDimensionCommand.h"
68 #include "SurfaceSetDimensionCommand.h"
69 #include "LayerSetPositionCommand.h"
70 #include "SurfaceSetPositionCommand.h"
71 #include "LayerGetPositionCommand.h"
72 #include "SurfaceGetPositionCommand.h"
73 #include "ShaderCreateCommand.h"
74 #include "ShaderDestroyCommand.h"
75 #include "SurfaceSetShaderCommand.h"
76 #include "ShaderSetUniformsCommand.h"
77 #include "ScreenDumpCommand.h"
78 #include "LayerDumpCommand.h"
79 #include "SurfaceDumpCommand.h"
80 #include "SurfaceSetNativeContentCommand.h"
81 #include "SurfaceRemoveNativeContentCommand.h"
82 #include "SurfaceSetKeyboardFocusCommand.h"
83 #include "SurfaceGetKeyboardFocusCommand.h"
84 #include "SurfaceUpdateInputEventAcceptance.h"
85 #include "SurfaceSetChromaKeyCommand.h"
86 #include "LayerSetChromaKeyCommand.h"
87
88 #include <stdbool.h>
89 #include <unistd.h>
90 #include <stdio.h>
91 #include <string.h>
92 #include <stdlib.h>
93 #include <string>
94
95 #define DEFAULT_SCREEN 0
96
97 const char* RESOURCE_ALREADY_INUSE = "Ressource already in use";
98 const char* INVALID_ARGUMENT = "Invalid argument";
99 const char* RESOURCE_NOT_FOUND = "Ressource not found";
100 const char* NOT_IMPLEMENTED = "Feature not implemented";
101
102
103 GenericCommunicator::GenericCommunicator(ICommandExecutor* executor)
104 : ICommunicator(executor)
105 , m_running(ILM_FALSE)
106 {
107     MethodTable manager_methods[] =
108     {
109         { "ServiceConnect",                   &GenericCommunicator::ServiceConnect },
110         { "ServiceDisconnect",                &GenericCommunicator::ServiceDisconnect },
111         { "Debug",                            &GenericCommunicator::Debug },
112         { "ScreenShot",                       &GenericCommunicator::ScreenShot },
113         { "ScreenShotOfLayer",                &GenericCommunicator::ScreenShotOfLayer },
114         { "ScreenShotOfSurface",              &GenericCommunicator::ScreenShotOfSurface },
115         { "GetScreenResolution",              &GenericCommunicator::GetScreenResolution },
116         { "GetNumberOfHardwareLayers",        &GenericCommunicator::GetNumberOfHardwareLayers },
117         { "GetScreenIDs",                     &GenericCommunicator::GetScreenIDs },
118         { "ListAllLayerIDS",                  &GenericCommunicator::ListAllLayerIDS },
119         { "ListAllLayerIDsOnScreen",          &GenericCommunicator::ListAllLayerIDsOnScreen },
120         { "ListAllSurfaceIDS",                &GenericCommunicator::ListAllSurfaceIDS },
121         { "ListAllLayerGroupIDS",             &GenericCommunicator::ListAllLayerGroupIDS },
122         { "ListAllSurfaceGroupIDS",           &GenericCommunicator::ListAllSurfaceGroupIDS },
123         { "ListSurfacesOfSurfacegroup",       &GenericCommunicator::ListSurfacesOfSurfacegroup },
124         { "ListLayersOfLayergroup",           &GenericCommunicator::ListLayersOfLayergroup },
125         { "ListSurfaceofLayer",               &GenericCommunicator::ListSurfaceofLayer },
126         { "GetPropertiesOfSurface",           &GenericCommunicator::GetPropertiesOfSurface },
127         { "GetPropertiesOfLayer",             &GenericCommunicator::GetPropertiesOfLayer },
128         { "CreateSurface",                    &GenericCommunicator::CreateSurface },
129         { "CreateSurfaceFromId",              &GenericCommunicator::CreateSurfaceFromId },
130         { "InitializeSurface",                &GenericCommunicator::InitializeSurface },
131         { "InitializeSurfaceFromId",          &GenericCommunicator::InitializeSurfaceFromId },
132         { "SetSurfaceNativeContent",          &GenericCommunicator::SetSurfaceNativeContent },
133         { "RemoveSurfaceNativeContent",       &GenericCommunicator::RemoveSurfaceNativeContent },
134         { "RemoveSurface",                    &GenericCommunicator::RemoveSurface },
135         { "CreateLayer",                      &GenericCommunicator::CreateLayer },
136         { "CreateLayerFromId",                &GenericCommunicator::CreateLayerFromId },
137         { "CreateLayerWithDimension",         &GenericCommunicator::CreateLayerWithDimension },
138         { "CreateLayerFromIdWithDimension",   &GenericCommunicator::CreateLayerFromIdWithDimension },
139         { "RemoveLayer",                      &GenericCommunicator::RemoveLayer },
140         { "AddSurfaceToSurfaceGroup",         &GenericCommunicator::AddSurfaceToSurfaceGroup },
141         { "RemoveSurfaceFromSurfaceGroup",    &GenericCommunicator::RemoveSurfaceFromSurfaceGroup },
142         { "AddLayerToLayerGroup",             &GenericCommunicator::AddLayerToLayerGroup },
143         { "RemoveLayerFromLayerGroup",        &GenericCommunicator::RemoveLayerFromLayerGroup },
144         { "AddSurfaceToLayer",                &GenericCommunicator::AddSurfaceToLayer },
145         { "RemoveSurfaceFromLayer",           &GenericCommunicator::RemoveSurfaceFromLayer },
146         { "CreateSurfaceGroup",               &GenericCommunicator::CreateSurfaceGroup },
147         { "CreateSurfaceGroupFromId",         &GenericCommunicator::CreateSurfaceGroupFromId },
148         { "RemoveSurfaceGroup",               &GenericCommunicator::RemoveSurfaceGroup },
149         { "CreateLayerGroup",                 &GenericCommunicator::CreateLayerGroup },
150         { "CreateLayerGroupFromId",           &GenericCommunicator::CreateLayerGroupFromId },
151         { "RemoveLayerGroup",                 &GenericCommunicator::RemoveLayerGroup },
152         { "SetSurfaceSourceRegion",           &GenericCommunicator::SetSurfaceSourceRegion },
153         { "SetLayerSourceRegion",             &GenericCommunicator::SetLayerSourceRegion },
154         { "SetSurfaceDestinationRegion",      &GenericCommunicator::SetSurfaceDestinationRegion },
155         { "SetSurfacePosition",               &GenericCommunicator::SetSurfacePosition },
156         { "GetSurfacePosition",               &GenericCommunicator::GetSurfacePosition },
157         { "SetSurfaceDimension",              &GenericCommunicator::SetSurfaceDimension },
158         { "SetLayerDestinationRegion",        &GenericCommunicator::SetLayerDestinationRegion },
159         { "SetLayerPosition",                 &GenericCommunicator::SetLayerPosition },
160         { "GetLayerPosition",                 &GenericCommunicator::GetLayerPosition },
161         { "SetLayerDimension",                &GenericCommunicator::SetLayerDimension },
162         { "GetLayerDimension",                &GenericCommunicator::GetLayerDimension },
163         { "GetSurfaceDimension",              &GenericCommunicator::GetSurfaceDimension },
164         { "SetSurfaceOpacity",                &GenericCommunicator::SetSurfaceOpacity },
165         { "SetLayerOpacity",                  &GenericCommunicator::SetLayerOpacity },
166         { "SetSurfacegroupOpacity",           &GenericCommunicator::SetSurfacegroupOpacity },
167         { "SetLayergroupOpacity",             &GenericCommunicator::SetLayergroupOpacity },
168         { "GetSurfaceOpacity",                &GenericCommunicator::GetSurfaceOpacity },
169         { "GetLayerOpacity",                  &GenericCommunicator::GetLayerOpacity },
170         { "SetSurfaceOrientation",            &GenericCommunicator::SetSurfaceOrientation },
171         { "GetSurfaceOrientation",            &GenericCommunicator::GetSurfaceOrientation },
172         { "SetLayerOrientation",              &GenericCommunicator::SetLayerOrientation },
173         { "GetLayerOrientation",              &GenericCommunicator::GetLayerOrientation },
174         { "GetSurfacePixelformat",            &GenericCommunicator::GetSurfacePixelformat },
175         { "SetSurfaceVisibility",             &GenericCommunicator::SetSurfaceVisibility },
176         { "SetLayerVisibility",               &GenericCommunicator::SetLayerVisibility },
177         { "GetSurfaceVisibility",             &GenericCommunicator::GetSurfaceVisibility },
178         { "GetLayerVisibility",               &GenericCommunicator::GetLayerVisibility },
179         { "SetSurfacegroupVisibility",        &GenericCommunicator::SetSurfacegroupVisibility },
180         { "SetLayergroupVisibility",          &GenericCommunicator::SetLayergroupVisibility },
181         { "SetRenderOrderOfLayers",           &GenericCommunicator::SetRenderOrderOfLayers },
182         { "SetSurfaceRenderOrderWithinLayer", &GenericCommunicator::SetSurfaceRenderOrderWithinLayer },
183         { "GetLayerType",                     &GenericCommunicator::GetLayerType },
184         { "GetLayertypeCapabilities",         &GenericCommunicator::GetLayertypeCapabilities },
185         { "GetLayerCapabilities",             &GenericCommunicator::GetLayerCapabilities },
186         { "Exit",                             &GenericCommunicator::Exit },
187         { "CommitChanges",                    &GenericCommunicator::CommitChanges },
188         { "CreateShader",                     &GenericCommunicator::CreateShader },
189         { "DestroyShader",                    &GenericCommunicator::DestroyShader },
190         { "SetShader",                        &GenericCommunicator::SetShader },
191         { "SetUniforms",                      &GenericCommunicator::SetUniforms },
192         { "SetKeyboardFocusOn",               &GenericCommunicator::SetKeyboardFocusOn },
193         { "GetKeyboardFocusSurfaceId",        &GenericCommunicator::GetKeyboardFocusSurfaceId },
194         { "UpdateInputEventAcceptanceOn",     &GenericCommunicator::UpdateInputEventAcceptanceOn },
195         { "SetSurfaceChromaKey",              &GenericCommunicator::SetSurfaceChromaKey },
196         { "SetLayerChromaKey",                &GenericCommunicator::SetLayerChromaKey },
197         { "LayerAddNotification",             &GenericCommunicator::LayerAddNotification },
198         { "SurfaceAddNotification",           &GenericCommunicator::SurfaceAddNotification },
199         { "LayerRemoveNotification",          &GenericCommunicator::LayerRemoveNotification },
200         { "SurfaceRemoveNotification",        &GenericCommunicator::SurfaceRemoveNotification }
201     };
202
203     int entryCount = sizeof(manager_methods) / sizeof(MethodTable);
204
205     for (int index = 0; index < entryCount; ++index)
206     {
207         MethodTable* method = &manager_methods[index];
208         if (method->function)
209         {
210             m_callBackTable[method->name] = *method;
211             LOG_DEBUG("GenericCommunicator", "registered callback for " << method->name);
212         }
213     }
214
215     memset(&m_ipcModule, 0, sizeof(m_ipcModule));
216 }
217
218 bool GenericCommunicator::start()
219 {
220     LOG_DEBUG("GenericCommunicator", "Starting up IpcModules.");
221
222     if (!loadIpcModule(&m_ipcModule))
223     {
224         LOG_ERROR("GenericCommunicator", "Loading IpcModule failed.");
225         return ILM_FALSE;
226     }
227     LOG_DEBUG("GenericCommunicator", "Loading IpcModule success.");
228
229     if (!m_ipcModule.initServiceMode())
230     {
231         LOG_ERROR("GenericCommunicator", "Initializing IpcModule failed.");
232         return ILM_FALSE;
233     }
234     LOG_DEBUG("GenericCommunicator", "Initializing IpcModule success.");
235
236     m_running = ILM_TRUE;
237
238     return ILM_TRUE;
239 }
240
241 void GenericCommunicator::stop()
242 {
243     LOG_INFO("GenericCommunicator","stopping");
244
245     if (m_running)
246     {
247         m_ipcModule.destroy();
248     }
249 }
250
251 void GenericCommunicator::process(int timeout_ms)
252 {
253     t_ilm_message message = m_ipcModule.receive(timeout_ms);
254     if (!message)
255     {
256         return;
257     }
258
259     t_ilm_message_type messageType = m_ipcModule.getMessageType(message);
260     t_ilm_const_string name = m_ipcModule.getMessageName(message);
261     t_ilm_client_handle senderHandle = m_ipcModule.getSenderHandle(message);
262
263     switch(messageType)
264     {
265     case IpcMessageTypeCommand:
266         if (m_callBackTable.end() != m_callBackTable.find(name))
267         {
268             LOG_DEBUG("GenericCommunicator", "received: " << name << " from "
269                        << m_executor->getSenderName(senderHandle)
270                        << "(" << m_executor->getSenderPid(senderHandle) << ")");
271             CallBackMethod method = m_callBackTable[name].function;
272             (this->*method)(message);
273         }
274         else
275         {
276             LOG_WARNING("GenericCommunicator", "Received unknown command " << name
277                   << " from " << m_executor->getSenderName(senderHandle)
278                   << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
279         }
280         processNotificationQueue();
281         break;
282
283     case IpcMessageTypeConnect:
284         LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
285                   << "(pid " << m_executor->getSenderPid(senderHandle) << ") connected");
286         break;
287
288     case IpcMessageTypeDisconnect:
289         LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
290                   << "(pid " << m_executor->getSenderPid(senderHandle) << ") disconnected");
291         {
292             const LayerMap& layers = m_executor->getScene()->getAllLayers();
293             LayerMapConstIterator layerIter =  layers.begin();
294             LayerMapConstIterator layerIterEnd = layers.end();
295             for (; layerIter != layerIterEnd; ++layerIter)
296             {
297                 Layer* layer = layerIter->second;
298                 layer->removeNotification(senderHandle);
299             }
300
301             const SurfaceMap& surfaces = m_executor->getScene()->getAllSurfaces();
302             SurfaceMapConstIterator surfaceIter =  surfaces.begin();
303             SurfaceMapConstIterator surfaceIterEnd = surfaces.end();
304             for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
305             {
306                 Surface* surface = surfaceIter->second;
307                 surface->removeNotification(senderHandle);
308             }
309         }
310         break;
311
312     case IpcMessageTypeError:
313         LOG_DEBUG("GenericCommunicator", "Received error message " << name << " from "
314                   << m_executor->getSenderName(senderHandle)
315                   << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
316         break;
317
318     case IpcMessageTypeShutdown:
319     case IpcMessageTypeNone:
320         break;
321
322     default:
323         LOG_DEBUG("GenericCommunicator", "Received unknown data from "
324                   << m_executor->getSenderName(senderHandle)
325                   << "(pid " << m_executor->getSenderPid(senderHandle) << "), Message type: " << messageType);
326         break;
327     }
328     m_ipcModule.destroyMessage(message);
329 }
330
331 void GenericCommunicator::setdebug(bool onoff)
332 {
333     (void)onoff; // TODO: remove, only prevents warning
334 }
335
336 void GenericCommunicator::ServiceConnect(t_ilm_message message)
337 {
338     LOG_DEBUG("GenericCommunicator", "ServiceConnect called");
339
340     t_ilm_message response;
341     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
342
343     unsigned int processId = 0;
344     char processName[1024];
345     m_ipcModule.getUint(message, &processId);
346     m_ipcModule.getString(message, processName);
347
348     m_executor->addApplicationReference(clientHandle, new IApplicationReference(processName, processId));
349
350     response = m_ipcModule.createResponse(message);
351     m_ipcModule.sendToClients(response, &clientHandle, 1);
352     m_ipcModule.destroyMessage(response);
353 }
354
355 void GenericCommunicator::ServiceDisconnect(t_ilm_message message)
356 {
357     LOG_DEBUG("GenericCommunicator", "ServiceDisconnect called");
358
359     t_ilm_message response;
360     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
361
362     m_executor->removeApplicationReference(clientHandle);
363
364     response = m_ipcModule.createResponse(message);
365     m_ipcModule.sendToClients(response, &clientHandle, 1);
366     m_ipcModule.destroyMessage(response);
367 }
368
369 void GenericCommunicator::Debug(t_ilm_message message)
370 {
371     t_ilm_message response;
372     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
373     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
374     t_ilm_bool param = ILM_FALSE;
375     m_ipcModule.getBool(message, &param);
376
377     t_ilm_bool status = m_executor->execute(new DebugCommand(clientPid, param));
378     if (status)
379     {
380         response = m_ipcModule.createResponse(message);
381     }
382     else
383     {
384         response = m_ipcModule.createErrorResponse(message);
385         m_ipcModule.appendString(response, INVALID_ARGUMENT);
386     }
387
388     m_ipcModule.sendToClients(response, &clientHandle, 1);
389     m_ipcModule.destroyMessage(response);
390 }
391
392 void GenericCommunicator::GetScreenResolution(t_ilm_message message)
393 {
394     t_ilm_message response;
395     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
396     uint screenid = 0;
397     m_ipcModule.getUint(message, &screenid);
398     uint* resolution = m_executor->getScreenResolution(screenid);
399
400     response = m_ipcModule.createResponse(message);
401     m_ipcModule.appendUint(response, resolution[0]);
402     m_ipcModule.appendUint(response, resolution[1]);
403     m_ipcModule.sendToClients(response, &clientHandle, 1);
404     m_ipcModule.destroyMessage(response);
405 }
406
407 void GenericCommunicator::GetNumberOfHardwareLayers(t_ilm_message message)
408 {
409     t_ilm_message response;
410     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
411     uint screenid = 0;
412     m_ipcModule.getUint(message, &screenid);
413     uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid);
414     response = m_ipcModule.createResponse(message);
415     m_ipcModule.appendUint(response, numberOfHardwareLayers);
416     m_ipcModule.sendToClients(response, &clientHandle, 1);
417     m_ipcModule.destroyMessage(response);
418 }
419
420 void GenericCommunicator::GetScreenIDs(t_ilm_message message)
421 {
422     t_ilm_message response;
423     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
424     uint length = 0;
425     uint* IDs = m_executor->getScreenIDs(&length);
426     response = m_ipcModule.createResponse(message);
427     m_ipcModule.appendUintArray(response, IDs, length);
428     m_ipcModule.sendToClients(response, &clientHandle, 1);
429     m_ipcModule.destroyMessage(response);
430 }
431
432 void GenericCommunicator::ScreenShot(t_ilm_message message)
433 {
434     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
435     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
436     t_ilm_message response;
437     uint screenid = 0;
438     char filename[1024];
439
440     m_ipcModule.getUint(message, &screenid);
441     m_ipcModule.getString(message, filename);
442
443     t_ilm_bool status = m_executor->execute(new ScreenDumpCommand(clientPid, filename, screenid));
444     if (status)
445     {
446         response = m_ipcModule.createResponse(message);
447     }
448     else
449     {
450         response = m_ipcModule.createErrorResponse(message);
451         m_ipcModule.appendString(response, INVALID_ARGUMENT);
452     }
453
454     m_ipcModule.sendToClients(response, &clientHandle, 1);
455     m_ipcModule.destroyMessage(response);
456 }
457
458 void GenericCommunicator::ScreenShotOfLayer(t_ilm_message message)
459 {
460     t_ilm_message response;
461     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
462     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
463     char filename[1024];
464     m_ipcModule.getString(message, filename);
465     uint layerid = 0;
466     m_ipcModule.getUint(message, &layerid);
467
468     t_ilm_bool status = m_executor->execute(new LayerDumpCommand(clientPid, filename, layerid));
469     if (status)
470     {
471         response = m_ipcModule.createResponse(message);
472     }
473     else
474     {
475         response = m_ipcModule.createErrorResponse(message);
476         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
477     }
478
479     m_ipcModule.sendToClients(response, &clientHandle, 1);
480     m_ipcModule.destroyMessage(response);
481 }
482
483 void GenericCommunicator::ScreenShotOfSurface(t_ilm_message message)
484 {
485     t_ilm_message response;
486     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
487     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
488     char filename[1024];
489     m_ipcModule.getString(message, filename);
490     uint id = 0;
491     m_ipcModule.getUint(message, &id);
492     t_ilm_bool status = m_executor->execute(new SurfaceDumpCommand(clientPid, filename, id));
493     if (status)
494     {
495         response = m_ipcModule.createResponse(message);
496     }
497     else
498     {
499         response = m_ipcModule.createErrorResponse(message);
500         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
501     }
502
503     m_ipcModule.sendToClients(response, &clientHandle, 1);
504     m_ipcModule.destroyMessage(response);
505 }
506
507 void GenericCommunicator::ListAllLayerIDS(t_ilm_message message)
508 {
509     t_ilm_message response;
510     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
511     uint* array = NULL;
512     uint length = 0;
513     m_executor->getScene()->lockScene();
514     m_executor->getScene()->getLayerIDs(&length, &array);
515     m_executor->getScene()->unlockScene();
516     response = m_ipcModule.createResponse(message);
517     m_ipcModule.appendUintArray(response, array, length);
518     m_ipcModule.sendToClients(response, &clientHandle, 1);
519     m_ipcModule.destroyMessage(response);
520 }
521
522 void GenericCommunicator::ListAllLayerIDsOnScreen(t_ilm_message message)
523 {
524     t_ilm_message response;
525     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
526     uint screenID = 0;
527     m_ipcModule.getUint(message, &screenID);
528
529     uint* array = NULL;
530     uint length = 0;
531     m_executor->getScene()->lockScene();
532     t_ilm_bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
533     m_executor->getScene()->unlockScene();
534     if (status)
535     {
536         response = m_ipcModule.createResponse(message);
537         m_ipcModule.appendUintArray(response, array, length);
538     }
539     else
540     {
541         response = m_ipcModule.createErrorResponse(message);
542         m_ipcModule.appendString(response, INVALID_ARGUMENT);
543     }
544
545     m_ipcModule.sendToClients(response, &clientHandle, 1);
546     m_ipcModule.destroyMessage(response);
547 }
548
549 void GenericCommunicator::ListAllSurfaceIDS(t_ilm_message message)
550 {
551     t_ilm_message response;
552     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
553     uint* array = NULL;
554     uint length = 0;
555     m_executor->getScene()->lockScene();
556     m_executor->getScene()->getSurfaceIDs(&length, &array);
557     m_executor->getScene()->unlockScene();
558     response = m_ipcModule.createResponse(message);
559     m_ipcModule.appendUintArray(response, array, length);
560     m_ipcModule.sendToClients(response, &clientHandle, 1);
561     m_ipcModule.destroyMessage(response);
562 }
563
564 void GenericCommunicator::ListAllLayerGroupIDS(t_ilm_message message)
565 {
566     t_ilm_message response;
567     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
568     uint* array = NULL;
569     uint length = 0;
570     m_executor->getScene()->lockScene();
571     m_executor->getScene()->getLayerGroupIDs(&length, &array);
572     m_executor->getScene()->unlockScene();
573     response = m_ipcModule.createResponse(message);
574     m_ipcModule.appendUintArray(response, array, length);
575     m_ipcModule.sendToClients(response, &clientHandle, 1);
576     m_ipcModule.destroyMessage(response);
577 }
578
579 void GenericCommunicator::ListAllSurfaceGroupIDS(t_ilm_message message)
580 {
581     t_ilm_message response;
582     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
583     uint* array = NULL;
584     uint length = 0;
585     m_executor->getScene()->lockScene();
586     m_executor->getScene()->getSurfaceGroupIDs(&length, &array);
587     m_executor->getScene()->unlockScene();
588     response = m_ipcModule.createResponse(message);
589     m_ipcModule.appendUintArray(response, array, length);
590     m_ipcModule.sendToClients(response, &clientHandle, 1);
591     m_ipcModule.destroyMessage(response);
592 }
593
594 void GenericCommunicator::ListSurfacesOfSurfacegroup(t_ilm_message message)
595 {
596     t_ilm_message response;
597     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
598     uint id = 0;
599     m_ipcModule.getUint(message, &id);
600     m_executor->getScene()->lockScene();
601     SurfaceGroup* sg = m_executor->getScene()->getSurfaceGroup(id);
602     if (NULL != sg)
603     {
604         std::list<Surface*> surfaces = sg->getList();
605         uint length = surfaces.size();
606         uint* array = new uint[length];
607         uint arrayPos = 0;
608
609         for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
610         {
611             Surface* s = *it;
612             array[arrayPos] = s->getID();
613             ++arrayPos;
614         }
615         m_executor->getScene()->unlockScene();
616
617         response = m_ipcModule.createResponse(message);
618         m_ipcModule.appendUintArray(response, array, length);
619     }
620     else
621     {
622         m_executor->getScene()->unlockScene();
623         response = m_ipcModule.createErrorResponse(message);
624         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
625     }
626
627     m_ipcModule.sendToClients(response, &clientHandle, 1);
628     m_ipcModule.destroyMessage(response);
629 }
630
631 void GenericCommunicator::ListLayersOfLayergroup(t_ilm_message message)
632 {
633     t_ilm_message response;
634     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
635     uint id = 0;
636     m_ipcModule.getUint(message, &id);
637     m_executor->getScene()->lockScene();
638     LayerGroup* sg = m_executor->getScene()->getLayerGroup(id);
639     if (NULL != sg)
640     {
641         std::list<Layer*> layers = sg->getList();
642
643         uint length = layers.size();
644         uint* array = new uint[length];
645         uint arrayPos = 0;
646
647         for (std::list<Layer*>::const_iterator it = layers.begin(); it != layers.end(); ++it)
648         {
649             Layer* l = *it;
650             array[arrayPos] = l->getID();
651             ++arrayPos;
652         }
653         m_executor->getScene()->unlockScene();
654
655         response = m_ipcModule.createResponse(message);
656         m_ipcModule.appendUintArray(response, array, length);
657     }
658     else
659     {
660         m_executor->getScene()->unlockScene();
661         response = m_ipcModule.createErrorResponse(message);
662         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
663     }
664
665     m_ipcModule.sendToClients(response, &clientHandle, 1);
666     m_ipcModule.destroyMessage(response);
667 }
668
669 void GenericCommunicator::ListSurfaceofLayer(t_ilm_message message)
670 {
671     t_ilm_message response;
672     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
673     uint id = 0;
674     m_ipcModule.getUint(message, &id);
675     m_executor->getScene()->lockScene();
676     Layer* layer = m_executor->getScene()->getLayer(id);
677     if (layer != NULL)
678     {
679         std::list<Surface*> surfaces = layer->getAllSurfaces();
680
681         uint length = surfaces.size();
682         uint* array = new uint[length];
683         uint arrayPos = 0;
684
685         for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
686         {
687             Surface* s = *it;
688             array[arrayPos] = s->getID();
689             ++arrayPos;
690         }
691         m_executor->getScene()->unlockScene();
692
693         response = m_ipcModule.createResponse(message);
694         m_ipcModule.appendUintArray(response, array, length);
695     }
696     else
697     {
698         m_executor->getScene()->unlockScene();
699         response = m_ipcModule.createErrorResponse(message);
700         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
701     }
702
703     m_ipcModule.sendToClients(response, &clientHandle, 1);
704     m_ipcModule.destroyMessage(response);
705 }
706
707 void GenericCommunicator::GetPropertiesOfSurface(t_ilm_message message)
708 {
709     t_ilm_message response;
710     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
711     uint id = 0;
712     m_ipcModule.getUint(message, &id);
713
714     Surface* surface = m_executor->getScene()->getSurface(id);
715     if (surface != NULL)
716     {
717         Rectangle dest = surface->getDestinationRegion();
718         Rectangle src = surface->getSourceRegion();
719         OrientationType orientation = surface->getOrientation();
720         unsigned char chromaKeyRed = 0;
721         unsigned char chromaKeyGreen = 0;
722         unsigned char chromaKeyBlue = 0;
723         surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
724
725         response = m_ipcModule.createResponse(message);
726         m_ipcModule.appendDouble(response, surface->getOpacity());
727         m_ipcModule.appendUint(response, src.x);
728         m_ipcModule.appendUint(response, src.y);
729         m_ipcModule.appendUint(response, src.width);
730         m_ipcModule.appendUint(response, src.height);
731         m_ipcModule.appendUint(response, surface->OriginalSourceWidth);
732         m_ipcModule.appendUint(response, surface->OriginalSourceHeight);
733         m_ipcModule.appendUint(response, dest.x);
734         m_ipcModule.appendUint(response, dest.y);
735         m_ipcModule.appendUint(response, dest.width);
736         m_ipcModule.appendUint(response, dest.height);
737         m_ipcModule.appendUint(response, orientation);
738         m_ipcModule.appendBool(response, surface->getVisibility());
739         m_ipcModule.appendUint(response, surface->frameCounter);
740         m_ipcModule.appendUint(response, surface->drawCounter);
741         m_ipcModule.appendUint(response, surface->updateCounter);
742         m_ipcModule.appendUint(response, surface->getPixelFormat());
743         m_ipcModule.appendUint(response, surface->getNativeContent());
744         m_ipcModule.appendUint(response, surface->getInputEventAcceptanceOnDevices());
745         m_ipcModule.appendBool(response, surface->getChromaKeyEnabled());
746         m_ipcModule.appendUint(response, chromaKeyRed);
747         m_ipcModule.appendUint(response, chromaKeyGreen);
748         m_ipcModule.appendUint(response, chromaKeyBlue);
749         m_ipcModule.appendInt(response, surface->getCreatorPid());
750     }
751     else
752     {
753         response = m_ipcModule.createErrorResponse(message);
754         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
755     }
756
757     m_ipcModule.sendToClients(response, &clientHandle, 1);
758     m_ipcModule.destroyMessage(response);
759 }
760
761 void GenericCommunicator::GetPropertiesOfLayer(t_ilm_message message)
762 {
763     t_ilm_message response;
764     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
765     uint id = 0;
766     m_ipcModule.getUint(message, &id);
767
768     Layer* layer = m_executor->getScene()->getLayer(id);
769     if (layer != NULL)
770     {
771         Rectangle dest = layer->getDestinationRegion();
772         Rectangle src = layer->getSourceRegion();
773         OrientationType orientation = layer->getOrientation();
774         unsigned char chromaKeyRed = 0;
775         unsigned char chromaKeyGreen = 0;
776         unsigned char chromaKeyBlue = 0;
777         layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
778
779         response = m_ipcModule.createResponse(message);
780         m_ipcModule.appendDouble(response, layer->getOpacity());
781         m_ipcModule.appendUint(response, src.x);
782         m_ipcModule.appendUint(response, src.y);
783         m_ipcModule.appendUint(response, src.width);
784         m_ipcModule.appendUint(response, src.height);
785         m_ipcModule.appendUint(response, layer->OriginalSourceWidth);
786         m_ipcModule.appendUint(response, layer->OriginalSourceHeight);
787         m_ipcModule.appendUint(response, dest.x);
788         m_ipcModule.appendUint(response, dest.y);
789         m_ipcModule.appendUint(response, dest.width);
790         m_ipcModule.appendUint(response, dest.height);
791         m_ipcModule.appendUint(response, orientation);
792         m_ipcModule.appendBool(response, layer->getVisibility());
793         m_ipcModule.appendUint(response, layer->getLayerType());
794         m_ipcModule.appendBool(response, layer->getChromaKeyEnabled());
795         m_ipcModule.appendUint(response, chromaKeyRed);
796         m_ipcModule.appendUint(response, chromaKeyGreen);
797         m_ipcModule.appendUint(response, chromaKeyBlue);
798         m_ipcModule.appendInt(response, layer->getCreatorPid());
799     }
800     else
801     {
802         response = m_ipcModule.createErrorResponse(message);
803         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
804     }
805
806     m_ipcModule.sendToClients(response, &clientHandle, 1);
807     m_ipcModule.destroyMessage(response);
808 }
809
810 void GenericCommunicator::CreateSurface(t_ilm_message message)
811 {
812     t_ilm_message response;
813     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
814     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
815     uint handle = 0;
816     uint width = 0;
817     uint height = 0;
818     uint pixelformat = 0;
819     PixelFormat pf = PIXELFORMAT_UNKNOWN;
820     uint id = GraphicalObject::INVALID_ID;
821
822     m_ipcModule.getUint(message, &handle);
823     m_ipcModule.getUint(message, &width);
824     m_ipcModule.getUint(message, &height);
825     m_ipcModule.getUint(message, &pixelformat);
826
827     pf = (PixelFormat) pixelformat;
828
829
830     // First of all create the surface
831     t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
832
833     // after that apply the native content
834     status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
835
836     if (status)
837     {
838         response = m_ipcModule.createResponse(message);
839         m_ipcModule.appendUint(response, id);
840     }
841     else
842     {
843         response = m_ipcModule.createErrorResponse(message);
844         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
845     }
846
847     m_ipcModule.sendToClients(response, &clientHandle, 1);
848     m_ipcModule.destroyMessage(response);
849 }
850
851 void GenericCommunicator::CreateSurfaceFromId(t_ilm_message message)
852 {
853     t_ilm_message response;
854     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
855     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
856     uint handle = 0;
857     uint width = 0;
858     uint height = 0;
859     uint pixelformat = 0;
860     PixelFormat pf = PIXELFORMAT_UNKNOWN;
861     uint id = 0;
862
863     m_ipcModule.getUint(message, &handle);
864     m_ipcModule.getUint(message, &width);
865     m_ipcModule.getUint(message, &height);
866     m_ipcModule.getUint(message, &pixelformat);
867     m_ipcModule.getUint(message, &id);
868
869     pf = (PixelFormat) pixelformat;
870
871     // First of all create the surface
872     t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
873
874     // after that apply the native content
875     status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
876
877     if (status)
878     {
879         response = m_ipcModule.createResponse(message);
880         m_ipcModule.appendUint(response, id);
881     }
882     else
883     {
884         response = m_ipcModule.createErrorResponse(message);
885         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
886     }
887
888     m_ipcModule.sendToClients(response, &clientHandle, 1);
889     m_ipcModule.destroyMessage(response);
890 }
891
892 void GenericCommunicator::InitializeSurface(t_ilm_message message)
893 {
894     t_ilm_message response;
895     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
896     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
897     uint id = GraphicalObject::INVALID_ID;
898
899     t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
900     if (status)
901     {
902         response = m_ipcModule.createResponse(message);
903         m_ipcModule.appendUint(response, id);
904     }
905     else
906     {
907         response = m_ipcModule.createErrorResponse(message);
908         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
909     }
910
911     m_ipcModule.sendToClients(response, &clientHandle, 1);
912     m_ipcModule.destroyMessage(response);
913 }
914
915 void GenericCommunicator::InitializeSurfaceFromId(t_ilm_message message)
916 {
917     t_ilm_message response;
918     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
919     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
920     uint id = 0;
921     m_ipcModule.getUint(message, &id);
922     t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
923     if (status)
924     {
925         response = m_ipcModule.createResponse(message);
926         m_ipcModule.appendUint(response, id);
927     }
928     else
929     {
930         response = m_ipcModule.createErrorResponse(message);
931         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
932     }
933
934     m_ipcModule.sendToClients(response, &clientHandle, 1);
935     m_ipcModule.destroyMessage(response);
936 }
937
938 void GenericCommunicator::SetSurfaceNativeContent(t_ilm_message message)
939 {
940     t_ilm_message response;
941     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
942     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
943     uint id = 0;
944     uint handle = 0;
945     uint width = 0;
946     uint height = 0;
947     uint pixelformat = 0;
948     PixelFormat pf = PIXELFORMAT_UNKNOWN;
949
950     m_ipcModule.getUint(message, &id);
951     m_ipcModule.getUint(message, &handle);
952     m_ipcModule.getUint(message, &width);
953     m_ipcModule.getUint(message, &height);
954     m_ipcModule.getUint(message, &pixelformat);
955
956     pf = (PixelFormat) pixelformat;
957
958     t_ilm_bool status = m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
959     if (status)
960     {
961         response = m_ipcModule.createResponse(message);
962     }
963     else
964     {
965         response = m_ipcModule.createErrorResponse(message);
966         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
967     }
968
969     m_ipcModule.sendToClients(response, &clientHandle, 1);
970     m_ipcModule.destroyMessage(response);
971 }
972
973 void GenericCommunicator::RemoveSurfaceNativeContent(t_ilm_message message)
974 {
975     t_ilm_message response;
976     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
977     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
978     uint id = 0;
979     m_ipcModule.getUint(message, &id);
980
981     t_ilm_bool status = m_executor->execute(new SurfaceRemoveNativeContentCommand(clientPid, id));
982     if (status)
983     {
984         response = m_ipcModule.createResponse(message);
985     }
986     else
987     {
988         response = m_ipcModule.createErrorResponse(message);
989         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
990     }
991
992     m_ipcModule.sendToClients(response, &clientHandle, 1);
993     m_ipcModule.destroyMessage(response);
994 }
995
996 void GenericCommunicator::RemoveSurface(t_ilm_message message)
997 {
998     t_ilm_message response;
999     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1000     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1001     uint param = 0;
1002     m_ipcModule.getUint(message, &param);
1003     t_ilm_bool status = m_executor->execute(new SurfaceRemoveCommand(clientPid, param));
1004     if (status)
1005     {
1006         response = m_ipcModule.createResponse(message);
1007     }
1008     else
1009     {
1010         response = m_ipcModule.createErrorResponse(message);
1011         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1012     }
1013
1014     m_ipcModule.sendToClients(response, &clientHandle, 1);
1015     m_ipcModule.destroyMessage(response);
1016 }
1017
1018 void GenericCommunicator::CreateLayer(t_ilm_message message)
1019 {
1020     t_ilm_message response;
1021     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1022     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1023     uint id = GraphicalObject::INVALID_ID;
1024     // use resolution of default screen as default width and height of layers
1025     uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
1026     t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
1027     if (status)
1028     {
1029         response = m_ipcModule.createResponse(message);
1030         m_ipcModule.appendUint(response, id);
1031     }
1032     else
1033     {
1034         response = m_ipcModule.createErrorResponse(message);
1035         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1036     }
1037
1038     m_ipcModule.sendToClients(response, &clientHandle, 1);
1039     m_ipcModule.destroyMessage(response);
1040 }
1041
1042 void GenericCommunicator::CreateLayerFromId(t_ilm_message message)
1043 {
1044     t_ilm_message response;
1045     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1046     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1047     uint id = GraphicalObject::INVALID_ID;
1048
1049     m_ipcModule.getUint(message, &id);
1050     // use resolution of default screen as default width and height of layers
1051     uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
1052     t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
1053     if (status)
1054     {
1055         response = m_ipcModule.createResponse(message);
1056         m_ipcModule.appendUint(response, id);
1057     }
1058     else
1059     {
1060         response = m_ipcModule.createErrorResponse(message);
1061         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1062     }
1063
1064     m_ipcModule.sendToClients(response, &clientHandle, 1);
1065     m_ipcModule.destroyMessage(response);
1066 }
1067
1068
1069 void GenericCommunicator::CreateLayerWithDimension(t_ilm_message message)
1070 {
1071     t_ilm_message response;
1072     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1073     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1074     uint width = 0;
1075     m_ipcModule.getUint(message, &width);
1076     uint height = 0;
1077     m_ipcModule.getUint(message, &height);
1078
1079     uint id = GraphicalObject::INVALID_ID;
1080     t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
1081     if (status)
1082     {
1083         response = m_ipcModule.createResponse(message);
1084         m_ipcModule.appendUint(response, id);
1085     }
1086     else
1087     {
1088         response = m_ipcModule.createErrorResponse(message);
1089         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1090     }
1091
1092     m_ipcModule.sendToClients(response, &clientHandle, 1);
1093     m_ipcModule.destroyMessage(response);
1094 }
1095
1096 void GenericCommunicator::CreateLayerFromIdWithDimension(t_ilm_message message)
1097 {
1098     t_ilm_message response;
1099     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1100     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1101     uint id = GraphicalObject::INVALID_ID;
1102     uint width = 0;
1103     uint height = 0;
1104     t_ilm_bool status = ILM_FALSE;
1105
1106     m_ipcModule.getUint(message, &id);
1107     m_ipcModule.getUint(message, &width);
1108     m_ipcModule.getUint(message, &height);
1109
1110     status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
1111     if (status)
1112     {
1113         response = m_ipcModule.createResponse(message);
1114         m_ipcModule.appendUint(response, id);
1115     }
1116     else
1117     {
1118         response = m_ipcModule.createErrorResponse(message);
1119         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1120     }
1121
1122     m_ipcModule.sendToClients(response, &clientHandle, 1);
1123     m_ipcModule.destroyMessage(response);
1124 }
1125
1126 void GenericCommunicator::RemoveLayer(t_ilm_message message)
1127 {
1128     t_ilm_message response;
1129     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1130     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1131     uint param = 0;
1132     m_ipcModule.getUint(message, &param);
1133     t_ilm_bool status = m_executor->execute(new LayerRemoveCommand(clientPid, param));
1134     if (status)
1135     {
1136         response = m_ipcModule.createResponse(message);
1137     }
1138     else
1139     {
1140         response = m_ipcModule.createErrorResponse(message);
1141         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1142     }
1143
1144     m_ipcModule.sendToClients(response, &clientHandle, 1);
1145     m_ipcModule.destroyMessage(response);
1146 }
1147
1148 void GenericCommunicator::AddSurfaceToSurfaceGroup(t_ilm_message message)
1149 {
1150     t_ilm_message response;
1151     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1152     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1153     uint surfaceid = 0;
1154     uint surfacegroupid = 0;
1155
1156     m_ipcModule.getUint(message, &surfaceid);
1157     m_ipcModule.getUint(message, &surfacegroupid);
1158
1159     t_ilm_bool status = m_executor->execute(new SurfacegroupAddSurfaceCommand(clientPid, surfacegroupid, surfaceid));
1160     if (status)
1161     {
1162         response = m_ipcModule.createResponse(message);
1163     }
1164     else
1165     {
1166         response = m_ipcModule.createErrorResponse(message);
1167         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1168     }
1169
1170     m_ipcModule.sendToClients(response, &clientHandle, 1);
1171     m_ipcModule.destroyMessage(response);
1172 }
1173
1174 void GenericCommunicator::RemoveSurfaceFromSurfaceGroup(t_ilm_message message)
1175 {
1176     t_ilm_message response;
1177     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1178     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1179     uint surfaceid = 0;
1180     uint surfacegroupid = 0;
1181
1182     m_ipcModule.getUint(message, &surfaceid);
1183     m_ipcModule.getUint(message, &surfacegroupid);
1184
1185     t_ilm_bool status = m_executor->execute(new SurfacegroupRemoveSurfaceCommand(clientPid, surfacegroupid, surfaceid));
1186     if (status)
1187     {
1188         response = m_ipcModule.createResponse(message);
1189     }
1190     else
1191     {
1192         response = m_ipcModule.createErrorResponse(message);
1193         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1194     }
1195
1196     m_ipcModule.sendToClients(response, &clientHandle, 1);
1197     m_ipcModule.destroyMessage(response);
1198 }
1199
1200 void GenericCommunicator::AddLayerToLayerGroup(t_ilm_message message)
1201 {
1202     t_ilm_message response;
1203     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1204     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1205     uint layerid = 0;
1206     uint layergroupid = 0;
1207
1208     m_ipcModule.getUint(message, &layerid);
1209     m_ipcModule.getUint(message, &layergroupid);
1210
1211     t_ilm_bool status = m_executor->execute(new LayergroupAddLayerCommand(clientPid, layergroupid, layerid));
1212     if (status)
1213     {
1214         response = m_ipcModule.createResponse(message);
1215     }
1216     else
1217     {
1218         response = m_ipcModule.createErrorResponse(message);
1219         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1220     }
1221
1222     m_ipcModule.sendToClients(response, &clientHandle, 1);
1223     m_ipcModule.destroyMessage(response);
1224 }
1225
1226 void GenericCommunicator::RemoveLayerFromLayerGroup(t_ilm_message message)
1227 {
1228     t_ilm_message response;
1229     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1230     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1231     uint layerid = 0;
1232     uint layergroupid = 0;
1233
1234     m_ipcModule.getUint(message, &layerid);
1235     m_ipcModule.getUint(message, &layergroupid);
1236
1237     t_ilm_bool status = m_executor->execute(new LayergroupRemoveLayerCommand(clientPid, layergroupid, layerid));
1238     if (status)
1239     {
1240         response = m_ipcModule.createResponse(message);
1241     }
1242     else
1243     {
1244         response = m_ipcModule.createErrorResponse(message);
1245         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1246     }
1247
1248     m_ipcModule.sendToClients(response, &clientHandle, 1);
1249     m_ipcModule.destroyMessage(response);
1250 }
1251
1252 void GenericCommunicator::AddSurfaceToLayer(t_ilm_message message)
1253 {
1254     t_ilm_message response;
1255     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1256     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1257     uint surfaceid = 0;
1258     uint layer = 0;
1259
1260     m_ipcModule.getUint(message, &surfaceid);
1261     m_ipcModule.getUint(message, &layer);
1262
1263     t_ilm_bool status = m_executor->execute(new LayerAddSurfaceCommand(clientPid, layer, surfaceid));
1264     if (status)
1265     {
1266         response = m_ipcModule.createResponse(message);
1267     }
1268     else
1269     {
1270         response = m_ipcModule.createErrorResponse(message);
1271         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1272     }
1273
1274     m_ipcModule.sendToClients(response, &clientHandle, 1);
1275     m_ipcModule.destroyMessage(response);
1276 }
1277
1278 void GenericCommunicator::RemoveSurfaceFromLayer(t_ilm_message message)
1279 {
1280     t_ilm_message response;
1281     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1282     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1283     uint surfaceid = 0;
1284     uint layerid = 0;
1285     m_ipcModule.getUint(message, &surfaceid);
1286     m_ipcModule.getUint(message, &layerid);
1287
1288     t_ilm_bool status = m_executor->execute(new LayerRemoveSurfaceCommand(clientPid, layerid, surfaceid));
1289     if (status)
1290     {
1291         response = m_ipcModule.createResponse(message);
1292     }
1293     else
1294     {
1295         response = m_ipcModule.createErrorResponse(message);
1296         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1297     }
1298
1299     m_ipcModule.sendToClients(response, &clientHandle, 1);
1300     m_ipcModule.destroyMessage(response);
1301 }
1302
1303 void GenericCommunicator::CreateSurfaceGroup(t_ilm_message message)
1304 {
1305     t_ilm_message response;
1306     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1307     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1308     uint newID = GraphicalObject::INVALID_ID;
1309
1310     t_ilm_bool status = m_executor->execute(new SurfacegroupCreateCommand(clientPid, &newID));
1311     if (status)
1312     {
1313         response = m_ipcModule.createResponse(message);
1314         m_ipcModule.appendUint(response, newID);
1315     }
1316     else
1317     {
1318         response = m_ipcModule.createErrorResponse(message);
1319         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1320     }
1321
1322     m_ipcModule.sendToClients(response, &clientHandle, 1);
1323     m_ipcModule.destroyMessage(response);
1324 }
1325
1326 void GenericCommunicator::CreateSurfaceGroupFromId(t_ilm_message message)
1327 {
1328     t_ilm_message response;
1329     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1330     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1331     uint newID = GraphicalObject::INVALID_ID;
1332
1333     m_ipcModule.getUint(message, &newID);
1334
1335     t_ilm_bool status = m_executor->execute(new SurfacegroupCreateCommand(clientPid, &newID));
1336     if (status)
1337     {
1338         response = m_ipcModule.createResponse(message);
1339         m_ipcModule.appendUint(response, newID);
1340     }
1341     else
1342     {
1343         response = m_ipcModule.createErrorResponse(message);
1344         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1345     }
1346
1347     m_ipcModule.sendToClients(response, &clientHandle, 1);
1348     m_ipcModule.destroyMessage(response);
1349 }
1350
1351 void GenericCommunicator::RemoveSurfaceGroup(t_ilm_message message)
1352 {
1353     t_ilm_message response;
1354     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1355     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1356     uint param = 0;
1357     m_ipcModule.getUint(message, &param);
1358
1359     t_ilm_bool status = m_executor->execute(new SurfacegroupRemoveCommand(clientPid, param));
1360     if (status)
1361     {
1362         response = m_ipcModule.createResponse(message);
1363     }
1364     else
1365     {
1366         response = m_ipcModule.createErrorResponse(message);
1367         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1368     }
1369
1370     m_ipcModule.sendToClients(response, &clientHandle, 1);
1371     m_ipcModule.destroyMessage(response);
1372 }
1373
1374 void GenericCommunicator::CreateLayerGroup(t_ilm_message message)
1375 {
1376     t_ilm_message response;
1377     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1378     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1379     uint newID = GraphicalObject::INVALID_ID;
1380
1381     t_ilm_bool status = m_executor->execute(new LayergroupCreateCommand(clientPid, &newID));
1382     if (status)
1383     {
1384         response = m_ipcModule.createResponse(message);
1385         m_ipcModule.appendUint(response, newID);
1386     }
1387     else
1388     {
1389         response = m_ipcModule.createErrorResponse(message);
1390         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1391     }
1392
1393     m_ipcModule.sendToClients(response, &clientHandle, 1);
1394     m_ipcModule.destroyMessage(response);
1395 }
1396
1397 void GenericCommunicator::CreateLayerGroupFromId(t_ilm_message message)
1398 {
1399     t_ilm_message response;
1400     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1401     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1402     uint newID = GraphicalObject::INVALID_ID;
1403
1404     m_ipcModule.getUint(message, &newID);
1405
1406     t_ilm_bool status = m_executor->execute(new LayergroupCreateCommand(clientPid, &newID));
1407     if (status)
1408     {
1409         response = m_ipcModule.createResponse(message);
1410         m_ipcModule.appendUint(response, newID);
1411     }
1412     else
1413     {
1414         response = m_ipcModule.createErrorResponse(message);
1415         m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1416     }
1417
1418     m_ipcModule.sendToClients(response, &clientHandle, 1);
1419     m_ipcModule.destroyMessage(response);
1420 }
1421
1422 void GenericCommunicator::RemoveLayerGroup(t_ilm_message message)
1423 {
1424     t_ilm_message response;
1425     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1426     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1427     uint param = 0;
1428     m_ipcModule.getUint(message, &param);
1429
1430     t_ilm_bool status = m_executor->execute(new LayergroupRemoveCommand(clientPid, param));
1431     if (status)
1432     {
1433         response = m_ipcModule.createResponse(message);
1434     }
1435     else
1436     {
1437         response = m_ipcModule.createErrorResponse(message);
1438         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1439     }
1440
1441     m_ipcModule.sendToClients(response, &clientHandle, 1);
1442     m_ipcModule.destroyMessage(response);
1443 }
1444
1445 void GenericCommunicator::SetSurfaceSourceRegion(t_ilm_message message)
1446 {
1447     t_ilm_message response;
1448     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1449     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1450     uint id = 0;
1451     uint x = 0;
1452     uint y = 0;
1453     uint width = 0;
1454     uint height = 0;
1455
1456     m_ipcModule.getUint(message, &id);
1457     m_ipcModule.getUint(message, &x);
1458     m_ipcModule.getUint(message, &y);
1459     m_ipcModule.getUint(message, &width);
1460     m_ipcModule.getUint(message, &height);
1461
1462     t_ilm_bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1463     if (status)
1464     {
1465         response = m_ipcModule.createResponse(message);
1466     }
1467     else
1468     {
1469         response = m_ipcModule.createErrorResponse(message);
1470         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1471     }
1472
1473     m_ipcModule.sendToClients(response, &clientHandle, 1);
1474     m_ipcModule.destroyMessage(response);
1475 }
1476
1477 void GenericCommunicator::SetLayerSourceRegion(t_ilm_message message)
1478 {
1479     t_ilm_message response;
1480     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1481     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1482     uint id = 0;
1483     uint x = 0;
1484     uint y = 0;
1485     uint width = 0;
1486     uint height = 0;
1487
1488     m_ipcModule.getUint(message, &id);
1489     m_ipcModule.getUint(message, &x);
1490     m_ipcModule.getUint(message, &y);
1491     m_ipcModule.getUint(message, &width);
1492     m_ipcModule.getUint(message, &height);
1493
1494     t_ilm_bool status = m_executor->execute(new LayerSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1495     if (status)
1496     {
1497         response = m_ipcModule.createResponse(message);
1498     }
1499     else
1500     {
1501         response = m_ipcModule.createErrorResponse(message);
1502         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1503     }
1504
1505     m_ipcModule.sendToClients(response, &clientHandle, 1);
1506     m_ipcModule.destroyMessage(response);
1507 }
1508
1509 void GenericCommunicator::SetSurfaceDestinationRegion(t_ilm_message message)
1510 {
1511     t_ilm_message response;
1512     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1513     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1514     uint id = 0;
1515     uint x = 0;
1516     uint y = 0;
1517     uint width = 0;
1518     uint height = 0;
1519
1520     m_ipcModule.getUint(message, &id);
1521     m_ipcModule.getUint(message, &x);
1522     m_ipcModule.getUint(message, &y);
1523     m_ipcModule.getUint(message, &width);
1524     m_ipcModule.getUint(message, &height);
1525
1526     t_ilm_bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1527     if (status)
1528     {
1529         response = m_ipcModule.createResponse(message);
1530     }
1531     else
1532     {
1533         response = m_ipcModule.createErrorResponse(message);
1534         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1535     }
1536
1537     m_ipcModule.sendToClients(response, &clientHandle, 1);
1538     m_ipcModule.destroyMessage(response);
1539 }
1540
1541 void GenericCommunicator::SetSurfacePosition(t_ilm_message message)
1542 {
1543     t_ilm_message response;
1544     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1545     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1546     uint id = 0;
1547     uint x = 0;
1548     uint y = 0;
1549
1550     m_ipcModule.getUint(message, &id);
1551     m_ipcModule.getUint(message, &x);
1552     m_ipcModule.getUint(message, &y);
1553
1554     t_ilm_bool status = m_executor->execute(new SurfaceSetPositionCommand(clientPid, id, x, y));
1555     if (status)
1556     {
1557         response = m_ipcModule.createResponse(message);
1558     }
1559     else
1560     {
1561         response = m_ipcModule.createErrorResponse(message);
1562         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1563     }
1564
1565     m_ipcModule.sendToClients(response, &clientHandle, 1);
1566     m_ipcModule.destroyMessage(response);
1567 }
1568
1569 void GenericCommunicator::GetSurfacePosition(t_ilm_message message)
1570 {
1571     t_ilm_message response;
1572     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1573     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1574     uint id = 0;
1575     uint x = 0;
1576     uint y = 0;
1577
1578     m_ipcModule.getUint(message, &id);
1579
1580     t_ilm_bool status = m_executor->execute(new SurfaceGetPositionCommand(clientPid, id, &x, &y));
1581     if (status)
1582     {
1583         response = m_ipcModule.createResponse(message);
1584         m_ipcModule.appendUint(response, x);
1585         m_ipcModule.appendUint(response, y);
1586     }
1587     else
1588     {
1589         response = m_ipcModule.createErrorResponse(message);
1590         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1591     }
1592
1593     m_ipcModule.sendToClients(response, &clientHandle, 1);
1594     m_ipcModule.destroyMessage(response);
1595 }
1596
1597 void GenericCommunicator::SetSurfaceDimension(t_ilm_message message)
1598 {
1599     t_ilm_message response;
1600     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1601     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1602     uint id = 0;
1603     uint width = 0;
1604     uint height = 0;
1605
1606     m_ipcModule.getUint(message, &id);
1607     m_ipcModule.getUint(message, &width);
1608     m_ipcModule.getUint(message, &height);
1609
1610     t_ilm_bool status = m_executor->execute(new SurfaceSetDimensionCommand(clientPid, id, width, height));
1611     if (status)
1612     {
1613         response = m_ipcModule.createResponse(message);
1614     }
1615     else
1616     {
1617         response = m_ipcModule.createErrorResponse(message);
1618         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1619     }
1620
1621     m_ipcModule.sendToClients(response, &clientHandle, 1);
1622     m_ipcModule.destroyMessage(response);
1623 }
1624
1625 void GenericCommunicator::SetLayerDestinationRegion(t_ilm_message message)
1626 {
1627     t_ilm_message response;
1628     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1629     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1630     uint id = 0;
1631     uint x = 0;
1632     uint y = 0;
1633     uint width = 0;
1634     uint height = 0;
1635
1636     m_ipcModule.getUint(message, &id);
1637     m_ipcModule.getUint(message, &x);
1638     m_ipcModule.getUint(message, &y);
1639     m_ipcModule.getUint(message, &width);
1640     m_ipcModule.getUint(message, &height);
1641
1642     t_ilm_bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1643     if (status)
1644     {
1645         response = m_ipcModule.createResponse(message);
1646     }
1647     else
1648     {
1649         response = m_ipcModule.createErrorResponse(message);
1650         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1651     }
1652
1653     m_ipcModule.sendToClients(response, &clientHandle, 1);
1654     m_ipcModule.destroyMessage(response);
1655 }
1656
1657 void GenericCommunicator::SetLayerPosition(t_ilm_message message)
1658 {
1659     t_ilm_message response;
1660     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1661     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1662     uint id = 0;
1663     uint x = 0;
1664     uint y = 0;
1665
1666     m_ipcModule.getUint(message, &id);
1667     m_ipcModule.getUint(message, &x);
1668     m_ipcModule.getUint(message, &y);
1669
1670     t_ilm_bool status = m_executor->execute(new LayerSetPositionCommand(clientPid, id, x, y));
1671     if (status)
1672     {
1673         response = m_ipcModule.createResponse(message);
1674     }
1675     else
1676     {
1677         response = m_ipcModule.createErrorResponse(message);
1678         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1679     }
1680
1681     m_ipcModule.sendToClients(response, &clientHandle, 1);
1682     m_ipcModule.destroyMessage(response);
1683 }
1684
1685 void GenericCommunicator::GetLayerPosition(t_ilm_message message)
1686 {
1687     t_ilm_message response;
1688     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1689     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1690     uint id = 0;
1691     uint x = 0;
1692     uint y = 0;
1693
1694     m_ipcModule.getUint(message, &id);
1695
1696     t_ilm_bool status = m_executor->execute(new LayerGetPositionCommand(clientPid, id, &x, &y));
1697     if (status)
1698     {
1699         response = m_ipcModule.createResponse(message);
1700         m_ipcModule.appendUint(response, x);
1701         m_ipcModule.appendUint(response, y);
1702     }
1703     else
1704     {
1705         response = m_ipcModule.createErrorResponse(message);
1706         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1707     }
1708
1709     m_ipcModule.sendToClients(response, &clientHandle, 1);
1710     m_ipcModule.destroyMessage(response);
1711 }
1712
1713 void GenericCommunicator::SetLayerDimension(t_ilm_message message)
1714 {
1715     t_ilm_message response;
1716     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1717     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1718     uint id = 0;
1719     uint width = 0;
1720     uint height = 0;
1721
1722     m_ipcModule.getUint(message, &id);
1723     m_ipcModule.getUint(message, &width);
1724     m_ipcModule.getUint(message, &height);
1725
1726     t_ilm_bool status = m_executor->execute(new LayerSetDimensionCommand(clientPid, id, width, height));
1727     if (status)
1728     {
1729         response = m_ipcModule.createResponse(message);
1730     }
1731     else
1732     {
1733         response = m_ipcModule.createErrorResponse(message);
1734         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1735     }
1736
1737     m_ipcModule.sendToClients(response, &clientHandle, 1);
1738     m_ipcModule.destroyMessage(response);
1739 }
1740
1741 void GenericCommunicator::GetLayerDimension(t_ilm_message message)
1742 {
1743     t_ilm_message response;
1744     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1745     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1746     uint id = 0;
1747     uint width = 0;
1748     uint height = 0;
1749
1750     m_ipcModule.getUint(message, &id);
1751
1752     t_ilm_bool status = m_executor->execute(new LayerGetDimensionCommand(clientPid, id, &width, &height));
1753     if (status)
1754     {
1755         response = m_ipcModule.createResponse(message);
1756         m_ipcModule.appendUint(response, width);
1757         m_ipcModule.appendUint(response, height);
1758     }
1759     else
1760     {
1761         response = m_ipcModule.createErrorResponse(message);
1762         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1763     }
1764
1765     m_ipcModule.sendToClients(response, &clientHandle, 1);
1766     m_ipcModule.destroyMessage(response);
1767 }
1768
1769 void GenericCommunicator::GetSurfaceDimension(t_ilm_message message)
1770 {
1771     t_ilm_message response;
1772     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1773     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1774     uint id = 0;
1775     uint width = 0;
1776     uint height = 0;
1777
1778     m_ipcModule.getUint(message, &id);
1779
1780     t_ilm_bool status = m_executor->execute(new SurfaceGetDimensionCommand(clientPid, id, &width, &height));
1781     if (status)
1782     {
1783         response = m_ipcModule.createResponse(message);
1784         m_ipcModule.appendUint(response, width);
1785         m_ipcModule.appendUint(response, height);
1786     }
1787     else
1788     {
1789         response = m_ipcModule.createErrorResponse(message);
1790         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1791     }
1792
1793     m_ipcModule.sendToClients(response, &clientHandle, 1);
1794     m_ipcModule.destroyMessage(response);
1795 }
1796
1797 void GenericCommunicator::SetSurfaceOpacity(t_ilm_message message)
1798 {
1799     t_ilm_message response;
1800     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1801     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1802     uint id = 0;
1803     double param = 0.0;
1804
1805     m_ipcModule.getUint(message, &id);
1806     m_ipcModule.getDouble(message, &param);
1807
1808     t_ilm_bool status = m_executor->execute(new SurfaceSetOpacityCommand(clientPid, id, param));
1809     if (status)
1810     {
1811         response = m_ipcModule.createResponse(message);
1812     }
1813     else
1814     {
1815         response = m_ipcModule.createErrorResponse(message);
1816         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1817     }
1818
1819     m_ipcModule.sendToClients(response, &clientHandle, 1);
1820     m_ipcModule.destroyMessage(response);
1821 }
1822
1823 void GenericCommunicator::SetLayerOpacity(t_ilm_message message)
1824 {
1825     t_ilm_message response;
1826     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1827     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1828     uint id = 0;
1829     double param = 0.0;
1830
1831     m_ipcModule.getUint(message, &id);
1832     m_ipcModule.getDouble(message, &param);
1833
1834     t_ilm_bool status = m_executor->execute(new LayerSetOpacityCommand(clientPid, id, param));
1835     if (status)
1836     {
1837         response = m_ipcModule.createResponse(message);
1838     }
1839     else
1840     {
1841         response = m_ipcModule.createErrorResponse(message);
1842         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1843     }
1844
1845     m_ipcModule.sendToClients(response, &clientHandle, 1);
1846     m_ipcModule.destroyMessage(response);
1847 }
1848
1849 void GenericCommunicator::SetSurfacegroupOpacity(t_ilm_message message)
1850 {
1851     t_ilm_message response;
1852     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1853     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1854     uint id = 0;
1855     double param = 0.0;
1856
1857     m_ipcModule.getUint(message, &id);
1858     m_ipcModule.getDouble(message, &param);
1859
1860     t_ilm_bool status = m_executor->execute(new SurfacegroupSetOpacityCommand(clientPid, id, param));
1861     if (status)
1862     {
1863         response = m_ipcModule.createResponse(message);
1864     }
1865     else
1866     {
1867         response = m_ipcModule.createErrorResponse(message);
1868         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1869     }
1870
1871     m_ipcModule.sendToClients(response, &clientHandle, 1);
1872     m_ipcModule.destroyMessage(response);
1873 }
1874
1875 void GenericCommunicator::SetLayergroupOpacity(t_ilm_message message)
1876 {
1877     t_ilm_message response;
1878     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1879     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1880     uint id = 0;
1881     double param = 0.0;
1882
1883     m_ipcModule.getUint(message, &id);
1884     m_ipcModule.getDouble(message, &param);
1885
1886     t_ilm_bool status = m_executor->execute(new LayergroupSetOpacityCommand(clientPid, id, param));
1887     if (status)
1888     {
1889         response = m_ipcModule.createResponse(message);
1890     }
1891     else
1892     {
1893         response = m_ipcModule.createErrorResponse(message);
1894         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1895     }
1896
1897     m_ipcModule.sendToClients(response, &clientHandle, 1);
1898     m_ipcModule.destroyMessage(response);
1899 }
1900
1901 void GenericCommunicator::GetSurfaceOpacity(t_ilm_message message)
1902 {
1903     t_ilm_message response;
1904     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1905     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1906     uint id = 0;
1907     double param = 0.0;
1908
1909     m_ipcModule.getUint(message, &id);
1910
1911     t_ilm_bool status = m_executor->execute(new SurfaceGetOpacityCommand(clientPid, id, &param));
1912     if (status)
1913     {
1914         response = m_ipcModule.createResponse(message);
1915         m_ipcModule.appendDouble(response, param);
1916     }
1917     else
1918     {
1919         response = m_ipcModule.createErrorResponse(message);
1920         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1921     }
1922
1923     m_ipcModule.sendToClients(response, &clientHandle, 1);
1924     m_ipcModule.destroyMessage(response);
1925 }
1926
1927 void GenericCommunicator::GetLayerOpacity(t_ilm_message message)
1928 {
1929     t_ilm_message response;
1930     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1931     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1932     uint id = 0;
1933     double param = 0.0;
1934
1935     m_ipcModule.getUint(message, &id);
1936
1937     t_ilm_bool status = m_executor->execute(new LayerGetOpacityCommand(clientPid, id, &param));
1938     if (status)
1939     {
1940         response = m_ipcModule.createResponse(message);
1941         m_ipcModule.appendDouble(response, param);
1942     }
1943     else
1944     {
1945         response = m_ipcModule.createErrorResponse(message);
1946         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1947     }
1948
1949     m_ipcModule.sendToClients(response, &clientHandle, 1);
1950     m_ipcModule.destroyMessage(response);
1951 }
1952
1953 void GenericCommunicator::SetSurfaceOrientation(t_ilm_message message)
1954 {
1955     t_ilm_message response;
1956     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1957     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1958     uint id = 0;
1959     uint param = 0;
1960     OrientationType o = Zero;
1961
1962     m_ipcModule.getUint(message, &id);
1963     m_ipcModule.getUint(message, &param);
1964
1965     o = (OrientationType) param;
1966
1967     t_ilm_bool status = m_executor->execute(new SurfaceSetOrientationCommand(clientPid, id, o));
1968     if (status)
1969     {
1970         response = m_ipcModule.createResponse(message);
1971     }
1972     else
1973     {
1974         response = m_ipcModule.createErrorResponse(message);
1975         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1976     }
1977
1978     m_ipcModule.sendToClients(response, &clientHandle, 1);
1979     m_ipcModule.destroyMessage(response);
1980 }
1981
1982 void GenericCommunicator::GetSurfaceOrientation(t_ilm_message message)
1983 {
1984     t_ilm_message response;
1985     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1986     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1987     uint id = 0;
1988     OrientationType o;
1989
1990     m_ipcModule.getUint(message, &id);
1991
1992     t_ilm_bool status = m_executor->execute(new SurfaceGetOrientationCommand(clientPid, id, &o));
1993     if (status)
1994     {
1995         response = m_ipcModule.createResponse(message);
1996         m_ipcModule.appendUint(response, o);
1997     }
1998     else
1999     {
2000         response = m_ipcModule.createErrorResponse(message);
2001         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2002     }
2003
2004     m_ipcModule.sendToClients(response, &clientHandle, 1);
2005     m_ipcModule.destroyMessage(response);
2006 }
2007
2008 void GenericCommunicator::SetLayerOrientation(t_ilm_message message)
2009 {
2010     t_ilm_message response;
2011     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2012     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2013     uint id = 0;
2014     uint param = 0;
2015     OrientationType o = Zero;
2016
2017     m_ipcModule.getUint(message, &id);
2018     m_ipcModule.getUint(message, &param);
2019
2020     o = (OrientationType) param;
2021
2022     t_ilm_bool status = m_executor->execute(new LayerSetOrientationCommand(clientPid, id, o));
2023     if (status)
2024     {
2025         response = m_ipcModule.createResponse(message);
2026     }
2027     else
2028     {
2029         response = m_ipcModule.createErrorResponse(message);
2030         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2031     }
2032
2033     m_ipcModule.sendToClients(response, &clientHandle, 1);
2034     m_ipcModule.destroyMessage(response);
2035 }
2036
2037 void GenericCommunicator::GetLayerOrientation(t_ilm_message message)
2038 {
2039     t_ilm_message response;
2040     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2041     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2042     uint id = 0;
2043     OrientationType o;
2044
2045     m_ipcModule.getUint(message, &id);
2046
2047     t_ilm_bool status = m_executor->execute(new LayerGetOrientationCommand(clientPid, id, &o));
2048     if (status)
2049     {
2050         response = m_ipcModule.createResponse(message);
2051         m_ipcModule.appendUint(response, o);
2052     }
2053     else
2054     {
2055         response = m_ipcModule.createErrorResponse(message);
2056         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2057     }
2058
2059     m_ipcModule.sendToClients(response, &clientHandle, 1);
2060     m_ipcModule.destroyMessage(response);
2061 }
2062
2063 void GenericCommunicator::GetSurfacePixelformat(t_ilm_message message)
2064 {
2065     t_ilm_message response;
2066     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2067     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2068     uint id = 0;
2069     PixelFormat pixelFormat;
2070
2071     m_ipcModule.getUint(message, &id);
2072
2073     t_ilm_bool status = m_executor->execute(new SurfaceGetPixelformatCommand(clientPid, id, &pixelFormat));
2074     if (status)
2075     {
2076         response = m_ipcModule.createResponse(message);
2077         m_ipcModule.appendUint(response, pixelFormat);
2078     }
2079     else
2080     {
2081         response = m_ipcModule.createErrorResponse(message);
2082         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2083     }
2084
2085     m_ipcModule.sendToClients(response, &clientHandle, 1);
2086     m_ipcModule.destroyMessage(response);
2087 }
2088
2089 void GenericCommunicator::SetSurfaceVisibility(t_ilm_message message)
2090 {
2091     t_ilm_message response;
2092     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2093     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2094     uint surfaceid = 0;
2095     t_ilm_bool newVis = ILM_FALSE;
2096
2097     m_ipcModule.getUint(message, &surfaceid);
2098     m_ipcModule.getBool(message, &newVis);
2099
2100     t_ilm_bool status = m_executor->execute(new SurfaceSetVisibilityCommand(clientPid, surfaceid, newVis));
2101     if (status)
2102     {
2103         response = m_ipcModule.createResponse(message);
2104     }
2105     else
2106     {
2107         response = m_ipcModule.createErrorResponse(message);
2108         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2109     }
2110
2111     m_ipcModule.sendToClients(response, &clientHandle, 1);
2112     m_ipcModule.destroyMessage(response);
2113 }
2114
2115 void GenericCommunicator::SetLayerVisibility(t_ilm_message message)
2116 {
2117     t_ilm_message response;
2118     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2119     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2120     uint layerid = 0;
2121     t_ilm_bool myparam = ILM_FALSE;
2122
2123     m_ipcModule.getUint(message, &layerid);
2124     m_ipcModule.getBool(message, &myparam);
2125
2126     t_ilm_bool status = m_executor->execute(new LayerSetVisibilityCommand(clientPid, layerid, myparam));
2127     if (status)
2128     {
2129         response = m_ipcModule.createResponse(message);
2130     }
2131     else
2132     {
2133         response = m_ipcModule.createErrorResponse(message);
2134         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2135     }
2136
2137     m_ipcModule.sendToClients(response, &clientHandle, 1);
2138     m_ipcModule.destroyMessage(response);
2139 }
2140
2141 void GenericCommunicator::GetSurfaceVisibility(t_ilm_message message)
2142 {
2143     t_ilm_message response;
2144     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2145     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2146     uint id = 0;
2147     bool visibility;
2148
2149     m_ipcModule.getUint(message, &id);
2150
2151     t_ilm_bool status = m_executor->execute(new SurfaceGetVisibilityCommand(clientPid, id, &visibility));
2152     if (status)
2153     {
2154         response = m_ipcModule.createResponse(message);
2155         m_ipcModule.appendBool(response, visibility);
2156     }
2157     else
2158     {
2159         response = m_ipcModule.createErrorResponse(message);
2160         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2161     }
2162
2163     m_ipcModule.sendToClients(response, &clientHandle, 1);
2164     m_ipcModule.destroyMessage(response);
2165 }
2166
2167 void GenericCommunicator::GetLayerVisibility(t_ilm_message message)
2168 {
2169     t_ilm_message response;
2170     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2171     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2172     uint id = 0;
2173     bool visibility;
2174
2175     m_ipcModule.getUint(message, &id);
2176
2177     t_ilm_bool status = m_executor->execute(new LayerGetVisibilityCommand(clientPid, id, &visibility));
2178     if (status)
2179     {
2180         response = m_ipcModule.createResponse(message);
2181         m_ipcModule.appendBool(response, visibility);
2182     }
2183     else
2184     {
2185         response = m_ipcModule.createErrorResponse(message);
2186         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2187     }
2188
2189     m_ipcModule.sendToClients(response, &clientHandle, 1);
2190     m_ipcModule.destroyMessage(response);
2191 }
2192
2193 void GenericCommunicator::SetSurfacegroupVisibility(t_ilm_message message)
2194 {
2195     t_ilm_message response;
2196     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2197     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2198     uint groupid = 0;
2199     t_ilm_bool myparam = ILM_FALSE;
2200
2201     m_ipcModule.getUint(message, &groupid);
2202     m_ipcModule.getBool(message, &myparam);
2203
2204     t_ilm_bool status = m_executor->execute(new SurfacegroupSetVisibilityCommand(clientPid, groupid, myparam));
2205     if (status)
2206     {
2207         response = m_ipcModule.createResponse(message);
2208     }
2209     else
2210     {
2211         response = m_ipcModule.createErrorResponse(message);
2212         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2213     }
2214
2215     m_ipcModule.sendToClients(response, &clientHandle, 1);
2216     m_ipcModule.destroyMessage(response);
2217 }
2218
2219 void GenericCommunicator::SetLayergroupVisibility(t_ilm_message message)
2220 {
2221     t_ilm_message response;
2222     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2223     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2224     uint groupid = 0;
2225     t_ilm_bool myparam = ILM_FALSE;
2226
2227     m_ipcModule.getUint(message, &groupid);
2228     m_ipcModule.getBool(message, &myparam);
2229
2230     t_ilm_bool status = m_executor->execute(new LayergroupSetVisibilityCommand(clientPid, groupid, myparam));
2231     if (status)
2232     {
2233         response = m_ipcModule.createResponse(message);
2234     }
2235     else
2236     {
2237         response = m_ipcModule.createErrorResponse(message);
2238         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2239     }
2240
2241     m_ipcModule.sendToClients(response, &clientHandle, 1);
2242     m_ipcModule.destroyMessage(response);
2243 }
2244
2245
2246 void GenericCommunicator::SetRenderOrderOfLayers(t_ilm_message message)
2247 {
2248     t_ilm_message response;
2249     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2250     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2251     uint* array = NULL;
2252     int length = 0;
2253
2254     m_ipcModule.getUintArray(message, &array, &length);
2255
2256     t_ilm_bool status = m_executor->execute(new ScreenSetRenderOrderCommand(clientPid, array, length));
2257     if (status)
2258     {
2259         response = m_ipcModule.createResponse(message);
2260     }
2261     else
2262     {
2263         response = m_ipcModule.createErrorResponse(message);
2264         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2265     }
2266
2267     m_ipcModule.sendToClients(response, &clientHandle, 1);
2268     m_ipcModule.destroyMessage(response);
2269 }
2270
2271 void GenericCommunicator::SetSurfaceRenderOrderWithinLayer(t_ilm_message message)
2272 {
2273     t_ilm_message response;
2274     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2275     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2276     uint* array = NULL;
2277     int length = 0;
2278     uint layerid = 0;
2279
2280     m_ipcModule.getUint(message, &layerid);
2281     m_ipcModule.getUintArray(message, &array, &length);
2282
2283     t_ilm_bool status = m_executor->execute(new LayerSetRenderOrderCommand(clientPid, layerid, array, length));
2284     if (status)
2285     {
2286         response = m_ipcModule.createResponse(message);
2287     }
2288     else
2289     {
2290         response = m_ipcModule.createErrorResponse(message);
2291         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2292     }
2293
2294     m_ipcModule.sendToClients(response, &clientHandle, 1);
2295     m_ipcModule.destroyMessage(response);
2296 }
2297
2298 void GenericCommunicator::GetLayerType(t_ilm_message message)
2299 {
2300     t_ilm_message response;
2301     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2302     uint id = 0;
2303     m_ipcModule.getUint(message, &id);
2304
2305     Layer* layer = m_executor->getScene()->getLayer(id);
2306     if (layer)
2307     {
2308         response = m_ipcModule.createResponse(message);
2309         m_ipcModule.appendUint(response, layer->getLayerType());
2310     }
2311     else
2312     {
2313         response = m_ipcModule.createErrorResponse(message);
2314         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2315     }
2316
2317     m_ipcModule.sendToClients(response, &clientHandle, 1);
2318     m_ipcModule.destroyMessage(response);
2319 }
2320
2321 void GenericCommunicator::GetLayertypeCapabilities(t_ilm_message message)
2322 {
2323     t_ilm_message response;
2324     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2325     uint id = 0;
2326     LayerType type = Unknown;
2327
2328     m_ipcModule.getUint(message, &id);
2329
2330     type = (LayerType) id;
2331
2332     uint capabilities = m_executor->getLayerTypeCapabilities(type);
2333     response = m_ipcModule.createResponse(message);
2334     m_ipcModule.appendUint(response, capabilities);
2335     m_ipcModule.sendToClients(response, &clientHandle, 1);
2336     m_ipcModule.destroyMessage(response);
2337 }
2338
2339 void GenericCommunicator::GetLayerCapabilities(t_ilm_message message)
2340 {
2341     t_ilm_message response;
2342     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2343     uint id = 0;
2344     m_ipcModule.getUint(message, &id);
2345
2346     Layer* layer = m_executor->getScene()->getLayer(id);
2347     if (layer)
2348     {
2349         response = m_ipcModule.createResponse(message);
2350         m_ipcModule.appendUint(response, layer->getCapabilities());
2351     }
2352     else
2353     {
2354         response = m_ipcModule.createErrorResponse(message);
2355         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2356     }
2357
2358     m_ipcModule.sendToClients(response, &clientHandle, 1);
2359     m_ipcModule.destroyMessage(response);
2360 }
2361
2362 void GenericCommunicator::FadeIn(t_ilm_message message)
2363 {
2364     t_ilm_message response;
2365     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2366     response = m_ipcModule.createErrorResponse(message);
2367     m_ipcModule.appendString(response, NOT_IMPLEMENTED);
2368     m_ipcModule.sendToClients(response, &clientHandle, 1);
2369     m_ipcModule.destroyMessage(response);
2370 }
2371
2372 void GenericCommunicator::SynchronizedFade(t_ilm_message message)
2373 {
2374     t_ilm_message response;
2375     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2376     response = m_ipcModule.createErrorResponse(message);
2377     m_ipcModule.appendString(response, NOT_IMPLEMENTED);
2378     m_ipcModule.sendToClients(response, &clientHandle, 1);
2379     m_ipcModule.destroyMessage(response);
2380 }
2381
2382 void GenericCommunicator::FadeOut(t_ilm_message message)
2383 {
2384     t_ilm_message response;
2385     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2386     response = m_ipcModule.createErrorResponse(message);
2387     m_ipcModule.appendString(response, NOT_IMPLEMENTED);
2388     m_ipcModule.sendToClients(response, &clientHandle, 1);
2389     m_ipcModule.destroyMessage(response);
2390 }
2391
2392 void GenericCommunicator::Exit(t_ilm_message message)
2393 {
2394     t_ilm_message response;
2395     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2396     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2397     t_ilm_bool status = m_executor->execute(new ExitCommand(clientPid));
2398     if (status)
2399     {
2400         response = m_ipcModule.createResponse(message);
2401     }
2402     else
2403     {
2404         response = m_ipcModule.createErrorResponse(message);
2405         m_ipcModule.appendString(response, INVALID_ARGUMENT);
2406     }
2407
2408     m_ipcModule.sendToClients(response, &clientHandle, 1);
2409     m_ipcModule.destroyMessage(response);
2410 }
2411
2412 void GenericCommunicator::CommitChanges(t_ilm_message message)
2413 {
2414     t_ilm_message response;
2415     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2416     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2417     t_ilm_bool status = m_executor->execute(new CommitCommand(clientPid));
2418     if (status)
2419     {
2420         response = m_ipcModule.createResponse(message);
2421     }
2422     else
2423     {
2424         response = m_ipcModule.createErrorResponse(message);
2425         m_ipcModule.appendString(response, INVALID_ARGUMENT);
2426     }
2427
2428     m_ipcModule.sendToClients(response, &clientHandle, 1);
2429     m_ipcModule.destroyMessage(response);
2430 }
2431
2432 void GenericCommunicator::CreateShader(t_ilm_message message)
2433 {
2434     t_ilm_message response;
2435     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2436     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2437     char vertname[1024];
2438     char fragname[1024];
2439     uint id = 0;
2440
2441     m_ipcModule.getString(message, vertname);
2442     m_ipcModule.getString(message, fragname);
2443
2444     t_ilm_bool status = m_executor->execute(new ShaderCreateCommand(clientPid, vertname, fragname, &id));
2445     if (status)
2446     {
2447         response = m_ipcModule.createResponse(message);
2448         m_ipcModule.appendUint(response, id);
2449     }
2450     else
2451     {
2452         response = m_ipcModule.createErrorResponse(message);
2453         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2454     }
2455
2456     m_ipcModule.sendToClients(response, &clientHandle, 1);
2457     m_ipcModule.destroyMessage(response);
2458 }
2459
2460 void GenericCommunicator::DestroyShader(t_ilm_message message)
2461 {
2462     t_ilm_message response;
2463     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2464     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2465     uint shaderid = 0;
2466
2467     m_ipcModule.getUint(message, &shaderid);
2468
2469     t_ilm_bool status = m_executor->execute(new ShaderDestroyCommand(clientPid, shaderid));
2470     if (status)
2471     {
2472         response = m_ipcModule.createResponse(message);
2473     }
2474     else
2475     {
2476         response = m_ipcModule.createErrorResponse(message);
2477         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2478     }
2479
2480     m_ipcModule.sendToClients(response, &clientHandle, 1);
2481     m_ipcModule.destroyMessage(response);
2482 }
2483
2484 void GenericCommunicator::SetShader(t_ilm_message message)
2485 {
2486     t_ilm_message response;
2487     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2488     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2489     uint surfaceId = 0;
2490     uint shaderid = 0;
2491
2492     m_ipcModule.getUint(message, &surfaceId);
2493     m_ipcModule.getUint(message, &shaderid);
2494
2495     t_ilm_bool status = m_executor->execute(new SurfaceSetShaderCommand(clientPid, surfaceId, shaderid));
2496     if (status)
2497     {
2498         response = m_ipcModule.createResponse(message);
2499     }
2500     else
2501     {
2502         response = m_ipcModule.createErrorResponse(message);
2503         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2504     }
2505
2506     m_ipcModule.sendToClients(response, &clientHandle, 1);
2507     m_ipcModule.destroyMessage(response);
2508 }
2509
2510 void GenericCommunicator::SetUniforms(t_ilm_message message)
2511 {
2512     t_ilm_message response;
2513     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2514     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2515     uint id = 0;
2516     std::vector<string> uniforms;
2517
2518     m_ipcModule.getUint(message, &id);
2519
2520     // TODO
2521     //m_ipcModule.getStringArray(&uniforms);
2522
2523     t_ilm_bool status = m_executor->execute(new ShaderSetUniformsCommand(clientPid, id, uniforms));
2524     if (status)
2525     {
2526         response = m_ipcModule.createResponse(message);
2527     }
2528     else
2529     {
2530         response = m_ipcModule.createErrorResponse(message);
2531         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2532     }
2533
2534     m_ipcModule.sendToClients(response, &clientHandle, 1);
2535     m_ipcModule.destroyMessage(response);
2536 }
2537
2538 void GenericCommunicator::SetKeyboardFocusOn(t_ilm_message message)
2539 {
2540     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2541     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2542     t_ilm_message response;
2543     uint surfaceId = 0;
2544
2545     m_ipcModule.getUint(message, &surfaceId);
2546
2547     t_ilm_bool status = m_executor->execute(new SurfaceSetKeyboardFocusCommand(clientPid, surfaceId));
2548     if (status)
2549     {
2550         response = m_ipcModule.createResponse(message);
2551     }
2552     else
2553     {
2554         response = m_ipcModule.createErrorResponse(message);
2555         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2556     }
2557
2558     m_ipcModule.sendToClients(response, &clientHandle, 1);
2559     m_ipcModule.destroyMessage(response);
2560 }
2561
2562
2563 void GenericCommunicator::GetKeyboardFocusSurfaceId(t_ilm_message message)
2564 {
2565     t_ilm_message response;
2566     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2567     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2568     uint surfaceId;
2569
2570     t_ilm_bool status = m_executor->execute(new SurfaceGetKeyboardFocusCommand(clientPid, &surfaceId));
2571     if (status)
2572     {
2573         response = m_ipcModule.createResponse(message);
2574         m_ipcModule.appendUint(response, surfaceId);
2575     }
2576     else
2577     {
2578         response = m_ipcModule.createErrorResponse(message);
2579         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2580     }
2581
2582     m_ipcModule.sendToClients(response, &clientHandle, 1);
2583     m_ipcModule.destroyMessage(response);
2584 }
2585
2586
2587 void GenericCommunicator::UpdateInputEventAcceptanceOn(t_ilm_message message)
2588 {
2589     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2590     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2591     t_ilm_message response;
2592     uint surfaceId = 0;
2593     uint udevices = 0;
2594     InputDevice devices;
2595     t_ilm_bool accept;
2596
2597     m_ipcModule.getUint(message, &surfaceId);
2598     m_ipcModule.getUint(message, &udevices);
2599     m_ipcModule.getBool(message, &accept);
2600
2601     devices = (InputDevice) udevices;
2602
2603     t_ilm_bool status = m_executor->execute(new SurfaceUpdateInputEventAcceptance(clientPid, surfaceId, devices, accept));
2604     if (status)
2605     {
2606         response = m_ipcModule.createResponse(message);
2607     }
2608     else
2609     {
2610         response = m_ipcModule.createErrorResponse(message);
2611         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2612     }
2613
2614     m_ipcModule.sendToClients(response, &clientHandle, 1);
2615     m_ipcModule.destroyMessage(response);
2616 }
2617
2618 void GenericCommunicator::SetSurfaceChromaKey(t_ilm_message message)
2619 {
2620     t_ilm_message response;
2621     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2622     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2623     uint* array = NULL;
2624     int length = 0;
2625     uint surfaceid = 0;
2626
2627     m_ipcModule.getUint(message, &surfaceid);
2628     m_ipcModule.getUintArray(message, &array, &length);
2629
2630     t_ilm_bool status = m_executor->execute(new SurfaceSetChromaKeyCommand(clientPid, surfaceid, array, length));
2631     if (status)
2632     {
2633         response = m_ipcModule.createResponse(message);
2634     }
2635     else
2636     {
2637         response = m_ipcModule.createErrorResponse(message);
2638         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2639     }
2640
2641     m_ipcModule.sendToClients(response, &clientHandle, 1);
2642     m_ipcModule.destroyMessage(response);
2643 }
2644
2645 void GenericCommunicator::SetLayerChromaKey(t_ilm_message message)
2646 {
2647     t_ilm_message response;
2648     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2649     t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2650     uint* array = NULL;
2651     int length = 0;
2652     uint layerid = 0;
2653
2654     m_ipcModule.getUint(message, &layerid);
2655     m_ipcModule.getUintArray(message, &array, &length);
2656
2657     t_ilm_bool status = m_executor->execute(new LayerSetChromaKeyCommand(clientPid, layerid, array, length));
2658     if (status)
2659     {
2660         response = m_ipcModule.createResponse(message);
2661     }
2662     else
2663     {
2664         response = m_ipcModule.createErrorResponse(message);
2665         m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2666     }
2667
2668     m_ipcModule.sendToClients(response, &clientHandle, 1);
2669     m_ipcModule.destroyMessage(response);
2670 }
2671
2672 void GenericCommunicator::LayerAddNotification(t_ilm_message message)
2673 {
2674     t_ilm_message response;
2675     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2676     uint layerid = 0;
2677
2678     m_ipcModule.getUint(message, &layerid);
2679
2680     Layer* layer = m_executor->getScene()->getLayer(layerid);
2681     if (layer)
2682     {
2683         layer->addNotification(clientHandle);
2684         response = m_ipcModule.createResponse(message);
2685     }
2686     else
2687     {
2688         response = m_ipcModule.createErrorResponse(message);
2689         m_ipcModule.appendString(response, INVALID_ARGUMENT);
2690     }
2691
2692     m_ipcModule.sendToClients(response, &clientHandle, 1);
2693     m_ipcModule.destroyMessage(response);
2694 }
2695
2696 void GenericCommunicator::SurfaceAddNotification(t_ilm_message message)
2697 {
2698     t_ilm_message response;
2699     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2700     uint surfaceid = 0;
2701
2702     m_ipcModule.getUint(message, &surfaceid);
2703
2704     Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2705     if (surface)
2706     {
2707         surface->addNotification(clientHandle);
2708         response = m_ipcModule.createResponse(message);
2709     }
2710     else
2711     {
2712         response = m_ipcModule.createErrorResponse(message);
2713         m_ipcModule.appendString(response, INVALID_ARGUMENT);
2714     }
2715
2716     m_ipcModule.sendToClients(response, &clientHandle, 1);
2717     m_ipcModule.destroyMessage(response);
2718 }
2719
2720 void GenericCommunicator::LayerRemoveNotification(t_ilm_message message)
2721 {
2722     t_ilm_message response;
2723     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2724     uint layerid = 0;
2725
2726     m_ipcModule.getUint(message, &layerid);
2727
2728     Layer* layer = m_executor->getScene()->getLayer(layerid);
2729     if (layer)
2730     {
2731         layer->removeNotification(clientHandle);
2732         response = m_ipcModule.createResponse(message);
2733     }
2734     else
2735     {
2736         response = m_ipcModule.createErrorResponse(message);
2737         m_ipcModule.appendString(response, INVALID_ARGUMENT);
2738     }
2739
2740     m_ipcModule.sendToClients(response, &clientHandle, 1);
2741     m_ipcModule.destroyMessage(response);
2742 }
2743
2744 void GenericCommunicator::SurfaceRemoveNotification(t_ilm_message message)
2745 {
2746     t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2747     t_ilm_message response;
2748     uint surfaceid = 0;
2749
2750     m_ipcModule.getUint(message, &surfaceid);
2751
2752     Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2753     if (surface)
2754     {
2755         surface->removeNotification(clientHandle);
2756         response = m_ipcModule.createResponse(message);
2757     }
2758     else
2759     {
2760         response = m_ipcModule.createErrorResponse(message);
2761         m_ipcModule.appendString(response, INVALID_ARGUMENT);
2762     }
2763
2764     m_ipcModule.sendToClients(response, &clientHandle, 1);
2765     m_ipcModule.destroyMessage(response);
2766 }
2767
2768 void GenericCommunicator::processNotificationQueue()
2769 {
2770     NotificationQueue& notificationQueue = m_executor->getClientNotificationQueue();
2771     NotificationQueue::iterator iter = notificationQueue.begin();
2772     NotificationQueue::iterator end = notificationQueue.end();
2773
2774     for (; iter != end; ++iter)
2775     {
2776         GraphicalObject* object = iter->first;
2777         t_ilm_notification_mask mask = iter->second;
2778         sendNotification(object, mask);
2779     }
2780     notificationQueue.clear();
2781 }
2782
2783 void GenericCommunicator::sendNotification(GraphicalObject* object, t_ilm_notification_mask mask)
2784 {
2785     switch (object->type)
2786     {
2787     case TypeLayer:
2788     {
2789         Layer* layer = static_cast<Layer*>(object);
2790         if (layer)
2791         {
2792             ApplicationReferenceList& arl = layer->getNotificationClients();
2793
2794             if (arl.size())
2795             {
2796                 t_ilm_message notification;
2797                 Rectangle dest = layer->getDestinationRegion();
2798                 Rectangle src = layer->getSourceRegion();
2799                 OrientationType orientation = layer->getOrientation();
2800
2801                 unsigned char chromaKeyRed = 0;
2802                 unsigned char chromaKeyGreen = 0;
2803                 unsigned char chromaKeyBlue = 0;
2804                 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2805
2806                 std::stringstream notificationName;
2807                 notificationName << "NotificationForLayer" << layer->getID();
2808
2809                 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2810                 m_ipcModule.appendUint(notification, layer->getID());
2811                 m_ipcModule.appendUint(notification, mask);
2812
2813                 m_ipcModule.appendDouble(notification, layer->getOpacity());
2814                 m_ipcModule.appendUint(notification, src.x);
2815                 m_ipcModule.appendUint(notification, src.y);
2816                 m_ipcModule.appendUint(notification, src.width);
2817                 m_ipcModule.appendUint(notification, src.height);
2818                 m_ipcModule.appendUint(notification, layer->OriginalSourceWidth);
2819                 m_ipcModule.appendUint(notification, layer->OriginalSourceHeight);
2820                 m_ipcModule.appendUint(notification, dest.x);
2821                 m_ipcModule.appendUint(notification, dest.y);
2822                 m_ipcModule.appendUint(notification, dest.width);
2823                 m_ipcModule.appendUint(notification, dest.height);
2824                 m_ipcModule.appendUint(notification, orientation);
2825                 m_ipcModule.appendBool(notification, layer->getVisibility());
2826                 m_ipcModule.appendUint(notification, layer->getLayerType());
2827                 m_ipcModule.appendBool(notification, layer->getChromaKeyEnabled());
2828                 m_ipcModule.appendUint(notification, chromaKeyRed);
2829                 m_ipcModule.appendUint(notification, chromaKeyGreen);
2830                 m_ipcModule.appendUint(notification, chromaKeyBlue);
2831                 m_ipcModule.appendInt(notification, layer->getCreatorPid());
2832
2833                 int clientCount = arl.size();
2834                 t_ilm_client_handle clientArray[256];
2835
2836                 ApplicationReferenceList::iterator iter = arl.begin();
2837                 ApplicationReferenceList::iterator end = arl.end();
2838
2839                 for (int clientNumber = 0;
2840                      iter != end, clientNumber < 256;
2841                      ++iter, ++clientNumber)
2842                 {
2843                     t_ilm_client_handle client = *iter;
2844                     clientArray[clientNumber] = client;
2845                 }
2846
2847                 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): layer " << layer->getID() << " was updated.");
2848
2849                 if (!m_ipcModule.sendToClients(notification, clientArray, clientCount))
2850                 {
2851                     LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2852                 }
2853
2854                 m_ipcModule.destroyMessage(notification);
2855             }
2856         }
2857     }
2858     break;
2859     case TypeSurface:
2860     {
2861         Surface* surface = static_cast<Surface*>(object);
2862         if (surface)
2863         {
2864             ApplicationReferenceList& arl = surface->getNotificationClients();
2865
2866             if (arl.size())
2867             {
2868                 t_ilm_message notification;
2869                 std::stringstream notificationName;
2870                 notificationName << "NotificationForSurface" << surface->getID();
2871
2872                 unsigned char chromaKeyRed = 0;
2873                 unsigned char chromaKeyGreen = 0;
2874                 unsigned char chromaKeyBlue = 0;
2875                 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2876
2877                 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2878                 m_ipcModule.appendUint(notification, surface->getID());
2879                 m_ipcModule.appendUint(notification, mask);
2880
2881                 m_ipcModule.appendDouble(notification, surface->getOpacity());
2882                 m_ipcModule.appendUint(notification, surface->getSourceRegion().x);
2883                 m_ipcModule.appendUint(notification, surface->getSourceRegion().y);
2884                 m_ipcModule.appendUint(notification, surface->getSourceRegion().width);
2885                 m_ipcModule.appendUint(notification, surface->getSourceRegion().height);
2886                 m_ipcModule.appendUint(notification, surface->OriginalSourceWidth);
2887                 m_ipcModule.appendUint(notification, surface->OriginalSourceHeight);
2888                 m_ipcModule.appendUint(notification, surface->getDestinationRegion().x);
2889                 m_ipcModule.appendUint(notification, surface->getDestinationRegion().y);
2890                 m_ipcModule.appendUint(notification, surface->getDestinationRegion().width);
2891                 m_ipcModule.appendUint(notification, surface->getDestinationRegion().height);
2892                 m_ipcModule.appendUint(notification, surface->getOrientation());
2893                 m_ipcModule.appendBool(notification, surface->getVisibility());
2894                 m_ipcModule.appendUint(notification, surface->frameCounter);
2895                 m_ipcModule.appendUint(notification, surface->drawCounter);
2896                 m_ipcModule.appendUint(notification, surface->updateCounter);
2897                 m_ipcModule.appendUint(notification, surface->getPixelFormat());
2898                 m_ipcModule.appendUint(notification, surface->getNativeContent());
2899                 m_ipcModule.appendUint(notification, surface->getInputEventAcceptanceOnDevices());
2900                 m_ipcModule.appendBool(notification, surface->getChromaKeyEnabled());
2901                 m_ipcModule.appendUint(notification, chromaKeyRed);
2902                 m_ipcModule.appendUint(notification, chromaKeyGreen);
2903                 m_ipcModule.appendUint(notification, chromaKeyBlue);
2904                 m_ipcModule.appendInt(notification, surface->getCreatorPid());
2905
2906                 int clientCount = arl.size();
2907                 t_ilm_client_handle clients[256];
2908
2909                 ApplicationReferenceList::iterator iter = arl.begin();
2910                 ApplicationReferenceList::iterator end = arl.end();
2911
2912                 for (int clientNumber = 0;
2913                      iter != end, clientNumber < 256;
2914                      ++iter, ++clientNumber)
2915                 {
2916                     clients[clientNumber] = *iter;
2917                 }
2918
2919                 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): surface " << surface->getID() << " was updated.");
2920
2921                 if (!m_ipcModule.sendToClients(notification, clients, clientCount))
2922                 {
2923                     LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2924                 }
2925
2926                 m_ipcModule.destroyMessage(notification);
2927             }
2928         }
2929     }
2930     break;
2931     default:
2932         LOG_INFO("GenericCommunicator", "Unknown notification found in queue.");
2933         break;
2934     }
2935 }
2936
2937 extern "C" ICommunicator* createGenericCommunicator(ICommandExecutor* executor)
2938 {
2939     return new GenericCommunicator(executor);
2940 }
2941
2942 extern "C" void destroyGenericCommunicator(GenericCommunicator* p)
2943 {
2944     delete p;
2945 }
2946