author | korovkin <korovkin> | 2006-03-25 18:10:13 (UTC) |
---|---|---|
committer | korovkin <korovkin> | 2006-03-25 18:10:13 (UTC) |
commit | c4f82599db775f52c7e04cce09c7c45ecc89ccfd (patch) (side-by-side diff) | |
tree | 81d48e5363a2135bb6820510ae7f5dee9999e8f2 /noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | |
parent | da3c4a6231882bc56266162415a8d1a2a1bf0293 (diff) | |
download | opie-c4f82599db775f52c7e04cce09c7c45ecc89ccfd.zip opie-c4f82599db775f52c7e04cce09c7c45ecc89ccfd.tar.gz opie-c4f82599db775f52c7e04cce09c7c45ecc89ccfd.tar.bz2 |
Added RFCOMM binding table functionality.
Diffstat (limited to 'noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | 115 |
1 files changed, 65 insertions, 50 deletions
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp index be720b8..7943deb 100644 --- a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp +++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp @@ -1,3 +1,13 @@ +/* $Id$ */ +/* RFCOMM binding table edit dialog */ +/*************************************************************************** + * * + * 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 "rfcommassigndialogimpl.h" #include "rfcommassigndialogitem.h" @@ -22,17 +32,16 @@ using namespace OpieTooth; RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) : RfcommAssignDialogBase( parent, name, modal, fl ) { - m_range = 5; - m_scrollView = new QScrollView( this ); + m_scrollView = new QScrollView(this); m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff ); - RfcommAssignDialogBaseLayout->addWidget( m_scrollView ); + RfcommAssignDialogBaseLayout->addWidget(m_scrollView); - m_box = new QVBox( m_scrollView->viewport() ); - m_scrollView->addChild( m_box ); + m_box = new QVBox(m_scrollView->viewport()); + m_scrollView->addChild(m_box); confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" ); @@ -48,92 +57,98 @@ RfcommAssignDialog::~RfcommAssignDialog() } -void RfcommAssignDialog::newDevice( const QString & mac ) +void RfcommAssignDialog::newDevice(const QString & mac, int channel) { for ( int i = 0 ; i < m_range; i++ ) { - QMap<QString, RfCommConfObject*>::Iterator it; - it = confHandler->foundEntries().find( QString("%1").arg( i ) ); + it = confHandler->foundEntries().find(QString::number(i)); // make sure that rfcommX is not assigned yet - if ( it == confHandler->foundEntries().end() ) + if ( it == confHandler->foundEntries().end() ) { QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); dialog.setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); - - RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); - newDev->setIdent( i ); - newDev->setMac( mac ); + QVBoxLayout layout(&dialog); + layout.setSpacing( 0 ); + layout.setMargin( 0 ); + + RfcommDialogItem newDev(&dialog); + newDev.setIdent( i ); + newDev.setMac( mac ); + newDev.setChannel( channel ); + layout.addWidget(&newDev); if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted ) { - RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); - m_itemList.insert( i , rfcomm ); + QMap<int, RfcommDialogItem*>::Iterator it; + it = m_itemList.find( i ); + RfcommDialogItem *rfcomm = it.data(); rfcomm->setIdent( i ); rfcomm->setMac( mac ); - rfcomm->setChannel( newDev->channel() ); - rfcomm->setComment( newDev->comment() ); + rfcomm->setChannel( newDev.channel() ); + rfcomm->setComment( newDev.comment() ); + rfcomm->setBind( newDev.isBind() ); odebug << "New device set up" << oendl; } + break; } } } +/* + * Load rfcomm bind configuration + */ void RfcommAssignDialog::loadConfig() { - - //Config cfg( "bluetoothmanager-rfcommbind" ); - for ( int i = 0 ; i < m_range; i++ ) { - // cfg.setGroup( QString("%1").arg( i ) ); RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); - m_itemList.insert( i , rfcomm ); - rfcomm->setIdent( i ); + m_itemList.insert(i, rfcomm); + rfcomm->setIdent(i); QMap<QString, RfCommConfObject*>::Iterator it; - it = confHandler->foundEntries().find( QString("%1").arg( i ) ); - if ( it != confHandler->foundEntries().end() ) + it = confHandler->foundEntries().find(QString::number(i)); + if (it != confHandler->foundEntries().end()) { - odebug << "Found key in foundEntries() " << oendl; - rfcomm->setMac( it.data()->mac() ); - rfcomm->setChannel( it.data()->channel() ); - rfcomm->setComment( it.data()->comment() ); + rfcomm->setMac(it.data()->mac()); + rfcomm->setChannel(it.data()->channel()); + rfcomm->setComment(it.data()->comment()); + rfcomm->setBind(it.data()->isBind()); } - /* Use rfcomm.conf directly for now - * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); - * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); - * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); - */ } } +/* + * Save rfcomm bind configuration + */ void RfcommAssignDialog::saveConfig() { - - //Config cfg( "bluetoothmanager-rfcommbind" ); - QMap< int, RfcommDialogItem*>::Iterator it; - QMap< QString, RfCommConfObject*> outMap; for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) { - - //cfg.setGroup( QString("%1").arg( it.key() ) ); RfcommDialogItem *rfcomm = it.data(); - - - outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); - - - //cfg.writeEntry( "mac", rfcomm->mac() ); - //cfg.writeEntry( "channel", rfcomm->channel() ); - //cfg.writeEntry( "comment", rfcomm->comment() ); + if (rfcomm->mac().isEmpty()) + continue; + outMap.insert(QString::number(it.key()), + new RfCommConfObject(it.key(), + rfcomm->mac(), rfcomm->channel(), rfcomm->comment(), + rfcomm->isBind())); } + confHandler->save(outMap); +} - confHandler->save( outMap ); - +/* + * Reaction on the OK button + */ +void RfcommAssignDialog::accept() +{ + odebug << "save configuration" << oendl; + saveConfig(); + RfcommAssignDialogBase::accept(); } + +//eof |