DBus-1-TQt 1.0
Loading...
Searching...
No Matches
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

◆ qDBusAddTimeout()

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

Definition at line 51 of file tqdbusintegrator.cpp.

52{
53 Q_ASSERT(timeout);
54 Q_ASSERT(data);
55
56 // tqDebug("addTimeout %d", dbus_timeout_get_interval(timeout));
57
59
60 if (!dbus_timeout_get_enabled(timeout))
61 return true;
62
63 if (!tqApp) {
64 d->pendingTimeouts.append(timeout);
65 return true;
66 }
67 int timerId = d->startTimer(dbus_timeout_get_interval(timeout));
68 if (!timerId)
69 return false;
70
71 d->timeouts[timerId] = timeout;
72 return true;
73}
TQValueList< DBusTimeout * > pendingTimeouts

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

+ Here is the caller graph for this function:

◆ qDBusAddWatch()

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

Definition at line 116 of file tqdbusintegrator.cpp.

117{
118 Q_ASSERT(watch);
119 Q_ASSERT(data);
120
122
123 int flags = dbus_watch_get_flags(watch);
124 int fd = dbus_watch_get_unix_fd(watch);
125
127 if (flags & DBUS_WATCH_READABLE) {
128 bool enabled = dbus_watch_get_enabled(watch);
129 //tqDebug("addReadWatch %d %s", fd, (enabled ? "enabled" : "disabled"));
130 watcher.watch = watch;
131 if (tqApp) {
132 watcher.read = new TQSocketNotifier(fd, TQSocketNotifier::Read, d);
133 if (!enabled) watcher.read->setEnabled(false);
134 d->connect(watcher.read, TQ_SIGNAL(activated(int)), TQ_SLOT(socketRead(int)));
135 }
136 }
137 if (flags & DBUS_WATCH_WRITABLE) {
138 bool enabled = dbus_watch_get_enabled(watch);
139 //tqDebug("addWriteWatch %d %s", fd, (enabled ? "enabled" : "disabled"));
140 watcher.watch = watch;
141 if (tqApp) {
142 watcher.write = new TQSocketNotifier(fd, TQSocketNotifier::Write, d);
143 if (!enabled) watcher.write->setEnabled(false);
144 d->connect(watcher.write, TQ_SIGNAL(activated(int)), TQ_SLOT(socketWrite(int)));
145 }
146 }
147 // FIXME-QT4 d->watchers.insertMulti(fd, watcher);
148 TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd);
149 if (it == d->watchers.end())
150 {
152 }
153 it.data().append(watcher);
154
155 return true;
156}

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

+ Here is the caller graph for this function:

◆ qDBusNewConnection()

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

Definition at line 234 of file tqdbusintegrator.cpp.

235{
236 Q_ASSERT(data); Q_ASSERT(server); Q_ASSERT(c);
237
238 tqDebug("SERVER: GOT A NEW CONNECTION"); // TODO
239}
+ Here is the caller graph for this function:

◆ qDBusRemoveTimeout()

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

Definition at line 75 of file tqdbusintegrator.cpp.

76{
77 Q_ASSERT(timeout);
78 Q_ASSERT(data);
79
80 // tqDebug("removeTimeout");
81
84 it != d->pendingTimeouts.end();) {
85 if ((*it) == timeout) {
86 it = d->pendingTimeouts.erase(it);
87 }
88 else
89 ++it;
90 }
91
92 TQT_DBusConnectionPrivate::TimeoutHash::iterator it = d->timeouts.begin();
93 while (it != d->timeouts.end()) {
94 if (it.data() == timeout) {
95 d->killTimer(it.key());
96 TQT_DBusConnectionPrivate::TimeoutHash::iterator copyIt = it;
97 ++it;
98 d->timeouts.erase(copyIt);
99 } else {
100 ++it;
101 }
102 }
103}

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

+ Here is the caller graph for this function:

◆ qDBusRemoveWatch()

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

Definition at line 158 of file tqdbusintegrator.cpp.

159{
160 Q_ASSERT(watch);
161 Q_ASSERT(data);
162
163 //tqDebug("remove watch");
164
166 int fd = dbus_watch_get_unix_fd(watch);
167
168 TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd);
169 if (it != d->watchers.end())
170 {
172 for (TQT_DBusConnectionPrivate::WatcherList::iterator wit = list.begin();
173 wit != list.end(); ++wit)
174 {
175 if ((*wit).watch == watch)
176 {
177 // migth be called from a function triggered by a socket listener
178 // so just disconnect them and schedule their delayed deletion.
179
180 d->removedWatches.append(*wit);
181 if ((*wit).read)
182 {
183 (*wit).read->disconnect(d);
184 (*wit).read = 0;
185 }
186 if ((*wit).write)
187 {
188 (*wit).write->disconnect(d);
189 (*wit).write = 0;
190 }
191 (*wit).watch = 0;
192 }
193 }
194 }
195
196 if (d->removedWatches.count() > 0)
197 TQTimer::singleShot(0, d, TQ_SLOT(purgeRemovedWatches()));
198}

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

