File: ConnectionState.h

package info (click to toggle)
l2tp-ipsec-vpn 1.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,396 kB
  • sloc: cpp: 9,952; xml: 400; makefile: 139; sh: 78
file content (146 lines) | stat: -rw-r--r-- 4,247 bytes parent folder | download
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*
 * $Id: ConnectionState.h 68 2011-04-08 02:50:25Z werner $
 *
 * File:   ConnectionState.h
 * Author: Werner Jaeger
 *
 * Created on July 8, 2010, 10:35 AM
 *
 * Copyright 2010 Werner Jaeger.
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 */

#ifndef CONNECTIONSTATE_H
#define	CONNECTIONSTATE_H

#include <QSystemTrayIcon>

#include "util/NetworkInterface.h"

class QSystemTrayIcon;
class QIcon;
class QString;
class QMovie;

class ConnectionState : public QObject
{
   Q_OBJECT

public:
   enum State {NotConnected, Connecting, Disconnecting, Connected, Error};

   ConnectionState(QSystemTrayIcon* pTrayIcon, const QString& strHostName, const QString& strMsgTitle, const QString& strMsgBody, const QIcon& icon, const QSystemTrayIcon::MessageIcon& msgIcon, const NetworkInterface& ptpInterface = NetworkInterface::null);
   virtual ~ConnectionState();

   virtual bool isState(State state) const = 0;
   const QString& hostName() const;
   const QString& msgTitle() const;
   const QString& msgBody() const;
   const QIcon& icon() const;
   const QSystemTrayIcon::MessageIcon& msgIcon() const;
   const NetworkInterface& ptpInterface() const;

protected:
   QSystemTrayIcon* trayIcon() const { return(m_pTrayIcon); }

private:
   ConnectionState(const ConnectionState& orig);
   ConnectionState& operator=(const ConnectionState& orig);

   QSystemTrayIcon* const m_pTrayIcon;
   const QString m_strHostName;
   const QString m_strMsgTitle;
   const QString m_strMsgBody;
   const QIcon m_Icon;
   const QSystemTrayIcon::MessageIcon m_MsgIcon;
   const NetworkInterface m_PtpInterface;
};

class NotConnected : public ConnectionState
{
public:
   NotConnected(QSystemTrayIcon* pTrayIcon);
   virtual ~NotConnected();
   virtual bool isState(State state) const { return(state == ConnectionState::NotConnected ? true : false); }

private:
   NotConnected(const NotConnected& orig);
   NotConnected& operator=(const NotConnected& orig);
};

class Connecting : public ConnectionState
{
   Q_OBJECT

public:
   Connecting(QSystemTrayIcon* pTrayIcon, const QString& strHostName);
   virtual ~Connecting();
   virtual bool isState(State state) const { return(state == ConnectionState::Connecting ? true : false); }

private slots:
   void onFrameChanged() const;

private:
   Connecting(const Connecting& orig);
   Connecting& operator=(const Connecting& orig);

   QMovie* const m_pMovie;
};

class Disconnecting : public ConnectionState
{
   Q_OBJECT

public:
   Disconnecting(QSystemTrayIcon* pTrayIcon, const QString& strHostName);
   virtual ~Disconnecting();
   virtual bool isState(State state) const { return(state == ConnectionState::Disconnecting ? true : false); }

private slots:
   void onFrameChanged() const;

private:
   Disconnecting(const Disconnecting& orig);
   Disconnecting& operator=(const Disconnecting& orig);

   QMovie* const m_pMovie;
};

class Connected : public ConnectionState
{
public:
   Connected(QSystemTrayIcon* pTrayIcon, const QString& strHostName, const NetworkInterface& ptpInterface);
   virtual ~Connected();
   virtual bool isState(State state) const { return(state == ConnectionState::Connected ? true : false); }

private:
   Connected(const Connected& orig);
   Connected& operator=(const Connected& orig);
};

class Error : public ConnectionState
{
public:
   Error(QSystemTrayIcon* pTrayIcon, const QString& strHostName, int iReturnCocde, bool fDisconnecting);
   virtual ~Error();
   virtual bool isState(State state) const { return(state == ConnectionState::Error ? true : false); }

private:
   Error(const Error& orig);
   Error& operator=(const Error& orig);
};

#endif	/* CONNECTIONSTATE_H */