summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib
authormickeyl <mickeyl>2005-07-09 16:05:57 (UTC)
committer mickeyl <mickeyl>2005-07-09 16:05:57 (UTC)
commit9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f (patch) (unidiff)
tree9d42efed66329ad925f3079e2739d9a3a9ced880 /noncore/net/opietooth/lib
parent5dbfa604bcc5dd32401d862372af806bfe674e89 (diff)
downloadopie-9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f.zip
opie-9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f.tar.gz
opie-9b070d84b36c5dc764b6b4a8a3ca511d2e3d441f.tar.bz2
autopopulate services list, use odebug where appropriate instead of owarn
Diffstat (limited to 'noncore/net/opietooth/lib') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc58
1 files changed, 29 insertions, 29 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 53122c1..83100f1 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -10,13 +10,13 @@ using namespace Opie::Core;
10using namespace OpieTooth; 10using namespace OpieTooth;
11 11
12using Opie::Core::OProcess; 12using Opie::Core::OProcess;
13Manager::Manager( const QString& dev ) 13Manager::Manager( const QString& dev )
14 : QObject() 14 : QObject()
15{ 15{
16 owarn << "created" << oendl; 16 odebug << "Manager: created" << oendl;
17 m_device = dev; 17 m_device = dev;
18 m_hcitool = 0; 18 m_hcitool = 0;
19 m_sdp = 0; 19 m_sdp = 0;
20} 20}
21Manager::Manager( Device* /*dev*/ ) 21Manager::Manager( Device* /*dev*/ )
22 : QObject() 22 : QObject()
@@ -55,22 +55,22 @@ void Manager::isAvailable( const QString& device ){
55 55
56void Manager::isAvailable( Device* /*dev*/ ){ 56void Manager::isAvailable( Device* /*dev*/ ){
57 57
58 58
59} 59}
60void Manager::searchDevices( const QString& device ){ 60void Manager::searchDevices( const QString& device ){
61 owarn << "search devices" << oendl; 61 odebug << "Manager: search devices" << oendl;
62 OProcess* hcitool = new OProcess(); 62 OProcess* hcitool = new OProcess();
63 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 63 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
64 *hcitool << "hcitool" << "scan"; 64 *hcitool << "hcitool" << "scan";
65 connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) , 65 connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) ,
66 this, SLOT(slotHCIExited(Opie::Core::OProcess* ) ) ); 66 this, SLOT(slotHCIExited(Opie::Core::OProcess* ) ) );
67 connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 67 connect( hcitool, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
68 this, SLOT(slotHCIOut(Opie::Core::OProcess*, char*, int ) ) ); 68 this, SLOT(slotHCIOut(Opie::Core::OProcess*, char*, int ) ) );
69 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 69 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
70 owarn << "could not start" << oendl; 70 odebug << "Manager: could not start" << oendl;
71 RemoteDevice::ValueList list; 71 RemoteDevice::ValueList list;
72 emit foundDevices( device, list ); 72 emit foundDevices( device, list );
73 delete hcitool; 73 delete hcitool;
74 } 74 }
75} 75}
76 76
@@ -105,19 +105,19 @@ void Manager::removeServices( const QStringList& list){
105 removeService( (*it) ); 105 removeService( (*it) );
106} 106}
107void Manager::searchServices( const QString& remDevice ){ 107void Manager::searchServices( const QString& remDevice ){
108 OProcess *m_sdp =new OProcess(); 108 OProcess *m_sdp =new OProcess();
109 *m_sdp << "sdptool" << "browse" << remDevice; 109 *m_sdp << "sdptool" << "browse" << remDevice;
110 m_sdp->setName( remDevice.latin1() ); 110 m_sdp->setName( remDevice.latin1() );
111 owarn << "search Services for " << remDevice.latin1() << oendl; 111 odebug << "Manager: search Services for " << remDevice.latin1() << oendl;
112 connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ), 112 connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ),
113 this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) ); 113 this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) );
114 connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 114 connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
115 this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) ); 115 this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) );
116 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 116 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
117 owarn << "could not start sdptool" << oendl; 117 odebug << "Manager: could not start sdptool" << oendl;
118 delete m_sdp; 118 delete m_sdp;
119 Services::ValueList list; 119 Services::ValueList list;
120 emit foundServices( remDevice, list ); 120 emit foundServices( remDevice, list );
121 } 121 }
122} 122}
123void Manager::searchServices( const RemoteDevice& dev){ 123void Manager::searchServices( const RemoteDevice& dev){
@@ -138,91 +138,91 @@ void Manager::slotProcessExited(OProcess* proc ) {
138 emit available( name, conn ); 138 emit available( name, conn );
139 delete proc; 139 delete proc;
140} 140}
141void Manager::slotSDPOut(OProcess* proc, char* ch, int len) 141void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
142{ 142{
143 QCString str(ch, len+1 ); 143 QCString str(ch, len+1 );
144 owarn << "SDP:" << str.data() << oendl; 144 odebug << "Manager: SDP:" << str.data() << oendl;
145 QMap<QString, QString>::Iterator it; 145 QMap<QString, QString>::Iterator it;
146 it = m_out.find(proc->name() ); 146 it = m_out.find(proc->name() );
147 QString string; 147 QString string;
148 if ( it != m_out.end() ) { 148 if ( it != m_out.end() ) {
149 string = it.data(); 149 string = it.data();
150 } 150 }
151 string.append( str ); 151 string.append( str );
152 m_out.replace( proc->name(), string ); 152 m_out.replace( proc->name(), string );
153 153
154} 154}
155void Manager::slotSDPExited( OProcess* proc) 155void Manager::slotSDPExited( OProcess* proc)
156{ 156{
157 owarn << "proc name " << proc->name() << oendl; 157 odebug << "Manager: proc name " << proc->name() << oendl;
158 Services::ValueList list; 158 Services::ValueList list;
159 if (proc->normalExit() ) { 159 if (proc->normalExit() ) {
160 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 160 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
161 if ( it != m_out.end() ) { 161 if ( it != m_out.end() ) {
162 owarn << "found process" << oendl; 162 odebug << "Manager: found process" << oendl;
163 list = parseSDPOutput( it.data() ); 163 list = parseSDPOutput( it.data() );
164 m_out.remove( it ); 164 m_out.remove( it );
165 } 165 }
166 } 166 }
167 emit foundServices( proc->name(), list ); 167 emit foundServices( proc->name(), list );
168 delete proc; 168 delete proc;
169} 169}
170Services::ValueList Manager::parseSDPOutput( const QString& out ) { 170Services::ValueList Manager::parseSDPOutput( const QString& out ) {
171 Services::ValueList list; 171 Services::ValueList list;
172 owarn << "parsing output" << oendl; 172 odebug << "Manager: parsing output" << oendl;
173 Parser parser( out ); 173 Parser parser( out );
174 list = parser.services(); 174 list = parser.services();
175 return list; 175 return list;
176} 176}
177 177
178void Manager::slotHCIExited(OProcess* proc ) { 178void Manager::slotHCIExited(OProcess* proc ) {
179 owarn << "process exited" << oendl; 179 odebug << "Manager: process exited" << oendl;
180 RemoteDevice::ValueList list; 180 RemoteDevice::ValueList list;
181 if (proc->normalExit() ) { 181 if (proc->normalExit() ) {
182 owarn << "normalExit " << proc->name() << oendl; 182 odebug << "Manager: normalExit " << proc->name() << oendl;
183 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 183 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
184 if (it != m_devices.end() ) { 184 if (it != m_devices.end() ) {
185 owarn << "!= end ;)" << oendl; 185 odebug << "Manager: != end ;)" << oendl;
186 list = parseHCIOutput( it.data() ); 186 list = parseHCIOutput( it.data() );
187 m_devices.remove( it ); 187 m_devices.remove( it );
188 } 188 }
189 } 189 }
190 emit foundDevices( proc->name(), list ); 190 emit foundDevices( proc->name(), list );
191 delete proc; 191 delete proc;
192} 192}
193void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 193void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
194 QCString str( ch, len+1 ); 194 QCString str( ch, len+1 );
195 owarn << "hci: " << str.data() << oendl; 195 odebug << "Manager: hci: " << str.data() << oendl;
196 QMap<QString, QString>::Iterator it; 196 QMap<QString, QString>::Iterator it;
197 it = m_devices.find( proc->name() ); 197 it = m_devices.find( proc->name() );
198 owarn << "proc->name " << proc->name() << oendl; 198 odebug << "Manager: proc->name " << proc->name() << oendl;
199 QString string; 199 QString string;
200 if (it != m_devices.end() ) { 200 if (it != m_devices.end() ) {
201 owarn << "slotHCIOut " << oendl; 201 odebug << "Manager: slotHCIOut " << oendl;
202 string = it.data(); 202 string = it.data();
203 } 203 }
204 string.append( str ); 204 string.append( str );
205 205
206 m_devices.replace( proc->name(), string ); 206 m_devices.replace( proc->name(), string );
207} 207}
208RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { 208RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
209 owarn << "parseHCI " << output.latin1() << oendl; 209 odebug << "Manager: parseHCI " << output.latin1() << oendl;
210 RemoteDevice::ValueList list; 210 RemoteDevice::ValueList list;
211 QStringList strList = QStringList::split('\n', output ); 211 QStringList strList = QStringList::split('\n', output );
212 QStringList::Iterator it; 212 QStringList::Iterator it;
213 QString str; 213 QString str;
214 for ( it = strList.begin(); it != strList.end(); ++it ) { 214 for ( it = strList.begin(); it != strList.end(); ++it ) {
215 str = (*it).stripWhiteSpace(); 215 str = (*it).stripWhiteSpace();
216 owarn << "OpieTooth " << str.latin1() << oendl; 216 odebug << "Manager: OpieTooth " << str.latin1() << oendl;
217 int pos = str.findRev(':' ); 217 int pos = str.findRev(':' );
218 if ( pos > 0 ) { 218 if ( pos > 0 ) {
219 QString mac = str.left(17 ); 219 QString mac = str.left(17 );
220 str.remove( 0, 17 ); 220 str.remove( 0, 17 );
221 owarn << "mac " << mac.latin1() << oendl; 221 odebug << "Manager: mac " << mac.latin1() << oendl;
222 owarn << "rest: " << str.latin1() << oendl; 222 odebug << "Manager: rest: " << str.latin1() << oendl;
223 RemoteDevice rem( mac , str.stripWhiteSpace() ); 223 RemoteDevice rem( mac , str.stripWhiteSpace() );
224 list.append( rem ); 224 list.append( rem );
225 } 225 }
226 } 226 }
227 return list; 227 return list;
228} 228}
@@ -241,13 +241,13 @@ void Manager::connectTo( const QString& mac) {
241 proc << mac; 241 proc << mac;
242 proc.start(OProcess::DontCare); // the lib does not care at this point 242 proc.start(OProcess::DontCare); // the lib does not care at this point
243} 243}
244 244
245 245
246void Manager::searchConnections() { 246void Manager::searchConnections() {
247 owarn << "searching connections?" << oendl; 247 odebug << "Manager: searchConnections()" << oendl;
248 OProcess* proc = new OProcess(); 248 OProcess* proc = new OProcess();
249 m_hcitoolCon = QString::null; 249 m_hcitoolCon = QString::null;
250 250
251 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*) ), 251 connect(proc, SIGNAL(processExited(Opie::Core::OProcess*) ),
252 this, SLOT(slotConnectionExited( Opie::Core::OProcess*) ) ); 252 this, SLOT(slotConnectionExited( Opie::Core::OProcess*) ) );
253 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ), 253 connect(proc, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int) ),
@@ -279,21 +279,21 @@ ConnectionState::ValueList Manager::parseConnections( const QString& out ) {
279 // remove the first line ( "Connections:") 279 // remove the first line ( "Connections:")
280 it = list.begin(); 280 it = list.begin();
281 it = list.remove( it ); 281 it = list.remove( it );
282 for (; it != list.end(); ++it ) { 282 for (; it != list.end(); ++it ) {
283 QString row = (*it).stripWhiteSpace(); 283 QString row = (*it).stripWhiteSpace();
284 QStringList value = QStringList::split(' ', row ); 284 QStringList value = QStringList::split(' ', row );
285 owarn << "0: %s" << value[0].latin1() << oendl; 285 odebug << "Manager: 0: " << value[0].latin1() << oendl;
286 owarn << "1: %s" << value[1].latin1() << oendl; 286 odebug << "Manager: 1: " << value[1].latin1() << oendl;
287 owarn << "2: %s" << value[2].latin1() << oendl; 287 odebug << "Manager: 2: " << value[2].latin1() << oendl;
288 owarn << "3: %s" << value[3].latin1() << oendl; 288 odebug << "Manager: 3: " << value[3].latin1() << oendl;
289 owarn << "4: %s" << value[4].latin1() << oendl; 289 odebug << "Manager: 4: " << value[4].latin1() << oendl;
290 owarn << "5: %s" << value[5].latin1() << oendl; 290 odebug << "Manager: 5: " << value[5].latin1() << oendl;
291 owarn << "6: %s" << value[6].latin1() << oendl; 291 odebug << "Manager: 6: " << value[6].latin1() << oendl;
292 owarn << "7: %s" << value[7].latin1() << oendl; 292 odebug << "Manager: 7: " << value[7].latin1() << oendl;
293 owarn << "8: %s" << value[8].latin1() << oendl; 293 odebug << "Manager: 8: " << value[8].latin1() << oendl;
294 ConnectionState con; 294 ConnectionState con;
295 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming ); 295 con.setDirection( value[0] == QString::fromLatin1("<") ? Outgoing : Incoming );
296 con.setConnectionMode( value[1] ); 296 con.setConnectionMode( value[1] );
297 con.setMac( value[2] ); 297 con.setMac( value[2] );
298 con.setHandle( value[4].toInt() ); 298 con.setHandle( value[4].toInt() );
299 con.setState( value[6].toInt() ); 299 con.setState( value[6].toInt() );