Skip to content

Commit

Permalink
[connectionagent] use a timer to see if we are really online.
Browse files Browse the repository at this point in the history
If after 12 seconds from 'ready' state, we are not online,
send error to ui about it.
  • Loading branch information
Lorn Potter committed Oct 29, 2013
1 parent 61c7847 commit 547029f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 16 additions & 1 deletion connd/qconnectionmanager.cpp
Expand Up @@ -123,6 +123,11 @@ QConnectionManager::QConnectionManager(QObject *parent) :
connmanAvailable = QDBusConnection::systemBus().interface()->isServiceRegistered("net.connman");
if (connmanAvailable)
setup();
goodConnectTimer = new QTimer(this);
goodConnectTimer->setSingleShot(true);
goodConnectTimer->setInterval(12 * 1000);
connect(goodConnectTimer,SIGNAL(timeout()),this,SLOT(connectionTimeout()));

}

QConnectionManager::~QConnectionManager()
Expand Down Expand Up @@ -230,7 +235,9 @@ void QConnectionManager::serviceStateChanged(const QString &state)
Q_EMIT errorReported(service->path(), "Connection failure: "+ service->name());
autoConnect();
}

if (state == "ready") {
goodConnectTimer->start();
}
//auto migrate
if (service->path() == serviceInProgress
&& state == "online") {
Expand Down Expand Up @@ -737,3 +744,11 @@ void QConnectionManager::displayStateChanged(const QString &state)
void QConnectionManager::sleepStateChanged(bool on)
{
}

void QConnectionManager::connectionTimeout()
{
if (netman->state() != "online") {
//bad
errorReported(serviceInProgress,"limited connection");
}
}
5 changes: 5 additions & 0 deletions connd/qconnectionmanager.h
Expand Up @@ -35,6 +35,8 @@ class NetworkService;
class QOfonoConnectionContext;
class NetworkTechnology;
class WakeupWatcher;
class QTimer;

class QConnectionManager : public QObject
{
Q_OBJECT
Expand Down Expand Up @@ -110,6 +112,7 @@ public Q_SLOTS:
bool tetheringEnabled;
bool flightModeSuppression;
WakeupWatcher *mceWatch;
QTimer *goodConnectTimer;
private slots:
void onScanFinished();
void updateServicesMap();
Expand Down Expand Up @@ -142,6 +145,8 @@ private slots:
void displayStateChanged(const QString &);
void sleepStateChanged(bool);

void connectionTimeout();

};

#endif // QCONNECTIONMANAGER_H

0 comments on commit 547029f

Please sign in to comment.