mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
drop symbian/harmattan related bearer management support [ci reset]
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
2b5a4345ec
commit
9499915786
79 changed files with 88 additions and 11020 deletions
|
@ -830,7 +830,6 @@ katie_generate_obsolete(QMutableVectorIterator QtCore qvector.h)
|
|||
katie_generate_obsolete(QMutexLocker QtCore qmutex.h)
|
||||
katie_generate_obsolete(QNetworkAddressEntry QtNetwork qnetworkinterface.h)
|
||||
katie_generate_obsolete(QNetworkCacheMetaData QtNetwork qabstractnetworkcache.h)
|
||||
katie_generate_obsolete(QNetworkConfigurationManager QtNetwork qnetworkconfigmanager.h)
|
||||
katie_generate_obsolete(QNetworkProxyFactory QtNetwork qnetworkproxy.h)
|
||||
katie_generate_obsolete(QNetworkProxyQuery QtNetwork qnetworkproxy.h)
|
||||
katie_generate_obsolete(QNoDebug QtCore qdebug.h)
|
||||
|
|
1
README
1
README
|
@ -46,6 +46,7 @@ There are several things you should be aware before considering Katie:
|
|||
- dropped Valgrind support
|
||||
- dropped recursive mutex and lock support
|
||||
- dropped wide character and string support
|
||||
- dropped network interfaces management support
|
||||
|
||||
- some additions have been made:
|
||||
- JSON document handler
|
||||
|
|
|
@ -1212,8 +1212,6 @@ include/katie/QtNetwork/QLocalSocket
|
|||
include/katie/QtNetwork/QNetworkAccessManager
|
||||
include/katie/QtNetwork/QNetworkAddressEntry
|
||||
include/katie/QtNetwork/QNetworkCacheMetaData
|
||||
include/katie/QtNetwork/QNetworkConfiguration
|
||||
include/katie/QtNetwork/QNetworkConfigurationManager
|
||||
include/katie/QtNetwork/QNetworkCookie
|
||||
include/katie/QtNetwork/QNetworkCookieJar
|
||||
include/katie/QtNetwork/QNetworkDiskCache
|
||||
|
@ -1223,7 +1221,6 @@ include/katie/QtNetwork/QNetworkProxyFactory
|
|||
include/katie/QtNetwork/QNetworkProxyQuery
|
||||
include/katie/QtNetwork/QNetworkReply
|
||||
include/katie/QtNetwork/QNetworkRequest
|
||||
include/katie/QtNetwork/QNetworkSession
|
||||
include/katie/QtNetwork/QSsl
|
||||
include/katie/QtNetwork/QSslCertificate
|
||||
include/katie/QtNetwork/QSslCipher
|
||||
|
@ -1249,8 +1246,6 @@ include/katie/QtNetwork/qhttpmultipart.h
|
|||
include/katie/QtNetwork/qlocalserver.h
|
||||
include/katie/QtNetwork/qlocalsocket.h
|
||||
include/katie/QtNetwork/qnetworkaccessmanager.h
|
||||
include/katie/QtNetwork/qnetworkconfigmanager.h
|
||||
include/katie/QtNetwork/qnetworkconfiguration.h
|
||||
include/katie/QtNetwork/qnetworkcookie.h
|
||||
include/katie/QtNetwork/qnetworkcookiejar.h
|
||||
include/katie/QtNetwork/qnetworkdiskcache.h
|
||||
|
@ -1258,7 +1253,6 @@ include/katie/QtNetwork/qnetworkinterface.h
|
|||
include/katie/QtNetwork/qnetworkproxy.h
|
||||
include/katie/QtNetwork/qnetworkreply.h
|
||||
include/katie/QtNetwork/qnetworkrequest.h
|
||||
include/katie/QtNetwork/qnetworksession.h
|
||||
include/katie/QtNetwork/qssl.h
|
||||
include/katie/QtNetwork/qsslcertificate.h
|
||||
include/katie/QtNetwork/qsslcipher.h
|
||||
|
@ -1457,7 +1451,6 @@ lib/katie/imports/Qt/labs/gestures/qmldir
|
|||
lib/katie/imports/Qt/labs/particles/libqmlparticlesplugin.so
|
||||
lib/katie/imports/Qt/labs/particles/qmldir
|
||||
lib/katie/plugins/accessible/libqtaccessiblewidgets.so
|
||||
lib/katie/plugins/bearer/libqgenericbearer.so
|
||||
lib/katie/plugins/designer/libqdeclarativeview.so
|
||||
lib/katie/plugins/iconengines/libqsvgicon.so
|
||||
lib/katie/plugins/imageformats/libqgif.so
|
||||
|
|
|
@ -1215,8 +1215,6 @@ include/katie/QtNetwork/QLocalSocket
|
|||
include/katie/QtNetwork/QNetworkAccessManager
|
||||
include/katie/QtNetwork/QNetworkAddressEntry
|
||||
include/katie/QtNetwork/QNetworkCacheMetaData
|
||||
include/katie/QtNetwork/QNetworkConfiguration
|
||||
include/katie/QtNetwork/QNetworkConfigurationManager
|
||||
include/katie/QtNetwork/QNetworkCookie
|
||||
include/katie/QtNetwork/QNetworkCookieJar
|
||||
include/katie/QtNetwork/QNetworkDiskCache
|
||||
|
@ -1226,7 +1224,6 @@ include/katie/QtNetwork/QNetworkProxyFactory
|
|||
include/katie/QtNetwork/QNetworkProxyQuery
|
||||
include/katie/QtNetwork/QNetworkReply
|
||||
include/katie/QtNetwork/QNetworkRequest
|
||||
include/katie/QtNetwork/QNetworkSession
|
||||
include/katie/QtNetwork/QSsl
|
||||
include/katie/QtNetwork/QSslCertificate
|
||||
include/katie/QtNetwork/QSslCipher
|
||||
|
@ -1252,8 +1249,6 @@ include/katie/QtNetwork/qhttpmultipart.h
|
|||
include/katie/QtNetwork/qlocalserver.h
|
||||
include/katie/QtNetwork/qlocalsocket.h
|
||||
include/katie/QtNetwork/qnetworkaccessmanager.h
|
||||
include/katie/QtNetwork/qnetworkconfigmanager.h
|
||||
include/katie/QtNetwork/qnetworkconfiguration.h
|
||||
include/katie/QtNetwork/qnetworkcookie.h
|
||||
include/katie/QtNetwork/qnetworkcookiejar.h
|
||||
include/katie/QtNetwork/qnetworkdiskcache.h
|
||||
|
@ -1261,7 +1256,6 @@ include/katie/QtNetwork/qnetworkinterface.h
|
|||
include/katie/QtNetwork/qnetworkproxy.h
|
||||
include/katie/QtNetwork/qnetworkreply.h
|
||||
include/katie/QtNetwork/qnetworkrequest.h
|
||||
include/katie/QtNetwork/qnetworksession.h
|
||||
include/katie/QtNetwork/qssl.h
|
||||
include/katie/QtNetwork/qsslcertificate.h
|
||||
include/katie/QtNetwork/qsslcipher.h
|
||||
|
@ -1460,7 +1454,6 @@ lib/katie/imports/Qt/labs/gestures/qmldir
|
|||
lib/katie/imports/Qt/labs/particles/libqmlparticlesplugin.so
|
||||
lib/katie/imports/Qt/labs/particles/qmldir
|
||||
lib/katie/plugins/accessible/libqtaccessiblewidgets.so
|
||||
lib/katie/plugins/bearer/libqgenericbearer.so
|
||||
lib/katie/plugins/designer/libqdeclarativeview.so
|
||||
lib/katie/plugins/iconengines/libqsvgicon.so
|
||||
lib/katie/plugins/imageformats/libqgif.so
|
|
@ -1,3 +0,0 @@
|
|||
@comment $NetBSD$
|
||||
lib/katie/plugins/bearer/libqconnmanbearer.so
|
||||
lib/katie/plugins/bearer/libqnmbearer.so
|
|
@ -1221,8 +1221,6 @@ include/katie/QtNetwork/QLocalSocket
|
|||
include/katie/QtNetwork/QNetworkAccessManager
|
||||
include/katie/QtNetwork/QNetworkAddressEntry
|
||||
include/katie/QtNetwork/QNetworkCacheMetaData
|
||||
include/katie/QtNetwork/QNetworkConfiguration
|
||||
include/katie/QtNetwork/QNetworkConfigurationManager
|
||||
include/katie/QtNetwork/QNetworkCookie
|
||||
include/katie/QtNetwork/QNetworkCookieJar
|
||||
include/katie/QtNetwork/QNetworkDiskCache
|
||||
|
@ -1232,7 +1230,6 @@ include/katie/QtNetwork/QNetworkProxyFactory
|
|||
include/katie/QtNetwork/QNetworkProxyQuery
|
||||
include/katie/QtNetwork/QNetworkReply
|
||||
include/katie/QtNetwork/QNetworkRequest
|
||||
include/katie/QtNetwork/QNetworkSession
|
||||
include/katie/QtNetwork/QSsl
|
||||
include/katie/QtNetwork/QSslCertificate
|
||||
include/katie/QtNetwork/QSslCipher
|
||||
|
@ -1258,8 +1255,6 @@ include/katie/QtNetwork/qhttpmultipart.h
|
|||
include/katie/QtNetwork/qlocalserver.h
|
||||
include/katie/QtNetwork/qlocalsocket.h
|
||||
include/katie/QtNetwork/qnetworkaccessmanager.h
|
||||
include/katie/QtNetwork/qnetworkconfigmanager.h
|
||||
include/katie/QtNetwork/qnetworkconfiguration.h
|
||||
include/katie/QtNetwork/qnetworkcookie.h
|
||||
include/katie/QtNetwork/qnetworkcookiejar.h
|
||||
include/katie/QtNetwork/qnetworkdiskcache.h
|
||||
|
@ -1267,7 +1262,6 @@ include/katie/QtNetwork/qnetworkinterface.h
|
|||
include/katie/QtNetwork/qnetworkproxy.h
|
||||
include/katie/QtNetwork/qnetworkreply.h
|
||||
include/katie/QtNetwork/qnetworkrequest.h
|
||||
include/katie/QtNetwork/qnetworksession.h
|
||||
include/katie/QtNetwork/qssl.h
|
||||
include/katie/QtNetwork/qsslcertificate.h
|
||||
include/katie/QtNetwork/qsslcipher.h
|
||||
|
@ -1483,8 +1477,6 @@ lib/katie/imports/Qt/labs/particles/qmldir
|
|||
lib/katie/plugins/
|
||||
lib/katie/plugins/accessible/
|
||||
@so lib/katie/plugins/accessible/libqtaccessiblewidgets.so
|
||||
lib/katie/plugins/bearer/
|
||||
@so lib/katie/plugins/bearer/libqgenericbearer.so
|
||||
lib/katie/plugins/designer/
|
||||
@so lib/katie/plugins/designer/libqdeclarativeview.so
|
||||
lib/katie/plugins/iconengines/
|
||||
|
|
|
@ -377,7 +377,6 @@ incmap = {
|
|||
'QIPv6Address': 'qhostaddress.h',
|
||||
'QNetworkAddressEntry': 'qnetworkinterface.h',
|
||||
'QNetworkCacheMetaData': 'qabstractnetworkcache.h',
|
||||
'QNetworkConfigurationManager': 'qnetworkconfigmanager.h',
|
||||
'QNetworkProxyFactory': 'qnetworkproxy.h',
|
||||
'QNetworkProxyQuery': 'qnetworkproxy.h',
|
||||
'Q_IPV6ADDR': 'qhostaddress.h',
|
||||
|
|
|
@ -443,8 +443,6 @@ classlist = [
|
|||
"QNetworkAccessManager",
|
||||
"QNetworkAddressEntry",
|
||||
"QNetworkCacheMetaData",
|
||||
"QNetworkConfiguration",
|
||||
"QNetworkConfigurationManager",
|
||||
"QNetworkCookie",
|
||||
"QNetworkCookieJar",
|
||||
"QNetworkDiskCache",
|
||||
|
@ -454,7 +452,6 @@ classlist = [
|
|||
"QNetworkProxyQuery",
|
||||
"QNetworkReply",
|
||||
"QNetworkRequest",
|
||||
"QNetworkSession",
|
||||
"QNoDebug",
|
||||
"QObject",
|
||||
"QObjectCleanupHandler",
|
||||
|
|
|
@ -101,6 +101,7 @@
|
|||
#define QT_NO_TEXTCODECPLUGIN
|
||||
#define QT_NO_SYSTEMLOCALE
|
||||
#define QT_NO_STL_WCHAR
|
||||
#define QT_NO_BEARERMANAGEMENT
|
||||
|
||||
// Not supported, used to bootstrap
|
||||
#cmakedefine QT_NO_QOBJECT
|
||||
|
@ -148,7 +149,6 @@
|
|||
#cmakedefine QT_NO_ACTION
|
||||
#cmakedefine QT_NO_ANIMATION
|
||||
#cmakedefine QT_NO_BACKINGSTORE
|
||||
#cmakedefine QT_NO_BEARERMANAGEMENT
|
||||
#cmakedefine QT_NO_BUTTONGROUP
|
||||
#cmakedefine QT_NO_CALENDARWIDGET
|
||||
#cmakedefine QT_NO_CAST_FROM_ASCII
|
||||
|
@ -404,11 +404,6 @@
|
|||
# define QT_NO_XMLSTREAMWRITER
|
||||
#endif
|
||||
|
||||
// Bearer Management
|
||||
#if !defined(QT_NO_BEARERMANAGEMENT) && defined(QT_NO_LIBRARY)
|
||||
# define QT_NO_BEARERMANAGEMENT
|
||||
#endif
|
||||
|
||||
// Context menu
|
||||
#if !defined(QT_NO_CONTEXTMENU) && defined(QT_NO_MENU)
|
||||
# define QT_NO_CONTEXTMENU
|
||||
|
|
|
@ -16,7 +16,6 @@ set(NETWORK_PUBLIC_HEADERS
|
|||
QLocalServer
|
||||
QLocalSocket
|
||||
QNetworkAccessManager
|
||||
QNetworkConfiguration
|
||||
QNetworkCookie
|
||||
QNetworkCookieJar
|
||||
QNetworkDiskCache
|
||||
|
@ -24,7 +23,6 @@ set(NETWORK_PUBLIC_HEADERS
|
|||
QNetworkProxy
|
||||
QNetworkReply
|
||||
QNetworkRequest
|
||||
QNetworkSession
|
||||
QSsl
|
||||
QSslCertificate
|
||||
QSslCipher
|
||||
|
@ -85,15 +83,6 @@ set(NETWORK_HEADERS
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/access/qhttpthreaddelegate_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/access/qhttpmultipart.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/access/qhttpmultipart_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworkconfiguration.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworksession.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworkconfigmanager.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworkconfigmanager_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworkconfiguration_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworksession_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qbearerengine_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qbearerplugin_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qsharednetworksession_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/qauthenticator.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/qauthenticator_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/qcryptographichash.h
|
||||
|
@ -163,13 +152,6 @@ set(NETWORK_SOURCES
|
|||
${CMAKE_CURRENT_SOURCE_DIR}/access/qnetworkdiskcache.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/access/qhttpthreaddelegate.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/access/qhttpmultipart.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworksession.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworkconfigmanager.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworkconfiguration.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworkconfigmanager_p.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qbearerengine.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qbearerplugin.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qsharednetworksession.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/qauthenticator.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/qcryptographichash.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/kernel/qhostaddress.cpp
|
||||
|
|
|
@ -301,10 +301,6 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port)
|
|||
socket = 0;
|
||||
}
|
||||
socket = new QTcpSocket(this);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the socket
|
||||
socket->setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
socket->setObjectName(QLatin1String("QFtpDTP Passive state socket"));
|
||||
connect(socket, SIGNAL(connected()), SLOT(socketConnected()));
|
||||
connect(socket, SIGNAL(readyRead()), SLOT(socketReadyRead()));
|
||||
|
@ -317,10 +313,6 @@ void QFtpDTP::connectToHost(const QString & host, quint16 port)
|
|||
|
||||
int QFtpDTP::setupListener(const QHostAddress &address)
|
||||
{
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the socket
|
||||
listener.setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
if (!listener.isListening() && !listener.listen(address, 0))
|
||||
return -1;
|
||||
return listener.serverPort();
|
||||
|
@ -831,11 +823,6 @@ QFtpPI::QFtpPI(QObject *parent) :
|
|||
void QFtpPI::connectToHost(const QString &host, quint16 port)
|
||||
{
|
||||
emit connectState(QFtp::HostLookup);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the socket & DTP
|
||||
commandSocket.setProperty("_q_networksession", property("_q_networksession"));
|
||||
dtp.setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
commandSocket.connectToHost(host, port);
|
||||
}
|
||||
|
||||
|
@ -2234,10 +2221,6 @@ void QFtpPrivate::_q_startNextCommand()
|
|||
c->rawCmds.clear();
|
||||
_q_piFinished(QLatin1String("Proxy set to ") + proxyHost + QLatin1Char(':') + QString::number(proxyPort));
|
||||
} else if (c->command == QFtp::ConnectToHost) {
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the PI
|
||||
pi.setProperty("_q_networksession", q->property("_q_networksession"));
|
||||
#endif
|
||||
if (!proxyHost.isEmpty()) {
|
||||
host = c->rawCmds[0];
|
||||
port = c->rawCmds[1].toUInt();
|
||||
|
|
|
@ -93,10 +93,6 @@ void QHttpNetworkConnectionPrivate::init()
|
|||
for (int i = 0; i < channelCount; i++) {
|
||||
channels[i].setConnection(this->q_func());
|
||||
channels[i].ssl = encrypt;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//push session down to channels
|
||||
channels[i].networkSession = networkSession;
|
||||
#endif
|
||||
channels[i].init();
|
||||
}
|
||||
}
|
||||
|
@ -840,23 +836,6 @@ void QHttpNetworkConnectionPrivate::readMoreLater(QHttpNetworkReply *reply)
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, QObject *parent, QSharedPointer<QNetworkSession> networkSession)
|
||||
: QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt)), parent)
|
||||
{
|
||||
Q_D(QHttpNetworkConnection);
|
||||
d->networkSession = networkSession;
|
||||
d->init();
|
||||
}
|
||||
|
||||
QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QString &hostName, quint16 port, bool encrypt, QObject *parent, QSharedPointer<QNetworkSession> networkSession)
|
||||
: QObject(*(new QHttpNetworkConnectionPrivate(connectionCount, hostName, port, encrypt)), parent)
|
||||
{
|
||||
Q_D(QHttpNetworkConnection);
|
||||
d->networkSession = networkSession;
|
||||
d->init();
|
||||
}
|
||||
#else
|
||||
QHttpNetworkConnection::QHttpNetworkConnection(const QString &hostName, quint16 port, bool encrypt, QObject *parent)
|
||||
: QObject(*(new QHttpNetworkConnectionPrivate(hostName, port, encrypt)), parent)
|
||||
{
|
||||
|
@ -870,7 +849,6 @@ QHttpNetworkConnection::QHttpNetworkConnection(quint16 connectionCount, const QS
|
|||
Q_D(QHttpNetworkConnection);
|
||||
d->init();
|
||||
}
|
||||
#endif
|
||||
|
||||
QHttpNetworkConnection::~QHttpNetworkConnection()
|
||||
{
|
||||
|
|
|
@ -35,7 +35,6 @@
|
|||
#include <QtNetwork/qnetworkrequest.h>
|
||||
#include <QtNetwork/qnetworkreply.h>
|
||||
#include <QtNetwork/qabstractsocket.h>
|
||||
#include <QtNetwork/qnetworksession.h>
|
||||
#include <QtNetwork/qsslsocket.h>
|
||||
#include <QtNetwork/qsslerror.h>
|
||||
|
||||
|
@ -47,7 +46,6 @@
|
|||
#include "qhttpnetworkheader_p.h"
|
||||
#include "qhttpnetworkrequest_p.h"
|
||||
#include "qhttpnetworkreply_p.h"
|
||||
|
||||
#include "qhttpnetworkconnectionchannel_p.h"
|
||||
|
||||
#ifndef QT_NO_HTTP
|
||||
|
@ -64,13 +62,8 @@ class Q_AUTOTEST_EXPORT QHttpNetworkConnection : public QObject
|
|||
Q_OBJECT
|
||||
public:
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QHttpNetworkConnection(const QString &hostName, quint16 port = 80, bool encrypt = false, QObject *parent = nullptr, QSharedPointer<QNetworkSession> networkSession = QSharedPointer<QNetworkSession>());
|
||||
QHttpNetworkConnection(quint16 channelCount, const QString &hostName, quint16 port = 80, bool encrypt = false, QObject *parent = nullptr, QSharedPointer<QNetworkSession> networkSession = QSharedPointer<QNetworkSession>());
|
||||
#else
|
||||
QHttpNetworkConnection(const QString &hostName, quint16 port = 80, bool encrypt = false, QObject *parent = nullptr);
|
||||
QHttpNetworkConnection(quint16 channelCount, const QString &hostName, quint16 port = 80, bool encrypt = false, QObject *parent = nullptr);
|
||||
#endif
|
||||
~QHttpNetworkConnection();
|
||||
|
||||
//The hostname to which this is connected to.
|
||||
|
@ -186,10 +179,6 @@ public:
|
|||
QList<HttpMessagePair> highPriorityQueue;
|
||||
QList<HttpMessagePair> lowPriorityQueue;
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QSharedPointer<QNetworkSession> networkSession;
|
||||
#endif
|
||||
|
||||
friend class QHttpNetworkConnectionChannel;
|
||||
};
|
||||
|
||||
|
|
|
@ -30,10 +30,6 @@
|
|||
|
||||
#ifndef QT_NO_HTTP
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#include "qnetworksession_p.h"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// TODO: Put channel specific stuff here so it does not polute qhttpnetworkconnection.cpp
|
||||
|
@ -67,11 +63,6 @@ void QHttpNetworkConnectionChannel::init()
|
|||
socket = new QSslSocket;
|
||||
else
|
||||
socket = new QTcpSocket;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//push session down to socket
|
||||
if (networkSession)
|
||||
socket->setProperty("_q_networksession", QVariant::fromValue(networkSession));
|
||||
#endif
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
// Set by QNAM anyway, but let's be safe here
|
||||
socket->setProxy(QNetworkProxy::NoProxy);
|
||||
|
|
|
@ -92,9 +92,6 @@ public:
|
|||
bool proxyCredentialsSent;
|
||||
bool ignoreAllSslErrors;
|
||||
QList<QSslError> ignoreSslErrorsList;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QSharedPointer<QNetworkSession> networkSession;
|
||||
#endif
|
||||
|
||||
// HTTP pipelining -> http://en.wikipedia.org/wiki/Http_pipelining
|
||||
enum PipeliningSupport {
|
||||
|
|
|
@ -131,13 +131,8 @@ class QNetworkAccessCachedHttpConnection: public QHttpNetworkConnection,
|
|||
{
|
||||
// Q_OBJECT
|
||||
public:
|
||||
#ifdef QT_NO_BEARERMANAGEMENT
|
||||
QNetworkAccessCachedHttpConnection(const QString &hostName, quint16 port, bool encrypt)
|
||||
: QHttpNetworkConnection(hostName, port, encrypt)
|
||||
#else
|
||||
QNetworkAccessCachedHttpConnection(const QString &hostName, quint16 port, bool encrypt, QSharedPointer<QNetworkSession> networkSession)
|
||||
: QHttpNetworkConnection(hostName, port, encrypt, /*parent=*/0, networkSession)
|
||||
#endif
|
||||
{
|
||||
setExpires(true);
|
||||
setShareable(true);
|
||||
|
@ -246,11 +241,7 @@ void QHttpThreadDelegate::startRequest()
|
|||
if (httpConnection == 0) {
|
||||
// no entry in cache; create an object
|
||||
// the http object is actually a QHttpNetworkConnection
|
||||
#ifdef QT_NO_BEARERMANAGEMENT
|
||||
httpConnection = new QNetworkAccessCachedHttpConnection(urlCopy.host(), urlCopy.port(), ssl);
|
||||
#else
|
||||
httpConnection = new QNetworkAccessCachedHttpConnection(urlCopy.host(), urlCopy.port(), ssl, networkSession);
|
||||
#endif
|
||||
// Set the QSslConfiguration from this QNetworkRequest.
|
||||
if (ssl && incomingSslConfiguration != QSslConfiguration::defaultConfiguration()) {
|
||||
httpConnection->setSslConfiguration(incomingSslConfiguration);
|
||||
|
|
|
@ -91,9 +91,6 @@ public:
|
|||
qint64 incomingContentLength;
|
||||
QNetworkReply::NetworkError incomingErrorCode;
|
||||
QString incomingErrorDetail;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QSharedPointer<QNetworkSession> networkSession;
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// The zerocopy download buffer, if used:
|
||||
|
|
|
@ -21,13 +21,11 @@
|
|||
|
||||
#include "qnetworkaccessbackend_p.h"
|
||||
#include "qnetworkaccessmanager_p.h"
|
||||
#include "qnetworkconfigmanager.h"
|
||||
#include "qnetworkrequest.h"
|
||||
#include "qnetworkreply.h"
|
||||
#include "qnetworkreply_p.h"
|
||||
#include "qhash.h"
|
||||
#include "qmutex.h"
|
||||
#include "qnetworksession_p.h"
|
||||
#include "qnetworkaccesscachebackend_p.h"
|
||||
#include "qabstractnetworkcache.h"
|
||||
#include "qhostinfo.h"
|
||||
|
@ -342,58 +340,9 @@ void QNetworkAccessBackend::sslErrors(const QList<QSslError> &errors)
|
|||
*/
|
||||
bool QNetworkAccessBackend::start()
|
||||
{
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
// For bearer, check if session start is required
|
||||
QSharedPointer<QNetworkSession> networkSession(manager->getNetworkSession());
|
||||
if (networkSession) {
|
||||
// session required
|
||||
if (networkSession->isOpen() &&
|
||||
networkSession->state() == QNetworkSession::Connected) {
|
||||
// Session is already open and ready to use.
|
||||
// copy network session down to the backend
|
||||
setProperty("_q_networksession", QVariant::fromValue(networkSession));
|
||||
} else {
|
||||
// Session not ready, but can skip for loopback connections
|
||||
|
||||
// This is not ideal.
|
||||
const QString host = reply->url.host();
|
||||
|
||||
if (host == QLatin1String("localhost") ||
|
||||
QHostAddress(host) == QHostAddress::LocalHost ||
|
||||
QHostAddress(host) == QHostAddress::LocalHostIPv6) {
|
||||
// Don't need an open session for localhost access.
|
||||
} else {
|
||||
// need to wait for session to be opened
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
// Get the proxy settings from the network session (in the case of service networks,
|
||||
// the proxy settings change depending which AP was activated)
|
||||
QNetworkSession *session = networkSession.data();
|
||||
QNetworkConfiguration config;
|
||||
if (session) {
|
||||
QNetworkConfigurationManager configManager;
|
||||
// The active configuration tells us what IAP is in use
|
||||
QVariant v = session->sessionProperty(QLatin1String("ActiveConfiguration"));
|
||||
if (v.isValid())
|
||||
config = configManager.configurationFromIdentifier(qvariant_cast<QString>(v));
|
||||
// Fallback to using the configuration if no active configuration
|
||||
if (!config.isValid())
|
||||
config = session->configuration();
|
||||
// or unspecified configuration if that is no good either
|
||||
if (!config.isValid())
|
||||
config = QNetworkConfiguration();
|
||||
}
|
||||
reply->proxyList = manager->queryProxy(QNetworkProxyQuery(config, url()));
|
||||
#else // QT_NO_BEARERMANAGEMENT
|
||||
// Without bearer management, the proxy depends only on the url
|
||||
// the proxy depends only on the url
|
||||
reply->proxyList = manager->queryProxy(QNetworkProxyQuery(url()));
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// now start the request
|
||||
|
|
|
@ -136,10 +136,6 @@ void QNetworkAccessFtpBackend::open()
|
|||
if (!objectCache->requestEntry(cacheKey, this,
|
||||
SLOT(ftpConnectionReady(QNetworkAccessCache::CacheableObject*)))) {
|
||||
ftp = new QNetworkAccessCachedFtpConnection;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the QFtp
|
||||
ftp->setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
if (proxy.type() == QNetworkProxy::FtpCachingProxy)
|
||||
ftp->setProxy(proxy.hostName(), proxy.port());
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#include "qabstractnetworkcache.h"
|
||||
#include "qnetworkrequest.h"
|
||||
#include "qnetworkreply.h"
|
||||
#include "qnetworksession_p.h"
|
||||
#include "qnetworkrequest_p.h"
|
||||
#include "qnetworkcookie_p.h"
|
||||
#include "qdatetime.h"
|
||||
|
@ -496,11 +495,6 @@ void QNetworkAccessHttpBackend::postRequest()
|
|||
|
||||
// Create the HTTP thread delegate
|
||||
QHttpThreadDelegate *delegate = new QHttpThreadDelegate;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QVariant v(property("_q_networksession"));
|
||||
if (v.isValid())
|
||||
delegate->networkSession = qvariant_cast<QSharedPointer<QNetworkSession> >(v);
|
||||
#endif
|
||||
|
||||
// For the synchronous HTTP, this is the normal way the delegate gets deleted
|
||||
// For the asynchronous HTTP this is a safety measure, the delegate deletes itself when HTTP is finished
|
||||
|
|
|
@ -26,9 +26,7 @@
|
|||
#include "qnetworkreply_p.h"
|
||||
#include "qnetworkcookie.h"
|
||||
#include "qabstractnetworkcache.h"
|
||||
#include "qnetworksession.h"
|
||||
#include "qnetworkcookiejar.h"
|
||||
#include "qsharednetworksession_p.h"
|
||||
#include "qnetworkaccesshttpbackend_p.h"
|
||||
#include "qnetworkaccessftpbackend_p.h"
|
||||
#include "qnetworkaccessfilebackend_p.h"
|
||||
|
@ -41,7 +39,6 @@
|
|||
#include "qvector.h"
|
||||
#include "qauthenticator_p.h"
|
||||
#include "qsslconfiguration.h"
|
||||
#include "qnetworkconfigmanager.h"
|
||||
#include "qhttpmultipart.h"
|
||||
#include "qhttpmultipart_p.h"
|
||||
#include "qthread.h"
|
||||
|
@ -123,32 +120,6 @@ static void ensureInitialized()
|
|||
can be:
|
||||
\snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 1
|
||||
|
||||
\section1 Network and Roaming support
|
||||
|
||||
With the addition of the \l {Bearer Management} API to Qt 4.7
|
||||
QNetworkAccessManager gained the ability to manage network connections.
|
||||
QNetworkAccessManager can start the network interface if the device is
|
||||
offline and terminates the interface if the current process is the last
|
||||
one to use the uplink. Note that some platform utilize grace periods from
|
||||
when the last application stops using a uplink until the system actually
|
||||
terminates the connectivity link. Roaming is equally transparent. Any
|
||||
queued/pending network requests are automatically transferred to new
|
||||
access point.
|
||||
|
||||
Clients wanting to utilize this feature should not require any changes. In fact
|
||||
it is likely that existing platform specific connection code can simply be
|
||||
removed from the application.
|
||||
|
||||
\note The network and roaming support in QNetworkAccessManager is conditional
|
||||
upon the platform supporting connection management. The
|
||||
\l QNetworkConfigurationManager::NetworkSessionRequired can be used to
|
||||
detect whether QNetworkAccessManager utilizes this feature. Currently only
|
||||
Meego/Harmattan and Symbian platforms provide connection management support.
|
||||
|
||||
\note This feature cannot be used in combination with the Bearer Management
|
||||
API as provided by QtMobility. Applications have to migrate to the Qt version
|
||||
of Bearer Management.
|
||||
|
||||
\sa QNetworkRequest, QNetworkReply, QNetworkProxy
|
||||
*/
|
||||
|
||||
|
@ -697,136 +668,6 @@ QNetworkReply *QNetworkAccessManager::deleteResource(const QNetworkRequest &requ
|
|||
return d_func()->postProcess(createRequest(QNetworkAccessManager::DeleteOperation, request));
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
/*!
|
||||
\since 4.7
|
||||
|
||||
Sets the network configuration that will be used when creating the
|
||||
\l {QNetworkSession}{network session} to \a config.
|
||||
|
||||
The network configuration is used to create and open a network session before any request that
|
||||
requires network access is process. If no network configuration is explicitly set via this
|
||||
function the network configuration returned by
|
||||
QNetworkConfigurationManager::defaultConfiguration() will be used.
|
||||
|
||||
To restore the default network configuration set the network configuration to the value
|
||||
returned from QNetworkConfigurationManager::defaultConfiguration().
|
||||
|
||||
\snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 2
|
||||
|
||||
If an invalid network configuration is set, a network session will not be created. In this
|
||||
case network requests will be processed regardless, but may fail. For example:
|
||||
|
||||
\snippet doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp 3
|
||||
|
||||
\sa configuration(), QNetworkSession
|
||||
*/
|
||||
void QNetworkAccessManager::setConfiguration(const QNetworkConfiguration &config)
|
||||
{
|
||||
d_func()->createSession(config);
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.7
|
||||
|
||||
Returns the network configuration that will be used to create the
|
||||
\l {QNetworkSession}{network session} which will be used when processing network requests.
|
||||
|
||||
\sa setConfiguration(), activeConfiguration()
|
||||
*/
|
||||
QNetworkConfiguration QNetworkAccessManager::configuration() const
|
||||
{
|
||||
Q_D(const QNetworkAccessManager);
|
||||
|
||||
QSharedPointer<QNetworkSession> session(d->getNetworkSession());
|
||||
if (session)
|
||||
return session->configuration();
|
||||
else
|
||||
return QNetworkConfiguration();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.7
|
||||
|
||||
Returns the current active network configuration.
|
||||
|
||||
If the network configuration returned by configuration() is of type
|
||||
QNetworkConfiguration::ServiceNetwork this function will return the current active child
|
||||
network configuration of that configuration. Otherwise returns the same network configuration
|
||||
as configuration().
|
||||
|
||||
Use this function to return the actual network configuration currently in use by the network
|
||||
session.
|
||||
|
||||
\sa configuration()
|
||||
*/
|
||||
QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const
|
||||
{
|
||||
Q_D(const QNetworkAccessManager);
|
||||
|
||||
QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession());
|
||||
if (networkSession) {
|
||||
QNetworkConfigurationManager manager;
|
||||
|
||||
return manager.configurationFromIdentifier(
|
||||
networkSession->sessionProperty(QLatin1String("ActiveConfiguration")).toString());
|
||||
} else {
|
||||
return QNetworkConfiguration();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.7
|
||||
|
||||
Overrides the reported network accessibility. If \a accessible is NotAccessible the reported
|
||||
network accessiblity will always be NotAccessible. Otherwise the reported network
|
||||
accessibility will reflect the actual device state.
|
||||
*/
|
||||
void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkAccessibility accessible)
|
||||
{
|
||||
Q_D(QNetworkAccessManager);
|
||||
|
||||
if (d->networkAccessible != accessible) {
|
||||
NetworkAccessibility previous = networkAccessible();
|
||||
d->networkAccessible = accessible;
|
||||
NetworkAccessibility current = networkAccessible();
|
||||
if (previous != current)
|
||||
emit networkAccessibleChanged(current);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.7
|
||||
|
||||
Returns the current network accessibility.
|
||||
*/
|
||||
QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccessible() const
|
||||
{
|
||||
Q_D(const QNetworkAccessManager);
|
||||
|
||||
QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession());
|
||||
if (networkSession) {
|
||||
// d->online holds online/offline state of this network session.
|
||||
if (d->online)
|
||||
return d->networkAccessible;
|
||||
else
|
||||
return NotAccessible;
|
||||
} else {
|
||||
// Network accessibility is either disabled or unknown.
|
||||
return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility;
|
||||
}
|
||||
}
|
||||
|
||||
QSharedPointer<QNetworkSession> QNetworkAccessManagerPrivate::getNetworkSession() const
|
||||
{
|
||||
if (networkSessionStrongRef)
|
||||
return networkSessionStrongRef;
|
||||
return networkSessionWeakRef.toStrongRef();
|
||||
}
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
/*!
|
||||
\since 4.7
|
||||
|
||||
|
@ -887,7 +728,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|
|||
return new QNetworkReplyDataImpl(this, req, op);
|
||||
}
|
||||
|
||||
// A request with QNetworkRequest::AlwaysCache does not need any bearer management
|
||||
QNetworkRequest::CacheLoadControl mode =
|
||||
static_cast<QNetworkRequest::CacheLoadControl>(
|
||||
req.attribute(QNetworkRequest::CacheLoadControlAttribute,
|
||||
|
@ -907,26 +747,6 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|
|||
return reply;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
// Return a disabled network reply if network access is disabled.
|
||||
// Except if the scheme is empty or file://.
|
||||
if (!d->networkAccessible && !isLocalFile) {
|
||||
return new QDisabledNetworkReply(this, req, op);
|
||||
}
|
||||
|
||||
if (!d->networkSessionStrongRef && (d->initializeSession || !d->networkConfiguration.isEmpty())) {
|
||||
QNetworkConfigurationManager manager;
|
||||
if (!d->networkConfiguration.isEmpty()) {
|
||||
d->createSession(manager.configurationFromIdentifier(d->networkConfiguration));
|
||||
} else {
|
||||
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired)
|
||||
d->createSession(manager.defaultConfiguration());
|
||||
else
|
||||
d->initializeSession = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
QNetworkRequest request = req;
|
||||
if (!request.header(QNetworkRequest::ContentLengthHeader).isValid() &&
|
||||
outgoingData && !outgoingData->isSequential()) {
|
||||
|
@ -946,14 +766,7 @@ QNetworkReply *QNetworkAccessManager::createRequest(QNetworkAccessManager::Opera
|
|||
}
|
||||
|
||||
// first step: create the reply
|
||||
QUrl url = request.url();
|
||||
QNetworkReplyImpl *reply = new QNetworkReplyImpl(this);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
if (!isLocalFile) {
|
||||
connect(this, SIGNAL(networkSessionConnected()),
|
||||
reply, SLOT(_q_networkSessionConnected()));
|
||||
}
|
||||
#endif
|
||||
QNetworkReplyImplPrivate *priv = reply->d_func();
|
||||
priv->manager = this;
|
||||
|
||||
|
@ -984,15 +797,6 @@ void QNetworkAccessManagerPrivate::_q_replyFinished()
|
|||
QNetworkReply *reply = qobject_cast<QNetworkReply *>(q->sender());
|
||||
if (reply)
|
||||
emit q->finished(reply);
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
// If there are no active requests, release our reference to the network session.
|
||||
// It will not be destroyed immediately, but rather when the connection cache is flushed
|
||||
// after 2 minutes.
|
||||
activeReplyCount--;
|
||||
if (networkSessionStrongRef && activeReplyCount == 0)
|
||||
networkSessionStrongRef.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
void QNetworkAccessManagerPrivate::_q_replySslErrors(const QList<QSslError> &errors)
|
||||
|
@ -1009,10 +813,6 @@ QNetworkReply *QNetworkAccessManagerPrivate::postProcess(QNetworkReply *reply)
|
|||
QNetworkReplyPrivate::setManager(reply, q);
|
||||
q->connect(reply, SIGNAL(finished()), SLOT(_q_replyFinished()));
|
||||
q->connect(reply, SIGNAL(sslErrors(QList<QSslError>)), SLOT(_q_replySslErrors(QList<QSslError>)));
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
activeReplyCount++;
|
||||
#endif
|
||||
|
||||
return reply;
|
||||
}
|
||||
|
||||
|
@ -1144,97 +944,6 @@ QNetworkAccessManagerPrivate::~QNetworkAccessManagerPrivate()
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &config)
|
||||
{
|
||||
Q_Q(QNetworkAccessManager);
|
||||
|
||||
initializeSession = false;
|
||||
|
||||
//resurrect weak ref if possible
|
||||
networkSessionStrongRef = networkSessionWeakRef.toStrongRef();
|
||||
|
||||
QSharedPointer<QNetworkSession> newSession;
|
||||
if (config.isValid())
|
||||
newSession = QSharedNetworkSessionManager::getSession(config);
|
||||
|
||||
if (networkSessionStrongRef) {
|
||||
//do nothing if new and old session are the same
|
||||
if (networkSessionStrongRef == newSession)
|
||||
return;
|
||||
//disconnect from old session
|
||||
QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));
|
||||
QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));
|
||||
QObject::disconnect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)),
|
||||
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)));
|
||||
}
|
||||
|
||||
//switch to new session (null if config was invalid)
|
||||
networkSessionStrongRef = newSession;
|
||||
networkSessionWeakRef = networkSessionStrongRef.toWeakRef();
|
||||
|
||||
if (!networkSessionStrongRef) {
|
||||
online = false;
|
||||
|
||||
if (networkAccessible == QNetworkAccessManager::NotAccessible)
|
||||
emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible);
|
||||
else
|
||||
emit q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//connect to new session
|
||||
QObject::connect(networkSessionStrongRef.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()), Qt::QueuedConnection);
|
||||
//QueuedConnection is used to avoid deleting the networkSession inside its closed signal
|
||||
QObject::connect(networkSessionStrongRef.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()), Qt::QueuedConnection);
|
||||
QObject::connect(networkSessionStrongRef.data(), SIGNAL(stateChanged(QNetworkSession::State)),
|
||||
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)), Qt::QueuedConnection);
|
||||
|
||||
_q_networkSessionStateChanged(networkSessionStrongRef->state());
|
||||
}
|
||||
|
||||
void QNetworkAccessManagerPrivate::_q_networkSessionClosed()
|
||||
{
|
||||
Q_Q(QNetworkAccessManager);
|
||||
QSharedPointer<QNetworkSession> networkSession(getNetworkSession());
|
||||
if (networkSession) {
|
||||
networkConfiguration = networkSession->configuration().identifier();
|
||||
|
||||
//disconnect from old session
|
||||
QObject::disconnect(networkSession.data(), SIGNAL(opened()), q, SIGNAL(networkSessionConnected()));
|
||||
QObject::disconnect(networkSession.data(), SIGNAL(closed()), q, SLOT(_q_networkSessionClosed()));
|
||||
QObject::disconnect(networkSession.data(), SIGNAL(stateChanged(QNetworkSession::State)),
|
||||
q, SLOT(_q_networkSessionStateChanged(QNetworkSession::State)));
|
||||
networkSessionStrongRef.clear();
|
||||
networkSessionWeakRef.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession::State state)
|
||||
{
|
||||
Q_Q(QNetworkAccessManager);
|
||||
|
||||
//Do not emit the networkSessionConnected signal here, except for roaming -> connected
|
||||
//transition, otherwise it is emitted twice in a row when opening a connection.
|
||||
if (state == QNetworkSession::Connected && lastSessionState == QNetworkSession::Roaming)
|
||||
emit q->networkSessionConnected();
|
||||
lastSessionState = state;
|
||||
|
||||
if (online) {
|
||||
if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) {
|
||||
online = false;
|
||||
emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible);
|
||||
}
|
||||
} else {
|
||||
if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) {
|
||||
online = true;
|
||||
emit q->networkAccessibleChanged(networkAccessible);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QNetworkRequest QNetworkAccessManagerPrivate::prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart)
|
||||
{
|
||||
// copy the request, we probably need to add some headers
|
||||
|
|
|
@ -40,9 +40,6 @@ class QNetworkReply;
|
|||
class QNetworkProxy;
|
||||
class QNetworkProxyFactory;
|
||||
class QSslError;
|
||||
#if !defined(QT_NO_BEARERMANAGEMENT)
|
||||
class QNetworkConfiguration;
|
||||
#endif
|
||||
class QHttpMultiPart;
|
||||
|
||||
class QNetworkReplyImplPrivate;
|
||||
|
@ -51,10 +48,6 @@ class Q_NETWORK_EXPORT QNetworkAccessManager: public QObject
|
|||
{
|
||||
Q_OBJECT
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
Q_PROPERTY(NetworkAccessibility networkAccessible READ networkAccessible WRITE setNetworkAccessible NOTIFY networkAccessibleChanged)
|
||||
#endif
|
||||
|
||||
public:
|
||||
enum Operation {
|
||||
HeadOperation = 1,
|
||||
|
@ -67,14 +60,6 @@ public:
|
|||
UnknownOperation = 0
|
||||
};
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
enum NetworkAccessibility {
|
||||
UnknownAccessibility = -1,
|
||||
NotAccessible = 0,
|
||||
Accessible = 1
|
||||
};
|
||||
#endif
|
||||
|
||||
explicit QNetworkAccessManager(QObject *parent = nullptr);
|
||||
~QNetworkAccessManager();
|
||||
|
||||
|
@ -102,17 +87,6 @@ public:
|
|||
QNetworkReply *deleteResource(const QNetworkRequest &request);
|
||||
QNetworkReply *sendCustomRequest(const QNetworkRequest &request, const QByteArray &verb, QIODevice *data = 0);
|
||||
|
||||
#if !defined(QT_NO_BEARERMANAGEMENT)
|
||||
void setConfiguration(const QNetworkConfiguration &config);
|
||||
QNetworkConfiguration configuration() const;
|
||||
QNetworkConfiguration activeConfiguration() const;
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void setNetworkAccessible(NetworkAccessibility accessible);
|
||||
NetworkAccessibility networkAccessible() const;
|
||||
#endif
|
||||
|
||||
Q_SIGNALS:
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
void proxyAuthenticationRequired(const QNetworkProxy &proxy, QAuthenticator *authenticator);
|
||||
|
@ -121,14 +95,6 @@ Q_SIGNALS:
|
|||
void finished(QNetworkReply *reply);
|
||||
void sslErrors(QNetworkReply *reply, const QList<QSslError> &errors);
|
||||
|
||||
#if !defined(QT_NO_BEARERMANAGEMENT)
|
||||
void networkSessionConnected();
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility accessible);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual QNetworkReply *createRequest(Operation op, const QNetworkRequest &request,
|
||||
QIODevice *outgoingData = 0);
|
||||
|
@ -140,10 +106,6 @@ private:
|
|||
Q_DECLARE_PRIVATE(QNetworkAccessManager)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_replyFinished())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_replySslErrors(QList<QSslError>))
|
||||
#if !defined(QT_NO_BEARERMANAGEMENT)
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionClosed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionStateChanged(QNetworkSession::State))
|
||||
#endif
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include "qnetworkaccessbackend_p.h"
|
||||
#include "qobject_p.h"
|
||||
#include "QtNetwork/qnetworkproxy.h"
|
||||
#include "QtNetwork/qnetworksession.h"
|
||||
#include "qnetworkaccessauthenticationmanager_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
@ -58,13 +57,6 @@ public:
|
|||
#endif
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
proxyFactory(0),
|
||||
#endif
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
lastSessionState(QNetworkSession::Invalid),
|
||||
networkAccessible(QNetworkAccessManager::Accessible),
|
||||
activeReplyCount(0),
|
||||
online(false),
|
||||
initializeSession(true),
|
||||
#endif
|
||||
cookieJarCreated(false),
|
||||
authenticationManager(new QNetworkAccessAuthenticationManager)
|
||||
|
@ -92,17 +84,6 @@ public:
|
|||
|
||||
QNetworkAccessBackend *findBackend(QNetworkAccessManager::Operation op, const QNetworkRequest &request);
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void createSession(const QNetworkConfiguration &config);
|
||||
QSharedPointer<QNetworkSession> getNetworkSession() const;
|
||||
|
||||
void _q_networkSessionClosed();
|
||||
void _q_networkSessionNewConfigurationActivated();
|
||||
void _q_networkSessionPreferredConfigurationChanged(const QNetworkConfiguration &config,
|
||||
bool isSeamless);
|
||||
void _q_networkSessionStateChanged(QNetworkSession::State state);
|
||||
#endif
|
||||
|
||||
QNetworkRequest prepareMultipart(const QNetworkRequest &request, QHttpMultiPart *multiPart);
|
||||
|
||||
// this is the cache for storing downloaded files
|
||||
|
@ -119,17 +100,6 @@ public:
|
|||
QNetworkProxyFactory *proxyFactory;
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QSharedPointer<QNetworkSession> networkSessionStrongRef;
|
||||
QWeakPointer<QNetworkSession> networkSessionWeakRef;
|
||||
QNetworkSession::State lastSessionState;
|
||||
QString networkConfiguration;
|
||||
QNetworkAccessManager::NetworkAccessibility networkAccessible;
|
||||
int activeReplyCount;
|
||||
bool online;
|
||||
bool initializeSession;
|
||||
#endif
|
||||
|
||||
bool cookieJarCreated;
|
||||
|
||||
// The cache with authorization data:
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "QtCore/qcoreapplication.h"
|
||||
#include "QtCore/qdatetime.h"
|
||||
#include "QtNetwork/qsslconfiguration.h"
|
||||
#include "QtNetwork/qnetworksession.h"
|
||||
#include "QtNetwork/qnetworkcookiejar.h"
|
||||
#include "qnetworkaccesshttpbackend_p.h"
|
||||
#include "qnetworkaccessmanager_p.h"
|
||||
|
@ -71,36 +70,11 @@ void QNetworkReplyImplPrivate::_q_startOperation()
|
|||
}
|
||||
|
||||
if (!backend->start()) {
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
// backend failed to start because the session state is not Connected.
|
||||
// QNetworkAccessManager will call _q_startOperation again for us when the session
|
||||
// state changes.
|
||||
state = WaitingForSession;
|
||||
|
||||
QSharedPointer<QNetworkSession> session(manager->d_func()->getNetworkSession());
|
||||
|
||||
if (session) {
|
||||
Q_Q(QNetworkReplyImpl);
|
||||
|
||||
QObject::connect(session.data(), SIGNAL(error(QNetworkSession::SessionError)),
|
||||
q, SLOT(_q_networkSessionFailed()), Qt::QueuedConnection);
|
||||
|
||||
if (!session->isOpen())
|
||||
session->open();
|
||||
} else {
|
||||
qWarning("Backend is waiting for QNetworkSession to connect, but there is none!");
|
||||
state = Working;
|
||||
error(QNetworkReplyImpl::UnknownNetworkError,
|
||||
QCoreApplication::translate("QNetworkReply", "Network session error."));
|
||||
finished();
|
||||
}
|
||||
#else
|
||||
qWarning("Backend start failed");
|
||||
state = Working;
|
||||
error(QNetworkReplyImpl::UnknownNetworkError,
|
||||
QCoreApplication::translate("QNetworkReply", "backend start error."));
|
||||
finished();
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -240,54 +214,6 @@ void QNetworkReplyImplPrivate::_q_bufferOutgoingData()
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void QNetworkReplyImplPrivate::_q_networkSessionConnected()
|
||||
{
|
||||
Q_Q(QNetworkReplyImpl);
|
||||
|
||||
if (manager.isNull())
|
||||
return;
|
||||
|
||||
QSharedPointer<QNetworkSession> session = manager->d_func()->getNetworkSession();
|
||||
if (!session)
|
||||
return;
|
||||
|
||||
if (session->state() != QNetworkSession::Connected)
|
||||
return;
|
||||
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
// Re-set proxies here as new session might have changed them
|
||||
proxyList = manager->d_func()->queryProxy(QNetworkProxyQuery(request.url()));
|
||||
#endif
|
||||
|
||||
switch (state) {
|
||||
case QNetworkReplyImplPrivate::Buffering:
|
||||
case QNetworkReplyImplPrivate::Working:
|
||||
case QNetworkReplyImplPrivate::Reconnecting:
|
||||
// Migrate existing downloads to new network connection.
|
||||
migrateBackend();
|
||||
break;
|
||||
case QNetworkReplyImplPrivate::WaitingForSession:
|
||||
// Start waiting requests.
|
||||
QMetaObject::invokeMethod(q, "_q_startOperation", Qt::QueuedConnection);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkReplyImplPrivate::_q_networkSessionFailed()
|
||||
{
|
||||
// Abort waiting and working replies.
|
||||
if (state == WaitingForSession || state == Working) {
|
||||
state = Working;
|
||||
error(QNetworkReplyImpl::UnknownNetworkError,
|
||||
QCoreApplication::translate("QNetworkReply", "Network session error."));
|
||||
finished();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void QNetworkReplyImplPrivate::setup(QNetworkAccessManager::Operation op, const QNetworkRequest &req,
|
||||
QIODevice *data)
|
||||
{
|
||||
|
@ -730,29 +656,6 @@ void QNetworkReplyImplPrivate::finished()
|
|||
if (preMigrationDownloaded != Q_INT64_C(-1))
|
||||
totalSize = totalSize.toLongLong() + preMigrationDownloaded;
|
||||
|
||||
if (!manager.isNull()) {
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QSharedPointer<QNetworkSession> session (manager->d_func()->getNetworkSession());
|
||||
if (session && session->state() == QNetworkSession::Roaming &&
|
||||
state == Working && errorCode != QNetworkReply::OperationCanceledError) {
|
||||
// only content with a known size will fail with a temporary network failure error
|
||||
if (!totalSize.isNull()) {
|
||||
if (QVariant(bytesDownloaded) != totalSize) {
|
||||
if (migrateBackend()) {
|
||||
// either we are migrating or the request is finished/aborted
|
||||
if (state == Reconnecting || state == WaitingForSession) {
|
||||
resumeNotificationHandling();
|
||||
return; // exit early if we are migrating.
|
||||
}
|
||||
} else {
|
||||
error(QNetworkReply::TemporaryNetworkFailureError,
|
||||
QNetworkReply::tr("Temporary network failure."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
resumeNotificationHandling();
|
||||
|
||||
state = Finished;
|
||||
|
@ -1073,32 +976,6 @@ bool QNetworkReplyImplPrivate::migrateBackend()
|
|||
return true;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QDisabledNetworkReply::QDisabledNetworkReply(QObject *parent,
|
||||
const QNetworkRequest &req,
|
||||
QNetworkAccessManager::Operation op)
|
||||
: QNetworkReply(parent)
|
||||
{
|
||||
setRequest(req);
|
||||
setUrl(req.url());
|
||||
setOperation(op);
|
||||
|
||||
qRegisterMetaType<QNetworkReply::NetworkError>("QNetworkReply::NetworkError");
|
||||
|
||||
QString msg = QCoreApplication::translate("QNetworkAccessManager",
|
||||
"Network access is disabled.");
|
||||
setError(UnknownNetworkError, msg);
|
||||
|
||||
QMetaObject::invokeMethod(this, "error", Qt::QueuedConnection,
|
||||
Q_ARG(QNetworkReply::NetworkError, UnknownNetworkError));
|
||||
QMetaObject::invokeMethod(this, "finished", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
QDisabledNetworkReply::~QDisabledNetworkReply()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qnetworkreplyimpl_p.h"
|
||||
|
|
|
@ -78,10 +78,6 @@ public:
|
|||
Q_PRIVATE_SLOT(d_func(), void _q_copyReadChannelFinished())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingData())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_bufferOutgoingDataFinished())
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionConnected())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_networkSessionFailed())
|
||||
#endif
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_cacheDestroyed())
|
||||
Q_PRIVATE_SLOT(d_func(), void _q_cacheSaveDeviceAboutToClose())
|
||||
};
|
||||
|
@ -116,10 +112,6 @@ public:
|
|||
void _q_copyReadChannelFinished();
|
||||
void _q_bufferOutgoingData();
|
||||
void _q_bufferOutgoingDataFinished();
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void _q_networkSessionConnected();
|
||||
void _q_networkSessionFailed();
|
||||
#endif
|
||||
void _q_cacheDestroyed();
|
||||
void _q_cacheSaveDeviceAboutToClose();
|
||||
|
||||
|
@ -199,22 +191,6 @@ public:
|
|||
Q_DECLARE_PUBLIC(QNetworkReplyImpl)
|
||||
};
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
class QDisabledNetworkReply : public QNetworkReply
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QDisabledNetworkReply(QObject *parent, const QNetworkRequest &req,
|
||||
QNetworkAccessManager::Operation op);
|
||||
~QDisabledNetworkReply();
|
||||
|
||||
void abort() { }
|
||||
protected:
|
||||
qint64 readData(char *, qint64) { return -1; }
|
||||
};
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbearerengine_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QBearerEngine::QBearerEngine(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QBearerEngine::~QBearerEngine()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
|
||||
|
||||
for (it = accessPointConfigurations.begin(), end = accessPointConfigurations.end();
|
||||
it != end; ++it) {
|
||||
it.value()->isValid = false;
|
||||
it.value()->id.clear();
|
||||
}
|
||||
accessPointConfigurations.clear();
|
||||
}
|
||||
|
||||
bool QBearerEngine::requiresPolling() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns true if configurations are in use; otherwise returns false.
|
||||
|
||||
If configurations are in use and requiresPolling() returns true, polling will be enabled for
|
||||
this engine.
|
||||
*/
|
||||
bool QBearerEngine::configurationsInUse() const
|
||||
{
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator it;
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::ConstIterator end;
|
||||
|
||||
for (it = accessPointConfigurations.constBegin(),
|
||||
end = accessPointConfigurations.constEnd(); it != end; ++it) {
|
||||
if (it.value()->ref > 1)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "moc_qbearerengine_p.h"
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QBEARERENGINE_P_H
|
||||
#define QBEARERENGINE_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qnetworkconfiguration_p.h"
|
||||
#include "qnetworksession.h"
|
||||
#include "qnetworkconfigmanager.h"
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qlist.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qhash.h>
|
||||
#include <QtCore/qsharedpointer.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkConfiguration;
|
||||
|
||||
class Q_NETWORK_EXPORT QBearerEngine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class QNetworkConfigurationManagerPrivate;
|
||||
|
||||
public:
|
||||
explicit QBearerEngine(QObject *parent = nullptr);
|
||||
virtual ~QBearerEngine();
|
||||
|
||||
virtual bool hasIdentifier(const QString &id) const = 0;
|
||||
|
||||
virtual QNetworkConfigurationManager::Capabilities capabilities() const = 0;
|
||||
|
||||
virtual QNetworkSessionPrivate *createSessionBackend() = 0;
|
||||
|
||||
virtual QNetworkConfigurationPrivatePointer defaultConfiguration() = 0;
|
||||
|
||||
virtual bool requiresPolling() const;
|
||||
bool configurationsInUse() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void configurationAdded(QNetworkConfigurationPrivatePointer config);
|
||||
void configurationRemoved(QNetworkConfigurationPrivatePointer config);
|
||||
void configurationChanged(QNetworkConfigurationPrivatePointer config);
|
||||
void updateCompleted();
|
||||
|
||||
protected:
|
||||
//this table contains an up to date list of all configs at any time.
|
||||
//it must be updated if configurations change, are added/removed or
|
||||
//the members of ServiceNetworks change
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer> accessPointConfigurations;
|
||||
|
||||
std::recursive_mutex mutex;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QBEARERENGINE_P_H
|
|
@ -1,43 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qbearerplugin_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QBearerEnginePlugin::QBearerEnginePlugin(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QBearerEnginePlugin::~QBearerEnginePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
|
||||
|
||||
#include "moc_qbearerplugin_p.h"
|
|
@ -1,76 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QBEARERPLUGIN_P_H
|
||||
#define QBEARERPLUGIN_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qbearerengine_p.h"
|
||||
|
||||
#include <QtCore/qplugin.h>
|
||||
#include <QtCore/qfactoryinterface.h>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
struct Q_NETWORK_EXPORT QBearerEngineFactoryInterface : public QFactoryInterface
|
||||
{
|
||||
virtual QBearerEngine *create(const QString &key) const = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#define QBearerEngineFactoryInterface_iid "Katie.QBearerEngineFactoryInterface"
|
||||
Q_DECLARE_INTERFACE(QBearerEngineFactoryInterface, QBearerEngineFactoryInterface_iid)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_NETWORK_EXPORT QBearerEnginePlugin : public QObject, public QBearerEngineFactoryInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(QBearerEngineFactoryInterface:QFactoryInterface)
|
||||
|
||||
public:
|
||||
explicit QBearerEnginePlugin(QObject *parent = nullptr);
|
||||
virtual ~QBearerEnginePlugin();
|
||||
|
||||
virtual QStringList keys() const = 0;
|
||||
virtual QBearerEngine *create(const QString &key) const = 0;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QBEARERPLUGIN_P_H
|
|
@ -1,355 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnetworkconfigmanager.h"
|
||||
|
||||
#include "qnetworkconfigmanager_p.h"
|
||||
#include "qbearerengine_p.h"
|
||||
|
||||
#include <QtCore/qstringlist.h>
|
||||
#include <QtCore/qcoreapplication.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static QAtomicPointer<QNetworkConfigurationManagerPrivate> connManager_ptr;
|
||||
Q_GLOBAL_STATIC(QMutex, connManager_mutex)
|
||||
static QAtomicInt appShutdown;
|
||||
|
||||
static void connManager_cleanup()
|
||||
{
|
||||
// this is not atomic or thread-safe!
|
||||
int shutdown = appShutdown.fetchAndStoreAcquire(1);
|
||||
Q_ASSERT(shutdown == 0);
|
||||
Q_UNUSED(shutdown);
|
||||
if(connManager_ptr)
|
||||
connManager_ptr->cleanup();
|
||||
connManager_ptr = 0;
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::addPostRoutine()
|
||||
{
|
||||
qAddPostRoutine(connManager_cleanup);
|
||||
}
|
||||
|
||||
static QNetworkConfigurationManagerPrivate *connManager()
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *ptr = connManager_ptr.fetchAndAddAcquire(0);
|
||||
if (!ptr && !appShutdown) {
|
||||
QMutexLocker locker(connManager_mutex());
|
||||
if (!(ptr = connManager_ptr.fetchAndAddAcquire(0))) {
|
||||
ptr = new QNetworkConfigurationManagerPrivate;
|
||||
|
||||
ptr->addPostRoutine();
|
||||
ptr->initialize();
|
||||
|
||||
connManager_ptr.fetchAndStoreRelease(ptr);
|
||||
}
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate()
|
||||
{
|
||||
return connManager();
|
||||
}
|
||||
|
||||
/*!
|
||||
\class QNetworkConfigurationManager
|
||||
|
||||
\brief The QNetworkConfigurationManager class manages the network configurations provided
|
||||
by the system.
|
||||
|
||||
\since 4.7
|
||||
|
||||
\inmodule QtNetwork
|
||||
\ingroup network
|
||||
|
||||
QNetworkConfigurationManager provides access to the network configurations known to the system and
|
||||
enables applications to detect the system capabilities (with regards to network sessions) at runtime.
|
||||
|
||||
A QNetworkConfiguration abstracts a set of configuration options describing how a
|
||||
network interface has to be configured to connect to a particular target network.
|
||||
QNetworkConfigurationManager maintains and updates the global list of
|
||||
QNetworkConfigurations. Applications can access and filter this list via
|
||||
allConfigurations(). If a new configuration is added or an existing one is removed or changed
|
||||
the configurationAdded(), configurationRemoved() and configurationChanged() signals are emitted
|
||||
respectively.
|
||||
|
||||
The defaultConfiguration() can be used when intending to immediately create a new
|
||||
network session without caring about the particular configuration. It returns
|
||||
a \l QNetworkConfiguration::Discovered configuration. If there are not any
|
||||
discovered ones an invalid configuration is returned.
|
||||
|
||||
Some configuration updates may require some time to perform updates. A WLAN scan is
|
||||
such an example. Unless the platform performs internal updates it may be required to
|
||||
manually trigger configuration updates via QNetworkConfigurationManager::updateConfigurations().
|
||||
The completion of the update process is indicated by emitting the updateCompleted()
|
||||
signal. The update process ensures that every existing QNetworkConfiguration instance
|
||||
is updated. There is no need to ask for a renewed configuration list via allConfigurations().
|
||||
|
||||
\sa QNetworkConfiguration
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkConfigurationManager::configurationAdded(const QNetworkConfiguration &config)
|
||||
|
||||
This signal is emitted whenever a new network configuration is added to the system. The new
|
||||
configuration is specified by \a config.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkConfigurationManager::configurationRemoved(const QNetworkConfiguration &config)
|
||||
\since 4.8
|
||||
|
||||
This signal is emitted when a configuration is about to be removed from the system. The removed
|
||||
configuration, specified by \a config, is invalid but retains name and identifier.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkConfigurationManager::updateCompleted()
|
||||
|
||||
This signal is emitted when the configuration update has been completed. Such an update can
|
||||
be initiated via \l updateConfigurations().
|
||||
*/
|
||||
|
||||
/*! \fn void QNetworkConfigurationManager::configurationChanged(const QNetworkConfiguration &config)
|
||||
|
||||
This signal is emitted when the \l {QNetworkConfiguration::state()}{state} of \a config changes.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkConfigurationManager::onlineStateChanged(bool isOnline)
|
||||
|
||||
This signal is emitted when the device changes from online to offline mode or vice versa.
|
||||
\a isOnline represents the new state of the device.
|
||||
|
||||
The state is considered to be online for as long as
|
||||
\l{allConfigurations()}{allConfigurations}(QNetworkConfiguration::Active) returns a list with
|
||||
at least one entry.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QNetworkConfigurationManager::Capability
|
||||
|
||||
Specifies the system capabilities of the bearer API. The possible values are:
|
||||
|
||||
\value CanStartAndStopInterfaces Network sessions and their underlying access points can be
|
||||
started and stopped. If this flag is not set QNetworkSession
|
||||
can only monitor but not influence the state of access points.
|
||||
On some platforms this feature may require elevated user
|
||||
permissions. This option is platform specific and may not
|
||||
always be available.
|
||||
\value DirectConnectionRouting Network sessions and their sockets can be bound to a
|
||||
particular network interface. Any packet that passes through
|
||||
the socket goes to the specified network interface and thus
|
||||
disregards standard routing table entries. This may be useful
|
||||
when two interfaces can reach overlapping IP ranges or an
|
||||
application has specific needs in regards to target networks.
|
||||
This option is platform specific and may not always be
|
||||
available.
|
||||
\value SystemSessionSupport If this flag is set the underlying platform ensures that a
|
||||
network interface is not shut down until the last network
|
||||
session has been \l{QNetworkSession::close()}{closed()}. This
|
||||
works across multiple processes. If the platform session
|
||||
support is missing this API can only ensure the above behavior
|
||||
for network sessions within the same process.
|
||||
In general mobile platforms (such as Symbian/S60) have such
|
||||
support whereas most desktop platform lack this capability.
|
||||
\value ApplicationLevelRoaming The system gives applications control over the systems roaming
|
||||
behavior. Applications can initiate roaming (in case the
|
||||
current link is not suitable) and are consulted if the system
|
||||
has identified a more suitable access point.
|
||||
\value ForcedRoaming The system disconnects an existing access point and reconnects
|
||||
via a more suitable one. The application does not have any
|
||||
control over this process and has to reconnect its active
|
||||
sockets.
|
||||
\value DataStatistics If this flag is set QNetworkSession can provide statistics
|
||||
about transmitted and received data.
|
||||
\value NetworkSessionRequired If this flag is set the platform requires that a network
|
||||
session is created before network operations can be performed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a QNetworkConfigurationManager with the given \a parent.
|
||||
|
||||
Note that to ensure a valid list of current configurations immediately available, updating
|
||||
is done during construction which causes some delay.
|
||||
*/
|
||||
QNetworkConfigurationManager::QNetworkConfigurationManager(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
|
||||
|
||||
connect(priv, SIGNAL(configurationAdded(QNetworkConfiguration)),
|
||||
this, SIGNAL(configurationAdded(QNetworkConfiguration)));
|
||||
connect(priv, SIGNAL(configurationRemoved(QNetworkConfiguration)),
|
||||
this, SIGNAL(configurationRemoved(QNetworkConfiguration)));
|
||||
connect(priv, SIGNAL(configurationChanged(QNetworkConfiguration)),
|
||||
this, SIGNAL(configurationChanged(QNetworkConfiguration)));
|
||||
connect(priv, SIGNAL(onlineStateChanged(bool)),
|
||||
this, SIGNAL(onlineStateChanged(bool)));
|
||||
connect(priv, SIGNAL(configurationUpdateComplete()),
|
||||
this, SIGNAL(updateCompleted()));
|
||||
|
||||
priv->enablePolling();
|
||||
}
|
||||
|
||||
/*!
|
||||
Frees the resources associated with the QNetworkConfigurationManager object.
|
||||
*/
|
||||
QNetworkConfigurationManager::~QNetworkConfigurationManager()
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = connManager();
|
||||
if (priv)
|
||||
priv->disablePolling();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns the default configuration to be used. This function always returns a discovered
|
||||
configuration; otherwise an invalid configuration.
|
||||
|
||||
In some cases it may be required to call updateConfigurations() and wait for the
|
||||
updateCompleted() signal before calling this function.
|
||||
|
||||
\sa allConfigurations()
|
||||
*/
|
||||
QNetworkConfiguration QNetworkConfigurationManager::defaultConfiguration() const
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = connManager();
|
||||
if (priv)
|
||||
return priv->defaultConfiguration();
|
||||
|
||||
return QNetworkConfiguration();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the list of configurations which comply with the given \a filter.
|
||||
|
||||
By default this function returns all (defined and undefined) configurations.
|
||||
|
||||
A wireless network with a particular SSID may only be accessible in a
|
||||
certain area despite the fact that the system has a valid configuration
|
||||
for it. Therefore the filter flag may be used to limit the list to
|
||||
discovered and possibly connected configurations only.
|
||||
|
||||
If \a filter is set to zero this function returns all possible configurations.
|
||||
|
||||
Note that this function returns the states for all configurations as they are known at
|
||||
the time of this function call. If for instance a configuration of type WLAN is defined
|
||||
the system may have to perform a WLAN scan in order to determine whether it is
|
||||
actually available. To obtain the most accurate state updateConfigurations() should
|
||||
be used to update each configuration's state. Note that such an update may require
|
||||
some time. It's completion is signalled by updateCompleted(). In the absence of a
|
||||
configuration update this function returns the best estimate at the time of the call.
|
||||
Therefore, if WLAN configurations are of interest, it is recommended that
|
||||
updateConfigurations() is called once after QNetworkConfigurationManager
|
||||
instantiation (WLAN scans are too time consuming to perform in constructor).
|
||||
After this the data is kept automatically up-to-date as the system reports
|
||||
any changes.
|
||||
*/
|
||||
QList<QNetworkConfiguration> QNetworkConfigurationManager::allConfigurations(QNetworkConfiguration::StateFlags filter) const
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = connManager();
|
||||
if (priv)
|
||||
return priv->allConfigurations(filter);
|
||||
|
||||
return QList<QNetworkConfiguration>();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the QNetworkConfiguration for \a identifier; otherwise returns an
|
||||
invalid QNetworkConfiguration.
|
||||
|
||||
\sa QNetworkConfiguration::identifier()
|
||||
*/
|
||||
QNetworkConfiguration QNetworkConfigurationManager::configurationFromIdentifier(const QString &identifier) const
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = connManager();
|
||||
if (priv)
|
||||
return priv->configurationFromIdentifier(identifier);
|
||||
|
||||
return QNetworkConfiguration();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the system is considered to be connected to another device via an active
|
||||
network interface; otherwise returns false.
|
||||
|
||||
This is equivalent to the following code snippet:
|
||||
|
||||
\snippet doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp 0
|
||||
|
||||
\sa onlineStateChanged()
|
||||
*/
|
||||
bool QNetworkConfigurationManager::isOnline() const
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = connManager();
|
||||
if (priv)
|
||||
return priv->isOnline();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the capabilities supported by the current platform.
|
||||
*/
|
||||
QNetworkConfigurationManager::Capabilities QNetworkConfigurationManager::capabilities() const
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = connManager();
|
||||
if (priv)
|
||||
return priv->capabilities();
|
||||
|
||||
return QNetworkConfigurationManager::Capabilities(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
Initiates an update of all configurations. This may be used to initiate WLAN scans or other
|
||||
time consuming updates which may be required to obtain the correct state for configurations.
|
||||
|
||||
This call is asynchronous. On completion of this update the updateCompleted() signal is
|
||||
emitted. If new configurations are discovered or old ones were removed or changed the update
|
||||
process may trigger the emission of one or multiple configurationAdded(),
|
||||
configurationRemoved() and configurationChanged() signals.
|
||||
|
||||
If a configuration state changes as a result of this update all existing QNetworkConfiguration
|
||||
instances are updated automatically.
|
||||
|
||||
\sa allConfigurations()
|
||||
*/
|
||||
void QNetworkConfigurationManager::updateConfigurations()
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = connManager();
|
||||
if (priv)
|
||||
priv->performAsyncConfigurationUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qnetworkconfigmanager.h"
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKCONFIGURATIONMANAGER_H
|
||||
#define QNETWORKCONFIGURATIONMANAGER_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtNetwork/qnetworkconfiguration.h>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkConfigurationManagerPrivate;
|
||||
class Q_NETWORK_EXPORT QNetworkConfigurationManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum Capability {
|
||||
CanStartAndStopInterfaces = 0x00000001,
|
||||
DirectConnectionRouting = 0x00000002,
|
||||
SystemSessionSupport = 0x00000004,
|
||||
ApplicationLevelRoaming = 0x00000008,
|
||||
ForcedRoaming = 0x00000010,
|
||||
DataStatistics = 0x00000020,
|
||||
NetworkSessionRequired = 0x00000040
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(Capabilities, Capability)
|
||||
|
||||
explicit QNetworkConfigurationManager(QObject *parent = nullptr);
|
||||
virtual ~QNetworkConfigurationManager();
|
||||
|
||||
QNetworkConfigurationManager::Capabilities capabilities() const;
|
||||
|
||||
QNetworkConfiguration defaultConfiguration() const;
|
||||
QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags flags = 0) const;
|
||||
QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
|
||||
|
||||
bool isOnline() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void updateConfigurations();
|
||||
|
||||
Q_SIGNALS:
|
||||
void configurationAdded(const QNetworkConfiguration &config);
|
||||
void configurationRemoved(const QNetworkConfiguration &config);
|
||||
void configurationChanged(const QNetworkConfiguration &config);
|
||||
void onlineStateChanged(bool isOnline);
|
||||
void updateCompleted();
|
||||
};
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS(QNetworkConfigurationManager::Capabilities)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QNETWORKCONFIGURATIONMANAGER_H
|
|
@ -1,422 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnetworkconfigmanager_p.h"
|
||||
#include "qbearerplugin_p.h"
|
||||
#include "qfactoryloader_p.h"
|
||||
#include "qdebug.h"
|
||||
#include "qtimer.h"
|
||||
#include "qstringlist.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
|
||||
(QBearerEngineFactoryInterface_iid, QLatin1String("/bearer")))
|
||||
#endif
|
||||
|
||||
QNetworkConfigurationManagerPrivate::QNetworkConfigurationManagerPrivate()
|
||||
: QObject(), pollTimer(0), forcedPolling(0), firstUpdate(true)
|
||||
{
|
||||
qRegisterMetaType<QNetworkConfiguration>("QNetworkConfiguration");
|
||||
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::initialize()
|
||||
{
|
||||
updateConfigurations();
|
||||
}
|
||||
|
||||
QNetworkConfigurationManagerPrivate::~QNetworkConfigurationManagerPrivate()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
qDeleteAll(sessionEngines);
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::cleanup()
|
||||
{
|
||||
deleteLater();
|
||||
}
|
||||
|
||||
QNetworkConfiguration QNetworkConfigurationManagerPrivate::defaultConfiguration() const
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines) {
|
||||
QNetworkConfigurationPrivatePointer ptr = engine->defaultConfiguration();
|
||||
if (ptr) {
|
||||
QNetworkConfiguration config;
|
||||
config.d = ptr;
|
||||
return config;
|
||||
}
|
||||
}
|
||||
|
||||
// Engines don't have a default configuration.
|
||||
QNetworkConfigurationPrivatePointer defaultConfiguration;
|
||||
|
||||
/*
|
||||
Find the perferred access point. The following priority order is used:
|
||||
|
||||
1. Active Ethernet
|
||||
2. Active WLAN
|
||||
3. Active Other
|
||||
4. Discovered Ethernet
|
||||
5. Discovered WLAN
|
||||
6. Discovered Other
|
||||
*/
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines) {
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> locker(engine->mutex);
|
||||
|
||||
for (it = engine->accessPointConfigurations.begin(),
|
||||
end = engine->accessPointConfigurations.end(); it != end; ++it) {
|
||||
QNetworkConfigurationPrivatePointer ptr = it.value();
|
||||
|
||||
std::lock_guard<std::recursive_mutex> configLocker(ptr->mutex);
|
||||
QNetworkConfiguration::BearerType bearerType = ptr->bearerType;
|
||||
|
||||
if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
|
||||
if (!defaultConfiguration) {
|
||||
defaultConfiguration = ptr;
|
||||
} else {
|
||||
std::lock_guard<std::recursive_mutex> defaultConfigLocker(defaultConfiguration->mutex);
|
||||
|
||||
if (defaultConfiguration->state == ptr->state) {
|
||||
switch (defaultConfiguration->bearerType) {
|
||||
case QNetworkConfiguration::BearerEthernet:
|
||||
// do nothing
|
||||
break;
|
||||
case QNetworkConfiguration::BearerWLAN:
|
||||
// Ethernet beats WLAN
|
||||
defaultConfiguration = ptr;
|
||||
break;
|
||||
default:
|
||||
// Ethernet and WLAN beats other
|
||||
if (bearerType == QNetworkConfiguration::BearerEthernet ||
|
||||
bearerType == QNetworkConfiguration::BearerWLAN) {
|
||||
defaultConfiguration = ptr;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// active beats discovered
|
||||
if ((defaultConfiguration->state & QNetworkConfiguration::Active) !=
|
||||
QNetworkConfiguration::Active) {
|
||||
defaultConfiguration = ptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No Active InternetAccessPoint return first Discovered InternetAccessPoint.
|
||||
if (defaultConfiguration) {
|
||||
QNetworkConfiguration config;
|
||||
config.d = defaultConfiguration;
|
||||
return config;
|
||||
}
|
||||
|
||||
return QNetworkConfiguration();
|
||||
}
|
||||
|
||||
QList<QNetworkConfiguration> QNetworkConfigurationManagerPrivate::allConfigurations(QNetworkConfiguration::StateFlags filter) const
|
||||
{
|
||||
QList<QNetworkConfiguration> result;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines) {
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator it;
|
||||
QHash<QString, QNetworkConfigurationPrivatePointer>::Iterator end;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> locker(engine->mutex);
|
||||
|
||||
//find all InternetAccessPoints
|
||||
for (it = engine->accessPointConfigurations.begin(),
|
||||
end = engine->accessPointConfigurations.end(); it != end; ++it) {
|
||||
QNetworkConfigurationPrivatePointer ptr = it.value();
|
||||
|
||||
std::lock_guard<std::recursive_mutex> configLocker(ptr->mutex);
|
||||
|
||||
if ((ptr->state & filter) == filter) {
|
||||
QNetworkConfiguration pt;
|
||||
pt.d = ptr;
|
||||
result << pt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
QNetworkConfiguration QNetworkConfigurationManagerPrivate::configurationFromIdentifier(const QString &identifier) const
|
||||
{
|
||||
QNetworkConfiguration item;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines) {
|
||||
std::lock_guard<std::recursive_mutex> locker(engine->mutex);
|
||||
|
||||
if (engine->accessPointConfigurations.contains(identifier)) {
|
||||
item.d = engine->accessPointConfigurations[identifier];
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
bool QNetworkConfigurationManagerPrivate::isOnline() const
|
||||
{
|
||||
return !onlineConfigurations.isEmpty();
|
||||
}
|
||||
|
||||
QNetworkConfigurationManager::Capabilities QNetworkConfigurationManagerPrivate::capabilities() const
|
||||
{
|
||||
QNetworkConfigurationManager::Capabilities capFlags;
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines)
|
||||
capFlags |= engine->capabilities();
|
||||
|
||||
return capFlags;
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::configurationAdded(QNetworkConfigurationPrivatePointer ptr)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if (!firstUpdate) {
|
||||
QNetworkConfiguration item;
|
||||
item.d = ptr;
|
||||
emit configurationAdded(item);
|
||||
}
|
||||
|
||||
ptr->mutex.lock();
|
||||
if (ptr->state == QNetworkConfiguration::Active) {
|
||||
ptr->mutex.unlock();
|
||||
onlineConfigurations.insert(ptr->id);
|
||||
if (!firstUpdate && onlineConfigurations.count() == 1)
|
||||
emit onlineStateChanged(true);
|
||||
} else {
|
||||
ptr->mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::configurationRemoved(QNetworkConfigurationPrivatePointer ptr)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
ptr->mutex.lock();
|
||||
ptr->isValid = false;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
if (!firstUpdate) {
|
||||
QNetworkConfiguration item;
|
||||
item.d = ptr;
|
||||
emit configurationRemoved(item);
|
||||
}
|
||||
|
||||
onlineConfigurations.remove(ptr->id);
|
||||
if (!firstUpdate && onlineConfigurations.isEmpty())
|
||||
emit onlineStateChanged(false);
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::configurationChanged(QNetworkConfigurationPrivatePointer ptr)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if (!firstUpdate) {
|
||||
QNetworkConfiguration item;
|
||||
item.d = ptr;
|
||||
emit configurationChanged(item);
|
||||
}
|
||||
|
||||
bool previous = !onlineConfigurations.isEmpty();
|
||||
|
||||
ptr->mutex.lock();
|
||||
if (ptr->state == QNetworkConfiguration::Active)
|
||||
onlineConfigurations.insert(ptr->id);
|
||||
else
|
||||
onlineConfigurations.remove(ptr->id);
|
||||
ptr->mutex.unlock();
|
||||
|
||||
bool online = !onlineConfigurations.isEmpty();
|
||||
|
||||
if (!firstUpdate && online != previous)
|
||||
emit onlineStateChanged(online);
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::updateConfigurations()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if (firstUpdate) {
|
||||
if (qobject_cast<QBearerEngine *>(sender()))
|
||||
return;
|
||||
|
||||
updating = false;
|
||||
|
||||
#ifndef QT_NO_LIBRARY
|
||||
QBearerEngine *generic = 0;
|
||||
|
||||
QFactoryLoader *l = loader();
|
||||
foreach (const QString &key, l->keys()) {
|
||||
QBearerEnginePlugin *plugin = qobject_cast<QBearerEnginePlugin *>(l->instance(key));
|
||||
if (plugin) {
|
||||
QBearerEngine *engine = plugin->create(key);
|
||||
if (!engine)
|
||||
continue;
|
||||
|
||||
if (key == QLatin1String("generic"))
|
||||
generic = engine;
|
||||
else
|
||||
sessionEngines.append(engine);
|
||||
|
||||
connect(engine, SIGNAL(updateCompleted()),
|
||||
this, SLOT(updateConfigurations()),
|
||||
Qt::QueuedConnection);
|
||||
connect(engine, SIGNAL(configurationAdded(QNetworkConfigurationPrivatePointer)),
|
||||
this, SLOT(configurationAdded(QNetworkConfigurationPrivatePointer)),
|
||||
Qt::QueuedConnection);
|
||||
connect(engine, SIGNAL(configurationRemoved(QNetworkConfigurationPrivatePointer)),
|
||||
this, SLOT(configurationRemoved(QNetworkConfigurationPrivatePointer)),
|
||||
Qt::QueuedConnection);
|
||||
connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
|
||||
this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)),
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
}
|
||||
|
||||
if (generic)
|
||||
sessionEngines.append(generic);
|
||||
#endif // QT_NO_LIBRARY
|
||||
}
|
||||
|
||||
QBearerEngine *engine = qobject_cast<QBearerEngine *>(sender());
|
||||
if (engine && !updatingEngines.isEmpty())
|
||||
updatingEngines.remove(engine);
|
||||
|
||||
if (updating && updatingEngines.isEmpty()) {
|
||||
updating = false;
|
||||
emit configurationUpdateComplete();
|
||||
}
|
||||
|
||||
if (engine && !pollingEngines.isEmpty()) {
|
||||
pollingEngines.remove(engine);
|
||||
if (pollingEngines.isEmpty())
|
||||
startPolling();
|
||||
}
|
||||
|
||||
if (firstUpdate) {
|
||||
firstUpdate = false;
|
||||
foreach (QBearerEngine* engine, sessionEngines) {
|
||||
QMetaObject::invokeMethod(engine, "initialize");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::performAsyncConfigurationUpdate()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if (sessionEngines.isEmpty()) {
|
||||
emit configurationUpdateComplete();
|
||||
return;
|
||||
}
|
||||
|
||||
updating = true;
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines) {
|
||||
updatingEngines.insert(engine);
|
||||
QMetaObject::invokeMethod(engine, "requestUpdate");
|
||||
}
|
||||
}
|
||||
|
||||
QList<QBearerEngine *> QNetworkConfigurationManagerPrivate::engines() const
|
||||
{
|
||||
return sessionEngines;
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::startPolling()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if(!pollTimer) {
|
||||
pollTimer = new QTimer(this);
|
||||
pollTimer->setInterval(10000);
|
||||
pollTimer->setSingleShot(true);
|
||||
connect(pollTimer, SIGNAL(timeout()), this, SLOT(pollEngines()));
|
||||
}
|
||||
|
||||
if(pollTimer->isActive())
|
||||
return;
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines) {
|
||||
if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
|
||||
pollTimer->start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::pollEngines()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
foreach (QBearerEngine *engine, sessionEngines) {
|
||||
if (engine->requiresPolling() && (forcedPolling || engine->configurationsInUse())) {
|
||||
pollingEngines.insert(engine);
|
||||
QMetaObject::invokeMethod(engine, "requestUpdate");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::enablePolling()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
++forcedPolling;
|
||||
|
||||
if (forcedPolling == 1)
|
||||
QMetaObject::invokeMethod(this, "startPolling");
|
||||
}
|
||||
|
||||
void QNetworkConfigurationManagerPrivate::disablePolling()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
--forcedPolling;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#include "moc_qnetworkconfigmanager_p.h"
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
|
|
@ -1,118 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKCONFIGURATIONMANAGERPRIVATE_H
|
||||
#define QNETWORKCONFIGURATIONMANAGERPRIVATE_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qnetworkconfigmanager.h"
|
||||
#include "qnetworkconfiguration_p.h"
|
||||
#include "qmutex.h"
|
||||
#include "qset.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QBearerEngine;
|
||||
class QTimer;
|
||||
|
||||
class Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QNetworkConfigurationManagerPrivate();
|
||||
virtual ~QNetworkConfigurationManagerPrivate();
|
||||
|
||||
QNetworkConfiguration defaultConfiguration() const;
|
||||
QList<QNetworkConfiguration> allConfigurations(QNetworkConfiguration::StateFlags filter) const;
|
||||
QNetworkConfiguration configurationFromIdentifier(const QString &identifier) const;
|
||||
|
||||
bool isOnline() const;
|
||||
|
||||
QNetworkConfigurationManager::Capabilities capabilities() const;
|
||||
|
||||
void performAsyncConfigurationUpdate();
|
||||
|
||||
QList<QBearerEngine *> engines() const;
|
||||
|
||||
void enablePolling();
|
||||
void disablePolling();
|
||||
|
||||
void initialize();
|
||||
void cleanup();
|
||||
public Q_SLOTS:
|
||||
void updateConfigurations();
|
||||
|
||||
static void addPostRoutine();
|
||||
|
||||
Q_SIGNALS:
|
||||
void configurationAdded(const QNetworkConfiguration &config);
|
||||
void configurationRemoved(const QNetworkConfiguration &config);
|
||||
void configurationChanged(const QNetworkConfiguration &config);
|
||||
void configurationUpdateComplete();
|
||||
void onlineStateChanged(bool isOnline);
|
||||
|
||||
private Q_SLOTS:
|
||||
void configurationAdded(QNetworkConfigurationPrivatePointer ptr);
|
||||
void configurationRemoved(QNetworkConfigurationPrivatePointer ptr);
|
||||
void configurationChanged(QNetworkConfigurationPrivatePointer ptr);
|
||||
|
||||
void pollEngines();
|
||||
|
||||
|
||||
private:
|
||||
Q_INVOKABLE void startPolling();
|
||||
QTimer *pollTimer;
|
||||
|
||||
private:
|
||||
mutable std::recursive_mutex mutex;
|
||||
|
||||
QList<QBearerEngine *> sessionEngines;
|
||||
|
||||
QSet<QString> onlineConfigurations;
|
||||
|
||||
QSet<QBearerEngine *> pollingEngines;
|
||||
QSet<QBearerEngine *> updatingEngines;
|
||||
int forcedPolling;
|
||||
bool updating;
|
||||
|
||||
bool firstUpdate;
|
||||
};
|
||||
|
||||
Q_NETWORK_EXPORT QNetworkConfigurationManagerPrivate *qNetworkConfigurationManagerPrivate();
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QNETWORKCONFIGURATIONMANAGERPRIVATE_H
|
|
@ -1,472 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnetworkconfiguration.h"
|
||||
#include "qnetworkconfiguration_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QNetworkConfiguration
|
||||
|
||||
\brief The QNetworkConfiguration class provides an abstraction of one or more access point configurations.
|
||||
|
||||
\since 4.7
|
||||
|
||||
\inmodule QtNetwork
|
||||
\ingroup network
|
||||
|
||||
QNetworkConfiguration encapsulates a single access point or service network.
|
||||
In most cases a single access point configuration can be mapped to one network
|
||||
interface. However a single network interface may not always map to only one
|
||||
access point configuration. Multiple configurations for the same
|
||||
network device may enable multiple access points. An example
|
||||
device that could exhibit such a configuration might be a
|
||||
Smartphone which allows the user to manage multiple WLAN
|
||||
configurations while the device itself has only one WLAN network device.
|
||||
|
||||
The QNetworkConfiguration also supports the concept of service networks.
|
||||
This concept allows the grouping of multiple access point configurations
|
||||
into one entity. Such a group is called service network and can be
|
||||
beneficial in cases whereby a network session to a
|
||||
particular destination network is required (e.g. a company network).
|
||||
When using a service network the user doesn't usually care which one of the
|
||||
connectivity options is chosen (e.g. corporate WLAN or VPN via GPRS)
|
||||
as long as he can reach the company's target server. Depending
|
||||
on the current position and time some of the access points that make
|
||||
up the service network may not even be available. Furthermore
|
||||
automated access point roaming can be enabled which enables the device
|
||||
to change the network interface configuration dynamically while maintaining
|
||||
the applications connection to the target network. It allows adaption
|
||||
to the changing environment and may enable optimization with regards to
|
||||
cost, speed or other network parameters.
|
||||
|
||||
Special configurations of type UserChoice provide a placeholder configuration which is
|
||||
resolved to an actual network configuration by the platform when a
|
||||
\l {QNetworkSession}{session} is \l {QNetworkSession::open()}{opened}. Not all platforms
|
||||
support the concept of a user choice configuration.
|
||||
|
||||
\section1 Configuration states
|
||||
|
||||
The list of available configurations can be obtained via
|
||||
QNetworkConfigurationManager::allConfigurations(). A configuration can have
|
||||
multiple states. The \l Defined configuration state indicates that the configuration
|
||||
is stored on the device. However the configuration is not yet ready to be activated
|
||||
as e.g. a WLAN may not be available at the current time.
|
||||
|
||||
The \l Discovered state implies that the configuration is \l Defined and
|
||||
the outside conditions are such that the configuration can be used immediately
|
||||
to open a new network session. An example of such an outside condition may be
|
||||
that the Ethernet cable is actually connected to the device or that the WLAN
|
||||
with the specified SSID is in range.
|
||||
|
||||
The \l Active state implies that the configuration is \l Discovered. A configuration
|
||||
in this state is currently being used by an application. The underlying network
|
||||
interface has a valid IP configuration and can transfer IP packets between the
|
||||
device and the target network.
|
||||
|
||||
The \l Undefined state indicates that the system has knowledge of possible target
|
||||
networks but cannot actually use that knowledge to connect to it. An example
|
||||
for such a state could be an encrypted WLAN that has been discovered
|
||||
but the user hasn't actually saved a configuration including the required password
|
||||
which would allow the device to connect to it.
|
||||
|
||||
Depending on the type of configuration some states are transient in nature. A GPRS/UMTS
|
||||
connection may almost always be \l Discovered if the GSM/UMTS network is available.
|
||||
However if the GSM/UMTS network looses the connection the associated configuration may change its state
|
||||
from \l Discovered to \l Defined as well. A similar use case might be triggered by
|
||||
WLAN availability. QNetworkConfigurationManager::updateConfigurations() can be used to
|
||||
manually trigger updates of states. Note that some platforms do not require such updates
|
||||
as they implicitly change the state once it has been discovered. If the state of a
|
||||
configuration changes all related QNetworkConfiguration instances change their state automatically.
|
||||
|
||||
\sa QNetworkSession, QNetworkConfigurationManager
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QNetworkConfiguration::Type
|
||||
|
||||
This enum describes the type of configuration.
|
||||
|
||||
\value InternetAccessPoint The configuration specifies the details for a single access point.
|
||||
Note that configurations of type InternetAccessPoint may be part
|
||||
of other QNetworkConfigurations of type ServiceNetwork.
|
||||
\value ServiceNetwork The configuration is based on a group of QNetworkConfigurations of
|
||||
type InternetAccessPoint. All group members can reach the same
|
||||
target network. This type of configuration is a mandatory
|
||||
requirement for roaming enabled network sessions. On some
|
||||
platforms this form of configuration may also be called Service
|
||||
Network Access Point (SNAP).
|
||||
\value UserChoice The configuration is a placeholder which will be resolved to an
|
||||
actual configuration by the platform when a session is opened. Depending
|
||||
on the platform the selection may generate a popup dialog asking the user
|
||||
for his preferred choice.
|
||||
\value Invalid The configuration is invalid.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QNetworkConfiguration::StateFlag
|
||||
|
||||
Specifies the configuration states.
|
||||
|
||||
\value Undefined This state is used for transient configurations such as newly discovered
|
||||
WLANs for which the user has not actually created a configuration yet.
|
||||
\value Defined Defined configurations are known to the system but are not immediately
|
||||
usable (e.g. a configured WLAN is not within range or the Ethernet cable
|
||||
is currently not plugged into the machine).
|
||||
\value Discovered A discovered configuration can be immediately used to create a new
|
||||
QNetworkSession. An example of a discovered configuration could be a WLAN
|
||||
which is within in range. If the device moves out of range the discovered
|
||||
flag is dropped. A second example is a GPRS configuration which generally
|
||||
remains discovered for as long as the device has network coverage. A
|
||||
configuration that has this state is also in state
|
||||
QNetworkConfiguration::Defined. If the configuration is a service network
|
||||
this flag is set if at least one of the underlying access points
|
||||
configurations has the Discovered state.
|
||||
\value Active The configuration is currently used by an open network session
|
||||
(see \l QNetworkSession::isOpen()). However this does not mean that the
|
||||
current process is the entity that created the open session. It merely
|
||||
indicates that if a new QNetworkSession were to be constructed based on
|
||||
this configuration \l QNetworkSession::state() would return
|
||||
\l QNetworkSession::Connected. This state implies the
|
||||
QNetworkConfiguration::Discovered state.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QNetworkConfiguration::Purpose
|
||||
|
||||
Specifies the purpose of the configuration.
|
||||
|
||||
\value UnknownPurpose The configuration doesn't specify any purpose. This is the default value.
|
||||
\value PublicPurpose The configuration can be used for general purpose internet access.
|
||||
\value PrivatePurpose The configuration is suitable to access a private network such as an office Intranet.
|
||||
\value ServiceSpecificPurpose The configuration can be used for operator specific services (e.g.
|
||||
receiving MMS messages or content streaming).
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QNetworkConfiguration::BearerType
|
||||
|
||||
Specifies the type of bearer used by a configuration.
|
||||
|
||||
\value BearerUnknown The type of bearer is unknown or unspecified. The bearerTypeName()
|
||||
function may return additional information.
|
||||
\value BearerEthernet The configuration is for an Ethernet interfaces.
|
||||
\value BearerWLAN The configuration is for a Wireless LAN interface.
|
||||
\value Bearer2G The configuration is for a CSD, GPRS, HSCSD, EDGE or cdmaOne interface.
|
||||
\value BearerCDMA2000 The configuration is for CDMA interface.
|
||||
\value BearerWCDMA The configuration is for W-CDMA/UMTS interface.
|
||||
\value BearerHSPA The configuration is for High Speed Packet Access (HSPA) interface.
|
||||
\value BearerBluetooth The configuration is for a Bluetooth interface.
|
||||
\value BearerWiMAX The configuration is for a WiMAX interface.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs an invalid configuration object.
|
||||
|
||||
\sa isValid()
|
||||
*/
|
||||
QNetworkConfiguration::QNetworkConfiguration()
|
||||
: d(0)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates a copy of the QNetworkConfiguration object contained in \a other.
|
||||
*/
|
||||
QNetworkConfiguration::QNetworkConfiguration(const QNetworkConfiguration &other)
|
||||
: d(other.d)
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Frees the resources associated with the QNetworkConfiguration object.
|
||||
*/
|
||||
QNetworkConfiguration::~QNetworkConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
/*!
|
||||
Copies the content of the QNetworkConfiguration object contained in \a other into this one.
|
||||
*/
|
||||
QNetworkConfiguration &QNetworkConfiguration::operator=(const QNetworkConfiguration &other)
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true, if this configuration is the same as the \a other
|
||||
configuration given; otherwise returns false.
|
||||
*/
|
||||
bool QNetworkConfiguration::operator==(const QNetworkConfiguration &other) const
|
||||
{
|
||||
return (d == other.d);
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn bool QNetworkConfiguration::operator!=(const QNetworkConfiguration &other) const
|
||||
|
||||
Returns true if this configuration is not the same as the \a other
|
||||
configuration given; otherwise returns false.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the user visible name of this configuration.
|
||||
|
||||
The name may either be the name of the underlying access point or the
|
||||
name for service network that this configuration represents.
|
||||
*/
|
||||
QString QNetworkConfiguration::name() const
|
||||
{
|
||||
if (!d)
|
||||
return QString();
|
||||
return d->name;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the unique and platform specific identifier for this network configuration;
|
||||
otherwise an empty string.
|
||||
*/
|
||||
QString QNetworkConfiguration::identifier() const
|
||||
{
|
||||
if (!d)
|
||||
return QString();
|
||||
return d->id;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the type of the configuration.
|
||||
|
||||
A configuration can represent a single access point configuration or
|
||||
a set of access point configurations. Such a set is called service network.
|
||||
A configuration that is based on a service network can potentially support
|
||||
roaming of network sessions.
|
||||
*/
|
||||
QNetworkConfiguration::Type QNetworkConfiguration::type() const
|
||||
{
|
||||
if (!d)
|
||||
return QNetworkConfiguration::Invalid;
|
||||
return d->type;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if this QNetworkConfiguration object is valid.
|
||||
A configuration may become invalid if the user deletes the configuration or
|
||||
the configuration was default-constructed.
|
||||
|
||||
The addition and removal of configurations can be monitored via the
|
||||
QNetworkConfigurationManager.
|
||||
|
||||
\sa QNetworkConfigurationManager
|
||||
*/
|
||||
bool QNetworkConfiguration::isValid() const
|
||||
{
|
||||
if (!d)
|
||||
return false;
|
||||
return d->isValid;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current state of the configuration.
|
||||
*/
|
||||
QNetworkConfiguration::StateFlags QNetworkConfiguration::state() const
|
||||
{
|
||||
if (!d)
|
||||
return QNetworkConfiguration::Undefined;
|
||||
return d->state;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the purpose of this configuration.
|
||||
|
||||
The purpose field may be used to programmatically determine the
|
||||
purpose of a configuration. Such information is usually part of the
|
||||
access point or service network meta data.
|
||||
*/
|
||||
QNetworkConfiguration::Purpose QNetworkConfiguration::purpose() const
|
||||
{
|
||||
if (!d)
|
||||
return QNetworkConfiguration::UnknownPurpose;
|
||||
return d->purpose;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if this configuration supports roaming; otherwise false.
|
||||
*/
|
||||
bool QNetworkConfiguration::isRoamingAvailable() const
|
||||
{
|
||||
if (!d)
|
||||
return false;
|
||||
return d->roamingSupported;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns all sub configurations of this network configuration in priority order. The first sub
|
||||
configuration in the list has the highest priority.
|
||||
|
||||
Only network configurations of type \l ServiceNetwork can have children. Otherwise this
|
||||
function returns an empty list.
|
||||
*/
|
||||
QList<QNetworkConfiguration> QNetworkConfiguration::children() const
|
||||
{
|
||||
QList<QNetworkConfiguration> results;
|
||||
|
||||
if (!d)
|
||||
return results;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> locker(d->mutex);
|
||||
|
||||
if (d->type != QNetworkConfiguration::ServiceNetwork || !d->isValid)
|
||||
return results;
|
||||
|
||||
QMutableMapIterator<unsigned int, QNetworkConfigurationPrivatePointer> i(d->serviceNetworkMembers);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
|
||||
QNetworkConfigurationPrivatePointer p = i.value();
|
||||
|
||||
//if we have an invalid member get rid of it -> was deleted earlier on
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> childLocker(p->mutex);
|
||||
|
||||
if (!p->isValid) {
|
||||
i.remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
QNetworkConfiguration item;
|
||||
item.d = p;
|
||||
results << item;
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/*!
|
||||
\fn QString QNetworkConfiguration::bearerName() const
|
||||
\deprecated
|
||||
|
||||
This function is deprecated. It is equivalent to calling bearerTypeName(), however
|
||||
bearerType() should be used in preference.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the type of bearer used by this network configuration.
|
||||
|
||||
If the bearer type is \l {QNetworkConfiguration::BearerUnknown}{unknown} the bearerTypeName()
|
||||
function can be used to retrieve a textural type name for the bearer.
|
||||
|
||||
An invalid network configuration always returns the BearerUnknown value.
|
||||
*/
|
||||
QNetworkConfiguration::BearerType QNetworkConfiguration::bearerType() const
|
||||
{
|
||||
if (!isValid())
|
||||
return BearerUnknown;
|
||||
return d->bearerType;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the type of bearer used by this network configuration as a string.
|
||||
|
||||
The string is not translated and therefore can not be shown to the user. The subsequent table
|
||||
shows the fixed mappings between BearerType and the bearer type name for known types. If the
|
||||
BearerType is unknown this function may return additional information if it is available;
|
||||
otherwise an empty string will be returned.
|
||||
|
||||
\table
|
||||
\header
|
||||
\o BearerType
|
||||
\o Value
|
||||
\row
|
||||
\o BearerUnknown
|
||||
\o
|
||||
\o The session is based on an unknown or unspecified bearer type. The value of the
|
||||
string returned describes the bearer type.
|
||||
\row
|
||||
\o BearerEthernet
|
||||
\o Ethernet
|
||||
\row
|
||||
\o BearerWLAN
|
||||
\o WLAN
|
||||
\row
|
||||
\o Bearer2G
|
||||
\o 2G
|
||||
\row
|
||||
\o BearerCDMA2000
|
||||
\o CDMA2000
|
||||
\row
|
||||
\o BearerWCDMA
|
||||
\o WCDMA
|
||||
\row
|
||||
\o BearerHSPA
|
||||
\o HSPA
|
||||
\row
|
||||
\o BearerBluetooth
|
||||
\o Bluetooth
|
||||
\row
|
||||
\o BearerWiMAX
|
||||
\o WiMAX
|
||||
\endtable
|
||||
|
||||
This function returns an empty string if this is an invalid configuration, a network
|
||||
configuration of type \l QNetworkConfiguration::ServiceNetwork or
|
||||
\l QNetworkConfiguration::UserChoice.
|
||||
|
||||
\sa bearerType()
|
||||
*/
|
||||
QString QNetworkConfiguration::bearerTypeName() const
|
||||
{
|
||||
if (!isValid())
|
||||
return QString();
|
||||
|
||||
if (d->type == QNetworkConfiguration::ServiceNetwork ||
|
||||
d->type == QNetworkConfiguration::UserChoice)
|
||||
return QString();
|
||||
|
||||
switch (d->bearerType) {
|
||||
case BearerUnknown:
|
||||
return d->bearerTypeName();
|
||||
case BearerEthernet:
|
||||
return QLatin1String("Ethernet");
|
||||
case BearerWLAN:
|
||||
return QLatin1String("WLAN");
|
||||
case Bearer2G:
|
||||
return QLatin1String("2G");
|
||||
case BearerCDMA2000:
|
||||
return QLatin1String("CDMA2000");
|
||||
case BearerWCDMA:
|
||||
return QLatin1String("WCDMA");
|
||||
case BearerHSPA:
|
||||
return QLatin1String("HSPA");
|
||||
case BearerBluetooth:
|
||||
return QLatin1String("Bluetooth");
|
||||
case BearerWiMAX:
|
||||
return QLatin1String("WiMAX");
|
||||
}
|
||||
|
||||
return QLatin1String("Unknown");
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
|
@ -1,104 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKCONFIGURATION_H
|
||||
#define QNETWORKCONFIGURATION_H
|
||||
|
||||
#include <QtCore/qshareddata.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkConfigurationPrivate;
|
||||
class Q_NETWORK_EXPORT QNetworkConfiguration
|
||||
{
|
||||
public:
|
||||
QNetworkConfiguration();
|
||||
QNetworkConfiguration(const QNetworkConfiguration& other);
|
||||
QNetworkConfiguration &operator=(const QNetworkConfiguration &other);
|
||||
~QNetworkConfiguration();
|
||||
|
||||
bool operator==(const QNetworkConfiguration &other) const;
|
||||
inline bool operator!=(const QNetworkConfiguration &other) const
|
||||
{ return !operator==(other); }
|
||||
|
||||
enum Type {
|
||||
InternetAccessPoint = 0,
|
||||
ServiceNetwork,
|
||||
UserChoice,
|
||||
Invalid
|
||||
};
|
||||
|
||||
enum Purpose {
|
||||
UnknownPurpose = 0,
|
||||
PublicPurpose,
|
||||
PrivatePurpose,
|
||||
ServiceSpecificPurpose
|
||||
};
|
||||
|
||||
enum StateFlag {
|
||||
Undefined = 0x0000001,
|
||||
Defined = 0x0000002,
|
||||
Discovered = 0x0000006,
|
||||
Active = 0x000000e
|
||||
};
|
||||
Q_DECLARE_FLAGS(StateFlags, StateFlag)
|
||||
|
||||
enum BearerType {
|
||||
BearerUnknown,
|
||||
BearerEthernet,
|
||||
BearerWLAN,
|
||||
Bearer2G,
|
||||
BearerCDMA2000,
|
||||
BearerWCDMA,
|
||||
BearerHSPA,
|
||||
BearerBluetooth,
|
||||
BearerWiMAX
|
||||
};
|
||||
|
||||
StateFlags state() const;
|
||||
Type type() const;
|
||||
Purpose purpose() const;
|
||||
|
||||
BearerType bearerType() const;
|
||||
QString bearerTypeName() const;
|
||||
|
||||
QString identifier() const;
|
||||
bool isRoamingAvailable() const;
|
||||
QList<QNetworkConfiguration> children() const;
|
||||
|
||||
QString name() const;
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
friend class QNetworkConfigurationPrivate;
|
||||
friend class QNetworkConfigurationManager;
|
||||
friend class QNetworkConfigurationManagerPrivate;
|
||||
friend class QNetworkSessionPrivate;
|
||||
QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> d;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
|
||||
#endif // QNETWORKCONFIGURATION_H
|
|
@ -1,86 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKCONFIGURATIONPRIVATE_H
|
||||
#define QNETWORKCONFIGURATIONPRIVATE_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qnetworkconfiguration.h"
|
||||
|
||||
#include <QtCore/qshareddata.h>
|
||||
#include <QtCore/qmutex.h>
|
||||
#include <QtCore/qmap.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef QExplicitlySharedDataPointer<QNetworkConfigurationPrivate> QNetworkConfigurationPrivatePointer;
|
||||
class QNetworkConfigurationPrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
QNetworkConfigurationPrivate() :
|
||||
type(QNetworkConfiguration::Invalid),
|
||||
purpose(QNetworkConfiguration::UnknownPurpose),
|
||||
bearerType(QNetworkConfiguration::BearerUnknown),
|
||||
isValid(false), roamingSupported(false)
|
||||
{}
|
||||
virtual ~QNetworkConfigurationPrivate()
|
||||
{
|
||||
//release pointers to member configurations
|
||||
serviceNetworkMembers.clear();
|
||||
}
|
||||
|
||||
virtual QString bearerTypeName() const
|
||||
{
|
||||
return QLatin1String("Unknown");
|
||||
}
|
||||
|
||||
QMap<unsigned int, QNetworkConfigurationPrivatePointer> serviceNetworkMembers;
|
||||
|
||||
mutable std::recursive_mutex mutex;
|
||||
|
||||
QString name;
|
||||
QString id;
|
||||
|
||||
QNetworkConfiguration::StateFlags state;
|
||||
QNetworkConfiguration::Type type;
|
||||
QNetworkConfiguration::Purpose purpose;
|
||||
QNetworkConfiguration::BearerType bearerType;
|
||||
|
||||
bool isValid;
|
||||
bool roamingSupported;
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(QNetworkConfigurationPrivate)
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QNETWORKCONFIGURATIONPRIVATE_H
|
|
@ -1,651 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnetworksession.h"
|
||||
#include "qbearerengine_p.h"
|
||||
#include "qnetworkcommon_p.h"
|
||||
|
||||
#include <QEventLoop>
|
||||
#include <QTimer>
|
||||
#include <QThread>
|
||||
|
||||
#include "qnetworkconfigmanager_p.h"
|
||||
#include "qnetworksession_p.h"
|
||||
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
/*!
|
||||
\class QNetworkSession
|
||||
|
||||
\brief The QNetworkSession class provides control over the system's access points
|
||||
and enables session management for cases when multiple clients access the same access point.
|
||||
|
||||
\since 4.7
|
||||
|
||||
\inmodule QtNetwork
|
||||
\ingroup network
|
||||
|
||||
A QNetworkSession enables control over the system's network interfaces. The session's configuration
|
||||
parameter are determined via the QNetworkConfiguration object to which it is bound. Depending on the
|
||||
type of the session (single access point or service network) a session may be linked to one or more
|
||||
network interfaces. By means of \l{open()}{opening} and \l{close()}{closing} of network sessions
|
||||
a developer can start and stop the systems network interfaces. If the configuration represents
|
||||
multiple access points (see \l QNetworkConfiguration::ServiceNetwork) more advanced features such as roaming may be supported.
|
||||
|
||||
QNetworkSession supports session management within the same process and depending on the platform's
|
||||
capabilities may support out-of-process sessions. If the same
|
||||
network configuration is used by multiple open sessions the underlying network interface is only terminated once
|
||||
the last session has been closed.
|
||||
|
||||
\section1 Roaming
|
||||
|
||||
Applications may connect to the preferredConfigurationChanged() signal in order to
|
||||
receive notifications when a more suitable access point becomes available.
|
||||
In response to this signal the application must either initiate the roaming via migrate()
|
||||
or ignore() the new access point. Once the session has roamed the
|
||||
newConfigurationActivated() signal is emitted. The application may now test the
|
||||
carrier and must either accept() or reject() it. The session will return to the previous
|
||||
access point if the roaming was rejected. The subsequent state diagram depicts the required
|
||||
state transitions.
|
||||
|
||||
\image roaming-states.png
|
||||
|
||||
Some platforms may distinguish forced roaming and application level roaming (ALR).
|
||||
ALR implies that the application controls (via migrate(), ignore(), accept() and reject())
|
||||
whether a network session can roam from one access point to the next. Such control is useful
|
||||
if the application maintains stateful socket connections and wants to control the transition from
|
||||
one interface to the next. Forced roaming implies that the system automatically roams to the next network without
|
||||
consulting the application. This has the advantage that the application can make use of roaming features
|
||||
without actually being aware of it. It is expected that the application detects that the underlying
|
||||
socket is broken and automatically reconnects via the new network link.
|
||||
|
||||
If the platform supports both modes of roaming, an application indicates its preference
|
||||
by connecting to the preferredConfigurationChanged() signal. Connecting to this signal means that
|
||||
the application wants to take control over the roaming behavior and therefore implies application
|
||||
level roaming. If the client does not connect to the preferredConfigurationChanged(), forced roaming
|
||||
is used. If forced roaming is not supported the network session will not roam by default.
|
||||
|
||||
Some applications may want to suppress any form of roaming altogether. Possible use cases may be
|
||||
high priority downloads or remote services which cannot handle a roaming enabled client. Clients
|
||||
can suppress roaming by connecting to the preferredConfigurationChanged() signal and answer each
|
||||
signal emission with ignore().
|
||||
|
||||
\sa QNetworkConfiguration, QNetworkConfigurationManager
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QNetworkSession::State
|
||||
|
||||
This enum describes the connectivity state of the session. If the session is based on a
|
||||
single access point configuration the state of the session is the same as the state of the
|
||||
associated network interface.
|
||||
|
||||
\value Invalid The session is invalid due to an invalid configuration. This may
|
||||
happen due to a removed access point or a configuration that was
|
||||
invalid to begin with.
|
||||
\value NotAvailable The session is based on a defined but not yet discovered QNetworkConfiguration
|
||||
(see \l QNetworkConfiguration::StateFlag).
|
||||
\value Connecting The network session is being established.
|
||||
\value Connected The network session is connected. If the current process wishes to use this session
|
||||
it has to register its interest by calling open(). A network session
|
||||
is considered to be ready for socket operations if it isOpen() and connected.
|
||||
\value Closing The network session is in the process of being shut down.
|
||||
\value Disconnected The network session is not connected. The associated QNetworkConfiguration
|
||||
has the state QNetworkConfiguration::Discovered.
|
||||
\value Roaming The network session is roaming from one access point to another
|
||||
access point.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\enum QNetworkSession::SessionError
|
||||
|
||||
This enum describes the session errors that can occur.
|
||||
|
||||
\value UnknownSessionError An unidentified error occurred.
|
||||
\value SessionAbortedError The session was aborted by the user or system.
|
||||
\value RoamingError The session cannot roam to a new configuration.
|
||||
\value OperationNotSupportedError The operation is not supported for current configuration.
|
||||
\value InvalidConfigurationError The operation cannot currently be performed for the
|
||||
current configuration.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkSession::stateChanged(QNetworkSession::State state)
|
||||
|
||||
This signal is emitted whenever the state of the network session changes.
|
||||
The \a state parameter is the new state.
|
||||
|
||||
\sa state()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkSession::error(QNetworkSession::SessionError error)
|
||||
|
||||
This signal is emitted after an error occurred. The \a error parameter
|
||||
describes the error that occurred.
|
||||
|
||||
\sa error(), errorString()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkSession::preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless)
|
||||
|
||||
This signal is emitted when the preferred configuration/access point for the
|
||||
session changes. Only sessions which are based on service network configurations
|
||||
may emit this signal. \a config can be used to determine access point specific
|
||||
details such as proxy settings and \a isSeamless indicates whether roaming will
|
||||
break the sessions IP address.
|
||||
|
||||
As a consequence to this signal the application must either start the roaming process
|
||||
by calling migrate() or choose to ignore() the new access point.
|
||||
|
||||
If the roaming process is non-seamless the IP address will change which means that
|
||||
a socket becomes invalid. However seamless mobility can ensure that the local IP address
|
||||
does not change. This is achieved by using a virtual IP address which is bound to the actual
|
||||
link address. During the roaming process the virtual address is attached to the new link
|
||||
address.
|
||||
|
||||
Some platforms may support the concept of Forced Roaming and Application Level Roaming (ALR).
|
||||
Forced roaming implies that the platform may simply roam to a new configuration without
|
||||
consulting applications. It is up to the application to detect the link layer loss and reestablish
|
||||
its sockets. In contrast ALR provides the opportunity to prevent the system from roaming.
|
||||
If this session is based on a configuration that supports roaming the application can choose
|
||||
whether it wants to be consulted (ALR use case) by connecting to this signal. For as long as this signal
|
||||
connection remains the session remains registered as a roaming stakeholder; otherwise roaming will
|
||||
be enforced by the platform.
|
||||
|
||||
\sa migrate(), ignore(), QNetworkConfiguration::isRoamingAvailable()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkSession::newConfigurationActivated()
|
||||
|
||||
This signal is emitted once the session has roamed to the new access point.
|
||||
The application may reopen its socket and test the suitability of the new network link.
|
||||
Subsequently it must either accept() or reject() the new access point.
|
||||
|
||||
\sa accept(), reject()
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkSession::opened()
|
||||
|
||||
This signal is emitted when the network session has been opened.
|
||||
|
||||
The underlying network interface will not be shut down as long as the session remains open.
|
||||
Note that this feature is dependent on \l{QNetworkConfigurationManager::SystemSessionSupport}{system wide session support}.
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn void QNetworkSession::closed()
|
||||
|
||||
This signal is emitted when the network session has been closed.
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a session based on \a connectionConfig with the given \a parent.
|
||||
|
||||
\sa QNetworkConfiguration
|
||||
*/
|
||||
QNetworkSession::QNetworkSession(const QNetworkConfiguration &connectionConfig, QObject *parent)
|
||||
: QObject(parent), d(0)
|
||||
{
|
||||
// invalid configuration
|
||||
if (!connectionConfig.identifier().isEmpty()) {
|
||||
foreach (QBearerEngine *engine, qNetworkConfigurationManagerPrivate()->engines()) {
|
||||
if (engine->hasIdentifier(connectionConfig.identifier())) {
|
||||
d = engine->createSessionBackend();
|
||||
d->publicConfig = connectionConfig;
|
||||
d->syncStateWithInterface();
|
||||
connect(d, SIGNAL(quitPendingWaitsForOpened()), this, SIGNAL(opened()));
|
||||
connect(d, SIGNAL(error(QNetworkSession::SessionError)),
|
||||
this, SIGNAL(error(QNetworkSession::SessionError)));
|
||||
connect(d, SIGNAL(stateChanged(QNetworkSession::State)),
|
||||
this, SIGNAL(stateChanged(QNetworkSession::State)));
|
||||
connect(d, SIGNAL(closed()), this, SIGNAL(closed()));
|
||||
connect(d, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)),
|
||||
this, SIGNAL(preferredConfigurationChanged(QNetworkConfiguration,bool)));
|
||||
connect(d, SIGNAL(newConfigurationActivated()),
|
||||
this, SIGNAL(newConfigurationActivated()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qRegisterMetaType<QNetworkSession::State>();
|
||||
qRegisterMetaType<QNetworkSession::SessionError>();
|
||||
}
|
||||
|
||||
/*!
|
||||
Frees the resources associated with the QNetworkSession object.
|
||||
*/
|
||||
QNetworkSession::~QNetworkSession()
|
||||
{
|
||||
delete d;
|
||||
}
|
||||
|
||||
/*!
|
||||
Creates an open session which increases the session counter on the underlying network interface.
|
||||
The system will not terminate a network interface until the session reference counter reaches zero.
|
||||
Therefore an open session allows an application to register its use of the interface.
|
||||
|
||||
As a result of calling open() the interface will be started if it is not connected/up yet.
|
||||
Some platforms may not provide support for out-of-process sessions. On such platforms the session
|
||||
counter ignores any sessions held by another process. The platform capabilities can be
|
||||
detected via QNetworkConfigurationManager::capabilities().
|
||||
|
||||
Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired
|
||||
by connecting to the stateChanged(), opened() or error() signals.
|
||||
|
||||
It is not a requirement to open a session in order to monitor the underlying network interface.
|
||||
|
||||
\sa close(), stop(), isOpen()
|
||||
*/
|
||||
void QNetworkSession::open()
|
||||
{
|
||||
if (d)
|
||||
d->open();
|
||||
else
|
||||
emit error(InvalidConfigurationError);
|
||||
}
|
||||
|
||||
/*!
|
||||
Waits until the session has been opened, up to \a msecs milliseconds. If the session has been opened, this
|
||||
function returns true; otherwise it returns false. In the case where it returns false, you can call error()
|
||||
to determine the cause of the error.
|
||||
|
||||
The following example waits up to one second for the session to be opened:
|
||||
|
||||
\code
|
||||
session->open();
|
||||
if (session->waitForOpened(1000))
|
||||
qDebug("Open!");
|
||||
\endcode
|
||||
|
||||
If \a msecs is -1, this function will not time out.
|
||||
|
||||
\sa open(), error()
|
||||
*/
|
||||
bool QNetworkSession::waitForOpened(int msecs)
|
||||
{
|
||||
if (!d)
|
||||
return false;
|
||||
|
||||
if (d->isOpen)
|
||||
return true;
|
||||
|
||||
if (!(d->state == Connecting || d->state == Connected)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
QEventLoop loop;
|
||||
QObject::connect(d, SIGNAL(quitPendingWaitsForOpened()), &loop, SLOT(quit()));
|
||||
QObject::connect(this, SIGNAL(error(QNetworkSession::SessionError)), &loop, SLOT(quit()));
|
||||
|
||||
//final call
|
||||
if (msecs >= 0)
|
||||
QTimer::singleShot(msecs, &loop, SLOT(quit()));
|
||||
|
||||
// enter the event loop and wait for opened/error/timeout
|
||||
loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::WaitForMoreEvents);
|
||||
|
||||
return d->isOpen;
|
||||
}
|
||||
|
||||
/*!
|
||||
Decreases the session counter on the associated network configuration. If the session counter reaches zero
|
||||
the active network interface is shut down. This also means that state() will only change from \l Connected to
|
||||
\l Disconnected if the current session was the last open session.
|
||||
|
||||
If the platform does not support out-of-process sessions calling this function does not stop the
|
||||
interface. In this case \l{stop()} has to be used to force a shut down.
|
||||
The platform capabilities can be detected via QNetworkConfigurationManager::capabilities().
|
||||
|
||||
Note that this call is asynchronous. Depending on the outcome of this call the results can be enquired
|
||||
by connecting to the stateChanged(), opened() or error() signals.
|
||||
|
||||
\sa open(), stop(), isOpen()
|
||||
*/
|
||||
void QNetworkSession::close()
|
||||
{
|
||||
if (d)
|
||||
d->close();
|
||||
}
|
||||
|
||||
/*!
|
||||
Invalidates all open sessions against the network interface and therefore stops the
|
||||
underlying network interface. This function always changes the session's state() flag to
|
||||
\l Disconnected.
|
||||
|
||||
On Symbian platform, a 'NetworkControl' capability is required for
|
||||
full interface-level stop (without the capability, only the current session is stopped).
|
||||
|
||||
\sa open(), close()
|
||||
*/
|
||||
void QNetworkSession::stop()
|
||||
{
|
||||
if (d)
|
||||
d->stop();
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the QNetworkConfiguration that this network session object is based on.
|
||||
|
||||
\sa QNetworkConfiguration
|
||||
*/
|
||||
QNetworkConfiguration QNetworkSession::configuration() const
|
||||
{
|
||||
return d ? d->publicConfig : QNetworkConfiguration();
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKINTERFACE
|
||||
/*!
|
||||
Returns the network interface that is used by this session.
|
||||
|
||||
This function only returns a valid QNetworkInterface when this session is \l Connected.
|
||||
|
||||
The returned interface may change as a result of a roaming process.
|
||||
|
||||
Note: this function does not work in Symbian emulator due to the way the
|
||||
connectivity is emulated on Windows.
|
||||
|
||||
\sa state()
|
||||
*/
|
||||
QNetworkInterface QNetworkSession::interface() const
|
||||
{
|
||||
return d ? d->currentInterface() : QNetworkInterface();
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Returns true if this session is open. If the number of all open sessions is greater than
|
||||
zero the underlying network interface will remain connected/up.
|
||||
|
||||
The session can be controlled via open() and close().
|
||||
*/
|
||||
bool QNetworkSession::isOpen() const
|
||||
{
|
||||
return d ? d->isOpen : false;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the state of the session.
|
||||
|
||||
If the session is based on a single access point configuration the state of the
|
||||
session is the same as the state of the associated network interface. Therefore
|
||||
a network session object can be used to monitor network interfaces.
|
||||
|
||||
A \l QNetworkConfiguration::ServiceNetwork based session summarizes the state of all its children
|
||||
and therefore returns the \l Connected state if at least one of the service network's
|
||||
\l {QNetworkConfiguration::children()}{children()} configurations is active.
|
||||
|
||||
Note that it is not required to hold an open session in order to obtain the network interface state.
|
||||
A connected but closed session may be used to monitor network interfaces whereas an open and connected
|
||||
session object may prevent the network interface from being shut down.
|
||||
|
||||
\sa error(), stateChanged()
|
||||
*/
|
||||
QNetworkSession::State QNetworkSession::state() const
|
||||
{
|
||||
return d ? d->state : QNetworkSession::Invalid;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the type of error that last occurred.
|
||||
|
||||
\sa state(), errorString()
|
||||
*/
|
||||
QNetworkSession::SessionError QNetworkSession::error() const
|
||||
{
|
||||
return d ? d->error() : InvalidConfigurationError;
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns a human-readable description of the last device error that
|
||||
occurred.
|
||||
|
||||
\sa error()
|
||||
*/
|
||||
QString QNetworkSession::errorString() const
|
||||
{
|
||||
return d ? d->errorString() : tr("Invalid configuration.");
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the value for property \a key.
|
||||
|
||||
A network session can have properties attached which may describe the session in more details.
|
||||
This function can be used to gain access to those properties.
|
||||
|
||||
The following property keys are guaranteed to be specified on all platforms:
|
||||
|
||||
\table
|
||||
\header
|
||||
\o Key \o Description
|
||||
\row
|
||||
\o ActiveConfiguration
|
||||
\o If the session \l isOpen() this property returns the identifier of the
|
||||
QNetworkConfiguration that is used by this session; otherwise an empty string.
|
||||
|
||||
The main purpose of this key is to determine which Internet access point is used
|
||||
if the session is based on a \l{QNetworkConfiguration::ServiceNetwork}{ServiceNetwork}.
|
||||
The following code snippet highlights the difference:
|
||||
\code
|
||||
QNetworkConfigurationManager mgr;
|
||||
QNetworkConfiguration ap = mgr.defaultConfiguration();
|
||||
QNetworkSession *session = new QNetworkSession(ap);
|
||||
... //code activates session
|
||||
|
||||
QString ident = session->sessionProperty("ActiveConfiguration").toString();
|
||||
if ( ap.type() == QNetworkConfiguration::ServiceNetwork ) {
|
||||
Q_ASSERT( ap.identifier() != ident );
|
||||
Q_ASSERT( ap.children().contains( mgr.configurationFromIdentifier(ident) ) );
|
||||
} else if ( ap.type() == QNetworkConfiguration::InternetAccessPoint ) {
|
||||
Q_ASSERT( ap.identifier() == ident );
|
||||
}
|
||||
\endcode
|
||||
\row
|
||||
\o UserChoiceConfiguration
|
||||
\o If the session \l isOpen() and is bound to a QNetworkConfiguration of type
|
||||
UserChoice, this property returns the identifier of the QNetworkConfiguration that the
|
||||
configuration resolved to when \l open() was called; otherwise an empty string.
|
||||
|
||||
The purpose of this key is to determine the real QNetworkConfiguration that the
|
||||
session is using. This key is different from \e ActiveConfiguration in that
|
||||
this key may return an identifier for either a
|
||||
\l {QNetworkConfiguration::ServiceNetwork}{service network} or a
|
||||
\l {QNetworkConfiguration::InternetAccessPoint}{Internet access points} configurations,
|
||||
whereas \e ActiveConfiguration always returns identifiers to
|
||||
\l {QNetworkConfiguration::InternetAccessPoint}{Internet access points} configurations.
|
||||
\row
|
||||
\o ConnectInBackground
|
||||
\o Setting this property to \e true before calling \l open() implies that the connection attempt
|
||||
is made but if no connection can be established, the user is not connsulted and asked to select
|
||||
a suitable connection. This property is not set by default and support for it depends on the platform.
|
||||
|
||||
\row
|
||||
\o AutoCloseSessionTimeout
|
||||
\o If the session requires polling to keep its state up to date, this property holds
|
||||
the timeout in milliseconds before the session will automatically close. If the
|
||||
value of this property is -1 the session will not automatically close. This property
|
||||
is set to -1 by default.
|
||||
|
||||
The purpose of this property is to minimize resource use on platforms that use
|
||||
polling to update the state of the session. Applications can set the value of this
|
||||
property to the desired timeout before the session is closed. In response to the
|
||||
closed() signal the network session should be deleted to ensure that all polling is
|
||||
stopped. The session can then be recreated once it is required again. This property
|
||||
has no effect for sessions that do not require polling.
|
||||
\endtable
|
||||
*/
|
||||
QVariant QNetworkSession::sessionProperty(const QString &key) const
|
||||
{
|
||||
if (!d || !d->publicConfig.isValid())
|
||||
return QVariant();
|
||||
|
||||
if (key == QLatin1String("ActiveConfiguration"))
|
||||
return d->isOpen ? d->activeConfig.identifier() : QString();
|
||||
|
||||
if (key == QLatin1String("UserChoiceConfiguration")) {
|
||||
if (!d->isOpen || d->publicConfig.type() != QNetworkConfiguration::UserChoice)
|
||||
return QString();
|
||||
|
||||
if (d->serviceConfig.isValid())
|
||||
return d->serviceConfig.identifier();
|
||||
else
|
||||
return d->activeConfig.identifier();
|
||||
}
|
||||
|
||||
return d->sessionProperty(key);
|
||||
}
|
||||
|
||||
/*!
|
||||
Sets the property \a value on the session. The property is identified using
|
||||
\a key. Removing an already set property can be achieved by passing an
|
||||
invalid QVariant.
|
||||
|
||||
Note that the \e UserChoiceConfiguration and \e ActiveConfiguration
|
||||
properties are read only and cannot be changed using this method.
|
||||
*/
|
||||
void QNetworkSession::setSessionProperty(const QString &key, const QVariant &value)
|
||||
{
|
||||
if (!d)
|
||||
return;
|
||||
|
||||
if (key == QLatin1String("ActiveConfiguration") ||
|
||||
key == QLatin1String("UserChoiceConfiguration")) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->setSessionProperty(key, value);
|
||||
}
|
||||
|
||||
/*!
|
||||
Instructs the session to roam to the new access point. The old access point remains active
|
||||
until the application calls accept().
|
||||
|
||||
The newConfigurationActivated() signal is emitted once roaming has been completed.
|
||||
|
||||
\sa accept()
|
||||
*/
|
||||
void QNetworkSession::migrate()
|
||||
{
|
||||
if (d)
|
||||
d->migrate();
|
||||
}
|
||||
|
||||
/*!
|
||||
This function indicates that the application does not wish to roam the session.
|
||||
|
||||
\sa migrate()
|
||||
*/
|
||||
void QNetworkSession::ignore()
|
||||
{
|
||||
// Needed on at least Symbian platform: the roaming must be explicitly
|
||||
// ignore()'d or migrate()'d
|
||||
if (d)
|
||||
d->ignore();
|
||||
}
|
||||
|
||||
/*!
|
||||
Instructs the session to permanently accept the new access point. Once this function
|
||||
has been called the session may not return to the old access point.
|
||||
|
||||
The old access point may be closed in the process if there are no other network sessions for it.
|
||||
Therefore any open socket that still uses the old access point
|
||||
may become unusable and should be closed before completing the migration.
|
||||
*/
|
||||
void QNetworkSession::accept()
|
||||
{
|
||||
if (d)
|
||||
d->accept();
|
||||
}
|
||||
|
||||
/*!
|
||||
The new access point is not suitable for the application. By calling this function the
|
||||
session returns to the previous access point/configuration. This action may invalidate
|
||||
any socket that has been created via the not desired access point.
|
||||
|
||||
\sa accept()
|
||||
*/
|
||||
void QNetworkSession::reject()
|
||||
{
|
||||
if (d)
|
||||
d->reject();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Returns the amount of data sent in bytes; otherwise 0.
|
||||
|
||||
This field value includes the usage across all open network
|
||||
sessions which use the same network interface.
|
||||
|
||||
If the session is based on a service network configuration the number of
|
||||
sent bytes across all active member configurations are returned.
|
||||
|
||||
This function may not always be supported on all platforms and returns 0.
|
||||
The platform capability can be detected via QNetworkConfigurationManager::DataStatistics.
|
||||
|
||||
\note On some platforms this function may run the main event loop.
|
||||
*/
|
||||
quint64 QNetworkSession::bytesWritten() const
|
||||
{
|
||||
return d ? d->bytesWritten() : Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the amount of data received in bytes; otherwise 0.
|
||||
|
||||
This field value includes the usage across all open network
|
||||
sessions which use the same network interface.
|
||||
|
||||
If the session is based on a service network configuration the number of
|
||||
sent bytes across all active member configurations are returned.
|
||||
|
||||
This function may not always be supported on all platforms and returns 0.
|
||||
The platform capability can be detected via QNetworkConfigurationManager::DataStatistics.
|
||||
|
||||
\note On some platforms this function may run the main event loop.
|
||||
*/
|
||||
quint64 QNetworkSession::bytesReceived() const
|
||||
{
|
||||
return d ? d->bytesReceived() : Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the number of seconds that the session has been active.
|
||||
*/
|
||||
quint64 QNetworkSession::activeTime() const
|
||||
{
|
||||
return d ? d->activeTime() : Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#include "moc_qnetworksession.h"
|
||||
|
||||
#include "moc_qnetworksession_p.h"
|
|
@ -1,113 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKSESSION_H
|
||||
#define QNETWORKSESSION_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qstring.h>
|
||||
#include <QtCore/qvariant.h>
|
||||
#include <QtCore/qshareddata.h>
|
||||
#include <QtNetwork/qnetworkinterface.h>
|
||||
#include <QtNetwork/qnetworkconfiguration.h>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkSessionPrivate;
|
||||
class Q_NETWORK_EXPORT QNetworkSession : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum State {
|
||||
Invalid = 0,
|
||||
NotAvailable,
|
||||
Connecting,
|
||||
Connected,
|
||||
Closing,
|
||||
Disconnected,
|
||||
Roaming
|
||||
};
|
||||
|
||||
enum SessionError {
|
||||
UnknownSessionError = 0,
|
||||
SessionAbortedError,
|
||||
RoamingError,
|
||||
OperationNotSupportedError,
|
||||
InvalidConfigurationError
|
||||
};
|
||||
|
||||
explicit QNetworkSession(const QNetworkConfiguration &connConfig, QObject *parent = nullptr);
|
||||
virtual ~QNetworkSession();
|
||||
|
||||
bool isOpen() const;
|
||||
QNetworkConfiguration configuration() const;
|
||||
#ifndef QT_NO_NETWORKINTERFACE
|
||||
QNetworkInterface interface() const;
|
||||
#endif
|
||||
|
||||
State state() const;
|
||||
SessionError error() const;
|
||||
QString errorString() const;
|
||||
QVariant sessionProperty(const QString &key) const;
|
||||
void setSessionProperty(const QString &key, const QVariant &value);
|
||||
|
||||
quint64 bytesWritten() const;
|
||||
quint64 bytesReceived() const;
|
||||
quint64 activeTime() const;
|
||||
|
||||
bool waitForOpened(int msecs = 30000);
|
||||
|
||||
public Q_SLOTS:
|
||||
void open();
|
||||
void close();
|
||||
void stop();
|
||||
|
||||
//roaming related slots
|
||||
void migrate();
|
||||
void ignore();
|
||||
void accept();
|
||||
void reject();
|
||||
|
||||
Q_SIGNALS:
|
||||
void stateChanged(QNetworkSession::State);
|
||||
void opened();
|
||||
void closed();
|
||||
void error(QNetworkSession::SessionError);
|
||||
void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
|
||||
void newConfigurationActivated();
|
||||
|
||||
private:
|
||||
QNetworkSessionPrivate *d;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QNetworkSession::State)
|
||||
Q_DECLARE_METATYPE(QNetworkSession::SessionError)
|
||||
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QNETWORKSESSION_H
|
|
@ -1,133 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKSESSIONPRIVATE_H
|
||||
#define QNETWORKSESSIONPRIVATE_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qnetworksession.h"
|
||||
#include "qnetworkconfiguration_p.h"
|
||||
#include "QtCore/qsharedpointer.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class Q_NETWORK_EXPORT QNetworkSessionPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class QNetworkSession;
|
||||
|
||||
public:
|
||||
QNetworkSessionPrivate() : QObject(),
|
||||
state(QNetworkSession::Invalid), isOpen(false)
|
||||
{}
|
||||
virtual ~QNetworkSessionPrivate()
|
||||
{}
|
||||
|
||||
//called by QNetworkSession constructor and ensures
|
||||
//that the state is immediately updated (w/o actually opening
|
||||
//a session). Also this function should take care of
|
||||
//notification hooks to discover future state changes.
|
||||
virtual void syncStateWithInterface() = 0;
|
||||
|
||||
#ifndef QT_NO_NETWORKINTERFACE
|
||||
virtual QNetworkInterface currentInterface() const = 0;
|
||||
#endif
|
||||
virtual QVariant sessionProperty(const QString &key) const = 0;
|
||||
virtual void setSessionProperty(const QString &key, const QVariant &value) = 0;
|
||||
|
||||
virtual void open() = 0;
|
||||
virtual void close() = 0;
|
||||
virtual void stop() = 0;
|
||||
|
||||
virtual void migrate() = 0;
|
||||
virtual void accept() = 0;
|
||||
virtual void ignore() = 0;
|
||||
virtual void reject() = 0;
|
||||
|
||||
virtual QString errorString() const = 0; //must return translated string
|
||||
virtual QNetworkSession::SessionError error() const = 0;
|
||||
|
||||
virtual quint64 bytesWritten() const = 0;
|
||||
virtual quint64 bytesReceived() const = 0;
|
||||
virtual quint64 activeTime() const = 0;
|
||||
|
||||
protected:
|
||||
inline QNetworkConfigurationPrivatePointer privateConfiguration(const QNetworkConfiguration &config) const
|
||||
{
|
||||
return config.d;
|
||||
}
|
||||
|
||||
inline void setPrivateConfiguration(QNetworkConfiguration &config,
|
||||
QNetworkConfigurationPrivatePointer ptr) const
|
||||
{
|
||||
config.d = ptr;
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
//releases any pending waitForOpened() calls
|
||||
void quitPendingWaitsForOpened();
|
||||
|
||||
void error(QNetworkSession::SessionError error);
|
||||
void stateChanged(QNetworkSession::State state);
|
||||
void closed();
|
||||
void newConfigurationActivated();
|
||||
void preferredConfigurationChanged(const QNetworkConfiguration &config, bool isSeamless);
|
||||
|
||||
protected:
|
||||
// The config set on QNetworkSession.
|
||||
QNetworkConfiguration publicConfig;
|
||||
|
||||
// If publicConfig is a ServiceNetwork this is a copy of publicConfig.
|
||||
// If publicConfig is an UserChoice that is resolved to a ServiceNetwork this is the actual
|
||||
// ServiceNetwork configuration.
|
||||
QNetworkConfiguration serviceConfig;
|
||||
|
||||
// This is the actual active configuration currently in use by the session.
|
||||
// Either a copy of publicConfig or one of serviceConfig.children().
|
||||
QNetworkConfiguration activeConfig;
|
||||
|
||||
QNetworkSession::State state;
|
||||
bool isOpen;
|
||||
|
||||
std::recursive_mutex mutex;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QSharedPointer<QNetworkSession>)
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QNETWORKSESSIONPRIVATE_H
|
|
@ -1,74 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qsharednetworksession_p.h"
|
||||
#include "qbearerengine_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
thread_local QSharedNetworkSessionManager* tls = nullptr;
|
||||
|
||||
inline QSharedNetworkSessionManager* sharedNetworkSessionManager()
|
||||
{
|
||||
if (!tls) {
|
||||
tls = new QSharedNetworkSessionManager;
|
||||
}
|
||||
return tls;
|
||||
}
|
||||
|
||||
static void doDeleteLater(QObject* obj)
|
||||
{
|
||||
obj->deleteLater();
|
||||
}
|
||||
|
||||
QSharedPointer<QNetworkSession> QSharedNetworkSessionManager::getSession(const QNetworkConfiguration &config)
|
||||
{
|
||||
QSharedNetworkSessionManager *m(sharedNetworkSessionManager());
|
||||
//if already have a session, return it
|
||||
if (m->sessions.contains(config)) {
|
||||
QSharedPointer<QNetworkSession> p = m->sessions.value(config).toStrongRef();
|
||||
if (!p.isNull())
|
||||
return p;
|
||||
}
|
||||
//otherwise make one
|
||||
QSharedPointer<QNetworkSession> session(new QNetworkSession(config), doDeleteLater);
|
||||
m->sessions[config] = session;
|
||||
return session;
|
||||
}
|
||||
|
||||
void QSharedNetworkSessionManager::setSession(QNetworkConfiguration config, QSharedPointer<QNetworkSession> session)
|
||||
{
|
||||
QSharedNetworkSessionManager *m(sharedNetworkSessionManager());
|
||||
m->sessions[config] = session;
|
||||
}
|
||||
|
||||
uint qHash(const QNetworkConfiguration& config)
|
||||
{
|
||||
return ((uint)config.type()) | (((uint)config.bearerType()) << 8) | (((uint)config.purpose()) << 16);
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the QtNetwork module of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QSHAREDNETWORKSESSIONPRIVATE_H
|
||||
#define QSHAREDNETWORKSESSIONPRIVATE_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qnetworksession.h"
|
||||
#include "qnetworkconfiguration.h"
|
||||
#include <QHash>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
uint qHash(const QNetworkConfiguration& config);
|
||||
|
||||
class QSharedNetworkSessionManager
|
||||
{
|
||||
public:
|
||||
static QSharedPointer<QNetworkSession> getSession(const QNetworkConfiguration &config);
|
||||
static void setSession(QNetworkConfiguration config, QSharedPointer<QNetworkSession> session);
|
||||
private:
|
||||
QHash<QNetworkConfiguration, QWeakPointer<QNetworkSession> > sessions;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif //QSHAREDNETWORKSESSIONPRIVATE_H
|
||||
|
|
@ -43,11 +43,6 @@
|
|||
#include <QElapsedTimer>
|
||||
#include <QCache>
|
||||
|
||||
#include <QNetworkSession>
|
||||
#include <QSharedPointer>
|
||||
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
|
|
|
@ -206,10 +206,6 @@
|
|||
#include "qmutex.h"
|
||||
#include "qurl.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#include <QtNetwork/QNetworkConfiguration>
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QSocks5SocketEngineHandler;
|
||||
|
@ -688,9 +684,6 @@ public:
|
|||
QUrl remote;
|
||||
int localPort;
|
||||
QNetworkProxyQuery::QueryType type;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QNetworkConfiguration config;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
|
||||
|
@ -752,11 +745,6 @@ template<> void QSharedDataPointer<QNetworkProxyQueryPrivate>::detach()
|
|||
like choosing an caching HTTP proxy for HTTP-based connections,
|
||||
but a more powerful SOCKSv5 proxy for all others.
|
||||
|
||||
The network configuration specifies which configuration to use,
|
||||
when bearer management is used. For example on a mobile phone
|
||||
the proxy settings are likely to be different for the cellular
|
||||
network vs WLAN.
|
||||
|
||||
Some of the criteria may not make sense in all of the types of
|
||||
query. The following table lists the criteria that are most
|
||||
commonly used, according to the type of query.
|
||||
|
@ -882,74 +870,6 @@ QNetworkProxyQuery::QNetworkProxyQuery(quint16 bindPort, const QString &protocol
|
|||
d->type = queryType;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
/*!
|
||||
\since 4.8
|
||||
|
||||
Constructs a QNetworkProxyQuery with the URL \a requestUrl and
|
||||
sets the query type to \a queryType. The specified \a networkConfiguration
|
||||
is used to resolve the proxy settings.
|
||||
|
||||
\sa protocolTag(), peerHostName(), peerPort(), networkConfiguration()
|
||||
*/
|
||||
QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
|
||||
const QUrl &requestUrl, QueryType queryType)
|
||||
{
|
||||
d->config = networkConfiguration;
|
||||
d->remote = requestUrl;
|
||||
d->type = queryType;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.8
|
||||
|
||||
Constructs a QNetworkProxyQuery of type \a queryType and sets the
|
||||
protocol tag to be \a protocolTag. This constructor is suitable
|
||||
for QNetworkProxyQuery::TcpSocket queries, because it sets the
|
||||
peer hostname to \a hostname and the peer's port number to \a
|
||||
port. The specified \a networkConfiguration
|
||||
is used to resolve the proxy settings.
|
||||
|
||||
\sa networkConfiguration()
|
||||
*/
|
||||
QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
|
||||
const QString &hostname, int port,
|
||||
const QString &protocolTag,
|
||||
QueryType queryType)
|
||||
{
|
||||
d->config = networkConfiguration;
|
||||
d->remote.setScheme(protocolTag);
|
||||
d->remote.setHost(hostname);
|
||||
d->remote.setPort(port);
|
||||
d->type = queryType;
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.8
|
||||
|
||||
Constructs a QNetworkProxyQuery of type \a queryType and sets the
|
||||
protocol tag to be \a protocolTag. This constructor is suitable
|
||||
for QNetworkProxyQuery::TcpSocket queries because it sets the
|
||||
local port number to \a bindPort. The specified \a networkConfiguration
|
||||
is used to resolve the proxy settings.
|
||||
|
||||
Note that \a bindPort is of type quint16 to indicate the exact
|
||||
port number that is requested. The value of -1 (unknown) is not
|
||||
allowed in this context.
|
||||
|
||||
\sa localPort(), networkConfiguration()
|
||||
*/
|
||||
QNetworkProxyQuery::QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
|
||||
quint16 bindPort, const QString &protocolTag,
|
||||
QueryType queryType)
|
||||
{
|
||||
d->config = networkConfiguration;
|
||||
d->remote.setScheme(protocolTag);
|
||||
d->localPort = bindPort;
|
||||
d->type = queryType;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
Constructs a QNetworkProxyQuery object that is a copy of \a other.
|
||||
*/
|
||||
|
@ -1164,37 +1084,6 @@ void QNetworkProxyQuery::setUrl(const QUrl &url)
|
|||
d->remote = url;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
/*!
|
||||
Returns the network configuration of the proxy query.
|
||||
|
||||
\sa setNetworkConfiguration()
|
||||
*/
|
||||
QNetworkConfiguration QNetworkProxyQuery::networkConfiguration() const
|
||||
{
|
||||
return d ? d->config : QNetworkConfiguration();
|
||||
}
|
||||
|
||||
/*!
|
||||
\since 4.8
|
||||
|
||||
Sets the network configuration component of this QNetworkProxyQuery
|
||||
object to be \a networkConfiguration. The network configuration can
|
||||
be used to return different proxy settings based on the network in
|
||||
use, for example WLAN vs cellular networks on a mobile phone.
|
||||
|
||||
In the case of "user choice" or "service network" configurations,
|
||||
you should first start the QNetworkSession and obtain the active
|
||||
configuration from its properties.
|
||||
|
||||
\sa networkConfiguration()
|
||||
*/
|
||||
void QNetworkProxyQuery::setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration)
|
||||
{
|
||||
d->config = networkConfiguration;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\class QNetworkProxyFactory
|
||||
\brief The QNetworkProxyFactory class provides fine-grained proxy selection.
|
||||
|
|
|
@ -30,9 +30,7 @@
|
|||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
class QUrl;
|
||||
class QNetworkConfiguration;
|
||||
|
||||
class QNetworkProxyQueryPrivate;
|
||||
class Q_NETWORK_EXPORT QNetworkProxyQuery
|
||||
|
@ -52,16 +50,6 @@ public:
|
|||
QNetworkProxyQuery(quint16 bindPort, const QString &protocolTag = QString(),
|
||||
QueryType queryType = TcpServer);
|
||||
QNetworkProxyQuery(const QNetworkProxyQuery &other);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
|
||||
const QUrl &requestUrl, QueryType queryType = UrlRequest);
|
||||
QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
|
||||
const QString &hostname, int port, const QString &protocolTag = QString(),
|
||||
QueryType queryType = TcpSocket);
|
||||
QNetworkProxyQuery(const QNetworkConfiguration &networkConfiguration,
|
||||
quint16 bindPort, const QString &protocolTag = QString(),
|
||||
QueryType queryType = TcpServer);
|
||||
#endif
|
||||
~QNetworkProxyQuery();
|
||||
QNetworkProxyQuery &operator=(const QNetworkProxyQuery &other);
|
||||
bool operator==(const QNetworkProxyQuery &other) const;
|
||||
|
@ -86,11 +74,6 @@ public:
|
|||
QUrl url() const;
|
||||
void setUrl(const QUrl &url);
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QNetworkConfiguration networkConfiguration() const;
|
||||
void setNetworkConfiguration(const QNetworkConfiguration &networkConfiguration);
|
||||
#endif
|
||||
|
||||
private:
|
||||
QSharedDataPointer<QNetworkProxyQueryPrivate> d;
|
||||
};
|
||||
|
|
|
@ -349,7 +349,6 @@
|
|||
#include "qabstractsocket.h"
|
||||
#include "qabstractsocket_p.h"
|
||||
#include "qhostinfo_p.h"
|
||||
#include "qnetworksession_p.h"
|
||||
#include "qabstracteventdispatcher.h"
|
||||
#include "qhostaddress.h"
|
||||
#include "qhostinfo.h"
|
||||
|
@ -486,10 +485,6 @@ bool QAbstractSocketPrivate::initSocketLayer(QAbstractSocket::NetworkLayerProtoc
|
|||
q->setErrorString(QAbstractSocket::tr("Operation on socket is not supported"));
|
||||
return false;
|
||||
}
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the socket engine (if it has been set)
|
||||
socketEngine->setProperty("_q_networksession", q->property("_q_networksession"));
|
||||
#endif
|
||||
#ifndef QT_NO_NETWORKPROXY
|
||||
//copy user agent to socket engine (if it has been set)
|
||||
socketEngine->setProperty("_q_user-agent", q->property("_q_user-agent"));
|
||||
|
@ -1483,10 +1478,6 @@ bool QAbstractSocket::setSocketDescriptor(int socketDescriptor, SocketState sock
|
|||
setErrorString(tr("Operation on socket is not supported"));
|
||||
return false;
|
||||
}
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the socket engine (if it has been set)
|
||||
d->socketEngine->setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
bool result = d->socketEngine->initialize(socketDescriptor, socketState);
|
||||
if (!result) {
|
||||
d->socketError = d->socketEngine->error();
|
||||
|
|
|
@ -55,9 +55,6 @@ bool QHttpSocketEngine::initialize(QAbstractSocket::SocketType type, QAbstractSo
|
|||
setProtocol(protocol);
|
||||
setSocketType(type);
|
||||
d->socket = new QTcpSocket(this);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
d->socket->setProperty("_q_networkSession", property("_q_networkSession"));
|
||||
#endif
|
||||
|
||||
// Explicitly disable proxying on the proxy socket itself to avoid
|
||||
// unwanted recursion.
|
||||
|
|
|
@ -514,9 +514,6 @@ void QSocks5SocketEnginePrivate::initialize(Socks5Mode socks5Mode)
|
|||
udpData = new QSocks5UdpAssociateData;
|
||||
data = udpData;
|
||||
udpData->udpSocket = new QUdpSocket(q);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
udpData->udpSocket->setProperty("_q_networksession", q->property("_q_networksession"));
|
||||
#endif
|
||||
udpData->udpSocket->setProxy(QNetworkProxy::NoProxy);
|
||||
QObject::connect(udpData->udpSocket, SIGNAL(readyRead()),
|
||||
q, SLOT(_q_udpSocketReadNotification()),
|
||||
|
@ -528,9 +525,6 @@ void QSocks5SocketEnginePrivate::initialize(Socks5Mode socks5Mode)
|
|||
}
|
||||
|
||||
data->controlSocket = new QTcpSocket(q);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
data->controlSocket->setProperty("_q_networksession", q->property("_q_networksession"));
|
||||
#endif
|
||||
data->controlSocket->setProxy(QNetworkProxy::NoProxy);
|
||||
QObject::connect(data->controlSocket, SIGNAL(connected()), q, SLOT(_q_controlSocketConnected()),
|
||||
Qt::DirectConnection);
|
||||
|
@ -1340,9 +1334,6 @@ bool QSocks5SocketEngine::bind(const QHostAddress &address, quint16 port)
|
|||
d->udpData->associatePort = d->localPort;
|
||||
d->localPort = 0;
|
||||
QUdpSocket dummy;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
dummy.setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
dummy.setProxy(QNetworkProxy::NoProxy);
|
||||
if (!dummy.bind()
|
||||
|| writeDatagram(0,0, d->data->controlSocket->localAddress(), dummy.localPort()) != 0
|
||||
|
|
|
@ -266,10 +266,6 @@ bool QTcpServer::listen(const QHostAddress &address, quint16 port)
|
|||
d->serverSocketErrorString = tr("Operation on socket is not supported");
|
||||
return false;
|
||||
}
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the socket engine (if it has been set)
|
||||
d->socketEngine->setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
if (!d->socketEngine->initialize(QAbstractSocket::TcpSocket, proto)) {
|
||||
d->serverSocketError = d->socketEngine->error();
|
||||
d->serverSocketErrorString = d->socketEngine->errorString();
|
||||
|
@ -388,10 +384,6 @@ bool QTcpServer::setSocketDescriptor(int socketDescriptor)
|
|||
d->serverSocketErrorString = tr("Operation on socket is not supported");
|
||||
return false;
|
||||
}
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the socket engine (if it has been set)
|
||||
d->socketEngine->setProperty("_q_networksession", property("_q_networksession"));
|
||||
#endif
|
||||
if (!d->socketEngine->initialize(socketDescriptor, QAbstractSocket::ListeningState)) {
|
||||
d->serverSocketError = d->socketEngine->error();
|
||||
d->serverSocketErrorString = d->socketEngine->errorString();
|
||||
|
|
|
@ -2008,10 +2008,6 @@ void QSslSocketPrivate::createPlainSocket(QIODevice::OpenMode openMode)
|
|||
q->setPeerName(QString());
|
||||
|
||||
plainSocket = new QTcpSocket(q);
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//copy network session down to the plain socket (if it has been set)
|
||||
plainSocket->setProperty("_q_networksession", q->property("_q_networksession"));
|
||||
#endif
|
||||
q->connect(plainSocket, SIGNAL(connected()),
|
||||
q, SLOT(_q_connectedSlot()),
|
||||
Qt::DirectConnection);
|
||||
|
|
|
@ -21,30 +21,6 @@ if(WITH_ACCESSIBILITY)
|
|||
endif()
|
||||
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/bearer")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/bearer")
|
||||
|
||||
set(SHAREDBEARER_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworksession_impl.cpp
|
||||
)
|
||||
set(SHAREDBEARER_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qnetworksession_impl.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer/qbearerengine_impl.h
|
||||
)
|
||||
katie_setup_target(sharedbearer ${SHAREDBEARER_SOURCES} ${SHAREDBEARER_HEADERS})
|
||||
add_library(sharedbearer OBJECT ${sharedbearer_SOURCES})
|
||||
target_include_directories(sharedbearer PUBLIC
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/bearer
|
||||
${CMAKE_CURRENT_BINARY_DIR}/bearer
|
||||
)
|
||||
|
||||
add_subdirectory(bearer/generic)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND WITH_DBUS AND DBUS_FOUND)
|
||||
add_subdirectory(bearer/connman)
|
||||
add_subdirectory(bearer/networkmanager)
|
||||
endif()
|
||||
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/iconengines")
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/plugins/iconengines")
|
||||
add_subdirectory(iconengines/svgiconengine)
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
set(QTCONNMANBEARERPLUGIN_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qconnmanservice_linux_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qofonoservice_linux_p.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qconnmanengine.h
|
||||
)
|
||||
|
||||
set(QTCONNMANBEARERPLUGIN_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmmain.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qconnmanservice_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qofonoservice_linux.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qconnmanengine.cpp
|
||||
)
|
||||
|
||||
katie_setup_target(qconnmanbearerplugin ${QTCONNMANBEARERPLUGIN_SOURCES} ${QTCONNMANBEARERPLUGIN_HEADERS})
|
||||
|
||||
add_library(qconnmanbearerplugin MODULE ${qconnmanbearerplugin_SOURCES}
|
||||
$<TARGET_OBJECTS:sharedbearer>
|
||||
)
|
||||
target_link_libraries(qconnmanbearerplugin KtCore KtNetwork KtDBus)
|
||||
set_target_properties(qconnmanbearerplugin PROPERTIES OUTPUT_NAME qconnmanbearer)
|
||||
target_include_directories(qconnmanbearerplugin PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/plugins/bearer
|
||||
${CMAKE_BINARY_DIR}/src/plugins/bearer
|
||||
)
|
||||
|
||||
katie_setup_object(qconnmanbearerplugin sharedbearer)
|
||||
katie_setup_plugin(qconnmanbearerplugin)
|
||||
|
||||
install(
|
||||
TARGETS qconnmanbearerplugin
|
||||
DESTINATION ${KATIE_PLUGINS_PATH}/bearer
|
||||
COMPONENT Runtime
|
||||
)
|
|
@ -1,73 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qconnmanengine.h"
|
||||
#include "qbearerplugin_p.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QConnmanEnginePlugin : public QBearerEnginePlugin
|
||||
{
|
||||
public:
|
||||
QConnmanEnginePlugin();
|
||||
~QConnmanEnginePlugin();
|
||||
|
||||
QStringList keys() const;
|
||||
QBearerEngine *create(const QString &key) const;
|
||||
};
|
||||
|
||||
QConnmanEnginePlugin::QConnmanEnginePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanEnginePlugin::~QConnmanEnginePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList QConnmanEnginePlugin::keys() const
|
||||
{
|
||||
static const QStringList list = QStringList()
|
||||
<< QLatin1String("connman");
|
||||
return list;
|
||||
}
|
||||
|
||||
QBearerEngine *QConnmanEnginePlugin::create(const QString &key) const
|
||||
{
|
||||
if (key == QLatin1String("connman")) {
|
||||
QConnmanEngine *engine = new QConnmanEngine;
|
||||
if (engine->connmanAvailable())
|
||||
return engine;
|
||||
else
|
||||
delete engine;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(qconnmanbearer, QConnmanEnginePlugin)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
|
@ -1,572 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qconnmanengine.h"
|
||||
#include "qconnmanservice_linux_p.h"
|
||||
#include "qofonoservice_linux_p.h"
|
||||
#include "../qnetworksession_impl.h"
|
||||
#include "qnetworkconfiguration_p.h"
|
||||
#include "qnetworksession.h"
|
||||
#include "qdebug.h"
|
||||
#include "qfile.h"
|
||||
#include "qtimer.h"
|
||||
#include "qdbusconnection.h"
|
||||
#include "qdbusinterface.h"
|
||||
#include "qdbusmessage.h"
|
||||
#include "qdbusreply.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QConnmanEngine::QConnmanEngine(QObject *parent)
|
||||
: QBearerEngineImpl(parent),
|
||||
connmanManager(new QConnmanManagerInterface(this))
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanEngine::~QConnmanEngine()
|
||||
{
|
||||
}
|
||||
|
||||
bool QConnmanEngine::connmanAvailable() const
|
||||
{
|
||||
return connmanManager->isValid();
|
||||
}
|
||||
|
||||
void QConnmanEngine::initialize()
|
||||
{
|
||||
connect(connmanManager,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SLOT(propertyChangedContext(QString,QString,QDBusVariant)));
|
||||
|
||||
foreach(const QString techPath, connmanManager->getTechnologies()) {
|
||||
QConnmanTechnologyInterface *tech;
|
||||
tech = new QConnmanTechnologyInterface(techPath, this);
|
||||
|
||||
connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
|
||||
}
|
||||
|
||||
foreach(const QString servPath, connmanManager->getServices()) {
|
||||
addServiceConfiguration(servPath);
|
||||
}
|
||||
|
||||
// Get current list of access points.
|
||||
getConfigurations();
|
||||
}
|
||||
|
||||
QList<QNetworkConfigurationPrivate *> QConnmanEngine::getConfigurations()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
QList<QNetworkConfigurationPrivate *> fetchedConfigurations;
|
||||
QNetworkConfigurationPrivate* cpPriv = 0;
|
||||
|
||||
for (int i = 0; i < foundConfigurations.count(); ++i) {
|
||||
QNetworkConfigurationPrivate *config = new QNetworkConfigurationPrivate;
|
||||
cpPriv = foundConfigurations.at(i);
|
||||
|
||||
config->name = cpPriv->name;
|
||||
config->isValid = cpPriv->isValid;
|
||||
config->id = cpPriv->id;
|
||||
config->state = cpPriv->state;
|
||||
config->type = cpPriv->type;
|
||||
config->roamingSupported = cpPriv->roamingSupported;
|
||||
config->purpose = cpPriv->purpose;
|
||||
config->bearerType = cpPriv->bearerType;
|
||||
|
||||
fetchedConfigurations.append(config);
|
||||
delete config;
|
||||
}
|
||||
return fetchedConfigurations;
|
||||
}
|
||||
|
||||
void QConnmanEngine::doRequestUpdate()
|
||||
{
|
||||
connmanManager->requestScan(QLatin1String(""));
|
||||
getConfigurations();
|
||||
emit updateCompleted();
|
||||
}
|
||||
|
||||
QString QConnmanEngine::getInterfaceFromId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
return configInterfaces.value(id);
|
||||
}
|
||||
|
||||
bool QConnmanEngine::hasIdentifier(const QString &id) const
|
||||
{
|
||||
return accessPointConfigurations.contains(id);
|
||||
}
|
||||
|
||||
void QConnmanEngine::connectToId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
QString servicePath = serviceFromId(id);
|
||||
QConnmanServiceInterface serv(servicePath);
|
||||
if(!serv.isValid()) {
|
||||
emit connectionError(id, QBearerEngineImpl::InterfaceLookupError);
|
||||
} else {
|
||||
if(serv.getType() != QLatin1String("cellular")) {
|
||||
|
||||
serv.connect();
|
||||
} else {
|
||||
QOfonoManagerInterface ofonoManager(0);
|
||||
QString modemPath = ofonoManager.currentModem().path();
|
||||
QOfonoDataConnectionManagerInterface dc(modemPath,0);
|
||||
foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
|
||||
if(dcPath.path().contains(servicePath.section(QLatin1Char('_'),-1))) {
|
||||
QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
|
||||
primaryContext.setActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QConnmanEngine::disconnectFromId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
QString servicePath = serviceFromId(id);
|
||||
QConnmanServiceInterface serv(servicePath);
|
||||
if(!serv.isValid()) {
|
||||
emit connectionError(id, DisconnectionError);
|
||||
} else {
|
||||
if(serv.getType() != QLatin1String("cellular")) {
|
||||
serv.disconnect();
|
||||
} else {
|
||||
QOfonoManagerInterface ofonoManager(0);
|
||||
QString modemPath = ofonoManager.currentModem().path();
|
||||
QOfonoDataConnectionManagerInterface dc(modemPath,0);
|
||||
foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
|
||||
if(dcPath.path().contains(servicePath.section(QLatin1Char('_'),-1))) {
|
||||
QOfonoPrimaryDataContextInterface primaryContext(dcPath.path(),0);
|
||||
primaryContext.setActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QConnmanEngine::requestUpdate()
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
QTimer::singleShot(0, this, SLOT(doRequestUpdate()));
|
||||
}
|
||||
|
||||
QString QConnmanEngine::serviceFromId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
foreach(const QString service, serviceNetworks) {
|
||||
if (id == QString::number(qHash(service)))
|
||||
return service;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QNetworkSession::State QConnmanEngine::sessionStateForId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
|
||||
if (!ptr)
|
||||
return QNetworkSession::Invalid;
|
||||
|
||||
if (!ptr->isValid) {
|
||||
return QNetworkSession::Invalid;
|
||||
|
||||
}
|
||||
QString service = serviceFromId(id);
|
||||
QConnmanServiceInterface serv(service);
|
||||
QString servState = serv.getState();
|
||||
|
||||
if(serv.isFavorite() && (servState == QLatin1String("idle") || servState == QLatin1String("failure"))) {
|
||||
return QNetworkSession::Disconnected;
|
||||
}
|
||||
|
||||
if(servState == QLatin1String("association") || servState == QLatin1String("configuration") || servState == QLatin1String("login")) {
|
||||
return QNetworkSession::Connecting;
|
||||
}
|
||||
if(servState == QLatin1String("ready") || servState == QLatin1String("online")) {
|
||||
return QNetworkSession::Connected;
|
||||
}
|
||||
|
||||
if ((ptr->state & QNetworkConfiguration::Discovered) ==
|
||||
QNetworkConfiguration::Discovered) {
|
||||
return QNetworkSession::Disconnected;
|
||||
} else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
|
||||
return QNetworkSession::NotAvailable;
|
||||
} else if ((ptr->state & QNetworkConfiguration::Undefined) ==
|
||||
QNetworkConfiguration::Undefined) {
|
||||
return QNetworkSession::NotAvailable;
|
||||
}
|
||||
|
||||
return QNetworkSession::Invalid;
|
||||
}
|
||||
|
||||
quint64 QConnmanEngine::bytesWritten(const QString &id)
|
||||
{
|
||||
//TODO use connman counter API
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
quint64 result = 0;
|
||||
QString devFile = getInterfaceFromId(id);
|
||||
QFile tx(QLatin1String("/sys/class/net/") + devFile + QLatin1String("/statistics/tx_bytes"));
|
||||
if(tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&tx);
|
||||
in >> result;
|
||||
tx.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
quint64 QConnmanEngine::bytesReceived(const QString &id)
|
||||
{
|
||||
//TODO use connman counter API
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
quint64 result = 0;
|
||||
QString devFile = getInterfaceFromId(id);
|
||||
QFile rx(QLatin1String("/sys/class/net/") + devFile + QLatin1String("/statistics/rx_bytes"));
|
||||
if(rx.exists() && rx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&rx);
|
||||
in >> result;
|
||||
rx.close();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
quint64 QConnmanEngine::startTime(const QString &/*id*/)
|
||||
{
|
||||
// TODO
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
if (activeTime.isNull()) {
|
||||
return 0;
|
||||
}
|
||||
return activeTime.secsTo(QDateTime::currentDateTime());
|
||||
}
|
||||
|
||||
QNetworkConfigurationManager::Capabilities QConnmanEngine::capabilities() const
|
||||
{
|
||||
return QNetworkConfigurationManager::ForcedRoaming |
|
||||
QNetworkConfigurationManager::DataStatistics |
|
||||
QNetworkConfigurationManager::CanStartAndStopInterfaces;
|
||||
}
|
||||
|
||||
QNetworkSessionPrivate *QConnmanEngine::createSessionBackend()
|
||||
{
|
||||
return new QNetworkSessionPrivateImpl;
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivatePointer QConnmanEngine::defaultConfiguration()
|
||||
{
|
||||
return QNetworkConfigurationPrivatePointer();
|
||||
}
|
||||
|
||||
void QConnmanEngine::propertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value)
|
||||
{
|
||||
Q_UNUSED(path);
|
||||
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
if(item == QLatin1String("Services")) {
|
||||
QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant());
|
||||
QStringList list = qdbus_cast<QStringList>(arg);
|
||||
|
||||
if(list.count() > accessPointConfigurations.count()) {
|
||||
foreach(const QString service, list) {
|
||||
addServiceConfiguration(service);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(item == QLatin1String("Technologies")) {
|
||||
QDBusArgument arg = qvariant_cast<QDBusArgument>(value.variant());
|
||||
QStringList newlist = qdbus_cast<QStringList>(arg);
|
||||
if(newlist.count() > 0) {
|
||||
QMap<QString,QConnmanTechnologyInterface *> oldtech = technologies;
|
||||
|
||||
foreach(const QString listPath, newlist) {
|
||||
if(!oldtech.contains(listPath)) {
|
||||
QConnmanTechnologyInterface *tech;
|
||||
tech = new QConnmanTechnologyInterface(listPath,this);
|
||||
connect(tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
|
||||
technologies.insert(listPath, tech);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(item == QLatin1String("State")) {
|
||||
// qDebug() << value.variant();
|
||||
}
|
||||
}
|
||||
|
||||
void QConnmanEngine::servicePropertyChangedContext(const QString &path,const QString &item, const QDBusVariant &value)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
if(item == QLatin1String("State")) {
|
||||
configurationChange(QString::number(qHash(path)));
|
||||
|
||||
if(value.variant().toString() == QLatin1String("failure")) {
|
||||
QConnmanServiceInterface serv(path);
|
||||
emit connectionError(QString::number(qHash(path)), ConnectError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QConnmanEngine::technologyPropertyChangedContext(const QString & path, const QString &item, const QDBusVariant &value)
|
||||
{
|
||||
if(item == QLatin1String("State")) {
|
||||
if(value.variant().toString() == QLatin1String("offline")) {
|
||||
QConnmanTechnologyInterface tech(path);
|
||||
disconnect(&tech,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SLOT(technologyPropertyChangedContext(QString,QString,QDBusVariant)));
|
||||
|
||||
technologies.remove(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QConnmanEngine::configurationChange(const QString &id)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if (accessPointConfigurations.contains(id)) {
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
|
||||
QString servicePath = serviceFromId(id);
|
||||
QConnmanServiceInterface serv(servicePath);
|
||||
QString networkName = serv.getName();
|
||||
|
||||
QNetworkConfiguration::StateFlags curState = getStateForService(servicePath);
|
||||
|
||||
ptr->mutex.lock();
|
||||
|
||||
if (!ptr->isValid) {
|
||||
ptr->isValid = true;
|
||||
}
|
||||
|
||||
if (ptr->name != networkName) {
|
||||
ptr->name = networkName;
|
||||
}
|
||||
|
||||
if (ptr->state != curState) {
|
||||
ptr->state = curState;
|
||||
}
|
||||
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.lock();
|
||||
}
|
||||
|
||||
locker.unlock();
|
||||
emit updateCompleted();
|
||||
}
|
||||
|
||||
QNetworkConfiguration::StateFlags QConnmanEngine::getStateForService(const QString &service)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
QConnmanServiceInterface serv(service);
|
||||
QNetworkConfiguration::StateFlags flag = QNetworkConfiguration::Defined;
|
||||
if( serv.getType() == QLatin1String("cellular")) {
|
||||
if(serv.isSetupRequired()) {
|
||||
flag = ( flag | QNetworkConfiguration::Defined);
|
||||
} else {
|
||||
flag = ( flag | QNetworkConfiguration::Discovered);
|
||||
}
|
||||
} else {
|
||||
if(serv.isFavorite()) {
|
||||
flag = ( flag | QNetworkConfiguration::Discovered);
|
||||
} else {
|
||||
flag = QNetworkConfiguration::Undefined;
|
||||
}
|
||||
}
|
||||
|
||||
if(serv.getState() == QLatin1String("ready") || serv.getState() == QLatin1String("online")) {
|
||||
flag = ( flag | QNetworkConfiguration::Active);
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
QNetworkConfiguration::BearerType QConnmanEngine::typeToBearer(const QString &type)
|
||||
{
|
||||
if (type == QLatin1String("wifi"))
|
||||
return QNetworkConfiguration::BearerWLAN;
|
||||
if (type == QLatin1String("ethernet"))
|
||||
return QNetworkConfiguration::BearerEthernet;
|
||||
if (type == QLatin1String("bluetooth"))
|
||||
return QNetworkConfiguration::BearerBluetooth;
|
||||
if (type == QLatin1String("cellular")) {
|
||||
return ofonoTechToBearerType(type);
|
||||
}
|
||||
if (type == QLatin1String("wimax"))
|
||||
return QNetworkConfiguration::BearerWiMAX;
|
||||
|
||||
// if(type == QLatin1String("gps"))
|
||||
// if(type == QLatin1String("vpn"))
|
||||
|
||||
return QNetworkConfiguration::BearerUnknown;
|
||||
}
|
||||
|
||||
QNetworkConfiguration::BearerType QConnmanEngine::ofonoTechToBearerType(const QString &/*type*/)
|
||||
{
|
||||
QOfonoManagerInterface ofonoManager(this);
|
||||
QOfonoNetworkRegistrationInterface ofonoNetwork(ofonoManager.currentModem().path(),this);
|
||||
|
||||
if(ofonoNetwork.isValid()) {
|
||||
foreach(const QDBusObjectPath op,ofonoNetwork.getOperators() ) {
|
||||
QOfonoNetworkOperatorInterface opIface(op.path(),this);
|
||||
|
||||
foreach(const QString opTech, opIface.getTechnologies()) {
|
||||
|
||||
if(opTech == QLatin1String("gsm")) {
|
||||
return QNetworkConfiguration::Bearer2G;
|
||||
}
|
||||
if(opTech == QLatin1String("edge")){
|
||||
return QNetworkConfiguration::BearerCDMA2000; //wrong, I know
|
||||
}
|
||||
if(opTech == QLatin1String("umts")){
|
||||
return QNetworkConfiguration::BearerWCDMA;
|
||||
}
|
||||
if(opTech == QLatin1String("hspa")){
|
||||
return QNetworkConfiguration::BearerHSPA;
|
||||
}
|
||||
if(opTech == QLatin1String("lte")){
|
||||
return QNetworkConfiguration::BearerWiMAX; //not exact
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return QNetworkConfiguration::BearerUnknown;
|
||||
}
|
||||
|
||||
bool QConnmanEngine::isRoamingAllowed(const QString &context)
|
||||
{
|
||||
QOfonoManagerInterface ofonoManager(this);
|
||||
QString modemPath = ofonoManager.currentModem().path();
|
||||
QOfonoDataConnectionManagerInterface dc(modemPath,this);
|
||||
foreach(const QDBusObjectPath dcPath,dc.getPrimaryContexts()) {
|
||||
if(dcPath.path().contains(context.section(QLatin1Char('_'),-1))) {
|
||||
return dc.isRoamingAllowed();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QConnmanEngine::removeConfiguration(const QString &id)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if (accessPointConfigurations.contains(id)) {
|
||||
|
||||
QString service = serviceFromId(id);
|
||||
QConnmanServiceInterface serv(service);
|
||||
|
||||
disconnect(&serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SLOT(servicePropertyChangedContext(QString,QString,QDBusVariant)));
|
||||
|
||||
serviceNetworks.removeOne(service);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
locker.lock();
|
||||
}
|
||||
}
|
||||
|
||||
void QConnmanEngine::addServiceConfiguration(const QString &servicePath)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
QConnmanServiceInterface serv(servicePath);
|
||||
|
||||
const QString id = QString::number(qHash(servicePath));
|
||||
|
||||
if (!accessPointConfigurations.contains(id)) {
|
||||
serviceNetworks.append(servicePath);
|
||||
|
||||
connect(&serv,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SLOT(servicePropertyChangedContext(QString,QString,QDBusVariant)));
|
||||
QNetworkConfigurationPrivate* cpPriv = new QNetworkConfigurationPrivate();
|
||||
|
||||
QString networkName = serv.getName();
|
||||
|
||||
const QString connectionType = serv.getType();
|
||||
if (connectionType == QLatin1String("ethernet")) {
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
|
||||
} else if (connectionType == QLatin1String("wifi")) {
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
|
||||
} else if (connectionType == QLatin1String("cellular")) {
|
||||
cpPriv->bearerType = ofonoTechToBearerType(QLatin1String("cellular"));
|
||||
if(servicePath.isEmpty()) {
|
||||
networkName = serv.getAPN();
|
||||
if(networkName.isEmpty()) {
|
||||
networkName = serv.getName();
|
||||
}
|
||||
}
|
||||
cpPriv->roamingSupported = isRoamingAllowed(servicePath);
|
||||
} else if (connectionType == QLatin1String("wimax")) {
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerWiMAX;
|
||||
} else {
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerUnknown;
|
||||
}
|
||||
|
||||
cpPriv->name = networkName;
|
||||
cpPriv->isValid = true;
|
||||
cpPriv->id = id;
|
||||
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
|
||||
|
||||
if(serv.getSecurity() == QLatin1String("none")) {
|
||||
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
|
||||
} else {
|
||||
cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
|
||||
}
|
||||
|
||||
cpPriv->state = getStateForService(servicePath);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr(cpPriv);
|
||||
accessPointConfigurations.insert(ptr->id, ptr);
|
||||
foundConfigurations.append(cpPriv);
|
||||
configInterfaces[cpPriv->id] = serv.getInterface();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationAdded(ptr);
|
||||
locker.lock();
|
||||
emit updateCompleted();
|
||||
}
|
||||
}
|
||||
|
||||
bool QConnmanEngine::requiresPolling() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#include "moc_qconnmanengine.h"
|
||||
#include "moc_qbearerengine_impl.h"
|
|
@ -1,123 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QCONNMANENGINE_P_H
|
||||
#define QCONNMANENGINE_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists for the convenience
|
||||
// of the QLibrary class. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "../qbearerengine_impl.h"
|
||||
|
||||
#include "qconnmanservice_linux_p.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
#include <QDateTime>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QConnmanEngine : public QBearerEngineImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QConnmanEngine(QObject *parent = nullptr);
|
||||
~QConnmanEngine();
|
||||
|
||||
bool connmanAvailable() const;
|
||||
|
||||
virtual QString getInterfaceFromId(const QString &id);
|
||||
bool hasIdentifier(const QString &id) const;
|
||||
|
||||
virtual void connectToId(const QString &id);
|
||||
virtual void disconnectFromId(const QString &id);
|
||||
|
||||
Q_INVOKABLE void initialize();
|
||||
Q_INVOKABLE void requestUpdate();
|
||||
|
||||
QNetworkSession::State sessionStateForId(const QString &id);
|
||||
QNetworkSessionPrivate *createSessionBackend();
|
||||
|
||||
virtual quint64 bytesWritten(const QString &id);
|
||||
virtual quint64 bytesReceived(const QString &id);
|
||||
virtual quint64 startTime(const QString &id);
|
||||
|
||||
|
||||
virtual QNetworkConfigurationManager::Capabilities capabilities() const;
|
||||
virtual QNetworkConfigurationPrivatePointer defaultConfiguration();
|
||||
|
||||
void configurationChange(const QString &id);
|
||||
QList<QNetworkConfigurationPrivate *> getConfigurations();
|
||||
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
void doRequestUpdate();
|
||||
void servicePropertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
void technologyPropertyChangedContext(const QString &,const QString &, const QDBusVariant &);
|
||||
|
||||
private:
|
||||
QConnmanManagerInterface *connmanManager;
|
||||
|
||||
QList<QNetworkConfigurationPrivate *> foundConfigurations;
|
||||
|
||||
QString serviceFromId(const QString &id);
|
||||
QString networkFromId(const QString &id);
|
||||
|
||||
QNetworkConfiguration::StateFlags getStateForService(const QString &service);
|
||||
QNetworkConfiguration::BearerType typeToBearer(const QString &type);
|
||||
|
||||
void removeConfiguration(const QString &servicePath);
|
||||
void addServiceConfiguration(const QString &servicePath);
|
||||
QDateTime activeTime;
|
||||
|
||||
|
||||
QMap<QString,QConnmanTechnologyInterface *> technologies; // techpath, tech interface
|
||||
QMap<QString,QString> configInterfaces; // id, interface name
|
||||
QList<QString> serviceNetworks; //servpath
|
||||
|
||||
QNetworkConfiguration::BearerType ofonoTechToBearerType(const QString &type);
|
||||
bool isRoamingAllowed(const QString &context);
|
||||
protected:
|
||||
bool requiresPolling() const;
|
||||
};
|
||||
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif
|
||||
|
|
@ -1,885 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
#include <QtDBus/qdbusmetatype.h>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusError>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QtDBus/QDBusPendingCall>
|
||||
|
||||
#include "qconnmanservice_linux_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &map)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << map.objectPath << map.propertyMap;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &map)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> map.objectPath >> map.propertyMap;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
static QDBusConnection connmanConnection = QDBusConnection::systemBus();
|
||||
|
||||
|
||||
QConnmanManagerInterface::QConnmanManagerInterface( QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
||||
QLatin1String(CONNMAN_MANAGER_PATH),
|
||||
CONNMAN_MANAGER_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
qDBusRegisterMetaType<ConnmanMap>();
|
||||
qDBusRegisterMetaType<ConnmanMapList>();
|
||||
qRegisterMetaType<ConnmanMapList>("ConnmanMapList");
|
||||
}
|
||||
|
||||
QConnmanManagerInterface::~QConnmanManagerInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanManagerInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if(!connection().connect(QLatin1String(CONNMAN_SERVICE),
|
||||
QLatin1String(CONNMAN_MANAGER_PATH),
|
||||
QLatin1String(CONNMAN_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "stateChanged(QString)") == 0) {
|
||||
if (!connection().connect(QLatin1String(CONNMAN_SERVICE),
|
||||
QLatin1String(CONNMAN_MANAGER_PATH),
|
||||
QLatin1String(CONNMAN_MANAGER_INTERFACE),
|
||||
QLatin1String("StateChanged"),
|
||||
this,SIGNAL(stateChanged(QString)))) {
|
||||
qWarning() << "StateChanged not connected";
|
||||
|
||||
}
|
||||
}
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QConnmanDBusHelper *helper = new QConnmanDBusHelper(this);
|
||||
|
||||
connmanConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
||||
QLatin1String(CONNMAN_MANAGER_PATH),
|
||||
QLatin1String(CONNMAN_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QConnmanManagerInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
QVariantMap QConnmanManagerInterface::getProperties()
|
||||
{
|
||||
if(this->isValid()) {
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
} else return QVariantMap();
|
||||
}
|
||||
|
||||
QString QConnmanManagerInterface::getState()
|
||||
{
|
||||
QDBusReply<QString > reply = this->call(QLatin1String("GetState"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
bool QConnmanManagerInterface::setProperty(const QString &name, const QDBusVariant &value)
|
||||
{
|
||||
Q_UNUSED(name);
|
||||
Q_UNUSED(value);
|
||||
return false;
|
||||
}
|
||||
|
||||
QDBusObjectPath QConnmanManagerInterface::createProfile(const QString &/*name*/)
|
||||
{
|
||||
return QDBusObjectPath();
|
||||
}
|
||||
|
||||
bool QConnmanManagerInterface::removeProfile(QDBusObjectPath /*path*/)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QConnmanManagerInterface::requestScan(const QString &type)
|
||||
{
|
||||
QDBusReply<QString> reply = this->call(QLatin1String("RequestScan"), QVariant::fromValue(type));
|
||||
|
||||
bool ok = true;
|
||||
if(reply.error().type() == QDBusError::InvalidArgs) {
|
||||
qWarning() << reply.error().message();
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool QConnmanManagerInterface::enableTechnology(const QString &type)
|
||||
{
|
||||
QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("EnableTechnology"), QVariant::fromValue(type));
|
||||
bool ok = true;
|
||||
if(reply.error().type() == QDBusError::InvalidArgs) {
|
||||
qWarning() << reply.error().message();
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
bool QConnmanManagerInterface::disableTechnology(const QString &type)
|
||||
{
|
||||
QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("DisableTechnology"), QVariant::fromValue(type));
|
||||
bool ok = true;
|
||||
if(reply.error().type() == QDBusError::InvalidArgs) {
|
||||
qWarning() << reply.error().message();
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
|
||||
QDBusObjectPath QConnmanManagerInterface::connectService(QVariantMap &map)
|
||||
{
|
||||
QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("ConnectService"), QVariant::fromValue(map));
|
||||
if(!reply.isValid()) {
|
||||
qDebug() << reply.error().message();
|
||||
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
void QConnmanManagerInterface::registerAgent(QDBusObjectPath &/*path*/)
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanManagerInterface::unregisterAgent(QDBusObjectPath /*path*/)
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanManagerInterface::registerCounter(const QString &path, quint32 interval)
|
||||
{ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RegisterCounter"),
|
||||
QVariant::fromValue(path),
|
||||
QVariant::fromValue(interval));
|
||||
if(reply.error().type() == QDBusError::InvalidArgs) {
|
||||
qWarning() << reply.error().message();
|
||||
}
|
||||
}
|
||||
|
||||
void QConnmanManagerInterface::unregisterCounter(const QString &path)
|
||||
{ QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("UnregisterCounter"),
|
||||
QVariant::fromValue(path));
|
||||
if(reply.error().type() == QDBusError::InvalidArgs) {
|
||||
qWarning() << reply.error().message();
|
||||
}
|
||||
}
|
||||
|
||||
QString QConnmanManagerInterface::requestSession(const QString &bearerName)
|
||||
{
|
||||
QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("RequestSession"),
|
||||
QVariant::fromValue(bearerName));
|
||||
return QString();
|
||||
}
|
||||
|
||||
void QConnmanManagerInterface::releaseSession()
|
||||
{
|
||||
QDBusReply<QList<QDBusObjectPath> > reply = this->call(QLatin1String("ReleaseSession"));
|
||||
}
|
||||
|
||||
|
||||
QDBusObjectPath QConnmanManagerInterface::lookupService(const QString &service)
|
||||
{
|
||||
QDBusReply<QDBusObjectPath > reply = this->call(QLatin1String("LookupService"), QVariant::fromValue(service));
|
||||
if(!reply.isValid()) {
|
||||
qDebug() << reply.error().message();
|
||||
}
|
||||
return reply;
|
||||
}
|
||||
|
||||
// properties
|
||||
|
||||
QStringList QConnmanManagerInterface::getAvailableTechnologies()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("AvailableTechnologies"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanManagerInterface::getEnabledTechnologies()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("EnabledTechnologies"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanManagerInterface::getConnectedTechnologies()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("ConnectedTechnologies"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QString QConnmanManagerInterface::getDefaultTechnology()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("DefaultTechnology"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
bool QConnmanManagerInterface::getOfflineMode()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("OfflineMode"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QString QConnmanManagerInterface::getActiveProfile()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("ActiveProfile"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanManagerInterface::getProfiles()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Profiles"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanManagerInterface::getTechnologies()
|
||||
{
|
||||
QStringList list;
|
||||
QDBusReply<ConnmanMapList> replyList = this->call(QLatin1String("GetTechnologies"));
|
||||
if (replyList.isValid()) {
|
||||
Q_FOREACH (ConnmanMap map, replyList.value()) {
|
||||
list << map.objectPath.path();
|
||||
}
|
||||
} else {
|
||||
// try for older version
|
||||
QVariant var = getProperty(QLatin1String("Technologies"));
|
||||
if (!var.isNull()) {
|
||||
list = qdbus_cast<QStringList>(var);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
QStringList QConnmanManagerInterface::getServices()
|
||||
{
|
||||
QStringList list;
|
||||
QDBusReply<ConnmanMapList> replyList = this->call(QLatin1String("GetServices"));
|
||||
if (replyList.isValid()) {
|
||||
Q_FOREACH (ConnmanMap map, replyList.value()) {
|
||||
list << map.objectPath.path();
|
||||
}
|
||||
} else {
|
||||
// try for older version
|
||||
QVariant var = getProperty(QLatin1String("Services"));
|
||||
if (!var.isNull()) {
|
||||
list = qdbus_cast<QStringList>(var);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
QString QConnmanManagerInterface::getPathForTechnology(const QString &name)
|
||||
{
|
||||
foreach(const QString path, getTechnologies()) {
|
||||
if(path.contains(name)) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
return QLatin1String("");
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
QConnmanProfileInterface::QConnmanProfileInterface(const QString &dbusPathName,QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
||||
dbusPathName,
|
||||
CONNMAN_PROFILE_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanProfileInterface::~QConnmanProfileInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanProfileInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
connmanConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(CONNMAN_PROFILE_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)));
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap QConnmanProfileInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QVariant QConnmanProfileInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
// properties
|
||||
QString QConnmanProfileInterface::getName()
|
||||
{
|
||||
|
||||
QVariant var = getProperty(QLatin1String("Name"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
bool QConnmanProfileInterface::isOfflineMode()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("OfflineMode"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanProfileInterface::getServices()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Services"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
QConnmanServiceInterface::QConnmanServiceInterface(const QString &dbusPathName,QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
||||
dbusPathName,
|
||||
CONNMAN_SERVICE_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanServiceInterface::~QConnmanServiceInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanServiceInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
connmanConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(CONNMAN_SERVICE_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)));
|
||||
}
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QConnmanDBusHelper *helper;
|
||||
helper = new QConnmanDBusHelper(this);
|
||||
|
||||
connmanConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(CONNMAN_SERVICE_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap QConnmanServiceInterface::getProperties()
|
||||
{
|
||||
if(this->isValid()) {
|
||||
QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
else
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
QVariant QConnmanServiceInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
void QConnmanServiceInterface::connect()
|
||||
{
|
||||
this->asyncCall(QLatin1String("Connect"));
|
||||
}
|
||||
|
||||
void QConnmanServiceInterface::disconnect()
|
||||
{
|
||||
QDBusReply<QVariantMap> reply = this->call(QLatin1String("Disconnect"));
|
||||
}
|
||||
|
||||
void QConnmanServiceInterface::remove()
|
||||
{
|
||||
QDBusReply<QVariantMap> reply = this->call(QLatin1String("Remove"));
|
||||
}
|
||||
|
||||
// void moveBefore(QDBusObjectPath &service);
|
||||
// void moveAfter(QDBusObjectPath &service);
|
||||
|
||||
// properties
|
||||
QString QConnmanServiceInterface::getState()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("State"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getError()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Error"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getName()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Name"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getType()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Type"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getMode()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Mode"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getSecurity()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Security"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getPassphrase()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Passphrase"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
bool QConnmanServiceInterface::isPassphraseRequired()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("PassphraseRequired"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
quint8 QConnmanServiceInterface::getSignalStrength()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Strength"));
|
||||
return qdbus_cast<quint8>(var);
|
||||
}
|
||||
|
||||
bool QConnmanServiceInterface::isFavorite()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Favorite"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
bool QConnmanServiceInterface::isImmutable()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Immutable"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
bool QConnmanServiceInterface::isAutoConnect()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("AutoConnect"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
bool QConnmanServiceInterface::isSetupRequired()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("SetupRequired"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getAPN()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("APN"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getMCC()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("MCC"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getMNC()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("MNC"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
bool QConnmanServiceInterface::isRoaming()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Roaming"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanServiceInterface::getNameservers()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("NameServers"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanServiceInterface::getDomains()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Domains"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QVariantMap QConnmanServiceInterface::getIPv4()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("IPv4"));
|
||||
return qdbus_cast<QVariantMap >(var);
|
||||
}
|
||||
|
||||
QVariantMap QConnmanServiceInterface::getIPv4Configuration()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("IPv4.Configuration"));
|
||||
return qdbus_cast<QVariantMap >(var);
|
||||
}
|
||||
|
||||
QVariantMap QConnmanServiceInterface::getProxy()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Proxy"));
|
||||
return qdbus_cast<QVariantMap >(var);
|
||||
}
|
||||
|
||||
QVariantMap QConnmanServiceInterface::getEthernet()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Ethernet"));
|
||||
return qdbus_cast<QVariantMap >(var);
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getMethod()
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getEthernet();
|
||||
QMapIterator<QString,QVariant> it(map);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
if(it.key() == QLatin1String("Method")) {
|
||||
return it.value().toString();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getInterface()
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getEthernet();
|
||||
|
||||
QMapIterator<QString,QVariant> it(map);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
if(it.key() == QLatin1String("Interface")) {
|
||||
return it.value().toString();
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getMacAddress()
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getEthernet();
|
||||
|
||||
QMapIterator<QString,QVariant> it(map);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
if(it.key() == QLatin1String("Address")) {
|
||||
return it.value().toString();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
quint16 QConnmanServiceInterface::getMtu()
|
||||
{
|
||||
quint16 mtu=0;
|
||||
QVariant var;
|
||||
QVariantMap map = getEthernet();
|
||||
|
||||
QMapIterator<QString,QVariant> it(map);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
if(it.key() == QLatin1String("MTU")) {
|
||||
return it.value().toUInt();
|
||||
}
|
||||
}
|
||||
return mtu;
|
||||
}
|
||||
|
||||
quint16 QConnmanServiceInterface::getSpeed()
|
||||
{
|
||||
quint16 speed=0;
|
||||
QVariant var;
|
||||
QVariantMap map = getEthernet();
|
||||
|
||||
QMapIterator<QString,QVariant> it(map);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
if(it.key() == QLatin1String("Speed")) {
|
||||
return it.value().toUInt();
|
||||
}
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
QString QConnmanServiceInterface::getDuplex()
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getEthernet();
|
||||
|
||||
QMapIterator<QString,QVariant> it(map);
|
||||
while(it.hasNext()) {
|
||||
it.next();
|
||||
if(it.key() == QLatin1String("Duplex")) {
|
||||
return it.value().toString();
|
||||
}
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
bool QConnmanServiceInterface::isOfflineMode()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("OfflineMode"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QStringList QConnmanServiceInterface::getServices()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Services"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////
|
||||
QConnmanTechnologyInterface::QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
||||
dbusPathName,
|
||||
CONNMAN_TECHNOLOGY_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanTechnologyInterface::~QConnmanTechnologyInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanTechnologyInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
connmanConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)));
|
||||
}
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QConnmanDBusHelper *helper;
|
||||
helper = new QConnmanDBusHelper(this);
|
||||
|
||||
connmanConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(CONNMAN_TECHNOLOGY_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariantMap QConnmanTechnologyInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap> reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QVariant QConnmanTechnologyInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
// properties
|
||||
QString QConnmanTechnologyInterface::getState()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("State"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanTechnologyInterface::getName()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Name"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QConnmanTechnologyInterface::getType()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Type"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////
|
||||
QConnmanAgentInterface::QConnmanAgentInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
||||
dbusPathName,
|
||||
CONNMAN_AGENT_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanAgentInterface::~QConnmanAgentInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanAgentInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
// connmanConnection.connect(QLatin1String(CONNMAN_SERVICE),
|
||||
// this->path(),
|
||||
// QLatin1String(CONNMAN_NETWORK_INTERFACE),
|
||||
// QLatin1String("PropertyChanged"),
|
||||
// this,SIGNAL(propertyChanged(QString,QVariant&)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QConnmanAgentInterface::release()
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanAgentInterface::reportError(QDBusObjectPath &/*path*/, const QString &/*error*/)
|
||||
{
|
||||
}
|
||||
|
||||
//dict QConnmanAgentInterface::requestInput(QDBusObjectPath &path, dict fields)
|
||||
//{
|
||||
//}
|
||||
|
||||
void QConnmanAgentInterface::cancel()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////
|
||||
QConnmanCounterInterface::QConnmanCounterInterface(const QString &dbusPathName,QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(CONNMAN_SERVICE),
|
||||
dbusPathName,
|
||||
CONNMAN_COUNTER_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanCounterInterface::~QConnmanCounterInterface()
|
||||
{
|
||||
}
|
||||
|
||||
quint32 QConnmanCounterInterface::getReceivedByteCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
quint32 QConnmanCounterInterface::getTransmittedByteCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
quint64 QConnmanCounterInterface::getTimeOnline()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////
|
||||
QConnmanDBusHelper::QConnmanDBusHelper(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QConnmanDBusHelper::~QConnmanDBusHelper()
|
||||
{
|
||||
}
|
||||
|
||||
void QConnmanDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var)
|
||||
{
|
||||
QDBusMessage msg = this->message();
|
||||
Q_EMIT propertyChangedContext(msg.path() ,item, var);
|
||||
}
|
||||
|
||||
/////////////////
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#include "moc_qconnmanservice_linux_p.h"
|
|
@ -1,308 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QCONNMANSERVICE_H
|
||||
#define QCONNMANSERVICE_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusError>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QtDBus/QDBusArgument>
|
||||
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QtDBus/QDBusContext>
|
||||
#include <QMap>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
#ifndef __CONNMAN_DBUS_H
|
||||
|
||||
#define CONNMAN_SERVICE "net.connman"
|
||||
#define CONNMAN_PATH "/net/connman"
|
||||
|
||||
#define CONNMAN_DEBUG_INTERFACE CONNMAN_SERVICE ".Debug"
|
||||
#define CONNMAN_ERROR_INTERFACE CONNMAN_SERVICE ".Error"
|
||||
#define CONNMAN_AGENT_INTERFACE CONNMAN_SERVICE ".Agent"
|
||||
#define CONNMAN_COUNTER_INTERFACE CONNMAN_SERVICE ".Counter"
|
||||
|
||||
#define CONNMAN_MANAGER_INTERFACE CONNMAN_SERVICE ".Manager"
|
||||
#define CONNMAN_MANAGER_PATH "/"
|
||||
|
||||
#define CONNMAN_TASK_INTERFACE CONNMAN_SERVICE ".Task"
|
||||
#define CONNMAN_PROFILE_INTERFACE CONNMAN_SERVICE ".Profile"
|
||||
#define CONNMAN_SERVICE_INTERFACE CONNMAN_SERVICE ".Service"
|
||||
#define CONNMAN_PROVIDER_INTERFACE CONNMAN_SERVICE ".Provider"
|
||||
#define CONNMAN_TECHNOLOGY_INTERFACE CONNMAN_SERVICE ".Technology"
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
struct ConnmanMap {
|
||||
QDBusObjectPath objectPath;
|
||||
QVariantMap propertyMap;
|
||||
};
|
||||
|
||||
typedef QList< ConnmanMap > ConnmanMapList;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMap))
|
||||
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ConnmanMapList))
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const ConnmanMap &obj);
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, ConnmanMap &obj);
|
||||
|
||||
|
||||
class QConnmanManagerInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QConnmanManagerInterface( QObject *parent = nullptr);
|
||||
~QConnmanManagerInterface();
|
||||
|
||||
QDBusObjectPath path() const;
|
||||
|
||||
QVariantMap getProperties();
|
||||
bool setProperty(const QString &name, const QDBusVariant &value);
|
||||
QDBusObjectPath createProfile(const QString &name);
|
||||
bool removeProfile(QDBusObjectPath path);
|
||||
bool requestScan(const QString &type);
|
||||
bool enableTechnology(const QString &type);
|
||||
bool disableTechnology(const QString &type);
|
||||
QDBusObjectPath connectService(QVariantMap &map);
|
||||
void registerAgent(QDBusObjectPath &path);
|
||||
void unregisterAgent(QDBusObjectPath path);
|
||||
void registerCounter(const QString &path, quint32 interval);
|
||||
void unregisterCounter(const QString &path);
|
||||
|
||||
QString requestSession(const QString &bearerName);
|
||||
void releaseSession();
|
||||
|
||||
// properties
|
||||
QString getState();
|
||||
QStringList getAvailableTechnologies();
|
||||
QStringList getEnabledTechnologies();
|
||||
QStringList getConnectedTechnologies();
|
||||
QString getDefaultTechnology();
|
||||
bool getOfflineMode();
|
||||
QString getActiveProfile();
|
||||
QStringList getProfiles();
|
||||
QStringList getTechnologies();
|
||||
QStringList getServices();
|
||||
QDBusObjectPath lookupService(const QString &);
|
||||
|
||||
QString getPathForTechnology(const QString &tech);
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
void stateChanged(const QString &);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
};
|
||||
|
||||
class QConnmanProfileInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QConnmanProfileInterface(const QString &dbusPathName,QObject *parent = nullptr);
|
||||
~QConnmanProfileInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
// properties
|
||||
QString getName();
|
||||
bool isOfflineMode();
|
||||
QStringList getServices();
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
};
|
||||
|
||||
class QConnmanServiceInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QConnmanServiceInterface(const QString &dbusPathName,QObject *parent = nullptr);
|
||||
~QConnmanServiceInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
// clearProperty
|
||||
void connect();
|
||||
void disconnect();
|
||||
void remove();
|
||||
// void moveBefore(QDBusObjectPath &service);
|
||||
// void moveAfter(QDBusObjectPath &service);
|
||||
|
||||
// properties
|
||||
QString getState();
|
||||
QString getError();
|
||||
QString getName();
|
||||
QString getType();
|
||||
QString getMode();
|
||||
QString getSecurity();
|
||||
QString getPassphrase();
|
||||
bool isPassphraseRequired();
|
||||
quint8 getSignalStrength();
|
||||
bool isFavorite();
|
||||
bool isImmutable();
|
||||
bool isAutoConnect();
|
||||
bool isSetupRequired();
|
||||
QString getAPN();
|
||||
QString getMCC();
|
||||
QString getMNC();
|
||||
bool isRoaming();
|
||||
QStringList getNameservers();
|
||||
QStringList getDomains();
|
||||
QVariantMap getIPv4();
|
||||
QVariantMap getIPv4Configuration();
|
||||
QVariantMap getProxy();
|
||||
QVariantMap getEthernet();
|
||||
|
||||
QString getMethod();
|
||||
QString getInterface();
|
||||
QString getMacAddress();
|
||||
quint16 getMtu();
|
||||
quint16 getSpeed();
|
||||
QString getDuplex();
|
||||
|
||||
bool isOfflineMode();
|
||||
QStringList getServices();
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
};
|
||||
|
||||
class QConnmanTechnologyInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QConnmanTechnologyInterface(const QString &dbusPathName,QObject *parent = nullptr);
|
||||
~QConnmanTechnologyInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
// properties
|
||||
QString getState();
|
||||
QString getName();
|
||||
QString getType();
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
|
||||
};
|
||||
|
||||
class QConnmanAgentInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QConnmanAgentInterface(const QString &dbusPathName,QObject *parent = nullptr);
|
||||
~QConnmanAgentInterface();
|
||||
|
||||
void release();
|
||||
void reportError(QDBusObjectPath &path, const QString &error);
|
||||
// dict requestInput(QDBusObjectPath &path, dict fields);
|
||||
void cancel();
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
};
|
||||
|
||||
class QConnmanCounterInterfacePrivate;
|
||||
class QConnmanCounterInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QConnmanCounterInterface(const QString &dbusPathName, QObject *parent = nullptr);
|
||||
~QConnmanCounterInterface();
|
||||
|
||||
// void release();
|
||||
QString getInterface();
|
||||
quint32 getReceivedByteCount();
|
||||
quint32 getTransmittedByteCount();
|
||||
quint64 getTimeOnline();
|
||||
|
||||
private:
|
||||
QConnmanCounterInterfacePrivate *d;
|
||||
};
|
||||
|
||||
class QConnmanDBusHelper: public QObject, protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QConnmanDBusHelper(QObject *parent = nullptr);
|
||||
~QConnmanDBusHelper();
|
||||
|
||||
public slots:
|
||||
void propertyChanged(const QString &, const QDBusVariant &);
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif //QCONNMANSERVICE_H
|
|
@ -1,911 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QDebug>
|
||||
#include <QtDBus/qdbusmetatype.h>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusError>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QtDBus/QDBusPendingCall>
|
||||
|
||||
#include "qofonoservice_linux_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &argument, const ObjectPathProperties &item)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument << item.path << item.properties;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &argument, ObjectPathProperties &item)
|
||||
{
|
||||
argument.beginStructure();
|
||||
argument >> item.path >> item.properties;
|
||||
argument.endStructure();
|
||||
return argument;
|
||||
}
|
||||
|
||||
static QDBusConnection ofonoConnection = QDBusConnection::systemBus();
|
||||
|
||||
|
||||
QOfonoManagerInterface::QOfonoManagerInterface( QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
QLatin1String(OFONO_MANAGER_PATH),
|
||||
OFONO_MANAGER_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
qDBusRegisterMetaType<ObjectPathProperties>();
|
||||
qDBusRegisterMetaType<PathPropertiesList>();
|
||||
}
|
||||
|
||||
QOfonoManagerInterface::~QOfonoManagerInterface()
|
||||
{
|
||||
}
|
||||
|
||||
QList <QDBusObjectPath> QOfonoManagerInterface::getModems()
|
||||
{
|
||||
QList <QDBusObjectPath> modemList;
|
||||
QList<QVariant> argumentList;
|
||||
QDBusReply<PathPropertiesList > reply = this->asyncCallWithArgumentList(QLatin1String("GetModems"), argumentList);
|
||||
if (reply.isValid()) {
|
||||
foreach (ObjectPathProperties modem, reply.value()) {
|
||||
modemList << modem.path;
|
||||
}
|
||||
}
|
||||
|
||||
return modemList;
|
||||
}
|
||||
|
||||
QDBusObjectPath QOfonoManagerInterface::currentModem()
|
||||
{
|
||||
QList<QDBusObjectPath> modems = getModems();
|
||||
foreach (const QDBusObjectPath modem, modems) {
|
||||
QOfonoModemInterface device(modem.path());
|
||||
if (device.isPowered() && device.isOnline())
|
||||
return modem;;
|
||||
}
|
||||
return QDBusObjectPath();
|
||||
}
|
||||
|
||||
|
||||
void QOfonoManagerInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
QLatin1String(OFONO_MANAGER_PATH),
|
||||
QLatin1String(OFONO_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
QLatin1String(OFONO_MANAGER_PATH),
|
||||
QLatin1String(OFONO_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)));
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QOfonoManagerInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
return map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
QVariantMap QOfonoManagerInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
if (reply.isValid())
|
||||
return reply.value();
|
||||
else
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
QOfonoDBusHelper::QOfonoDBusHelper(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoDBusHelper::~QOfonoDBusHelper()
|
||||
{
|
||||
}
|
||||
|
||||
void QOfonoDBusHelper::propertyChanged(const QString &item, const QDBusVariant &var)
|
||||
{
|
||||
QDBusMessage msg = this->message();
|
||||
Q_EMIT propertyChangedContext(msg.path() ,item, var);
|
||||
}
|
||||
|
||||
|
||||
QOfonoModemInterface::QOfonoModemInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
dbusPathName,
|
||||
OFONO_MODEM_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoModemInterface::~QOfonoModemInterface()
|
||||
{
|
||||
}
|
||||
|
||||
bool QOfonoModemInterface::isPowered()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Powered"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
bool QOfonoModemInterface::isOnline()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Online"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QString QOfonoModemInterface::getName()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Name"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoModemInterface::getManufacturer()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Manufacturer"));
|
||||
return qdbus_cast<QString>(var);
|
||||
|
||||
}
|
||||
|
||||
QString QOfonoModemInterface::getModel()
|
||||
{
|
||||
|
||||
QVariant var = getProperty(QLatin1String("Model"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoModemInterface::getRevision()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Revision"));
|
||||
return qdbus_cast<QString>(var);
|
||||
|
||||
}
|
||||
QString QOfonoModemInterface::getSerial()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Serial"));
|
||||
return qdbus_cast<QString>(var);
|
||||
|
||||
}
|
||||
|
||||
QStringList QOfonoModemInterface::getFeatures()
|
||||
{
|
||||
//sms, sim
|
||||
QVariant var = getProperty(QLatin1String("Features"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QStringList QOfonoModemInterface::getInterfaces()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Interfaces"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
QString QOfonoModemInterface::defaultInterface()
|
||||
{
|
||||
foreach (const QString &modem,getInterfaces()) {
|
||||
return modem;
|
||||
}
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
void QOfonoModemInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_MODEM_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_MODEM_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}}
|
||||
|
||||
QVariantMap QOfonoModemInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QVariant QOfonoModemInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
|
||||
QOfonoNetworkRegistrationInterface::QOfonoNetworkRegistrationInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
dbusPathName,
|
||||
OFONO_NETWORK_REGISTRATION_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoNetworkRegistrationInterface::~QOfonoNetworkRegistrationInterface()
|
||||
{
|
||||
}
|
||||
|
||||
QString QOfonoNetworkRegistrationInterface::getStatus()
|
||||
{
|
||||
/*
|
||||
"unregistered" Not registered to any network
|
||||
"registered" Registered to home network
|
||||
"searching" Not registered, but searching
|
||||
"denied" Registration has been denied
|
||||
"unknown" Status is unknown
|
||||
"roaming" Registered, but roaming*/
|
||||
QVariant var = getProperty(QLatin1String("Status"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
quint16 QOfonoNetworkRegistrationInterface::getLac()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("LocationAreaCode"));
|
||||
return var.value<quint16>();
|
||||
}
|
||||
|
||||
|
||||
quint32 QOfonoNetworkRegistrationInterface::getCellId()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("CellId"));
|
||||
return var.value<quint32>();
|
||||
}
|
||||
|
||||
QString QOfonoNetworkRegistrationInterface::getTechnology()
|
||||
{
|
||||
// "gsm", "edge", "umts", "hspa","lte"
|
||||
QVariant var = getProperty(QLatin1String("Technology"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoNetworkRegistrationInterface::getOperatorName()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Name"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
int QOfonoNetworkRegistrationInterface::getSignalStrength()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Strength"));
|
||||
return qdbus_cast<int>(var);
|
||||
|
||||
}
|
||||
|
||||
QString QOfonoNetworkRegistrationInterface::getBaseStation()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("BaseStation"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QList <QDBusObjectPath> QOfonoNetworkRegistrationInterface::getOperators()
|
||||
{
|
||||
QList <QDBusObjectPath> operatorList;
|
||||
QList<QVariant> argumentList;
|
||||
QDBusReply<PathPropertiesList > reply = this->asyncCallWithArgumentList(QLatin1String("GetOperators"),
|
||||
argumentList);
|
||||
if (reply.isValid()) {
|
||||
foreach (ObjectPathProperties netop, reply.value()) {
|
||||
operatorList << netop.path;
|
||||
}
|
||||
}
|
||||
return operatorList;
|
||||
}
|
||||
|
||||
void QOfonoNetworkRegistrationInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_NETWORK_REGISTRATION_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QOfonoNetworkRegistrationInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
QVariantMap QOfonoNetworkRegistrationInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
|
||||
|
||||
QOfonoNetworkOperatorInterface::QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
dbusPathName,
|
||||
OFONO_NETWORK_OPERATOR_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoNetworkOperatorInterface::~QOfonoNetworkOperatorInterface()
|
||||
{
|
||||
}
|
||||
|
||||
QString QOfonoNetworkOperatorInterface::getName()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Name"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoNetworkOperatorInterface::getStatus()
|
||||
{
|
||||
// "unknown", "available", "current" and "forbidden"
|
||||
QVariant var = getProperty(QLatin1String("Status"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoNetworkOperatorInterface::getMcc()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("MobileCountryCode"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoNetworkOperatorInterface::getMnc()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("MobileNetworkCode"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QStringList QOfonoNetworkOperatorInterface::getTechnologies()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Technologies"));
|
||||
return qdbus_cast<QStringList>(var);
|
||||
}
|
||||
|
||||
void QOfonoNetworkOperatorInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_NETWORK_OPERATOR_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QOfonoNetworkOperatorInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
QVariantMap QOfonoNetworkOperatorInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QOfonoSimInterface::QOfonoSimInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
dbusPathName,
|
||||
OFONO_SIM_MANAGER_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoSimInterface::~QOfonoSimInterface()
|
||||
{
|
||||
}
|
||||
|
||||
bool QOfonoSimInterface::isPresent()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Present"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QString QOfonoSimInterface::getHomeMcc()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("MobileCountryCode"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoSimInterface::getHomeMnc()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("MobileNetworkCode"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
// QStringList subscriberNumbers();
|
||||
// QMap<QString,QString> serviceNumbers();
|
||||
QString QOfonoSimInterface::pinRequired()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("PinRequired"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoSimInterface::lockedPins()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("LockedPins"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoSimInterface::cardIdentifier()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("CardIdentifier"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
void QOfonoSimInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_SIM_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QOfonoSimInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
QVariantMap QOfonoSimInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QOfonoDataConnectionManagerInterface::QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
dbusPathName,
|
||||
OFONO_DATA_CONNECTION_MANAGER_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoDataConnectionManagerInterface::~QOfonoDataConnectionManagerInterface()
|
||||
{
|
||||
}
|
||||
|
||||
QList<QDBusObjectPath> QOfonoDataConnectionManagerInterface::getPrimaryContexts()
|
||||
{
|
||||
QList <QDBusObjectPath> contextList;
|
||||
QList<QVariant> argumentList;
|
||||
QDBusReply<PathPropertiesList > reply = this->asyncCallWithArgumentList(QLatin1String("GetContexts"),
|
||||
argumentList);
|
||||
if (reply.isValid()) {
|
||||
foreach (ObjectPathProperties context, reply.value()) {
|
||||
contextList << context.path;
|
||||
}
|
||||
}
|
||||
return contextList;
|
||||
}
|
||||
|
||||
bool QOfonoDataConnectionManagerInterface::isAttached()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Attached"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
bool QOfonoDataConnectionManagerInterface::isRoamingAllowed()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("RoamingAllowed"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
bool QOfonoDataConnectionManagerInterface::isPowered()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Powered"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
void QOfonoDataConnectionManagerInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_DATA_CONNECTION_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QOfonoDataConnectionManagerInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
QVariantMap QOfonoDataConnectionManagerInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QOfonoPrimaryDataContextInterface::QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
dbusPathName,
|
||||
OFONO_DATA_CONTEXT_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoPrimaryDataContextInterface::~QOfonoPrimaryDataContextInterface()
|
||||
{
|
||||
}
|
||||
|
||||
bool QOfonoPrimaryDataContextInterface::isActive()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Active"));
|
||||
return qdbus_cast<bool>(var);
|
||||
}
|
||||
|
||||
QString QOfonoPrimaryDataContextInterface::getApName()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("AccessPointName"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoPrimaryDataContextInterface::getType()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Type"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoPrimaryDataContextInterface::getName()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Name"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QVariantMap QOfonoPrimaryDataContextInterface::getSettings()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Settings"));
|
||||
return qdbus_cast<QVariantMap>(var);
|
||||
}
|
||||
|
||||
QString QOfonoPrimaryDataContextInterface::getInterface()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Interface"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
QString QOfonoPrimaryDataContextInterface::getAddress()
|
||||
{
|
||||
QVariant var = getProperty(QLatin1String("Address"));
|
||||
return qdbus_cast<QString>(var);
|
||||
}
|
||||
|
||||
bool QOfonoPrimaryDataContextInterface::setActive(bool on)
|
||||
{
|
||||
// this->setProperty("Active", QVariant(on));
|
||||
|
||||
return setProp(QLatin1String("Active"), qVariantFromValue(on));
|
||||
}
|
||||
|
||||
bool QOfonoPrimaryDataContextInterface::setApn(const QString &name)
|
||||
{
|
||||
return setProp(QLatin1String("AccessPointName"), QVariant::fromValue(name));
|
||||
}
|
||||
|
||||
void QOfonoPrimaryDataContextInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_DATA_CONTEXT_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)), Qt::UniqueConnection);
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QOfonoPrimaryDataContextInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
QVariantMap QOfonoPrimaryDataContextInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
bool QOfonoPrimaryDataContextInterface::setProp(const QString &property, const QVariant &var)
|
||||
{
|
||||
QList<QVariant> args;
|
||||
args << qVariantFromValue(property) << qVariantFromValue(QDBusVariant(var));
|
||||
|
||||
QDBusMessage reply = this->callWithArgumentList(QDBus::AutoDetect,
|
||||
QLatin1String("SetProperty"),
|
||||
args);
|
||||
bool ok = true;
|
||||
if (reply.type() != QDBusMessage::ReplyMessage) {
|
||||
qWarning() << reply.errorMessage();
|
||||
ok = false;
|
||||
}
|
||||
qWarning() << reply.errorMessage();
|
||||
return ok;
|
||||
}
|
||||
|
||||
QOfonoSmsInterface::QOfonoSmsInterface(const QString &dbusPathName, QObject *parent)
|
||||
: QDBusAbstractInterface(QLatin1String(OFONO_SERVICE),
|
||||
dbusPathName,
|
||||
OFONO_SMS_MANAGER_INTERFACE,
|
||||
QDBusConnection::systemBus(), parent)
|
||||
{
|
||||
}
|
||||
|
||||
QOfonoSmsInterface::~QOfonoSmsInterface()
|
||||
{
|
||||
}
|
||||
|
||||
void QOfonoSmsInterface::connectNotify(const char *signal)
|
||||
{
|
||||
if (strcmp(signal + 1, "propertyChanged(QString,QDBusVariant)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
this,SIGNAL(propertyChanged(QString,QDBusVariant)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "propertyChangedContext(QString,QString,QDBusVariant)") == 0) {
|
||||
QOfonoDBusHelper *helper;
|
||||
helper = new QOfonoDBusHelper(this);
|
||||
|
||||
ofonoConnection.connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
|
||||
QLatin1String("PropertyChanged"),
|
||||
helper,SLOT(propertyChanged(QString,QDBusVariant)));
|
||||
|
||||
|
||||
QObject::connect(helper,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)),
|
||||
this,SIGNAL(propertyChangedContext(QString,QString,QDBusVariant)));
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "immediateMessage(QString,QVariantMap)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
|
||||
QLatin1String("ImmediateMessage"),
|
||||
this,SIGNAL(immediateMessage(QString,QVariantMap)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
|
||||
if (strcmp(signal + 1, "incomingMessage(QString,QVariantMap)") == 0) {
|
||||
if (!connection().connect(QLatin1String(OFONO_SERVICE),
|
||||
this->path(),
|
||||
QLatin1String(OFONO_SMS_MANAGER_INTERFACE),
|
||||
QLatin1String("IncomingMessage"),
|
||||
this,SIGNAL(incomingMessage(QString,QVariantMap)))) {
|
||||
qWarning() << "PropertyCHanged not connected";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QVariant QOfonoSmsInterface::getProperty(const QString &property)
|
||||
{
|
||||
QVariant var;
|
||||
QVariantMap map = getProperties();
|
||||
if (map.contains(property)) {
|
||||
var = map.value(property);
|
||||
} else {
|
||||
qDebug() << Q_FUNC_INFO << "does not contain" << property;
|
||||
}
|
||||
return var;
|
||||
}
|
||||
|
||||
QVariantMap QOfonoSmsInterface::getProperties()
|
||||
{
|
||||
QDBusReply<QVariantMap > reply = this->call(QLatin1String("GetProperties"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
void QOfonoSmsInterface::sendMessage(const QString &to, const QString &message)
|
||||
{
|
||||
QDBusReply<QString> reply = this->call(QLatin1String("SendMessage"),
|
||||
QVariant::fromValue(to),
|
||||
QVariant::fromValue(message));
|
||||
if (reply.error().type() == QDBusError::InvalidArgs)
|
||||
qWarning() << reply.error().message();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
#include "moc_qofonoservice_linux_p.h"
|
|
@ -1,318 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QOFONOSERVICE_H
|
||||
#define QOFONOSERVICE_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusError>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QtDBus/QDBusContext>
|
||||
#include <QMap>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
#define OFONO_SERVICE "org.ofono"
|
||||
#define OFONO_MANAGER_INTERFACE "org.ofono.Manager"
|
||||
#define OFONO_MANAGER_PATH "/"
|
||||
#define OFONO_MODEM_INTERFACE "org.ofono.Modem"
|
||||
#define OFONO_NETWORK_REGISTRATION_INTERFACE "org.ofono.NetworkRegistration"
|
||||
#define OFONO_NETWORK_OPERATOR_INTERFACE "org.ofono.NetworkOperator"
|
||||
#define OFONO_DATA_CONNECTION_MANAGER_INTERFACE "org.ofono.DataConnectionManager"
|
||||
#define OFONO_SIM_MANAGER_INTERFACE "org.ofono.SimManager"
|
||||
#define OFONO_DATA_CONTEXT_INTERFACE "org.ofono.PrimaryDataContext"
|
||||
|
||||
#define OFONO_SMS_MANAGER_INTERFACE "org.ofono.SmsManager"
|
||||
#define OFONO_PHONEBOOK_INTERFACE "org.ofono.Phonebook"
|
||||
#define OFONO_MESSAGE_WAITING_INTERFACE "org.ofono.MessageWaiting"
|
||||
|
||||
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
struct ObjectPathProperties
|
||||
{
|
||||
QDBusObjectPath path;
|
||||
QVariantMap properties;
|
||||
};
|
||||
typedef QList<ObjectPathProperties> PathPropertiesList;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(ObjectPathProperties)
|
||||
Q_DECLARE_METATYPE(PathPropertiesList)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QOfonoManagerInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QOfonoManagerInterface( QObject *parent = nullptr);
|
||||
~QOfonoManagerInterface();
|
||||
|
||||
QDBusObjectPath path() const;
|
||||
|
||||
QVariantMap getProperties();
|
||||
bool setProperty(const QString &name, const QDBusVariant &value);
|
||||
QList <QDBusObjectPath> getModems();
|
||||
QDBusObjectPath currentModem();
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
|
||||
};
|
||||
|
||||
|
||||
class QOfonoDBusHelper: public QObject, protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QOfonoDBusHelper(QObject *parent = nullptr);
|
||||
~QOfonoDBusHelper();
|
||||
|
||||
public slots:
|
||||
void propertyChanged(const QString &, const QDBusVariant &);
|
||||
Q_SIGNALS:
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
};
|
||||
|
||||
class QOfonoModemInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QOfonoModemInterface(const QString &dbusModemPathName, QObject *parent = nullptr);
|
||||
~QOfonoModemInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
//properties
|
||||
bool isPowered();
|
||||
bool isOnline();
|
||||
QString getName();
|
||||
QString getManufacturer();
|
||||
QString getModel();
|
||||
QString getRevision();
|
||||
QString getSerial();
|
||||
|
||||
QStringList getFeatures(); //sms, sim
|
||||
QStringList getInterfaces();
|
||||
QString defaultInterface();
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
};
|
||||
|
||||
|
||||
class QOfonoNetworkRegistrationInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QOfonoNetworkRegistrationInterface(const QString &dbusModemPathName, QObject *parent = nullptr);
|
||||
~QOfonoNetworkRegistrationInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
|
||||
//properties
|
||||
QString getStatus();
|
||||
quint16 getLac();
|
||||
quint32 getCellId();
|
||||
QString getTechnology();
|
||||
QString getOperatorName();
|
||||
int getSignalStrength();
|
||||
QString getBaseStation();
|
||||
QList <QDBusObjectPath> getOperators();
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
|
||||
};
|
||||
|
||||
class QOfonoNetworkOperatorInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//modem or operator paths
|
||||
QOfonoNetworkOperatorInterface(const QString &dbusPathName, QObject *parent = nullptr);
|
||||
~QOfonoNetworkOperatorInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
|
||||
//properties
|
||||
QString getName();
|
||||
QString getStatus();// "unknown", "available", "current" and "forbidden"
|
||||
QString getMcc();
|
||||
QString getMnc();
|
||||
QStringList getTechnologies();
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
};
|
||||
|
||||
class QOfonoSimInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QOfonoSimInterface(const QString &dbusModemPathName, QObject *parent = nullptr);
|
||||
~QOfonoSimInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
|
||||
//properties
|
||||
bool isPresent();
|
||||
QString getHomeMcc();
|
||||
QString getHomeMnc();
|
||||
// QStringList subscriberNumbers();
|
||||
// QMap<QString,QString> serviceNumbers();
|
||||
QString pinRequired();
|
||||
QString lockedPins();
|
||||
QString cardIdentifier();
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
};
|
||||
|
||||
|
||||
class QOfonoDataConnectionManagerInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QOfonoDataConnectionManagerInterface(const QString &dbusPathName, QObject *parent = nullptr);
|
||||
~QOfonoDataConnectionManagerInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
|
||||
//properties
|
||||
QList<QDBusObjectPath> getPrimaryContexts();
|
||||
bool isAttached();
|
||||
bool isRoamingAllowed();
|
||||
bool isPowered();
|
||||
|
||||
bool setPower(bool on);
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
};
|
||||
|
||||
|
||||
class QOfonoPrimaryDataContextInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QOfonoPrimaryDataContextInterface(const QString &dbusPathName, QObject *parent = nullptr);
|
||||
~QOfonoPrimaryDataContextInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
|
||||
//properties
|
||||
bool isActive();
|
||||
QString getApName();
|
||||
QString getType();
|
||||
QString getName();
|
||||
QVariantMap getSettings();
|
||||
QString getInterface();
|
||||
QString getAddress();
|
||||
|
||||
bool setActive(bool on);
|
||||
bool setApn(const QString &name);
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
bool setProp(const QString &, const QVariant &var);
|
||||
};
|
||||
|
||||
class QOfonoSmsInterface : public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QOfonoSmsInterface(const QString &dbusModemPathName, QObject *parent = nullptr);
|
||||
~QOfonoSmsInterface();
|
||||
|
||||
QVariantMap getProperties();
|
||||
void sendMessage(const QString &to, const QString &message);
|
||||
|
||||
//properties
|
||||
QString serviceCenterAddress();
|
||||
bool useDeliveryReports();
|
||||
QString bearer();
|
||||
|
||||
protected:
|
||||
void connectNotify(const char *signal);
|
||||
QVariant getProperty(const QString &);
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertyChanged(const QString &, const QDBusVariant &value);
|
||||
void propertyChangedContext(const QString &,const QString &,const QDBusVariant &);
|
||||
void immediateMessage(const QString &message, const QVariantMap &info);
|
||||
void incomingMessage(const QString &message, const QVariantMap &info);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif //QOFONOSERVICE_H
|
|
@ -1,29 +0,0 @@
|
|||
set(QGENERICBEARERPLUGIN_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qgenericengine.h
|
||||
)
|
||||
|
||||
set(QGENERICBEARERPLUGIN_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qgenericmain.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qgenericengine.cpp
|
||||
)
|
||||
|
||||
katie_setup_target(qgenericbearerplugin ${QGENERICBEARERPLUGIN_SOURCES} ${QGENERICBEARERPLUGIN_HEADERS})
|
||||
|
||||
add_library(qgenericbearerplugin MODULE ${qgenericbearerplugin_SOURCES}
|
||||
$<TARGET_OBJECTS:sharedbearer>
|
||||
)
|
||||
target_link_libraries(qgenericbearerplugin KtCore KtNetwork)
|
||||
set_target_properties(qgenericbearerplugin PROPERTIES OUTPUT_NAME qgenericbearer)
|
||||
target_include_directories(qgenericbearerplugin PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/plugins/bearer
|
||||
${CMAKE_BINARY_DIR}/src/plugins/bearer
|
||||
)
|
||||
|
||||
katie_setup_object(qgenericbearerplugin sharedbearer)
|
||||
katie_setup_plugin(qgenericbearerplugin)
|
||||
|
||||
install(
|
||||
TARGETS qgenericbearerplugin
|
||||
DESTINATION ${KATIE_PLUGINS_PATH}/bearer
|
||||
COMPONENT Runtime
|
||||
)
|
|
@ -1,282 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qgenericengine.h"
|
||||
#include "qnetworkconfiguration_p.h"
|
||||
#include "qthread.h"
|
||||
#include "qmutex.h"
|
||||
#include "qcoreapplication.h"
|
||||
#include "qstringlist.h"
|
||||
#include "qdebug.h"
|
||||
#include "qcoreapplication_p.h"
|
||||
#include "qnet_unix_p.h"
|
||||
#include "../qnetworksession_impl.h"
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
#ifndef QT_NO_NETWORKINTERFACE
|
||||
static QNetworkConfiguration::BearerType qGetInterfaceType(const QString &interface)
|
||||
{
|
||||
#if defined(Q_OS_LINUX)
|
||||
int sock = qt_safe_socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
struct ifreq request;
|
||||
strncpy(request.ifr_name, interface.toLocal8Bit().data(), sizeof(request.ifr_name));
|
||||
int result = ::ioctl(sock, SIOCGIFHWADDR, &request);
|
||||
qt_safe_close(sock);
|
||||
|
||||
if (result >= 0 && request.ifr_hwaddr.sa_family == ARPHRD_ETHER)
|
||||
return QNetworkConfiguration::BearerEthernet;
|
||||
#else
|
||||
Q_UNUSED(interface);
|
||||
#endif
|
||||
|
||||
return QNetworkConfiguration::BearerUnknown;
|
||||
}
|
||||
#endif
|
||||
|
||||
QGenericEngine::QGenericEngine(QObject *parent)
|
||||
: QBearerEngineImpl(parent)
|
||||
{
|
||||
//workaround for deadlock in __cxa_guard_acquire with webkit on macos x
|
||||
//initialise the Q_GLOBAL_STATIC in same thread as the AtomicallyInitializedStatic
|
||||
(void)QNetworkInterface::interfaceFromIndex(0);
|
||||
}
|
||||
|
||||
QGenericEngine::~QGenericEngine()
|
||||
{
|
||||
}
|
||||
|
||||
QString QGenericEngine::getInterfaceFromId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
return configurationInterface.value(id);
|
||||
}
|
||||
|
||||
bool QGenericEngine::hasIdentifier(const QString &id) const
|
||||
{
|
||||
return configurationInterface.contains(id);
|
||||
}
|
||||
|
||||
void QGenericEngine::connectToId(const QString &id)
|
||||
{
|
||||
emit connectionError(id, OperationNotSupported);
|
||||
}
|
||||
|
||||
void QGenericEngine::disconnectFromId(const QString &id)
|
||||
{
|
||||
emit connectionError(id, OperationNotSupported);
|
||||
}
|
||||
|
||||
void QGenericEngine::initialize()
|
||||
{
|
||||
doRequestUpdate();
|
||||
}
|
||||
|
||||
void QGenericEngine::requestUpdate()
|
||||
{
|
||||
doRequestUpdate();
|
||||
}
|
||||
|
||||
void QGenericEngine::doRequestUpdate()
|
||||
{
|
||||
#ifndef QT_NO_NETWORKINTERFACE
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
// Immediately after connecting with a wireless access point
|
||||
// QNetworkInterface::allInterfaces() will sometimes return an empty list. Calling it again a
|
||||
// second time results in a non-empty list. If we loose interfaces we will end up removing
|
||||
// network configurations which will break current sessions.
|
||||
QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
|
||||
if (interfaces.isEmpty())
|
||||
interfaces = QNetworkInterface::allInterfaces();
|
||||
|
||||
QStringList previous = accessPointConfigurations.keys();
|
||||
|
||||
// create configuration for each interface
|
||||
while (!interfaces.isEmpty()) {
|
||||
QNetworkInterface interface = interfaces.takeFirst();
|
||||
|
||||
if (!interface.isValid())
|
||||
continue;
|
||||
|
||||
// ignore loopback interface
|
||||
if (interface.flags() & QNetworkInterface::IsLoopBack)
|
||||
continue;
|
||||
|
||||
// ignore WLAN interface handled in separate engine
|
||||
if (qGetInterfaceType(interface.name()) == QNetworkConfiguration::BearerWLAN)
|
||||
continue;
|
||||
|
||||
uint identifier;
|
||||
if (interface.index())
|
||||
identifier = qHash(QLatin1String("generic:") + QString::number(interface.index()));
|
||||
else
|
||||
identifier = qHash(QLatin1String("generic:") + interface.hardwareAddress());
|
||||
|
||||
const QString id = QString::number(identifier);
|
||||
|
||||
previous.removeAll(id);
|
||||
|
||||
QString name = interface.humanReadableName();
|
||||
if (name.isEmpty())
|
||||
name = interface.name();
|
||||
|
||||
QNetworkConfiguration::StateFlags state = QNetworkConfiguration::Defined;
|
||||
if ((interface.flags() & QNetworkInterface::IsRunning) && !interface.addressEntries().isEmpty())
|
||||
state |= QNetworkConfiguration::Active;
|
||||
|
||||
if (accessPointConfigurations.contains(id)) {
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
|
||||
bool changed = false;
|
||||
|
||||
ptr->mutex.lock();
|
||||
|
||||
if (!ptr->isValid) {
|
||||
ptr->isValid = true;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (ptr->name != name) {
|
||||
ptr->name = name;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (ptr->id != id) {
|
||||
ptr->id = id;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (ptr->state != state) {
|
||||
ptr->state = state;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
ptr->mutex.unlock();
|
||||
|
||||
if (changed) {
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.lock();
|
||||
}
|
||||
} else {
|
||||
QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
|
||||
|
||||
ptr->name = name;
|
||||
ptr->isValid = true;
|
||||
ptr->id = id;
|
||||
ptr->state = state;
|
||||
ptr->type = QNetworkConfiguration::InternetAccessPoint;
|
||||
ptr->bearerType = qGetInterfaceType(interface.name());
|
||||
|
||||
accessPointConfigurations.insert(id, ptr);
|
||||
configurationInterface.insert(id, interface.name());
|
||||
|
||||
locker.unlock();
|
||||
emit configurationAdded(ptr);
|
||||
locker.lock();
|
||||
}
|
||||
}
|
||||
|
||||
while (!previous.isEmpty()) {
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.take(previous.takeFirst());
|
||||
|
||||
configurationInterface.remove(ptr->id);
|
||||
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
locker.lock();
|
||||
}
|
||||
|
||||
locker.unlock();
|
||||
#endif
|
||||
|
||||
emit updateCompleted();
|
||||
}
|
||||
|
||||
QNetworkSession::State QGenericEngine::sessionStateForId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
|
||||
if (!ptr)
|
||||
return QNetworkSession::Invalid;
|
||||
|
||||
std::lock_guard<std::recursive_mutex> configLocker(ptr->mutex);
|
||||
|
||||
if (!ptr->isValid) {
|
||||
return QNetworkSession::Invalid;
|
||||
} else if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
|
||||
return QNetworkSession::Connected;
|
||||
} else if ((ptr->state & QNetworkConfiguration::Discovered) ==
|
||||
QNetworkConfiguration::Discovered) {
|
||||
return QNetworkSession::Disconnected;
|
||||
} else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined) {
|
||||
return QNetworkSession::NotAvailable;
|
||||
} else if ((ptr->state & QNetworkConfiguration::Undefined) ==
|
||||
QNetworkConfiguration::Undefined) {
|
||||
return QNetworkSession::NotAvailable;
|
||||
}
|
||||
|
||||
return QNetworkSession::Invalid;
|
||||
}
|
||||
|
||||
QNetworkConfigurationManager::Capabilities QGenericEngine::capabilities() const
|
||||
{
|
||||
return QNetworkConfigurationManager::ForcedRoaming;
|
||||
}
|
||||
|
||||
QNetworkSessionPrivate *QGenericEngine::createSessionBackend()
|
||||
{
|
||||
return new QNetworkSessionPrivateImpl;
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivatePointer QGenericEngine::defaultConfiguration()
|
||||
{
|
||||
return QNetworkConfigurationPrivatePointer();
|
||||
}
|
||||
|
||||
|
||||
bool QGenericEngine::requiresPolling() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#include "moc_qgenericengine.h"
|
||||
#include "moc_qbearerengine_impl.h"
|
|
@ -1,76 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QGENERICENGINE_H
|
||||
#define QGENERICENGINE_H
|
||||
|
||||
#include "../qbearerengine_impl.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QTimer>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkConfigurationPrivate;
|
||||
class QNetworkSessionPrivate;
|
||||
|
||||
class QGenericEngine : public QBearerEngineImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QGenericEngine(QObject *parent = nullptr);
|
||||
~QGenericEngine();
|
||||
|
||||
QString getInterfaceFromId(const QString &id);
|
||||
bool hasIdentifier(const QString &id) const;
|
||||
|
||||
void connectToId(const QString &id);
|
||||
void disconnectFromId(const QString &id);
|
||||
|
||||
Q_INVOKABLE void initialize();
|
||||
Q_INVOKABLE void requestUpdate();
|
||||
|
||||
QNetworkSession::State sessionStateForId(const QString &id);
|
||||
|
||||
QNetworkConfigurationManager::Capabilities capabilities() const;
|
||||
|
||||
QNetworkSessionPrivate *createSessionBackend();
|
||||
|
||||
QNetworkConfigurationPrivatePointer defaultConfiguration();
|
||||
|
||||
bool requiresPolling() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void doRequestUpdate();
|
||||
|
||||
private:
|
||||
QMap<QString, QString> configurationInterface;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qgenericengine.h"
|
||||
#include "qbearerplugin_p.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QGenericEnginePlugin : public QBearerEnginePlugin
|
||||
{
|
||||
public:
|
||||
QGenericEnginePlugin();
|
||||
~QGenericEnginePlugin();
|
||||
|
||||
QStringList keys() const;
|
||||
QBearerEngine *create(const QString &key) const;
|
||||
};
|
||||
|
||||
QGenericEnginePlugin::QGenericEnginePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QGenericEnginePlugin::~QGenericEnginePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList QGenericEnginePlugin::keys() const
|
||||
{
|
||||
static const QStringList list = QStringList()
|
||||
<< QLatin1String("generic");
|
||||
return list;
|
||||
}
|
||||
|
||||
QBearerEngine *QGenericEnginePlugin::create(const QString &key) const
|
||||
{
|
||||
if (key == QLatin1String("generic"))
|
||||
return new QGenericEngine;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(qgenericbearer, QGenericEnginePlugin)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
|
@ -1,33 +0,0 @@
|
|||
set(QNMBEARERPLUGIN_HEADERS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qnmdbushelper.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qnetworkmanagerservice.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qnetworkmanagerengine.h
|
||||
)
|
||||
|
||||
set(QNMBEARERPLUGIN_SOURCES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/nmmain.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qnmdbushelper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qnetworkmanagerservice.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/qnetworkmanagerengine.cpp
|
||||
)
|
||||
|
||||
katie_setup_target(qnmbearerplugin ${QNMBEARERPLUGIN_SOURCES} ${QNMBEARERPLUGIN_HEADERS})
|
||||
|
||||
add_library(qnmbearerplugin MODULE ${qnmbearerplugin_SOURCES}
|
||||
$<TARGET_OBJECTS:sharedbearer>
|
||||
)
|
||||
target_link_libraries(qnmbearerplugin KtCore KtNetwork KtDBus)
|
||||
set_target_properties(qnmbearerplugin PROPERTIES OUTPUT_NAME qnmbearer)
|
||||
target_include_directories(qnmbearerplugin PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/plugins/bearer
|
||||
${CMAKE_BINARY_DIR}/src/plugins/bearer
|
||||
)
|
||||
|
||||
katie_setup_object(qnmbearerplugin sharedbearer)
|
||||
katie_setup_plugin(qnmbearerplugin)
|
||||
|
||||
install(
|
||||
TARGETS qnmbearerplugin
|
||||
DESTINATION ${KATIE_PLUGINS_PATH}/bearer
|
||||
COMPONENT Runtime
|
||||
)
|
|
@ -1,74 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnetworkmanagerengine.h"
|
||||
#include "qbearerplugin_p.h"
|
||||
#include "qdebug.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkManagerEnginePlugin : public QBearerEnginePlugin
|
||||
{
|
||||
public:
|
||||
QNetworkManagerEnginePlugin();
|
||||
~QNetworkManagerEnginePlugin();
|
||||
|
||||
QStringList keys() const;
|
||||
QBearerEngine *create(const QString &key) const;
|
||||
};
|
||||
|
||||
QNetworkManagerEnginePlugin::QNetworkManagerEnginePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QNetworkManagerEnginePlugin::~QNetworkManagerEnginePlugin()
|
||||
{
|
||||
}
|
||||
|
||||
QStringList QNetworkManagerEnginePlugin::keys() const
|
||||
{
|
||||
static const QStringList list = QStringList()
|
||||
<< QLatin1String("networkmanager");
|
||||
return list;
|
||||
}
|
||||
|
||||
QBearerEngine *QNetworkManagerEnginePlugin::create(const QString &key) const
|
||||
{
|
||||
if (key == QLatin1String("networkmanager")) {
|
||||
QNetworkManagerEngine *engine = new QNetworkManagerEngine;
|
||||
if (engine->networkManagerAvailable())
|
||||
return engine;
|
||||
else
|
||||
delete engine;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Q_EXPORT_PLUGIN2(qnmbearer, QNetworkManagerEnginePlugin)
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
|
@ -1,887 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnetworkmanagerengine.h"
|
||||
#include "qnetworkmanagerservice.h"
|
||||
#include "../qnetworksession_impl.h"
|
||||
#include "qnetworkconfiguration_p.h"
|
||||
#include "qnetworksession.h"
|
||||
#include "qdebug.h"
|
||||
#include "qfile.h"
|
||||
#include "qdbusmetatype.h"
|
||||
#include "qdbusconnection.h"
|
||||
#include "qdbuserror.h"
|
||||
#include "qdbusinterface.h"
|
||||
#include "qdbusmessage.h"
|
||||
#include "qdbusreply.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QNetworkManagerEngine::QNetworkManagerEngine(QObject *parent)
|
||||
: QBearerEngineImpl(parent),
|
||||
interface(new QNetworkManagerInterface(this)),
|
||||
systemSettings(new QNetworkManagerSettings(QLatin1String(NM_DBUS_SERVICE_SYSTEM_SETTINGS), this)),
|
||||
userSettings(new QNetworkManagerSettings(QLatin1String(NM_DBUS_SERVICE_USER_SETTINGS), this))
|
||||
{
|
||||
if (!interface->isValid())
|
||||
return;
|
||||
|
||||
interface->setConnections();
|
||||
connect(interface, SIGNAL(deviceAdded(QDBusObjectPath)),
|
||||
this, SLOT(deviceAdded(QDBusObjectPath)));
|
||||
connect(interface, SIGNAL(deviceRemoved(QDBusObjectPath)),
|
||||
this, SLOT(deviceRemoved(QDBusObjectPath)));
|
||||
#if 0
|
||||
connect(interface, SIGNAL(stateChanged(QString,quint32)),
|
||||
this, SIGNAL(configurationsChanged()));
|
||||
#endif
|
||||
connect(interface, SIGNAL(activationFinished(QDBusPendingCallWatcher*)),
|
||||
this, SLOT(activationFinished(QDBusPendingCallWatcher*)));
|
||||
connect(interface, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this, SLOT(interfacePropertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
|
||||
qDBusRegisterMetaType<QNmSettingsMap>();
|
||||
|
||||
systemSettings->setConnections();
|
||||
connect(systemSettings, SIGNAL(newConnection(QDBusObjectPath)),
|
||||
this, SLOT(newConnection(QDBusObjectPath)));
|
||||
|
||||
userSettings->setConnections();
|
||||
connect(userSettings, SIGNAL(newConnection(QDBusObjectPath)),
|
||||
this, SLOT(newConnection(QDBusObjectPath)));
|
||||
}
|
||||
|
||||
QNetworkManagerEngine::~QNetworkManagerEngine()
|
||||
{
|
||||
qDeleteAll(connections);
|
||||
qDeleteAll(accessPoints);
|
||||
qDeleteAll(wirelessDevices);
|
||||
qDeleteAll(activeConnections);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::initialize()
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
// Get current list of access points.
|
||||
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
|
||||
locker.unlock();
|
||||
deviceAdded(devicePath);
|
||||
locker.lock();
|
||||
}
|
||||
|
||||
// Get connections.
|
||||
foreach (const QDBusObjectPath &settingsPath, systemSettings->listConnections()) {
|
||||
locker.unlock();
|
||||
newConnection(settingsPath, systemSettings);
|
||||
locker.lock();
|
||||
}
|
||||
foreach (const QDBusObjectPath &settingsPath, userSettings->listConnections()) {
|
||||
locker.unlock();
|
||||
newConnection(settingsPath, userSettings);
|
||||
locker.lock();
|
||||
}
|
||||
|
||||
// Get active connections.
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive *activeConnection =
|
||||
new QNetworkManagerConnectionActive(acPath.path());
|
||||
activeConnections.insert(acPath.path(), activeConnection);
|
||||
|
||||
activeConnection->setConnections();
|
||||
connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
}
|
||||
}
|
||||
|
||||
bool QNetworkManagerEngine::networkManagerAvailable() const
|
||||
{
|
||||
return interface->isValid();
|
||||
}
|
||||
|
||||
QString QNetworkManagerEngine::getInterfaceFromId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
const QString identifier = QString::number(qHash(activeConnection.serviceName() + QLatin1Char(' ') +
|
||||
activeConnection.connection().path()));
|
||||
|
||||
if (id == identifier) {
|
||||
QList<QDBusObjectPath> devices = activeConnection.devices();
|
||||
|
||||
if (devices.isEmpty())
|
||||
continue;
|
||||
|
||||
QNetworkManagerInterfaceDevice device(devices.at(0).path());
|
||||
return device.networkInterface();
|
||||
}
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
bool QNetworkManagerEngine::hasIdentifier(const QString &id) const
|
||||
{
|
||||
if (connectionFromId(id))
|
||||
return true;
|
||||
|
||||
for (int i = 0; i < accessPoints.count(); ++i) {
|
||||
QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
|
||||
|
||||
const QString identifier =
|
||||
QString::number(qHash(accessPoint->connectionInterface()->path()));
|
||||
|
||||
if (id == identifier)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::connectToId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkManagerSettingsConnection *connection = connectionFromId(id);
|
||||
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
QNmSettingsMap map = connection->getSettings();
|
||||
const QString connectionType = map.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
|
||||
|
||||
QString dbusDevicePath;
|
||||
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
|
||||
QNetworkManagerInterfaceDevice device(devicePath.path());
|
||||
if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET &&
|
||||
connectionType == QLatin1String("802-3-ethernet")) {
|
||||
dbusDevicePath = devicePath.path();
|
||||
break;
|
||||
} else if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS &&
|
||||
connectionType == QLatin1String("802-11-wireless")) {
|
||||
dbusDevicePath = devicePath.path();
|
||||
break;
|
||||
}
|
||||
else if (device.deviceType() == DEVICE_TYPE_GSM &&
|
||||
connectionType == QLatin1String("gsm")) {
|
||||
dbusDevicePath = devicePath.path();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
|
||||
interface->activateConnection(service, QDBusObjectPath(settingsPath),
|
||||
QDBusObjectPath(dbusDevicePath), QDBusObjectPath("/"));
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::disconnectFromId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
const QString identifier = QString::number(qHash(activeConnection.serviceName() + QLatin1Char(' ') +
|
||||
activeConnection.connection().path()));
|
||||
|
||||
if (id == identifier && accessPointConfigurations.contains(id)) {
|
||||
interface->deactivateConnection(acPath);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::requestUpdate()
|
||||
{
|
||||
QMetaObject::invokeMethod(this, "updateCompleted", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::interfacePropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
Q_UNUSED(path)
|
||||
|
||||
QMapIterator<QString, QVariant> i(properties);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
|
||||
if (i.key() == QLatin1String("ActiveConnections")) {
|
||||
// Active connections changed, update configurations.
|
||||
|
||||
QList<QDBusObjectPath> activeConnections =
|
||||
qdbus_cast<QList<QDBusObjectPath> >(i.value().value<QDBusArgument>());
|
||||
|
||||
QStringList identifiers = accessPointConfigurations.keys();
|
||||
foreach (const QString &id, identifiers)
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
|
||||
QStringList priorActiveConnections = this->activeConnections.keys();
|
||||
|
||||
foreach (const QDBusObjectPath &acPath, activeConnections) {
|
||||
priorActiveConnections.removeOne(acPath.path());
|
||||
QNetworkManagerConnectionActive *activeConnection =
|
||||
this->activeConnections.value(acPath.path());
|
||||
if (!activeConnection) {
|
||||
activeConnection = new QNetworkManagerConnectionActive(acPath.path());
|
||||
this->activeConnections.insert(acPath.path(), activeConnection);
|
||||
|
||||
activeConnection->setConnections();
|
||||
connect(activeConnection, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this, SLOT(activeConnectionPropertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
}
|
||||
|
||||
const QString id = QString::number(qHash(activeConnection->serviceName() + QLatin1Char(' ') +
|
||||
activeConnection->connection().path()));
|
||||
|
||||
identifiers.removeOne(id);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr) {
|
||||
ptr->mutex.lock();
|
||||
if (activeConnection->state() == 2 &&
|
||||
ptr->state != QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Active;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.lock();
|
||||
} else {
|
||||
ptr->mutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
while (!priorActiveConnections.isEmpty())
|
||||
delete this->activeConnections.take(priorActiveConnections.takeFirst());
|
||||
|
||||
while (!identifiers.isEmpty()) {
|
||||
// These configurations are not active
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(identifiers.takeFirst());
|
||||
|
||||
ptr->mutex.lock();
|
||||
if ((ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Discovered;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.lock();
|
||||
} else {
|
||||
ptr->mutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::activeConnectionPropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
Q_UNUSED(properties)
|
||||
|
||||
QNetworkManagerConnectionActive *activeConnection = activeConnections.value(path);
|
||||
|
||||
if (!activeConnection)
|
||||
return;
|
||||
|
||||
const QString id = QString::number(qHash(activeConnection->serviceName() + QLatin1Char(' ') +
|
||||
activeConnection->connection().path()));
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr) {
|
||||
ptr->mutex.lock();
|
||||
if (activeConnection->state() == 2 &&
|
||||
ptr->state != QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Active;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.lock();
|
||||
} else {
|
||||
ptr->mutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::devicePropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties)
|
||||
{
|
||||
Q_UNUSED(path);
|
||||
Q_UNUSED(properties);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::deviceAdded(const QDBusObjectPath &path)
|
||||
{
|
||||
QNetworkManagerInterfaceDevice device(path.path());
|
||||
if (device.deviceType() == DEVICE_TYPE_802_11_WIRELESS) {
|
||||
QNetworkManagerInterfaceDeviceWireless *wirelessDevice =
|
||||
new QNetworkManagerInterfaceDeviceWireless(device.connectionInterface()->path());
|
||||
|
||||
wirelessDevice->setConnections();
|
||||
connect(wirelessDevice, SIGNAL(accessPointAdded(QString,QDBusObjectPath)),
|
||||
this, SLOT(newAccessPoint(QString,QDBusObjectPath)));
|
||||
connect(wirelessDevice, SIGNAL(accessPointRemoved(QString,QDBusObjectPath)),
|
||||
this, SLOT(removeAccessPoint(QString,QDBusObjectPath)));
|
||||
connect(wirelessDevice, SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this, SLOT(devicePropertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
|
||||
foreach (const QDBusObjectPath &apPath, wirelessDevice->getAccessPoints())
|
||||
newAccessPoint(QString(), apPath);
|
||||
|
||||
mutex.lock();
|
||||
wirelessDevices.insert(path.path(), wirelessDevice);
|
||||
mutex.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::deviceRemoved(const QDBusObjectPath &path)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
delete wirelessDevices.take(path.path());
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::newConnection(const QDBusObjectPath &path,
|
||||
QNetworkManagerSettings *settings)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
if (!settings)
|
||||
settings = qobject_cast<QNetworkManagerSettings *>(sender());
|
||||
|
||||
if (!settings)
|
||||
return;
|
||||
|
||||
QNetworkManagerSettingsConnection *connection =
|
||||
new QNetworkManagerSettingsConnection(settings->connectionInterface()->service(),
|
||||
path.path());
|
||||
connections.append(connection);
|
||||
|
||||
connect(connection, SIGNAL(removed(QString)), this, SLOT(removeConnection(QString)));
|
||||
connect(connection, SIGNAL(updated(QNmSettingsMap)),
|
||||
this, SLOT(updateConnection(QNmSettingsMap)));
|
||||
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
|
||||
QNetworkConfigurationPrivate *cpPriv =
|
||||
parseConnection(service, settingsPath, connection->getSettings());
|
||||
|
||||
// Check if connection is active.
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
if (activeConnection.serviceName() == service &&
|
||||
activeConnection.connection().path() == settingsPath &&
|
||||
activeConnection.state() == 2) {
|
||||
cpPriv->state |= QNetworkConfiguration::Active;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr(cpPriv);
|
||||
accessPointConfigurations.insert(ptr->id, ptr);
|
||||
|
||||
locker.unlock();
|
||||
emit configurationAdded(ptr);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::removeConnection(const QString &path)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
Q_UNUSED(path)
|
||||
|
||||
QNetworkManagerSettingsConnection *connection =
|
||||
qobject_cast<QNetworkManagerSettingsConnection *>(sender());
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
connections.removeAll(connection);
|
||||
|
||||
const QString id = QString::number(qHash(connection->connectionInterface()->service() + QLatin1Char(' ') +
|
||||
connection->connectionInterface()->path()));
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.take(id);
|
||||
|
||||
connection->deleteLater();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::updateConnection(const QNmSettingsMap &settings)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkManagerSettingsConnection *connection =
|
||||
qobject_cast<QNetworkManagerSettingsConnection *>(sender());
|
||||
if (!connection)
|
||||
return;
|
||||
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
|
||||
QNetworkConfigurationPrivate *cpPriv = parseConnection(service, settingsPath, settings);
|
||||
|
||||
// Check if connection is active.
|
||||
foreach (const QDBusObjectPath &acPath, interface->activeConnections()) {
|
||||
QNetworkManagerConnectionActive activeConnection(acPath.path());
|
||||
|
||||
if (activeConnection.serviceName() == service &&
|
||||
activeConnection.connection().path() == settingsPath &&
|
||||
activeConnection.state() == NM_ACTIVE_CONNECTION_STATE_ACTIVATED) {
|
||||
cpPriv->state |= QNetworkConfiguration::Active;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(cpPriv->id);
|
||||
|
||||
ptr->mutex.lock();
|
||||
|
||||
ptr->isValid = cpPriv->isValid;
|
||||
ptr->name = cpPriv->name;
|
||||
ptr->id = cpPriv->id;
|
||||
ptr->state = cpPriv->state;
|
||||
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
delete cpPriv;
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::activationFinished(QDBusPendingCallWatcher *watcher)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QDBusPendingReply<QDBusObjectPath> reply = *watcher;
|
||||
if (!reply.isError()) {
|
||||
QDBusObjectPath result = reply.value();
|
||||
|
||||
QNetworkManagerConnectionActive activeConnection(result.path());
|
||||
|
||||
const QString id = QString::number(qHash(activeConnection.serviceName() + QLatin1Char(' ') +
|
||||
activeConnection.connection().path()));
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr) {
|
||||
ptr->mutex.lock();
|
||||
if (activeConnection.state() == 2 &&
|
||||
ptr->state != QNetworkConfiguration::Active) {
|
||||
ptr->state = QNetworkConfiguration::Active;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.lock();
|
||||
} else {
|
||||
ptr->mutex.unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::newAccessPoint(const QString &path, const QDBusObjectPath &objectPath)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
Q_UNUSED(path)
|
||||
|
||||
QNetworkManagerInterfaceAccessPoint *accessPoint =
|
||||
new QNetworkManagerInterfaceAccessPoint(objectPath.path());
|
||||
accessPoints.append(accessPoint);
|
||||
|
||||
accessPoint->setConnections();
|
||||
connect(accessPoint, SIGNAL(propertiesChanged(QMap<QString,QVariant>)),
|
||||
this, SLOT(updateAccessPoint(QMap<QString,QVariant>)));
|
||||
|
||||
// Check if configuration for this SSID already exists.
|
||||
for (int i = 0; i < accessPoints.count(); ++i) {
|
||||
if (accessPoint != accessPoints.at(i) &&
|
||||
accessPoint->ssid() == accessPoints.at(i)->ssid()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if configuration exists for connection.
|
||||
if (!accessPoint->ssid().isEmpty()) {
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
|
||||
if (accessPoint->ssid() == connection->getSsid()) {
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
const QString connectionId = QString::number(qHash(service + QLatin1Char(' ') + settingsPath));
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(connectionId);
|
||||
ptr->mutex.lock();
|
||||
ptr->state = QNetworkConfiguration::Discovered;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// New access point.
|
||||
QNetworkConfigurationPrivatePointer ptr(new QNetworkConfigurationPrivate);
|
||||
|
||||
ptr->name = accessPoint->ssid();
|
||||
ptr->isValid = true;
|
||||
ptr->id = QString::number(qHash(objectPath.path()));
|
||||
ptr->type = QNetworkConfiguration::InternetAccessPoint;
|
||||
if(accessPoint->flags() == NM_802_11_AP_FLAGS_PRIVACY) {
|
||||
ptr->purpose = QNetworkConfiguration::PrivatePurpose;
|
||||
} else {
|
||||
ptr->purpose = QNetworkConfiguration::PublicPurpose;
|
||||
}
|
||||
ptr->state = QNetworkConfiguration::Undefined;
|
||||
ptr->bearerType = QNetworkConfiguration::BearerWLAN;
|
||||
|
||||
accessPointConfigurations.insert(ptr->id, ptr);
|
||||
|
||||
locker.unlock();
|
||||
emit configurationAdded(ptr);
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::removeAccessPoint(const QString &path,
|
||||
const QDBusObjectPath &objectPath)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
Q_UNUSED(path)
|
||||
|
||||
for (int i = 0; i < accessPoints.count(); ++i) {
|
||||
QNetworkManagerInterfaceAccessPoint *accessPoint = accessPoints.at(i);
|
||||
|
||||
if (accessPoint->connectionInterface()->path() == objectPath.path()) {
|
||||
accessPoints.removeOne(accessPoint);
|
||||
|
||||
if (configuredAccessPoints.contains(accessPoint)) {
|
||||
// find connection and change state to Defined
|
||||
configuredAccessPoints.removeOne(accessPoint);
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
|
||||
if (accessPoint->ssid() == connection->getSsid()) {
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
const QString connectionId =
|
||||
QString::number(qHash(service + QLatin1Char(' ') + settingsPath));
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(connectionId);
|
||||
ptr->mutex.lock();
|
||||
ptr->state = QNetworkConfiguration::Defined;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
locker.lock();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.take(QString::number(qHash(objectPath.path())));
|
||||
|
||||
if (ptr) {
|
||||
locker.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
locker.lock();
|
||||
}
|
||||
}
|
||||
|
||||
delete accessPoint;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkManagerEngine::updateAccessPoint(const QMap<QString, QVariant> &map)
|
||||
{
|
||||
std::unique_lock<std::recursive_mutex> locker(mutex);
|
||||
|
||||
Q_UNUSED(map)
|
||||
|
||||
QNetworkManagerInterfaceAccessPoint *accessPoint =
|
||||
qobject_cast<QNetworkManagerInterfaceAccessPoint *>(sender());
|
||||
if (!accessPoint)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
|
||||
if (accessPoint->ssid() == connection->getSsid()) {
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
const QString connectionId = QString::number(qHash(service + QLatin1Char(' ') + settingsPath));
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.value(connectionId);
|
||||
ptr->mutex.lock();
|
||||
ptr->state = QNetworkConfiguration::Discovered;
|
||||
ptr->mutex.unlock();
|
||||
|
||||
locker.unlock();
|
||||
emit configurationChanged(ptr);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivate *QNetworkManagerEngine::parseConnection(const QString &service,
|
||||
const QString &settingsPath,
|
||||
const QNmSettingsMap &map)
|
||||
{
|
||||
QNetworkConfigurationPrivate *cpPriv = new QNetworkConfigurationPrivate;
|
||||
cpPriv->name = map.value(QLatin1String("connection")).value(QLatin1String("id")).toString();
|
||||
cpPriv->isValid = true;
|
||||
cpPriv->id = QString::number(qHash(service + QLatin1Char(' ') + settingsPath));
|
||||
cpPriv->type = QNetworkConfiguration::InternetAccessPoint;
|
||||
|
||||
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
|
||||
|
||||
cpPriv->state = QNetworkConfiguration::Defined;
|
||||
|
||||
const QString connectionType = map.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
|
||||
|
||||
if (connectionType == QLatin1String("802-3-ethernet")) {
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerEthernet;
|
||||
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
|
||||
|
||||
foreach (const QDBusObjectPath &devicePath, interface->getDevices()) {
|
||||
QNetworkManagerInterfaceDevice device(devicePath.path());
|
||||
if (device.deviceType() == DEVICE_TYPE_802_3_ETHERNET) {
|
||||
QNetworkManagerInterfaceDeviceWired wiredDevice(device.connectionInterface()->path());
|
||||
if (wiredDevice.carrier()) {
|
||||
cpPriv->state |= QNetworkConfiguration::Discovered;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else if (connectionType == QLatin1String("802-11-wireless")) {
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerWLAN;
|
||||
|
||||
const QString connectionSsid = map.value(QLatin1String("802-11-wireless")).value(QLatin1String("ssid")).toString();
|
||||
const QString connectionSecurity = map.value(QLatin1String("802-11-wireless")).value(QLatin1String("security")).toString();
|
||||
if(!connectionSecurity.isEmpty()) {
|
||||
cpPriv->purpose = QNetworkConfiguration::PrivatePurpose;
|
||||
} else {
|
||||
cpPriv->purpose = QNetworkConfiguration::PublicPurpose;
|
||||
}
|
||||
for (int i = 0; i < accessPoints.count(); ++i) {
|
||||
if (connectionSsid == accessPoints.at(i)->ssid()) {
|
||||
cpPriv->state |= QNetworkConfiguration::Discovered;
|
||||
if (!configuredAccessPoints.contains(accessPoints.at(i))) {
|
||||
configuredAccessPoints.append(accessPoints.at(i));
|
||||
|
||||
const QString accessPointId =
|
||||
QString::number(qHash(accessPoints.at(i)->connectionInterface()->path()));
|
||||
QNetworkConfigurationPrivatePointer ptr =
|
||||
accessPointConfigurations.take(accessPointId);
|
||||
|
||||
if (ptr) {
|
||||
mutex.unlock();
|
||||
emit configurationRemoved(ptr);
|
||||
mutex.lock();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (connectionType == QLatin1String("gsm")) {
|
||||
cpPriv->bearerType = QNetworkConfiguration::Bearer2G;
|
||||
} else if (connectionType == QLatin1String("cdma")) {
|
||||
cpPriv->bearerType = QNetworkConfiguration::BearerCDMA2000;
|
||||
}
|
||||
|
||||
return cpPriv;
|
||||
}
|
||||
|
||||
QNetworkManagerSettingsConnection *QNetworkManagerEngine::connectionFromId(const QString &id) const
|
||||
{
|
||||
for (int i = 0; i < connections.count(); ++i) {
|
||||
QNetworkManagerSettingsConnection *connection = connections.at(i);
|
||||
const QString service = connection->connectionInterface()->service();
|
||||
const QString settingsPath = connection->connectionInterface()->path();
|
||||
|
||||
const QString identifier = QString::number(qHash(service + QLatin1Char(' ') + settingsPath));
|
||||
|
||||
if (id == identifier)
|
||||
return connection;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
QNetworkSession::State QNetworkManagerEngine::sessionStateForId(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
|
||||
if (!ptr)
|
||||
return QNetworkSession::Invalid;
|
||||
|
||||
if (!ptr->isValid)
|
||||
return QNetworkSession::Invalid;
|
||||
|
||||
foreach (const QString &acPath, activeConnections.keys()) {
|
||||
QNetworkManagerConnectionActive *activeConnection = activeConnections.value(acPath);
|
||||
|
||||
const QString identifier = QString::number(qHash(activeConnection->serviceName() + QLatin1Char(' ') +
|
||||
activeConnection->connection().path()));
|
||||
|
||||
if (id == identifier) {
|
||||
switch (activeConnection->state()) {
|
||||
case 0:
|
||||
return QNetworkSession::Disconnected;
|
||||
case 1:
|
||||
return QNetworkSession::Connecting;
|
||||
case 2:
|
||||
return QNetworkSession::Connected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((ptr->state & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered)
|
||||
return QNetworkSession::Disconnected;
|
||||
else if ((ptr->state & QNetworkConfiguration::Defined) == QNetworkConfiguration::Defined)
|
||||
return QNetworkSession::NotAvailable;
|
||||
else if ((ptr->state & QNetworkConfiguration::Undefined) == QNetworkConfiguration::Undefined)
|
||||
return QNetworkSession::NotAvailable;
|
||||
|
||||
return QNetworkSession::Invalid;
|
||||
}
|
||||
|
||||
quint64 QNetworkManagerEngine::bytesWritten(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
|
||||
const QString networkInterface = getInterfaceFromId(id);
|
||||
if (!networkInterface.isEmpty()) {
|
||||
const QString devFile = QLatin1String("/sys/class/net/") +
|
||||
networkInterface +
|
||||
QLatin1String("/statistics/tx_bytes");
|
||||
|
||||
quint64 result = Q_UINT64_C(0);
|
||||
|
||||
QFile tx(devFile);
|
||||
if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&tx);
|
||||
in >> result;
|
||||
tx.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
quint64 QNetworkManagerEngine::bytesReceived(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkConfigurationPrivatePointer ptr = accessPointConfigurations.value(id);
|
||||
if (ptr && (ptr->state & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
|
||||
const QString networkInterface = getInterfaceFromId(id);
|
||||
if (!networkInterface.isEmpty()) {
|
||||
const QString devFile = QLatin1String("/sys/class/net/") +
|
||||
networkInterface +
|
||||
QLatin1String("/statistics/rx_bytes");
|
||||
|
||||
quint64 result = Q_UINT64_C(0);
|
||||
|
||||
QFile tx(devFile);
|
||||
if (tx.exists() && tx.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||
QTextStream in(&tx);
|
||||
in >> result;
|
||||
tx.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
return Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
quint64 QNetworkManagerEngine::startTime(const QString &id)
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> locker(mutex);
|
||||
|
||||
QNetworkManagerSettingsConnection *connection = connectionFromId(id);
|
||||
if (connection)
|
||||
return connection->getTimestamp();
|
||||
else
|
||||
return Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
QNetworkConfigurationManager::Capabilities QNetworkManagerEngine::capabilities() const
|
||||
{
|
||||
return QNetworkConfigurationManager::ForcedRoaming |
|
||||
QNetworkConfigurationManager::CanStartAndStopInterfaces;
|
||||
}
|
||||
|
||||
QNetworkSessionPrivate *QNetworkManagerEngine::createSessionBackend()
|
||||
{
|
||||
return new QNetworkSessionPrivateImpl;
|
||||
}
|
||||
|
||||
QNetworkConfigurationPrivatePointer QNetworkManagerEngine::defaultConfiguration()
|
||||
{
|
||||
return QNetworkConfigurationPrivatePointer();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#include "moc_qnetworkmanagerengine.h"
|
||||
#include "moc_qbearerengine_impl.h"
|
|
@ -1,122 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKMANAGERENGINE_P_H
|
||||
#define QNETWORKMANAGERENGINE_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists for the convenience
|
||||
// of the QLibrary class. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "../qbearerengine_impl.h"
|
||||
|
||||
#include "qnetworkmanagerservice.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkManagerEngine : public QBearerEngineImpl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QNetworkManagerEngine(QObject *parent = nullptr);
|
||||
~QNetworkManagerEngine();
|
||||
|
||||
bool networkManagerAvailable() const;
|
||||
|
||||
QString getInterfaceFromId(const QString &id);
|
||||
bool hasIdentifier(const QString &id) const;
|
||||
|
||||
void connectToId(const QString &id);
|
||||
void disconnectFromId(const QString &id);
|
||||
|
||||
Q_INVOKABLE void initialize();
|
||||
Q_INVOKABLE void requestUpdate();
|
||||
|
||||
QNetworkSession::State sessionStateForId(const QString &id);
|
||||
|
||||
quint64 bytesWritten(const QString &id);
|
||||
quint64 bytesReceived(const QString &id);
|
||||
quint64 startTime(const QString &id);
|
||||
|
||||
QNetworkConfigurationManager::Capabilities capabilities() const;
|
||||
|
||||
QNetworkSessionPrivate *createSessionBackend();
|
||||
|
||||
QNetworkConfigurationPrivatePointer defaultConfiguration();
|
||||
|
||||
private Q_SLOTS:
|
||||
void interfacePropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties);
|
||||
void activeConnectionPropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties);
|
||||
void devicePropertiesChanged(const QString &path,
|
||||
const QMap<QString, QVariant> &properties);
|
||||
|
||||
void deviceAdded(const QDBusObjectPath &path);
|
||||
void deviceRemoved(const QDBusObjectPath &path);
|
||||
|
||||
void newConnection(const QDBusObjectPath &path, QNetworkManagerSettings *settings = 0);
|
||||
void removeConnection(const QString &path);
|
||||
void updateConnection(const QNmSettingsMap &settings);
|
||||
void activationFinished(QDBusPendingCallWatcher *watcher);
|
||||
|
||||
void newAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
|
||||
void removeAccessPoint(const QString &path, const QDBusObjectPath &objectPath);
|
||||
void updateAccessPoint(const QMap<QString, QVariant> &map);
|
||||
|
||||
private:
|
||||
QNetworkConfigurationPrivate *parseConnection(const QString &service,
|
||||
const QString &settingsPath,
|
||||
const QNmSettingsMap &map);
|
||||
QNetworkManagerSettingsConnection *connectionFromId(const QString &id) const;
|
||||
|
||||
private:
|
||||
QNetworkManagerInterface *interface;
|
||||
QNetworkManagerSettings *systemSettings;
|
||||
QNetworkManagerSettings *userSettings;
|
||||
QHash<QString, QNetworkManagerInterfaceDeviceWireless *> wirelessDevices;
|
||||
QHash<QString, QNetworkManagerConnectionActive *> activeConnections;
|
||||
QList<QNetworkManagerSettingsConnection *> connections;
|
||||
QList<QNetworkManagerInterfaceAccessPoint *> accessPoints;
|
||||
QList<QNetworkManagerInterfaceAccessPoint *> configuredAccessPoints;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif
|
||||
|
|
@ -1,912 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include <QtDBus/qdbusmetatype.h>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusError>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QtDBus/QDBusPendingCall>
|
||||
|
||||
#include "qnetworkmanagerservice.h"
|
||||
#include "qnmdbushelper.h"
|
||||
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static QDBusConnection nmConnection = QDBusConnection::systemBus();
|
||||
|
||||
class QNetworkManagerInterfacePrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerInterface::QNetworkManagerInterface(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
d = new QNetworkManagerInterfacePrivate();
|
||||
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
|
||||
QLatin1String(NM_DBUS_PATH),
|
||||
QLatin1String(NM_DBUS_INTERFACE),
|
||||
nmConnection);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)),
|
||||
this, SIGNAL(stateChanged(QString,quint32)));
|
||||
|
||||
}
|
||||
|
||||
QNetworkManagerInterface::~QNetworkManagerInterface()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterface::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterface::setConnections()
|
||||
{
|
||||
if(!isValid() )
|
||||
return false;
|
||||
bool allOk = false;
|
||||
if (!nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
QLatin1String(NM_DBUS_PATH),
|
||||
QLatin1String(NM_DBUS_INTERFACE),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
|
||||
allOk = true;
|
||||
}
|
||||
if (!nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
QLatin1String(NM_DBUS_PATH),
|
||||
QLatin1String(NM_DBUS_INTERFACE),
|
||||
QLatin1String("DeviceAdded"),
|
||||
this,SIGNAL(deviceAdded(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
}
|
||||
if (!nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
QLatin1String(NM_DBUS_PATH),
|
||||
QLatin1String(NM_DBUS_INTERFACE),
|
||||
QLatin1String("DeviceRemoved"),
|
||||
this,SIGNAL(deviceRemoved(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerInterface::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
QList <QDBusObjectPath> QNetworkManagerInterface::getDevices() const
|
||||
{
|
||||
QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetDevices"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
void QNetworkManagerInterface::activateConnection( const QString &serviceName,
|
||||
QDBusObjectPath connectionPath,
|
||||
QDBusObjectPath devicePath,
|
||||
QDBusObjectPath specificObject)
|
||||
{
|
||||
QDBusPendingCall pendingCall = d->connectionInterface->asyncCall(QLatin1String("ActivateConnection"),
|
||||
QVariant(serviceName),
|
||||
QVariant::fromValue(connectionPath),
|
||||
QVariant::fromValue(devicePath),
|
||||
QVariant::fromValue(specificObject));
|
||||
|
||||
QDBusPendingCallWatcher *callWatcher = new QDBusPendingCallWatcher(pendingCall, this);
|
||||
connect(callWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
||||
this, SIGNAL(activationFinished(QDBusPendingCallWatcher*)));
|
||||
}
|
||||
|
||||
void QNetworkManagerInterface::deactivateConnection(QDBusObjectPath connectionPath) const
|
||||
{
|
||||
d->connectionInterface->call(QLatin1String("DeactivateConnection"), QVariant::fromValue(connectionPath));
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterface::wirelessEnabled() const
|
||||
{
|
||||
return d->connectionInterface->property("WirelessEnabled").toBool();
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterface::wirelessHardwareEnabled() const
|
||||
{
|
||||
return d->connectionInterface->property("WirelessHardwareEnabled").toBool();
|
||||
}
|
||||
|
||||
QList <QDBusObjectPath> QNetworkManagerInterface::activeConnections() const
|
||||
{
|
||||
QVariant prop = d->connectionInterface->property("ActiveConnections");
|
||||
return prop.value<QList<QDBusObjectPath> >();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterface::state()
|
||||
{
|
||||
return d->connectionInterface->property("State").toUInt();
|
||||
}
|
||||
|
||||
class QNetworkManagerInterfaceAccessPointPrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerInterfaceAccessPoint::QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent)
|
||||
: QObject(parent), nmDBusHelper(0)
|
||||
{
|
||||
d = new QNetworkManagerInterfaceAccessPointPrivate();
|
||||
d->path = dbusPathName;
|
||||
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
|
||||
nmConnection);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
|
||||
}
|
||||
|
||||
QNetworkManagerInterfaceAccessPoint::~QNetworkManagerInterfaceAccessPoint()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceAccessPoint::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceAccessPoint::setConnections()
|
||||
{
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
|
||||
if(nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_ACCESS_POINT),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = true;
|
||||
|
||||
}
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerInterfaceAccessPoint::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceAccessPoint::flags() const
|
||||
{
|
||||
return d->connectionInterface->property("Flags").toUInt();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceAccessPoint::wpaFlags() const
|
||||
{
|
||||
return d->connectionInterface->property("WpaFlags").toUInt();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceAccessPoint::rsnFlags() const
|
||||
{
|
||||
return d->connectionInterface->property("RsnFlags").toUInt();
|
||||
}
|
||||
|
||||
QString QNetworkManagerInterfaceAccessPoint::ssid() const
|
||||
{
|
||||
return d->connectionInterface->property("Ssid").toString();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceAccessPoint::frequency() const
|
||||
{
|
||||
return d->connectionInterface->property("Frequency").toUInt();
|
||||
}
|
||||
|
||||
QString QNetworkManagerInterfaceAccessPoint::hwAddress() const
|
||||
{
|
||||
return d->connectionInterface->property("HwAddress").toString();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceAccessPoint::mode() const
|
||||
{
|
||||
return d->connectionInterface->property("Mode").toUInt();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceAccessPoint::maxBitrate() const
|
||||
{
|
||||
return d->connectionInterface->property("MaxBitrate").toUInt();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceAccessPoint::strength() const
|
||||
{
|
||||
return d->connectionInterface->property("Strength").toUInt();
|
||||
}
|
||||
|
||||
class QNetworkManagerInterfaceDevicePrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerInterfaceDevice::QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent)
|
||||
: QObject(parent), nmDBusHelper(0)
|
||||
{
|
||||
d = new QNetworkManagerInterfaceDevicePrivate();
|
||||
d->path = deviceObjectPath;
|
||||
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE),
|
||||
nmConnection);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
}
|
||||
|
||||
QNetworkManagerInterfaceDevice::~QNetworkManagerInterfaceDevice()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceDevice::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceDevice::setConnections()
|
||||
{
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper,SIGNAL(pathForStateChanged(QString,quint32)),
|
||||
this, SIGNAL(stateChanged(QString,quint32)));
|
||||
if(nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE),
|
||||
QLatin1String("StateChanged"),
|
||||
nmDBusHelper,SLOT(deviceStateChanged(quint32)))) {
|
||||
allOk = true;
|
||||
}
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerInterfaceDevice::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
QString QNetworkManagerInterfaceDevice::udi() const
|
||||
{
|
||||
return d->connectionInterface->property("Udi").toString();
|
||||
}
|
||||
|
||||
QString QNetworkManagerInterfaceDevice::networkInterface() const
|
||||
{
|
||||
return d->connectionInterface->property("Interface").toString();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceDevice::ip4Address() const
|
||||
{
|
||||
return d->connectionInterface->property("Ip4Address").toUInt();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceDevice::state() const
|
||||
{
|
||||
return d->connectionInterface->property("State").toUInt();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceDevice::deviceType() const
|
||||
{
|
||||
return d->connectionInterface->property("DeviceType").toUInt();
|
||||
}
|
||||
|
||||
QDBusObjectPath QNetworkManagerInterfaceDevice::ip4config() const
|
||||
{
|
||||
QVariant prop = d->connectionInterface->property("Ip4Config");
|
||||
return prop.value<QDBusObjectPath>();
|
||||
}
|
||||
|
||||
class QNetworkManagerInterfaceDeviceWiredPrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerInterfaceDeviceWired::QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath, QObject *parent)
|
||||
: QObject(parent), nmDBusHelper(0)
|
||||
{
|
||||
d = new QNetworkManagerInterfaceDeviceWiredPrivate();
|
||||
d->path = ifaceDevicePath;
|
||||
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
|
||||
nmConnection, parent);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
}
|
||||
|
||||
QNetworkManagerInterfaceDeviceWired::~QNetworkManagerInterfaceDeviceWired()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceDeviceWired::isValid()
|
||||
{
|
||||
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceDeviceWired::setConnections()
|
||||
{
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
if(nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRED),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = true;
|
||||
}
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerInterfaceDeviceWired::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
QString QNetworkManagerInterfaceDeviceWired::hwAddress() const
|
||||
{
|
||||
return d->connectionInterface->property("HwAddress").toString();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceDeviceWired::speed() const
|
||||
{
|
||||
return d->connectionInterface->property("Speed").toUInt();
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceDeviceWired::carrier() const
|
||||
{
|
||||
return d->connectionInterface->property("Carrier").toBool();
|
||||
}
|
||||
|
||||
class QNetworkManagerInterfaceDeviceWirelessPrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerInterfaceDeviceWireless::QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath, QObject *parent)
|
||||
: QObject(parent), nmDBusHelper(0)
|
||||
{
|
||||
d = new QNetworkManagerInterfaceDeviceWirelessPrivate();
|
||||
d->path = ifaceDevicePath;
|
||||
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
nmConnection, parent);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
}
|
||||
|
||||
QNetworkManagerInterfaceDeviceWireless::~QNetworkManagerInterfaceDeviceWireless()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceDeviceWireless::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerInterfaceDeviceWireless::setConnections()
|
||||
{
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
|
||||
connect(nmDBusHelper, SIGNAL(pathForAccessPointAdded(QString,QDBusObjectPath)),
|
||||
this,SIGNAL(accessPointAdded(QString,QDBusObjectPath)));
|
||||
|
||||
connect(nmDBusHelper, SIGNAL(pathForAccessPointRemoved(QString,QDBusObjectPath)),
|
||||
this,SIGNAL(accessPointRemoved(QString,QDBusObjectPath)));
|
||||
|
||||
if(!nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
QLatin1String("AccessPointAdded"),
|
||||
nmDBusHelper, SLOT(slotAccessPointAdded(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
}
|
||||
|
||||
|
||||
if(!nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
QLatin1String("AccessPointRemoved"),
|
||||
nmDBusHelper, SLOT(slotAccessPointRemoved(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
}
|
||||
|
||||
|
||||
if(!nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_DEVICE_WIRELESS),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
|
||||
allOk = true;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerInterfaceDeviceWireless::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
QList <QDBusObjectPath> QNetworkManagerInterfaceDeviceWireless::getAccessPoints()
|
||||
{
|
||||
QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("GetAccessPoints"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QString QNetworkManagerInterfaceDeviceWireless::hwAddress() const
|
||||
{
|
||||
return d->connectionInterface->property("HwAddress").toString();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceDeviceWireless::mode() const
|
||||
{
|
||||
return d->connectionInterface->property("Mode").toUInt();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceDeviceWireless::bitrate() const
|
||||
{
|
||||
return d->connectionInterface->property("Bitrate").toUInt();
|
||||
}
|
||||
|
||||
QDBusObjectPath QNetworkManagerInterfaceDeviceWireless::activeAccessPoint() const
|
||||
{
|
||||
return d->connectionInterface->property("ActiveAccessPoint").value<QDBusObjectPath>();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerInterfaceDeviceWireless::wirelessCapabilities() const
|
||||
{
|
||||
return d->connectionInterface->property("WirelelessCapabilities").toUInt();
|
||||
}
|
||||
|
||||
class QNetworkManagerSettingsPrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerSettings::QNetworkManagerSettings(const QString &settingsService, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
d = new QNetworkManagerSettingsPrivate();
|
||||
d->path = settingsService;
|
||||
d->connectionInterface = new QDBusInterface(settingsService,
|
||||
QLatin1String(NM_DBUS_PATH_SETTINGS),
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS),
|
||||
nmConnection);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
}
|
||||
|
||||
QNetworkManagerSettings::~QNetworkManagerSettings()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerSettings::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerSettings::setConnections()
|
||||
{
|
||||
bool allOk = false;
|
||||
|
||||
if (!nmConnection.connect(d->path, QLatin1String(NM_DBUS_PATH_SETTINGS),
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS), QLatin1String("NewConnection"),
|
||||
this, SIGNAL(newConnection(QDBusObjectPath)))) {
|
||||
allOk = true;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QList <QDBusObjectPath> QNetworkManagerSettings::listConnections()
|
||||
{
|
||||
QDBusReply<QList<QDBusObjectPath> > reply = d->connectionInterface->call(QLatin1String("ListConnections"));
|
||||
return reply.value();
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerSettings::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
|
||||
class QNetworkManagerSettingsConnectionPrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
QString service;
|
||||
QNmSettingsMap settingsMap;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerSettingsConnection::QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent)
|
||||
: QObject(parent), nmDBusHelper(0)
|
||||
{
|
||||
qDBusRegisterMetaType<QNmSettingsMap>();
|
||||
d = new QNetworkManagerSettingsConnectionPrivate();
|
||||
d->path = connectionObjectPath;
|
||||
d->service = settingsService;
|
||||
d->connectionInterface = new QDBusInterface(settingsService,
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION),
|
||||
nmConnection, parent);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
|
||||
d->settingsMap = rep.value();
|
||||
}
|
||||
|
||||
QNetworkManagerSettingsConnection::~QNetworkManagerSettingsConnection()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerSettingsConnection::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerSettingsConnection::setConnections()
|
||||
{
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
if(!nmConnection.connect(d->service, d->path,
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
|
||||
this, SIGNAL(updated(QNmSettingsMap)))) {
|
||||
allOk = true;
|
||||
} else {
|
||||
QDBusError error = nmConnection.lastError();
|
||||
}
|
||||
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(QString)),
|
||||
this,SIGNAL(removed(QString)));
|
||||
|
||||
if (!nmConnection.connect(d->service, d->path,
|
||||
QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"),
|
||||
nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
|
||||
allOk = true;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerSettingsConnection::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
QNmSettingsMap QNetworkManagerSettingsConnection::getSettings()
|
||||
{
|
||||
QDBusReply< QNmSettingsMap > rep = d->connectionInterface->call(QLatin1String("GetSettings"));
|
||||
d->settingsMap = rep.value();
|
||||
return d->settingsMap;
|
||||
}
|
||||
|
||||
NMDeviceType QNetworkManagerSettingsConnection::getType()
|
||||
{
|
||||
const QString devType =
|
||||
d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("type")).toString();
|
||||
|
||||
if (devType == QLatin1String("802-3-ethernet"))
|
||||
return DEVICE_TYPE_802_3_ETHERNET;
|
||||
else if (devType == QLatin1String("802-11-wireless"))
|
||||
return DEVICE_TYPE_802_11_WIRELESS;
|
||||
else
|
||||
return DEVICE_TYPE_UNKNOWN;
|
||||
}
|
||||
|
||||
bool QNetworkManagerSettingsConnection::isAutoConnect()
|
||||
{
|
||||
const QVariant autoConnect =
|
||||
d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("autoconnect"));
|
||||
|
||||
// NetworkManager default is to auto connect
|
||||
if (!autoConnect.isValid())
|
||||
return true;
|
||||
|
||||
return autoConnect.toBool();
|
||||
}
|
||||
|
||||
quint64 QNetworkManagerSettingsConnection::getTimestamp()
|
||||
{
|
||||
return d->settingsMap.value(QLatin1String("connection"))
|
||||
.value(QLatin1String("timestamp")).toUInt();
|
||||
}
|
||||
|
||||
QString QNetworkManagerSettingsConnection::getId()
|
||||
{
|
||||
return d->settingsMap.value(QLatin1String("connection")).value(QLatin1String("id")).toString();
|
||||
}
|
||||
|
||||
QString QNetworkManagerSettingsConnection::getUuid()
|
||||
{
|
||||
const QString id = d->settingsMap.value(QLatin1String("connection"))
|
||||
.value(QLatin1String("uuid")).toString();
|
||||
|
||||
// is no uuid, return the connection path
|
||||
return id.isEmpty() ? d->connectionInterface->path() : id;
|
||||
}
|
||||
|
||||
QString QNetworkManagerSettingsConnection::getSsid()
|
||||
{
|
||||
return d->settingsMap.value(QLatin1String("802-11-wireless"))
|
||||
.value(QLatin1String("ssid")).toString();
|
||||
}
|
||||
|
||||
QString QNetworkManagerSettingsConnection::getMacAddress()
|
||||
{
|
||||
NMDeviceType type = getType();
|
||||
|
||||
if (type == DEVICE_TYPE_802_3_ETHERNET) {
|
||||
return d->settingsMap.value(QLatin1String("802-3-ethernet"))
|
||||
.value(QLatin1String("mac-address")).toString();
|
||||
} else if (type == DEVICE_TYPE_802_11_WIRELESS) {
|
||||
return d->settingsMap.value(QLatin1String("802-11-wireless"))
|
||||
.value(QLatin1String("mac-address")).toString();
|
||||
} else {
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
QStringList QNetworkManagerSettingsConnection::getSeenBssids()
|
||||
{
|
||||
if (getType() == DEVICE_TYPE_802_11_WIRELESS) {
|
||||
return d->settingsMap.value(QLatin1String("802-11-wireless"))
|
||||
.value(QLatin1String("seen-bssids")).toStringList();
|
||||
} else {
|
||||
return QStringList();
|
||||
}
|
||||
}
|
||||
|
||||
class QNetworkManagerConnectionActivePrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerConnectionActive::QNetworkManagerConnectionActive( const QString &activeConnectionObjectPath, QObject *parent)
|
||||
: QObject(parent), nmDBusHelper(0)
|
||||
{
|
||||
d = new QNetworkManagerConnectionActivePrivate();
|
||||
d->path = activeConnectionObjectPath;
|
||||
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
|
||||
nmConnection, parent);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
}
|
||||
|
||||
QNetworkManagerConnectionActive::~QNetworkManagerConnectionActive()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerConnectionActive::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
bool QNetworkManagerConnectionActive::setConnections()
|
||||
{
|
||||
if(!isValid() )
|
||||
return false;
|
||||
|
||||
bool allOk = false;
|
||||
delete nmDBusHelper;
|
||||
nmDBusHelper = new QNmDBusHelper(this);
|
||||
connect(nmDBusHelper, SIGNAL(pathForPropertiesChanged(QString,QMap<QString,QVariant>)),
|
||||
this,SIGNAL(propertiesChanged(QString,QMap<QString,QVariant>)));
|
||||
if(nmConnection.connect(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_ACTIVE_CONNECTION),
|
||||
QLatin1String("PropertiesChanged"),
|
||||
nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>))) ) {
|
||||
allOk = true;
|
||||
}
|
||||
|
||||
return allOk;
|
||||
}
|
||||
|
||||
QDBusInterface *QNetworkManagerConnectionActive::connectionInterface() const
|
||||
{
|
||||
return d->connectionInterface;
|
||||
}
|
||||
|
||||
QString QNetworkManagerConnectionActive::serviceName() const
|
||||
{
|
||||
return d->connectionInterface->property("ServiceName").toString();
|
||||
}
|
||||
|
||||
QDBusObjectPath QNetworkManagerConnectionActive::connection() const
|
||||
{
|
||||
QVariant prop = d->connectionInterface->property("Connection");
|
||||
return prop.value<QDBusObjectPath>();
|
||||
}
|
||||
|
||||
QDBusObjectPath QNetworkManagerConnectionActive::specificObject() const
|
||||
{
|
||||
QVariant prop = d->connectionInterface->property("SpecificObject");
|
||||
return prop.value<QDBusObjectPath>();
|
||||
}
|
||||
|
||||
QList<QDBusObjectPath> QNetworkManagerConnectionActive::devices() const
|
||||
{
|
||||
QVariant prop = d->connectionInterface->property("Devices");
|
||||
return prop.value<QList<QDBusObjectPath> >();
|
||||
}
|
||||
|
||||
quint32 QNetworkManagerConnectionActive::state() const
|
||||
{
|
||||
return d->connectionInterface->property("State").toUInt();
|
||||
}
|
||||
|
||||
bool QNetworkManagerConnectionActive::defaultRoute() const
|
||||
{
|
||||
return d->connectionInterface->property("Default").toBool();
|
||||
}
|
||||
|
||||
class QNetworkManagerIp4ConfigPrivate
|
||||
{
|
||||
public:
|
||||
QDBusInterface *connectionInterface;
|
||||
QString path;
|
||||
bool valid;
|
||||
};
|
||||
|
||||
QNetworkManagerIp4Config::QNetworkManagerIp4Config( const QString &deviceObjectPath, QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
d = new QNetworkManagerIp4ConfigPrivate();
|
||||
d->path = deviceObjectPath;
|
||||
d->connectionInterface = new QDBusInterface(QLatin1String(NM_DBUS_SERVICE),
|
||||
d->path,
|
||||
QLatin1String(NM_DBUS_INTERFACE_IP4_CONFIG),
|
||||
nmConnection, parent);
|
||||
if (!d->connectionInterface->isValid()) {
|
||||
d->valid = false;
|
||||
return;
|
||||
}
|
||||
d->valid = true;
|
||||
}
|
||||
|
||||
QNetworkManagerIp4Config::~QNetworkManagerIp4Config()
|
||||
{
|
||||
delete d->connectionInterface;
|
||||
delete d;
|
||||
}
|
||||
|
||||
bool QNetworkManagerIp4Config::isValid()
|
||||
{
|
||||
return d->valid;
|
||||
}
|
||||
|
||||
QStringList QNetworkManagerIp4Config::domains() const
|
||||
{
|
||||
return d->connectionInterface->property("Domains").toStringList();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#include "moc_qnetworkmanagerservice.h"
|
|
@ -1,427 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKMANAGERSERVICE_H
|
||||
#define QNETWORKMANAGERSERVICE_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusError>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/QDBusMessage>
|
||||
#include <QtDBus/QDBusReply>
|
||||
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QtDBus/QDBusContext>
|
||||
#include <QMap>
|
||||
#include "qnmdbushelper.h"
|
||||
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
#ifndef NETWORK_MANAGER_H
|
||||
typedef enum NMDeviceType
|
||||
{
|
||||
DEVICE_TYPE_UNKNOWN = 0,
|
||||
DEVICE_TYPE_802_3_ETHERNET,
|
||||
DEVICE_TYPE_802_11_WIRELESS,
|
||||
DEVICE_TYPE_GSM,
|
||||
DEVICE_TYPE_CDMA
|
||||
} NMDeviceType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NM_DEVICE_STATE_UNKNOWN = 0,
|
||||
NM_DEVICE_STATE_UNMANAGED,
|
||||
NM_DEVICE_STATE_UNAVAILABLE,
|
||||
NM_DEVICE_STATE_DISCONNECTED,
|
||||
NM_DEVICE_STATE_PREPARE,
|
||||
NM_DEVICE_STATE_CONFIG,
|
||||
NM_DEVICE_STATE_NEED_AUTH,
|
||||
NM_DEVICE_STATE_IP_CONFIG,
|
||||
NM_DEVICE_STATE_ACTIVATED,
|
||||
NM_DEVICE_STATE_FAILED
|
||||
} NMDeviceState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
NM_ACTIVE_CONNECTION_STATE_UNKNOWN = 0,
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATING,
|
||||
NM_ACTIVE_CONNECTION_STATE_ACTIVATED
|
||||
} NMActiveConnectionState;
|
||||
|
||||
#define NM_DBUS_SERVICE "org.freedesktop.NetworkManager"
|
||||
|
||||
#define NM_DBUS_PATH "/org/freedesktop/NetworkManager"
|
||||
#define NM_DBUS_INTERFACE "org.freedesktop.NetworkManager"
|
||||
#define NM_DBUS_INTERFACE_DEVICE NM_DBUS_INTERFACE ".Device"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_WIRED NM_DBUS_INTERFACE_DEVICE ".Wired"
|
||||
#define NM_DBUS_INTERFACE_DEVICE_WIRELESS NM_DBUS_INTERFACE_DEVICE ".Wireless"
|
||||
#define NM_DBUS_PATH_ACCESS_POINT NM_DBUS_PATH "/AccessPoint"
|
||||
#define NM_DBUS_INTERFACE_ACCESS_POINT NM_DBUS_INTERFACE ".AccessPoint"
|
||||
|
||||
#define NM_DBUS_PATH_SETTINGS "/org/freedesktop/NetworkManagerSettings"
|
||||
|
||||
#define NM_DBUS_IFACE_SETTINGS_CONNECTION "org.freedesktop.NetworkManagerSettings.Connection"
|
||||
#define NM_DBUS_IFACE_SETTINGS "org.freedesktop.NetworkManagerSettings"
|
||||
#define NM_DBUS_INTERFACE_ACTIVE_CONNECTION NM_DBUS_INTERFACE ".Connection.Active"
|
||||
#define NM_DBUS_INTERFACE_IP4_CONFIG NM_DBUS_INTERFACE ".IP4Config"
|
||||
|
||||
#define NM_DBUS_SERVICE_USER_SETTINGS "org.freedesktop.NetworkManagerUserSettings"
|
||||
#define NM_DBUS_SERVICE_SYSTEM_SETTINGS "org.freedesktop.NetworkManagerSystemSettings"
|
||||
|
||||
#define NM_802_11_AP_FLAGS_NONE 0x00000000
|
||||
#define NM_802_11_AP_FLAGS_PRIVACY 0x00000001
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
typedef QMap< QString, QMap<QString,QVariant> > QNmSettingsMap;
|
||||
typedef QList<quint32> ServerThing;
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(QNmSettingsMap))
|
||||
Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE(ServerThing))
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNetworkManagerInterfacePrivate;
|
||||
class QNetworkManagerInterface : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QNetworkManagerInterface(QObject *parent = nullptr);
|
||||
~QNetworkManagerInterface();
|
||||
|
||||
QList <QDBusObjectPath> getDevices() const;
|
||||
void activateConnection(const QString &serviceName, QDBusObjectPath connection, QDBusObjectPath device, QDBusObjectPath specificObject);
|
||||
void deactivateConnection(QDBusObjectPath connectionPath) const;
|
||||
|
||||
QDBusObjectPath path() const;
|
||||
QDBusInterface *connectionInterface() const;
|
||||
|
||||
bool wirelessEnabled() const;
|
||||
bool wirelessHardwareEnabled() const;
|
||||
QList <QDBusObjectPath> activeConnections() const;
|
||||
quint32 state();
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
Q_SIGNALS:
|
||||
void deviceAdded(QDBusObjectPath);
|
||||
void deviceRemoved(QDBusObjectPath);
|
||||
void propertiesChanged( const QString &, QMap<QString,QVariant>);
|
||||
void stateChanged(const QString&, quint32);
|
||||
void activationFinished(QDBusPendingCallWatcher*);
|
||||
|
||||
private Q_SLOTS:
|
||||
private:
|
||||
QNetworkManagerInterfacePrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
};
|
||||
|
||||
class QNetworkManagerInterfaceAccessPointPrivate;
|
||||
class QNetworkManagerInterfaceAccessPoint : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum DeviceState {
|
||||
Unknown = 0,
|
||||
Unmanaged,
|
||||
Unavailable,
|
||||
Disconnected,
|
||||
Prepare,
|
||||
Config,
|
||||
NeedAuthentication,
|
||||
IpConfig,
|
||||
Activated,
|
||||
Failed
|
||||
};
|
||||
|
||||
enum ApFlag {
|
||||
ApNone = 0x0,
|
||||
Privacy = 0x1
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(ApFlags, ApFlag)
|
||||
|
||||
enum ApSecurityFlag {
|
||||
ApSecurityNone = 0x0,
|
||||
PairWep40 = 0x1,
|
||||
PairWep104 = 0x2,
|
||||
PairTkip = 0x4,
|
||||
PairCcmp = 0x8,
|
||||
GroupWep40 = 0x10,
|
||||
GroupWep104 = 0x20,
|
||||
GroupTkip = 0x40,
|
||||
GroupCcmp = 0x80,
|
||||
KeyPsk = 0x100,
|
||||
Key8021x = 0x200
|
||||
};
|
||||
|
||||
Q_DECLARE_FLAGS(ApSecurityFlags, ApSecurityFlag)
|
||||
|
||||
explicit QNetworkManagerInterfaceAccessPoint(const QString &dbusPathName, QObject *parent = nullptr);
|
||||
~QNetworkManagerInterfaceAccessPoint();
|
||||
|
||||
QDBusInterface *connectionInterface() const;
|
||||
|
||||
quint32 flags() const;
|
||||
quint32 wpaFlags() const;
|
||||
quint32 rsnFlags() const;
|
||||
QString ssid() const;
|
||||
quint32 frequency() const;
|
||||
QString hwAddress() const;
|
||||
quint32 mode() const;
|
||||
quint32 maxBitrate() const;
|
||||
quint32 strength() const;
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertiesChanged(QMap <QString,QVariant>);
|
||||
void propertiesChanged( const QString &, QMap<QString,QVariant>);
|
||||
private:
|
||||
QNetworkManagerInterfaceAccessPointPrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
|
||||
};
|
||||
|
||||
class QNetworkManagerInterfaceDevicePrivate;
|
||||
class QNetworkManagerInterfaceDevice : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit QNetworkManagerInterfaceDevice(const QString &deviceObjectPath, QObject *parent = nullptr);
|
||||
~QNetworkManagerInterfaceDevice();
|
||||
|
||||
QString udi() const;
|
||||
QString networkInterface() const;
|
||||
QDBusInterface *connectionInterface() const;
|
||||
quint32 ip4Address() const;
|
||||
quint32 state() const;
|
||||
quint32 deviceType() const;
|
||||
|
||||
QDBusObjectPath ip4config() const;
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
Q_SIGNALS:
|
||||
void stateChanged(const QString &, quint32);
|
||||
|
||||
private:
|
||||
QNetworkManagerInterfaceDevicePrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
};
|
||||
|
||||
class QNetworkManagerInterfaceDeviceWiredPrivate;
|
||||
class QNetworkManagerInterfaceDeviceWired : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit QNetworkManagerInterfaceDeviceWired(const QString &ifaceDevicePath,
|
||||
QObject *parent = nullptr);
|
||||
~QNetworkManagerInterfaceDeviceWired();
|
||||
|
||||
QDBusInterface *connectionInterface() const;
|
||||
QString hwAddress() const;
|
||||
quint32 speed() const;
|
||||
bool carrier() const;
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertiesChanged( const QString &, QMap<QString,QVariant>);
|
||||
private:
|
||||
QNetworkManagerInterfaceDeviceWiredPrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
};
|
||||
|
||||
class QNetworkManagerInterfaceDeviceWirelessPrivate;
|
||||
class QNetworkManagerInterfaceDeviceWireless : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum DeviceCapability {
|
||||
None = 0x0,
|
||||
Wep40 = 0x1,
|
||||
Wep104 = 0x2,
|
||||
Tkip = 0x4,
|
||||
Ccmp = 0x8,
|
||||
Wpa = 0x10,
|
||||
Rsn = 0x20
|
||||
};
|
||||
|
||||
explicit QNetworkManagerInterfaceDeviceWireless(const QString &ifaceDevicePath,
|
||||
QObject *parent = nullptr);
|
||||
~QNetworkManagerInterfaceDeviceWireless();
|
||||
|
||||
QDBusObjectPath path() const;
|
||||
QList <QDBusObjectPath> getAccessPoints();
|
||||
QDBusInterface *connectionInterface() const;
|
||||
|
||||
QString hwAddress() const;
|
||||
quint32 mode() const;
|
||||
quint32 bitrate() const;
|
||||
QDBusObjectPath activeAccessPoint() const;
|
||||
quint32 wirelessCapabilities() const;
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertiesChanged( const QString &, QMap<QString,QVariant>);
|
||||
void accessPointAdded(const QString &,QDBusObjectPath);
|
||||
void accessPointRemoved(const QString &,QDBusObjectPath);
|
||||
private:
|
||||
QNetworkManagerInterfaceDeviceWirelessPrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
};
|
||||
|
||||
class QNetworkManagerSettingsPrivate;
|
||||
class QNetworkManagerSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit QNetworkManagerSettings(const QString &settingsService, QObject *parent = nullptr);
|
||||
~QNetworkManagerSettings();
|
||||
|
||||
QDBusInterface *connectionInterface() const;
|
||||
QList <QDBusObjectPath> listConnections();
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
Q_SIGNALS:
|
||||
void newConnection(QDBusObjectPath);
|
||||
private:
|
||||
QNetworkManagerSettingsPrivate *d;
|
||||
};
|
||||
|
||||
class QNetworkManagerSettingsConnectionPrivate;
|
||||
class QNetworkManagerSettingsConnection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
QNetworkManagerSettingsConnection(const QString &settingsService, const QString &connectionObjectPath, QObject *parent = nullptr);
|
||||
~QNetworkManagerSettingsConnection();
|
||||
|
||||
QDBusInterface *connectionInterface() const;
|
||||
QNmSettingsMap getSettings();
|
||||
bool setConnections();
|
||||
NMDeviceType getType();
|
||||
bool isAutoConnect();
|
||||
quint64 getTimestamp();
|
||||
QString getId();
|
||||
QString getUuid();
|
||||
QString getSsid();
|
||||
QString getMacAddress();
|
||||
QStringList getSeenBssids();
|
||||
bool isValid();
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
void updated(const QNmSettingsMap &settings);
|
||||
void removed(const QString &path);
|
||||
|
||||
private:
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
QNetworkManagerSettingsConnectionPrivate *d;
|
||||
};
|
||||
|
||||
class QNetworkManagerConnectionActivePrivate;
|
||||
class QNetworkManagerConnectionActive : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
enum ActiveConnectionState {
|
||||
Unknown = 0,
|
||||
Activating = 1,
|
||||
Activated = 2
|
||||
};
|
||||
|
||||
explicit QNetworkManagerConnectionActive(const QString &dbusPathName, QObject *parent = nullptr);
|
||||
~ QNetworkManagerConnectionActive();
|
||||
|
||||
QDBusInterface *connectionInterface() const;
|
||||
QString serviceName() const;
|
||||
QDBusObjectPath connection() const;
|
||||
QDBusObjectPath specificObject() const;
|
||||
QList<QDBusObjectPath> devices() const;
|
||||
quint32 state() const;
|
||||
bool defaultRoute() const;
|
||||
bool setConnections();
|
||||
bool isValid();
|
||||
|
||||
|
||||
Q_SIGNALS:
|
||||
void propertiesChanged(QList<QDBusObjectPath>);
|
||||
void propertiesChanged( const QString &, QMap<QString,QVariant>);
|
||||
private:
|
||||
QNetworkManagerConnectionActivePrivate *d;
|
||||
QNmDBusHelper *nmDBusHelper;
|
||||
};
|
||||
|
||||
class QNetworkManagerIp4ConfigPrivate;
|
||||
class QNetworkManagerIp4Config : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit QNetworkManagerIp4Config(const QString &dbusPathName, QObject *parent = nullptr);
|
||||
~QNetworkManagerIp4Config();
|
||||
|
||||
QStringList domains() const;
|
||||
bool isValid();
|
||||
|
||||
private:
|
||||
QNetworkManagerIp4ConfigPrivate *d;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#endif //QNETWORKMANAGERSERVICE_H
|
|
@ -1,111 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
// this class is for helping qdbus get stuff
|
||||
|
||||
#include "qnmdbushelper.h"
|
||||
|
||||
#include "qnetworkmanagerservice.h"
|
||||
|
||||
#include <QDBusError>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusReply>
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QNmDBusHelper::QNmDBusHelper(QObject * parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QNmDBusHelper::~QNmDBusHelper()
|
||||
{
|
||||
}
|
||||
|
||||
void QNmDBusHelper::deviceStateChanged(quint32 state)
|
||||
{
|
||||
QDBusMessage msg = this->message();
|
||||
if(state == NM_DEVICE_STATE_ACTIVATED
|
||||
|| state == NM_DEVICE_STATE_DISCONNECTED
|
||||
|| state == NM_DEVICE_STATE_UNAVAILABLE
|
||||
|| state == NM_DEVICE_STATE_FAILED) {
|
||||
emit pathForStateChanged(msg.path(), state);
|
||||
}
|
||||
}
|
||||
|
||||
void QNmDBusHelper::slotAccessPointAdded(QDBusObjectPath path)
|
||||
{
|
||||
if(path.path().length() > 2) {
|
||||
QDBusMessage msg = this->message();
|
||||
emit pathForAccessPointAdded(msg.path(), path);
|
||||
}
|
||||
}
|
||||
|
||||
void QNmDBusHelper::slotAccessPointRemoved(QDBusObjectPath path)
|
||||
{
|
||||
if(path.path().length() > 2) {
|
||||
QDBusMessage msg = this->message();
|
||||
emit pathForAccessPointRemoved(msg.path(), path);
|
||||
}
|
||||
}
|
||||
|
||||
void QNmDBusHelper::slotPropertiesChanged(QMap<QString,QVariant> map)
|
||||
{
|
||||
QDBusMessage msg = this->message();
|
||||
QMapIterator<QString, QVariant> i(map);
|
||||
while (i.hasNext()) {
|
||||
i.next();
|
||||
if( i.key() == QLatin1String("State")) { //state only applies to device interfaces
|
||||
quint32 state = i.value().toUInt();
|
||||
if( state == NM_DEVICE_STATE_ACTIVATED
|
||||
|| state == NM_DEVICE_STATE_DISCONNECTED
|
||||
|| state == NM_DEVICE_STATE_UNAVAILABLE
|
||||
|| state == NM_DEVICE_STATE_FAILED) {
|
||||
emit pathForPropertiesChanged( msg.path(), map);
|
||||
}
|
||||
} else if( i.key() == QLatin1String("ActiveAccessPoint")) {
|
||||
emit pathForPropertiesChanged(msg.path(), map);
|
||||
// qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().value<QDBusObjectPath>().path();
|
||||
// } else if( i.key() == "Strength")
|
||||
// qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value().toUInt();
|
||||
// else
|
||||
// qWarning() << __PRETTY_FUNCTION__ << i.key() << ": " << i.value();
|
||||
} else if (i.key() == QLatin1String("ActiveConnections")) {
|
||||
emit pathForPropertiesChanged(msg.path(), map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QNmDBusHelper::slotSettingsRemoved()
|
||||
{
|
||||
QDBusMessage msg = this->message();
|
||||
emit pathForSettingsRemoved(msg.path());
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
#include "moc_qnmdbushelper.h"
|
|
@ -1,59 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNMDBUSHELPERPRIVATE_H
|
||||
#define QNMDBUSHELPERPRIVATE_H
|
||||
|
||||
#include <QtDBus/qdbusextratypes.h>
|
||||
#include <QDBusContext>
|
||||
#include <QMap>
|
||||
|
||||
#ifndef QT_NO_DBUS
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QNmDBusHelper: public QObject, protected QDBusContext
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QNmDBusHelper(QObject *parent = nullptr);
|
||||
~QNmDBusHelper();
|
||||
|
||||
public slots:
|
||||
void deviceStateChanged(quint32);
|
||||
void slotAccessPointAdded( QDBusObjectPath );
|
||||
void slotAccessPointRemoved( QDBusObjectPath );
|
||||
void slotPropertiesChanged( QMap<QString,QVariant>);
|
||||
void slotSettingsRemoved();
|
||||
|
||||
Q_SIGNALS:
|
||||
void pathForStateChanged(const QString &, quint32);
|
||||
void pathForAccessPointAdded(const QString &, QDBusObjectPath );
|
||||
void pathForAccessPointRemoved(const QString &, QDBusObjectPath );
|
||||
void pathForPropertiesChanged(const QString &, QMap<QString,QVariant>);
|
||||
void pathForSettingsRemoved(const QString &);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_DBUS
|
||||
|
||||
#endif// QNMDBUSHELPERPRIVATE_H
|
|
@ -1,65 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QBEARERENGINE_IMPL_H
|
||||
#define QBEARERENGINE_IMPL_H
|
||||
|
||||
#include "qbearerengine_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QBearerEngineImpl : public QBearerEngine
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
enum ConnectionError {
|
||||
InterfaceLookupError = 0,
|
||||
ConnectError,
|
||||
OperationNotSupported,
|
||||
DisconnectionError,
|
||||
};
|
||||
|
||||
QBearerEngineImpl(QObject *parent = nullptr) : QBearerEngine(parent) {}
|
||||
~QBearerEngineImpl() {}
|
||||
|
||||
virtual void connectToId(const QString &id) = 0;
|
||||
virtual void disconnectFromId(const QString &id) = 0;
|
||||
|
||||
virtual QString getInterfaceFromId(const QString &id) = 0;
|
||||
|
||||
virtual QNetworkSession::State sessionStateForId(const QString &id) = 0;
|
||||
|
||||
virtual quint64 bytesWritten(const QString &) { return Q_UINT64_C(0); }
|
||||
virtual quint64 bytesReceived(const QString &) { return Q_UINT64_C(0); }
|
||||
virtual quint64 startTime(const QString &) { return Q_UINT64_C(0); }
|
||||
|
||||
Q_SIGNALS:
|
||||
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error);
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QBEARERENGINE_IMPL_H
|
|
@ -1,404 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qnetworksession_impl.h"
|
||||
#include "qbearerengine_impl.h"
|
||||
#include "qnetworksession.h"
|
||||
#include "qnetworkconfigmanager_p.h"
|
||||
|
||||
#include <QtCore/qdatetime.h>
|
||||
#include <QtCore/qdebug.h>
|
||||
#include <QtCore/qstringlist.h>
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
static QBearerEngineImpl *getEngineFromId(const QString &id)
|
||||
{
|
||||
QNetworkConfigurationManagerPrivate *priv = qNetworkConfigurationManagerPrivate();
|
||||
|
||||
foreach (QBearerEngine *engine, priv->engines()) {
|
||||
QBearerEngineImpl *engineImpl = qobject_cast<QBearerEngineImpl *>(engine);
|
||||
if (engineImpl && engineImpl->hasIdentifier(id))
|
||||
return engineImpl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
class QNetworkSessionManagerPrivate : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QNetworkSessionManagerPrivate(QObject *parent = nullptr) : QObject(parent) {}
|
||||
~QNetworkSessionManagerPrivate() {}
|
||||
|
||||
inline void forceSessionClose(const QNetworkConfiguration &config)
|
||||
{ emit forcedSessionClose(config); }
|
||||
|
||||
Q_SIGNALS:
|
||||
void forcedSessionClose(const QNetworkConfiguration &config);
|
||||
};
|
||||
|
||||
#include "moc_qnetworksession_impl.cpp"
|
||||
#include "moc_qnetworksession_impl.h"
|
||||
|
||||
Q_GLOBAL_STATIC(QNetworkSessionManagerPrivate, sessionManager)
|
||||
|
||||
void QNetworkSessionPrivateImpl::syncStateWithInterface()
|
||||
{
|
||||
connect(sessionManager(), SIGNAL(forcedSessionClose(QNetworkConfiguration)),
|
||||
this, SLOT(forcedSessionClose(QNetworkConfiguration)));
|
||||
|
||||
opened = false;
|
||||
isOpen = false;
|
||||
state = QNetworkSession::Invalid;
|
||||
lastError = QNetworkSession::UnknownSessionError;
|
||||
|
||||
qRegisterMetaType<QBearerEngineImpl::ConnectionError>("QBearerEngineImpl::ConnectionError");
|
||||
|
||||
switch (publicConfig.type()) {
|
||||
case QNetworkConfiguration::InternetAccessPoint:
|
||||
activeConfig = publicConfig;
|
||||
engine = getEngineFromId(activeConfig.identifier());
|
||||
if (engine) {
|
||||
qRegisterMetaType<QNetworkConfigurationPrivatePointer>("QNetworkConfigurationPrivatePointer");
|
||||
connect(engine, SIGNAL(configurationChanged(QNetworkConfigurationPrivatePointer)),
|
||||
this, SLOT(configurationChanged(QNetworkConfigurationPrivatePointer)),
|
||||
Qt::QueuedConnection);
|
||||
connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
|
||||
this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
break;
|
||||
case QNetworkConfiguration::ServiceNetwork:
|
||||
serviceConfig = publicConfig;
|
||||
// Defer setting engine and signals until open().
|
||||
// fall through
|
||||
case QNetworkConfiguration::UserChoice:
|
||||
// Defer setting serviceConfig and activeConfig until open().
|
||||
// fall through
|
||||
default:
|
||||
engine = 0;
|
||||
}
|
||||
|
||||
networkConfigurationsChanged();
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::open()
|
||||
{
|
||||
if (serviceConfig.isValid()) {
|
||||
lastError = QNetworkSession::OperationNotSupportedError;
|
||||
emit QNetworkSessionPrivate::error(lastError);
|
||||
} else if (!isOpen) {
|
||||
if ((activeConfig.state() & QNetworkConfiguration::Discovered) != QNetworkConfiguration::Discovered) {
|
||||
lastError = QNetworkSession::InvalidConfigurationError;
|
||||
state = QNetworkSession::Invalid;
|
||||
emit stateChanged(state);
|
||||
emit QNetworkSessionPrivate::error(lastError);
|
||||
return;
|
||||
}
|
||||
opened = true;
|
||||
|
||||
if ((activeConfig.state() & QNetworkConfiguration::Active) != QNetworkConfiguration::Active &&
|
||||
(activeConfig.state() & QNetworkConfiguration::Discovered) == QNetworkConfiguration::Discovered) {
|
||||
state = QNetworkSession::Connecting;
|
||||
emit stateChanged(state);
|
||||
|
||||
engine->connectToId(activeConfig.identifier());
|
||||
}
|
||||
|
||||
isOpen = (activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active;
|
||||
if (isOpen)
|
||||
emit quitPendingWaitsForOpened();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::close()
|
||||
{
|
||||
if (serviceConfig.isValid()) {
|
||||
lastError = QNetworkSession::OperationNotSupportedError;
|
||||
emit QNetworkSessionPrivate::error(lastError);
|
||||
} else if (isOpen) {
|
||||
opened = false;
|
||||
isOpen = false;
|
||||
emit closed();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::stop()
|
||||
{
|
||||
if (serviceConfig.isValid()) {
|
||||
lastError = QNetworkSession::OperationNotSupportedError;
|
||||
emit QNetworkSessionPrivate::error(lastError);
|
||||
} else {
|
||||
if ((activeConfig.state() & QNetworkConfiguration::Active) == QNetworkConfiguration::Active) {
|
||||
state = QNetworkSession::Closing;
|
||||
emit stateChanged(state);
|
||||
|
||||
engine->disconnectFromId(activeConfig.identifier());
|
||||
|
||||
sessionManager()->forceSessionClose(activeConfig);
|
||||
}
|
||||
|
||||
opened = false;
|
||||
isOpen = false;
|
||||
emit closed();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::migrate()
|
||||
{
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::accept()
|
||||
{
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::ignore()
|
||||
{
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::reject()
|
||||
{
|
||||
}
|
||||
|
||||
#ifndef QT_NO_NETWORKINTERFACE
|
||||
QNetworkInterface QNetworkSessionPrivateImpl::currentInterface() const
|
||||
{
|
||||
if (!engine || state != QNetworkSession::Connected || !publicConfig.isValid())
|
||||
return QNetworkInterface();
|
||||
|
||||
QString interface = engine->getInterfaceFromId(activeConfig.identifier());
|
||||
if (interface.isEmpty())
|
||||
return QNetworkInterface();
|
||||
return QNetworkInterface::interfaceFromName(interface);
|
||||
}
|
||||
#endif
|
||||
|
||||
QVariant QNetworkSessionPrivateImpl::sessionProperty(const QString &key) const
|
||||
{
|
||||
if (key == QLatin1String("AutoCloseSessionTimeout")) {
|
||||
if (engine && engine->requiresPolling() &&
|
||||
!(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
|
||||
return sessionTimeout >= 0 ? sessionTimeout * 10000 : -1;
|
||||
}
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::setSessionProperty(const QString &key, const QVariant &value)
|
||||
{
|
||||
if (key == QLatin1String("AutoCloseSessionTimeout")) {
|
||||
if (engine && engine->requiresPolling() &&
|
||||
!(engine->capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces)) {
|
||||
int timeout = value.toInt();
|
||||
if (timeout >= 0) {
|
||||
connect(engine, SIGNAL(updateCompleted()),
|
||||
this, SLOT(decrementTimeout()), Qt::UniqueConnection);
|
||||
sessionTimeout = timeout / 10000; // convert to poll intervals
|
||||
} else {
|
||||
disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
|
||||
sessionTimeout = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString QNetworkSessionPrivateImpl::errorString() const
|
||||
{
|
||||
switch (lastError) {
|
||||
case QNetworkSession::UnknownSessionError:
|
||||
return tr("Unknown session error.");
|
||||
case QNetworkSession::SessionAbortedError:
|
||||
return tr("The session was aborted by the user or system.");
|
||||
case QNetworkSession::OperationNotSupportedError:
|
||||
return tr("The requested operation is not supported by the system.");
|
||||
case QNetworkSession::InvalidConfigurationError:
|
||||
return tr("The specified configuration cannot be used.");
|
||||
case QNetworkSession::RoamingError:
|
||||
return tr("Roaming was aborted or is not possible.");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
QNetworkSession::SessionError QNetworkSessionPrivateImpl::error() const
|
||||
{
|
||||
return lastError;
|
||||
}
|
||||
|
||||
quint64 QNetworkSessionPrivateImpl::bytesWritten() const
|
||||
{
|
||||
if (engine && state == QNetworkSession::Connected)
|
||||
return engine->bytesWritten(activeConfig.identifier());
|
||||
return Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
quint64 QNetworkSessionPrivateImpl::bytesReceived() const
|
||||
{
|
||||
if (engine && state == QNetworkSession::Connected)
|
||||
return engine->bytesReceived(activeConfig.identifier());
|
||||
return Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
quint64 QNetworkSessionPrivateImpl::activeTime() const
|
||||
{
|
||||
if (state == QNetworkSession::Connected && startTime != Q_UINT64_C(0))
|
||||
return QDateTime::currentDateTime().toTime_t() - startTime;
|
||||
return Q_UINT64_C(0);
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::updateStateFromServiceNetwork()
|
||||
{
|
||||
QNetworkSession::State oldState = state;
|
||||
|
||||
foreach (const QNetworkConfiguration &config, serviceConfig.children()) {
|
||||
if ((config.state() & QNetworkConfiguration::Active) != QNetworkConfiguration::Active)
|
||||
continue;
|
||||
|
||||
if (activeConfig != config) {
|
||||
if (engine) {
|
||||
disconnect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
|
||||
this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)));
|
||||
}
|
||||
|
||||
activeConfig = config;
|
||||
engine = getEngineFromId(activeConfig.identifier());
|
||||
|
||||
if (engine) {
|
||||
connect(engine, SIGNAL(connectionError(QString,QBearerEngineImpl::ConnectionError)),
|
||||
this, SLOT(connectionError(QString,QBearerEngineImpl::ConnectionError)),
|
||||
Qt::QueuedConnection);
|
||||
}
|
||||
emit newConfigurationActivated();
|
||||
}
|
||||
|
||||
state = QNetworkSession::Connected;
|
||||
if (state != oldState)
|
||||
emit stateChanged(state);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (serviceConfig.children().isEmpty())
|
||||
state = QNetworkSession::NotAvailable;
|
||||
else
|
||||
state = QNetworkSession::Disconnected;
|
||||
|
||||
if (state != oldState)
|
||||
emit stateChanged(state);
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::updateStateFromActiveConfig()
|
||||
{
|
||||
if (!engine)
|
||||
return;
|
||||
|
||||
QNetworkSession::State oldState = state;
|
||||
state = engine->sessionStateForId(activeConfig.identifier());
|
||||
|
||||
bool oldActive = isOpen;
|
||||
isOpen = (state == QNetworkSession::Connected) ? opened : false;
|
||||
|
||||
if (!oldActive && isOpen)
|
||||
emit quitPendingWaitsForOpened();
|
||||
if (oldActive && !isOpen)
|
||||
emit closed();
|
||||
|
||||
if (oldState != state)
|
||||
emit stateChanged(state);
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::networkConfigurationsChanged()
|
||||
{
|
||||
if (serviceConfig.isValid())
|
||||
updateStateFromServiceNetwork();
|
||||
else
|
||||
updateStateFromActiveConfig();
|
||||
|
||||
if (!engine) {
|
||||
startTime = Q_UINT64_C(0);
|
||||
} else {
|
||||
startTime = engine->startTime(activeConfig.identifier());
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::configurationChanged(QNetworkConfigurationPrivatePointer config)
|
||||
{
|
||||
if (serviceConfig.isValid() &&
|
||||
(config->id == serviceConfig.identifier() || config->id == activeConfig.identifier())) {
|
||||
updateStateFromServiceNetwork();
|
||||
} else if (config->id == activeConfig.identifier()) {
|
||||
updateStateFromActiveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::forcedSessionClose(const QNetworkConfiguration &config)
|
||||
{
|
||||
if (activeConfig == config) {
|
||||
opened = false;
|
||||
isOpen = false;
|
||||
|
||||
emit closed();
|
||||
|
||||
lastError = QNetworkSession::SessionAbortedError;
|
||||
emit QNetworkSessionPrivate::error(lastError);
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::connectionError(const QString &id, QBearerEngineImpl::ConnectionError error)
|
||||
{
|
||||
if (activeConfig.identifier() == id) {
|
||||
networkConfigurationsChanged();
|
||||
switch (error) {
|
||||
case QBearerEngineImpl::OperationNotSupported:
|
||||
lastError = QNetworkSession::OperationNotSupportedError;
|
||||
opened = false;
|
||||
break;
|
||||
case QBearerEngineImpl::InterfaceLookupError:
|
||||
case QBearerEngineImpl::ConnectError:
|
||||
case QBearerEngineImpl::DisconnectionError:
|
||||
default:
|
||||
lastError = QNetworkSession::UnknownSessionError;
|
||||
}
|
||||
|
||||
emit QNetworkSessionPrivate::error(lastError);
|
||||
}
|
||||
}
|
||||
|
||||
void QNetworkSessionPrivateImpl::decrementTimeout()
|
||||
{
|
||||
if (--sessionTimeout <= 0) {
|
||||
disconnect(engine, SIGNAL(updateCompleted()), this, SLOT(decrementTimeout()));
|
||||
sessionTimeout = -1;
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
|
@ -1,111 +0,0 @@
|
|||
/****************************************************************************
|
||||
**
|
||||
** Copyright (C) 2015 The Qt Company Ltd.
|
||||
** Copyright (C) 2016 Ivailo Monev
|
||||
**
|
||||
** This file is part of the plugins of the Katie Toolkit.
|
||||
**
|
||||
** $QT_BEGIN_LICENSE:LGPL$
|
||||
**
|
||||
** 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.
|
||||
**
|
||||
** $QT_END_LICENSE$
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QNETWORKSESSION_IMPL_H
|
||||
#define QNETWORKSESSION_IMPL_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Katie API. It exists purely as an
|
||||
// implementation detail. This header file may change from version to
|
||||
// version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "qbearerengine_impl.h"
|
||||
#include "qnetworkconfigmanager_p.h"
|
||||
#include "qnetworksession_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
class QBearerEngineImpl;
|
||||
|
||||
class QNetworkSessionPrivateImpl : public QNetworkSessionPrivate
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QNetworkSessionPrivateImpl()
|
||||
: startTime(0), sessionTimeout(-1)
|
||||
{}
|
||||
~QNetworkSessionPrivateImpl()
|
||||
{}
|
||||
|
||||
//called by QNetworkSession constructor and ensures
|
||||
//that the state is immediately updated (w/o actually opening
|
||||
//a session). Also this function should take care of
|
||||
//notification hooks to discover future state changes.
|
||||
void syncStateWithInterface();
|
||||
|
||||
#ifndef QT_NO_NETWORKINTERFACE
|
||||
QNetworkInterface currentInterface() const;
|
||||
#endif
|
||||
QVariant sessionProperty(const QString& key) const;
|
||||
void setSessionProperty(const QString& key, const QVariant& value);
|
||||
|
||||
void open();
|
||||
void close();
|
||||
void stop();
|
||||
void migrate();
|
||||
void accept();
|
||||
void ignore();
|
||||
void reject();
|
||||
|
||||
QString errorString() const; //must return translated string
|
||||
QNetworkSession::SessionError error() const;
|
||||
|
||||
quint64 bytesWritten() const;
|
||||
quint64 bytesReceived() const;
|
||||
quint64 activeTime() const;
|
||||
|
||||
private Q_SLOTS:
|
||||
void networkConfigurationsChanged();
|
||||
void configurationChanged(QNetworkConfigurationPrivatePointer config);
|
||||
void forcedSessionClose(const QNetworkConfiguration &config);
|
||||
void connectionError(const QString &id, QBearerEngineImpl::ConnectionError error);
|
||||
void decrementTimeout();
|
||||
|
||||
private:
|
||||
void updateStateFromServiceNetwork();
|
||||
void updateStateFromActiveConfig();
|
||||
|
||||
private:
|
||||
QBearerEngineImpl *engine;
|
||||
|
||||
quint64 startTime;
|
||||
|
||||
QNetworkSession::SessionError lastError;
|
||||
|
||||
int sessionTimeout;
|
||||
|
||||
bool opened;
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_BEARERMANAGEMENT
|
||||
|
||||
#endif // QNETWORKSESSION_IMPL_H
|
|
@ -425,8 +425,6 @@ static const struct ClassTblData {
|
|||
{ QLatin1String("QNetworkAccessManager"), QLatin1String("QtNetwork/qnetworkaccessmanager.h") },
|
||||
{ QLatin1String("QNetworkAddressEntry"), QLatin1String("QtNetwork/qnetworkinterface.h") },
|
||||
{ QLatin1String("QNetworkCacheMetaData"), QLatin1String("QtNetwork/qabstractnetworkcache.h") },
|
||||
{ QLatin1String("QNetworkConfiguration"), QLatin1String("QtNetwork/qnetworkconfiguration.h") },
|
||||
{ QLatin1String("QNetworkConfigurationManager"), QLatin1String("QtNetwork/qnetworkconfigmanager.h") },
|
||||
{ QLatin1String("QNetworkCookie"), QLatin1String("QtNetwork/qnetworkcookie.h") },
|
||||
{ QLatin1String("QNetworkCookieJar"), QLatin1String("QtNetwork/qnetworkcookiejar.h") },
|
||||
{ QLatin1String("QNetworkDiskCache"), QLatin1String("QtNetwork/qnetworkdiskcache.h") },
|
||||
|
@ -436,7 +434,6 @@ static const struct ClassTblData {
|
|||
{ QLatin1String("QNetworkProxyQuery"), QLatin1String("QtNetwork/qnetworkproxy.h") },
|
||||
{ QLatin1String("QNetworkReply"), QLatin1String("QtNetwork/qnetworkreply.h") },
|
||||
{ QLatin1String("QNetworkRequest"), QLatin1String("QtNetwork/qnetworkrequest.h") },
|
||||
{ QLatin1String("QNetworkSession"), QLatin1String("QtNetwork/qnetworksession.h") },
|
||||
{ QLatin1String("QObject"), QLatin1String("QtCore/qobject.h") },
|
||||
{ QLatin1String("QObjectCleanupHandler"), QLatin1String("QtCore/qobjectcleanuphandler.h") },
|
||||
{ QLatin1String("QPageSetupDialog"), QLatin1String("QtGui/qpagesetupdialog.h") },
|
||||
|
|
|
@ -29,12 +29,6 @@
|
|||
#include <qhostinfo.h>
|
||||
#include "qhostinfo_p.h"
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
#include <QtNetwork/qnetworkconfigmanager.h>
|
||||
#include <QtNetwork/qnetworkconfiguration.h>
|
||||
#include <QtNetwork/qnetworksession.h>
|
||||
#endif
|
||||
|
||||
#include "../network-settings.h"
|
||||
#include "../../shared/util.h"
|
||||
|
||||
|
@ -85,11 +79,6 @@ private:
|
|||
bool lookupDone;
|
||||
int lookupsDoneCounter;
|
||||
QHostInfo lookupResults;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QNetworkConfigurationManager *netConfMan;
|
||||
QNetworkConfiguration networkConfiguration;
|
||||
QScopedPointer<QNetworkSession> networkSession;
|
||||
#endif
|
||||
};
|
||||
|
||||
// Testing get/set functions
|
||||
|
@ -130,23 +119,6 @@ tst_QHostInfo::~tst_QHostInfo()
|
|||
|
||||
void tst_QHostInfo::initTestCase()
|
||||
{
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
netConfMan = new QNetworkConfigurationManager(this);
|
||||
netConfMan->updateConfigurations();
|
||||
connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
QTestEventLoop::instance().enterLoop(10);
|
||||
networkConfiguration = netConfMan->defaultConfiguration();
|
||||
if (networkConfiguration.isValid()) {
|
||||
networkSession.reset(new QNetworkSession(networkConfiguration));
|
||||
if (!networkSession->isOpen()) {
|
||||
networkSession->open();
|
||||
QVERIFY(networkSession->waitForOpened(30000));
|
||||
}
|
||||
} else {
|
||||
QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
|
||||
}
|
||||
#endif
|
||||
|
||||
ipv6Available = QtNetworkSettings::supportsIPv6();
|
||||
|
||||
// run each testcase with and without test enabled
|
||||
|
|
|
@ -26,16 +26,13 @@
|
|||
#include <qcoreapplication.h>
|
||||
#include <qdebug.h>
|
||||
#include <qnetworkproxy.h>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QNetworkConfigurationManager>
|
||||
#include <QNetworkSession>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkInterface>
|
||||
#include <QList>
|
||||
#include <QThread>
|
||||
|
||||
Q_DECLARE_METATYPE(QNetworkConfiguration);
|
||||
Q_DECLARE_METATYPE(QList<QNetworkProxy>);
|
||||
|
||||
class tst_QNetworkProxyFactory : public QObject {
|
||||
|
@ -61,11 +58,6 @@ private slots:
|
|||
void systemProxyForQueryCalledFromThread();
|
||||
void systemProxyForQuery_data();
|
||||
void systemProxyForQuery() const;
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
void fromConfigurations();
|
||||
void inNetworkAccessManager_data();
|
||||
void inNetworkAccessManager();
|
||||
#endif
|
||||
|
||||
private:
|
||||
QString formatProxyName(const QNetworkProxy & proxy) const;
|
||||
|
@ -223,110 +215,6 @@ void tst_QNetworkProxyFactory::systemProxyForQuery() const
|
|||
}
|
||||
}
|
||||
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
//Purpose of this test is just to check systemProxyForQuery doesn't hang or crash
|
||||
//with any given configuration including no configuration.
|
||||
//We can't test it returns the right proxies without implementing the native proxy code
|
||||
//again here, which would be testing our implementation against itself.
|
||||
//Therefore it's just testing that something valid is returned (at least a NoProxy entry)
|
||||
void tst_QNetworkProxyFactory::fromConfigurations()
|
||||
{
|
||||
QNetworkConfigurationManager manager;
|
||||
//update is done to get the active / discovered states
|
||||
manager.updateConfigurations();
|
||||
connect(&manager, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
QTestEventLoop::instance().enterLoop(10);
|
||||
QList<QNetworkProxy> proxies;
|
||||
QUrl url(QLatin1String("http://qt-project.org"));
|
||||
//get from known configurations
|
||||
foreach (QNetworkConfiguration config, manager.allConfigurations()) {
|
||||
QNetworkProxyQuery query(config, url, QNetworkProxyQuery::UrlRequest);
|
||||
proxies = QNetworkProxyFactory::systemProxyForQuery(query);
|
||||
QVERIFY(!proxies.isEmpty());
|
||||
foreach (QNetworkProxy proxy, proxies) {
|
||||
qDebug() << config.name() << " - " << config.identifier() << " - " << formatProxyName(proxy);
|
||||
}
|
||||
}
|
||||
|
||||
//get from default configuration
|
||||
QNetworkProxyQuery defaultquery(url, QNetworkProxyQuery::UrlRequest);
|
||||
proxies = QNetworkProxyFactory::systemProxyForQuery(defaultquery);
|
||||
QVERIFY(!proxies.isEmpty());
|
||||
foreach (QNetworkProxy proxy, proxies) {
|
||||
qDebug() << "default - " << formatProxyName(proxy);
|
||||
}
|
||||
|
||||
//get from active configuration
|
||||
QNetworkSession session(manager.defaultConfiguration());
|
||||
session.open();
|
||||
QVERIFY(session.waitForOpened(30000));
|
||||
proxies = QNetworkProxyFactory::systemProxyForQuery(defaultquery);
|
||||
QVERIFY(!proxies.isEmpty());
|
||||
foreach (QNetworkProxy proxy, proxies) {
|
||||
qDebug() << "active - " << formatProxyName(proxy);
|
||||
}
|
||||
|
||||
//get from known configurations while there is one active
|
||||
foreach (QNetworkConfiguration config, manager.allConfigurations()) {
|
||||
QNetworkProxyQuery query(config, url, QNetworkProxyQuery::UrlRequest);
|
||||
proxies = QNetworkProxyFactory::systemProxyForQuery(query);
|
||||
QVERIFY(!proxies.isEmpty());
|
||||
foreach (QNetworkProxy proxy, proxies) {
|
||||
qDebug() << config.name() << " - " << config.identifier() << " - " << formatProxyName(proxy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QNetworkProxyFactory::inNetworkAccessManager_data()
|
||||
{
|
||||
QTest::addColumn<QNetworkConfiguration>("config");
|
||||
QTest::addColumn<QList<QNetworkProxy> >("proxies");
|
||||
QNetworkConfigurationManager manager;
|
||||
//get from known configurations
|
||||
foreach (QNetworkConfiguration config, manager.allConfigurations()) {
|
||||
QNetworkProxyQuery query(config, QUrl(QString("http://qt.nokia.com")), QNetworkProxyQuery::UrlRequest);
|
||||
QList<QNetworkProxy> proxies = QNetworkProxyFactory::systemProxyForQuery(query);
|
||||
QTest::newRow(config.name().toUtf8()) << config << proxies;
|
||||
}
|
||||
}
|
||||
|
||||
//Purpose of this test is to check that QNetworkAccessManager uses the proxy from the configuration it
|
||||
//has been given. Needs two or more working configurations to be a good test.
|
||||
void tst_QNetworkProxyFactory::inNetworkAccessManager()
|
||||
{
|
||||
QFETCH(QNetworkConfiguration, config);
|
||||
QFETCH(QList<QNetworkProxy>, proxies);
|
||||
|
||||
int count = factory->requestCounter;
|
||||
|
||||
QNetworkAccessManager manager;
|
||||
manager.setConfiguration(config);
|
||||
|
||||
//using an internet server, because cellular APs won't have a route to the test server.
|
||||
QNetworkRequest req(QUrl(QString("http://qt.nokia.com")));
|
||||
QNetworkReply *reply = manager.get(req);
|
||||
connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
QTestEventLoop::instance().enterLoop(30);
|
||||
delete reply;
|
||||
|
||||
if (count == factory->requestCounter) {
|
||||
//RND phones are preconfigured with several test access points which won't work without a matching SIM
|
||||
//If the network fails to start, QNAM won't ask the factory for proxies so we can't test.
|
||||
QSKIP("network configuration didn't start", SkipSingle);
|
||||
}
|
||||
|
||||
qDebug() << "testing network configuration for" << config.name();
|
||||
foreach (QNetworkProxy proxy, factory->returnedList) {
|
||||
qDebug() << formatProxyName(proxy);
|
||||
}
|
||||
qDebug() << " <vs> ";
|
||||
foreach (QNetworkProxy proxy, proxies) {
|
||||
qDebug() << formatProxyName(proxy);
|
||||
}
|
||||
QCOMPARE(factory->returnedList, proxies);
|
||||
}
|
||||
#endif //QT_NO_BEARERMANAGEMENT
|
||||
|
||||
class QSPFQThread : public QThread
|
||||
{
|
||||
protected:
|
||||
|
|
|
@ -28,9 +28,6 @@
|
|||
#include <qstringlist.h>
|
||||
#include <qplatformdefs.h>
|
||||
#include <qhostinfo.h>
|
||||
#include <QNetworkConfiguration>
|
||||
#include <QNetworkConfigurationManager>
|
||||
#include <QNetworkSession>
|
||||
#include <QNetworkProxy>
|
||||
|
||||
Q_DECLARE_METATYPE(QNetworkProxy)
|
||||
|
@ -56,12 +53,6 @@ private slots:
|
|||
void ipv4LoopbackPerformanceTest();
|
||||
void ipv6LoopbackPerformanceTest();
|
||||
void ipv4PerformanceTest();
|
||||
private:
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
QNetworkConfigurationManager *netConfMan;
|
||||
QNetworkConfiguration networkConfiguration;
|
||||
QSharedPointer<QNetworkSession> networkSession;
|
||||
#endif
|
||||
};
|
||||
|
||||
tst_QTcpServer::tst_QTcpServer()
|
||||
|
@ -70,22 +61,6 @@ tst_QTcpServer::tst_QTcpServer()
|
|||
|
||||
void tst_QTcpServer::initTestCase()
|
||||
{
|
||||
#ifndef QT_NO_BEARERMANAGEMENT
|
||||
netConfMan = new QNetworkConfigurationManager(this);
|
||||
netConfMan->updateConfigurations();
|
||||
connect(netConfMan, SIGNAL(updateCompleted()), &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
QTestEventLoop::instance().enterLoop(10);
|
||||
networkConfiguration = netConfMan->defaultConfiguration();
|
||||
if (networkConfiguration.isValid()) {
|
||||
networkSession = QSharedPointer<QNetworkSession>(new QNetworkSession(networkConfiguration));
|
||||
if (!networkSession->isOpen()) {
|
||||
networkSession->open();
|
||||
QVERIFY(networkSession->waitForOpened(30000));
|
||||
}
|
||||
} else {
|
||||
QVERIFY(!(netConfMan->capabilities() & QNetworkConfigurationManager::NetworkSessionRequired));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
tst_QTcpServer::~tst_QTcpServer()
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-08-13 23:30+0300\n"
|
||||
"POT-Creation-Date: 2021-08-25 17:50+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -45,7 +45,7 @@ msgstr ""
|
|||
#: src/core/plugin/qlibrary.cpp:796 src/core/plugin/qpluginloader.cpp:279
|
||||
#: src/core/io/qiodevice.cpp:1519 src/network/ssl/qsslerror.cpp:249
|
||||
#: src/network/socket/qnativesocketengine.cpp:250
|
||||
#: src/network/access/qftp.cpp:1428 src/uitools/formscriptrunner.cpp:104
|
||||
#: src/network/access/qftp.cpp:1415 src/uitools/formscriptrunner.cpp:104
|
||||
msgid "Unknown error"
|
||||
msgstr ""
|
||||
|
||||
|
@ -150,11 +150,11 @@ msgctxt "QStandardPaths"
|
|||
msgid "Download"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/io/qfile.cpp:573
|
||||
#: src/core/io/qfile.cpp:574
|
||||
msgid "Destination file exists"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/io/qfile.cpp:961
|
||||
#: src/core/io/qfile.cpp:963
|
||||
msgid "No file engine available or engine does not support UnMapExtension"
|
||||
msgstr ""
|
||||
|
||||
|
@ -336,27 +336,27 @@ msgctxt "QJsonDocument"
|
|||
msgid "Data is empty"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/tools/qjsondocument.cpp:108
|
||||
#: src/core/tools/qjsondocument.cpp:112
|
||||
msgctxt "QJsonDocument"
|
||||
msgid "Unknown JSON type in array"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/tools/qjsondocument.cpp:141 src/core/tools/qjsondocument.cpp:224
|
||||
#: src/core/tools/qjsondocument.cpp:145 src/core/tools/qjsondocument.cpp:228
|
||||
msgctxt "QJsonDocument"
|
||||
msgid "Unknown JSON type"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/tools/qjsondocument.cpp:149
|
||||
#: src/core/tools/qjsondocument.cpp:153
|
||||
msgctxt "QJsonDocument"
|
||||
msgid "Rootless array/values are not supported"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/tools/qjsondocument.cpp:164
|
||||
#: src/core/tools/qjsondocument.cpp:168
|
||||
msgctxt "QJsonDocument"
|
||||
msgid "Data map is empty"
|
||||
msgstr ""
|
||||
|
||||
#: src/core/tools/qjsondocument.cpp:167
|
||||
#: src/core/tools/qjsondocument.cpp:171
|
||||
msgctxt "QJsonDocument"
|
||||
msgid "Maximum depth reached"
|
||||
msgstr ""
|
||||
|
@ -4783,7 +4783,7 @@ msgstr ""
|
|||
msgid "Error during SSL handshake: %1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/kernel/qhostinfo_p.h:79
|
||||
#: src/network/kernel/qhostinfo_p.h:74
|
||||
msgctxt "QHostInfo"
|
||||
msgid "Unknown error"
|
||||
msgstr ""
|
||||
|
@ -4795,10 +4795,10 @@ msgstr ""
|
|||
|
||||
#: src/network/kernel/qhostinfo_unix.cpp:87
|
||||
#: src/network/kernel/qhostinfo_unix.cpp:173
|
||||
#: src/network/socket/qabstractsocket.cpp:835
|
||||
#: src/network/socket/qhttpsocketengine.cpp:651
|
||||
#: src/network/socket/qsocks5socketengine.cpp:626
|
||||
#: src/network/socket/qsocks5socketengine.cpp:652
|
||||
#: src/network/socket/qabstractsocket.cpp:830
|
||||
#: src/network/socket/qhttpsocketengine.cpp:648
|
||||
#: src/network/socket/qsocks5socketengine.cpp:620
|
||||
#: src/network/socket/qsocks5socketengine.cpp:646
|
||||
msgid "Host not found"
|
||||
msgstr ""
|
||||
|
||||
|
@ -4814,14 +4814,10 @@ msgstr ""
|
|||
msgid "Unknown address type"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/bearer/qnetworksession.cpp:432
|
||||
msgid "Invalid configuration."
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qtcpserver.cpp:266 src/network/socket/qtcpserver.cpp:388
|
||||
#: src/network/socket/qabstractsocket.cpp:486
|
||||
#: src/network/socket/qabstractsocket.cpp:1273
|
||||
#: src/network/socket/qabstractsocket.cpp:1483
|
||||
#: src/network/socket/qtcpserver.cpp:266 src/network/socket/qtcpserver.cpp:384
|
||||
#: src/network/socket/qabstractsocket.cpp:485
|
||||
#: src/network/socket/qabstractsocket.cpp:1268
|
||||
#: src/network/socket/qabstractsocket.cpp:1478
|
||||
msgid "Operation on socket is not supported"
|
||||
msgstr ""
|
||||
|
||||
|
@ -4843,59 +4839,59 @@ msgstr ""
|
|||
msgid "%1: Unknown error %2"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qabstractsocket.cpp:877
|
||||
#: src/network/socket/qhttpsocketengine.cpp:654
|
||||
#: src/network/socket/qabstractsocket.cpp:872
|
||||
#: src/network/socket/qhttpsocketengine.cpp:651
|
||||
#: src/network/socket/qnativesocketengine.cpp:214
|
||||
#: src/network/socket/qsocks5socketengine.cpp:656
|
||||
#: src/network/socket/qsocks5socketengine.cpp:650
|
||||
msgid "Connection refused"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qabstractsocket.cpp:1019
|
||||
#: src/network/socket/qabstractsocket.cpp:1014
|
||||
#: src/network/socket/qnativesocketengine.cpp:211
|
||||
msgid "Connection timed out"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qabstractsocket.cpp:1660
|
||||
#: src/network/socket/qabstractsocket.cpp:1651
|
||||
msgid "Socket operation timed out"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qabstractsocket.cpp:2071
|
||||
#: src/network/socket/qabstractsocket.cpp:2062
|
||||
msgid "Socket is not connected"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:551
|
||||
#: src/network/socket/qhttpsocketengine.cpp:548
|
||||
msgid "Did not receive HTTP response from proxy"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:587
|
||||
#: src/network/socket/qhttpsocketengine.cpp:584
|
||||
msgid "Error parsing authentication request from proxy"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:621
|
||||
#: src/network/socket/qhttpsocketengine.cpp:618
|
||||
msgid "Authentication required"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:648
|
||||
#: src/network/socket/qhttpsocketengine.cpp:645
|
||||
msgid "Proxy denied connection"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:658
|
||||
#: src/network/socket/qhttpsocketengine.cpp:655
|
||||
msgid "Error communicating with HTTP proxy"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:681
|
||||
#: src/network/socket/qhttpsocketengine.cpp:678
|
||||
msgid "Proxy server not found"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:683
|
||||
#: src/network/socket/qhttpsocketengine.cpp:680
|
||||
msgid "Proxy connection refused"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:685
|
||||
#: src/network/socket/qhttpsocketengine.cpp:682
|
||||
msgid "Proxy server connection timed out"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qhttpsocketengine.cpp:687
|
||||
#: src/network/socket/qhttpsocketengine.cpp:684
|
||||
msgid "Proxy connection closed prematurely"
|
||||
msgstr ""
|
||||
|
||||
|
@ -4940,7 +4936,7 @@ msgid "Host unreachable"
|
|||
msgstr ""
|
||||
|
||||
#: src/network/socket/qnativesocketengine.cpp:205
|
||||
#: src/network/socket/qsocks5socketengine.cpp:648
|
||||
#: src/network/socket/qsocks5socketengine.cpp:642
|
||||
msgid "Network unreachable"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5032,105 +5028,105 @@ msgstr ""
|
|||
msgid "This platform does not support IPv6"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:581
|
||||
#: src/network/socket/qsocks5socketengine.cpp:575
|
||||
msgid "Connection to proxy refused"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:585
|
||||
#: src/network/socket/qsocks5socketengine.cpp:579
|
||||
msgid "Connection to proxy closed prematurely"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:589
|
||||
#: src/network/socket/qsocks5socketengine.cpp:583
|
||||
msgid "Proxy host not found"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:594
|
||||
#: src/network/socket/qsocks5socketengine.cpp:588
|
||||
msgid "Connection to proxy timed out"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:611
|
||||
#: src/network/socket/qsocks5socketengine.cpp:605
|
||||
msgid "Proxy authentication failed"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:612
|
||||
#: src/network/socket/qsocks5socketengine.cpp:606
|
||||
msgid "Proxy authentication failed: %1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:621
|
||||
#: src/network/socket/qsocks5socketengine.cpp:615
|
||||
msgid "SOCKS version 5 protocol error"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:640
|
||||
#: src/network/socket/qsocks5socketengine.cpp:634
|
||||
msgid "General SOCKSv5 server failure"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:644
|
||||
#: src/network/socket/qsocks5socketengine.cpp:638
|
||||
msgid "Connection not allowed by SOCKSv5 server"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:660
|
||||
#: src/network/socket/qsocks5socketengine.cpp:654
|
||||
msgid "TTL expired"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:664
|
||||
#: src/network/socket/qsocks5socketengine.cpp:658
|
||||
msgid "SOCKSv5 command not supported"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:668
|
||||
#: src/network/socket/qsocks5socketengine.cpp:662
|
||||
msgid "Address type not supported"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:673
|
||||
#: src/network/socket/qsocks5socketengine.cpp:667
|
||||
msgid "Unknown SOCKSv5 proxy error code 0x%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/socket/qsocks5socketengine.cpp:1365
|
||||
#: src/network/socket/qsocks5socketengine.cpp:1356
|
||||
msgctxt "QSocks5SocketEngine"
|
||||
msgid "Network operation timed out"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:656
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:652
|
||||
#: src/network/access/qhttp.cpp:2591
|
||||
msgctxt "QHttp"
|
||||
msgid "Host %1 not found"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:659
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:655
|
||||
msgctxt "QHttp"
|
||||
msgid "Connection refused"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:662
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:658
|
||||
msgctxt "QHttp"
|
||||
msgid "Connection closed"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:665
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:661
|
||||
msgctxt "QAbstractSocket"
|
||||
msgid "Socket operation timed out"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:668
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:664
|
||||
msgctxt "QHttp"
|
||||
msgid "Proxy requires authentication"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:671
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:667
|
||||
msgctxt "QHttp"
|
||||
msgid "Host requires authentication"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:674
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:670
|
||||
msgctxt "QHttp"
|
||||
msgid "Data corrupted"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:677
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:673
|
||||
msgctxt "QHttp"
|
||||
msgid "Unknown protocol specified"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:680
|
||||
#: src/network/access/qhttpnetworkconnection.cpp:676
|
||||
msgctxt "QHttp"
|
||||
msgid "SSL handshake failed"
|
||||
msgstr ""
|
||||
|
@ -5149,7 +5145,7 @@ msgid "Remote host closed the connection prematurely on %1"
|
|||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkaccessftpbackend.cpp:114
|
||||
#: src/network/access/qnetworkaccesshttpbackend.cpp:404
|
||||
#: src/network/access/qnetworkaccesshttpbackend.cpp:403
|
||||
msgid "No suitable proxy found"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5157,15 +5153,15 @@ msgstr ""
|
|||
msgid "Cannot open %1: is a directory"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkaccessftpbackend.cpp:228
|
||||
#: src/network/access/qnetworkaccessftpbackend.cpp:224
|
||||
msgid "Logging in to %1 failed: authentication required"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkaccessftpbackend.cpp:260
|
||||
#: src/network/access/qnetworkaccessftpbackend.cpp:256
|
||||
msgid "Error while downloading %1: %2"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkaccessftpbackend.cpp:262
|
||||
#: src/network/access/qnetworkaccessftpbackend.cpp:258
|
||||
msgid "Error while uploading %1: %2"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5243,130 +5239,115 @@ msgctxt "QHttp"
|
|||
msgid "Error writing response to device"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qhttpthreaddelegate.cpp:407
|
||||
#: src/network/access/qhttpthreaddelegate.cpp:430
|
||||
#: src/network/access/qhttpthreaddelegate.cpp:398
|
||||
#: src/network/access/qhttpthreaddelegate.cpp:421
|
||||
msgctxt "QNetworkReply"
|
||||
msgid "Error downloading %1 - server replied: %2"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:68
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:67
|
||||
msgctxt "QNetworkReply"
|
||||
msgid "Protocol \"%1\" is unknown"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:94
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:285
|
||||
msgctxt "QNetworkReply"
|
||||
msgid "Network session error."
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:101
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:76
|
||||
msgctxt "QNetworkReply"
|
||||
msgid "backend start error."
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:749
|
||||
msgid "Temporary network failure."
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:864
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:894
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:767
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:797
|
||||
msgid "Operation canceled"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qnetworkreplyimpl.cpp:1089
|
||||
msgctxt "QNetworkAccessManager"
|
||||
msgid "Network access is disabled."
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:856
|
||||
#: src/network/access/qftp.cpp:843
|
||||
msgid "Not connected"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:935
|
||||
#: src/network/access/qftp.cpp:922
|
||||
msgid "Host %1 not found"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:939
|
||||
#: src/network/access/qftp.cpp:926
|
||||
msgid "Connection refused to host %1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:943
|
||||
#: src/network/access/qftp.cpp:930
|
||||
msgid "Connection timed out to host %1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:1047
|
||||
#: src/network/access/qftp.cpp:1034
|
||||
msgid "Connected to host %1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:1255
|
||||
#: src/network/access/qftp.cpp:1242
|
||||
msgid "Connection refused for data connection"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2329
|
||||
#: src/network/access/qftp.cpp:2312
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Connecting to host failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2333
|
||||
#: src/network/access/qftp.cpp:2316
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Login failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2337
|
||||
#: src/network/access/qftp.cpp:2320
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Listing directory failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2341
|
||||
#: src/network/access/qftp.cpp:2324
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Changing directory failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2345
|
||||
#: src/network/access/qftp.cpp:2328
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Downloading file failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2349
|
||||
#: src/network/access/qftp.cpp:2332
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Uploading file failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2353
|
||||
#: src/network/access/qftp.cpp:2336
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Removing file failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2357
|
||||
#: src/network/access/qftp.cpp:2340
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Creating directory failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2361
|
||||
#: src/network/access/qftp.cpp:2344
|
||||
msgctxt "QFtp"
|
||||
msgid ""
|
||||
"Removing directory failed:\n"
|
||||
"%1"
|
||||
msgstr ""
|
||||
|
||||
#: src/network/access/qftp.cpp:2389
|
||||
#: src/network/access/qftp.cpp:2372
|
||||
msgctxt "QFtp"
|
||||
msgid "Connection closed"
|
||||
msgstr ""
|
||||
|
@ -5527,26 +5508,6 @@ msgstr ""
|
|||
msgid "Could not reset to start position"
|
||||
msgstr ""
|
||||
|
||||
#: src/plugins/bearer/qnetworksession_impl.cpp:233
|
||||
msgid "Unknown session error."
|
||||
msgstr ""
|
||||
|
||||
#: src/plugins/bearer/qnetworksession_impl.cpp:235
|
||||
msgid "The session was aborted by the user or system."
|
||||
msgstr ""
|
||||
|
||||
#: src/plugins/bearer/qnetworksession_impl.cpp:237
|
||||
msgid "The requested operation is not supported by the system."
|
||||
msgstr ""
|
||||
|
||||
#: src/plugins/bearer/qnetworksession_impl.cpp:239
|
||||
msgid "The specified configuration cannot be used."
|
||||
msgstr ""
|
||||
|
||||
#: src/plugins/bearer/qnetworksession_impl.cpp:241
|
||||
msgid "Roaming was aborted or is not possible."
|
||||
msgstr ""
|
||||
|
||||
#: src/plugins/sqldrivers/psql/qsql_psql.cpp:184
|
||||
msgctxt "QPSQLResult"
|
||||
msgid "Unable to create query"
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2021-08-13 23:30+0300\n"
|
||||
"POT-Creation-Date: 2021-08-25 17:50+0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
|
Loading…
Add table
Reference in a new issue