Skip to content

Latest commit

 

History

History
177 lines (139 loc) · 4.66 KB

qconnectionagent.h

File metadata and controls

177 lines (139 loc) · 4.66 KB
 
Mar 18, 2013
Mar 18, 2013
1
2
/****************************************************************************
**
Mar 17, 2014
Mar 17, 2014
3
** Copyright (C) 2014 Jolla Ltd
Mar 18, 2013
Mar 18, 2013
4
5
6
7
** Contact: lorn.potter@gmail.com
**
**
** GNU Lesser General Public License Usage
Mar 19, 2013
Mar 19, 2013
8
** This file may be used under the terms of the GNU Lesser
Mar 18, 2013
Mar 18, 2013
9
10
11
12
13
14
15
16
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
****************************************************************************/
Mar 17, 2014
Mar 17, 2014
17
18
#ifndef QCONNECTIONAGENT_H
#define QCONNECTIONAGENT_H
Mar 18, 2013
Mar 18, 2013
19
20
21
22
23
24
25
#include <QObject>
#include <QMap>
#include <QStringList>
#include <QVariant>
#include <QDBusMessage>
#include <QDBusObjectPath>
Apr 16, 2013
Apr 16, 2013
26
27
#include <QQueue>
#include <QPair>
Nov 14, 2013
Nov 14, 2013
28
#include <QElapsedTimer>
Oct 1, 2014
Oct 1, 2014
29
#include <QVector>
Mar 18, 2013
Mar 18, 2013
30
31
32
33
34
class UserAgent;
class SessionAgent;
class NetworkManager;
Mar 23, 2013
Mar 23, 2013
35
class NetworkService;
Oct 5, 2013
Oct 5, 2013
36
class NetworkTechnology;
Oct 29, 2013
Oct 29, 2013
37
class WakeupWatcher;
Oct 29, 2013
Oct 29, 2013
38
39
class QTimer;
Mar 17, 2014
Mar 17, 2014
40
class QConnectionAgent : public QObject
Mar 18, 2013
Mar 18, 2013
41
42
43
44
{
Q_OBJECT
public:
Jul 7, 2015
Jul 7, 2015
45
explicit QConnectionAgent(QObject *parent = 0);
Mar 17, 2014
Mar 17, 2014
46
~QConnectionAgent();
Feb 6, 2014
Feb 6, 2014
47
Jul 7, 2015
Jul 7, 2015
48
bool isValid() const;
Mar 18, 2013
Mar 18, 2013
49
50
51
52
53
Q_SIGNALS:
void userInputRequested(const QString &servicePath, const QVariantMap &fields);
void userInputCanceled();
Jun 7, 2013
Jun 7, 2013
54
void errorReported(const QString &servicePath, const QString &error);
Mar 18, 2013
Mar 18, 2013
55
void connectionRequest();
Apr 10, 2013
Apr 10, 2013
56
void configurationNeeded(const QString &type);
Apr 4, 2013
Apr 4, 2013
57
void connectionState(const QString &state, const QString &type);
Jul 3, 2013
Jul 3, 2013
58
void connectNow(const QString &path);
Sep 16, 2013
Sep 16, 2013
59
Mar 17, 2014
Mar 17, 2014
60
void requestBrowser(const QString &url);
Apr 30, 2014
Apr 30, 2014
61
void tetheringFinished(bool);
Sep 16, 2013
Sep 16, 2013
62
Mar 18, 2013
Mar 18, 2013
63
64
65
66
public Q_SLOTS:
void onUserInputRequested(const QString &servicePath, const QVariantMap &fields);
void onUserInputCanceled();
Jun 6, 2013
Jun 6, 2013
67
void onErrorReported(const QString &servicePath, const QString &error);
Mar 18, 2013
Mar 18, 2013
68
69
70
71
72
73
void onConnectionRequest();
void sendConnectReply(const QString &in0, int in1);
void sendUserReply(const QVariantMap &input);
Mar 20, 2013
Mar 20, 2013
74
void connectToType(const QString &type);
Jul 3, 2013
Jul 3, 2013
75
Apr 30, 2014
Apr 30, 2014
76
void startTethering(const QString &type);
Jul 11, 2014
Jul 11, 2014
77
void stopTethering(bool keepPowered = false);
Apr 30, 2014
Apr 30, 2014
78
Mar 18, 2013
Mar 18, 2013
79
private:
Oct 1, 2014
Oct 1, 2014
80
81
82
83
class Service
{
public:
Jul 7, 2015
Jul 7, 2015
84
85
QString path;
NetworkService *service;
Oct 1, 2014
Oct 1, 2014
86
Jul 7, 2015
Jul 7, 2015
87
88
89
bool operator==(const Service &other) const {
return other.path == path;
}
Oct 1, 2014
Oct 1, 2014
90
91
92
93
94
};
class ServiceList : public QVector<Service>
{
public:
Jul 7, 2015
Jul 7, 2015
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
int indexOf(const QString &path, int from = 0) const {
Service key;
key.path = path;
return QVector<Service>::indexOf(key, from);
}
bool contains(const QString &path) const {
Service key;
key.path = path;
return QVector<Service>::indexOf(key) >= 0;
}
void remove(const QString &path) {
Service key;
key.path = path;
int pos = QVector<Service>::indexOf(key);
if (pos >= 0)
QVector<Service>::remove(pos);
}
Oct 1, 2014
Oct 1, 2014
114
115
};
Jul 7, 2015
Jul 7, 2015
116
117
void setup();
void updateServices();
Jul 7, 2015
Jul 7, 2015
118
119
120
121
122
bool isStateOnline(const QString &state);
bool isBestService(NetworkService *service);
QString findBestConnectableService();
void removeAllTypes(const QString &type);
Mar 18, 2013
Mar 18, 2013
123
UserAgent *ua;
Mar 20, 2013
Mar 20, 2013
124
125
NetworkManager *netman;
Apr 4, 2013
Apr 4, 2013
126
SessionAgent *sessionAgent;
Mar 23, 2013
Mar 23, 2013
127
Mar 18, 2013
Mar 18, 2013
128
QString currentNetworkState;
Apr 4, 2013
Apr 4, 2013
129
Oct 1, 2014
Oct 1, 2014
130
ServiceList orderedServicesList;
Apr 16, 2013
Apr 16, 2013
131
132
QStringList techPreferenceList;
Jun 11, 2013
Jun 11, 2013
133
bool isEthernet;
Sep 20, 2013
Sep 20, 2013
134
bool connmanAvailable;
Jul 3, 2013
Jul 3, 2013
135
Oct 5, 2013
Oct 5, 2013
136
NetworkTechnology *tetheringWifiTech;
Oct 19, 2013
Oct 19, 2013
137
bool tetheringEnabled;
Oct 22, 2013
Oct 22, 2013
138
bool flightModeSuppression;
Nov 6, 2013
Nov 6, 2013
139
WakeupWatcher *mceWatch;
Nov 26, 2013
Nov 26, 2013
140
uint scanTimeoutInterval;
Nov 14, 2013
Nov 14, 2013
141
Dec 13, 2013
Dec 13, 2013
142
143
QTimer *scanTimer;
QStringList knownTechnologies;
Apr 30, 2014
Apr 30, 2014
144
145
bool tetheringStarted;
bool delayedTethering;
Jul 7, 2015
Jul 7, 2015
146
bool valid;
Dec 13, 2013
Dec 13, 2013
147
Mar 20, 2013
Mar 20, 2013
148
149
150
private slots:
void onScanFinished();
Apr 16, 2013
Apr 16, 2013
151
152
153
154
void serviceErrorChanged(const QString &error);
void serviceStateChanged(const QString &state);
void networkStateChanged(const QString &state);
Apr 25, 2013
Apr 25, 2013
155
void connmanAvailabilityChanged(bool b);
Jul 3, 2013
Jul 3, 2013
156
157
void servicesError(const QString &);
void technologyPowerChanged(bool);
Sep 16, 2013
Sep 16, 2013
158
void browserRequest(const QString &servicePath, const QString &url);
Oct 19, 2013
Oct 19, 2013
159
160
161
void techChanged();
void servicesListChanged(const QStringList &);
Oct 22, 2013
Oct 22, 2013
162
163
void offlineModeChanged(bool);
void flightModeDialogSuppressionTimeout();
Oct 29, 2013
Oct 29, 2013
164
165
void displayStateChanged(const QString &);
Mar 17, 2014
Mar 17, 2014
166
// void sleepStateChanged(bool);
Oct 29, 2013
Oct 29, 2013
167
Oct 31, 2013
Oct 31, 2013
168
void serviceAutoconnectChanged(bool);
Nov 26, 2013
Nov 26, 2013
169
void scanTimeout();
Apr 15, 2014
Apr 15, 2014
170
171
void techTetheringChanged(bool b);
void servicesChanged();
Apr 15, 2014
Apr 15, 2014
172
173
void openConnectionDialog(const QString &type);
Jun 12, 2014
Jun 12, 2014
174
void setWifiTetheringEnabled();
Mar 18, 2013
Mar 18, 2013
175
176
};
Mar 17, 2014
Mar 17, 2014
177
#endif // QCONNECTIONAGENT_H