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 | 665 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/panpopup.cpp | 46 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/panpopup.h | 11 |
9 files changed, 480 insertions, 390 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,90 +1,94 @@ #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; } ConnectionState::ConnectionState( bool in, const QString& conType, const QString& mac, int handle, int state, int linkMode ) { m_direction = in; m_contype = conType; m_mac = mac; m_handle = handle; m_state = state; m_linkMode = linkMode; } void ConnectionState::setDirection( bool incoming ) { m_direction = incoming; } bool ConnectionState::direction() const { return m_direction; } void ConnectionState::setConnectionMode( const QString& conType ) { m_contype = conType; } QString ConnectionState::connectionMode() const { return m_contype; } void ConnectionState::setMac( const QString& mac ) { m_mac = mac; } QString ConnectionState::mac() const{ return m_mac; } void ConnectionState::setHandle( int handle ) { m_handle = handle; } int ConnectionState::handle() const{ return m_handle; } void ConnectionState::setState( int state ) { m_state = state; } int ConnectionState::state()const { return m_state; } void ConnectionState::setLinkMode( int linkMode ) { m_linkMode = linkMode; } int ConnectionState::linkMode()const{ return m_linkMode; } ConnectionState &ConnectionState::operator=( const ConnectionState& con1 ) { m_direction = con1.m_direction; m_contype = con1.m_contype; m_mac = con1.m_mac; m_handle = con1.m_handle; m_state = con1.m_state; m_linkMode = con1.m_linkMode; return (*this); } 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,150 +1,181 @@ #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: /** * typedef for a list of * Connections */ typedef QValueList<ConnectionState> ValueList; /** * Copy c'tor. */ ConnectionState( const ConnectionState& ); /** * Main c'tor * Basicly it holds all values * a blueZ connections can have * @param in If the connection is either incoming or outgoing * @param conType Either ACL or SCO for connection type * @param mac The BD Address( mac ) of the peer * @param handle the blueZ handle * @param state the State of the connection * @param linkMode the linkmode of the connection MASTER or not * * < ACL 00:02:C7:09:2B:53 handle 1 state 1 lm MASTER * */ ConnectionState( bool in, const QString& conType, const QString& mac, int handle, int state, int linkMode ); /** * C'tor for compability with QValueList * QValueList needs this c'tor. */ ConnectionState(); /** * Set if the connection is incoming or * outgoing * @param in Whether or not the connection is ingoing or not. * for param use either Incoming or Outgoing * */ void setDirection( bool incoming = Incoming ); /** * direction() will return Incoming( true ) * if the direction is incomoning or Outgoing( false) * if outgoing */ bool direction() const; /** * sets the ConnectionMode * @param comMode I know that SCO and ACL exists so far */ void setConnectionMode( const QString& comMode ); /** * linkMode returns the linkMode * MASTER for example */ QString connectionMode() const; /** * The Bluetooth Address or mac * is set by this function * @param mac the BluetoothAddress( mac) */ void setMac( const QString& mac); /** * returns the mac */ QString mac() const; /** * Set the handle of the bt connection */ void setHandle(int handle ); /** * @return the handle of the connection */ int handle() const; /** * sets the state */ void setState( int state ); /** * return the state */ int state() const; /** * Sets the link mode of the Connection */ void setLinkMode( int linkMode = Master ); /** * returns the linkMode */ int linkMode()const; /** * copy c'tor */ ConnectionState &operator=( const ConnectionState& ); private: class ConnectionStatePrivate; ConnectionStatePrivate *d; bool m_direction : 1; QString m_contype; QString m_mac; int m_handle; int m_state; int m_linkMode; }; }; #endif 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,30 +1,30 @@ 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 \ ../../../../i18n/hu/libopietooth.ts \ ../../../../i18n/ja/libopietooth.ts \ ../../../../i18n/ko/libopietooth.ts \ ../../../../i18n/no/libopietooth.ts \ ../../../../i18n/pl/libopietooth.ts \ ../../../../i18n/pt/libopietooth.ts \ ../../../../i18n/pt_BR/libopietooth.ts \ ../../../../i18n/sl/libopietooth.ts \ ../../../../i18n/zh_CN/libopietooth.ts \ ../../../../i18n/zh_TW/libopietooth.ts include ( $(OPIEDIR)/include.pro ) 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 @@ -1,610 +1,610 @@ /* * bluebase.cpp * * --------------------- * * copyright : (c) 2002 by Maximilian Reiß * email : max.reiss@gmx.de * */ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include "bluebase.h" #include "scandialog.h" #include "hciconfwrapper.h" #include "devicehandler.h" #include "btconnectionitem.h" #include <remotedevice.h> #include <services.h> #include <stdlib.h> #include <qframe.h> #include <qlabel.h> #include <qpushbutton.h> #include <qlayout.h> #include <qvariant.h> #include <qimage.h> #include <qpixmap.h> #include <qtabwidget.h> #include <qscrollview.h> #include <qvbox.h> #include <qmessagebox.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qlistview.h> #include <qdir.h> #include <qpopupmenu.h> #include <qtimer.h> #include <qlist.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/config.h> using namespace OpieTooth; BlueBase::BlueBase( QWidget* parent, const char* name, WFlags fl ) : BluetoothBase( parent, name, fl ) { m_localDevice = new Manager( "hci0" ); connect( PushButton2, SIGNAL( clicked() ), this, SLOT(startScan() ) ); connect( configApplyButton, SIGNAL(clicked() ), this, SLOT(applyConfigChanges() ) ); // not good since lib is async // connect( ListView2, SIGNAL( expanded ( QListViewItem* ) ), // this, SLOT( addServicesToDevice( QListViewItem * ) ) ); connect( ListView2, SIGNAL( clicked( QListViewItem* )), this, SLOT( startServiceActionClicked( QListViewItem* ) ) ); connect( ListView2, SIGNAL( rightButtonClicked( QListViewItem *, const QPoint &, int ) ), this, SLOT(startServiceActionHold( QListViewItem *, const QPoint &, int) ) ); connect( m_localDevice , SIGNAL( foundServices( const QString& , Services::ValueList ) ), this, SLOT( addServicesToDevice( const QString& , Services::ValueList ) ) ); connect( m_localDevice, SIGNAL( available( const QString&, bool ) ), this, SLOT( deviceActive( const QString& , bool ) ) ); connect( m_localDevice, SIGNAL( connections( ConnectionState::ValueList ) ), this, SLOT( addConnectedDevices( ConnectionState::ValueList ) ) ); connect( m_localDevice, SIGNAL( signalStrength( const QString&, const QString& ) ), this, SLOT( addSignalStrength( const QString&, const QString& ) ) ); // let hold be rightButtonClicked() QPEApplication::setStylusOperation( ListView2->viewport(), QPEApplication::RightOnHold); QPEApplication::setStylusOperation( ListView4->viewport(), QPEApplication::RightOnHold); //Load all icons needed m_offPix = Resource::loadPixmap( "opietooth/notconnected" ); m_onPix = Resource::loadPixmap( "opietooth/connected" ); m_findPix = Resource::loadPixmap( "opietooth/find" ); QPalette pal = this->palette(); QColor col = pal.color( QPalette::Active, QColorGroup::Background ); pal.setColor( QPalette::Active, QColorGroup::Button, col ); pal.setColor( QPalette::Inactive, QColorGroup::Button, col ); pal.setColor( QPalette::Normal, QColorGroup::Button, col ); pal.setColor( QPalette::Disabled, QColorGroup::Button, col ); this->setPalette( pal ); setCaption( tr( "Bluetooth Manager" ) ); readConfig(); initGui(); ListView2->setRootIsDecorated(true); writeToHciConfig(); // search conncetions addConnectedDevices(); addSignalStrength(); m_iconLoader = new BTIconLoader(); readSavedDevices(); } /** * Reads all options from the config file */ void BlueBase::readConfig() { Config cfg( "bluetoothmanager" ); cfg.setGroup( "bluezsettings" ); m_deviceName = cfg.readEntry( "name" , "No name" ); // name the device should identify with m_defaultPasskey = cfg.readEntryCrypt( "passkey" , "" ); // <- hmm, look up how good the trolls did that, maybe too weak m_useEncryption = cfg.readBoolEntry( "useEncryption" , TRUE ); m_enableAuthentification = cfg.readBoolEntry( "enableAuthentification" , TRUE ); m_enablePagescan = cfg.readBoolEntry( "enablePagescan" , TRUE ); m_enableInquiryscan = cfg.readBoolEntry( "enableInquiryscan" , TRUE ); } /** * Writes all options to the config file */ void BlueBase::writeConfig() { Config cfg( "bluetoothmanager" ); cfg.setGroup( "bluezsettings" ); cfg.writeEntry( "name" , m_deviceName ); cfg.writeEntryCrypt( "passkey" , m_defaultPasskey ); cfg.writeEntry( "useEncryption" , m_useEncryption ); cfg.writeEntry( "enableAuthentification" , m_enableAuthentification ); cfg.writeEntry( "enablePagescan" , m_enablePagescan ); cfg.writeEntry( "enableInquiryscan" , m_enableInquiryscan ); writeToHciConfig(); } /** * Modify the hcid.conf file to our needs */ void BlueBase::writeToHciConfig() { qWarning("writeToHciConfig"); HciConfWrapper hciconf ( "/etc/bluetooth/hcid.conf" ); hciconf.load(); hciconf.setPinHelper( "/bin/QtPalmtop/bin/blue-pin" ); hciconf.setName( m_deviceName ); hciconf.setEncrypt( m_useEncryption ); hciconf.setAuth( m_enableAuthentification ); hciconf.setPscan( m_enablePagescan ); hciconf.setIscan( m_enableInquiryscan ); hciconf.save(); } /** * Read the list of allready known devices */ void BlueBase::readSavedDevices() { QValueList<RemoteDevice> loadedDevices; DeviceHandler handler; loadedDevices = handler.load(); addSearchedDevices( loadedDevices ); } /** * Write the list of allready known devices */ void BlueBase::writeSavedDevices() { QListViewItemIterator it( ListView2 ); BTListItem* item; BTDeviceItem* device; RemoteDevice::ValueList list; for ( ; it.current(); ++it ) { item = (BTListItem*)it.current(); if(item->typeId() != BTListItem::Device ) continue; device = (BTDeviceItem*)item; list.append( device->remoteDevice() ); } /* * if not empty save the List through DeviceHandler */ if ( list.isEmpty() ) return; DeviceHandler handler; handler.save( list ); } /** * Set up the gui */ void BlueBase::initGui() { StatusLabel->setText( status() ); // maybe move it to getStatus() cryptCheckBox->setChecked( m_useEncryption ); authCheckBox->setChecked( m_enableAuthentification ); pagescanCheckBox->setChecked( m_enablePagescan ); inquiryscanCheckBox->setChecked( m_enableInquiryscan ); deviceNameLine->setText( m_deviceName ); passkeyLine->setText( m_defaultPasskey ); // set info tab setInfo(); } /** * Get the status informations and returns it * @return QString the status informations gathered */ QString BlueBase::status()const{ QString infoString = tr( "<b>Device name : </b> Ipaq" ); infoString += QString( "<br><b>" + tr( "MAC adress: " ) +"</b> No idea" ); infoString += QString( "<br><b>" + tr( "Class" ) + "</b> PDA" ); return (infoString); } /** * Read the current values from the gui and invoke writeConfig() */ void BlueBase::applyConfigChanges() { m_deviceName = deviceNameLine->text(); m_defaultPasskey = passkeyLine->text(); m_useEncryption = cryptCheckBox->isChecked(); m_enableAuthentification = authCheckBox->isChecked(); m_enablePagescan = pagescanCheckBox->isChecked(); m_enableInquiryscan = inquiryscanCheckBox->isChecked(); writeConfig(); QMessageBox::information( this, tr("Test") , tr("Changes were applied.") ); } /** * Add fresh found devices from scan dialog to the listing * */ void BlueBase::addSearchedDevices( const QValueList<RemoteDevice> &newDevices ) { BTDeviceItem * deviceItem; QValueList<RemoteDevice>::ConstIterator it; for( it = newDevices.begin(); it != newDevices.end() ; ++it ) { if (find( (*it) )) // is already inserted continue; deviceItem = new BTDeviceItem( ListView2 , (*it) ); deviceItem->setPixmap( 1, m_findPix ); deviceItem->setExpandable ( true ); // look if device is avail. atm, async deviceActive( (*it) ); // ggf auch hier? addServicesToDevice( deviceItem ); } } /** * Action that is toggled on entrys on click */ void BlueBase::startServiceActionClicked( QListViewItem */*item*/ ) { } /** * Action that are toggled on hold (mostly QPopups i guess) */ void BlueBase::startServiceActionHold( QListViewItem * item, const QPoint & point, int /*column*/ ) { if (!item ) return; QPopupMenu *menu = new QPopupMenu(); int ret=0; if ( ((BTListItem*)item)->type() == "device") { QPopupMenu *groups = new QPopupMenu(); menu->insertItem( ((BTDeviceItem*)item)->name(),0 ); menu->insertSeparator(1); menu->insertItem( tr("rescan sevices"), 2); menu->insertItem( tr("to group"), groups , 3); menu->insertItem( tr("delete"), 4); ret = menu->exec( point , 0); switch(ret) { case -1: break; case 2: addServicesToDevice( (BTDeviceItem*)item ); break; case 4: // deletes childs too delete item; break; } delete groups; } /* * We got service sensitive PopupMenus in our factory * We will create one through the factory and will insert * our Separator + ShowInfo into the menu or create a new * one if the factory returns 0 * PopupMenu deletion is kind of weird. * 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); ret = popup->exec( point ); qWarning("returned from exec() "); if ( ret == -1 ) { ; } else if ( ret == test1 ) { ; } delete popup; } delete menu; } /** * Search and display avail. services for a device (on expand from device listing) * @param item the service item returned */ void BlueBase::addServicesToDevice( BTDeviceItem * item ) { qDebug("addServicesToDevice"); // row of mac adress text(3) RemoteDevice device = item->remoteDevice(); m_deviceList.insert( item->mac() , item ); // and some time later I get a signal foundServices( const QString& device, Services::ValueList ); back m_localDevice->searchServices( device ); } /** * Overloaded. This one it the one that is ted to the foundServices signal * @param device the mac address of the remote device * @param servicesList the list with the service the device has. */ void BlueBase::addServicesToDevice( const QString& device, Services::ValueList servicesList ) { qDebug("fill services list"); QMap<QString,BTDeviceItem*>::Iterator it; BTDeviceItem* deviceItem = 0; // get the right devices which requested the search it = m_deviceList.find( device ); if( it == m_deviceList.end() ) return; deviceItem = it.data(); // remove previous entries QList<QListViewItem> tempList; tempList.setAutoDelete( true ); QListViewItem * child = deviceItem->firstChild(); while( child ) { tempList.append( child ); child = child->nextSibling(); } tempList.clear(); QValueList<OpieTooth::Services>::Iterator it2; BTServiceItem* serviceItem; if (!servicesList.isEmpty() ) { // add services QMap<int, QString> list; QMap<int, QString>::Iterator classIt; for( it2 = servicesList.begin(); it2 != servicesList.end(); ++it2 ) { serviceItem = new BTServiceItem( deviceItem, (*it2) ); list = (*it2).classIdList(); classIt = list.begin(); int classId=0; if ( classIt != list.end() ) { classId = classIt.key(); } serviceItem->setPixmap( 0, m_iconLoader->serviceIcon( classId ) ); } } else { Services s1; s1.setServiceName( tr("no services found") ); serviceItem = new BTServiceItem( deviceItem, s1 ); } // now remove them from the list m_deviceList.remove( it ); } void BlueBase::addSignalStrength() { QListViewItemIterator it( ListView4 ); for ( ; it.current(); ++it ) { m_localDevice->signalStrength( ((BTConnectionItem*)it.current() )->connection().mac() ); } QTimer::singleShot( 5000, this, SLOT( addSignalStrength() ) ); } void BlueBase::addSignalStrength( const QString& mac, const QString& strength ) { QListViewItemIterator it( ListView4 ); for ( ; it.current(); ++it ) { if( ((BTConnectionItem*)it.current())->connection().mac() == mac ) { ((BTConnectionItem*)it.current() )->setSignalStrength( strength ); } } } /** * Add the existing connections (pairs) to the connections tab. * This one triggers the search */ void BlueBase::addConnectedDevices() { m_localDevice->searchConnections(); } /** * This adds the found connections to the connection tab. * @param connectionList the ValueList with all current connections */ void BlueBase::addConnectedDevices( ConnectionState::ValueList connectionList ) { QValueList<OpieTooth::ConnectionState>::Iterator it; BTConnectionItem * connectionItem; if ( !connectionList.isEmpty() ) { for (it = connectionList.begin(); it != connectionList.end(); ++it) { QListViewItemIterator it2( ListView4 ); bool found = false; for ( ; it2.current(); ++it2 ) { if( ( (BTConnectionItem*)it2.current())->connection().mac() == (*it).mac() ) { found = true; } } if ( found == false ) { connectionItem = new BTConnectionItem( ListView4, (*it) ); if( m_deviceList.find((*it).mac()).data() ) { connectionItem->setName( m_deviceList.find( (*it).mac()).data()->name() ); } } } QListViewItemIterator it2( ListView4 ); for ( ; it2.current(); ++it2 ) { bool found = false; for (it = connectionList.begin(); it != connectionList.end(); ++it) { if( ( ((BTConnectionItem*)it2.current())->connection().mac() ) == (*it).mac() ) { found = true; } } if ( !found ) { delete it2.current(); } } } else { ListView4->clear(); ConnectionState con; con.setMac( tr("No connections found") ); connectionItem = new BTConnectionItem( ListView4 , con ); } // recall connection search after some time QTimer::singleShot( 15000, this, SLOT( addConnectedDevices() ) ); } /** * Find out if a device can currently be reached * @param device */ void BlueBase::deviceActive( const RemoteDevice &device ) { // search by mac, async, gets a signal back // We should have a BTDeviceItem there or where does it get added to the map -zecke m_localDevice->isAvailable( device.mac() ); } /** * The signal catcher. Set the avail. status on device. * @param device - the mac address * @param connected - if it is avail. or not */ void BlueBase::deviceActive( const QString& device, bool connected ) { qDebug("deviceActive slot"); QMap<QString,BTDeviceItem*>::Iterator it; it = m_deviceList.find( device ); if( it == m_deviceList.end() ) return; BTDeviceItem* deviceItem = it.data(); if ( connected ) { deviceItem->setPixmap( 1, m_onPix ); } else { deviceItem->setPixmap( 1, m_offPix ); } m_deviceList.remove( it ); } /** * Open the "scan for devices" dialog */ void BlueBase::startScan() { ScanDialog *scan = new ScanDialog( this, "ScanDialog", true, WDestructiveClose ); QObject::connect( scan, SIGNAL( selectedDevices( const QValueList<RemoteDevice>& ) ), this, SLOT( addSearchedDevices( const QValueList<RemoteDevice>& ) ) ); scan->showMaximized(); } /** * Set the informations about the local device in information Tab */ void BlueBase::setInfo() { StatusLabel->setText( status() ); } /** * Decontructor */ BlueBase::~BlueBase() { writeSavedDevices(); delete m_iconLoader; } /** * find searches the ListView for a BTDeviceItem containig * the same Device if found return true else false * @param dev RemoteDevice to find * @return returns true if found */ bool BlueBase::find( const RemoteDevice& rem ) { QListViewItemIterator it( ListView2 ); BTListItem* item; BTDeviceItem* device; for (; it.current(); ++it ) { item = (BTListItem*) it.current(); if ( item->typeId() != BTListItem::Device ) continue; device = (BTDeviceItem*)item; if ( rem.equals( device->remoteDevice() ) ) return true; } return false; // not found } 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 @@ -1,440 +1,395 @@ <!DOCTYPE UI><UI> <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> - <widget> - <class>QTabWidget</class> + <property> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <vbox> <property stdset="1"> - <name>name</name> - <cstring>Status</cstring> + <name>margin</name> + <number>0</number> </property> <property stdset="1"> - <name>geometry</name> - <rect> - <x>0</x> - <y>0</y> - <width>260</width> - <height>350</height> - </rect> + <name>spacing</name> + <number>0</number> </property> <widget> - <class>QWidget</class> + <class>QTabWidget</class> <property stdset="1"> <name>name</name> - <cstring>tab</cstring> + <cstring>Status</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> + <name>layoutMargin</name> + </property> + <property> + <name>layoutSpacing</name> + </property> + <widget> + <class>QWidget</class> <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> + <cstring>tab</cstring> </property> - <property stdset="1"> - <name>orientation</name> - <enum>Vertical</enum> - </property> - <property stdset="1"> - <name>sizeType</name> - <enum>Fixed</enum> - </property> - <property> - <name>sizeHint</name> - <size> - <width>20</width> - <height>20</height> - </size> - </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> - <name>resizeable</name> - <bool>true</bool> - </property> - </column> - <column> - <property> - <name>text</name> - <string>Online</string> - </property> - <property> - <name>clickable</name> - <bool>true</bool> + <attribute> + <name>title</name> + <string>Devices</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> </property> - <property> - <name>resizeable</name> - <bool>true</bool> + <property stdset="1"> + <name>spacing</name> + <number>2</number> </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> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Device Name</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Online</string> + </property> + <property> + <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> + </widget> + <widget> + <class>QPushButton</class> + <property stdset="1"> + <name>name</name> + <cstring>PushButton2</cstring> + </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>QPushButton</class> + <class>QWidget</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> + <cstring>tab</cstring> </property> - </widget> - </widget> - <widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>tab</cstring> - </property> - <attribute> - <name>title</name> - <string>Connections</string> - </attribute> - <widget> - <class>QListView</class> - <column> - <property> - <name>text</name> - <string>Device Name</string> - </property> - <property> - <name>clickable</name> - <bool>true</bool> - </property> - <property> - <name>resizeable</name> - <bool>true</bool> - </property> - </column> - <column> - <property> - <name>text</name> - <string>Connection type</string> - </property> - <property> - <name>clickable</name> - <bool>true</bool> - </property> - <property> - <name>resizeable</name> - <bool>true</bool> - </property> - </column> - <column> - <property> - <name>text</name> - <string>Signal</string> - </property> - <property> - <name>clickable</name> - <bool>true</bool> + <attribute> + <name>title</name> + <string>Connections</string> + </attribute> + <vbox> + <property stdset="1"> + <name>margin</name> + <number>2</number> </property> - <property> - <name>resizeable</name> - <bool>true</bool> + <property stdset="1"> + <name>spacing</name> + <number>2</number> </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> - </widget> - <widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>tab</cstring> - </property> - <attribute> - <name>title</name> - <string>Config</string> - </attribute> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>deviceNameLabel</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>10</y> - <width>70</width> - <height>20</height> - </rect> - </property> - <property stdset="1"> - <name>text</name> - <string>Device Name</string> - </property> - </widget> - <widget> - <class>QLabel</class> - <property stdset="1"> - <name>name</name> - <cstring>passkeyLabel</cstring> - </property> - <property stdset="1"> - <name>geometry</name> - <rect> - <x>10</x> - <y>50</y> - <width>80</width> - <height>20</height> - </rect> - </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> + <class>QListView</class> + <column> + <property> + <name>text</name> + <string>Device Name</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Connection type</string> + </property> + <property> + <name>clickable</name> + <bool>true</bool> + </property> + <property> + <name>resizeable</name> + <bool>true</bool> + </property> + </column> + <column> + <property> + <name>text</name> + <string>Signal</string> + </property> + <property> + <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> + </widget> + </vbox> </widget> <widget> - <class>QLayoutWidget</class> + <class>QWidget</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> + <cstring>tab</cstring> </property> + <attribute> + <name>title</name> + <string>Config</string> + </attribute> <vbox> <property stdset="1"> <name>margin</name> - <number>0</number> + <number>2</number> </property> <property stdset="1"> <name>spacing</name> - <number>6</number> + <number>2</number> </property> <widget> - <class>QCheckBox</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>authCheckBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>enable authentification</string> + <cstring>Layout2</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>deviceNameLabel</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Device Name</string> + </property> + </widget> + <widget> + <class>QLineEdit</class> + <property stdset="1"> + <name>name</name> + <cstring>deviceNameLine</cstring> + </property> + </widget> + </hbox> </widget> <widget> - <class>QCheckBox</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>cryptCheckBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>enable encryption</string> + <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>echoMode</name> + <enum>Password</enum> + </property> + </widget> + </hbox> </widget> <widget> - <class>QCheckBox</class> + <class>QLayoutWidget</class> <property stdset="1"> <name>name</name> - <cstring>pagescanCheckBox</cstring> - </property> - <property stdset="1"> - <name>text</name> - <string>Enable Page scan</string> + <cstring>Layout5</cstring> </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"> + <name>name</name> + <cstring>authCheckBox</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>enable authentification</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>cryptCheckBox</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>enable encryption</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <property stdset="1"> + <name>name</name> + <cstring>pagescanCheckBox</cstring> + </property> + <property stdset="1"> + <name>text</name> + <string>Enable Page scan</string> + </property> + </widget> + <widget> + <class>QCheckBox</class> + <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>QCheckBox</class> + <class>QPushButton</class> <property stdset="1"> <name>name</name> - <cstring>inquiryscanCheckBox</cstring> + <cstring>configApplyButton</cstring> </property> <property stdset="1"> <name>text</name> - <string>Enable Inquiry scan</string> + <string>Apply</string> </property> </widget> </vbox> </widget> <widget> - <class>QLineEdit</class> + <class>QWidget</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> - </widget> - <widget> - <class>QWidget</class> - <property stdset="1"> - <name>name</name> - <cstring>tab</cstring> - </property> - <attribute> - <name>title</name> - <string>Status</string> - </attribute> - <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> + <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>text</name> + <string>Status Label</string> + </property> + </widget> + </vbox> </widget> </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 @@ -1,70 +1,62 @@ #include <qpe/qcopenvelope_qws.h> #include <qtimer.h> #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 = new QAction(); // so it's get deleted + 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 |