X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-qt%2Fqt-watch.cpp;h=2426798a3c0d9ec47b0f362b3454bb23746165a3;hb=7df29f3e6c12a937e7cf7e476c428da57b6a5d16;hp=407a9055a972c8f072d17202f404e62426a62e20;hpb=520f6eb0e117cc9010a307cf1ec9237188e663ee;p=catta diff --git a/avahi-qt/qt-watch.cpp b/avahi-qt/qt-watch.cpp index 407a905..2426798 100644 --- a/avahi-qt/qt-watch.cpp +++ b/avahi-qt/qt-watch.cpp @@ -1,3 +1,5 @@ +/* $Id$ */ + /*** This file is part of avahi. @@ -113,6 +115,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); } @@ -120,9 +125,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 } } @@ -170,7 +178,7 @@ static void q_timeout_free(AvahiTimeout *t) static AvahiPoll qt_poll; -const AvahiPoll* avahi_qt_poll_get() +const AvahiPoll* avahi_qt_poll_get(void) { qt_poll.userdata=0; qt_poll.watch_new = q_watch_new; @@ -184,4 +192,8 @@ const AvahiPoll* avahi_qt_poll_get() return &qt_poll; } -#include "qt-watch.moc" +#ifdef QT4 +#include "qt-watch.moc4" +#else +#include "qt-watch.moc3" +#endif