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