10 files changed, 197 insertions, 80 deletions
diff --git a/noncore/net/opietooth/manager/TODO.txt b/noncore/net/opietooth/manager/TODO.txt index e6bd9b1..76fae68 100644 --- a/noncore/net/opietooth/manager/TODO.txt +++ b/noncore/net/opietooth/manager/TODO.txt | |||
@@ -1,5 +1,4 @@ | |||
1 | 1. Make bind table edit /etc/bluetooth/rfcomm.conf file. | 1 | 1. Add an rfcomm port number to the connection dialog. |
2 | 2. Add an rfcomm port number to the connection dialog. | 2 | 2. Collect requirements from others. |
3 | 3. Collect requirements from others. | ||
4 | 3 | ||
5 | //eof | 4 | //eof |
diff --git a/noncore/net/opietooth/manager/btdeviceitem.cpp b/noncore/net/opietooth/manager/btdeviceitem.cpp index fb1b1c1..c112463 100644 --- a/noncore/net/opietooth/manager/btdeviceitem.cpp +++ b/noncore/net/opietooth/manager/btdeviceitem.cpp | |||
@@ -7,7 +7,7 @@ using namespace OpieTooth; | |||
7 | BTDeviceItem::BTDeviceItem( QListView* parent, const RemoteDevice& dev ) | 7 | BTDeviceItem::BTDeviceItem( QListView* parent, const RemoteDevice& dev ) |
8 | : BTListItem( parent ) { | 8 | : BTListItem( parent ) { |
9 | 9 | ||
10 | setText( 0, dev.name() ); | 10 | setText( 0, dev.name().utf8() ); |
11 | m_device = dev; | 11 | m_device = dev; |
12 | }; | 12 | }; |
13 | BTDeviceItem::~BTDeviceItem() { | 13 | BTDeviceItem::~BTDeviceItem() { |
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 @@ | |||
1 | /* $Id$ */ | ||
2 | /* RFCOMM binding table edit dialog */ | ||
3 | /*************************************************************************** | ||
4 | * * | ||
5 | * This program is free software; you can redistribute it and/or modify * | ||
6 | * it under the terms of the GNU General Public License as published by * | ||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||
8 | * (at your option) any later version. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
1 | 11 | ||
2 | #include "rfcommassigndialogimpl.h" | 12 | #include "rfcommassigndialogimpl.h" |
3 | #include "rfcommassigndialogitem.h" | 13 | #include "rfcommassigndialogitem.h" |
@@ -22,7 +32,6 @@ using namespace OpieTooth; | |||
22 | RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) | 32 | RfcommAssignDialog::RfcommAssignDialog( QWidget* parent, const char* name, bool modal, WFlags fl ) |
23 | : RfcommAssignDialogBase( parent, name, modal, fl ) | 33 | : RfcommAssignDialogBase( parent, name, modal, fl ) |
24 | { | 34 | { |
25 | |||
26 | m_range = 5; | 35 | m_range = 5; |
27 | 36 | ||
28 | m_scrollView = new QScrollView( this ); | 37 | m_scrollView = new QScrollView( this ); |
@@ -48,92 +57,98 @@ RfcommAssignDialog::~RfcommAssignDialog() | |||
48 | } | 57 | } |
49 | 58 | ||
50 | 59 | ||
51 | void RfcommAssignDialog::newDevice( const QString & mac ) | 60 | void RfcommAssignDialog::newDevice(const QString & mac, int channel) |
52 | { | 61 | { |
53 | 62 | ||
54 | for ( int i = 0 ; i < m_range; i++ ) | 63 | for ( int i = 0 ; i < m_range; i++ ) |
55 | { | 64 | { |
56 | |||
57 | QMap<QString, RfCommConfObject*>::Iterator it; | 65 | QMap<QString, RfCommConfObject*>::Iterator it; |
58 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); | 66 | it = confHandler->foundEntries().find(QString::number(i)); |
59 | // make sure that rfcommX is not assigned yet | 67 | // make sure that rfcommX is not assigned yet |
60 | if ( it == confHandler->foundEntries().end() ) | 68 | if ( it == confHandler->foundEntries().end() ) |
61 | { | 69 | { |
62 | QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); | 70 | QDialog dialog( this, "newdevice", true, WStyle_ContextHelp ); |
63 | dialog.setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, | 71 | dialog.setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, |
64 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); | 72 | (QSizePolicy::SizeType)7, sizePolicy().hasHeightForWidth())); |
73 | QVBoxLayout layout(&dialog); | ||
74 | layout.setSpacing( 0 ); | ||
75 | layout.setMargin( 0 ); | ||
65 | 76 | ||
66 | RfcommDialogItem *newDev = new RfcommDialogItem( &dialog ); | 77 | RfcommDialogItem newDev(&dialog); |
67 | newDev->setIdent( i ); | 78 | newDev.setIdent( i ); |
68 | newDev->setMac( mac ); | 79 | newDev.setMac( mac ); |
80 | newDev.setChannel( channel ); | ||
81 | layout.addWidget(&newDev); | ||
69 | 82 | ||
70 | if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted ) | 83 | if ( QPEApplication::execDialog( &dialog ) == QDialog::Accepted ) |
71 | { | 84 | { |
72 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); | 85 | QMap<int, RfcommDialogItem*>::Iterator it; |
73 | m_itemList.insert( i , rfcomm ); | 86 | it = m_itemList.find( i ); |
87 | RfcommDialogItem *rfcomm = it.data(); | ||
74 | rfcomm->setIdent( i ); | 88 | rfcomm->setIdent( i ); |
75 | rfcomm->setMac( mac ); | 89 | rfcomm->setMac( mac ); |
76 | rfcomm->setChannel( newDev->channel() ); | 90 | rfcomm->setChannel( newDev.channel() ); |
77 | rfcomm->setComment( newDev->comment() ); | 91 | rfcomm->setComment( newDev.comment() ); |
92 | rfcomm->setBind( newDev.isBind() ); | ||
78 | odebug << "New device set up" << oendl; | 93 | odebug << "New device set up" << oendl; |
79 | } | 94 | } |
95 | break; | ||
80 | } | 96 | } |
81 | } | 97 | } |
82 | } | 98 | } |
83 | 99 | ||
100 | /* | ||
101 | * Load rfcomm bind configuration | ||
102 | */ | ||
84 | void RfcommAssignDialog::loadConfig() | 103 | void RfcommAssignDialog::loadConfig() |
85 | { | 104 | { |
86 | |||
87 | //Config cfg( "bluetoothmanager-rfcommbind" ); | ||
88 | |||
89 | for ( int i = 0 ; i < m_range; i++ ) | 105 | for ( int i = 0 ; i < m_range; i++ ) |
90 | { | 106 | { |
91 | // cfg.setGroup( QString("%1").arg( i ) ); | ||
92 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); | 107 | RfcommDialogItem *rfcomm = new RfcommDialogItem( m_box ); |
93 | m_itemList.insert( i , rfcomm ); | 108 | m_itemList.insert( i , rfcomm ); |
94 | rfcomm->setIdent( i ); | 109 | rfcomm->setIdent( i ); |
95 | QMap<QString, RfCommConfObject*>::Iterator it; | 110 | QMap<QString, RfCommConfObject*>::Iterator it; |
96 | it = confHandler->foundEntries().find( QString("%1").arg( i ) ); | 111 | it = confHandler->foundEntries().find(QString::number(i)); |
97 | if ( it != confHandler->foundEntries().end() ) | 112 | if ( it != confHandler->foundEntries().end() ) |
98 | { | 113 | { |
99 | odebug << "Found key in foundEntries() " << oendl; | ||
100 | rfcomm->setMac( it.data()->mac() ); | 114 | rfcomm->setMac( it.data()->mac() ); |
101 | rfcomm->setChannel( it.data()->channel() ); | 115 | rfcomm->setChannel( it.data()->channel() ); |
102 | rfcomm->setComment( it.data()->comment() ); | 116 | rfcomm->setComment( it.data()->comment() ); |
117 | rfcomm->setBind(it.data()->isBind()); | ||
103 | } | 118 | } |
104 | /* Use rfcomm.conf directly for now | ||
105 | * rfcomm->setMac( cfg.readEntry( "mac", "" ) ); | ||
106 | * rfcomm->setChannel( cfg.readNumEntry( "channel", 1 ) ); | ||
107 | * rfcomm->setComment( cfg.readEntry( "comment", "" ) ); | ||
108 | */ | ||
109 | } | 119 | } |
110 | } | 120 | } |
111 | 121 | ||
112 | 122 | ||
123 | /* | ||
124 | * Save rfcomm bind configuration | ||
125 | */ | ||
113 | void RfcommAssignDialog::saveConfig() | 126 | void RfcommAssignDialog::saveConfig() |
114 | { | 127 | { |
115 | |||
116 | //Config cfg( "bluetoothmanager-rfcommbind" ); | ||
117 | |||
118 | QMap< int, RfcommDialogItem*>::Iterator it; | 128 | QMap< int, RfcommDialogItem*>::Iterator it; |
119 | |||
120 | QMap< QString, RfCommConfObject*> outMap; | 129 | QMap< QString, RfCommConfObject*> outMap; |
121 | 130 | ||
122 | for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) | 131 | for( it = m_itemList.begin(); it != m_itemList.end(); ++it ) |
123 | { | 132 | { |
124 | |||
125 | //cfg.setGroup( QString("%1").arg( it.key() ) ); | ||
126 | RfcommDialogItem *rfcomm = it.data(); | 133 | RfcommDialogItem *rfcomm = it.data(); |
127 | 134 | if (rfcomm->mac().isEmpty()) | |
128 | 135 | continue; | |
129 | outMap.insert( QString( "%1").arg( it.key() ), new RfCommConfObject( it.key(), rfcomm->mac(), rfcomm->channel(), rfcomm->comment() ) ); | 136 | outMap.insert(QString::number(it.key()), |
130 | 137 | new RfCommConfObject(it.key(), | |
131 | 138 | rfcomm->mac(), rfcomm->channel(), rfcomm->comment(), | |
132 | //cfg.writeEntry( "mac", rfcomm->mac() ); | 139 | rfcomm->isBind())); |
133 | //cfg.writeEntry( "channel", rfcomm->channel() ); | ||
134 | //cfg.writeEntry( "comment", rfcomm->comment() ); | ||
135 | } | 140 | } |
136 | |||
137 | confHandler->save( outMap ); | 141 | confHandler->save( outMap ); |
142 | } | ||
138 | 143 | ||
144 | /* | ||
145 | * Reaction on the OK button | ||
146 | */ | ||
147 | void RfcommAssignDialog::accept() | ||
148 | { | ||
149 | odebug << "save configuration" << oendl; | ||
150 | saveConfig(); | ||
151 | RfcommAssignDialogBase::accept(); | ||
139 | } | 152 | } |
153 | |||
154 | //eof | ||
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogimpl.h b/noncore/net/opietooth/manager/rfcommassigndialogimpl.h index 9983632..12cde0e 100644 --- a/noncore/net/opietooth/manager/rfcommassigndialogimpl.h +++ b/noncore/net/opietooth/manager/rfcommassigndialogimpl.h | |||
@@ -1,3 +1,13 @@ | |||
1 | /* $Id$ */ | ||
2 | /* RFCOMM binding table edit dialog */ | ||
3 | /*************************************************************************** | ||
4 | * * | ||
5 | * This program is free software; you can redistribute it and/or modify * | ||
6 | * it under the terms of the GNU General Public License as published by * | ||
7 | * the Free Software Foundation; either version 2 of the License, or * | ||
8 | * (at your option) any later version. * | ||
9 | * * | ||
10 | ***************************************************************************/ | ||
1 | #ifndef RFCOMMASSIGN | 11 | #ifndef RFCOMMASSIGN |
2 | #define RFCOMMASSIGN | 12 | #define RFCOMMASSIGN |
3 | 13 | ||
@@ -12,18 +22,16 @@ | |||
12 | namespace OpieTooth { | 22 | namespace OpieTooth { |
13 | 23 | ||
14 | class RfcommAssignDialog: public RfcommAssignDialogBase { | 24 | class RfcommAssignDialog: public RfcommAssignDialogBase { |
15 | |||
16 | Q_OBJECT | 25 | Q_OBJECT |
17 | |||
18 | public: | 26 | public: |
19 | 27 | RfcommAssignDialog(QWidget* parent = 0, const char* name = 0, | |
20 | RfcommAssignDialog( QWidget* parent = 0, const char* name = 0,bool modal = 0, WFlags fl = 0 ); | 28 | bool modal = 0, WFlags fl = 0); |
21 | ~RfcommAssignDialog(); | 29 | ~RfcommAssignDialog(); |
22 | 30 | ||
23 | void loadConfig(); | 31 | void loadConfig(); |
24 | void saveConfig(); | 32 | void saveConfig(); |
25 | 33 | ||
26 | void newDevice( const QString & mac ); | 34 | void newDevice( const QString & mac, int channel ); |
27 | 35 | ||
28 | private: | 36 | private: |
29 | QScrollView *m_scrollView; | 37 | QScrollView *m_scrollView; |
@@ -32,6 +40,8 @@ namespace OpieTooth { | |||
32 | QMap< int, RfcommDialogItem* > m_itemList; | 40 | QMap< int, RfcommDialogItem* > m_itemList; |
33 | QVBox *m_box; | 41 | QVBox *m_box; |
34 | RfCommConfHandler *confHandler; | 42 | RfCommConfHandler *confHandler; |
43 | protected slots: | ||
44 | virtual void accept(); | ||
35 | }; | 45 | }; |
36 | 46 | ||
37 | } | 47 | } |
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp b/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp index a41f304..472b86c 100644 --- a/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp +++ b/noncore/net/opietooth/manager/rfcommassigndialogitem.cpp | |||
@@ -4,6 +4,7 @@ | |||
4 | #include <qlineedit.h> | 4 | #include <qlineedit.h> |
5 | #include <qcombobox.h> | 5 | #include <qcombobox.h> |
6 | #include <qgroupbox.h> | 6 | #include <qgroupbox.h> |
7 | #include <qcheckbox.h> | ||
7 | 8 | ||
8 | using namespace OpieTooth; | 9 | using namespace OpieTooth; |
9 | 10 | ||
@@ -33,6 +34,10 @@ QString RfcommDialogItem::comment() { | |||
33 | return m_commentLine->text(); | 34 | return m_commentLine->text(); |
34 | } | 35 | } |
35 | 36 | ||
37 | bool RfcommDialogItem::isBind() { | ||
38 | return m_bind->isChecked(); | ||
39 | } | ||
40 | |||
36 | void RfcommDialogItem::setIdent( int ident ) { | 41 | void RfcommDialogItem::setIdent( int ident ) { |
37 | m_ident = ident; | 42 | m_ident = ident; |
38 | m_identLabel->setTitle( QString( "rfcomm%1").arg( ident ) ); | 43 | m_identLabel->setTitle( QString( "rfcomm%1").arg( ident ) ); |
@@ -50,4 +55,8 @@ void RfcommDialogItem::setComment( const QString &comment ) { | |||
50 | m_commentLine->setText( comment ); | 55 | m_commentLine->setText( comment ); |
51 | } | 56 | } |
52 | 57 | ||
58 | void RfcommDialogItem::setBind( bool dobind ) { | ||
59 | m_bind->setChecked( dobind ); | ||
60 | } | ||
53 | 61 | ||
62 | //eof | ||
diff --git a/noncore/net/opietooth/manager/rfcommassigndialogitem.h b/noncore/net/opietooth/manager/rfcommassigndialogitem.h index 34a794f..cc9c8db 100644 --- a/noncore/net/opietooth/manager/rfcommassigndialogitem.h +++ b/noncore/net/opietooth/manager/rfcommassigndialogitem.h | |||
@@ -21,11 +21,13 @@ namespace OpieTooth { | |||
21 | QString mac(); | 21 | QString mac(); |
22 | int channel(); | 22 | int channel(); |
23 | QString comment(); | 23 | QString comment(); |
24 | bool isBind(); | ||
24 | 25 | ||
25 | void setIdent( int ident ); | 26 | void setIdent( int ident ); |
26 | void setMac( const QString& mac ); | 27 | void setMac( const QString& mac ); |
27 | void setChannel( int channel ); | 28 | void setChannel( int channel ); |
28 | void setComment( const QString& comment ); | 29 | void setComment( const QString& comment ); |
30 | void setBind(bool dobind); | ||
29 | 31 | ||
30 | private: | 32 | private: |
31 | 33 | ||
diff --git a/noncore/net/opietooth/manager/rfcommconfhandler.cpp b/noncore/net/opietooth/manager/rfcommconfhandler.cpp index f82d2c8..054b446 100644 --- a/noncore/net/opietooth/manager/rfcommconfhandler.cpp +++ b/noncore/net/opietooth/manager/rfcommconfhandler.cpp | |||
@@ -11,12 +11,13 @@ using namespace OpieTooth; | |||
11 | // move to lib | 11 | // move to lib |
12 | 12 | ||
13 | 13 | ||
14 | RfCommConfObject::RfCommConfObject( int number, QString mac, int channel, QString comment ) { | 14 | RfCommConfObject::RfCommConfObject(int number, QString mac, int channel, |
15 | QString comment, bool bind) { | ||
15 | m_number = number; | 16 | m_number = number; |
16 | m_mac = mac; | 17 | m_mac = mac; |
17 | m_channel = channel; | 18 | m_channel = channel; |
18 | m_comment = comment; | 19 | m_comment = comment; |
19 | // m_foundEntries = 0; | 20 | m_doBind = bind; |
20 | } | 21 | } |
21 | 22 | ||
22 | void RfCommConfObject::setNumber( int number ) { | 23 | void RfCommConfObject::setNumber( int number ) { |
@@ -41,7 +42,6 @@ RfCommConfObject::~RfCommConfObject() { | |||
41 | 42 | ||
42 | 43 | ||
43 | RfCommConfHandler::RfCommConfHandler( const QString & filename ) { | 44 | RfCommConfHandler::RfCommConfHandler( const QString & filename ) { |
44 | |||
45 | m_filename = filename; | 45 | m_filename = filename; |
46 | load(); | 46 | load(); |
47 | } | 47 | } |
@@ -52,19 +52,32 @@ RfCommConfHandler::~RfCommConfHandler() { | |||
52 | 52 | ||
53 | void RfCommConfHandler::save( QMap<QString, RfCommConfObject*> devices ) { | 53 | void RfCommConfHandler::save( QMap<QString, RfCommConfObject*> devices ) { |
54 | 54 | ||
55 | QFile rfCommConf( "/tmp/test" ); | 55 | //// For debugging purposes |
56 | //// QFile rfCommConf( "/mnt/net/opie/bin/rfcomm.conf" ); | ||
57 | QFile rfCommConf( m_filename ); | ||
56 | QTextStream outStream( &rfCommConf ); | 58 | QTextStream outStream( &rfCommConf ); |
57 | if ( rfCommConf.open( IO_WriteOnly ) ) { | 59 | if ( rfCommConf.open( IO_WriteOnly ) ) { |
58 | |||
59 | QMap<QString, RfCommConfObject*>::Iterator it; | 60 | QMap<QString, RfCommConfObject*>::Iterator it; |
61 | outStream << "#\n"; | ||
62 | outStream << "# RFCOMM configuration file.\n"; | ||
63 | outStream << "#\n"; | ||
64 | outStream << "# $Id$\n"; | ||
65 | outStream << "#\n\n"; | ||
60 | for( it = devices.begin(); it != devices.end(); ++it ) { | 66 | for( it = devices.begin(); it != devices.end(); ++it ) { |
61 | outStream << "rfcomm" + QString("%1").arg( it.data()->number() ) + " {\n"; | 67 | outStream << "rfcomm" + QString("%1").arg( it.data()->number() ) + " {\n"; |
62 | outStream << " device " + it.data()->mac() + ";\n"; | 68 | outStream << "\t# Automatically bind the device at startup\n"; |
63 | outStream << " channel " + QString( "%1" ).arg( it.data()->channel() ) + ";\n"; | 69 | outStream << "\tbind " << ((it.data()->isBind())? "yes": "no") << ";\n"; |
64 | outStream << " comment \"" + it.data()->comment() + "\";\n"; | 70 | outStream << "\n"; |
71 | outStream << "\t# Bluetooth address of the device\n"; | ||
72 | outStream << "\tdevice " + it.data()->mac() + ";\n"; | ||
73 | outStream << "\n"; | ||
74 | outStream << "\t# RFCOMM channel for the connection\n"; | ||
75 | outStream << "\tchannel\t" + QString( "%1" ).arg( it.data()->channel() ) + ";\n"; | ||
76 | outStream << "\n"; | ||
77 | outStream << "\t# Description of the connection\n"; | ||
78 | outStream << "\tcomment \"" + it.data()->comment() + "\";\n"; | ||
65 | outStream << "}\n\n"; | 79 | outStream << "}\n\n"; |
66 | } | 80 | } |
67 | |||
68 | rfCommConf.close(); | 81 | rfCommConf.close(); |
69 | } | 82 | } |
70 | } | 83 | } |
@@ -75,38 +88,67 @@ QMap<QString, RfCommConfObject*> RfCommConfHandler::foundEntries() { | |||
75 | } | 88 | } |
76 | 89 | ||
77 | void RfCommConfHandler::load() { | 90 | void RfCommConfHandler::load() { |
78 | 91 | //Keywords | |
79 | QFile rfCommConf( m_filename ); | 92 | QCString k_rfcomm("rfcomm"); |
93 | QCString k_device("device "); | ||
94 | QCString k_channel("channel "); | ||
95 | QCString k_comment("comment "); | ||
96 | QCString k_bind("bind "); | ||
97 | |||
98 | m_foundEntries.clear(); | ||
99 | QFile rfCommConf(m_filename); //File we read | ||
80 | if ( rfCommConf.open( IO_ReadOnly ) ) { | 100 | if ( rfCommConf.open( IO_ReadOnly ) ) { |
81 | 101 | ||
82 | QStringList list; | 102 | QStringList list; |
83 | QTextStream inStream( &rfCommConf ); | 103 | QTextStream inStream( &rfCommConf ); |
84 | list = QStringList::split( "\n", inStream.read() ); | 104 | list = QStringList::split( "\n", inStream.read() ); |
85 | 105 | ||
86 | QString number; | ||
87 | QString mac; | 106 | QString mac; |
88 | QString channel; | 107 | QString channel; |
89 | QString comment; | 108 | QString comment; |
109 | QString bind; | ||
110 | bool bbind; | ||
111 | QString number; | ||
90 | 112 | ||
91 | for ( QStringList::Iterator line=list.begin(); line != list.end(); line++ ) { | 113 | for (QStringList::Iterator line = list.begin(); |
114 | line != list.end(); line++) { | ||
92 | 115 | ||
93 | QString tmpLine = ( *line ).stripWhiteSpace(); | 116 | QString tmpLine = (*line).simplifyWhiteSpace(); |
94 | 117 | ||
95 | if ( tmpLine.startsWith("rfcomm") ) { | 118 | if (tmpLine.startsWith(k_rfcomm)) { |
96 | QString number = tmpLine.mid( 6,1 ); | 119 | number = tmpLine.mid( k_rfcomm.length(), 1 ); |
97 | odebug << tmpLine << oendl; | 120 | odebug << tmpLine << oendl; |
98 | odebug << "TEST " + number << oendl; | 121 | odebug << "device " << number << oendl; |
99 | } else if ( tmpLine.startsWith( "}" ) ) { | 122 | } else if ( tmpLine.startsWith( "}" ) ) { |
100 | m_foundEntries.insert( number, new RfCommConfObject( number.toInt(), mac, channel.toInt(), comment ) ); | 123 | m_foundEntries.insert(number, |
101 | } else if ( tmpLine.startsWith( "device" ) ) { | 124 | new RfCommConfObject(number.toInt(), mac, channel.toInt(), |
102 | mac = tmpLine.mid( 7, 17 ); | 125 | comment, bbind)); |
126 | } else if ( tmpLine.startsWith(k_device) ) { | ||
127 | mac = tmpLine.mid(k_device.length(), | ||
128 | tmpLine.find(';') - k_device.length()); | ||
103 | odebug << "mac" + mac << oendl; | 129 | odebug << "mac" + mac << oendl; |
104 | } else if ( tmpLine.startsWith( "channel" ) ) { | 130 | } else if ( tmpLine.startsWith(k_channel) ) { |
105 | channel = tmpLine.mid( 8, 1 ); | 131 | channel = tmpLine.mid(k_channel.length(), |
132 | tmpLine.find(';') - k_channel.length()); | ||
106 | odebug << "Channel :" << channel << oendl; | 133 | odebug << "Channel :" << channel << oendl; |
107 | } else if ( tmpLine.startsWith( "comment" ) ) { | 134 | } else if ( tmpLine.startsWith(k_comment) ) { |
108 | comment = tmpLine.mid( 9, tmpLine.find( ';' ) - 9 - 1 ); | 135 | comment = tmpLine.mid(k_comment.length(), |
136 | tmpLine.find(';') - k_comment.length()); | ||
137 | if (comment.left(1) == "\"") | ||
138 | comment.remove(0, 1); | ||
139 | if (comment.right(1) == "\"") | ||
140 | comment.remove(comment.length() - 1, 1); | ||
109 | odebug << "Comment: " + comment << oendl; | 141 | odebug << "Comment: " + comment << oendl; |
142 | } else if ( tmpLine.startsWith(k_bind) ) { | ||
143 | bind = tmpLine.mid(k_bind.length(), | ||
144 | tmpLine.find(';') - k_bind.length()); | ||
145 | if (bind == "no") | ||
146 | bbind = false; | ||
147 | else if (bind == "yes") | ||
148 | bbind = true; | ||
149 | else | ||
150 | bbind = true; | ||
151 | odebug << "bind: " + bind << oendl; | ||
110 | } | 152 | } |
111 | } | 153 | } |
112 | rfCommConf.close(); | 154 | rfCommConf.close(); |
@@ -114,3 +156,5 @@ void RfCommConfHandler::load() { | |||
114 | save( m_foundEntries ); | 156 | save( m_foundEntries ); |
115 | odebug << QString( "ENTries: %1").arg( m_foundEntries.count() ) << oendl; | 157 | odebug << QString( "ENTries: %1").arg( m_foundEntries.count() ) << oendl; |
116 | } | 158 | } |
159 | |||
160 | //eof | ||
diff --git a/noncore/net/opietooth/manager/rfcommconfhandler.h b/noncore/net/opietooth/manager/rfcommconfhandler.h index e13c833..46aaa26 100644 --- a/noncore/net/opietooth/manager/rfcommconfhandler.h +++ b/noncore/net/opietooth/manager/rfcommconfhandler.h | |||
@@ -11,7 +11,8 @@ namespace OpieTooth { | |||
11 | class RfCommConfObject { | 11 | class RfCommConfObject { |
12 | 12 | ||
13 | public: | 13 | public: |
14 | RfCommConfObject( int number, QString mac, int channel, QString comment ); | 14 | RfCommConfObject( int number, QString mac, int channel, QString comment, |
15 | bool bind); | ||
15 | ~RfCommConfObject(); | 16 | ~RfCommConfObject(); |
16 | 17 | ||
17 | void setNumber( int number ); | 18 | void setNumber( int number ); |
@@ -22,9 +23,11 @@ namespace OpieTooth { | |||
22 | int channel() { return m_channel; }; | 23 | int channel() { return m_channel; }; |
23 | void setComment( QString comment ); | 24 | void setComment( QString comment ); |
24 | QString comment() { return m_comment; }; | 25 | QString comment() { return m_comment; }; |
25 | 26 | bool isBind() { return m_doBind; } | |
27 | void doBind(bool arg) { m_doBind = arg; } | ||
26 | 28 | ||
27 | private: | 29 | private: |
30 | bool m_doBind; | ||
28 | int m_number; | 31 | int m_number; |
29 | QString m_mac; | 32 | QString m_mac; |
30 | int m_channel; | 33 | int m_channel; |
diff --git a/noncore/net/opietooth/manager/rfcommdialogitembase.ui b/noncore/net/opietooth/manager/rfcommdialogitembase.ui index dd8f121..43f3269 100644 --- a/noncore/net/opietooth/manager/rfcommdialogitembase.ui +++ b/noncore/net/opietooth/manager/rfcommdialogitembase.ui | |||
@@ -11,7 +11,7 @@ | |||
11 | <rect> | 11 | <rect> |
12 | <x>0</x> | 12 | <x>0</x> |
13 | <y>0</y> | 13 | <y>0</y> |
14 | <width>239</width> | 14 | <width>235</width> |
15 | <height>95</height> | 15 | <height>95</height> |
16 | </rect> | 16 | </rect> |
17 | </property> | 17 | </property> |
@@ -44,21 +44,53 @@ | |||
44 | <property> | 44 | <property> |
45 | <name>layoutSpacing</name> | 45 | <name>layoutSpacing</name> |
46 | </property> | 46 | </property> |
47 | <grid> | 47 | <vbox> |
48 | <property stdset="1"> | 48 | <property stdset="1"> |
49 | <name>margin</name> | 49 | <name>margin</name> |
50 | <number>5</number> | 50 | <number>0</number> |
51 | </property> | 51 | </property> |
52 | <property stdset="1"> | 52 | <property stdset="1"> |
53 | <name>spacing</name> | 53 | <name>spacing</name> |
54 | <number>5</number> | 54 | <number>2</number> |
55 | </property> | 55 | </property> |
56 | <widget row="0" column="0" > | 56 | <widget> |
57 | <class>QLayoutWidget</class> | 57 | <class>QLayoutWidget</class> |
58 | <property stdset="1"> | 58 | <property stdset="1"> |
59 | <name>name</name> | 59 | <name>name</name> |
60 | <cstring>Layout3</cstring> | 60 | <cstring>Layout3</cstring> |
61 | </property> | 61 | </property> |
62 | <property> | ||
63 | <name>layoutSpacing</name> | ||
64 | </property> | ||
65 | <vbox> | ||
66 | <property stdset="1"> | ||
67 | <name>margin</name> | ||
68 | <number>0</number> | ||
69 | </property> | ||
70 | <property stdset="1"> | ||
71 | <name>spacing</name> | ||
72 | <number>2</number> | ||
73 | </property> | ||
74 | <widget> | ||
75 | <class>QCheckBox</class> | ||
76 | <property stdset="1"> | ||
77 | <name>name</name> | ||
78 | <cstring>m_bind</cstring> | ||
79 | </property> | ||
80 | <property stdset="1"> | ||
81 | <name>text</name> | ||
82 | <string>bind automatically</string> | ||
83 | </property> | ||
84 | </widget> | ||
85 | <widget> | ||
86 | <class>QLayoutWidget</class> | ||
87 | <property stdset="1"> | ||
88 | <name>name</name> | ||
89 | <cstring>Layout3</cstring> | ||
90 | </property> | ||
91 | <property> | ||
92 | <name>layoutSpacing</name> | ||
93 | </property> | ||
62 | <hbox> | 94 | <hbox> |
63 | <property stdset="1"> | 95 | <property stdset="1"> |
64 | <name>margin</name> | 96 | <name>margin</name> |
@@ -172,7 +204,7 @@ | |||
172 | </widget> | 204 | </widget> |
173 | </hbox> | 205 | </hbox> |
174 | </widget> | 206 | </widget> |
175 | <widget row="1" column="0" > | 207 | <widget> |
176 | <class>QLayoutWidget</class> | 208 | <class>QLayoutWidget</class> |
177 | <property stdset="1"> | 209 | <property stdset="1"> |
178 | <name>name</name> | 210 | <name>name</name> |
@@ -214,7 +246,9 @@ | |||
214 | </widget> | 246 | </widget> |
215 | </hbox> | 247 | </hbox> |
216 | </widget> | 248 | </widget> |
217 | </grid> | 249 | </vbox> |
250 | </widget> | ||
251 | </vbox> | ||
218 | </widget> | 252 | </widget> |
219 | </vbox> | 253 | </vbox> |
220 | </widget> | 254 | </widget> |
diff --git a/noncore/net/opietooth/manager/rfcpopup.cpp b/noncore/net/opietooth/manager/rfcpopup.cpp index 7711f0a..04da19f 100644 --- a/noncore/net/opietooth/manager/rfcpopup.cpp +++ b/noncore/net/opietooth/manager/rfcpopup.cpp | |||
@@ -105,7 +105,8 @@ void RfcCommPopup::slotBind() | |||
105 | { | 105 | { |
106 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); | 106 | RfcommAssignDialog rfcommAssign ( this, "RfcommAssignDialog", true, WStyle_ContextHelp ); |
107 | 107 | ||
108 | rfcommAssign.newDevice( m_item->mac() ); | 108 | rfcommAssign.newDevice( m_item->mac(), |
109 | m_service.protocolDescriptorList().last().port()); | ||
109 | 110 | ||
110 | if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) | 111 | if ( QPEApplication::execDialog( &rfcommAssign ) == QDialog::Accepted ) |
111 | { | 112 | { |