diff options
author | Shane Kearns <shane.kearns@accenture.com> | 2011-03-18 11:30:35 (GMT) |
---|---|---|
committer | Shane Kearns <shane.kearns@accenture.com> | 2011-03-18 11:57:28 (GMT) |
commit | 0679abb6b4f85878cb64fce2089ba926e3b9400c (patch) | |
tree | 91809edccdaf14e9f4f55dfcc02e2aad953616a4 /src | |
parent | b35009bab4d4353aa82830f4f7f8c29700b2bd08 (diff) | |
download | Qt-0679abb6b4f85878cb64fce2089ba926e3b9400c.zip Qt-0679abb6b4f85878cb64fce2089ba926e3b9400c.tar.gz Qt-0679abb6b4f85878cb64fce2089ba926e3b9400c.tar.bz2 |
handle errors in QSymbianHostResolver::requestHostLookup
It was hanging because although the error flags were set, the callback
was not emitted and nothing was done with the return value from the
function.
Now, it sets the state to error, and self completes - so that the
completion through RunL is used as normal. Because the state is error,
the processing of name/address is skipped and the error string is not
rewritten.
Note, error being detected at this point is only common when using an
explicit network session (as RHostResolver::Open can fail if the
RConnection is in the wrong state)
Reviewed-by: Markus Goetz
Diffstat (limited to 'src')
-rw-r--r-- | src/network/kernel/qhostinfo_p.h | 5 | ||||
-rw-r--r-- | src/network/kernel/qhostinfo_symbian.cpp | 64 |
2 files changed, 38 insertions, 31 deletions
diff --git a/src/network/kernel/qhostinfo_p.h b/src/network/kernel/qhostinfo_p.h index 79fad84..909bd03 100644 --- a/src/network/kernel/qhostinfo_p.h +++ b/src/network/kernel/qhostinfo_p.h @@ -228,7 +228,7 @@ public: QSymbianHostResolver(const QString &hostName, int id); ~QSymbianHostResolver(); - QHostInfo requestHostLookup(); + void requestHostLookup(); int id(); QHostInfoResult resultEmitter; @@ -258,7 +258,8 @@ private: enum { EIdle, EGetByName, - EGetByAddress + EGetByAddress, + EError } iState; }; diff --git a/src/network/kernel/qhostinfo_symbian.cpp b/src/network/kernel/qhostinfo_symbian.cpp index ad5f38a..54ec33c 100644 --- a/src/network/kernel/qhostinfo_symbian.cpp +++ b/src/network/kernel/qhostinfo_symbian.cpp @@ -233,7 +233,7 @@ QSymbianHostResolver::~QSymbianHostResolver() } // Async equivalent to QHostInfoAgent::fromName() -QHostInfo QSymbianHostResolver::requestHostLookup() +void QSymbianHostResolver::requestHostLookup() { #if defined(QHOSTINFO_DEBUG) @@ -245,45 +245,51 @@ QHostInfo QSymbianHostResolver::requestHostLookup() if (err) { // What are we doing with iResults?? iResults.setError(QHostInfo::UnknownError); - iResults.setErrorString(QObject::tr("Symbian error code: %1").arg(err)); + iResults.setErrorString(QSystemError(err, QSystemError::NativeError).toString()); - iHostResolver.Close(); - return iResults; - } + } else { - if (iAddress.setAddress(iHostName)) { - // Reverse lookup + if (iAddress.setAddress(iHostName)) { + // Reverse lookup - TInetAddr IpAdd; - IpAdd.Input(qt_QString2TPtrC(iHostName)); + TInetAddr IpAdd; + IpAdd.Input(qt_QString2TPtrC(iHostName)); - // Asynchronous request. - iHostResolver.GetByAddress(IpAdd, iNameResult, iStatus); // <---- ASYNC - iState = EGetByAddress; + // Asynchronous request. + iHostResolver.GetByAddress(IpAdd, iNameResult, iStatus); // <---- ASYNC + iState = EGetByAddress; - } else { + } else { - // IDN support - QByteArray aceHostname = QUrl::toAce(iHostName); - iResults.setHostName(iHostName); - if (aceHostname.isEmpty()) { - iResults.setError(QHostInfo::HostNotFound); - iResults.setErrorString(iHostName.isEmpty() ? - QCoreApplication::translate("QHostInfoAgent", "No host name given") : - QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); + // IDN support + QByteArray aceHostname = QUrl::toAce(iHostName); + iResults.setHostName(iHostName); + if (aceHostname.isEmpty()) { + iResults.setError(QHostInfo::HostNotFound); + iResults.setErrorString(iHostName.isEmpty() ? + QCoreApplication::translate("QHostInfoAgent", "No host name given") : + QCoreApplication::translate("QHostInfoAgent", "Invalid hostname")); - iHostResolver.Close(); - return iResults; - } + err = KErrArgument; + } else { - // Asynchronous request. - iHostResolver.GetByName(qt_QString2TPtrC(QString::fromLatin1(aceHostname)), iNameResult, iStatus); - iState = EGetByName; + // Asynchronous request. + iHostResolver.GetByName(qt_QString2TPtrC(QString::fromLatin1(aceHostname)), iNameResult, iStatus); + iState = EGetByName; + } + } } - SetActive(); + if (err) { + iHostResolver.Close(); - return iResults; + //self complete so that RunL can inform manager without causing recursion + iState = EError; + iStatus = KRequestPending; + SetActive(); + TRequestStatus* stat = &iStatus; + User::RequestComplete(stat, err); + } } void QSymbianHostResolver::DoCancel() |