summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
Unidiff
Diffstat (limited to 'noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp51
1 files changed, 33 insertions, 18 deletions
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
index b5cc074..fc76301 100644
--- a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
+++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp
@@ -1,24 +1,28 @@
1 1
2#include "rfcommassigndialogimpl.h" 2#include "rfcommassigndialogimpl.h"
3#include "rfcommassigndialogitem.h" 3#include "rfcommassigndialogitem.h"
4#include "rfcommconfhandler.h" 4#include "rfcommconfhandler.h"
5 5
6/* OPIE */
6#include <qpe/config.h> 7#include <qpe/config.h>
8#include <qpe/qpeapplication.h>
7 9
10/* QT */
8#include <qlayout.h> 11#include <qlayout.h>
9 12
10using namespace OpieTooth; 13using namespace OpieTooth;
11 14
12// TODO: write only the file in bluebase? 15// TODO: write only the file in bluebase?
13// muss rfcommd dann neu gestartet werden 16// muss rfcommd dann neu gestartet werden
14// sollte rfcomm bind all nicht eh default config sein ( polled das? - d.h. sobald nen gerät in der nähe ist bindet es? 17// sollte rfcomm bind all nicht eh default config sein ( polled das? - d.h. sobald nen gerät in der nähe ist bindet es?
15 18
16 19
17RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) 20RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
18 : RfcommAssignDialogBase( parent, name, modal, fl ) { 21 : RfcommAssignDialogBase( parent, name, modal, fl )
22{
19 23
20 m_range = 5; 24 m_range = 5;
21 25
22 m_scrollView = new QScrollView( this ); 26 m_scrollView = new QScrollView( this );
23 m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); 27 m_scrollView->setResizePolicy( QScrollView::AutoOneFit );
24 m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff ); 28 m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff );
@@ -30,81 +34,92 @@ RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool
30 34
31 confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" ); 35 confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" );
32 36
33 loadConfig(); 37 loadConfig();
34} 38}
35 39
36RfcommAssignDialog::~RfcommAssignDialog() { 40RfcommAssignDialog::~RfcommAssignDialog()
37 if ( confHandler ) { 41{
42 if ( confHandler )
43 {
38 delete confHandler; 44 delete confHandler;
39 } 45 }
40} 46}
41 47
42 48
43void RfcommAssignDialog::newDevice( const QString & mac ) { 49void RfcommAssignDialog::newDevice( const QString & mac )
50{
44 51
45 for ( int i = 0 ; i < m_range; i++ ) { 52 for ( int i = 0 ; i < m_range; i++ )
53 {
46 54
47 QMap<QString, RfCommConfObject*>::Iterator it; 55 QMap<QString, RfCommConfObject*>::Iterator it;
48 it = confHandler->foundEntries().find( QString("%1").arg( i ) ); 56 it = confHandler->foundEntries().find( QString("%1").arg( i ) );
49 // make sure that rfcommX is not assigned yet 57 // make sure that rfcommX is not assigned yet
50 if ( it == confHandler->foundEntries().end() ) { 58 if ( it == confHandler->foundEntries().end() )
59 {
51 QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); 60 QDialog dialog( this, "newdevice", true, WStyle_ContextHelp );
52 dialog.showMaximized(); 61
53 RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); 62 RfcommDialogItem *newDev = new RfcommDialogItem( &dialog );
54 newDev->setIdent( i ); 63 newDev->setIdent( i );
55 newDev->setMac( mac ); 64 newDev->setMac( mac );
56 65
57 if ( dialog.exec() == QDialog::Accepted ) { 66 if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted )
67 {
58 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); 68 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box );
59 m_itemList.insert( i , rfcomm ); 69 m_itemList.insert( i , rfcomm );
60 rfcomm->setIdent( i ); 70 rfcomm->setIdent( i );
61 rfcomm->setMac( mac ); 71 rfcomm->setMac( mac );
62 rfcomm->setChannel( newDev->channel() ); 72 rfcomm->setChannel( newDev->channel() );
63 rfcomm->setComment( newDev->comment() ); 73 rfcomm->setComment( newDev->comment() );
64 qDebug( "New device set up" ); 74 qDebug( "New device set up" );
65 } 75 }
66 } 76 }
67 } 77 }
68} 78}
69 79
70void RfcommAssignDialog::loadConfig() { 80void RfcommAssignDialog::loadConfig()
81{
71 82
72 //Config cfg( "bluetoothmanager-rfcommbind" ); 83 //Config cfg( "bluetoothmanager-rfcommbind" );
73 84
74 for ( int i = 0 ; i < m_range; i++ ) { 85 for ( int i = 0 ; i < m_range; i++ )
86 {
75 // cfg.setGroup( QString("%1").arg( i ) ); 87 // cfg.setGroup( QString("%1").arg( i ) );
76 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); 88 RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box );
77 m_itemList.insert( i , rfcomm ); 89 m_itemList.insert( i , rfcomm );
78 rfcomm->setIdent( i ); 90 rfcomm->setIdent( i );
79 QMap<QString, RfCommConfObject*>::Iterator it; 91 QMap<QString, RfCommConfObject*>::Iterator it;
80 it = confHandler->foundEntries().find( QString("%1").arg( i ) ); 92 it = confHandler->foundEntries().find( QString("%1").arg( i ) );
81 if ( it != confHandler->foundEntries().end() ) { 93 if ( it != confHandler->foundEntries().end() )
94 {
82 qDebug( "Found key in foundEntries() " ); 95 qDebug( "Found key in foundEntries() " );
83 rfcomm->setMac( it.data()->mac() ); 96 rfcomm->setMac( it.data()->mac() );
84 rfcomm->setChannel( it.data()->channel() ); 97 rfcomm->setChannel( it.data()->channel() );
85 rfcomm->setComment( it.data()->comment() ); 98 rfcomm->setComment( it.data()->comment() );
86 } 99 }
87 /* Use rfcomm.conf directly for now 100 /* Use rfcomm.conf directly for now
88 * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); 101 * rfcomm->setMac( cfg.readEntry( "mac", "" ) );
89 * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); 102 * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) );
90 * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); 103 * rfcomm->setComment( cfg.readEntry( "comment", "" ) );
91 */ 104 */
92 } 105 }
93} 106}
94 107
95 108
96void RfcommAssignDialog::saveConfig() { 109void RfcommAssignDialog::saveConfig()
110{
97 111
98 //Config cfg( "bluetoothmanager-rfcommbind" ); 112 //Config cfg( "bluetoothmanager-rfcommbind" );
99 113
100 QMap< int, RfcommDialogItem*>::Iterator it; 114 QMap< int, RfcommDialogItem*>::Iterator it;
101 115
102 QMap< QString, RfCommConfObject*> outMap; 116 QMap< QString, RfCommConfObject*> outMap;
103 117
104 for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) { 118 for( it = m_itemList.begin(); it != m_itemList.end(); ++it )
119 {
105 120
106 //cfg.setGroup( QString("%1").arg( it.key() ) ); 121 //cfg.setGroup( QString("%1").arg( it.key() ) );
107 RfcommDialogItem *rfcomm = it.data(); 122 RfcommDialogItem *rfcomm = it.data();
108 123
109 124
110 outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); 125 outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) );