summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorJanne Anttila <janne.anttila@digia.com>2009-08-04 07:20:57 (GMT)
committerJanne Anttila <janne.anttila@digia.com>2009-08-04 07:34:24 (GMT)
commit2c9007fbedf7664c0e389d8a3c5ab3eb2f187c01 (patch)
tree389ec18e250d033511730c11d096da7692bc8b7c /src/network
parent76629bf75b29a29e8532943e530bb5455ee9cdf8 (diff)
downloadQt-2c9007fbedf7664c0e389d8a3c5ab3eb2f187c01.zip
Qt-2c9007fbedf7664c0e389d8a3c5ab3eb2f187c01.tar.gz
Qt-2c9007fbedf7664c0e389d8a3c5ab3eb2f187c01.tar.bz2
Cleanup and applied Qt coding style for qnetworkinterface_symbian.cpp
Diffstat (limited to 'src/network')
-rw-r--r--src/network/kernel/qnetworkinterface_symbian.cpp114
1 files changed, 46 insertions, 68 deletions
diff --git a/src/network/kernel/qnetworkinterface_symbian.cpp b/src/network/kernel/qnetworkinterface_symbian.cpp
index bec2dc3..f2ded36 100644
--- a/src/network/kernel/qnetworkinterface_symbian.cpp
+++ b/src/network/kernel/qnetworkinterface_symbian.cpp
@@ -41,12 +41,8 @@
//#define QNETWORKINTERFACE_DEBUG
-//#include "qset.h"
#include "qnetworkinterface.h"
#include "qnetworkinterface_p.h"
-//#include <private/qnativesocketengine_p.h>
-//#include "qalgorithms.h"
-
#ifndef QT_NO_NETWORKINTERFACE
@@ -54,57 +50,49 @@
#include <in_iface.h>
#include <es_sock.h>
-//#include <sys/types.h>
-//#include <sys/socket.h>
-//#include <errno.h>
-//#include <net/if.h>
-//#include <qplatformdefs.h>
-
QT_BEGIN_NAMESPACE
-static QNetworkInterface::InterfaceFlags convertFlags( const TSoInetInterfaceInfo& aInfo )
+static QNetworkInterface::InterfaceFlags convertFlags(const TSoInetInterfaceInfo& aInfo)
{
QNetworkInterface::InterfaceFlags flags = 0;
flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsUp : QNetworkInterface::InterfaceFlag(0);
// We do not have separate flag for running in Symbian OS
flags |= (aInfo.iState == EIfUp) ? QNetworkInterface::IsRunning : QNetworkInterface::InterfaceFlag(0);
- flags |= (aInfo.iFeatures&KIfCanBroadcast) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0);
- flags |= (aInfo.iFeatures&KIfIsLoopback) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0);
- flags |= (aInfo.iFeatures&KIfIsPointToPoint) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0);
- flags |= (aInfo.iFeatures&KIfCanMulticast) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures & KIfCanBroadcast) ? QNetworkInterface::CanBroadcast : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures & KIfIsLoopback) ? QNetworkInterface::IsLoopBack : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures & KIfIsPointToPoint) ? QNetworkInterface::IsPointToPoint : QNetworkInterface::InterfaceFlag(0);
+ flags |= (aInfo.iFeatures & KIfCanMulticast) ? QNetworkInterface::CanMulticast : QNetworkInterface::InterfaceFlag(0);
return flags;
}
-QString qstringFromDesc( const TDesC& aData )
+QString qstringFromDesc(const TDesC& aData)
{
return QString::fromUtf16(aData.Ptr(), aData.Length());
}
static QList<QNetworkInterfacePrivate *> interfaceListing()
{
- TInt err( KErrNone );
+ TInt err(KErrNone);
QList<QNetworkInterfacePrivate *> interfaces;
// Connect to Native socket server
RSocketServ socketServ;
err = socketServ.Connect();
- if( err )
+ if (err)
return interfaces;
// Open dummy socket for interface queries
RSocket socket;
- err = socket.Open( socketServ, _L("udp"));
- if( err )
- {
+ err = socket.Open(socketServ, _L("udp"));
+ if (err) {
socketServ.Close();
return interfaces;
}
// Ask socket to start enumerating interfaces
- err = socket.SetOpt( KSoInetEnumInterfaces, KSolInetIfCtrl );
- if( err )
- {
+ err = socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl);
+ if (err) {
socket.Close();
socketServ.Close();
return interfaces;
@@ -113,11 +101,9 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
int ifindex = 0;
TPckgBuf<TSoInetInterfaceInfo> infoPckg;
TSoInetInterfaceInfo &info = infoPckg();
- while( socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, infoPckg) == KErrNone )
- {
+ while (socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, infoPckg) == KErrNone) {
// Do not include IPv6 addresses because netmask and broadcast address cannot be determined correctly
- if( info.iName != KNullDesC && info.iAddress.IsV4Mapped() )
- {
+ if (info.iName != KNullDesC && info.iAddress.IsV4Mapped()) {
TName address;
QNetworkAddressEntry entry;
QNetworkInterfacePrivate *iface = 0;
@@ -125,51 +111,48 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
iface = new QNetworkInterfacePrivate;
iface->index = ifindex++;
interfaces << iface;
- iface->name = qstringFromDesc( info.iName );
- iface->flags = convertFlags( info );
+ iface->name = qstringFromDesc(info.iName);
+ iface->flags = convertFlags(info);
- if( /*info.iFeatures&KIfHasHardwareAddr &&*/ info.iHwAddr.Family() != KAFUnspec )
- {
- for ( TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++ )
- {
+ if (/*info.iFeatures&KIfHasHardwareAddr &&*/ info.iHwAddr.Family() != KAFUnspec) {
+ for (TInt i = sizeof(SSockAddr); i < sizeof(SSockAddr) + info.iHwAddr.GetUserLen(); i++) {
address.AppendNumFixedWidth(info.iHwAddr[i], EHex, 2);
- if( ( i + 1) < sizeof(SSockAddr) + info.iHwAddr.GetUserLen() )
- address.Append( _L(":") );
+ if ((i + 1) < sizeof(SSockAddr) + info.iHwAddr.GetUserLen())
+ address.Append(_L(":"));
}
address.UpperCase();
- iface->hardwareAddress = qstringFromDesc( address );
+ iface->hardwareAddress = qstringFromDesc(address);
}
// Get the address of the interface
info.iAddress.Output(address);
- entry.setIp( QHostAddress( qstringFromDesc( address ) ) );
+ entry.setIp(QHostAddress(qstringFromDesc(address)));
// Get the interface netmask
- // TODO: For some reason netmask is always 0.0.0.0
- //info.iNetMask.Output(address);
- //entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) );
+ // For some reason netmask is always 0.0.0.0
+ // info.iNetMask.Output(address);
+ // entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) );
// Workaround: Let Symbian determine netmask based on IP address class
- // TODO: works only for IPv4
+ // TODO: Works only for IPv4 - Task: 259128 Implement IPv6 support
TInetAddr netmask;
- netmask.NetMask( info.iAddress );
+ netmask.NetMask(info.iAddress);
netmask.Output(address);
- entry.setNetmask( QHostAddress( qstringFromDesc( address ) ) );
+ entry.setNetmask(QHostAddress(qstringFromDesc(address)));
// Get the interface broadcast address
- if (iface->flags & QNetworkInterface::CanBroadcast)
- {
+ if (iface->flags & QNetworkInterface::CanBroadcast) {
// For some reason broadcast address is always 0.0.0.0
// info.iBrdAddr.Output(address);
// entry.setBroadcast( QHostAddress( qstringFromDesc( address ) ) );
// Workaround: Let Symbian determine broadcast address based on IP address
- // TODO: works only for IPv4
+ // TODO: Works only for IPv4 - Task: 259128 Implement IPv6 support
TInetAddr broadcast;
- broadcast.NetBroadcast( info.iAddress );
+ broadcast.NetBroadcast(info.iAddress);
broadcast.Output(address);
- entry.setBroadcast( QHostAddress( qstringFromDesc( address ) ) );
- }
+ entry.setBroadcast(QHostAddress(qstringFromDesc(address)));
+ }
// Add new entry to interface address entries
iface->addressEntries << entry;
@@ -180,11 +163,11 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
IsLoopBack = %d, IsPointToPoint = %d, CanMulticast = %d, \n\
ip = %s, netmask = %s, broadcast = %s,\n\
hwaddress = %s",
- iface->name.toLatin1().constData(),
- iface->flags & QNetworkInterface::IsUp, iface->flags & QNetworkInterface::IsRunning, iface->flags & QNetworkInterface::CanBroadcast,
- iface->flags & QNetworkInterface::IsLoopBack, iface->flags & QNetworkInterface::IsPointToPoint, iface->flags & QNetworkInterface::CanMulticast,
- entry.ip().toString().toLatin1().constData(), entry.netmask().toString().toLatin1().constData(), entry.broadcast().toString().toLatin1().constData(),
- iface->hardwareAddress.toLatin1().constData());
+ iface->name.toLatin1().constData(),
+ iface->flags & QNetworkInterface::IsUp, iface->flags & QNetworkInterface::IsRunning, iface->flags & QNetworkInterface::CanBroadcast,
+ iface->flags & QNetworkInterface::IsLoopBack, iface->flags & QNetworkInterface::IsPointToPoint, iface->flags & QNetworkInterface::CanMulticast,
+ entry.ip().toString().toLatin1().constData(), entry.netmask().toString().toLatin1().constData(), entry.broadcast().toString().toLatin1().constData(),
+ iface->hardwareAddress.toLatin1().constData());
#endif
}
}
@@ -195,8 +178,7 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
// use dummy socket to start enumerating routes
err = socket.SetOpt(KSoInetEnumRoutes, KSolInetRtCtrl);
- if( err )
- {
+ if (err) {
socket.Close();
socketServ.Close();
// return what we have
@@ -206,29 +188,28 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
TSoInetRouteInfo routeInfo;
TPckg<TSoInetRouteInfo> routeInfoPkg(routeInfo);
- while(socket.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone)
- {
+ while (socket.GetOpt(KSoInetNextRoute, KSolInetRtCtrl, routeInfoPkg) == KErrNone) {
TName address;
// get interface address
routeInfo.iIfAddr.Output(address);
QHostAddress ifAddr(qstringFromDesc(address));
- if(ifAddr.isNull())
+ if (ifAddr.isNull())
continue;
routeInfo.iDstAddr.Output(address);
QHostAddress destination(qstringFromDesc(address));
- if(destination.isNull() || destination != ifAddr)
+ if (destination.isNull() || destination != ifAddr)
continue;
// search interfaces
- for(int ifindex = 0; ifindex < interfaces.size(); ++ifindex) {
+ for (int ifindex = 0; ifindex < interfaces.size(); ++ifindex) {
QNetworkInterfacePrivate *iface = interfaces.at(ifindex);
- for(int eindex = 0; eindex < iface->addressEntries.size(); ++eindex) {
+ for (int eindex = 0; eindex < iface->addressEntries.size(); ++eindex) {
QNetworkAddressEntry entry = iface->addressEntries.at(eindex);
- if(entry.ip() != ifAddr) {
+ if (entry.ip() != ifAddr) {
continue;
- } else if(entry.ip().protocol() != QAbstractSocket::IPv4Protocol) {
+ } else if (entry.ip().protocol() != QAbstractSocket::IPv4Protocol) {
// skip if not IPv4 address (e.g. IPv6)
// as results not reliable on Symbian
continue;
@@ -240,9 +221,6 @@ static QList<QNetworkInterfacePrivate *> interfaceListing()
// ::postProcess to have effect
entry.setBroadcast(QHostAddress());
iface->addressEntries.replace(eindex, entry);
-// printf("for %s netmask = %s and destination = %s ; type = %d; state = %d; metric = %d \n",
-// ifAddr.toString().toLatin1().constData(), netmask.toString().toLatin1().constData(), destination.toString().toLatin1().constData(),
-// routeInfo.iType, routeInfo.iState, routeInfo.iMetric);
}
}
}