author | harlekin <harlekin> | 2002-06-16 20:21:06 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2002-06-16 20:21:06 (UTC) |
commit | 5c098847f0fd716c4fe697e5eb314111a4ae5df1 (patch) (unidiff) | |
tree | 590ed709442bf6ba4a28eb242840dcf1de6da756 | |
parent | 8dde6abcd14717bd362248c365fe140efe0f0386 (diff) | |
download | opie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.zip opie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.tar.gz opie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.tar.bz2 |
remoteDevice not removeDevices
-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 12 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 6 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/remotedevice.cc | 22 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/remotedevice.h | 16 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/bluebase.h | 2 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.cpp | 3 | ||||
-rw-r--r-- | noncore/net/opietooth/manager/scandialog.h | 4 |
7 files changed, 33 insertions, 32 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index 40c1f0a..c454588 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc | |||
@@ -57,17 +57,17 @@ void Manager::searchDevices( const QString& device ){ | |||
57 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); | 57 | hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); |
58 | *hcitool << "hcitool" << "scan"; | 58 | *hcitool << "hcitool" << "scan"; |
59 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , | 59 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , |
60 | this, SLOT(slotHCIExited(OProcess* ) ) ); | 60 | this, SLOT(slotHCIExited(OProcess* ) ) ); |
61 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 61 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
62 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); | 62 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); |
63 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 63 | if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
64 | qWarning("could not start"); | 64 | qWarning("could not start"); |
65 | RemoteDevices::ValueList list; | 65 | RemoteDevice::ValueList list; |
66 | emit foundDevices( device, list ); | 66 | emit foundDevices( device, list ); |
67 | delete hcitool; | 67 | delete hcitool; |
68 | } | 68 | } |
69 | } | 69 | } |
70 | 70 | ||
71 | void Manager::searchDevices(Device* d ){ | 71 | void Manager::searchDevices(Device* d ){ |
72 | 72 | ||
73 | 73 | ||
@@ -107,17 +107,17 @@ void Manager::searchServices( const QString& remDevice ){ | |||
107 | connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | 107 | connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), |
108 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); | 108 | this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); |
109 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { | 109 | if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { |
110 | delete m_sdp; | 110 | delete m_sdp; |
111 | Services::ValueList list; | 111 | Services::ValueList list; |
112 | emit foundServices( remDevice, list ); | 112 | emit foundServices( remDevice, list ); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | void Manager::searchServices( const RemoteDevices& dev){ | 115 | void Manager::searchServices( const RemoteDevice& dev){ |
116 | searchServices( dev.mac() ); | 116 | searchServices( dev.mac() ); |
117 | } | 117 | } |
118 | QString Manager::toDevice( const QString& mac ){ | 118 | QString Manager::toDevice( const QString& mac ){ |
119 | 119 | ||
120 | } | 120 | } |
121 | QString Manager::toMac( const QString &device ){ | 121 | QString Manager::toMac( const QString &device ){ |
122 | 122 | ||
123 | } | 123 | } |
@@ -157,17 +157,17 @@ void Manager::slotSDPExited( OProcess* proc) | |||
157 | } | 157 | } |
158 | Services::ValueList Manager::parseSDPOutput( const QString& out ) { | 158 | Services::ValueList Manager::parseSDPOutput( const QString& out ) { |
159 | Services::ValueList list; | 159 | Services::ValueList list; |
160 | return list; | 160 | return list; |
161 | } | 161 | } |
162 | 162 | ||
163 | void Manager::slotHCIExited(OProcess* proc ) { | 163 | void Manager::slotHCIExited(OProcess* proc ) { |
164 | qWarning("process exited"); | 164 | qWarning("process exited"); |
165 | RemoteDevices::ValueList list; | 165 | RemoteDevice::ValueList list; |
166 | if (proc->normalExit() ) { | 166 | if (proc->normalExit() ) { |
167 | qWarning("normalExit %s", proc->name() ); | 167 | qWarning("normalExit %s", proc->name() ); |
168 | QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); | 168 | QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); |
169 | if (it != m_devices.end() ) { | 169 | if (it != m_devices.end() ) { |
170 | qWarning("!= end ;)"); | 170 | qWarning("!= end ;)"); |
171 | list = parseHCIOutput( it.data() ); | 171 | list = parseHCIOutput( it.data() ); |
172 | m_devices.remove( it ); | 172 | m_devices.remove( it ); |
173 | } | 173 | } |
@@ -185,29 +185,29 @@ void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { | |||
185 | if (it != m_devices.end() ) { | 185 | if (it != m_devices.end() ) { |
186 | qWarning("slotHCIOut "); | 186 | qWarning("slotHCIOut "); |
187 | string = it.data(); | 187 | string = it.data(); |
188 | } | 188 | } |
189 | string.append( str ); | 189 | string.append( str ); |
190 | 190 | ||
191 | m_devices.replace( proc->name(), string ); | 191 | m_devices.replace( proc->name(), string ); |
192 | } | 192 | } |
193 | RemoteDevices::ValueList Manager::parseHCIOutput(const QString& output ) { | 193 | RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { |
194 | qWarning("parseHCI %s", output.latin1() ); | 194 | qWarning("parseHCI %s", output.latin1() ); |
195 | RemoteDevices::ValueList list; | 195 | RemoteDevice::ValueList list; |
196 | QStringList strList = QStringList::split('\n', output ); | 196 | QStringList strList = QStringList::split('\n', output ); |
197 | QStringList::Iterator it; | 197 | QStringList::Iterator it; |
198 | QString str; | 198 | QString str; |
199 | for ( it = strList.begin(); it != strList.end(); ++it ) { | 199 | for ( it = strList.begin(); it != strList.end(); ++it ) { |
200 | str = (*it).stripWhiteSpace(); | 200 | str = (*it).stripWhiteSpace(); |
201 | qWarning("OpieTooth %s", str.latin1() ); | 201 | qWarning("OpieTooth %s", str.latin1() ); |
202 | int pos = str.findRev(':' ); | 202 | int pos = str.findRev(':' ); |
203 | if ( pos > 0 ) { | 203 | if ( pos > 0 ) { |
204 | QString mac = str.left(17 ); | 204 | QString mac = str.left(17 ); |
205 | str.remove( 0, 17 ); | 205 | str.remove( 0, 17 ); |
206 | qWarning("mac %s", mac.latin1() ); | 206 | qWarning("mac %s", mac.latin1() ); |
207 | qWarning("rest:%s", str.latin1() ); | 207 | qWarning("rest:%s", str.latin1() ); |
208 | RemoteDevices rem( mac , str.stripWhiteSpace() ); | 208 | RemoteDevice rem( mac , str.stripWhiteSpace() ); |
209 | list.append( rem ); | 209 | list.append( rem ); |
210 | } | 210 | } |
211 | } | 211 | } |
212 | return list; | 212 | return list; |
213 | } | 213 | } |
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index 95e4306..aba70f7 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h | |||
@@ -93,38 +93,38 @@ Q_OBJECT | |||
93 | /** | 93 | /** |
94 | * search for services on a remote device | 94 | * search for services on a remote device |
95 | * | 95 | * |
96 | */ | 96 | */ |
97 | void searchServices( const QString& remDevice ); | 97 | void searchServices( const QString& remDevice ); |
98 | /** | 98 | /** |
99 | * search for services on a remote device | 99 | * search for services on a remote device |
100 | */ | 100 | */ |
101 | void searchServices( const RemoteDevices& ); | 101 | void searchServices( const RemoteDevice& ); |
102 | /*static*/ QString toDevice( const QString& mac ); | 102 | /*static*/ QString toDevice( const QString& mac ); |
103 | /*static*/ QString toMac( const QString &device ); | 103 | /*static*/ QString toMac( const QString &device ); |
104 | 104 | ||
105 | signals: | 105 | signals: |
106 | // device either mac or dev name | 106 | // device either mac or dev name |
107 | // the first device is the device which you access | 107 | // the first device is the device which you access |
108 | void connected( const QString& device, bool connected ); | 108 | void connected( const QString& device, bool connected ); |
109 | void addedService( const QString& service, bool added ); | 109 | void addedService( const QString& service, bool added ); |
110 | void removedService( const QString& service, bool removed ); | 110 | void removedService( const QString& service, bool removed ); |
111 | void foundServices( const QString& device, Services::ValueList ); | 111 | void foundServices( const QString& device, Services::ValueList ); |
112 | void foundDevices( const QString& device, RemoteDevices::ValueList ); | 112 | void foundDevices( const QString& device, RemoteDevice::ValueList ); |
113 | 113 | ||
114 | private slots: | 114 | private slots: |
115 | void slotProcessExited(OProcess* ); | 115 | void slotProcessExited(OProcess* ); |
116 | void slotSDPExited(OProcess*); | 116 | void slotSDPExited(OProcess*); |
117 | void slotSDPOut(OProcess*, char*, int); | 117 | void slotSDPOut(OProcess*, char*, int); |
118 | void slotHCIExited(OProcess* ); | 118 | void slotHCIExited(OProcess* ); |
119 | void slotHCIOut(OProcess*, char*, int ); | 119 | void slotHCIOut(OProcess*, char*, int ); |
120 | private: | 120 | private: |
121 | Services::ValueList parseSDPOutput( const QString& ); | 121 | Services::ValueList parseSDPOutput( const QString& ); |
122 | RemoteDevices::ValueList parseHCIOutput( const QString& ); | 122 | RemoteDevice::ValueList parseHCIOutput( const QString& ); |
123 | OProcess *m_hcitool; | 123 | OProcess *m_hcitool; |
124 | OProcess *m_sdp; // not only one | 124 | OProcess *m_sdp; // not only one |
125 | QString m_device; | 125 | QString m_device; |
126 | QMap<QString, QString> m_out; | 126 | QMap<QString, QString> m_out; |
127 | QMap<QString, QString> m_devices; | 127 | QMap<QString, QString> m_devices; |
128 | }; | 128 | }; |
129 | }; | 129 | }; |
130 | 130 | ||
diff --git a/noncore/net/opietooth/lib/remotedevice.cc b/noncore/net/opietooth/lib/remotedevice.cc index 0045904..08fb397 100644 --- a/noncore/net/opietooth/lib/remotedevice.cc +++ b/noncore/net/opietooth/lib/remotedevice.cc | |||
@@ -1,48 +1,48 @@ | |||
1 | 1 | ||
2 | #include "remotedevice.h" | 2 | #include "remotedevice.h" |
3 | 3 | ||
4 | using namespace OpieTooth; | 4 | using namespace OpieTooth; |
5 | 5 | ||
6 | bool operator==(const RemoteDevices& rem1, const RemoteDevices& rem2){ | 6 | bool operator==(const RemoteDevice& rem1, const RemoteDevice& rem2){ |
7 | if( ( rem1.mac() == rem2.mac() ) && (rem1.name() == rem2.name() ) ) | 7 | if( ( rem1.mac() == rem2.mac() ) && (rem1.name() == rem2.name() ) ) |
8 | return true; | 8 | return true; |
9 | 9 | ||
10 | return false; | 10 | return false; |
11 | } | 11 | } |
12 | 12 | ||
13 | RemoteDevices::RemoteDevices(){ | 13 | RemoteDevice::RemoteDevice(){ |
14 | 14 | ||
15 | } | 15 | } |
16 | RemoteDevices::RemoteDevices(const RemoteDevices& ole ){ | 16 | RemoteDevice::RemoteDevice(const RemoteDevice& ole ){ |
17 | (*this) = ole; | 17 | (*this) = ole; |
18 | } | 18 | } |
19 | RemoteDevices::RemoteDevices(const QString &mac, const QString& name ){ | 19 | RemoteDevice::RemoteDevice(const QString &mac, const QString& name ){ |
20 | m_mac = mac; | 20 | m_mac = mac; |
21 | m_name = name; | 21 | m_name = name; |
22 | } | 22 | } |
23 | RemoteDevices::~RemoteDevices(){ | 23 | RemoteDevice::~RemoteDevice(){ |
24 | 24 | ||
25 | } | 25 | } |
26 | bool RemoteDevices::isEmpty() const { | 26 | bool RemoteDevice::isEmpty() const { |
27 | if( m_name.isEmpty() && m_mac.isEmpty() ) | 27 | if( m_name.isEmpty() && m_mac.isEmpty() ) |
28 | return true; | 28 | return true; |
29 | return false; | 29 | return false; |
30 | }; | 30 | }; |
31 | RemoteDevices& RemoteDevices::operator=( const RemoteDevices& rem1){ | 31 | RemoteDevice& RemoteDevice::operator=( const RemoteDevice& rem1){ |
32 | m_name = rem1.m_name; | 32 | m_name = rem1.m_name; |
33 | m_mac = rem1.m_mac; | 33 | m_mac = rem1.m_mac; |
34 | return *this; | 34 | return *this; |
35 | 35 | ||
36 | } | 36 | } |
37 | QString RemoteDevices::mac() const { | 37 | QString RemoteDevice::mac() const { |
38 | return m_mac; | 38 | return m_mac; |
39 | } | 39 | } |
40 | void RemoteDevices::setMac( const QString& mac ){ | 40 | void RemoteDevice::setMac( const QString& mac ){ |
41 | m_mac = mac; | 41 | m_mac = mac; |
42 | } | 42 | } |
43 | QString RemoteDevices::name() const{ | 43 | QString RemoteDevice::name() const{ |
44 | return m_name; | 44 | return m_name; |
45 | } | 45 | } |
46 | void RemoteDevices::setName( const QString& name ){ | 46 | void RemoteDevice::setName( const QString& name ){ |
47 | m_name = name; | 47 | m_name = name; |
48 | } | 48 | } |
diff --git a/noncore/net/opietooth/lib/remotedevice.h b/noncore/net/opietooth/lib/remotedevice.h index 96a27de..23f98bd 100644 --- a/noncore/net/opietooth/lib/remotedevice.h +++ b/noncore/net/opietooth/lib/remotedevice.h | |||
@@ -1,24 +1,24 @@ | |||
1 | 1 | ||
2 | #ifndef OpieToothRemoteDevice | 2 | #ifndef OpieToothRemoteDevice |
3 | #define OpieToothRemoteDevice | 3 | #define OpieToothRemoteDevice |
4 | 4 | ||
5 | #include <qvaluelist.h> | 5 | #include <qvaluelist.h> |
6 | 6 | ||
7 | namespace OpieTooth{ | 7 | namespace OpieTooth{ |
8 | class RemoteDevices { | 8 | class RemoteDevice { |
9 | public: | 9 | public: |
10 | typedef QValueList<RemoteDevices> ValueList; | 10 | typedef QValueList<RemoteDevice> ValueList; |
11 | RemoteDevices(); | 11 | RemoteDevice(); |
12 | RemoteDevices(const RemoteDevices& ); | 12 | RemoteDevice(const RemoteDevice& ); |
13 | RemoteDevices(const QString &mac, const QString &name ); | 13 | RemoteDevice(const QString &mac, const QString &name ); |
14 | ~RemoteDevices(); | 14 | ~RemoteDevice(); |
15 | friend bool operator==(const RemoteDevices&, const RemoteDevices&); | 15 | friend bool operator==(const RemoteDevice&, const RemoteDevice&); |
16 | RemoteDevices &operator=(const RemoteDevices& ); | 16 | RemoteDevice &operator=(const RemoteDevice& ); |
17 | bool isEmpty()const; | 17 | bool isEmpty()const; |
18 | QString mac()const; | 18 | QString mac()const; |
19 | void setMac(const QString& mac ); | 19 | void setMac(const QString& mac ); |
20 | QString name()const; | 20 | QString name()const; |
21 | void setName( const QString& name ); | 21 | void setName( const QString& name ); |
22 | private: | 22 | private: |
23 | QString m_name; | 23 | QString m_name; |
24 | QString m_mac; | 24 | QString m_mac; |
diff --git a/noncore/net/opietooth/manager/bluebase.h b/noncore/net/opietooth/manager/bluebase.h index ae5ce67..5364e51 100644 --- a/noncore/net/opietooth/manager/bluebase.h +++ b/noncore/net/opietooth/manager/bluebase.h | |||
@@ -5,16 +5,18 @@ | |||
5 | #include <qvariant.h> | 5 | #include <qvariant.h> |
6 | #include <qwidget.h> | 6 | #include <qwidget.h> |
7 | #include <qscrollview.h> | 7 | #include <qscrollview.h> |
8 | #include <qsplitter.h> | 8 | #include <qsplitter.h> |
9 | #include <qlist.h> | 9 | #include <qlist.h> |
10 | 10 | ||
11 | #include "bluetoothbase.h" | 11 | #include "bluetoothbase.h" |
12 | 12 | ||
13 | #include <remotedevice.h> | ||
14 | |||
13 | class QVBox; | 15 | class QVBox; |
14 | class QHBoxLayout; | 16 | class QHBoxLayout; |
15 | class QGridLayout; | 17 | class QGridLayout; |
16 | class QFrame; | 18 | class QFrame; |
17 | class QLabel; | 19 | class QLabel; |
18 | class QPushButton; | 20 | class QPushButton; |
19 | class QTabWidget; | 21 | class QTabWidget; |
20 | class QCheckBox; | 22 | class QCheckBox; |
diff --git a/noncore/net/opietooth/manager/scandialog.cpp b/noncore/net/opietooth/manager/scandialog.cpp index 70ea77a..8a7ea01 100644 --- a/noncore/net/opietooth/manager/scandialog.cpp +++ b/noncore/net/opietooth/manager/scandialog.cpp | |||
@@ -129,34 +129,33 @@ namespace OpieTooth { | |||
129 | QCheckListItem * deviceItem; | 129 | QCheckListItem * deviceItem; |
130 | 130 | ||
131 | RemoteDevices::ValueList::Iterator it; | 131 | RemoteDevices::ValueList::Iterator it; |
132 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { | 132 | for( it = deviceList.begin(); it != deviceList.end(); ++it ) { |
133 | 133 | ||
134 | deviceItem = new QCheckListItem( ListView1, (*it).name() ); | 134 | deviceItem = new QCheckListItem( ListView1, (*it).name() ); |
135 | deviceItem->setText(1, (*it).mac() ); | 135 | deviceItem->setText(1, (*it).mac() ); |
136 | } | 136 | } |
137 | |||
138 | } | 137 | } |
139 | 138 | ||
140 | /* | 139 | /* |
141 | * Iterates trough the items, and collects the checked items. | 140 | * Iterates trough the items, and collects the checked items. |
142 | * Then it emits it, so the manager can connect to the signal to fill the listing. | 141 | * Then it emits it, so the manager can connect to the signal to fill the listing. |
143 | */ | 142 | */ |
144 | void ScanDialog::emitToManager() { | 143 | void ScanDialog::emitToManager() { |
145 | 144 | ||
146 | if (!ListView1) { | 145 | if (!ListView1) { |
147 | return; | 146 | return; |
148 | } | 147 | } |
149 | 148 | ||
150 | QList<RemoteDevices> *deviceList = new QList<RemoteDevices>; | 149 | QList<RemoteDevices> *deviceList = new QList<RemoteDevices>; |
151 | 150 | ||
152 | QListViewItemIterator it( ListView1 ); | 151 | QListViewItemIterator it( ListView1 ); |
153 | for ( ; it.current(); ++it ) { | 152 | for ( ; it.current(); ++it ) { |
154 | if ( it.current()->isSelected() ) { | 153 | if ( ((QCheckListItem*)it.current())->isOn() ) { |
155 | RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0)); | 154 | RemoteDevices* device = new RemoteDevices( it.current()->text(1), it.current()->text(0)); |
156 | deviceList->append( device ); | 155 | deviceList->append( device ); |
157 | } | 156 | } |
158 | } | 157 | } |
159 | emit selectedDevices( *deviceList ); | 158 | emit selectedDevices( *deviceList ); |
160 | } | 159 | } |
161 | 160 | ||
162 | /* | 161 | /* |
diff --git a/noncore/net/opietooth/manager/scandialog.h b/noncore/net/opietooth/manager/scandialog.h index 4785a62..0ca302a 100644 --- a/noncore/net/opietooth/manager/scandialog.h +++ b/noncore/net/opietooth/manager/scandialog.h | |||
@@ -16,31 +16,31 @@ | |||
16 | 16 | ||
17 | #ifndef SCANDIALOG_H | 17 | #ifndef SCANDIALOG_H |
18 | #define SCANDIALOG_H | 18 | #define SCANDIALOG_H |
19 | 19 | ||
20 | #include <qvariant.h> | 20 | #include <qvariant.h> |
21 | #include <qdialog.h> | 21 | #include <qdialog.h> |
22 | #include <qlist.h> | 22 | #include <qlist.h> |
23 | 23 | ||
24 | 24 | #include <remotedevice.h> | |
25 | class QVBoxLayout; | 25 | class QVBoxLayout; |
26 | class QHBoxLayout; | 26 | class QHBoxLayout; |
27 | class QGridLayout; | 27 | class QGridLayout; |
28 | class QFrame; | 28 | class QFrame; |
29 | class QLabel; | 29 | class QLabel; |
30 | class QListView; | 30 | class QListView; |
31 | class QListViewItem; | 31 | class QListViewItem; |
32 | class QPushButton; | 32 | class QPushButton; |
33 | class QProgressBar; | 33 | class QProgressBar; |
34 | 34 | ||
35 | 35 | ||
36 | namespace OpieTooth { | 36 | namespace OpieTooth { |
37 | 37 | ||
38 | #include <remotedevices.h> | 38 | |
39 | class Manager; | 39 | class Manager; |
40 | class Device; | 40 | class Device; |
41 | 41 | ||
42 | class ScanDialog : public QDialog { | 42 | class ScanDialog : public QDialog { |
43 | Q_OBJECT | 43 | Q_OBJECT |
44 | 44 | ||
45 | public: | 45 | public: |
46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); | 46 | ScanDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |