summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-15 22:06:57 (UTC)
committer zecke <zecke>2002-06-15 22:06:57 (UTC)
commitac6c5de1e7a15b4ca5bdf226a9eeceffb82aea94 (patch) (unidiff)
tree256f0b9d270972b30961bfae5529ab0de7fed9d6
parent9d02762b3d2e07f6db24c21621a5d577ea6acda7 (diff)
downloadopie-ac6c5de1e7a15b4ca5bdf226a9eeceffb82aea94.zip
opie-ac6c5de1e7a15b4ca5bdf226a9eeceffb82aea94.tar.gz
opie-ac6c5de1e7a15b4ca5bdf226a9eeceffb82aea94.tar.bz2
Fix the manager to find devices
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc37
1 files changed, 27 insertions, 10 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index d65dbd4..40c1f0a 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -10,2 +10,3 @@ Manager::Manager( const QString& dev )
10{ 10{
11 qWarning("created");
11 m_device = dev; 12 m_device = dev;
@@ -53,4 +54,5 @@ void Manager::isConnected( Device* dev ){
53void Manager::searchDevices( const QString& device ){ 54void Manager::searchDevices( const QString& device ){
55 qWarning("search devices");
54 OProcess* hcitool = new OProcess(); 56 OProcess* hcitool = new OProcess();
55 hcitool->setName( device.latin1() ); 57 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
56 *hcitool << "hcitool" << "scan"; 58 *hcitool << "hcitool" << "scan";
@@ -60,3 +62,4 @@ void Manager::searchDevices( const QString& device ){
60 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); 62 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) );
61 if (!hcitool->start() ) { 63 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
64 qWarning("could not start");
62 RemoteDevices::ValueList list; 65 RemoteDevices::ValueList list;
@@ -105,3 +108,3 @@ void Manager::searchServices( const QString& remDevice ){
105 this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); 108 this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
106 if (!m_sdp->start() ) { 109 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
107 delete m_sdp; 110 delete m_sdp;
@@ -160,6 +163,9 @@ Services::ValueList Manager::parseSDPOutput( const QString& out ) {
160void Manager::slotHCIExited(OProcess* proc ) { 163void Manager::slotHCIExited(OProcess* proc ) {
164 qWarning("process exited");
161 RemoteDevices::ValueList list; 165 RemoteDevices::ValueList list;
162 if (proc->normalExit() ) { 166 if (proc->normalExit() ) {
167 qWarning("normalExit %s", proc->name() );
163 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 168 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
164 if (it != m_devices.end() ) { 169 if (it != m_devices.end() ) {
170 qWarning("!= end ;)");
165 list = parseHCIOutput( it.data() ); 171 list = parseHCIOutput( it.data() );
@@ -173,11 +179,17 @@ void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
173 QCString str( ch, len+1 ); 179 QCString str( ch, len+1 );
180 qWarning("hci: %s", str.data() );
174 QMap<QString, QString>::Iterator it; 181 QMap<QString, QString>::Iterator it;
175 it = m_devices.find( proc->name() ); 182 it = m_devices.find( proc->name() );
183 qWarning("proc->name %s", proc->name() );
184 QString string;
176 if (it != m_devices.end() ) { 185 if (it != m_devices.end() ) {
177 QString string = it.data(); 186 qWarning("slotHCIOut ");
178 string.append( str ); 187 string = it.data();
179 m_devices.replace( proc->name(), string );
180 } 188 }
189 string.append( str );
190
191 m_devices.replace( proc->name(), string );
181} 192}
182RemoteDevices::ValueList Manager::parseHCIOutput(const QString& output ) { 193RemoteDevices::ValueList Manager::parseHCIOutput(const QString& output ) {
194 qWarning("parseHCI %s", output.latin1() );
183 RemoteDevices::ValueList list; 195 RemoteDevices::ValueList list;
@@ -189,6 +201,11 @@ RemoteDevices::ValueList Manager::parseHCIOutput(const QString& output ) {
189 qWarning("OpieTooth %s", str.latin1() ); 201 qWarning("OpieTooth %s", str.latin1() );
190 QStringList split = QStringList::split(" ", str ); 202 int pos = str.findRev(':' );
191 qWarning("Left:%s Right:%s", split[0].latin1() , split[1].latin1() ); 203 if ( pos > 0 ) {
192 RemoteDevices rem( split[0].latin1() , split[1].latin1() ); 204 QString mac = str.left(17 );
193 list.append( rem ); 205 str.remove( 0, 17 );
206 qWarning("mac %s", mac.latin1() );
207 qWarning("rest:%s", str.latin1() );
208 RemoteDevices rem( mac , str.stripWhiteSpace() );
209 list.append( rem );
210 }
194 } 211 }