Diffstat (limited to 'noncore/applets/wirelessapplet/networkinfo.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/wirelessapplet/networkinfo.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/noncore/applets/wirelessapplet/networkinfo.h b/noncore/applets/wirelessapplet/networkinfo.h new file mode 100644 index 0000000..c5eb743 --- a/dev/null +++ b/noncore/applets/wirelessapplet/networkinfo.h | |||
@@ -0,0 +1,126 @@ | |||
1 | /********************************************************************** | ||
2 | ** MNetwork* classes | ||
3 | ** | ||
4 | ** Encapsulates network information | ||
5 | ** | ||
6 | ** Copyright (C) 2002, Michael Lauer | ||
7 | ** mickey@tm.informatik.uni-frankfurt.de | ||
8 | ** http://www.Vanille.de | ||
9 | ** | ||
10 | ** This file may be distributed and/or modified under the terms of the | ||
11 | ** GNU General Public License version 2 as published by the Free Software | ||
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
13 | ** packaging of this file. | ||
14 | ** | ||
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
17 | ** | ||
18 | **********************************************************************/ | ||
19 | |||
20 | #ifndef NETWORKINFO_H | ||
21 | #define NETWORKINFO_H | ||
22 | |||
23 | #include <qstring.h> | ||
24 | #include <qdict.h> | ||
25 | |||
26 | //--------------------------------------------------------------------------- | ||
27 | // class MNetworkInterface | ||
28 | // | ||
29 | |||
30 | class MNetworkInterface | ||
31 | { | ||
32 | public: | ||
33 | |||
34 | MNetworkInterface( const char* name = "eth0" ); | ||
35 | virtual ~MNetworkInterface(); | ||
36 | |||
37 | bool isLoopback() { return isLoopbackInterface; }; | ||
38 | const QString& getName() { return name; }; | ||
39 | |||
40 | virtual void updateStatistics(); | ||
41 | |||
42 | protected: | ||
43 | |||
44 | int fd; | ||
45 | const QString name; | ||
46 | bool isLoopbackInterface; | ||
47 | bool isIrda; | ||
48 | bool isTunnel; | ||
49 | }; | ||
50 | |||
51 | //--------------------------------------------------------------------------- | ||
52 | // class MWirelessNetworkInterface | ||
53 | // | ||
54 | |||
55 | class MWirelessNetworkInterface : public MNetworkInterface | ||
56 | { | ||
57 | public: | ||
58 | MWirelessNetworkInterface( const char* name = "wlan0" ); | ||
59 | virtual ~MWirelessNetworkInterface(); | ||
60 | |||
61 | int noisePercent(); | ||
62 | int qualityPercent(); | ||
63 | int signalPercent(); | ||
64 | |||
65 | QString APAddr; | ||
66 | QString essid; | ||
67 | QString mode; | ||
68 | QString nick; | ||
69 | QString rate; | ||
70 | double freq; | ||
71 | int channel; | ||
72 | |||
73 | virtual void updateStatistics(); | ||
74 | |||
75 | private: | ||
76 | int quality; | ||
77 | int signal; | ||
78 | int noise; | ||
79 | |||
80 | bool hasWirelessExtensions; | ||
81 | }; | ||
82 | |||
83 | //--------------------------------------------------------------------------- | ||
84 | // class MNetwork | ||
85 | // | ||
86 | |||
87 | class MNetwork | ||
88 | { | ||
89 | public: | ||
90 | MNetwork(); | ||
91 | virtual ~MNetwork(); | ||
92 | |||
93 | typedef QDict<MNetworkInterface> InterfaceMap; | ||
94 | typedef QDictIterator<MNetworkInterface> InterfaceMapIterator; | ||
95 | |||
96 | bool hasInterfaces() const { return interfaces.isEmpty(); }; | ||
97 | int numInterfaces() const { return interfaces.count(); }; | ||
98 | |||
99 | MNetworkInterface* getFirstInterface(); | ||
100 | |||
101 | protected: | ||
102 | QString procfile; | ||
103 | InterfaceMap interfaces; | ||
104 | |||
105 | virtual MNetworkInterface* createInterface( const char* name ) const; | ||
106 | |||
107 | private: | ||
108 | void enumerateInterfaces(); | ||
109 | }; | ||
110 | |||
111 | //--------------------------------------------------------------------------- | ||
112 | // class MWirelessNetwork | ||
113 | // | ||
114 | |||
115 | class MWirelessNetwork : public MNetwork | ||
116 | { | ||
117 | public: | ||
118 | MWirelessNetwork(); | ||
119 | virtual ~MWirelessNetwork(); | ||
120 | |||
121 | protected: | ||
122 | virtual MNetworkInterface* createInterface( const char* name ) | ||
123 | const; | ||
124 | }; | ||
125 | |||
126 | #endif | ||