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 GenericCommunicator::GenericCommunicator(ICommandExecutor& executor, Configuration& config)
92 : ICommunicator(&executor)
93 , PluginBase(executor, config, Communicator_Api_v1)
94 , m_running(ILM_FALSE)
96 MethodTable manager_methods[] =
98 { "ServiceConnect", &GenericCommunicator::ServiceConnect },
99 { "ServiceDisconnect", &GenericCommunicator::ServiceDisconnect },
100 { "Debug", &GenericCommunicator::Debug },
101 { "ScreenShot", &GenericCommunicator::ScreenShot },
102 { "ScreenShotOfLayer", &GenericCommunicator::ScreenShotOfLayer },
103 { "ScreenShotOfSurface", &GenericCommunicator::ScreenShotOfSurface },
104 { "GetScreenResolution", &GenericCommunicator::GetScreenResolution },
105 { "GetNumberOfHardwareLayers", &GenericCommunicator::GetNumberOfHardwareLayers },
106 { "GetScreenIDs", &GenericCommunicator::GetScreenIDs },
107 { "ListAllLayerIDS", &GenericCommunicator::ListAllLayerIDS },
108 { "ListAllLayerIDsOnScreen", &GenericCommunicator::ListAllLayerIDsOnScreen },
109 { "ListAllSurfaceIDS", &GenericCommunicator::ListAllSurfaceIDS },
110 { "ListSurfaceofLayer", &GenericCommunicator::ListSurfaceofLayer },
111 { "GetPropertiesOfSurface", &GenericCommunicator::GetPropertiesOfSurface },
112 { "GetPropertiesOfLayer", &GenericCommunicator::GetPropertiesOfLayer },
113 { "CreateSurface", &GenericCommunicator::CreateSurface },
114 { "CreateSurfaceFromId", &GenericCommunicator::CreateSurfaceFromId },
115 { "InitializeSurface", &GenericCommunicator::InitializeSurface },
116 { "InitializeSurfaceFromId", &GenericCommunicator::InitializeSurfaceFromId },
117 { "SetSurfaceNativeContent", &GenericCommunicator::SetSurfaceNativeContent },
118 { "RemoveSurfaceNativeContent", &GenericCommunicator::RemoveSurfaceNativeContent },
119 { "RemoveSurface", &GenericCommunicator::RemoveSurface },
120 { "CreateLayer", &GenericCommunicator::CreateLayer },
121 { "CreateLayerFromId", &GenericCommunicator::CreateLayerFromId },
122 { "CreateLayerWithDimension", &GenericCommunicator::CreateLayerWithDimension },
123 { "CreateLayerFromIdWithDimension", &GenericCommunicator::CreateLayerFromIdWithDimension },
124 { "RemoveLayer", &GenericCommunicator::RemoveLayer },
125 { "AddSurfaceToLayer", &GenericCommunicator::AddSurfaceToLayer },
126 { "RemoveSurfaceFromLayer", &GenericCommunicator::RemoveSurfaceFromLayer },
127 { "SetSurfaceSourceRegion", &GenericCommunicator::SetSurfaceSourceRegion },
128 { "SetLayerSourceRegion", &GenericCommunicator::SetLayerSourceRegion },
129 { "SetSurfaceDestinationRegion", &GenericCommunicator::SetSurfaceDestinationRegion },
130 { "SetSurfacePosition", &GenericCommunicator::SetSurfacePosition },
131 { "GetSurfacePosition", &GenericCommunicator::GetSurfacePosition },
132 { "SetSurfaceDimension", &GenericCommunicator::SetSurfaceDimension },
133 { "SetLayerDestinationRegion", &GenericCommunicator::SetLayerDestinationRegion },
134 { "SetLayerPosition", &GenericCommunicator::SetLayerPosition },
135 { "GetLayerPosition", &GenericCommunicator::GetLayerPosition },
136 { "SetLayerDimension", &GenericCommunicator::SetLayerDimension },
137 { "GetLayerDimension", &GenericCommunicator::GetLayerDimension },
138 { "GetSurfaceDimension", &GenericCommunicator::GetSurfaceDimension },
139 { "SetSurfaceOpacity", &GenericCommunicator::SetSurfaceOpacity },
140 { "SetLayerOpacity", &GenericCommunicator::SetLayerOpacity },
141 { "GetSurfaceOpacity", &GenericCommunicator::GetSurfaceOpacity },
142 { "GetLayerOpacity", &GenericCommunicator::GetLayerOpacity },
143 { "SetSurfaceOrientation", &GenericCommunicator::SetSurfaceOrientation },
144 { "GetSurfaceOrientation", &GenericCommunicator::GetSurfaceOrientation },
145 { "SetLayerOrientation", &GenericCommunicator::SetLayerOrientation },
146 { "GetLayerOrientation", &GenericCommunicator::GetLayerOrientation },
147 { "GetSurfacePixelformat", &GenericCommunicator::GetSurfacePixelformat },
148 { "SetSurfaceVisibility", &GenericCommunicator::SetSurfaceVisibility },
149 { "SetLayerVisibility", &GenericCommunicator::SetLayerVisibility },
150 { "GetSurfaceVisibility", &GenericCommunicator::GetSurfaceVisibility },
151 { "GetLayerVisibility", &GenericCommunicator::GetLayerVisibility },
152 { "SetRenderOrderOfLayers", &GenericCommunicator::SetRenderOrderOfLayers },
153 { "SetSurfaceRenderOrderWithinLayer", &GenericCommunicator::SetSurfaceRenderOrderWithinLayer },
154 { "GetLayerType", &GenericCommunicator::GetLayerType },
155 { "GetLayertypeCapabilities", &GenericCommunicator::GetLayertypeCapabilities },
156 { "GetLayerCapabilities", &GenericCommunicator::GetLayerCapabilities },
157 { "Exit", &GenericCommunicator::Exit },
158 { "CommitChanges", &GenericCommunicator::CommitChanges },
159 { "CreateShader", &GenericCommunicator::CreateShader },
160 { "DestroyShader", &GenericCommunicator::DestroyShader },
161 { "SetShader", &GenericCommunicator::SetShader },
162 { "SetUniforms", &GenericCommunicator::SetUniforms },
163 { "SetKeyboardFocusOn", &GenericCommunicator::SetKeyboardFocusOn },
164 { "GetKeyboardFocusSurfaceId", &GenericCommunicator::GetKeyboardFocusSurfaceId },
165 { "UpdateInputEventAcceptanceOn", &GenericCommunicator::UpdateInputEventAcceptanceOn },
166 { "SetSurfaceChromaKey", &GenericCommunicator::SetSurfaceChromaKey },
167 { "SetLayerChromaKey", &GenericCommunicator::SetLayerChromaKey },
168 { "LayerAddNotification", &GenericCommunicator::LayerAddNotification },
169 { "SurfaceAddNotification", &GenericCommunicator::SurfaceAddNotification },
170 { "LayerRemoveNotification", &GenericCommunicator::LayerRemoveNotification },
171 { "SurfaceRemoveNotification", &GenericCommunicator::SurfaceRemoveNotification },
172 { "SetOptimizationMode", &GenericCommunicator::SetOptimizationMode },
173 { "GetOptimizationMode", &GenericCommunicator::GetOptimizationMode },
174 { "GetPropertiesOfScreen", &GenericCommunicator::GetPropertiesOfScreen }
177 int entryCount = sizeof(manager_methods) / sizeof(MethodTable);
179 for (int index = 0; index < entryCount; ++index)
181 MethodTable* method = &manager_methods[index];
182 if (method->function)
184 m_callBackTable[method->name] = *method;
185 LOG_DEBUG("GenericCommunicator", "registered callback for " << method->name);
189 memset(&m_ipcModule, 0, sizeof(m_ipcModule));
191 mThreadId = pthread_self();
194 bool GenericCommunicator::start()
196 LOG_DEBUG("GenericCommunicator", "Starting up IpcModules.");
198 if (!loadIpcModule(&m_ipcModule))
200 LOG_ERROR("GenericCommunicator", "Loading IpcModule failed.");
203 LOG_DEBUG("GenericCommunicator", "Loading IpcModule success.");
205 if (!m_ipcModule.initServiceMode())
207 LOG_ERROR("GenericCommunicator", "Initializing IpcModule failed.");
210 LOG_DEBUG("GenericCommunicator", "Initializing IpcModule success.");
212 m_running = ILM_TRUE;
213 pluginSetHealth(HealthRunning);
222 void GenericCommunicator::stop()
224 LOG_INFO("GenericCommunicator", "stopping");
230 m_ipcModule.destroy();
232 pluginSetHealth(HealthStopped);
235 void GenericCommunicator::process(int timeout_ms)
237 t_ilm_message message = m_ipcModule.receive(timeout_ms);
243 t_ilm_message_type messageType = m_ipcModule.getMessageType(message);
244 t_ilm_const_string name = m_ipcModule.getMessageName(message);
245 t_ilm_client_handle senderHandle = m_ipcModule.getSenderHandle(message);
249 case IpcMessageTypeCommand:
250 if (m_callBackTable.end() != m_callBackTable.find(name))
252 LOG_DEBUG("GenericCommunicator", "received: " << name << " from "
253 << m_executor->getSenderName(senderHandle)
254 << "(" << m_executor->getSenderPid(senderHandle) << ")");
255 CallBackMethod method = m_callBackTable[name].function;
256 (this->*method)(message);
260 LOG_WARNING("GenericCommunicator", "Received unknown command " << name
261 << " from " << m_executor->getSenderName(senderHandle)
262 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
264 processNotificationQueue();
267 case IpcMessageTypeConnect:
268 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
269 << "(pid " << m_executor->getSenderPid(senderHandle) << ") connected");
272 case IpcMessageTypeDisconnect:
273 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
274 << "(pid " << m_executor->getSenderPid(senderHandle) << ") disconnected");
276 const LayerMap& layers = m_executor->getScene()->getAllLayers();
277 LayerMapConstIterator layerIter = layers.begin();
278 LayerMapConstIterator layerIterEnd = layers.end();
279 for (; layerIter != layerIterEnd; ++layerIter)
281 Layer* layer = layerIter->second;
282 layer->removeNotification(senderHandle);
285 const SurfaceMap& surfaces = m_executor->getScene()->getAllSurfaces();
286 SurfaceMapConstIterator surfaceIter = surfaces.begin();
287 SurfaceMapConstIterator surfaceIterEnd = surfaces.end();
288 for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
290 Surface* surface = surfaceIter->second;
291 surface->removeNotification(senderHandle);
296 case IpcMessageTypeError:
297 LOG_DEBUG("GenericCommunicator", "Received error message " << name << " from "
298 << m_executor->getSenderName(senderHandle)
299 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
302 case IpcMessageTypeShutdown:
303 case IpcMessageTypeNone:
307 LOG_DEBUG("GenericCommunicator", "Received unknown data from "
308 << m_executor->getSenderName(senderHandle)
309 << "(pid " << m_executor->getSenderPid(senderHandle) << "), Message type: " << messageType);
312 m_ipcModule.destroyMessage(message);
315 void GenericCommunicator::setdebug(bool onoff)
317 (void)onoff; // TODO: remove, only prevents warning
320 t_ilm_bool GenericCommunicator::threadMainLoop()
326 t_ilm_const_string GenericCommunicator::pluginGetName() const
328 return "GenericCommunicator";
331 void GenericCommunicator::ServiceConnect(t_ilm_message message)
333 t_ilm_message response;
334 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
336 unsigned int processId = 0;
337 char processName[1024];
338 m_ipcModule.getUint(message, &processId);
339 m_ipcModule.getString(message, processName);
341 m_executor->addApplicationReference(clientHandle, new IApplicationReference(processName, processId));
343 LOG_DEBUG("GenericCommunicator", "ServiceConnect called from "
344 << m_executor->getSenderName(clientHandle)
345 << "(" << m_executor->getSenderPid(clientHandle) << ")");
347 response = m_ipcModule.createResponse(message);
348 m_ipcModule.sendToClients(response, &clientHandle, 1);
349 m_ipcModule.destroyMessage(response);
352 void GenericCommunicator::ServiceDisconnect(t_ilm_message message)
354 t_ilm_message response;
355 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
357 LOG_DEBUG("GenericCommunicator", "ServiceDisconnect called from "
358 << m_executor->getSenderName(clientHandle)
359 << "(" << m_executor->getSenderPid(clientHandle) << ")");
361 m_executor->removeApplicationReference(clientHandle);
363 response = m_ipcModule.createResponse(message);
364 m_ipcModule.sendToClients(response, &clientHandle, 1);
365 m_ipcModule.destroyMessage(response);
368 void GenericCommunicator::Debug(t_ilm_message message)
370 t_ilm_message response;
371 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
372 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
373 t_ilm_bool param = ILM_FALSE;
374 m_ipcModule.getBool(message, ¶m);
376 t_ilm_bool status = m_executor->execute(new DebugCommand(clientPid, param));
379 response = m_ipcModule.createResponse(message);
383 response = m_ipcModule.createErrorResponse(message);
384 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
387 m_ipcModule.sendToClients(response, &clientHandle, 1);
388 m_ipcModule.destroyMessage(response);
391 void GenericCommunicator::GetScreenResolution(t_ilm_message message)
393 t_ilm_message response;
394 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
396 m_ipcModule.getUint(message, &screenid);
397 uint* resolution = m_executor->getScreenResolution(screenid);
399 response = m_ipcModule.createResponse(message);
400 m_ipcModule.appendUint(response, resolution[0]);
401 m_ipcModule.appendUint(response, resolution[1]);
402 m_ipcModule.sendToClients(response, &clientHandle, 1);
403 m_ipcModule.destroyMessage(response);
406 void GenericCommunicator::GetNumberOfHardwareLayers(t_ilm_message message)
408 t_ilm_message response;
409 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
411 m_ipcModule.getUint(message, &screenid);
412 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid);
413 response = m_ipcModule.createResponse(message);
414 m_ipcModule.appendUint(response, numberOfHardwareLayers);
415 m_ipcModule.sendToClients(response, &clientHandle, 1);
416 m_ipcModule.destroyMessage(response);
419 void GenericCommunicator::GetScreenIDs(t_ilm_message message)
421 t_ilm_message response;
422 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
424 uint* IDs = m_executor->getScreenIDs(&length);
425 response = m_ipcModule.createResponse(message);
426 m_ipcModule.appendUintArray(response, IDs, length);
427 m_ipcModule.sendToClients(response, &clientHandle, 1);
428 m_ipcModule.destroyMessage(response);
431 void GenericCommunicator::ScreenShot(t_ilm_message message)
433 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
434 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
435 t_ilm_message response;
439 m_ipcModule.getUint(message, &screenid);
440 m_ipcModule.getString(message, filename);
442 t_ilm_bool status = m_executor->execute(new ScreenDumpCommand(clientPid, filename, screenid));
445 response = m_ipcModule.createResponse(message);
449 response = m_ipcModule.createErrorResponse(message);
450 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
453 m_ipcModule.sendToClients(response, &clientHandle, 1);
454 m_ipcModule.destroyMessage(response);
457 void GenericCommunicator::ScreenShotOfLayer(t_ilm_message message)
459 t_ilm_message response;
460 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
461 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
463 m_ipcModule.getString(message, filename);
465 m_ipcModule.getUint(message, &layerid);
467 t_ilm_bool status = m_executor->execute(new LayerDumpCommand(clientPid, filename, layerid));
470 response = m_ipcModule.createResponse(message);
474 response = m_ipcModule.createErrorResponse(message);
475 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
478 m_ipcModule.sendToClients(response, &clientHandle, 1);
479 m_ipcModule.destroyMessage(response);
482 void GenericCommunicator::ScreenShotOfSurface(t_ilm_message message)
484 t_ilm_message response;
485 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
486 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
488 m_ipcModule.getString(message, filename);
490 m_ipcModule.getUint(message, &id);
491 t_ilm_bool status = m_executor->execute(new SurfaceDumpCommand(clientPid, filename, id));
494 response = m_ipcModule.createResponse(message);
498 response = m_ipcModule.createErrorResponse(message);
499 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
502 m_ipcModule.sendToClients(response, &clientHandle, 1);
503 m_ipcModule.destroyMessage(response);
506 void GenericCommunicator::ListAllLayerIDS(t_ilm_message message)
508 t_ilm_message response;
509 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
512 m_executor->getScene()->lockScene();
513 m_executor->getScene()->getLayerIDs(&length, &array);
514 m_executor->getScene()->unlockScene();
515 response = m_ipcModule.createResponse(message);
516 m_ipcModule.appendUintArray(response, array, length);
517 m_ipcModule.sendToClients(response, &clientHandle, 1);
518 m_ipcModule.destroyMessage(response);
521 void GenericCommunicator::ListAllLayerIDsOnScreen(t_ilm_message message)
523 t_ilm_message response;
524 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
526 m_ipcModule.getUint(message, &screenID);
530 m_executor->getScene()->lockScene();
531 t_ilm_bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
532 m_executor->getScene()->unlockScene();
535 response = m_ipcModule.createResponse(message);
536 m_ipcModule.appendUintArray(response, array, length);
540 response = m_ipcModule.createErrorResponse(message);
541 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
544 m_ipcModule.sendToClients(response, &clientHandle, 1);
545 m_ipcModule.destroyMessage(response);
548 void GenericCommunicator::ListAllSurfaceIDS(t_ilm_message message)
550 t_ilm_message response;
551 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
554 m_executor->getScene()->lockScene();
555 m_executor->getScene()->getSurfaceIDs(&length, &array);
556 m_executor->getScene()->unlockScene();
557 response = m_ipcModule.createResponse(message);
558 m_ipcModule.appendUintArray(response, array, length);
559 m_ipcModule.sendToClients(response, &clientHandle, 1);
560 m_ipcModule.destroyMessage(response);
563 void GenericCommunicator::ListSurfaceofLayer(t_ilm_message message)
565 t_ilm_message response;
566 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
568 m_ipcModule.getUint(message, &id);
569 m_executor->getScene()->lockScene();
570 Layer* layer = m_executor->getScene()->getLayer(id);
573 std::list<Surface*> surfaces = layer->getAllSurfaces();
575 uint length = surfaces.size();
576 uint* array = new uint[length];
579 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
582 array[arrayPos] = s->getID();
585 m_executor->getScene()->unlockScene();
587 response = m_ipcModule.createResponse(message);
588 m_ipcModule.appendUintArray(response, array, length);
592 m_executor->getScene()->unlockScene();
593 response = m_ipcModule.createErrorResponse(message);
594 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
597 m_ipcModule.sendToClients(response, &clientHandle, 1);
598 m_ipcModule.destroyMessage(response);
601 void GenericCommunicator::GetPropertiesOfSurface(t_ilm_message message)
603 t_ilm_message response;
604 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
606 m_ipcModule.getUint(message, &id);
608 Surface* surface = m_executor->getScene()->getSurface(id);
611 Rectangle dest = surface->getDestinationRegion();
612 Rectangle src = surface->getSourceRegion();
613 OrientationType orientation = surface->getOrientation();
614 unsigned char chromaKeyRed = 0;
615 unsigned char chromaKeyGreen = 0;
616 unsigned char chromaKeyBlue = 0;
617 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
619 response = m_ipcModule.createResponse(message);
620 m_ipcModule.appendDouble(response, surface->getOpacity());
621 m_ipcModule.appendUint(response, src.x);
622 m_ipcModule.appendUint(response, src.y);
623 m_ipcModule.appendUint(response, src.width);
624 m_ipcModule.appendUint(response, src.height);
625 m_ipcModule.appendUint(response, surface->OriginalSourceWidth);
626 m_ipcModule.appendUint(response, surface->OriginalSourceHeight);
627 m_ipcModule.appendUint(response, dest.x);
628 m_ipcModule.appendUint(response, dest.y);
629 m_ipcModule.appendUint(response, dest.width);
630 m_ipcModule.appendUint(response, dest.height);
631 m_ipcModule.appendUint(response, orientation);
632 m_ipcModule.appendBool(response, surface->getVisibility());
633 m_ipcModule.appendUint(response, surface->frameCounter);
634 m_ipcModule.appendUint(response, surface->drawCounter);
635 m_ipcModule.appendUint(response, surface->updateCounter);
636 m_ipcModule.appendUint(response, surface->getPixelFormat());
637 m_ipcModule.appendUint(response, surface->getNativeContent());
638 m_ipcModule.appendUint(response, surface->getInputEventAcceptanceOnDevices());
639 m_ipcModule.appendBool(response, surface->getChromaKeyEnabled());
640 m_ipcModule.appendUint(response, chromaKeyRed);
641 m_ipcModule.appendUint(response, chromaKeyGreen);
642 m_ipcModule.appendUint(response, chromaKeyBlue);
643 m_ipcModule.appendInt(response, surface->getCreatorPid());
647 response = m_ipcModule.createErrorResponse(message);
648 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
651 m_ipcModule.sendToClients(response, &clientHandle, 1);
652 m_ipcModule.destroyMessage(response);
655 void GenericCommunicator::GetPropertiesOfLayer(t_ilm_message message)
657 t_ilm_message response;
658 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
660 m_ipcModule.getUint(message, &id);
662 Layer* layer = m_executor->getScene()->getLayer(id);
665 Rectangle dest = layer->getDestinationRegion();
666 Rectangle src = layer->getSourceRegion();
667 OrientationType orientation = layer->getOrientation();
668 unsigned char chromaKeyRed = 0;
669 unsigned char chromaKeyGreen = 0;
670 unsigned char chromaKeyBlue = 0;
671 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
673 response = m_ipcModule.createResponse(message);
674 m_ipcModule.appendDouble(response, layer->getOpacity());
675 m_ipcModule.appendUint(response, src.x);
676 m_ipcModule.appendUint(response, src.y);
677 m_ipcModule.appendUint(response, src.width);
678 m_ipcModule.appendUint(response, src.height);
679 m_ipcModule.appendUint(response, layer->OriginalSourceWidth);
680 m_ipcModule.appendUint(response, layer->OriginalSourceHeight);
681 m_ipcModule.appendUint(response, dest.x);
682 m_ipcModule.appendUint(response, dest.y);
683 m_ipcModule.appendUint(response, dest.width);
684 m_ipcModule.appendUint(response, dest.height);
685 m_ipcModule.appendUint(response, orientation);
686 m_ipcModule.appendBool(response, layer->getVisibility());
687 m_ipcModule.appendUint(response, layer->getLayerType());
688 m_ipcModule.appendBool(response, layer->getChromaKeyEnabled());
689 m_ipcModule.appendUint(response, chromaKeyRed);
690 m_ipcModule.appendUint(response, chromaKeyGreen);
691 m_ipcModule.appendUint(response, chromaKeyBlue);
692 m_ipcModule.appendInt(response, layer->getCreatorPid());
696 response = m_ipcModule.createErrorResponse(message);
697 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
700 m_ipcModule.sendToClients(response, &clientHandle, 1);
701 m_ipcModule.destroyMessage(response);
704 void GenericCommunicator::CreateSurface(t_ilm_message message)
706 t_ilm_message response;
707 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
708 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
712 uint pixelformat = 0;
713 PixelFormat pf = PIXELFORMAT_UNKNOWN;
714 uint id = GraphicalObject::INVALID_ID;
716 m_ipcModule.getUint(message, &handle);
717 m_ipcModule.getUint(message, &width);
718 m_ipcModule.getUint(message, &height);
719 m_ipcModule.getUint(message, &pixelformat);
721 pf = (PixelFormat) pixelformat;
723 // First of all create the surface
724 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
726 // after that apply the native content
727 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
731 response = m_ipcModule.createResponse(message);
732 m_ipcModule.appendUint(response, id);
736 response = m_ipcModule.createErrorResponse(message);
737 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
740 m_ipcModule.sendToClients(response, &clientHandle, 1);
741 m_ipcModule.destroyMessage(response);
744 void GenericCommunicator::CreateSurfaceFromId(t_ilm_message message)
746 t_ilm_message response;
747 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
748 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
752 uint pixelformat = 0;
753 PixelFormat pf = PIXELFORMAT_UNKNOWN;
756 m_ipcModule.getUint(message, &handle);
757 m_ipcModule.getUint(message, &width);
758 m_ipcModule.getUint(message, &height);
759 m_ipcModule.getUint(message, &pixelformat);
760 m_ipcModule.getUint(message, &id);
762 pf = (PixelFormat) pixelformat;
764 // First of all create the surface
765 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
767 // after that apply the native content
768 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
772 response = m_ipcModule.createResponse(message);
773 m_ipcModule.appendUint(response, id);
777 response = m_ipcModule.createErrorResponse(message);
778 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
781 m_ipcModule.sendToClients(response, &clientHandle, 1);
782 m_ipcModule.destroyMessage(response);
785 void GenericCommunicator::InitializeSurface(t_ilm_message message)
787 t_ilm_message response;
788 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
789 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
790 uint id = GraphicalObject::INVALID_ID;
792 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
795 response = m_ipcModule.createResponse(message);
796 m_ipcModule.appendUint(response, id);
800 response = m_ipcModule.createErrorResponse(message);
801 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
804 m_ipcModule.sendToClients(response, &clientHandle, 1);
805 m_ipcModule.destroyMessage(response);
808 void GenericCommunicator::InitializeSurfaceFromId(t_ilm_message message)
810 t_ilm_message response;
811 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
812 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
814 m_ipcModule.getUint(message, &id);
815 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
818 response = m_ipcModule.createResponse(message);
819 m_ipcModule.appendUint(response, id);
823 response = m_ipcModule.createErrorResponse(message);
824 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
827 m_ipcModule.sendToClients(response, &clientHandle, 1);
828 m_ipcModule.destroyMessage(response);
831 void GenericCommunicator::SetSurfaceNativeContent(t_ilm_message message)
833 t_ilm_message response;
834 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
835 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
840 uint pixelformat = 0;
841 PixelFormat pf = PIXELFORMAT_UNKNOWN;
843 m_ipcModule.getUint(message, &id);
844 m_ipcModule.getUint(message, &handle);
845 m_ipcModule.getUint(message, &width);
846 m_ipcModule.getUint(message, &height);
847 m_ipcModule.getUint(message, &pixelformat);
849 pf = (PixelFormat) pixelformat;
851 t_ilm_bool status = m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
854 response = m_ipcModule.createResponse(message);
858 response = m_ipcModule.createErrorResponse(message);
859 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
862 m_ipcModule.sendToClients(response, &clientHandle, 1);
863 m_ipcModule.destroyMessage(response);
866 void GenericCommunicator::RemoveSurfaceNativeContent(t_ilm_message message)
868 t_ilm_message response;
869 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
870 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
872 m_ipcModule.getUint(message, &id);
874 t_ilm_bool status = m_executor->execute(new SurfaceRemoveNativeContentCommand(clientPid, id));
877 response = m_ipcModule.createResponse(message);
881 response = m_ipcModule.createErrorResponse(message);
882 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
885 m_ipcModule.sendToClients(response, &clientHandle, 1);
886 m_ipcModule.destroyMessage(response);
889 void GenericCommunicator::RemoveSurface(t_ilm_message message)
891 t_ilm_message response;
892 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
893 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
895 m_ipcModule.getUint(message, ¶m);
896 t_ilm_bool status = m_executor->execute(new SurfaceRemoveCommand(clientPid, param));
899 response = m_ipcModule.createResponse(message);
903 response = m_ipcModule.createErrorResponse(message);
904 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
907 m_ipcModule.sendToClients(response, &clientHandle, 1);
908 m_ipcModule.destroyMessage(response);
911 void GenericCommunicator::CreateLayer(t_ilm_message message)
913 t_ilm_message response;
914 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
915 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
916 uint id = GraphicalObject::INVALID_ID;
917 // use resolution of default screen as default width and height of layers
918 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
919 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
922 response = m_ipcModule.createResponse(message);
923 m_ipcModule.appendUint(response, id);
927 response = m_ipcModule.createErrorResponse(message);
928 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
931 m_ipcModule.sendToClients(response, &clientHandle, 1);
932 m_ipcModule.destroyMessage(response);
935 void GenericCommunicator::CreateLayerFromId(t_ilm_message message)
937 t_ilm_message response;
938 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
939 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
940 uint id = GraphicalObject::INVALID_ID;
942 m_ipcModule.getUint(message, &id);
943 // use resolution of default screen as default width and height of layers
944 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
945 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
948 response = m_ipcModule.createResponse(message);
949 m_ipcModule.appendUint(response, id);
953 response = m_ipcModule.createErrorResponse(message);
954 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
957 m_ipcModule.sendToClients(response, &clientHandle, 1);
958 m_ipcModule.destroyMessage(response);
962 void GenericCommunicator::CreateLayerWithDimension(t_ilm_message message)
964 t_ilm_message response;
965 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
966 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
968 m_ipcModule.getUint(message, &width);
970 m_ipcModule.getUint(message, &height);
972 uint id = GraphicalObject::INVALID_ID;
973 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
976 response = m_ipcModule.createResponse(message);
977 m_ipcModule.appendUint(response, id);
981 response = m_ipcModule.createErrorResponse(message);
982 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
985 m_ipcModule.sendToClients(response, &clientHandle, 1);
986 m_ipcModule.destroyMessage(response);
989 void GenericCommunicator::CreateLayerFromIdWithDimension(t_ilm_message message)
991 t_ilm_message response;
992 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
993 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
994 uint id = GraphicalObject::INVALID_ID;
997 t_ilm_bool status = ILM_FALSE;
999 m_ipcModule.getUint(message, &id);
1000 m_ipcModule.getUint(message, &width);
1001 m_ipcModule.getUint(message, &height);
1003 status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
1006 response = m_ipcModule.createResponse(message);
1007 m_ipcModule.appendUint(response, id);
1011 response = m_ipcModule.createErrorResponse(message);
1012 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
1015 m_ipcModule.sendToClients(response, &clientHandle, 1);
1016 m_ipcModule.destroyMessage(response);
1019 void GenericCommunicator::RemoveLayer(t_ilm_message message)
1021 t_ilm_message response;
1022 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1023 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1025 m_ipcModule.getUint(message, ¶m);
1026 t_ilm_bool status = m_executor->execute(new LayerRemoveCommand(clientPid, param));
1029 response = m_ipcModule.createResponse(message);
1033 response = m_ipcModule.createErrorResponse(message);
1034 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1037 m_ipcModule.sendToClients(response, &clientHandle, 1);
1038 m_ipcModule.destroyMessage(response);
1041 void GenericCommunicator::AddSurfaceToLayer(t_ilm_message message)
1043 t_ilm_message response;
1044 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1045 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1049 m_ipcModule.getUint(message, &surfaceid);
1050 m_ipcModule.getUint(message, &layer);
1052 t_ilm_bool status = m_executor->execute(new LayerAddSurfaceCommand(clientPid, layer, surfaceid));
1055 response = m_ipcModule.createResponse(message);
1059 response = m_ipcModule.createErrorResponse(message);
1060 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_ALREADY_INUSE);
1063 m_ipcModule.sendToClients(response, &clientHandle, 1);
1064 m_ipcModule.destroyMessage(response);
1067 void GenericCommunicator::RemoveSurfaceFromLayer(t_ilm_message message)
1069 t_ilm_message response;
1070 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1071 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1074 m_ipcModule.getUint(message, &surfaceid);
1075 m_ipcModule.getUint(message, &layerid);
1077 t_ilm_bool status = m_executor->execute(new LayerRemoveSurfaceCommand(clientPid, layerid, surfaceid));
1080 response = m_ipcModule.createResponse(message);
1084 response = m_ipcModule.createErrorResponse(message);
1085 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1088 m_ipcModule.sendToClients(response, &clientHandle, 1);
1089 m_ipcModule.destroyMessage(response);
1092 void GenericCommunicator::SetSurfaceSourceRegion(t_ilm_message message)
1094 t_ilm_message response;
1095 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1096 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1103 m_ipcModule.getUint(message, &id);
1104 m_ipcModule.getUint(message, &x);
1105 m_ipcModule.getUint(message, &y);
1106 m_ipcModule.getUint(message, &width);
1107 m_ipcModule.getUint(message, &height);
1109 t_ilm_bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1112 response = m_ipcModule.createResponse(message);
1116 response = m_ipcModule.createErrorResponse(message);
1117 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1120 m_ipcModule.sendToClients(response, &clientHandle, 1);
1121 m_ipcModule.destroyMessage(response);
1124 void GenericCommunicator::SetLayerSourceRegion(t_ilm_message message)
1126 t_ilm_message response;
1127 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1128 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1135 m_ipcModule.getUint(message, &id);
1136 m_ipcModule.getUint(message, &x);
1137 m_ipcModule.getUint(message, &y);
1138 m_ipcModule.getUint(message, &width);
1139 m_ipcModule.getUint(message, &height);
1141 t_ilm_bool status = m_executor->execute(new LayerSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1144 response = m_ipcModule.createResponse(message);
1148 response = m_ipcModule.createErrorResponse(message);
1149 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1152 m_ipcModule.sendToClients(response, &clientHandle, 1);
1153 m_ipcModule.destroyMessage(response);
1156 void GenericCommunicator::SetSurfaceDestinationRegion(t_ilm_message message)
1158 t_ilm_message response;
1159 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1160 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1167 m_ipcModule.getUint(message, &id);
1168 m_ipcModule.getUint(message, &x);
1169 m_ipcModule.getUint(message, &y);
1170 m_ipcModule.getUint(message, &width);
1171 m_ipcModule.getUint(message, &height);
1173 t_ilm_bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1176 response = m_ipcModule.createResponse(message);
1180 response = m_ipcModule.createErrorResponse(message);
1181 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1184 m_ipcModule.sendToClients(response, &clientHandle, 1);
1185 m_ipcModule.destroyMessage(response);
1188 void GenericCommunicator::SetSurfacePosition(t_ilm_message message)
1190 t_ilm_message response;
1191 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1192 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1197 m_ipcModule.getUint(message, &id);
1198 m_ipcModule.getUint(message, &x);
1199 m_ipcModule.getUint(message, &y);
1201 t_ilm_bool status = m_executor->execute(new SurfaceSetPositionCommand(clientPid, id, x, y));
1204 response = m_ipcModule.createResponse(message);
1208 response = m_ipcModule.createErrorResponse(message);
1209 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1212 m_ipcModule.sendToClients(response, &clientHandle, 1);
1213 m_ipcModule.destroyMessage(response);
1216 void GenericCommunicator::GetSurfacePosition(t_ilm_message message)
1218 t_ilm_message response;
1219 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1220 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1225 m_ipcModule.getUint(message, &id);
1227 t_ilm_bool status = m_executor->execute(new SurfaceGetPositionCommand(clientPid, id, &x, &y));
1230 response = m_ipcModule.createResponse(message);
1231 m_ipcModule.appendUint(response, x);
1232 m_ipcModule.appendUint(response, y);
1236 response = m_ipcModule.createErrorResponse(message);
1237 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1240 m_ipcModule.sendToClients(response, &clientHandle, 1);
1241 m_ipcModule.destroyMessage(response);
1244 void GenericCommunicator::SetSurfaceDimension(t_ilm_message message)
1246 t_ilm_message response;
1247 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1248 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1253 m_ipcModule.getUint(message, &id);
1254 m_ipcModule.getUint(message, &width);
1255 m_ipcModule.getUint(message, &height);
1257 t_ilm_bool status = m_executor->execute(new SurfaceSetDimensionCommand(clientPid, id, width, height));
1260 response = m_ipcModule.createResponse(message);
1264 response = m_ipcModule.createErrorResponse(message);
1265 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1268 m_ipcModule.sendToClients(response, &clientHandle, 1);
1269 m_ipcModule.destroyMessage(response);
1272 void GenericCommunicator::SetLayerDestinationRegion(t_ilm_message message)
1274 t_ilm_message response;
1275 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1276 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1283 m_ipcModule.getUint(message, &id);
1284 m_ipcModule.getUint(message, &x);
1285 m_ipcModule.getUint(message, &y);
1286 m_ipcModule.getUint(message, &width);
1287 m_ipcModule.getUint(message, &height);
1289 t_ilm_bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1292 response = m_ipcModule.createResponse(message);
1296 response = m_ipcModule.createErrorResponse(message);
1297 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1300 m_ipcModule.sendToClients(response, &clientHandle, 1);
1301 m_ipcModule.destroyMessage(response);
1304 void GenericCommunicator::SetLayerPosition(t_ilm_message message)
1306 t_ilm_message response;
1307 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1308 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1313 m_ipcModule.getUint(message, &id);
1314 m_ipcModule.getUint(message, &x);
1315 m_ipcModule.getUint(message, &y);
1317 t_ilm_bool status = m_executor->execute(new LayerSetPositionCommand(clientPid, id, x, y));
1320 response = m_ipcModule.createResponse(message);
1324 response = m_ipcModule.createErrorResponse(message);
1325 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1328 m_ipcModule.sendToClients(response, &clientHandle, 1);
1329 m_ipcModule.destroyMessage(response);
1332 void GenericCommunicator::GetLayerPosition(t_ilm_message message)
1334 t_ilm_message response;
1335 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1336 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1341 m_ipcModule.getUint(message, &id);
1343 t_ilm_bool status = m_executor->execute(new LayerGetPositionCommand(clientPid, id, &x, &y));
1346 response = m_ipcModule.createResponse(message);
1347 m_ipcModule.appendUint(response, x);
1348 m_ipcModule.appendUint(response, y);
1352 response = m_ipcModule.createErrorResponse(message);
1353 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1356 m_ipcModule.sendToClients(response, &clientHandle, 1);
1357 m_ipcModule.destroyMessage(response);
1360 void GenericCommunicator::SetLayerDimension(t_ilm_message message)
1362 t_ilm_message response;
1363 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1364 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1369 m_ipcModule.getUint(message, &id);
1370 m_ipcModule.getUint(message, &width);
1371 m_ipcModule.getUint(message, &height);
1373 t_ilm_bool status = m_executor->execute(new LayerSetDimensionCommand(clientPid, id, width, height));
1376 response = m_ipcModule.createResponse(message);
1380 response = m_ipcModule.createErrorResponse(message);
1381 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1384 m_ipcModule.sendToClients(response, &clientHandle, 1);
1385 m_ipcModule.destroyMessage(response);
1388 void GenericCommunicator::GetLayerDimension(t_ilm_message message)
1390 t_ilm_message response;
1391 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1392 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1397 m_ipcModule.getUint(message, &id);
1399 t_ilm_bool status = m_executor->execute(new LayerGetDimensionCommand(clientPid, id, &width, &height));
1402 response = m_ipcModule.createResponse(message);
1403 m_ipcModule.appendUint(response, width);
1404 m_ipcModule.appendUint(response, height);
1408 response = m_ipcModule.createErrorResponse(message);
1409 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1412 m_ipcModule.sendToClients(response, &clientHandle, 1);
1413 m_ipcModule.destroyMessage(response);
1416 void GenericCommunicator::GetSurfaceDimension(t_ilm_message message)
1418 t_ilm_message response;
1419 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1420 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1425 m_ipcModule.getUint(message, &id);
1427 t_ilm_bool status = m_executor->execute(new SurfaceGetDimensionCommand(clientPid, id, &width, &height));
1430 response = m_ipcModule.createResponse(message);
1431 m_ipcModule.appendUint(response, width);
1432 m_ipcModule.appendUint(response, height);
1436 response = m_ipcModule.createErrorResponse(message);
1437 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1440 m_ipcModule.sendToClients(response, &clientHandle, 1);
1441 m_ipcModule.destroyMessage(response);
1444 void GenericCommunicator::SetSurfaceOpacity(t_ilm_message message)
1446 t_ilm_message response;
1447 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1448 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1452 m_ipcModule.getUint(message, &id);
1453 m_ipcModule.getDouble(message, ¶m);
1455 t_ilm_bool status = m_executor->execute(new SurfaceSetOpacityCommand(clientPid, id, param));
1458 response = m_ipcModule.createResponse(message);
1462 response = m_ipcModule.createErrorResponse(message);
1463 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1466 m_ipcModule.sendToClients(response, &clientHandle, 1);
1467 m_ipcModule.destroyMessage(response);
1470 void GenericCommunicator::SetLayerOpacity(t_ilm_message message)
1472 t_ilm_message response;
1473 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1474 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1478 m_ipcModule.getUint(message, &id);
1479 m_ipcModule.getDouble(message, ¶m);
1481 t_ilm_bool status = m_executor->execute(new LayerSetOpacityCommand(clientPid, id, param));
1484 response = m_ipcModule.createResponse(message);
1488 response = m_ipcModule.createErrorResponse(message);
1489 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1492 m_ipcModule.sendToClients(response, &clientHandle, 1);
1493 m_ipcModule.destroyMessage(response);
1496 void GenericCommunicator::GetSurfaceOpacity(t_ilm_message message)
1498 t_ilm_message response;
1499 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1500 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1504 m_ipcModule.getUint(message, &id);
1506 t_ilm_bool status = m_executor->execute(new SurfaceGetOpacityCommand(clientPid, id, ¶m));
1509 response = m_ipcModule.createResponse(message);
1510 m_ipcModule.appendDouble(response, param);
1514 response = m_ipcModule.createErrorResponse(message);
1515 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1518 m_ipcModule.sendToClients(response, &clientHandle, 1);
1519 m_ipcModule.destroyMessage(response);
1522 void GenericCommunicator::GetLayerOpacity(t_ilm_message message)
1524 t_ilm_message response;
1525 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1526 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1530 m_ipcModule.getUint(message, &id);
1532 t_ilm_bool status = m_executor->execute(new LayerGetOpacityCommand(clientPid, id, ¶m));
1535 response = m_ipcModule.createResponse(message);
1536 m_ipcModule.appendDouble(response, param);
1540 response = m_ipcModule.createErrorResponse(message);
1541 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1544 m_ipcModule.sendToClients(response, &clientHandle, 1);
1545 m_ipcModule.destroyMessage(response);
1548 void GenericCommunicator::SetSurfaceOrientation(t_ilm_message message)
1550 t_ilm_message response;
1551 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1552 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1555 OrientationType o = Zero;
1557 m_ipcModule.getUint(message, &id);
1558 m_ipcModule.getUint(message, ¶m);
1560 o = (OrientationType) param;
1562 t_ilm_bool status = m_executor->execute(new SurfaceSetOrientationCommand(clientPid, id, o));
1565 response = m_ipcModule.createResponse(message);
1569 response = m_ipcModule.createErrorResponse(message);
1570 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1573 m_ipcModule.sendToClients(response, &clientHandle, 1);
1574 m_ipcModule.destroyMessage(response);
1577 void GenericCommunicator::GetSurfaceOrientation(t_ilm_message message)
1579 t_ilm_message response;
1580 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1581 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1585 m_ipcModule.getUint(message, &id);
1587 t_ilm_bool status = m_executor->execute(new SurfaceGetOrientationCommand(clientPid, id, &o));
1590 response = m_ipcModule.createResponse(message);
1591 m_ipcModule.appendUint(response, o);
1595 response = m_ipcModule.createErrorResponse(message);
1596 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1599 m_ipcModule.sendToClients(response, &clientHandle, 1);
1600 m_ipcModule.destroyMessage(response);
1603 void GenericCommunicator::SetLayerOrientation(t_ilm_message message)
1605 t_ilm_message response;
1606 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1607 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1610 OrientationType o = Zero;
1612 m_ipcModule.getUint(message, &id);
1613 m_ipcModule.getUint(message, ¶m);
1615 o = (OrientationType) param;
1617 t_ilm_bool status = m_executor->execute(new LayerSetOrientationCommand(clientPid, id, o));
1620 response = m_ipcModule.createResponse(message);
1624 response = m_ipcModule.createErrorResponse(message);
1625 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1628 m_ipcModule.sendToClients(response, &clientHandle, 1);
1629 m_ipcModule.destroyMessage(response);
1632 void GenericCommunicator::GetLayerOrientation(t_ilm_message message)
1634 t_ilm_message response;
1635 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1636 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1640 m_ipcModule.getUint(message, &id);
1642 t_ilm_bool status = m_executor->execute(new LayerGetOrientationCommand(clientPid, id, &o));
1645 response = m_ipcModule.createResponse(message);
1646 m_ipcModule.appendUint(response, o);
1650 response = m_ipcModule.createErrorResponse(message);
1651 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1654 m_ipcModule.sendToClients(response, &clientHandle, 1);
1655 m_ipcModule.destroyMessage(response);
1658 void GenericCommunicator::GetSurfacePixelformat(t_ilm_message message)
1660 t_ilm_message response;
1661 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1662 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1664 PixelFormat pixelFormat;
1666 m_ipcModule.getUint(message, &id);
1668 t_ilm_bool status = m_executor->execute(new SurfaceGetPixelformatCommand(clientPid, id, &pixelFormat));
1671 response = m_ipcModule.createResponse(message);
1672 m_ipcModule.appendUint(response, pixelFormat);
1676 response = m_ipcModule.createErrorResponse(message);
1677 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1680 m_ipcModule.sendToClients(response, &clientHandle, 1);
1681 m_ipcModule.destroyMessage(response);
1684 void GenericCommunicator::SetSurfaceVisibility(t_ilm_message message)
1686 t_ilm_message response;
1687 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1688 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1690 t_ilm_bool newVis = ILM_FALSE;
1692 m_ipcModule.getUint(message, &surfaceid);
1693 m_ipcModule.getBool(message, &newVis);
1695 t_ilm_bool status = m_executor->execute(new SurfaceSetVisibilityCommand(clientPid, surfaceid, newVis));
1698 response = m_ipcModule.createResponse(message);
1702 response = m_ipcModule.createErrorResponse(message);
1703 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1706 m_ipcModule.sendToClients(response, &clientHandle, 1);
1707 m_ipcModule.destroyMessage(response);
1710 void GenericCommunicator::SetLayerVisibility(t_ilm_message message)
1712 t_ilm_message response;
1713 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1714 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1716 t_ilm_bool myparam = ILM_FALSE;
1718 m_ipcModule.getUint(message, &layerid);
1719 m_ipcModule.getBool(message, &myparam);
1721 t_ilm_bool status = m_executor->execute(new LayerSetVisibilityCommand(clientPid, layerid, myparam));
1724 response = m_ipcModule.createResponse(message);
1728 response = m_ipcModule.createErrorResponse(message);
1729 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1732 m_ipcModule.sendToClients(response, &clientHandle, 1);
1733 m_ipcModule.destroyMessage(response);
1736 void GenericCommunicator::GetSurfaceVisibility(t_ilm_message message)
1738 t_ilm_message response;
1739 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1740 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1744 m_ipcModule.getUint(message, &id);
1746 t_ilm_bool status = m_executor->execute(new SurfaceGetVisibilityCommand(clientPid, id, &visibility));
1749 response = m_ipcModule.createResponse(message);
1750 m_ipcModule.appendBool(response, visibility);
1754 response = m_ipcModule.createErrorResponse(message);
1755 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1758 m_ipcModule.sendToClients(response, &clientHandle, 1);
1759 m_ipcModule.destroyMessage(response);
1762 void GenericCommunicator::GetLayerVisibility(t_ilm_message message)
1764 t_ilm_message response;
1765 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1766 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1770 m_ipcModule.getUint(message, &id);
1772 t_ilm_bool status = m_executor->execute(new LayerGetVisibilityCommand(clientPid, id, &visibility));
1775 response = m_ipcModule.createResponse(message);
1776 m_ipcModule.appendBool(response, visibility);
1780 response = m_ipcModule.createErrorResponse(message);
1781 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1784 m_ipcModule.sendToClients(response, &clientHandle, 1);
1785 m_ipcModule.destroyMessage(response);
1788 void GenericCommunicator::SetRenderOrderOfLayers(t_ilm_message message)
1790 t_ilm_message response;
1791 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1792 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1797 m_ipcModule.getUintArray(message, &array, &length);
1798 m_ipcModule.getUint(message, &screenID);
1800 t_ilm_bool status = m_executor->execute(new ScreenSetRenderOrderCommand(clientPid, screenID, array, length));
1803 response = m_ipcModule.createResponse(message);
1807 response = m_ipcModule.createErrorResponse(message);
1808 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1811 m_ipcModule.sendToClients(response, &clientHandle, 1);
1812 m_ipcModule.destroyMessage(response);
1815 void GenericCommunicator::SetSurfaceRenderOrderWithinLayer(t_ilm_message message)
1817 t_ilm_message response;
1818 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1819 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1824 m_ipcModule.getUint(message, &layerid);
1825 m_ipcModule.getUintArray(message, &array, &length);
1827 t_ilm_bool status = m_executor->execute(new LayerSetRenderOrderCommand(clientPid, layerid, array, length));
1830 response = m_ipcModule.createResponse(message);
1834 response = m_ipcModule.createErrorResponse(message);
1835 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1838 m_ipcModule.sendToClients(response, &clientHandle, 1);
1839 m_ipcModule.destroyMessage(response);
1842 void GenericCommunicator::GetLayerType(t_ilm_message message)
1844 t_ilm_message response;
1845 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1847 m_ipcModule.getUint(message, &id);
1849 Layer* layer = m_executor->getScene()->getLayer(id);
1852 response = m_ipcModule.createResponse(message);
1853 m_ipcModule.appendUint(response, layer->getLayerType());
1857 response = m_ipcModule.createErrorResponse(message);
1858 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1861 m_ipcModule.sendToClients(response, &clientHandle, 1);
1862 m_ipcModule.destroyMessage(response);
1865 void GenericCommunicator::GetLayertypeCapabilities(t_ilm_message message)
1867 t_ilm_message response;
1868 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1870 LayerType type = Unknown;
1872 m_ipcModule.getUint(message, &id);
1874 type = (LayerType) id;
1876 uint capabilities = m_executor->getLayerTypeCapabilities(type);
1877 response = m_ipcModule.createResponse(message);
1878 m_ipcModule.appendUint(response, capabilities);
1879 m_ipcModule.sendToClients(response, &clientHandle, 1);
1880 m_ipcModule.destroyMessage(response);
1883 void GenericCommunicator::GetLayerCapabilities(t_ilm_message message)
1885 t_ilm_message response;
1886 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1888 m_ipcModule.getUint(message, &id);
1890 Layer* layer = m_executor->getScene()->getLayer(id);
1893 response = m_ipcModule.createResponse(message);
1894 m_ipcModule.appendUint(response, layer->getCapabilities());
1898 response = m_ipcModule.createErrorResponse(message);
1899 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
1902 m_ipcModule.sendToClients(response, &clientHandle, 1);
1903 m_ipcModule.destroyMessage(response);
1906 void GenericCommunicator::FadeIn(t_ilm_message message)
1908 t_ilm_message response;
1909 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1910 response = m_ipcModule.createErrorResponse(message);
1911 m_ipcModule.appendUint(response, ILM_ERROR_NOT_IMPLEMENTED);
1912 m_ipcModule.sendToClients(response, &clientHandle, 1);
1913 m_ipcModule.destroyMessage(response);
1916 void GenericCommunicator::SynchronizedFade(t_ilm_message message)
1918 t_ilm_message response;
1919 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1920 response = m_ipcModule.createErrorResponse(message);
1921 m_ipcModule.appendUint(response, ILM_ERROR_NOT_IMPLEMENTED);
1922 m_ipcModule.sendToClients(response, &clientHandle, 1);
1923 m_ipcModule.destroyMessage(response);
1926 void GenericCommunicator::FadeOut(t_ilm_message message)
1928 t_ilm_message response;
1929 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1930 response = m_ipcModule.createErrorResponse(message);
1931 m_ipcModule.appendUint(response, ILM_ERROR_NOT_IMPLEMENTED);
1932 m_ipcModule.sendToClients(response, &clientHandle, 1);
1933 m_ipcModule.destroyMessage(response);
1936 void GenericCommunicator::Exit(t_ilm_message message)
1938 t_ilm_message response;
1939 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1940 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1941 t_ilm_bool status = m_executor->execute(new ExitCommand(clientPid));
1944 response = m_ipcModule.createResponse(message);
1948 response = m_ipcModule.createErrorResponse(message);
1949 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
1952 m_ipcModule.sendToClients(response, &clientHandle, 1);
1953 m_ipcModule.destroyMessage(response);
1956 void GenericCommunicator::CommitChanges(t_ilm_message message)
1958 t_ilm_message response;
1959 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1960 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1961 t_ilm_bool status = m_executor->execute(new CommitCommand(clientPid));
1964 response = m_ipcModule.createResponse(message);
1968 response = m_ipcModule.createErrorResponse(message);
1969 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
1972 m_ipcModule.sendToClients(response, &clientHandle, 1);
1973 m_ipcModule.destroyMessage(response);
1976 void GenericCommunicator::CreateShader(t_ilm_message message)
1978 t_ilm_message response;
1979 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1980 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1981 char vertname[1024];
1982 char fragname[1024];
1985 m_ipcModule.getString(message, vertname);
1986 m_ipcModule.getString(message, fragname);
1988 t_ilm_bool status = m_executor->execute(new ShaderCreateCommand(clientPid, vertname, fragname, &id));
1991 response = m_ipcModule.createResponse(message);
1992 m_ipcModule.appendUint(response, id);
1996 response = m_ipcModule.createErrorResponse(message);
1997 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2000 m_ipcModule.sendToClients(response, &clientHandle, 1);
2001 m_ipcModule.destroyMessage(response);
2004 void GenericCommunicator::DestroyShader(t_ilm_message message)
2006 t_ilm_message response;
2007 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2008 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2011 m_ipcModule.getUint(message, &shaderid);
2013 t_ilm_bool status = m_executor->execute(new ShaderDestroyCommand(clientPid, shaderid));
2016 response = m_ipcModule.createResponse(message);
2020 response = m_ipcModule.createErrorResponse(message);
2021 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2024 m_ipcModule.sendToClients(response, &clientHandle, 1);
2025 m_ipcModule.destroyMessage(response);
2028 void GenericCommunicator::SetShader(t_ilm_message message)
2030 t_ilm_message response;
2031 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2032 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2036 m_ipcModule.getUint(message, &surfaceId);
2037 m_ipcModule.getUint(message, &shaderid);
2039 t_ilm_bool status = m_executor->execute(new SurfaceSetShaderCommand(clientPid, surfaceId, shaderid));
2042 response = m_ipcModule.createResponse(message);
2046 response = m_ipcModule.createErrorResponse(message);
2047 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2050 m_ipcModule.sendToClients(response, &clientHandle, 1);
2051 m_ipcModule.destroyMessage(response);
2054 void GenericCommunicator::SetUniforms(t_ilm_message message)
2056 t_ilm_message response;
2057 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2058 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2060 std::vector<string> uniforms;
2062 m_ipcModule.getUint(message, &id);
2065 //m_ipcModule.getStringArray(&uniforms);
2067 t_ilm_bool status = m_executor->execute(new ShaderSetUniformsCommand(clientPid, id, uniforms));
2070 response = m_ipcModule.createResponse(message);
2074 response = m_ipcModule.createErrorResponse(message);
2075 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2078 m_ipcModule.sendToClients(response, &clientHandle, 1);
2079 m_ipcModule.destroyMessage(response);
2082 void GenericCommunicator::SetKeyboardFocusOn(t_ilm_message message)
2084 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2085 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2086 t_ilm_message response;
2089 m_ipcModule.getUint(message, &surfaceId);
2091 t_ilm_bool status = m_executor->execute(new SurfaceSetKeyboardFocusCommand(clientPid, surfaceId));
2094 response = m_ipcModule.createResponse(message);
2098 response = m_ipcModule.createErrorResponse(message);
2099 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2102 m_ipcModule.sendToClients(response, &clientHandle, 1);
2103 m_ipcModule.destroyMessage(response);
2107 void GenericCommunicator::GetKeyboardFocusSurfaceId(t_ilm_message message)
2109 t_ilm_message response;
2110 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2111 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2114 t_ilm_bool status = m_executor->execute(new SurfaceGetKeyboardFocusCommand(clientPid, &surfaceId));
2117 response = m_ipcModule.createResponse(message);
2118 m_ipcModule.appendUint(response, surfaceId);
2122 response = m_ipcModule.createErrorResponse(message);
2123 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2126 m_ipcModule.sendToClients(response, &clientHandle, 1);
2127 m_ipcModule.destroyMessage(response);
2131 void GenericCommunicator::UpdateInputEventAcceptanceOn(t_ilm_message message)
2133 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2134 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2135 t_ilm_message response;
2138 InputDevice devices;
2141 m_ipcModule.getUint(message, &surfaceId);
2142 m_ipcModule.getUint(message, &udevices);
2143 m_ipcModule.getBool(message, &accept);
2145 devices = (InputDevice) udevices;
2147 t_ilm_bool status = m_executor->execute(new SurfaceUpdateInputEventAcceptance(clientPid, surfaceId, devices, accept));
2150 response = m_ipcModule.createResponse(message);
2154 response = m_ipcModule.createErrorResponse(message);
2155 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2158 m_ipcModule.sendToClients(response, &clientHandle, 1);
2159 m_ipcModule.destroyMessage(response);
2162 void GenericCommunicator::SetSurfaceChromaKey(t_ilm_message message)
2164 t_ilm_message response;
2165 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2166 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2171 m_ipcModule.getUint(message, &surfaceid);
2172 m_ipcModule.getUintArray(message, &array, &length);
2174 t_ilm_bool status = m_executor->execute(new SurfaceSetChromaKeyCommand(clientPid, surfaceid, array, length));
2177 response = m_ipcModule.createResponse(message);
2181 response = m_ipcModule.createErrorResponse(message);
2182 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2185 m_ipcModule.sendToClients(response, &clientHandle, 1);
2186 m_ipcModule.destroyMessage(response);
2189 void GenericCommunicator::SetLayerChromaKey(t_ilm_message message)
2191 t_ilm_message response;
2192 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2193 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2198 m_ipcModule.getUint(message, &layerid);
2199 m_ipcModule.getUintArray(message, &array, &length);
2201 t_ilm_bool status = m_executor->execute(new LayerSetChromaKeyCommand(clientPid, layerid, array, length));
2204 response = m_ipcModule.createResponse(message);
2208 response = m_ipcModule.createErrorResponse(message);
2209 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2212 m_ipcModule.sendToClients(response, &clientHandle, 1);
2213 m_ipcModule.destroyMessage(response);
2216 void GenericCommunicator::LayerAddNotification(t_ilm_message message)
2218 t_ilm_message response;
2219 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2222 m_ipcModule.getUint(message, &layerid);
2224 Layer* layer = m_executor->getScene()->getLayer(layerid);
2227 layer->addNotification(clientHandle);
2228 response = m_ipcModule.createResponse(message);
2232 response = m_ipcModule.createErrorResponse(message);
2233 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2236 m_ipcModule.sendToClients(response, &clientHandle, 1);
2237 m_ipcModule.destroyMessage(response);
2240 void GenericCommunicator::SurfaceAddNotification(t_ilm_message message)
2242 t_ilm_message response;
2243 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2246 m_ipcModule.getUint(message, &surfaceid);
2248 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2251 surface->addNotification(clientHandle);
2252 response = m_ipcModule.createResponse(message);
2256 response = m_ipcModule.createErrorResponse(message);
2257 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2260 m_ipcModule.sendToClients(response, &clientHandle, 1);
2261 m_ipcModule.destroyMessage(response);
2264 void GenericCommunicator::LayerRemoveNotification(t_ilm_message message)
2266 t_ilm_message response;
2267 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2270 m_ipcModule.getUint(message, &layerid);
2272 Layer* layer = m_executor->getScene()->getLayer(layerid);
2275 layer->removeNotification(clientHandle);
2276 response = m_ipcModule.createResponse(message);
2280 response = m_ipcModule.createErrorResponse(message);
2281 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2284 m_ipcModule.sendToClients(response, &clientHandle, 1);
2285 m_ipcModule.destroyMessage(response);
2288 void GenericCommunicator::SurfaceRemoveNotification(t_ilm_message message)
2290 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2291 t_ilm_message response;
2294 m_ipcModule.getUint(message, &surfaceid);
2296 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2299 surface->removeNotification(clientHandle);
2300 response = m_ipcModule.createResponse(message);
2304 response = m_ipcModule.createErrorResponse(message);
2305 m_ipcModule.appendUint(response, ILM_ERROR_INVALID_ARGUMENTS);
2308 m_ipcModule.sendToClients(response, &clientHandle, 1);
2309 m_ipcModule.destroyMessage(response);
2312 void GenericCommunicator::processNotificationQueue()
2314 NotificationQueue& notificationQueue = m_executor->getClientNotificationQueue();
2315 NotificationQueue::iterator iter = notificationQueue.begin();
2316 NotificationQueue::iterator end = notificationQueue.end();
2318 for (; iter != end; ++iter)
2320 GraphicalObject* object = iter->first;
2321 t_ilm_notification_mask mask = iter->second;
2322 sendNotification(object, mask);
2324 notificationQueue.clear();
2327 void GenericCommunicator::sendNotification(GraphicalObject* object, t_ilm_notification_mask mask)
2329 switch (object->type)
2333 Layer* layer = static_cast<Layer*>(object);
2336 ApplicationReferenceList& arl = layer->getNotificationClients();
2340 t_ilm_message notification;
2341 Rectangle dest = layer->getDestinationRegion();
2342 Rectangle src = layer->getSourceRegion();
2343 OrientationType orientation = layer->getOrientation();
2345 unsigned char chromaKeyRed = 0;
2346 unsigned char chromaKeyGreen = 0;
2347 unsigned char chromaKeyBlue = 0;
2348 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2350 std::stringstream notificationName;
2351 notificationName << "NotificationForLayer" << layer->getID();
2353 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2354 m_ipcModule.appendUint(notification, layer->getID());
2355 m_ipcModule.appendUint(notification, mask);
2357 m_ipcModule.appendDouble(notification, layer->getOpacity());
2358 m_ipcModule.appendUint(notification, src.x);
2359 m_ipcModule.appendUint(notification, src.y);
2360 m_ipcModule.appendUint(notification, src.width);
2361 m_ipcModule.appendUint(notification, src.height);
2362 m_ipcModule.appendUint(notification, layer->OriginalSourceWidth);
2363 m_ipcModule.appendUint(notification, layer->OriginalSourceHeight);
2364 m_ipcModule.appendUint(notification, dest.x);
2365 m_ipcModule.appendUint(notification, dest.y);
2366 m_ipcModule.appendUint(notification, dest.width);
2367 m_ipcModule.appendUint(notification, dest.height);
2368 m_ipcModule.appendUint(notification, orientation);
2369 m_ipcModule.appendBool(notification, layer->getVisibility());
2370 m_ipcModule.appendUint(notification, layer->getLayerType());
2371 m_ipcModule.appendBool(notification, layer->getChromaKeyEnabled());
2372 m_ipcModule.appendUint(notification, chromaKeyRed);
2373 m_ipcModule.appendUint(notification, chromaKeyGreen);
2374 m_ipcModule.appendUint(notification, chromaKeyBlue);
2375 m_ipcModule.appendInt(notification, layer->getCreatorPid());
2377 int clientCount = arl.size();
2378 t_ilm_client_handle clientArray[256];
2380 ApplicationReferenceList::iterator iter = arl.begin();
2381 ApplicationReferenceList::iterator end = arl.end();
2383 for (int clientNumber = 0;
2384 iter != end, clientNumber < 256;
2385 ++iter, ++clientNumber)
2387 t_ilm_client_handle client = *iter;
2388 clientArray[clientNumber] = client;
2391 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): layer " << layer->getID() << " was updated.");
2393 if (!m_ipcModule.sendToClients(notification, clientArray, clientCount))
2395 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2398 m_ipcModule.destroyMessage(notification);
2405 Surface* surface = static_cast<Surface*>(object);
2408 ApplicationReferenceList& arl = surface->getNotificationClients();
2412 t_ilm_message notification;
2413 std::stringstream notificationName;
2414 notificationName << "NotificationForSurface" << surface->getID();
2416 unsigned char chromaKeyRed = 0;
2417 unsigned char chromaKeyGreen = 0;
2418 unsigned char chromaKeyBlue = 0;
2419 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2421 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2422 m_ipcModule.appendUint(notification, surface->getID());
2423 m_ipcModule.appendUint(notification, mask);
2425 m_ipcModule.appendDouble(notification, surface->getOpacity());
2426 m_ipcModule.appendUint(notification, surface->getSourceRegion().x);
2427 m_ipcModule.appendUint(notification, surface->getSourceRegion().y);
2428 m_ipcModule.appendUint(notification, surface->getSourceRegion().width);
2429 m_ipcModule.appendUint(notification, surface->getSourceRegion().height);
2430 m_ipcModule.appendUint(notification, surface->OriginalSourceWidth);
2431 m_ipcModule.appendUint(notification, surface->OriginalSourceHeight);
2432 m_ipcModule.appendUint(notification, surface->getDestinationRegion().x);
2433 m_ipcModule.appendUint(notification, surface->getDestinationRegion().y);
2434 m_ipcModule.appendUint(notification, surface->getDestinationRegion().width);
2435 m_ipcModule.appendUint(notification, surface->getDestinationRegion().height);
2436 m_ipcModule.appendUint(notification, surface->getOrientation());
2437 m_ipcModule.appendBool(notification, surface->getVisibility());
2438 m_ipcModule.appendUint(notification, surface->frameCounter);
2439 m_ipcModule.appendUint(notification, surface->drawCounter);
2440 m_ipcModule.appendUint(notification, surface->updateCounter);
2441 m_ipcModule.appendUint(notification, surface->getPixelFormat());
2442 m_ipcModule.appendUint(notification, surface->getNativeContent());
2443 m_ipcModule.appendUint(notification, surface->getInputEventAcceptanceOnDevices());
2444 m_ipcModule.appendBool(notification, surface->getChromaKeyEnabled());
2445 m_ipcModule.appendUint(notification, chromaKeyRed);
2446 m_ipcModule.appendUint(notification, chromaKeyGreen);
2447 m_ipcModule.appendUint(notification, chromaKeyBlue);
2448 m_ipcModule.appendInt(notification, surface->getCreatorPid());
2450 int clientCount = arl.size();
2451 t_ilm_client_handle clients[256];
2453 ApplicationReferenceList::iterator iter = arl.begin();
2454 ApplicationReferenceList::iterator end = arl.end();
2456 for (int clientNumber = 0;
2457 iter != end, clientNumber < 256;
2458 ++iter, ++clientNumber)
2460 clients[clientNumber] = *iter;
2463 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): surface " << surface->getID() << " was updated.");
2465 if (!m_ipcModule.sendToClients(notification, clients, clientCount))
2467 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2470 m_ipcModule.destroyMessage(notification);
2476 LOG_INFO("GenericCommunicator", "Unknown notification found in queue.");
2481 HealthCondition GenericCommunicator::pluginGetHealth()
2483 HealthCondition health = PluginBase::pluginGetHealth();
2484 if (0 != pthread_kill(mThreadId, 0))
2486 health = HealthDead;
2491 void GenericCommunicator::SetOptimizationMode(t_ilm_message message)
2493 t_ilm_message response;
2494 OptimizationType optimizationId;
2495 OptimizationModeType optimizationMode;
2496 unsigned int optMode;
2497 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2498 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2500 m_ipcModule.getUint(message, &optMode);
2501 optimizationId = (OptimizationType)optMode;
2502 m_ipcModule.getUint(message, &optMode);
2503 optimizationMode = (OptimizationModeType)optMode;
2505 t_ilm_bool status = m_executor->execute(new SetOptimizationModeCommand(clientPid, optimizationId, optimizationMode));
2508 response = m_ipcModule.createResponse(message);
2512 response = m_ipcModule.createErrorResponse(message);
2513 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2515 m_ipcModule.sendToClients(response, &clientHandle, 1);
2516 m_ipcModule.destroyMessage(response);
2519 void GenericCommunicator::GetOptimizationMode(t_ilm_message message)
2521 t_ilm_message response;
2522 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2523 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2524 OptimizationType optimizationId;
2525 OptimizationModeType optimizationMode;
2528 m_ipcModule.getUint(message, &o);
2529 optimizationId = (OptimizationType)o;
2531 t_ilm_bool status = m_executor->execute(new GetOptimizationModeCommand(clientPid, optimizationId, &optimizationMode));
2534 response = m_ipcModule.createResponse(message);
2535 m_ipcModule.appendUint(response, (unsigned int)optimizationMode);
2539 response = m_ipcModule.createErrorResponse(message);
2540 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2542 m_ipcModule.sendToClients(response, &clientHandle, 1);
2543 m_ipcModule.destroyMessage(response);
2546 void GenericCommunicator::GetPropertiesOfScreen(t_ilm_message message)
2548 t_ilm_message response;
2549 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2551 m_ipcModule.getUint(message, &id);
2553 LmScreen* screen = m_executor->getScene()->getScreen(id);
2556 LayerList renderOrder = screen->getCurrentRenderOrder();
2557 std::vector<t_ilm_layer> layerIdVector;
2559 LayerListConstIterator iter = renderOrder.begin();
2560 LayerListConstIterator end = renderOrder.end();
2561 for (; iter != end; ++iter)
2563 layerIdVector.push_back((*iter)->getID());
2566 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(id);
2567 uint* resolution = m_executor->getScreenResolution(id);
2569 response = m_ipcModule.createResponse(message);
2570 m_ipcModule.appendUintArray(response, layerIdVector.data(), layerIdVector.size());
2571 m_ipcModule.appendUint(response, numberOfHardwareLayers);
2572 m_ipcModule.appendUint(response, resolution[0]);
2573 m_ipcModule.appendUint(response, resolution[1]);
2577 response = m_ipcModule.createErrorResponse(message);
2578 m_ipcModule.appendUint(response, ILM_ERROR_RESOURCE_NOT_FOUND);
2581 m_ipcModule.sendToClients(response, &clientHandle, 1);
2582 m_ipcModule.destroyMessage(response);
2585 DECLARE_LAYERMANAGEMENT_PLUGIN(GenericCommunicator)