author | mickeyl <mickeyl> | 2003-10-29 18:18:19 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-10-29 18:18:19 (UTC) |
commit | 1af1f1d9f398d38a2bc666cd2edff5725da7a770 (patch) (unidiff) | |
tree | b3bb0d90cafc1e933b5b9297a7b2669ce3b184ea /noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | |
parent | 35615947e11575a61456c8483e7f6d67fe59d5ed (diff) | |
download | opie-1af1f1d9f398d38a2bc666cd2edff5725da7a770.zip opie-1af1f1d9f398d38a2bc666cd2edff5725da7a770.tar.gz opie-1af1f1d9f398d38a2bc666cd2edff5725da7a770.tar.bz2 |
mrege noncore/net/*
Diffstat (limited to 'noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp new file mode 100644 index 0000000..b5cc074 --- a/dev/null +++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.cpp | |||
@@ -0,0 +1,120 @@ | |||
1 | |||
2 | #include "rfcommassigndialogimpl.h" | ||
3 | #include "rfcommassigndialogitem.h" | ||
4 | #include "rfcommconfhandler.h" | ||
5 | |||
6 | #include <qpe/config.h> | ||
7 | |||
8 | #include <qlayout.h> | ||
9 | |||
10 | using namespace OpieTooth; | ||
11 | |||
12 | // TODO: write only the file in bluebase? | ||
13 | // 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? | ||
15 | |||
16 | |||
17 | RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | ||
18 | : RfcommAssignDialogBase( parent, name, modal, fl ) { | ||
19 | |||
20 | m_range = 5; | ||
21 | |||
22 | m_scrollView = new QScrollView( this ); | ||
23 | m_scrollView->setResizePolicy( QScrollView::AutoOneFit ); | ||
24 | m_scrollView->setHScrollBarMode( QScrollView::AlwaysOff ); | ||
25 | |||
26 | RfcommAssignDialogBaseLayout->addWidget( m_scrollView ); | ||
27 | |||
28 | m_box = new QVBox( m_scrollView->viewport() ); | ||
29 | m_scrollView->addChild( m_box ); | ||
30 | |||
31 | confHandler = new RfCommConfHandler( "/etc/bluetooth/rfcomm.conf" ); | ||
32 | |||
33 | loadConfig(); | ||
34 | } | ||
35 | |||
36 | RfcommAssignDialog::~RfcommAssignDialog() { | ||
37 | if ( confHandler ) { | ||
38 | delete confHandler; | ||
39 | } | ||
40 | } | ||
41 | |||
42 | |||
43 | void RfcommAssignDialog::newDevice( const QString & mac ) { | ||
44 | |||
45 | for ( int i = 0 ; i < m_range; i++ ) { | ||
46 | |||
47 | QMap<QString, RfCommConfObject*>::Iterator it; | ||
48 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); | ||
49 | // make sure that rfcommX is not assigned yet | ||
50 | if ( it == confHandler->foundEntries().end() ) { | ||
51 | QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); | ||
52 | dialog.showMaximized(); | ||
53 | RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); | ||
54 | newDev->setIdent( i ); | ||
55 | newDev->setMac( mac ); | ||
56 | |||
57 | if ( dialog.exec() == QDialog::Accepted ) { | ||
58 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); | ||
59 | m_itemList.insert( i , rfcomm ); | ||
60 | rfcomm->setIdent( i ); | ||
61 | rfcomm->setMac( mac ); | ||
62 | rfcomm->setChannel( newDev->channel() ); | ||
63 | rfcomm->setComment( newDev->comment() ); | ||
64 | qDebug( "New device set up" ); | ||
65 | } | ||
66 | } | ||
67 | } | ||
68 | } | ||
69 | |||
70 | void RfcommAssignDialog::loadConfig() { | ||
71 | |||
72 | //Config cfg( "bluetoothmanager-rfcommbind" ); | ||
73 | |||
74 | for ( int i = 0 ; i < m_range; i++ ) { | ||
75 | // cfg.setGroup( QString("%1").arg( i ) ); | ||
76 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); | ||
77 | m_itemList.insert( i , rfcomm ); | ||
78 | rfcomm->setIdent( i ); | ||
79 | QMap<QString, RfCommConfObject*>::Iterator it; | ||
80 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); | ||
81 | if ( it != confHandler->foundEntries().end() ) { | ||
82 | qDebug( "Found key in foundEntries() " ); | ||
83 | rfcomm->setMac( it.data()->mac() ); | ||
84 | rfcomm->setChannel( it.data()->channel() ); | ||
85 | rfcomm->setComment( it.data()->comment() ); | ||
86 | } | ||
87 | /* Use rfcomm.conf directly for now | ||
88 | * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); | ||
89 | * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); | ||
90 | * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); | ||
91 | */ | ||
92 | } | ||
93 | } | ||
94 | |||
95 | |||
96 | void RfcommAssignDialog::saveConfig() { | ||
97 | |||
98 | //Config cfg( "bluetoothmanager-rfcommbind" ); | ||
99 | |||
100 | QMap< int, RfcommDialogItem*>::Iterator it; | ||
101 | |||
102 | QMap< QString, RfCommConfObject*> outMap; | ||
103 | |||
104 | for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) { | ||
105 | |||
106 | //cfg.setGroup( QString("%1").arg( it.key() ) ); | ||
107 | RfcommDialogItem *rfcomm = it.data(); | ||
108 | |||
109 | |||
110 | outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); | ||
111 | |||
112 | |||
113 | //cfg.writeEntry( "mac", rfcomm->mac() ); | ||
114 | //cfg.writeEntry( "channel", rfcomm->channel() ); | ||
115 | //cfg.writeEntry( "comment", rfcomm->comment() ); | ||
116 | } | ||
117 | |||
118 | confHandler->save( outMap ); | ||
119 | |||
120 | } | ||