summaryrefslogtreecommitdiff
authorzecke <zecke>2002-06-23 19:25:49 (UTC)
committer zecke <zecke>2002-06-23 19:25:49 (UTC)
commit7c4524d0ff6d329c1f5f76fa2e7a727e553d51c8 (patch) (side-by-side diff)
tree08c4b8268c71e568096ad154b0fecb20df76e25b
parent616f8cef3111756cac0240be10aea38d4f38ad8e (diff)
downloadopie-7c4524d0ff6d329c1f5f76fa2e7a727e553d51c8.zip
opie-7c4524d0ff6d329c1f5f76fa2e7a727e553d51c8.tar.gz
opie-7c4524d0ff6d329c1f5f76fa2e7a727e553d51c8.tar.bz2
Fix Service/Profile parser
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
@@ -108,2 +108,3 @@ void Manager::searchServices( const QString& remDevice ){
m_sdp->setName( remDevice.latin1() );
+ qWarning("search Services for %s", remDevice.latin1() );
connect(m_sdp, SIGNAL(processExited(OProcess*) ),
@@ -113,2 +114,3 @@ void Manager::searchServices( const QString& remDevice ){
if (!m_sdp->start(OProcess::NotifyOnExit, OProcess::AllOutput) ) {
+ qWarning("could not start sdptool" );
delete m_sdp;
@@ -139,9 +141,11 @@ void Manager::slotSDPOut(OProcess* proc, char* ch, int len)
QCString str(ch, len+1 );
+ qWarning("SDP:%s", str.data() );
QMap<QString, QString>::Iterator it;
it = m_out.find(proc->name() );
+ QString string;
if ( it != m_out.end() ) {
- QString string = it.data();
- string.append( str );
- m_out.replace( proc->name(), string );
+ string = it.data();
}
+ string.append( str );
+ m_out.replace( proc->name(), string );
@@ -150,2 +154,3 @@ void Manager::slotSDPExited( OProcess* proc)
{
+ qWarning("proc name %s", proc->name() );
Services::ValueList list;
@@ -154,2 +159,3 @@ void Manager::slotSDPExited( OProcess* proc)
if ( it != m_out.end() ) {
+ qWarning("found process" );
list = parseSDPOutput( it.data() );
@@ -163,2 +169,3 @@ Services::ValueList Manager::parseSDPOutput( const QString& out ) {
Services::ValueList list;
+ qWarning("parsing output" );
Parser parser( out );
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
@@ -15,2 +15,3 @@ namespace {
int convert( const QString& line, QString& ret ) {
+// qWarning("called");
ret = QString::null;
@@ -19,12 +20,20 @@ int convert( const QString& line, QString& ret ) {
if ( pos > 0 ) { // it shouldn't be at pos 0
- ret = line.left(pos-1 ).stripWhiteSpace();
- qWarning("ret: %s", ret.latin1() );
+ ret = line.left(pos ).stripWhiteSpace();
+ // qWarning("ret: %s", ret.latin1() );
ret = ret.replace(QRegExp("[\"]"), "");
- qWarning("ret: %s", ret.latin1() );
- QString dummy = line.mid(pos + 4 );
- qWarning("dummy: %s", dummy.latin1() );
- dummy = dummy.remove( dummy.length() -1, 1 ); // remove the (
+ //qWarning("ret: %s", ret.latin1() );
+ QString dummy = line.mid(pos + 5 );
+ //qWarning("dummy: %s", dummy.latin1() );
+ dummy = dummy.replace(QRegExp("[)]"), "");
+ //qWarning("dummy: %s", dummy.latin1() );
+// dummy = dummy.remove( dummy.length() -2, 1 ); // remove the )
bool ok;
i = dummy.toInt(&ok, 16 );
+ //if (ok ) {
+ // qWarning("converted %d", i);
+ //}else qWarning("failed" );
+ //qWarning("exiting");
+ return i;
}
+ //qWarning("output %d", i );
return i;
@@ -47,11 +56,14 @@ void Parser::parse( const QString& string) {
m_complete = true;
- QStringList list = QStringList::split('\n', string );
+ QStringList list = QStringList::split('\n', string,TRUE );
QStringList::Iterator it;
for (it = list.begin(); it != list.end(); ++it ) {
+ qWarning("line:%s:line", (*it).latin1() );
if ( (*it).startsWith("Browsing") ) continue;
- if ( (*it).isEmpty() ) { // line is empty because a new Service begins
- // now see if complete and add
+ if ( (*it).stripWhiteSpace().isEmpty() ) { // line is empty because a new Service begins
+ qWarning("could add");
+ // now see if complete and add
if (m_complete ) {
- m_list.append( m_item );
+ if (!m_item.serviceName().isEmpty() )
+ m_list.append( m_item );
Services serv;
@@ -70,3 +82,12 @@ void Parser::parse( const QString& string) {
if (m_complete) {
- m_list.append(m_item );
+ qWarning("adding");
+ if (!m_item.serviceName().isEmpty() )
+ m_list.append(m_item );
+ }
+ QValueList<Services>::Iterator it2;
+
+ if (m_list.isEmpty() )
+ qWarning("m_list is empty");
+ for (it2 = m_list.begin(); it2 != m_list.end(); ++it2 ) {
+ qWarning("name %s", (*it2).serviceName().latin1() );
}
@@ -85,3 +106,3 @@ bool Parser::parseRecHandle( const QString& str) {
qWarning("out %s", out.latin1() );
- int value = out.toInt(&m_ok, 16 );
+ int value = out.mid(2).toInt(&m_ok, 16 );
if (m_ok && (value != -1) )
@@ -90,4 +111,6 @@ bool Parser::parseRecHandle( const QString& str) {
m_complete = false;
- return true;
+ qWarning("rec handle %d", value);
m_item.setRecHandle( value );
+ return true;
+
}