-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | examples/opienet/miniwellenreiter/miniwellenreiter.cpp | 2 | ||||
-rw-r--r-- | examples/opienet/onetworkdemo/onetworkdemo.cpp | 2 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.cpp | 19 | ||||
-rw-r--r-- | libopie2/opienet/onetutils.h | 8 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 43 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.h | 7 | ||||
-rw-r--r-- | noncore/applets/networkapplet/networkapplet.cpp | 6 | ||||
-rw-r--r-- | noncore/net/opiestumbler/opiestumbler.cpp | 2 |
9 files changed, 47 insertions, 44 deletions
@@ -24,12 +24,14 @@ Internal -------- * Make BluezApplet use OTaskbarApplet (mickeyl) * Rewrite OFileNotification to use the upcoming inotify interface instead of the deprecated dnotify (mickeyl) * libopienet: Skip hostap control interfaces 'wifi' and improve robustness in ONetworkInterface (mickeyl) + * libopieui: Remove OVersatileView and OVersatileViewItem (mickeyl) + * libopienet: Miscellaneous API cleanups (mickeyl) 2005-03-25 Opie 1.2.0 Fixed Bugs ---------- * #1613 - AdvancedFM - scale toolbar icons appropriately (drw) diff --git a/examples/opienet/miniwellenreiter/miniwellenreiter.cpp b/examples/opienet/miniwellenreiter/miniwellenreiter.cpp index ebd3b5f..ba9d2ca 100644 --- a/examples/opienet/miniwellenreiter/miniwellenreiter.cpp +++ b/examples/opienet/miniwellenreiter/miniwellenreiter.cpp @@ -48,13 +48,13 @@ public: while ( it.current() ) { if ( it.current()->isWireless() ) { printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), (const char*) it.current()->macAddress().toString(), - (const char*) it.current()->ipV4Address() ); + (const char*) it.current()->ipV4Address().toString() ); } ++it; } exit( -1 ); } diff --git a/examples/opienet/onetworkdemo/onetworkdemo.cpp b/examples/opienet/onetworkdemo/onetworkdemo.cpp index b3a1115..e8958dc 100644 --- a/examples/opienet/onetworkdemo/onetworkdemo.cpp +++ b/examples/opienet/onetworkdemo/onetworkdemo.cpp @@ -56,13 +56,13 @@ int main( int argc, char** argv ) odebug << "DEMO: Datalink code is '" << it.current()->dataLinkType() << "'" << oendl; odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString() << "'" << oendl; odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; - odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; + odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address().toString() << "'" << oendl; if ( it.current()->isWireless() ) { OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; odebug << "DEMO: Current SSID is '" << iface->SSID() << "'" << oendl; odebug << "DEMO: Antenna is tuned to '" << iface->frequency() << "', that is channel " << iface->channel() << "" << oendl; diff --git a/libopie2/opienet/onetutils.cpp b/libopie2/opienet/onetutils.cpp index c8c494a..9c3e650 100644 --- a/libopie2/opienet/onetutils.cpp +++ b/libopie2/opienet/onetutils.cpp @@ -1,11 +1,9 @@ /* This file is part of the Opie Project - - (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software @@ -133,12 +131,27 @@ bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) /*====================================================================================== * OHostAddress *======================================================================================*/ +OHostAddress::OHostAddress() + :QHostAddress() +{ +} + + +OHostAddress::OHostAddress( Q_UINT32 ip4Addr ) + :QHostAddress( ip4Addr ) +{ +} + + +OHostAddress::~OHostAddress() +{ +} /*====================================================================================== * OPrivateIOCTL *======================================================================================*/ OPrivateIOCTL::OPrivateIOCTL( QObject* parent, const char* name, int cmd, int getargs, int setargs ) diff --git a/libopie2/opienet/onetutils.h b/libopie2/opienet/onetutils.h index 25c9238..f08738c 100644 --- a/libopie2/opienet/onetutils.h +++ b/libopie2/opienet/onetutils.h @@ -1,10 +1,9 @@ /* This file is part of the Opie Project - (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software @@ -86,16 +85,17 @@ bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); /*====================================================================================== * OHostAddress *======================================================================================*/ class OHostAddress : public QHostAddress { - /*public: + public: OHostAddress(); + OHostAddress( Q_UINT32 ip4Addr ); ~OHostAddress(); - */ + private: class Private; Private *d; }; diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 1deb051..0649ca2 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp @@ -1,10 +1,9 @@ /* This file is part of the Opie Project - Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software @@ -82,16 +81,12 @@ ONetwork::ONetwork() synchronize(); } void ONetwork::synchronize() { // gather available interfaces by inspecting /proc/net/dev - //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices - //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices - //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev - _interfaces.clear(); QString str; QFile f( "/proc/net/dev" ); bool hasFile = f.open( IO_ReadOnly ); if ( !hasFile ) { @@ -199,13 +194,12 @@ struct ifreq& ONetworkInterface::ifr() const } void ONetworkInterface::init() { odebug << "ONetworkInterface::init()" << oendl; - memset( &_ifr, 0, sizeof( struct ifreq ) ); if ( _sfd == -1 ) { odebug << "ONetworkInterface::init(): Warning - can't get socket for device '" << name() << "'" << oendl; return; @@ -267,23 +261,16 @@ void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) sa->sin_port = 0; sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); ioctl( SIOCSIFADDR ); } -QString ONetworkInterface::ipV4Address() const +OHostAddress ONetworkInterface::ipV4Address() const { - if ( ioctl( SIOCGIFADDR ) ) - { - struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; - //FIXME: Use QHostAddress here - return QString( inet_ntoa( sa->sin_addr ) ); - } - else - return "<unknown>"; - + struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; + return ioctl( SIOCGIFADDR ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); } void ONetworkInterface::setMacAddress( const OMacAddress& addr ) { _ifr.ifr_hwaddr.sa_family = ARPHRD_ETHER; @@ -312,22 +299,16 @@ void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) sa->sin_port = 0; sa->sin_addr.s_addr = htonl( addr.ip4Addr() ); ioctl( SIOCSIFNETMASK ); } -QString ONetworkInterface::ipV4Netmask() const +OHostAddress ONetworkInterface::ipV4Netmask() const { - if ( ioctl( SIOCGIFNETMASK ) ) - { - struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; - //FIXME: Use QHostAddress here - return QString( inet_ntoa( sa->sin_addr ) ); - } - else - return "<unknown>"; + struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; + return ioctl( SIOCGIFNETMASK ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); } int ONetworkInterface::dataLinkType() const { if ( ioctl( SIOCGIFHWADDR ) ) @@ -544,13 +525,21 @@ void OWirelessNetworkInterface::buildInformation() memset( buffer, 0, len ); memcpy( wrq.ifr_name, name(), IFNAMSIZ); wrq.u.data.pointer = (caddr_t) buffer; wrq.u.data.length = sizeof buffer; wrq.u.data.flags = 0; - if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) + int result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); + if ( result == -1 ) + { + owarn << "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (" << strerror( errno ) << ") - retrying with smaller buffer..." << oendl; + wrq.u.data.length = sizeof( struct iw_range ); + result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); + } + + if ( result == -1 ) { owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; _channels.insert( 2412, 1 ); // 2.412 GHz _channels.insert( 2417, 2 ); // 2.417 GHz _channels.insert( 2422, 3 ); // 2.422 GHz _channels.insert( 2427, 4 ); // 2.427 GHz diff --git a/libopie2/opienet/onetwork.h b/libopie2/opienet/onetwork.h index f0c4450..b13c7a3 100644 --- a/libopie2/opienet/onetwork.h +++ b/libopie2/opienet/onetwork.h @@ -1,10 +1,9 @@ /* This file is part of the Opie Project - Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> - =. + =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software @@ -195,13 +194,13 @@ class ONetworkInterface : public QObject * Associate the IP address @ addr with the interface. */ void setIPV4Address( const QHostAddress& addr ); /** * @returns the IPv4 address associated with the interface. */ - QString ipV4Address() const; //TODO: make this return an OHostAddress + OHostAddress ipV4Address() const; /** * Associate the MAC address @a addr with the interface. * @note It can be necessary to shut down the interface prior to calling this method. * @note This operation needs root privileges * @warning This is not supported by all drivers. */ @@ -214,13 +213,13 @@ class ONetworkInterface : public QObject * Associate the IPv4 @a netmask with the interface. */ void setIPV4Netmask( const QHostAddress& netmask ); /** * @returns the IPv4 netmask associated with the interface. */ - QString ipV4Netmask() const; //TODO: make this return an OHostAddress + OHostAddress ipV4Netmask() const; /** * @returns the data link type currently associated with the interface. * @see #include <net/if_arp.h> for possible values. */ int dataLinkType() const; /** diff --git a/noncore/applets/networkapplet/networkapplet.cpp b/noncore/applets/networkapplet/networkapplet.cpp index 534a8d0..bd6ca66 100644 --- a/noncore/applets/networkapplet/networkapplet.cpp +++ b/noncore/applets/networkapplet/networkapplet.cpp @@ -80,13 +80,13 @@ void IfaceUpDownButton::clicked() IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) :QLineEdit( parent, name ) { setFont( QFont( "fixed" ) ); _iface = ONetwork::instance()->interface( name ); setFixedWidth( 105 ); - setText( _iface->ipV4Address() ); + setText( _iface->ipV4Address().toString() ); connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); } IfaceIPAddress::~IfaceIPAddress() { @@ -95,16 +95,16 @@ IfaceIPAddress::~IfaceIPAddress() void IfaceIPAddress::returnPressed() { QHostAddress a; a.setAddress( text() ); QHostAddress mask; - mask.setAddress( _iface->ipV4Netmask() ); // setIPV4Address destroys the netmask... + mask.setAddress( _iface->ipV4Netmask().toString() ); // setIPV4Address destroys the netmask... _iface->setIPV4Address( a ); _iface->setIPV4Netmask( mask ); // recover the old netmask - setText( _iface->ipV4Address() ); + setText( _iface->ipV4Address().toString() ); repaint(); } NetworkAppletControl::NetworkAppletControl( OTaskbarApplet* parent, const char* name ) :QFrame( parent, name, WStyle_StaysOnTop | WType_Popup ), l(0) diff --git a/noncore/net/opiestumbler/opiestumbler.cpp b/noncore/net/opiestumbler/opiestumbler.cpp index 8dedd67..f231fca 100644 --- a/noncore/net/opiestumbler/opiestumbler.cpp +++ b/noncore/net/opiestumbler/opiestumbler.cpp @@ -333,13 +333,13 @@ void OpieStumbler::slotCheckDHCP() return; } m_listCurrent->show(); OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); - Global::statusMessage(tr("Obtained IP ") + wiface->ipV4Address()); + Global::statusMessage(tr("Obtained IP ") + wiface->ipV4Address().toString()); } |