does not need DQT3_SUPPORT
[kdenetwork.git] / wifi / interface_wireless.h
blob1ec0726f4ca8d18f495ce3933b0ea869b7742052
1 /***************************************************************************
2 stuff.h - description
3 -------------------
4 begin : Mon Aug 19 2002
5 copyright : (C) 2002 by Stefan Winter
6 email : mail@stefan-winter.de
7 ***************************************************************************/
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
18 #ifndef INTERFACE_WIRELESS_H
19 #define INTERFACE_WIRELESS_H
21 #include "config-wifi.h"
23 #include <QObject>
24 #include <QString>
25 #include <QStringList>
26 #include <QAbstractTableModel>
27 #include <QVarLengthArray>
29 #ifndef WITHOUT_ARTS
30 #include <arts/iomanager.h>
31 #include <arts/dispatcher.h>
32 #endif
34 const int POLL_DELAY_MS = 250; // how much time between device polls
35 const int MAX_HISTORY = 240; // number of device states to be saved
37 enum CARDSTATES
38 { NO_CARD, NO_CONNECTION, AD_HOC, AP_CONNECT };
39 enum WEP_KEY
40 { NONE, VALID_HEX, VALID_STRING, INVALID };
42 struct NetworkParameterData
44 QString ssid;
45 QString mode;
46 int quality;
47 QString encryption;
50 class NetworkParameterDataModel:public QAbstractTableModel
52 Q_OBJECT public:
53 int rowCount ( const QModelIndex & parent ) const;
54 int columnCount ( const QModelIndex & parent ) const;
55 QVariant data ( const QModelIndex & index, int role ) const;
56 QVariant data ( int row, int col );
57 QVariant headerData ( int section, Qt::Orientation orientation, int role ) const;
58 QVariant headerData ( int row );
59 bool setData ( const QModelIndex & index, const QVariant & value, int role );
60 bool setData ( int row, int col, const QVariant & value );
61 Qt::ItemFlags flags ( const QModelIndex & index ) const;
62 public slots:void gotFinishedIndicator ( );
63 signals:void finishedScanning ( );
64 protected:
65 QVarLengthArray < struct NetworkParameterData >dataContainer;
66 WEP_KEY checkWEP ( const QString & key ) const;
69 class Interface_wireless:public QObject
71 Q_OBJECT public:
72 Interface_wireless ( );
73 virtual ~ Interface_wireless ( )
77 virtual bool get_device_freq ( long &freq );
78 // true: device returned valid frequency (frequency in MEGAHertz)
79 virtual bool get_mode ( int &mode );
80 // true: device returned valid mode info
81 virtual bool get_key ( QString & key, int &size, int &flags );
82 // true: device has set up a valid crypto key
83 virtual QString get_essid ( );
84 virtual bool get_AP_info ( QString & mac, QString & ip );
85 // true: could retrieve IP, false: returned IP info invalid
86 virtual QStringList get_IP_info ( );
87 virtual signed long get_bitrate ( );
88 virtual QString get_interface_name ( );
89 // if no device is attached, return empty QString
90 virtual bool get_current_quality ( int &sig, int &noi, int &qua );
91 // quality info is only valid when true
92 virtual long toggleFreqChannel ( long input ) = 0;
93 // converts frequency <-> channel, frequency in MEGAHertz
94 virtual NetworkParameterDataModel *get_available_networks ( ) = 0;
95 virtual bool get_has_txpower ( );
96 virtual int get_txpower_disabled ( );
97 virtual CARDSTATES getDeviceState ( );
98 virtual void setActiveDevice ( QString device ) = 0;
99 virtual signed long getMaxBitrate ( );
100 // stats
101 int sigLevel[MAX_HISTORY];
102 int sigLevelMin, sigLevelMax;
103 int noiseLevel[MAX_HISTORY];
104 int noiseLevelMin, noiseLevelMax;
105 int qual[MAX_HISTORY];
106 bool valid[MAX_HISTORY];
107 int current;
109 public slots:virtual bool poll_device_info ( ) = 0;
111 signals:
112 void notifyInterfaceChanged ( );
113 void strengthChanged ( int, int, int );
114 void statusChanged ( );
115 void modeChanged ( CARDSTATES );
116 void speedChanged ( signed long );
117 void essidChanged ( QString );
118 void txPowerChanged ( );
119 void statsUpdated ( );
120 protected:
121 bool already_warned;
122 // device info
123 bool has_frequency;
124 long frequency;
125 bool has_mode;
126 int mode;
127 bool has_key;
128 QString key;
129 int key_size;
130 int key_flags;
131 QString essid;
132 QString access_point_address;
133 QStringList ip_addresses;
134 signed long bitrate;
135 signed long maxBitrate;
136 QString interface_name;
137 int socket;
138 bool has_range;
139 int max_quality;
140 static QStringList ignoreInterfaces;
141 bool has_txpower;
142 int txpower_disabled;
143 NetworkParameterDataModel *networks;
146 #ifndef WITHOUT_ARTS
148 void sinus_wave ( double frequency );
150 class MyTimeNotify:public
151 Arts::TimeNotify
153 public:
154 Arts::Dispatcher * test;
155 MyTimeNotify ( Arts::Dispatcher * siff )
157 test = siff;
159 void notifyTime ( );
162 #endif
164 QString whois ( const char *MAC_ADR, QStringList APList );
166 #endif /* INTERFACE_WIRELESS_H */