author | mickeyl <mickeyl> | 2005-05-17 16:57:08 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-17 16:57:08 (UTC) |
commit | d2ae68c413873e234b34f733818427902e738948 (patch) (unidiff) | |
tree | f5748014d7b1785302c167c6f43fbd0622bf1019 | |
parent | cce15d6b9a27880df72ea2638f9295900ea6c21e (diff) | |
download | opie-d2ae68c413873e234b34f733818427902e738948.zip opie-d2ae68c413873e234b34f733818427902e738948.tar.gz opie-d2ae68c413873e234b34f733818427902e738948.tar.bz2 |
libopienet API cleanups
-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
@@ -26,8 +26,10 @@ | |||
26 | -------- | 26 | -------- |
27 | * Make BluezApplet use OTaskbarApplet (mickeyl) | 27 | * Make BluezApplet use OTaskbarApplet (mickeyl) |
28 | * Rewrite OFileNotification to use the upcoming inotify interface instead of the deprecated dnotify (mickeyl) | 28 | * Rewrite OFileNotification to use the upcoming inotify interface instead of the deprecated dnotify (mickeyl) |
29 | * libopienet: Skip hostap control interfaces 'wifi' and improve robustness in ONetworkInterface (mickeyl) | 29 | * libopienet: Skip hostap control interfaces 'wifi' and improve robustness in ONetworkInterface (mickeyl) |
30 | * libopieui: Remove OVersatileView and OVersatileViewItem (mickeyl) | ||
31 | * libopienet: Miscellaneous API cleanups (mickeyl) | ||
30 | 32 | ||
31 | 2005-03-25Opie 1.2.0 | 33 | 2005-03-25Opie 1.2.0 |
32 | 34 | ||
33 | Fixed Bugs | 35 | Fixed Bugs |
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 | |||
@@ -50,9 +50,9 @@ public: | |||
50 | if ( it.current()->isWireless() ) | 50 | if ( it.current()->isWireless() ) |
51 | { | 51 | { |
52 | printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), | 52 | printf( " - '%s' (MAC=%s) (IPv4=%s)\n", (const char*) it.current()->name(), |
53 | (const char*) it.current()->macAddress().toString(), | 53 | (const char*) it.current()->macAddress().toString(), |
54 | (const char*) it.current()->ipV4Address() ); | 54 | (const char*) it.current()->ipV4Address().toString() ); |
55 | } | 55 | } |
56 | ++it; | 56 | ++it; |
57 | } | 57 | } |
58 | exit( -1 ); | 58 | 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 | |||
@@ -58,9 +58,9 @@ int main( int argc, char** argv ) | |||
58 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; | 58 | odebug << "DEMO: MAC Address is '" << it.current()->macAddress().toString(true) << "'" << oendl; |
59 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; | 59 | odebug << "DEMO: MAC Manufacturer seems to be '" << it.current()->macAddress().manufacturer() << "'" << oendl; |
60 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; | 60 | odebug << "DEMO: Manufacturertest1 = '" << OManufacturerDB::instance()->lookupExt( "08:00:87" ) << "'" << oendl; |
61 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; | 61 | odebug << "DEMO: Manufacturertest2 = '" << OManufacturerDB::instance()->lookupExt( "E2:0C:0F" ) << "'" << oendl; |
62 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address() << "'" << oendl; | 62 | odebug << "Demo: IPv4 Address is '" << it.current()->ipV4Address().toString() << "'" << oendl; |
63 | if ( it.current()->isWireless() ) | 63 | if ( it.current()->isWireless() ) |
64 | { | 64 | { |
65 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); | 65 | OWirelessNetworkInterface* iface = static_cast<OWirelessNetworkInterface*>( it.current() ); |
66 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << oendl; | 66 | odebug << "DEMO: '" << iface->name() << "' seems to feature the wireless extensions." << 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,9 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | |
4 | (C) 2003 Michael 'Mickey' Lauer <mickey@Vanille.de> | ||
5 | =. | ||
6 | .=l. | 4 | .=l. |
7 | .>+-= | 5 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
@@ -135,8 +133,23 @@ bool operator==( const OMacAddress &m1, const OMacAddress &m2 ) | |||
135 | /*====================================================================================== | 133 | /*====================================================================================== |
136 | * OHostAddress | 134 | * OHostAddress |
137 | *======================================================================================*/ | 135 | *======================================================================================*/ |
138 | 136 | ||
137 | OHostAddress::OHostAddress() | ||
138 | :QHostAddress() | ||
139 | { | ||
140 | } | ||
141 | |||
142 | |||
143 | OHostAddress::OHostAddress( Q_UINT32 ip4Addr ) | ||
144 | :QHostAddress( ip4Addr ) | ||
145 | { | ||
146 | } | ||
147 | |||
148 | |||
149 | OHostAddress::~OHostAddress() | ||
150 | { | ||
151 | } | ||
139 | 152 | ||
140 | /*====================================================================================== | 153 | /*====================================================================================== |
141 | * OPrivateIOCTL | 154 | * OPrivateIOCTL |
142 | *======================================================================================*/ | 155 | *======================================================================================*/ |
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,8 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
@@ -88,12 +87,13 @@ bool operator==( const OMacAddress &m1, const OMacAddress &m2 ); | |||
88 | *======================================================================================*/ | 87 | *======================================================================================*/ |
89 | 88 | ||
90 | class OHostAddress : public QHostAddress | 89 | class OHostAddress : public QHostAddress |
91 | { | 90 | { |
92 | /*public: | 91 | public: |
93 | OHostAddress(); | 92 | OHostAddress(); |
93 | OHostAddress( Q_UINT32 ip4Addr ); | ||
94 | ~OHostAddress(); | 94 | ~OHostAddress(); |
95 | */ | 95 | |
96 | private: | 96 | private: |
97 | class Private; | 97 | class Private; |
98 | Private *d; | 98 | Private *d; |
99 | }; | 99 | }; |
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,8 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
@@ -84,12 +83,8 @@ ONetwork::ONetwork() | |||
84 | 83 | ||
85 | void ONetwork::synchronize() | 84 | void ONetwork::synchronize() |
86 | { | 85 | { |
87 | // gather available interfaces by inspecting /proc/net/dev | 86 | // gather available interfaces by inspecting /proc/net/dev |
88 | //FIXME: we could use SIOCGIFCONF here, but we aren't interested in virtual (e.g. eth0:0) devices | ||
89 | //FIXME: Use SIOCGIFCONF anway, because we can disable listing of aliased devices | ||
90 | //FIXME: Best is use SIOCGIFCONF and if this doesn't work (result=-1), then fallback to parsing /proc/net/dev | ||
91 | |||
92 | _interfaces.clear(); | 87 | _interfaces.clear(); |
93 | QString str; | 88 | QString str; |
94 | QFile f( "/proc/net/dev" ); | 89 | QFile f( "/proc/net/dev" ); |
95 | bool hasFile = f.open( IO_ReadOnly ); | 90 | bool hasFile = f.open( IO_ReadOnly ); |
@@ -201,9 +196,8 @@ struct ifreq& ONetworkInterface::ifr() const | |||
201 | 196 | ||
202 | void ONetworkInterface::init() | 197 | void ONetworkInterface::init() |
203 | { | 198 | { |
204 | odebug << "ONetworkInterface::init()" << oendl; | 199 | odebug << "ONetworkInterface::init()" << oendl; |
205 | |||
206 | memset( &_ifr, 0, sizeof( struct ifreq ) ); | 200 | memset( &_ifr, 0, sizeof( struct ifreq ) ); |
207 | 201 | ||
208 | if ( _sfd == -1 ) | 202 | if ( _sfd == -1 ) |
209 | { | 203 | { |
@@ -269,19 +263,12 @@ void ONetworkInterface::setIPV4Address( const QHostAddress& addr ) | |||
269 | ioctl( SIOCSIFADDR ); | 263 | ioctl( SIOCSIFADDR ); |
270 | } | 264 | } |
271 | 265 | ||
272 | 266 | ||
273 | QString ONetworkInterface::ipV4Address() const | 267 | OHostAddress ONetworkInterface::ipV4Address() const |
274 | { | 268 | { |
275 | if ( ioctl( SIOCGIFADDR ) ) | 269 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
276 | { | 270 | return ioctl( SIOCGIFADDR ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); |
277 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | ||
278 | //FIXME: Use QHostAddress here | ||
279 | return QString( inet_ntoa( sa->sin_addr ) ); | ||
280 | } | ||
281 | else | ||
282 | return "<unknown>"; | ||
283 | |||
284 | } | 271 | } |
285 | 272 | ||
286 | 273 | ||
287 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) | 274 | void ONetworkInterface::setMacAddress( const OMacAddress& addr ) |
@@ -314,18 +301,12 @@ void ONetworkInterface::setIPV4Netmask( const QHostAddress& addr ) | |||
314 | ioctl( SIOCSIFNETMASK ); | 301 | ioctl( SIOCSIFNETMASK ); |
315 | } | 302 | } |
316 | 303 | ||
317 | 304 | ||
318 | QString ONetworkInterface::ipV4Netmask() const | 305 | OHostAddress ONetworkInterface::ipV4Netmask() const |
319 | { | 306 | { |
320 | if ( ioctl( SIOCGIFNETMASK ) ) | 307 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; |
321 | { | 308 | return ioctl( SIOCGIFNETMASK ) ? OHostAddress( ntohl( sa->sin_addr.s_addr ) ) : OHostAddress(); |
322 | struct sockaddr_in* sa = (struct sockaddr_in *) &_ifr.ifr_addr; | ||
323 | //FIXME: Use QHostAddress here | ||
324 | return QString( inet_ntoa( sa->sin_addr ) ); | ||
325 | } | ||
326 | else | ||
327 | return "<unknown>"; | ||
328 | } | 309 | } |
329 | 310 | ||
330 | 311 | ||
331 | int ONetworkInterface::dataLinkType() const | 312 | int ONetworkInterface::dataLinkType() const |
@@ -546,9 +527,17 @@ void OWirelessNetworkInterface::buildInformation() | |||
546 | wrq.u.data.pointer = (caddr_t) buffer; | 527 | wrq.u.data.pointer = (caddr_t) buffer; |
547 | wrq.u.data.length = sizeof buffer; | 528 | wrq.u.data.length = sizeof buffer; |
548 | wrq.u.data.flags = 0; | 529 | wrq.u.data.flags = 0; |
549 | 530 | ||
550 | if ( ::ioctl( _sfd, SIOCGIWRANGE, &wrq ) == -1 ) | 531 | int result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); |
532 | if ( result == -1 ) | ||
533 | { | ||
534 | owarn << "OWirelessNetworkInterface::buildInformation(): SIOCGIWRANGE failed (" << strerror( errno ) << ") - retrying with smaller buffer..." << oendl; | ||
535 | wrq.u.data.length = sizeof( struct iw_range ); | ||
536 | result = ::ioctl( _sfd, SIOCGIWRANGE, &wrq ); | ||
537 | } | ||
538 | |||
539 | if ( result == -1 ) | ||
551 | { | 540 | { |
552 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; | 541 | owarn << "OWirelessNetworkInterface::buildInformation(): Can't get driver information (" << strerror( errno ) << ") - using default values." << oendl; |
553 | _channels.insert( 2412, 1 ); // 2.412 GHz | 542 | _channels.insert( 2412, 1 ); // 2.412 GHz |
554 | _channels.insert( 2417, 2 ); // 2.417 GHz | 543 | _channels.insert( 2417, 2 ); // 2.417 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,8 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. Copyright (C) 2003-2005 by Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | =. | ||
5 | .=l. | 4 | .=l. |
6 | .>+-= | 5 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
@@ -197,9 +196,9 @@ class ONetworkInterface : public QObject | |||
197 | void setIPV4Address( const QHostAddress& addr ); | 196 | void setIPV4Address( const QHostAddress& addr ); |
198 | /** | 197 | /** |
199 | * @returns the IPv4 address associated with the interface. | 198 | * @returns the IPv4 address associated with the interface. |
200 | */ | 199 | */ |
201 | QString ipV4Address() const; //TODO: make this return an OHostAddress | 200 | OHostAddress ipV4Address() const; |
202 | /** | 201 | /** |
203 | * Associate the MAC address @a addr with the interface. | 202 | * Associate the MAC address @a addr with the interface. |
204 | * @note It can be necessary to shut down the interface prior to calling this method. | 203 | * @note It can be necessary to shut down the interface prior to calling this method. |
205 | * @note This operation needs root privileges | 204 | * @note This operation needs root privileges |
@@ -216,9 +215,9 @@ class ONetworkInterface : public QObject | |||
216 | void setIPV4Netmask( const QHostAddress& netmask ); | 215 | void setIPV4Netmask( const QHostAddress& netmask ); |
217 | /** | 216 | /** |
218 | * @returns the IPv4 netmask associated with the interface. | 217 | * @returns the IPv4 netmask associated with the interface. |
219 | */ | 218 | */ |
220 | QString ipV4Netmask() const; //TODO: make this return an OHostAddress | 219 | OHostAddress ipV4Netmask() const; |
221 | /** | 220 | /** |
222 | * @returns the data link type currently associated with the interface. | 221 | * @returns the data link type currently associated with the interface. |
223 | * @see #include <net/if_arp.h> for possible values. | 222 | * @see #include <net/if_arp.h> for possible values. |
224 | */ | 223 | */ |
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 | |||
@@ -82,9 +82,9 @@ IfaceIPAddress::IfaceIPAddress( QWidget* parent, const char* name ) | |||
82 | { | 82 | { |
83 | setFont( QFont( "fixed" ) ); | 83 | setFont( QFont( "fixed" ) ); |
84 | _iface = ONetwork::instance()->interface( name ); | 84 | _iface = ONetwork::instance()->interface( name ); |
85 | setFixedWidth( 105 ); | 85 | setFixedWidth( 105 ); |
86 | setText( _iface->ipV4Address() ); | 86 | setText( _iface->ipV4Address().toString() ); |
87 | connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); | 87 | connect( this, SIGNAL( returnPressed() ), this, SLOT( returnPressed() ) ); |
88 | } | 88 | } |
89 | 89 | ||
90 | 90 | ||
@@ -97,12 +97,12 @@ void IfaceIPAddress::returnPressed() | |||
97 | { | 97 | { |
98 | QHostAddress a; | 98 | QHostAddress a; |
99 | a.setAddress( text() ); | 99 | a.setAddress( text() ); |
100 | QHostAddress mask; | 100 | QHostAddress mask; |
101 | mask.setAddress( _iface->ipV4Netmask() ); // setIPV4Address destroys the netmask... | 101 | mask.setAddress( _iface->ipV4Netmask().toString() ); // setIPV4Address destroys the netmask... |
102 | _iface->setIPV4Address( a ); | 102 | _iface->setIPV4Address( a ); |
103 | _iface->setIPV4Netmask( mask ); // recover the old netmask | 103 | _iface->setIPV4Netmask( mask ); // recover the old netmask |
104 | setText( _iface->ipV4Address() ); | 104 | setText( _iface->ipV4Address().toString() ); |
105 | repaint(); | 105 | repaint(); |
106 | } | 106 | } |
107 | 107 | ||
108 | 108 | ||
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 | |||
@@ -335,9 +335,9 @@ void OpieStumbler::slotCheckDHCP() | |||
335 | m_listCurrent->show(); | 335 | m_listCurrent->show(); |
336 | 336 | ||
337 | 337 | ||
338 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); | 338 | OWirelessNetworkInterface *wiface = static_cast<OWirelessNetworkInterface*>(ONetwork::instance()->interface(m_interface)); |
339 | Global::statusMessage(tr("Obtained IP ") + wiface->ipV4Address()); | 339 | Global::statusMessage(tr("Obtained IP ") + wiface->ipV4Address().toString()); |
340 | } | 340 | } |
341 | 341 | ||
342 | 342 | ||
343 | 343 | ||