summaryrefslogtreecommitdiff
path: root/noncore/net/opietooth/lib/parser.cc
Unidiff
Diffstat (limited to 'noncore/net/opietooth/lib/parser.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opietooth/lib/parser.cc60
1 files changed, 33 insertions, 27 deletions
diff --git a/noncore/net/opietooth/lib/parser.cc b/noncore/net/opietooth/lib/parser.cc
index 8baf284..7e95907 100644
--- a/noncore/net/opietooth/lib/parser.cc
+++ b/noncore/net/opietooth/lib/parser.cc
@@ -1,7 +1,13 @@
1 1
2#include "parser.h"
3
4/* OPIE */
5#include <opie2/odebug.h>
6using namespace Opie::Core;
7
8/* QT */
2#include <qstringlist.h> 9#include <qstringlist.h>
3 10
4#include "parser.h"
5 11
6using namespace OpieTooth; 12using namespace OpieTooth;
7 13
@@ -13,29 +19,29 @@ namespace {
13 // @eturn 13398 19 // @eturn 13398
14 // tactic find " ( 20 // tactic find " (
15int convert( const QString& line, QString& ret ) { 21int convert( const QString& line, QString& ret ) {
16// qWarning("called"); 22// owarn << "called" << oendl;
17 ret = QString::null; 23 ret = QString::null;
18 int i = 0; 24 int i = 0;
19 int pos = line.findRev("\" ("); 25 int pos = line.findRev("\" (");
20 if ( pos > 0 ) { // it shouldn't be at pos 0 26 if ( pos > 0 ) { // it shouldn't be at pos 0
21 ret = line.left(pos ).stripWhiteSpace(); 27 ret = line.left(pos ).stripWhiteSpace();
22 // qWarning("ret: %s", ret.latin1() ); 28 // owarn << "ret: " << ret.latin1() << oendl;
23 ret = ret.replace(QRegExp("[\"]"), ""); 29 ret = ret.replace(QRegExp("[\"]"), "");
24 //qWarning("ret: %s", ret.latin1() ); 30 //owarn << "ret: " << ret.latin1() << oendl;
25 QString dummy = line.mid(pos + 5 ); 31 QString dummy = line.mid(pos + 5 );
26 //qWarning("dummy: %s", dummy.latin1() ); 32 //owarn << "dummy: " << dummy.latin1() << oendl;
27 dummy = dummy.replace(QRegExp("[)]"), ""); 33 dummy = dummy.replace(QRegExp("[)]"), "");
28 //qWarning("dummy: %s", dummy.latin1() ); 34 //owarn << "dummy: " << dummy.latin1() << oendl;
29// dummy = dummy.remove( dummy.length() -2, 1 ); // remove the ) 35// dummy = dummy.remove( dummy.length() -2, 1 ); // remove the )
30 bool ok; 36 bool ok;
31 i = dummy.toInt(&ok, 16 ); 37 i = dummy.toInt(&ok, 16 );
32 //if (ok ) { 38 //if (ok ) {
33 // qWarning("converted %d", i); 39 // owarn << "converted " << i << oendl;
34 //}else qWarning("failed" ); 40 //}else owarn << "failed" << oendl;
35 //qWarning("exiting"); 41 //owarn << "exiting" << oendl;
36 return i; 42 return i;
37 } 43 }
38 //qWarning("output %d", i ); 44 //owarn << "output " << i << oendl;
39 return i; 45 return i;
40} 46}
41 47
@@ -57,11 +63,11 @@ void Parser::parse( const QString& string) {
57 QStringList list = QStringList::split('\n', string,TRUE ); 63 QStringList list = QStringList::split('\n', string,TRUE );
58 QStringList::Iterator it; 64 QStringList::Iterator it;
59 for (it = list.begin(); it != list.end(); ++it ) { 65 for (it = list.begin(); it != list.end(); ++it ) {
60 //qWarning("line:%s:line", (*it).latin1() ); 66 //owarn << "line:" << (*it).latin1() << oendl;
61 if ( (*it).startsWith("Browsing") ) continue; 67 if ( (*it).startsWith("Browsing") ) continue;
62 68
63 if ( (*it).stripWhiteSpace().isEmpty() ) { // line is empty because a new Service begins 69 if ( (*it).stripWhiteSpace().isEmpty() ) { // line is empty because a new Service begins
64 qWarning("could add"); 70 owarn << "could add" << oendl;
65 // now see if complete and add 71 // now see if complete and add
66 if (m_complete ) { 72 if (m_complete ) {
67 if (!m_item.serviceName().isEmpty() ) 73 if (!m_item.serviceName().isEmpty() )
@@ -80,22 +86,22 @@ void Parser::parse( const QString& string) {
80 } 86 }
81 // missed the last one 87 // missed the last one
82 if (m_complete) { 88 if (m_complete) {
83// qWarning("adding"); 89// owarn << "adding" << oendl;
84 if (!m_item.serviceName().isEmpty() ) 90 if (!m_item.serviceName().isEmpty() )
85 m_list.append(m_item ); 91 m_list.append(m_item );
86 } 92 }
87 QValueList<Services>::Iterator it2; 93 QValueList<Services>::Iterator it2;
88 94
89 if (m_list.isEmpty() ) 95 if (m_list.isEmpty() )
90 qWarning("m_list is empty"); 96 owarn << "m_list is empty" << oendl;
91 for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) { 97 for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) {
92 qWarning("name %s", (*it2).serviceName().latin1() ); 98 owarn << "name " << (*it2).serviceName().latin1() << oendl;
93 } 99 }
94} 100}
95bool Parser::parseName( const QString& str) { 101bool Parser::parseName( const QString& str) {
96 if (str.startsWith("Service Name:") ) { 102 if (str.startsWith("Service Name:") ) {
97 m_item.setServiceName( str.mid(13).stripWhiteSpace() ); 103 m_item.setServiceName( str.mid(13).stripWhiteSpace() );
98 qWarning(m_item.serviceName() ); 104 owarn << m_item.serviceName() << oendl;
99 return true; 105 return true;
100 } 106 }
101 return false; 107 return false;
@@ -103,13 +109,13 @@ bool Parser::parseName( const QString& str) {
103bool Parser::parseRecHandle( const QString& str) { 109bool Parser::parseRecHandle( const QString& str) {
104 if (str.startsWith("Service RecHandle:" ) ) { 110 if (str.startsWith("Service RecHandle:" ) ) {
105 QString out = str.mid(18 ).stripWhiteSpace(); 111 QString out = str.mid(18 ).stripWhiteSpace();
106 qWarning("out %s", out.latin1() ); 112 owarn << "out " << out.latin1() << oendl;
107 int value = out.mid(2).toInt(&m_ok, 16 ); 113 int value = out.mid(2).toInt(&m_ok, 16 );
108 if (m_ok && (value != -1) ) 114 if (m_ok && (value != -1) )
109 m_complete = true; 115 m_complete = true;
110 else 116 else
111 m_complete = false; 117 m_complete = false;
112 qWarning("rec handle %d", value); 118 owarn << "rec handle " << value << oendl;
113 m_item.setRecHandle( value ); 119 m_item.setRecHandle( value );
114 return true; 120 return true;
115 121
@@ -118,13 +124,13 @@ bool Parser::parseRecHandle( const QString& str) {
118} 124}
119bool Parser::parseClassId( const QString& str) { 125bool Parser::parseClassId( const QString& str) {
120 if (str.startsWith("Service Class ID List:") ) { 126 if (str.startsWith("Service Class ID List:") ) {
121 qWarning("found class id" ); 127 owarn << "found class id" << oendl;
122 qWarning("line:%s", str.latin1() ); 128 owarn << "line: " << str.latin1() << oendl;
123 m_classOver = true; 129 m_classOver = true;
124 return true; 130 return true;
125 }else if ( m_classOver && str.startsWith(" " ) ){ // ok now are the informations in place 131 }else if ( m_classOver && str.startsWith(" " ) ){ // ok now are the informations in place
126 qWarning("line with class id" ); 132 owarn << "line with class id" << oendl;
127 qWarning("%s",str.latin1() ); 133 owarn << str.latin1() << oendl;
128 134
129 // "Obex Object Push" (0x1105) 135 // "Obex Object Push" (0x1105)
130 // find backwards the " and the from 0 to pos and the mid pos+1 136 // find backwards the " and the from 0 to pos and the mid pos+1
@@ -133,12 +139,12 @@ bool Parser::parseClassId( const QString& str) {
133 QString classes; 139 QString classes;
134 int ids; 140 int ids;
135 ids = convert( str, classes ); 141 ids = convert( str, classes );
136 qWarning("ids %d", ids ); 142 owarn << "ids " << ids << oendl;
137 m_item.insertClassId( ids, classes ); 143 m_item.insertClassId( ids, classes );
138 144
139 return true; 145 return true;
140 }else{ 146 }else{
141 qWarning("Else %d", m_classOver ); 147 owarn << "Else " << m_classOver << oendl;
142 m_classOver = false; 148 m_classOver = false;
143 } 149 }
144 return false; 150 return false;
@@ -150,7 +156,7 @@ bool Parser::parseProtocol( const QString& str) {
150 return true; 156 return true;
151 157
152 }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100) 158 }else if (m_protocolOver && str.startsWith(" ") ) { // "L2CAP" (0x0100)
153 qWarning("double protocol filter"); 159 owarn << "double protocol filter" << oendl;
154 160
155 if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now 161 if (!m_protocolAdded ) { // the protocol does neither supply a channel nor port so add it now
156 Services::ProtocolDescriptor desc( m_protName, m_protId ); 162 Services::ProtocolDescriptor desc( m_protName, m_protId );
@@ -162,7 +168,7 @@ bool Parser::parseProtocol( const QString& str) {
162 } 168 }
163 return true; 169 return true;
164 }else if (m_protocolOver && str.startsWith(" ") ) { 170 }else if (m_protocolOver && str.startsWith(" ") ) {
165 qWarning("tripple protocol filter"); 171 owarn << "tripple protocol filter" << oendl;
166 m_protocolAdded = true; 172 m_protocolAdded = true;
167 QString dummy = str.stripWhiteSpace(); 173 QString dummy = str.stripWhiteSpace();
168 int pos = dummy.findRev(':'); 174 int pos = dummy.findRev(':');
@@ -187,7 +193,7 @@ bool Parser::parseProfile( const QString& str) {
187 int pos = str.findRev(':'); 193 int pos = str.findRev(':');
188 if ( pos > 0 ) { 194 if ( pos > 0 ) {
189 int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt(); 195 int dummy = str.mid(pos+1 ).stripWhiteSpace().toInt();
190 qWarning("dummyInt:%d", dummy ); 196 owarn << "dummyInt: " << dummy << oendl;
191 Services::ProfileDescriptor desc( m_profName, m_profId, dummy ); 197 Services::ProfileDescriptor desc( m_profName, m_profId, dummy );
192 m_item.insertProfileDescriptor(desc); 198 m_item.insertProfileDescriptor(desc);
193 } 199 }