Improved Error handling sended by dbus.
[profile/ivi/layer-management.git] / LayerManagerPlugins / Communicators / DBUSCommunicator / src / DBUSCommunicator.cpp
1 /***************************************************************************
2  *
3  * Copyright 2010,2011 BMW Car IT GmbH
4  *
5  *
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
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  *
18  ****************************************************************************/
19 #include <dbus/dbus.h>
20 #include <stdbool.h>
21 #include <unistd.h>
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include <string.h>
25 #include <string>
26
27 #include "DBUSCommunicator.h"
28 #include "DBUSIntrospection.h"
29 #include "DBUSMessageHandler.h"
30 #include "DBUSConfiguration.h"
31
32 #include "Log.h"
33
34 #define DEFAULT_SCREEN 0
35
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";
40
41
42
43 static DBUSMessageHandler* g_pDbusMessage;
44
45 static MethodTable manager_methods[] =
46 {
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 },
129     { "",                                 "",      "",            NULL }
130 };
131
132 #include <sstream>
133 using std::stringstream;
134
135 #include <string>
136 using std::string;
137
138 DBUSCommunicator::DBUSCommunicator(ICommandExecutor* executor)
139 : ICommunicator(executor)
140 , m_running(false)
141 {
142 }
143
144 void DBUSCommunicator::setdebug(bool onoff)
145 {
146     (void)onoff; // TODO: remove, only prevents warning
147 }
148
149 bool DBUSCommunicator::start()
150 {
151         LOG_DEBUG("DBUSCommunicator", "Starting up dbus connector");
152
153     g_pDbusMessage = new DBUSMessageHandler();
154
155     LOG_DEBUG("DBUSCommunicator","registering for dbus path " << DBUS_SERVICE_OBJECT_PATH);
156     bool registered = g_pDbusMessage->registerPathFunction(DBUSCommunicator::processMessageFunc,
157                                                                DBUSCommunicator::unregisterMessageFunc,
158                                                                this);
159     if (!registered)
160     {
161         LOG_ERROR("DBUSCommunicator","Register Message Callbacks failed");
162         exit(-1);
163     }
164
165     LOG_INFO("DBUSCommunicator", "Started dbus connector");
166     return true;
167 }
168
169 void DBUSCommunicator::stop()
170 {
171     LOG_INFO("DBUSCommunicator","stopping");
172
173     // deregister dbus messaging implicitly by deleting messageHandler
174     delete g_pDbusMessage;
175 }
176
177 void DBUSCommunicator::Debug(DBusConnection* conn, DBusMessage* msg)
178 {
179     (void)conn; // TODO: remove, only prevents warning
180
181     g_pDbusMessage->initReceive(msg);
182     bool param = g_pDbusMessage->getBool();
183
184     bool status = m_executor->execute(new DebugCommand(param));
185     if (status)
186     {
187         g_pDbusMessage->initReply(msg);
188         g_pDbusMessage->closeReply();
189     }
190     else
191     {
192         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
193     }
194 }
195
196 void DBUSCommunicator::GetScreenResolution(DBusConnection* conn, DBusMessage* msg)
197 {
198     (void)conn; // TODO: remove, only prevents warning
199
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();
207 }
208
209 void DBUSCommunicator::GetNumberOfHardwareLayers(DBusConnection* conn, DBusMessage* msg)
210 {
211     (void)conn; // TODO: remove, only prevents warning
212
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();
219 }
220
221 void DBUSCommunicator::GetScreenIDs(DBusConnection* conn, DBusMessage* msg)
222 {
223     (void)conn; // TODO: remove, only prevents warning
224
225     g_pDbusMessage->initReceive(msg);
226     uint length = 0;
227     uint* IDs = m_executor->getScreenIDs(&length);
228     g_pDbusMessage->initReply(msg);
229     g_pDbusMessage->appendArrayOfUInt(length, IDs);
230     g_pDbusMessage->closeReply();
231 }
232
233 void DBUSCommunicator::ScreenShot(DBusConnection* conn, DBusMessage* msg)
234 {
235     (void)conn; // TODO: remove, only prevents warning
236
237     g_pDbusMessage->initReceive(msg);
238     uint screenid = g_pDbusMessage->getUInt();
239     char* filename = g_pDbusMessage->getString();
240
241     bool status = m_executor->execute(new ScreenDumpCommand(filename, screenid));
242     if (status)
243     {
244         g_pDbusMessage->initReply(msg);
245         g_pDbusMessage->closeReply();
246     }
247     else
248     {
249         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
250     }
251 }
252 void DBUSCommunicator::process(int timeout_ms) 
253 {
254     dbus_connection_read_write_dispatch (g_pDbusMessage->getConnection(), timeout_ms);
255 }
256 void DBUSCommunicator::ScreenShotOfLayer(DBusConnection* conn, DBusMessage* msg)
257 {
258     (void)conn; // TODO: remove, only prevents warning
259
260     g_pDbusMessage->initReceive(msg);
261     char* filename = g_pDbusMessage->getString();
262     uint layerid = g_pDbusMessage->getUInt();
263
264     bool status = m_executor->execute(new LayerDumpCommand(filename, layerid));
265     if (status)
266     {
267         g_pDbusMessage->initReply(msg);
268         g_pDbusMessage->closeReply();
269     }
270     else
271     {
272         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
273     }
274 }
275
276 void DBUSCommunicator::ScreenShotOfSurface(DBusConnection* conn, DBusMessage* msg)
277 {
278     (void)conn; // TODO: remove, only prevents warning
279
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));
284     if (status)
285     {
286         g_pDbusMessage->initReply(msg);
287         g_pDbusMessage->closeReply();
288     }
289     else
290     {
291         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
292     }
293 }
294
295 void DBUSCommunicator::ListAllLayerIDS(DBusConnection* conn, DBusMessage* msg)
296 {
297     (void)conn; // TODO: remove, only prevents warning
298
299     uint* array = NULL;
300     uint length = 0;
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();
307 }
308
309 void DBUSCommunicator::ListAllLayerIDsOnScreen(DBusConnection* conn, DBusMessage* msg)
310 {
311     (void)conn; // TODO: remove, only prevents warning
312
313     g_pDbusMessage->initReceive(msg);
314     uint screenID = g_pDbusMessage->getUInt();
315
316     uint* array = NULL;
317     uint length = 0;
318     m_executor->getScene()->lockScene();
319     bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array);
320     if (status)
321     {
322         g_pDbusMessage->initReply(msg);
323         g_pDbusMessage->appendArrayOfUInt(length, array);
324         g_pDbusMessage->closeReply();
325     }
326     else
327     {
328         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
329     }
330     m_executor->getScene()->unlockScene();
331
332 }
333
334 void DBUSCommunicator::ListAllSurfaceIDS(DBusConnection* conn, DBusMessage* msg)
335 {
336     (void)conn; // TODO: remove, only prevents warning
337
338     uint* array = NULL;
339     uint length = 0;
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();
346 }
347
348 void DBUSCommunicator::ListAllLayerGroupIDS(DBusConnection* conn, DBusMessage* msg)
349 {
350     (void)conn; // TODO: remove, only prevents warning
351
352     uint* array = NULL;
353     uint length = 0;
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();
360 }
361
362 void DBUSCommunicator::ListAllSurfaceGroupIDS(DBusConnection* conn, DBusMessage* msg)
363 {
364     (void)conn; // TODO: remove, only prevents warning
365
366     uint* array = NULL;
367     uint length = 0;
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();
374 }
375
376 void DBUSCommunicator::ListSurfacesOfSurfacegroup(DBusConnection* conn, DBusMessage* msg)
377 {
378     (void)conn; // TODO: remove, only prevents warning
379
380     g_pDbusMessage->initReceive(msg);
381     uint id = g_pDbusMessage->getUInt();
382     m_executor->getScene()->lockScene();
383     SurfaceGroup* sg = m_executor->getScene()->getSurfaceGroup(id);
384     if (NULL != sg)
385     {
386         std::list<Surface*> surfaces = sg->getList();
387         uint length = surfaces.size();
388         uint* array = new uint[length];
389         uint arrayPos = 0;
390         g_pDbusMessage->initReply(msg);
391
392         for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
393         {
394             Surface* s = *it;
395             array[arrayPos] = s->getID();
396             ++arrayPos;
397         }
398
399         g_pDbusMessage->appendArrayOfUInt(length, array);
400
401         g_pDbusMessage->closeReply();
402         m_executor->getScene()->unlockScene();
403     }
404     else
405     {
406         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
407     }
408 }
409 DBusHandlerResult DBUSCommunicator::processMessageFunc(DBusConnection* conn,DBusMessage* msg, void *user_data)
410 {
411     return ((DBUSCommunicator*)user_data)->delegateMessage(conn,msg);
412 }
413
414 void DBUSCommunicator::unregisterMessageFunc(DBusConnection* conn, void *user_data)
415 {
416     DBusConnection* connection = NULL;
417     DBUSCommunicator* cominstance = NULL;
418     connection = conn;
419     cominstance = (DBUSCommunicator*)user_data;
420 }
421
422 void DBUSCommunicator::ListLayersOfLayergroup(DBusConnection* conn, DBusMessage* msg)
423 {
424     (void)conn; // TODO: remove, only prevents warning
425
426     g_pDbusMessage->initReceive(msg);
427     uint id = g_pDbusMessage->getUInt();
428     m_executor->getScene()->lockScene();
429     LayerGroup* sg = m_executor->getScene()->getLayerGroup(id);
430     if (NULL != sg)
431     {
432         std::list<Layer*> layers = sg->getList();
433
434         uint length = layers.size();
435         uint* array = new uint[length];
436         uint arrayPos = 0;
437
438         g_pDbusMessage->initReply(msg);
439         for (std::list<Layer*>::const_iterator it = layers.begin(); it != layers.end(); ++it)
440         {
441             Layer* l = *it;
442             array[arrayPos] = l->getID();
443             ++arrayPos;
444         }
445
446         g_pDbusMessage->appendArrayOfUInt(length, array);
447
448         g_pDbusMessage->closeReply();
449         m_executor->getScene()->unlockScene();
450     }
451     else
452     {
453         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
454     }
455 }
456
457 void DBUSCommunicator::ListSurfaceofLayer(DBusConnection* conn, DBusMessage* msg)
458 {
459     (void)conn; // TODO: remove, only prevents warning
460
461     g_pDbusMessage->initReceive(msg);
462     uint id = g_pDbusMessage->getUInt();
463     m_executor->getScene()->lockScene();
464     Layer* layer = m_executor->getScene()->getLayer(id);
465     if (layer != NULL)
466     {
467         std::list<Surface*> surfaces = layer->getAllSurfaces();
468
469         uint length = surfaces.size();
470         uint* array = new uint[length];
471         uint arrayPos = 0;
472
473         g_pDbusMessage->initReply(msg);
474
475         for (std::list<Surface*>::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it)
476         {
477             Surface* s = *it;
478             array[arrayPos] = s->getID();
479             ++arrayPos;
480         }
481
482         g_pDbusMessage->appendArrayOfUInt(length, array);
483
484         g_pDbusMessage->closeReply();
485     }
486     else
487     {
488         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
489     }
490     m_executor->getScene()->unlockScene();
491 }
492
493 void DBUSCommunicator::GetPropertiesOfSurface(DBusConnection* conn, DBusMessage* msg)
494 {
495     (void)conn; // TODO: remove, only prevents warning
496
497     g_pDbusMessage->initReceive(msg);
498     uint id = g_pDbusMessage->getUInt();
499
500     Surface* surface = m_executor->getScene()->getSurface(id);
501     if (surface != NULL)
502     {
503         Rectangle dest = surface->getDestinationRegion();
504         Rectangle src = surface->getSourceRegion();
505         OrientationType orientation = surface->getOrientation();
506
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();
523     }
524     else
525     {
526         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
527     }
528 }
529
530 void DBUSCommunicator::GetPropertiesOfLayer(DBusConnection* conn, DBusMessage* msg)
531 {
532     (void)conn; // TODO: remove, only prevents warning
533
534     g_pDbusMessage->initReceive(msg);
535     uint id = g_pDbusMessage->getUInt();
536
537     Layer* layer = m_executor->getScene()->getLayer(id);
538     if (layer != NULL)
539     {
540         Rectangle dest = layer->getDestinationRegion();
541         Rectangle src = layer->getSourceRegion();
542         OrientationType orientation = layer->getOrientation();
543
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();
559     }
560     else
561     {
562         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
563     }
564 }
565
566 void DBUSCommunicator::CreateSurface(DBusConnection* conn, DBusMessage* msg)
567 {
568     (void)conn; // TODO: remove, only prevents warning
569
570     (void)conn; // TODO: remove, only prevents warning
571
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;
578
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));    
585     if (status)
586     {
587         g_pDbusMessage->initReply(msg);
588         g_pDbusMessage->appendUInt(id);
589         g_pDbusMessage->closeReply();
590     }
591     else
592     {
593         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
594     }
595 }
596
597 void DBUSCommunicator::CreateSurfaceFromId(DBusConnection* conn, DBusMessage* msg)
598 {
599     (void)conn; // TODO: remove, only prevents warning
600
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;
607
608     //LOG_DEBUG("DBUSCommunicator::CreateSurface","pixelformat: " << pixelformat);
609     uint id = g_pDbusMessage->getUInt();
610
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));    
615
616     if (status)
617     {
618         g_pDbusMessage->initReply(msg);
619         g_pDbusMessage->appendUInt(id);
620         g_pDbusMessage->closeReply();
621     }
622     else
623     {
624         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
625     }
626 }
627
628 void DBUSCommunicator::InitializeSurface(DBusConnection* conn, DBusMessage* msg)
629 {
630     (void)conn; // TODO: remove, only prevents warning
631
632     g_pDbusMessage->initReceive(msg);
633     uint id = GraphicalObject::INVALID_ID;
634
635     bool status = m_executor->execute(new SurfaceCreateCommand(&id));
636     if (status)
637     {
638         g_pDbusMessage->initReply(msg);
639         g_pDbusMessage->appendUInt(id);
640         g_pDbusMessage->closeReply();
641     }
642     else
643     {
644         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
645     }
646 }
647
648 void DBUSCommunicator::InitializeSurfaceFromId(DBusConnection* conn, DBusMessage* msg)
649 {
650     (void)conn; // TODO: remove, only prevents warning
651
652     g_pDbusMessage->initReceive(msg);
653     uint id = g_pDbusMessage->getUInt();
654     bool status = m_executor->execute(new SurfaceCreateCommand(&id));
655     if (status)
656     {
657         g_pDbusMessage->initReply(msg);
658         g_pDbusMessage->appendUInt(id);
659         g_pDbusMessage->closeReply();
660     }
661     else
662     {
663         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
664     }
665 }
666
667 void DBUSCommunicator::SetSurfaceNativeContent(DBusConnection* conn, DBusMessage* msg)
668 {
669     (void)conn; // TODO: remove, only prevents warning
670
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();
677
678     bool status = m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height));
679     if (status)
680     {
681         g_pDbusMessage->initReply(msg);
682         g_pDbusMessage->closeReply();
683     }
684     else
685     {
686         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
687     }
688 }
689
690 void DBUSCommunicator::RemoveSurface(DBusConnection* conn, DBusMessage* msg)
691 {
692     (void)conn; // TODO: remove, only prevents warning
693
694     g_pDbusMessage->initReceive(msg);
695     uint param = g_pDbusMessage->getUInt();
696     bool status = m_executor->execute(new SurfaceRemoveCommand(param));
697     if (status)
698     {
699         g_pDbusMessage->initReply(msg);
700         g_pDbusMessage->closeReply();
701     }
702     else
703     {
704         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
705     }
706 }
707
708 void DBUSCommunicator::CreateLayer(DBusConnection* conn, DBusMessage* msg)
709 {
710     (void)conn; // TODO: remove, only prevents warning
711
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));
716     if (status)
717     {
718         g_pDbusMessage->initReply(msg);
719         g_pDbusMessage->appendUInt(id);
720         g_pDbusMessage->closeReply();
721     }
722     else
723     {
724         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
725     }
726 }
727
728 void DBUSCommunicator::CreateLayerFromId(DBusConnection* conn, DBusMessage* msg)
729 {
730     (void)conn; // TODO: remove, only prevents warning
731
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));
738     if (status)
739     {
740         g_pDbusMessage->initReply(msg);
741         g_pDbusMessage->appendUInt(id);
742         g_pDbusMessage->closeReply();
743     }
744     else
745     {
746         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
747     }
748 }
749
750
751 void DBUSCommunicator::CreateLayerWithDimension(DBusConnection* conn, DBusMessage* msg)
752 {
753     (void)conn; // TODO: remove, only prevents warning
754
755     g_pDbusMessage->initReceive(msg);
756     uint width = g_pDbusMessage->getUInt();
757     uint height = g_pDbusMessage->getUInt();
758
759     uint id = GraphicalObject::INVALID_ID;
760     bool status = m_executor->execute(new LayerCreateCommand(width, height, &id));
761     if (status)
762     {
763         g_pDbusMessage->initReply(msg);
764         g_pDbusMessage->appendUInt(id);
765         g_pDbusMessage->closeReply();
766     }
767     else
768     {
769         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
770     }
771 }
772
773 void DBUSCommunicator::CreateLayerFromIdWithDimension(DBusConnection* conn, DBusMessage* msg)
774 {
775     (void)conn; // TODO: remove, only prevents warning
776
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));
783     if (status)
784     {
785         g_pDbusMessage->initReply(msg);
786         g_pDbusMessage->appendUInt(id);
787         g_pDbusMessage->closeReply();
788     }
789     else
790     {
791         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
792     }
793 }
794
795 void DBUSCommunicator::RemoveLayer(DBusConnection* conn, DBusMessage* msg)
796 {
797    (void)conn; // TODO: remove, only prevents warning
798
799     g_pDbusMessage->initReceive(msg);
800     uint param = g_pDbusMessage->getUInt();
801     bool status = m_executor->execute(new LayerRemoveCommand(param));
802     if (status)
803     {
804         g_pDbusMessage->initReply(msg);
805         g_pDbusMessage->closeReply();
806     }
807     else
808     {
809         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
810     }
811 }
812
813 void DBUSCommunicator::AddSurfaceToSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
814 {
815     (void)conn; // TODO: remove, only prevents warning
816
817     g_pDbusMessage->initReceive(msg);
818     uint surfaceid = g_pDbusMessage->getUInt();
819     uint surfacegroupid = g_pDbusMessage->getUInt();
820
821     bool status = m_executor->execute(new SurfacegroupAddSurfaceCommand(surfacegroupid, surfaceid));
822     if (status)
823     {
824         g_pDbusMessage->initReply(msg);
825         g_pDbusMessage->closeReply();
826     }
827     else
828     {
829         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
830     }
831 }
832
833 void DBUSCommunicator::RemoveSurfaceFromSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
834 {
835     (void)conn; // TODO: remove, only prevents warning
836
837     g_pDbusMessage->initReceive(msg);
838     uint surfaceid = g_pDbusMessage->getUInt();
839     uint surfacegroupid = g_pDbusMessage->getUInt();
840
841     bool status = m_executor->execute(new SurfacegroupRemoveSurfaceCommand(surfacegroupid, surfaceid));
842     if (status)
843     {
844         g_pDbusMessage->initReply(msg);
845         g_pDbusMessage->closeReply();
846     }
847     else
848     {
849         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
850     }
851 }
852
853 void DBUSCommunicator::AddLayerToLayerGroup(DBusConnection* conn, DBusMessage* msg)
854 {
855     (void)conn; // TODO: remove, only prevents warning
856
857     g_pDbusMessage->initReceive(msg);
858     uint layerid = g_pDbusMessage->getUInt();
859     uint layergroupid = g_pDbusMessage->getUInt();
860
861     bool status = m_executor->execute(new LayergroupAddLayerCommand(layergroupid, layerid));
862     if (status)
863     {
864         g_pDbusMessage->initReply(msg);
865         g_pDbusMessage->closeReply();
866     }
867     else
868     {
869         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
870     }
871 }
872
873 void DBUSCommunicator::RemoveLayerFromLayerGroup(DBusConnection* conn, DBusMessage* msg)
874 {
875     (void)conn; // TODO: remove, only prevents warning
876
877     g_pDbusMessage->initReceive(msg);
878     uint layerid = g_pDbusMessage->getUInt();
879     uint layergroupid = g_pDbusMessage->getUInt();
880
881     bool status = m_executor->execute(new LayergroupRemoveLayerCommand(layergroupid, layerid));
882     if (status)
883     {
884         g_pDbusMessage->initReply(msg);
885         g_pDbusMessage->closeReply();
886     }
887     else
888     {
889         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
890     }
891 }
892
893 void DBUSCommunicator::AddSurfaceToLayer(DBusConnection* conn, DBusMessage* msg)
894 {
895     (void)conn; // TODO: remove, only prevents warning
896
897     g_pDbusMessage->initReceive(msg);
898     uint surfaceid = g_pDbusMessage->getUInt();
899     uint layer = g_pDbusMessage->getUInt();
900
901     bool status = m_executor->execute(new LayerAddSurfaceCommand(layer, surfaceid));
902     if (status)
903     {
904         g_pDbusMessage->initReply(msg);
905         g_pDbusMessage->closeReply();
906     }
907     else
908     {
909         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
910     }
911 }
912
913 void DBUSCommunicator::RemoveSurfaceFromLayer(DBusConnection* conn, DBusMessage* msg)
914 {
915     (void)conn; // TODO: remove, only prevents warning
916
917     g_pDbusMessage->initReceive(msg);
918     uint surfaceid = g_pDbusMessage->getUInt();
919     uint layerid = g_pDbusMessage->getUInt();
920
921     bool status = m_executor->execute(new LayerRemoveSurfaceCommand(layerid, surfaceid));
922     if (status)
923     {
924         g_pDbusMessage->initReply(msg);
925         g_pDbusMessage->closeReply();
926     }
927     else
928     {
929         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
930     }
931 }
932
933 void DBUSCommunicator::CreateSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
934 {
935     (void)conn; // TODO: remove, only prevents warning
936
937     uint newID = GraphicalObject::INVALID_ID;
938
939     bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID));
940     if (status)
941     {
942         g_pDbusMessage->initReply(msg);
943         g_pDbusMessage->appendUInt(newID);
944         g_pDbusMessage->closeReply();
945     }
946     else
947     {
948         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
949     }
950 }
951
952 void DBUSCommunicator::CreateSurfaceGroupFromId(DBusConnection* conn, DBusMessage* msg)
953 {
954     (void)conn; // TODO: remove, only prevents warning
955
956     uint newID = GraphicalObject::INVALID_ID;
957     g_pDbusMessage->initReceive(msg);
958     newID = g_pDbusMessage->getUInt();
959
960     bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID));
961     if (status)
962     {
963         g_pDbusMessage->initReply(msg);
964         g_pDbusMessage->appendUInt(newID);
965         g_pDbusMessage->closeReply();
966     }
967     else
968     {
969         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
970     }
971 }
972
973 void DBUSCommunicator::RemoveSurfaceGroup(DBusConnection* conn, DBusMessage* msg)
974 {
975     (void)conn; // TODO: remove, only prevents warning
976
977     g_pDbusMessage->initReceive(msg);
978     uint param = g_pDbusMessage->getUInt();
979
980     bool status = m_executor->execute(new SurfacegroupRemoveCommand(param));
981     if (status)
982     {
983         g_pDbusMessage->initReply(msg);
984         g_pDbusMessage->closeReply();
985     }
986     else
987     {
988         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
989     }
990 }
991
992 void DBUSCommunicator::CreateLayerGroup(DBusConnection* conn, DBusMessage* msg)
993 {
994     (void)conn; // TODO: remove, only prevents warning
995
996     uint newID = GraphicalObject::INVALID_ID;
997
998     bool status = m_executor->execute(new LayergroupCreateCommand(&newID));
999     if (status)
1000     {
1001         g_pDbusMessage->initReply(msg);
1002         g_pDbusMessage->appendUInt(newID);
1003         g_pDbusMessage->closeReply();
1004     }
1005     else
1006     {
1007         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
1008     }
1009 }
1010
1011 void DBUSCommunicator::CreateLayerGroupFromId(DBusConnection* conn, DBusMessage* msg)
1012 {
1013     (void)conn; // TODO: remove, only prevents warning
1014
1015     uint newID = GraphicalObject::INVALID_ID;
1016     g_pDbusMessage->initReceive(msg);
1017     newID = g_pDbusMessage->getUInt();
1018
1019     bool status = m_executor->execute(new LayergroupCreateCommand(&newID));
1020     if (status)
1021     {
1022         g_pDbusMessage->initReply(msg);
1023         g_pDbusMessage->appendUInt(newID);
1024         g_pDbusMessage->closeReply();
1025     }
1026     else
1027     {
1028         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE);
1029     }
1030 }
1031
1032 void DBUSCommunicator::RemoveLayerGroup(DBusConnection* conn, DBusMessage* msg)
1033 {
1034     (void)conn; // TODO: remove, only prevents warning
1035
1036     g_pDbusMessage->initReceive(msg);
1037     uint param = g_pDbusMessage->getUInt();
1038
1039     bool status = m_executor->execute(new LayergroupRemoveCommand(param));
1040     if (status)
1041     {
1042         g_pDbusMessage->initReply(msg);
1043         g_pDbusMessage->closeReply();
1044     }
1045     else
1046     {
1047         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1048     }
1049 }
1050
1051 void DBUSCommunicator::SetSurfaceSourceRegion(DBusConnection* conn, DBusMessage* msg)
1052 {
1053     (void)conn; // TODO: remove, only prevents warning
1054
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();
1061
1062     bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(id, x, y, width, height));
1063     if (status)
1064     {
1065         g_pDbusMessage->initReply(msg);
1066         g_pDbusMessage->closeReply();
1067     }
1068     else
1069     {
1070         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1071     }
1072 }
1073
1074 void DBUSCommunicator::SetLayerSourceRegion(DBusConnection* conn, DBusMessage* msg)
1075 {
1076     (void)conn; // TODO: remove, only prevents warning
1077
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();
1084
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));
1087     if (status)
1088     {
1089         g_pDbusMessage->initReply(msg);
1090         g_pDbusMessage->closeReply();
1091     }
1092     else
1093     {
1094         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1095     }
1096 }
1097
1098 void DBUSCommunicator::SetSurfaceDestinationRegion(DBusConnection* conn, DBusMessage* msg)
1099 {
1100     (void)conn; // TODO: remove, only prevents warning
1101
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();
1108
1109     bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(id, x, y, width, height));
1110     if (status)
1111     {
1112         g_pDbusMessage->initReply(msg);
1113         g_pDbusMessage->closeReply();
1114     }
1115     else
1116     {
1117         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1118     }
1119 }
1120
1121 void DBUSCommunicator::SetSurfacePosition(DBusConnection* conn, DBusMessage* msg)
1122 {
1123     (void)conn; // TODO: remove, only prevents warning
1124
1125     g_pDbusMessage->initReceive(msg);
1126     uint id = g_pDbusMessage->getUInt();
1127     uint x = g_pDbusMessage->getUInt();
1128     uint y = g_pDbusMessage->getUInt();
1129
1130     bool status = m_executor->execute(new SurfaceSetPositionCommand(id, x, y));
1131     if (status)
1132     {
1133         g_pDbusMessage->initReply(msg);
1134         g_pDbusMessage->closeReply();
1135     }
1136     else
1137     {
1138         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1139     }
1140 }
1141
1142 void DBUSCommunicator::GetSurfacePosition(DBusConnection* conn, DBusMessage* msg)
1143 {
1144     (void)conn; // TODO: remove, only prevents warning
1145
1146     g_pDbusMessage->initReceive(msg);
1147     uint id = g_pDbusMessage->getUInt();
1148     uint x = 0;
1149     uint y = 0;
1150
1151     bool status = m_executor->execute(new SurfaceGetPositionCommand(id, &x, &y));
1152     if (status)
1153     {
1154         g_pDbusMessage->initReply(msg);
1155         g_pDbusMessage->appendUInt(x);
1156         g_pDbusMessage->appendUInt(y);
1157         g_pDbusMessage->closeReply();
1158     }
1159     else
1160     {
1161         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1162     }
1163 }
1164
1165 void DBUSCommunicator::SetSurfaceDimension(DBusConnection* conn, DBusMessage* msg)
1166 {
1167     (void)conn; // TODO: remove, only prevents warning
1168
1169     g_pDbusMessage->initReceive(msg);
1170     uint id = g_pDbusMessage->getUInt();
1171     uint width = g_pDbusMessage->getUInt();
1172     uint height = g_pDbusMessage->getUInt();
1173
1174     bool status = m_executor->execute(new SurfaceSetDimensionCommand(id, width, height));
1175     if (status)
1176     {
1177         g_pDbusMessage->initReply(msg);
1178         g_pDbusMessage->closeReply();
1179     }
1180     else
1181     {
1182         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1183     }
1184 }
1185
1186 void DBUSCommunicator::SetLayerDestinationRegion(DBusConnection* conn, DBusMessage* msg)
1187 {
1188     (void)conn; // TODO: remove, only prevents warning
1189
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();
1196
1197     bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(id, x, y, width, height));
1198     if (status)
1199     {
1200         g_pDbusMessage->initReply(msg);
1201         g_pDbusMessage->closeReply();
1202     }
1203     else
1204     {
1205         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1206     }
1207 }
1208
1209 void DBUSCommunicator::SetLayerPosition(DBusConnection* conn, DBusMessage* msg)
1210 {
1211     (void)conn; // TODO: remove, only prevents warning
1212
1213     g_pDbusMessage->initReceive(msg);
1214     uint id = g_pDbusMessage->getUInt();
1215     uint x = g_pDbusMessage->getUInt();
1216     uint y = g_pDbusMessage->getUInt();
1217
1218     bool status = m_executor->execute(new LayerSetPositionCommand(id, x, y));
1219     if (status)
1220     {
1221         g_pDbusMessage->initReply(msg);
1222         g_pDbusMessage->closeReply();
1223     }
1224     else
1225     {
1226         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1227     }
1228 }
1229
1230 void DBUSCommunicator::GetLayerPosition(DBusConnection* conn, DBusMessage* msg)
1231 {
1232     (void)conn; // TODO: remove, only prevents warning
1233
1234     g_pDbusMessage->initReceive(msg);
1235     uint id = g_pDbusMessage->getUInt();
1236     uint x = 0;
1237     uint y = 0;
1238
1239     bool status = m_executor->execute(new LayerGetPositionCommand(id, &x, &y));
1240     if (status)
1241     {
1242         g_pDbusMessage->initReply(msg);
1243         g_pDbusMessage->appendUInt(x);
1244         g_pDbusMessage->appendUInt(y);
1245         g_pDbusMessage->closeReply();
1246     }
1247     else
1248     {
1249         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1250     }
1251 }
1252
1253 void DBUSCommunicator::SetLayerDimension(DBusConnection* conn, DBusMessage* msg)
1254 {
1255     (void)conn; // TODO: remove, only prevents warning
1256
1257     g_pDbusMessage->initReceive(msg);
1258     uint id = g_pDbusMessage->getUInt();
1259     uint width = g_pDbusMessage->getUInt();
1260     uint height = g_pDbusMessage->getUInt();
1261
1262     bool status = m_executor->execute(new LayerSetDimensionCommand(id, width, height));
1263     if (status)
1264     {
1265         g_pDbusMessage->initReply(msg);
1266         g_pDbusMessage->closeReply();
1267     }
1268     else
1269     {
1270         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1271     }
1272 }
1273
1274 void DBUSCommunicator::GetLayerDimension(DBusConnection* conn, DBusMessage* msg)
1275 {
1276     (void)conn; // TODO: remove, only prevents warning
1277
1278     g_pDbusMessage->initReceive(msg);
1279     uint id = g_pDbusMessage->getUInt();
1280     uint width = 0;
1281     uint height = 0;
1282
1283     bool status = m_executor->execute(new LayerGetDimensionCommand(id, &width, &height));
1284     if (status)
1285     {
1286         g_pDbusMessage->initReply(msg);
1287         g_pDbusMessage->appendUInt(width);
1288         g_pDbusMessage->appendUInt(height);
1289         g_pDbusMessage->closeReply();
1290     }
1291     else
1292     {
1293         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1294     }
1295 }
1296
1297 void DBUSCommunicator::GetSurfaceDimension(DBusConnection* conn, DBusMessage* msg)
1298 {
1299     (void)conn; // TODO: remove, only prevents warning
1300
1301     g_pDbusMessage->initReceive(msg);
1302     uint id = g_pDbusMessage->getUInt();
1303     uint width = 0;
1304     uint height = 0;
1305
1306     bool status = m_executor->execute(new SurfaceGetDimensionCommand(id, &width, &height));
1307     if (status)
1308     {
1309         g_pDbusMessage->initReply(msg);
1310         g_pDbusMessage->appendUInt(width);
1311         g_pDbusMessage->appendUInt(height);
1312         g_pDbusMessage->closeReply();
1313     }
1314     else
1315     {
1316         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1317     }
1318 }
1319
1320 void DBUSCommunicator::SetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg)
1321 {
1322     (void)conn; // TODO: remove, only prevents warning
1323
1324     g_pDbusMessage->initReceive(msg);
1325     uint id = g_pDbusMessage->getUInt();
1326     double param = g_pDbusMessage->getDouble();
1327
1328     bool status = m_executor->execute(new SurfaceSetOpacityCommand(id, param));
1329     if (status)
1330     {
1331         g_pDbusMessage->initReply(msg);
1332         g_pDbusMessage->closeReply();
1333     }
1334     else
1335     {
1336         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1337     }
1338 }
1339
1340 void DBUSCommunicator::SetLayerOpacity(DBusConnection* conn, DBusMessage* msg)
1341 {
1342     (void)conn; // TODO: remove, only prevents warning
1343
1344     g_pDbusMessage->initReceive(msg);
1345     uint id = g_pDbusMessage->getUInt();
1346     double param = g_pDbusMessage->getDouble();
1347
1348     bool status = m_executor->execute(new LayerSetOpacityCommand(id, param));
1349     if (status)
1350     {
1351         g_pDbusMessage->initReply(msg);
1352         g_pDbusMessage->closeReply();
1353     }
1354     else
1355     {
1356         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1357     }
1358 }
1359
1360 void DBUSCommunicator::SetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg)
1361 {
1362     (void)conn; // TODO: remove, only prevents warning
1363
1364     g_pDbusMessage->initReceive(msg);
1365     uint id = g_pDbusMessage->getUInt();
1366     double param = g_pDbusMessage->getDouble();
1367
1368     bool status = m_executor->execute(new SurfacegroupSetOpacityCommand(id, param));
1369     if (status)
1370     {
1371         g_pDbusMessage->initReply(msg);
1372         g_pDbusMessage->closeReply();
1373     }
1374     else
1375     {
1376         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1377     }
1378 }
1379
1380 void DBUSCommunicator::SetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg)
1381 {
1382     (void)conn; // TODO: remove, only prevents warning
1383
1384     g_pDbusMessage->initReceive(msg);
1385     uint id = g_pDbusMessage->getUInt();
1386     double param = g_pDbusMessage->getDouble();
1387
1388     bool status = m_executor->execute(new LayergroupSetOpacityCommand(id, param));
1389     if (status)
1390     {
1391         g_pDbusMessage->initReply(msg);
1392         g_pDbusMessage->closeReply();
1393     }
1394     else
1395     {
1396         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1397     }
1398 }
1399
1400 void DBUSCommunicator::GetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg)
1401 {
1402     (void)conn; // TODO: remove, only prevents warning
1403
1404     g_pDbusMessage->initReceive(msg);
1405     uint id = g_pDbusMessage->getUInt();
1406     double param = 0.0;
1407
1408     bool status = m_executor->execute(new SurfaceGetOpacityCommand(id, &param));
1409     if (status)
1410     {
1411         g_pDbusMessage->initReply(msg);
1412         g_pDbusMessage->appendDouble(param);
1413         g_pDbusMessage->closeReply();
1414     }
1415     else
1416     {
1417         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1418     }
1419 }
1420
1421 void DBUSCommunicator::GetLayerOpacity(DBusConnection* conn, DBusMessage* msg)
1422 {
1423     (void)conn; // TODO: remove, only prevents warning
1424
1425     g_pDbusMessage->initReceive(msg);
1426     uint id = g_pDbusMessage->getUInt();
1427     double param = 0.0;
1428
1429     bool status = m_executor->execute(new LayerGetOpacityCommand(id, &param));
1430     if (status)
1431     {
1432         g_pDbusMessage->initReply(msg);
1433         g_pDbusMessage->appendDouble(param);
1434         g_pDbusMessage->closeReply();
1435     }
1436     else
1437     {
1438         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1439     }
1440 }
1441
1442 void DBUSCommunicator::GetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg)
1443 {
1444     (void)conn; // TODO: remove, only prevents warning
1445
1446     g_pDbusMessage->initReceive(msg);
1447     uint id = g_pDbusMessage->getUInt();
1448     double param = 0.0;
1449
1450     bool status = m_executor->execute(new SurfacegroupGetOpacityCommand(id, &param));
1451     if (status)
1452     {
1453         g_pDbusMessage->initReply(msg);
1454         g_pDbusMessage->appendDouble(param);
1455         g_pDbusMessage->closeReply();
1456     }
1457     else
1458     {
1459         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1460     }
1461 }
1462
1463 void DBUSCommunicator::GetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg)
1464 {
1465     (void)conn; // TODO: remove, only prevents warning
1466
1467     g_pDbusMessage->initReceive(msg);
1468     uint id = g_pDbusMessage->getUInt();
1469     double param = 0.0;
1470
1471     bool status = m_executor->execute(new LayergroupGetOpacityCommand(id, &param));
1472     if (status)
1473     {
1474         g_pDbusMessage->initReply(msg);
1475         g_pDbusMessage->appendDouble(param);
1476         g_pDbusMessage->closeReply();
1477     }
1478     else
1479     {
1480         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1481     }
1482 }
1483
1484 void DBUSCommunicator::SetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg)
1485 {
1486     (void)conn; // TODO: remove, only prevents warning
1487
1488     g_pDbusMessage->initReceive(msg);
1489     uint id = g_pDbusMessage->getUInt();
1490     uint param = g_pDbusMessage->getUInt();
1491     OrientationType o = (OrientationType) param;
1492
1493     bool status = m_executor->execute(new SurfaceSetOrientationCommand(id, o));
1494     if (status)
1495     {
1496         g_pDbusMessage->initReply(msg);
1497         g_pDbusMessage->closeReply();
1498     }
1499     else
1500     {
1501         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1502     }
1503 }
1504
1505 void DBUSCommunicator::GetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg)
1506 {
1507     (void)conn; // TODO: remove, only prevents warning
1508
1509     g_pDbusMessage->initReceive(msg);
1510     uint id = g_pDbusMessage->getUInt();
1511     OrientationType o;
1512
1513     bool status = m_executor->execute(new SurfaceGetOrientationCommand(id, &o));
1514     if (status)
1515     {
1516         g_pDbusMessage->initReply(msg);
1517         g_pDbusMessage->appendUInt(o);
1518         g_pDbusMessage->closeReply();
1519     }
1520     else
1521     {
1522         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1523     }
1524 }
1525
1526 void DBUSCommunicator::SetLayerOrientation(DBusConnection* conn, DBusMessage* msg)
1527 {
1528     (void)conn; // TODO: remove, only prevents warning
1529
1530     g_pDbusMessage->initReceive(msg);
1531     uint id = g_pDbusMessage->getUInt();
1532     uint param = g_pDbusMessage->getUInt();
1533     OrientationType o = (OrientationType) param;
1534
1535     bool status = m_executor->execute(new LayerSetOrientationCommand(id, o));
1536     if (status)
1537     {
1538         g_pDbusMessage->initReply(msg);
1539         g_pDbusMessage->closeReply();
1540     }
1541     else
1542     {
1543         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1544     }
1545 }
1546
1547 void DBUSCommunicator::GetLayerOrientation(DBusConnection* conn, DBusMessage* msg)
1548 {
1549     (void)conn; // TODO: remove, only prevents warning
1550
1551     g_pDbusMessage->initReceive(msg);
1552     uint id = g_pDbusMessage->getUInt();
1553     OrientationType o;
1554
1555     bool status = m_executor->execute(new LayerGetOrientationCommand(id, &o));
1556     if (status)
1557     {
1558         g_pDbusMessage->initReply(msg);
1559         g_pDbusMessage->appendUInt(o);
1560         g_pDbusMessage->closeReply();
1561     }
1562     else
1563     {
1564         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1565     }
1566 }
1567
1568 void DBUSCommunicator::GetSurfacePixelformat(DBusConnection* conn, DBusMessage* msg)
1569 {
1570     (void)conn; // TODO: remove, only prevents warning
1571
1572     g_pDbusMessage->initReceive(msg);
1573     uint id = g_pDbusMessage->getUInt();
1574     PixelFormat param;
1575
1576     bool status = m_executor->execute(new SurfaceGetPixelformatCommand(id, &param));
1577     if (status)
1578     {
1579         g_pDbusMessage->initReply(msg);
1580         g_pDbusMessage->appendUInt(param);
1581         g_pDbusMessage->closeReply();
1582     }
1583     else
1584     {
1585         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1586     }
1587 }
1588
1589 void DBUSCommunicator::SetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg)
1590 {
1591     (void)conn; // TODO: remove, only prevents warning
1592
1593     g_pDbusMessage->initReceive(msg);
1594     const uint surfaceid = g_pDbusMessage->getUInt();
1595     bool newVis = g_pDbusMessage->getBool();
1596
1597     bool status = m_executor->execute(new SurfaceSetVisibilityCommand(surfaceid, newVis));
1598     if (status)
1599     {
1600         g_pDbusMessage->initReply(msg);
1601         g_pDbusMessage->closeReply();
1602     }
1603     else
1604     {
1605         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1606     }
1607 }
1608
1609 void DBUSCommunicator::SetLayerVisibility(DBusConnection* conn, DBusMessage* msg)
1610 {
1611     (void)conn; // TODO: remove, only prevents warning
1612
1613     g_pDbusMessage->initReceive(msg);
1614     const uint layerid = g_pDbusMessage->getUInt();
1615     bool myparam = g_pDbusMessage->getBool();
1616
1617     bool status = m_executor->execute(new LayerSetVisibilityCommand(layerid, myparam));
1618     if (status)
1619     {
1620         g_pDbusMessage->initReply(msg);
1621         g_pDbusMessage->closeReply();
1622     }
1623     else
1624     {
1625         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1626     }
1627 }
1628
1629 void DBUSCommunicator::GetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg)
1630 {
1631     (void)conn; // TODO: remove, only prevents warning
1632
1633     g_pDbusMessage->initReceive(msg);
1634     uint id = g_pDbusMessage->getUInt();
1635     bool param;
1636
1637     bool status = m_executor->execute(new SurfaceGetVisibilityCommand(id, &param));
1638     if (status)
1639     {
1640         g_pDbusMessage->initReply(msg);
1641         //LOG_DEBUG("DBUSCommunicator", "returning surfacevisibility: " << param);
1642         g_pDbusMessage->appendBool(param);
1643         g_pDbusMessage->closeReply();
1644     }
1645     else
1646     {
1647         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1648     }
1649 }
1650
1651 void DBUSCommunicator::GetLayerVisibility(DBusConnection* conn, DBusMessage* msg)
1652 {
1653     (void)conn; // TODO: remove, only prevents warning
1654
1655     g_pDbusMessage->initReceive(msg);
1656     uint id = g_pDbusMessage->getUInt();
1657     bool param;
1658
1659     bool status = m_executor->execute(new LayerGetVisibilityCommand(id, &param));
1660     if (status)
1661     {
1662         g_pDbusMessage->initReply(msg);
1663         g_pDbusMessage->appendBool(param);
1664         //LOG_DEBUG("DBUSCommunicator", "returning layervisibility: " << param);
1665         g_pDbusMessage->closeReply();
1666     }
1667     else
1668     {
1669         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1670     }
1671 }
1672
1673 void DBUSCommunicator::SetSurfacegroupVisibility(DBusConnection* conn, DBusMessage* msg)
1674 {
1675     (void)conn; // TODO: remove, only prevents warning
1676
1677     g_pDbusMessage->initReceive(msg);
1678     uint groupid = g_pDbusMessage->getUInt();
1679     bool myparam = g_pDbusMessage->getBool();
1680
1681     bool status = m_executor->execute(new SurfacegroupSetVisibilityCommand(groupid, myparam));
1682     if (status)
1683     {
1684         g_pDbusMessage->initReply(msg);
1685         g_pDbusMessage->closeReply();
1686     }
1687     else
1688     {
1689         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1690     }
1691 }
1692
1693 void DBUSCommunicator::SetLayergroupVisibility(DBusConnection* conn, DBusMessage* msg)
1694 {
1695     (void)conn; // TODO: remove, only prevents warning
1696
1697     g_pDbusMessage->initReceive(msg);
1698     uint groupid = g_pDbusMessage->getUInt();
1699     bool myparam = g_pDbusMessage->getBool();
1700
1701     bool status = m_executor->execute(new LayergroupSetVisibilityCommand(groupid, myparam));
1702     if (status)
1703     {
1704         g_pDbusMessage->initReply(msg);
1705         g_pDbusMessage->closeReply();
1706     }
1707     else
1708     {
1709         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1710     }
1711 }
1712
1713
1714 void DBUSCommunicator::SetRenderOrderOfLayers(DBusConnection* conn, DBusMessage* msg)
1715 {
1716     (void)conn; // TODO: remove, only prevents warning
1717
1718     uint* array;
1719     int length;
1720     g_pDbusMessage->initReceive(msg);
1721     g_pDbusMessage->getArrayOfUInt(&length, &array);
1722
1723     //LOG_DEBUG("DBUSCommunicator","Renderorder: Got " << length << " ids.");
1724
1725     bool status = m_executor->execute(new ScreenSetRenderOrderCommand(array, length));
1726     if (status)
1727     {
1728         g_pDbusMessage->initReply(msg);
1729         g_pDbusMessage->closeReply();
1730     }
1731     else
1732     {
1733         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1734     }
1735 }
1736
1737 void DBUSCommunicator::SetSurfaceRenderOrderWithinLayer(DBusConnection* conn, DBusMessage* msg)
1738 {
1739     (void)conn; // TODO: remove, only prevents warning
1740
1741     uint* array;
1742     int length;
1743
1744     g_pDbusMessage->initReceive(msg);
1745     uint layerid = g_pDbusMessage->getUInt();
1746
1747     g_pDbusMessage->getArrayOfUInt(&length, &array);
1748
1749
1750     bool status = m_executor->execute(new LayerSetRenderOrderCommand(layerid, array, length));
1751     if (status)
1752     {
1753         g_pDbusMessage->initReply(msg);
1754         g_pDbusMessage->closeReply();
1755     }
1756     else
1757     {
1758         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1759     }
1760 }
1761
1762 void DBUSCommunicator::GetLayerType(DBusConnection* conn, DBusMessage* msg)
1763 {
1764     (void)conn; // TODO: remove, only prevents warning
1765
1766     g_pDbusMessage->initReceive(msg);
1767     uint id = g_pDbusMessage->getUInt();
1768     Layer* l = m_executor->getScene()->getLayer(id);
1769     if (l != NULL)
1770     {
1771         g_pDbusMessage->initReply(msg);
1772         g_pDbusMessage->appendUInt(l->getLayerType());
1773         g_pDbusMessage->closeReply();
1774     }
1775     else
1776     {
1777         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1778     }
1779 }
1780
1781 void DBUSCommunicator::GetLayertypeCapabilities(DBusConnection* conn, DBusMessage* msg)
1782 {
1783     (void)conn; // TODO: remove, only prevents warning
1784
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();
1793 }
1794
1795 void DBUSCommunicator::GetLayerCapabilities(DBusConnection* conn, DBusMessage* msg)
1796 {
1797     (void)conn; // TODO: remove, only prevents warning
1798
1799     g_pDbusMessage->initReceive(msg);
1800     uint id = g_pDbusMessage->getUInt();
1801     Layer* l = m_executor->getScene()->getLayer(id);
1802     if (l != NULL)
1803     {
1804         g_pDbusMessage->initReply(msg);
1805         g_pDbusMessage->appendUInt(l->getCapabilities());
1806         g_pDbusMessage->closeReply();
1807     }
1808     else
1809     {
1810         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1811     }
1812 }
1813
1814 void DBUSCommunicator::FadeIn(DBusConnection* conn, DBusMessage* msg)
1815 {
1816     (void)conn; // TODO: remove, only prevents warning
1817
1818     g_pDbusMessage->initReceive(msg);
1819     g_pDbusMessage->initReply(msg);
1820     g_pDbusMessage->closeReply();
1821 }
1822
1823 void DBUSCommunicator::SynchronizedFade(DBusConnection* conn, DBusMessage* msg)
1824 {
1825     (void)conn; // TODO: remove, only prevents warning
1826
1827     g_pDbusMessage->initReceive(msg);
1828     g_pDbusMessage->initReply(msg);
1829     g_pDbusMessage->closeReply();
1830 }
1831
1832 void DBUSCommunicator::FadeOut(DBusConnection* conn, DBusMessage* msg)
1833 {
1834     (void)conn; // TODO: remove, only prevents warning
1835
1836     g_pDbusMessage->initReceive(msg);
1837     g_pDbusMessage->initReply(msg);
1838     g_pDbusMessage->closeReply();
1839 }
1840
1841 void DBUSCommunicator::Exit(DBusConnection* conn, DBusMessage* msg)
1842 {
1843     (void)conn; // TODO: remove, only prevents warning
1844
1845     bool status = m_executor->execute(new ExitCommand());
1846     if (status)
1847     {
1848         g_pDbusMessage->initReply(msg);
1849         g_pDbusMessage->closeReply();
1850     }
1851     else
1852     {
1853         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
1854     }
1855 }
1856
1857 void DBUSCommunicator::CommitChanges(DBusConnection* conn, DBusMessage* msg)
1858 {
1859     (void)conn; // TODO: remove, only prevents warning
1860
1861     bool status = m_executor->execute(new CommitCommand());
1862     if (status)
1863     {
1864         g_pDbusMessage->initReply(msg);
1865         g_pDbusMessage->closeReply();
1866     }
1867     else
1868     {
1869         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT);
1870     }
1871 }
1872
1873 void DBUSCommunicator::CreateShader(DBusConnection* conn, DBusMessage* msg)
1874 {
1875     (void)conn; // TODO: remove, only prevents warning
1876
1877     g_pDbusMessage->initReceive(msg);
1878     char* vertname = g_pDbusMessage->getString();
1879     char* fragname = g_pDbusMessage->getString();
1880     uint id = 0;
1881
1882     bool status = m_executor->execute(new ShaderCreateCommand(vertname, fragname, &id));
1883     if (status)
1884     {
1885         g_pDbusMessage->initReply(msg);
1886         g_pDbusMessage->appendUInt(id);
1887         g_pDbusMessage->closeReply();
1888     }
1889     else
1890     {
1891         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1892     }
1893 }
1894
1895 void DBUSCommunicator::DestroyShader(DBusConnection* conn, DBusMessage* msg)
1896 {
1897     (void)conn; // TODO: remove, only prevents warning
1898
1899     g_pDbusMessage->initReceive(msg);
1900     uint shaderid = g_pDbusMessage->getUInt();
1901
1902     bool status = m_executor->execute(new ShaderDestroyCommand(shaderid));
1903     if (status)
1904     {
1905         g_pDbusMessage->initReply(msg);
1906         g_pDbusMessage->closeReply();
1907     }
1908     else
1909     {
1910         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1911     }
1912 }
1913
1914 void DBUSCommunicator::SetShader(DBusConnection* conn, DBusMessage* msg)
1915 {
1916     (void)conn; // TODO: remove, only prevents warning
1917
1918     g_pDbusMessage->initReceive(msg);
1919     uint surfaceId = g_pDbusMessage->getUInt();
1920     uint shaderid = g_pDbusMessage->getUInt();
1921
1922     bool status = m_executor->execute(new SurfaceSetShaderCommand(surfaceId, shaderid));
1923     if (status)
1924     {
1925         g_pDbusMessage->initReply(msg);
1926         g_pDbusMessage->closeReply();
1927     }
1928     else
1929     {
1930         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1931     }
1932 }
1933
1934 void DBUSCommunicator::SetUniforms(DBusConnection* conn, DBusMessage* msg)
1935 {
1936     (void)conn; // TODO: remove, only prevents warning
1937
1938     g_pDbusMessage->initReceive(msg);
1939     uint id = g_pDbusMessage->getUInt();
1940
1941     std::vector<string> uniforms;
1942
1943     g_pDbusMessage->getArrayOfString(&uniforms);
1944
1945     bool status = m_executor->execute(new ShaderSetUniformsCommand(id, uniforms));
1946     if (status)
1947     {
1948         g_pDbusMessage->initReply(msg);
1949         g_pDbusMessage->closeReply();
1950     }
1951     else
1952     {
1953         g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND);
1954     }
1955 }
1956
1957 DBusHandlerResult DBUSCommunicator::delegateMessage(DBusConnection* conn, DBusMessage* msg) 
1958 {
1959     DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED;
1960     LOG_DEBUG("DBUSCommunicator","message received");
1961     const char *n = dbus_message_get_member(msg);
1962     bool found = false;
1963     int i = 0;
1964
1965     while (!found && strcmp(manager_methods[i].name, "") != 0)
1966     {
1967         if (n && strcmp(manager_methods[i].name, n) == 0)
1968         {
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);
1974             found = true;
1975         }
1976         i++;
1977     }
1978
1979     if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect"))
1980     {
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
1986     }
1987
1988     if (!found)
1989     {
1990         result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
1991     }
1992     return result;
1993 }
1994
1995 extern "C" ICommunicator* createDBUSCommunicator(ICommandExecutor* executor)
1996 {
1997     return new DBUSCommunicator(executor);
1998 }
1999
2000 extern "C" void destroyDBUSCommunicator(DBUSCommunicator* p)
2001 {
2002     delete p;
2003 }
2004