summaryrefslogtreecommitdiff
path: root/library/networkinterface.cpp
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /library/networkinterface.cpp
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'library/networkinterface.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/networkinterface.cpp104
1 files changed, 104 insertions, 0 deletions
diff --git a/library/networkinterface.cpp b/library/networkinterface.cpp
new file mode 100644
index 0000000..56a0e5b
--- a/dev/null
+++ b/library/networkinterface.cpp
@@ -0,0 +1,104 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
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
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
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.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "networkinterface.h"
22#include "network.h"
23#include "config.h"
24#include <stdio.h>
25
26QString NetworkInterface::device( Config& cfg ) const
27{
28 return cfg.readEntry("Device");
29}
30
31bool NetworkInterface::isActive( Config& cfg ) const
32{
33 QString dev = device(cfg);
34 if ( dev.isEmpty() )
35 return FALSE;
36 QString dev0 = dev+'0';
37
38 FILE* f;
39 f = fopen("/proc/net/dev", "r");
40 if ( f ) {
41 char line[1024];
42 char devname[80];
43 while ( fgets( line, 1024, f ) ) {
44 if ( sscanf(line," %[^:]:", devname)==1 )
45 {
46 if ( devname == dev || devname == dev0 ) {
47 fclose(f);
48 Network::writeProxySettings( cfg );
49 return TRUE;
50 }
51 }
52 }
53 fclose(f);
54 }
55 return FALSE;
56}
57
58QString NetworkInterface::cardType( Config& cfg ) const
59{
60 return cfg.readEntry("CardType");
61}
62
63bool NetworkInterface::isAvailable( Config& cfg ) const
64{
65 QString ct = cardType(cfg);
66 if ( ct.isEmpty() )
67 return FALSE;
68
69 FILE* f = fopen("/var/run/stab", "r");
70 if (!f) f = fopen("/var/state/pcmcia/stab", "r");
71 if (!f) f = fopen("/var/lib/pcmcia/stab", "r");
72
73 if ( f ) {
74 char line[1024];
75 char devtype[80];
76 while ( fgets( line, 1024, f ) ) {
77 if ( sscanf(line,"%*d %s %*s", devtype )==1 )
78 {
79 if ( ct == devtype ) {
80 fclose(f);
81 return TRUE;
82 }
83 }
84 }
85 fclose(f);
86 }
87
88 return FALSE;
89}
90
91bool NetworkInterface::start( Config& cfg, const QString& /*password*/ )
92{
93 return start(cfg);
94}
95
96bool NetworkInterface::needPassword( Config& ) const
97{
98 return FALSE;
99}
100
101QWidget* NetworkInterface::addStateWidget( QWidget*, Config& ) const
102{
103 return 0;
104}