summaryrefslogtreecommitdiff
authorkorovkin <korovkin>2006-05-02 19:48:56 (UTC)
committer korovkin <korovkin>2006-05-02 19:48:56 (UTC)
commit1240155cf5865df0d0ce0e4bd04dfec68ec1ede5 (patch) (unidiff)
tree5b02700cd155920820712a9033cafe5ea60d6a30
parentc1299012f67f2ae99a4f83445692afbe9244a676 (diff)
downloadopie-1240155cf5865df0d0ce0e4bd04dfec68ec1ede5.zip
opie-1240155cf5865df0d0ce0e4bd04dfec68ec1ede5.tar.gz
opie-1240155cf5865df0d0ce0e4bd04dfec68ec1ede5.tar.bz2
Destroy process on an object destruction.
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
@@ -59,18 +59,19 @@ void Manager::isAvailable( Device* /*dev*/ ){
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
@@ -105,7 +106,7 @@ void Manager::removeServices( const QStringList& list){
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;
@@ -116,6 +117,7 @@ void Manager::searchServices( const QString& remDevice ){
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 }
@@ -165,6 +167,8 @@ void Manager::slotSDPExited( OProcess* proc)
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 ) {
@@ -188,6 +192,8 @@ void Manager::slotHCIExited(OProcess* proc ) {
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) {