author | harlekin <harlekin> | 2003-03-21 15:56:58 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-21 15:56:58 (UTC) |
commit | d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c (patch) (unidiff) | |
tree | 922b36110df58bdc00a3e2508313609c0f00c45f /noncore/net/opietooth/lib | |
parent | 69086f42072e7fc1ea5256cb9275a27bf5b41f87 (diff) | |
download | opie-d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c.zip opie-d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c.tar.gz opie-d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c.tar.bz2 |
move connection work to the lib
-rw-r--r-- | noncore/net/opietooth/lib/connection.cpp | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/connection.h | 31 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/lib.pro | 4 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/startpanconnection.cpp | 67 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/startpanconnection.h | 40 |
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 | |||
@@ -4,4 +4,8 @@ | |||
4 | using namespace OpieTooth; | 4 | using namespace OpieTooth; |
5 | 5 | ||
6 | |||
7 | |||
8 | |||
9 | |||
6 | ConnectionState::ConnectionState() { | 10 | ConnectionState::ConnectionState() { |
7 | m_direction = Incoming; | 11 | m_direction = Incoming; |
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 | |||
@@ -5,7 +5,38 @@ | |||
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | #include <qvaluelist.h> | 6 | #include <qvaluelist.h> |
7 | #include <qobject.h> | ||
7 | 8 | ||
8 | namespace OpieTooth { | 9 | namespace OpieTooth { |
9 | 10 | ||
11 | |||
12 | |||
13 | |||
14 | /** | ||
15 | * Parent class for all kinds of starting connection | ||
16 | * subclasses | ||
17 | * | ||
18 | */ | ||
19 | class StartConnection : public QObject { | ||
20 | |||
21 | protected: | ||
22 | |||
23 | enum ConnectionType{ | ||
24 | Pan = 0, | ||
25 | Rfcomm, | ||
26 | Obex, | ||
27 | Hci | ||
28 | }; | ||
29 | |||
30 | virtual ~StartConnection() {}; | ||
31 | |||
32 | virtual QString name() = 0; | ||
33 | virtual void setName( QString name ) = 0; | ||
34 | virtual ConnectionType type() = 0; | ||
35 | virtual void setConnectionType() = 0; | ||
36 | virtual void start() = 0; | ||
37 | virtual void stop() = 0; | ||
38 | |||
39 | }; | ||
40 | |||
10 | enum LinkDirection { Incoming= true, Outgoing = false }; | 41 | enum LinkDirection { Incoming= true, Outgoing = false }; |
11 | enum LinkMode { Master =0, Client }; | 42 | enum LinkMode { Master =0, Client }; |
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,6 +1,6 @@ | |||
1 | TEMPLATE = lib | 1 | TEMPLATE = lib |
2 | CONFIG += qte warn_on release | 2 | CONFIG += qte warn_on release |
3 | HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h | 3 | HEADERS = connection.h parser.h device.h manager.h remotedevice.h services.h startpanconnection.h |
4 | SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc | 4 | SOURCES = connection.cpp parser.cc device.cc manager.cc remotedevice.cc services.cc startpanconnection.cpp |
5 | TARGET = opietooth | 5 | TARGET = opietooth |
6 | INCLUDEPATH += $(OPIEDIR)/include . | 6 | INCLUDEPATH += $(OPIEDIR)/include . |
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 @@ | |||
1 | |||
2 | #include "startpanconnection.h" | ||
3 | |||
4 | using namespace OpieTooth; | ||
5 | |||
6 | |||
7 | StartPanConnection::StartPanConnection() { | ||
8 | m_panConnect = 0l; | ||
9 | setConnectionType(); | ||
10 | } | ||
11 | |||
12 | StartPanConnection::~StartPanConnection() { | ||
13 | delete m_panConnect; | ||
14 | } | ||
15 | |||
16 | StartPanConnection::StartPanConnection( QString mac ) { | ||
17 | m_panConnect = 0l; | ||
18 | m_mac = mac; | ||
19 | setConnectionType(); | ||
20 | } | ||
21 | |||
22 | void StartPanConnection::setName( QString name ) { | ||
23 | m_name = name; | ||
24 | } | ||
25 | |||
26 | QString StartPanConnection::name() { | ||
27 | return m_name; | ||
28 | } | ||
29 | |||
30 | void StartPanConnection::setConnectionType() { | ||
31 | m_connectionType = Pan; | ||
32 | } | ||
33 | |||
34 | StartConnection::ConnectionType StartPanConnection::type() { | ||
35 | return m_connectionType; | ||
36 | } | ||
37 | |||
38 | void StartPanConnection::start() { | ||
39 | m_panConnect = new OProcess(); | ||
40 | *m_panConnect << "pand" << "--connect" << m_mac; | ||
41 | |||
42 | connect( m_panConnect, SIGNAL( processExited( OProcess* ) ) , | ||
43 | this, SLOT( slotExited( OProcess* ) ) ); | ||
44 | connect( m_panConnect, SIGNAL( receivedStdout( OProcess*, char*, int ) ), | ||
45 | this, SLOT( slotStdOut( OProcess*, char*, int ) ) ); | ||
46 | if (!m_panConnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { | ||
47 | qWarning( "could not start" ); | ||
48 | delete m_panConnect; | ||
49 | } | ||
50 | } | ||
51 | |||
52 | |||
53 | void StartPanConnection::slotExited( OProcess* proc ) { | ||
54 | delete m_panConnect; | ||
55 | } | ||
56 | |||
57 | void StartPanConnection::slotStdOut(OProcess* proc, char* chars, int len) | ||
58 | {} | ||
59 | |||
60 | |||
61 | void StartPanConnection::stop() { | ||
62 | if ( m_panConnect ) { | ||
63 | delete m_panConnect; | ||
64 | m_panConnect = 0l; | ||
65 | } | ||
66 | } | ||
67 | |||
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 @@ | |||
1 | #ifndef startpanconnection_h | ||
2 | #define startpanconnection_h | ||
3 | |||
4 | #include <qobject.h> | ||
5 | #include "connection.h" | ||
6 | #include <opie/oprocess.h> | ||
7 | |||
8 | namespace OpieTooth { | ||
9 | |||
10 | class StartPanConnection : StartConnection { | ||
11 | |||
12 | Q_OBJECT | ||
13 | |||
14 | public: | ||
15 | StartPanConnection(); | ||
16 | StartPanConnection( QString mac ); | ||
17 | ~StartPanConnection(); | ||
18 | |||
19 | QString name(); | ||
20 | void setName( QString name ); | ||
21 | StartConnection::ConnectionType type(); | ||
22 | void setConnectionType( ); | ||
23 | void start(); | ||
24 | void stop(); | ||
25 | |||
26 | private: | ||
27 | QString m_name; | ||
28 | QString m_mac; | ||
29 | ConnectionType m_connectionType; | ||
30 | OProcess* m_panConnect; | ||
31 | |||
32 | private slots: | ||
33 | void slotExited( OProcess* proc ); | ||
34 | void slotStdOut( OProcess* proc, char* chars, int len ); | ||
35 | }; | ||
36 | |||
37 | |||
38 | } | ||
39 | |||
40 | #endif | ||