From 9826492b0066d47cfa9ba68d6efe737cc3c317a3 Mon Sep 17 00:00:00 2001 From: Christian Mueller Date: Fri, 5 Aug 2011 10:51:38 +0200 Subject: [PATCH] update on dbus --- AudioManagerDaemon/CommandHandler.cpp | 2 +- AudioManagerDaemon/commandInterface.h | 2 +- AudioManagerDaemon/main.cpp | 4 +- PluginCommandInterfaceDbus/CMakeLists.txt | 1 - PluginCommandInterfaceDbus/CommandDbusReceive.cpp | 83 ++---- PluginCommandInterfaceDbus/CommandDbusReceive.h | 11 +- PluginCommandInterfaceDbus/DBUSMessageHandler.cpp | 290 ++++++++++++++---- PluginCommandInterfaceDbus/DBUSMessageHandler.h | 69 ++++- PluginCommandInterfaceDbus/DBUSTypes.h | 39 --- PluginCommandInterfaceDbus/DbusInterface.cpp | 8 +- PluginCommandInterfaceDbus/DbusInterface.h | 5 +- PluginCommandInterfaceDbus/headers.h | 10 +- .../AudiomanagerInterface.cpp | 29 +- PluginRoutingInterfaceDbus/AudiomanagerInterface.h | 1 - PluginRoutingInterfaceDbus/CMakeLists.txt | 1 - PluginRoutingInterfaceDbus/DBUSIntrospection.cpp | 208 ------------- PluginRoutingInterfaceDbus/DBUSIntrospection.h | 66 ----- PluginRoutingInterfaceDbus/DBUSMessageHandler.cpp | 324 +++++++++++++++++++-- PluginRoutingInterfaceDbus/DBUSMessageHandler.h | 78 +++-- PluginRoutingInterfaceDbus/DBUSTypes.h | 41 --- PluginRoutingInterfaceDbus/headers.h | 2 - 21 files changed, 717 insertions(+), 557 deletions(-) delete mode 100644 PluginCommandInterfaceDbus/DBUSTypes.h delete mode 100644 PluginRoutingInterfaceDbus/DBUSIntrospection.cpp delete mode 100644 PluginRoutingInterfaceDbus/DBUSIntrospection.h delete mode 100644 PluginRoutingInterfaceDbus/DBUSTypes.h diff --git a/AudioManagerDaemon/CommandHandler.cpp b/AudioManagerDaemon/CommandHandler.cpp index 96cf8ed..7a7719f 100644 --- a/AudioManagerDaemon/CommandHandler.cpp +++ b/AudioManagerDaemon/CommandHandler.cpp @@ -60,7 +60,7 @@ void CommandHandler::loadPlugins(){ } - CommandPlugin->startupInterface(m_receiver); + CommandPlugin->startupInterface(m_receiver,m_core->returnDbusHandler()); DLT_LOG( AudioManager, DLT_LOG_INFO, DLT_STRING("Registered Routing Plugin")); m_interfaceList.push_back(CommandPlugin); } diff --git a/AudioManagerDaemon/commandInterface.h b/AudioManagerDaemon/commandInterface.h index daef4ca..f95d207 100644 --- a/AudioManagerDaemon/commandInterface.h +++ b/AudioManagerDaemon/commandInterface.h @@ -55,7 +55,7 @@ public: class CommandSendInterface { public: - virtual void startupInterface(CommandReceiveInterface * action)=0; + virtual void startupInterface(CommandReceiveInterface * action, dbusRoothandler* dbushandler)=0; virtual void stop()=0; /** * Callback that is called when the number of connections change diff --git a/AudioManagerDaemon/main.cpp b/AudioManagerDaemon/main.cpp index ea6d5f5..2531e15 100644 --- a/AudioManagerDaemon/main.cpp +++ b/AudioManagerDaemon/main.cpp @@ -61,7 +61,7 @@ int main(int argc, char *argv[]) { core.registerHookEngine(&hookhandler); core.registerReceiver(&breceiver); core.registerDbusRootHandler(&dbushandler); - //core.registerCommandInterfa email whenever you are availce(&commandIface); +// core.registerCommandInterface(&commandIface); router.registerDatabasehandler(&dhandler); //commandIface.registerDatabasehandler(&dhandler); @@ -91,7 +91,7 @@ int main(int argc, char *argv[]) { DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("load bus plugins")); bushandler.load_Bus_plugins(); bushandler.StartupInterfaces(); -// chandler.loadPlugins(); + chandler.loadPlugins(); DLT_LOG(AudioManager,DLT_LOG_INFO, DLT_STRING("Init phase is over, everything up and running")); DBusConnection* con=dbushandler.returnConnection(); diff --git a/PluginCommandInterfaceDbus/CMakeLists.txt b/PluginCommandInterfaceDbus/CMakeLists.txt index a1d7209..62d4dc1 100644 --- a/PluginCommandInterfaceDbus/CMakeLists.txt +++ b/PluginCommandInterfaceDbus/CMakeLists.txt @@ -37,7 +37,6 @@ INCLUDE_DIRECTORIES( SET(PLUGINDBUS_SRCS_CXX CommandDbusReceive.cpp DbusInterface.cpp - DBUSIntrospection.cpp DBUSMessageHandler.cpp DbusSend.cpp ) diff --git a/PluginCommandInterfaceDbus/CommandDbusReceive.cpp b/PluginCommandInterfaceDbus/CommandDbusReceive.cpp index 4269bbe..e4d4bbb 100644 --- a/PluginCommandInterfaceDbus/CommandDbusReceive.cpp +++ b/PluginCommandInterfaceDbus/CommandDbusReceive.cpp @@ -43,9 +43,9 @@ static MethodTable manager_methods[] = { { "connect", "uu", "u", &CommandDbusReceive::connect }, { "disconnect", "uu", "u", &CommandDbusReceive::disconnect }, - { "getListConnections", "", "a{ii}", &CommandDbusReceive::getListConnections }, - { "getListSinks", "", "a{si}", &CommandDbusReceive::getListSinks }, - { "getListSources", "", "a{si}", &CommandDbusReceive::getListSources }, + { "getListConnections", "", "a(ii)", &CommandDbusReceive::getListConnections }, + { "getListSinks", "", "a(si)", &CommandDbusReceive::getListSinks }, + { "getListSources", "", "a(si)", &CommandDbusReceive::getListSources }, { "interruptRequest", "ss", "u", &CommandDbusReceive::interruptRequest }, { "interruptResume", "s", "u", &CommandDbusReceive::interruptResume }, { "setVolume", "ss", "u", &CommandDbusReceive::setVolume }, @@ -59,25 +59,24 @@ static SignalTable manager_signals[] = { { "", ""} }; +static DBusObjectPathVTable vtable = +{ + NULL,CommandDbusReceive::receive_callback,NULL, NULL, NULL, NULL +}; + + -CommandDbusReceive::CommandDbusReceive(CommandReceiveInterface* r_interface): m_audioman(r_interface),m_running(false) { +CommandDbusReceive::CommandDbusReceive(CommandReceiveInterface* r_interface, dbusRoothandler* roothandler): m_audioman(r_interface),m_Introspection(new DBUSIntrospection(manager_methods, manager_signals,std::string(MY_NODE))),m_roothandler(roothandler) { } bool CommandDbusReceive::startup_interface() { DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("Starting up dbus connector")); - - g_pDbusMessage = new DBUSMessageHandler(); - DLT_LOG(DBusCommandPlugin,DLT_LOG_INFO, DLT_STRING("create thread")); - this->m_running = true; - pthread_create(&m_currentThread, NULL, CommandDbusReceive::run, this); - DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("Started dbus connector")); + g_pDbusMessage = new DBUSMessageHandler(&vtable,m_roothandler->returnConnection(),this); return true; } void CommandDbusReceive::stop() { DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("Stopped dbus communication")); - this->m_running = false; - pthread_join(m_currentThread, NULL); delete g_pDbusMessage; } @@ -175,52 +174,34 @@ void CommandDbusReceive::emitSignalNumberofSourcesChanged() { } DBusHandlerResult CommandDbusReceive::receive_callback (DBusConnection *conn,DBusMessage *msg,void *user_data) { - (void) user_data; + m_reference=(CommandDbusReceive*) user_data; DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("message received")); - const char *member = dbus_message_get_member(msg); - const char *iface = dbus_message_get_interface(msg); - bool found=false; - int i = 0; + string nodeString =std::string(DBUS_SERVICE_ROOT)+"/"+std::string(MY_NODE); if (dbus_message_is_method_call(msg, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) { - DBUSIntrospection introspectionString(manager_methods,manager_signals); - introspectionString.process(conn, msg); 'a' - g_pDbusMessage->setConnection(conn); - dbus_connection_pop_message(conn); + m_reference->m_Introspection->process(conn,msg); return DBUS_HANDLER_RESULT_HANDLED; - } else if (strcmp(DBUS_SERVICE_PREFIX,iface)==0) { - - while (!found && strcmp(manager_methods[i].name, "") != 0) { - if (strcmp(manager_methods[i].name, member) == 0) - { - MethodTable entry = manager_methods[i]; - DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("got call for method:"),DLT_STRING(entry.name)); - CallBackMethod m = entry.function; - (m_reference->*m)(conn, msg); - found = true; - } - i++; + } + + bool found=false; + int i = 0; + + const char *n = dbus_message_get_member(msg); + DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("got call for method:"),DLT_STRING(n)); + while (!found && strcmp(manager_methods[i].name, "") != 0) { + if (dbus_message_is_method_call(msg,DBUS_SERVICE_SERVICE,manager_methods[i].name)) { + MethodTable entry = manager_methods[i]; + DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("got call for method:"),DLT_STRING(entry.name)); + CallBackMethod m = entry.function; + (m_reference->*m)(conn, msg); + found=true; + return DBUS_HANDLER_RESULT_HANDLED; } - return DBUS_HANDLER_RESULT_HANDLED; - } else { - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + i++; } -} -void* CommandDbusReceive::run(void * arg) -{ - DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("Main loop running")); - m_reference = (CommandDbusReceive*) arg; - DBusConnection* conn = g_pDbusMessage->getConnection(); - if (!dbus_connection_add_filter(conn, (DBusHandleMessageFunction)&m_reference->receive_callback, NULL,NULL)) { - DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("failing filter thread")); - } - while (m_reference->m_running && dbus_connection_read_write_dispatch(conn, -1)) - { - DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("Dispatching Most message...")); - } - - DLT_LOG(DBusCommandPlugin, DLT_LOG_INFO, DLT_STRING("Stopping thread")); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } + diff --git a/PluginCommandInterfaceDbus/CommandDbusReceive.h b/PluginCommandInterfaceDbus/CommandDbusReceive.h index f8daa7e..72b43b7 100644 --- a/PluginCommandInterfaceDbus/CommandDbusReceive.h +++ b/PluginCommandInterfaceDbus/CommandDbusReceive.h @@ -27,15 +27,17 @@ #include "headers.h" +class DBUSIntrospection; + class CommandDbusReceive { public: - CommandDbusReceive(CommandReceiveInterface* r_interface); + CommandDbusReceive(CommandReceiveInterface* r_interface, dbusRoothandler* roothandler); bool startup_interface(); void stop(); + static DBusHandlerResult receive_callback (DBusConnection *,DBusMessage *,void *); - static DBusHandlerResult receive_callback (DBusConnection *connection,DBusMessage *message,void *user_data); void connect(DBusConnection* conn, DBusMessage* msg); void disconnect(DBusConnection* conn, DBusMessage* msg); void getListConnections(DBusConnection* conn, DBusMessage* msg); @@ -50,11 +52,10 @@ public: void emitSignalNumberofSourcesChanged(); private: - static void* run(void * threadid); - pthread_t m_currentThread; static CommandDbusReceive* m_reference; CommandReceiveInterface* m_audioman; - bool m_running; + DBUSIntrospection* m_Introspection; + dbusRoothandler* m_roothandler; }; #endif /* DBUSINTERFACE_H_ */ diff --git a/PluginCommandInterfaceDbus/DBUSMessageHandler.cpp b/PluginCommandInterfaceDbus/DBUSMessageHandler.cpp index a796f28..7c4f39a 100644 --- a/PluginCommandInterfaceDbus/DBUSMessageHandler.cpp +++ b/PluginCommandInterfaceDbus/DBUSMessageHandler.cpp @@ -3,37 +3,19 @@ #include "headers.h" #include -DBUSMessageHandler::DBUSMessageHandler() +DBUSMessageHandler::DBUSMessageHandler(DBusObjectPathVTable* vtable, DBusConnection* conn, void* reference) : m_MessageIter() , m_pReply(0) , m_serial(0) -, m_pConnection(0) +, m_pConnection(conn) { dbus_error_init(&m_err); - // connect to the bus and check for errors - m_pConnection = dbus_bus_get(DBUS_BUS_SESSION, &m_err); - if (dbus_error_is_set(&m_err)) - { - DLT_LOG(DBusCommandPlugin,DLT_LOG_INFO, DLT_STRING("DBUSCommunicator Connection error")); - dbus_error_free(&m_err); - } - if (NULL == m_pConnection) - { - DLT_LOG(DBusCommandPlugin,DLT_LOG_INFO, DLT_STRING("DBUSCommunicator 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)) - { - DLT_LOG(DBusCommandPlugin,DLT_LOG_INFO, DLT_STRING("DBUSCommunicator Name Error"),DLT_STRING(m_err.message)); - dbus_error_free(&m_err); - } - if (DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER != ret) - { - DLT_LOG(DBusCommandPlugin,DLT_LOG_INFO, DLT_STRING("DBUSCommunicatorNot Primary Owner"), DLT_INT(ret)); - exit(1); - } + string nodeString =std::string(DBUS_SERVICE_ROOT)+"/"+std::string(MY_NODE); + dbus_bool_t b=dbus_connection_register_object_path(m_pConnection, nodeString.c_str(), vtable, reference); + if(!b) { + DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("Registering of node"), DLT_STRING(MY_NODE),DLT_STRING("failed")); + } } DBUSMessageHandler::~DBUSMessageHandler() @@ -43,23 +25,23 @@ DBUSMessageHandler::~DBUSMessageHandler() bool errorset = dbus_error_is_set(&err); if (errorset) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); } - dbus_bus_name_has_owner(m_pConnection, DBUS_SERVICE_PREFIX, &err); + dbus_bus_name_has_owner(m_pConnection, DBUS_SERVICE_SERVICE, &err); errorset = dbus_error_is_set(&err); if (errorset) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); } dbus_error_init(&err); - dbus_bus_release_name(m_pConnection, DBUS_SERVICE_PREFIX, &err); + dbus_bus_release_name(m_pConnection, DBUS_SERVICE_SERVICE, &err); } void DBUSMessageHandler::initReceive(DBusMessage* msg) { if (!dbus_message_iter_init(msg, &m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS Message has no arguments!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS Message has no arguments!")); } } @@ -75,10 +57,10 @@ void DBUSMessageHandler::closeReply() // send the reply && flush the connection if (!dbus_connection_send(m_pConnection, m_pReply, &m_serial)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply!")); dbus_connection_flush(m_pConnection); // free the reply @@ -92,10 +74,10 @@ void DBUSMessageHandler::ReplyError(DBusMessage* msg, const char* errorname, con // send the reply && flush the connection if (!dbus_connection_send(m_pConnection, m_pReply, &m_serial)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply with error!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply with error!")); dbus_connection_flush(m_pConnection); // free the reply @@ -105,9 +87,10 @@ void DBUSMessageHandler::ReplyError(DBusMessage* msg, const char* errorname, con char* DBUSMessageHandler::getString() { char* param; + if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); } else { @@ -123,7 +106,7 @@ dbus_bool_t DBUSMessageHandler::getBool() if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no bool!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no bool!")); } else { @@ -139,7 +122,7 @@ char DBUSMessageHandler::getByte() if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no byte!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no byte!")); } else { @@ -155,7 +138,7 @@ dbus_uint32_t DBUSMessageHandler::getUInt() if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no uint32_t!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no uint32_t!")); } else { @@ -171,7 +154,7 @@ double DBUSMessageHandler::getDouble() if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no double!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no double!")); } else { @@ -185,7 +168,7 @@ void DBUSMessageHandler::getArrayOfUInt(int* pLength, unsigned int** ppArray) { if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); return; } @@ -206,7 +189,7 @@ void DBUSMessageHandler::getArrayOfString(std::vector* stringVector { if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); return; } @@ -217,7 +200,7 @@ void DBUSMessageHandler::getArrayOfString(std::vector* stringVector { if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&arrayIter)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); } char* param; dbus_message_iter_get_basic(&arrayIter, ¶m); @@ -240,7 +223,7 @@ void DBUSMessageHandler::append(bool toAppend) dbus_bool_t mybool=toAppend; if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_BOOLEAN, &mybool)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } @@ -249,7 +232,7 @@ void DBUSMessageHandler::append(dbus_uint32_t toAppend) { if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_UINT32, &toAppend)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } @@ -258,7 +241,7 @@ void DBUSMessageHandler::append(double toAppend) { if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_DOUBLE, &toAppend)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } @@ -267,7 +250,7 @@ void DBUSMessageHandler::append(char toAppend) { if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_BYTE, &toAppend)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } @@ -287,16 +270,17 @@ void DBUSMessageHandler::sendSignal(const char* signalname) { dbus_uint32_t serial = 0; DBusMessage* msg; - msg =dbus_message_new_signal(DBUS_SERVICE_PREFIX_PATH,DBUS_SERVICE_PREFIX,signalname); + string nodeString =std::string(DBUS_SERVICE_ROOT)+"/"+std::string(MY_NODE); + msg =dbus_message_new_signal(nodeString.c_str(),DBUS_SERVICE_SERVICE,signalname); if (NULL == msg) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("Message null!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("Message null!")); this->~DBUSMessageHandler(); } if (!dbus_connection_send(m_pConnection, msg, &serial)) { - DLT_LOG(DBusCommandPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); this->~DBUSMessageHandler(); } @@ -354,7 +338,215 @@ void DBUSMessageHandler::append(std::list list){ +DBUSIntrospection::DBUSIntrospection(MethodTable* methodTable, SignalTable* signalTable,std::string nodename) +: m_methodTable(methodTable), m_signalTable(signalTable), m_nodename(nodename) +{ + generateString(); +} + +void DBUSIntrospection::generateString() +{ + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("Generating instrospection data!")); + + addHeader(); + openNode(m_nodename); + openInterface("org.freedesktop.DBus.Introspectable"); + openMethod("Introspect"); + addArgument("data", "out", "s"); + closeMethod(); + closeInterface(); + openInterface(DBUS_SERVICE_SERVICE); + + int index = 0; + + while (strcmp(m_methodTable[index].name, "") != 0) + { + MethodTable entry = m_methodTable[index]; + addEntry(entry); + ++index; + } + + index=0; + if (m_signalTable) { + while (strcmp(m_signalTable[index].name, "") != 0) + { + SignalTable entry = m_signalTable[index]; + addEntry(entry); + ++index; + } + } + closeInterface(); + closeNode(); + +} + +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::openSignal(string signalname) { + m_introspectionString<<" \n"; +} + +void DBUSIntrospection::addArgument(string argname, string direction, string type) +{ + m_introspectionString << " \n"; +} + + +void DBUSIntrospection::addSignalArgument(string argname, 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::closeSignal(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': + if (parameterArray.at(parameterIndex+1)=='(') { + int size=parameterArray.find((')'),parameterIndex); + addArgument("","in",parameterArray.substr(parameterIndex,size+1)); + parameterIndex+=size; + } else { + addArgument("","in", parameterArray.substr(parameterIndex,2)); + parameterIndex+=2; + } + break; + default: + addArgument("","in", parameterArray.substr(parameterIndex,1)); + break; + } + } + + + for(uint returnValueIndex = 0; returnValueIndex < returnValueArray.length(); ++returnValueIndex) + { + switch (returnValueArray.at(returnValueIndex)) + { + case 'a': + if (returnValueArray.at(returnValueIndex+1)=='(') { + int size=returnValueArray.find((')'),returnValueIndex); + addArgument("","out",returnValueArray.substr(returnValueIndex,size+1)); + returnValueIndex+=size; + } else { + addArgument("","out", returnValueArray.substr(returnValueIndex,2)); + returnValueIndex+=2; + } + break; + default: + addArgument("","out", returnValueArray.substr(returnValueIndex,1)); + break; + } + } + + closeMethod(); +} +void DBUSIntrospection::addEntry(SignalTable entry) +{ + string methodName = entry.name; + string parameterArray = entry.signature; + + openSignal(methodName); + + for(uint parameterIndex = 0; parameterIndex < parameterArray.length(); ++parameterIndex) + { + switch (parameterArray.at(parameterIndex)) + { + case 'a': + if (parameterArray.at(parameterIndex+1)=='{') { + int size=parameterArray.find(('}'),parameterIndex); + addSignalArgument("",parameterArray.substr(parameterIndex,size+1)); + parameterIndex+=size; + } else { + parameterIndex++; + addSignalArgument("", "a" + parameterArray.at(parameterIndex)); + } + break; + default: + addSignalArgument("", parameterArray.substr(parameterIndex,1)); + break; + } + } + + closeSignal(); +} + +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)) + { + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + } + + // send the reply && flush the connection + if (!dbus_connection_send(conn, reply, &serial)) + { + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + } + dbus_connection_flush(conn); + + // free the reply + dbus_message_unref(reply); +} diff --git a/PluginCommandInterfaceDbus/DBUSMessageHandler.h b/PluginCommandInterfaceDbus/DBUSMessageHandler.h index 0ec6d3a..819b8f2 100644 --- a/PluginCommandInterfaceDbus/DBUSMessageHandler.h +++ b/PluginCommandInterfaceDbus/DBUSMessageHandler.h @@ -21,24 +21,44 @@ #define _DBUSMESSAGEHANDLER_H_ #include +#include +using std::stringstream; + #include +using std::string; + #include "headers.h" +#include + +#define DLT_CONTEXT DBusCommandPlugin + +typedef void (CommandDbusReceive::*CallBackMethod)(DBusConnection *connection, DBusMessage *message); + +struct MethodTable +{ + const char *name; + const char *signature; + const char *reply; + CallBackMethod function; +}; + +struct SignalTable { + const char* name; + const char* signature; +}; + class DBUSMessageHandler { public: - DBUSMessageHandler(); + DBUSMessageHandler(DBusObjectPathVTable* vtable, DBusConnection* conn, void* reference); ~DBUSMessageHandler(); - void setConnection(DBusConnection* conn); - DBusConnection* getConnection(); - void initReceive(DBusMessage* msg); void initReply(DBusMessage* msg); void closeReply(); void ReplyError(DBusMessage* msg, const char* errorname, const char* errorMsg); - dbus_uint32_t getUInt(); char getByte(); dbus_bool_t getBool(); @@ -66,15 +86,38 @@ private: DBusError m_err; }; - -inline void DBUSMessageHandler::setConnection(DBusConnection* conn) +class DBUSIntrospection { - m_pConnection = conn; -} +public: + DBUSIntrospection(MethodTable* table, SignalTable* stable,std::string nodename); + void process(DBusConnection* conn, DBusMessage* msg); -inline DBusConnection* DBUSMessageHandler::getConnection() -{ - return m_pConnection; -} +private: + void generateString(void); + + void addHeader(void); + void addArgument(string argname, string direction, string type); + void addSignalArgument(string argname, string type); + void addEntry(MethodTable entry); + void addEntry(SignalTable entry); + + void openNode(string nodename); + void closeNode(void); + + void openInterface(string interfacename); + void closeInterface(void); + + void openMethod(string methodname); + void closeMethod(void); + + void openSignal(string signalname); + void closeSignal(void); + +private: + stringstream m_introspectionString; + MethodTable* m_methodTable; + SignalTable* m_signalTable; + std::string m_nodename; +}; #endif // _DBUSMESSAGEWRAPPER_H_ diff --git a/PluginCommandInterfaceDbus/DBUSTypes.h b/PluginCommandInterfaceDbus/DBUSTypes.h deleted file mode 100644 index 0f8474c..0000000 --- a/PluginCommandInterfaceDbus/DBUSTypes.h +++ /dev/null @@ -1,39 +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_ - -#include "headers.h" - -typedef void (CommandDbusReceive::*CallBackMethod)(DBusConnection *connection, DBusMessage *message); - -struct MethodTable -{ - const char *name; - const char *signature; - const char *reply; - CallBackMethod function; -}; - -struct SignalTable { - const char* name; - const char* signature; -}; - -#endif // _DBUSTYPES_H_ diff --git a/PluginCommandInterfaceDbus/DbusInterface.cpp b/PluginCommandInterfaceDbus/DbusInterface.cpp index a83a549..c37ada2 100644 --- a/PluginCommandInterfaceDbus/DbusInterface.cpp +++ b/PluginCommandInterfaceDbus/DbusInterface.cpp @@ -35,7 +35,7 @@ DLT_DECLARE_CONTEXT(DBusCommandPlugin) -DbusCommandInterface::DbusCommandInterface() : m_busname(DBUS_BUSNAME), m_path(DBUS_PATH) { +DbusCommandInterface::DbusCommandInterface() { DLT_REGISTER_APP("DBusCommandPlugin", "DBusCommandPlugin"); DLT_REGISTER_CONTEXT(DBusCommandPlugin, "PluginCommand", "DBusCommandPlugin"); @@ -46,10 +46,12 @@ DbusCommandInterface::~DbusCommandInterface() { delete m_DbusInterface; } -void DbusCommandInterface::startupInterface(CommandReceiveInterface* iface) { +void DbusCommandInterface::startupInterface(CommandReceiveInterface* iface, dbusRoothandler* dbushandler) { m_audioman = iface; - m_DbusInterface = new CommandDbusReceive(iface); + m_rootHandler = dbushandler; + m_DbusInterface = new CommandDbusReceive(iface,dbushandler); m_DbusInterface->startup_interface(); + m_rootHandler->registerNode(MY_NODE); DBusError err; dbus_error_init(&err); diff --git a/PluginCommandInterfaceDbus/DbusInterface.h b/PluginCommandInterfaceDbus/DbusInterface.h index 83a04b8..b4c5a45 100644 --- a/PluginCommandInterfaceDbus/DbusInterface.h +++ b/PluginCommandInterfaceDbus/DbusInterface.h @@ -44,15 +44,14 @@ public: void cbConnectionChanged(); void cbNumberOfSinksChanged(); void cbNumberOfSourcesChanged(); - void startupInterface(CommandReceiveInterface* iface); + void startupInterface(CommandReceiveInterface* iface,dbusRoothandler* dbushandler); void stop(); private: CommandReceiveInterface *m_audioman; CommandDbusReceive* m_DbusInterface; DBusConnection* m_conn; - char* m_busname; - char* m_path; + dbusRoothandler* m_rootHandler; }; diff --git a/PluginCommandInterfaceDbus/headers.h b/PluginCommandInterfaceDbus/headers.h index 062675f..078dfdc 100644 --- a/PluginCommandInterfaceDbus/headers.h +++ b/PluginCommandInterfaceDbus/headers.h @@ -15,17 +15,11 @@ #include "commandInterface.h" #include "DbusSend.h" #include "DBUSMessageHandler.h" -#include "DBUSIntrospection.h" +#include "dbusRoothandler.h" #include "DbusInterface.h" -#include "DBUSTypes.h" -#define BUS_NAME "DBUS" -#define DBUS_BUSNAME "org.genivi.pulse" -#define DBUS_PATH "/pulse" - -const char DBUS_SERVICE_PREFIX[] = "org.bla.audiomanagerCommand\0"; -const char DBUS_SERVICE_PREFIX_PATH[] = "/org/bla/audiomanagerCommand\0"; +const char MY_NODE[]="commandinterface\0"; DLT_IMPORT_CONTEXT(DBusCommandPlugin); diff --git a/PluginRoutingInterfaceDbus/AudiomanagerInterface.cpp b/PluginRoutingInterfaceDbus/AudiomanagerInterface.cpp index bdfbdd4..650486c 100644 --- a/PluginRoutingInterfaceDbus/AudiomanagerInterface.cpp +++ b/PluginRoutingInterfaceDbus/AudiomanagerInterface.cpp @@ -39,12 +39,12 @@ static DBUSMessageHandler* g_pDbusMessage; static MethodTable manager_methods[] = { - { "peekDomain", "s", "u", &AudioManagerInterface::peekDomain }, - { "registerSource", "sss", "u", &AudioManagerInterface::registerSource }, - { "registerSink", "sss", "u", &AudioManagerInterface::registerSink }, - { "registerDomain", "sssb", "u", &AudioManagerInterface::registerDomain }, - { "registerGateway", "sssss", "u", &AudioManagerInterface::registerGateway }, - { "", "", "", NULL } + { "peekDomain", "s", "u", &AudioManagerInterface::peekDomain }, + { "registerSource", "sss", "u", &AudioManagerInterface::registerSource }, + { "registerSink", "sss", "u", &AudioManagerInterface::registerSink }, + { "registerDomain", "sssb", "u", &AudioManagerInterface::registerDomain }, + { "registerGateway", "sssss", "u", &AudioManagerInterface::registerGateway }, + { "", "", "", NULL } }; static SignalTable manager_signals[] = { @@ -52,7 +52,7 @@ static SignalTable manager_signals[] = { { "", ""} }; -static DBusObjectPathVTable _vtable = +static DBusObjectPathVTable vtable = { NULL,AudioManagerInterface::receive_callback,NULL, NULL, NULL, NULL }; @@ -65,14 +65,11 @@ AudioManagerInterface::AudioManagerInterface(RoutingReceiveInterface* r_interfac bool AudioManagerInterface::startup_interface() { DLT_LOG(DBusPlugin, DLT_LOG_INFO, DLT_STRING("Starting up dbus connector")); - - g_pDbusMessage = new DBUSMessageHandler(&_vtable,m_roothandler->returnConnection(),this); - + g_pDbusMessage = new DBUSMessageHandler(&vtable,m_roothandler->returnConnection(),this); return true; } void AudioManagerInterface::stop() - { DLT_LOG(DBusPlugin, DLT_LOG_INFO, DLT_STRING("Stopped dbus connector")); delete g_pDbusMessage; @@ -84,7 +81,7 @@ void AudioManagerInterface::peekDomain(DBusConnection* conn, DBusMessage* msg) { char* name = g_pDbusMessage->getString(); domain_t domain = m_audioman->peekDomain(name); g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(domain); + g_pDbusMessage->append((dbus_uint32_t)domain); g_pDbusMessage->closeReply(); } @@ -96,7 +93,7 @@ void AudioManagerInterface::registerSource(DBusConnection* conn, DBusMessage* ms char* domain = g_pDbusMessage->getString(); source_t source=m_audioman->registerSource(name, audioclass, domain); g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(source); + g_pDbusMessage->append((dbus_uint32_t)source); g_pDbusMessage->closeReply(); } void AudioManagerInterface::registerSink(DBusConnection* conn, DBusMessage* msg) { @@ -107,7 +104,7 @@ void AudioManagerInterface::registerSink(DBusConnection* conn, DBusMessage* msg) char* domain = g_pDbusMessage->getString(); sink_t sink=m_audioman->registerSink(name, audioclass, domain); g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(sink); + g_pDbusMessage->append((dbus_uint32_t)sink); g_pDbusMessage->closeReply(); } @@ -121,7 +118,7 @@ void AudioManagerInterface::registerDomain(DBusConnection* conn, DBusMessage* ms bool earlymode = g_pDbusMessage->getString(); domain_t domain=m_reference->m_audioman->registerDomain(name, busname, node, earlymode); g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(domain); + g_pDbusMessage->append((dbus_uint32_t)domain); g_pDbusMessage->closeReply(); } @@ -136,7 +133,7 @@ void AudioManagerInterface::registerGateway(DBusConnection* conn, DBusMessage* m char* controlDomain = g_pDbusMessage->getString(); domain_t domain=m_audioman->registerGateway(name, sink, source, domainSource, domainSink, controlDomain); g_pDbusMessage->initReply(msg); - g_pDbusMessage->appendUInt(domain); + g_pDbusMessage->append((dbus_uint32_t)domain); g_pDbusMessage->closeReply(); emit_systemReady(); } diff --git a/PluginRoutingInterfaceDbus/AudiomanagerInterface.h b/PluginRoutingInterfaceDbus/AudiomanagerInterface.h index a56975c..3411bd3 100644 --- a/PluginRoutingInterfaceDbus/AudiomanagerInterface.h +++ b/PluginRoutingInterfaceDbus/AudiomanagerInterface.h @@ -26,7 +26,6 @@ #define DBUSINTERFACE_H_ #include "headers.h" -#include "DBUSIntrospection.h" class DBUSIntrospection; diff --git a/PluginRoutingInterfaceDbus/CMakeLists.txt b/PluginRoutingInterfaceDbus/CMakeLists.txt index 4880da1..c9e80ea 100644 --- a/PluginRoutingInterfaceDbus/CMakeLists.txt +++ b/PluginRoutingInterfaceDbus/CMakeLists.txt @@ -37,7 +37,6 @@ INCLUDE_DIRECTORIES( SET(PLUGINDBUS_SRCS_CXX AudiomanagerInterface.cpp DbusInterface.cpp - DBUSIntrospection.cpp DBUSMessageHandler.cpp DbusSend.cpp ) diff --git a/PluginRoutingInterfaceDbus/DBUSIntrospection.cpp b/PluginRoutingInterfaceDbus/DBUSIntrospection.cpp deleted file mode 100644 index 20d682a..0000000 --- a/PluginRoutingInterfaceDbus/DBUSIntrospection.cpp +++ /dev/null @@ -1,208 +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 -#include - -DLT_IMPORT_CONTEXT(DBusCommandPlugin); - -using std::stringstream; - - -DBUSIntrospection::DBUSIntrospection(MethodTable* methodTable, SignalTable* signalTable,std::string nodename) -: m_methodTable(methodTable), m_signalTable(signalTable), m_nodename(nodename) -{ - generateString(); -} - -void DBUSIntrospection::generateString() -{ - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("Generating instrospection data!")); - - addHeader(); - openNode(m_nodename); - openInterface("org.freedesktop.DBus.Introspectable"); - openMethod("Introspect"); - addArgument("data", "out", "s"); - closeMethod(); - closeInterface(); - openInterface(DBUS_SERVICE_SERVICE); - - int index = 0; - - while (strcmp(m_methodTable[index].name, "") != 0) - { - MethodTable entry = m_methodTable[index]; - addEntry(entry); - ++index; - } - - index=0; - if (m_signalTable) { - while (strcmp(m_signalTable[index].name, "") != 0) - { - SignalTable entry = m_signalTable[index]; - addEntry(entry); - ++index; - } - } - closeInterface(); - closeNode(); - -} - -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::addSignal(string signalname) { - 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.at(parameterIndex)); - break; - default: - addArgument("param", "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.at(returnValueIndex)); - break; - default: - addArgument("param", "out", returnValueArray.substr(returnValueIndex,1)); - break; - } - } - - closeMethod(); -} - -void DBUSIntrospection::addEntry(SignalTable entry) -{ - string methodName = entry.name; - string parameterArray = entry.signature; - - addSignal(methodName); - - for(uint parameterIndex = 0; parameterIndex < parameterArray.length(); ++parameterIndex) - { - switch (parameterArray.at(parameterIndex)) - { - case 'a': - parameterIndex++; - addArgument("", "in", "a" + parameterArray.at(parameterIndex)); - break; - default: - addArgument("param", "in", parameterArray.substr(parameterIndex,1)); - break; - } - } -} - -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)) - { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); - } - - // send the reply && flush the connection - if (!dbus_connection_send(conn, reply, &serial)) - { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); - } - dbus_connection_flush(conn); - - // free the reply - dbus_message_unref(reply); -} - diff --git a/PluginRoutingInterfaceDbus/DBUSIntrospection.h b/PluginRoutingInterfaceDbus/DBUSIntrospection.h deleted file mode 100644 index 64636dd..0000000 --- a/PluginRoutingInterfaceDbus/DBUSIntrospection.h +++ /dev/null @@ -1,66 +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" -#include - -class DBUSIntrospection -{ -public: - DBUSIntrospection(MethodTable* table, SignalTable* stable,std::string nodename); - 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 addEntry(SignalTable entry); - - void openNode(string nodename); - void closeNode(void); - - void openInterface(string interfacename); - void closeInterface(void); - - void openMethod(string methodname); - void closeMethod(void); - - void addSignal(string signalname); - - -private: - stringstream m_introspectionString; - MethodTable* m_methodTable; - SignalTable* m_signalTable; - std::string m_nodename; -}; - - -#endif // _DBUSINTROSPECTION_H_ diff --git a/PluginRoutingInterfaceDbus/DBUSMessageHandler.cpp b/PluginRoutingInterfaceDbus/DBUSMessageHandler.cpp index 51d69dc..7c4f39a 100644 --- a/PluginRoutingInterfaceDbus/DBUSMessageHandler.cpp +++ b/PluginRoutingInterfaceDbus/DBUSMessageHandler.cpp @@ -14,7 +14,7 @@ DBUSMessageHandler::DBUSMessageHandler(DBusObjectPathVTable* vtable, DBusConnect string nodeString =std::string(DBUS_SERVICE_ROOT)+"/"+std::string(MY_NODE); dbus_bool_t b=dbus_connection_register_object_path(m_pConnection, nodeString.c_str(), vtable, reference); if(!b) { - DLT_LOG(DBusPlugin, DLT_LOG_INFO, DLT_STRING("Registering of node"), DLT_STRING(MY_NODE),DLT_STRING("failed")); + DLT_LOG(DLT_CONTEXT, DLT_LOG_INFO, DLT_STRING("Registering of node"), DLT_STRING(MY_NODE),DLT_STRING("failed")); } } @@ -25,13 +25,13 @@ DBUSMessageHandler::~DBUSMessageHandler() bool errorset = dbus_error_is_set(&err); if (errorset) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); } dbus_bus_name_has_owner(m_pConnection, DBUS_SERVICE_SERVICE, &err); errorset = dbus_error_is_set(&err); if (errorset) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("there was an dbus error")); } dbus_error_init(&err); dbus_bus_release_name(m_pConnection, DBUS_SERVICE_SERVICE, &err); @@ -41,7 +41,7 @@ void DBUSMessageHandler::initReceive(DBusMessage* msg) { if (!dbus_message_iter_init(msg, &m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS Message has no arguments!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS Message has no arguments!")); } } @@ -57,10 +57,10 @@ void DBUSMessageHandler::closeReply() // send the reply && flush the connection if (!dbus_connection_send(m_pConnection, m_pReply, &m_serial)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply!")); dbus_connection_flush(m_pConnection); // free the reply @@ -74,10 +74,10 @@ void DBUSMessageHandler::ReplyError(DBusMessage* msg, const char* errorname, con // send the reply && flush the connection if (!dbus_connection_send(m_pConnection, m_pReply, &m_serial)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply with error!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler sending reply with error!")); dbus_connection_flush(m_pConnection); // free the reply @@ -90,7 +90,7 @@ char* DBUSMessageHandler::getString() if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); } else { @@ -106,7 +106,7 @@ dbus_bool_t DBUSMessageHandler::getBool() if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no bool!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no bool!")); } else { @@ -122,7 +122,7 @@ char DBUSMessageHandler::getByte() if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no byte!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no byte!")); } else { @@ -138,7 +138,7 @@ dbus_uint32_t DBUSMessageHandler::getUInt() if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no uint32_t!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no uint32_t!")); } else { @@ -154,7 +154,7 @@ double DBUSMessageHandler::getDouble() if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no double!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no double!")); } else { @@ -168,7 +168,7 @@ void DBUSMessageHandler::getArrayOfUInt(int* pLength, unsigned int** ppArray) { if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); return; } @@ -189,7 +189,7 @@ void DBUSMessageHandler::getArrayOfString(std::vector* stringVector { if (DBUS_TYPE_ARRAY != dbus_message_iter_get_arg_type(&m_MessageIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no array!")); return; } @@ -200,7 +200,7 @@ void DBUSMessageHandler::getArrayOfString(std::vector* stringVector { if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&arrayIter)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler argument is no string!")); } char* param; dbus_message_iter_get_basic(&arrayIter, ¶m); @@ -218,43 +218,44 @@ void DBUSMessageHandler::getArrayOfString(std::vector* stringVector } } -void DBUSMessageHandler::appendBool(dbus_bool_t toAppend) +void DBUSMessageHandler::append(bool toAppend) { - if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_BOOLEAN, &toAppend)) + dbus_bool_t mybool=toAppend; + if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_BOOLEAN, &mybool)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } -void DBUSMessageHandler::appendUInt(dbus_uint32_t toAppend) +void DBUSMessageHandler::append(dbus_uint32_t toAppend) { if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_UINT32, &toAppend)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } -void DBUSMessageHandler::appendDouble(double toAppend) +void DBUSMessageHandler::append(double toAppend) { if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_DOUBLE, &toAppend)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } -void DBUSMessageHandler::appendByte(char toAppend) +void DBUSMessageHandler::append(char toAppend) { if (!dbus_message_iter_append_basic(&m_MessageIter, DBUS_TYPE_BYTE, &toAppend)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); exit(1); } } -void DBUSMessageHandler::appendArrayOfUInt(unsigned int length, unsigned int *IDs) +void DBUSMessageHandler::append(unsigned int length, unsigned int *IDs) { DBusMessageIter arrayIter; dbus_message_iter_open_container(&m_MessageIter, DBUS_TYPE_ARRAY, "u", &arrayIter); @@ -269,16 +270,17 @@ void DBUSMessageHandler::sendSignal(const char* signalname) { dbus_uint32_t serial = 0; DBusMessage* msg; - msg =dbus_message_new_signal(DBUS_SERVICE_ROOT,DBUS_SERVICE_SERVICE,signalname); + string nodeString =std::string(DBUS_SERVICE_ROOT)+"/"+std::string(MY_NODE); + msg =dbus_message_new_signal(nodeString.c_str(),DBUS_SERVICE_SERVICE,signalname); if (NULL == msg) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("Message null!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("Message null!")); this->~DBUSMessageHandler(); } if (!dbus_connection_send(m_pConnection, msg, &serial)) { - DLT_LOG(DBusPlugin,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); this->~DBUSMessageHandler(); } @@ -287,3 +289,267 @@ void DBUSMessageHandler::sendSignal(const char* signalname) { // free the message dbus_message_unref(msg); } + +void DBUSMessageHandler::append(std::list list){ + DBusMessageIter arrayIter; + dbus_message_iter_open_container(&m_MessageIter, DBUS_TYPE_ARRAY, "uu", &arrayIter); + + std::list::iterator Ilist; + std::list::iterator Ibegin=list.begin(); + std::list::iterator Iend=list.end(); + for(Ilist=Ibegin;Ilist!=Iend; Ilist++) + { + dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_UINT32, &Ilist->Sink_ID); + dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_UINT32, &Ilist->Source_ID); + } + dbus_message_iter_close_container(&m_MessageIter, &arrayIter); +} + +void DBUSMessageHandler::append(std::list list){ + DBusMessageIter arrayIter; + dbus_message_iter_open_container(&m_MessageIter, DBUS_TYPE_ARRAY, "su", &arrayIter); + + std::list::iterator Ilist; + std::list::iterator Ibegin=list.begin(); + std::list::iterator Iend=list.end(); + for(Ilist=Ibegin;Ilist!=Iend; Ilist++) + { + dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_STRING, &Ilist->name); + dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_UINT32, &Ilist->ID); + } + dbus_message_iter_close_container(&m_MessageIter, &arrayIter); + +} + +void DBUSMessageHandler::append(std::list list){ + DBusMessageIter arrayIter; + dbus_message_iter_open_container(&m_MessageIter, DBUS_TYPE_ARRAY, "su", &arrayIter); + + std::list::iterator Ilist; + std::list::iterator Ibegin=list.begin(); + std::list::iterator Iend=list.end(); + for(Ilist=Ibegin;Ilist!=Iend; Ilist++) + { + dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_STRING, &Ilist->name); + dbus_message_iter_append_basic(&arrayIter, DBUS_TYPE_UINT32, &Ilist->ID); + } + dbus_message_iter_close_container(&m_MessageIter, &arrayIter); +} + + + +DBUSIntrospection::DBUSIntrospection(MethodTable* methodTable, SignalTable* signalTable,std::string nodename) +: m_methodTable(methodTable), m_signalTable(signalTable), m_nodename(nodename) +{ + generateString(); +} + +void DBUSIntrospection::generateString() +{ + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("Generating instrospection data!")); + + addHeader(); + openNode(m_nodename); + openInterface("org.freedesktop.DBus.Introspectable"); + openMethod("Introspect"); + addArgument("data", "out", "s"); + closeMethod(); + closeInterface(); + openInterface(DBUS_SERVICE_SERVICE); + + int index = 0; + + while (strcmp(m_methodTable[index].name, "") != 0) + { + MethodTable entry = m_methodTable[index]; + addEntry(entry); + ++index; + } + + index=0; + if (m_signalTable) { + while (strcmp(m_signalTable[index].name, "") != 0) + { + SignalTable entry = m_signalTable[index]; + addEntry(entry); + ++index; + } + } + closeInterface(); + closeNode(); + +} + +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::openSignal(string signalname) { + m_introspectionString<<" \n"; +} + +void DBUSIntrospection::addArgument(string argname, string direction, string type) +{ + m_introspectionString << " \n"; +} + + +void DBUSIntrospection::addSignalArgument(string argname, 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::closeSignal(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': + if (parameterArray.at(parameterIndex+1)=='(') { + int size=parameterArray.find((')'),parameterIndex); + addArgument("","in",parameterArray.substr(parameterIndex,size+1)); + parameterIndex+=size; + } else { + addArgument("","in", parameterArray.substr(parameterIndex,2)); + parameterIndex+=2; + } + break; + default: + addArgument("","in", parameterArray.substr(parameterIndex,1)); + break; + } + } + + + for(uint returnValueIndex = 0; returnValueIndex < returnValueArray.length(); ++returnValueIndex) + { + switch (returnValueArray.at(returnValueIndex)) + { + case 'a': + if (returnValueArray.at(returnValueIndex+1)=='(') { + int size=returnValueArray.find((')'),returnValueIndex); + addArgument("","out",returnValueArray.substr(returnValueIndex,size+1)); + returnValueIndex+=size; + } else { + addArgument("","out", returnValueArray.substr(returnValueIndex,2)); + returnValueIndex+=2; + } + break; + default: + addArgument("","out", returnValueArray.substr(returnValueIndex,1)); + break; + } + } + + closeMethod(); +} + +void DBUSIntrospection::addEntry(SignalTable entry) +{ + string methodName = entry.name; + string parameterArray = entry.signature; + + openSignal(methodName); + + for(uint parameterIndex = 0; parameterIndex < parameterArray.length(); ++parameterIndex) + { + switch (parameterArray.at(parameterIndex)) + { + case 'a': + if (parameterArray.at(parameterIndex+1)=='{') { + int size=parameterArray.find(('}'),parameterIndex); + addSignalArgument("",parameterArray.substr(parameterIndex,size+1)); + parameterIndex+=size; + } else { + parameterIndex++; + addSignalArgument("", "a" + parameterArray.at(parameterIndex)); + } + break; + default: + addSignalArgument("", parameterArray.substr(parameterIndex,1)); + break; + } + } + + closeSignal(); +} + +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)) + { + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + } + + // send the reply && flush the connection + if (!dbus_connection_send(conn, reply, &serial)) + { + DLT_LOG(DLT_CONTEXT,DLT_LOG_ERROR, DLT_STRING("DBUS handler Out Of Memory!")); + } + dbus_connection_flush(conn); + + // free the reply + dbus_message_unref(reply); +} + + + + + + diff --git a/PluginRoutingInterfaceDbus/DBUSMessageHandler.h b/PluginRoutingInterfaceDbus/DBUSMessageHandler.h index 8ef0b3d..a7f0d4a 100644 --- a/PluginRoutingInterfaceDbus/DBUSMessageHandler.h +++ b/PluginRoutingInterfaceDbus/DBUSMessageHandler.h @@ -21,8 +21,32 @@ #define _DBUSMESSAGEHANDLER_H_ #include +#include +using std::stringstream; + #include +using std::string; + #include "headers.h" +#include + +#define DLT_CONTEXT DBusPlugin + +typedef void (AudioManagerInterface::*CallBackMethod)(DBusConnection *connection, DBusMessage *message); + +struct MethodTable +{ + const char *name; + const char *signature; + const char *reply; + CallBackMethod function; +}; + +struct SignalTable { + const char* name; + const char* signature; +}; + class DBUSMessageHandler { @@ -30,15 +54,11 @@ public: DBUSMessageHandler(DBusObjectPathVTable* vtable, DBusConnection* conn, void* reference); ~DBUSMessageHandler(); - void setConnection(DBusConnection* conn); - DBusConnection* getConnection(); - void initReceive(DBusMessage* msg); void initReply(DBusMessage* msg); void closeReply(); void ReplyError(DBusMessage* msg, const char* errorname, const char* errorMsg); - dbus_uint32_t getUInt(); char getByte(); dbus_bool_t getBool(); @@ -47,11 +67,14 @@ public: 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); + void append(dbus_uint32_t toAppend); + void append(char toAppend); + void append(bool toAppend); + void append(double toAppend); + void append(unsigned int length, unsigned int *IDs); + void append(std::list list); + void append(std::list list); + void append(std::list list); void sendSignal(const char* signalname); @@ -63,17 +86,38 @@ private: DBusError m_err; }; - -inline void DBUSMessageHandler::setConnection(DBusConnection* conn) +class DBUSIntrospection { - m_pConnection = conn; -} +public: + DBUSIntrospection(MethodTable* table, SignalTable* stable,std::string nodename); + void process(DBusConnection* conn, DBusMessage* msg); -inline DBusConnection* DBUSMessageHandler::getConnection() -{ - return m_pConnection; -} +private: + void generateString(void); + + void addHeader(void); + void addArgument(string argname, string direction, string type); + void addSignalArgument(string argname, string type); + void addEntry(MethodTable entry); + void addEntry(SignalTable entry); + void openNode(string nodename); + void closeNode(void); + void openInterface(string interfacename); + void closeInterface(void); + + void openMethod(string methodname); + void closeMethod(void); + + void openSignal(string signalname); + void closeSignal(void); + +private: + stringstream m_introspectionString; + MethodTable* m_methodTable; + SignalTable* m_signalTable; + std::string m_nodename; +}; #endif // _DBUSMESSAGEWRAPPER_H_ diff --git a/PluginRoutingInterfaceDbus/DBUSTypes.h b/PluginRoutingInterfaceDbus/DBUSTypes.h deleted file mode 100644 index 2f6d0ef..0000000 --- a/PluginRoutingInterfaceDbus/DBUSTypes.h +++ /dev/null @@ -1,41 +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_ - -#include "headers.h" - -class AudioManagerInterface; - -typedef void (AudioManagerInterface::*CallBackMethod)(DBusConnection *connection, DBusMessage *message); - -struct MethodTable -{ - const char *name; - const char *signature; - const char *reply; - CallBackMethod function; -}; - -struct SignalTable { - const char* name; - const char* signature; -}; - -#endif // _DBUSTYPES_H_ diff --git a/PluginRoutingInterfaceDbus/headers.h b/PluginRoutingInterfaceDbus/headers.h index dbb6f3c..9f49ce4 100644 --- a/PluginRoutingInterfaceDbus/headers.h +++ b/PluginRoutingInterfaceDbus/headers.h @@ -15,10 +15,8 @@ #include "AudiomanagerInterface.h" #include "DbusSend.h" #include "DBUSMessageHandler.h" -#include "DBUSIntrospection.h" #include "DbusInterface.h" - #define BUS_NAME "DBUS" #define DBUS_BUSNAME "org.genivi.command" #define DBUS_PATH "/pulse" -- 2.7.4