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"
23 #include "Configuration.h"
25 #include "ICommandExecutor.h"
26 #include "CommitCommand.h"
27 #include "LayerCreateCommand.h"
28 #include "SurfaceCreateCommand.h"
29 #include "SurfaceGetDimensionCommand.h"
30 #include "LayerGetDimensionCommand.h"
31 #include "SurfaceGetOpacityCommand.h"
32 #include "LayerGetOpacityCommand.h"
33 #include "SurfaceGetPixelformatCommand.h"
34 #include "LayerGetVisibilityCommand.h"
35 #include "SurfaceGetVisibilityCommand.h"
36 #include "LayerAddSurfaceCommand.h"
37 #include "LayerRemoveSurfaceCommand.h"
38 #include "LayerRemoveCommand.h"
39 #include "SurfaceRemoveCommand.h"
40 #include "SurfaceGetOrientationCommand.h"
41 #include "LayerGetOrientationCommand.h"
42 #include "LayerSetDestinationRectangleCommand.h"
43 #include "SurfaceSetDestinationRectangleCommand.h"
44 #include "LayerSetOpacityCommand.h"
45 #include "SurfaceSetOpacityCommand.h"
46 #include "LayerSetSourceRectangleCommand.h"
47 #include "SurfaceSetSourceRectangleCommand.h"
48 #include "LayerSetOrientationCommand.h"
49 #include "SurfaceSetOrientationCommand.h"
50 #include "LayerSetVisibilityCommand.h"
51 #include "SurfaceSetVisibilityCommand.h"
52 #include "DebugCommand.h"
53 #include "ExitCommand.h"
54 #include "ScreenSetRenderOrderCommand.h"
55 #include "LayerSetRenderOrderCommand.h"
56 #include "LayerSetDimensionCommand.h"
57 #include "SurfaceSetDimensionCommand.h"
58 #include "LayerSetPositionCommand.h"
59 #include "SurfaceSetPositionCommand.h"
60 #include "LayerGetPositionCommand.h"
61 #include "SurfaceGetPositionCommand.h"
62 #include "ShaderCreateCommand.h"
63 #include "ShaderDestroyCommand.h"
64 #include "SurfaceSetShaderCommand.h"
65 #include "ShaderSetUniformsCommand.h"
66 #include "ScreenDumpCommand.h"
67 #include "LayerDumpCommand.h"
68 #include "SurfaceDumpCommand.h"
69 #include "SurfaceSetNativeContentCommand.h"
70 #include "SurfaceRemoveNativeContentCommand.h"
71 #include "SurfaceSetKeyboardFocusCommand.h"
72 #include "SurfaceGetKeyboardFocusCommand.h"
73 #include "SurfaceUpdateInputEventAcceptance.h"
74 #include "SurfaceSetChromaKeyCommand.h"
75 #include "LayerSetChromaKeyCommand.h"
76 #include "SetOptimizationModeCommand.h"
77 #include "GetOptimizationModeCommand.h"
87 #define DEFAULT_SCREEN 0
89 const char* RESOURCE_ALREADY_INUSE = "Ressource already in use";
90 const char* INVALID_ARGUMENT = "Invalid argument";
91 const char* RESOURCE_NOT_FOUND = "Ressource not found";
92 const char* NOT_IMPLEMENTED = "Feature not implemented";
95 GenericCommunicator::GenericCommunicator(ICommandExecutor& executor, Configuration& config)
96 : ICommunicator(&executor)
97 , PluginBase(executor, config, Communicator_Api_v1)
98 , m_running(ILM_FALSE)
100 MethodTable manager_methods[] =
102 { "ServiceConnect", &GenericCommunicator::ServiceConnect },
103 { "ServiceDisconnect", &GenericCommunicator::ServiceDisconnect },
104 { "Debug", &GenericCommunicator::Debug },
105 { "ScreenShot", &GenericCommunicator::ScreenShot },
106 { "ScreenShotOfLayer", &GenericCommunicator::ScreenShotOfLayer },
107 { "ScreenShotOfSurface", &GenericCommunicator::ScreenShotOfSurface },
108 { "GetScreenResolution", &GenericCommunicator::GetScreenResolution },
109 { "GetNumberOfHardwareLayers", &GenericCommunicator::GetNumberOfHardwareLayers },
110 { "GetScreenIDs", &GenericCommunicator::GetScreenIDs },
111 { "ListAllLayerIDS", &GenericCommunicator::ListAllLayerIDS },
112 { "ListAllLayerIDsOnScreen", &GenericCommunicator::ListAllLayerIDsOnScreen },
113 { "ListAllSurfaceIDS", &GenericCommunicator::ListAllSurfaceIDS },
114 { "ListSurfaceofLayer", &GenericCommunicator::ListSurfaceofLayer },
115 { "GetPropertiesOfSurface", &GenericCommunicator::GetPropertiesOfSurface },
116 { "GetPropertiesOfLayer", &GenericCommunicator::GetPropertiesOfLayer },
117 { "CreateSurface", &GenericCommunicator::CreateSurface },
118 { "CreateSurfaceFromId", &GenericCommunicator::CreateSurfaceFromId },
119 { "InitializeSurface", &GenericCommunicator::InitializeSurface },
120 { "InitializeSurfaceFromId", &GenericCommunicator::InitializeSurfaceFromId },
121 { "SetSurfaceNativeContent", &GenericCommunicator::SetSurfaceNativeContent },
122 { "RemoveSurfaceNativeContent", &GenericCommunicator::RemoveSurfaceNativeContent },
123 { "RemoveSurface", &GenericCommunicator::RemoveSurface },
124 { "CreateLayer", &GenericCommunicator::CreateLayer },
125 { "CreateLayerFromId", &GenericCommunicator::CreateLayerFromId },
126 { "CreateLayerWithDimension", &GenericCommunicator::CreateLayerWithDimension },
127 { "CreateLayerFromIdWithDimension", &GenericCommunicator::CreateLayerFromIdWithDimension },
128 { "RemoveLayer", &GenericCommunicator::RemoveLayer },
129 { "AddSurfaceToLayer", &GenericCommunicator::AddSurfaceToLayer },
130 { "RemoveSurfaceFromLayer", &GenericCommunicator::RemoveSurfaceFromLayer },
131 { "SetSurfaceSourceRegion", &GenericCommunicator::SetSurfaceSourceRegion },
132 { "SetLayerSourceRegion", &GenericCommunicator::SetLayerSourceRegion },
133 { "SetSurfaceDestinationRegion", &GenericCommunicator::SetSurfaceDestinationRegion },
134 { "SetSurfacePosition", &GenericCommunicator::SetSurfacePosition },
135 { "GetSurfacePosition", &GenericCommunicator::GetSurfacePosition },
136 { "SetSurfaceDimension", &GenericCommunicator::SetSurfaceDimension },
137 { "SetLayerDestinationRegion", &GenericCommunicator::SetLayerDestinationRegion },
138 { "SetLayerPosition", &GenericCommunicator::SetLayerPosition },
139 { "GetLayerPosition", &GenericCommunicator::GetLayerPosition },
140 { "SetLayerDimension", &GenericCommunicator::SetLayerDimension },
141 { "GetLayerDimension", &GenericCommunicator::GetLayerDimension },
142 { "GetSurfaceDimension", &GenericCommunicator::GetSurfaceDimension },
143 { "SetSurfaceOpacity", &GenericCommunicator::SetSurfaceOpacity },
144 { "SetLayerOpacity", &GenericCommunicator::SetLayerOpacity },
145 { "GetSurfaceOpacity", &GenericCommunicator::GetSurfaceOpacity },
146 { "GetLayerOpacity", &GenericCommunicator::GetLayerOpacity },
147 { "SetSurfaceOrientation", &GenericCommunicator::SetSurfaceOrientation },
148 { "GetSurfaceOrientation", &GenericCommunicator::GetSurfaceOrientation },
149 { "SetLayerOrientation", &GenericCommunicator::SetLayerOrientation },
150 { "GetLayerOrientation", &GenericCommunicator::GetLayerOrientation },
151 { "GetSurfacePixelformat", &GenericCommunicator::GetSurfacePixelformat },
152 { "SetSurfaceVisibility", &GenericCommunicator::SetSurfaceVisibility },
153 { "SetLayerVisibility", &GenericCommunicator::SetLayerVisibility },
154 { "GetSurfaceVisibility", &GenericCommunicator::GetSurfaceVisibility },
155 { "GetLayerVisibility", &GenericCommunicator::GetLayerVisibility },
156 { "SetRenderOrderOfLayers", &GenericCommunicator::SetRenderOrderOfLayers },
157 { "SetSurfaceRenderOrderWithinLayer", &GenericCommunicator::SetSurfaceRenderOrderWithinLayer },
158 { "GetLayerType", &GenericCommunicator::GetLayerType },
159 { "GetLayertypeCapabilities", &GenericCommunicator::GetLayertypeCapabilities },
160 { "GetLayerCapabilities", &GenericCommunicator::GetLayerCapabilities },
161 { "Exit", &GenericCommunicator::Exit },
162 { "CommitChanges", &GenericCommunicator::CommitChanges },
163 { "CreateShader", &GenericCommunicator::CreateShader },
164 { "DestroyShader", &GenericCommunicator::DestroyShader },
165 { "SetShader", &GenericCommunicator::SetShader },
166 { "SetUniforms", &GenericCommunicator::SetUniforms },
167 { "SetKeyboardFocusOn", &GenericCommunicator::SetKeyboardFocusOn },
168 { "GetKeyboardFocusSurfaceId", &GenericCommunicator::GetKeyboardFocusSurfaceId },
169 { "UpdateInputEventAcceptanceOn", &GenericCommunicator::UpdateInputEventAcceptanceOn },
170 { "SetSurfaceChromaKey", &GenericCommunicator::SetSurfaceChromaKey },
171 { "SetLayerChromaKey", &GenericCommunicator::SetLayerChromaKey },
172 { "LayerAddNotification", &GenericCommunicator::LayerAddNotification },
173 { "SurfaceAddNotification", &GenericCommunicator::SurfaceAddNotification },
174 { "LayerRemoveNotification", &GenericCommunicator::LayerRemoveNotification },
175 { "SurfaceRemoveNotification", &GenericCommunicator::SurfaceRemoveNotification },
176 { "SetOptimizationMode", &GenericCommunicator::SetOptimizationMode },
177 { "GetOptimizationMode", &GenericCommunicator::GetOptimizationMode }
180 int entryCount = sizeof(manager_methods) / sizeof(MethodTable);
182 for (int index = 0; index < entryCount; ++index)
184 MethodTable* method = &manager_methods[index];
185 if (method->function)
187 m_callBackTable[method->name] = *method;
188 LOG_DEBUG("GenericCommunicator", "registered callback for " << method->name);
192 memset(&m_ipcModule, 0, sizeof(m_ipcModule));
194 mThreadId = pthread_self();
197 bool GenericCommunicator::start()
199 LOG_DEBUG("GenericCommunicator", "Starting up IpcModules.");
201 if (!loadIpcModule(&m_ipcModule))
203 LOG_ERROR("GenericCommunicator", "Loading IpcModule failed.");
206 LOG_DEBUG("GenericCommunicator", "Loading IpcModule success.");
208 if (!m_ipcModule.initServiceMode())
210 LOG_ERROR("GenericCommunicator", "Initializing IpcModule failed.");
213 LOG_DEBUG("GenericCommunicator", "Initializing IpcModule success.");
215 m_running = ILM_TRUE;
216 pluginSetHealth(HealthRunning);
225 void GenericCommunicator::stop()
227 LOG_INFO("GenericCommunicator","stopping");
233 m_ipcModule.destroy();
235 pluginSetHealth(HealthStopped);
238 void GenericCommunicator::process(int timeout_ms)
240 t_ilm_message message = m_ipcModule.receive(timeout_ms);
246 t_ilm_message_type messageType = m_ipcModule.getMessageType(message);
247 t_ilm_const_string name = m_ipcModule.getMessageName(message);
248 t_ilm_client_handle senderHandle = m_ipcModule.getSenderHandle(message);
252 case IpcMessageTypeCommand:
253 if (m_callBackTable.end() != m_callBackTable.find(name))
255 LOG_DEBUG("GenericCommunicator", "received: " << name << " from "
256 << m_executor->getSenderName(senderHandle)
257 << "(" << m_executor->getSenderPid(senderHandle) << ")");
258 CallBackMethod method = m_callBackTable[name].function;
259 (this->*method)(message);
263 LOG_WARNING("GenericCommunicator", "Received unknown command " << name
264 << " from " << m_executor->getSenderName(senderHandle)
265 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
267 processNotificationQueue();
270 case IpcMessageTypeConnect:
271 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
272 << "(pid " << m_executor->getSenderPid(senderHandle) << ") connected");
275 case IpcMessageTypeDisconnect:
276 LOG_DEBUG("GenericCommunicator", "client " << m_executor->getSenderName(senderHandle)
277 << "(pid " << m_executor->getSenderPid(senderHandle) << ") disconnected");
279 const LayerMap& layers = m_executor->getScene()->getAllLayers();
280 LayerMapConstIterator layerIter = layers.begin();
281 LayerMapConstIterator layerIterEnd = layers.end();
282 for (; layerIter != layerIterEnd; ++layerIter)
284 Layer* layer = layerIter->second;
285 layer->removeNotification(senderHandle);
288 const SurfaceMap& surfaces = m_executor->getScene()->getAllSurfaces();
289 SurfaceMapConstIterator surfaceIter = surfaces.begin();
290 SurfaceMapConstIterator surfaceIterEnd = surfaces.end();
291 for (; surfaceIter != surfaceIterEnd; ++surfaceIter)
293 Surface* surface = surfaceIter->second;
294 surface->removeNotification(senderHandle);
299 case IpcMessageTypeError:
300 LOG_DEBUG("GenericCommunicator", "Received error message " << name << " from "
301 << m_executor->getSenderName(senderHandle)
302 << "(pid " << m_executor->getSenderPid(senderHandle) << ")");
305 case IpcMessageTypeShutdown:
306 case IpcMessageTypeNone:
310 LOG_DEBUG("GenericCommunicator", "Received unknown data from "
311 << m_executor->getSenderName(senderHandle)
312 << "(pid " << m_executor->getSenderPid(senderHandle) << "), Message type: " << messageType);
315 m_ipcModule.destroyMessage(message);
318 void GenericCommunicator::setdebug(bool onoff)
320 (void)onoff; // TODO: remove, only prevents warning
323 t_ilm_bool GenericCommunicator::threadMainLoop()
329 t_ilm_const_string GenericCommunicator::pluginGetName() const
331 return "GenericCommunicator";
334 void GenericCommunicator::ServiceConnect(t_ilm_message message)
336 t_ilm_message response;
337 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
339 unsigned int processId = 0;
340 char processName[1024];
341 m_ipcModule.getUint(message, &processId);
342 m_ipcModule.getString(message, processName);
344 m_executor->addApplicationReference(clientHandle, new IApplicationReference(processName, processId));
346 LOG_DEBUG("GenericCommunicator", "ServiceConnect called from "
347 << m_executor->getSenderName(clientHandle)
348 << "(" << m_executor->getSenderPid(clientHandle) << ")");
350 response = m_ipcModule.createResponse(message);
351 m_ipcModule.sendToClients(response, &clientHandle, 1);
352 m_ipcModule.destroyMessage(response);
355 void GenericCommunicator::ServiceDisconnect(t_ilm_message message)
357 t_ilm_message response;
358 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
360 LOG_DEBUG("GenericCommunicator", "ServiceDisconnect called from "
361 << m_executor->getSenderName(clientHandle)
362 << "(" << m_executor->getSenderPid(clientHandle) << ")");
364 m_executor->removeApplicationReference(clientHandle);
366 response = m_ipcModule.createResponse(message);
367 m_ipcModule.sendToClients(response, &clientHandle, 1);
368 m_ipcModule.destroyMessage(response);
371 void GenericCommunicator::Debug(t_ilm_message message)
373 t_ilm_message response;
374 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
375 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
376 t_ilm_bool param = ILM_FALSE;
377 m_ipcModule.getBool(message, ¶m);
379 t_ilm_bool status = m_executor->execute(new DebugCommand(clientPid, param));
382 response = m_ipcModule.createResponse(message);
386 response = m_ipcModule.createErrorResponse(message);
387 m_ipcModule.appendString(response, INVALID_ARGUMENT);
390 m_ipcModule.sendToClients(response, &clientHandle, 1);
391 m_ipcModule.destroyMessage(response);
394 void GenericCommunicator::GetScreenResolution(t_ilm_message message)
396 t_ilm_message response;
397 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
399 m_ipcModule.getUint(message, &screenid);
400 uint* resolution = m_executor->getScreenResolution(screenid);
402 response = m_ipcModule.createResponse(message);
403 m_ipcModule.appendUint(response, resolution[0]);
404 m_ipcModule.appendUint(response, resolution[1]);
405 m_ipcModule.sendToClients(response, &clientHandle, 1);
406 m_ipcModule.destroyMessage(response);
409 void GenericCommunicator::GetNumberOfHardwareLayers(t_ilm_message message)
411 t_ilm_message response;
412 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
414 m_ipcModule.getUint(message, &screenid);
415 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid);
416 response = m_ipcModule.createResponse(message);
417 m_ipcModule.appendUint(response, numberOfHardwareLayers);
418 m_ipcModule.sendToClients(response, &clientHandle, 1);
419 m_ipcModule.destroyMessage(response);
422 void GenericCommunicator::GetScreenIDs(t_ilm_message message)
424 t_ilm_message response;
425 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
427 uint* IDs = m_executor->getScreenIDs(&length);
428 response = m_ipcModule.createResponse(message);
429 m_ipcModule.appendUintArray(response, IDs, length);
430 m_ipcModule.sendToClients(response, &clientHandle, 1);
431 m_ipcModule.destroyMessage(response);
434 void GenericCommunicator::ScreenShot(t_ilm_message message)
436 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
437 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
438 t_ilm_message response;
442 m_ipcModule.getUint(message, &screenid);
443 m_ipcModule.getString(message, filename);
445 t_ilm_bool status = m_executor->execute(new ScreenDumpCommand(clientPid, filename, screenid));
448 response = m_ipcModule.createResponse(message);
452 response = m_ipcModule.createErrorResponse(message);
453 m_ipcModule.appendString(response, INVALID_ARGUMENT);
456 m_ipcModule.sendToClients(response, &clientHandle, 1);
457 m_ipcModule.destroyMessage(response);
460 void GenericCommunicator::ScreenShotOfLayer(t_ilm_message message)
462 t_ilm_message response;
463 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
464 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
466 m_ipcModule.getString(message, filename);
468 m_ipcModule.getUint(message, &layerid);
470 t_ilm_bool status = m_executor->execute(new LayerDumpCommand(clientPid, filename, layerid));
473 response = m_ipcModule.createResponse(message);
477 response = m_ipcModule.createErrorResponse(message);
478 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
481 m_ipcModule.sendToClients(response, &clientHandle, 1);
482 m_ipcModule.destroyMessage(response);
485 void GenericCommunicator::ScreenShotOfSurface(t_ilm_message message)
487 t_ilm_message response;
488 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
489 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
491 m_ipcModule.getString(message, filename);
493 m_ipcModule.getUint(message, &id);
494 t_ilm_bool status = m_executor->execute(new SurfaceDumpCommand(clientPid, filename, id));
497 response = m_ipcModule.createResponse(message);
501 response = m_ipcModule.createErrorResponse(message);
502 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
505 m_ipcModule.sendToClients(response, &clientHandle, 1);
506 m_ipcModule.destroyMessage(response);
509 void GenericCommunicator::ListAllLayerIDS(t_ilm_message message)
511 t_ilm_message response;
512 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
515 m_executor->getScene()->lockScene();
516 m_executor->getScene()->getLayerIDs(&length, &array);
517 m_executor->getScene()->unlockScene();
518 response = m_ipcModule.createResponse(message);
519 m_ipcModule.appendUintArray(response, array, length);
520 m_ipcModule.sendToClients(response, &clientHandle, 1);
521 m_ipcModule.destroyMessage(response);
524 void GenericCommunicator::ListAllLayerIDsOnScreen(t_ilm_message message)
526 t_ilm_message response;
527 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
529 m_ipcModule.getUint(message, &screenID);
533 m_executor->getScene()->lockScene();
534 t_ilm_bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
535 m_executor->getScene()->unlockScene();
538 response = m_ipcModule.createResponse(message);
539 m_ipcModule.appendUintArray(response, array, length);
543 response = m_ipcModule.createErrorResponse(message);
544 m_ipcModule.appendString(response, INVALID_ARGUMENT);
547 m_ipcModule.sendToClients(response, &clientHandle, 1);
548 m_ipcModule.destroyMessage(response);
551 void GenericCommunicator::ListAllSurfaceIDS(t_ilm_message message)
553 t_ilm_message response;
554 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
557 m_executor->getScene()->lockScene();
558 m_executor->getScene()->getSurfaceIDs(&length, &array);
559 m_executor->getScene()->unlockScene();
560 response = m_ipcModule.createResponse(message);
561 m_ipcModule.appendUintArray(response, array, length);
562 m_ipcModule.sendToClients(response, &clientHandle, 1);
563 m_ipcModule.destroyMessage(response);
566 void GenericCommunicator::ListSurfaceofLayer(t_ilm_message message)
568 t_ilm_message response;
569 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
571 m_ipcModule.getUint(message, &id);
572 m_executor->getScene()->lockScene();
573 Layer* layer = m_executor->getScene()->getLayer(id);
576 std::list<Surface*> surfaces = layer->getAllSurfaces();
578 uint length = surfaces.size();
579 uint* array = new uint[length];
582 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
585 array[arrayPos] = s->getID();
588 m_executor->getScene()->unlockScene();
590 response = m_ipcModule.createResponse(message);
591 m_ipcModule.appendUintArray(response, array, length);
595 m_executor->getScene()->unlockScene();
596 response = m_ipcModule.createErrorResponse(message);
597 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
600 m_ipcModule.sendToClients(response, &clientHandle, 1);
601 m_ipcModule.destroyMessage(response);
604 void GenericCommunicator::GetPropertiesOfSurface(t_ilm_message message)
606 t_ilm_message response;
607 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
609 m_ipcModule.getUint(message, &id);
611 Surface* surface = m_executor->getScene()->getSurface(id);
614 Rectangle dest = surface->getDestinationRegion();
615 Rectangle src = surface->getSourceRegion();
616 OrientationType orientation = surface->getOrientation();
617 unsigned char chromaKeyRed = 0;
618 unsigned char chromaKeyGreen = 0;
619 unsigned char chromaKeyBlue = 0;
620 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
622 response = m_ipcModule.createResponse(message);
623 m_ipcModule.appendDouble(response, surface->getOpacity());
624 m_ipcModule.appendUint(response, src.x);
625 m_ipcModule.appendUint(response, src.y);
626 m_ipcModule.appendUint(response, src.width);
627 m_ipcModule.appendUint(response, src.height);
628 m_ipcModule.appendUint(response, surface->OriginalSourceWidth);
629 m_ipcModule.appendUint(response, surface->OriginalSourceHeight);
630 m_ipcModule.appendUint(response, dest.x);
631 m_ipcModule.appendUint(response, dest.y);
632 m_ipcModule.appendUint(response, dest.width);
633 m_ipcModule.appendUint(response, dest.height);
634 m_ipcModule.appendUint(response, orientation);
635 m_ipcModule.appendBool(response, surface->getVisibility());
636 m_ipcModule.appendUint(response, surface->frameCounter);
637 m_ipcModule.appendUint(response, surface->drawCounter);
638 m_ipcModule.appendUint(response, surface->updateCounter);
639 m_ipcModule.appendUint(response, surface->getPixelFormat());
640 m_ipcModule.appendUint(response, surface->getNativeContent());
641 m_ipcModule.appendUint(response, surface->getInputEventAcceptanceOnDevices());
642 m_ipcModule.appendBool(response, surface->getChromaKeyEnabled());
643 m_ipcModule.appendUint(response, chromaKeyRed);
644 m_ipcModule.appendUint(response, chromaKeyGreen);
645 m_ipcModule.appendUint(response, chromaKeyBlue);
646 m_ipcModule.appendInt(response, surface->getCreatorPid());
650 response = m_ipcModule.createErrorResponse(message);
651 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
654 m_ipcModule.sendToClients(response, &clientHandle, 1);
655 m_ipcModule.destroyMessage(response);
658 void GenericCommunicator::GetPropertiesOfLayer(t_ilm_message message)
660 t_ilm_message response;
661 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
663 m_ipcModule.getUint(message, &id);
665 Layer* layer = m_executor->getScene()->getLayer(id);
668 Rectangle dest = layer->getDestinationRegion();
669 Rectangle src = layer->getSourceRegion();
670 OrientationType orientation = layer->getOrientation();
671 unsigned char chromaKeyRed = 0;
672 unsigned char chromaKeyGreen = 0;
673 unsigned char chromaKeyBlue = 0;
674 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
676 response = m_ipcModule.createResponse(message);
677 m_ipcModule.appendDouble(response, layer->getOpacity());
678 m_ipcModule.appendUint(response, src.x);
679 m_ipcModule.appendUint(response, src.y);
680 m_ipcModule.appendUint(response, src.width);
681 m_ipcModule.appendUint(response, src.height);
682 m_ipcModule.appendUint(response, layer->OriginalSourceWidth);
683 m_ipcModule.appendUint(response, layer->OriginalSourceHeight);
684 m_ipcModule.appendUint(response, dest.x);
685 m_ipcModule.appendUint(response, dest.y);
686 m_ipcModule.appendUint(response, dest.width);
687 m_ipcModule.appendUint(response, dest.height);
688 m_ipcModule.appendUint(response, orientation);
689 m_ipcModule.appendBool(response, layer->getVisibility());
690 m_ipcModule.appendUint(response, layer->getLayerType());
691 m_ipcModule.appendBool(response, layer->getChromaKeyEnabled());
692 m_ipcModule.appendUint(response, chromaKeyRed);
693 m_ipcModule.appendUint(response, chromaKeyGreen);
694 m_ipcModule.appendUint(response, chromaKeyBlue);
695 m_ipcModule.appendInt(response, layer->getCreatorPid());
699 response = m_ipcModule.createErrorResponse(message);
700 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
703 m_ipcModule.sendToClients(response, &clientHandle, 1);
704 m_ipcModule.destroyMessage(response);
707 void GenericCommunicator::CreateSurface(t_ilm_message message)
709 t_ilm_message response;
710 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
711 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
715 uint pixelformat = 0;
716 PixelFormat pf = PIXELFORMAT_UNKNOWN;
717 uint id = GraphicalObject::INVALID_ID;
719 m_ipcModule.getUint(message, &handle);
720 m_ipcModule.getUint(message, &width);
721 m_ipcModule.getUint(message, &height);
722 m_ipcModule.getUint(message, &pixelformat);
724 pf = (PixelFormat) pixelformat;
727 // First of all create the surface
728 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
730 // after that apply the native content
731 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
735 response = m_ipcModule.createResponse(message);
736 m_ipcModule.appendUint(response, id);
740 response = m_ipcModule.createErrorResponse(message);
741 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
744 m_ipcModule.sendToClients(response, &clientHandle, 1);
745 m_ipcModule.destroyMessage(response);
748 void GenericCommunicator::CreateSurfaceFromId(t_ilm_message message)
750 t_ilm_message response;
751 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
752 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
756 uint pixelformat = 0;
757 PixelFormat pf = PIXELFORMAT_UNKNOWN;
760 m_ipcModule.getUint(message, &handle);
761 m_ipcModule.getUint(message, &width);
762 m_ipcModule.getUint(message, &height);
763 m_ipcModule.getUint(message, &pixelformat);
764 m_ipcModule.getUint(message, &id);
766 pf = (PixelFormat) pixelformat;
768 // First of all create the surface
769 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
771 // after that apply the native content
772 status &= m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
776 response = m_ipcModule.createResponse(message);
777 m_ipcModule.appendUint(response, id);
781 response = m_ipcModule.createErrorResponse(message);
782 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
785 m_ipcModule.sendToClients(response, &clientHandle, 1);
786 m_ipcModule.destroyMessage(response);
789 void GenericCommunicator::InitializeSurface(t_ilm_message message)
791 t_ilm_message response;
792 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
793 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
794 uint id = GraphicalObject::INVALID_ID;
796 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
799 response = m_ipcModule.createResponse(message);
800 m_ipcModule.appendUint(response, id);
804 response = m_ipcModule.createErrorResponse(message);
805 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
808 m_ipcModule.sendToClients(response, &clientHandle, 1);
809 m_ipcModule.destroyMessage(response);
812 void GenericCommunicator::InitializeSurfaceFromId(t_ilm_message message)
814 t_ilm_message response;
815 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
816 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
818 m_ipcModule.getUint(message, &id);
819 t_ilm_bool status = m_executor->execute(new SurfaceCreateCommand(clientPid, &id));
822 response = m_ipcModule.createResponse(message);
823 m_ipcModule.appendUint(response, id);
827 response = m_ipcModule.createErrorResponse(message);
828 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
831 m_ipcModule.sendToClients(response, &clientHandle, 1);
832 m_ipcModule.destroyMessage(response);
835 void GenericCommunicator::SetSurfaceNativeContent(t_ilm_message message)
837 t_ilm_message response;
838 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
839 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
844 uint pixelformat = 0;
845 PixelFormat pf = PIXELFORMAT_UNKNOWN;
847 m_ipcModule.getUint(message, &id);
848 m_ipcModule.getUint(message, &handle);
849 m_ipcModule.getUint(message, &width);
850 m_ipcModule.getUint(message, &height);
851 m_ipcModule.getUint(message, &pixelformat);
853 pf = (PixelFormat) pixelformat;
855 t_ilm_bool status = m_executor->execute(new SurfaceSetNativeContentCommand(clientPid, id, handle, pf, width, height));
858 response = m_ipcModule.createResponse(message);
862 response = m_ipcModule.createErrorResponse(message);
863 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
866 m_ipcModule.sendToClients(response, &clientHandle, 1);
867 m_ipcModule.destroyMessage(response);
870 void GenericCommunicator::RemoveSurfaceNativeContent(t_ilm_message message)
872 t_ilm_message response;
873 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
874 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
876 m_ipcModule.getUint(message, &id);
878 t_ilm_bool status = m_executor->execute(new SurfaceRemoveNativeContentCommand(clientPid, id));
881 response = m_ipcModule.createResponse(message);
885 response = m_ipcModule.createErrorResponse(message);
886 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
889 m_ipcModule.sendToClients(response, &clientHandle, 1);
890 m_ipcModule.destroyMessage(response);
893 void GenericCommunicator::RemoveSurface(t_ilm_message message)
895 t_ilm_message response;
896 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
897 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
899 m_ipcModule.getUint(message, ¶m);
900 t_ilm_bool status = m_executor->execute(new SurfaceRemoveCommand(clientPid, param));
903 response = m_ipcModule.createResponse(message);
907 response = m_ipcModule.createErrorResponse(message);
908 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
911 m_ipcModule.sendToClients(response, &clientHandle, 1);
912 m_ipcModule.destroyMessage(response);
915 void GenericCommunicator::CreateLayer(t_ilm_message message)
917 t_ilm_message response;
918 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
919 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
920 uint id = GraphicalObject::INVALID_ID;
921 // use resolution of default screen as default width and height of layers
922 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
923 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
926 response = m_ipcModule.createResponse(message);
927 m_ipcModule.appendUint(response, id);
931 response = m_ipcModule.createErrorResponse(message);
932 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
935 m_ipcModule.sendToClients(response, &clientHandle, 1);
936 m_ipcModule.destroyMessage(response);
939 void GenericCommunicator::CreateLayerFromId(t_ilm_message message)
941 t_ilm_message response;
942 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
943 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
944 uint id = GraphicalObject::INVALID_ID;
946 m_ipcModule.getUint(message, &id);
947 // use resolution of default screen as default width and height of layers
948 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
949 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, resolution[0], resolution[1], &id));
952 response = m_ipcModule.createResponse(message);
953 m_ipcModule.appendUint(response, id);
957 response = m_ipcModule.createErrorResponse(message);
958 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
961 m_ipcModule.sendToClients(response, &clientHandle, 1);
962 m_ipcModule.destroyMessage(response);
966 void GenericCommunicator::CreateLayerWithDimension(t_ilm_message message)
968 t_ilm_message response;
969 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
970 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
972 m_ipcModule.getUint(message, &width);
974 m_ipcModule.getUint(message, &height);
976 uint id = GraphicalObject::INVALID_ID;
977 t_ilm_bool status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
980 response = m_ipcModule.createResponse(message);
981 m_ipcModule.appendUint(response, id);
985 response = m_ipcModule.createErrorResponse(message);
986 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
989 m_ipcModule.sendToClients(response, &clientHandle, 1);
990 m_ipcModule.destroyMessage(response);
993 void GenericCommunicator::CreateLayerFromIdWithDimension(t_ilm_message message)
995 t_ilm_message response;
996 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
997 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
998 uint id = GraphicalObject::INVALID_ID;
1001 t_ilm_bool status = ILM_FALSE;
1003 m_ipcModule.getUint(message, &id);
1004 m_ipcModule.getUint(message, &width);
1005 m_ipcModule.getUint(message, &height);
1007 status = m_executor->execute(new LayerCreateCommand(clientPid, width, height, &id));
1010 response = m_ipcModule.createResponse(message);
1011 m_ipcModule.appendUint(response, id);
1015 response = m_ipcModule.createErrorResponse(message);
1016 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1019 m_ipcModule.sendToClients(response, &clientHandle, 1);
1020 m_ipcModule.destroyMessage(response);
1023 void GenericCommunicator::RemoveLayer(t_ilm_message message)
1025 t_ilm_message response;
1026 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1027 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1029 m_ipcModule.getUint(message, ¶m);
1030 t_ilm_bool status = m_executor->execute(new LayerRemoveCommand(clientPid, param));
1033 response = m_ipcModule.createResponse(message);
1037 response = m_ipcModule.createErrorResponse(message);
1038 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1041 m_ipcModule.sendToClients(response, &clientHandle, 1);
1042 m_ipcModule.destroyMessage(response);
1045 void GenericCommunicator::AddSurfaceToLayer(t_ilm_message message)
1047 t_ilm_message response;
1048 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1049 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1053 m_ipcModule.getUint(message, &surfaceid);
1054 m_ipcModule.getUint(message, &layer);
1056 t_ilm_bool status = m_executor->execute(new LayerAddSurfaceCommand(clientPid, layer, surfaceid));
1059 response = m_ipcModule.createResponse(message);
1063 response = m_ipcModule.createErrorResponse(message);
1064 m_ipcModule.appendString(response, RESOURCE_ALREADY_INUSE);
1067 m_ipcModule.sendToClients(response, &clientHandle, 1);
1068 m_ipcModule.destroyMessage(response);
1071 void GenericCommunicator::RemoveSurfaceFromLayer(t_ilm_message message)
1073 t_ilm_message response;
1074 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1075 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1078 m_ipcModule.getUint(message, &surfaceid);
1079 m_ipcModule.getUint(message, &layerid);
1081 t_ilm_bool status = m_executor->execute(new LayerRemoveSurfaceCommand(clientPid, layerid, surfaceid));
1084 response = m_ipcModule.createResponse(message);
1088 response = m_ipcModule.createErrorResponse(message);
1089 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1092 m_ipcModule.sendToClients(response, &clientHandle, 1);
1093 m_ipcModule.destroyMessage(response);
1096 void GenericCommunicator::SetSurfaceSourceRegion(t_ilm_message message)
1098 t_ilm_message response;
1099 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1100 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1107 m_ipcModule.getUint(message, &id);
1108 m_ipcModule.getUint(message, &x);
1109 m_ipcModule.getUint(message, &y);
1110 m_ipcModule.getUint(message, &width);
1111 m_ipcModule.getUint(message, &height);
1113 t_ilm_bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1116 response = m_ipcModule.createResponse(message);
1120 response = m_ipcModule.createErrorResponse(message);
1121 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1124 m_ipcModule.sendToClients(response, &clientHandle, 1);
1125 m_ipcModule.destroyMessage(response);
1128 void GenericCommunicator::SetLayerSourceRegion(t_ilm_message message)
1130 t_ilm_message response;
1131 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1132 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1139 m_ipcModule.getUint(message, &id);
1140 m_ipcModule.getUint(message, &x);
1141 m_ipcModule.getUint(message, &y);
1142 m_ipcModule.getUint(message, &width);
1143 m_ipcModule.getUint(message, &height);
1145 t_ilm_bool status = m_executor->execute(new LayerSetSourceRectangleCommand(clientPid, id, x, y, width, height));
1148 response = m_ipcModule.createResponse(message);
1152 response = m_ipcModule.createErrorResponse(message);
1153 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1156 m_ipcModule.sendToClients(response, &clientHandle, 1);
1157 m_ipcModule.destroyMessage(response);
1160 void GenericCommunicator::SetSurfaceDestinationRegion(t_ilm_message message)
1162 t_ilm_message response;
1163 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1164 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1171 m_ipcModule.getUint(message, &id);
1172 m_ipcModule.getUint(message, &x);
1173 m_ipcModule.getUint(message, &y);
1174 m_ipcModule.getUint(message, &width);
1175 m_ipcModule.getUint(message, &height);
1177 t_ilm_bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1180 response = m_ipcModule.createResponse(message);
1184 response = m_ipcModule.createErrorResponse(message);
1185 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1188 m_ipcModule.sendToClients(response, &clientHandle, 1);
1189 m_ipcModule.destroyMessage(response);
1192 void GenericCommunicator::SetSurfacePosition(t_ilm_message message)
1194 t_ilm_message response;
1195 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1196 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1201 m_ipcModule.getUint(message, &id);
1202 m_ipcModule.getUint(message, &x);
1203 m_ipcModule.getUint(message, &y);
1205 t_ilm_bool status = m_executor->execute(new SurfaceSetPositionCommand(clientPid, id, x, y));
1208 response = m_ipcModule.createResponse(message);
1212 response = m_ipcModule.createErrorResponse(message);
1213 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1216 m_ipcModule.sendToClients(response, &clientHandle, 1);
1217 m_ipcModule.destroyMessage(response);
1220 void GenericCommunicator::GetSurfacePosition(t_ilm_message message)
1222 t_ilm_message response;
1223 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1224 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1229 m_ipcModule.getUint(message, &id);
1231 t_ilm_bool status = m_executor->execute(new SurfaceGetPositionCommand(clientPid, id, &x, &y));
1234 response = m_ipcModule.createResponse(message);
1235 m_ipcModule.appendUint(response, x);
1236 m_ipcModule.appendUint(response, y);
1240 response = m_ipcModule.createErrorResponse(message);
1241 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1244 m_ipcModule.sendToClients(response, &clientHandle, 1);
1245 m_ipcModule.destroyMessage(response);
1248 void GenericCommunicator::SetSurfaceDimension(t_ilm_message message)
1250 t_ilm_message response;
1251 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1252 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1257 m_ipcModule.getUint(message, &id);
1258 m_ipcModule.getUint(message, &width);
1259 m_ipcModule.getUint(message, &height);
1261 t_ilm_bool status = m_executor->execute(new SurfaceSetDimensionCommand(clientPid, id, width, height));
1264 response = m_ipcModule.createResponse(message);
1268 response = m_ipcModule.createErrorResponse(message);
1269 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1272 m_ipcModule.sendToClients(response, &clientHandle, 1);
1273 m_ipcModule.destroyMessage(response);
1276 void GenericCommunicator::SetLayerDestinationRegion(t_ilm_message message)
1278 t_ilm_message response;
1279 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1280 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1287 m_ipcModule.getUint(message, &id);
1288 m_ipcModule.getUint(message, &x);
1289 m_ipcModule.getUint(message, &y);
1290 m_ipcModule.getUint(message, &width);
1291 m_ipcModule.getUint(message, &height);
1293 t_ilm_bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(clientPid, id, x, y, width, height));
1296 response = m_ipcModule.createResponse(message);
1300 response = m_ipcModule.createErrorResponse(message);
1301 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1304 m_ipcModule.sendToClients(response, &clientHandle, 1);
1305 m_ipcModule.destroyMessage(response);
1308 void GenericCommunicator::SetLayerPosition(t_ilm_message message)
1310 t_ilm_message response;
1311 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1312 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1317 m_ipcModule.getUint(message, &id);
1318 m_ipcModule.getUint(message, &x);
1319 m_ipcModule.getUint(message, &y);
1321 t_ilm_bool status = m_executor->execute(new LayerSetPositionCommand(clientPid, id, x, y));
1324 response = m_ipcModule.createResponse(message);
1328 response = m_ipcModule.createErrorResponse(message);
1329 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1332 m_ipcModule.sendToClients(response, &clientHandle, 1);
1333 m_ipcModule.destroyMessage(response);
1336 void GenericCommunicator::GetLayerPosition(t_ilm_message message)
1338 t_ilm_message response;
1339 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1340 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1345 m_ipcModule.getUint(message, &id);
1347 t_ilm_bool status = m_executor->execute(new LayerGetPositionCommand(clientPid, id, &x, &y));
1350 response = m_ipcModule.createResponse(message);
1351 m_ipcModule.appendUint(response, x);
1352 m_ipcModule.appendUint(response, y);
1356 response = m_ipcModule.createErrorResponse(message);
1357 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1360 m_ipcModule.sendToClients(response, &clientHandle, 1);
1361 m_ipcModule.destroyMessage(response);
1364 void GenericCommunicator::SetLayerDimension(t_ilm_message message)
1366 t_ilm_message response;
1367 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1368 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1373 m_ipcModule.getUint(message, &id);
1374 m_ipcModule.getUint(message, &width);
1375 m_ipcModule.getUint(message, &height);
1377 t_ilm_bool status = m_executor->execute(new LayerSetDimensionCommand(clientPid, id, width, height));
1380 response = m_ipcModule.createResponse(message);
1384 response = m_ipcModule.createErrorResponse(message);
1385 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1388 m_ipcModule.sendToClients(response, &clientHandle, 1);
1389 m_ipcModule.destroyMessage(response);
1392 void GenericCommunicator::GetLayerDimension(t_ilm_message message)
1394 t_ilm_message response;
1395 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1396 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1401 m_ipcModule.getUint(message, &id);
1403 t_ilm_bool status = m_executor->execute(new LayerGetDimensionCommand(clientPid, id, &width, &height));
1406 response = m_ipcModule.createResponse(message);
1407 m_ipcModule.appendUint(response, width);
1408 m_ipcModule.appendUint(response, height);
1412 response = m_ipcModule.createErrorResponse(message);
1413 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1416 m_ipcModule.sendToClients(response, &clientHandle, 1);
1417 m_ipcModule.destroyMessage(response);
1420 void GenericCommunicator::GetSurfaceDimension(t_ilm_message message)
1422 t_ilm_message response;
1423 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1424 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1429 m_ipcModule.getUint(message, &id);
1431 t_ilm_bool status = m_executor->execute(new SurfaceGetDimensionCommand(clientPid, id, &width, &height));
1434 response = m_ipcModule.createResponse(message);
1435 m_ipcModule.appendUint(response, width);
1436 m_ipcModule.appendUint(response, height);
1440 response = m_ipcModule.createErrorResponse(message);
1441 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1444 m_ipcModule.sendToClients(response, &clientHandle, 1);
1445 m_ipcModule.destroyMessage(response);
1448 void GenericCommunicator::SetSurfaceOpacity(t_ilm_message message)
1450 t_ilm_message response;
1451 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1452 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1456 m_ipcModule.getUint(message, &id);
1457 m_ipcModule.getDouble(message, ¶m);
1459 t_ilm_bool status = m_executor->execute(new SurfaceSetOpacityCommand(clientPid, id, param));
1462 response = m_ipcModule.createResponse(message);
1466 response = m_ipcModule.createErrorResponse(message);
1467 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1470 m_ipcModule.sendToClients(response, &clientHandle, 1);
1471 m_ipcModule.destroyMessage(response);
1474 void GenericCommunicator::SetLayerOpacity(t_ilm_message message)
1476 t_ilm_message response;
1477 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1478 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1482 m_ipcModule.getUint(message, &id);
1483 m_ipcModule.getDouble(message, ¶m);
1485 t_ilm_bool status = m_executor->execute(new LayerSetOpacityCommand(clientPid, id, param));
1488 response = m_ipcModule.createResponse(message);
1492 response = m_ipcModule.createErrorResponse(message);
1493 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1496 m_ipcModule.sendToClients(response, &clientHandle, 1);
1497 m_ipcModule.destroyMessage(response);
1500 void GenericCommunicator::GetSurfaceOpacity(t_ilm_message message)
1502 t_ilm_message response;
1503 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1504 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1508 m_ipcModule.getUint(message, &id);
1510 t_ilm_bool status = m_executor->execute(new SurfaceGetOpacityCommand(clientPid, id, ¶m));
1513 response = m_ipcModule.createResponse(message);
1514 m_ipcModule.appendDouble(response, param);
1518 response = m_ipcModule.createErrorResponse(message);
1519 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1522 m_ipcModule.sendToClients(response, &clientHandle, 1);
1523 m_ipcModule.destroyMessage(response);
1526 void GenericCommunicator::GetLayerOpacity(t_ilm_message message)
1528 t_ilm_message response;
1529 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1530 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1534 m_ipcModule.getUint(message, &id);
1536 t_ilm_bool status = m_executor->execute(new LayerGetOpacityCommand(clientPid, id, ¶m));
1539 response = m_ipcModule.createResponse(message);
1540 m_ipcModule.appendDouble(response, param);
1544 response = m_ipcModule.createErrorResponse(message);
1545 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1548 m_ipcModule.sendToClients(response, &clientHandle, 1);
1549 m_ipcModule.destroyMessage(response);
1552 void GenericCommunicator::SetSurfaceOrientation(t_ilm_message message)
1554 t_ilm_message response;
1555 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1556 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1559 OrientationType o = Zero;
1561 m_ipcModule.getUint(message, &id);
1562 m_ipcModule.getUint(message, ¶m);
1564 o = (OrientationType) param;
1566 t_ilm_bool status = m_executor->execute(new SurfaceSetOrientationCommand(clientPid, id, o));
1569 response = m_ipcModule.createResponse(message);
1573 response = m_ipcModule.createErrorResponse(message);
1574 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1577 m_ipcModule.sendToClients(response, &clientHandle, 1);
1578 m_ipcModule.destroyMessage(response);
1581 void GenericCommunicator::GetSurfaceOrientation(t_ilm_message message)
1583 t_ilm_message response;
1584 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1585 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1589 m_ipcModule.getUint(message, &id);
1591 t_ilm_bool status = m_executor->execute(new SurfaceGetOrientationCommand(clientPid, id, &o));
1594 response = m_ipcModule.createResponse(message);
1595 m_ipcModule.appendUint(response, o);
1599 response = m_ipcModule.createErrorResponse(message);
1600 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1603 m_ipcModule.sendToClients(response, &clientHandle, 1);
1604 m_ipcModule.destroyMessage(response);
1607 void GenericCommunicator::SetLayerOrientation(t_ilm_message message)
1609 t_ilm_message response;
1610 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1611 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1614 OrientationType o = Zero;
1616 m_ipcModule.getUint(message, &id);
1617 m_ipcModule.getUint(message, ¶m);
1619 o = (OrientationType) param;
1621 t_ilm_bool status = m_executor->execute(new LayerSetOrientationCommand(clientPid, id, o));
1624 response = m_ipcModule.createResponse(message);
1628 response = m_ipcModule.createErrorResponse(message);
1629 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1632 m_ipcModule.sendToClients(response, &clientHandle, 1);
1633 m_ipcModule.destroyMessage(response);
1636 void GenericCommunicator::GetLayerOrientation(t_ilm_message message)
1638 t_ilm_message response;
1639 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1640 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1644 m_ipcModule.getUint(message, &id);
1646 t_ilm_bool status = m_executor->execute(new LayerGetOrientationCommand(clientPid, id, &o));
1649 response = m_ipcModule.createResponse(message);
1650 m_ipcModule.appendUint(response, o);
1654 response = m_ipcModule.createErrorResponse(message);
1655 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1658 m_ipcModule.sendToClients(response, &clientHandle, 1);
1659 m_ipcModule.destroyMessage(response);
1662 void GenericCommunicator::GetSurfacePixelformat(t_ilm_message message)
1664 t_ilm_message response;
1665 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1666 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1668 PixelFormat pixelFormat;
1670 m_ipcModule.getUint(message, &id);
1672 t_ilm_bool status = m_executor->execute(new SurfaceGetPixelformatCommand(clientPid, id, &pixelFormat));
1675 response = m_ipcModule.createResponse(message);
1676 m_ipcModule.appendUint(response, pixelFormat);
1680 response = m_ipcModule.createErrorResponse(message);
1681 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1684 m_ipcModule.sendToClients(response, &clientHandle, 1);
1685 m_ipcModule.destroyMessage(response);
1688 void GenericCommunicator::SetSurfaceVisibility(t_ilm_message message)
1690 t_ilm_message response;
1691 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1692 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1694 t_ilm_bool newVis = ILM_FALSE;
1696 m_ipcModule.getUint(message, &surfaceid);
1697 m_ipcModule.getBool(message, &newVis);
1699 t_ilm_bool status = m_executor->execute(new SurfaceSetVisibilityCommand(clientPid, surfaceid, newVis));
1702 response = m_ipcModule.createResponse(message);
1706 response = m_ipcModule.createErrorResponse(message);
1707 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1710 m_ipcModule.sendToClients(response, &clientHandle, 1);
1711 m_ipcModule.destroyMessage(response);
1714 void GenericCommunicator::SetLayerVisibility(t_ilm_message message)
1716 t_ilm_message response;
1717 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1718 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1720 t_ilm_bool myparam = ILM_FALSE;
1722 m_ipcModule.getUint(message, &layerid);
1723 m_ipcModule.getBool(message, &myparam);
1725 t_ilm_bool status = m_executor->execute(new LayerSetVisibilityCommand(clientPid, layerid, myparam));
1728 response = m_ipcModule.createResponse(message);
1732 response = m_ipcModule.createErrorResponse(message);
1733 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1736 m_ipcModule.sendToClients(response, &clientHandle, 1);
1737 m_ipcModule.destroyMessage(response);
1740 void GenericCommunicator::GetSurfaceVisibility(t_ilm_message message)
1742 t_ilm_message response;
1743 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1744 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1748 m_ipcModule.getUint(message, &id);
1750 t_ilm_bool status = m_executor->execute(new SurfaceGetVisibilityCommand(clientPid, id, &visibility));
1753 response = m_ipcModule.createResponse(message);
1754 m_ipcModule.appendBool(response, visibility);
1758 response = m_ipcModule.createErrorResponse(message);
1759 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1762 m_ipcModule.sendToClients(response, &clientHandle, 1);
1763 m_ipcModule.destroyMessage(response);
1766 void GenericCommunicator::GetLayerVisibility(t_ilm_message message)
1768 t_ilm_message response;
1769 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1770 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1774 m_ipcModule.getUint(message, &id);
1776 t_ilm_bool status = m_executor->execute(new LayerGetVisibilityCommand(clientPid, id, &visibility));
1779 response = m_ipcModule.createResponse(message);
1780 m_ipcModule.appendBool(response, visibility);
1784 response = m_ipcModule.createErrorResponse(message);
1785 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1788 m_ipcModule.sendToClients(response, &clientHandle, 1);
1789 m_ipcModule.destroyMessage(response);
1792 void GenericCommunicator::SetRenderOrderOfLayers(t_ilm_message message)
1794 t_ilm_message response;
1795 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1796 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1801 m_ipcModule.getUintArray(message, &array, &length);
1802 m_ipcModule.getUint(message, &screenID);
1804 t_ilm_bool status = m_executor->execute(new ScreenSetRenderOrderCommand(clientPid, screenID, array, length));
1807 response = m_ipcModule.createResponse(message);
1811 response = m_ipcModule.createErrorResponse(message);
1812 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1815 m_ipcModule.sendToClients(response, &clientHandle, 1);
1816 m_ipcModule.destroyMessage(response);
1819 void GenericCommunicator::SetSurfaceRenderOrderWithinLayer(t_ilm_message message)
1821 t_ilm_message response;
1822 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1823 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1828 m_ipcModule.getUint(message, &layerid);
1829 m_ipcModule.getUintArray(message, &array, &length);
1831 t_ilm_bool status = m_executor->execute(new LayerSetRenderOrderCommand(clientPid, layerid, array, length));
1834 response = m_ipcModule.createResponse(message);
1838 response = m_ipcModule.createErrorResponse(message);
1839 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1842 m_ipcModule.sendToClients(response, &clientHandle, 1);
1843 m_ipcModule.destroyMessage(response);
1846 void GenericCommunicator::GetLayerType(t_ilm_message message)
1848 t_ilm_message response;
1849 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1851 m_ipcModule.getUint(message, &id);
1853 Layer* layer = m_executor->getScene()->getLayer(id);
1856 response = m_ipcModule.createResponse(message);
1857 m_ipcModule.appendUint(response, layer->getLayerType());
1861 response = m_ipcModule.createErrorResponse(message);
1862 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1865 m_ipcModule.sendToClients(response, &clientHandle, 1);
1866 m_ipcModule.destroyMessage(response);
1869 void GenericCommunicator::GetLayertypeCapabilities(t_ilm_message message)
1871 t_ilm_message response;
1872 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1874 LayerType type = Unknown;
1876 m_ipcModule.getUint(message, &id);
1878 type = (LayerType) id;
1880 uint capabilities = m_executor->getLayerTypeCapabilities(type);
1881 response = m_ipcModule.createResponse(message);
1882 m_ipcModule.appendUint(response, capabilities);
1883 m_ipcModule.sendToClients(response, &clientHandle, 1);
1884 m_ipcModule.destroyMessage(response);
1887 void GenericCommunicator::GetLayerCapabilities(t_ilm_message message)
1889 t_ilm_message response;
1890 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1892 m_ipcModule.getUint(message, &id);
1894 Layer* layer = m_executor->getScene()->getLayer(id);
1897 response = m_ipcModule.createResponse(message);
1898 m_ipcModule.appendUint(response, layer->getCapabilities());
1902 response = m_ipcModule.createErrorResponse(message);
1903 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
1906 m_ipcModule.sendToClients(response, &clientHandle, 1);
1907 m_ipcModule.destroyMessage(response);
1910 void GenericCommunicator::FadeIn(t_ilm_message message)
1912 t_ilm_message response;
1913 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1914 response = m_ipcModule.createErrorResponse(message);
1915 m_ipcModule.appendString(response, NOT_IMPLEMENTED);
1916 m_ipcModule.sendToClients(response, &clientHandle, 1);
1917 m_ipcModule.destroyMessage(response);
1920 void GenericCommunicator::SynchronizedFade(t_ilm_message message)
1922 t_ilm_message response;
1923 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1924 response = m_ipcModule.createErrorResponse(message);
1925 m_ipcModule.appendString(response, NOT_IMPLEMENTED);
1926 m_ipcModule.sendToClients(response, &clientHandle, 1);
1927 m_ipcModule.destroyMessage(response);
1930 void GenericCommunicator::FadeOut(t_ilm_message message)
1932 t_ilm_message response;
1933 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1934 response = m_ipcModule.createErrorResponse(message);
1935 m_ipcModule.appendString(response, NOT_IMPLEMENTED);
1936 m_ipcModule.sendToClients(response, &clientHandle, 1);
1937 m_ipcModule.destroyMessage(response);
1940 void GenericCommunicator::Exit(t_ilm_message message)
1942 t_ilm_message response;
1943 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1944 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1945 t_ilm_bool status = m_executor->execute(new ExitCommand(clientPid));
1948 response = m_ipcModule.createResponse(message);
1952 response = m_ipcModule.createErrorResponse(message);
1953 m_ipcModule.appendString(response, INVALID_ARGUMENT);
1956 m_ipcModule.sendToClients(response, &clientHandle, 1);
1957 m_ipcModule.destroyMessage(response);
1960 void GenericCommunicator::CommitChanges(t_ilm_message message)
1962 t_ilm_message response;
1963 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1964 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1965 t_ilm_bool status = m_executor->execute(new CommitCommand(clientPid));
1968 response = m_ipcModule.createResponse(message);
1972 response = m_ipcModule.createErrorResponse(message);
1973 m_ipcModule.appendString(response, INVALID_ARGUMENT);
1976 m_ipcModule.sendToClients(response, &clientHandle, 1);
1977 m_ipcModule.destroyMessage(response);
1980 void GenericCommunicator::CreateShader(t_ilm_message message)
1982 t_ilm_message response;
1983 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
1984 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
1985 char vertname[1024];
1986 char fragname[1024];
1989 m_ipcModule.getString(message, vertname);
1990 m_ipcModule.getString(message, fragname);
1992 t_ilm_bool status = m_executor->execute(new ShaderCreateCommand(clientPid, vertname, fragname, &id));
1995 response = m_ipcModule.createResponse(message);
1996 m_ipcModule.appendUint(response, id);
2000 response = m_ipcModule.createErrorResponse(message);
2001 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2004 m_ipcModule.sendToClients(response, &clientHandle, 1);
2005 m_ipcModule.destroyMessage(response);
2008 void GenericCommunicator::DestroyShader(t_ilm_message message)
2010 t_ilm_message response;
2011 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2012 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2015 m_ipcModule.getUint(message, &shaderid);
2017 t_ilm_bool status = m_executor->execute(new ShaderDestroyCommand(clientPid, shaderid));
2020 response = m_ipcModule.createResponse(message);
2024 response = m_ipcModule.createErrorResponse(message);
2025 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2028 m_ipcModule.sendToClients(response, &clientHandle, 1);
2029 m_ipcModule.destroyMessage(response);
2032 void GenericCommunicator::SetShader(t_ilm_message message)
2034 t_ilm_message response;
2035 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2036 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2040 m_ipcModule.getUint(message, &surfaceId);
2041 m_ipcModule.getUint(message, &shaderid);
2043 t_ilm_bool status = m_executor->execute(new SurfaceSetShaderCommand(clientPid, surfaceId, shaderid));
2046 response = m_ipcModule.createResponse(message);
2050 response = m_ipcModule.createErrorResponse(message);
2051 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2054 m_ipcModule.sendToClients(response, &clientHandle, 1);
2055 m_ipcModule.destroyMessage(response);
2058 void GenericCommunicator::SetUniforms(t_ilm_message message)
2060 t_ilm_message response;
2061 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2062 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2064 std::vector<string> uniforms;
2066 m_ipcModule.getUint(message, &id);
2069 //m_ipcModule.getStringArray(&uniforms);
2071 t_ilm_bool status = m_executor->execute(new ShaderSetUniformsCommand(clientPid, id, uniforms));
2074 response = m_ipcModule.createResponse(message);
2078 response = m_ipcModule.createErrorResponse(message);
2079 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2082 m_ipcModule.sendToClients(response, &clientHandle, 1);
2083 m_ipcModule.destroyMessage(response);
2086 void GenericCommunicator::SetKeyboardFocusOn(t_ilm_message message)
2088 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2089 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2090 t_ilm_message response;
2093 m_ipcModule.getUint(message, &surfaceId);
2095 t_ilm_bool status = m_executor->execute(new SurfaceSetKeyboardFocusCommand(clientPid, surfaceId));
2098 response = m_ipcModule.createResponse(message);
2102 response = m_ipcModule.createErrorResponse(message);
2103 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2106 m_ipcModule.sendToClients(response, &clientHandle, 1);
2107 m_ipcModule.destroyMessage(response);
2111 void GenericCommunicator::GetKeyboardFocusSurfaceId(t_ilm_message message)
2113 t_ilm_message response;
2114 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2115 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2118 t_ilm_bool status = m_executor->execute(new SurfaceGetKeyboardFocusCommand(clientPid, &surfaceId));
2121 response = m_ipcModule.createResponse(message);
2122 m_ipcModule.appendUint(response, surfaceId);
2126 response = m_ipcModule.createErrorResponse(message);
2127 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2130 m_ipcModule.sendToClients(response, &clientHandle, 1);
2131 m_ipcModule.destroyMessage(response);
2135 void GenericCommunicator::UpdateInputEventAcceptanceOn(t_ilm_message message)
2137 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2138 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2139 t_ilm_message response;
2142 InputDevice devices;
2145 m_ipcModule.getUint(message, &surfaceId);
2146 m_ipcModule.getUint(message, &udevices);
2147 m_ipcModule.getBool(message, &accept);
2149 devices = (InputDevice) udevices;
2151 t_ilm_bool status = m_executor->execute(new SurfaceUpdateInputEventAcceptance(clientPid, surfaceId, devices, accept));
2154 response = m_ipcModule.createResponse(message);
2158 response = m_ipcModule.createErrorResponse(message);
2159 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2162 m_ipcModule.sendToClients(response, &clientHandle, 1);
2163 m_ipcModule.destroyMessage(response);
2166 void GenericCommunicator::SetSurfaceChromaKey(t_ilm_message message)
2168 t_ilm_message response;
2169 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2170 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2175 m_ipcModule.getUint(message, &surfaceid);
2176 m_ipcModule.getUintArray(message, &array, &length);
2178 t_ilm_bool status = m_executor->execute(new SurfaceSetChromaKeyCommand(clientPid, surfaceid, array, length));
2181 response = m_ipcModule.createResponse(message);
2185 response = m_ipcModule.createErrorResponse(message);
2186 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2189 m_ipcModule.sendToClients(response, &clientHandle, 1);
2190 m_ipcModule.destroyMessage(response);
2193 void GenericCommunicator::SetLayerChromaKey(t_ilm_message message)
2195 t_ilm_message response;
2196 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2197 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2202 m_ipcModule.getUint(message, &layerid);
2203 m_ipcModule.getUintArray(message, &array, &length);
2205 t_ilm_bool status = m_executor->execute(new LayerSetChromaKeyCommand(clientPid, layerid, array, length));
2208 response = m_ipcModule.createResponse(message);
2212 response = m_ipcModule.createErrorResponse(message);
2213 m_ipcModule.appendString(response, RESOURCE_NOT_FOUND);
2216 m_ipcModule.sendToClients(response, &clientHandle, 1);
2217 m_ipcModule.destroyMessage(response);
2220 void GenericCommunicator::LayerAddNotification(t_ilm_message message)
2222 t_ilm_message response;
2223 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2226 m_ipcModule.getUint(message, &layerid);
2228 Layer* layer = m_executor->getScene()->getLayer(layerid);
2231 layer->addNotification(clientHandle);
2232 response = m_ipcModule.createResponse(message);
2236 response = m_ipcModule.createErrorResponse(message);
2237 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2240 m_ipcModule.sendToClients(response, &clientHandle, 1);
2241 m_ipcModule.destroyMessage(response);
2244 void GenericCommunicator::SurfaceAddNotification(t_ilm_message message)
2246 t_ilm_message response;
2247 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2250 m_ipcModule.getUint(message, &surfaceid);
2252 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2255 surface->addNotification(clientHandle);
2256 response = m_ipcModule.createResponse(message);
2260 response = m_ipcModule.createErrorResponse(message);
2261 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2264 m_ipcModule.sendToClients(response, &clientHandle, 1);
2265 m_ipcModule.destroyMessage(response);
2268 void GenericCommunicator::LayerRemoveNotification(t_ilm_message message)
2270 t_ilm_message response;
2271 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2274 m_ipcModule.getUint(message, &layerid);
2276 Layer* layer = m_executor->getScene()->getLayer(layerid);
2279 layer->removeNotification(clientHandle);
2280 response = m_ipcModule.createResponse(message);
2284 response = m_ipcModule.createErrorResponse(message);
2285 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2288 m_ipcModule.sendToClients(response, &clientHandle, 1);
2289 m_ipcModule.destroyMessage(response);
2292 void GenericCommunicator::SurfaceRemoveNotification(t_ilm_message message)
2294 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2295 t_ilm_message response;
2298 m_ipcModule.getUint(message, &surfaceid);
2300 Surface* surface = m_executor->getScene()->getSurface(surfaceid);
2303 surface->removeNotification(clientHandle);
2304 response = m_ipcModule.createResponse(message);
2308 response = m_ipcModule.createErrorResponse(message);
2309 m_ipcModule.appendString(response, INVALID_ARGUMENT);
2312 m_ipcModule.sendToClients(response, &clientHandle, 1);
2313 m_ipcModule.destroyMessage(response);
2316 void GenericCommunicator::processNotificationQueue()
2318 NotificationQueue& notificationQueue = m_executor->getClientNotificationQueue();
2319 NotificationQueue::iterator iter = notificationQueue.begin();
2320 NotificationQueue::iterator end = notificationQueue.end();
2322 for (; iter != end; ++iter)
2324 GraphicalObject* object = iter->first;
2325 t_ilm_notification_mask mask = iter->second;
2326 sendNotification(object, mask);
2328 notificationQueue.clear();
2331 void GenericCommunicator::sendNotification(GraphicalObject* object, t_ilm_notification_mask mask)
2333 switch (object->type)
2337 Layer* layer = static_cast<Layer*>(object);
2340 ApplicationReferenceList& arl = layer->getNotificationClients();
2344 t_ilm_message notification;
2345 Rectangle dest = layer->getDestinationRegion();
2346 Rectangle src = layer->getSourceRegion();
2347 OrientationType orientation = layer->getOrientation();
2349 unsigned char chromaKeyRed = 0;
2350 unsigned char chromaKeyGreen = 0;
2351 unsigned char chromaKeyBlue = 0;
2352 layer->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2354 std::stringstream notificationName;
2355 notificationName << "NotificationForLayer" << layer->getID();
2357 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2358 m_ipcModule.appendUint(notification, layer->getID());
2359 m_ipcModule.appendUint(notification, mask);
2361 m_ipcModule.appendDouble(notification, layer->getOpacity());
2362 m_ipcModule.appendUint(notification, src.x);
2363 m_ipcModule.appendUint(notification, src.y);
2364 m_ipcModule.appendUint(notification, src.width);
2365 m_ipcModule.appendUint(notification, src.height);
2366 m_ipcModule.appendUint(notification, layer->OriginalSourceWidth);
2367 m_ipcModule.appendUint(notification, layer->OriginalSourceHeight);
2368 m_ipcModule.appendUint(notification, dest.x);
2369 m_ipcModule.appendUint(notification, dest.y);
2370 m_ipcModule.appendUint(notification, dest.width);
2371 m_ipcModule.appendUint(notification, dest.height);
2372 m_ipcModule.appendUint(notification, orientation);
2373 m_ipcModule.appendBool(notification, layer->getVisibility());
2374 m_ipcModule.appendUint(notification, layer->getLayerType());
2375 m_ipcModule.appendBool(notification, layer->getChromaKeyEnabled());
2376 m_ipcModule.appendUint(notification, chromaKeyRed);
2377 m_ipcModule.appendUint(notification, chromaKeyGreen);
2378 m_ipcModule.appendUint(notification, chromaKeyBlue);
2379 m_ipcModule.appendInt(notification, layer->getCreatorPid());
2381 int clientCount = arl.size();
2382 t_ilm_client_handle clientArray[256];
2384 ApplicationReferenceList::iterator iter = arl.begin();
2385 ApplicationReferenceList::iterator end = arl.end();
2387 for (int clientNumber = 0;
2388 iter != end, clientNumber < 256;
2389 ++iter, ++clientNumber)
2391 t_ilm_client_handle client = *iter;
2392 clientArray[clientNumber] = client;
2395 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): layer " << layer->getID() << " was updated.");
2397 if (!m_ipcModule.sendToClients(notification, clientArray, clientCount))
2399 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2402 m_ipcModule.destroyMessage(notification);
2409 Surface* surface = static_cast<Surface*>(object);
2412 ApplicationReferenceList& arl = surface->getNotificationClients();
2416 t_ilm_message notification;
2417 std::stringstream notificationName;
2418 notificationName << "NotificationForSurface" << surface->getID();
2420 unsigned char chromaKeyRed = 0;
2421 unsigned char chromaKeyGreen = 0;
2422 unsigned char chromaKeyBlue = 0;
2423 surface->getChromaKey(chromaKeyRed, chromaKeyGreen, chromaKeyBlue);
2425 notification = m_ipcModule.createNotification(notificationName.str().c_str());
2426 m_ipcModule.appendUint(notification, surface->getID());
2427 m_ipcModule.appendUint(notification, mask);
2429 m_ipcModule.appendDouble(notification, surface->getOpacity());
2430 m_ipcModule.appendUint(notification, surface->getSourceRegion().x);
2431 m_ipcModule.appendUint(notification, surface->getSourceRegion().y);
2432 m_ipcModule.appendUint(notification, surface->getSourceRegion().width);
2433 m_ipcModule.appendUint(notification, surface->getSourceRegion().height);
2434 m_ipcModule.appendUint(notification, surface->OriginalSourceWidth);
2435 m_ipcModule.appendUint(notification, surface->OriginalSourceHeight);
2436 m_ipcModule.appendUint(notification, surface->getDestinationRegion().x);
2437 m_ipcModule.appendUint(notification, surface->getDestinationRegion().y);
2438 m_ipcModule.appendUint(notification, surface->getDestinationRegion().width);
2439 m_ipcModule.appendUint(notification, surface->getDestinationRegion().height);
2440 m_ipcModule.appendUint(notification, surface->getOrientation());
2441 m_ipcModule.appendBool(notification, surface->getVisibility());
2442 m_ipcModule.appendUint(notification, surface->frameCounter);
2443 m_ipcModule.appendUint(notification, surface->drawCounter);
2444 m_ipcModule.appendUint(notification, surface->updateCounter);
2445 m_ipcModule.appendUint(notification, surface->getPixelFormat());
2446 m_ipcModule.appendUint(notification, surface->getNativeContent());
2447 m_ipcModule.appendUint(notification, surface->getInputEventAcceptanceOnDevices());
2448 m_ipcModule.appendBool(notification, surface->getChromaKeyEnabled());
2449 m_ipcModule.appendUint(notification, chromaKeyRed);
2450 m_ipcModule.appendUint(notification, chromaKeyGreen);
2451 m_ipcModule.appendUint(notification, chromaKeyBlue);
2452 m_ipcModule.appendInt(notification, surface->getCreatorPid());
2454 int clientCount = arl.size();
2455 t_ilm_client_handle clients[256];
2457 ApplicationReferenceList::iterator iter = arl.begin();
2458 ApplicationReferenceList::iterator end = arl.end();
2460 for (int clientNumber = 0;
2461 iter != end, clientNumber < 256;
2462 ++iter, ++clientNumber)
2464 clients[clientNumber] = *iter;
2467 LOG_DEBUG("GenericCommunicator", "Sending " << clientCount << " notification(s): surface " << surface->getID() << " was updated.");
2469 if (!m_ipcModule.sendToClients(notification, clients, clientCount))
2471 LOG_ERROR("GenericCommunicator", "Sending notification to clients failed.")
2474 m_ipcModule.destroyMessage(notification);
2480 LOG_INFO("GenericCommunicator", "Unknown notification found in queue.");
2485 HealthCondition GenericCommunicator::pluginGetHealth()
2487 HealthCondition health = PluginBase::pluginGetHealth();
2488 if (0 != pthread_kill(mThreadId, 0))
2490 health = HealthDead;
2495 void GenericCommunicator::SetOptimizationMode(t_ilm_message message)
2497 t_ilm_message response;
2498 OptimizationType optimizationId;
2499 OptimizationModeType optimizationMode;
2501 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2502 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2504 m_ipcModule.getUint(message,&o);
2505 optimizationId = (OptimizationType) o;
2506 m_ipcModule.getUint(message,&o);
2507 optimizationMode = (OptimizationModeType) o;
2509 t_ilm_bool status = m_executor->execute(new SetOptimizationModeCommand(clientPid, optimizationId, optimizationMode));
2512 response = m_ipcModule.createResponse(message);
2516 response = m_ipcModule.createErrorResponse(message);
2517 m_ipcModule.appendString(response,RESOURCE_NOT_FOUND);
2519 m_ipcModule.sendToClients(response,&clientHandle,1);
2520 m_ipcModule.destroyMessage(response);
2523 void GenericCommunicator::GetOptimizationMode(t_ilm_message message)
2525 t_ilm_message response;
2526 t_ilm_client_handle clientHandle = m_ipcModule.getSenderHandle(message);
2527 t_ilm_uint clientPid = m_executor->getSenderPid(clientHandle);
2528 OptimizationType optimizationId;
2529 OptimizationModeType optimizationMode;
2532 m_ipcModule.getUint(message,&o);
2533 optimizationId = (OptimizationType)o;
2535 t_ilm_bool status = m_executor->execute(new GetOptimizationModeCommand(clientPid, optimizationId, &optimizationMode));
2539 response = m_ipcModule.createResponse(message);
2540 m_ipcModule.appendUint(response,(unsigned int)optimizationMode);
2544 response = m_ipcModule.createErrorResponse(message);
2545 m_ipcModule.appendString(response,RESOURCE_NOT_FOUND);
2547 m_ipcModule.sendToClients(response,&clientHandle,1);
2548 m_ipcModule.destroyMessage(response);
2552 DECLARE_LAYERMANAGEMENT_PLUGIN(GenericCommunicator)