author | harlekin <harlekin> | 2003-03-21 15:56:58 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-21 15:56:58 (UTC) |
commit | d3f71dadbd2dafcf42480afeffe75e7e36ec7d9c (patch) (side-by-side diff) | |
tree | 922b36110df58bdc00a3e2508313609c0f00c45f | |
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 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.cpp | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluetoothbase.ui | 243 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/panpopup.cpp | 44 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/panpopup.h | 9 |
9 files changed, 267 insertions, 177 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,17 +1,21 @@ #include "connection.h" using namespace OpieTooth; + + + + ConnectionState::ConnectionState() { m_direction = Incoming; m_handle = -1; m_state = -1; m_linkMode = -1; }; ConnectionState::ConnectionState( const ConnectionState& con1 ) { (*this) = con1; } 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,21 +1,52 @@ #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 * the output of hcitool con * in a OO way */ class ConnectionState { public: 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,16 +1,16 @@ 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 TRANSLATIONS = ../../../../i18n/de/libopietooth.ts \ ../../../../i18n/da/libopietooth.ts \ ../../../../i18n/xx/libopietooth.ts \ ../../../../i18n/en/libopietooth.ts \ ../../../../i18n/es/libopietooth.ts \ ../../../../i18n/fr/libopietooth.ts \ 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 diff --git a/noncore/net/opietooth/manager/bluebase.cpp b/noncore/net/opietooth/manager/bluebase.cpp index b5a09e5..04fa117 100644 --- a/noncore/net/opietooth/manager/bluebase.cpp +++ b/noncore/net/opietooth/manager/bluebase.cpp @@ -324,25 +324,25 @@ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & poin * If escaped( -1 ) or any of our items were chosen we'll * delete the PopupMenu otherwise it's the responsibility of * the PopupMenu to delete itself * */ else if ( ((BTListItem*)item)->type() == "service") { BTServiceItem* service = (BTServiceItem*)item; QMap<int, QString> list = service->services().classIdList(); QMap<int, QString>::Iterator it = list.begin(); QPopupMenu *popup =0l; if ( it != list.end() ) { qWarning("Searching id %d %s", it.key(), it.data().latin1() ); - popup = m_popHelper.find( it.key() /*1*/, + popup = m_popHelper.find( 4358, service->services(), (BTDeviceItem*)service->parent() ); }else { qWarning("Empty"); } if ( popup == 0l ) { qWarning("factory returned 0l"); popup = new QPopupMenu(); } int test1 = popup->insertItem( tr("Test1:"), 2); diff --git a/noncore/net/opietooth/manager/bluetoothbase.ui b/noncore/net/opietooth/manager/bluetoothbase.ui index b51c8c6..9ff970f 100644 --- a/noncore/net/opietooth/manager/bluetoothbase.ui +++ b/noncore/net/opietooth/manager/bluetoothbase.ui @@ -2,99 +2,78 @@ <class>BluetoothBase</class> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>BluetoothBase</cstring> </property> <property stdset="1"> <name>geometry</name> <rect> <x>0</x> <y>0</y> - <width>228</width> + <width>224</width> <height>320</height> </rect> </property> <property stdset="1"> <name>caption</name> <string>Form1</string> </property> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>0</number> + </property> <widget> <class>QTabWidget</class> <property stdset="1"> <name>name</name> <cstring>Status</cstring> </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>260</width> - <height>350</height> - </rect> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> </property> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Devices</string> </attribute> - <spacer> - <property> - <name>name</name> - <cstring>Spacer3</cstring> - </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Expanding</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - <spacer> - <property> - <name>name</name> - <cstring>Spacer1</cstring> - </property> + <vbox> <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> + <name>margin</name> + <number>2</number> </property> <property stdset="1"> - <name>sizeType</name> - <enum>Fixed</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> + <name>spacing</name> + <number>2</number> </property> - </spacer> <widget> <class>QListView</class> <column> <property> <name>text</name> <string>Device Name</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> @@ -111,72 +90,64 @@ <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <property stdset="1"> <name>name</name> <cstring>ListView2</cstring> </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>230</width> - <height>230</height> - </rect> - </property> </widget> <widget> <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>PushButton2</cstring> </property> <property stdset="1"> - <name>geometry</name> - <rect> - <x>40</x> - <y>231</y> - <width>154</width> - <height>30</height> - </rect> - </property> - <property stdset="1"> <name>sizePolicy</name> <sizepolicy> <hsizetype>0</hsizetype> <vsizetype>0</vsizetype> </sizepolicy> </property> <property stdset="1"> <name>text</name> <string>Scan for Devices</string> </property> </widget> + </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Connections</string> </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> <widget> <class>QListView</class> <column> <property> <name>text</name> <string>Device Name</string> </property> <property> <name>clickable</name> <bool>true</bool> </property> <property> @@ -207,120 +178,126 @@ <name>clickable</name> <bool>true</bool> </property> <property> <name>resizeable</name> <bool>true</bool> </property> </column> <property stdset="1"> <name>name</name> <cstring>ListView4</cstring> </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>240</width> - <height>240</height> - </rect> - </property> </widget> + </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Config</string> </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> <widget> - <class>QLabel</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>deviceNameLabel</cstring> + <cstring>Layout2</cstring> </property> + <hbox> <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>10</y> - <width>70</width> - <height>20</height> - </rect> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>deviceNameLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>Device Name</string> </property> </widget> <widget> - <class>QLabel</class> + <class>QLineEdit</class> <property stdset="1"> <name>name</name> - <cstring>passkeyLabel</cstring> + <cstring>deviceNameLine</cstring> </property> + </widget> + </hbox> + </widget> + <widget> + <class>QLayoutWidget</class> <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>50</y> - <width>80</width> - <height>20</height> - </rect> + <name>name</name> + <cstring>Layout3</cstring> + </property> + <hbox> + <property stdset="1"> + <name>margin</name> + <number>0</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>6</number> + </property> + <widget> + <class>QLabel</class> + <property stdset="1"> + <name>name</name> + <cstring>passkeyLabel</cstring> </property> <property stdset="1"> <name>text</name> <string>Default Passkey</string> </property> </widget> <widget> <class>QLineEdit</class> <property stdset="1"> <name>name</name> <cstring>passkeyLine</cstring> </property> <property stdset="1"> - <name>geometry</name> - <rect> - <x>98</x> - <y>53</y> - <width>120</width> - <height>22</height> - </rect> - </property> - <property stdset="1"> <name>echoMode</name> <enum>Password</enum> </property> </widget> + </hbox> + </widget> <widget> <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> <cstring>Layout5</cstring> </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>100</y> - <width>188</width> - <height>120</height> - </rect> - </property> <vbox> <property stdset="1"> <name>margin</name> <number>0</number> </property> <property stdset="1"> <name>spacing</name> <number>6</number> </property> <widget> <class>QCheckBox</class> <property stdset="1"> @@ -359,82 +336,60 @@ <property stdset="1"> <name>name</name> <cstring>inquiryscanCheckBox</cstring> </property> <property stdset="1"> <name>text</name> <string>Enable Inquiry scan</string> </property> </widget> </vbox> </widget> <widget> - <class>QLineEdit</class> - <property stdset="1"> - <name>name</name> - <cstring>deviceNameLine</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>98</x> - <y>13</y> - <width>120</width> - <height>22</height> - </rect> - </property> - </widget> - <widget> <class>QPushButton</class> <property stdset="1"> <name>name</name> <cstring>configApplyButton</cstring> </property> <property stdset="1"> - <name>geometry</name> - <rect> - <x>60</x> - <y>230</y> - <width>99</width> - <height>32</height> - </rect> - </property> - <property stdset="1"> <name>text</name> <string>Apply</string> </property> </widget> + </vbox> </widget> <widget> <class>QWidget</class> <property stdset="1"> <name>name</name> <cstring>tab</cstring> </property> <attribute> <name>title</name> <string>Status</string> </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> + </property> + <property stdset="1"> + <name>spacing</name> + <number>2</number> + </property> <widget> <class>QLabel</class> <property stdset="1"> <name>name</name> <cstring>StatusLabel</cstring> </property> <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>10</y> - <width>220</width> - <height>250</height> - </rect> - </property> - <property stdset="1"> <name>text</name> <string>Status Label</string> </property> </widget> + </vbox> </widget> </widget> + </vbox> </widget> </UI> diff --git a/noncore/net/opietooth/manager/panpopup.cpp b/noncore/net/opietooth/manager/panpopup.cpp index d3d1347..61e632b 100644 --- a/noncore/net/opietooth/manager/panpopup.cpp +++ b/noncore/net/opietooth/manager/panpopup.cpp @@ -5,66 +5,58 @@ #include "panpopup.h" using namespace OpieTooth; /* * c'tor init the QAction */ PanPopup::PanPopup( OpieTooth::BTDeviceItem* item ) : QPopupMenu() { qWarning("PanPopup c'tor"); m_item = item; - m_panconnect = 0l; - QAction *a, *b; + QAction *a, *b, *c; + m_panconnection = 0l; /* connect action */ + + a = new QAction( ); // so it's get deleted - a->setText( "connect" ); + a->setText( tr("connect") ); a->addTo( this ); connect( a, SIGNAL( activated() ), this, SLOT( slotConnect() ) ); + b = new QAction(); - b->setText( "connect+conf" ); + b->setText( tr( "connect+conf" ) ); b->addTo( this ); connect( b, SIGNAL( activated() ), this, SLOT( slotConnectAndConfig() ) ); + + c = new QAction(); + c->setText( tr( "disconnect" ) ); + c->addTo( this ); + connect( c, SIGNAL( activated() ), this, SLOT( slotDisconnect() ) ); + }; PanPopup::~PanPopup() { - delete m_panconnect; + } void PanPopup::slotConnect() { - - - // SHOULD move to lib - // before pand must be in "pand --listen --role panu" mode ( client ) - - m_panconnect = new OProcess(); - *m_panconnect << "pand" << "--connect" << m_item->mac(); - - connect( m_panconnect, SIGNAL( processExited( OProcess* ) ) , - this, SLOT( slotConnectExited( OProcess* ) ) ); - connect( m_panconnect, SIGNAL( receivedStdout( OProcess*, char*, int ) ), - this, SLOT( slotConnectOut( OProcess*, char*, int ) ) ); - if (!m_panconnect->start( OProcess::NotifyOnExit, OProcess::AllOutput) ) { - qWarning( "could not start" ); - delete m_panconnect; - } + m_panconnection = new StartPanConnection( m_item->mac() ); + m_panconnection->start(); } -void PanPopup::slotExited( OProcess* proc ) { - delete m_panconnect; +void PanPopup::slotDisconnect() { + m_panconnection->stop(); } -void PanPopup::slotStdOut(OProcess* proc, char* chars, int len) -{} - void PanPopup::slotConnectAndConfig() { slotConnect(); // more intelligence here later like passing the device ( bnepX ) QCopEnvelope e( "QPE/System", "execute(QString)" ); e << QString( "networksetup" ); } diff --git a/noncore/net/opietooth/manager/panpopup.h b/noncore/net/opietooth/manager/panpopup.h index 9d99f5e..1496f3a 100644 --- a/noncore/net/opietooth/manager/panpopup.h +++ b/noncore/net/opietooth/manager/panpopup.h @@ -1,32 +1,33 @@ #ifndef PANPOPUP_H #define PANPOPUP_H #include <qpopupmenu.h> #include <qaction.h> -#include <opie/oprocess.h> + +#include <startpanconnection.h> #include "btdeviceitem.h" + namespace OpieTooth { class PanPopup : public QPopupMenu { Q_OBJECT public: PanPopup( OpieTooth::BTDeviceItem* ); ~PanPopup(); private: QAction* m_push; - OProcess* m_panconnect; + OpieTooth::StartPanConnection* m_panconnection; OpieTooth::BTDeviceItem *m_item; private slots: void slotConnect(); + void slotDisconnect(); void slotConnectAndConfig(); - void slotExited( OProcess* proc ); - void slotStdOut( OProcess* proc, char* chars, int len ); }; }; #endif |