#include <tqdbusconnection_p.h>
Collaboration diagram for TQT_DBusConnectionPrivate:Definition at line 69 of file tqdbusconnection_p.h.
| typedef TQMap<TQString, TQT_DBusObjectBase*> TQT_DBusConnectionPrivate::ObjectMap |
Definition at line 144 of file tqdbusconnection_p.h.
| typedef TQMap<DBusPendingCall*, TQT_DBusPendingCall*> TQT_DBusConnectionPrivate::PendingCallMap |
Definition at line 155 of file tqdbusconnection_p.h.
| typedef TQValueList<TQT_DBusMessage> TQT_DBusConnectionPrivate::PendingMessagesForEmit |
Definition at line 158 of file tqdbusconnection_p.h.
| typedef TQMap<int, DBusTimeout*> TQT_DBusConnectionPrivate::TimeoutHash |
Definition at line 141 of file tqdbusconnection_p.h.
| typedef TQMap<int, WatcherList> TQT_DBusConnectionPrivate::WatcherHash |
Definition at line 137 of file tqdbusconnection_p.h.
| typedef TQValueList<Watcher> TQT_DBusConnectionPrivate::WatcherList |
Definition at line 135 of file tqdbusconnection_p.h.
Definition at line 111 of file tqdbusconnection_p.h.
{ InvalidMode, ServerMode, ClientMode };
| TQT_DBusConnectionPrivate::TQT_DBusConnectionPrivate | ( | TQObject * | parent = 0 |
) |
Definition at line 274 of file tqdbusintegrator.cpp.
References dispatch(), dispatcher, error, m_messageEmissionQueueTimer, m_resultEmissionQueueTimer, registerMessageMetaType(), transmitMessageEmissionQueue(), and transmitResultEmissionQueue().
: TQObject(parent), ref(1), mode(InvalidMode), connection(0), server(0), dispatcher(0), inDispatch(false) { static const int msgType = registerMessageMetaType(); Q_UNUSED(msgType); dbus_error_init(&error); dispatcher = new TQTimer(this); TQObject::connect(dispatcher, TQT_SIGNAL(timeout()), this, TQT_SLOT(dispatch())); m_resultEmissionQueueTimer = new TQTimer(this); TQObject::connect(m_resultEmissionQueueTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(transmitResultEmissionQueue())); m_messageEmissionQueueTimer = new TQTimer(this); TQObject::connect(m_messageEmissionQueueTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(transmitMessageEmissionQueue())); }
Here is the call graph for this function:| TQT_DBusConnectionPrivate::~TQT_DBusConnectionPrivate | ( | ) |
Definition at line 292 of file tqdbusintegrator.cpp.
References closeConnection(), error, and pendingCalls.
{
for (PendingCallMap::iterator it = pendingCalls.begin(); it != pendingCalls.end();)
{
PendingCallMap::iterator copyIt = it;
++it;
dbus_pending_call_cancel(copyIt.key());
dbus_pending_call_unref(copyIt.key());
delete copyIt.data();
pendingCalls.erase(copyIt);
}
if (dbus_error_is_set(&error))
dbus_error_free(&error);
closeConnection();
}
Here is the call graph for this function:| void TQT_DBusConnectionPrivate::bindToApplication | ( | ) |
Definition at line 347 of file tqdbusintegrator.cpp.
References pendingTimeouts, qDBusAddTimeout(), qDBusAddWatch(), and watchers.
{
// Yay, now that we have an application we are in business
// Re-add all watchers
WatcherHash oldWatchers = watchers;
watchers.clear();
// FIXME-QT4 TQHashIterator<int, TQT_DBusConnectionPrivate::Watcher> it(oldWatchers);
for (WatcherHash::const_iterator it = oldWatchers.begin(); it != oldWatchers.end(); ++it)
{
const WatcherList& list = *it;
for (WatcherList::const_iterator wit = list.begin(); wit != list.end(); ++wit)
{
if (!(*wit).read && !(*wit).write) {
qDBusAddWatch((*wit).watch, this);
}
}
}
// Re-add all timeouts
while (!pendingTimeouts.isEmpty()) {
qDBusAddTimeout(pendingTimeouts.first(), this);
pendingTimeouts.pop_front();
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::closeConnection | ( | ) |
Definition at line 310 of file tqdbusintegrator.cpp.
References ClientMode, connection, mode, server, and ServerMode.
{
ConnectionMode oldMode = mode;
mode = InvalidMode; // prevent reentrancy
if (oldMode == ServerMode) {
if (server) {
dbus_server_disconnect(server);
dbus_server_unref(server);
server = 0;
}
} else if (oldMode == ClientMode) {
if (connection) {
// closing shared connections is forbidden
#if 0
dbus_connection_close(connection);
// send the "close" message
while (dbus_connection_dispatch(connection) == DBUS_DISPATCH_DATA_REMAINS);
#endif
dbus_connection_unref(connection);
connection = 0;
}
}
}
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::dbusPendingCallReply | ( | const TQT_DBusMessage & | message | ) | [signal] |
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::dbusSignal | ( | const TQT_DBusMessage & | message | ) | [signal] |
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::dispatch | ( | ) | [slot] |
Definition at line 468 of file tqdbusintegrator.cpp.
References ClientMode, connection, dispatcher, inDispatch, and mode.
{
// dbus_connection_dispatch will hang if called recursively
if (inDispatch) {
printf("[dbus-1-tqt] WARNING: Attempt to call dispatch() recursively was silently ignored to prevent lockup!\n\r"); fflush(stdout);
return;
}
inDispatch = true;
if (mode == ClientMode)
{
if (dbus_connection_dispatch(connection) != DBUS_DISPATCH_DATA_REMAINS)
{
// stop dispatch timer
dispatcher->stop();
}
}
inDispatch = false;
}
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::emitPendingCallReply | ( | const TQT_DBusMessage & | message | ) |
Definition at line 342 of file tqdbusintegrator.cpp.
References dbusPendingCallReply().
{
emit dbusPendingCallReply(message);
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::flush | ( | ) |
Definition at line 660 of file tqdbusintegrator.cpp.
References connection.
{
if (!connection) return;
dbus_connection_flush(connection);
}
Here is the caller graph for this function:| bool TQT_DBusConnectionPrivate::handleError | ( | ) |
Definition at line 334 of file tqdbusintegrator.cpp.
References error, TQT_DBusError::isValid(), and lastError.
{
lastError = TQT_DBusError(&error);
if (dbus_error_is_set(&error))
dbus_error_free(&error);
return lastError.isValid();
}
Here is the call graph for this function:
Here is the caller graph for this function:| bool TQT_DBusConnectionPrivate::handleObjectCall | ( | DBusMessage * | message | ) |
Definition at line 500 of file tqdbusintegrator.cpp.
References TQT_DBusMessage::fromDBusMessage(), TQT_DBusMessage::path(), and registeredObjects.
{
TQT_DBusMessage msg = TQT_DBusMessage::fromDBusMessage(message);
ObjectMap::iterator it = registeredObjects.find(msg.path());
if (it == registeredObjects.end())
return false;
return it.data()->handleMethodCall(msg);
}
Here is the call graph for this function:
Here is the caller graph for this function:| bool TQT_DBusConnectionPrivate::handleSignal | ( | DBusMessage * | msg | ) |
Definition at line 511 of file tqdbusintegrator.cpp.
References TQT_DBusMessage::fromDBusMessage(), m_messageEmissionQueueTimer, and pendingMessages.
{
TQT_DBusMessage msg = TQT_DBusMessage::fromDBusMessage(message);
// yes, it is a single "|" below...
// FIXME-QT4
//return handleSignal(TQString(), msg) | handleSignal(msg.path(), msg);
// If dbusSignal(msg) were called here, it could easily cause a lockup as it would enter the TQt3 event loop,
// which could result in arbitrary methods being called while still inside dbus_connection_dispatch.
// Instead, I enqueue the messages here for TQt3 event loop transmission after dbus_connection_dispatch is finished.
pendingMessages.append(msg);
if (!m_messageEmissionQueueTimer->isActive()) m_messageEmissionQueueTimer->start(0, TRUE);
return true;
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::newMethodInResultEmissionQueue | ( | ) |
Definition at line 667 of file tqdbusintegrator.cpp.
References m_resultEmissionQueueTimer.
{
if (!m_resultEmissionQueueTimer->isActive()) m_resultEmissionQueueTimer->start(0, TRUE);
}
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::objectDestroyed | ( | TQObject * | object | ) | [slot] |
Definition at line 404 of file tqdbusintegrator.cpp.
References pendingCalls.
{
//tqDebug("Object destroyed");
for (PendingCallMap::iterator it = pendingCalls.begin(); it != pendingCalls.end();)
{
TQObject* receiver = (TQObject*) it.data()->receiver;
if (receiver == object || receiver == 0)
{
PendingCallMap::iterator copyIt = it;
++it;
dbus_pending_call_cancel(copyIt.key());
dbus_pending_call_unref(copyIt.key());
delete copyIt.data();
pendingCalls.erase(copyIt);
}
else
++it;
}
}
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::purgeRemovedWatches | ( | ) | [slot] |
Definition at line 425 of file tqdbusintegrator.cpp.
References removedWatches, and watchers.
{
if (removedWatches.isEmpty()) return;
WatcherList::iterator listIt = removedWatches.begin();
for (; listIt != removedWatches.end(); ++listIt)
{
delete (*listIt).read;
delete (*listIt).write;
}
removedWatches.clear();
uint count = 0;
WatcherHash::iterator it = watchers.begin();
while (it != watchers.end())
{
WatcherList& list = *it;
listIt = list.begin();
while (listIt != list.end())
{
if (!((*listIt).read) && !((*listIt).write))
{
listIt = list.erase(listIt);
++count;
}
}
if (list.isEmpty())
{
WatcherHash::iterator copyIt = it;
++it;
watchers.erase(copyIt);
}
else
++it;
}
}
| int TQT_DBusConnectionPrivate::registerMessageMetaType | ( | ) | [static] |
Definition at line 267 of file tqdbusintegrator.cpp.
{
// FIXME-QT4 int tp = messageMetaType = qRegisterMetaType<TQT_DBusMessage>("TQT_DBusMessage");
int tp = 0;
return tp;
}
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::scheduleDispatch | ( | ) | [slot] |
Definition at line 463 of file tqdbusintegrator.cpp.
References dispatcher.
{
dispatcher->start(0);
}
Here is the caller graph for this function:| int TQT_DBusConnectionPrivate::sendWithReplyAsync | ( | const TQT_DBusMessage & | message, | |
| TQObject * | receiver, | |||
| const char * | method | |||
| ) |
Definition at line 628 of file tqdbusintegrator.cpp.
References connection, TQT_DBusConnectionPrivate::TQT_DBusPendingCall::method, objectDestroyed(), TQT_DBusConnectionPrivate::TQT_DBusPendingCall::pending, pendingCalls, qDBusResultReceived(), TQT_DBusConnectionPrivate::TQT_DBusPendingCall::receiver, TQT_DBusMessage::timeout(), and TQT_DBusMessage::toDBusMessage().
{
if (!receiver || !method)
return 0;
if (!TQObject::connect(receiver, TQT_SIGNAL(destroyed(TQObject*)),
this, TQT_SLOT(objectDestroyed(TQObject*))))
return false;
DBusMessage *msg = message.toDBusMessage();
if (!msg)
return 0;
int msg_serial = 0;
DBusPendingCall *pending = 0;
if (dbus_connection_send_with_reply(connection, msg, &pending, message.timeout())) {
TQT_DBusPendingCall *pcall = new TQT_DBusPendingCall;
pcall->receiver = receiver;
pcall->method = method;
pcall->pending = pending;
pendingCalls.insert(pcall->pending, pcall);
dbus_pending_call_set_notify(pending, qDBusResultReceived, this, 0);
msg_serial = dbus_message_get_serial(msg);
}
dbus_message_unref(msg);
return msg_serial;
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::setConnection | ( | DBusConnection * | connection | ) |
Definition at line 553 of file tqdbusintegrator.cpp.
References closeConnection(), connection, error, handleError(), mode, qDBusAddTimeout(), qDBusAddWatch(), qDBusRemoveTimeout(), qDBusRemoveWatch(), qDBusSignalFilter(), qDBusToggleTimeout(), and qDBusToggleWatch().
{
if (!dbc) {
handleError();
return;
}
connection = dbc;
mode = ClientMode;
dbus_connection_set_exit_on_disconnect(connection, false);
dbus_connection_set_watch_functions(connection, qDBusAddWatch, qDBusRemoveWatch,
qDBusToggleWatch, this, 0);
dbus_connection_set_timeout_functions(connection, qDBusAddTimeout, qDBusRemoveTimeout,
qDBusToggleTimeout, this, 0);
// dbus_bus_add_match(connection, "type='signal',interface='com.trolltech.dbus.Signal'", &error);
// dbus_bus_add_match(connection, "type='signal'", &error);
dbus_bus_add_match(connection, "type='signal'", &error);
if (handleError()) {
closeConnection();
return;
}
const char *service = dbus_bus_get_unique_name(connection);
if (service) {
TQCString filter;
filter += "destination='";
filter += service;
filter += "\'";
dbus_bus_add_match(connection, filter.data(), &error);
if (handleError()) {
closeConnection();
return;
}
} else {
tqWarning("TQT_DBusConnectionPrivate::SetConnection: Unable to get unique name");
}
dbus_connection_add_filter(connection, qDBusSignalFilter, this, 0);
//tqDebug("unique name: %s", service);
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::setServer | ( | DBusServer * | server | ) |
Definition at line 530 of file tqdbusintegrator.cpp.
References handleError(), mode, qDBusAddTimeout(), qDBusAddWatch(), qDBusNewConnection(), qDBusRemoveTimeout(), qDBusRemoveWatch(), qDBusToggleTimeout(), qDBusToggleWatch(), server, and server_slot.
{
if (!server) {
handleError();
return;
}
server = s;
mode = ServerMode;
dbus_server_allocate_data_slot(&server_slot);
if (server_slot < 0)
return;
dbus_server_set_watch_functions(server, qDBusAddWatch, qDBusRemoveWatch,
qDBusToggleWatch, this, 0); // ### check return type?
dbus_server_set_timeout_functions(server, qDBusAddTimeout, qDBusRemoveTimeout,
qDBusToggleTimeout, this, 0);
dbus_server_set_new_connection_function(server, qDBusNewConnection, this, 0);
dbus_server_set_data(server, server_slot, this, 0);
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::socketRead | ( | int | fd | ) | [slot] |
Definition at line 372 of file tqdbusintegrator.cpp.
References ClientMode, mode, scheduleDispatch(), and watchers.
{
// FIXME-QT4 TQHashIterator<int, TQT_DBusConnectionPrivate::Watcher> it(watchers);
WatcherHash::const_iterator it = watchers.find(fd);
if (it != watchers.end()) {
const WatcherList& list = *it;
for (WatcherList::const_iterator wit = list.begin(); wit != list.end(); ++wit) {
if ((*wit).read && (*wit).read->isEnabled()) {
if (!dbus_watch_handle((*wit).watch, DBUS_WATCH_READABLE))
tqDebug("OUT OF MEM");
}
}
}
if (mode == ClientMode)
scheduleDispatch();
}
Here is the call graph for this function:| void TQT_DBusConnectionPrivate::socketWrite | ( | int | fd | ) | [slot] |
Definition at line 389 of file tqdbusintegrator.cpp.
References watchers.
{
// FIXME-QT4 TQHashIterator<int, TQT_DBusConnectionPrivate::Watcher> it(watchers);
WatcherHash::const_iterator it = watchers.find(fd);
if (it != watchers.end()) {
const WatcherList& list = *it;
for (WatcherList::const_iterator wit = list.begin(); wit != list.end(); ++wit) {
if ((*wit).write && (*wit).write->isEnabled()) {
if (!dbus_watch_handle((*wit).watch, DBUS_WATCH_WRITABLE))
tqDebug("OUT OF MEM");
}
}
}
}
| void TQT_DBusConnectionPrivate::timerEvent | ( | TQTimerEvent * | e | ) |
Definition at line 246 of file tqdbusconnection.cpp.
References timeouts.
{
DBusTimeout *timeout = timeouts[e->timerId()];
dbus_timeout_handle(timeout);
}
| void TQT_DBusConnectionPrivate::transmitMessageEmissionQueue | ( | ) | [private, slot] |
Definition at line 489 of file tqdbusintegrator.cpp.
References dbusSignal(), and pendingMessages.
{
TQT_DBusConnectionPrivate::PendingMessagesForEmit::iterator pmfe;
pmfe = pendingMessages.begin();
while (pmfe != pendingMessages.end()) {
TQT_DBusMessage msg = *pmfe;
pmfe = pendingMessages.remove(pmfe);
dbusSignal(msg);
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| void TQT_DBusConnectionPrivate::transmitResultEmissionQueue | ( | ) | [private, slot] |
Definition at line 672 of file tqdbusintegrator.cpp.
References dbusPendingCallReply(), emitPendingCallReply(), m_resultEmissionQueue, TQT_DBusResultInfo::message, TQT_DBusResultInfo::method, and TQT_DBusResultInfo::receiver.
{
if (!m_resultEmissionQueue.isEmpty()) {
TQT_DBusResultInfoList::Iterator it;
it = m_resultEmissionQueue.begin();
while (it != m_resultEmissionQueue.end()) {
TQT_DBusResultInfo dbusResult = (*it);
m_resultEmissionQueue.remove(it);
it = m_resultEmissionQueue.begin();
TQObject::connect(this, TQT_SIGNAL(dbusPendingCallReply(const TQT_DBusMessage&)), dbusResult.receiver, dbusResult.method.data());
emitPendingCallReply(dbusResult.message);
TQObject::disconnect(this, TQT_SIGNAL(dbusPendingCallReply(const TQT_DBusMessage&)), dbusResult.receiver, dbusResult.method.data());
}
}
}
Here is the call graph for this function:
Here is the caller graph for this function:| DBusConnection* TQT_DBusConnectionPrivate::connection |
Definition at line 116 of file tqdbusconnection_p.h.
Definition at line 119 of file tqdbusconnection_p.h.
| DBusError TQT_DBusConnectionPrivate::error |
Definition at line 108 of file tqdbusconnection_p.h.
Definition at line 161 of file tqdbusconnection_p.h.
Definition at line 109 of file tqdbusconnection_p.h.
TQTimer* TQT_DBusConnectionPrivate::m_messageEmissionQueueTimer [private] |
Definition at line 174 of file tqdbusconnection_p.h.
Definition at line 163 of file tqdbusconnection_p.h.
TQTimer* TQT_DBusConnectionPrivate::m_resultEmissionQueueTimer [private] |
Definition at line 173 of file tqdbusconnection_p.h.
int TQT_DBusConnectionPrivate::messageMetaType = 0 [static] |
Definition at line 121 of file tqdbusconnection_p.h.
Definition at line 115 of file tqdbusconnection_p.h.
Definition at line 156 of file tqdbusconnection_p.h.
Definition at line 159 of file tqdbusconnection_p.h.
| TQValueList<DBusTimeout *> TQT_DBusConnectionPrivate::pendingTimeouts |
Definition at line 147 of file tqdbusconnection_p.h.
Definition at line 114 of file tqdbusconnection_p.h.
Definition at line 145 of file tqdbusconnection_p.h.
Definition at line 136 of file tqdbusconnection_p.h.
| DBusServer* TQT_DBusConnectionPrivate::server |
Definition at line 117 of file tqdbusconnection_p.h.
Definition at line 142 of file tqdbusconnection_p.h.
Definition at line 138 of file tqdbusconnection_p.h.
1.7.1