summaryrefslogtreecommitdiffstats
path: root/wifi/interface_wireless.h
blob: 029a8156aebe8cb9dd879119ce06cb43e6b1cda2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/***************************************************************************
                          stuff.h  -  description
                             -------------------
    begin                : Mon Aug 19 2002
    copyright            : (C) 2002 by Stefan Winter
    email                : mail@stefan-winter.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef INTERFACE_WIRELESS_H
#define INTERFACE_WIRELESS_H

#include "config.h"

#include <qobject.h>
#include <qstring.h>
#include <qtable.h>

#ifndef WITHOUT_ARTS
#include <arts/iomanager.h>
#include <arts/dispatcher.h>
#endif

const int POLL_DELAY_MS = 250;	// how much time between device polls
const int MAX_HISTORY = 240;	// number of device states to be saved

class Interface_wireless:public QObject
{
Q_OBJECT public:
  Interface_wireless (QStringList * ignoreInterfaces);
  virtual ~ Interface_wireless() { };

  virtual bool get_device_freq (double &freq);
  // true: device returned valid frequency
  virtual bool get_mode (int &mode);
  // true: device returned valid mode info
  virtual bool get_key (QString & key, int &size, int &flags);
  // true: device has set up a valid crypto key
  virtual QString get_essid ();
  virtual bool get_AP_info (QString & mac, QString & ip);
  // true: could retrieve IP, false: returned IP info invalid
  virtual QString get_IP_info ();
  virtual double get_bitrate ();
  virtual QString get_interface_name ();
  // if no device is attached, return empty QString
  virtual bool get_current_quality (int &sig, int &noi, int &qua);
  // quality info is only valid when true
  virtual QTable* get_available_networks () = 0;
  virtual bool get_has_txpower();
  virtual int get_txpower_disabled();
  virtual void setActiveDevice( QString device ) = 0;
  // stats
  int sigLevel[MAX_HISTORY];
  int sigLevelMin, sigLevelMax;
  int noiseLevel[MAX_HISTORY];
  int noiseLevelMin, noiseLevelMax;
  int qual[MAX_HISTORY];
  bool valid[MAX_HISTORY];
  int current;
  
public slots:
  virtual bool poll_device_info () = 0;

signals:
  void interfaceChanged ();
  void strengthChanged ();
  void statusChanged ();
  void modeChanged ();
  void speedChanged ();
  void essidChanged (QString essid);
  void txPowerChanged ();
  void statsUpdated ();
protected:
  bool already_warned;
  // device info
  bool has_frequency;
  float frequency;
  bool has_mode;
  int mode;
  bool has_key;
  QString key;
  int key_size;
  int key_flags;
  QString essid;
  QString access_point_address;
  QString ip_address;
  double bitrate;
  QString interface_name;
  int socket;
  bool has_range;
  int range;
  QStringList * ignoreInterfaces;
  bool has_txpower;
  int txpower_disabled;
};

#ifndef WITHOUT_ARTS

void sinus_wave (double frequency);

class MyTimeNotify:public
  Arts::TimeNotify
{
public:
  Arts::Dispatcher * test;
  MyTimeNotify (Arts::Dispatcher * siff)
  {
    test = siff;
  };
  void notifyTime ();
};

#endif

QString whois (const char *MAC_ADR, QStringList APList);

#endif /*  INTERFACE_WIRELESS_H */