Skip to content

Latest commit

 

History

History
159 lines (126 loc) · 4.39 KB

qconnectionagent.h

File metadata and controls

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