DBus-1-TQt  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
tqdbusintegrator.cpp File Reference
#include <tqapplication.h>
#include <tqevent.h>
#include <tqmetaobject.h>
#include <tqsocketnotifier.h>
#include <tqtimer.h>
#include "tqdbusconnection_p.h"
#include "tqdbusmessage.h"
#include "tqdbusconnection_p.moc"
+ Include dependency graph for tqdbusintegrator.cpp:

Go to the source code of this file.

Functions

static dbus_bool_t qDBusAddTimeout (DBusTimeout *timeout, void *data)
static void qDBusRemoveTimeout (DBusTimeout *timeout, void *data)
static void qDBusToggleTimeout (DBusTimeout *timeout, void *data)
static dbus_bool_t qDBusAddWatch (DBusWatch *watch, void *data)
static void qDBusRemoveWatch (DBusWatch *watch, void *data)
static void qDBusToggleWatch (DBusWatch *watch, void *data)
static void qDBusNewConnection (DBusServer *server, DBusConnection *c, void *data)
static DBusHandlerResult qDBusSignalFilter (DBusConnection *connection, DBusMessage *message, void *data)
static void qDBusResultReceived (DBusPendingCall *pending, void *user_data)

Variables

static dbus_int32_t server_slot = -1

Function Documentation

static dbus_bool_t qDBusAddTimeout ( DBusTimeout *  timeout,
void *  data 
)
static

Definition at line 51 of file tqdbusintegrator.cpp.

References TQT_DBusConnectionPrivate::pendingTimeouts, and TQT_DBusConnectionPrivate::timeouts.

{
Q_ASSERT(timeout);
Q_ASSERT(data);
// tqDebug("addTimeout %d", dbus_timeout_get_interval(timeout));
if (!dbus_timeout_get_enabled(timeout))
return true;
if (!tqApp) {
d->pendingTimeouts.append(timeout);
return true;
}
int timerId = d->startTimer(dbus_timeout_get_interval(timeout));
if (!timerId)
return false;
d->timeouts[timerId] = timeout;
return true;
}

+ Here is the caller graph for this function:

static dbus_bool_t qDBusAddWatch ( DBusWatch *  watch,
void *  data 
)
static

Definition at line 116 of file tqdbusintegrator.cpp.

References TQT_DBusConnectionPrivate::Watcher::read, TQT_DBusConnectionPrivate::Watcher::watch, TQT_DBusConnectionPrivate::watchers, and TQT_DBusConnectionPrivate::Watcher::write.

{
Q_ASSERT(watch);
Q_ASSERT(data);
int flags = dbus_watch_get_flags(watch);
int fd = dbus_watch_get_unix_fd(watch);
if (flags & DBUS_WATCH_READABLE) {
bool enabled = dbus_watch_get_enabled(watch);
//tqDebug("addReadWatch %d %s", fd, (enabled ? "enabled" : "disabled"));
watcher.watch = watch;
if (tqApp) {
watcher.read = new TQSocketNotifier(fd, TQSocketNotifier::Read, d);
if (!enabled) watcher.read->setEnabled(false);
d->connect(watcher.read, TQT_SIGNAL(activated(int)), TQT_SLOT(socketRead(int)));
}
}
if (flags & DBUS_WATCH_WRITABLE) {
bool enabled = dbus_watch_get_enabled(watch);
//tqDebug("addWriteWatch %d %s", fd, (enabled ? "enabled" : "disabled"));
watcher.watch = watch;
if (tqApp) {
watcher.write = new TQSocketNotifier(fd, TQSocketNotifier::Write, d);
if (!enabled) watcher.write->setEnabled(false);
d->connect(watcher.write, TQT_SIGNAL(activated(int)), TQT_SLOT(socketWrite(int)));
}
}
// FIXME-QT4 d->watchers.insertMulti(fd, watcher);
TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd);
if (it == d->watchers.end())
{
}
it.data().append(watcher);
return true;
}

+ Here is the caller graph for this function:

static void qDBusNewConnection ( DBusServer *  server,
DBusConnection *  c,
void *  data 
)
static

Definition at line 234 of file tqdbusintegrator.cpp.

{
Q_ASSERT(data); Q_ASSERT(server); Q_ASSERT(c);
tqDebug("SERVER: GOT A NEW CONNECTION"); // TODO
}

+ Here is the caller graph for this function:

static void qDBusRemoveTimeout ( DBusTimeout *  timeout,
void *  data 
)
static

Definition at line 75 of file tqdbusintegrator.cpp.

References TQT_DBusConnectionPrivate::pendingTimeouts, and TQT_DBusConnectionPrivate::timeouts.

{
Q_ASSERT(timeout);
Q_ASSERT(data);
// tqDebug("removeTimeout");
for (TQValueList<DBusTimeout*>::iterator it = d->pendingTimeouts.begin();
it != d->pendingTimeouts.end();) {
if ((*it) == timeout) {
it = d->pendingTimeouts.erase(it);
}
else
++it;
}
TQT_DBusConnectionPrivate::TimeoutHash::iterator it = d->timeouts.begin();
while (it != d->timeouts.end()) {
if (it.data() == timeout) {
d->killTimer(it.key());
TQT_DBusConnectionPrivate::TimeoutHash::iterator copyIt = it;
++it;
d->timeouts.erase(copyIt);
} else {
++it;
}
}
}

+ Here is the caller graph for this function:

static void qDBusRemoveWatch ( DBusWatch *  watch,
void *  data 
)
static

