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