+ Here is the caller graph for this function:

◆ qDBusResultReceived()

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

Definition at line 619 of file tqdbusintegrator.cpp.

620{
621 //tqDebug("Pending Call Result received");
622 TQT_DBusConnectionPrivate* d = reinterpret_cast<TQT_DBusConnectionPrivate*>(user_data);
623 TQT_DBusConnectionPrivate::PendingCallMap::iterator it = d->pendingCalls.find(pending);
624
625 DBusMessage *dbusReply = dbus_pending_call_steal_reply(pending);
626
627 dbus_set_error_from_message(&d->error, dbusReply);
628 d->handleError();
629
630 if (it != d->pendingCalls.end())
631 {
633
634 TQT_DBusResultInfo dbusResult;
635 dbusResult.message = reply;
636 dbusResult.receiver = it.data()->receiver;
637 dbusResult.method = it.data()->method.data();
638 d->m_resultEmissionQueue.append(dbusResult);
640 }
641
642 dbus_message_unref(dbusReply);
643 dbus_pending_call_unref(pending);
644 delete it.data();
645
646 d->pendingCalls.erase(it);
647}
TQT_DBusResultInfoList m_resultEmissionQueue
A message converts and transports data over D-Bus.
static TQT_DBusMessage fromDBusMessage(DBusMessage *dmsg)
Creates a TQt3-bindings message from the given raw D-Bus message.
TQT_DBusMessage message

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.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qDBusSignalFilter()

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

Definition at line 241 of file tqdbusintegrator.cpp.

243{
244 Q_ASSERT(data);
245 Q_UNUSED(connection);
246
249 return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
250
251 int msgType = dbus_message_get_type(message);
252 bool handled = false;
253
254 //TQT_DBusMessage amsg = TQT_DBusMessage::fromDBusMessage(message);
255 //tqDebug() << "got message: " << dbus_message_get_type(message) << amsg;
256
257 if (msgType == DBUS_MESSAGE_TYPE_SIGNAL) {
258 handled = d->handleSignal(message);
259 } else if (msgType == DBUS_MESSAGE_TYPE_METHOD_CALL) {
260 handled = d->handleObjectCall(message);
261 }
262
263 return handled ? DBUS_HANDLER_RESULT_HANDLED :
264 DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
265}
bool handleObjectCall(DBusMessage *message)
bool handleSignal(DBusMessage *msg)

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qDBusToggleTimeout()

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

Definition at line 105 of file tqdbusintegrator.cpp.

106{
107 Q_ASSERT(timeout);
108 Q_ASSERT(data);
109
110 //tqDebug("ToggleTimeout");
111
112 qDBusRemoveTimeout(timeout, data);
113 qDBusAddTimeout(timeout, data);
114}
static dbus_bool_t qDBusAddTimeout(DBusTimeout *timeout, void *data)
static void qDBusRemoveTimeout(DBusTimeout *timeout, void *data)

References qDBusAddTimeout(), and qDBusRemoveTimeout().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ qDBusToggleWatch()

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

Definition at line 200 of file tqdbusintegrator.cpp.

201{
202 Q_ASSERT(watch);
203 Q_ASSERT(data);
204
205 //tqDebug("toggle watch");
206
208 int fd = dbus_watch_get_unix_fd(watch);
209
210 TQT_DBusConnectionPrivate::WatcherHash::iterator it = d->watchers.find(fd);
211 if (it != d->watchers.end()) {
213 for (TQT_DBusConnectionPrivate::WatcherList::iterator wit = list.begin(); wit != list.end();
214 ++wit)
215 {
216 if ((*wit).watch == watch) {
217 bool enabled = dbus_watch_get_enabled(watch);
218 int flags = dbus_watch_get_flags(watch);
219
220// tqDebug("toggle watch %d to %d (write: %d, read: %d)",
221// dbus_watch_get_unix_fd(watch), enabled,
222// flags & DBUS_WATCH_WRITABLE, flags & DBUS_WATCH_READABLE);
223
224 if (flags & DBUS_WATCH_READABLE && (*wit).read)
225 (*wit).read->setEnabled(enabled);
226 if (flags & DBUS_WATCH_WRITABLE && (*wit).write)
227 (*wit).write->setEnabled(enabled);
228 return;
229 }
230 }
231 }
232}

References TQT_DBusConnectionPrivate::watchers.

+ Here is the caller graph for this function:

Variable Documentation

◆ server_slot

dbus_int32_t server_slot = -1
static

Definition at line 551 of file tqdbusintegrator.cpp.