Commit 72bd715e authored by Lorn Potter's avatar Lorn Potter

[connectionagent] support connman 1.21 and refactor

parent 00cfb490
......@@ -12,7 +12,7 @@ equals(QT_MAJOR_VERSION, 5): {
PKGCONFIG += connman-qt5 qofono-qt5
}
CONFIG += console link_pkgconfig
CONFIG += console link_pkgconfig
CONFIG -= app_bundle
TEMPLATE = app
......@@ -25,12 +25,12 @@ OTHER_FILES += com.jolla.Connectiond.xml
#system(qdbusxml2cpp -c ConnAdaptor -a connadaptor.h:connadaptor.cpp com.jollamobile.Connectiond.xml)
SOURCES += main.cpp \
qconnectionmanager.cpp \
qconnectionagent.cpp \
connadaptor.cpp \
wakeupwatcher.cpp
HEADERS+= \
qconnectionmanager.h \
qconnectionagent.h \
connadaptor.h \
wakeupwatcher.h
......
......@@ -24,7 +24,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include "qconnectionmanager.h"
#include "qconnectionagent.h"
#include "connadaptor.h"
static void signal_handler(int signum)
......@@ -108,7 +108,7 @@ int main(int argc, char *argv[])
return 1;
}
QConnectionManager::instance();
QConnectionAgent::instance();
return a.exec();
}
......
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd
** Copyright (C) 2014 Jolla Ltd
** Contact: lorn.potter@gmail.com
**
**
......@@ -14,8 +14,8 @@
**
****************************************************************************/
#ifndef QCONNECTIONMANAGER_H
#define QCONNECTIONMANAGER_H
#ifndef QCONNECTIONAGENT_H
#define QCONNECTIONAGENT_H
#include <QObject>
#include <QMap>
......@@ -38,15 +38,15 @@ class NetworkTechnology;
class WakeupWatcher;
class QTimer;
class QConnectionManager : public QObject
class QConnectionAgent : public QObject
{
Q_OBJECT
Q_PROPERTY(bool askRoaming READ askRoaming WRITE setAskRoaming)
public:
~QConnectionManager();
~QConnectionAgent();
static QConnectionManager &instance();
static QConnectionAgent &instance();
bool askRoaming() const;
void setAskRoaming(bool value);
......@@ -60,7 +60,7 @@ Q_SIGNALS:
void connectionState(const QString &state, const QString &type);
void connectNow(const QString &path);
void requestBrowser(/*const QString &path,*/ const QString &url);
void requestBrowser(const QString &url);
public Q_SLOTS:
......@@ -76,54 +76,33 @@ public Q_SLOTS:
void connectToType(const QString &type);
private:
explicit QConnectionManager(QObject *parent = 0);
static QConnectionManager *self;
explicit QConnectionAgent(QObject *parent = 0);
static QConnectionAgent *self;
ConnAdaptor *connectionAdaptor;
UserAgent *ua;
bool autoConnect();
NetworkManager *netman;
SessionAgent *sessionAgent;
QString currentNetworkState;
QString currentType;
bool serviceConnect;
uint currentNotification;
QMap<QString,NetworkService *> servicesMap;
QStringList orderedServicesList;
QString findBestConnectableService();
QStringList techPreferenceList;
bool askForRoaming;
bool isEthernet;
bool connmanAvailable;
bool handoverInProgress;
QString serviceInProgress;
bool isBestService(const QString &servicePath);
bool isStateOnline(const QString &state);
void requestDisconnect(const QString &service);
void requestConnect(const QString &service);
QOfonoConnectionContext *oContext;
NetworkTechnology *tetheringWifiTech;
bool tetheringEnabled;
bool flightModeSuppression;
WakeupWatcher *mceWatch;
QTimer *goodConnectTimer;
QElapsedTimer manualConnnectionTimer;
QString lastManuallyConnectedService;
uint scanTimeoutInterval;
QElapsedTimer manualDisconnectionTimer;
QString lastManuallyDisconnectedService;
QString delayedConnectService;
QTimer *scanTimer;
QMap <QString, QList <uint> > wifiStrengths;
uint averageSignalStrength(const QString &servicePath);
QStringList knownTechnologies;
private slots:
......@@ -133,8 +112,6 @@ private slots:
void serviceErrorChanged(const QString &error);
void serviceStateChanged(const QString &state);
void networkStateChanged(const QString &state);
void onServiceStrengthChanged(uint);
bool connectToNetworkService(const QString &service);
void connmanAvailabilityChanged(bool b);
void setup();
......@@ -142,10 +119,6 @@ private slots:
void ofonoServicesError(const QString &);
void technologyPowerChanged(bool);
void browserRequest(const QString &servicePath, const QString &url);
void onServiceConnectionStarted();
void onServiceDisconnectionStarted();
void techTetheringChanged(bool);
void techChanged();
void serviceRemoved(const QString &);
......@@ -155,15 +128,11 @@ private slots:
void flightModeDialogSuppressionTimeout();
void displayStateChanged(const QString &);
void sleepStateChanged(bool);
// void sleepStateChanged(bool);
void goodConnectionTimeout();
void serviceAutoconnectChanged(bool);
void scanTimeout();
void delayedAutoconnect();
void delayedConnect();
};
#endif // QCONNECTIONMANAGER_H
#endif // QCONNECTIONAGENT_H
......@@ -5,16 +5,13 @@ SUBDIRS += test
equals(QT_MAJOR_VERSION, 4): {
SUBDIRS += test/testqml
OTHER_FILES += rpm/connectionagent.spec \
rpm/connectionagent.yaml
}
OTHER_FILES += rpm/connectionagent.spec }
equals(QT_MAJOR_VERSION, 5): {
SUBDIRS += config
SUBDIRS += connd
OTHER_FILES += rpm/connectionagent-qt5.spec \
rpm/connectionagent-qt5.yaml \
rpm/connectionagent.tracing
}
......@@ -9,7 +9,7 @@ Name: connectionagent-qt5
# << macros
Summary: User Agent daemon
Version: 0.9.29
Version: 0.10.1
Release: 0
Group: Communications/Connectivity Adaptation
License: LGPLv2
......
Name: connectionagent-qt5
Summary: User Agent daemon
Version: 0.9.29
Release: 0
Group: "Communications/Connectivity Adaptation"
License: LGPLv2
URL: http://github.com/lpotter/connectionagent
Description: |
Connection Agent provides multi user access to connman's User Agent.
It also provides autoconnecting features.
Sources:
- "%{name}-%{version}.tar.bz"
Requires:
- connman-qt5-declarative
- systemd
- systemd-user-session-targets
Provides:
- connectionagent > 0.7.6
Obsoletes:
- connectionagent <= 0.7.6
PkgConfigBR:
- Qt5Core
- Qt5DBus
- connman-qt5
- qofono-qt5
- Qt5Network
- Qt5Test
- Qt5Qml
Configure: none
Builder: qmake5
Files:
- "%{_bindir}/connectionagent"
- "%{_datadir}/dbus-1/services/com.jolla.Connectiond.service"
- "%{_libdir}/systemd/user/connectionagent.service"
- "%{_sysconfdir}/dbus-1/session.d/connectionagent.conf"
SubPackages:
- Name: declarative
Summary: Declarative plugin for connection agent.
Group: Development/Tools
Description: This package contains the declarative plugin for connection agent.
Requires:
- "%{name} = %{version}"
Files:
- "%{_libdir}/qt5/qml/com/jolla/connection/*"
- Name: test
Summary: auto test for connection agent.
Group: Development/Tools
Description: This package contains the auto tests for connection agent.
Requires:
- "%{name} = %{version}"
Files:
- "%{_prefix}/opt/tests/libqofono/*"
......@@ -9,7 +9,7 @@ Name: connectionagent
# << macros
Summary: User Agent daemon
Version: 0.9.29
Version: 0.10.1
Release: 0
Group: Communications/Connectivity Adaptation
License: LGPLv2
......
Name: connectionagent
Summary: User Agent daemon
Version: 0.9.29
Release: 0
Group: "Communications/Connectivity Adaptation"
License: LGPLv2
URL: http://github.com/lpotter/connectionagent
Description: |
Connection Agent provides multi user access to connman's User Agent.
It also provides autoconnecting features.
Sources:
- "%{name}-%{version}.tar.bz2"
PkgConfigBR:
- QtCore
- QtDBus
- connman-qt4
- qofono-qt
- QtNetwork
Configure: none
Builder: qmake
NoFiles: true
SubPackages:
- Name: declarative
Summary: Declarative plugin for connection agent.
Group: Development/Tools
Description: This package contains the declarative plugin for connection agent.
Requires:
- connectionagent-qt5
Files:
- "%{_libdir}/qt4/imports/com/jolla/connection/*"
- Name: test
Summary: Tests for connection agent.
Group: Development/Tools
Description: This package contains the tests for connection agent.
Requires:
- connectionagent-qt5
Files:
- "/opt/sdk/bin/testqml"
- "/opt/sdk/share/applications/testqml.desktop"
- "/opt/sdk/share/testqml/*"
- "%{_prefix}/opt/tests/libqofono/*"
......@@ -22,7 +22,7 @@
#include <QtTest>
#include <QProcess>
#include "../../../connd/qconnectionmanager.h"
#include "../../../connd/qconnectionagent.h"
#include <networkmanager.h>
#include <networktechnology.h>
......@@ -32,10 +32,10 @@
class Tst_connectionagent : public QObject
{
Q_OBJECT
public:
Tst_connectionagent();
private Q_SLOTS:
void tst_networkInstance();
void tst_restartconnman();
......@@ -57,7 +57,7 @@ void Tst_connectionagent::tst_networkInstance()
{
NetworkManager *netman = NetworkManagerFactory::createInstance();
QString currentState = netman->state();
QConnectionManager::instance();
QConnectionAgent::instance();
QVERIFY(currentState == netman->state());
}
......@@ -67,11 +67,11 @@ void Tst_connectionagent::tst_restartconnman()
void Tst_connectionagent::tst_onUserInputRequested()
{
QSignalSpy spy(&QConnectionManager::instance(), SIGNAL(userInputRequested(QString,QVariantMap)));
QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(userInputRequested(QString,QVariantMap)));
QVariantMap map;
map.insert("test",true);
QConnectionManager::instance().onUserInputRequested(QLatin1String("test_path"), map);
QConnectionAgent::instance().onUserInputRequested(QLatin1String("test_path"), map);
QCOMPARE(spy.count(),1);
QList<QVariant> arguments;
arguments = spy.takeFirst();
......@@ -83,15 +83,15 @@ void Tst_connectionagent::tst_onUserInputRequested()
void Tst_connectionagent::tst_onUserInputCanceled()
{
QSignalSpy spy(&QConnectionManager::instance(), SIGNAL(userInputCanceled()));
QConnectionManager::instance().onUserInputCanceled();
QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(userInputCanceled()));
QConnectionAgent::instance().onUserInputCanceled();
QCOMPARE(spy.count(),1);
}
void Tst_connectionagent::tst_onErrorReported()
{
QSignalSpy spy(&QConnectionManager::instance(), SIGNAL(errorReported(QString,QString)));
QConnectionManager::instance().onErrorReported("test_path","Test error");
QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(errorReported(QString,QString)));
QConnectionAgent::instance().onErrorReported("test_path","Test error");
QCOMPARE(spy.count(),1);
QList<QVariant> arguments;
......@@ -99,7 +99,7 @@ void Tst_connectionagent::tst_onErrorReported()
QCOMPARE(arguments.at(0).toString(), QString("test_path"));
QCOMPARE(arguments.at(1).toString(), QString("Test error"));
QConnectionManager::instance().connectToType("test");
QConnectionAgent::instance().connectToType("test");
QCOMPARE(spy.count(),1);
arguments = spy.takeFirst();
QCOMPARE(arguments.at(0).toString(), QString(""));
......@@ -116,8 +116,8 @@ void Tst_connectionagent::tst_onConnectionRequest()
service->requestDisconnect();
// service->requestConnect();
}
QSignalSpy spy(&QConnectionManager::instance(), SIGNAL(connectionRequest()));
QConnectionManager::instance().onConnectionRequest();
QSignalSpy spy(&QConnectionAgent::instance(), SIGNAL(connectionRequest()));
QConnectionAgent::instance().onConnectionRequest();
if (currentState == "online")
QCOMPARE(spy.count(),0);
......
......@@ -10,12 +10,12 @@ TEMPLATE = app
DEFINES += SRCDIR=\\\"$$PWD/\\\"
SOURCES += tst_connectionagent.cpp \
../../../connd/qconnectionmanager.cpp \
../../../connd/qconnectionagent.cpp \
../../../connd/connadaptor.cpp \
../../../connd/wakeupwatcher.cpp
HEADERS += \
../../../connd/qconnectionmanager.h \
../../../connd/qconnectionagent.h \
../../../connd/connadaptor.h \
../../../connd/wakeupwatcher.h
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment