summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/manager.cc13
-rw-r--r--noncore/net/opietooth/lib/parser.cc49
2 files changed, 46 insertions, 16 deletions
diff --git a/noncore/net/opietooth/lib/manager.cc b/noncore/net/opietooth/lib/manager.cc
index 177c94e..23506b3 100644
--- a/noncore/net/opietooth/lib/manager.cc
+++ b/noncore/net/opietooth/lib/manager.cc
@@ -1,219 +1,226 @@
1 1
2 2
3#include <opie/oprocess.h> 3#include <opie/oprocess.h>
4 4
5#include "parser.h" 5#include "parser.h"
6#include "manager.h" 6#include "manager.h"
7 7
8 8
9using namespace OpieTooth; 9using namespace OpieTooth;
10 10
11Manager::Manager( const QString& dev ) 11Manager::Manager( const QString& dev )
12 : QObject() 12 : QObject()
13{ 13{
14 qWarning("created"); 14 qWarning("created");
15 m_device = dev; 15 m_device = dev;
16 m_hcitool = 0; 16 m_hcitool = 0;
17 m_sdp = 0; 17 m_sdp = 0;
18} 18}
19Manager::Manager( Device* /*dev*/ ) 19Manager::Manager( Device* /*dev*/ )
20 : QObject() 20 : QObject()
21{ 21{
22 m_hcitool = 0; 22 m_hcitool = 0;
23 m_sdp = 0; 23 m_sdp = 0;
24} 24}
25Manager::Manager() 25Manager::Manager()
26 : QObject() 26 : QObject()
27{ 27{
28 m_hcitool = 0; 28 m_hcitool = 0;
29 m_sdp = 0; 29 m_sdp = 0;
30} 30}
31Manager::~Manager(){ 31Manager::~Manager(){
32 delete m_hcitool; 32 delete m_hcitool;
33 delete m_sdp; 33 delete m_sdp;
34} 34}
35void Manager::setDevice( const QString& dev ){ 35void Manager::setDevice( const QString& dev ){
36 m_device = dev; 36 m_device = dev;
37} 37}
38void Manager::setDevice( Device* /*dev*/ ){ 38void Manager::setDevice( Device* /*dev*/ ){
39 39
40} 40}
41void Manager::isAvailable( const QString& device ){ 41void Manager::isAvailable( const QString& device ){
42 OProcess* l2ping = new OProcess(); 42 OProcess* l2ping = new OProcess();
43 l2ping->setName( device.latin1() ); 43 l2ping->setName( device.latin1() );
44 *l2ping << "l2ping" << "-c1" << device; 44 *l2ping << "l2ping" << "-c1" << device;
45 connect(l2ping, SIGNAL(processExited(OProcess* ) ), 45 connect(l2ping, SIGNAL(processExited(OProcess* ) ),
46 this, SLOT(slotProcessExited(OProcess*) ) ); 46 this, SLOT(slotProcessExited(OProcess*) ) );
47 if (!l2ping->start() ) { 47 if (!l2ping->start() ) {
48 emit available( device, false ); 48 emit available( device, false );
49 delete l2ping; 49 delete l2ping;
50 } 50 }
51 51
52} 52}
53 53
54void Manager::isAvailable( Device* /*dev*/ ){ 54void Manager::isAvailable( Device* /*dev*/ ){
55 55
56 56
57} 57}
58void Manager::searchDevices( const QString& device ){ 58void Manager::searchDevices( const QString& device ){
59 qWarning("search devices"); 59 qWarning("search devices");
60 OProcess* hcitool = new OProcess(); 60 OProcess* hcitool = new OProcess();
61 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() ); 61 hcitool->setName( device.isEmpty() ? "hci0" : device.latin1() );
62 *hcitool << "hcitool" << "scan"; 62 *hcitool << "hcitool" << "scan";
63 connect( hcitool, SIGNAL(processExited(OProcess*) ) , 63 connect( hcitool, SIGNAL(processExited(OProcess*) ) ,
64 this, SLOT(slotHCIExited(OProcess* ) ) ); 64 this, SLOT(slotHCIExited(OProcess* ) ) );
65 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 65 connect( hcitool, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
66 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) ); 66 this, SLOT(slotHCIOut(OProcess*, char*, int ) ) );
67 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 67 if (!hcitool->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
68 qWarning("could not start"); 68 qWarning("could not start");
69 RemoteDevice::ValueList list; 69 RemoteDevice::ValueList list;
70 emit foundDevices( device, list ); 70 emit foundDevices( device, list );
71 delete hcitool; 71 delete hcitool;
72 } 72 }
73} 73}
74 74
75void Manager::searchDevices(Device* /*d*/ ){ 75void Manager::searchDevices(Device* /*d*/ ){
76 76
77 77
78} 78}
79void Manager::addService(const QString& name ){ 79void Manager::addService(const QString& name ){
80 OProcess proc; 80 OProcess proc;
81 proc << "sdptool" << "add" << name; 81 proc << "sdptool" << "add" << name;
82 bool bo = true; 82 bool bo = true;
83 if (!proc.start(OProcess::DontCare ) ) 83 if (!proc.start(OProcess::DontCare ) )
84 bo = false; 84 bo = false;
85 emit addedService( name, bo ); 85 emit addedService( name, bo );
86} 86}
87void Manager::addServices(const QStringList& list){ 87void Manager::addServices(const QStringList& list){
88 QStringList::ConstIterator it; 88 QStringList::ConstIterator it;
89 for (it = list.begin(); it != list.end(); ++it ) 89 for (it = list.begin(); it != list.end(); ++it )
90 addService( (*it) ); 90 addService( (*it) );
91} 91}
92void Manager::removeService( const QString& name ){ 92void Manager::removeService( const QString& name ){
93 OProcess prc; 93 OProcess prc;
94 prc << "sdptool" << "del" << name; 94 prc << "sdptool" << "del" << name;
95 bool bo = true; 95 bool bo = true;
96 if (!prc.start(OProcess::DontCare ) ) 96 if (!prc.start(OProcess::DontCare ) )
97 bo = false; 97 bo = false;
98 emit removedService( name, bo ); 98 emit removedService( name, bo );
99} 99}
100void Manager::removeServices( const QStringList& list){ 100void Manager::removeServices( const QStringList& list){
101 QStringList::ConstIterator it; 101 QStringList::ConstIterator it;
102 for (it = list.begin(); it != list.end(); ++it ) 102 for (it = list.begin(); it != list.end(); ++it )
103 removeService( (*it) ); 103 removeService( (*it) );
104} 104}
105void Manager::searchServices( const QString& remDevice ){ 105void Manager::searchServices( const QString& remDevice ){
106 OProcess *m_sdp =new OProcess(); 106 OProcess *m_sdp =new OProcess();
107 *m_sdp << "sdptool" << "browse" << remDevice; 107 *m_sdp << "sdptool" << "browse" << remDevice;
108 m_sdp->setName( remDevice.latin1() ); 108 m_sdp->setName( remDevice.latin1() );
109 qWarning("search Services for %s", remDevice.latin1() );
109 connect(m_sdp, SIGNAL(processExited(OProcess*) ), 110 connect(m_sdp, SIGNAL(processExited(OProcess*) ),
110 this, SLOT(slotSDPExited(OProcess* ) ) ); 111 this, SLOT(slotSDPExited(OProcess* ) ) );
111 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ), 112 connect(m_sdp, SIGNAL(receivedStdout(OProcess*, char*, int ) ),
112 this, SLOT(slotSDPOut(OProcess*, char*, int) ) ); 113 this, SLOT(slotSDPOut(OProcess*, char*, int) ) );
113 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) { 114 if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
115 qWarning("could not start sdptool" );
114 delete m_sdp; 116 delete m_sdp;
115 Services::ValueList list; 117 Services::ValueList list;
116 emit foundServices( remDevice, list ); 118 emit foundServices( remDevice, list );
117 } 119 }
118} 120}
119void Manager::searchServices( const RemoteDevice& dev){ 121void Manager::searchServices( const RemoteDevice& dev){
120 searchServices( dev.mac() ); 122 searchServices( dev.mac() );
121} 123}
122QString Manager::toDevice( const QString& /*mac*/ ){ 124QString Manager::toDevice( const QString& /*mac*/ ){
123 return QString::null; 125 return QString::null;
124} 126}
125QString Manager::toMac( const QString &/*device*/ ){ 127QString Manager::toMac( const QString &/*device*/ ){
126 return QString::null; 128 return QString::null;
127} 129}
128void Manager::slotProcessExited(OProcess* proc ) { 130void Manager::slotProcessExited(OProcess* proc ) {
129 bool conn= false; 131 bool conn= false;
130 if (proc->normalExit() && proc->exitStatus() == 0 ) 132 if (proc->normalExit() && proc->exitStatus() == 0 )
131 conn = true; 133 conn = true;
132 134
133 QString name = QString::fromLatin1(proc->name() ); 135 QString name = QString::fromLatin1(proc->name() );
134 emit available( name, conn ); 136 emit available( name, conn );
135 delete proc; 137 delete proc;
136} 138}
137void Manager::slotSDPOut(OProcess* proc, char* ch, int len) 139void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
138{ 140{
139 QCString str(ch, len+1 ); 141 QCString str(ch, len+1 );
142 qWarning("SDP:%s", str.data() );
140 QMap<QString, QString>::Iterator it; 143 QMap<QString, QString>::Iterator it;
141 it = m_out.find(proc->name() ); 144 it = m_out.find(proc->name() );
145 QString string;
142 if ( it != m_out.end() ) { 146 if ( it != m_out.end() ) {
143 QString string = it.data(); 147 string = it.data();
144 string.append( str );
145 m_out.replace( proc->name(), string );
146 } 148 }
149 string.append( str );
150 m_out.replace( proc->name(), string );
147 151
148} 152}
149void Manager::slotSDPExited( OProcess* proc) 153void Manager::slotSDPExited( OProcess* proc)
150{ 154{
155 qWarning("proc name %s", proc->name() );
151 Services::ValueList list; 156 Services::ValueList list;
152 if (proc->normalExit() ) { 157 if (proc->normalExit() ) {
153 QMap<QString, QString>::Iterator it = m_out.find( proc->name() ); 158 QMap<QString, QString>::Iterator it = m_out.find( proc->name() );
154 if ( it != m_out.end() ) { 159 if ( it != m_out.end() ) {
160 qWarning("found process" );
155 list = parseSDPOutput( it.data() ); 161 list = parseSDPOutput( it.data() );
156 m_out.remove( it ); 162 m_out.remove( it );
157 } 163 }
158 } 164 }
159 emit foundServices( proc->name(), list ); 165 emit foundServices( proc->name(), list );
160 delete proc; 166 delete proc;
161} 167}
162Services::ValueList Manager::parseSDPOutput( const QString& out ) { 168Services::ValueList Manager::parseSDPOutput( const QString& out ) {
163 Services::ValueList list; 169 Services::ValueList list;
170 qWarning("parsing output" );
164 Parser parser( out ); 171 Parser parser( out );
165 list = parser.services(); 172 list = parser.services();
166 return list; 173 return list;
167} 174}
168 175
169void Manager::slotHCIExited(OProcess* proc ) { 176void Manager::slotHCIExited(OProcess* proc ) {
170 qWarning("process exited"); 177 qWarning("process exited");
171 RemoteDevice::ValueList list; 178 RemoteDevice::ValueList list;
172 if (proc->normalExit() ) { 179 if (proc->normalExit() ) {
173 qWarning("normalExit %s", proc->name() ); 180 qWarning("normalExit %s", proc->name() );
174 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() ); 181 QMap<QString, QString>::Iterator it = m_devices.find(proc->name() );
175 if (it != m_devices.end() ) { 182 if (it != m_devices.end() ) {
176 qWarning("!= end ;)"); 183 qWarning("!= end ;)");
177 list = parseHCIOutput( it.data() ); 184 list = parseHCIOutput( it.data() );
178 m_devices.remove( it ); 185 m_devices.remove( it );
179 } 186 }
180 } 187 }
181 emit foundDevices( proc->name(), list ); 188 emit foundDevices( proc->name(), list );
182 delete proc; 189 delete proc;
183} 190}
184void Manager::slotHCIOut(OProcess* proc, char* ch, int len) { 191void Manager::slotHCIOut(OProcess* proc, char* ch, int len) {
185 QCString str( ch, len+1 ); 192 QCString str( ch, len+1 );
186 qWarning("hci: %s", str.data() ); 193 qWarning("hci: %s", str.data() );
187 QMap<QString, QString>::Iterator it; 194 QMap<QString, QString>::Iterator it;
188 it = m_devices.find( proc->name() ); 195 it = m_devices.find( proc->name() );
189 qWarning("proc->name %s", proc->name() ); 196 qWarning("proc->name %s", proc->name() );
190 QString string; 197 QString string;
191 if (it != m_devices.end() ) { 198 if (it != m_devices.end() ) {
192 qWarning("slotHCIOut "); 199 qWarning("slotHCIOut ");
193 string = it.data(); 200 string = it.data();
194 } 201 }
195 string.append( str ); 202 string.append( str );
196 203
197 m_devices.replace( proc->name(), string ); 204 m_devices.replace( proc->name(), string );
198} 205}
199RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) { 206RemoteDevice::ValueList Manager::parseHCIOutput(const QString& output ) {
200 qWarning("parseHCI %s", output.latin1() ); 207 qWarning("parseHCI %s", output.latin1() );
201 RemoteDevice::ValueList list; 208 RemoteDevice::ValueList list;
202 QStringList strList = QStringList::split('\n', output ); 209 QStringList strList = QStringList::split('\n', output );
203 QStringList::Iterator it; 210 QStringList::Iterator it;
204 QString str; 211 QString str;
205 for ( it = strList.begin(); it != strList.end(); ++it ) { 212 for ( it = strList.begin(); it != strList.end(); ++it ) {
206 str = (*it).stripWhiteSpace(); 213 str = (*it).stripWhiteSpace();
207 qWarning("OpieTooth %s", str.latin1() ); 214 qWarning("OpieTooth %s", str.latin1() );
208 int pos = str.findRev(':' ); 215 int pos = str.findRev(':' );
209 if ( pos > 0 ) { 216 if ( pos > 0 ) {
210 QString mac = str.left(17 ); 217 QString mac = str.left(17 );
211 str.remove( 0, 17 ); 218 str.remove( 0, 17 );
212 qWarning("mac %s", mac.latin1() ); 219 qWarning("mac %s", mac.latin1() );
213 qWarning("rest:%s", str.latin1() ); 220 qWarning("rest:%s", str.latin1() );
214 RemoteDevice rem( mac , str.stripWhiteSpace() ); 221 RemoteDevice rem( mac , str.stripWhiteSpace() );
215 list.append( rem ); 222 list.append( rem );
216 } 223 }
217 } 224 }
218 return list; 225 return list;
219} 226}
diff --git a/noncore/net/opietooth/lib/parser.cc b/noncore/net/opietooth/lib/parser.cc
index 18d534e..00ec84a 100644
--- a/noncore/net/opietooth/lib/parser.cc
+++ b/noncore/net/opietooth/lib/parser.cc
@@ -1,173 +1,196 @@
1 1
2#include <qstringlist.h> 2#include <qstringlist.h>
3 3
4#include "parser.h" 4#include "parser.h"
5 5
6using namespace OpieTooth; 6using namespace OpieTooth;
7 7
8namespace { 8namespace {
9 9
10 10
11 // "Test Foo Bar" (0x3456) 11 // "Test Foo Bar" (0x3456)
12 // @param ret Test Foo Bar 12 // @param ret Test Foo Bar
13 // @eturn 13398 13 // @eturn 13398
14 // tactic find " ( 14 // tactic find " (
15int convert( const QString& line, QString& ret ) { 15int convert( const QString& line, QString& ret ) {
16// qWarning("called");
16 ret = QString::null; 17 ret = QString::null;
17 int i = 0; 18 int i = 0;
18 int pos = line.findRev("\" ("); 19 int pos = line.findRev("\" (");
19 if ( pos > 0 ) { // it shouldn't be at pos 0 20 if ( pos > 0 ) { // it shouldn't be at pos 0
20 ret = line.left(pos-1 ).stripWhiteSpace(); 21 ret = line.left(pos ).stripWhiteSpace();
21 qWarning("ret: %s", ret.latin1() ); 22 // qWarning("ret: %s", ret.latin1() );
22 ret = ret.replace(QRegExp("[\"]"), ""); 23 ret = ret.replace(QRegExp("[\"]"), "");
23 qWarning("ret: %s", ret.latin1() ); 24 //qWarning("ret: %s", ret.latin1() );
24 QString dummy = line.mid(pos + 4 ); 25 QString dummy = line.mid(pos + 5 );
25 qWarning("dummy: %s", dummy.latin1() ); 26 //qWarning("dummy: %s", dummy.latin1() );
26 dummy = dummy.remove( dummy.length() -1, 1 ); // remove the ( 27 dummy = dummy.replace(QRegExp("[)]"), "");
28 //qWarning("dummy: %s", dummy.latin1() );
29// dummy = dummy.remove( dummy.length() -2, 1 ); // remove the )
27 bool ok; 30 bool ok;
28 i = dummy.toInt(&ok, 16 ); 31 i = dummy.toInt(&ok, 16 );
32 //if (ok ) {
33 // qWarning("converted %d", i);
34 //}else qWarning("failed" );
35 //qWarning("exiting");
36 return i;
29 } 37 }
38 //qWarning("output %d", i );
30 return i; 39 return i;
31} 40}
32 41
33}; 42};
34 43
35 44
36Parser::Parser(const QString& output ) { 45Parser::Parser(const QString& output ) {
37 parse( output ); 46 parse( output );
38} 47}
39void Parser::setText(const QString& output) { 48void Parser::setText(const QString& output) {
40 parse( output ); 49 parse( output );
41} 50}
42Services::ValueList Parser::services() const { 51Services::ValueList Parser::services() const {
43 return m_list; 52 return m_list;
44} 53}
45void Parser::parse( const QString& string) { 54void Parser::parse( const QString& string) {
46 m_list.clear(); 55 m_list.clear();
47 m_complete = true; 56 m_complete = true;
48 QStringList list = QStringList::split('\n', string ); 57 QStringList list = QStringList::split('\n', string,TRUE );
49 QStringList::Iterator it; 58 QStringList::Iterator it;
50 for (it = list.begin(); it != list.end(); ++it ) { 59 for (it = list.begin(); it != list.end(); ++it ) {
60 qWarning("line:%s:line", (*it).latin1() );
51 if ( (*it).startsWith("Browsing") ) continue; 61 if ( (*it).startsWith("Browsing") ) continue;
52 62
53 if ( (*it).isEmpty() ) { // line is empty because a new Service begins 63 if ( (*it).stripWhiteSpace().isEmpty() ) { // line is empty because a new Service begins
54 // now see if complete and add 64 qWarning("could add");
65 // now see if complete and add
55 if (m_complete ) { 66 if (m_complete ) {
56 m_list.append( m_item ); 67 if (!m_item.serviceName().isEmpty() )
68 m_list.append( m_item );
57 Services serv; 69 Services serv;
58 m_item = serv; 70 m_item = serv;
59 m_complete = true; 71 m_complete = true;
60 continue; 72 continue;
61 } 73 }
62 } 74 }
63 if (parseName( (*it) ) ) ;//continue; 75 if (parseName( (*it) ) ) ;//continue;
64 if (parseRecHandle( (*it) ) ) ;//continue; 76 if (parseRecHandle( (*it) ) ) ;//continue;
65 if (parseClassId( (*it) ) ) ;//continue; 77 if (parseClassId( (*it) ) ) ;//continue;
66 if (parseProtocol( (*it) ) ) ;//continue; 78 if (parseProtocol( (*it) ) ) ;//continue;
67 if (parseProfile( (*it) ) ) ;//continue; 79 if (parseProfile( (*it) ) ) ;//continue;
68 } 80 }
69 // missed the last one 81 // missed the last one
70 if (m_complete) { 82 if (m_complete) {
71 m_list.append(m_item ); 83 qWarning("adding");
84 if (!m_item.serviceName().isEmpty() )
85 m_list.append(m_item );
86 }
87 QValueList<Services>::Iterator it2;
88
89 if (m_list.isEmpty() )
90 qWarning("m_list is empty");
91 for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) {
92 qWarning("name %s", (*it2).serviceName().latin1() );
72 } 93 }
73} 94}
74bool Parser::parseName( const QString& str) { 95bool Parser::parseName( const QString& str) {
75 if (str.startsWith("Service Name:") ) { 96 if (str.startsWith("Service Name:") ) {
76 m_item.setServiceName( str.mid(13).stripWhiteSpace() ); 97 m_item.setServiceName( str.mid(13).stripWhiteSpace() );
77 qWarning(m_item.serviceName() ); 98 qWarning(m_item.serviceName() );
78 return true; 99 return true;
79 } 100 }
80 return false; 101 return false;
81} 102}
82bool Parser::parseRecHandle( const QString& str) { 103bool Parser::parseRecHandle( const QString& str) {
83 if (str.startsWith("Service RecHandle:" ) ) { 104 if (str.startsWith("Service RecHandle:" ) ) {
84 QString out = str.mid(18 ).stripWhiteSpace(); 105 QString out = str.mid(18 ).stripWhiteSpace();
85 qWarning("out %s", out.latin1() ); 106 qWarning("out %s", out.latin1() );
86 int value = out.toInt(&m_ok, 16 ); 107 int value = out.mid(2).toInt(&m_ok, 16 );
87 if (m_ok && (value != -1) ) 108 if (m_ok && (value != -1) )
88 m_complete = true; 109 m_complete = true;
89 else 110 else
90 m_complete = false; 111 m_complete = false;
91 return true; 112 qWarning("rec handle %d", value);
92 m_item.setRecHandle( value ); 113 m_item.setRecHandle( value );
114 return true;
115
93 } 116 }
94 return false; 117 return false;
95} 118}
96bool Parser::parseClassId( const QString& str) { 119bool Parser::parseClassId( const QString& str) {
97 if (str.startsWith("Service Class ID List:") ) { 120 if (str.startsWith("Service Class ID List:") ) {
98 m_classOver = true; 121 m_classOver = true;
99 return true; 122 return true;
100 }else if ( m_classOver ) { // ok now are the informations in place 123 }else if ( m_classOver ) { // ok now are the informations in place
101 124
102 m_classOver = false; 125 m_classOver = false;
103 126
104 // "Obex Object Push" (0x1105) 127 // "Obex Object Push" (0x1105)
105 // find backwards the " and the from 0 to pos and the mid pos+1 128 // find backwards the " and the from 0 to pos and the mid pos+1
106 // then stripWhiteSpace add name replace '"' with "" 129 // then stripWhiteSpace add name replace '"' with ""
107 // and then convert 0x1105 toInt() 130 // and then convert 0x1105 toInt()
108 QString classes; 131 QString classes;
109 int ids; 132 int ids;
110 ids = convert( str, classes ); 133 ids = convert( str, classes );
111 qWarning("ids %d", ids ); 134 qWarning("ids %d", ids );
112 m_item.setClassIdList( classes ); 135 m_item.setClassIdList( classes );
113 m_item.setClassIdList( ids ); 136 m_item.setClassIdList( ids );
114 137
115 return true; 138 return true;
116 }else 139 }else
117 m_classOver = true; 140 m_classOver = true;
118 return false; 141 return false;
119} 142}
120bool Parser::parseProtocol( const QString& str) { 143bool Parser::parseProtocol( const QString& str) {
121 if (str.startsWith("Protocol Descriptor List:") ) { 144 if (str.startsWith("Protocol Descriptor List:") ) {
122 m_protocolOver = true; 145 m_protocolOver = true;
123 m_protocolAdded = false; 146 m_protocolAdded = false;
124 return true; 147 return true;
125 148
126 }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100) 149 }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100)
127 qWarning("double protocol filter"); 150 qWarning("double protocol filter");
128 151
129 if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now 152 if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now
130 Services::ProtocolDescriptor desc( m_protName, m_protId ); 153 Services::ProtocolDescriptor desc( m_protName, m_protId );
131 m_item.insertProtocolDescriptor( desc ); 154 m_item.insertProtocolDescriptor( desc );
132 } 155 }
133 m_protocolAdded = false; 156 m_protocolAdded = false;
134 { // the find function 157 { // the find function
135 m_protId = convert(str, m_protName ); 158 m_protId = convert(str, m_protName );
136 } 159 }
137 return true; 160 return true;
138 }else if (m_protocolOver && str.startsWith(" ") ) { 161 }else if (m_protocolOver && str.startsWith(" ") ) {
139 qWarning("tripple protocol filter"); 162 qWarning("tripple protocol filter");
140 m_protocolAdded = true; 163 m_protocolAdded = true;
141 QString dummy = str.stripWhiteSpace(); 164 QString dummy = str.stripWhiteSpace();
142 int pos = dummy.findRev(':'); 165 int pos = dummy.findRev(':');
143 if ( pos > -1 ) { 166 if ( pos > -1 ) {
144 int port = dummy.mid(pos+1 ).stripWhiteSpace().toInt(); 167 int port = dummy.mid(pos+1 ).stripWhiteSpace().toInt();
145 Services::ProtocolDescriptor desc( m_protName, m_protId, port ); 168 Services::ProtocolDescriptor desc( m_protName, m_protId, port );
146 m_item.insertProtocolDescriptor( desc ); 169 m_item.insertProtocolDescriptor( desc );
147 } 170 }
148 return true; 171 return true;
149 }else if (m_protocolOver ) { 172 }else if (m_protocolOver ) {
150 m_protocolOver = false; 173 m_protocolOver = false;
151 } 174 }
152 return false; 175 return false;
153} 176}
154bool Parser::parseProfile( const QString& str) { 177bool Parser::parseProfile( const QString& str) {
155 if (str.startsWith("Profile Descriptor List:") ) { 178 if (str.startsWith("Profile Descriptor List:") ) {
156 m_profOver = true; 179 m_profOver = true;
157 }else if ( m_profOver && str.startsWith(" ") ) { 180 }else if ( m_profOver && str.startsWith(" ") ) {
158 m_profId = convert( str, m_profName ); 181 m_profId = convert( str, m_profName );
159 }else if ( m_profOver && str.startsWith(" ") ) { 182 }else if ( m_profOver && str.startsWith(" ") ) {
160 // now find 183 // now find
161 int pos = str.findRev(':'); 184 int pos = str.findRev(':');
162 if ( pos > 0 ) { 185 if ( pos > 0 ) {
163 int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt(); 186 int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt();
164 qWarning("dummyInt:%d", dummy ); 187 qWarning("dummyInt:%d", dummy );
165 Services::ProfileDescriptor desc( m_profName, m_profId, dummy ); 188 Services::ProfileDescriptor desc( m_profName, m_profId, dummy );
166 m_item.insertProfileDescriptor(desc); 189 m_item.insertProfileDescriptor(desc);
167 } 190 }
168 }else 191 }else
169 m_profOver = false; 192 m_profOver = false;
170 193
171 194
172 return false; 195 return false;
173} 196}