/
declarativeconnectionagent.h
102 lines (89 loc) · 3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd
** Contact: lorn.potter@gmail.com
**
**
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser
** 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.
**
****************************************************************************/
17
18
#ifndef DECLARATIVECONNECTIONAGENT_H
#define DECLARATIVECONNECTIONAGENT_H
19
20
#include "declarativeconnectionagent.h"
21
#include "connectiond_interface.h"
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
/*
*This class is for accessing connman's UserAgent from multiple sources.
*This is because currently, there can only be one UserAgent per system.
*
*It also makes use of a patch to connman, that allows the UserAgent
*to get signaled when a connection is needed. This is the real reason
*this daemon is needed. An InputRequest is short lived, and thus, may
*not clash with other apps that need to use UserAgent.
*
*When you are trying to intercept a connection request, you need a long
*living process to wait until such time. This will immediately clash if
*a wlan needs user Input signal from connman, and the configure will never
*get the proper signal.
*
*This qml type can be used as such:
*
*import com.jolla.connection 1.0
*
* ConnectionAgent {
* id: userAgent
* onUserInputRequested: {
* console.log(" onUserInputRequested:")
* }
*
* onConnectionRequest: {
* console.log("onConnectionRequest ")
* sendSuppress()
* }
* onErrorReported: {
* console.log("Got error from connman: " + error);
* }
* }
*
**/
class DeclarativeConnectionAgent : public QObject
59
60
{
Q_OBJECT
61
62
Q_DISABLE_COPY(DeclarativeConnectionAgent)
63
64
public:
65
66
explicit DeclarativeConnectionAgent(QObject *parent = 0);
~DeclarativeConnectionAgent();
67
68
69
70
public slots:
void sendUserReply(const QVariantMap &input);
void sendConnectReply(const QString &replyMessage, int timeout = 120);
71
void connectToType(const QString &type);
72
void startTethering(const QString &type);
73
void stopTethering(bool keepPowered = false);
74
75
76
77
signals:
void userInputRequested(const QString &servicePath, const QVariantMap &fields);
void userInputCanceled();
78
void errorReported(const QString &servicePath, const QString &error);
79
void connectionRequest();
80
void configurationNeeded(const QString &type);
81
void connectionState(const QString &state, const QString &type);
82
void browserRequested(const QString &url);
83
void tetheringFinished(bool);
84
85
86
87
88
89
private:
com::jolla::Connectiond *connManagerInterface;
QDBusServiceWatcher *connectiondWatcher;
private slots:
90
void onErrorReported(const QString &servicePath, const QString &error);
91
92
93
void onRequestBrowser(const QString &url);
void onUserInputRequested(const QString &service, const QVariantMap &fields);
void onConnectionRequested();
94
void onConnectionState(const QString &state, const QString &type);
95
void onTetheringFinished(bool);
96
97
98
99
100
void connectToConnectiond(const QString = QString());
void connectiondUnregistered(const QString = QString());
};
101
#endif