author | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-09-10 12:09:49 (UTC) |
commit | 6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4 (patch) (unidiff) | |
tree | 6ebc93c6432f4ed9d00ef1448b6a047ef522a79a /library/networkinterface.cpp | |
parent | d10cddb3c9ce75bc90b14add14bc133737fe35aa (diff) | |
download | opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.zip opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.gz opie-6b77a1cdb9536b1c135eb86d53a6b2c22c19b0a4.tar.bz2 |
Qtopia1-6 merge
still to test
bic changes to be resolved
more changes to be made?
Diffstat (limited to 'library/networkinterface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | library/networkinterface.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/library/networkinterface.cpp b/library/networkinterface.cpp index 56a0e5b..2b5c77e 100644 --- a/library/networkinterface.cpp +++ b/library/networkinterface.cpp | |||
@@ -1,96 +1,98 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "networkinterface.h" | 21 | #include "networkinterface.h" |
22 | #include "network.h" | 22 | #include "network.h" |
23 | #include "config.h" | 23 | #include "config.h" |
24 | #include <stdio.h> | 24 | #include <stdio.h> |
25 | 25 | ||
26 | QString NetworkInterface::device( Config& cfg ) const | 26 | QString NetworkInterface::device( Config& cfg ) const |
27 | { | 27 | { |
28 | return cfg.readEntry("Device"); | 28 | return cfg.readEntry("Device"); |
29 | } | 29 | } |
30 | 30 | ||
31 | bool NetworkInterface::isActive( Config& cfg ) const | 31 | bool NetworkInterface::isActive( Config& cfg ) const |
32 | { | 32 | { |
33 | QString dev = device(cfg); | 33 | QString dev = device(cfg); |
34 | if ( dev.isEmpty() ) | 34 | if ( dev.isEmpty() ) |
35 | return FALSE; | 35 | return FALSE; |
36 | QString dev0 = dev+'0'; | 36 | QString dev0 = dev+'0'; |
37 | 37 | ||
38 | FILE* f; | 38 | FILE* f; |
39 | f = fopen("/proc/net/dev", "r"); | 39 | f = fopen("/proc/net/dev", "r"); |
40 | if ( f ) { | 40 | if ( f ) { |
41 | char line[1024]; | 41 | char line[1024]; |
42 | char devname[80]; | 42 | char devname[80]; |
43 | while ( fgets( line, 1024, f ) ) { | 43 | while ( fgets( line, 1024, f ) ) { |
44 | if ( sscanf(line," %[^:]:", devname)==1 ) | 44 | if ( sscanf(line," %[^:]:", devname)==1 ) |
45 | { | 45 | { |
46 | if ( devname == dev || devname == dev0 ) { | 46 | if ( devname == dev || devname == dev0 ) { |
47 | fclose(f); | 47 | fclose(f); |
48 | #ifdef QWS | ||
48 | Network::writeProxySettings( cfg ); | 49 | Network::writeProxySettings( cfg ); |
50 | #endif | ||
49 | return TRUE; | 51 | return TRUE; |
50 | } | 52 | } |
51 | } | 53 | } |
52 | } | 54 | } |
53 | fclose(f); | 55 | fclose(f); |
54 | } | 56 | } |
55 | return FALSE; | 57 | return FALSE; |
56 | } | 58 | } |
57 | 59 | ||
58 | QString NetworkInterface::cardType( Config& cfg ) const | 60 | QString NetworkInterface::cardType( Config& cfg ) const |
59 | { | 61 | { |
60 | return cfg.readEntry("CardType"); | 62 | return cfg.readEntry("CardType"); |
61 | } | 63 | } |
62 | 64 | ||
63 | bool NetworkInterface::isAvailable( Config& cfg ) const | 65 | bool NetworkInterface::isAvailable( Config& cfg ) const |
64 | { | 66 | { |
65 | QString ct = cardType(cfg); | 67 | QString ct = cardType(cfg); |
66 | if ( ct.isEmpty() ) | 68 | if ( ct.isEmpty() ) |
67 | return FALSE; | 69 | return FALSE; |
68 | 70 | ||
69 | FILE* f = fopen("/var/run/stab", "r"); | 71 | FILE* f = fopen("/var/run/stab", "r"); |
70 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); | 72 | if (!f) f = fopen("/var/state/pcmcia/stab", "r"); |
71 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); | 73 | if (!f) f = fopen("/var/lib/pcmcia/stab", "r"); |
72 | 74 | ||
73 | if ( f ) { | 75 | if ( f ) { |
74 | char line[1024]; | 76 | char line[1024]; |
75 | char devtype[80]; | 77 | char devtype[80]; |
76 | while ( fgets( line, 1024, f ) ) { | 78 | while ( fgets( line, 1024, f ) ) { |
77 | if ( sscanf(line,"%*d %s %*s", devtype )==1 ) | 79 | if ( sscanf(line,"%*d %s %*s", devtype )==1 ) |
78 | { | 80 | { |
79 | if ( ct == devtype ) { | 81 | if ( ct == devtype ) { |
80 | fclose(f); | 82 | fclose(f); |
81 | return TRUE; | 83 | return TRUE; |
82 | } | 84 | } |
83 | } | 85 | } |
84 | } | 86 | } |
85 | fclose(f); | 87 | fclose(f); |
86 | } | 88 | } |
87 | 89 | ||
88 | return FALSE; | 90 | return FALSE; |
89 | } | 91 | } |
90 | 92 | ||
91 | bool NetworkInterface::start( Config& cfg, const QString& /*password*/ ) | 93 | bool NetworkInterface::start( Config& cfg, const QString& /*password*/ ) |
92 | { | 94 | { |
93 | return start(cfg); | 95 | return start(cfg); |
94 | } | 96 | } |
95 | 97 | ||
96 | bool NetworkInterface::needPassword( Config& ) const | 98 | bool NetworkInterface::needPassword( Config& ) const |