#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 <ntqmetaobject.h>#include <ntqapplication.h>#include <private/qucomextra_p.h>#include <ntqobjectdefs.h>#include <ntqsignalslotimp.h>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 |
| 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.
00052 { 00053 Q_ASSERT(timeout); 00054 Q_ASSERT(data); 00055 00056 // tqDebug("addTimeout %d", dbus_timeout_get_interval(timeout)); 00057 00058 TQT_DBusConnectionPrivate *d = static_cast<TQT_DBusConnectionPrivate *>(data); 00059 00060 if (!dbus_timeout_get_enabled(timeout)) 00061 return true; 00062 00063 if (!tqApp) { 00064 d->pendingTimeouts.append(timeout); 00065 return true; 00066 } 00067 int timerId = d->startTimer(dbus_timeout_get_interval(timeout)); 00068 if (!timerId) 00069 return false; 00070 00071 d->timeouts[timerId] = timeout; 00072 return true; 00073 }
| 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.
00117 { 00118 Q_ASSERT(watch); 00119 Q_ASSERT(data); 00120 00121 TQT_DBusConnectionPrivate *d = static_cast<TQT_DBusConnectionPrivate *>(data); 00122 00123 int flags = dbus_watch_get_flags(watch); 00124 int fd = dbus_watch_get_unix_fd(watch); 00125 00126 TQT_DBusConnectionPrivate::Watcher watcher; 00127 if (flags & DBUS_WATCH_READABLE) { 00128 bool enabled = dbus_watch_get_enabled(watch); 00129 //tqDebug("addReadWatch %d %s", fd, (enabled ? "enabled" : "disabled")); 00130 watcher.watch = watch; 00131 if (tqApp) { 00132 watcher.read = new TQSocketNotifier(fd, TQSocketNotifier::Read, d); 00133 if (!enabled) watcher.read->setEnabled(false); 00134 d->connect(watcher.read, TQT_SIGNAL(activated(int)), TQT_SLOT(socketRead(int))); 00135 } 00136 } 00137 if (flags & DBUS_WATCH_WRITABLE) { 00138 bool enabled = dbus_watch_get_enabled(watch); 00139 //tqDebug("addWriteWatch %d %s", fd, (enabled ? "enabled" : "disabled")); 00140 watcher.watch = watch; 00141 if (tqApp) { 00142 watcher.write = new TQSocketNotifier(fd, TQSocketNotifier::Write, d); 00143 if (!enabled) watcher.write->setEnabled(false); 00144 d->connect(watcher.write, TQT_SIGNAL(activated(int)), TQT_SLOT(socketWrite(int))); 00145 } 00146 } 00147 // FIXME-QT4 d->watchers.insertMulti(fd, watcher); 00148 TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd); 00149 if (it == d->watchers.end()) 00150 { 00151 it = d->watchers.insert(fd, TQT_DBusConnectionPrivate::WatcherList()); 00152 } 00153 it.data().append(watcher); 00154 00155 return true; 00156 }
| static void qDBusNewConnection | ( | DBusServer * | server, | |
| DBusConnection * | c, | |||
| void * | data | |||
| ) | [static] |
Definition at line 234 of file tqdbusintegrator.cpp.
00235 { 00236 Q_ASSERT(data); Q_ASSERT(server); Q_ASSERT(c); 00237 00238 tqDebug("SERVER: GOT A NEW CONNECTION"); // TODO 00239 }
| static void qDBusRemoveTimeout | ( | DBusTimeout * | timeout, | |
| void * | data | |||
| ) | [static] |
Definition at line 75 of file tqdbusintegrator.cpp.
References TQT_DBusConnectionPrivate::pendingTimeouts, and TQT_DBusConnectionPrivate::timeouts.
00076 { 00077 Q_ASSERT(timeout); 00078 Q_ASSERT(data); 00079 00080 // tqDebug("removeTimeout"); 00081 00082 TQT_DBusConnectionPrivate *d = static_cast<TQT_DBusConnectionPrivate *>(data); 00083 for (TQValueList<DBusTimeout*>::iterator it = d->pendingTimeouts.begin(); 00084 it != d->pendingTimeouts.end();) { 00085 if ((*it) == timeout) { 00086 it = d->pendingTimeouts.erase(it); 00087 } 00088 else 00089 ++it; 00090 } 00091 00092 TQT_DBusConnectionPrivate::TimeoutHash::iterator it = d->timeouts.begin(); 00093 while (it != d->timeouts.end()) { 00094 if (it.data() == timeout) { 00095 d->killTimer(it.key()); 00096 TQT_DBusConnectionPrivate::TimeoutHash::iterator copyIt = it; 00097 ++it; 00098 d->timeouts.erase(copyIt); 00099 } else { 00100 ++it; 00101 } 00102 } 00103 }
| static void qDBusRemoveWatch | ( | DBusWatch * | watch, | |
| void * | data | |||
| ) | [static] |
Definition at line 158 of file tqdbusintegrator.cpp.
References TQT_DBusConnectionPrivate::removedWatches, and TQT_DBusConnectionPrivate::watchers.
00159 { 00160 Q_ASSERT(watch); 00161 Q_ASSERT(data); 00162 00163 //tqDebug("remove watch"); 00164 00165 TQT_DBusConnectionPrivate *d = static_cast<TQT_DBusConnectionPrivate *>(data); 00166 int fd = dbus_watch_get_unix_fd(watch); 00167 00168 TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd); 00169 if (it != d->watchers.end()) 00170 { 00171 TQT_DBusConnectionPrivate::WatcherList& list = *it; 00172 for (TQT_DBusConnectionPrivate::WatcherList::iterator wit = list.begin(); 00173 wit != list.end(); ++wit) 00174 { 00175 if ((*wit).watch == watch) 00176 { 00177 // migth be called from a function triggered by a socket listener 00178 // so just disconnect them and schedule their delayed deletion. 00179 00180 d->removedWatches.append(*wit); 00181 if ((*wit).read) 00182 { 00183 (*wit).read->disconnect(d); 00184 (*wit).read = 0; 00185 } 00186 if ((*wit).write) 00187 { 00188 (*wit).write->disconnect(d); 00189 (*wit).write = 0; 00190 } 00191 (*wit).watch = 0; 00192 } 00193 } 00194 } 00195 00196 if (d->removedWatches.count() > 0) 00197 TQTimer::singleShot(0, d, TQT_SLOT(purgeRemovedWatches())); 00198 }
| 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.
00599 { 00600 //tqDebug("Pending Call Result received"); 00601 TQT_DBusConnectionPrivate* d = reinterpret_cast<TQT_DBusConnectionPrivate*>(user_data); 00602 TQT_DBusConnectionPrivate::PendingCallMap::iterator it = d->pendingCalls.find(pending); 00603 00604 DBusMessage *dbusReply = dbus_pending_call_steal_reply(pending); 00605 00606 dbus_set_error_from_message(&d->error, dbusReply); 00607 d->handleError(); 00608 00609 if (it != d->pendingCalls.end()) 00610 { 00611 TQT_DBusMessage reply = TQT_DBusMessage::fromDBusMessage(dbusReply); 00612 00613 TQT_DBusResultInfo dbusResult; 00614 dbusResult.message = reply; 00615 dbusResult.receiver = it.data()->receiver; 00616 dbusResult.method = it.data()->method.data(); 00617 d->m_resultEmissionQueue.append(dbusResult); 00618 d->newMethodInResultEmissionQueue(); 00619 } 00620 00621 dbus_message_unref(dbusReply); 00622 dbus_pending_call_unref(pending); 00623 delete it.data(); 00624 00625 d->pendingCalls.erase(it); 00626 }
| 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.
00243 { 00244 Q_ASSERT(data); 00245 Q_UNUSED(connection); 00246 00247 TQT_DBusConnectionPrivate *d = static_cast<TQT_DBusConnectionPrivate *>(data); 00248 if (d->mode == TQT_DBusConnectionPrivate::InvalidMode) 00249 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 00250 00251 int msgType = dbus_message_get_type(message); 00252 bool handled = false; 00253 00254 //TQT_DBusMessage amsg = TQT_DBusMessage::fromDBusMessage(message); 00255 //tqDebug() << "got message: " << dbus_message_get_type(message) << amsg; 00256 00257 if (msgType == DBUS_MESSAGE_TYPE_SIGNAL) { 00258 handled = d->handleSignal(message); 00259 } else if (msgType == DBUS_MESSAGE_TYPE_METHOD_CALL) { 00260 handled = d->handleObjectCall(message); 00261 } 00262 00263 return handled ? DBUS_HANDLER_RESULT_HANDLED : 00264 DBUS_HANDLER_RESULT_NOT_YET_HANDLED; 00265 }
| static void qDBusToggleTimeout | ( | DBusTimeout * | timeout, | |
| void * | data | |||
| ) | [static] |
Definition at line 105 of file tqdbusintegrator.cpp.
References qDBusAddTimeout(), and qDBusRemoveTimeout().
00106 { 00107 Q_ASSERT(timeout); 00108 Q_ASSERT(data); 00109 00110 //tqDebug("ToggleTimeout"); 00111 00112 qDBusRemoveTimeout(timeout, data); 00113 qDBusAddTimeout(timeout, data); 00114 }
| static void qDBusToggleWatch | ( | DBusWatch * | watch, | |
| void * | data | |||
| ) | [static] |
Definition at line 200 of file tqdbusintegrator.cpp.
References TQT_DBusConnectionPrivate::watchers.
00201 { 00202 Q_ASSERT(watch); 00203 Q_ASSERT(data); 00204 00205 //tqDebug("toggle watch"); 00206 00207 TQT_DBusConnectionPrivate *d = static_cast<TQT_DBusConnectionPrivate *>(data); 00208 int fd = dbus_watch_get_unix_fd(watch); 00209 00210 TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd); 00211 if (it != d->watchers.end()) { 00212 TQT_DBusConnectionPrivate::WatcherList& list = *it; 00213 for (TQT_DBusConnectionPrivate::WatcherList::iterator wit = list.begin(); wit != list.end(); 00214 ++wit) 00215 { 00216 if ((*wit).watch == watch) { 00217 bool enabled = dbus_watch_get_enabled(watch); 00218 int flags = dbus_watch_get_flags(watch); 00219 00220 // tqDebug("toggle watch %d to %d (write: %d, read: %d)", 00221 // dbus_watch_get_unix_fd(watch), enabled, 00222 // flags & DBUS_WATCH_WRITABLE, flags & DBUS_WATCH_READABLE); 00223 00224 if (flags & DBUS_WATCH_READABLE && (*wit).read) 00225 (*wit).read->setEnabled(enabled); 00226 if (flags & DBUS_WATCH_WRITABLE && (*wit).write) 00227 (*wit).write->setEnabled(enabled); 00228 return; 00229 } 00230 } 00231 } 00232 }
dbus_int32_t server_slot = -1 [static] |
Definition at line 528 of file tqdbusintegrator.cpp.
1.6.3