X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-qt%2Fqt-watch.cpp;h=5b49845e5f278da6c802f83e1c5e92085d2ee1c0;hb=4ecb5cd013710a7871f58b68fa118b7f1a58ac8d;hp=627d3d98daabf168ffafd7f7ec044bb93282ceec;hpb=ee4ab29edd9a7257962444d001283d4ae69c5fbb;p=catta diff --git a/avahi-qt/qt-watch.cpp b/avahi-qt/qt-watch.cpp index 627d3d9..5b49845 100644 --- a/avahi-qt/qt-watch.cpp +++ b/avahi-qt/qt-watch.cpp @@ -29,6 +29,7 @@ #include #include #endif +#include #include "qt-watch.h" class AvahiWatch : public QObject @@ -124,17 +125,14 @@ AvahiTimeout::AvahiTimeout(const struct timeval* tv, AvahiTimeoutCallback callba void AvahiTimeout::update(const struct timeval *tv) { m_timer.stop(); - if (tv) - if (tv->tv_sec==0 && tv->tv_usec==0) timeout(); // absolute timeval they say ... - else { - struct timeval now; - gettimeofday(&now, 0); + if (tv) { + AvahiUsec u = avahi_age(tv)/1000; #ifdef QT4 - m_timer.start((tv->tv_sec-now.tv_sec)*1000+(tv->tv_usec-now.tv_usec)/1000); + m_timer.start( (u>0) ? 0 : -u); #else - m_timer.start((tv->tv_sec-now.tv_sec)*1000+(tv->tv_usec-now.tv_usec)/1000,true); + m_timer.start( (u>0) ? 0 : -u,true); #endif - } + } } void AvahiTimeout::timeout()