summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib
authorharlekin <harlekin>2003-03-21 15:56:58 (UTC)
committer harlekin <harlekin>2003-03-21 15:56:58 (UTC)
commitd3f71dadbd2dafcf42480afeffe75e7e36ec7d9c (patch) (side-by-side diff)
tree922b36110df58bdc00a3e2508313609c0f00c45f /noncore/net/opietooth/lib
parent69086f42072e7fc1ea5256cb9275a27bf5b41f87 (diff)
downloadopie-d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c.zip
opie-d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c.tar.gz
opie-d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c.tar.bz2
move connection work to the lib
Diffstat (limited to 'noncore/net/opietooth/lib') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/connection.cpp4
-rw-r--r--noncore/net/opietooth/lib/connection.h31
-rw-r--r--noncore/net/opietooth/lib/lib.pro4
-rw-r--r--noncore/net/opietooth/lib/startpanconnection.cpp67
-rw-r--r--noncore/net/opietooth/lib/startpanconnection.h40
5 files changed, 144 insertions, 2 deletions
diff --git a/noncore/net/opietooth/lib/connection.cpp b/noncore/net/opietooth/lib/connection.cpp
index ef7d925..5e35463 100644
--- a/noncore/net/opietooth/lib/connection.cpp
+++ b/noncore/net/opietooth/lib/connection.cpp
@@ -1,11 +1,15 @@
#include "connection.h"
using namespace OpieTooth;
+
+
+
+
ConnectionState::ConnectionState() {
m_direction = Incoming;
m_handle = -1;
m_state = -1;
m_linkMode = -1;
};
diff --git a/noncore/net/opietooth/lib/connection.h b/noncore/net/opietooth/lib/connection.h
index 76e5dad..a0c50f2 100644
--- a/noncore/net/opietooth/lib/connection.h
+++ b/noncore/net/opietooth/lib/connection.h
@@ -1,15 +1,46 @@
#ifndef OpieTooth_Connection_H
#define OpieTooth_Connection_H
#include <qstring.h>
#include <qvaluelist.h>
+#include <qobject.h>
namespace OpieTooth {
+
+
+
+ /**
+ * Parent class for all kinds of starting connection
+ * subclasses
+ *
+ */
+ class StartConnection : public QObject {
+
+ protected:
+
+ enum ConnectionType{
+ Pan = 0,
+ Rfcomm,
+ Obex,
+ Hci
+ };
+
+ virtual ~StartConnection() {};
+
+ virtual QString name() = 0;
+ virtual void setName( QString name ) = 0;
+ virtual ConnectionType type() = 0;
+ virtual void setConnectionType() = 0;
+ virtual void start() = 0;
+ virtual void stop() = 0;
+
+ };
+
enum LinkDirection { Incoming= true, Outgoing = false };
enum LinkMode { Master =0, Client };
/**
* The Connection class stores
diff --git a/noncore/net/opietooth/lib/lib.pro b/noncore/net/opietooth/lib/lib.pro
index 88df1fb..d081b5c 100644
--- a/noncore/net/opietooth/lib/lib.pro
+++ b/noncore/net/opietooth/lib/lib.pro
@@ -1,10 +1,10 @@
TEMPLATE = lib
CONFIG += qte warn_on release
-HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h
-SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc
+HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h startpanconnection.h
+SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc startpanconnection.cpp
TARGET = opietooth
INCLUDEPATH += $(OPIEDIR)/include .
DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
LIBS += -lopie
#VERSION = 0.0.0
diff --git a/noncore/net/opietooth/lib/startpanconnection.cpp b/noncore/net/opietooth/lib/startpanconnection.cpp
new file mode 100644
index 0000000..b68f02d
--- a/dev/null
+++ b/noncore/net/opietooth/lib/startpanconnection.cpp
@@ -0,0 +1,67 @@
+
+#include "startpanconnection.h"
+
+using namespace OpieTooth;
+
+
+StartPanConnection::StartPanConnection() {
+ m_panConnect = 0l;
+ setConnectionType();
+}
+
+StartPanConnection::~StartPanConnection() {
+ delete m_panConnect;
+}
+
+StartPanConnection::StartPanConnection( QString mac ) {
+ m_panConnect = 0l;
+ m_mac = mac;
+ setConnectionType();
+}
+
+void StartPanConnection::setName( QString name ) {
+ m_name = name;
+}
+
+QString StartPanConnection::name() {
+ return m_name;
+}
+
+void StartPanConnection::setConnectionType() {
+ m_connectionType = Pan;
+}
+
+StartConnection::ConnectionType StartPanConnection::type() {
+ return m_connectionType;
+}
+
+void StartPanConnection::start() {
+ m_panConnect = new OProcess();
+ *m_panConnect << "pand" << "--connect" << m_mac;
+
+ connect( m_panConnect, SIGNAL( processExited( OProcess* ) ) ,
+ this, SLOT( slotExited( OProcess* ) ) );
+ connect( m_panConnect, SIGNAL( receivedStdout( OProcess*, char*, int ) ),
+ this, SLOT( slotStdOut( OProcess*, char*, int ) ) );
+ if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) {
+ qWarning( "could not start" );
+ delete m_panConnect;
+ }
+}
+
+
+void StartPanConnection::slotExited( OProcess* proc ) {
+ delete m_panConnect;
+}
+
+void StartPanConnection::slotStdOut(OProcess* proc, char* chars, int len)
+{}
+
+
+void StartPanConnection::stop() {
+ if ( m_panConnect ) {
+ delete m_panConnect;
+ m_panConnect = 0l;
+ }
+}
+
diff --git a/noncore/net/opietooth/lib/startpanconnection.h b/noncore/net/opietooth/lib/startpanconnection.h
new file mode 100644
index 0000000..7e5bd95
--- a/dev/null
+++ b/noncore/net/opietooth/lib/startpanconnection.h
@@ -0,0 +1,40 @@
+#ifndef startpanconnection_h
+#define startpanconnection_h
+
+#include <qobject.h>
+#include "connection.h"
+#include <opie/oprocess.h>
+
+namespace OpieTooth {
+
+ class StartPanConnection : StartConnection {
+
+ Q_OBJECT
+
+ public:
+ StartPanConnection();
+ StartPanConnection( QString mac );
+ ~StartPanConnection();
+
+ QString name();
+ void setName( QString name );
+ StartConnection::ConnectionType type();
+ void setConnectionType( );
+ void start();
+ void stop();
+
+ private:
+ QString m_name;
+ QString m_mac;
+ ConnectionType m_connectionType;
+ OProcess* m_panConnect;
+
+ private slots:
+ void slotExited( OProcess* proc );
+ void slotStdOut( OProcess* proc, char* chars, int len );
+ };
+
+
+}
+
+#endif