|
|
|
@ -18,21 +18,16 @@
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#include <sys/time.h>
|
|
|
|
|
#ifdef QT4
|
|
|
|
|
#include <Qt/qsocketnotifier.h>
|
|
|
|
|
#include <Qt/qobject.h>
|
|
|
|
|
#include <Qt/qtimer.h>
|
|
|
|
|
#else
|
|
|
|
|
#include <qsocketnotifier.h>
|
|
|
|
|
#include <qobject.h>
|
|
|
|
|
#include <qtimer.h>
|
|
|
|
|
#endif
|
|
|
|
|
#include <tqsocketnotifier.h>
|
|
|
|
|
#include <tqobject.h>
|
|
|
|
|
#include <tqtimer.h>
|
|
|
|
|
#include <avahi-common/timeval.h>
|
|
|
|
|
#include "qt-watch.h"
|
|
|
|
|
|
|
|
|
|
class AvahiWatch : public QObject
|
|
|
|
|
class AvahiWatch : public TQObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
TQ_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
AvahiWatch(int fd, AvahiWatchEvent event, AvahiWatchCallback callback, void* userdata);
|
|
|
|
|
~AvahiWatch() {}
|
|
|
|
@ -44,8 +39,8 @@ private slots:
|
|
|
|
|
void gotOut();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QSocketNotifier* m_in;
|
|
|
|
|
QSocketNotifier* m_out;
|
|
|
|
|
TQSocketNotifier* m_in;
|
|
|
|
|
TQSocketNotifier* m_out;
|
|
|
|
|
//FIXME: ERR and HUP?
|
|
|
|
|
AvahiWatchCallback m_callback;
|
|
|
|
|
AvahiWatchEvent m_lastEvent;
|
|
|
|
@ -54,9 +49,10 @@ private:
|
|
|
|
|
bool m_incallback;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class AvahiTimeout : public QObject
|
|
|
|
|
class AvahiTimeout : public TQObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
TQ_OBJECT
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
AvahiTimeout(const struct timeval* tv, AvahiTimeoutCallback callback, void* userdata);
|
|
|
|
@ -67,7 +63,7 @@ private slots:
|
|
|
|
|
void timeout();
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QTimer m_timer;
|
|
|
|
|
TQTimer m_timer;
|
|
|
|
|
AvahiTimeoutCallback m_callback;
|
|
|
|
|
void* m_userdata;
|
|
|
|
|
};
|
|
|
|
@ -101,22 +97,19 @@ void AvahiWatch::setWatchedEvents(AvahiWatchEvent event)
|
|
|
|
|
if (!(event & AVAHI_WATCH_IN)) { delete m_in; m_in=0; }
|
|
|
|
|
if (!(event & AVAHI_WATCH_OUT)) { delete m_out; m_out=0; }
|
|
|
|
|
if (event & AVAHI_WATCH_IN) {
|
|
|
|
|
m_in = new QSocketNotifier(m_fd,QSocketNotifier::Read, this);
|
|
|
|
|
connect(m_in,SIGNAL(activated(int)),SLOT(gotIn()));
|
|
|
|
|
m_in = new TQSocketNotifier(m_fd,TQSocketNotifier::Read, this);
|
|
|
|
|
connect(m_in,TQT_SIGNAL(activated(int)),TQT_SLOT(gotIn()));
|
|
|
|
|
}
|
|
|
|
|
if (event & AVAHI_WATCH_OUT) {
|
|
|
|
|
m_out = new QSocketNotifier(m_fd,QSocketNotifier::Write, this);
|
|
|
|
|
connect(m_out,SIGNAL(activated(int)),SLOT(gotOut()));
|
|
|
|
|
m_out = new TQSocketNotifier(m_fd,TQSocketNotifier::Write, this);
|
|
|
|
|
connect(m_out,TQT_SIGNAL(activated(int)),TQT_SLOT(gotOut()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AvahiTimeout::AvahiTimeout(const struct timeval* tv, AvahiTimeoutCallback callback, void *userdata) :
|
|
|
|
|
m_callback(callback), m_userdata(userdata)
|
|
|
|
|
{
|
|
|
|
|
connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeout()));
|
|
|
|
|
#ifdef QT4
|
|
|
|
|
m_timer.setSingleShot(true);
|
|
|
|
|
#endif
|
|
|
|
|
connect(&m_timer, TQT_SIGNAL(timeout()), this, TQT_SLOT(timeout()));
|
|
|
|
|
update(tv);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -125,11 +118,7 @@ void AvahiTimeout::update(const struct timeval *tv)
|
|
|
|
|
m_timer.stop();
|
|
|
|
|
if (tv) {
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -191,8 +180,4 @@ const AvahiPoll* avahi_qt_poll_get(void)
|
|
|
|
|
return &qt_poll;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef QT4
|
|
|
|
|
#include "qt-watch.moc4"
|
|
|
|
|
#else
|
|
|
|
|
#include "qt-watch.moc3"
|
|
|
|
|
#endif
|
|
|
|
|