Skip to content

Commit

Permalink
[connectionagent] dont disconnect if online. fixes JB#6946
Browse files Browse the repository at this point in the history
add test
  • Loading branch information
Lorn Potter committed Jun 6, 2013
1 parent 424c749 commit c3fdc19
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 3 deletions.
9 changes: 6 additions & 3 deletions connd/qconnectionmanager.cpp
Expand Up @@ -57,7 +57,8 @@ QConnectionManager::QConnectionManager(QObject *parent) :
qDebug() << Q_FUNC_INFO << netman->state();

// let me control autoconnect
netman->setSessionMode(true);
if (netman->state() != "online")
netman->setSessionMode(true);

connectionAdaptor = new ConnAdaptor(this);
QDBusConnection dbus = QDBusConnection::sessionBus();
Expand Down Expand Up @@ -104,13 +105,14 @@ QConnectionManager::QConnectionManager(QObject *parent) :
connmanConf.close();
}
if (techPreferenceList.isEmpty())
techPreferenceList << "wifi" << "bluetooth" << "cellular";
techPreferenceList << "ethernet" << "wifi" << "bluetooth" << "cellular";

updateServicesMap();

QSettings confFile;
confFile.beginGroup("Connectionagent");
if (confFile.value("connected").toBool()) {
if (confFile.value("connected", true).toBool()
&& netman->state() != "online") {
autoConnect();
}

Expand Down Expand Up @@ -226,6 +228,7 @@ void QConnectionManager::serviceStateChanged(const QString &state)
service->requestDisconnect();
service->remove(); //reset this service
okToConnect = true;
Q_EMIT onErrorReported("Connection failure: "+ service->name());
}

//auto migrate
Expand Down
1 change: 1 addition & 0 deletions test/auto/auto.pro
Expand Up @@ -3,4 +3,5 @@ TEMPLATE = subdirs
TEMPLATE += ordered

SUBDIRS += tst_connectionagent_plugin
SUBDIRS += tst_connectionagent

57 changes: 57 additions & 0 deletions test/auto/tst_connectionagent/tst_connectionagent.cpp
@@ -0,0 +1,57 @@
/****************************************************************************
**
** Copyright (C) 2013 Jolla Ltd
** Contact: lorn.potter@jollamobile.com
**
**
** $QT_BEGIN_LICENSE:LGPL$
**
** GNU Lesser General Public License Usage
** Alternatively, 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 <QString>
#include <QtTest>

#include "../../../connd/qconnectionmanager.h"

#include <networkmanager.h>
#include <networktechnology.h>
#include <networkservice.h>


class Tst_connectionagent : public QObject
{
Q_OBJECT

public:
Tst_connectionagent();

private Q_SLOTS:
void testCase1();
};

Tst_connectionagent::Tst_connectionagent()
{
NetworkManager *netman = NetworkManagerFactory::createInstance();
QString currentState = netman->state();
QConnectionManager::instance();
QVERIFY(currentState == netman->state());
}

void Tst_connectionagent::testCase1()
{
QVERIFY2(true, "Failure");
}

QTEST_APPLESS_MAIN(Tst_connectionagent)

#include "tst_connectionagent.moc"
33 changes: 33 additions & 0 deletions test/auto/tst_connectionagent/tst_connectionagent.pro
@@ -0,0 +1,33 @@
QT += testlib dbus
QT -= gui

TARGET = tst_connectionagent
CONFIG += console
CONFIG -= app_bundle

TEMPLATE = app

DEFINES += SRCDIR=\\\"$$PWD/\\\"

SOURCES += tst_connectionagent.cpp \
../../../connd/qconnectionmanager.cpp \
../../../connd/connadaptor.cpp

HEADERS += \
../../../connd/qconnectionmanager.h \
../../../connd/connadaptor.h

INCLUDEPATH += ../../../connd

equals(QT_MAJOR_VERSION, 4): {
PKGCONFIG += connman-qt4
LIBS += -lconnman-qt4
INCLUDEPATH += /usr/include/connman-qt
}

equals(QT_MAJOR_VERSION, 5): {
PKGCONFIG += connman-qt5
LIBS += -lconnman-qt5
INCLUDEPATH += /usr/include/connman-qt5
}

0 comments on commit c3fdc19

Please sign in to comment.