-
Notifications
You must be signed in to change notification settings - Fork 5
/
packetinterface.h
108 lines (88 loc) · 3.53 KB
/
packetinterface.h
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
/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*-
*
* XASTIR, Amateur Station Tracking and Information Reporting
* Copyright (C) 1999,2000 Frank Giannandrea
* Copyright (C) 2000-2018 The Xastir Group
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* Look at the README for more information on the program.
*/
#ifndef PACKETINTERFACE_H
#define PACKETINTERFACE_H
#include <QObject>
#include <QSettings>
class PacketInterface : public QObject
{
Q_OBJECT
public:
explicit PacketInterface(int ifaceNumber = 0, QObject *parent = 0);
public:
enum Device_Active {
DEVICE_NOT_IN_USE,
DEVICE_IN_USE
};
enum Device_Status {
DEVICE_DOWN,
DEVICE_STARTING,
DEVICE_UP,
DEVICE_ERROR
};
virtual void start() = 0;
virtual void stop() = 0;
/*! \brief Save interface settings using QSettings
*
* This will save this interfaces settings in a platform independant
* manner using QSettings. It is assumed that the caller has created a
* settings group before calling as appropriate. (For example, each interface
* should be in a seperate group to avoid collision.)
*
* This function will call saveSpecificSettings, so any derived classes can
* put their class specific settings in an overriden version of saveSpecificSettings.)
*/
void saveSettings(QSettings& settings);
/*! \brief Restore interface settings using QSettings
*
* This will retreive interface settings in a platform independant
* manner using QSettings. It is assumed that the caller has set a
* settings group before calling as appropriate. (For example, each interface
* should be in a seperate group to avoid collision.)
*
* This function will call restoreSpecificSettings, so any derived classes can
* handle their class specific settings in an overriden version of saveSpecificSettings.)
*/
void restoreFromSettings(QSettings& settings);
bool transmitAllowed();
Device_Status deviceStatus();
virtual QString deviceName() = 0;
virtual QString deviceDescription() = 0;
bool getActivateOnStartup() {return activateOnStartup;}
void setActivateOnStartup(bool newValue) { activateOnStartup = newValue; }
int getInterfaceNumber() { return interfaceNumber; }
void setInterfaceNumber(int newValue) { interfaceNumber = newValue; }
void setTransmitAllowed(bool newValue) { allowTransmit = newValue; }
signals:
void packetReceived(PacketInterface *device, QString data);
void interfaceChangedState(PacketInterface *iface, PacketInterface::Device_Status state);
public slots:
protected:
virtual void saveSpecificSettings(QSettings&) {}
virtual void restoreSpecificSettings(QSettings&) {}
bool allowTransmit;
bool activateOnStartup;
int interfaceNumber;
Device_Status deviceState;
};
#endif // PACKETINTERFACE_H