summaryrefslogtreecommitdiff
path: root/pluginRoutingInterfaceTCP
diff options
context:
space:
mode:
Diffstat (limited to 'pluginRoutingInterfaceTCP')
-rw-r--r--pluginRoutingInterfaceTCP/CMakeLists.txt70
-rw-r--r--pluginRoutingInterfaceTCP/RoutingSend.cpp46
-rw-r--r--pluginRoutingInterfaceTCP/RoutingSend.h44
-rw-r--r--pluginRoutingInterfaceTCP/TcpServer.cpp68
-rw-r--r--pluginRoutingInterfaceTCP/TcpServer.h34
-rw-r--r--pluginRoutingInterfaceTCP/tcpClient.cpp62
-rw-r--r--pluginRoutingInterfaceTCP/tcpClient.h36
7 files changed, 0 insertions, 360 deletions
diff --git a/pluginRoutingInterfaceTCP/CMakeLists.txt b/pluginRoutingInterfaceTCP/CMakeLists.txt
deleted file mode 100644
index 48e5290..0000000
--- a/pluginRoutingInterfaceTCP/CMakeLists.txt
+++ /dev/null
@@ -1,70 +0,0 @@
-cmake_minimum_required(VERSION 2.6)
-
-PROJECT(PluginRoutingInterfaceTCP)
-
-set(CMAKE_CXX_FLAGS "-g -pipe -fPIC -Wall -W -D_REENTRANT")
-
-set(STD_INCLUDE_DIRS "/usr/include")
-set(EXECUTABLE_OUTPUT_PATH ../../bin/)
-set(LIBRARY_OUTPUT_PATH ../plugins)
-set(DBUS_FOLDER ${CMAKE_SOURCE_DIR}/../dbusInterfaces)
-
-cmake_policy(SET CMP0015 NEW)
-
-FIND_PACKAGE(Qt4 REQUIRED)
-FIND_PACKAGE(PkgConfig)
-pkg_check_modules(GLIB REQUIRED glib-2.0)
-
-INCLUDE_DIRECTORIES(
- include
- ${CMAKE_SOURCE_DIR}
- ${STD_INCLUDE_DIRS}
- ${GLIB_INCLUDE_DIRS}
- ${DBUS_FOLDER}
- ../AudioManagerDaemon
-)
-
-LINK_DIRECTORIES(
- ${LINK_DIRECTORIES}
- ${GLIB_LIBRARY_DIRS}
-)
-
-# add Qt modules here, the include will setup QT_LIBRARIES
-SET(QT_USE_QTNETWORK TRUE)
-
-# defines for QL Plugins
-ADD_DEFINITIONS(${QT_DEFINITIONS})
-ADD_DEFINITIONS(-DQT_STATICPLUGIN)
-ADD_DEFINITIONS(-DQT_PLUGIN)
-ADD_DEFINITIONS(-DQT_SHARED)
-
-
-
-INCLUDE(${QT_USE_FILE})
-
-# all source files go here
-SET(PLUGINJACK_SRCS_CXX
- RoutingSend.cpp
- tcpClient.cpp
- TcpServer.cpp
-)
-
-# every header that contains QT stuff like Q_OBJECT .... and must be mocced
-SET(PLUGINJACK_MOC_SRCS
- RoutingSend.h
- tcpClient.h
- TcpServer.h
-)
-
-#now take the headers, moc them and append the resulting moc files to the sources
-QT4_WRAP_CPP(PLUGINJACK_SRCS_CXX ${PLUGINJACK_MOC_SRCS})
-
-add_library(RoutingTcpPlugin ${PLUGINJACK_SRCS_CXX})
-
-TARGET_LINK_LIBRARIES(RoutingTcpPlugin
- ${QT_LIBRARIES}
-)
-
-
-
-
diff --git a/pluginRoutingInterfaceTCP/RoutingSend.cpp b/pluginRoutingInterfaceTCP/RoutingSend.cpp
deleted file mode 100644
index 71829ac..0000000
--- a/pluginRoutingInterfaceTCP/RoutingSend.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Bus_Interface.cpp
- *
- * Created on: Jan 19, 2011
- * Author: demo
- */
-#include <iostream>
-
-
-#include "RoutingSend.h"
-#include "routinginterface.h"
-#include "tcpMessages.h"
-
-
-using namespace std;
-
-
-void RoutingSendTcp::startup_interface(RoutingReceiveInterface* audioman){
- audiomanager=audioman;
- m_server=new TcpServer(AUDIOMAN_PORT);
- m_client=new tcpClient(BEAGLE_IP,BEAGLE_PORT);
- m_server->registerAudioManager(audiomanager);
- cout<<"server started"<<endl;
-}
-
-void RoutingSendTcp::return_BusName(char* BusName) {
- strcpy(BusName,BUS_NAME);
-}
-
-int RoutingSendTcp::Connect(int source, int sink){
- return m_client->connect(source,sink);
-}
-
-void RoutingSendTcp::system_ready() {
-
- m_client->system_ready();
- cout<<"Tcp ready"<<endl;
-
-}
-
-
-RoutingSendInterface* SampleRoutingInterfaceTcpFactory::returnInstance(){
- return new RoutingSendTcp();
-}
-
-Q_EXPORT_PLUGIN2(RoutingTcpPlugin, SampleRoutingInterfaceTcpFactory);
diff --git a/pluginRoutingInterfaceTCP/RoutingSend.h b/pluginRoutingInterfaceTCP/RoutingSend.h
deleted file mode 100644
index 30518a6..0000000
--- a/pluginRoutingInterfaceTCP/RoutingSend.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Bus_Interface.h
- *
- * Created on: Feb 24, 2011
- * Author: demo
- */
-
-#ifndef BUS_INTERFACE_H_
-#define BUS_INTERFACE_H_
-
-#include <qplugin.h>
-#include "routinginterface.h"
-#include "TcpServer.h"
-#include "tcpClient.h"
-
-#define BUS_NAME "TCP"
-
-class RoutingSendTcp: public RoutingSendInterface
-{
-Q_OBJECT
-public:
- void startup_interface(RoutingReceiveInterface * audioman);
- void return_BusName(char * BusName);
- int Connect(int source, int sink);
-public slots:
- void system_ready();
-
-private:
- RoutingReceiveInterface *audiomanager;
- TcpServer* m_server;
- tcpClient* m_client;
-};
-
-//That is the actual implementation of the Factory Class returning the real Interface
-
-class SampleRoutingInterfaceTcpFactory: public QObject, public RoutingInterfaceFactory
-{
-Q_OBJECT
-Q_INTERFACES(RoutingInterfaceFactory)
-public:
- RoutingSendInterface* returnInstance();
-};
-
-#endif /* BUS_INTERFACE_H_ */
diff --git a/pluginRoutingInterfaceTCP/TcpServer.cpp b/pluginRoutingInterfaceTCP/TcpServer.cpp
deleted file mode 100644
index 1e63f8b..0000000
--- a/pluginRoutingInterfaceTCP/TcpServer.cpp
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * TcpServer.cpp
- *
- * Created on: Apr 6, 2011
- * Author: blacky
- */
-
-#include "TcpServer.h"
-
-#include <iostream>
-#include <QList>
-#include <QByteArray>
-
-using namespace std;
-
-TcpServer::TcpServer(int ListenPort) {
- connect(this, SIGNAL(newConnection()), this, SLOT(receivedCommand()));
- if (! this->listen(QHostAddress::Any,ListenPort)) {
- cout<<" Problem: "<<this->errorString().toStdString()<<endl;
- }
-}
-
-TcpServer::~TcpServer() {
- // TODO Auto-generated destructor stub
-}
-
-void TcpServer::registerAudioManager(RoutingReceiveInterface *audiomanager_) {
- audiomanager=audiomanager_;
-}
-
-void TcpServer::receivedCommand() {
- socket=this->nextPendingConnection ();
- connect(socket, SIGNAL(readyRead()), this, SLOT(startRead()));
- cout<<"got new command"<<endl;
-}
-
-void TcpServer::startRead() {
- QByteArray buffer;
- int answer;
- bool earlyMode=false;
- buffer=socket->readAll();
- QList<QByteArray> bList=buffer.split('#');
- switch (bList.at(0).toInt()) {
- case MSG_registerDomain:
- if (QString(bList.at(4))=="true") {
- earlyMode=true;
- }
- answer=audiomanager->registerDomain((char*)bList.at(1).data(),(char*)bList.at(2).data(),(char*)bList.at(3).data(),earlyMode);
- socket->write(QByteArray::number(answer));
- break;
- case MSG_registerGateway:
- answer=audiomanager->registerGateway((char*)bList.at(1).data(),(char*)bList.at(2).data(),(char*)bList.at(3).data(),(char*)bList.at(4).data(),(char*)bList.at(5).data(),(char*)bList.at(6).data());
- socket->write(QByteArray::number(answer));
- break;
- case MSG_registerSink:
- answer=audiomanager->registerSink((char*)bList.at(1).data(),(char*)bList.at(2).data(),(char*)bList.at(3).data());
- socket->write(QByteArray::number(answer));
- break;
- case MSG_registerSource:
- answer=audiomanager->registerSource((char*)bList.at(1).data(),(char*)bList.at(2).data(),(char*)bList.at(3).data());
- socket->write(QByteArray::number(answer));
- break;
- case MSG_peekDomain:
- answer=audiomanager->peekDomain((char*)bList.at(1).data());
- socket->write(QByteArray::number(answer));
- break;
- }
-}
diff --git a/pluginRoutingInterfaceTCP/TcpServer.h b/pluginRoutingInterfaceTCP/TcpServer.h
deleted file mode 100644
index 32f9745..0000000
--- a/pluginRoutingInterfaceTCP/TcpServer.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * TcpServer.h
- *
- * Created on: Apr 6, 2011
- * Author: blacky
- */
-
-#ifndef I2CSERVER_H_
-#define I2CSERVER_H_
-
-#include <QtNetwork>
-#include <QObject>
-
-#include "routinginterface.h"
-#include "tcpMessages.h"
-
-class TcpServer : public QTcpServer{
-Q_OBJECT
-public:
- TcpServer(int ListenPort);
- virtual ~TcpServer();
-
- void registerAudioManager(RoutingReceiveInterface *audiomanager_);
-
-public slots:
- void receivedCommand();
- void startRead();
-
-private:
- QTcpSocket* socket;
- RoutingReceiveInterface *audiomanager;
-};
-
-#endif /* I2CSERVER_H_ */
diff --git a/pluginRoutingInterfaceTCP/tcpClient.cpp b/pluginRoutingInterfaceTCP/tcpClient.cpp
deleted file mode 100644
index b2aefe3..0000000
--- a/pluginRoutingInterfaceTCP/tcpClient.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * udpClient.cpp
- *
- * Created on: Apr 6, 2011
- * Author: blacky
- */
-
-#include "tcpClient.h"
-#include <iostream>
-
-using namespace std;
-
-tcpClient::tcpClient(QString serverIP_, int serverPort_) {
- serverIP=serverIP_;
- serverPort=serverPort_;
- QObject::connect(this, SIGNAL(connected()), this, SLOT(sendOut()));
-}
-
-tcpClient::~tcpClient() {
- // TODO Auto-generated destructor stub
-}
-
-int tcpClient::connect(int source, int sink) {
-
- sendBuffer.clear();
- sendBuffer.append(QByteArray::number(MSG_CONNECT));
- sendBuffer.append('#');
- sendBuffer.append(QByteArray::number(source));
- sendBuffer.append('#');
- sendBuffer.append(QByteArray::number(sink));
- if (send()) {
- this->waitForReadyRead(CONNECT_TIMEOUT);
- return this->readAll().toInt();
- } else {
- return -1;
- }
-
-}
-
-void tcpClient::system_ready() {
-
- sendBuffer.clear();
- sendBuffer.append(QByteArray::number(SIG_system_ready));
- send();
-}
-
-bool tcpClient::send() {
- QHostAddress adr;
- adr.setAddress(serverIP);
- this->connectToHost(adr,serverPort);
- if (!this->waitForConnected(CONNECT_TIMEOUT)) {
- cout<<"No connection"<<endl;
- return false;
- } else {
- cout<<"got connection"<<endl;
- return true;
- }
-}
-
-void tcpClient::sendOut() {
- this->write(sendBuffer);
-}
diff --git a/pluginRoutingInterfaceTCP/tcpClient.h b/pluginRoutingInterfaceTCP/tcpClient.h
deleted file mode 100644
index 1d93246..0000000
--- a/pluginRoutingInterfaceTCP/tcpClient.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * udpClient.h
- *
- * Created on: Apr 6, 2011
- * Author: blacky
- */
-#ifndef UDPCLIENT_H_
-#define UDPCLIENT_H_
-
-#include <QtNetwork>
-#include "tcpMessages.h"
-
-class tcpClient : public QTcpSocket
-{
-Q_OBJECT
-public:
- tcpClient(QString serverIP, int serverPort);
- virtual ~tcpClient();
-
- int connect(int source, int sink);
- void system_ready();
-
- bool send();
-
-public slots:
- void sendOut();
-
-
-private:
- QString serverIP;
- int serverPort;
- QByteArray sendBuffer;
-
-};
-
-#endif /* UDPCLIENT_H_ */