-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 | |||
@@ -1,29 +1,33 @@ | |||
1 | 1 | ||
2 | #include "connection.h" | 2 | #include "connection.h" |
3 | 3 | ||
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; |
8 | m_handle = -1; | 12 | m_handle = -1; |
9 | m_state = -1; | 13 | m_state = -1; |
10 | m_linkMode = -1; | 14 | m_linkMode = -1; |
11 | }; | 15 | }; |
12 | 16 | ||
13 | ConnectionState::ConnectionState( const ConnectionState& con1 ) { | 17 | ConnectionState::ConnectionState( const ConnectionState& con1 ) { |
14 | (*this) = con1; | 18 | (*this) = con1; |
15 | } | 19 | } |
16 | 20 | ||
17 | 21 | ||
18 | ConnectionState::ConnectionState( bool in, | 22 | ConnectionState::ConnectionState( bool in, |
19 | const QString& conType, | 23 | const QString& conType, |
20 | const QString& mac, | 24 | const QString& mac, |
21 | int handle, | 25 | int handle, |
22 | int state, | 26 | int state, |
23 | int linkMode ) { | 27 | int linkMode ) { |
24 | m_direction = in; | 28 | m_direction = in; |
25 | m_contype = conType; | 29 | m_contype = conType; |
26 | m_mac = mac; | 30 | m_mac = mac; |
27 | m_handle = handle; | 31 | m_handle = handle; |
28 | m_state = state; | 32 | m_state = state; |
29 | m_linkMode = linkMode; | 33 | m_linkMode = linkMode; |
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,33 +1,64 @@ | |||
1 | 1 | ||
2 | #ifndef OpieTooth_Connection_H | 2 | #ifndef OpieTooth_Connection_H |
3 | #define OpieTooth_Connection_H | 3 | #define OpieTooth_Connection_H |
4 | 4 | ||
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 }; |
12 | 43 | ||
13 | 44 | ||
14 | /** | 45 | /** |
15 | * The Connection class stores | 46 | * The Connection class stores |
16 | * the output of hcitool con | 47 | * the output of hcitool con |
17 | * in a OO way | 48 | * in a OO way |
18 | */ | 49 | */ |
19 | 50 | ||
20 | class ConnectionState { | 51 | class ConnectionState { |
21 | public: | 52 | public: |
22 | /** | 53 | /** |
23 | * typedef for a list of | 54 | * typedef for a list of |
24 | * Connections | 55 | * Connections |
25 | */ | 56 | */ |
26 | typedef QValueList<ConnectionState> ValueList; | 57 | typedef QValueList<ConnectionState> ValueList; |
27 | 58 | ||
28 | /** | 59 | /** |
29 | * Copy c'tor. | 60 | * Copy c'tor. |
30 | */ | 61 | */ |
31 | ConnectionState( const ConnectionState& ); | 62 | ConnectionState( const ConnectionState& ); |
32 | 63 | ||
33 | /** | 64 | /** |
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,28 +1,28 @@ | |||
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 . |
7 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) | 7 | DESTDIR = $(OPIEDIR)/lib$(PROJMAK) |
8 | LIBS += -lopie | 8 | LIBS += -lopie |
9 | #VERSION = 0.0.0 | 9 | #VERSION = 0.0.0 |
10 | 10 | ||
11 | TRANSLATIONS = ../../../../i18n/de/libopietooth.ts \ | 11 | TRANSLATIONS = ../../../../i18n/de/libopietooth.ts \ |
12 | ../../../../i18n/da/libopietooth.ts \ | 12 | ../../../../i18n/da/libopietooth.ts \ |
13 | ../../../../i18n/xx/libopietooth.ts \ | 13 | ../../../../i18n/xx/libopietooth.ts \ |
14 | ../../../../i18n/en/libopietooth.ts \ | 14 | ../../../../i18n/en/libopietooth.ts \ |
15 | ../../../../i18n/es/libopietooth.ts \ | 15 | ../../../../i18n/es/libopietooth.ts \ |
16 | ../../../../i18n/fr/libopietooth.ts \ | 16 | ../../../../i18n/fr/libopietooth.ts \ |
17 | ../../../../i18n/hu/libopietooth.ts \ | 17 | ../../../../i18n/hu/libopietooth.ts \ |
18 | ../../../../i18n/ja/libopietooth.ts \ | 18 | ../../../../i18n/ja/libopietooth.ts \ |
19 | ../../../../i18n/ko/libopietooth.ts \ | 19 | ../../../../i18n/ko/libopietooth.ts \ |
20 | ../../../../i18n/no/libopietooth.ts \ | 20 | ../../../../i18n/no/libopietooth.ts \ |
21 | ../../../../i18n/pl/libopietooth.ts \ | 21 | ../../../../i18n/pl/libopietooth.ts \ |
22 | ../../../../i18n/pt/libopietooth.ts \ | 22 | ../../../../i18n/pt/libopietooth.ts \ |
23 | ../../../../i18n/pt_BR/libopietooth.ts \ | 23 | ../../../../i18n/pt_BR/libopietooth.ts \ |
24 | ../../../../i18n/sl/libopietooth.ts \ | 24 | ../../../../i18n/sl/libopietooth.ts \ |
25 | ../../../../i18n/zh_CN/libopietooth.ts \ | 25 | ../../../../i18n/zh_CN/libopietooth.ts \ |
26 | ../../../../i18n/zh_TW/libopietooth.ts | 26 | ../../../../i18n/zh_TW/libopietooth.ts |
27 | 27 | ||
28 | 28 | ||
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 | ||