]> git.meshlink.io Git - catta/blobdiff - avahi-qt/qt-watch.cpp
Update doxygen docs a little to make clearer when to use what API when modifying...
[catta] / avahi-qt / qt-watch.cpp
index 3b8ebceb1506b7949e13813f56192e54eb3467eb..5b49845e5f278da6c802f83e1c5e92085d2ee1c0 100644 (file)
@@ -29,6 +29,7 @@
 #include <qobject.h>
 #include <qtimer.h>
 #endif
+#include <avahi-common/timeval.h>
 #include "qt-watch.h"
 
 class AvahiWatch : public QObject 
@@ -115,6 +116,9 @@ AvahiTimeout::AvahiTimeout(const struct timeval* tv, AvahiTimeoutCallback callba
     m_callback(callback), m_userdata(userdata)
 {
     connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
+#ifdef QT4
+    m_timer.setSingleShot(true);
+#endif
     update(tv);
 }
 
@@ -122,9 +126,12 @@ void AvahiTimeout::update(const struct timeval *tv)
 {
     m_timer.stop();
     if (tv) {
-        struct timeval now;
-        gettimeofday(&now, 0);
-        m_timer.start((tv->tv_sec-now.tv_sec)*1000+(tv->tv_usec-now.tv_usec)/1000);
+    AvahiUsec u = avahi_age(tv)/1000;
+#ifdef QT4
+    m_timer.start( (u>0) ? 0 : -u);
+#else
+    m_timer.start( (u>0) ? 0 : -u,true);
+#endif
     }
 }