From 9832c60375a9689e42cd899d1de5afd0b776ae48 Mon Sep 17 00:00:00 2001 From: Aaron Tunney Date: Wed, 19 Jan 2011 16:36:46 +0000 Subject: Initial draft of QHostInfo::localHostName(), plus fix for address buffer for IPv6 addresses. Reviewed-by: Shane Kearns --- src/network/kernel/qhostinfo_symbian.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/src/network/kernel/qhostinfo_symbian.cpp b/src/network/kernel/qhostinfo_symbian.cpp index fbd7fe9..7fc40bc 100644 --- a/src/network/kernel/qhostinfo_symbian.cpp +++ b/src/network/kernel/qhostinfo_symbian.cpp @@ -143,7 +143,9 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) QList hostAddresses; TInetAddr hostAdd = nameResult().iAddr; - TBuf<16> ipAddr; + // 39 is the maximum length of an IPv6 address. + TBuf<39> ipAddr; + // Fill ipAddr with the IP address from hostAdd hostAdd.Output(ipAddr); if (ipAddr.Length() > 0) @@ -173,8 +175,24 @@ QHostInfo QHostInfoAgent::fromName(const QString &hostName) QString QHostInfo::localHostName() { - // TODO - fill with code. - return QString(); + // Connect to ESOCK + RSocketServ socketServ(qt_symbianGetSocketServer()); + RHostResolver hostResolver; + + // Will return both IPv4 and IPv6 + // TODO: Pass RHostResolver.Open() the global RConnection + int err = hostResolver.Open(socketServ, KAfInet, KProtocolInetUdp); + if (err) + return QString(); + + THostName hostName; + err = hostResolver.GetHostName(hostName); + if (err) + return QString(); + + hostResolver.Close(); + + return qt_TDesC2QString(hostName); } QString QHostInfo::localDomainName() -- cgit v0.12