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 { "Debug", "b", "", &DBUSCommunicator::Debug },
48 { "ScreenShot", "us", "", &DBUSCommunicator::ScreenShot },
49 { "ScreenShotOfLayer", "su", "", &DBUSCommunicator::ScreenShotOfLayer },
50 { "ScreenShotOfSurface", "su", "", &DBUSCommunicator::ScreenShotOfSurface },
51 { "GetScreenResolution", "u", "uu", &DBUSCommunicator::GetScreenResolution },
52 { "GetNumberOfHardwareLayers", "u", "u", &DBUSCommunicator::GetNumberOfHardwareLayers },
53 { "GetScreenIDs", "", "au", &DBUSCommunicator::GetScreenIDs },
54 { "ListAllLayerIDS", "", "au", &DBUSCommunicator::ListAllLayerIDS },
55 { "ListAllLayerIDsOnScreen", "u", "au", &DBUSCommunicator::ListAllLayerIDsOnScreen },
56 { "ListAllSurfaceIDS", "", "au", &DBUSCommunicator::ListAllSurfaceIDS },
57 { "ListAllLayerGroupIDS", "", "au", &DBUSCommunicator::ListAllLayerGroupIDS },
58 { "ListAllSurfaceGroupIDS", "", "au", &DBUSCommunicator::ListAllSurfaceGroupIDS },
59 { "ListSurfacesOfSurfacegroup", "u", "au", &DBUSCommunicator::ListSurfacesOfSurfacegroup },
60 { "ListLayersOfLayergroup", "u", "au", &DBUSCommunicator::ListLayersOfLayergroup },
61 { "ListSurfaceofLayer", "u", "au", &DBUSCommunicator::ListSurfaceofLayer },
62 { "GetPropertiesOfSurface", "u", "duuuuuuuuuuybu", &DBUSCommunicator::GetPropertiesOfSurface },
63 { "GetPropertiesOfLayer", "u", "duuuuuuuuuuyb", &DBUSCommunicator::GetPropertiesOfLayer },
64 { "CreateSurface", "uuuu", "u", &DBUSCommunicator::CreateSurface },
65 { "CreateSurfaceFromId", "uuuuu", "u", &DBUSCommunicator::CreateSurfaceFromId },
66 { "InitializeSurface", "", "u", &DBUSCommunicator::InitializeSurface },
67 { "InitializeSurfaceFromId", "u", "u", &DBUSCommunicator::InitializeSurfaceFromId },
68 { "SetSurfaceNativeContent", "uuuuu", "", &DBUSCommunicator::SetSurfaceNativeContent },
69 { "RemoveSurface", "u", "", &DBUSCommunicator::RemoveSurface },
70 { "CreateLayer", "", "u", &DBUSCommunicator::CreateLayer },
71 { "CreateLayerFromId", "u", "u", &DBUSCommunicator::CreateLayerFromId },
72 { "CreateLayerWithDimension", "uu", "u", &DBUSCommunicator::CreateLayerWithDimension },
73 { "CreateLayerFromIdWithDimension", "uuu", "u", &DBUSCommunicator::CreateLayerFromIdWithDimension },
74 { "RemoveLayer", "u", "", &DBUSCommunicator::RemoveLayer },
75 { "AddSurfaceToSurfaceGroup", "uu", "", &DBUSCommunicator::AddSurfaceToSurfaceGroup },
76 { "RemoveSurfaceFromSurfaceGroup", "uu", "", &DBUSCommunicator::RemoveSurfaceFromSurfaceGroup },
77 { "AddLayerToLayerGroup", "uu", "", &DBUSCommunicator::AddLayerToLayerGroup },
78 { "RemoveLayerFromLayerGroup", "uu", "", &DBUSCommunicator::RemoveLayerFromLayerGroup },
79 { "AddSurfaceToLayer", "uu", "", &DBUSCommunicator::AddSurfaceToLayer },
80 { "RemoveSurfaceFromLayer", "uu", "", &DBUSCommunicator::RemoveSurfaceFromLayer },
81 { "CreateSurfaceGroup", "", "u", &DBUSCommunicator::CreateSurfaceGroup },
82 { "CreateSurfaceGroupFromId", "u", "u", &DBUSCommunicator::CreateSurfaceGroupFromId },
83 { "RemoveSurfaceGroup", "u", "", &DBUSCommunicator::RemoveSurfaceGroup },
84 { "CreateLayerGroup", "", "u", &DBUSCommunicator::CreateLayerGroup },
85 { "CreateLayerGroupFromId", "u", "u", &DBUSCommunicator::CreateLayerGroupFromId },
86 { "RemoveLayerGroup", "u", "", &DBUSCommunicator::RemoveLayerGroup },
87 { "SetSurfaceSourceRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceSourceRegion },
88 { "SetLayerSourceRegion", "uuuuu", "", &DBUSCommunicator::SetLayerSourceRegion },
89 { "SetSurfaceDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceDestinationRegion },
90 { "SetSurfacePosition", "uuu", "", &DBUSCommunicator::SetSurfacePosition },
91 { "GetSurfacePosition", "u", "uu", &DBUSCommunicator::GetSurfacePosition },
92 { "SetSurfaceDimension", "uuu", "", &DBUSCommunicator::SetSurfaceDimension },
93 { "SetLayerDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetLayerDestinationRegion },
94 { "SetLayerPosition", "uuu", "", &DBUSCommunicator::SetLayerPosition },
95 { "GetLayerPosition", "u", "uu", &DBUSCommunicator::GetLayerPosition },
96 { "SetLayerDimension", "uuu", "", &DBUSCommunicator::SetLayerDimension },
97 { "GetLayerDimension", "u", "uu", &DBUSCommunicator::GetLayerDimension },
98 { "GetSurfaceDimension", "u", "uu", &DBUSCommunicator::GetSurfaceDimension },
99 { "SetSurfaceOpacity", "ud", "", &DBUSCommunicator::SetSurfaceOpacity },
100 { "SetLayerOpacity", "ud", "", &DBUSCommunicator::SetLayerOpacity },
101 { "SetSurfacegroupOpacity", "ud", "", &DBUSCommunicator::SetSurfacegroupOpacity },
102 { "SetLayergroupOpacity", "ud", "", &DBUSCommunicator::SetLayergroupOpacity },
103 { "GetSurfaceOpacity", "u", "d", &DBUSCommunicator::GetSurfaceOpacity },
104 { "GetLayerOpacity", "u", "d", &DBUSCommunicator::GetLayerOpacity },
105 { "GetSurfacegroupOpacity", "u", "d", &DBUSCommunicator::GetSurfacegroupOpacity },
106 { "GetLayergroupOpacity", "u", "d", &DBUSCommunicator::GetLayergroupOpacity },
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,
161 LOG_ERROR("DBUSCommunicator","Register Message Callbacks failed");
165 LOG_INFO("DBUSCommunicator", "Started dbus connector");
169 void DBUSCommunicator::stop()
171 LOG_INFO("DBUSCommunicator","stopping");
173 // deregister dbus messaging implicitly by deleting messageHandler
174 delete g_pDbusMessage;
177 void DBUSCommunicator::Debug(DBusConnection* conn, DBusMessage* msg)
179 (void)conn; // TODO: remove, only prevents warning
181 g_pDbusMessage->initReceive(msg);
182 bool param = g_pDbusMessage->getBool();
184 bool status = m_executor->execute(new DebugCommand(param));
187 g_pDbusMessage->initReply(msg);
188 g_pDbusMessage->closeReply();
192 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
196 void DBUSCommunicator::GetScreenResolution(DBusConnection* conn, DBusMessage* msg)
198 (void)conn; // TODO: remove, only prevents warning
200 g_pDbusMessage->initReceive(msg);
201 uint screenid = g_pDbusMessage->getUInt();
202 uint* resolution = m_executor->getScreenResolution(screenid);
203 g_pDbusMessage->initReply(msg);
204 g_pDbusMessage->appendUInt(resolution[0]);
205 g_pDbusMessage->appendUInt(resolution[1]);
206 g_pDbusMessage->closeReply();
209 void DBUSCommunicator::GetNumberOfHardwareLayers(DBusConnection* conn, DBusMessage* msg)
211 (void)conn; // TODO: remove, only prevents warning
213 g_pDbusMessage->initReceive(msg);
214 uint screenid = g_pDbusMessage->getUInt();
215 uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid);
216 g_pDbusMessage->initReply(msg);
217 g_pDbusMessage->appendUInt(numberOfHardwareLayers);
218 g_pDbusMessage->closeReply();
221 void DBUSCommunicator::GetScreenIDs(DBusConnection* conn, DBusMessage* msg)
223 (void)conn; // TODO: remove, only prevents warning
225 g_pDbusMessage->initReceive(msg);
227 uint* IDs = m_executor->getScreenIDs(&length);
228 g_pDbusMessage->initReply(msg);
229 g_pDbusMessage->appendArrayOfUInt(length, IDs);
230 g_pDbusMessage->closeReply();
233 void DBUSCommunicator::ScreenShot(DBusConnection* conn, DBusMessage* msg)
235 (void)conn; // TODO: remove, only prevents warning
237 g_pDbusMessage->initReceive(msg);
238 uint screenid = g_pDbusMessage->getUInt();
239 char* filename = g_pDbusMessage->getString();
241 bool status = m_executor->execute(new ScreenDumpCommand(filename, screenid));
244 g_pDbusMessage->initReply(msg);
245 g_pDbusMessage->closeReply();
249 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
252 void DBUSCommunicator::process(int timeout_ms)
254 dbus_connection_read_write_dispatch (g_pDbusMessage->getConnection(), timeout_ms);
256 void DBUSCommunicator::ScreenShotOfLayer(DBusConnection* conn, DBusMessage* msg)
258 (void)conn; // TODO: remove, only prevents warning
260 g_pDbusMessage->initReceive(msg);
261 char* filename = g_pDbusMessage->getString();
262 uint layerid = g_pDbusMessage->getUInt();
264 bool status = m_executor->execute(new LayerDumpCommand(filename, layerid));
267 g_pDbusMessage->initReply(msg);
268 g_pDbusMessage->closeReply();
272 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
276 void DBUSCommunicator::ScreenShotOfSurface(DBusConnection* conn, DBusMessage* msg)
278 (void)conn; // TODO: remove, only prevents warning
280 g_pDbusMessage->initReceive(msg);
281 char* filename = g_pDbusMessage->getString();
282 uint id = g_pDbusMessage->getUInt();
283 bool status = m_executor->execute(new SurfaceDumpCommand(filename, id));
286 g_pDbusMessage->initReply(msg);
287 g_pDbusMessage->closeReply();
291 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
295 void DBUSCommunicator::ListAllLayerIDS(DBusConnection* conn, DBusMessage* msg)
297 (void)conn; // TODO: remove, only prevents warning
301 m_executor->getScene()->lockScene();
302 m_executor->getScene()->getLayerIDs(&length, &array);
303 g_pDbusMessage->initReply(msg);
304 g_pDbusMessage->appendArrayOfUInt(length, array);
305 g_pDbusMessage->closeReply();
306 m_executor->getScene()->unlockScene();
309 void DBUSCommunicator::ListAllLayerIDsOnScreen(DBusConnection* conn, DBusMessage* msg)
311 (void)conn; // TODO: remove, only prevents warning
313 g_pDbusMessage->initReceive(msg);
314 uint screenID = g_pDbusMessage->getUInt();
318 m_executor->getScene()->lockScene();
319 bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
322 g_pDbusMessage->initReply(msg);
323 g_pDbusMessage->appendArrayOfUInt(length, array);
324 g_pDbusMessage->closeReply();
328 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
330 m_executor->getScene()->unlockScene();
334 void DBUSCommunicator::ListAllSurfaceIDS(DBusConnection* conn, DBusMessage* msg)
336 (void)conn; // TODO: remove, only prevents warning
340 m_executor->getScene()->lockScene();
341 m_executor->getScene()->getSurfaceIDs(&length, &array);
342 g_pDbusMessage->initReply(msg);
343 g_pDbusMessage->appendArrayOfUInt(length, array);
344 g_pDbusMessage->closeReply();
345 m_executor->getScene()->unlockScene();
348 void DBUSCommunicator::ListAllLayerGroupIDS(DBusConnection* conn, DBusMessage* msg)
350 (void)conn; // TODO: remove, only prevents warning
354 m_executor->getScene()->lockScene();
355 m_executor->getScene()->getLayerGroupIDs(&length, &array);
356 g_pDbusMessage->initReply(msg);
357 g_pDbusMessage->appendArrayOfUInt(length, array);
358 g_pDbusMessage->closeReply();
359 m_executor->getScene()->unlockScene();
362 void DBUSCommunicator::ListAllSurfaceGroupIDS(DBusConnection* conn, DBusMessage* msg)
364 (void)conn; // TODO: remove, only prevents warning
368 m_executor->getScene()->lockScene();
369 m_executor->getScene()->getSurfaceGroupIDs(&length, &array);
370 g_pDbusMessage->initReply(msg);
371 g_pDbusMessage->appendArrayOfUInt(length, array);
372 g_pDbusMessage->closeReply();
373 m_executor->getScene()->unlockScene();
376 void DBUSCommunicator::ListSurfacesOfSurfacegroup(DBusConnection* conn, DBusMessage* msg)
378 (void)conn; // TODO: remove, only prevents warning
380 g_pDbusMessage->initReceive(msg);
381 uint id = g_pDbusMessage->getUInt();
382 m_executor->getScene()->lockScene();
383 SurfaceGroup* sg = m_executor->getScene()->getSurfaceGroup(id);
386 std::list<Surface*> surfaces = sg->getList();
387 uint length = surfaces.size();
388 uint* array = new uint[length];
390 g_pDbusMessage->initReply(msg);
392 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
395 array[arrayPos] = s->getID();
399 g_pDbusMessage->appendArrayOfUInt(length, array);
401 g_pDbusMessage->closeReply();
402 m_executor->getScene()->unlockScene();
406 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
409 DBusHandlerResult DBUSCommunicator::processMessageFunc(DBusConnection* conn,DBusMessage* msg, void *user_data)
411 return ((DBUSCommunicator*)user_data)->delegateMessage(conn,msg);
414 void DBUSCommunicator::unregisterMessageFunc(DBusConnection* conn, void *user_data)
416 DBusConnection* connection = NULL;
417 DBUSCommunicator* cominstance = NULL;
419 cominstance = (DBUSCommunicator*)user_data;
422 void DBUSCommunicator::ListLayersOfLayergroup(DBusConnection* conn, DBusMessage* msg)
424 (void)conn; // TODO: remove, only prevents warning
426 g_pDbusMessage->initReceive(msg);
427 uint id = g_pDbusMessage->getUInt();
428 m_executor->getScene()->lockScene();
429 LayerGroup* sg = m_executor->getScene()->getLayerGroup(id);
432 std::list<Layer*> layers = sg->getList();
434 uint length = layers.size();
435 uint* array = new uint[length];
438 g_pDbusMessage->initReply(msg);
439 for (std::list<Layer*>::const_iterator it = layers.begin(); it != layers.end(); ++it)
442 array[arrayPos] = l->getID();
446 g_pDbusMessage->appendArrayOfUInt(length, array);
448 g_pDbusMessage->closeReply();
449 m_executor->getScene()->unlockScene();
453 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
457 void DBUSCommunicator::ListSurfaceofLayer(DBusConnection* conn, DBusMessage* msg)
459 (void)conn; // TODO: remove, only prevents warning
461 g_pDbusMessage->initReceive(msg);
462 uint id = g_pDbusMessage->getUInt();
463 m_executor->getScene()->lockScene();
464 Layer* layer = m_executor->getScene()->getLayer(id);
467 std::list<Surface*> surfaces = layer->getAllSurfaces();
469 uint length = surfaces.size();
470 uint* array = new uint[length];
473 g_pDbusMessage->initReply(msg);
475 for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
478 array[arrayPos] = s->getID();
482 g_pDbusMessage->appendArrayOfUInt(length, array);
484 g_pDbusMessage->closeReply();
488 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
490 m_executor->getScene()->unlockScene();
493 void DBUSCommunicator::GetPropertiesOfSurface(DBusConnection* conn, DBusMessage* msg)
495 (void)conn; // TODO: remove, only prevents warning
497 g_pDbusMessage->initReceive(msg);
498 uint id = g_pDbusMessage->getUInt();
500 Surface* surface = m_executor->getScene()->getSurface(id);
503 Rectangle dest = surface->getDestinationRegion();
504 Rectangle src = surface->getSourceRegion();
505 OrientationType orientation = surface->getOrientation();
507 g_pDbusMessage->initReply(msg);
508 g_pDbusMessage->appendDouble(surface->getOpacity());
509 g_pDbusMessage->appendUInt(src.x);
510 g_pDbusMessage->appendUInt(src.y);
511 g_pDbusMessage->appendUInt(src.width);
512 g_pDbusMessage->appendUInt(src.height);
513 g_pDbusMessage->appendUInt(surface->OriginalSourceWidth);
514 g_pDbusMessage->appendUInt(surface->OriginalSourceHeight);
515 g_pDbusMessage->appendUInt(dest.x);
516 g_pDbusMessage->appendUInt(dest.y);
517 g_pDbusMessage->appendUInt(dest.width);
518 g_pDbusMessage->appendUInt(dest.height);
519 g_pDbusMessage->appendUInt(orientation);
520 g_pDbusMessage->appendBool(surface->getVisibility());
521 g_pDbusMessage->appendUInt(surface->frameCounter);
522 g_pDbusMessage->closeReply();
526 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
530 void DBUSCommunicator::GetPropertiesOfLayer(DBusConnection* conn, DBusMessage* msg)
532 (void)conn; // TODO: remove, only prevents warning
534 g_pDbusMessage->initReceive(msg);
535 uint id = g_pDbusMessage->getUInt();
537 Layer* layer = m_executor->getScene()->getLayer(id);
540 Rectangle dest = layer->getDestinationRegion();
541 Rectangle src = layer->getSourceRegion();
542 OrientationType orientation = layer->getOrientation();
544 g_pDbusMessage->initReply(msg);
545 g_pDbusMessage->appendDouble(layer->getOpacity());
546 g_pDbusMessage->appendUInt(src.x);
547 g_pDbusMessage->appendUInt(src.y);
548 g_pDbusMessage->appendUInt(src.width);
549 g_pDbusMessage->appendUInt(src.height);
550 g_pDbusMessage->appendUInt(layer->OriginalSourceWidth);
551 g_pDbusMessage->appendUInt(layer->OriginalSourceHeight);
552 g_pDbusMessage->appendUInt(dest.x);
553 g_pDbusMessage->appendUInt(dest.y);
554 g_pDbusMessage->appendUInt(dest.width);
555 g_pDbusMessage->appendUInt(dest.height);
556 g_pDbusMessage->appendUInt(orientation);
557 g_pDbusMessage->appendBool(layer->getVisibility());
558 g_pDbusMessage->closeReply();
562 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
566 void DBUSCommunicator::CreateSurface(DBusConnection* conn, DBusMessage* msg)
568 (void)conn; // TODO: remove, only prevents warning
570 (void)conn; // TODO: remove, only prevents warning
572 g_pDbusMessage->initReceive(msg);
573 uint handle = g_pDbusMessage->getUInt();
574 uint width = g_pDbusMessage->getUInt();
575 uint height = g_pDbusMessage->getUInt();
576 uint pixelformat = g_pDbusMessage->getUInt();
577 PixelFormat pf = (PixelFormat) pixelformat;
579 //LOG_DEBUG("DBUSCommunicator::CreateSurface","pixelformat: " << pixelformat);
580 uint id = GraphicalObject::INVALID_ID;
581 /* First of all create the surface */
582 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
583 /* after that apply the native content */
584 status &= m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height));
587 g_pDbusMessage->initReply(msg);
588 g_pDbusMessage->appendUInt(id);
589 g_pDbusMessage->closeReply();
593 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
597 void DBUSCommunicator::CreateSurfaceFromId(DBusConnection* conn, DBusMessage* msg)
599 (void)conn; // TODO: remove, only prevents warning
601 g_pDbusMessage->initReceive(msg);
602 uint handle = g_pDbusMessage->getUInt();
603 uint width = g_pDbusMessage->getUInt();
604 uint height = g_pDbusMessage->getUInt();
605 uint pixelformat = g_pDbusMessage->getUInt();
606 PixelFormat pf = (PixelFormat) pixelformat;
608 //LOG_DEBUG("DBUSCommunicator::CreateSurface","pixelformat: " << pixelformat);
609 uint id = g_pDbusMessage->getUInt();
611 /* First of all create the surface */
612 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
613 /* after that apply the native content */
614 status &= m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height));
618 g_pDbusMessage->initReply(msg);
619 g_pDbusMessage->appendUInt(id);
620 g_pDbusMessage->closeReply();
624 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
628 void DBUSCommunicator::InitializeSurface(DBusConnection* conn, DBusMessage* msg)
630 (void)conn; // TODO: remove, only prevents warning
632 g_pDbusMessage->initReceive(msg);
633 uint id = GraphicalObject::INVALID_ID;
635 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
638 g_pDbusMessage->initReply(msg);
639 g_pDbusMessage->appendUInt(id);
640 g_pDbusMessage->closeReply();
644 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
648 void DBUSCommunicator::InitializeSurfaceFromId(DBusConnection* conn, DBusMessage* msg)
650 (void)conn; // TODO: remove, only prevents warning
652 g_pDbusMessage->initReceive(msg);
653 uint id = g_pDbusMessage->getUInt();
654 bool status = m_executor->execute(new SurfaceCreateCommand(&id));
657 g_pDbusMessage->initReply(msg);
658 g_pDbusMessage->appendUInt(id);
659 g_pDbusMessage->closeReply();
663 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
667 void DBUSCommunicator::SetSurfaceNativeContent(DBusConnection* conn, DBusMessage* msg)
669 (void)conn; // TODO: remove, only prevents warning
671 g_pDbusMessage->initReceive(msg);
672 uint id = g_pDbusMessage->getUInt();
673 uint handle = g_pDbusMessage->getUInt();
674 uint width = g_pDbusMessage->getUInt();
675 uint height = g_pDbusMessage->getUInt();
676 PixelFormat pf = (PixelFormat)g_pDbusMessage->getUInt();
678 bool status = m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height));
681 g_pDbusMessage->initReply(msg);
682 g_pDbusMessage->closeReply();
686 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
690 void DBUSCommunicator::RemoveSurface(DBusConnection* conn, DBusMessage* msg)
692 (void)conn; // TODO: remove, only prevents warning
694 g_pDbusMessage->initReceive(msg);
695 uint param = g_pDbusMessage->getUInt();
696 bool status = m_executor->execute(new SurfaceRemoveCommand(param));
699 g_pDbusMessage->initReply(msg);
700 g_pDbusMessage->closeReply();
704 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
708 void DBUSCommunicator::CreateLayer(DBusConnection* conn, DBusMessage* msg)
710 (void)conn; // TODO: remove, only prevents warning
712 uint id = GraphicalObject::INVALID_ID;
713 // use resolution of default screen as default width and height of layers
714 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
715 bool status = m_executor->execute(new LayerCreateCommand(resolution[0], resolution[1], &id));
718 g_pDbusMessage->initReply(msg);
719 g_pDbusMessage->appendUInt(id);
720 g_pDbusMessage->closeReply();
724 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
728 void DBUSCommunicator::CreateLayerFromId(DBusConnection* conn, DBusMessage* msg)
730 (void)conn; // TODO: remove, only prevents warning
732 uint id = GraphicalObject::INVALID_ID;
733 g_pDbusMessage->initReceive(msg);
734 id = g_pDbusMessage->getUInt();
735 // use resolution of default screen as default width and height of layers
736 uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN);
737 bool status = m_executor->execute(new LayerCreateCommand(resolution[0], resolution[1], &id));
740 g_pDbusMessage->initReply(msg);
741 g_pDbusMessage->appendUInt(id);
742 g_pDbusMessage->closeReply();
746 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
751 void DBUSCommunicator::CreateLayerWithDimension(DBusConnection* conn, DBusMessage* msg)
753 (void)conn; // TODO: remove, only prevents warning
755 g_pDbusMessage->initReceive(msg);
756 uint width = g_pDbusMessage->getUInt();
757 uint height = g_pDbusMessage->getUInt();
759 uint id = GraphicalObject::INVALID_ID;
760 bool status = m_executor->execute(new LayerCreateCommand(width, height, &id));
763 g_pDbusMessage->initReply(msg);
764 g_pDbusMessage->appendUInt(id);
765 g_pDbusMessage->closeReply();
769 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
773 void DBUSCommunicator::CreateLayerFromIdWithDimension(DBusConnection* conn, DBusMessage* msg)
775 (void)conn; // TODO: remove, only prevents warning
777 uint id = GraphicalObject::INVALID_ID;
778 g_pDbusMessage->initReceive(msg);
779 id = g_pDbusMessage->getUInt();
780 uint width = g_pDbusMessage->getUInt();
781 uint height = g_pDbusMessage->getUInt();
782 bool status = m_executor->execute(new LayerCreateCommand(width, height, &id));
785 g_pDbusMessage->initReply(msg);
786 g_pDbusMessage->appendUInt(id);
787 g_pDbusMessage->closeReply();
791 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
795 void DBUSCommunicator::RemoveLayer(DBusConnection* conn, DBusMessage* msg)
797 (void)conn; // TODO: remove, only prevents warning
799 g_pDbusMessage->initReceive(msg);
800 uint param = g_pDbusMessage->getUInt();
801 bool status = m_executor->execute(new LayerRemoveCommand(param));
804 g_pDbusMessage->initReply(msg);
805 g_pDbusMessage->closeReply();
809 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
813 void DBUSCommunicator::AddSurfaceToSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
815 (void)conn; // TODO: remove, only prevents warning
817 g_pDbusMessage->initReceive(msg);
818 uint surfaceid = g_pDbusMessage->getUInt();
819 uint surfacegroupid = g_pDbusMessage->getUInt();
821 bool status = m_executor->execute(new SurfacegroupAddSurfaceCommand(surfacegroupid, surfaceid));
824 g_pDbusMessage->initReply(msg);
825 g_pDbusMessage->closeReply();
829 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
833 void DBUSCommunicator::RemoveSurfaceFromSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
835 (void)conn; // TODO: remove, only prevents warning
837 g_pDbusMessage->initReceive(msg);
838 uint surfaceid = g_pDbusMessage->getUInt();
839 uint surfacegroupid = g_pDbusMessage->getUInt();
841 bool status = m_executor->execute(new SurfacegroupRemoveSurfaceCommand(surfacegroupid, surfaceid));
844 g_pDbusMessage->initReply(msg);
845 g_pDbusMessage->closeReply();
849 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
853 void DBUSCommunicator::AddLayerToLayerGroup(DBusConnection* conn, DBusMessage* msg)
855 (void)conn; // TODO: remove, only prevents warning
857 g_pDbusMessage->initReceive(msg);
858 uint layerid = g_pDbusMessage->getUInt();
859 uint layergroupid = g_pDbusMessage->getUInt();
861 bool status = m_executor->execute(new LayergroupAddLayerCommand(layergroupid, layerid));
864 g_pDbusMessage->initReply(msg);
865 g_pDbusMessage->closeReply();
869 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
873 void DBUSCommunicator::RemoveLayerFromLayerGroup(DBusConnection* conn, DBusMessage* msg)
875 (void)conn; // TODO: remove, only prevents warning
877 g_pDbusMessage->initReceive(msg);
878 uint layerid = g_pDbusMessage->getUInt();
879 uint layergroupid = g_pDbusMessage->getUInt();
881 bool status = m_executor->execute(new LayergroupRemoveLayerCommand(layergroupid, layerid));
884 g_pDbusMessage->initReply(msg);
885 g_pDbusMessage->closeReply();
889 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
893 void DBUSCommunicator::AddSurfaceToLayer(DBusConnection* conn, DBusMessage* msg)
895 (void)conn; // TODO: remove, only prevents warning
897 g_pDbusMessage->initReceive(msg);
898 uint surfaceid = g_pDbusMessage->getUInt();
899 uint layer = g_pDbusMessage->getUInt();
901 bool status = m_executor->execute(new LayerAddSurfaceCommand(layer, surfaceid));
904 g_pDbusMessage->initReply(msg);
905 g_pDbusMessage->closeReply();
909 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
913 void DBUSCommunicator::RemoveSurfaceFromLayer(DBusConnection* conn, DBusMessage* msg)
915 (void)conn; // TODO: remove, only prevents warning
917 g_pDbusMessage->initReceive(msg);
918 uint surfaceid = g_pDbusMessage->getUInt();
919 uint layerid = g_pDbusMessage->getUInt();
921 bool status = m_executor->execute(new LayerRemoveSurfaceCommand(layerid, surfaceid));
924 g_pDbusMessage->initReply(msg);
925 g_pDbusMessage->closeReply();
929 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
933 void DBUSCommunicator::CreateSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
935 (void)conn; // TODO: remove, only prevents warning
937 uint newID = GraphicalObject::INVALID_ID;
939 bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID));
942 g_pDbusMessage->initReply(msg);
943 g_pDbusMessage->appendUInt(newID);
944 g_pDbusMessage->closeReply();
948 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
952 void DBUSCommunicator::CreateSurfaceGroupFromId(DBusConnection* conn, DBusMessage* msg)
954 (void)conn; // TODO: remove, only prevents warning
956 uint newID = GraphicalObject::INVALID_ID;
957 g_pDbusMessage->initReceive(msg);
958 newID = g_pDbusMessage->getUInt();
960 bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID));
963 g_pDbusMessage->initReply(msg);
964 g_pDbusMessage->appendUInt(newID);
965 g_pDbusMessage->closeReply();
969 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
973 void DBUSCommunicator::RemoveSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
975 (void)conn; // TODO: remove, only prevents warning
977 g_pDbusMessage->initReceive(msg);
978 uint param = g_pDbusMessage->getUInt();
980 bool status = m_executor->execute(new SurfacegroupRemoveCommand(param));
983 g_pDbusMessage->initReply(msg);
984 g_pDbusMessage->closeReply();
988 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
992 void DBUSCommunicator::CreateLayerGroup(DBusConnection* conn, DBusMessage* msg)
994 (void)conn; // TODO: remove, only prevents warning
996 uint newID = GraphicalObject::INVALID_ID;
998 bool status = m_executor->execute(new LayergroupCreateCommand(&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::CreateLayerGroupFromId(DBusConnection* conn, DBusMessage* msg)
1013 (void)conn; // TODO: remove, only prevents warning
1015 uint newID = GraphicalObject::INVALID_ID;
1016 g_pDbusMessage->initReceive(msg);
1017 newID = g_pDbusMessage->getUInt();
1019 bool status = m_executor->execute(new LayergroupCreateCommand(&newID));
1022 g_pDbusMessage->initReply(msg);
1023 g_pDbusMessage->appendUInt(newID);
1024 g_pDbusMessage->closeReply();
1028 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
1032 void DBUSCommunicator::RemoveLayerGroup(DBusConnection* conn, DBusMessage* msg)
1034 (void)conn; // TODO: remove, only prevents warning
1036 g_pDbusMessage->initReceive(msg);
1037 uint param = g_pDbusMessage->getUInt();
1039 bool status = m_executor->execute(new LayergroupRemoveCommand(param));
1042 g_pDbusMessage->initReply(msg);
1043 g_pDbusMessage->closeReply();
1047 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1051 void DBUSCommunicator::SetSurfaceSourceRegion(DBusConnection* conn, DBusMessage* msg)
1053 (void)conn; // TODO: remove, only prevents warning
1055 g_pDbusMessage->initReceive(msg);
1056 uint id = g_pDbusMessage->getUInt();
1057 uint x = g_pDbusMessage->getUInt();
1058 uint y = g_pDbusMessage->getUInt();
1059 uint width = g_pDbusMessage->getUInt();
1060 uint height = g_pDbusMessage->getUInt();
1062 bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(id, x, y, width, height));
1065 g_pDbusMessage->initReply(msg);
1066 g_pDbusMessage->closeReply();
1070 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1074 void DBUSCommunicator::SetLayerSourceRegion(DBusConnection* conn, DBusMessage* msg)
1076 (void)conn; // TODO: remove, only prevents warning
1078 g_pDbusMessage->initReceive(msg);
1079 uint id = g_pDbusMessage->getUInt();
1080 uint x = g_pDbusMessage->getUInt();
1081 uint y = g_pDbusMessage->getUInt();
1082 uint width = g_pDbusMessage->getUInt();
1083 uint height = g_pDbusMessage->getUInt();
1085 //LOG_DEBUG("DBUSC","new SetSourceRectangleCommand with arguments: " <<id <<" " << x <<" "<< y <<" "<< width <<" "<< height );
1086 bool status = m_executor->execute(new LayerSetSourceRectangleCommand(id, x, y, width, height));
1089 g_pDbusMessage->initReply(msg);
1090 g_pDbusMessage->closeReply();
1094 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1098 void DBUSCommunicator::SetSurfaceDestinationRegion(DBusConnection* conn, DBusMessage* msg)
1100 (void)conn; // TODO: remove, only prevents warning
1102 g_pDbusMessage->initReceive(msg);
1103 uint id = g_pDbusMessage->getUInt();
1104 uint x = g_pDbusMessage->getUInt();
1105 uint y = g_pDbusMessage->getUInt();
1106 uint width = g_pDbusMessage->getUInt();
1107 uint height = g_pDbusMessage->getUInt();
1109 bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(id, x, y, width, height));
1112 g_pDbusMessage->initReply(msg);
1113 g_pDbusMessage->closeReply();
1117 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1121 void DBUSCommunicator::SetSurfacePosition(DBusConnection* conn, DBusMessage* msg)
1123 (void)conn; // TODO: remove, only prevents warning
1125 g_pDbusMessage->initReceive(msg);
1126 uint id = g_pDbusMessage->getUInt();
1127 uint x = g_pDbusMessage->getUInt();
1128 uint y = g_pDbusMessage->getUInt();
1130 bool status = m_executor->execute(new SurfaceSetPositionCommand(id, x, y));
1133 g_pDbusMessage->initReply(msg);
1134 g_pDbusMessage->closeReply();
1138 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1142 void DBUSCommunicator::GetSurfacePosition(DBusConnection* conn, DBusMessage* msg)
1144 (void)conn; // TODO: remove, only prevents warning
1146 g_pDbusMessage->initReceive(msg);
1147 uint id = g_pDbusMessage->getUInt();
1151 bool status = m_executor->execute(new SurfaceGetPositionCommand(id, &x, &y));
1154 g_pDbusMessage->initReply(msg);
1155 g_pDbusMessage->appendUInt(x);
1156 g_pDbusMessage->appendUInt(y);
1157 g_pDbusMessage->closeReply();
1161 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1165 void DBUSCommunicator::SetSurfaceDimension(DBusConnection* conn, DBusMessage* msg)
1167 (void)conn; // TODO: remove, only prevents warning
1169 g_pDbusMessage->initReceive(msg);
1170 uint id = g_pDbusMessage->getUInt();
1171 uint width = g_pDbusMessage->getUInt();
1172 uint height = g_pDbusMessage->getUInt();
1174 bool status = m_executor->execute(new SurfaceSetDimensionCommand(id, width, height));
1177 g_pDbusMessage->initReply(msg);
1178 g_pDbusMessage->closeReply();
1182 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1186 void DBUSCommunicator::SetLayerDestinationRegion(DBusConnection* conn, DBusMessage* msg)
1188 (void)conn; // TODO: remove, only prevents warning
1190 g_pDbusMessage->initReceive(msg);
1191 uint id = g_pDbusMessage->getUInt();
1192 uint x = g_pDbusMessage->getUInt();
1193 uint y = g_pDbusMessage->getUInt();
1194 uint width = g_pDbusMessage->getUInt();
1195 uint height = g_pDbusMessage->getUInt();
1197 bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(id, x, y, width, height));
1200 g_pDbusMessage->initReply(msg);
1201 g_pDbusMessage->closeReply();
1205 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1209 void DBUSCommunicator::SetLayerPosition(DBusConnection* conn, DBusMessage* msg)
1211 (void)conn; // TODO: remove, only prevents warning
1213 g_pDbusMessage->initReceive(msg);
1214 uint id = g_pDbusMessage->getUInt();
1215 uint x = g_pDbusMessage->getUInt();
1216 uint y = g_pDbusMessage->getUInt();
1218 bool status = m_executor->execute(new LayerSetPositionCommand(id, x, y));
1221 g_pDbusMessage->initReply(msg);
1222 g_pDbusMessage->closeReply();
1226 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1230 void DBUSCommunicator::GetLayerPosition(DBusConnection* conn, DBusMessage* msg)
1232 (void)conn; // TODO: remove, only prevents warning
1234 g_pDbusMessage->initReceive(msg);
1235 uint id = g_pDbusMessage->getUInt();
1239 bool status = m_executor->execute(new LayerGetPositionCommand(id, &x, &y));
1242 g_pDbusMessage->initReply(msg);
1243 g_pDbusMessage->appendUInt(x);
1244 g_pDbusMessage->appendUInt(y);
1245 g_pDbusMessage->closeReply();
1249 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1253 void DBUSCommunicator::SetLayerDimension(DBusConnection* conn, DBusMessage* msg)
1255 (void)conn; // TODO: remove, only prevents warning
1257 g_pDbusMessage->initReceive(msg);
1258 uint id = g_pDbusMessage->getUInt();
1259 uint width = g_pDbusMessage->getUInt();
1260 uint height = g_pDbusMessage->getUInt();
1262 bool status = m_executor->execute(new LayerSetDimensionCommand(id, width, height));
1265 g_pDbusMessage->initReply(msg);
1266 g_pDbusMessage->closeReply();
1270 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1274 void DBUSCommunicator::GetLayerDimension(DBusConnection* conn, DBusMessage* msg)
1276 (void)conn; // TODO: remove, only prevents warning
1278 g_pDbusMessage->initReceive(msg);
1279 uint id = g_pDbusMessage->getUInt();
1283 bool status = m_executor->execute(new LayerGetDimensionCommand(id, &width, &height));
1286 g_pDbusMessage->initReply(msg);
1287 g_pDbusMessage->appendUInt(width);
1288 g_pDbusMessage->appendUInt(height);
1289 g_pDbusMessage->closeReply();
1293 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1297 void DBUSCommunicator::GetSurfaceDimension(DBusConnection* conn, DBusMessage* msg)
1299 (void)conn; // TODO: remove, only prevents warning
1301 g_pDbusMessage->initReceive(msg);
1302 uint id = g_pDbusMessage->getUInt();
1306 bool status = m_executor->execute(new SurfaceGetDimensionCommand(id, &width, &height));
1309 g_pDbusMessage->initReply(msg);
1310 g_pDbusMessage->appendUInt(width);
1311 g_pDbusMessage->appendUInt(height);
1312 g_pDbusMessage->closeReply();
1316 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1320 void DBUSCommunicator::SetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg)
1322 (void)conn; // TODO: remove, only prevents warning
1324 g_pDbusMessage->initReceive(msg);
1325 uint id = g_pDbusMessage->getUInt();
1326 double param = g_pDbusMessage->getDouble();
1328 bool status = m_executor->execute(new SurfaceSetOpacityCommand(id, param));
1331 g_pDbusMessage->initReply(msg);
1332 g_pDbusMessage->closeReply();
1336 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1340 void DBUSCommunicator::SetLayerOpacity(DBusConnection* conn, DBusMessage* msg)
1342 (void)conn; // TODO: remove, only prevents warning
1344 g_pDbusMessage->initReceive(msg);
1345 uint id = g_pDbusMessage->getUInt();
1346 double param = g_pDbusMessage->getDouble();
1348 bool status = m_executor->execute(new LayerSetOpacityCommand(id, param));
1351 g_pDbusMessage->initReply(msg);
1352 g_pDbusMessage->closeReply();
1356 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1360 void DBUSCommunicator::SetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg)
1362 (void)conn; // TODO: remove, only prevents warning
1364 g_pDbusMessage->initReceive(msg);
1365 uint id = g_pDbusMessage->getUInt();
1366 double param = g_pDbusMessage->getDouble();
1368 bool status = m_executor->execute(new SurfacegroupSetOpacityCommand(id, param));
1371 g_pDbusMessage->initReply(msg);
1372 g_pDbusMessage->closeReply();
1376 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1380 void DBUSCommunicator::SetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg)
1382 (void)conn; // TODO: remove, only prevents warning
1384 g_pDbusMessage->initReceive(msg);
1385 uint id = g_pDbusMessage->getUInt();
1386 double param = g_pDbusMessage->getDouble();
1388 bool status = m_executor->execute(new LayergroupSetOpacityCommand(id, param));
1391 g_pDbusMessage->initReply(msg);
1392 g_pDbusMessage->closeReply();
1396 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1400 void DBUSCommunicator::GetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg)
1402 (void)conn; // TODO: remove, only prevents warning
1404 g_pDbusMessage->initReceive(msg);
1405 uint id = g_pDbusMessage->getUInt();
1408 bool status = m_executor->execute(new SurfaceGetOpacityCommand(id, ¶m));
1411 g_pDbusMessage->initReply(msg);
1412 g_pDbusMessage->appendDouble(param);
1413 g_pDbusMessage->closeReply();
1417 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1421 void DBUSCommunicator::GetLayerOpacity(DBusConnection* conn, DBusMessage* msg)
1423 (void)conn; // TODO: remove, only prevents warning
1425 g_pDbusMessage->initReceive(msg);
1426 uint id = g_pDbusMessage->getUInt();
1429 bool status = m_executor->execute(new LayerGetOpacityCommand(id, ¶m));
1432 g_pDbusMessage->initReply(msg);
1433 g_pDbusMessage->appendDouble(param);
1434 g_pDbusMessage->closeReply();
1438 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1442 void DBUSCommunicator::GetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg)
1444 (void)conn; // TODO: remove, only prevents warning
1446 g_pDbusMessage->initReceive(msg);
1447 uint id = g_pDbusMessage->getUInt();
1450 bool status = m_executor->execute(new SurfacegroupGetOpacityCommand(id, ¶m));
1453 g_pDbusMessage->initReply(msg);
1454 g_pDbusMessage->appendDouble(param);
1455 g_pDbusMessage->closeReply();
1459 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1463 void DBUSCommunicator::GetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg)
1465 (void)conn; // TODO: remove, only prevents warning
1467 g_pDbusMessage->initReceive(msg);
1468 uint id = g_pDbusMessage->getUInt();
1471 bool status = m_executor->execute(new LayergroupGetOpacityCommand(id, ¶m));
1474 g_pDbusMessage->initReply(msg);
1475 g_pDbusMessage->appendDouble(param);
1476 g_pDbusMessage->closeReply();
1480 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1484 void DBUSCommunicator::SetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg)
1486 (void)conn; // TODO: remove, only prevents warning
1488 g_pDbusMessage->initReceive(msg);
1489 uint id = g_pDbusMessage->getUInt();
1490 uint param = g_pDbusMessage->getUInt();
1491 OrientationType o = (OrientationType) param;
1493 bool status = m_executor->execute(new SurfaceSetOrientationCommand(id, o));
1496 g_pDbusMessage->initReply(msg);
1497 g_pDbusMessage->closeReply();
1501 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1505 void DBUSCommunicator::GetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg)
1507 (void)conn; // TODO: remove, only prevents warning
1509 g_pDbusMessage->initReceive(msg);
1510 uint id = g_pDbusMessage->getUInt();
1513 bool status = m_executor->execute(new SurfaceGetOrientationCommand(id, &o));
1516 g_pDbusMessage->initReply(msg);
1517 g_pDbusMessage->appendUInt(o);
1518 g_pDbusMessage->closeReply();
1522 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1526 void DBUSCommunicator::SetLayerOrientation(DBusConnection* conn, DBusMessage* msg)
1528 (void)conn; // TODO: remove, only prevents warning
1530 g_pDbusMessage->initReceive(msg);
1531 uint id = g_pDbusMessage->getUInt();
1532 uint param = g_pDbusMessage->getUInt();
1533 OrientationType o = (OrientationType) param;
1535 bool status = m_executor->execute(new LayerSetOrientationCommand(id, o));
1538 g_pDbusMessage->initReply(msg);
1539 g_pDbusMessage->closeReply();
1543 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1547 void DBUSCommunicator::GetLayerOrientation(DBusConnection* conn, DBusMessage* msg)
1549 (void)conn; // TODO: remove, only prevents warning
1551 g_pDbusMessage->initReceive(msg);
1552 uint id = g_pDbusMessage->getUInt();
1555 bool status = m_executor->execute(new LayerGetOrientationCommand(id, &o));
1558 g_pDbusMessage->initReply(msg);
1559 g_pDbusMessage->appendUInt(o);
1560 g_pDbusMessage->closeReply();
1564 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1568 void DBUSCommunicator::GetSurfacePixelformat(DBusConnection* conn, DBusMessage* msg)
1570 (void)conn; // TODO: remove, only prevents warning
1572 g_pDbusMessage->initReceive(msg);
1573 uint id = g_pDbusMessage->getUInt();
1576 bool status = m_executor->execute(new SurfaceGetPixelformatCommand(id, ¶m));
1579 g_pDbusMessage->initReply(msg);
1580 g_pDbusMessage->appendUInt(param);
1581 g_pDbusMessage->closeReply();
1585 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1589 void DBUSCommunicator::SetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg)
1591 (void)conn; // TODO: remove, only prevents warning
1593 g_pDbusMessage->initReceive(msg);
1594 const uint surfaceid = g_pDbusMessage->getUInt();
1595 bool newVis = g_pDbusMessage->getBool();
1597 bool status = m_executor->execute(new SurfaceSetVisibilityCommand(surfaceid, newVis));
1600 g_pDbusMessage->initReply(msg);
1601 g_pDbusMessage->closeReply();
1605 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1609 void DBUSCommunicator::SetLayerVisibility(DBusConnection* conn, DBusMessage* msg)
1611 (void)conn; // TODO: remove, only prevents warning
1613 g_pDbusMessage->initReceive(msg);
1614 const uint layerid = g_pDbusMessage->getUInt();
1615 bool myparam = g_pDbusMessage->getBool();
1617 bool status = m_executor->execute(new LayerSetVisibilityCommand(layerid, myparam));
1620 g_pDbusMessage->initReply(msg);
1621 g_pDbusMessage->closeReply();
1625 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1629 void DBUSCommunicator::GetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg)
1631 (void)conn; // TODO: remove, only prevents warning
1633 g_pDbusMessage->initReceive(msg);
1634 uint id = g_pDbusMessage->getUInt();
1637 bool status = m_executor->execute(new SurfaceGetVisibilityCommand(id, ¶m));
1640 g_pDbusMessage->initReply(msg);
1641 //LOG_DEBUG("DBUSCommunicator", "returning surfacevisibility: " << param);
1642 g_pDbusMessage->appendBool(param);
1643 g_pDbusMessage->closeReply();
1647 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1651 void DBUSCommunicator::GetLayerVisibility(DBusConnection* conn, DBusMessage* msg)
1653 (void)conn; // TODO: remove, only prevents warning
1655 g_pDbusMessage->initReceive(msg);
1656 uint id = g_pDbusMessage->getUInt();
1659 bool status = m_executor->execute(new LayerGetVisibilityCommand(id, ¶m));
1662 g_pDbusMessage->initReply(msg);
1663 g_pDbusMessage->appendBool(param);
1664 //LOG_DEBUG("DBUSCommunicator", "returning layervisibility: " << param);
1665 g_pDbusMessage->closeReply();
1669 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1673 void DBUSCommunicator::SetSurfacegroupVisibility(DBusConnection* conn, DBusMessage* msg)
1675 (void)conn; // TODO: remove, only prevents warning
1677 g_pDbusMessage->initReceive(msg);
1678 uint groupid = g_pDbusMessage->getUInt();
1679 bool myparam = g_pDbusMessage->getBool();
1681 bool status = m_executor->execute(new SurfacegroupSetVisibilityCommand(groupid, myparam));
1684 g_pDbusMessage->initReply(msg);
1685 g_pDbusMessage->closeReply();
1689 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1693 void DBUSCommunicator::SetLayergroupVisibility(DBusConnection* conn, DBusMessage* msg)
1695 (void)conn; // TODO: remove, only prevents warning
1697 g_pDbusMessage->initReceive(msg);
1698 uint groupid = g_pDbusMessage->getUInt();
1699 bool myparam = g_pDbusMessage->getBool();
1701 bool status = m_executor->execute(new LayergroupSetVisibilityCommand(groupid, myparam));
1704 g_pDbusMessage->initReply(msg);
1705 g_pDbusMessage->closeReply();
1709 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1714 void DBUSCommunicator::SetRenderOrderOfLayers(DBusConnection* conn, DBusMessage* msg)
1716 (void)conn; // TODO: remove, only prevents warning
1720 g_pDbusMessage->initReceive(msg);
1721 g_pDbusMessage->getArrayOfUInt(&length, &array);
1723 //LOG_DEBUG("DBUSCommunicator","Renderorder: Got " << length << " ids.");
1725 bool status = m_executor->execute(new ScreenSetRenderOrderCommand(array, length));
1728 g_pDbusMessage->initReply(msg);
1729 g_pDbusMessage->closeReply();
1733 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1737 void DBUSCommunicator::SetSurfaceRenderOrderWithinLayer(DBusConnection* conn, DBusMessage* msg)
1739 (void)conn; // TODO: remove, only prevents warning
1744 g_pDbusMessage->initReceive(msg);
1745 uint layerid = g_pDbusMessage->getUInt();
1747 g_pDbusMessage->getArrayOfUInt(&length, &array);
1750 bool status = m_executor->execute(new LayerSetRenderOrderCommand(layerid, array, length));
1753 g_pDbusMessage->initReply(msg);
1754 g_pDbusMessage->closeReply();
1758 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1762 void DBUSCommunicator::GetLayerType(DBusConnection* conn, DBusMessage* msg)
1764 (void)conn; // TODO: remove, only prevents warning
1766 g_pDbusMessage->initReceive(msg);
1767 uint id = g_pDbusMessage->getUInt();
1768 Layer* l = m_executor->getScene()->getLayer(id);
1771 g_pDbusMessage->initReply(msg);
1772 g_pDbusMessage->appendUInt(l->getLayerType());
1773 g_pDbusMessage->closeReply();
1777 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1781 void DBUSCommunicator::GetLayertypeCapabilities(DBusConnection* conn, DBusMessage* msg)
1783 (void)conn; // TODO: remove, only prevents warning
1785 g_pDbusMessage->initReceive(msg);
1786 uint id = g_pDbusMessage->getUInt();
1787 LayerType type = (LayerType) id;
1788 uint capabilities = m_executor->getLayerTypeCapabilities(type);
1789 //LOG_DEBUG("DBUSCommunicator", "GetLayertypeCapabilities: returning capabilities:" << capabilities);
1790 g_pDbusMessage->initReply(msg);
1791 g_pDbusMessage->appendUInt(capabilities);
1792 g_pDbusMessage->closeReply();
1795 void DBUSCommunicator::GetLayerCapabilities(DBusConnection* conn, DBusMessage* msg)
1797 (void)conn; // TODO: remove, only prevents warning
1799 g_pDbusMessage->initReceive(msg);
1800 uint id = g_pDbusMessage->getUInt();
1801 Layer* l = m_executor->getScene()->getLayer(id);
1804 g_pDbusMessage->initReply(msg);
1805 g_pDbusMessage->appendUInt(l->getCapabilities());
1806 g_pDbusMessage->closeReply();
1810 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1814 void DBUSCommunicator::FadeIn(DBusConnection* conn, DBusMessage* msg)
1816 (void)conn; // TODO: remove, only prevents warning
1818 g_pDbusMessage->initReceive(msg);
1819 g_pDbusMessage->initReply(msg);
1820 g_pDbusMessage->closeReply();
1823 void DBUSCommunicator::SynchronizedFade(DBusConnection* conn, DBusMessage* msg)
1825 (void)conn; // TODO: remove, only prevents warning
1827 g_pDbusMessage->initReceive(msg);
1828 g_pDbusMessage->initReply(msg);
1829 g_pDbusMessage->closeReply();
1832 void DBUSCommunicator::FadeOut(DBusConnection* conn, DBusMessage* msg)
1834 (void)conn; // TODO: remove, only prevents warning
1836 g_pDbusMessage->initReceive(msg);
1837 g_pDbusMessage->initReply(msg);
1838 g_pDbusMessage->closeReply();
1841 void DBUSCommunicator::Exit(DBusConnection* conn, DBusMessage* msg)
1843 (void)conn; // TODO: remove, only prevents warning
1845 bool status = m_executor->execute(new ExitCommand());
1848 g_pDbusMessage->initReply(msg);
1849 g_pDbusMessage->closeReply();
1853 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
1857 void DBUSCommunicator::CommitChanges(DBusConnection* conn, DBusMessage* msg)
1859 (void)conn; // TODO: remove, only prevents warning
1861 bool status = m_executor->execute(new CommitCommand());
1864 g_pDbusMessage->initReply(msg);
1865 g_pDbusMessage->closeReply();
1869 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
1873 void DBUSCommunicator::CreateShader(DBusConnection* conn, DBusMessage* msg)
1875 (void)conn; // TODO: remove, only prevents warning
1877 g_pDbusMessage->initReceive(msg);
1878 char* vertname = g_pDbusMessage->getString();
1879 char* fragname = g_pDbusMessage->getString();
1882 bool status = m_executor->execute(new ShaderCreateCommand(vertname, fragname, &id));
1885 g_pDbusMessage->initReply(msg);
1886 g_pDbusMessage->appendUInt(id);
1887 g_pDbusMessage->closeReply();
1891 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1895 void DBUSCommunicator::DestroyShader(DBusConnection* conn, DBusMessage* msg)
1897 (void)conn; // TODO: remove, only prevents warning
1899 g_pDbusMessage->initReceive(msg);
1900 uint shaderid = g_pDbusMessage->getUInt();
1902 bool status = m_executor->execute(new ShaderDestroyCommand(shaderid));
1905 g_pDbusMessage->initReply(msg);
1906 g_pDbusMessage->closeReply();
1910 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1914 void DBUSCommunicator::SetShader(DBusConnection* conn, DBusMessage* msg)
1916 (void)conn; // TODO: remove, only prevents warning
1918 g_pDbusMessage->initReceive(msg);
1919 uint surfaceId = g_pDbusMessage->getUInt();
1920 uint shaderid = g_pDbusMessage->getUInt();
1922 bool status = m_executor->execute(new SurfaceSetShaderCommand(surfaceId, shaderid));
1925 g_pDbusMessage->initReply(msg);
1926 g_pDbusMessage->closeReply();
1930 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1934 void DBUSCommunicator::SetUniforms(DBusConnection* conn, DBusMessage* msg)
1936 (void)conn; // TODO: remove, only prevents warning
1938 g_pDbusMessage->initReceive(msg);
1939 uint id = g_pDbusMessage->getUInt();
1941 std::vector<string> uniforms;
1943 g_pDbusMessage->getArrayOfString(&uniforms);
1945 bool status = m_executor->execute(new ShaderSetUniformsCommand(id, uniforms));
1948 g_pDbusMessage->initReply(msg);
1949 g_pDbusMessage->closeReply();
1953 g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1957 DBusHandlerResult DBUSCommunicator::delegateMessage(DBusConnection* conn, DBusMessage* msg)
1959 DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED;
1960 LOG_DEBUG("DBUSCommunicator","message received");
1961 const char *n = dbus_message_get_member(msg);
1965 while (!found && strcmp(manager_methods[i].name, "") != 0)
1967 if (n && strcmp(manager_methods[i].name, n) == 0)
1969 MethodTable entry = manager_methods[i];
1970 LOG_DEBUG("DBUSCommunicator","got call for method:" << entry.name);
1971 CallBackMethod m = entry.function;
1972 LOG_DEBUG("DBUSCommunicator","enter method");
1973 (this->*m)(conn, msg);
1979 if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
1981 LOG_DEBUG("DBUSCommunicator", "Introspection called");
1982 DBUSIntrospection introspectionString(manager_methods);
1983 introspectionString.process(conn, msg);
1984 g_pDbusMessage->setConnection(conn);
1985 found = true; // TODO: always true
1990 result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1995 extern "C" ICommunicator* createDBUSCommunicator(ICommandExecutor* executor)
1997 return new DBUSCommunicator(executor);
2000 extern "C" void destroyDBUSCommunicator(DBUSCommunicator* p)