1 /***************************************************************************
2 * Copyright 2012 BMW Car IT GmbH
3 * Copyright (C) 2012 DENSO CORPORATION and Robert Bosch Car Multimedia Gmbh
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 ****************************************************************************/
20 #include "GenericCommunicator.h"
21 #include "ilm_types.h"
24 #include "Configuration.h"
26 #include "ICommandExecutor.h"
27 #include "CommitCommand.h"
28 #include "LayerCreateCommand.h"
29 #include "SurfaceCreateCommand.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 "SurfaceGetOrientationCommand.h"
42 #include "LayerGetOrientationCommand.h"
43 #include "LayerSetDestinationRectangleCommand.h"
44 #include "SurfaceSetDestinationRectangleCommand.h"
45 #include "LayerSetOpacityCommand.h"
46 #include "SurfaceSetOpacityCommand.h"
47 #include "LayerSetSourceRectangleCommand.h"
48 #include "SurfaceSetSourceRectangleCommand.h"
49 #include "LayerSetOrientationCommand.h"
50 #include "SurfaceSetOrientationCommand.h"
51 #include "LayerSetVisibilityCommand.h"
52 #include "SurfaceSetVisibilityCommand.h"
53 #include "DebugCommand.h"
54 #include "ExitCommand.h"
55 #include "ScreenSetRenderOrderCommand.h"
56 #include "LayerSetRenderOrderCommand.h"
57 #include "LayerSetDimensionCommand.h"
58 #include "SurfaceSetDimensionCommand.h"
59 #include "LayerSetPositionCommand.h"
60 #include "SurfaceSetPositionCommand.h"
61 #include "LayerGetPositionCommand.h"
62 #include "SurfaceGetPositionCommand.h"
63 #include "ShaderCreateCommand.h"
64 #include "ShaderDestroyCommand.h"
65 #include "SurfaceSetShaderCommand.h"
66 #include "ShaderSetUniformsCommand.h"
67 #include "ScreenDumpCommand.h"
68 #include "LayerDumpCommand.h"
69 #include "SurfaceDumpCommand.h"
70 #include "SurfaceSetNativeContentCommand.h"
71 #include "SurfaceRemoveNativeContentCommand.h"
72 #include "SurfaceSetKeyboardFocusCommand.h"
73 #include "SurfaceGetKeyboardFocusCommand.h"
74 #include "SurfaceUpdateInputEventAcceptance.h"
75 #include "SurfaceSetChromaKeyCommand.h"
76 #include "LayerSetChromaKeyCommand.h"
77 #include "SetOptimizationModeCommand.h"
78 #include "GetOptimizationModeCommand.h"
89 #define DEFAULT_SCREEN 0
91 const char* RESOURCE_ALREADY_INUSE = "Ressource already in use";
92 const char* INVALID_ARGUMENT = "Invalid argument";
93 const char* RESOURCE_NOT_FOUND = "Ressource not found";
94 const char* NOT_IMPLEMENTED = "Feature not implemented";
97 GenericCommunicator::GenericCommunicator(ICommandExecutor& executor, Configuration& config)
98 : ICommunicator(&executor)
99 , PluginBase(executor, config, Communicator_Api_v1)
100 , m_running(ILM_FALSE)
102 MethodTable manager_methods[] =
104 { "ServiceConnect", &GenericCommunicator::ServiceConnect },
105 { "ServiceDisconnect", &GenericCommunicator::ServiceDisconnect },
106 { "Debug", &GenericCommunicator::Debug },
107 { "ScreenShot", &GenericCommunicator::ScreenShot },
108 { "ScreenShotOfLayer", &GenericCommunicator::ScreenShotOfLayer },
109 { "ScreenShotOfSurface", &GenericCommunicator::ScreenShotOfSurface },
110 { "GetScreenResolution", &GenericCommunicator::GetScreenResolution },
111 { "GetNumberOfHardwareLayers", &GenericCommunicator::GetNumberOfHardwareLayers },
112 { "GetScreenIDs", &GenericCommunicator::GetScreenIDs },
113 { "ListAllLayerIDS", &GenericCommunicator::ListAllLayerIDS },
114 { "ListAllLayerIDsOnScreen", &GenericCommunicator::ListAllLayerIDsOnScreen },
115 { "ListAllSurfaceIDS", &GenericCommunicator::ListAllSurfaceIDS },
116 { "ListSurfaceofLayer", &GenericCommunicator::ListSurfaceofLayer },
117 { "GetPropertiesOfSurface", &GenericCommunicator::GetPropertiesOfSurface },
118 { "GetPropertiesOfLayer", &GenericCommunicator::GetPropertiesOfLayer },
119 { "CreateSurface", &GenericCommunicator::CreateSurface },
120 { "CreateSurfaceFromId", &GenericCommunicator::CreateSurfaceFromId },
121 { "InitializeSurface", &GenericCommunicator::InitializeSurface },
122 { "InitializeSurfaceFromId", &GenericCommunicator::InitializeSurfaceFromId },
123 { "SetSurfaceNativeContent", &GenericCommunicator::SetSurfaceNativeContent },
124 { "RemoveSurfaceNativeContent", &GenericCommunicator::RemoveSurfaceNativeContent },
125 { "RemoveSurface", &GenericCommunicator::RemoveSurface },
126 { "CreateLayer", &GenericCommunicator::CreateLayer },
127 { "CreateLayerFromId", &GenericCommunicator::CreateLayerFromId },
128 { "CreateLayerWithDimension", &GenericCommunicator::CreateLayerWithDimension },
129 { "CreateLayerFromIdWithDimension", &GenericCommunicator::CreateLayerFromIdWithDimension },
130 { "RemoveLayer", &GenericCommunicator::RemoveLayer },
131 { "AddSurfaceToLayer", &GenericCommunicator::AddSurfaceToLayer },
132 { "RemoveSurfaceFromLayer", &GenericCommunicator::RemoveSurfaceFromLayer },
133 { "SetSurfaceSourceRegion", &GenericCommunicator::SetSurfaceSourceRegion },
134 { "SetLayerSourceRegion", &GenericCommunicator::SetLayerSourceRegion },
135 { "SetSurfaceDestinationRegion", &GenericCommunicator::SetSurfaceDestinationRegion },
136 { "SetSurfacePosition", &GenericCommunicator::SetSurfacePosition },
137 { "GetSurfacePosition", &GenericCommunicator::GetSurfacePosition },
138 { "SetSurfaceDimension", &GenericCommunicator::SetSurfaceDimension },
139 { "SetLayerDestinationRegion", &GenericCommunicator::SetLayerDestinationRegion },
140 { "SetLayerPosition", &GenericCommunicator::SetLayerPosition },
141 { "GetLayerPosition", &GenericCommunicator::GetLayerPosition },
142 { "SetLayerDimension", &GenericCommunicator::SetLayerDimension },
143 { "GetLayerDimension", &GenericCommunicator::GetLayerDimension },
144 { "GetSurfaceDimension", &GenericCommunicator::GetSurfaceDimension },
145 { "SetSurfaceOpacity", &GenericCommunicator::SetSurfaceOpacity },
146 { "SetLayerOpacity", &GenericCommunicator::SetLayerOpacity },
147 { "GetSurfaceOpacity", &GenericCommunicator::GetSurfaceOpacity },
148 { "GetLayerOpacity", &GenericCommunicator::GetLayerOpacity },
149 { "SetSurfaceOrientation", &GenericCommunicator::SetSurfaceOrientation },
150 { "GetSurfaceOrientation", &GenericCommunicator::GetSurfaceOrientation },
151 { "SetLayerOrientation", &GenericCommunicator::SetLayerOrientation },
152 { "GetLayerOrientation", &GenericCommunicator::GetLayerOrientation },
153 { "GetSurfacePixelformat", &GenericCommunicator::GetSurfacePixelformat },
154 { "SetSurfaceVisibility", &GenericCommunicator::SetSurfaceVisibility },
155 { "SetLayerVisibility", &GenericCommunicator::SetLayerVisibility },
156 { "GetSurfaceVisibility", &GenericCommunicator::GetSurfaceVisibility },
157 { "GetLayerVisibility", &GenericCommunicator::GetLayerVisibility },
158 { "SetRenderOrderOfLayers", &GenericCommunicator::SetRenderOrderOfLayers },
159 { "SetSurfaceRenderOrderWithinLayer", &GenericCommunicator::SetSurfaceRenderOrderWithinLayer },
160 { "GetLayerType", &GenericCommunicator::GetLayerType },
161 { "GetLayertypeCapabilities", &GenericCommunicator::GetLayertypeCapabilities },
162 { "GetLayerCapabilities", &GenericCommunicator::GetLayerCapabilities },
163 { "Exit", &GenericCommunicator::Exit },
164 { "CommitChanges", &GenericCommunicator::CommitChanges },
165 { "CreateShader", &GenericCommunicator::CreateShader },
166 { "DestroyShader", &GenericCommunicator::DestroyShader },
167 { "SetShader", &GenericCommunicator::SetShader },
168 { "SetUniforms", &GenericCommunicator::SetUniforms },
169 { "SetKeyboardFocusOn", &GenericCommunicator::SetKeyboardFocusOn },
170 { "GetKeyboardFocusSurfaceId", &GenericCommunicator::GetKeyboardFocusSurfaceId },
171 { "UpdateInputEventAcceptanceOn", &GenericCommunicator::UpdateInputEventAcceptanceOn },
172 { "SetSurfaceChromaKey", &GenericCommunicator::SetSurfaceChromaKey },
173 { "SetLayerChromaKey", &GenericCommunicator::SetLayerChromaKey },
174 { "LayerAddNotification", &GenericCommunicator::LayerAddNotification },
175 { "SurfaceAddNotification", &GenericCommunicator::SurfaceAddNotification },
176 { "LayerRemoveNotification", &GenericCommunicator::LayerRemoveNotification },
177 { "SurfaceRemoveNotification", &GenericCommunicator::SurfaceRemoveNotification },
178 { "SetOptimizationMode", &GenericCommunicator::SetOptimizationMode },
179 { "GetOptimizationMode", &GenericCommunicator::GetOptimizationMode },
180 { "GetPropertiesOfScreen", &GenericCommunicator::GetPropertiesOfScreen }
183 int entryCount = sizeof(manager_methods) / sizeof(MethodTable);
185 for (int index = 0; index < entryCount; ++index)
187 MethodTable* method = &manager_methods[index];
188 if (method->function)
190 m_callBackTable[method->name] = *method;
191 LOG_DEBUG("GenericCommunicator", "registered callback for " << method->name);
195 memset(&m_ipcModule, 0, sizeof(m_ipcModule));
197 mThreadId = pthread_self();
200 bool GenericCommunicator::start()
202 LOG_DEBUG("GenericCommunicator", "Starting up IpcModules.");
204 if (!loadIpcModule(&m_ipcModule))
206 LOG_ERROR("GenericCommunicator", "Loading IpcModule failed.");
209 LOG_DEBUG("GenericCommunicator", "Loading IpcModule success.");
211 if (!m_ipcModule.initServiceMode())
213 LOG_ERROR("GenericCommunicator", "Initializing IpcModule failed.");
216 LOG_DEBUG("GenericCommunicator", "Initializing IpcModule success.");
218 m_running = ILM_TRUE;
219 pluginSetHealth(HealthRunning);
228 void GenericCommunicator::stop()
230 LOG_INFO("GenericCommunicator","stopping");
236 m_ipcModule.destroy();
238 pluginSetHealth(HealthStopped);
241 void GenericCommunicator::process(int timeout_ms)
243 t_ilm_message message = m_ipcModule.receive(timeout_ms);
249 t_ilm_message_type messageType = m_ipcModule.getMessageType(message);
250 t_ilm_const_string name = m_ipcModule.getMessageName(message);
251 t_ilm_client_handle senderHandle = m_ipcModule.getSenderHandle(message);
255 case IpcMessageTypeCommand:
256 if (m_callBackTable.end() != m_callBackTable.find(name))
258 LOG_DEBUG("GenericCommunicator", "received: " << name << " from "
259 << m_executor->getSenderName(senderHandle)
260 << "(" << m_executor->getSenderPid(senderHandle) << ")");
261 CallBackMethod method = m_callBackTable[name].function;
262 (this->*method)(message);
266 LOG_WARNING("GenericCommunicator", "Received unknown command " << name
267 << " from " << m_executor->getSenderName(senderHandle)
268 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
270 processNotificationQueue();
273 case IpcMessageTypeConnect:
274 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
275 << "(pid " << m_executor->getSenderPid(senderHandle) << ") connected");
278 case IpcMessageTypeDisconnect:
279 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
280 << "(pid " << m_executor->getSenderPid(senderHandle) << ") disconnected");
282 const LayerMap& layers = m_executor->getScene()->getAllLayers();
283 LayerMapConstIterator layerIter = layers.begin();
284 LayerMapConstIterator layerIterEnd = layers.end();
285 for (; layerIter != layerIterEnd; ++layerIter)
287 Layer* layer = layerIter->second;
288 layer->removeNotification(senderHandle);
291 const SurfaceMap& surfaces = m_executor->getScene()->getAllSurfaces();
292 SurfaceMapConstIterator surfaceIter = surfaces.begin();
293 SurfaceMapConstIterator surfaceIterEnd = surfaces.end();
294 for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
296 Surface* surface = surfaceIter->second;
297 surface->removeNotification(senderHandle);
302 case IpcMessageTypeError:
303 LOG_DEBUG("GenericCommunicator", "Received error message " << name << " from "
304 << m_executor->getSenderName(senderHandle)
305 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
308 case IpcMessageTypeShutdown:
309 case IpcMessageTypeNone:
313 LOG_DEBUG("GenericCommunicator", "Received unknown data from "
314 << m_executor->getSenderName(senderHandle)
315 << "(pid " << m_executor->getSenderPid(senderHandle) << "), Message type: " << messageType);
318 m_ipcModule.destroyMessage(message);
321 void GenericCommunicator::setdebug(bool onoff)
323 (void)onoff; // TODO: remove, only prevents warning
326 t_ilm_bool GenericCommunicator::threadMainLoop()
332 t_ilm_const_string GenericCommunicator::pluginGetName() const
334 return "GenericCommunicator";
337 void GenericCommunicator::ServiceConnect(t_ilm_message message)
339 t_ilm_message response;
340 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
342 unsigned int processId = 0;
343 char processName[1024];
344 m_ipcModule.getUint(message, &processId);
345 m_ipcModule.getString(message, processName);
347 m_executor->addApplicationReference(clientHandle, new IApplicationReference(processName, processId));
349 LOG_DEBUG("GenericCommunicator", "ServiceConnect called from "
350 << m_executor->getSenderName(clientHandle)
351 << "(" << m_executor->getSenderPid(clientHandle) << ")");
353 response = m_ipcModule.createResponse(message);
354 m_ipcModule.sendToClients(response, &clientHandle, 1);
355 m_ipcModule.destroyMessage(response);
358 void GenericCommunicator::ServiceDisconnect(t_ilm_message message)
360 t_ilm_message response;
361 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
363 LOG_DEBUG("GenericCommunicator", "ServiceDisconnect called from "
364 << m_executor->getSenderName(clientHandle)
365 << "(" << m_executor->getSenderPid(clientHandle) << ")");
367 m_executor->removeApplicationReference(clientHandle);
369 response = m_ipcModule.createResponse(message);
370 m_ipcModule.sendToClients(response, &clientHandle, 1);
371 m_ipcModule.destroyMessage(response);
374 void GenericCommunicator::Debug(t_ilm_message message)
376 t_ilm_message response;
377 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
378 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
379 t_ilm_bool param = ILM_FALSE;
380 m_ipcModule.getBool(message, ¶m);
382 t_ilm_bool status = m_executor->execute(new DebugCommand(clientPid, param));
385 response = m_ipcModule.createResponse(message);
389 response = m_ipcModule.createErrorResponse(message);
390 m_ipcModule.appendString(response, INVALID_ARGUMENT);
393 m_ipcModule.sendToClients(response, &clientHandle, 1);
394 m_ipcModule.destroyMessage(response);
397 void GenericCommunicator::GetScreenResolution(t_ilm_message message)
399 t_ilm_message response;
400 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
402 m_ipcModule.getUint(message, &screenid);
403 uint* resolution = m_executor->getScreenResolution(screenid);
405 response = m_ipcModule.createResponse(message);
406 m_ipcModule.appendUint(response, resolution[0]);
407 m_ipcModule.appendUint(response, resolution[1]);
408 m_ipcModule.sendToClients(response, &clientHandle, 1);
409 m_ipcModule.destroyMessage(response);
412 void GenericCommunicator::GetNumberOfHardwareLayers(t_ilm_message message)
414 t_ilm_message response;
415 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
417 m_ipcModule.getUint(message, &screenid);
418 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid);
419 response = m_ipcModule.createResponse(message);
420 m_ipcModule.appendUint(response, numberOfHardwareLayers);
421 m_ipcModule.sendToClients(response, &clientHandle, 1);
422 m_ipcModule.destroyMessage(response);
425 void GenericCommunicator::GetScreenIDs(t_ilm_message message)
427 t_ilm_message response;
428 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
430 uint* IDs = m_executor->getScreenIDs(&length);
431 response = m_ipcModule.createResponse(message);
432 m_ipcModule.appendUintArray(response, IDs, length);
433 m_ipcModule.sendToClients(response, &clientHandle, 1);
434 m_ipcModule.destroyMessage(response);
437 void GenericCommunicator::ScreenShot(t_ilm_message message)
439 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
440 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
441 t_ilm_message response;
445 m_ipcModule.getUint(message, &screenid);
446 m_ipcModule.getString(message, filename);
448 t_ilm_bool status = m_executor->execute(new ScreenDumpCommand(clientPid, filename, screenid));
451 response = m_ipcModule.createResponse(message);
455 response = m_ipcModule.createErrorResponse(message);
456 m_ipcModule.appendString(response, INVALID_ARGUMENT);
459 m_ipcModule.sendToClients(response, &clientHandle, 1);
460 m_ipcModule.destroyMessage(response);
463 void GenericCommunicator::ScreenShotOfLayer(t_ilm_message message)
465 t_ilm_message response;
466 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
467 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
469 m_ipcModule.getString(message, filename);
471 m_ipcModule.getUint(message, &layerid);
473 t_ilm_bool status = m_executor->execute(new LayerDumpCommand(clientPid, filename, layerid));
476 response = m_ipcModule.createResponse(message);
480 response = m_ipcModule.createErrorResponse(message);
481 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
484 m_ipcModule.sendToClients(response, &clientHandle, 1);
485 m_ipcModule.destroyMessage(response);
488 void GenericCommunicator::ScreenShotOfSurface(t_ilm_message message)
490 t_ilm_message response;
491 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
492 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
494 m_ipcModule.getString(message, filename);
496 m_ipcModule.getUint(message, &id);
497 t_ilm_bool status = m_executor->execute(new SurfaceDumpCommand(clientPid, filename, id));
500 response = m_ipcModule.createResponse(message);
504 response = m_ipcModule.createErrorResponse(message);
505 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
508 m_ipcModule.sendToClients(response, &clientHandle, 1);
509 m_ipcModule.destroyMessage(response);
512 void GenericCommunicator::ListAllLayerIDS(t_ilm_message message)
514 t_ilm_message response;
515 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
518 m_executor->getScene()->lockScene();
519 m_executor->getScene()->getLayerIDs(&length, &array);
520 m_executor->getScene()->unlockScene();
521 response = m_ipcModule.createResponse(message);
522 m_ipcModule.appendUintArray(response, array, length);
523 m_ipcModule.sendToClients(response, &clientHandle, 1);
524 m_ipcModule.destroyMessage(response);
527 void GenericCommunicator::ListAllLayerIDsOnScreen(t_ilm_message message)
529 t_ilm_message response;
530 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
532 m_ipcModule.getUint(message, &screenID);
536 m_executor->getScene()->lockScene();
537 t_ilm_bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
538 m_executor->getScene()->unlockScene();
541 response = m_ipcModule.createResponse(message);
542 m_ipcModule.appendUintArray(response, array, length);
546 response = m_ipcModule.createErrorResponse(message);
547 m_ipcModule.appendString(response, INVALID_ARGUMENT);
550 m_ipcModule.sendToClients(response, &clientHandle, 1);
551 m_ipcModule.destroyMessage(response);
554 void GenericCommunicator::ListAllSurfaceIDS(t_ilm_message message)
556 t_ilm_message response;
557 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
560 m_executor->getScene()->lockScene();
561 m_executor->getScene()->getSurfaceIDs(&length, &array);
562 m_executor->getScene()->unlockScene();
563 response = m_ipcModule.createResponse(message);
564 m_ipcModule.appendUintArray(response, array, length);
565 m_ipcModule.sendToClients(response, &clientHandle, 1);
566 m_ipcModule.destroyMessage(response);
569 void GenericCommunicator::ListSurfaceofLayer(t_ilm_message message)
571 t_ilm_message response;
572 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
574 m_ipcModule.getUint(message, &id);
575 m_executor->getScene()->lockScene();
576 Layer* layer = m_executor->getScene()->getLayer(id);
579 std::list<Surface*> surfaces = layer->getAllSurfaces();
581 uint length = surfaces.size();
582 uint* array = new uint[length];
585 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
588 array[arrayPos] = s->getID();
591 m_executor->getScene()->unlockScene();
593 response = m_ipcModule.createResponse(message);
594 m_ipcModule.appendUintArray(response, array, length);
598 m_executor->getScene()->unlockScene();
599 response = m_ipcModule.createErrorResponse(message);
600 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
603 m_ipcModule.sendToClients(response, &clientHandle, 1);
604 m_ipcModule.destroyMessage(response);
607 void GenericCommunicator::GetPropertiesOfSurface(t_ilm_message message)
609 t_ilm_message response;
610 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
612 m_ipcModule.getUint(message, &id);
614 Surface* surface = m_executor->getScene()->getSurface(id);
617 Rectangle dest = surface->getDestinationRegion();
618 Rectangle src = surface->getSourceRegion();
619 OrientationType orientation = surface->getOrientation();
620 unsigned char chromaKeyRed = 0;
621 unsigned char chromaKeyGreen = 0;
622 unsigned char chromaKeyBlue = 0;
623 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
625 response = m_ipcModule.createResponse(message);
626 m_ipcModule.appendDouble(response, surface->getOpacity());
627 m_ipcModule.appendUint(response, src.x);
628 m_ipcModule.appendUint(response, src.y);
629 m_ipcModule.appendUint(response, src.width);
630 m_ipcModule.appendUint(response, src.height);
631 m_ipcModule.appendUint(response, surface->OriginalSourceWidth);
632 m_ipcModule.appendUint(response, surface->OriginalSourceHeight);
633 m_ipcModule.appendUint(response, dest.x);
634 m_ipcModule.appendUint(response, dest.y);
635 m_ipcModule.appendUint(response, dest.width);
636 m_ipcModule.appendUint(response, dest.height);
637 m_ipcModule.appendUint(response, orientation);
638 m_ipcModule.appendBool(response, surface->getVisibility());
639 m_ipcModule.appendUint(response, surface->frameCounter);
640 m_ipcModule.appendUint(response, surface->drawCounter);
641 m_ipcModule.appendUint(response, surface->updateCounter);
642 m_ipcModule.appendUint(response, surface->getPixelFormat());
643 m_ipcModule.appendUint(response, surface->getNativeContent());
644 m_ipcModule.appendUint(response, surface->getInputEventAcceptanceOnDevices());
645 m_ipcModule.appendBool(response, surface->getChromaKeyEnabled());
646 m_ipcModule.appendUint(response, chromaKeyRed);
647 m_ipcModule.appendUint(response, chromaKeyGreen);
648 m_ipcModule.appendUint(response, chromaKeyBlue);
649 m_ipcModule.appendInt(response, surface->getCreatorPid());
653 response = m_ipcModule.createErrorResponse(message);
654 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
657 m_ipcModule.sendToClients(response, &clientHandle, 1);
658 m_ipcModule.destroyMessage(response);
661 void GenericCommunicator::GetPropertiesOfLayer(t_ilm_message message)
663 t_ilm_message response;
664 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
666 m_ipcModule.getUint(message, &id);
668 Layer* layer = m_executor->getScene()->getLayer(id);
671 Rectangle dest = layer->getDestinationRegion();
672 Rectangle src = layer->getSourceRegion();
673 OrientationType orientation = layer->getOrientation();
674 unsigned char chromaKeyRed = 0;
675 unsigned char chromaKeyGreen = 0;
676 unsigned char chromaKeyBlue = 0;
677 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
679 response = m_ipcModule.createResponse(message);
680 m_ipcModule.appendDouble(response, layer->getOpacity());
681 m_ipcModule.appendUint(response, src.x);
682 m_ipcModule.appendUint(response, src.y);
683 m_ipcModule.appendUint(response, src.width);
684 m_ipcModule.appendUint(response, src.height);
685 m_ipcModule.appendUint(response, layer->OriginalSourceWidth);
686 m_ipcModule.appendUint(response, layer->OriginalSourceHeight);
687 m_ipcModule.appendUint(response, dest.x);
688 m_ipcModule.appendUint(response, dest.y);
689 m_ipcModule.appendUint(response, dest.width);
690 m_ipcModule.appendUint(response, dest.height);
691 m_ipcModule.appendUint(response, orientation);
692 m_ipcModule.appendBool(response, layer->getVisibility());
693 m_ipcModule.appendUint(response, layer->getLayerType());
694 m_ipcModule.appendBool(response, layer->getChromaKeyEnabled());
695 m_ipcModule.appendUint(response, chromaKeyRed);
696 m_ipcModule.appendUint(response, chromaKeyGreen);
697 m_ipcModule.appendUint(response, chromaKeyBlue);
698 m_ipcModule.appendInt(response, layer->getCreatorPid());
702 response = m_ipcModule.createErrorResponse(message);
703 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
706 m_ipcModule.sendToClients(response, &clientHandle, 1);
707 m_ipcModule.destroyMessage(response);
710 void GenericCommunicator::CreateSurface(t_ilm_message message)
712 t_ilm_message response;
713 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
714 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
718 uint pixelformat = 0;
719 PixelFormat pf = PIXELFORMAT_UNKNOWN;
720 uint id = GraphicalObject::INVALID_ID;
722 m_ipcModule.getUint(message, &handle);
723 m_ipcModule.getUint(message, &width);
724 m_ipcModule.getUint(message, &height);
725 m_ipcModule.getUint(message, &pixelformat);
727 pf = (PixelFormat) pixelformat;
730 // First of all create the surface
731 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
733 // after that apply the native content
734 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
738 response = m_ipcModule.createResponse(message);
739 m_ipcModule.appendUint(response, id);
743 response = m_ipcModule.createErrorResponse(message);
744 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
747 m_ipcModule.sendToClients(response, &clientHandle, 1);
748 m_ipcModule.destroyMessage(response);
751 void GenericCommunicator::CreateSurfaceFromId(t_ilm_message message)
753 t_ilm_message response;
754 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
755 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
759 uint pixelformat = 0;
760 PixelFormat pf = PIXELFORMAT_UNKNOWN;
763 m_ipcModule.getUint(message, &handle);
764 m_ipcModule.getUint(message, &width);
765 m_ipcModule.getUint(message, &height);
766 m_ipcModule.getUint(message, &pixelformat);
767 m_ipcModule.getUint(message, &id);
769 pf = (PixelFormat) pixelformat;
771 // First of all create the surface
772 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
774 // after that apply the native content
775 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
779 response = m_ipcModule.createResponse(message);
780 m_ipcModule.appendUint(response, id);
784 response = m_ipcModule.createErrorResponse(message);
785 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
788 m_ipcModule.sendToClients(response, &clientHandle, 1);
789 m_ipcModule.destroyMessage(response);
792 void GenericCommunicator::InitializeSurface(t_ilm_message message)
794 t_ilm_message response;
795 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
796 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
797 uint id = GraphicalObject::INVALID_ID;
799 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
802 response = m_ipcModule.createResponse(message);
803 m_ipcModule.appendUint(response, id);
807 response = m_ipcModule.createErrorResponse(message);
808 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
811 m_ipcModule.sendToClients(response, &clientHandle, 1);
812 m_ipcModule.destroyMessage(response);
815 void GenericCommunicator::InitializeSurfaceFromId(t_ilm_message message)
817 t_ilm_message response;
818 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
819 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
821 m_ipcModule.getUint(message, &id);
822 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
825 response = m_ipcModule.createResponse(message);
826 m_ipcModule.appendUint(response, id);
830 response = m_ipcModule.createErrorResponse(message);
831 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
834 m_ipcModule.sendToClients(response, &clientHandle, 1);
835 m_ipcModule.destroyMessage(response);
838 void GenericCommunicator::SetSurfaceNativeContent(t_ilm_message message)
840 t_ilm_message response;
841 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
842 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
847 uint pixelformat = 0;
848 PixelFormat pf = PIXELFORMAT_UNKNOWN;
850 m_ipcModule.getUint(message, &id);
851 m_ipcModule.getUint(message, &handle);
852 m_ipcModule.getUint(message, &width);
853 m_ipcModule.getUint(message, &height);
854 m_ipcModule.getUint(message, &pixelformat);
856 pf = (PixelFormat) pixelformat;
858 t_ilm_bool status = m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
861 response = m_ipcModule.createResponse(message);
865 response = m_ipcModule.createErrorResponse(message);
866 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
869 m_ipcModule.sendToClients(response, &clientHandle, 1);
870 m_ipcModule.destroyMessage(response);
873 void GenericCommunicator::RemoveSurfaceNativeContent(t_ilm_message message)
875 t_ilm_message response;
876 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
877 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
879 m_ipcModule.getUint(message, &id);
881 t_ilm_bool status = m_executor->execute(new SurfaceRemoveNativeContentCommand(clientPid, id));
884 response = m_ipcModule.createResponse(message);
888 response = m_ipcModule.createErrorResponse(message);
889 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
892 m_ipcModule.sendToClients(response, &clientHandle, 1);
893 m_ipcModule.destroyMessage(response);
896 void GenericCommunicator::RemoveSurface(t_ilm_message message)
898 t_ilm_message response;
899 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
900 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
902 m_ipcModule.getUint(message, ¶m);
903 t_ilm_bool status = m_executor->execute(new SurfaceRemoveCommand(clientPid, param));
906 response = m_ipcModule.createResponse(message);
910 response = m_ipcModule.createErrorResponse(message);
911 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
914 m_ipcModule.sendToClients(response, &clientHandle, 1);
915 m_ipcModule.destroyMessage(response);
918 void GenericCommunicator::CreateLayer(t_ilm_message message)
920 t_ilm_message response;
921 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
922 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
923 uint id = GraphicalObject::INVALID_ID;
924 // use resolution of default screen as default width and height of layers
925 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
926 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
929 response = m_ipcModule.createResponse(message);
930 m_ipcModule.appendUint(response, id);
934 response = m_ipcModule.createErrorResponse(message);
935 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
938 m_ipcModule.sendToClients(response, &clientHandle, 1);
939 m_ipcModule.destroyMessage(response);
942 void GenericCommunicator::CreateLayerFromId(t_ilm_message message)
944 t_ilm_message response;
945 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
946 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
947 uint id = GraphicalObject::INVALID_ID;
949 m_ipcModule.getUint(message, &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(clientPid, resolution[0], resolution[1], &id));
955 response = m_ipcModule.createResponse(message);
956 m_ipcModule.appendUint(response, id);
960 response = m_ipcModule.createErrorResponse(message);
961 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
964 m_ipcModule.sendToClients(response, &clientHandle, 1);
965 m_ipcModule.destroyMessage(response);
969 void GenericCommunicator::CreateLayerWithDimension(t_ilm_message message)
971 t_ilm_message response;
972 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
973 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
975 m_ipcModule.getUint(message, &width);
977 m_ipcModule.getUint(message, &height);
979 uint id = GraphicalObject::INVALID_ID;
980 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
983 response = m_ipcModule.createResponse(message);
984 m_ipcModule.appendUint(response, id);
988 response = m_ipcModule.createErrorResponse(message);
989 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
992 m_ipcModule.sendToClients(response, &clientHandle, 1);
993 m_ipcModule.destroyMessage(response);
996 void GenericCommunicator::CreateLayerFromIdWithDimension(t_ilm_message message)
998 t_ilm_message response;
999 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1000 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1001 uint id = GraphicalObject::INVALID_ID;
1004 t_ilm_bool status = ILM_FALSE;
1006 m_ipcModule.getUint(message, &id);
1007 m_ipcModule.getUint(message, &width);
1008 m_ipcModule.getUint(message, &height);
1010 status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
1013 response = m_ipcModule.createResponse(message);
1014 m_ipcModule.appendUint(response, id);
1018 response = m_ipcModule.createErrorResponse(message);
1019 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1022 m_ipcModule.sendToClients(response, &clientHandle, 1);
1023 m_ipcModule.destroyMessage(response);
1026 void GenericCommunicator::RemoveLayer(t_ilm_message message)
1028 t_ilm_message response;
1029 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1030 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1032 m_ipcModule.getUint(message, ¶m);
1033 t_ilm_bool status = m_executor->execute(new LayerRemoveCommand(clientPid, param));
1036 response = m_ipcModule.createResponse(message);
1040 response = m_ipcModule.createErrorResponse(message);
1041 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1044 m_ipcModule.sendToClients(response, &clientHandle, 1);
1045 m_ipcModule.destroyMessage(response);
1048 void GenericCommunicator::AddSurfaceToLayer(t_ilm_message message)
1050 t_ilm_message response;
1051 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1052 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1056 m_ipcModule.getUint(message, &surfaceid);
1057 m_ipcModule.getUint(message, &layer);
1059 t_ilm_bool status = m_executor->execute(new LayerAddSurfaceCommand(clientPid, layer, surfaceid));
1062 response = m_ipcModule.createResponse(message);
1066 response = m_ipcModule.createErrorResponse(message);
1067 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1070 m_ipcModule.sendToClients(response, &clientHandle, 1);
1071 m_ipcModule.destroyMessage(response);
1074 void GenericCommunicator::RemoveSurfaceFromLayer(t_ilm_message message)
1076 t_ilm_message response;
1077 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1078 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1081 m_ipcModule.getUint(message, &surfaceid);
1082 m_ipcModule.getUint(message, &layerid);
1084 t_ilm_bool status = m_executor->execute(new LayerRemoveSurfaceCommand(clientPid, layerid, surfaceid));
1087 response = m_ipcModule.createResponse(message);
1091 response = m_ipcModule.createErrorResponse(message);
1092 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1095 m_ipcModule.sendToClients(response, &clientHandle, 1);
1096 m_ipcModule.destroyMessage(response);
1099 void GenericCommunicator::SetSurfaceSourceRegion(t_ilm_message message)
1101 t_ilm_message response;
1102 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1103 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1110 m_ipcModule.getUint(message, &id);
1111 m_ipcModule.getUint(message, &x);
1112 m_ipcModule.getUint(message, &y);
1113 m_ipcModule.getUint(message, &width);
1114 m_ipcModule.getUint(message, &height);
1116 t_ilm_bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1119 response = m_ipcModule.createResponse(message);
1123 response = m_ipcModule.createErrorResponse(message);
1124 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1127 m_ipcModule.sendToClients(response, &clientHandle, 1);
1128 m_ipcModule.destroyMessage(response);
1131 void GenericCommunicator::SetLayerSourceRegion(t_ilm_message message)
1133 t_ilm_message response;
1134 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1135 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1142 m_ipcModule.getUint(message, &id);
1143 m_ipcModule.getUint(message, &x);
1144 m_ipcModule.getUint(message, &y);
1145 m_ipcModule.getUint(message, &width);
1146 m_ipcModule.getUint(message, &height);
1148 t_ilm_bool status = m_executor->execute(new LayerSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1151 response = m_ipcModule.createResponse(message);
1155 response = m_ipcModule.createErrorResponse(message);
1156 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1159 m_ipcModule.sendToClients(response, &clientHandle, 1);
1160 m_ipcModule.destroyMessage(response);
1163 void GenericCommunicator::SetSurfaceDestinationRegion(t_ilm_message message)
1165 t_ilm_message response;
1166 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1167 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1174 m_ipcModule.getUint(message, &id);
1175 m_ipcModule.getUint(message, &x);
1176 m_ipcModule.getUint(message, &y);
1177 m_ipcModule.getUint(message, &width);
1178 m_ipcModule.getUint(message, &height);
1180 t_ilm_bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1183 response = m_ipcModule.createResponse(message);
1187 response = m_ipcModule.createErrorResponse(message);
1188 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1191 m_ipcModule.sendToClients(response, &clientHandle, 1);
1192 m_ipcModule.destroyMessage(response);
1195 void GenericCommunicator::SetSurfacePosition(t_ilm_message message)
1197 t_ilm_message response;
1198 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1199 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1204 m_ipcModule.getUint(message, &id);
1205 m_ipcModule.getUint(message, &x);
1206 m_ipcModule.getUint(message, &y);
1208 t_ilm_bool status = m_executor->execute(new SurfaceSetPositionCommand(clientPid, id, x, y));
1211 response = m_ipcModule.createResponse(message);
1215 response = m_ipcModule.createErrorResponse(message);
1216 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1219 m_ipcModule.sendToClients(response, &clientHandle, 1);
1220 m_ipcModule.destroyMessage(response);
1223 void GenericCommunicator::GetSurfacePosition(t_ilm_message message)
1225 t_ilm_message response;
1226 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1227 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1232 m_ipcModule.getUint(message, &id);
1234 t_ilm_bool status = m_executor->execute(new SurfaceGetPositionCommand(clientPid, id, &x, &y));
1237 response = m_ipcModule.createResponse(message);
1238 m_ipcModule.appendUint(response, x);
1239 m_ipcModule.appendUint(response, y);
1243 response = m_ipcModule.createErrorResponse(message);
1244 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1247 m_ipcModule.sendToClients(response, &clientHandle, 1);
1248 m_ipcModule.destroyMessage(response);
1251 void GenericCommunicator::SetSurfaceDimension(t_ilm_message message)
1253 t_ilm_message response;
1254 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1255 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1260 m_ipcModule.getUint(message, &id);
1261 m_ipcModule.getUint(message, &width);
1262 m_ipcModule.getUint(message, &height);
1264 t_ilm_bool status = m_executor->execute(new SurfaceSetDimensionCommand(clientPid, id, width, height));
1267 response = m_ipcModule.createResponse(message);
1271 response = m_ipcModule.createErrorResponse(message);
1272 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1275 m_ipcModule.sendToClients(response, &clientHandle, 1);
1276 m_ipcModule.destroyMessage(response);
1279 void GenericCommunicator::SetLayerDestinationRegion(t_ilm_message message)
1281 t_ilm_message response;
1282 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1283 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1290 m_ipcModule.getUint(message, &id);
1291 m_ipcModule.getUint(message, &x);
1292 m_ipcModule.getUint(message, &y);
1293 m_ipcModule.getUint(message, &width);
1294 m_ipcModule.getUint(message, &height);
1296 t_ilm_bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1299 response = m_ipcModule.createResponse(message);
1303 response = m_ipcModule.createErrorResponse(message);
1304 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1307 m_ipcModule.sendToClients(response, &clientHandle, 1);
1308 m_ipcModule.destroyMessage(response);
1311 void GenericCommunicator::SetLayerPosition(t_ilm_message message)
1313 t_ilm_message response;
1314 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1315 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1320 m_ipcModule.getUint(message, &id);
1321 m_ipcModule.getUint(message, &x);
1322 m_ipcModule.getUint(message, &y);
1324 t_ilm_bool status = m_executor->execute(new LayerSetPositionCommand(clientPid, id, x, y));
1327 response = m_ipcModule.createResponse(message);
1331 response = m_ipcModule.createErrorResponse(message);
1332 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1335 m_ipcModule.sendToClients(response, &clientHandle, 1);
1336 m_ipcModule.destroyMessage(response);
1339 void GenericCommunicator::GetLayerPosition(t_ilm_message message)
1341 t_ilm_message response;
1342 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1343 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1348 m_ipcModule.getUint(message, &id);
1350 t_ilm_bool status = m_executor->execute(new LayerGetPositionCommand(clientPid, id, &x, &y));
1353 response = m_ipcModule.createResponse(message);
1354 m_ipcModule.appendUint(response, x);
1355 m_ipcModule.appendUint(response, y);
1359 response = m_ipcModule.createErrorResponse(message);
1360 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1363 m_ipcModule.sendToClients(response, &clientHandle, 1);
1364 m_ipcModule.destroyMessage(response);
1367 void GenericCommunicator::SetLayerDimension(t_ilm_message message)
1369 t_ilm_message response;
1370 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1371 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1376 m_ipcModule.getUint(message, &id);
1377 m_ipcModule.getUint(message, &width);
1378 m_ipcModule.getUint(message, &height);
1380 t_ilm_bool status = m_executor->execute(new LayerSetDimensionCommand(clientPid, id, width, height));
1383 response = m_ipcModule.createResponse(message);
1387 response = m_ipcModule.createErrorResponse(message);
1388 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1391 m_ipcModule.sendToClients(response, &clientHandle, 1);
1392 m_ipcModule.destroyMessage(response);
1395 void GenericCommunicator::GetLayerDimension(t_ilm_message message)
1397 t_ilm_message response;
1398 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1399 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1404 m_ipcModule.getUint(message, &id);
1406 t_ilm_bool status = m_executor->execute(new LayerGetDimensionCommand(clientPid, id, &width, &height));
1409 response = m_ipcModule.createResponse(message);
1410 m_ipcModule.appendUint(response, width);
1411 m_ipcModule.appendUint(response, height);
1415 response = m_ipcModule.createErrorResponse(message);
1416 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1419 m_ipcModule.sendToClients(response, &clientHandle, 1);
1420 m_ipcModule.destroyMessage(response);
1423 void GenericCommunicator::GetSurfaceDimension(t_ilm_message message)
1425 t_ilm_message response;
1426 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1427 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1432 m_ipcModule.getUint(message, &id);
1434 t_ilm_bool status = m_executor->execute(new SurfaceGetDimensionCommand(clientPid, id, &width, &height));
1437 response = m_ipcModule.createResponse(message);
1438 m_ipcModule.appendUint(response, width);
1439 m_ipcModule.appendUint(response, height);
1443 response = m_ipcModule.createErrorResponse(message);
1444 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1447 m_ipcModule.sendToClients(response, &clientHandle, 1);
1448 m_ipcModule.destroyMessage(response);
1451 void GenericCommunicator::SetSurfaceOpacity(t_ilm_message message)
1453 t_ilm_message response;
1454 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1455 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1459 m_ipcModule.getUint(message, &id);
1460 m_ipcModule.getDouble(message, ¶m);
1462 t_ilm_bool status = m_executor->execute(new SurfaceSetOpacityCommand(clientPid, id, param));
1465 response = m_ipcModule.createResponse(message);
1469 response = m_ipcModule.createErrorResponse(message);
1470 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1473 m_ipcModule.sendToClients(response, &clientHandle, 1);
1474 m_ipcModule.destroyMessage(response);
1477 void GenericCommunicator::SetLayerOpacity(t_ilm_message message)
1479 t_ilm_message response;
1480 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1481 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1485 m_ipcModule.getUint(message, &id);
1486 m_ipcModule.getDouble(message, ¶m);
1488 t_ilm_bool status = m_executor->execute(new LayerSetOpacityCommand(clientPid, id, param));
1491 response = m_ipcModule.createResponse(message);
1495 response = m_ipcModule.createErrorResponse(message);
1496 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1499 m_ipcModule.sendToClients(response, &clientHandle, 1);
1500 m_ipcModule.destroyMessage(response);
1503 void GenericCommunicator::GetSurfaceOpacity(t_ilm_message message)
1505 t_ilm_message response;
1506 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1507 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1511 m_ipcModule.getUint(message, &id);
1513 t_ilm_bool status = m_executor->execute(new SurfaceGetOpacityCommand(clientPid, id, ¶m));
1516 response = m_ipcModule.createResponse(message);
1517 m_ipcModule.appendDouble(response, param);
1521 response = m_ipcModule.createErrorResponse(message);
1522 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1525 m_ipcModule.sendToClients(response, &clientHandle, 1);
1526 m_ipcModule.destroyMessage(response);
1529 void GenericCommunicator::GetLayerOpacity(t_ilm_message message)
1531 t_ilm_message response;
1532 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1533 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1537 m_ipcModule.getUint(message, &id);
1539 t_ilm_bool status = m_executor->execute(new LayerGetOpacityCommand(clientPid, id, ¶m));
1542 response = m_ipcModule.createResponse(message);
1543 m_ipcModule.appendDouble(response, param);
1547 response = m_ipcModule.createErrorResponse(message);
1548 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1551 m_ipcModule.sendToClients(response, &clientHandle, 1);
1552 m_ipcModule.destroyMessage(response);
1555 void GenericCommunicator::SetSurfaceOrientation(t_ilm_message message)
1557 t_ilm_message response;
1558 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1559 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1562 OrientationType o = Zero;
1564 m_ipcModule.getUint(message, &id);
1565 m_ipcModule.getUint(message, ¶m);
1567 o = (OrientationType) param;
1569 t_ilm_bool status = m_executor->execute(new SurfaceSetOrientationCommand(clientPid, id, o));
1572 response = m_ipcModule.createResponse(message);
1576 response = m_ipcModule.createErrorResponse(message);
1577 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1580 m_ipcModule.sendToClients(response, &clientHandle, 1);
1581 m_ipcModule.destroyMessage(response);
1584 void GenericCommunicator::GetSurfaceOrientation(t_ilm_message message)
1586 t_ilm_message response;
1587 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1588 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1592 m_ipcModule.getUint(message, &id);
1594 t_ilm_bool status = m_executor->execute(new SurfaceGetOrientationCommand(clientPid, id, &o));
1597 response = m_ipcModule.createResponse(message);
1598 m_ipcModule.appendUint(response, o);
1602 response = m_ipcModule.createErrorResponse(message);
1603 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1606 m_ipcModule.sendToClients(response, &clientHandle, 1);
1607 m_ipcModule.destroyMessage(response);
1610 void GenericCommunicator::SetLayerOrientation(t_ilm_message message)
1612 t_ilm_message response;
1613 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1614 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1617 OrientationType o = Zero;
1619 m_ipcModule.getUint(message, &id);
1620 m_ipcModule.getUint(message, ¶m);
1622 o = (OrientationType) param;
1624 t_ilm_bool status = m_executor->execute(new LayerSetOrientationCommand(clientPid, id, o));
1627 response = m_ipcModule.createResponse(message);
1631 response = m_ipcModule.createErrorResponse(message);
1632 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1635 m_ipcModule.sendToClients(response, &clientHandle, 1);
1636 m_ipcModule.destroyMessage(response);
1639 void GenericCommunicator::GetLayerOrientation(t_ilm_message message)
1641 t_ilm_message response;
1642 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1643 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1647 m_ipcModule.getUint(message, &id);
1649 t_ilm_bool status = m_executor->execute(new LayerGetOrientationCommand(clientPid, id, &o));
1652 response = m_ipcModule.createResponse(message);
1653 m_ipcModule.appendUint(response, o);
1657 response = m_ipcModule.createErrorResponse(message);
1658 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1661 m_ipcModule.sendToClients(response, &clientHandle, 1);
1662 m_ipcModule.destroyMessage(response);
1665 void GenericCommunicator::GetSurfacePixelformat(t_ilm_message message)
1667 t_ilm_message response;
1668 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1669 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1671 PixelFormat pixelFormat;
1673 m_ipcModule.getUint(message, &id);
1675 t_ilm_bool status = m_executor->execute(new SurfaceGetPixelformatCommand(clientPid, id, &pixelFormat));
1678 response = m_ipcModule.createResponse(message);
1679 m_ipcModule.appendUint(response, pixelFormat);
1683 response = m_ipcModule.createErrorResponse(message);
1684 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1687 m_ipcModule.sendToClients(response, &clientHandle, 1);
1688 m_ipcModule.destroyMessage(response);
1691 void GenericCommunicator::SetSurfaceVisibility(t_ilm_message message)
1693 t_ilm_message response;
1694 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1695 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1697 t_ilm_bool newVis = ILM_FALSE;
1699 m_ipcModule.getUint(message, &surfaceid);
1700 m_ipcModule.getBool(message, &newVis);
1702 t_ilm_bool status = m_executor->execute(new SurfaceSetVisibilityCommand(clientPid, surfaceid, newVis));
1705 response = m_ipcModule.createResponse(message);
1709 response = m_ipcModule.createErrorResponse(message);
1710 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1713 m_ipcModule.sendToClients(response, &clientHandle, 1);
1714 m_ipcModule.destroyMessage(response);
1717 void GenericCommunicator::SetLayerVisibility(t_ilm_message message)
1719 t_ilm_message response;
1720 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1721 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1723 t_ilm_bool myparam = ILM_FALSE;
1725 m_ipcModule.getUint(message, &layerid);
1726 m_ipcModule.getBool(message, &myparam);
1728 t_ilm_bool status = m_executor->execute(new LayerSetVisibilityCommand(clientPid, layerid, myparam));
1731 response = m_ipcModule.createResponse(message);
1735 response = m_ipcModule.createErrorResponse(message);
1736 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1739 m_ipcModule.sendToClients(response, &clientHandle, 1);
1740 m_ipcModule.destroyMessage(response);
1743 void GenericCommunicator::GetSurfaceVisibility(t_ilm_message message)
1745 t_ilm_message response;
1746 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1747 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1751 m_ipcModule.getUint(message, &id);
1753 t_ilm_bool status = m_executor->execute(new SurfaceGetVisibilityCommand(clientPid, id, &visibility));
1756 response = m_ipcModule.createResponse(message);
1757 m_ipcModule.appendBool(response, visibility);
1761 response = m_ipcModule.createErrorResponse(message);
1762 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1765 m_ipcModule.sendToClients(response, &clientHandle, 1);
1766 m_ipcModule.destroyMessage(response);
1769 void GenericCommunicator::GetLayerVisibility(t_ilm_message message)
1771 t_ilm_message response;
1772 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1773 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1777 m_ipcModule.getUint(message, &id);
1779 t_ilm_bool status = m_executor->execute(new LayerGetVisibilityCommand(clientPid, id, &visibility));
1782 response = m_ipcModule.createResponse(message);
1783 m_ipcModule.appendBool(response, visibility);
1787 response = m_ipcModule.createErrorResponse(message);
1788 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1791 m_ipcModule.sendToClients(response, &clientHandle, 1);
1792 m_ipcModule.destroyMessage(response);
1795 void GenericCommunicator::SetRenderOrderOfLayers(t_ilm_message message)
1797 t_ilm_message response;
1798 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1799 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1804 m_ipcModule.getUintArray(message, &array, &length);
1805 m_ipcModule.getUint(message, &screenID);
1807 t_ilm_bool status = m_executor->execute(new ScreenSetRenderOrderCommand(clientPid, screenID, array, length));
1810 response = m_ipcModule.createResponse(message);
1814 response = m_ipcModule.createErrorResponse(message);
1815 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1818 m_ipcModule.sendToClients(response, &clientHandle, 1);
1819 m_ipcModule.destroyMessage(response);
1822 void GenericCommunicator::SetSurfaceRenderOrderWithinLayer(t_ilm_message message)
1824 t_ilm_message response;
1825 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1826 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1831 m_ipcModule.getUint(message, &layerid);
1832 m_ipcModule.getUintArray(message, &array, &length);
1834 t_ilm_bool status = m_executor->execute(new LayerSetRenderOrderCommand(clientPid, layerid, array, length));
1837 response = m_ipcModule.createResponse(message);
1841 response = m_ipcModule.createErrorResponse(message);
1842 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1845 m_ipcModule.sendToClients(response, &clientHandle, 1);
1846 m_ipcModule.destroyMessage(response);
1849 void GenericCommunicator::GetLayerType(t_ilm_message message)
1851 t_ilm_message response;
1852 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1854 m_ipcModule.getUint(message, &id);
1856 Layer* layer = m_executor->getScene()->getLayer(id);
1859 response = m_ipcModule.createResponse(message);
1860 m_ipcModule.appendUint(response, layer->getLayerType());
1864 response = m_ipcModule.createErrorResponse(message);
1865 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1868 m_ipcModule.sendToClients(response, &clientHandle, 1);
1869 m_ipcModule.destroyMessage(response);
1872 void GenericCommunicator::GetLayertypeCapabilities(t_ilm_message message)
1874 t_ilm_message response;
1875 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1877 LayerType type = Unknown;
1879 m_ipcModule.getUint(message, &id);
1881 type = (LayerType) id;
1883 uint capabilities = m_executor->getLayerTypeCapabilities(type);
1884 response = m_ipcModule.createResponse(message);
1885 m_ipcModule.appendUint(response, capabilities);
1886 m_ipcModule.sendToClients(response, &clientHandle, 1);
1887 m_ipcModule.destroyMessage(response);
1890 void GenericCommunicator::GetLayerCapabilities(t_ilm_message message)
1892 t_ilm_message response;
1893 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1895 m_ipcModule.getUint(message, &id);
1897 Layer* layer = m_executor->getScene()->getLayer(id);
1900 response = m_ipcModule.createResponse(message);
1901 m_ipcModule.appendUint(response, layer->getCapabilities());
1905 response = m_ipcModule.createErrorResponse(message);
1906 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1909 m_ipcModule.sendToClients(response, &clientHandle, 1);
1910 m_ipcModule.destroyMessage(response);
1913 void GenericCommunicator::FadeIn(t_ilm_message message)
1915 t_ilm_message response;
1916 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1917 response = m_ipcModule.createErrorResponse(message);
1918 m_ipcModule.appendString(response, NOT_IMPLEMENTED);
1919 m_ipcModule.sendToClients(response, &clientHandle, 1);
1920 m_ipcModule.destroyMessage(response);
1923 void GenericCommunicator::SynchronizedFade(t_ilm_message message)
1925 t_ilm_message response;
1926 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1927 response = m_ipcModule.createErrorResponse(message);
1928 m_ipcModule.appendString(response, NOT_IMPLEMENTED);
1929 m_ipcModule.sendToClients(response, &clientHandle, 1);
1930 m_ipcModule.destroyMessage(response);
1933 void GenericCommunicator::FadeOut(t_ilm_message message)
1935 t_ilm_message response;
1936 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1937 response = m_ipcModule.createErrorResponse(message);
1938 m_ipcModule.appendString(response, NOT_IMPLEMENTED);
1939 m_ipcModule.sendToClients(response, &clientHandle, 1);
1940 m_ipcModule.destroyMessage(response);
1943 void GenericCommunicator::Exit(t_ilm_message message)
1945 t_ilm_message response;
1946 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1947 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1948 t_ilm_bool status = m_executor->execute(new ExitCommand(clientPid));
1951 response = m_ipcModule.createResponse(message);
1955 response = m_ipcModule.createErrorResponse(message);
1956 m_ipcModule.appendString(response, INVALID_ARGUMENT);
1959 m_ipcModule.sendToClients(response, &clientHandle, 1);
1960 m_ipcModule.destroyMessage(response);
1963 void GenericCommunicator::CommitChanges(t_ilm_message message)
1965 t_ilm_message response;
1966 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1967 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1968 t_ilm_bool status = m_executor->execute(new CommitCommand(clientPid));
1971 response = m_ipcModule.createResponse(message);
1975 response = m_ipcModule.createErrorResponse(message);
1976 m_ipcModule.appendString(response, INVALID_ARGUMENT);
1979 m_ipcModule.sendToClients(response, &clientHandle, 1);
1980 m_ipcModule.destroyMessage(response);
1983 void GenericCommunicator::CreateShader(t_ilm_message message)
1985 t_ilm_message response;
1986 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1987 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1988 char vertname[1024];
1989 char fragname[1024];
1992 m_ipcModule.getString(message, vertname);
1993 m_ipcModule.getString(message, fragname);
1995 t_ilm_bool status = m_executor->execute(new ShaderCreateCommand(clientPid, vertname, fragname, &id));
1998 response = m_ipcModule.createResponse(message);
1999 m_ipcModule.appendUint(response, id);
2003 response = m_ipcModule.createErrorResponse(message);
2004 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2007 m_ipcModule.sendToClients(response, &clientHandle, 1);
2008 m_ipcModule.destroyMessage(response);
2011 void GenericCommunicator::DestroyShader(t_ilm_message message)
2013 t_ilm_message response;
2014 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2015 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2018 m_ipcModule.getUint(message, &shaderid);
2020 t_ilm_bool status = m_executor->execute(new ShaderDestroyCommand(clientPid, shaderid));
2023 response = m_ipcModule.createResponse(message);
2027 response = m_ipcModule.createErrorResponse(message);
2028 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2031 m_ipcModule.sendToClients(response, &clientHandle, 1);
2032 m_ipcModule.destroyMessage(response);
2035 void GenericCommunicator::SetShader(t_ilm_message message)
2037 t_ilm_message response;
2038 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2039 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2043 m_ipcModule.getUint(message, &surfaceId);
2044 m_ipcModule.getUint(message, &shaderid);
2046 t_ilm_bool status = m_executor->execute(new SurfaceSetShaderCommand(clientPid, surfaceId, shaderid));
2049 response = m_ipcModule.createResponse(message);
2053 response = m_ipcModule.createErrorResponse(message);
2054 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2057 m_ipcModule.sendToClients(response, &clientHandle, 1);
2058 m_ipcModule.destroyMessage(response);
2061 void GenericCommunicator::SetUniforms(t_ilm_message message)
2063 t_ilm_message response;
2064 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2065 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2067 std::vector<string> uniforms;
2069 m_ipcModule.getUint(message, &id);
2072 //m_ipcModule.getStringArray(&uniforms);
2074 t_ilm_bool status = m_executor->execute(new ShaderSetUniformsCommand(clientPid, id, uniforms));
2077 response = m_ipcModule.createResponse(message);
2081 response = m_ipcModule.createErrorResponse(message);
2082 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2085 m_ipcModule.sendToClients(response, &clientHandle, 1);
2086 m_ipcModule.destroyMessage(response);
2089 void GenericCommunicator::SetKeyboardFocusOn(t_ilm_message message)
2091 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2092 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2093 t_ilm_message response;
2096 m_ipcModule.getUint(message, &surfaceId);
2098 t_ilm_bool status = m_executor->execute(new SurfaceSetKeyboardFocusCommand(clientPid, surfaceId));
2101 response = m_ipcModule.createResponse(message);
2105 response = m_ipcModule.createErrorResponse(message);
2106 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2109 m_ipcModule.sendToClients(response, &clientHandle, 1);
2110 m_ipcModule.destroyMessage(response);
2114 void GenericCommunicator::GetKeyboardFocusSurfaceId(t_ilm_message message)
2116 t_ilm_message response;
2117 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2118 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2121 t_ilm_bool status = m_executor->execute(new SurfaceGetKeyboardFocusCommand(clientPid, &surfaceId));
2124 response = m_ipcModule.createResponse(message);
2125 m_ipcModule.appendUint(response, surfaceId);
2129 response = m_ipcModule.createErrorResponse(message);
2130 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2133 m_ipcModule.sendToClients(response, &clientHandle, 1);
2134 m_ipcModule.destroyMessage(response);
2138 void GenericCommunicator::UpdateInputEventAcceptanceOn(t_ilm_message message)
2140 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2141 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2142 t_ilm_message response;
2145 InputDevice devices;
2148 m_ipcModule.getUint(message, &surfaceId);
2149 m_ipcModule.getUint(message, &udevices);
2150 m_ipcModule.getBool(message, &accept);
2152 devices = (InputDevice) udevices;
2154 t_ilm_bool status = m_executor->execute(new SurfaceUpdateInputEventAcceptance(clientPid, surfaceId, devices, accept));
2157 response = m_ipcModule.createResponse(message);
2161 response = m_ipcModule.createErrorResponse(message);
2162 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2165 m_ipcModule.sendToClients(response, &clientHandle, 1);
2166 m_ipcModule.destroyMessage(response);
2169 void GenericCommunicator::SetSurfaceChromaKey(t_ilm_message message)
2171 t_ilm_message response;
2172 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2173 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2178 m_ipcModule.getUint(message, &surfaceid);
2179 m_ipcModule.getUintArray(message, &array, &length);
2181 t_ilm_bool status = m_executor->execute(new SurfaceSetChromaKeyCommand(clientPid, surfaceid, array, length));
2184 response = m_ipcModule.createResponse(message);
2188 response = m_ipcModule.createErrorResponse(message);
2189 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2192 m_ipcModule.sendToClients(response, &clientHandle, 1);
2193 m_ipcModule.destroyMessage(response);
2196 void GenericCommunicator::SetLayerChromaKey(t_ilm_message message)
2198 t_ilm_message response;
2199 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2200 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2205 m_ipcModule.getUint(message, &layerid);
2206 m_ipcModule.getUintArray(message, &array, &length);
2208 t_ilm_bool status = m_executor->execute(new LayerSetChromaKeyCommand(clientPid, layerid, array, length));
2211 response = m_ipcModule.createResponse(message);
2215 response = m_ipcModule.createErrorResponse(message);
2216 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2219 m_ipcModule.sendToClients(response, &clientHandle, 1);
2220 m_ipcModule.destroyMessage(response);
2223 void GenericCommunicator::LayerAddNotification(t_ilm_message message)
2225 t_ilm_message response;
2226 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2229 m_ipcModule.getUint(message, &layerid);
2231 Layer* layer = m_executor->getScene()->getLayer(layerid);
2234 layer->addNotification(clientHandle);
2235 response = m_ipcModule.createResponse(message);
2239 response = m_ipcModule.createErrorResponse(message);
2240 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2243 m_ipcModule.sendToClients(response, &clientHandle, 1);
2244 m_ipcModule.destroyMessage(response);
2247 void GenericCommunicator::SurfaceAddNotification(t_ilm_message message)
2249 t_ilm_message response;
2250 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2253 m_ipcModule.getUint(message, &surfaceid);
2255 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2258 surface->addNotification(clientHandle);
2259 response = m_ipcModule.createResponse(message);
2263 response = m_ipcModule.createErrorResponse(message);
2264 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2267 m_ipcModule.sendToClients(response, &clientHandle, 1);
2268 m_ipcModule.destroyMessage(response);
2271 void GenericCommunicator::LayerRemoveNotification(t_ilm_message message)
2273 t_ilm_message response;
2274 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2277 m_ipcModule.getUint(message, &layerid);
2279 Layer* layer = m_executor->getScene()->getLayer(layerid);
2282 layer->removeNotification(clientHandle);
2283 response = m_ipcModule.createResponse(message);
2287 response = m_ipcModule.createErrorResponse(message);
2288 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2291 m_ipcModule.sendToClients(response, &clientHandle, 1);
2292 m_ipcModule.destroyMessage(response);
2295 void GenericCommunicator::SurfaceRemoveNotification(t_ilm_message message)
2297 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2298 t_ilm_message response;
2301 m_ipcModule.getUint(message, &surfaceid);
2303 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2306 surface->removeNotification(clientHandle);
2307 response = m_ipcModule.createResponse(message);
2311 response = m_ipcModule.createErrorResponse(message);
2312 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2315 m_ipcModule.sendToClients(response, &clientHandle, 1);
2316 m_ipcModule.destroyMessage(response);
2319 void GenericCommunicator::processNotificationQueue()
2321 NotificationQueue& notificationQueue = m_executor->getClientNotificationQueue();
2322 NotificationQueue::iterator iter = notificationQueue.begin();
2323 NotificationQueue::iterator end = notificationQueue.end();
2325 for (; iter != end; ++iter)
2327 GraphicalObject* object = iter->first;
2328 t_ilm_notification_mask mask = iter->second;
2329 sendNotification(object, mask);
2331 notificationQueue.clear();
2334 void GenericCommunicator::sendNotification(GraphicalObject* object, t_ilm_notification_mask mask)
2336 switch (object->type)
2340 Layer* layer = static_cast<Layer*>(object);
2343 ApplicationReferenceList& arl = layer->getNotificationClients();
2347 t_ilm_message notification;
2348 Rectangle dest = layer->getDestinationRegion();
2349 Rectangle src = layer->getSourceRegion();
2350 OrientationType orientation = layer->getOrientation();
2352 unsigned char chromaKeyRed = 0;
2353 unsigned char chromaKeyGreen = 0;
2354 unsigned char chromaKeyBlue = 0;
2355 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2357 std::stringstream notificationName;
2358 notificationName << "NotificationForLayer" << layer->getID();
2360 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2361 m_ipcModule.appendUint(notification, layer->getID());
2362 m_ipcModule.appendUint(notification, mask);
2364 m_ipcModule.appendDouble(notification, layer->getOpacity());
2365 m_ipcModule.appendUint(notification, src.x);
2366 m_ipcModule.appendUint(notification, src.y);
2367 m_ipcModule.appendUint(notification, src.width);
2368 m_ipcModule.appendUint(notification, src.height);
2369 m_ipcModule.appendUint(notification, layer->OriginalSourceWidth);
2370 m_ipcModule.appendUint(notification, layer->OriginalSourceHeight);
2371 m_ipcModule.appendUint(notification, dest.x);
2372 m_ipcModule.appendUint(notification, dest.y);
2373 m_ipcModule.appendUint(notification, dest.width);
2374 m_ipcModule.appendUint(notification, dest.height);
2375 m_ipcModule.appendUint(notification, orientation);
2376 m_ipcModule.appendBool(notification, layer->getVisibility());
2377 m_ipcModule.appendUint(notification, layer->getLayerType());
2378 m_ipcModule.appendBool(notification, layer->getChromaKeyEnabled());
2379 m_ipcModule.appendUint(notification, chromaKeyRed);
2380 m_ipcModule.appendUint(notification, chromaKeyGreen);
2381 m_ipcModule.appendUint(notification, chromaKeyBlue);
2382 m_ipcModule.appendInt(notification, layer->getCreatorPid());
2384 int clientCount = arl.size();
2385 t_ilm_client_handle clientArray[256];
2387 ApplicationReferenceList::iterator iter = arl.begin();
2388 ApplicationReferenceList::iterator end = arl.end();
2390 for (int clientNumber = 0;
2391 iter != end, clientNumber < 256;
2392 ++iter, ++clientNumber)
2394 t_ilm_client_handle client = *iter;
2395 clientArray[clientNumber] = client;
2398 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): layer " << layer->getID() << " was updated.");
2400 if (!m_ipcModule.sendToClients(notification, clientArray, clientCount))
2402 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2405 m_ipcModule.destroyMessage(notification);
2412 Surface* surface = static_cast<Surface*>(object);
2415 ApplicationReferenceList& arl = surface->getNotificationClients();
2419 t_ilm_message notification;
2420 std::stringstream notificationName;
2421 notificationName << "NotificationForSurface" << surface->getID();
2423 unsigned char chromaKeyRed = 0;
2424 unsigned char chromaKeyGreen = 0;
2425 unsigned char chromaKeyBlue = 0;
2426 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2428 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2429 m_ipcModule.appendUint(notification, surface->getID());
2430 m_ipcModule.appendUint(notification, mask);
2432 m_ipcModule.appendDouble(notification, surface->getOpacity());
2433 m_ipcModule.appendUint(notification, surface->getSourceRegion().x);
2434 m_ipcModule.appendUint(notification, surface->getSourceRegion().y);
2435 m_ipcModule.appendUint(notification, surface->getSourceRegion().width);
2436 m_ipcModule.appendUint(notification, surface->getSourceRegion().height);
2437 m_ipcModule.appendUint(notification, surface->OriginalSourceWidth);
2438 m_ipcModule.appendUint(notification, surface->OriginalSourceHeight);
2439 m_ipcModule.appendUint(notification, surface->getDestinationRegion().x);
2440 m_ipcModule.appendUint(notification, surface->getDestinationRegion().y);
2441 m_ipcModule.appendUint(notification, surface->getDestinationRegion().width);
2442 m_ipcModule.appendUint(notification, surface->getDestinationRegion().height);
2443 m_ipcModule.appendUint(notification, surface->getOrientation());
2444 m_ipcModule.appendBool(notification, surface->getVisibility());
2445 m_ipcModule.appendUint(notification, surface->frameCounter);
2446 m_ipcModule.appendUint(notification, surface->drawCounter);
2447 m_ipcModule.appendUint(notification, surface->updateCounter);
2448 m_ipcModule.appendUint(notification, surface->getPixelFormat());
2449 m_ipcModule.appendUint(notification, surface->getNativeContent());
2450 m_ipcModule.appendUint(notification, surface->getInputEventAcceptanceOnDevices());
2451 m_ipcModule.appendBool(notification, surface->getChromaKeyEnabled());
2452 m_ipcModule.appendUint(notification, chromaKeyRed);
2453 m_ipcModule.appendUint(notification, chromaKeyGreen);
2454 m_ipcModule.appendUint(notification, chromaKeyBlue);
2455 m_ipcModule.appendInt(notification, surface->getCreatorPid());
2457 int clientCount = arl.size();
2458 t_ilm_client_handle clients[256];
2460 ApplicationReferenceList::iterator iter = arl.begin();
2461 ApplicationReferenceList::iterator end = arl.end();
2463 for (int clientNumber = 0;
2464 iter != end, clientNumber < 256;
2465 ++iter, ++clientNumber)
2467 clients[clientNumber] = *iter;
2470 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): surface " << surface->getID() << " was updated.");
2472 if (!m_ipcModule.sendToClients(notification, clients, clientCount))
2474 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2477 m_ipcModule.destroyMessage(notification);
2483 LOG_INFO("GenericCommunicator", "Unknown notification found in queue.");
2488 HealthCondition GenericCommunicator::pluginGetHealth()
2490 HealthCondition health = PluginBase::pluginGetHealth();
2491 if (0 != pthread_kill(mThreadId, 0))
2493 health = HealthDead;
2498 void GenericCommunicator::SetOptimizationMode(t_ilm_message message)
2500 t_ilm_message response;
2501 OptimizationType optimizationId;
2502 OptimizationModeType optimizationMode;
2504 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2505 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2507 m_ipcModule.getUint(message,&o);
2508 optimizationId = (OptimizationType) o;
2509 m_ipcModule.getUint(message,&o);
2510 optimizationMode = (OptimizationModeType) o;
2512 t_ilm_bool status = m_executor->execute(new SetOptimizationModeCommand(clientPid, optimizationId, optimizationMode));
2515 response = m_ipcModule.createResponse(message);
2519 response = m_ipcModule.createErrorResponse(message);
2520 m_ipcModule.appendString(response,RESOURCE_NOT_FOUND);
2522 m_ipcModule.sendToClients(response,&clientHandle,1);
2523 m_ipcModule.destroyMessage(response);
2526 void GenericCommunicator::GetOptimizationMode(t_ilm_message message)
2528 t_ilm_message response;
2529 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2530 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2531 OptimizationType optimizationId;
2532 OptimizationModeType optimizationMode;
2535 m_ipcModule.getUint(message,&o);
2536 optimizationId = (OptimizationType)o;
2538 t_ilm_bool status = m_executor->execute(new GetOptimizationModeCommand(clientPid, optimizationId, &optimizationMode));
2542 response = m_ipcModule.createResponse(message);
2543 m_ipcModule.appendUint(response,(unsigned int)optimizationMode);
2547 response = m_ipcModule.createErrorResponse(message);
2548 m_ipcModule.appendString(response,RESOURCE_NOT_FOUND);
2550 m_ipcModule.sendToClients(response,&clientHandle,1);
2551 m_ipcModule.destroyMessage(response);
2555 void GenericCommunicator::GetPropertiesOfScreen(t_ilm_message message)
2557 t_ilm_message response;
2558 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2560 m_ipcModule.getUint(message, &id);
2562 LmScreen* screen = m_executor->getScene()->getScreen(id);
2565 LayerList renderOrder = screen->getCurrentRenderOrder();
2566 std::vector<t_ilm_layer> layerIdVector;
2568 LayerListConstIterator iter = renderOrder.begin();
2569 LayerListConstIterator end = renderOrder.end();
2570 for (; iter != end; ++iter)
2572 layerIdVector.push_back((*iter)->getID());
2575 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(id);
2576 uint* resolution = m_executor->getScreenResolution(id);
2578 response = m_ipcModule.createResponse(message);
2579 m_ipcModule.appendUintArray(response, layerIdVector.data(), layerIdVector.size());
2580 m_ipcModule.appendUint(response,numberOfHardwareLayers);
2581 m_ipcModule.appendUint(response, resolution[0]);
2582 m_ipcModule.appendUint(response, resolution[1]);
2586 response = m_ipcModule.createErrorResponse(message);
2587 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2590 m_ipcModule.sendToClients(response, &clientHandle, 1);
2591 m_ipcModule.destroyMessage(response);
2594 DECLARE_LAYERMANAGEMENT_PLUGIN(GenericCommunicator)