summaryrefslogtreecommitdiff
path: root/src/reconnecttimer.cpp
diff options
context:
space:
mode:
authorJavier S. Pedro <dev.git@javispedro.com>2014-09-06 03:25:38 +0200
committerJavier S. Pedro <dev.git@javispedro.com>2014-09-06 03:25:38 +0200
commited40a7f1cbc1da5ae21c58882df241fc0071c2f7 (patch)
treea3e34febb658c4cc5b631577d685361ab489678a /src/reconnecttimer.cpp
parent643db0927177037646b61cc4af21b9af1428b0e4 (diff)
downloadsalmeta-ed40a7f1cbc1da5ae21c58882df241fc0071c2f7.tar.gz
salmeta-ed40a7f1cbc1da5ae21c58882df241fc0071c2f7.zip
adding initial UI to select device
Diffstat (limited to 'src/reconnecttimer.cpp')
-rw-r--r--src/reconnecttimer.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/reconnecttimer.cpp b/src/reconnecttimer.cpp
index eaf6cbb..a58a13e 100644
--- a/src/reconnecttimer.cpp
+++ b/src/reconnecttimer.cpp
@@ -15,33 +15,33 @@ ReconnectTimer::ReconnectTimer(QObject *parent)
: QObject(parent),
_iphb(iphb_open(0)),
_notifier(new QSocketNotifier(iphb_get_fd(_iphb), QSocketNotifier::Read, this)),
- _active(false)
+ _active(false),
+ _counter(0)
{
connect(_notifier, &QSocketNotifier::activated, this, &ReconnectTimer::handleIphbActivity);
}
ReconnectTimer::~ReconnectTimer()
{
- iphb_close(_iphb);
+ _active = false;
+ _iphb = iphb_close(_iphb);
}
-void ReconnectTimer::start()
+void ReconnectTimer::scheduleNextAttempt()
{
_active = true;
- _counter = 0;
- setupWait();
+
+ time_t res = iphb_wait2(_iphb, wait_times[_counter] / 2, wait_times[_counter], 0, 0);
+
+ if (res == -1) {
+ qErrnoWarning("Failed to iphb_wait");
+ }
}
void ReconnectTimer::stop()
{
_active = false;
_counter = 0;
- iphb_wait(_iphb, 0, 0, 0);
-}
-
-void ReconnectTimer::setupWait()
-{
- iphb_wait(_iphb, wait_times[_counter] / 2, wait_times[_counter], 0);
}
void ReconnectTimer::handleIphbActivity()
@@ -55,10 +55,9 @@ void ReconnectTimer::handleIphbActivity()
return;
}
- emit tick();
-
+ _active = false;
if (++_counter > num_wait_times)
_counter = num_wait_times;
- setupWait();
+ emit tryReconnect();
}