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