Definition at line 158 of file tqdbusintegrator.cpp.

References TQT_DBusConnectionPrivate::removedWatches, and TQT_DBusConnectionPrivate::watchers.

{
Q_ASSERT(watch);
Q_ASSERT(data);
//tqDebug("remove watch");
int fd = dbus_watch_get_unix_fd(watch);
TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd);
if (it != d->watchers.end())
{
for (TQT_DBusConnectionPrivate::WatcherList::iterator wit = list.begin();
wit != list.end(); ++wit)
{
if ((*wit).watch == watch)
{
// migth be called from a function triggered by a socket listener
// so just disconnect them and schedule their delayed deletion.
d->removedWatches.append(*wit);
if ((*wit).read)
{
(*wit).read->disconnect(d);
(*wit).read = 0;
}
if ((*wit).write)
{
(*wit).write->disconnect(d);
(*wit).write = 0;
}
(*wit).watch = 0;
}
}
}
if (d->removedWatches.count() > 0)
TQTimer::singleShot(0, d, TQT_SLOT(purgeRemovedWatches()));
}

+ Here is the caller graph for this function:

static void qDBusResultReceived ( DBusPendingCall *  pending,
void *  user_data 
)
static

Definition at line 598 of file tqdbusintegrator.cpp.

References TQT_DBusConnectionPrivate::error, TQT_DBusMessage::fromDBusMessage(), TQT_DBusConnectionPrivate::handleError(), TQT_DBusConnectionPrivate::m_resultEmissionQueue, TQT_DBusResultInfo::message, TQT_DBusResultInfo::method, TQT_DBusConnectionPrivate::newMethodInResultEmissionQueue(), TQT_DBusConnectionPrivate::pendingCalls, and TQT_DBusResultInfo::receiver.

{
//tqDebug("Pending Call Result received");
TQT_DBusConnectionPrivate* d = reinterpret_cast<TQT_DBusConnectionPrivate*>(user_data);
TQT_DBusConnectionPrivate::PendingCallMap::iterator it = d->pendingCalls.find(pending);
DBusMessage *dbusReply = dbus_pending_call_steal_reply(pending);
dbus_set_error_from_message(&d->error, dbusReply);
if (it != d->pendingCalls.end())
{
TQT_DBusResultInfo dbusResult;
dbusResult.message = reply;
dbusResult.receiver = it.data()->receiver;
dbusResult.method = it.data()->method.data();
d->m_resultEmissionQueue.append(dbusResult);
}
dbus_message_unref(dbusReply);
dbus_pending_call_unref(pending);
delete it.data();
d->pendingCalls.erase(it);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static DBusHandlerResult qDBusSignalFilter ( DBusConnection *  connection,
DBusMessage *  message,
void *  data 
)
static

Definition at line 241 of file tqdbusintegrator.cpp.

References TQT_DBusConnectionPrivate::handleObjectCall(), TQT_DBusConnectionPrivate::handleSignal(), TQT_DBusConnectionPrivate::InvalidMode, and TQT_DBusConnectionPrivate::mode.

{
Q_ASSERT(data);
Q_UNUSED(connection);
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
int msgType = dbus_message_get_type(message);
bool handled = false;
//TQT_DBusMessage amsg = TQT_DBusMessage::fromDBusMessage(message);
//tqDebug() << "got message: " << dbus_message_get_type(message) << amsg;
if (msgType == DBUS_MESSAGE_TYPE_SIGNAL) {
handled = d->handleSignal(message);
} else if (msgType == DBUS_MESSAGE_TYPE_METHOD_CALL) {
handled = d->handleObjectCall(message);
}
return handled ? DBUS_HANDLER_RESULT_HANDLED :
DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void qDBusToggleTimeout ( DBusTimeout *  timeout,
void *  data 
)
static

Definition at line 105 of file tqdbusintegrator.cpp.

References qDBusAddTimeout(), and qDBusRemoveTimeout().

{
Q_ASSERT(timeout);
Q_ASSERT(data);
//tqDebug("ToggleTimeout");
qDBusRemoveTimeout(timeout, data);
qDBusAddTimeout(timeout, data);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void qDBusToggleWatch ( DBusWatch *  watch,
void *  data 
)
static

Definition at line 200 of file tqdbusintegrator.cpp.

References TQT_DBusConnectionPrivate::watchers.

{
Q_ASSERT(watch);
Q_ASSERT(data);
//tqDebug("toggle watch");
int fd = dbus_watch_get_unix_fd(watch);
TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd);
if (it != d->watchers.end()) {
for (TQT_DBusConnectionPrivate::WatcherList::iterator wit = list.begin(); wit != list.end();
++wit)
{
if ((*wit).watch == watch) {
bool enabled = dbus_watch_get_enabled(watch);
int flags = dbus_watch_get_flags(watch);
// tqDebug("toggle watch %d to %d (write: %d, read: %d)",
// dbus_watch_get_unix_fd(watch), enabled,
// flags & DBUS_WATCH_WRITABLE, flags & DBUS_WATCH_READABLE);
if (flags & DBUS_WATCH_READABLE && (*wit).read)
(*wit).read->setEnabled(enabled);
if (flags & DBUS_WATCH_WRITABLE && (*wit).write)
(*wit).write->setEnabled(enabled);
return;
}
}
}
}

+ Here is the caller graph for this function:

Variable Documentation

dbus_int32_t server_slot = -1
static

Definition at line 528 of file tqdbusintegrator.cpp.