Skip to content

Commit

Permalink
make sure things get initialized properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorn Potter committed Sep 20, 2013
1 parent 0de63e5 commit 6986111
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
27 changes: 17 additions & 10 deletions connd/qconnectionmanager.cpp
Expand Up @@ -54,7 +54,7 @@ QConnectionManager::QConnectionManager(QObject *parent) :
currentNotification(0),
askForRoaming(0),
isEthernet(0),
connmanPropertiesAvailable(0),
connmanAvailable(0),
handoverInProgress(0)
{
qDebug() << Q_FUNC_INFO;
Expand Down Expand Up @@ -108,7 +108,9 @@ QConnectionManager::QConnectionManager(QObject *parent) :
//ethernet,bluetooth,cellular,wifi is default
techPreferenceList << "bluetooth" << "wifi" << "cellular" << "ethernet" ;

setup();
connmanAvailable = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman");
if (connmanAvailable)
setup();
}

QConnectionManager::~QConnectionManager()
Expand Down Expand Up @@ -202,8 +204,11 @@ void QConnectionManager::serviceStateChanged(const QString &state)
{
NetworkService *service = qobject_cast<NetworkService *>(sender());

qDebug() << Q_FUNC_INFO << state;

if (currentNetworkState == "disconnect") {
ua->sendConnectReply("Clear");
lastConnectedService = service->path();
}
if (state == "failure") {
service->requestDisconnect();
Expand Down Expand Up @@ -257,6 +262,8 @@ void QConnectionManager::serviceStateChanged(const QString &state)

bool QConnectionManager::autoConnect()
{
qDebug() << Q_FUNC_INFO << "handoverInProgress" << handoverInProgress;

QString selectedService;
if (handoverInProgress)
return false;
Expand Down Expand Up @@ -347,6 +354,8 @@ void QConnectionManager::connectToType(const QString &type)

void QConnectionManager::connectToNetworkService(const QString &servicePath)
{
qDebug() << Q_FUNC_INFO;

if (!servicesMap.contains(servicePath))
return;

Expand Down Expand Up @@ -409,7 +418,7 @@ void QConnectionManager::servicesError(const QString &errorMessage)

QString QConnectionManager::findBestConnectableService()
{

qDebug() << Q_FUNC_INFO;
for (int i = 0; i < orderedServicesList.count(); i++) {

QString path = orderedServicesList.at(i);
Expand Down Expand Up @@ -444,6 +453,7 @@ QString QConnectionManager::findBestConnectableService()

void QConnectionManager::connectionHandover(const QString &oldService, const QString &newService)
{
qDebug() << Q_FUNC_INFO;
bool isOnline = false;
bool ok = true;
if (newService.isEmpty())
Expand Down Expand Up @@ -523,8 +533,9 @@ void QConnectionManager::setAskRoaming(bool value)

void QConnectionManager::connmanAvailabilityChanged(bool b)
{
connmanPropertiesAvailable = b;
connmanAvailable = b;
if (b) {
setup();
connect(netman,SIGNAL(servicesChanged()),this,SLOT(setup()));
currentNetworkState = netman->state();
} else {
Expand All @@ -541,13 +552,9 @@ void QConnectionManager::emitConnectionState()

void QConnectionManager::setup()
{
qDebug() << Q_FUNC_INFO;

if (!connmanPropertiesAvailable) {
connmanPropertiesAvailable = true;

// let me control autoconnect
// if (!netman->sessionMode())
// netman->setSessionMode(true);
if (connmanAvailable) {

if (netman->servicesList("ethernet").count() > 0)
isEthernet = true;
Expand Down
3 changes: 2 additions & 1 deletion connd/qconnectionmanager.h
Expand Up @@ -98,8 +98,9 @@ public Q_SLOTS:
QStringList techPreferenceList;
bool askForRoaming;
bool isEthernet;
bool connmanPropertiesAvailable;
bool connmanAvailable;
bool handoverInProgress;
QString lastConnectedService;


private slots:
Expand Down

0 comments on commit 6986111

Please sign in to comment.