Fixed encoding issue so can now enter addresses in the UI.
authorMax Waterman <davidmaxwaterman+maemogit@fastmail.co.uk>
Mon, 1 Mar 2010 21:41:24 +0000 (23:41 +0200)
committerMax Waterman <davidmaxwaterman+maemogit@fastmail.co.uk>
Mon, 1 Mar 2010 21:41:24 +0000 (23:41 +0200)
zouba/location.cpp
zouba/location_p.cpp
zouba/ytv.h

index b41360c..2ffa63f 100644 (file)
@@ -63,7 +63,7 @@ void Location::resolveAddress( QString address )
 {
   QUrl fullUrl( ytv );
 
-  fullUrl.addEncodedQueryItem( "key", address.toUtf8() );
+  fullUrl.addEncodedQueryItem( "key", address.toAscii().toPercentEncoding() );
   fullUrl.addQueryItem( "user", username );
   fullUrl.addQueryItem( "pass", password );
 
@@ -74,7 +74,7 @@ void Location::replyFinished( QNetworkReply * reply )
 {
   q->parseReply( reply->readAll() );
 
-  if ( q->isValid() ) {
+  if ( isValid() ) {
     emit( becomeValid() );
   }
 }
index 318630d..8eac5e0 100644 (file)
@@ -38,6 +38,7 @@ void LocationPrivate::parseReply( const QByteArray &reply )
 
   if ( xml.hasError() ) {
     qDebug() << "xml error";
+    m_valid = false;
   } else {
     m_valid = true;
   }
index 2bcc02b..16915f0 100644 (file)
@@ -3,13 +3,11 @@
 #include <QString>
 
 namespace {
-  const QUrl ytv( "http://api.reittiopas.fi/public-ytv/fi/api/" );
+  const QString ytv( "http://api.reittiopas.fi/public-ytv/fi/api/" );
   const QString username( "zouba" );
   const QString password( "caf9r3ee" );
 
-  //const QString home( "Taivaanvuohentie 7, Helsinki" );
-  //const QString work( "Itämerenkatu 11, Helsinki" );
-  const QString home( "Taivaanvuohentie%207%2CHelsinki" );
-  const QString work( "It%E4merenkatu%2011%2CHelsinki" );
+  const QString home( QByteArray::fromPercentEncoding( "Taivaanvuohentie%207%2CHelsinki" ) );
+  const QString work( QByteArray::fromPercentEncoding( "It%E4merenkatu%2011%2CHelsinki" ) );
 }