summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/manager.cc
authorharlekin <harlekin>2002-06-16 20:21:06 (UTC)
committer harlekin <harlekin>2002-06-16 20:21:06 (UTC)
commit5c098847f0fd716c4fe697e5eb314111a4ae5df1 (patch) (unidiff)
tree590ed709442bf6ba4a28eb242840dcf1de6da756 /noncore/net/opietooth/lib/manager.cc
parent8dde6abcd14717bd362248c365fe140efe0f0386 (diff)
downloadopie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.zip
opie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.tar.gz
opie-5c098847f0fd716c4fe697e5eb314111a4ae5df1.tar.bz2
remoteDevice not removeDevices
Diffstat (limited to 'noncore/net/opietooth/lib/manager.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 40c1f0a..c454588 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -41,49 +41,49 @@ void Manager::isConnected( const QString& device ){
41 *l2ping << "l2ping" << "-c1" << device; 41 *l2ping << "l2ping" << "-c1" << device;
42 connect(l2ping, SIGNAL(processExited(OProcess* ) ), 42 connect(l2ping, SIGNAL(processExited(OProcess* ) ),
43 this, SLOT(slotProcessExited(OProcess*) ) ); 43 this, SLOT(slotProcessExited(OProcess*) ) );
44 if (!l2ping->start() ) { 44 if (!l2ping->start() ) {
45 emit connected( device, false ); 45 emit connected( device, false );
46 delete l2ping; 46 delete l2ping;
47 } 47 }
48 48
49} 49}
50void Manager::isConnected( Device* dev ){ 50void Manager::isConnected( Device* dev ){
51 51
52 52
53} 53}
54void Manager::searchDevices( const QString& device ){ 54void Manager::searchDevices( const QString& device ){
55 qWarning("search devices"); 55 qWarning("search devices");
56 OProcess* hcitool = new OProcess(); 56 OProcess* hcitool = new OProcess();
57 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 57 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
58 *hcitool << "hcitool" << "scan"; 58 *hcitool << "hcitool" << "scan";
59 connect( hcitool, SIGNAL(processExited(OProcess*) ) , 59 connect( hcitool, SIGNAL(processExited(OProcess*) ) ,
60 this, SLOT(slotHCIExited(OProcess* ) ) ); 60 this, SLOT(slotHCIExited(OProcess* ) ) );
61 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 61 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
62 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); 62 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) );
63 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 63 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
64 qWarning("could not start"); 64 qWarning("could not start");
65 RemoteDevices::ValueList list; 65 RemoteDevice::ValueList list;
66 emit foundDevices( device, list ); 66 emit foundDevices( device, list );
67 delete hcitool; 67 delete hcitool;
68 } 68 }
69} 69}
70 70
71void Manager::searchDevices(Device* d ){ 71void Manager::searchDevices(Device* d ){
72 72
73 73
74} 74}
75void Manager::addService(const QString& name ){ 75void Manager::addService(const QString& name ){
76 OProcess proc; 76 OProcess proc;
77 proc << "sdptool" << "add" << name; 77 proc << "sdptool" << "add" << name;
78 bool bo = true; 78 bool bo = true;
79 if (!proc.start(OProcess::DontCare ) ) 79 if (!proc.start(OProcess::DontCare ) )
80 bo = false; 80 bo = false;
81 emit addedService( name, bo ); 81 emit addedService( name, bo );
82} 82}
83void Manager::addServices(const QStringList& list){ 83void Manager::addServices(const QStringList& list){
84 QStringList::ConstIterator it; 84 QStringList::ConstIterator it;
85 for (it = list.begin(); it != list.end(); ++it ) 85 for (it = list.begin(); it != list.end(); ++it )
86 addService( (*it) ); 86 addService( (*it) );
87} 87}
88void Manager::removeService( const QString& name ){ 88void Manager::removeService( const QString& name ){
89 OProcess prc; 89 OProcess prc;
@@ -91,49 +91,49 @@ void Manager::removeService( const QString& name ){
91 bool bo = true; 91 bool bo = true;
92 if (!prc.start(OProcess::DontCare ) ) 92 if (!prc.start(OProcess::DontCare ) )
93 bo = false; 93 bo = false;
94 emit removedService( name, bo ); 94 emit removedService( name, bo );
95} 95}
96void Manager::removeServices( const QStringList& list){ 96void Manager::removeServices( const QStringList& list){
97 QStringList::ConstIterator it; 97 QStringList::ConstIterator it;
98 for (it = list.begin(); it != list.end(); ++it ) 98 for (it = list.begin(); it != list.end(); ++it )
99 removeService( (*it) ); 99 removeService( (*it) );
100} 100}
101void Manager::searchServices( const QString& remDevice ){ 101void Manager::searchServices( const QString& remDevice ){
102 OProcess *m_sdp =new OProcess(); 102 OProcess *m_sdp =new OProcess();
103 *m_sdp << "sdptool" << "browse" << remDevice; 103 *m_sdp << "sdptool" << "browse" << remDevice;
104 m_sdp->setName( remDevice.latin1() ); 104 m_sdp->setName( remDevice.latin1() );
105 connect(m_sdp, SIGNAL(processExited(OProcess*) ), 105 connect(m_sdp, SIGNAL(processExited(OProcess*) ),
106 this, SLOT(slotSDPExited(OProcess* ) ) ); 106 this, SLOT(slotSDPExited(OProcess* ) ) );
107 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 107 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
108 this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); 108 this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
109 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 109 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
110 delete m_sdp; 110 delete m_sdp;
111 Services::ValueList list; 111 Services::ValueList list;
112 emit foundServices( remDevice, list ); 112 emit foundServices( remDevice, list );
113 } 113 }
114} 114}
115void Manager::searchServices( const RemoteDevices& dev){ 115void Manager::searchServices( const RemoteDevice& dev){
116 searchServices( dev.mac() ); 116 searchServices( dev.mac() );
117} 117}
118QString Manager::toDevice( const QString& mac ){ 118QString Manager::toDevice( const QString& mac ){
119 119
120} 120}
121QString Manager::toMac( const QString &device ){ 121QString Manager::toMac( const QString &device ){
122 122
123} 123}
124void Manager::slotProcessExited(OProcess* proc ) { 124void Manager::slotProcessExited(OProcess* proc ) {
125 bool conn= false; 125 bool conn= false;
126 if (proc->normalExit() && proc->exitStatus() == 0 ) 126 if (proc->normalExit() && proc->exitStatus() == 0 )
127 conn = true; 127 conn = true;
128 128
129 QString name = QString::fromLatin1(proc->name() ); 129 QString name = QString::fromLatin1(proc->name() );
130 emit connected( name, conn ); 130 emit connected( name, conn );
131 delete proc; 131 delete proc;
132} 132}
133void Manager::slotSDPOut(OProcess* proc, char* ch, int len) 133void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
134{ 134{
135 QCString str(ch, len+1 ); 135 QCString str(ch, len+1 );
136 QMap<QString, QString>::Iterator it; 136 QMap<QString, QString>::Iterator it;
137 it = m_out.find(proc->name() ); 137 it = m_out.find(proc->name() );
138 if ( it != m_out.end() ) { 138 if ( it != m_out.end() ) {
139 QString string = it.data(); 139 QString string = it.data();
@@ -141,73 +141,73 @@ void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
141 m_out.replace( proc->name(), string ); 141 m_out.replace( proc->name(), string );
142 } 142 }
143 143
144} 144}
145void Manager::slotSDPExited( OProcess* proc) 145void Manager::slotSDPExited( OProcess* proc)
146{ 146{
147 Services::ValueList list; 147 Services::ValueList list;
148 if (proc->normalExit() ) { 148 if (proc->normalExit() ) {
149 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 149 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
150 if ( it != m_out.end() ) { 150 if ( it != m_out.end() ) {
151 list = parseSDPOutput( it.data() ); 151 list = parseSDPOutput( it.data() );
152 m_out.remove( it ); 152 m_out.remove( it );
153 } 153 }
154 } 154 }
155 emit foundServices( proc->name(), list ); 155 emit foundServices( proc->name(), list );
156 delete proc; 156 delete proc;
157} 157}
158Services::ValueList Manager::parseSDPOutput( const QString& out ) { 158Services::ValueList Manager::parseSDPOutput( const QString& out ) {
159 Services::ValueList list; 159 Services::ValueList list;
160 return list; 160 return list;
161} 161}
162 162
163void Manager::slotHCIExited(OProcess* proc ) { 163void Manager::slotHCIExited(OProcess* proc ) {
164 qWarning("process exited"); 164 qWarning("process exited");
165 RemoteDevices::ValueList list; 165 RemoteDevice::ValueList list;
166 if (proc->normalExit() ) { 166 if (proc->normalExit() ) {
167 qWarning("normalExit %s", proc->name() ); 167 qWarning("normalExit %s", proc->name() );
168 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 168 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
169 if (it != m_devices.end() ) { 169 if (it != m_devices.end() ) {
170 qWarning("!= end ;)"); 170 qWarning("!= end ;)");
171 list = parseHCIOutput( it.data() ); 171 list = parseHCIOutput( it.data() );
172 m_devices.remove( it ); 172 m_devices.remove( it );
173 } 173 }
174 } 174 }
175 emit foundDevices( proc->name(), list ); 175 emit foundDevices( proc->name(), list );
176 delete proc; 176 delete proc;
177} 177}
178void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 178void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
179 QCString str( ch, len+1 ); 179 QCString str( ch, len+1 );
180 qWarning("hci: %s", str.data() ); 180 qWarning("hci: %s", str.data() );
181 QMap<QString, QString>::Iterator it; 181 QMap<QString, QString>::Iterator it;
182 it = m_devices.find( proc->name() ); 182 it = m_devices.find( proc->name() );
183 qWarning("proc->name %s", proc->name() ); 183 qWarning("proc->name %s", proc->name() );
184 QString string; 184 QString string;
185 if (it != m_devices.end() ) { 185 if (it != m_devices.end() ) {
186 qWarning("slotHCIOut "); 186 qWarning("slotHCIOut ");
187 string = it.data(); 187 string = it.data();
188 } 188 }
189 string.append( str ); 189 string.append( str );
190 190
191 m_devices.replace( proc->name(), string ); 191 m_devices.replace( proc->name(), string );
192} 192}
193RemoteDevices::ValueList Manager::parseHCIOutput(const QString& output ) { 193RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
194 qWarning("parseHCI %s", output.latin1() ); 194 qWarning("parseHCI %s", output.latin1() );
195 RemoteDevices::ValueList list; 195 RemoteDevice::ValueList list;
196 QStringList strList = QStringList::split('\n', output ); 196 QStringList strList = QStringList::split('\n', output );
197 QStringList::Iterator it; 197 QStringList::Iterator it;
198 QString str; 198 QString str;
199 for ( it = strList.begin(); it != strList.end(); ++it ) { 199 for ( it = strList.begin(); it != strList.end(); ++it ) {
200 str = (*it).stripWhiteSpace(); 200 str = (*it).stripWhiteSpace();
201 qWarning("OpieTooth %s", str.latin1() ); 201 qWarning("OpieTooth %s", str.latin1() );
202 int pos = str.findRev(':' ); 202 int pos = str.findRev(':' );
203 if ( pos > 0 ) { 203 if ( pos > 0 ) {
204 QString mac = str.left(17 ); 204 QString mac = str.left(17 );
205 str.remove( 0, 17 ); 205 str.remove( 0, 17 );
206 qWarning("mac %s", mac.latin1() ); 206 qWarning("mac %s", mac.latin1() );
207 qWarning("rest:%s", str.latin1() ); 207 qWarning("rest:%s", str.latin1() );
208 RemoteDevices rem( mac , str.stripWhiteSpace() ); 208 RemoteDevice rem( mac , str.stripWhiteSpace() );
209 list.append( rem ); 209 list.append( rem );
210 } 210 }
211 } 211 }
212 return list; 212 return list;
213} 213}