author | zecke <zecke> | 2002-06-15 21:37:42 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-06-15 21:37:42 (UTC) |
commit | 9d02762b3d2e07f6db24c21621a5d577ea6acda7 (patch) (unidiff) | |
tree | d3a6ffb032a55991e4ef989f911f000090e29b09 | |
parent | 6f9b901d1f8db793a0e4a42f99f14f802e96f62e (diff) | |
download | opie-9d02762b3d2e07f6db24c21621a5d577ea6acda7.zip opie-9d02762b3d2e07f6db24c21621a5d577ea6acda7.tar.gz opie-9d02762b3d2e07f6db24c21621a5d577ea6acda7.tar.bz2 |
Manager should work now
-rw-r--r-- | noncore/net/opietooth/lib/manager.cc | 64 | ||||
-rw-r--r-- | noncore/net/opietooth/lib/manager.h | 7 |
2 files changed, 69 insertions, 2 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc index eeeab19..d65dbd4 100644 --- a/noncore/net/opietooth/lib/manager.cc +++ b/noncore/net/opietooth/lib/manager.cc | |||
@@ -50,9 +50,20 @@ void Manager::isConnected( Device* dev ){ | |||
50 | 50 | ||
51 | 51 | ||
52 | } | 52 | } |
53 | void Manager::searchDevices( const QString& device ){ | 53 | void Manager::searchDevices( const QString& device ){ |
54 | 54 | OProcess* hcitool = new OProcess(); | |
55 | hcitool->setName( device.latin1() ); | ||
56 | *hcitool << "hcitool" << "scan"; | ||
57 | connect( hcitool, SIGNAL(processExited(OProcess*) ) , | ||
58 | this, SLOT(slotHCIExited(OProcess* ) ) ); | ||
59 | connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), | ||
60 | this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); | ||
61 | if (!hcitool->start() ) { | ||
62 | RemoteDevices::ValueList list; | ||
63 | emit foundDevices( device, list ); | ||
64 | delete hcitool; | ||
65 | } | ||
55 | } | 66 | } |
56 | 67 | ||
57 | void Manager::searchDevices(Device* d ){ | 68 | void Manager::searchDevices(Device* d ){ |
58 | 69 | ||
@@ -129,6 +140,57 @@ void Manager::slotSDPOut(OProcess* proc, char* ch, int len) | |||
129 | 140 | ||
130 | } | 141 | } |
131 | void Manager::slotSDPExited( OProcess* proc) | 142 | void Manager::slotSDPExited( OProcess* proc) |
132 | { | 143 | { |
144 | Services::ValueList list; | ||
145 | if (proc->normalExit() ) { | ||
146 | QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); | ||
147 | if ( it != m_out.end() ) { | ||
148 | list = parseSDPOutput( it.data() ); | ||
149 | m_out.remove( it ); | ||
150 | } | ||
151 | } | ||
152 | emit foundServices( proc->name(), list ); | ||
153 | delete proc; | ||
154 | } | ||
155 | Services::ValueList Manager::parseSDPOutput( const QString& out ) { | ||
156 | Services::ValueList list; | ||
157 | return list; | ||
158 | } | ||
159 | |||
160 | void Manager::slotHCIExited(OProcess* proc ) { | ||
161 | RemoteDevices::ValueList list; | ||
162 | if (proc->normalExit() ) { | ||
163 | QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); | ||
164 | if (it != m_devices.end() ) { | ||
165 | list = parseHCIOutput( it.data() ); | ||
166 | m_devices.remove( it ); | ||
167 | } | ||
168 | } | ||
169 | emit foundDevices( proc->name(), list ); | ||
133 | delete proc; | 170 | delete proc; |
134 | } | 171 | } |
172 | void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { | ||
173 | QCString str( ch, len+1 ); | ||
174 | QMap<QString, QString>::Iterator it; | ||
175 | it = m_devices.find( proc->name() ); | ||
176 | if (it != m_devices.end() ) { | ||
177 | QString string = it.data(); | ||
178 | string.append( str ); | ||
179 | m_devices.replace( proc->name(), string ); | ||
180 | } | ||
181 | } | ||
182 | RemoteDevices::ValueList Manager::parseHCIOutput(const QString& output ) { | ||
183 | RemoteDevices::ValueList list; | ||
184 | QStringList strList = QStringList::split('\n', output ); | ||
185 | QStringList::Iterator it; | ||
186 | QString str; | ||
187 | for ( it = strList.begin(); it != strList.end(); ++it ) { | ||
188 | str = (*it).stripWhiteSpace(); | ||
189 | qWarning("OpieTooth %s", str.latin1() ); | ||
190 | QStringList split = QStringList::split(" ", str ); | ||
191 | qWarning("Left:%s Right:%s", split[0].latin1() , split[1].latin1() ); | ||
192 | RemoteDevices rem( split[0].latin1() , split[1].latin1() ); | ||
193 | list.append( rem ); | ||
194 | } | ||
195 | return list; | ||
196 | } | ||
diff --git a/noncore/net/opietooth/lib/manager.h b/noncore/net/opietooth/lib/manager.h index 03375c5..95e4306 100644 --- a/noncore/net/opietooth/lib/manager.h +++ b/noncore/net/opietooth/lib/manager.h | |||
@@ -109,18 +109,23 @@ Q_OBJECT | |||
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, RemoteDevices::ValueList ); |
113 | void foundNothing( const QString& device ); | 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* ); | ||
119 | void slotHCIOut(OProcess*, char*, int ); | ||
118 | private: | 120 | private: |
121 | Services::ValueList parseSDPOutput( const QString& ); | ||
122 | RemoteDevices::ValueList parseHCIOutput( const QString& ); | ||
119 | OProcess *m_hcitool; | 123 | OProcess *m_hcitool; |
120 | OProcess *m_sdp; // not only one | 124 | OProcess *m_sdp; // not only one |
121 | QString m_device; | 125 | QString m_device; |
122 | QMap<QString, QString> m_out; | 126 | QMap<QString, QString> m_out; |
127 | QMap<QString, QString> m_devices; | ||
123 | }; | 128 | }; |
124 | }; | 129 | }; |
125 | 130 | ||
126 | #endif | 131 | #endif |