summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc22
1 files changed, 14 insertions, 8 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 83accf7..7311484 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -50,36 +50,37 @@ void Manager::isAvailable( const QString& device ){
50 emit available( device, false ); 50 emit available( device, false );
51 delete l2ping; 51 delete l2ping;
52 } 52 }
53 53
54} 54}
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 odebug << "Manager: search devices" << oendl; 61 odebug << "Manager: search devices" << oendl;
62 OProcess* hcitool = new OProcess(); 62 m_hcitool = new OProcess();
63 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 63 m_hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
64 *hcitool << "hcitool" << "scan"; 64 *m_hcitool << "hcitool" << "scan";
65 connect( hcitool, SIGNAL(processExited(Opie::Core::OProcess*) ) , 65 connect( m_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( m_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 (!m_hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
70 odebug << "Manager: 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 m_hcitool;
74 m_hcitool = 0;
74 } 75 }
75} 76}
76 77
77void Manager::searchDevices(Device* /*d*/ ){ 78void Manager::searchDevices(Device* /*d*/ ){
78 79
79 80
80} 81}
81void Manager::addService(const QString& name ){ 82void Manager::addService(const QString& name ){
82 OProcess proc; 83 OProcess proc;
83 proc << "sdptool" << "add" << name; 84 proc << "sdptool" << "add" << name;
84 bool bo = true; 85 bool bo = true;
85 if (!proc.start(OProcess::DontCare ) ) 86 if (!proc.start(OProcess::DontCare ) )
@@ -96,35 +97,36 @@ void Manager::removeService( const QString& name ){
96 prc << "sdptool" << "del" << name; 97 prc << "sdptool" << "del" << name;
97 bool bo = true; 98 bool bo = true;
98 if (!prc.start(OProcess::DontCare ) ) 99 if (!prc.start(OProcess::DontCare ) )
99 bo = false; 100 bo = false;
100 emit removedService( name, bo ); 101 emit removedService( name, bo );
101} 102}
102void Manager::removeServices( const QStringList& list){ 103void Manager::removeServices( const QStringList& list){
103 QStringList::ConstIterator it; 104 QStringList::ConstIterator it;
104 for (it = list.begin(); it != list.end(); ++it ) 105 for (it = list.begin(); it != list.end(); ++it )
105 removeService( (*it) ); 106 removeService( (*it) );
106} 107}
107void Manager::searchServices( const QString& remDevice ){ 108void Manager::searchServices( const QString& remDevice ){
108 OProcess *m_sdp =new OProcess(); 109 m_sdp =new OProcess();
109 *m_sdp << "sdptool" << "browse" << remDevice; 110 *m_sdp << "sdptool" << "browse" << remDevice;
110 m_sdp->setName( remDevice.latin1() ); 111 m_sdp->setName( remDevice.latin1() );
111 odebug << "Manager: search Services for " << remDevice.latin1() << oendl; 112 odebug << "Manager: search Services for " << remDevice.latin1() << oendl;
112 connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ), 113 connect(m_sdp, SIGNAL(processExited(Opie::Core::OProcess*) ),
113 this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) ); 114 this, SLOT(slotSDPExited(Opie::Core::OProcess* ) ) );
114 connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ), 115 connect(m_sdp, SIGNAL(receivedStdout(Opie::Core::OProcess*, char*, int ) ),
115 this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) ); 116 this, SLOT(slotSDPOut(Opie::Core::OProcess*, char*, int) ) );
116 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 117 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
117 odebug << "Manager: could not start sdptool" << oendl; 118 odebug << "Manager: could not start sdptool" << oendl;
118 delete m_sdp; 119 delete m_sdp;
120 m_sdp = 0;
119 Services::ValueList list; 121 Services::ValueList list;
120 emit foundServices( remDevice, list ); 122 emit foundServices( remDevice, list );
121 } 123 }
122} 124}
123void Manager::searchServices( const RemoteDevice& dev){ 125void Manager::searchServices( const RemoteDevice& dev){
124 searchServices( dev.mac() ); 126 searchServices( dev.mac() );
125} 127}
126QString Manager::toDevice( const QString& /*mac*/ ){ 128QString Manager::toDevice( const QString& /*mac*/ ){
127 return QString::null; 129 return QString::null;
128} 130}
129QString Manager::toMac( const QString &/*device*/ ){ 131QString Manager::toMac( const QString &/*device*/ ){
130 return QString::null; 132 return QString::null;
@@ -156,47 +158,51 @@ void Manager::slotSDPExited( OProcess* proc)
156{ 158{
157 odebug << "Manager: proc name " << proc->name() << oendl; 159 odebug << "Manager: proc name " << proc->name() << oendl;
158 Services::ValueList list; 160 Services::ValueList list;
159 if (proc->normalExit() ) { 161 if (proc->normalExit() ) {
160 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 162 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
161 if ( it != m_out.end() ) { 163 if ( it != m_out.end() ) {
162 odebug << "Manager: found process" << oendl; 164 odebug << "Manager: found process" << oendl;
163 list = parseSDPOutput( it.data() ); 165 list = parseSDPOutput( it.data() );
164 m_out.remove( it ); 166 m_out.remove( it );
165 } 167 }
166 } 168 }
167 emit foundServices( proc->name(), list ); 169 emit foundServices( proc->name(), list );
170 if (proc == m_sdp)
171 m_sdp = 0;
168 delete proc; 172 delete proc;
169} 173}
170Services::ValueList Manager::parseSDPOutput( const QString& out ) { 174Services::ValueList Manager::parseSDPOutput( const QString& out ) {
171 Services::ValueList list; 175 Services::ValueList list;
172 odebug << "Manager: parsing output" << oendl; 176 odebug << "Manager: parsing output" << oendl;
173 Parser parser( out ); 177 Parser parser( out );
174 list = parser.services(); 178 list = parser.services();
175 return list; 179 return list;
176} 180}
177 181
178void Manager::slotHCIExited(OProcess* proc ) { 182void Manager::slotHCIExited(OProcess* proc ) {
179 odebug << "Manager: process exited" << oendl; 183 odebug << "Manager: process exited" << oendl;
180 RemoteDevice::ValueList list; 184 RemoteDevice::ValueList list;
181 if (proc->normalExit() ) { 185 if (proc->normalExit() ) {
182 odebug << "Manager: normalExit " << proc->name() << oendl; 186 odebug << "Manager: normalExit " << proc->name() << oendl;
183 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 187 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
184 if (it != m_devices.end() ) { 188 if (it != m_devices.end() ) {
185 odebug << "Manager: != end ;)" << oendl; 189 odebug << "Manager: != end ;)" << oendl;
186 list = parseHCIOutput( it.data() ); 190 list = parseHCIOutput( it.data() );
187 m_devices.remove( it ); 191 m_devices.remove( it );
188 } 192 }
189 } 193 }
190 emit foundDevices( proc->name(), list ); 194 emit foundDevices( proc->name(), list );
195 if (proc == m_hcitool)
196 m_hcitool = 0;
191 delete proc; 197 delete proc;
192} 198}
193void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 199void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
194 QCString str( ch, len+1 ); 200 QCString str( ch, len+1 );
195 odebug << "Manager: hci: " << str.data() << oendl; 201 odebug << "Manager: hci: " << str.data() << oendl;
196 QMap<QString, QString>::Iterator it; 202 QMap<QString, QString>::Iterator it;
197 it = m_devices.find( proc->name() ); 203 it = m_devices.find( proc->name() );
198 odebug << "Manager: proc->name " << proc->name() << oendl; 204 odebug << "Manager: proc->name " << proc->name() << oendl;
199 QString string; 205 QString string;
200 if (it != m_devices.end() ) { 206 if (it != m_devices.end() ) {
201 odebug << "Manager: slotHCIOut " << oendl; 207 odebug << "Manager: slotHCIOut " << oendl;
202 string = it.data(); 208 string = it.data();