1 /***************************************************************************
3 * Copyright 2010,2011 BMW Car IT 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 ****************************************************************************/
19 #include <dbus/dbus.h>
27 #include "DBUSCommunicator.h"
28 #include "DBUSIntrospection.h"
29 #include "DBUSMessageHandler.h"
30 #include "DBUSConfiguration.h"
34 #define DEFAULT_SCREEN 0
36 const char* SERVICE_ERROR = "org.genivi.layermanagementservice.error";
37 const char* RESSOURCE_ALREADY_INUSE = "Ressource already in use";
38 const char* INVALID_ARGUMENT = "Invalid argument";
39 const char* RESSOURCE_NOT_FOUND = "Ressource not found";
43 static DBUSMessageHandler* g_pDbusMessage;
45 static MethodTable manager_methods[] =
47 { "ServiceConnect", "u", "", &DBUSCommunicator::ServiceConnect },
48 { "ServiceDisconnect", "u", "", &DBUSCommunicator::ServiceDisconnect },
49 { "Debug", "b", "", &DBUSCommunicator::Debug },
50 { "ScreenShot", "us", "", &DBUSCommunicator::ScreenShot },
51 { "ScreenShotOfLayer", "su", "", &DBUSCommunicator::ScreenShotOfLayer },
52 { "ScreenShotOfSurface", "su", "", &DBUSCommunicator::ScreenShotOfSurface },
53 { "GetScreenResolution", "u", "uu", &DBUSCommunicator::GetScreenResolution },
54 { "GetNumberOfHardwareLayers", "u", "u", &DBUSCommunicator::GetNumberOfHardwareLayers },
55 { "GetScreenIDs", "", "au", &DBUSCommunicator::GetScreenIDs },
56 { "ListAllLayerIDS", "", "au", &DBUSCommunicator::ListAllLayerIDS },
57 { "ListAllLayerIDsOnScreen", "u", "au", &DBUSCommunicator::ListAllLayerIDsOnScreen },
58 { "ListAllSurfaceIDS", "", "au", &DBUSCommunicator::ListAllSurfaceIDS },
59 { "ListAllLayerGroupIDS", "", "au", &DBUSCommunicator::ListAllLayerGroupIDS },
60 { "ListAllSurfaceGroupIDS", "", "au", &DBUSCommunicator::ListAllSurfaceGroupIDS },
61 { "ListSurfacesOfSurfacegroup", "u", "au", &DBUSCommunicator::ListSurfacesOfSurfacegroup },
62 { "ListLayersOfLayergroup", "u", "au", &DBUSCommunicator::ListLayersOfLayergroup },
63 { "ListSurfaceofLayer", "u", "au", &DBUSCommunicator::ListSurfaceofLayer },
64 { "GetPropertiesOfSurface", "u", "duuuuuuuuuuybu", &DBUSCommunicator::GetPropertiesOfSurface },
65 { "GetPropertiesOfLayer", "u", "duuuuuuuuuuyb", &DBUSCommunicator::GetPropertiesOfLayer },
66 { "CreateSurface", "uuuu", "u", &DBUSCommunicator::CreateSurface },
67 { "CreateSurfaceFromId", "uuuuu", "u", &DBUSCommunicator::CreateSurfaceFromId },
68 { "InitializeSurface", "", "u", &DBUSCommunicator::InitializeSurface },
69 { "InitializeSurfaceFromId", "u", "u", &DBUSCommunicator::InitializeSurfaceFromId },
70 { "SetSurfaceNativeContent", "uuuuu", "", &DBUSCommunicator::SetSurfaceNativeContent },
71 { "RemoveSurface", "u", "", &DBUSCommunicator::RemoveSurface },
72 { "CreateLayer", "", "u", &DBUSCommunicator::CreateLayer },
73 { "CreateLayerFromId", "u", "u", &DBUSCommunicator::CreateLayerFromId },
74 { "CreateLayerWithDimension", "uu", "u", &DBUSCommunicator::CreateLayerWithDimension },
75 { "CreateLayerFromIdWithDimension", "uuu", "u", &DBUSCommunicator::CreateLayerFromIdWithDimension },
76 { "RemoveLayer", "u", "", &DBUSCommunicator::RemoveLayer },
77 { "AddSurfaceToSurfaceGroup", "uu", "", &DBUSCommunicator::AddSurfaceToSurfaceGroup },
78 { "RemoveSurfaceFromSurfaceGroup", "uu", "", &DBUSCommunicator::RemoveSurfaceFromSurfaceGroup },
79 { "AddLayerToLayerGroup", "uu", "", &DBUSCommunicator::AddLayerToLayerGroup },
80 { "RemoveLayerFromLayerGroup", "uu", "", &DBUSCommunicator::RemoveLayerFromLayerGroup },
81 { "AddSurfaceToLayer", "uu", "", &DBUSCommunicator::AddSurfaceToLayer },
82 { "RemoveSurfaceFromLayer", "uu", "", &DBUSCommunicator::RemoveSurfaceFromLayer },
83 { "CreateSurfaceGroup", "", "u", &DBUSCommunicator::CreateSurfaceGroup },
84 { "CreateSurfaceGroupFromId", "u", "u", &DBUSCommunicator::CreateSurfaceGroupFromId },
85 { "RemoveSurfaceGroup", "u", "", &DBUSCommunicator::RemoveSurfaceGroup },
86 { "CreateLayerGroup", "", "u", &DBUSCommunicator::CreateLayerGroup },
87 { "CreateLayerGroupFromId", "u", "u", &DBUSCommunicator::CreateLayerGroupFromId },
88 { "RemoveLayerGroup", "u", "", &DBUSCommunicator::RemoveLayerGroup },
89 { "SetSurfaceSourceRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceSourceRegion },
90 { "SetLayerSourceRegion", "uuuuu", "", &DBUSCommunicator::SetLayerSourceRegion },
91 { "SetSurfaceDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceDestinationRegion },
92 { "SetSurfacePosition", "uuu", "", &DBUSCommunicator::SetSurfacePosition },
93 { "GetSurfacePosition", "u", "uu", &DBUSCommunicator::GetSurfacePosition },
94 { "SetSurfaceDimension", "uuu", "", &DBUSCommunicator::SetSurfaceDimension },
95 { "SetLayerDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetLayerDestinationRegion },
96 { "SetLayerPosition", "uuu", "", &DBUSCommunicator::SetLayerPosition },
97 { "GetLayerPosition", "u", "uu", &DBUSCommunicator::GetLayerPosition },
98 { "SetLayerDimension", "uuu", "", &DBUSCommunicator::SetLayerDimension },
99 { "GetLayerDimension", "u", "uu", &DBUSCommunicator::GetLayerDimension },
100 { "GetSurfaceDimension", "u", "uu", &DBUSCommunicator::GetSurfaceDimension },
101 { "SetSurfaceOpacity", "ud", "", &DBUSCommunicator::SetSurfaceOpacity },
102 { "SetLayerOpacity", "ud", "", &DBUSCommunicator::SetLayerOpacity },
103 { "SetSurfacegroupOpacity", "ud", "", &DBUSCommunicator::SetSurfacegroupOpacity },
104 { "SetLayergroupOpacity", "ud", "", &DBUSCommunicator::SetLayergroupOpacity },
105 { "GetSurfaceOpacity", "u", "d", &DBUSCommunicator::GetSurfaceOpacity },
106 { "GetLayerOpacity", "u", "d", &DBUSCommunicator::GetLayerOpacity },
107 { "SetSurfaceOrientation", "uu", "", &DBUSCommunicator::SetSurfaceOrientation },
108 { "GetSurfaceOrientation", "uu", "", &DBUSCommunicator::GetSurfaceOrientation },
109 { "SetLayerOrientation", "uu", "", &DBUSCommunicator::SetLayerOrientation },
110 { "GetLayerOrientation", "uu", "", &DBUSCommunicator::GetLayerOrientation },
111 { "GetSurfacePixelformat", "u", "u", &DBUSCommunicator::GetSurfacePixelformat },
112 { "SetSurfaceVisibility", "ub", "", &DBUSCommunicator::SetSurfaceVisibility },
113 { "SetLayerVisibility", "ub", "", &DBUSCommunicator::SetLayerVisibility },
114 { "GetSurfaceVisibility", "u", "b", &DBUSCommunicator::GetSurfaceVisibility },
115 { "GetLayerVisibility", "u", "b", &DBUSCommunicator::GetLayerVisibility },
116 { "SetSurfacegroupVisibility", "ub", "", &DBUSCommunicator::SetSurfacegroupVisibility },
117 { "SetLayergroupVisibility", "ub", "", &DBUSCommunicator::SetLayergroupVisibility },
118 { "SetRenderOrderOfLayers", "auu", "", &DBUSCommunicator::SetRenderOrderOfLayers },
119 { "SetSurfaceRenderOrderWithinLayer", "uau", "", &DBUSCommunicator::SetSurfaceRenderOrderWithinLayer },
120 { "GetLayerType", "u", "u", &DBUSCommunicator::GetLayerType },
121 { "GetLayertypeCapabilities", "u", "u", &DBUSCommunicator::GetLayertypeCapabilities },
122 { "GetLayerCapabilities", "u", "u", &DBUSCommunicator::GetLayerCapabilities },
123 { "Exit", "", "", &DBUSCommunicator::Exit },
124 { "CommitChanges", "", "", &DBUSCommunicator::CommitChanges },
125 { "CreateShader", "ss", "u", &DBUSCommunicator::CreateShader },
126 { "DestroyShader", "u", "", &DBUSCommunicator::DestroyShader },
127 { "SetShader", "uu", "", &DBUSCommunicator::SetShader },
128 { "SetUniforms", "uas", "", &DBUSCommunicator::SetUniforms },
133 using std::stringstream;
138 DBUSCommunicator::DBUSCommunicator(ICommandExecutor* executor)
139 : ICommunicator(executor)
144 void DBUSCommunicator::setdebug(bool onoff)
146 (void)onoff; // TODO: remove, only prevents warning
149 bool DBUSCommunicator::start()
151 LOG_DEBUG("DBUSCommunicator", "Starting up dbus connector");
153 g_pDbusMessage = new DBUSMessageHandler();
155 LOG_DEBUG("DBUSCommunicator","registering for dbus path " << DBUS_SERVICE_OBJECT_PATH);
156 bool registered = g_pDbusMessage->registerPathFunction(DBUSCommunicator::processMessageFunc,
157 DBUSCommunicator::unregisterMessageFunc,
162 LOG_ERROR("DBUSCommunicator","Register Message Callbacks failed");
167 registered = g_pDbusMessage->registerMessageFilter(DBUSCommunicator::processMessageFunc,this);
171 LOG_ERROR("DBUSCommunicator","Register Message Filter failed");
175 LOG_INFO("DBUSCommunicator", "Started dbus connector");
180 void DBUSCommunicator::stop()
182 LOG_INFO("DBUSCommunicator","stopping");
185 g_pDbusMessage->unregisterMessageFilter(DBUSCommunicator::processMessageFunc,this);
186 // deregister dbus messaging implicitly by deleting messageHandler
188 if (g_pDbusMessage != NULL)
190 delete g_pDbusMessage;
194 void DBUSCommunicator::ServiceConnect(DBusConnection* conn, DBusMessage* msg)
196 g_pDbusMessage->initReceive(msg);
197 u_int32_t processId = g_pDbusMessage->getUInt();
198 char* owner = strdup(dbus_message_get_sender(msg));
199 m_executor->addApplicationReference(new IApplicationReference(owner,processId));
200 AddClientWatch(conn,owner);
201 g_pDbusMessage->initReply(msg);
202 g_pDbusMessage->closeReply();
205 void DBUSCommunicator::ServiceDisconnect(DBusConnection* conn, DBusMessage* msg)
207 (void)conn; // TODO: remove, only prevents warning
209 g_pDbusMessage->initReceive(msg);
210 char* owner = strdup(dbus_message_get_sender(msg));
211 RemoveApplicationReference(owner);
212 RemoveClientWatch(conn,owner);
213 g_pDbusMessage->initReply(msg);
214 g_pDbusMessage->closeReply();
217 void DBUSCommunicator::Debug(DBusConnection* conn, DBusMessage* msg)
219 (void)conn; // TODO: remove, only prevents warning
221 g_pDbusMessage->initReceive(msg);
222 bool param = g_pDbusMessage->getBool();
224 bool status = m_executor->execute(new DebugCommand(param));
227 g_pDbusMessage->initReply(msg);
228 g_pDbusMessage->closeReply();
232 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
236 void DBUSCommunicator::GetScreenResolution(DBusConnection* conn, DBusMessage* msg)
238 (void)conn; // TODO: remove, only prevents warning
240 g_pDbusMessage->initReceive(msg);
241 uint screenid = g_pDbusMessage->getUInt();
242 uint* resolution = m_executor->getScreenResolution(screenid);
243 g_pDbusMessage->initReply(msg);
244 g_pDbusMessage->appendUInt(resolution[0]);
245 g_pDbusMessage->appendUInt(resolution[1]);
246 g_pDbusMessage->closeReply();
249 void DBUSCommunicator::GetNumberOfHardwareLayers(DBusConnection* conn, DBusMessage* msg)
251 (void)conn; // TODO: remove, only prevents warning
253 g_pDbusMessage->initReceive(msg);
254 uint screenid = g_pDbusMessage->getUInt();
255 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid);
256 g_pDbusMessage->initReply(msg);
257 g_pDbusMessage->appendUInt(numberOfHardwareLayers);
258 g_pDbusMessage->closeReply();
261 void DBUSCommunicator::GetScreenIDs(DBusConnection* conn, DBusMessage* msg)
263 (void)conn; // TODO: remove, only prevents warning
265 g_pDbusMessage->initReceive(msg);
267 uint* IDs = m_executor->getScreenIDs(&length);
268 g_pDbusMessage->initReply(msg);
269 g_pDbusMessage->appendArrayOfUInt(length, IDs);
270 g_pDbusMessage->closeReply();
273 void DBUSCommunicator::ScreenShot(DBusConnection* conn, DBusMessage* msg)
275 (void)conn; // TODO: remove, only prevents warning
277 g_pDbusMessage->initReceive(msg);
278 uint screenid = g_pDbusMessage->getUInt();
279 char* filename = g_pDbusMessage->getString();
281 bool status = m_executor->execute(new ScreenDumpCommand(filename, screenid));
284 g_pDbusMessage->initReply(msg);
285 g_pDbusMessage->closeReply();
289 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
292 void DBUSCommunicator::process(int timeout_ms)
294 dbus_connection_read_write_dispatch (g_pDbusMessage->getConnection(), timeout_ms);
296 void DBUSCommunicator::ScreenShotOfLayer(DBusConnection* conn, DBusMessage* msg)
298 (void)conn; // TODO: remove, only prevents warning
300 g_pDbusMessage->initReceive(msg);
301 char* filename = g_pDbusMessage->getString();
302 uint layerid = g_pDbusMessage->getUInt();
304 bool status = m_executor->execute(new LayerDumpCommand(filename, layerid));
307 g_pDbusMessage->initReply(msg);
308 g_pDbusMessage->closeReply();
312 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
316 void DBUSCommunicator::ScreenShotOfSurface(DBusConnection* conn, DBusMessage* msg)
318 (void)conn; // TODO: remove, only prevents warning
320 g_pDbusMessage->initReceive(msg);
321 char* filename = g_pDbusMessage->getString();
322 uint id = g_pDbusMessage->getUInt();
323 bool status = m_executor->execute(new SurfaceDumpCommand(filename, id));
326 g_pDbusMessage->initReply(msg);
327 g_pDbusMessage->closeReply();
331 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
335 void DBUSCommunicator::ListAllLayerIDS(DBusConnection* conn, DBusMessage* msg)
337 (void)conn; // TODO: remove, only prevents warning
341 m_executor->getScene()->lockScene();
342 m_executor->getScene()->getLayerIDs(&length, &array);
343 g_pDbusMessage->initReply(msg);
344 g_pDbusMessage->appendArrayOfUInt(length, array);
345 g_pDbusMessage->closeReply();
346 m_executor->getScene()->unlockScene();
349 void DBUSCommunicator::ListAllLayerIDsOnScreen(DBusConnection* conn, DBusMessage* msg)
351 (void)conn; // TODO: remove, only prevents warning
353 g_pDbusMessage->initReceive(msg);
354 uint screenID = g_pDbusMessage->getUInt();
358 m_executor->getScene()->lockScene();
359 bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
362 g_pDbusMessage->initReply(msg);
363 g_pDbusMessage->appendArrayOfUInt(length, array);
364 g_pDbusMessage->closeReply();
368 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
370 m_executor->getScene()->unlockScene();
374 void DBUSCommunicator::ListAllSurfaceIDS(DBusConnection* conn, DBusMessage* msg)
376 (void)conn; // TODO: remove, only prevents warning
380 m_executor->getScene()->lockScene();
381 m_executor->getScene()->getSurfaceIDs(&length, &array);
382 g_pDbusMessage->initReply(msg);
383 g_pDbusMessage->appendArrayOfUInt(length, array);
384 g_pDbusMessage->closeReply();
385 m_executor->getScene()->unlockScene();
388 void DBUSCommunicator::ListAllLayerGroupIDS(DBusConnection* conn, DBusMessage* msg)
390 (void)conn; // TODO: remove, only prevents warning
394 m_executor->getScene()->lockScene();
395 m_executor->getScene()->getLayerGroupIDs(&length, &array);
396 g_pDbusMessage->initReply(msg);
397 g_pDbusMessage->appendArrayOfUInt(length, array);
398 g_pDbusMessage->closeReply();
399 m_executor->getScene()->unlockScene();
402 void DBUSCommunicator::ListAllSurfaceGroupIDS(DBusConnection* conn, DBusMessage* msg)
404 (void)conn; // TODO: remove, only prevents warning
408 m_executor->getScene()->lockScene();
409 m_executor->getScene()->getSurfaceGroupIDs(&length, &array);
410 g_pDbusMessage->initReply(msg);
411 g_pDbusMessage->appendArrayOfUInt(length, array);
412 g_pDbusMessage->closeReply();
413 m_executor->getScene()->unlockScene();
416 void DBUSCommunicator::ListSurfacesOfSurfacegroup(DBusConnection* conn, DBusMessage* msg)
418 (void)conn; // TODO: remove, only prevents warning
420 g_pDbusMessage->initReceive(msg);
421 uint id = g_pDbusMessage->getUInt();
422 m_executor->getScene()->lockScene();
423 SurfaceGroup* sg = m_executor->getScene()->getSurfaceGroup(id);
426 std::list<Surface*> surfaces = sg->getList();
427 uint length = surfaces.size();
428 uint* array = new uint[length];
430 g_pDbusMessage->initReply(msg);
432 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
435 array[arrayPos] = s->getID();
439 g_pDbusMessage->appendArrayOfUInt(length, array);
441 g_pDbusMessage->closeReply();
442 m_executor->getScene()->unlockScene();
446 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
449 DBusHandlerResult DBUSCommunicator::processMessageFunc(DBusConnection* conn,DBusMessage* msg, void *user_data)
451 return ((DBUSCommunicator*)user_data)->delegateMessage(conn,msg);
454 void DBUSCommunicator::unregisterMessageFunc(DBusConnection* conn, void *user_data)
460 void DBUSCommunicator::ListLayersOfLayergroup(DBusConnection* conn, DBusMessage* msg)
462 (void)conn; // TODO: remove, only prevents warning
464 g_pDbusMessage->initReceive(msg);
465 uint id = g_pDbusMessage->getUInt();
466 m_executor->getScene()->lockScene();
467 LayerGroup* sg = m_executor->getScene()->getLayerGroup(id);
470 std::list<Layer*> layers = sg->getList();
472 uint length = layers.size();
473 uint* array = new uint[length];
476 g_pDbusMessage->initReply(msg);
477 for (std::list<Layer*>::const_iterator it = layers.begin(); it != layers.end(); ++it)
480 array[arrayPos] = l->getID();
484 g_pDbusMessage->appendArrayOfUInt(length, array);
486 g_pDbusMessage->closeReply();
487 m_executor->getScene()->unlockScene();
491 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
495 void DBUSCommunicator::ListSurfaceofLayer(DBusConnection* conn, DBusMessage* msg)
497 (void)conn; // TODO: remove, only prevents warning
499 g_pDbusMessage->initReceive(msg);
500 uint id = g_pDbusMessage->getUInt();
501 m_executor->getScene()->lockScene();
502 Layer* layer = m_executor->getScene()->getLayer(id);
505 std::list<Surface*> surfaces = layer->getAllSurfaces();
507 uint length = surfaces.size();
508 uint* array = new uint[length];
511 g_pDbusMessage->initReply(msg);
513 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
516 array[arrayPos] = s->getID();
520 g_pDbusMessage->appendArrayOfUInt(length, array);
522 g_pDbusMessage->closeReply();
526 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
528 m_executor->getScene()->unlockScene();
531 void DBUSCommunicator::GetPropertiesOfSurface(DBusConnection* conn, DBusMessage* msg)
533 (void)conn; // TODO: remove, only prevents warning
535 g_pDbusMessage->initReceive(msg);
536 uint id = g_pDbusMessage->getUInt();
538 Surface* surface = m_executor->getScene()->getSurface(id);
541 Rectangle dest = surface->getDestinationRegion();
542 Rectangle src = surface->getSourceRegion();
543 OrientationType orientation = surface->getOrientation();
545 g_pDbusMessage->initReply(msg);
546 g_pDbusMessage->appendDouble(surface->getOpacity());
547 g_pDbusMessage->appendUInt(src.x);
548 g_pDbusMessage->appendUInt(src.y);
549 g_pDbusMessage->appendUInt(src.width);
550 g_pDbusMessage->appendUInt(src.height);
551 g_pDbusMessage->appendUInt(surface->OriginalSourceWidth);
552 g_pDbusMessage->appendUInt(surface->OriginalSourceHeight);
553 g_pDbusMessage->appendUInt(dest.x);
554 g_pDbusMessage->appendUInt(dest.y);
555 g_pDbusMessage->appendUInt(dest.width);
556 g_pDbusMessage->appendUInt(dest.height);
557 g_pDbusMessage->appendUInt(orientation);
558 g_pDbusMessage->appendBool(surface->getVisibility());
559 g_pDbusMessage->appendUInt(surface->frameCounter);
560 g_pDbusMessage->closeReply();
564 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
568 void DBUSCommunicator::GetPropertiesOfLayer(DBusConnection* conn, DBusMessage* msg)
570 (void)conn; // TODO: remove, only prevents warning
572 g_pDbusMessage->initReceive(msg);
573 uint id = g_pDbusMessage->getUInt();
575 Layer* layer = m_executor->getScene()->getLayer(id);
578 Rectangle dest = layer->getDestinationRegion();
579 Rectangle src = layer->getSourceRegion();
580 OrientationType orientation = layer->getOrientation();
582 g_pDbusMessage->initReply(msg);
583 g_pDbusMessage->appendDouble(layer->getOpacity());
584 g_pDbusMessage->appendUInt(src.x);
585 g_pDbusMessage->appendUInt(src.y);
586 g_pDbusMessage->appendUInt(src.width);
587 g_pDbusMessage->appendUInt(src.height);
588 g_pDbusMessage->appendUInt(layer->OriginalSourceWidth);
589 g_pDbusMessage->appendUInt(layer->OriginalSourceHeight);
590 g_pDbusMessage->appendUInt(dest.x);
591 g_pDbusMessage->appendUInt(dest.y);
592 g_pDbusMessage->appendUInt(dest.width);
593 g_pDbusMessage->appendUInt(dest.height);
594 g_pDbusMessage->appendUInt(orientation);
595 g_pDbusMessage->appendBool(layer->getVisibility());
596 g_pDbusMessage->closeReply();
600 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
604 void DBUSCommunicator::CreateSurface(DBusConnection* conn, DBusMessage* msg)
606 (void)conn; // TODO: remove, only prevents warning
608 (void)conn; // TODO: remove, only prevents warning
610 g_pDbusMessage->initReceive(msg);
611 uint handle = g_pDbusMessage->getUInt();
612 uint width = g_pDbusMessage->getUInt();
613 uint height = g_pDbusMessage->getUInt();
614 uint pixelformat = g_pDbusMessage->getUInt();
615 PixelFormat pf = (PixelFormat) pixelformat;
617 //LOG_DEBUG("DBUSCommunicator::CreateSurface","pixelformat: " << pixelformat);
618 uint id = GraphicalObject::INVALID_ID;
619 /* First of all create the surface */
620 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
621 /* after that apply the native content */
622 status &= m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height));
625 g_pDbusMessage->initReply(msg);
626 g_pDbusMessage->appendUInt(id);
627 g_pDbusMessage->closeReply();
631 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
635 void DBUSCommunicator::CreateSurfaceFromId(DBusConnection* conn, DBusMessage* msg)
637 (void)conn; // TODO: remove, only prevents warning
639 g_pDbusMessage->initReceive(msg);
640 uint handle = g_pDbusMessage->getUInt();
641 uint width = g_pDbusMessage->getUInt();
642 uint height = g_pDbusMessage->getUInt();
643 uint pixelformat = g_pDbusMessage->getUInt();
644 PixelFormat pf = (PixelFormat) pixelformat;
646 //LOG_DEBUG("DBUSCommunicator::CreateSurface","pixelformat: " << pixelformat);
647 uint id = g_pDbusMessage->getUInt();
649 /* First of all create the surface */
650 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
651 /* after that apply the native content */
652 status &= m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height));
656 g_pDbusMessage->initReply(msg);
657 g_pDbusMessage->appendUInt(id);
658 g_pDbusMessage->closeReply();
662 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
666 void DBUSCommunicator::InitializeSurface(DBusConnection* conn, DBusMessage* msg)
668 (void)conn; // TODO: remove, only prevents warning
670 g_pDbusMessage->initReceive(msg);
671 uint id = GraphicalObject::INVALID_ID;
673 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
676 g_pDbusMessage->initReply(msg);
677 g_pDbusMessage->appendUInt(id);
678 g_pDbusMessage->closeReply();
682 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
686 void DBUSCommunicator::InitializeSurfaceFromId(DBusConnection* conn, DBusMessage* msg)
688 (void)conn; // TODO: remove, only prevents warning
690 g_pDbusMessage->initReceive(msg);
691 uint id = g_pDbusMessage->getUInt();
692 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
695 g_pDbusMessage->initReply(msg);
696 g_pDbusMessage->appendUInt(id);
697 g_pDbusMessage->closeReply();
701 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
705 void DBUSCommunicator::SetSurfaceNativeContent(DBusConnection* conn, DBusMessage* msg)
707 (void)conn; // TODO: remove, only prevents warning
709 g_pDbusMessage->initReceive(msg);
710 uint id = g_pDbusMessage->getUInt();
711 uint handle = g_pDbusMessage->getUInt();
712 uint width = g_pDbusMessage->getUInt();
713 uint height = g_pDbusMessage->getUInt();
714 PixelFormat pf = (PixelFormat)g_pDbusMessage->getUInt();
716 bool status = m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height));
719 g_pDbusMessage->initReply(msg);
720 g_pDbusMessage->closeReply();
724 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
728 void DBUSCommunicator::RemoveSurface(DBusConnection* conn, DBusMessage* msg)
730 (void)conn; // TODO: remove, only prevents warning
732 g_pDbusMessage->initReceive(msg);
733 uint param = g_pDbusMessage->getUInt();
734 bool status = m_executor->execute(new SurfaceRemoveCommand(param));
737 g_pDbusMessage->initReply(msg);
738 g_pDbusMessage->closeReply();
742 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
746 void DBUSCommunicator::CreateLayer(DBusConnection* conn, DBusMessage* msg)
748 (void)conn; // TODO: remove, only prevents warning
750 uint id = GraphicalObject::INVALID_ID;
751 // use resolution of default screen as default width and height of layers
752 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
753 bool status = m_executor->execute(new LayerCreateCommand(resolution[0], resolution[1], &id));
756 g_pDbusMessage->initReply(msg);
757 g_pDbusMessage->appendUInt(id);
758 g_pDbusMessage->closeReply();
762 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
766 void DBUSCommunicator::CreateLayerFromId(DBusConnection* conn, DBusMessage* msg)
768 (void)conn; // TODO: remove, only prevents warning
770 uint id = GraphicalObject::INVALID_ID;
771 g_pDbusMessage->initReceive(msg);
772 id = g_pDbusMessage->getUInt();
773 // use resolution of default screen as default width and height of layers
774 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
775 bool status = m_executor->execute(new LayerCreateCommand(resolution[0], resolution[1], &id));
778 g_pDbusMessage->initReply(msg);
779 g_pDbusMessage->appendUInt(id);
780 g_pDbusMessage->closeReply();
784 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
789 void DBUSCommunicator::CreateLayerWithDimension(DBusConnection* conn, DBusMessage* msg)
791 (void)conn; // TODO: remove, only prevents warning
793 g_pDbusMessage->initReceive(msg);
794 uint width = g_pDbusMessage->getUInt();
795 uint height = g_pDbusMessage->getUInt();
797 uint id = GraphicalObject::INVALID_ID;
798 bool status = m_executor->execute(new LayerCreateCommand(width, height, &id));
801 g_pDbusMessage->initReply(msg);
802 g_pDbusMessage->appendUInt(id);
803 g_pDbusMessage->closeReply();
807 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
811 void DBUSCommunicator::CreateLayerFromIdWithDimension(DBusConnection* conn, DBusMessage* msg)
813 (void)conn; // TODO: remove, only prevents warning
815 uint id = GraphicalObject::INVALID_ID;
816 g_pDbusMessage->initReceive(msg);
817 id = g_pDbusMessage->getUInt();
818 uint width = g_pDbusMessage->getUInt();
819 uint height = g_pDbusMessage->getUInt();
820 bool status = m_executor->execute(new LayerCreateCommand(width, height, &id));
823 g_pDbusMessage->initReply(msg);
824 g_pDbusMessage->appendUInt(id);
825 g_pDbusMessage->closeReply();
829 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
833 void DBUSCommunicator::RemoveLayer(DBusConnection* conn, DBusMessage* msg)
835 (void)conn; // TODO: remove, only prevents warning
837 g_pDbusMessage->initReceive(msg);
838 uint param = g_pDbusMessage->getUInt();
839 bool status = m_executor->execute(new LayerRemoveCommand(param));
842 g_pDbusMessage->initReply(msg);
843 g_pDbusMessage->closeReply();
847 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
851 void DBUSCommunicator::AddSurfaceToSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
853 (void)conn; // TODO: remove, only prevents warning
855 g_pDbusMessage->initReceive(msg);
856 uint surfaceid = g_pDbusMessage->getUInt();
857 uint surfacegroupid = g_pDbusMessage->getUInt();
859 bool status = m_executor->execute(new SurfacegroupAddSurfaceCommand(surfacegroupid, surfaceid));
862 g_pDbusMessage->initReply(msg);
863 g_pDbusMessage->closeReply();
867 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
871 void DBUSCommunicator::RemoveSurfaceFromSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
873 (void)conn; // TODO: remove, only prevents warning
875 g_pDbusMessage->initReceive(msg);
876 uint surfaceid = g_pDbusMessage->getUInt();
877 uint surfacegroupid = g_pDbusMessage->getUInt();
879 bool status = m_executor->execute(new SurfacegroupRemoveSurfaceCommand(surfacegroupid, surfaceid));
882 g_pDbusMessage->initReply(msg);
883 g_pDbusMessage->closeReply();
887 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
891 void DBUSCommunicator::AddLayerToLayerGroup(DBusConnection* conn, DBusMessage* msg)
893 (void)conn; // TODO: remove, only prevents warning
895 g_pDbusMessage->initReceive(msg);
896 uint layerid = g_pDbusMessage->getUInt();
897 uint layergroupid = g_pDbusMessage->getUInt();
899 bool status = m_executor->execute(new LayergroupAddLayerCommand(layergroupid, layerid));
902 g_pDbusMessage->initReply(msg);
903 g_pDbusMessage->closeReply();
907 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
911 void DBUSCommunicator::RemoveLayerFromLayerGroup(DBusConnection* conn, DBusMessage* msg)
913 (void)conn; // TODO: remove, only prevents warning
915 g_pDbusMessage->initReceive(msg);
916 uint layerid = g_pDbusMessage->getUInt();
917 uint layergroupid = g_pDbusMessage->getUInt();
919 bool status = m_executor->execute(new LayergroupRemoveLayerCommand(layergroupid, layerid));
922 g_pDbusMessage->initReply(msg);
923 g_pDbusMessage->closeReply();
927 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
931 void DBUSCommunicator::AddSurfaceToLayer(DBusConnection* conn, DBusMessage* msg)
933 (void)conn; // TODO: remove, only prevents warning
935 g_pDbusMessage->initReceive(msg);
936 uint surfaceid = g_pDbusMessage->getUInt();
937 uint layer = g_pDbusMessage->getUInt();
939 bool status = m_executor->execute(new LayerAddSurfaceCommand(layer, surfaceid));
942 g_pDbusMessage->initReply(msg);
943 g_pDbusMessage->closeReply();
947 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
951 void DBUSCommunicator::RemoveSurfaceFromLayer(DBusConnection* conn, DBusMessage* msg)
953 (void)conn; // TODO: remove, only prevents warning
955 g_pDbusMessage->initReceive(msg);
956 uint surfaceid = g_pDbusMessage->getUInt();
957 uint layerid = g_pDbusMessage->getUInt();
959 bool status = m_executor->execute(new LayerRemoveSurfaceCommand(layerid, surfaceid));
962 g_pDbusMessage->initReply(msg);
963 g_pDbusMessage->closeReply();
967 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
971 void DBUSCommunicator::CreateSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
973 (void)conn; // TODO: remove, only prevents warning
975 uint newID = GraphicalObject::INVALID_ID;
977 bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID));
980 g_pDbusMessage->initReply(msg);
981 g_pDbusMessage->appendUInt(newID);
982 g_pDbusMessage->closeReply();
986 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
990 void DBUSCommunicator::CreateSurfaceGroupFromId(DBusConnection* conn, DBusMessage* msg)
992 (void)conn; // TODO: remove, only prevents warning
994 uint newID = GraphicalObject::INVALID_ID;
995 g_pDbusMessage->initReceive(msg);
996 newID = g_pDbusMessage->getUInt();
998 bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID));
1001 g_pDbusMessage->initReply(msg);
1002 g_pDbusMessage->appendUInt(newID);
1003 g_pDbusMessage->closeReply();
1007 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
1011 void DBUSCommunicator::RemoveSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
1013 (void)conn; // TODO: remove, only prevents warning
1015 g_pDbusMessage->initReceive(msg);
1016 uint param = g_pDbusMessage->getUInt();
1018 bool status = m_executor->execute(new SurfacegroupRemoveCommand(param));
1021 g_pDbusMessage->initReply(msg);
1022 g_pDbusMessage->closeReply();
1026 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1030 void DBUSCommunicator::CreateLayerGroup(DBusConnection* conn, DBusMessage* msg)
1032 (void)conn; // TODO: remove, only prevents warning
1034 uint newID = GraphicalObject::INVALID_ID;
1036 bool status = m_executor->execute(new LayergroupCreateCommand(&newID));
1039 g_pDbusMessage->initReply(msg);
1040 g_pDbusMessage->appendUInt(newID);
1041 g_pDbusMessage->closeReply();
1045 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
1049 void DBUSCommunicator::CreateLayerGroupFromId(DBusConnection* conn, DBusMessage* msg)
1051 (void)conn; // TODO: remove, only prevents warning
1053 uint newID = GraphicalObject::INVALID_ID;
1054 g_pDbusMessage->initReceive(msg);
1055 newID = g_pDbusMessage->getUInt();
1057 bool status = m_executor->execute(new LayergroupCreateCommand(&newID));
1060 g_pDbusMessage->initReply(msg);
1061 g_pDbusMessage->appendUInt(newID);
1062 g_pDbusMessage->closeReply();
1066 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
1070 void DBUSCommunicator::RemoveLayerGroup(DBusConnection* conn, DBusMessage* msg)
1072 (void)conn; // TODO: remove, only prevents warning
1074 g_pDbusMessage->initReceive(msg);
1075 uint param = g_pDbusMessage->getUInt();
1077 bool status = m_executor->execute(new LayergroupRemoveCommand(param));
1080 g_pDbusMessage->initReply(msg);
1081 g_pDbusMessage->closeReply();
1085 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1089 void DBUSCommunicator::SetSurfaceSourceRegion(DBusConnection* conn, DBusMessage* msg)
1091 (void)conn; // TODO: remove, only prevents warning
1093 g_pDbusMessage->initReceive(msg);
1094 uint id = g_pDbusMessage->getUInt();
1095 uint x = g_pDbusMessage->getUInt();
1096 uint y = g_pDbusMessage->getUInt();
1097 uint width = g_pDbusMessage->getUInt();
1098 uint height = g_pDbusMessage->getUInt();
1100 bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(id, x, y, width, height));
1103 g_pDbusMessage->initReply(msg);
1104 g_pDbusMessage->closeReply();
1108 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1112 void DBUSCommunicator::SetLayerSourceRegion(DBusConnection* conn, DBusMessage* msg)
1114 (void)conn; // TODO: remove, only prevents warning
1116 g_pDbusMessage->initReceive(msg);
1117 uint id = g_pDbusMessage->getUInt();
1118 uint x = g_pDbusMessage->getUInt();
1119 uint y = g_pDbusMessage->getUInt();
1120 uint width = g_pDbusMessage->getUInt();
1121 uint height = g_pDbusMessage->getUInt();
1123 //LOG_DEBUG("DBUSC","new SetSourceRectangleCommand with arguments: " <<id <<" " << x <<" "<< y <<" "<< width <<" "<< height );
1124 bool status = m_executor->execute(new LayerSetSourceRectangleCommand(id, x, y, width, height));
1127 g_pDbusMessage->initReply(msg);
1128 g_pDbusMessage->closeReply();
1132 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1136 void DBUSCommunicator::SetSurfaceDestinationRegion(DBusConnection* conn, DBusMessage* msg)
1138 (void)conn; // TODO: remove, only prevents warning
1140 g_pDbusMessage->initReceive(msg);
1141 uint id = g_pDbusMessage->getUInt();
1142 uint x = g_pDbusMessage->getUInt();
1143 uint y = g_pDbusMessage->getUInt();
1144 uint width = g_pDbusMessage->getUInt();
1145 uint height = g_pDbusMessage->getUInt();
1147 bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(id, x, y, width, height));
1150 g_pDbusMessage->initReply(msg);
1151 g_pDbusMessage->closeReply();
1155 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1159 void DBUSCommunicator::SetSurfacePosition(DBusConnection* conn, DBusMessage* msg)
1161 (void)conn; // TODO: remove, only prevents warning
1163 g_pDbusMessage->initReceive(msg);
1164 uint id = g_pDbusMessage->getUInt();
1165 uint x = g_pDbusMessage->getUInt();
1166 uint y = g_pDbusMessage->getUInt();
1168 bool status = m_executor->execute(new SurfaceSetPositionCommand(id, x, y));
1171 g_pDbusMessage->initReply(msg);
1172 g_pDbusMessage->closeReply();
1176 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1180 void DBUSCommunicator::GetSurfacePosition(DBusConnection* conn, DBusMessage* msg)
1182 (void)conn; // TODO: remove, only prevents warning
1184 g_pDbusMessage->initReceive(msg);
1185 uint id = g_pDbusMessage->getUInt();
1189 bool status = m_executor->execute(new SurfaceGetPositionCommand(id, &x, &y));
1192 g_pDbusMessage->initReply(msg);
1193 g_pDbusMessage->appendUInt(x);
1194 g_pDbusMessage->appendUInt(y);
1195 g_pDbusMessage->closeReply();
1199 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1203 void DBUSCommunicator::SetSurfaceDimension(DBusConnection* conn, DBusMessage* msg)
1205 (void)conn; // TODO: remove, only prevents warning
1207 g_pDbusMessage->initReceive(msg);
1208 uint id = g_pDbusMessage->getUInt();
1209 uint width = g_pDbusMessage->getUInt();
1210 uint height = g_pDbusMessage->getUInt();
1212 bool status = m_executor->execute(new SurfaceSetDimensionCommand(id, width, height));
1215 g_pDbusMessage->initReply(msg);
1216 g_pDbusMessage->closeReply();
1220 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1224 void DBUSCommunicator::SetLayerDestinationRegion(DBusConnection* conn, DBusMessage* msg)
1226 (void)conn; // TODO: remove, only prevents warning
1228 g_pDbusMessage->initReceive(msg);
1229 uint id = g_pDbusMessage->getUInt();
1230 uint x = g_pDbusMessage->getUInt();
1231 uint y = g_pDbusMessage->getUInt();
1232 uint width = g_pDbusMessage->getUInt();
1233 uint height = g_pDbusMessage->getUInt();
1235 bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(id, x, y, width, height));
1238 g_pDbusMessage->initReply(msg);
1239 g_pDbusMessage->closeReply();
1243 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1247 void DBUSCommunicator::SetLayerPosition(DBusConnection* conn, DBusMessage* msg)
1249 (void)conn; // TODO: remove, only prevents warning
1251 g_pDbusMessage->initReceive(msg);
1252 uint id = g_pDbusMessage->getUInt();
1253 uint x = g_pDbusMessage->getUInt();
1254 uint y = g_pDbusMessage->getUInt();
1256 bool status = m_executor->execute(new LayerSetPositionCommand(id, x, y));
1259 g_pDbusMessage->initReply(msg);
1260 g_pDbusMessage->closeReply();
1264 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1268 void DBUSCommunicator::GetLayerPosition(DBusConnection* conn, DBusMessage* msg)
1270 (void)conn; // TODO: remove, only prevents warning
1272 g_pDbusMessage->initReceive(msg);
1273 uint id = g_pDbusMessage->getUInt();
1277 bool status = m_executor->execute(new LayerGetPositionCommand(id, &x, &y));
1280 g_pDbusMessage->initReply(msg);
1281 g_pDbusMessage->appendUInt(x);
1282 g_pDbusMessage->appendUInt(y);
1283 g_pDbusMessage->closeReply();
1287 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1291 void DBUSCommunicator::SetLayerDimension(DBusConnection* conn, DBusMessage* msg)
1293 (void)conn; // TODO: remove, only prevents warning
1295 g_pDbusMessage->initReceive(msg);
1296 uint id = g_pDbusMessage->getUInt();
1297 uint width = g_pDbusMessage->getUInt();
1298 uint height = g_pDbusMessage->getUInt();
1300 bool status = m_executor->execute(new LayerSetDimensionCommand(id, width, height));
1303 g_pDbusMessage->initReply(msg);
1304 g_pDbusMessage->closeReply();
1308 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1312 void DBUSCommunicator::GetLayerDimension(DBusConnection* conn, DBusMessage* msg)
1314 (void)conn; // TODO: remove, only prevents warning
1316 g_pDbusMessage->initReceive(msg);
1317 uint id = g_pDbusMessage->getUInt();
1321 bool status = m_executor->execute(new LayerGetDimensionCommand(id, &width, &height));
1324 g_pDbusMessage->initReply(msg);
1325 g_pDbusMessage->appendUInt(width);
1326 g_pDbusMessage->appendUInt(height);
1327 g_pDbusMessage->closeReply();
1331 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1335 void DBUSCommunicator::GetSurfaceDimension(DBusConnection* conn, DBusMessage* msg)
1337 (void)conn; // TODO: remove, only prevents warning
1339 g_pDbusMessage->initReceive(msg);
1340 uint id = g_pDbusMessage->getUInt();
1344 bool status = m_executor->execute(new SurfaceGetDimensionCommand(id, &width, &height));
1347 g_pDbusMessage->initReply(msg);
1348 g_pDbusMessage->appendUInt(width);
1349 g_pDbusMessage->appendUInt(height);
1350 g_pDbusMessage->closeReply();
1354 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1358 void DBUSCommunicator::SetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg)
1360 (void)conn; // TODO: remove, only prevents warning
1362 g_pDbusMessage->initReceive(msg);
1363 uint id = g_pDbusMessage->getUInt();
1364 double param = g_pDbusMessage->getDouble();
1366 bool status = m_executor->execute(new SurfaceSetOpacityCommand(id, param));
1369 g_pDbusMessage->initReply(msg);
1370 g_pDbusMessage->closeReply();
1374 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1378 void DBUSCommunicator::SetLayerOpacity(DBusConnection* conn, DBusMessage* msg)
1380 (void)conn; // TODO: remove, only prevents warning
1382 g_pDbusMessage->initReceive(msg);
1383 uint id = g_pDbusMessage->getUInt();
1384 double param = g_pDbusMessage->getDouble();
1386 bool status = m_executor->execute(new LayerSetOpacityCommand(id, param));
1389 g_pDbusMessage->initReply(msg);
1390 g_pDbusMessage->closeReply();
1394 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1398 void DBUSCommunicator::SetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg)
1400 (void)conn; // TODO: remove, only prevents warning
1402 g_pDbusMessage->initReceive(msg);
1403 uint id = g_pDbusMessage->getUInt();
1404 double param = g_pDbusMessage->getDouble();
1406 bool status = m_executor->execute(new SurfacegroupSetOpacityCommand(id, param));
1409 g_pDbusMessage->initReply(msg);
1410 g_pDbusMessage->closeReply();
1414 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1418 void DBUSCommunicator::SetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg)
1420 (void)conn; // TODO: remove, only prevents warning
1422 g_pDbusMessage->initReceive(msg);
1423 uint id = g_pDbusMessage->getUInt();
1424 double param = g_pDbusMessage->getDouble();
1426 bool status = m_executor->execute(new LayergroupSetOpacityCommand(id, param));
1429 g_pDbusMessage->initReply(msg);
1430 g_pDbusMessage->closeReply();
1434 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1438 void DBUSCommunicator::GetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg)
1440 (void)conn; // TODO: remove, only prevents warning
1442 g_pDbusMessage->initReceive(msg);
1443 uint id = g_pDbusMessage->getUInt();
1446 bool status = m_executor->execute(new SurfaceGetOpacityCommand(id, ¶m));
1449 g_pDbusMessage->initReply(msg);
1450 g_pDbusMessage->appendDouble(param);
1451 g_pDbusMessage->closeReply();
1455 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1459 void DBUSCommunicator::GetLayerOpacity(DBusConnection* conn, DBusMessage* msg)
1461 (void)conn; // TODO: remove, only prevents warning
1463 g_pDbusMessage->initReceive(msg);
1464 uint id = g_pDbusMessage->getUInt();
1467 bool status = m_executor->execute(new LayerGetOpacityCommand(id, ¶m));
1470 g_pDbusMessage->initReply(msg);
1471 g_pDbusMessage->appendDouble(param);
1472 g_pDbusMessage->closeReply();
1476 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1480 void DBUSCommunicator::SetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg)
1482 (void)conn; // TODO: remove, only prevents warning
1484 g_pDbusMessage->initReceive(msg);
1485 uint id = g_pDbusMessage->getUInt();
1486 uint param = g_pDbusMessage->getUInt();
1487 OrientationType o = (OrientationType) param;
1489 bool status = m_executor->execute(new SurfaceSetOrientationCommand(id, o));
1492 g_pDbusMessage->initReply(msg);
1493 g_pDbusMessage->closeReply();
1497 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1501 void DBUSCommunicator::GetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg)
1503 (void)conn; // TODO: remove, only prevents warning
1505 g_pDbusMessage->initReceive(msg);
1506 uint id = g_pDbusMessage->getUInt();
1509 bool status = m_executor->execute(new SurfaceGetOrientationCommand(id, &o));
1512 g_pDbusMessage->initReply(msg);
1513 g_pDbusMessage->appendUInt(o);
1514 g_pDbusMessage->closeReply();
1518 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1522 void DBUSCommunicator::SetLayerOrientation(DBusConnection* conn, DBusMessage* msg)
1524 (void)conn; // TODO: remove, only prevents warning
1526 g_pDbusMessage->initReceive(msg);
1527 uint id = g_pDbusMessage->getUInt();
1528 uint param = g_pDbusMessage->getUInt();
1529 OrientationType o = (OrientationType) param;
1531 bool status = m_executor->execute(new LayerSetOrientationCommand(id, o));
1534 g_pDbusMessage->initReply(msg);
1535 g_pDbusMessage->closeReply();
1539 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1543 void DBUSCommunicator::GetLayerOrientation(DBusConnection* conn, DBusMessage* msg)
1545 (void)conn; // TODO: remove, only prevents warning
1547 g_pDbusMessage->initReceive(msg);
1548 uint id = g_pDbusMessage->getUInt();
1551 bool status = m_executor->execute(new LayerGetOrientationCommand(id, &o));
1554 g_pDbusMessage->initReply(msg);
1555 g_pDbusMessage->appendUInt(o);
1556 g_pDbusMessage->closeReply();
1560 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1564 void DBUSCommunicator::GetSurfacePixelformat(DBusConnection* conn, DBusMessage* msg)
1566 (void)conn; // TODO: remove, only prevents warning
1568 g_pDbusMessage->initReceive(msg);
1569 uint id = g_pDbusMessage->getUInt();
1572 bool status = m_executor->execute(new SurfaceGetPixelformatCommand(id, ¶m));
1575 g_pDbusMessage->initReply(msg);
1576 g_pDbusMessage->appendUInt(param);
1577 g_pDbusMessage->closeReply();
1581 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1585 void DBUSCommunicator::SetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg)
1587 (void)conn; // TODO: remove, only prevents warning
1589 g_pDbusMessage->initReceive(msg);
1590 const uint surfaceid = g_pDbusMessage->getUInt();
1591 bool newVis = g_pDbusMessage->getBool();
1593 bool status = m_executor->execute(new SurfaceSetVisibilityCommand(surfaceid, newVis));
1596 g_pDbusMessage->initReply(msg);
1597 g_pDbusMessage->closeReply();
1601 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1605 void DBUSCommunicator::SetLayerVisibility(DBusConnection* conn, DBusMessage* msg)
1607 (void)conn; // TODO: remove, only prevents warning
1609 g_pDbusMessage->initReceive(msg);
1610 const uint layerid = g_pDbusMessage->getUInt();
1611 bool myparam = g_pDbusMessage->getBool();
1613 bool status = m_executor->execute(new LayerSetVisibilityCommand(layerid, myparam));
1616 g_pDbusMessage->initReply(msg);
1617 g_pDbusMessage->closeReply();
1621 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1625 void DBUSCommunicator::GetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg)
1627 (void)conn; // TODO: remove, only prevents warning
1629 g_pDbusMessage->initReceive(msg);
1630 uint id = g_pDbusMessage->getUInt();
1633 bool status = m_executor->execute(new SurfaceGetVisibilityCommand(id, ¶m));
1636 g_pDbusMessage->initReply(msg);
1637 //LOG_DEBUG("DBUSCommunicator", "returning surfacevisibility: " << param);
1638 g_pDbusMessage->appendBool(param);
1639 g_pDbusMessage->closeReply();
1643 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1647 void DBUSCommunicator::GetLayerVisibility(DBusConnection* conn, DBusMessage* msg)
1649 (void)conn; // TODO: remove, only prevents warning
1651 g_pDbusMessage->initReceive(msg);
1652 uint id = g_pDbusMessage->getUInt();
1655 bool status = m_executor->execute(new LayerGetVisibilityCommand(id, ¶m));
1658 g_pDbusMessage->initReply(msg);
1659 g_pDbusMessage->appendBool(param);
1660 //LOG_DEBUG("DBUSCommunicator", "returning layervisibility: " << param);
1661 g_pDbusMessage->closeReply();
1665 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1669 void DBUSCommunicator::SetSurfacegroupVisibility(DBusConnection* conn, DBusMessage* msg)
1671 (void)conn; // TODO: remove, only prevents warning
1673 g_pDbusMessage->initReceive(msg);
1674 uint groupid = g_pDbusMessage->getUInt();
1675 bool myparam = g_pDbusMessage->getBool();
1677 bool status = m_executor->execute(new SurfacegroupSetVisibilityCommand(groupid, myparam));
1680 g_pDbusMessage->initReply(msg);
1681 g_pDbusMessage->closeReply();
1685 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1689 void DBUSCommunicator::SetLayergroupVisibility(DBusConnection* conn, DBusMessage* msg)
1691 (void)conn; // TODO: remove, only prevents warning
1693 g_pDbusMessage->initReceive(msg);
1694 uint groupid = g_pDbusMessage->getUInt();
1695 bool myparam = g_pDbusMessage->getBool();
1697 bool status = m_executor->execute(new LayergroupSetVisibilityCommand(groupid, myparam));
1700 g_pDbusMessage->initReply(msg);
1701 g_pDbusMessage->closeReply();
1705 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1710 void DBUSCommunicator::SetRenderOrderOfLayers(DBusConnection* conn, DBusMessage* msg)
1712 (void)conn; // TODO: remove, only prevents warning
1716 g_pDbusMessage->initReceive(msg);
1717 g_pDbusMessage->getArrayOfUInt(&length, &array);
1719 //LOG_DEBUG("DBUSCommunicator","Renderorder: Got " << length << " ids.");
1721 bool status = m_executor->execute(new ScreenSetRenderOrderCommand(array, length));
1724 g_pDbusMessage->initReply(msg);
1725 g_pDbusMessage->closeReply();
1729 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1733 void DBUSCommunicator::SetSurfaceRenderOrderWithinLayer(DBusConnection* conn, DBusMessage* msg)
1735 (void)conn; // TODO: remove, only prevents warning
1740 g_pDbusMessage->initReceive(msg);
1741 uint layerid = g_pDbusMessage->getUInt();
1743 g_pDbusMessage->getArrayOfUInt(&length, &array);
1746 bool status = m_executor->execute(new LayerSetRenderOrderCommand(layerid, array, length));
1749 g_pDbusMessage->initReply(msg);
1750 g_pDbusMessage->closeReply();
1754 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1758 void DBUSCommunicator::GetLayerType(DBusConnection* conn, DBusMessage* msg)
1760 (void)conn; // TODO: remove, only prevents warning
1762 g_pDbusMessage->initReceive(msg);
1763 uint id = g_pDbusMessage->getUInt();
1764 Layer* l = m_executor->getScene()->getLayer(id);
1767 g_pDbusMessage->initReply(msg);
1768 g_pDbusMessage->appendUInt(l->getLayerType());
1769 g_pDbusMessage->closeReply();
1773 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1777 void DBUSCommunicator::GetLayertypeCapabilities(DBusConnection* conn, DBusMessage* msg)
1779 (void)conn; // TODO: remove, only prevents warning
1781 g_pDbusMessage->initReceive(msg);
1782 uint id = g_pDbusMessage->getUInt();
1783 LayerType type = (LayerType) id;
1784 uint capabilities = m_executor->getLayerTypeCapabilities(type);
1785 //LOG_DEBUG("DBUSCommunicator", "GetLayertypeCapabilities: returning capabilities:" << capabilities);
1786 g_pDbusMessage->initReply(msg);
1787 g_pDbusMessage->appendUInt(capabilities);
1788 g_pDbusMessage->closeReply();
1791 void DBUSCommunicator::GetLayerCapabilities(DBusConnection* conn, DBusMessage* msg)
1793 (void)conn; // TODO: remove, only prevents warning
1795 g_pDbusMessage->initReceive(msg);
1796 uint id = g_pDbusMessage->getUInt();
1797 Layer* l = m_executor->getScene()->getLayer(id);
1800 g_pDbusMessage->initReply(msg);
1801 g_pDbusMessage->appendUInt(l->getCapabilities());
1802 g_pDbusMessage->closeReply();
1806 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1810 void DBUSCommunicator::FadeIn(DBusConnection* conn, DBusMessage* msg)
1812 (void)conn; // TODO: remove, only prevents warning
1814 g_pDbusMessage->initReceive(msg);
1815 g_pDbusMessage->initReply(msg);
1816 g_pDbusMessage->closeReply();
1819 void DBUSCommunicator::SynchronizedFade(DBusConnection* conn, DBusMessage* msg)
1821 (void)conn; // TODO: remove, only prevents warning
1823 g_pDbusMessage->initReceive(msg);
1824 g_pDbusMessage->initReply(msg);
1825 g_pDbusMessage->closeReply();
1828 void DBUSCommunicator::FadeOut(DBusConnection* conn, DBusMessage* msg)
1830 (void)conn; // TODO: remove, only prevents warning
1832 g_pDbusMessage->initReceive(msg);
1833 g_pDbusMessage->initReply(msg);
1834 g_pDbusMessage->closeReply();
1837 void DBUSCommunicator::Exit(DBusConnection* conn, DBusMessage* msg)
1839 (void)conn; // TODO: remove, only prevents warning
1841 bool status = m_executor->execute(new ExitCommand());
1844 g_pDbusMessage->initReply(msg);
1845 g_pDbusMessage->closeReply();
1849 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
1853 void DBUSCommunicator::CommitChanges(DBusConnection* conn, DBusMessage* msg)
1855 (void)conn; // TODO: remove, only prevents warning
1857 bool status = m_executor->execute(new CommitCommand());
1860 g_pDbusMessage->initReply(msg);
1861 g_pDbusMessage->closeReply();
1865 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
1869 void DBUSCommunicator::CreateShader(DBusConnection* conn, DBusMessage* msg)
1871 (void)conn; // TODO: remove, only prevents warning
1873 g_pDbusMessage->initReceive(msg);
1874 char* vertname = g_pDbusMessage->getString();
1875 char* fragname = g_pDbusMessage->getString();
1878 bool status = m_executor->execute(new ShaderCreateCommand(vertname, fragname, &id));
1881 g_pDbusMessage->initReply(msg);
1882 g_pDbusMessage->appendUInt(id);
1883 g_pDbusMessage->closeReply();
1887 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1891 void DBUSCommunicator::DestroyShader(DBusConnection* conn, DBusMessage* msg)
1893 (void)conn; // TODO: remove, only prevents warning
1895 g_pDbusMessage->initReceive(msg);
1896 uint shaderid = g_pDbusMessage->getUInt();
1898 bool status = m_executor->execute(new ShaderDestroyCommand(shaderid));
1901 g_pDbusMessage->initReply(msg);
1902 g_pDbusMessage->closeReply();
1906 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1910 void DBUSCommunicator::SetShader(DBusConnection* conn, DBusMessage* msg)
1912 (void)conn; // TODO: remove, only prevents warning
1914 g_pDbusMessage->initReceive(msg);
1915 uint surfaceId = g_pDbusMessage->getUInt();
1916 uint shaderid = g_pDbusMessage->getUInt();
1918 bool status = m_executor->execute(new SurfaceSetShaderCommand(surfaceId, shaderid));
1921 g_pDbusMessage->initReply(msg);
1922 g_pDbusMessage->closeReply();
1926 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1930 void DBUSCommunicator::SetUniforms(DBusConnection* conn, DBusMessage* msg)
1932 (void)conn; // TODO: remove, only prevents warning
1934 g_pDbusMessage->initReceive(msg);
1935 uint id = g_pDbusMessage->getUInt();
1937 std::vector<string> uniforms;
1939 g_pDbusMessage->getArrayOfString(&uniforms);
1941 bool status = m_executor->execute(new ShaderSetUniformsCommand(id, uniforms));
1944 g_pDbusMessage->initReply(msg);
1945 g_pDbusMessage->closeReply();
1949 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1953 void DBUSCommunicator::RemoveApplicationReference(char* owner)
1955 ApplicationReferenceMapIterator iter = m_executor->getApplicationReferenceMap()->find(IApplicationReference::generateApplicationHash(owner));
1956 ApplicationReferenceMapIterator iterEnd = m_executor->getApplicationReferenceMap()->end();
1958 if ( iter != iterEnd )
1960 m_executor->removeApplicationReference((*iter).second);
1965 void DBUSCommunicator::AddClientWatch(DBusConnection *conn, char* sender)
1968 dbus_error_init(&err);
1970 sprintf(rule,"type='signal',sender='%s',interface='%s',member='%s',arg0='%s'",DBUS_INTERFACE_DBUS,DBUS_INTERFACE_DBUS,"NameOwnerChanged",sender);
1972 dbus_bus_add_match(conn,rule,&err);
1973 if (dbus_error_is_set(&err))
1975 LOG_ERROR("DBUSCommunicator", "Could not add client watch "<< err.message);
1976 dbus_error_free(&err);
1980 void DBUSCommunicator::RemoveClientWatch(DBusConnection *conn, char* sender)
1983 dbus_error_init(&err);
1985 sprintf(rule,"type='signal',sender='%s',interface='%s',member='%s',arg0='%s'",DBUS_INTERFACE_DBUS,DBUS_INTERFACE_DBUS,"NameOwnerChanged",sender);
1987 dbus_bus_remove_match(conn,rule,&err);
1988 if (dbus_error_is_set(&err))
1990 LOG_ERROR("DBUSCommunicator", "Could not remove client watch "<< err.message);
1991 dbus_error_free(&err);
1995 DBusHandlerResult DBUSCommunicator::delegateMessage(DBusConnection* conn, DBusMessage* msg)
1997 DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED;
1998 LOG_DEBUG("DBUSCommunicator","message received");
1999 const char *n = dbus_message_get_member(msg);
2000 char* owner = strdup(dbus_message_get_sender(msg));
2004 while (!found && strcmp(manager_methods[i].name, "") != 0)
2006 if (n && strcmp(manager_methods[i].name, n) == 0)
2008 MethodTable entry = manager_methods[i];
2009 LOG_DEBUG("DBUSCommunicator","got call for method:" << entry.name);
2010 CallBackMethod m = entry.function;
2011 LOG_DEBUG("DBUSCommunicator","enter method");
2012 (this->*m)(conn, msg);
2018 if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
2020 LOG_DEBUG("DBUSCommunicator", "Introspection called");
2021 DBUSIntrospection introspectionString(manager_methods);
2022 introspectionString.process(conn, msg);
2023 g_pDbusMessage->setConnection(conn);
2024 found = true; // TODO: always true
2027 if (dbus_message_is_signal(msg, DBUS_INTERFACE_DBUS, "NameOwnerChanged"))
2029 char *name, *oldName, *newName;
2030 LOG_DEBUG("DBUSCommunicator","NameOwner Changed detected ");
2031 if (!dbus_message_get_args(msg, NULL,
2032 DBUS_TYPE_STRING, &name,
2033 DBUS_TYPE_STRING, &oldName,
2034 DBUS_TYPE_STRING, &newName,
2037 LOG_WARNING("DBUSCommunicator","Invalid arguments for NameOwnerChanged signal");
2038 } else if ( *newName == '\0' )
2040 LOG_DEBUG("DBUSCommunicator","Client Disconnect detected " << name);
2041 RemoveClientWatch(conn,owner);
2042 RemoveApplicationReference(name);
2047 result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
2052 extern "C" ICommunicator* createDBUSCommunicator(ICommandExecutor* executor)
2054 return new DBUSCommunicator(executor);
2057 extern "C" void destroyDBUSCommunicator(DBUSCommunicator* p)