author | mickeyl <mickeyl> | 2005-05-06 09:27:12 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2005-05-06 09:27:12 (UTC) |
commit | 543d9d7c58c9601dba6f47b3a4011313d1d75499 (patch) (unidiff) | |
tree | 6b9d259a91b220264c961d542e25b69fe070320f /libopie2/opienet | |
parent | c199fa0b0ef971c3a121af6c31a9a9822561a1be (diff) | |
download | opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.zip opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.tar.gz opie-543d9d7c58c9601dba6f47b3a4011313d1d75499.tar.bz2 |
- OManufacturerDB: check if there is a QApplication before calling Global::statusMessage or qApp->processEvents()
- ONetwork: skip hostap control interfaces 'wifi*'
- OWirelessNetworkInterface: set \0 in SSID() and nickName() to work around (buggy) drivers not returning a
zero-terminated string
-rw-r--r-- | libopie2/opienet/omanufacturerdb.cpp | 17 | ||||
-rw-r--r-- | libopie2/opienet/onetwork.cpp | 9 | ||||
-rw-r--r-- | libopie2/opienet/opienet.pro | 2 |
3 files changed, 13 insertions, 15 deletions
diff --git a/libopie2/opienet/omanufacturerdb.cpp b/libopie2/opienet/omanufacturerdb.cpp index 123aee8..3af3d4c 100644 --- a/libopie2/opienet/omanufacturerdb.cpp +++ b/libopie2/opienet/omanufacturerdb.cpp | |||
@@ -19,26 +19,24 @@ | |||
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | */ | 27 | */ |
28 | 28 | ||
29 | #include "omanufacturerdb.h" | 29 | #include "omanufacturerdb.h" |
30 | 30 | ||
31 | #define OPIE_IMPROVE_GUI_LATENCY 1 | ||
32 | |||
33 | /* OPIE */ | 31 | /* OPIE */ |
34 | #include <opie2/odebug.h> | 32 | #include <opie2/odebug.h> |
35 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
36 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 34 | #ifdef OPIE_IMPROVE_GUI_LATENCY |
37 | #include <qpe/global.h> | 35 | #include <qpe/global.h> |
38 | #endif | 36 | #endif |
39 | 37 | ||
40 | 38 | ||
41 | 39 | ||
42 | /* QT */ | 40 | /* QT */ |
43 | #include <qapplication.h> | 41 | #include <qapplication.h> |
44 | #include <qfile.h> | 42 | #include <qfile.h> |
@@ -54,27 +52,25 @@ OManufacturerDB* OManufacturerDB::instance() | |||
54 | { | 52 | { |
55 | if ( !OManufacturerDB::_instance ) | 53 | if ( !OManufacturerDB::_instance ) |
56 | { | 54 | { |
57 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; | 55 | odebug << "OManufacturerDB::instance(): creating OManufacturerDB..." << oendl; |
58 | _instance = new OManufacturerDB(); | 56 | _instance = new OManufacturerDB(); |
59 | } | 57 | } |
60 | return _instance; | 58 | return _instance; |
61 | } | 59 | } |
62 | 60 | ||
63 | 61 | ||
64 | OManufacturerDB::OManufacturerDB() | 62 | OManufacturerDB::OManufacturerDB() |
65 | { | 63 | { |
66 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 64 | if ( qApp ) Global::statusMessage( "Reading Manufacturers..." ); |
67 | Global::statusMessage( "Reading Manufacturers..." ); | ||
68 | #endif | ||
69 | QString filename( "/etc/manufacturers" ); | 65 | QString filename( "/etc/manufacturers" ); |
70 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 66 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
71 | if ( !QFile::exists( filename ) ) | 67 | if ( !QFile::exists( filename ) ) |
72 | { | 68 | { |
73 | filename = QPEApplication::qpeDir()+"etc/manufacturers"; | 69 | filename = QPEApplication::qpeDir()+"etc/manufacturers"; |
74 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 70 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
75 | if ( !QFile::exists( filename ) ) | 71 | if ( !QFile::exists( filename ) ) |
76 | { | 72 | { |
77 | filename = "/usr/share/wellenreiter/manufacturers"; | 73 | filename = "/usr/share/wellenreiter/manufacturers"; |
78 | odebug << "OManufacturerDB: trying to read " << filename << oendl; | 74 | odebug << "OManufacturerDB: trying to read " << filename << oendl; |
79 | } | 75 | } |
80 | } | 76 | } |
@@ -83,49 +79,44 @@ OManufacturerDB::OManufacturerDB() | |||
83 | bool hasFile = file.open( IO_ReadOnly ); | 79 | bool hasFile = file.open( IO_ReadOnly ); |
84 | if (!hasFile) | 80 | if (!hasFile) |
85 | { | 81 | { |
86 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; | 82 | owarn << "OManufacturerDB: no valid manufacturer list found." << oendl; |
87 | } | 83 | } |
88 | else | 84 | else |
89 | { | 85 | { |
90 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; | 86 | odebug << "OManufacturerDB: found manufacturer list in " << filename << oendl; |
91 | QTextStream s( &file ); | 87 | QTextStream s( &file ); |
92 | QString addr; | 88 | QString addr; |
93 | QString manu; | 89 | QString manu; |
94 | QString extManu; | 90 | QString extManu; |
95 | #ifdef OPIE_IMPROVE_GUI_LATENCY | ||
96 | int counter = 0; | 91 | int counter = 0; |
97 | #endif | 92 | |
98 | while (!s.atEnd()) | 93 | while (!s.atEnd()) |
99 | { | 94 | { |
100 | s >> addr; | 95 | s >> addr; |
101 | s >> manu; | 96 | s >> manu; |
102 | s >> extManu; | 97 | s >> extManu; |
103 | 98 | ||
104 | manufacturers.insert( addr, manu ); | 99 | manufacturers.insert( addr, manu ); |
105 | manufacturersExt.insert( addr, extManu ); | 100 | manufacturersExt.insert( addr, extManu ); |
106 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; | 101 | // odebug << "OmanufacturerDB: parse '" << addr << "' as '" << manu << "' (" << extManu << ")" << oendl; |
107 | #ifdef OPIE_IMPROVE_GUI_LATENCY | ||
108 | counter++; | 102 | counter++; |
109 | if ( counter == 50 ) | 103 | if ( counter == 50 ) |
110 | { | 104 | { |
111 | qApp->processEvents(); | 105 | if ( qApp ) qApp->processEvents(); |
112 | counter = 0; | 106 | counter = 0; |
113 | } | 107 | } |
114 | #endif | ||
115 | } | 108 | } |
116 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; | 109 | odebug << "OManufacturerDB: manufacturer list completed." << oendl; |
117 | #ifdef OPIE_IMPROVE_GUI_LATENCY | 110 | if ( qApp ) Global::statusMessage( "Manufacturers Complete..." ); |
118 | Global::statusMessage( "Manufacturers Complete..." ); | ||
119 | #endif | ||
120 | } | 111 | } |
121 | } | 112 | } |
122 | 113 | ||
123 | 114 | ||
124 | OManufacturerDB::~OManufacturerDB() | 115 | OManufacturerDB::~OManufacturerDB() |
125 | { | 116 | { |
126 | } | 117 | } |
127 | 118 | ||
128 | 119 | ||
129 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const | 120 | const QString& OManufacturerDB::lookup( const QString& macaddr ) const |
130 | { | 121 | { |
131 | return manufacturers[macaddr.upper().left(8)]; | 122 | return manufacturers[macaddr.upper().left(8)]; |
diff --git a/libopie2/opienet/onetwork.cpp b/libopie2/opienet/onetwork.cpp index 0a74019..f4bdbe0 100644 --- a/libopie2/opienet/onetwork.cpp +++ b/libopie2/opienet/onetwork.cpp | |||
@@ -95,24 +95,30 @@ void ONetwork::synchronize() | |||
95 | { | 95 | { |
96 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; | 96 | odebug << "ONetwork: /proc/net/dev not existing. No network devices available" << oendl; |
97 | return; | 97 | return; |
98 | } | 98 | } |
99 | QTextStream s( &f ); | 99 | QTextStream s( &f ); |
100 | s.readLine(); | 100 | s.readLine(); |
101 | s.readLine(); | 101 | s.readLine(); |
102 | while ( !s.atEnd() ) | 102 | while ( !s.atEnd() ) |
103 | { | 103 | { |
104 | s >> str; | 104 | s >> str; |
105 | str.truncate( str.find( ':' ) ); | 105 | str.truncate( str.find( ':' ) ); |
106 | odebug << "ONetwork: found interface '" << str << "'" << oendl; | 106 | odebug << "ONetwork: found interface '" << str << "'" << oendl; |
107 | if ( str.startsWith( "wifi" ) ) | ||
108 | { | ||
109 | odebug << "ONetwork: ignoring hostap control interface" << oendl; | ||
110 | s.readLine(); | ||
111 | continue; | ||
112 | } | ||
107 | ONetworkInterface* iface = 0; | 113 | ONetworkInterface* iface = 0; |
108 | if ( isWirelessInterface( str ) ) | 114 | if ( isWirelessInterface( str ) ) |
109 | { | 115 | { |
110 | iface = new OWirelessNetworkInterface( this, (const char*) str ); | 116 | iface = new OWirelessNetworkInterface( this, (const char*) str ); |
111 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; | 117 | odebug << "ONetwork: interface '" << str << "' has Wireless Extensions" << oendl; |
112 | } | 118 | } |
113 | else | 119 | else |
114 | { | 120 | { |
115 | iface = new ONetworkInterface( this, (const char*) str ); | 121 | iface = new ONetworkInterface( this, (const char*) str ); |
116 | } | 122 | } |
117 | _interfaces.insert( str, iface ); | 123 | _interfaces.insert( str, iface ); |
118 | s.readLine(); | 124 | s.readLine(); |
@@ -799,25 +805,25 @@ void OWirelessNetworkInterface::setNickName( const QString& nickname ) | |||
799 | 805 | ||
800 | QString OWirelessNetworkInterface::nickName() const | 806 | QString OWirelessNetworkInterface::nickName() const |
801 | { | 807 | { |
802 | char str[IW_ESSID_MAX_SIZE]; | 808 | char str[IW_ESSID_MAX_SIZE]; |
803 | _iwr.u.data.pointer = &str[0]; | 809 | _iwr.u.data.pointer = &str[0]; |
804 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; | 810 | _iwr.u.data.length = IW_ESSID_MAX_SIZE; |
805 | if ( !wioctl( SIOCGIWNICKN ) ) | 811 | if ( !wioctl( SIOCGIWNICKN ) ) |
806 | { | 812 | { |
807 | return "<unknown>"; | 813 | return "<unknown>"; |
808 | } | 814 | } |
809 | else | 815 | else |
810 | { | 816 | { |
811 | str[_iwr.u.data.length] = 0x0; // some drivers (e.g. wlan-ng) don't zero-terminate the string | 817 | str[_iwr.u.data.length] = '\0'; // some drivers don't zero-terminate the string |
812 | return str; | 818 | return str; |
813 | } | 819 | } |
814 | } | 820 | } |
815 | 821 | ||
816 | 822 | ||
817 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) | 823 | void OWirelessNetworkInterface::setPrivate( const QString& call, int numargs, ... ) |
818 | { | 824 | { |
819 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); | 825 | OPrivateIOCTL* priv = static_cast<OPrivateIOCTL*>( child( (const char*) call ) ); |
820 | if ( !priv ) | 826 | if ( !priv ) |
821 | { | 827 | { |
822 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() | 828 | owarn << "OWirelessNetworkInterface::setPrivate(): interface '" << name() |
823 | << "' does not support private ioctl '" << call << "'" << oendl; | 829 | << "' does not support private ioctl '" << call << "'" << oendl; |
@@ -857,24 +863,25 @@ bool OWirelessNetworkInterface::hasPrivate( const QString& call ) | |||
857 | 863 | ||
858 | QString OWirelessNetworkInterface::SSID() const | 864 | QString OWirelessNetworkInterface::SSID() const |
859 | { | 865 | { |
860 | char str[IW_ESSID_MAX_SIZE]; | 866 | char str[IW_ESSID_MAX_SIZE]; |
861 | _iwr.u.essid.pointer = &str[0]; | 867 | _iwr.u.essid.pointer = &str[0]; |
862 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; | 868 | _iwr.u.essid.length = IW_ESSID_MAX_SIZE; |
863 | if ( !wioctl( SIOCGIWESSID ) ) | 869 | if ( !wioctl( SIOCGIWESSID ) ) |
864 | { | 870 | { |
865 | return "<unknown>"; | 871 | return "<unknown>"; |
866 | } | 872 | } |
867 | else | 873 | else |
868 | { | 874 | { |
875 | str[_iwr.u.essid.length] = '\0'; // some drivers don't zero-terminate the string | ||
869 | return str; | 876 | return str; |
870 | } | 877 | } |
871 | } | 878 | } |
872 | 879 | ||
873 | 880 | ||
874 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) | 881 | void OWirelessNetworkInterface::setSSID( const QString& ssid ) |
875 | { | 882 | { |
876 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); | 883 | _iwr.u.essid.pointer = const_cast<char*>( (const char*) ssid ); |
877 | _iwr.u.essid.length = ssid.length()+1; // zero byte | 884 | _iwr.u.essid.length = ssid.length()+1; // zero byte |
878 | wioctl( SIOCSIWESSID ); | 885 | wioctl( SIOCSIWESSID ); |
879 | } | 886 | } |
880 | 887 | ||
diff --git a/libopie2/opienet/opienet.pro b/libopie2/opienet/opienet.pro index a10a949..460de0a 100644 --- a/libopie2/opienet/opienet.pro +++ b/libopie2/opienet/opienet.pro | |||
@@ -9,25 +9,25 @@ HEADERS = 802_11_user.h \ | |||
9 | onetutils.h \ | 9 | onetutils.h \ |
10 | onetwork.h \ | 10 | onetwork.h \ |
11 | opcap.h \ | 11 | opcap.h \ |
12 | ostation.h | 12 | ostation.h |
13 | SOURCES = odebugmapper.cpp \ | 13 | SOURCES = odebugmapper.cpp \ |
14 | omanufacturerdb.cpp \ | 14 | omanufacturerdb.cpp \ |
15 | onetutils.cpp \ | 15 | onetutils.cpp \ |
16 | onetwork.cpp \ | 16 | onetwork.cpp \ |
17 | opcap.cpp \ | 17 | opcap.cpp \ |
18 | ostation.cpp | 18 | ostation.cpp |
19 | INTERFACES = | 19 | INTERFACES = |
20 | TARGET = opienet2 | 20 | TARGET = opienet2 |
21 | VERSION = 1.8.5 | 21 | VERSION = 1.8.6 |
22 | INCLUDEPATH += $(OPIEDIR)/include | 22 | INCLUDEPATH += $(OPIEDIR)/include |
23 | DEPENDPATH += $(OPIEDIR)/include | 23 | DEPENDPATH += $(OPIEDIR)/include |
24 | LIBS += -lpcap | 24 | LIBS += -lpcap |
25 | 25 | ||
26 | 26 | ||
27 | !contains( platform, x11 ) { | 27 | !contains( platform, x11 ) { |
28 | include( $(OPIEDIR)/include.pro ) | 28 | include( $(OPIEDIR)/include.pro ) |
29 | } | 29 | } |
30 | 30 | ||
31 | contains( platform, x11 ) { | 31 | contains( platform, x11 ) { |
32 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib | 32 | LIBS += -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib |
33 | } | 33 | } |