--- a/javacommons/gcfprotocols/socket/socket/src.s60/socketlocalhostinfo.cpp Tue Jul 06 14:10:26 2010 +0300
+++ b/javacommons/gcfprotocols/socket/socket/src.s60/socketlocalhostinfo.cpp Wed Aug 18 09:43:15 2010 +0300
@@ -22,7 +22,24 @@
#include "logger.h"
#include "connectionmanager.h"
+#define localhost_len 20
int GetlocalIPAdressL(char *localaddr, int aMidletIapId, int aApType);
+char* GetlocalHostNameL();
+
+char* SocketLocalHostInfo::getLocalHostName()
+{
+ char* localhostname =NULL;
+ TRAPD(err,localhostname = GetlocalHostNameL());
+ ILOG1(ESOCKET, "err %d ", err);
+ if (err != KErrNone)
+ {
+ localhostname = new char[localhost_len];
+ strcpy(localhostname,"localhost");
+ return localhostname;
+ }
+ else
+ return localhostname;
+}
OS_EXPORT int SocketLocalHostInfo::getLocalAddress(int /* aSd */, char *aLocalAddr,
int aMidletIapId, int aApType)
@@ -190,3 +207,41 @@
}
+
+char* GetlocalHostNameL()
+{
+ TUint32 activeIapId = 0;
+
+ TConnectionInfoBuf connectionInfo;
+ TUint count = 0;
+ RSocketServ socketServ;
+ RSocket sock;
+ RConnection conn;
+
+ User::LeaveIfError(socketServ.Connect());
+ User::LeaveIfError(sock.Open(socketServ, KAfInet, KSockStream,
+ KProtocolInetTcp));
+ User::LeaveIfError(conn.Open(socketServ));
+ User::LeaveIfError(conn.EnumerateConnections(count));
+
+ char* localhost = new char[localhost_len];
+
+ if (count <= 0)
+ {
+ strcpy(localhost,"localhost");
+ }
+ else
+ {
+
+ User::LeaveIfError(conn.GetConnectionInfo(1, connectionInfo));
+ activeIapId = connectionInfo().iIapId;
+ getIPAddressL(activeIapId,localhost);
+ }
+
+ conn.Close();
+ sock.Close();
+ socketServ.Close();
+
+ return localhost;
+}
+