From edab1e5f7e4b4182e5223169d56134d6659a9f26 Mon Sep 17 00:00:00 2001 From: Timo Lotterbach Date: Tue, 27 Mar 2012 14:18:34 +0200 Subject: [PATCH] DBUSCommunicator: removed DBUS specific communciator DBUs Communication is now handled by GenericCommunicator using the DBUSIpcModule. --- CMakeLists.txt | 1 - LayerManager.spec.in | 1 - .../Communicators/DBUSCommunicator/CMakeLists.txt | 57 - .../DBUSCommunicator/include/DBUSCommunicator.h | 200 -- .../DBUSCommunicator/include/DBUSConfiguration.h | 26 - .../DBUSCommunicator/include/DBUSIntrospection.h | 60 - .../DBUSCommunicator/include/DBUSMessageHandler.h | 81 - .../DBUSCommunicator/include/DBUSTypes.h | 36 - .../include/LayerManagerService.conf | 43 - .../DBUSCommunicator/src/DBUSCommunicator.cpp | 2064 -------------------- .../DBUSCommunicator/src/DBUSIntrospection.cpp | 177 -- .../DBUSCommunicator/src/DBUSMessageHandler.cpp | 340 ---- .../DBUSCommunicator/test/CMakeLists.txt | 48 - .../DBUSCommunicator/test/DBUSCommunicatorTest.cpp | 875 --------- .../DBUSCommunicator/test/mock_CommandExecutor.h | 60 - .../DBUSCommunicator/test/mock_Communicator.h | 35 - .../DBUSCommunicator/test/mock_Layerlist.h | 48 - .../DBUSCommunicator/test/mock_Renderer.h | 36 - distfiles | 1 - 19 files changed, 4189 deletions(-) delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/CMakeLists.txt delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSCommunicator.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSConfiguration.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSIntrospection.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSMessageHandler.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSTypes.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/include/LayerManagerService.conf delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSCommunicator.cpp delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSIntrospection.cpp delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSMessageHandler.cpp delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/test/CMakeLists.txt delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/test/DBUSCommunicatorTest.cpp delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_CommandExecutor.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Communicator.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Layerlist.h delete mode 100644 LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Renderer.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 692b2c6..9d1ce9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,6 @@ include_directories ("${PROJECT_SOURCE_DIR}/3rdParty/") add_subdirectory (3rdParty) add_subdirectory (LayerManagerPlugins/Communicators/GenericCommunicator) -add_subdirectory (LayerManagerPlugins/Communicators/DBUSCommunicator) add_subdirectory (LayerManagerPlugins/IpcModules) add_subdirectory (LayerManagerClient/ilmClient) add_subdirectory (LayerManagerCommands) diff --git a/LayerManager.spec.in b/LayerManager.spec.in index faa35cc..f164982 100644 --- a/LayerManager.spec.in +++ b/LayerManager.spec.in @@ -50,7 +50,6 @@ rm -rf $RPM_BUILD_ROOT %dir %_libdir/layermanager %{_libdir}/layermanager/libLayerScene.so %dir %_libdir/layermanager/communicator -%{_libdir}/layermanager/communicator/libDBUSCommunicator.so %{_libdir}/layermanager/communicator/libGenericCommunicator.so %{_libdir}/layermanager/ipcmodules/*.so %{_libdir}/libIpcModuleLoader.so diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/CMakeLists.txt b/LayerManagerPlugins/Communicators/DBUSCommunicator/CMakeLists.txt deleted file mode 100644 index baea0fc..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/CMakeLists.txt +++ /dev/null @@ -1,57 +0,0 @@ -############################################################################ -# -# Copyright 2010, 2011 BMW Car IT GmbH -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -############################################################################ - -cmake_minimum_required (VERSION 2.6) - -include_directories ("include") -include_directories ("${PROJECT_SOURCE_DIR}/config") -include_directories ("${PROJECT_SOURCE_DIR}/LayerManagerService/include") -include_directories ("${PROJECT_SOURCE_DIR}/LayerManagerUtils/include") -include_directories ("${PROJECT_SOURCE_DIR}/LayerManagerCommands/include") - -link_directories ("${PROJECT_SOURCE_DIR}/LayerManagerUtils/bin") -link_directories ("${PROJECT_SOURCE_DIR}/LayerManagerCommands") - -find_package(DBUS REQUIRED) -include_directories(${DBUS_INCLUDE_DIR}) -include_directories(${DBUS_ARCH_INCLUDE_DIR}) - -find_package (Threads) -set(LIBS ${LIBS} ${DBUS_LIBRARY} ${CMAKE_THREAD_LIBS_INIT}) - -add_library(DBUSCommunicator SHARED src/DBUSCommunicator.cpp - src/DBUSIntrospection.cpp - src/DBUSMessageHandler.cpp) - -target_link_libraries(DBUSCommunicator LayerManagerCommands ${LIBS}) - -add_dependencies(DBUSCommunicator LayerManagerService) -add_dependencies(DBUSCommunicator LayerManagerUtils) -add_dependencies(DBUSCommunicator LayerManagerCommands) - -install (TARGETS DBUSCommunicator LIBRARY DESTINATION lib/layermanager/communicator) -install (FILES include/LayerManagerService.conf DESTINATION /etc/dbus-1/system.d) -install (FILES include/LayerManagerService.conf DESTINATION /etc/dbus-1/session.d) - - -if (WITH_TESTS) -enable_testing() -add_subdirectory (test) -endif(WITH_TESTS) - diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSCommunicator.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSCommunicator.h deleted file mode 100644 index 63ec6b1..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSCommunicator.h +++ /dev/null @@ -1,200 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ -#ifndef _DBUSCOMMUNICATOR_H_ -#define _DBUSCOMMUNICATOR_H_ - -/** - * \defgroup DbusCommunicator DBUS Communicator API - */ - -#include "ICommunicator.h" -#include "Log.h" - -#include "ICommandExecutor.h" -#include "IApplicationReference.h" -#include "ApplicationReferenceMap.h" -#include "CommitCommand.h" -#include "LayerCreateCommand.h" -#include "LayergroupCreateCommand.h" -#include "SurfaceCreateCommand.h" -#include "SurfacegroupCreateCommand.h" -#include "SurfaceGetDimensionCommand.h" -#include "LayerGetDimensionCommand.h" -#include "SurfaceGetOpacityCommand.h" -#include "LayerGetOpacityCommand.h" -#include "SurfaceGetPixelformatCommand.h" -#include "LayerGetVisibilityCommand.h" -#include "SurfaceGetVisibilityCommand.h" -#include "LayerAddSurfaceCommand.h" -#include "LayerRemoveSurfaceCommand.h" -#include "LayerRemoveCommand.h" -#include "SurfaceRemoveCommand.h" -#include "LayergroupRemoveCommand.h" -#include "SurfacegroupRemoveCommand.h" -#include "SurfaceGetOrientationCommand.h" -#include "LayerGetOrientationCommand.h" -#include "LayergroupAddLayerCommand.h" -#include "LayergroupRemoveLayerCommand.h" -#include "LayerSetDestinationRectangleCommand.h" -#include "SurfaceSetDestinationRectangleCommand.h" -#include "LayerSetOpacityCommand.h" -#include "LayergroupSetOpacityCommand.h" -#include "SurfaceSetOpacityCommand.h" -#include "SurfacegroupSetOpacityCommand.h" -#include "LayerSetSourceRectangleCommand.h" -#include "SurfaceSetSourceRectangleCommand.h" -#include "LayerSetOrientationCommand.h" -#include "SurfaceSetOrientationCommand.h" -#include "SurfacegroupAddSurfaceCommand.h" -#include "SurfacegroupRemoveSurfaceCommand.h" -#include "LayerSetVisibilityCommand.h" -#include "SurfaceSetVisibilityCommand.h" -#include "LayergroupSetVisibilityCommand.h" -#include "SurfacegroupSetVisibilityCommand.h" -#include "DebugCommand.h" -#include "ExitCommand.h" -#include "ScreenSetRenderOrderCommand.h" -#include "LayerSetRenderOrderCommand.h" -#include "LayerSetDimensionCommand.h" -#include "SurfaceSetDimensionCommand.h" -#include "LayerSetPositionCommand.h" -#include "SurfaceSetPositionCommand.h" -#include "LayerGetPositionCommand.h" -#include "SurfaceGetPositionCommand.h" -#include "ShaderCreateCommand.h" -#include "ShaderDestroyCommand.h" -#include "SurfaceSetShaderCommand.h" -#include "ShaderSetUniformsCommand.h" -#include "ScreenDumpCommand.h" -#include "LayerDumpCommand.h" -#include "SurfaceDumpCommand.h" -#include "SurfaceSetNativeContentCommand.h" - -#include -#include "DBUSTypes.h" - -class DBUSCommunicator: public ICommunicator -{ -public: - DBUSCommunicator(ICommandExecutor* executor); - virtual ~DBUSCommunicator() {} - virtual bool start(); - virtual void stop(); - virtual void process(int timeout_ms); - virtual void setdebug(bool onoff); - void ServiceConnect(DBusConnection* conn, DBusMessage* msg); - void ServiceDisconnect(DBusConnection* conn, DBusMessage* msg); - void Debug(DBusConnection* conn, DBusMessage* msg); - void ScreenShot(DBusConnection* conn, DBusMessage* msg); - void ScreenShotOfLayer(DBusConnection* conn, DBusMessage* msg); - void ScreenShotOfSurface(DBusConnection* conn, DBusMessage* msg); - void GetScreenResolution(DBusConnection* conn, DBusMessage* msg); - void GetNumberOfHardwareLayers(DBusConnection* conn, DBusMessage* msg); - void GetScreenIDs(DBusConnection* conn, DBusMessage* msg); - void ListAllLayerIDS(DBusConnection* conn, DBusMessage* msg); - void ListAllLayerIDsOnScreen(DBusConnection* conn, DBusMessage* msg); - void ListAllSurfaceIDS(DBusConnection* conn, DBusMessage* msg); - void ListAllLayerGroupIDS(DBusConnection* conn, DBusMessage* msg); - void ListAllSurfaceGroupIDS(DBusConnection* conn, DBusMessage* msg); - void ListSurfacesOfSurfacegroup(DBusConnection* conn, DBusMessage* msg); - void ListLayersOfLayergroup(DBusConnection* conn, DBusMessage* msg); - void ListSurfaceofLayer(DBusConnection* conn, DBusMessage* msg); - void GetPropertiesOfSurface(DBusConnection* conn, DBusMessage* msg); - void GetPropertiesOfLayer(DBusConnection* conn, DBusMessage* msg); - void CreateSurface(DBusConnection* conn, DBusMessage* msg); - void InitializeSurface(DBusConnection* conn, DBusMessage* msg); - void InitializeSurfaceFromId(DBusConnection* conn, DBusMessage* msg); - void CreateSurfaceFromId(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceNativeContent(DBusConnection* conn, DBusMessage* msg); - void RemoveSurface(DBusConnection* conn, DBusMessage* msg); - void CreateLayer(DBusConnection* conn, DBusMessage* msg); - void CreateLayerFromId(DBusConnection* conn, DBusMessage* msg); - void CreateLayerWithDimension(DBusConnection* conn, DBusMessage* msg); - void CreateLayerFromIdWithDimension(DBusConnection* conn, DBusMessage* msg); - void RemoveLayer(DBusConnection* conn, DBusMessage* msg); - void AddSurfaceToSurfaceGroup(DBusConnection* conn, DBusMessage* msg); - void RemoveSurfaceFromSurfaceGroup(DBusConnection* conn, DBusMessage* msg); - void AddLayerToLayerGroup(DBusConnection* conn, DBusMessage* msg); - void RemoveLayerFromLayerGroup(DBusConnection* conn, DBusMessage* msg); - void AddSurfaceToLayer(DBusConnection* conn, DBusMessage* msg); - void RemoveSurfaceFromLayer(DBusConnection* conn, DBusMessage* msg); - void CreateSurfaceGroup(DBusConnection* conn, DBusMessage* msg); - void CreateSurfaceGroupFromId(DBusConnection* conn, DBusMessage* msg); - void RemoveSurfaceGroup(DBusConnection* conn, DBusMessage* msg); - void CreateLayerGroup(DBusConnection* conn, DBusMessage* msg); - void CreateLayerGroupFromId(DBusConnection* conn, DBusMessage* msg); - void RemoveLayerGroup(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceSourceRegion(DBusConnection* conn, DBusMessage* msg); - void SetLayerSourceRegion(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceDestinationRegion(DBusConnection* conn, DBusMessage* msg); - void SetSurfacePosition(DBusConnection* conn, DBusMessage* msg); - void GetSurfacePosition(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceDimension(DBusConnection* conn, DBusMessage* msg); - void SetLayerDestinationRegion(DBusConnection* conn, DBusMessage* msg); - void SetLayerPosition(DBusConnection* conn, DBusMessage* msg); - void GetLayerPosition(DBusConnection* conn, DBusMessage* msg); - void SetLayerDimension(DBusConnection* conn, DBusMessage* msg); - void GetLayerDimension(DBusConnection* conn, DBusMessage* msg); - void GetSurfaceDimension(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg); - void SetLayerOpacity(DBusConnection* conn, DBusMessage* msg); - void SetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg); - void SetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg); - void GetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg); - void GetLayerOpacity(DBusConnection* conn, DBusMessage* msg); - void GetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg); - void GetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg); - void GetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg); - void SetLayerOrientation(DBusConnection* conn, DBusMessage* msg); - void GetLayerOrientation(DBusConnection* conn, DBusMessage* msg); - void GetSurfacePixelformat(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg); - void SetLayerVisibility(DBusConnection* conn, DBusMessage* msg); - void GetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg); - void GetLayerVisibility(DBusConnection* conn, DBusMessage* msg); - void SetSurfacegroupVisibility(DBusConnection* conn, DBusMessage* msg); - void SetLayergroupVisibility(DBusConnection* conn, DBusMessage* msg); - void SetRenderOrderOfLayers(DBusConnection* conn, DBusMessage* msg); - void SetSurfaceRenderOrderWithinLayer(DBusConnection* conn, DBusMessage* msg); - void GetLayerType(DBusConnection* conn, DBusMessage* msg); - void GetLayertypeCapabilities(DBusConnection* conn, DBusMessage* msg); - void GetLayerCapabilities(DBusConnection* conn, DBusMessage* msg); - void FadeIn(DBusConnection* conn, DBusMessage* msg); - void SynchronizedFade(DBusConnection* conn, DBusMessage* msg); - void FadeOut(DBusConnection* conn, DBusMessage* msg); - void Exit(DBusConnection* conn, DBusMessage* msg); - void CommitChanges(DBusConnection* conn, DBusMessage* msg); - void CreateShader(DBusConnection* conn, DBusMessage* msg); - void DestroyShader(DBusConnection* conn, DBusMessage* msg); - void SetShader(DBusConnection* conn, DBusMessage* msg); - void SetUniforms(DBusConnection* conn, DBusMessage* msg); - DBusHandlerResult delegateMessage(DBusConnection* conn, DBusMessage* msg); - - -private: - void AddClientWatch(DBusConnection *conn, char* sender); - void RemoveClientWatch(DBusConnection *conn, char* sender); - void RemoveApplicationReference(char* owner); - static DBusHandlerResult processMessageFunc(DBusConnection* conn,DBusMessage* msg, void *user_data); - static void unregisterMessageFunc(DBusConnection* conn, void *user_data); - bool m_running; -}; - -#endif /* _DBUSCOMMUNICATOR_H_ */ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSConfiguration.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSConfiguration.h deleted file mode 100644 index 9c181c2..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSConfiguration.h +++ /dev/null @@ -1,26 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ - -#ifndef _DBUSCONFIGURATION_H_ -#define _DBUSCONFIGURATION_H_ - -// TODO: genivi.. genivi.layermanagercommunicator. -#define DBUS_SERVICE_PREFIX "org.genivi.layermanagementservice\0" -#define DBUS_SERVICE_OBJECT_PATH "/org/genivi/layermanagementservice\0" -#endif // _DBUSCONFIGURATION_H_ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSIntrospection.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSIntrospection.h deleted file mode 100644 index b289a4f..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSIntrospection.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ - -#ifndef _DBUSINTROSPECTION_H_ -#define _DBUSINTROSPECTION_H_ - -#include -using std::stringstream; - -#include -using std::string; - -#include "DBUSTypes.h" - -class DBUSIntrospection -{ -public: - DBUSIntrospection(MethodTable* table); - void process(DBusConnection* conn, DBusMessage* msg); - -private: - void generateString(void); - - void addHeader(void); - void addArgument(string argname, string direction, string type); - void addEntry(MethodTable entry); - - void openNode(string nodename); - void closeNode(void); - - void openInterface(string interfacename); - void closeInterface(void); - - void openMethod(string methodname); - void closeMethod(void); - - -private: - stringstream m_introspectionString; - MethodTable* m_methodTable; -}; - - -#endif // _DBUSINTROSPECTION_H_ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSMessageHandler.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSMessageHandler.h deleted file mode 100644 index 16d67e3..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSMessageHandler.h +++ /dev/null @@ -1,81 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ - -#ifndef _DBUSMESSAGEHANDLER_H_ -#define _DBUSMESSAGEHANDLER_H_ - -#include -#include -#include - -class DBUSMessageHandler -{ -public: - DBUSMessageHandler(); - ~DBUSMessageHandler(); - - void setConnection(DBusConnection* conn); - DBusConnection* getConnection(); - - void initReceive(DBusMessage* msg); - bool registerPathFunction( DBusObjectPathMessageFunction fMessageFunc, - DBusObjectPathUnregisterFunction fUnregisterFunc, - void* comInstance); - void initReply(DBusMessage* msg); - void closeReply(); - void ReplyError(DBusMessage* msg, const char* errorname, const char* errorMsg); - bool registerMessageFilter( DBusHandleMessageFunction fMessageFunc, - void* comInstance ); - - void unregisterMessageFilter( DBusHandleMessageFunction fMessageFunc, - void* comInstance ); - dbus_uint32_t getUInt(); - char getByte(); - dbus_bool_t getBool(); - double getDouble(); - char* getString(); - void getArrayOfUInt(int* length, unsigned int** array); - void getArrayOfString(std::vector* uniforms); - - void appendUInt(dbus_uint32_t toAppend); - void appendByte(char toAppend); - void appendBool(dbus_bool_t toAppend); - void appendDouble(double toAppend); - void appendArrayOfUInt(unsigned int length, unsigned int *IDs); - -private: - DBusMessageIter m_MessageIter; - DBusMessage* m_pReply; - dbus_uint32_t m_serial; - DBusConnection* m_pConnection; - DBusError m_err; -}; - - -inline void DBUSMessageHandler::setConnection(DBusConnection* conn) -{ - m_pConnection = conn; -} - -inline DBusConnection* DBUSMessageHandler::getConnection() -{ - return m_pConnection; -} - -#endif // _DBUSMESSAGEWRAPPER_H_ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSTypes.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSTypes.h deleted file mode 100644 index a20398e..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSTypes.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ -#ifndef _DBUSTYPES_H_ -#define _DBUSTYPES_H_ - -class DBUSCommunicator; -class DBusConnection; -class DBusMessage; - -typedef void (DBUSCommunicator::*CallBackMethod)(DBusConnection *connection, DBusMessage *message); - -struct MethodTable -{ - const char *name; - const char *signature; - const char *reply; - CallBackMethod function; -}; - -#endif // _DBUSTYPES_H_ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/LayerManagerService.conf b/LayerManagerPlugins/Communicators/DBUSCommunicator/include/LayerManagerService.conf deleted file mode 100644 index 6d5d2e7..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/include/LayerManagerService.conf +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSCommunicator.cpp b/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSCommunicator.cpp deleted file mode 100644 index 2e1ad2c..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSCommunicator.cpp +++ /dev/null @@ -1,2064 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ -#include -#include -#include -#include -#include -#include -#include - -#include "DBUSCommunicator.h" -#include "DBUSIntrospection.h" -#include "DBUSMessageHandler.h" -#include "DBUSConfiguration.h" - -#include "Log.h" - -#define DEFAULT_SCREEN 0 - -const char* SERVICE_ERROR = "org.genivi.layermanagementservice.error"; -const char* RESSOURCE_ALREADY_INUSE = "Ressource already in use"; -const char* INVALID_ARGUMENT = "Invalid argument"; -const char* RESSOURCE_NOT_FOUND = "Ressource not found"; - - - -static DBUSMessageHandler* g_pDbusMessage; - -static MethodTable manager_methods[] = -{ - { "ServiceConnect", "u", "", &DBUSCommunicator::ServiceConnect }, - { "ServiceDisconnect", "u", "", &DBUSCommunicator::ServiceDisconnect }, - { "Debug", "b", "", &DBUSCommunicator::Debug }, - { "ScreenShot", "us", "", &DBUSCommunicator::ScreenShot }, - { "ScreenShotOfLayer", "su", "", &DBUSCommunicator::ScreenShotOfLayer }, - { "ScreenShotOfSurface", "su", "", &DBUSCommunicator::ScreenShotOfSurface }, - { "GetScreenResolution", "u", "uu", &DBUSCommunicator::GetScreenResolution }, - { "GetNumberOfHardwareLayers", "u", "u", &DBUSCommunicator::GetNumberOfHardwareLayers }, - { "GetScreenIDs", "", "au", &DBUSCommunicator::GetScreenIDs }, - { "ListAllLayerIDS", "", "au", &DBUSCommunicator::ListAllLayerIDS }, - { "ListAllLayerIDsOnScreen", "u", "au", &DBUSCommunicator::ListAllLayerIDsOnScreen }, - { "ListAllSurfaceIDS", "", "au", &DBUSCommunicator::ListAllSurfaceIDS }, - { "ListAllLayerGroupIDS", "", "au", &DBUSCommunicator::ListAllLayerGroupIDS }, - { "ListAllSurfaceGroupIDS", "", "au", &DBUSCommunicator::ListAllSurfaceGroupIDS }, - { "ListSurfacesOfSurfacegroup", "u", "au", &DBUSCommunicator::ListSurfacesOfSurfacegroup }, - { "ListLayersOfLayergroup", "u", "au", &DBUSCommunicator::ListLayersOfLayergroup }, - { "ListSurfaceofLayer", "u", "au", &DBUSCommunicator::ListSurfaceofLayer }, - { "GetPropertiesOfSurface", "u", "duuuuuuuuuuybu", &DBUSCommunicator::GetPropertiesOfSurface }, - { "GetPropertiesOfLayer", "u", "duuuuuuuuuuyb", &DBUSCommunicator::GetPropertiesOfLayer }, - { "CreateSurface", "uuuu", "u", &DBUSCommunicator::CreateSurface }, - { "CreateSurfaceFromId", "uuuuu", "u", &DBUSCommunicator::CreateSurfaceFromId }, - { "InitializeSurface", "", "u", &DBUSCommunicator::InitializeSurface }, - { "InitializeSurfaceFromId", "u", "u", &DBUSCommunicator::InitializeSurfaceFromId }, - { "SetSurfaceNativeContent", "uuuuu", "", &DBUSCommunicator::SetSurfaceNativeContent }, - { "RemoveSurface", "u", "", &DBUSCommunicator::RemoveSurface }, - { "CreateLayer", "", "u", &DBUSCommunicator::CreateLayer }, - { "CreateLayerFromId", "u", "u", &DBUSCommunicator::CreateLayerFromId }, - { "CreateLayerWithDimension", "uu", "u", &DBUSCommunicator::CreateLayerWithDimension }, - { "CreateLayerFromIdWithDimension", "uuu", "u", &DBUSCommunicator::CreateLayerFromIdWithDimension }, - { "RemoveLayer", "u", "", &DBUSCommunicator::RemoveLayer }, - { "AddSurfaceToSurfaceGroup", "uu", "", &DBUSCommunicator::AddSurfaceToSurfaceGroup }, - { "RemoveSurfaceFromSurfaceGroup", "uu", "", &DBUSCommunicator::RemoveSurfaceFromSurfaceGroup }, - { "AddLayerToLayerGroup", "uu", "", &DBUSCommunicator::AddLayerToLayerGroup }, - { "RemoveLayerFromLayerGroup", "uu", "", &DBUSCommunicator::RemoveLayerFromLayerGroup }, - { "AddSurfaceToLayer", "uu", "", &DBUSCommunicator::AddSurfaceToLayer }, - { "RemoveSurfaceFromLayer", "uu", "", &DBUSCommunicator::RemoveSurfaceFromLayer }, - { "CreateSurfaceGroup", "", "u", &DBUSCommunicator::CreateSurfaceGroup }, - { "CreateSurfaceGroupFromId", "u", "u", &DBUSCommunicator::CreateSurfaceGroupFromId }, - { "RemoveSurfaceGroup", "u", "", &DBUSCommunicator::RemoveSurfaceGroup }, - { "CreateLayerGroup", "", "u", &DBUSCommunicator::CreateLayerGroup }, - { "CreateLayerGroupFromId", "u", "u", &DBUSCommunicator::CreateLayerGroupFromId }, - { "RemoveLayerGroup", "u", "", &DBUSCommunicator::RemoveLayerGroup }, - { "SetSurfaceSourceRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceSourceRegion }, - { "SetLayerSourceRegion", "uuuuu", "", &DBUSCommunicator::SetLayerSourceRegion }, - { "SetSurfaceDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetSurfaceDestinationRegion }, - { "SetSurfacePosition", "uuu", "", &DBUSCommunicator::SetSurfacePosition }, - { "GetSurfacePosition", "u", "uu", &DBUSCommunicator::GetSurfacePosition }, - { "SetSurfaceDimension", "uuu", "", &DBUSCommunicator::SetSurfaceDimension }, - { "SetLayerDestinationRegion", "uuuuu", "", &DBUSCommunicator::SetLayerDestinationRegion }, - { "SetLayerPosition", "uuu", "", &DBUSCommunicator::SetLayerPosition }, - { "GetLayerPosition", "u", "uu", &DBUSCommunicator::GetLayerPosition }, - { "SetLayerDimension", "uuu", "", &DBUSCommunicator::SetLayerDimension }, - { "GetLayerDimension", "u", "uu", &DBUSCommunicator::GetLayerDimension }, - { "GetSurfaceDimension", "u", "uu", &DBUSCommunicator::GetSurfaceDimension }, - { "SetSurfaceOpacity", "ud", "", &DBUSCommunicator::SetSurfaceOpacity }, - { "SetLayerOpacity", "ud", "", &DBUSCommunicator::SetLayerOpacity }, - { "SetSurfacegroupOpacity", "ud", "", &DBUSCommunicator::SetSurfacegroupOpacity }, - { "SetLayergroupOpacity", "ud", "", &DBUSCommunicator::SetLayergroupOpacity }, - { "GetSurfaceOpacity", "u", "d", &DBUSCommunicator::GetSurfaceOpacity }, - { "GetLayerOpacity", "u", "d", &DBUSCommunicator::GetLayerOpacity }, - { "SetSurfaceOrientation", "uu", "", &DBUSCommunicator::SetSurfaceOrientation }, - { "GetSurfaceOrientation", "uu", "", &DBUSCommunicator::GetSurfaceOrientation }, - { "SetLayerOrientation", "uu", "", &DBUSCommunicator::SetLayerOrientation }, - { "GetLayerOrientation", "uu", "", &DBUSCommunicator::GetLayerOrientation }, - { "GetSurfacePixelformat", "u", "u", &DBUSCommunicator::GetSurfacePixelformat }, - { "SetSurfaceVisibility", "ub", "", &DBUSCommunicator::SetSurfaceVisibility }, - { "SetLayerVisibility", "ub", "", &DBUSCommunicator::SetLayerVisibility }, - { "GetSurfaceVisibility", "u", "b", &DBUSCommunicator::GetSurfaceVisibility }, - { "GetLayerVisibility", "u", "b", &DBUSCommunicator::GetLayerVisibility }, - { "SetSurfacegroupVisibility", "ub", "", &DBUSCommunicator::SetSurfacegroupVisibility }, - { "SetLayergroupVisibility", "ub", "", &DBUSCommunicator::SetLayergroupVisibility }, - { "SetRenderOrderOfLayers", "auu", "", &DBUSCommunicator::SetRenderOrderOfLayers }, - { "SetSurfaceRenderOrderWithinLayer", "uau", "", &DBUSCommunicator::SetSurfaceRenderOrderWithinLayer }, - { "GetLayerType", "u", "u", &DBUSCommunicator::GetLayerType }, - { "GetLayertypeCapabilities", "u", "u", &DBUSCommunicator::GetLayertypeCapabilities }, - { "GetLayerCapabilities", "u", "u", &DBUSCommunicator::GetLayerCapabilities }, - { "Exit", "", "", &DBUSCommunicator::Exit }, - { "CommitChanges", "", "", &DBUSCommunicator::CommitChanges }, - { "CreateShader", "ss", "u", &DBUSCommunicator::CreateShader }, - { "DestroyShader", "u", "", &DBUSCommunicator::DestroyShader }, - { "SetShader", "uu", "", &DBUSCommunicator::SetShader }, - { "SetUniforms", "uas", "", &DBUSCommunicator::SetUniforms }, - { "", "", "", NULL } -}; - -#include -using std::stringstream; - -#include -using std::string; - -DBUSCommunicator::DBUSCommunicator(ICommandExecutor* executor) -: ICommunicator(executor) -, m_running(false) -{ -} - -void DBUSCommunicator::setdebug(bool onoff) -{ - (void)onoff; // TODO: remove, only prevents warning -} - -bool DBUSCommunicator::start() -{ - LOG_DEBUG("DBUSCommunicator", "Starting up dbus connector"); - bool result = true; - g_pDbusMessage = new DBUSMessageHandler(); - - LOG_DEBUG("DBUSCommunicator","registering for dbus path " << DBUS_SERVICE_OBJECT_PATH); - bool registered = g_pDbusMessage->registerPathFunction(DBUSCommunicator::processMessageFunc, - DBUSCommunicator::unregisterMessageFunc, - this); - if (!registered) - { - - LOG_ERROR("DBUSCommunicator","Register Message Callbacks failed"); - result = false; - } - else - { - registered = g_pDbusMessage->registerMessageFilter(DBUSCommunicator::processMessageFunc,this); - if (!registered) - { - - LOG_ERROR("DBUSCommunicator","Register Message Filter failed"); - result = false; - } - } - LOG_INFO("DBUSCommunicator", "Started dbus connector"); - m_running = true; - return result; -} - -void DBUSCommunicator::stop() -{ - LOG_INFO("DBUSCommunicator","stopping"); - if (m_running) - { - g_pDbusMessage->unregisterMessageFilter(DBUSCommunicator::processMessageFunc,this); - // deregister dbus messaging implicitly by deleting messageHandler - } - if (g_pDbusMessage != NULL) - { - delete g_pDbusMessage; - } -} - -void DBUSCommunicator::ServiceConnect(DBusConnection* conn, DBusMessage* msg) -{ - g_pDbusMessage->initReceive(msg); - u_int32_t processId = g_pDbusMessage->getUInt(); - char* owner = strdup(dbus_message_get_sender(msg)); - m_executor->addApplicationReference(new IApplicationReference(owner,processId)); - AddClientWatch(conn,owner); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::ServiceDisconnect(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - char* owner = strdup(dbus_message_get_sender(msg)); - RemoveApplicationReference(owner); - RemoveClientWatch(conn,owner); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::Debug(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - bool param = g_pDbusMessage->getBool(); - - bool status = m_executor->execute(new DebugCommand(param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT); - } -} - -void DBUSCommunicator::GetScreenResolution(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint screenid = g_pDbusMessage->getUInt(); - uint* resolution = m_executor->getScreenResolution(screenid); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(resolution[0]); - g_pDbusMessage->appendUInt(resolution[1]); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::GetNumberOfHardwareLayers(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint screenid = g_pDbusMessage->getUInt(); - uint numberOfHardwareLayers = m_executor->getNumberOfHardwareLayers(screenid); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(numberOfHardwareLayers); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::GetScreenIDs(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint length = 0; - uint* IDs = m_executor->getScreenIDs(&length); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendArrayOfUInt(length, IDs); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::ScreenShot(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint screenid = g_pDbusMessage->getUInt(); - char* filename = g_pDbusMessage->getString(); - - bool status = m_executor->execute(new ScreenDumpCommand(filename, screenid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT); - } -} -void DBUSCommunicator::process(int timeout_ms) -{ - dbus_connection_read_write_dispatch (g_pDbusMessage->getConnection(), timeout_ms); -} -void DBUSCommunicator::ScreenShotOfLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - char* filename = g_pDbusMessage->getString(); - uint layerid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayerDumpCommand(filename, layerid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::ScreenShotOfSurface(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - char* filename = g_pDbusMessage->getString(); - uint id = g_pDbusMessage->getUInt(); - bool status = m_executor->execute(new SurfaceDumpCommand(filename, id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::ListAllLayerIDS(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint* array = NULL; - uint length = 0; - m_executor->getScene()->lockScene(); - m_executor->getScene()->getLayerIDs(&length, &array); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendArrayOfUInt(length, array); - g_pDbusMessage->closeReply(); - m_executor->getScene()->unlockScene(); -} - -void DBUSCommunicator::ListAllLayerIDsOnScreen(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint screenID = g_pDbusMessage->getUInt(); - - uint* array = NULL; - uint length = 0; - m_executor->getScene()->lockScene(); - bool status = m_executor->getScene()->getLayerIDsOfScreen(screenID, &length, &array); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendArrayOfUInt(length, array); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT); - } - m_executor->getScene()->unlockScene(); - -} - -void DBUSCommunicator::ListAllSurfaceIDS(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint* array = NULL; - uint length = 0; - m_executor->getScene()->lockScene(); - m_executor->getScene()->getSurfaceIDs(&length, &array); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendArrayOfUInt(length, array); - g_pDbusMessage->closeReply(); - m_executor->getScene()->unlockScene(); -} - -void DBUSCommunicator::ListAllLayerGroupIDS(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint* array = NULL; - uint length = 0; - m_executor->getScene()->lockScene(); - m_executor->getScene()->getLayerGroupIDs(&length, &array); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendArrayOfUInt(length, array); - g_pDbusMessage->closeReply(); - m_executor->getScene()->unlockScene(); -} - -void DBUSCommunicator::ListAllSurfaceGroupIDS(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint* array = NULL; - uint length = 0; - m_executor->getScene()->lockScene(); - m_executor->getScene()->getSurfaceGroupIDs(&length, &array); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendArrayOfUInt(length, array); - g_pDbusMessage->closeReply(); - m_executor->getScene()->unlockScene(); -} - -void DBUSCommunicator::ListSurfacesOfSurfacegroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - m_executor->getScene()->lockScene(); - SurfaceGroup* sg = m_executor->getScene()->getSurfaceGroup(id); - if (NULL != sg) - { - std::list surfaces = sg->getList(); - uint length = surfaces.size(); - uint* array = new uint[length]; - uint arrayPos = 0; - g_pDbusMessage->initReply(msg); - - for (std::list::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it) - { - Surface* s = *it; - array[arrayPos] = s->getID(); - ++arrayPos; - } - - g_pDbusMessage->appendArrayOfUInt(length, array); - - g_pDbusMessage->closeReply(); - m_executor->getScene()->unlockScene(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} -DBusHandlerResult DBUSCommunicator::processMessageFunc(DBusConnection* conn,DBusMessage* msg, void *user_data) -{ - return ((DBUSCommunicator*)user_data)->delegateMessage(conn,msg); -} - -void DBUSCommunicator::unregisterMessageFunc(DBusConnection* conn, void *user_data) -{ - (void)conn; - (void)user_data; -} - -void DBUSCommunicator::ListLayersOfLayergroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - m_executor->getScene()->lockScene(); - LayerGroup* sg = m_executor->getScene()->getLayerGroup(id); - if (NULL != sg) - { - std::list layers = sg->getList(); - - uint length = layers.size(); - uint* array = new uint[length]; - uint arrayPos = 0; - - g_pDbusMessage->initReply(msg); - for (std::list::const_iterator it = layers.begin(); it != layers.end(); ++it) - { - Layer* l = *it; - array[arrayPos] = l->getID(); - ++arrayPos; - } - - g_pDbusMessage->appendArrayOfUInt(length, array); - - g_pDbusMessage->closeReply(); - m_executor->getScene()->unlockScene(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::ListSurfaceofLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - m_executor->getScene()->lockScene(); - Layer* layer = m_executor->getScene()->getLayer(id); - if (layer != NULL) - { - std::list surfaces = layer->getAllSurfaces(); - - uint length = surfaces.size(); - uint* array = new uint[length]; - uint arrayPos = 0; - - g_pDbusMessage->initReply(msg); - - for (std::list::const_iterator it = surfaces.begin(); it != surfaces.end(); ++it) - { - Surface* s = *it; - array[arrayPos] = s->getID(); - ++arrayPos; - } - - g_pDbusMessage->appendArrayOfUInt(length, array); - - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } - m_executor->getScene()->unlockScene(); -} - -void DBUSCommunicator::GetPropertiesOfSurface(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - - Surface* surface = m_executor->getScene()->getSurface(id); - if (surface != NULL) - { - Rectangle dest = surface->getDestinationRegion(); - Rectangle src = surface->getSourceRegion(); - OrientationType orientation = surface->getOrientation(); - - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendDouble(surface->getOpacity()); - g_pDbusMessage->appendUInt(src.x); - g_pDbusMessage->appendUInt(src.y); - g_pDbusMessage->appendUInt(src.width); - g_pDbusMessage->appendUInt(src.height); - g_pDbusMessage->appendUInt(surface->OriginalSourceWidth); - g_pDbusMessage->appendUInt(surface->OriginalSourceHeight); - g_pDbusMessage->appendUInt(dest.x); - g_pDbusMessage->appendUInt(dest.y); - g_pDbusMessage->appendUInt(dest.width); - g_pDbusMessage->appendUInt(dest.height); - g_pDbusMessage->appendUInt(orientation); - g_pDbusMessage->appendBool(surface->getVisibility()); - g_pDbusMessage->appendUInt(surface->frameCounter); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetPropertiesOfLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - - Layer* layer = m_executor->getScene()->getLayer(id); - if (layer != NULL) - { - Rectangle dest = layer->getDestinationRegion(); - Rectangle src = layer->getSourceRegion(); - OrientationType orientation = layer->getOrientation(); - - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendDouble(layer->getOpacity()); - g_pDbusMessage->appendUInt(src.x); - g_pDbusMessage->appendUInt(src.y); - g_pDbusMessage->appendUInt(src.width); - g_pDbusMessage->appendUInt(src.height); - g_pDbusMessage->appendUInt(layer->OriginalSourceWidth); - g_pDbusMessage->appendUInt(layer->OriginalSourceHeight); - g_pDbusMessage->appendUInt(dest.x); - g_pDbusMessage->appendUInt(dest.y); - g_pDbusMessage->appendUInt(dest.width); - g_pDbusMessage->appendUInt(dest.height); - g_pDbusMessage->appendUInt(orientation); - g_pDbusMessage->appendBool(layer->getVisibility()); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::CreateSurface(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint handle = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - uint pixelformat = g_pDbusMessage->getUInt(); - PixelFormat pf = (PixelFormat) pixelformat; - - //LOG_DEBUG("DBUSCommunicator::CreateSurface","pixelformat: " << pixelformat); - uint id = GraphicalObject::INVALID_ID; - /* First of all create the surface */ - bool status = m_executor->execute(new SurfaceCreateCommand(&id)); - /* after that apply the native content */ - status &= m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::CreateSurfaceFromId(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint handle = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - uint pixelformat = g_pDbusMessage->getUInt(); - PixelFormat pf = (PixelFormat) pixelformat; - - //LOG_DEBUG("DBUSCommunicator::CreateSurface","pixelformat: " << pixelformat); - uint id = g_pDbusMessage->getUInt(); - - /* First of all create the surface */ - bool status = m_executor->execute(new SurfaceCreateCommand(&id)); - /* after that apply the native content */ - status &= m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height)); - - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::InitializeSurface(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = GraphicalObject::INVALID_ID; - - bool status = m_executor->execute(new SurfaceCreateCommand(&id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::InitializeSurfaceFromId(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - bool status = m_executor->execute(new SurfaceCreateCommand(&id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::SetSurfaceNativeContent(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint handle = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - PixelFormat pf = (PixelFormat)g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfaceSetNativeContentCommand(id, handle, pf, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::RemoveSurface(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint param = g_pDbusMessage->getUInt(); - bool status = m_executor->execute(new SurfaceRemoveCommand(param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::CreateLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint id = GraphicalObject::INVALID_ID; - // use resolution of default screen as default width and height of layers - uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN); - bool status = m_executor->execute(new LayerCreateCommand(resolution[0], resolution[1], &id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::CreateLayerFromId(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint id = GraphicalObject::INVALID_ID; - g_pDbusMessage->initReceive(msg); - id = g_pDbusMessage->getUInt(); - // use resolution of default screen as default width and height of layers - uint* resolution = m_executor->getScreenResolution(DEFAULT_SCREEN); - bool status = m_executor->execute(new LayerCreateCommand(resolution[0], resolution[1], &id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - - -void DBUSCommunicator::CreateLayerWithDimension(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - - uint id = GraphicalObject::INVALID_ID; - bool status = m_executor->execute(new LayerCreateCommand(width, height, &id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::CreateLayerFromIdWithDimension(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint id = GraphicalObject::INVALID_ID; - g_pDbusMessage->initReceive(msg); - id = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - bool status = m_executor->execute(new LayerCreateCommand(width, height, &id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::RemoveLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint param = g_pDbusMessage->getUInt(); - bool status = m_executor->execute(new LayerRemoveCommand(param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::AddSurfaceToSurfaceGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint surfaceid = g_pDbusMessage->getUInt(); - uint surfacegroupid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfacegroupAddSurfaceCommand(surfacegroupid, surfaceid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::RemoveSurfaceFromSurfaceGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint surfaceid = g_pDbusMessage->getUInt(); - uint surfacegroupid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfacegroupRemoveSurfaceCommand(surfacegroupid, surfaceid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::AddLayerToLayerGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint layerid = g_pDbusMessage->getUInt(); - uint layergroupid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayergroupAddLayerCommand(layergroupid, layerid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::RemoveLayerFromLayerGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint layerid = g_pDbusMessage->getUInt(); - uint layergroupid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayergroupRemoveLayerCommand(layergroupid, layerid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::AddSurfaceToLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint surfaceid = g_pDbusMessage->getUInt(); - uint layer = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayerAddSurfaceCommand(layer, surfaceid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::RemoveSurfaceFromLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint surfaceid = g_pDbusMessage->getUInt(); - uint layerid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayerRemoveSurfaceCommand(layerid, surfaceid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::CreateSurfaceGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint newID = GraphicalObject::INVALID_ID; - - bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(newID); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::CreateSurfaceGroupFromId(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint newID = GraphicalObject::INVALID_ID; - g_pDbusMessage->initReceive(msg); - newID = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfacegroupCreateCommand(&newID)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(newID); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::RemoveSurfaceGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint param = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfacegroupRemoveCommand(param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::CreateLayerGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint newID = GraphicalObject::INVALID_ID; - - bool status = m_executor->execute(new LayergroupCreateCommand(&newID)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(newID); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::CreateLayerGroupFromId(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint newID = GraphicalObject::INVALID_ID; - g_pDbusMessage->initReceive(msg); - newID = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayergroupCreateCommand(&newID)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(newID); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_ALREADY_INUSE); - } -} - -void DBUSCommunicator::RemoveLayerGroup(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint param = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayergroupRemoveCommand(param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfaceSourceRegion(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = g_pDbusMessage->getUInt(); - uint y = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfaceSetSourceRectangleCommand(id, x, y, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayerSourceRegion(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = g_pDbusMessage->getUInt(); - uint y = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - - //LOG_DEBUG("DBUSC","new SetSourceRectangleCommand with arguments: " <execute(new LayerSetSourceRectangleCommand(id, x, y, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfaceDestinationRegion(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = g_pDbusMessage->getUInt(); - uint y = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfaceSetDestinationRectangleCommand(id, x, y, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfacePosition(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = g_pDbusMessage->getUInt(); - uint y = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfaceSetPositionCommand(id, x, y)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetSurfacePosition(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = 0; - uint y = 0; - - bool status = m_executor->execute(new SurfaceGetPositionCommand(id, &x, &y)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(x); - g_pDbusMessage->appendUInt(y); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfaceDimension(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfaceSetDimensionCommand(id, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayerDestinationRegion(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = g_pDbusMessage->getUInt(); - uint y = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayerSetDestinationRectangleCommand(id, x, y, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayerPosition(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = g_pDbusMessage->getUInt(); - uint y = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayerSetPositionCommand(id, x, y)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetLayerPosition(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint x = 0; - uint y = 0; - - bool status = m_executor->execute(new LayerGetPositionCommand(id, &x, &y)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(x); - g_pDbusMessage->appendUInt(y); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayerDimension(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint width = g_pDbusMessage->getUInt(); - uint height = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new LayerSetDimensionCommand(id, width, height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetLayerDimension(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint width = 0; - uint height = 0; - - bool status = m_executor->execute(new LayerGetDimensionCommand(id, &width, &height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(width); - g_pDbusMessage->appendUInt(height); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetSurfaceDimension(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint width = 0; - uint height = 0; - - bool status = m_executor->execute(new SurfaceGetDimensionCommand(id, &width, &height)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(width); - g_pDbusMessage->appendUInt(height); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - double param = g_pDbusMessage->getDouble(); - - bool status = m_executor->execute(new SurfaceSetOpacityCommand(id, param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayerOpacity(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - double param = g_pDbusMessage->getDouble(); - - bool status = m_executor->execute(new LayerSetOpacityCommand(id, param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfacegroupOpacity(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - double param = g_pDbusMessage->getDouble(); - - bool status = m_executor->execute(new SurfacegroupSetOpacityCommand(id, param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayergroupOpacity(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - double param = g_pDbusMessage->getDouble(); - - bool status = m_executor->execute(new LayergroupSetOpacityCommand(id, param)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetSurfaceOpacity(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - double param = 0.0; - - bool status = m_executor->execute(new SurfaceGetOpacityCommand(id, ¶m)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendDouble(param); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetLayerOpacity(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - double param = 0.0; - - bool status = m_executor->execute(new LayerGetOpacityCommand(id, ¶m)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendDouble(param); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint param = g_pDbusMessage->getUInt(); - OrientationType o = (OrientationType) param; - - bool status = m_executor->execute(new SurfaceSetOrientationCommand(id, o)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetSurfaceOrientation(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - OrientationType o; - - bool status = m_executor->execute(new SurfaceGetOrientationCommand(id, &o)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(o); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayerOrientation(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - uint param = g_pDbusMessage->getUInt(); - OrientationType o = (OrientationType) param; - - bool status = m_executor->execute(new LayerSetOrientationCommand(id, o)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetLayerOrientation(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - OrientationType o; - - bool status = m_executor->execute(new LayerGetOrientationCommand(id, &o)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(o); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetSurfacePixelformat(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - PixelFormat param; - - bool status = m_executor->execute(new SurfaceGetPixelformatCommand(id, ¶m)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(param); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - const uint surfaceid = g_pDbusMessage->getUInt(); - bool newVis = g_pDbusMessage->getBool(); - - bool status = m_executor->execute(new SurfaceSetVisibilityCommand(surfaceid, newVis)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayerVisibility(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - const uint layerid = g_pDbusMessage->getUInt(); - bool myparam = g_pDbusMessage->getBool(); - - bool status = m_executor->execute(new LayerSetVisibilityCommand(layerid, myparam)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetSurfaceVisibility(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - bool param; - - bool status = m_executor->execute(new SurfaceGetVisibilityCommand(id, ¶m)); - if (status) - { - g_pDbusMessage->initReply(msg); - //LOG_DEBUG("DBUSCommunicator", "returning surfacevisibility: " << param); - g_pDbusMessage->appendBool(param); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetLayerVisibility(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - bool param; - - bool status = m_executor->execute(new LayerGetVisibilityCommand(id, ¶m)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendBool(param); - //LOG_DEBUG("DBUSCommunicator", "returning layervisibility: " << param); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfacegroupVisibility(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint groupid = g_pDbusMessage->getUInt(); - bool myparam = g_pDbusMessage->getBool(); - - bool status = m_executor->execute(new SurfacegroupSetVisibilityCommand(groupid, myparam)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetLayergroupVisibility(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint groupid = g_pDbusMessage->getUInt(); - bool myparam = g_pDbusMessage->getBool(); - - bool status = m_executor->execute(new LayergroupSetVisibilityCommand(groupid, myparam)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - - -void DBUSCommunicator::SetRenderOrderOfLayers(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint* array; - int length; - g_pDbusMessage->initReceive(msg); - g_pDbusMessage->getArrayOfUInt(&length, &array); - - //LOG_DEBUG("DBUSCommunicator","Renderorder: Got " << length << " ids."); - - bool status = m_executor->execute(new ScreenSetRenderOrderCommand(array, length)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetSurfaceRenderOrderWithinLayer(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - uint* array; - int length; - - g_pDbusMessage->initReceive(msg); - uint layerid = g_pDbusMessage->getUInt(); - - g_pDbusMessage->getArrayOfUInt(&length, &array); - - - bool status = m_executor->execute(new LayerSetRenderOrderCommand(layerid, array, length)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetLayerType(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - Layer* l = m_executor->getScene()->getLayer(id); - if (l != NULL) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(l->getLayerType()); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::GetLayertypeCapabilities(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - LayerType type = (LayerType) id; - uint capabilities = m_executor->getLayerTypeCapabilities(type); - //LOG_DEBUG("DBUSCommunicator", "GetLayertypeCapabilities: returning capabilities:" << capabilities); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(capabilities); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::GetLayerCapabilities(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - Layer* l = m_executor->getScene()->getLayer(id); - if (l != NULL) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(l->getCapabilities()); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::FadeIn(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::SynchronizedFade(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::FadeOut(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); -} - -void DBUSCommunicator::Exit(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - bool status = m_executor->execute(new ExitCommand()); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT); - } -} - -void DBUSCommunicator::CommitChanges(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - bool status = m_executor->execute(new CommitCommand()); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, INVALID_ARGUMENT); - } -} - -void DBUSCommunicator::CreateShader(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - char* vertname = g_pDbusMessage->getString(); - char* fragname = g_pDbusMessage->getString(); - uint id = 0; - - bool status = m_executor->execute(new ShaderCreateCommand(vertname, fragname, &id)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(id); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::DestroyShader(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint shaderid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new ShaderDestroyCommand(shaderid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetShader(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint surfaceId = g_pDbusMessage->getUInt(); - uint shaderid = g_pDbusMessage->getUInt(); - - bool status = m_executor->execute(new SurfaceSetShaderCommand(surfaceId, shaderid)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::SetUniforms(DBusConnection* conn, DBusMessage* msg) -{ - (void)conn; // TODO: remove, only prevents warning - - g_pDbusMessage->initReceive(msg); - uint id = g_pDbusMessage->getUInt(); - - std::vector uniforms; - - g_pDbusMessage->getArrayOfString(&uniforms); - - bool status = m_executor->execute(new ShaderSetUniformsCommand(id, uniforms)); - if (status) - { - g_pDbusMessage->initReply(msg); - g_pDbusMessage->closeReply(); - } - else - { - g_pDbusMessage->ReplyError(msg, SERVICE_ERROR, RESSOURCE_NOT_FOUND); - } -} - -void DBUSCommunicator::RemoveApplicationReference(char* owner) -{ - ApplicationReferenceMapIterator iter = m_executor->getApplicationReferenceMap()->find(IApplicationReference::generateApplicationHash(owner)); - ApplicationReferenceMapIterator iterEnd = m_executor->getApplicationReferenceMap()->end(); - - if ( iter != iterEnd ) - { - m_executor->removeApplicationReference((*iter).second); - } -} - - -void DBUSCommunicator::AddClientWatch(DBusConnection *conn, char* sender) -{ - DBusError err; - dbus_error_init(&err); - char rule[1024]; - sprintf(rule,"type='signal',sender='%s',interface='%s',member='%s',arg0='%s'",DBUS_INTERFACE_DBUS,DBUS_INTERFACE_DBUS,"NameOwnerChanged",sender); - - dbus_bus_add_match(conn,rule,&err); - if (dbus_error_is_set(&err)) - { - LOG_ERROR("DBUSCommunicator", "Could not add client watch "<< err.message); - dbus_error_free(&err); - } -} - -void DBUSCommunicator::RemoveClientWatch(DBusConnection *conn, char* sender) -{ - DBusError err; - dbus_error_init(&err); - char rule[1024]; - sprintf(rule,"type='signal',sender='%s',interface='%s',member='%s',arg0='%s'",DBUS_INTERFACE_DBUS,DBUS_INTERFACE_DBUS,"NameOwnerChanged",sender); - - dbus_bus_remove_match(conn,rule,&err); - if (dbus_error_is_set(&err)) - { - LOG_ERROR("DBUSCommunicator", "Could not remove client watch "<< err.message); - dbus_error_free(&err); - } -} - -DBusHandlerResult DBUSCommunicator::delegateMessage(DBusConnection* conn, DBusMessage* msg) -{ - DBusHandlerResult result = DBUS_HANDLER_RESULT_HANDLED; - LOG_DEBUG("DBUSCommunicator","message received"); - const char *n = dbus_message_get_member(msg); - char* owner = strdup(dbus_message_get_sender(msg)); - bool found = false; - int i = 0; - - while (!found && strcmp(manager_methods[i].name, "") != 0) - { - if (n && strcmp(manager_methods[i].name, n) == 0) - { - MethodTable entry = manager_methods[i]; - LOG_DEBUG("DBUSCommunicator","got call for method:" << entry.name); - CallBackMethod m = entry.function; - LOG_DEBUG("DBUSCommunicator","enter method"); - (this->*m)(conn, msg); - found = true; - } - i++; - } - - if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) - { - LOG_DEBUG("DBUSCommunicator", "Introspection called"); - DBUSIntrospection introspectionString(manager_methods); - introspectionString.process(conn, msg); - g_pDbusMessage->setConnection(conn); - found = true; // TODO: always true - } - - if (dbus_message_is_signal(msg, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) - { - char *name, *oldName, *newName; - LOG_DEBUG("DBUSCommunicator","NameOwner Changed detected "); - if (!dbus_message_get_args(msg, NULL, - DBUS_TYPE_STRING, &name, - DBUS_TYPE_STRING, &oldName, - DBUS_TYPE_STRING, &newName, - DBUS_TYPE_INVALID)) - { - LOG_WARNING("DBUSCommunicator","Invalid arguments for NameOwnerChanged signal"); - } else if ( *newName == '\0' ) - { - LOG_DEBUG("DBUSCommunicator","Client Disconnect detected " << name); - RemoveClientWatch(conn,owner); - RemoveApplicationReference(name); - } - } - if (!found) - { - result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - - free(owner); - - return result; -} - -extern "C" ICommunicator* createDBUSCommunicator(ICommandExecutor* executor) -{ - return new DBUSCommunicator(executor); -} - -extern "C" void destroyDBUSCommunicator(DBUSCommunicator* p) -{ - delete p; -} - diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSIntrospection.cpp b/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSIntrospection.cpp deleted file mode 100644 index 8bd0adf..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSIntrospection.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ -#include "DBUSIntrospection.h" -#include "DBUSCommunicator.h" -#include "DBUSConfiguration.h" - -#include -#include -using std::stringstream; - - -DBUSIntrospection::DBUSIntrospection(MethodTable* methodTable) -: m_methodTable(methodTable) -{ - generateString(); -} - -void DBUSIntrospection::generateString() -{ - LOG_DEBUG("DBUSCommunicator", "Generating introspection data"); - - addHeader(); - openNode(DBUS_SERVICE_PREFIX); - openInterface("org.freedesktop.DBus.Introspectable"); - openMethod("Introspect"); - addArgument("data", "out", "s"); - closeMethod(); - closeInterface(); - openInterface(DBUS_SERVICE_PREFIX); - - int index = 0; - - while (strcmp(m_methodTable[index].name, "") != 0) - { - MethodTable entry = m_methodTable[index]; - addEntry(entry); - ++index; - } - - closeInterface(); - - closeNode(); - //LOG_DEBUG("DBUSCommunicator", "generated introspection data"); -} - -void DBUSIntrospection::addHeader(void) -{ - m_introspectionString << " \n"; -} - -void DBUSIntrospection::openNode(string nodename) -{ - m_introspectionString << " \n"; -} - -void DBUSIntrospection::openInterface(string interfacename) -{ - m_introspectionString << " \n"; -} - -void DBUSIntrospection::openMethod(string methodname) -{ - m_introspectionString << " \n"; -} - -void DBUSIntrospection::addArgument(string argname, string direction, string type) -{ - m_introspectionString << " \n"; -} - -void DBUSIntrospection::closeMethod(void) -{ - m_introspectionString << " \n"; -} - -void DBUSIntrospection::closeInterface(void) -{ - m_introspectionString << " \n"; -} - -void DBUSIntrospection::closeNode(void) -{ - m_introspectionString << " \n"; -} - - -void DBUSIntrospection::addEntry(MethodTable entry) -{ - string methodName = entry.name; - string parameterArray = entry.signature; - string returnValueArray = string(entry.reply); - - openMethod(methodName); - - for(uint parameterIndex = 0; parameterIndex < parameterArray.length(); ++parameterIndex) - { - switch (parameterArray.at(parameterIndex)) - { - - case 'a': - parameterIndex++; - addArgument("", "in", "a" + parameterArray.substr(parameterIndex,1)); - break; - default: - addArgument("", "in",parameterArray.substr(parameterIndex,1)); - break; - } - } - - for(uint returnValueIndex = 0; returnValueIndex < returnValueArray.length(); ++returnValueIndex) - { - switch (returnValueArray.at(returnValueIndex)) - { - case 'a': - returnValueIndex++; - addArgument("", "out", "a" + returnValueArray.substr(returnValueIndex,1)); - break; - default: - addArgument("", "out",returnValueArray.substr(returnValueIndex,1)); - break; - } - } - - closeMethod(); -} - -void DBUSIntrospection::process(DBusConnection* conn, DBusMessage* msg) -{ - DBusMessage * reply; - DBusMessageIter args; - dbus_uint32_t serial = 0; - - // create a reply from the message - reply = dbus_message_new_method_return(msg); - - string introspect = m_introspectionString.str(); - const char* string = introspect.c_str(); - - // add the arguments to the reply - dbus_message_iter_init_append(reply, &args); - if (!dbus_message_iter_append_basic(&args, DBUS_TYPE_STRING, &string)) - { - LOG_ERROR("DBUSCommunicator", "Out Of Memory!"); - exit(1); - } - - // send the reply && flush the connection - if (!dbus_connection_send(conn, reply, &serial)) - { - LOG_ERROR("DBUSCommunicator", "Out Of Memory!"); - exit(1); - } - dbus_connection_flush(conn); - - // free the reply - dbus_message_unref(reply); -} - diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSMessageHandler.cpp b/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSMessageHandler.cpp deleted file mode 100644 index 9b46da4..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSMessageHandler.cpp +++ /dev/null @@ -1,340 +0,0 @@ - -#include "DBUSMessageHandler.h" -#include "DBUSConfiguration.h" -#include -#include -#include "Log.h" - -DBUSMessageHandler::DBUSMessageHandler() -: m_MessageIter() -, m_pReply(0) -, m_serial(0) -, m_pConnection(0) -{ - dbus_error_init(&m_err); - - // connect to the bus and check for errors - char* useSessionBus = getenv("LM_USE_SESSION_BUS"); - if ( NULL != useSessionBus && strcmp(useSessionBus,"enable") == 0 ) - { - LOG_INFO("DBUSMessageHandler", "Using Session Bus"); - m_pConnection = dbus_bus_get(DBUS_BUS_SESSION, &m_err); - } - else - { - LOG_INFO("DBUSMessageHandler", "Using System Bus"); - m_pConnection = dbus_bus_get(DBUS_BUS_SYSTEM, &m_err); - } - - if (dbus_error_is_set(&m_err)) - { - LOG_ERROR("DBUSMessageHandler","Connection error"); - dbus_error_free(&m_err); - } - - if (NULL == m_pConnection) - { - LOG_ERROR("DBUSMessageHandler","Connection is null"); - exit(1); - } - - int ret = dbus_bus_request_name(m_pConnection, DBUS_SERVICE_PREFIX, DBUS_NAME_FLAG_REPLACE_EXISTING, &m_err); - - if (dbus_error_is_set(&m_err)) - { - LOG_ERROR("DBUSMessageHandler", "Name Error "<< m_err.message); - dbus_error_free(&m_err); - } - - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) - { - LOG_ERROR("DBUSMessageHandler", "Not Primary Owner "<< ret); - exit(1); - } -} - -DBUSMessageHandler::~DBUSMessageHandler() -{ - DBusError err; - dbus_error_init(&err); - bool errorset = dbus_error_is_set(&err); - if (errorset) - { - LOG_ERROR("DBUSMessageHandler","there was an dbus error"); - } - dbus_connection_unregister_object_path(m_pConnection,DBUS_SERVICE_OBJECT_PATH); - - LOG_INFO("DBUSMessageHandler","Ask about owner name"); - dbus_bus_name_has_owner(m_pConnection, DBUS_SERVICE_PREFIX, &err); - errorset = dbus_error_is_set(&err); - if (errorset) - { - LOG_ERROR("DBUSMessageHandler","there was an dbus error"); - } - dbus_error_init(&err); - dbus_bus_release_name(m_pConnection, DBUS_SERVICE_PREFIX, &err); -} - -bool DBUSMessageHandler::registerMessageFilter( DBusHandleMessageFunction fMessageFunc, - void* comInstance ) -{ - bool result = true; - if ( !dbus_connection_add_filter ( m_pConnection , fMessageFunc, comInstance, NULL) ) - { - result = false; - } - return result; -} - -void DBUSMessageHandler::unregisterMessageFilter( DBusHandleMessageFunction fMessageFunc, - void* comInstance ) -{ - dbus_connection_remove_filter ( m_pConnection , fMessageFunc, comInstance); -} - -bool DBUSMessageHandler::registerPathFunction( DBusObjectPathMessageFunction fMessageFunc, - DBusObjectPathUnregisterFunction fUnregisterFunc, - void* comInstance) -{ - bool result = true; - DBusObjectPathVTable objectPathVTable; - memset(&objectPathVTable, 0, sizeof(objectPathVTable)); - objectPathVTable.unregister_function = fUnregisterFunc; - objectPathVTable.message_function = fMessageFunc; - - if (!dbus_connection_register_object_path(m_pConnection, DBUS_SERVICE_OBJECT_PATH, &objectPathVTable, comInstance) ) - { - result = false; - } - return result; -} - -void DBUSMessageHandler::initReceive(DBusMessage* msg) -{ - LOG_DEBUG("DBUSMessageHandler","Message " << dbus_message_get_member(msg) << " was sent by " << dbus_message_get_sender(msg) ); - if (!dbus_message_iter_init(msg, &m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler", "Message has no arguments!"); - } -} - -void DBUSMessageHandler::initReply(DBusMessage* msg) -{ - // create a reply from the message - m_pReply = dbus_message_new_method_return(msg); - dbus_message_iter_init_append(m_pReply, &m_MessageIter); -} - -void DBUSMessageHandler::closeReply() -{ - // send the reply && flush the connection - if (!dbus_connection_send(m_pConnection, m_pReply, &m_serial)) - { - LOG_ERROR("DBUSMessageHandler", "Out Of Memory!"); - exit(1); - } - LOG_DEBUG("DBUSMessageHandler", "sending reply"); - dbus_connection_flush(m_pConnection); - - // free the reply - dbus_message_unref(m_pReply); - m_pReply = NULL; -} - -void DBUSMessageHandler::ReplyError(DBusMessage* msg, const char* errorname, const char* errorMsg) -{ - m_pReply = dbus_message_new_error(msg, errorname, errorMsg); - // send the reply && flush the connection - if (!dbus_connection_send(m_pConnection, m_pReply, &m_serial)) - { - LOG_ERROR("DBUSMessageHandler", "Out Of Memory!"); - exit(1); - } - LOG_INFO("DBUSMessageHandler", "sending reply with error"); - dbus_connection_flush(m_pConnection); - - // free the reply - dbus_message_unref(m_pReply); - m_pReply = NULL; -} - -char* DBUSMessageHandler::getString() -{ - char* param = NULL; - - if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler", "Argument is not string!"); - } - else - { - dbus_message_iter_get_basic(&m_MessageIter, ¶m); - dbus_message_iter_next(&m_MessageIter); - } - return param; -} - -dbus_bool_t DBUSMessageHandler::getBool() -{ - dbus_bool_t boolparam = FALSE; - - if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler", "Argument is not bool!"); - } - else - { - dbus_message_iter_get_basic(&m_MessageIter, &boolparam); - dbus_message_iter_next(&m_MessageIter); - } - return boolparam; -} - -char DBUSMessageHandler::getByte() -{ - char param = 0; - - if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler", "Argument is not byte!"); - } - else - { - dbus_message_iter_get_basic(&m_MessageIter, ¶m); - dbus_message_iter_next(&m_MessageIter); - } - return param; -} - -dbus_uint32_t DBUSMessageHandler::getUInt() -{ - dbus_uint32_t param = 0; - - if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler", "Argument is not uint32!"); - } - else - { - dbus_message_iter_get_basic(&m_MessageIter, ¶m); - dbus_message_iter_next(&m_MessageIter); - } - return param; -} - -double DBUSMessageHandler::getDouble() -{ - double param = 0.0; - - if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler","Argument is not double!"); - } - else - { - dbus_message_iter_get_basic(&m_MessageIter, ¶m); - dbus_message_iter_next(&m_MessageIter); - } - return param; -} - -void DBUSMessageHandler::getArrayOfUInt(int* pLength, unsigned int** ppArray) -{ - if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler","Argument is not an array!"); - return; - } - - DBusMessageIter arrayIter; - dbus_message_iter_recurse(&m_MessageIter, &arrayIter); - - uint* localArray; - dbus_message_iter_get_fixed_array(&arrayIter, &localArray, pLength); - - *ppArray = new uint[*pLength]; - for (int i = 0; i < *pLength; i++) - { - (*ppArray)[i] = localArray[i]; - } -} - -void DBUSMessageHandler::getArrayOfString(std::vector* stringVector) -{ - if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&m_MessageIter)) - { - LOG_ERROR("DBUSMessageHandler", "Argument is not an array!"); - return; - } - - DBusMessageIter arrayIter; - dbus_message_iter_recurse(&m_MessageIter, &arrayIter); - bool hasNext = true; - while (hasNext) - { - if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&arrayIter)) - { - LOG_ERROR("DBUSMessageHandler", "Argument is not an string!"); - } - char* param; - dbus_message_iter_get_basic(&arrayIter, ¶m); - - stringVector->push_back(std::string(param)); - - if (dbus_message_iter_has_next(&arrayIter)) - { - dbus_message_iter_next(&arrayIter); - } - else - { - hasNext = false; - } - } -} - -void DBUSMessageHandler::appendBool(dbus_bool_t toAppend) -{ - if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_BOOLEAN, &toAppend)) - { - LOG_ERROR("DBUSMessageHandler", "Out Of Memory!"); - exit(1); - } -} - -void DBUSMessageHandler::appendUInt(dbus_uint32_t toAppend) -{ - if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_UINT32, &toAppend)) - { - LOG_ERROR("DBUSMessageHandler", "Out Of Memory!"); - exit(1); - } -} - -void DBUSMessageHandler::appendDouble(double toAppend) -{ - if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_DOUBLE, &toAppend)) - { - LOG_ERROR("DBUSMessageHandler", "Out Of Memory!"); - exit(1); - } -} - -void DBUSMessageHandler::appendByte(char toAppend) -{ - if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_BYTE, &toAppend)) - { - LOG_ERROR("DBUSMessageHandler", "Out Of Memory!"); - exit(1); - } -} - -void DBUSMessageHandler::appendArrayOfUInt(unsigned int length, unsigned int *IDs) -{ - DBusMessageIter arrayIter; - dbus_message_iter_open_container(&m_MessageIter, DBUS_TYPE_ARRAY, "u", &arrayIter); - for(unsigned int i = 0; i < length; i++) - { - dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_UINT32, &IDs[i]); - } - dbus_message_iter_close_container(&m_MessageIter, &arrayIter); -} diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/CMakeLists.txt b/LayerManagerPlugins/Communicators/DBUSCommunicator/test/CMakeLists.txt deleted file mode 100644 index f9f4f5d..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -############################################################################ -# -# Copyright 2010, 2011 BMW Car IT GmbH -# -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -############################################################################ - - -include_directories (".") -include_directories ("../include") -include_directories ("${PROJECT_SOURCE_DIR}/LayerManagerService/include") -#link_directories ("${PROJECT_SOURCE_DIR}/LayerManagerService/bin") -include_directories ("${PROJECT_SOURCE_DIR}/LayerManagerUtils/include") -#link_directories ("${PROJECT_SOURCE_DIR}/LayerManagerUtils/bin") -link_directories ("${PROJECT_SOURCE_DIR}/LayerManagerCommands") - -find_package(DBUS REQUIRED) -include_directories(${DBUS_INCLUDE_DIR}) -include_directories(${DBUS_ARCH_INCLUDE_DIR}) - -find_package (Threads) -set(LIBS ${LIBS} ${DBUS_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} LayerManagerUtils ${DLT_LIBRARY}) - -file(GLOB LM_SOURCES "${PROJECT_SOURCE_DIR}/LayerManagerService/src/Scene.cpp" - "${PROJECT_SOURCE_DIR}/LayerManagerService/src/Layermanager.cpp" - "${PROJECT_SOURCE_DIR}/LayerManagerService/src/GraphicalObject.cpp" - "${PROJECT_SOURCE_DIR}/LayerManagerService/src/GraphicalSurface.cpp" - "${PROJECT_SOURCE_DIR}/LayerManagerService/src/shader/*.cpp" - "${PROJECT_SOURCE_DIR}/LayerManagerService/src/commands/*.cpp") - -file(GLOB DBUSCommunicator_SOURCES "../src/*.cpp") - -add_executable(DBUSCommunicator_Test DBUSCommunicatorTest.cpp ${LM_SOURCES} ${DBUSCommunicator_SOURCES}) -target_link_libraries(DBUSCommunicator_Test gmock LayerManagerCommands ${LIBS}) - -add_test(DBUSCommunicator DBUSCommunicator_Test) diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/DBUSCommunicatorTest.cpp b/LayerManagerPlugins/Communicators/DBUSCommunicator/test/DBUSCommunicatorTest.cpp deleted file mode 100644 index ba404f9..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/DBUSCommunicatorTest.cpp +++ /dev/null @@ -1,875 +0,0 @@ -/*************************************************************************** - * - * Copyright 2010,2011 BMW Car IT GmbH - * - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ****************************************************************************/ - -#ifndef DBUSDBUSCommunicatorTest_H_ -#define DBUSDBUSCommunicatorTest_H_ - -#include -#include -#include "ICommunicator.h" -#include "DBUSCommunicator.h" -#include "mock_CommandExecutor.h" -#include "mock_Layerlist.h" -//#include "FieldMatcher.h" -#include -#include - -using ::testing::Field; -using ::testing::Property; -using ::testing::Matcher; -using ::testing::Pointee; -using ::testing::AllOf; -using ::testing::SafeMatcherCast; -using ::testing::MatcherCast; -using ::testing::DefaultValue; -using ::testing::Eq; -using ::testing::An; -using ::testing::ElementsAreArray; -using ::testing::ElementsAre; -using ::testing::NotNull; - -std::string DBUSCOMMAND_SYSTEM = - "dbus-send --system --type=method_call --print-reply --dest=org.genivi.layermanagementservice /org/genivi/layermanagementservice org.genivi.layermanagementservice."; -std::string DBUSCOMMAND_SESSION = - "dbus-send --type=method_call --print-reply --dest=org.genivi.layermanagementservice /org/genivi/layermanagementservice org.genivi.layermanagementservice."; -std::string DBUSCOMMAND = DBUSCOMMAND_SYSTEM; - -class DBUSCommunicatorTest: public ::testing::Test { -public: - pthread_t processThread; - bool running; - ICommunicator* communicatorUnderTest; - MockCommandExecutor mockCommandExecutor; - MockLayerList layerlist; - - DBUSCommunicatorTest() - : processThread(0) - , running(false) - , communicatorUnderTest(NULL) - { - } - - virtual ~DBUSCommunicatorTest() { - } - - static void *processLoop(void * ptr) { - while (((DBUSCommunicatorTest*) ptr)->running) { - ((DBUSCommunicatorTest*) ptr)->communicatorUnderTest->process(100); - } - return NULL; - } - - void SetUp() { - char* useSessionBus = getenv("LM_USE_SESSION_BUS"); - if (NULL != useSessionBus && strcmp(useSessionBus, "enable") == 0) { - DBUSCOMMAND = DBUSCOMMAND_SESSION; - } else { - DBUSCOMMAND = DBUSCOMMAND_SYSTEM; - } - communicatorUnderTest = new DBUSCommunicator(&mockCommandExecutor); - this->communicatorUnderTest->start(); - running = true; - pthread_create(&processThread, NULL, processLoop, (void*) this); - } - - void TearDown() { - running = false; - if (communicatorUnderTest) { - this->communicatorUnderTest->stop(); - pthread_join(processThread, NULL); - delete communicatorUnderTest; - } - } -}; - -MATCHER_P(DebugCommandEq, onoff, "DebugCommand has onoff set to %(onoff)s") { - return ((DebugCommand*)arg)->m_onoff == onoff; -} - -TEST_F(DBUSCommunicatorTest, TurnDebugOnAndOff) { - EXPECT_CALL(this->mockCommandExecutor, execute(DebugCommandEq(false) ) ).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("Debug boolean:false")).c_str())); - EXPECT_CALL(this->mockCommandExecutor, execute(DebugCommandEq(true) ) ).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("Debug boolean:true")).c_str())); - EXPECT_CALL(this->mockCommandExecutor, execute(DebugCommandEq(false) ) ).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("Debug boolean:false")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, ListAllLayerIDS) { - DefaultValue::Set((Scene*) &this->layerlist); - EXPECT_CALL(this->layerlist, getLayerIDs(NotNull(),NotNull() )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("ListAllLayerIDS")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, listAlllayerGroupIDS) { - std::list defaultlist; - DefaultValue::Set((Scene*) &this->layerlist); - DefaultValue >::Set(defaultlist); - EXPECT_CALL(this->layerlist, getLayerGroupIDs(NotNull(),NotNull()) ).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("ListAllLayerGroupIDS")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, listAllSurfaceGroupIDS) { - std::list defaultlist; - DefaultValue::Set((Scene*) &this->layerlist); - DefaultValue >::Set(defaultlist); - EXPECT_CALL(this->layerlist, getSurfaceGroupIDs(NotNull(),NotNull() )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("ListAllSurfaceGroupIDS")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, listSurfacesOfSurfacegroup) { - - std::list defaultlist; - DefaultValue::Set((Scene*) &this->layerlist); - DefaultValue >::Set(defaultlist); - DefaultValue::Set(new SurfaceGroup()); - EXPECT_CALL(this->layerlist, getSurfaceGroup(Eq(84567u) )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("ListSurfacesOfSurfacegroup uint32:84567")).c_str())); - -} - -TEST_F(DBUSCommunicatorTest, listlayersOflayergroup) { - - std::list defaultlist; - DefaultValue::Set((Scene*) &this->layerlist); - DefaultValue >::Set(defaultlist); - DefaultValue::Set(new LayerGroup()); - - EXPECT_CALL(this->layerlist, getLayerGroup(Eq(345u) )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("ListLayersOfLayergroup uint32:345")).c_str())); - -} - -TEST_F(DBUSCommunicatorTest, listSurfaceoflayer) { - - Scene scene; - DefaultValue::Set(scene.createLayer(234)); - DefaultValue::Set((Scene*) &layerlist); - EXPECT_CALL(this->layerlist, getLayer(Eq(234u) )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("ListSurfaceofLayer uint32:234")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, getPropertiesOfSurface) { - - Scene scene; - unsigned int newID = 0; - DefaultValue::Set((Scene*) &layerlist); - DefaultValue::Set(scene.createSurface(newID)); - EXPECT_CALL(this->layerlist, getSurface(Eq(876u) )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetPropertiesOfSurface uint32:876")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, getPropertiesOflayer) { - - Scene scene; - DefaultValue::Set(scene.createLayer(0)); - DefaultValue::Set((Scene*) &layerlist); - EXPECT_CALL(this->layerlist, getLayer(Eq(876u) )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetPropertiesOfLayer uint32:876")).c_str())); -} -/* -MATCHER_P4(SurfaceCreateCommandEq, nativeHandle, OriginalWidth, OriginalHeight, pixelformat, "%(*)s"){ - return ((SurfaceCreateCommand*)arg)->m_nativeHandle == nativeHandle - && ((SurfaceCreateCommand*)arg)->m_originalHeight == OriginalHeight - && ((SurfaceCreateCommand*)arg)->m_originalWidth == OriginalWidth - && ((SurfaceCreateCommand*)arg)->m_pixelformat == pixelformat; -} -*/ - -/* -TEST_F(DBUSCommunicatorTest, CreateSurface) { - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfaceCreateCommandEq(44u,33u,22u,PIXELFORMAT_RGBA8888))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateSurface uint32:44 uint32:33 uint32:22 uint32:2 ")).c_str()); - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfaceCreateCommandEq(404u,303u,0u,PIXELFORMAT_RGB888))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateSurface uint32:404 uint32:303 uint32:0 uint32:1 ")).c_str()); -} -*/ - -MATCHER_P2(LayerCreateCommandEq, OriginalWidth, OriginalHeight, "%(*)s"){ - return ((LayerCreateCommand*)arg)->m_originalHeight == OriginalHeight - && ((LayerCreateCommand*)arg)->m_originalWidth == OriginalWidth; -} - -TEST_F(DBUSCommunicatorTest, CreateLayer) { - - uint resolution[2] = { 0, 0 }; - DefaultValue::Set(resolution); - - EXPECT_CALL(this->mockCommandExecutor, execute( LayerCreateCommandEq(0u,0u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateLayer")).c_str())); -} - -MATCHER_P(SurfaceRemoveCommandEq, idToRemove, "%(*)s"){ - return ((SurfaceRemoveCommand*)arg)->m_idToRemove == idToRemove; -} - -TEST_F(DBUSCommunicatorTest, RemoveSurface) { - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfaceRemoveCommandEq(8u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveSurface uint32:8")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfaceRemoveCommandEq(5u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveSurface uint32:5")).c_str())); -} - -MATCHER_P(LayerRemoveCommandEq, idToRemove, "%(*)s"){ - return ((LayerRemoveCommand*)arg)->m_idToRemove == idToRemove; -} - -TEST_F(DBUSCommunicatorTest, Removelayer) { - EXPECT_CALL(this->mockCommandExecutor, execute( LayerRemoveCommandEq(8u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveLayer uint32:8")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute( LayerRemoveCommandEq(5u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveLayer uint32:5")).c_str())); -} - -MATCHER_P2(SurfaceSetOpacityCommandEq, id, Opacity, "%(*)s"){ - return ((SurfaceSetOpacityCommand*)arg)->m_id == id - && ((SurfaceSetOpacityCommand*)arg)->m_opacity == Opacity; -} - -TEST_F(DBUSCommunicatorTest, SetSurfaceOpacity) { - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetOpacityCommandEq(36u,0.88) )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceOpacity uint32:36 double:0.88")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetOpacityCommandEq(44u,0.001) )).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceOpacity uint32:44 double:0.001")).c_str())); -} - -/* -TEST_F(DBUSCommunicatorTest, Exit) { - EXPECT_CALL(this->mockCommandExecutor, execute(Field(&Command::commandType,Eq(Command::Exit)) ) ).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("Exit")).c_str()); - - //EXPECT_EXIT(ASSERT_NE(-1, system((DBUSCOMMAND + std::string("Exit")).c_str());, ::testing::ExitedWithCode(0), ""); -} -*/ - -/* -TEST_F(DBUSCommunicatorTest, Commit) { - EXPECT_CALL(this->mockCommandExecutor, execute(Field(&ICommand::commandType, Eq(ICommand::CommitChanges)) ) ).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CommitChanges")).c_str()); -} -*/ - -MATCHER_P5(SurfaceSetSourceRectangleCommandEq, id, x, y, width, height, "%(*)s"){ - return ((SurfaceSetSourceRectangleCommand*)arg)->m_id == id - && ((SurfaceSetSourceRectangleCommand*)arg)->m_x == x - && ((SurfaceSetSourceRectangleCommand*)arg)->m_y == y - && ((SurfaceSetSourceRectangleCommand*)arg)->m_width == width - && ((SurfaceSetSourceRectangleCommand*)arg)->m_height == height; -} - -TEST_F(DBUSCommunicatorTest, SetSurfaceSourceRegion) { - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfaceSetSourceRectangleCommandEq(36u,1u,2u,3u,4u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceSourceRegion uint32:36 uint32:1 uint32:2 uint32:3 uint32:4")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfaceSetSourceRectangleCommandEq(44u,15u,25u,35u,45u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceSourceRegion uint32:44 uint32:15 uint32:25 uint32:35 uint32:45 ")).c_str())); -} - -MATCHER_P5(LayerSetSourceRectangleCommandEq, id, x, y, width, height, "%(*)s"){ - return ((LayerSetSourceRectangleCommand*)arg)->m_id == id - && ((LayerSetSourceRectangleCommand*)arg)->m_x == x - && ((LayerSetSourceRectangleCommand*)arg)->m_y == y - && ((LayerSetSourceRectangleCommand*)arg)->m_width == width - && ((LayerSetSourceRectangleCommand*)arg)->m_height == height; -} - -TEST_F(DBUSCommunicatorTest, SetlayerSourceRegion) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetSourceRectangleCommandEq(36u,1u,2u,3u,4u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerSourceRegion uint32:36 uint32:1 uint32:2 uint32:3 uint32:4")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetSourceRectangleCommandEq(44u,15u,25u,35u,45u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerSourceRegion uint32:44 uint32:15 uint32:25 uint32:35 uint32:45 ")).c_str())); -} - -MATCHER_P5(LayerSetDestinationRectangleCommandEq, id, x, y, width, height, "%(*)s") { - return ((LayerSetDestinationRectangleCommand*)arg)->m_id == id - && ((LayerSetDestinationRectangleCommand*)arg)->m_x == x - && ((LayerSetDestinationRectangleCommand*)arg)->m_y == y - && ((LayerSetDestinationRectangleCommand*)arg)->m_width == width - && ((LayerSetDestinationRectangleCommand*)arg)->m_height == height; -} - -TEST_F(DBUSCommunicatorTest, SetlayerDestinationRegion) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetDestinationRectangleCommandEq(36u,1u,2u,3u,4u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerDestinationRegion uint32:36 uint32:1 uint32:2 uint32:3 uint32:4")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetDestinationRectangleCommandEq(44u,15u,25u,35u,45u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerDestinationRegion uint32:44 uint32:15 uint32:25 uint32:35 uint32:45 ")).c_str())); -} - -MATCHER_P5(SurfaceSetDestinationRectangleCommandEq, id, x, y, width, height, "%(*)s") { - return ((SurfaceSetDestinationRectangleCommand*)arg)->m_id == id - && ((SurfaceSetDestinationRectangleCommand*)arg)->m_x == x - && ((SurfaceSetDestinationRectangleCommand*)arg)->m_y == y - && ((SurfaceSetDestinationRectangleCommand*)arg)->m_width == width - && ((SurfaceSetDestinationRectangleCommand*)arg)->m_height == height; -} - -TEST_F(DBUSCommunicatorTest, SetSurfaceDestinationRegion) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetDestinationRectangleCommandEq(36u,1u,2u,3u,4u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceDestinationRegion uint32:36 uint32:1 uint32:2 uint32:3 uint32:4")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetDestinationRectangleCommandEq(44u,15u,25u,35u,45u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceDestinationRegion uint32:44 uint32:15 uint32:25 uint32:35 uint32:45 ")).c_str())); -} - -MATCHER_P3(LayerSetPositionCommandEq, id, x, y, "%(*)s"){ - return ((LayerSetPositionCommand*)arg)->m_id == id - && ((LayerSetPositionCommand*)arg)->m_x == x - && ((LayerSetPositionCommand*)arg)->m_y == y; -} - -TEST_F(DBUSCommunicatorTest, SetlayerPosition) { - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetPositionCommandEq(36u,1u,2u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerPosition uint32:36 uint32:1 uint32:2")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetPositionCommandEq(44u,15u,25u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerPosition uint32:44 uint32:15 uint32:25 ")).c_str())); -} - -MATCHER_P3(SurfaceSetPositionCommandEq, id, x, y, "%(*)s"){ - return ((SurfaceSetPositionCommand*)arg)->m_id == id - && ((SurfaceSetPositionCommand*)arg)->m_x == x - && ((SurfaceSetPositionCommand*)arg)->m_y == y; -} - -TEST_F(DBUSCommunicatorTest, SetSurfacePosition) { - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetPositionCommandEq(36u,3u,4u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacePosition uint32:36 uint32:3 uint32:4")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetPositionCommandEq(44u,35u,45u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacePosition uint32:44 uint32:35 uint32:45 ")).c_str())); -} - -MATCHER_P3(LayerSetDimensionCommandEq, id, width, height, "%(*)s"){ - return ((LayerSetDimensionCommand*)arg)->m_id == id - && ((LayerSetDimensionCommand*)arg)->m_width == width - && ((LayerSetDimensionCommand*)arg)->m_height == height; -} - -TEST_F(DBUSCommunicatorTest, SetlayerDimension) { - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetDimensionCommandEq(8554u,400u,444u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerDimension uint32:8554 uint32:400 uint32:444")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetDimensionCommandEq(34589u,400u,444u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerDimension uint32:34589 uint32:400 uint32:444")).c_str())); -} - -MATCHER_P3(SurfaceSetDimensionCommandEq, id, width, height, "%(*)s"){ - return ((SurfaceSetDimensionCommand*)arg)->m_id == id - && ((SurfaceSetDimensionCommand*)arg)->m_width == width - && ((SurfaceSetDimensionCommand*)arg)->m_height == height; -} - -TEST_F(DBUSCommunicatorTest, SetSurfaceDimension) { - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetDimensionCommandEq(36u,3u,4u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceDimension uint32:36 uint32:3 uint32:4")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetDimensionCommandEq(44u,35u,45u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceDimension uint32:44 uint32:35 uint32:45 ")).c_str())); -} - -MATCHER_P2(LayerSetOpacityCommandEq, id, Opacity, "%(*)s"){ - return ((LayerSetOpacityCommand*)arg)->m_id == id - && ((LayerSetOpacityCommand*)arg)->m_opacity == Opacity; -} - -TEST_F(DBUSCommunicatorTest, SetlayerOpacity) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetOpacityCommandEq(36u,0.88))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerOpacity uint32:36 double:0.88")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetOpacityCommandEq(44u,0.001))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerOpacity uint32:44 double:0.001")).c_str())); -} - -MATCHER_P(LayerGetOpacityCommandEq, id, "%(*)s"){ - return ((LayerGetOpacityCommand*)arg)->m_id == id; -} - -TEST_F(DBUSCommunicatorTest, GetlayerOpacity) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerGetOpacityCommandEq(36u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerOpacity uint32:36")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerGetOpacityCommandEq(44u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerOpacity uint32:44 ")).c_str())); -} - -MATCHER_P2(SurfacegroupSetOpacityCommandEq, id, Opacity, "%(*)s") { - return ((SurfacegroupSetOpacityCommand*)arg)->m_id == id - && ((SurfacegroupSetOpacityCommand*)arg)->m_opacity == Opacity; -} - -TEST_F(DBUSCommunicatorTest, SetSurfacegroupOpacity) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupSetOpacityCommandEq(36u,0.88))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacegroupOpacity uint32:36 double:0.88")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupSetOpacityCommandEq(44u,0.001))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacegroupOpacity uint32:44 double:0.001")).c_str())); -} - -MATCHER_P2(LayergroupSetOpacityCommandEq, id, Opacity, "%(*)s"){ - return ((LayergroupSetOpacityCommand*)arg)->m_id == id - && ((LayergroupSetOpacityCommand*)arg)->m_opacity == Opacity; -} - -TEST_F(DBUSCommunicatorTest, SetlayergroupOpacity) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupSetOpacityCommandEq(36u,0.88))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayergroupOpacity uint32:36 double:0.88")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupSetOpacityCommandEq(44u,0.001))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayergroupOpacity uint32:44 double:0.001")).c_str())); -} - -MATCHER_P2(SurfaceSetOrientationCommandEq, id, Orientation, "%(*)s") { - return ((SurfaceSetOrientationCommand*)arg)->m_id == id - && ((SurfaceSetOrientationCommand*)arg)->m_orientation == Orientation; -} - -TEST_F(DBUSCommunicatorTest, SetSurfaceOrientation) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetOrientationCommandEq(36u,0))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceOrientation uint32:36 uint32:0")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetOrientationCommandEq(44u,1))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceOrientation uint32:44 uint32:1")).c_str())); -} - -MATCHER_P2(LayerSetOrientationCommandEq, id, Orientation, "%(*)s") { - return ((LayerSetOrientationCommand*)arg)->m_id == id - && ((LayerSetOrientationCommand*)arg)->m_orientation == Orientation; -} - -TEST_F(DBUSCommunicatorTest, SetlayerOrientation) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetOrientationCommandEq(36u,0))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerOrientation uint32:36 uint32:0")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetOrientationCommandEq(44u,1))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerOrientation uint32:44 uint32:1")).c_str())); -} - -MATCHER_P2(SurfaceSetVisibilityCommandEq, id, visibility, "%(*)s"){ - return ((SurfaceSetVisibilityCommand*)arg)->m_idtoSet == id - && ((SurfaceSetVisibilityCommand*)arg)->m_visibility == visibility; -} - -TEST_F(DBUSCommunicatorTest, SetSurfaceVisibility) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceVisibility uint32:44 boolean:true")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfaceVisibility uint32:44 boolean:true")).c_str())); -} - -MATCHER_P2(LayerSetVisibilityCommandEq, id, visibility, "%(*)s"){ - return ((LayerSetVisibilityCommand*)arg)->m_idtoSet == id - && ((LayerSetVisibilityCommand*)arg)->m_visibility == visibility; -} - -TEST_F(DBUSCommunicatorTest, SetlayerVisibility) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerVisibility uint32:44 boolean:true")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayerVisibility uint32:44 boolean:true")).c_str())); -} - -MATCHER_P2(SurfacegroupSetVisibilityCommandEq, id, visibility, "%(*)s"){ - return ((SurfacegroupSetVisibilityCommand*)arg)->m_idtoSet == id - && ((SurfacegroupSetVisibilityCommand*)arg)->m_visibility == visibility; -} - -TEST_F(DBUSCommunicatorTest, SetSurfacegroupVisibility) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacegroupVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacegroupVisibility uint32:44 boolean:true")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacegroupVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetSurfacegroupVisibility uint32:44 boolean:true")).c_str())); - -} - -MATCHER_P2(LayergroupSetVisibilityCommandEq, id, visibility, "%(*)s"){ - return ((LayergroupSetVisibilityCommand*)arg)->m_idtoSet == id - && ((LayergroupSetVisibilityCommand*)arg)->m_visibility == visibility; -} - -TEST_F(DBUSCommunicatorTest, SetlayergroupVisibility) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayergroupVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayergroupVisibility uint32:44 boolean:true")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupSetVisibilityCommandEq(36u,false))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayergroupVisibility uint32:36 boolean:false")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupSetVisibilityCommandEq(44u,true))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetLayergroupVisibility uint32:44 boolean:true")).c_str())); -} - -MATCHER_P2(SurfacegroupAddSurfaceCommandEq, surfaceid, surfacegroupid, "%(*)s"){ - return ((SurfacegroupAddSurfaceCommand*)arg)->m_surfacegroupid == surfacegroupid - && ((SurfacegroupAddSurfaceCommand*)arg)->m_surfaceid == surfaceid; - -} -TEST_F(DBUSCommunicatorTest, AddSurfaceToSurfaceGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfacegroupAddSurfaceCommandEq(36u,77u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("AddSurfaceToSurfaceGroup uint32:36 uint32:77")).c_str())); -} - -MATCHER_P2(SurfacegroupRemoveSurfaceCommandEq, surfacegroupid, surfaceid, "%(*)s"){ - return ((SurfacegroupRemoveSurfaceCommand*)arg)->m_surfacegroupid == surfacegroupid - && ((SurfacegroupRemoveSurfaceCommand*)arg)->m_surfaceid == surfaceid; -} - -TEST_F(DBUSCommunicatorTest, RemoveSurfaceFromSurfaceGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute( SurfacegroupAddSurfaceCommandEq(36u,77u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveSurfaceFromSurfaceGroup uint32:36 uint32:77")).c_str())); -} - -MATCHER_P2(LayergroupAddLayerCommandEq, layerid, layergroupid, "%(*)s"){ - return ((LayergroupAddLayerCommand*)arg)->m_layergroupid == layergroupid - && ((LayergroupAddLayerCommand*)arg)->m_layerid == layerid; -} - -TEST_F(DBUSCommunicatorTest, AddlayerTolayerGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute( LayergroupAddLayerCommandEq(36u,77u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("AddLayerToLayerGroup uint32:36 uint32:77")).c_str())); -} - -MATCHER_P2(LayergroupRemoveLayerCommandEq, layerid,layergroupid, "%(*)s"){ - return ((LayergroupRemoveLayerCommand*)arg)->m_layergroupid == layergroupid - && ((LayergroupRemoveLayerCommand*)arg)->m_layerid == layerid; -} - -TEST_F(DBUSCommunicatorTest, RemovelayerFromlayerGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute( LayergroupRemoveLayerCommandEq(36u,77u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveLayerFromLayerGroup uint32:36 uint32:77")).c_str())); -} - -MATCHER_P2(LayerAddSurfaceCommandEq, surfaceid, layerid, "%(*)s"){ - return ((LayerAddSurfaceCommand*)arg)->m_layerid == layerid - && ((LayerAddSurfaceCommand*)arg)->m_surfaceid == surfaceid; -} - -TEST_F(DBUSCommunicatorTest, AddSurfaceTolayer) { - - EXPECT_CALL(this->mockCommandExecutor, execute( LayerAddSurfaceCommandEq(36u,77u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("AddSurfaceToLayer uint32:36 uint32:77")).c_str())); -} - -MATCHER_P2(LayerRemoveSurfaceCommandEq, surfaceid, layerid, "%(*)s"){ - return ((LayerRemoveSurfaceCommand*)arg)->m_layerid == layerid - && ((LayerRemoveSurfaceCommand*)arg)->m_surfaceid == surfaceid; -} - -TEST_F(DBUSCommunicatorTest, RemoveSurfaceFromlayer) { - - EXPECT_CALL(this->mockCommandExecutor, execute( LayerRemoveSurfaceCommandEq(36u,77u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveSurfaceFromLayer uint32:36 uint32:77")).c_str())); -} - -/* -TEST_F(DBUSCommunicatorTest, CreateSurfaceGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute()).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateSurfaceGroup")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute( CreateCommandEq(0u,0u,0u,TypeSurfaceGroup,PIXELFORMAT_R8))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateSurfaceGroup")).c_str())); -} -*/ - -MATCHER_P(SurfacegroupRemoveCommandEq, idToRemove, "%(*)s") { - return ((SurfacegroupRemoveCommand*)arg)->m_idToRemove == idToRemove; -} - -TEST_F(DBUSCommunicatorTest, RemoveSurfaceGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupRemoveCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveSurfaceGroup uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfacegroupRemoveCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveSurfaceGroup uint32:34589")).c_str())); -} - -/* -TEST_F(DBUSCommunicatorTest, CreatelayerGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute( CreateCommandEq(0u,0u,0u,TypeLayerGroup,PIXELFORMAT_R8))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateLayerGroup")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute( CreateCommandEq(0u,0u,0u,TypeLayerGroup,PIXELFORMAT_R8))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateLayerGroup")).c_str())); -} -*/ - -MATCHER_P(LayergroupRemoveCommandEq, idToRemove, "%(*)s") { - return ((LayergroupRemoveCommand*)arg)->m_idToRemove == idToRemove; -} - -TEST_F(DBUSCommunicatorTest, RemovelayerGroup) { - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupRemoveCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveLayerGroup uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayergroupRemoveCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("RemoveLayerGroup uint32:34589")).c_str())); -} - -MATCHER_P(LayerGetDimensionCommandEq, id, "%(*)s") { - return ((LayerGetDimensionCommand*)arg)->m_id == id; -} - -TEST_F(DBUSCommunicatorTest, GetlayerDimension) { - EXPECT_CALL(this->mockCommandExecutor, execute(LayerGetDimensionCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerDimension uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerGetDimensionCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerDimension uint32:34589")).c_str())); -} - -MATCHER_P(SurfaceGetDimensionCommandEq, id, "%(*)s") { - return ((SurfaceGetDimensionCommand*)arg)->m_id == id; -} - -TEST_F(DBUSCommunicatorTest, GetSurfaceDimension) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetDimensionCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfaceDimension uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetDimensionCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfaceDimension uint32:34589")).c_str())); -} - -MATCHER_P(SurfaceGetPixelformatCommandEq, id, "%(*)s"){ - return ((SurfaceGetPixelformatCommand*)arg)->m_id == id; -} - -TEST_F(DBUSCommunicatorTest, GetSurfacePixelformat) { - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetPixelformatCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfacePixelformat uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetPixelformatCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfacePixelformat uint32:34589")).c_str())); -} - -MATCHER_P(SurfaceGetOpacityCommandEq, id, "%(*)s"){ - return ((SurfaceGetOpacityCommand*)arg)->m_id == id; -} - -TEST_F(DBUSCommunicatorTest, GetSurfaceOpacity) { - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetOpacityCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfaceOpacity uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetOpacityCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfaceOpacity uint32:34589")).c_str())); -} - -MATCHER_P(SurfaceGetVisibilityCommandEq, id, "%(*)s") { - return ((SurfaceGetVisibilityCommand*)arg)->m_id == id; -} - -TEST_F(DBUSCommunicatorTest, GetSurfaceVisibility) { - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetVisibilityCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfaceVisibility uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceGetVisibilityCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetSurfaceVisibility uint32:34589")).c_str())); -} - -MATCHER_P(LayerGetVisibilityCommandEq, id, "%(*)s"){ - return ((LayerGetVisibilityCommand*)arg)->m_id == id; -} - -TEST_F(DBUSCommunicatorTest, GetlayerVisibility) { - EXPECT_CALL(this->mockCommandExecutor, execute(LayerGetVisibilityCommandEq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerVisibility uint32:8554")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(LayerGetVisibilityCommandEq(34589u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerVisibility uint32:34589")).c_str())); -} - -/* -MATCHER_P2(RenderOrderTester,commandtype,list, "") { - LOG_ERROR("in tester",0); - commandtype_type command = (commandtype_type)arg; - testing::internal::ElementsAreArrayMatcher matcher = ElementsAreArray(command->array,3); - std::vector l; - testing::Matcher > > matcher2 = matcher.operator Matcher >(); - bool result = matcher2.Matches(list); - return result; -} - -TEST_F(DBUSCommunicatorTest, SetRenderOrderOflayers) { - -// DBUSClient* client = dbus_helper(); -// if (NULL== client) -// LOG_ERROR("TEST", "client is null"); -// -// std::vector expected; -// expected.push_back(4); -// expected.push_back(47); -// expected.push_back(49); -// SetLayerOrderCommand * p; -// EXPECT_CALL(this->mockCommandExecutor,execute(RenderOrderTester(p,expected))).Times(1); -// uint display = 0; -// client->SetRenderOrderOfLayers(expected,display); - -} - -TEST_F(DBUSCommunicatorTest, SetRenderOrderWithinlayer) { -// DBUSClient* client = dbus_helper(); -// -// std::vector expected; -// expected.push_back(4); -// expected.push_back(47); -// expected.push_back(49); -// SetOrderWithinLayerCommand * p; -// EXPECT_CALL(this->mockCommandExecutor,execute(AllOf( -// RenderOrderTester(p,expected), -// FieldCast(&SetOrderWithinLayerCommand::layerid,55)) -// )).Times(1); -// client->SetSurfaceRenderOrderWithinLayer(55,expected); -} -*/ - -TEST_F(DBUSCommunicatorTest, GetlayerType) { - DefaultValue::Set((Scene*) &layerlist); - EXPECT_CALL(this->layerlist, getLayer(Eq(8554u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerType uint32:8554")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, GetlayertypeCapabilities) { - EXPECT_CALL(this->mockCommandExecutor, getLayerTypeCapabilities(Eq(367))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayertypeCapabilities uint32:367")).c_str())); -} - -TEST_F(DBUSCommunicatorTest, GetlayerCapabilities) { - Scene scene; - DefaultValue::Set((Scene*) &layerlist); - EXPECT_CALL(this->layerlist, getLayer(Eq(367u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("GetLayerCapabilities uint32:367")).c_str())); - -} - -MATCHER_P2(ShaderCreateCommandEq, _vertName,_fragName, "%(*)s") { - return ((ShaderCreateCommand*)arg)->getVertName() == _vertName - && ((ShaderCreateCommand*)arg)->getFragName() == _fragName; -} - -TEST_F(DBUSCommunicatorTest, CreateShader) { - EXPECT_CALL(this->mockCommandExecutor, execute(ShaderCreateCommandEq(std::string("test123.glslv"),std::string("differentshader.glslv")))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateShader string:test123.glslv string:differentshader.glslv")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(ShaderCreateCommandEq(std::string("/usr/lib/shadertest.glslv"),std::string("foobar")))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("CreateShader string:/usr/lib/shadertest.glslv string:foobar")).c_str())); -} - -MATCHER_P(ShaderDestroyCommandEq, id, "%(*)s") { - return ((ShaderDestroyCommand*)arg)->getShaderID() == id; -} - -TEST_F(DBUSCommunicatorTest, DestroyShaderCommand) { - EXPECT_CALL(this->mockCommandExecutor, execute(ShaderDestroyCommandEq(567u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("DestroyShader uint32:567")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(ShaderDestroyCommandEq(185u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("DestroyShader uint32:185")).c_str())); -} - -MATCHER_P2(SurfaceSetShaderCommandEq, id, shaderid, "%(*)s") { - return ((SurfaceSetShaderCommand*)arg)->getID() == id - && ((SurfaceSetShaderCommand*)arg)->getShaderID() == shaderid; -} - -TEST_F(DBUSCommunicatorTest, SetShaderCommand) { - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetShaderCommandEq(987u, 567u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetShader uint32:987 uint32:567")).c_str())); - - EXPECT_CALL(this->mockCommandExecutor, execute(SurfaceSetShaderCommandEq(1u, 998877u))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetShader uint32:1 uint32:998877")).c_str())); -} - -MATCHER_P(ShaderUniformsMatcher,expectedlist,"") { - ShaderSetUniformsCommand* command = (ShaderSetUniformsCommand*)arg; - std::vector uniforms = command->getUniforms(); - - EXPECT_THAT(uniforms,ElementsAreArray(*expectedlist)); - //EXPECT_THAT(uniforms,ElementsAreArray(expectedlist)); - return true; -} - -MATCHER_P(ShaderSetUniformsCommandEq, _shaderid, "%(*)s"){ - return ((ShaderSetUniformsCommand*)arg)->getShaderId() == _shaderid; -} - -TEST_F(DBUSCommunicatorTest, ShaderSetUniformsCommand) { - - std::string expected1[] = { "uRotAngle 1f 1 0", "uRotVector 3f 1 1 0 0" }; - EXPECT_CALL(this->mockCommandExecutor, execute( AllOf(ShaderSetUniformsCommandEq(1u), ShaderUniformsMatcher(&expected1)))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetUniforms uint32:1 array:string:\"uRotAngle 1f 1 0\",\"uRotVector 3f 1 1 0 0\"")).c_str())); - - std::string expected2[] = { "teststring foobar" }; - EXPECT_CALL(this->mockCommandExecutor, execute(AllOf(ShaderSetUniformsCommandEq(17346u), ShaderUniformsMatcher(&expected2)))).Times(1); - ASSERT_NE(-1, system((DBUSCOMMAND + std::string("SetUniforms uint32:17346 array:string:\"teststring foobar\"")).c_str())); -} - -#endif /* DBUSCommunicatorTest_H_ */ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_CommandExecutor.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_CommandExecutor.h deleted file mode 100644 index a666bdd..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_CommandExecutor.h +++ /dev/null @@ -1,60 +0,0 @@ -/*************************************************************************** -* -* Copyright 2010,2011 BMW Car IT GmbH -* -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -****************************************************************************/ - -#ifndef MockCommandExecutor_H_ -#define MockCommandExecutor_H_ - -#include "GraphicalSurface.h" -#include "ICommand.h" -#include "ICommandExecutor.h" -#include -#include // Brings in Google Mock. -using ::testing::DefaultValue; -class MockCommandExecutor : public ICommandExecutor { - public: - MOCK_METHOD1(execute, bool(ICommand* commandToBeExecuted)); - - MOCK_METHOD3(startManagement, bool(const int width, const int height, const char* displayName)); - MOCK_METHOD0(stopManagement, bool()); - - MOCK_METHOD0(getScene, Scene*()); - - MOCK_METHOD0(getRendererList, RendererList*()); - MOCK_METHOD1(addRenderer, void(IRenderer* renderer)); - MOCK_METHOD1(removeRenderer, void(IRenderer* renderer)); - - MOCK_METHOD0(getCommunicatorList, CommunicatorList*()); - MOCK_METHOD1(addCommunicator, void(ICommunicator* renderer)); - MOCK_METHOD1(removeCommunicator, void(ICommunicator* renderer)); - - MOCK_METHOD0(getSceneProviderList, SceneProviderList*()); - MOCK_METHOD1(addSceneProvider, void(ISceneProvider* provider)); - MOCK_METHOD1(removeSceneProvider, void(ISceneProvider* provider)); - - MOCK_METHOD0(getApplicationReferenceMap, ApplicationReferenceMap*()); - MOCK_METHOD1(addApplicationReference, void(IApplicationReference* reference)); - MOCK_METHOD1(removeApplicationReference, void(IApplicationReference* reference)); - - MOCK_CONST_METHOD1(getLayerTypeCapabilities, uint(LayerType)); - MOCK_CONST_METHOD1(getNumberOfHardwareLayers, uint(uint)); - MOCK_CONST_METHOD1(getScreenResolution, uint*(uint)); - MOCK_CONST_METHOD1(getScreenIDs, uint*(uint*)); -}; - -#endif /* MockCommandExecutor_H_ */ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Communicator.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Communicator.h deleted file mode 100644 index 4fffdb9..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Communicator.h +++ /dev/null @@ -1,35 +0,0 @@ -/*************************************************************************** -* -* Copyright 2010,2011 BMW Car IT GmbH -* -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -****************************************************************************/ - -#ifndef MockCommunicator_H_ -#define MockCommunicator_H_ - -#include "AbstractCommunicator.h" -#include -#include // Brings in Google Mock. -class MockCommunicator : public AbstractCommunicator { - public: - MockCommunicator(ICommandExecutor* executor, Scene* pScene) : AbstractCommunicator(executor,pScene){}; - MOCK_METHOD0(start, bool()); - MOCK_METHOD0(stop, void()); - MOCK_METHOD1(setdebug, void(bool onoff)); - -}; - -#endif /* MockCommunicator_H_ */ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Layerlist.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Layerlist.h deleted file mode 100644 index b1e8193..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Layerlist.h +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** -* -* Copyright 2010,2011 BMW Car IT GmbH -* -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -****************************************************************************/ - -#ifndef MockLayerList_H_ -#define MockLayerList_H_ - -#include -#include // Brings in Google Mock. -class MockLayerList : public Scene { - public: - MOCK_METHOD1(createLayer, Layer*(unsigned int)); - MOCK_METHOD1(createSurface, Surface*(unsigned int)); - MOCK_METHOD1(createLayerGroup, LayerGroup*(unsigned int)); - MOCK_METHOD1(createSurfaceGroup, SurfaceGroup*(unsigned int)); - MOCK_METHOD1(removeLayer, bool(Layer*)); - MOCK_METHOD1(removeSurface, bool(Surface*)); - MOCK_CONST_METHOD1(getLayer, Layer*(unsigned int)); - MOCK_CONST_METHOD1(getSurface, Surface*(unsigned int)); - MOCK_CONST_METHOD1(getSurfaceGroup, SurfaceGroup*(unsigned int)); - MOCK_CONST_METHOD1(getLayerGroup, LayerGroup*(unsigned int id)); - MOCK_CONST_METHOD2(getLayerIDs, void(unsigned int*,unsigned int**)); - MOCK_CONST_METHOD3(getLayerIDsOfScreen, bool(unsigned int,unsigned int*,unsigned int**)); - MOCK_CONST_METHOD2(getSurfaceIDs, void(unsigned int*,unsigned int**)); - MOCK_CONST_METHOD2(getLayerGroupIDs, void(unsigned int*,unsigned int**)); - MOCK_CONST_METHOD2(getSurfaceGroupIDs, void(unsigned int*,unsigned int**)); - MOCK_METHOD0(lockScene, void()); - MOCK_METHOD0(unlockScene, void()); - - -}; - -#endif /* MockLayerList_H_ */ diff --git a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Renderer.h b/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Renderer.h deleted file mode 100644 index ef33d73..0000000 --- a/LayerManagerPlugins/Communicators/DBUSCommunicator/test/mock_Renderer.h +++ /dev/null @@ -1,36 +0,0 @@ -/*************************************************************************** -* -* Copyright 2010,2011 BMW Car IT GmbH -* -* -* Licensed under the Apache License, Version 2.0 (the "License"); -* you may not use this file except in compliance with the License. -* You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -* -****************************************************************************/ - -#ifndef MockRenderer_H_ -#define MockRenderer_H_ - -#include "AbstractRenderer.h" -#include -#include // Brings in Google Mock. -class MockRenderer : public AbstractRenderer { - public: - MockRenderer() : AbstractRenderer(NULL){}; - MOCK_METHOD3(start, bool(int, int, const char* )); - MOCK_METHOD0(stop, void()); - MOCK_METHOD1(setdebug, void(bool onoff)); - MOCK_METHOD1(getLayerTypeCapabilities, uint(LayerType)); -}; - - -#endif /* MockRenderer_H_ */ diff --git a/distfiles b/distfiles index fdc0956..b964505 100644 --- a/distfiles +++ b/distfiles @@ -4,7 +4,6 @@ LayerManagerExamples/.* LayerManagerUtils/.* LayerManagerCommands/.* LayerManagerService/.* -LayerManagerPlugins/Communicators/DBUSCommunicator/.* LayerManagerPlugins/Communicators/GenericCommunicator/.* LayerManagerPlugins/Renderers/.* LayerManagerPlugins/IpcModules/.* -- 2.7.4