DBus-1-TQt 1.0
Loading...
Searching...
No Matches
TQT_DBusConnection Class Reference

#include <tqdbusconnection.h>

+ Collaboration diagram for TQT_DBusConnection:

Public Types

enum  BusType { SessionBus , SystemBus , ActivationBus }
 
enum  NameRequestMode { NoReplace = 0 , AllowReplace = 1 , ReplaceExisting = 2 }
 

Public Member Functions

 TQT_DBusConnection ()
 
 TQT_DBusConnection (const TQString &name)
 
 TQT_DBusConnection (const TQT_DBusConnection &other)
 
 ~TQT_DBusConnection ()
 
TQT_DBusConnectionoperator= (const TQT_DBusConnection &other)
 
bool isConnected () const
 
TQT_DBusError lastError () const
 
bool requestName (const TQString &name, int modeFlags=NoReplace)
 
TQString uniqueName () const
 
bool send (const TQT_DBusMessage &message) const
 
TQT_DBusMessage sendWithReply (const TQT_DBusMessage &message, TQT_DBusError *error=0) const
 
int sendWithAsyncReply (const TQT_DBusMessage &message, TQObject *receiver, const char *slot) const
 
void flush () const
 
void dispatch () const
 
void scheduleDispatch () const
 
bool connect (TQObject *object, const char *slot)
 
bool disconnect (TQObject *object, const char *slot)
 
bool registerObject (const TQString &path, TQT_DBusObjectBase *object)
 
void unregisterObject (const TQString &path)
 

Static Public Member Functions

static TQT_DBusConnection sessionBus ()
 
static TQT_DBusConnection systemBus ()
 
static TQT_DBusConnection addConnection (BusType type, const TQString &name=default_connection_name)
 
static TQT_DBusConnection addConnection (const TQString &address, const TQString &name=default_connection_name)
 
static void closeConnection (const TQString &name=default_connection_name)
 

Static Public Attributes

static const char * default_connection_name = "qt_dbus_default_connection"
 

Private Attributes

TQT_DBusConnectionPrivated
 

Detailed Description

Provides access to a specific D-Bus bus.

In order to access a D-Bus message bus an application has to connect to it. This is very similar to connecting to an FTP server using TQFtp, where any number of commands can be sent in sequence over the same connection.

Additionally to the asynchronous command execution provided by TQFtp a TQT_DBusConnection can also execute synchronous (blocking) calls so the code around those calls stays closer to in-process method incovations.

However it is recommended to only perform blocking calls on D-Bus service methods that are likely to be processed fast.

TQT_DBusConnection implements a shared resource, i.e. if you create a connection with a specific name in one part of your code and then create one with the same name somewhere else, the second creation will actually return the same shared connection object the first caller created.

The application can be connected to more than one message bus simultaniously using one or more connections per bus, however the most common case is to have one connection per bus.

The two main bus types are:

  • System bus: a bus connecting applications on one system across user or session boundaries, for example allowing to communicate with system services like printer spoolers, etc
  • Session bus: a bus connecting applications within one user session, for example started at login or by a session manager. Use cases or this kind of bus would be accessing user specific resources like addressbooks, retrieving user settings or controlling session services (e.g. disabling screensaver in a video player application during playback)

While TQT_DBusConnection provides the basic API to access D-Bus services it is more convenient to use TQT_DBusProxy on top of the connection.

See sections Using D-Bus as a client and Providing services over D-Bus for examples

Definition at line 171 of file tqdbusconnection.h.

Member Enumeration Documentation

◆ BusType

DBus bus types

Enumerator
SessionBus 

The session bus is a user and user session specific message channel. It will usually be started by a login script or a session manager.

SystemBus 

The system bus is a message channel bridging user level and system level process boundaries, e.g. it can allow a user process with normal user access restrictions to perform a limited subset of operations on a process running with elevated rights.

Warning
if an applications exposed services on the system bus, i.e. registers objects using registerObject(), it should be carefully examined on potential security issues
ActivationBus 

Definition at line 177 of file tqdbusconnection.h.

178 {
185
196 SystemBus,
197
198 // TODO find out about ActivationBus purpose
200 };

◆ NameRequestMode

Flags for controlling the behavior name collision handling.

See also
requestName()
Enumerator
NoReplace 

Do not allow others to take over a name requested by this application

AllowReplace 

Allow other applications that request the same name to get it, i.e. allow the bus to transfer the name from this application to the one requesting it

ReplaceExisting 

Try to get the name transferred from the current owner to this application. This will only work if the other application as requested the name using the AllowReplace flag

Definition at line 282 of file tqdbusconnection.h.

Constructor & Destructor Documentation

◆ TQT_DBusConnection() [1/3]

TQT_DBusConnection::TQT_DBusConnection ( )

Creates an empty/disconnected connection handle.

This is mainly used for initializing variables of this type, i.e. like the default TQString constructor.

A variable set to such an empty connection can be assigned a working connection at any time.

Definition at line 144 of file tqdbusconnection.cpp.

144 : d(0)
145{
146}
TQT_DBusConnectionPrivate * d
+ Here is the caller graph for this function:

◆ TQT_DBusConnection() [2/3]

TQT_DBusConnection::TQT_DBusConnection ( const TQString &  name)

Creates a connection handle to a named connection.

This will result in an disconnected connection handle if no connection with that name has been created by addConnection before.

Therefore it is recommended to use addConnection() instead to get a connection handle.

Parameters
nameidentifier of the shared connection object

Definition at line 148 of file tqdbusconnection.cpp.

149{
150 d = manager()->connection(name);
151 if (d)
152 d->ref.ref();
153}
TQT_DBusConnectionPrivate * connection(const TQString &name) const
TQT_DBusConnectionManager * manager()

References TQT_DBusConnectionManager::connection(), d, manager(), Atomic::ref(), and TQT_DBusConnectionPrivate::ref.

+ Here is the call graph for this function:

◆ TQT_DBusConnection() [3/3]

TQT_DBusConnection::TQT_DBusConnection ( const TQT_DBusConnection other)

Creates a shallow copy of the given connection.

Allows to pass connection handles around by value, similar to TQString thus avoiding problems like dangling pointers in application code

Parameters
otherthe connection to copy from

Definition at line 155 of file tqdbusconnection.cpp.

156{
157 d = other.d;
158 if (d)
159 d->ref.ref();
160}

References d, Atomic::ref(), and TQT_DBusConnectionPrivate::ref.

+ Here is the call graph for this function:

◆ ~TQT_DBusConnection()

TQT_DBusConnection::~TQT_DBusConnection ( )

Destroys the connection handle.

If this handle is the last one referencing the shared connection object it will delete it, disconnecting it from any objects it was collaborating with

Definition at line 162 of file tqdbusconnection.cpp.

163{
164 if (d && !d->ref.deref())
165 delete d;
166}

References d, Atomic::deref(), and TQT_DBusConnectionPrivate::ref.

+ Here is the call graph for this function:

Member Function Documentation

◆ addConnection() [1/2]

TQT_DBusConnection TQT_DBusConnection::addConnection ( BusType  type,
const TQString &  name = default_connection_name 
)
static

Add a connection to a bus with a specific bus type.

This is a factory method as it will create a connection for the given name if its not available yet, but return a previously created connection for that name if available.

Depending on the BusType the D-Bus library will connect to the address configured for that type, so this is the recommended way to create connection to D-Bus.

// Associate the default connection name with a connection to the user's
// session bus
// check if we are connected and which uniqueName we got
if (con.isConnected())
{
tqDebug("Connected to session bus. We got uniqueName %s",
con.uniqueName().local8Bit().data());
}
Provides access to a specific D-Bus bus.
TQString uniqueName() const
Returns the connection identifier assigned at connect.
static TQT_DBusConnection addConnection(BusType type, const TQString &name=default_connection_name)
Add a connection to a bus with a specific bus type.
bool isConnected() const
Returns whether the connection is connected to a bus.

For the common use cases see also sessionBus() and systemBus()

Parameters
typethe BusType of the bus to connect to
namethe name to use for TQT_DBusConnection's connection sharing
Returns
a connection handle. Check isConnected() to find out if the connection attempt has been successfull
See also
closeConnection()

Definition at line 193 of file tqdbusconnection.cpp.

194{
195// Q_ASSERT_X(TQCoreApplication::instance(), "TQT_DBusConnection::addConnection",
196// "Cannot create connection without a Q[Core]Application instance");
197
199 if (d)
200 return TQT_DBusConnection(name);
201
203 DBusConnection *c = 0;
204 switch (type) {
205 case SystemBus:
206 c = dbus_bus_get(DBUS_BUS_SYSTEM, &d->error);
207 break;
208 case SessionBus:
209 c = dbus_bus_get(DBUS_BUS_SESSION, &d->error);
210 break;
211 case ActivationBus:
212 c = dbus_bus_get(DBUS_BUS_STARTER, &d->error);
213 break;
214 }
215 d->setConnection(c); //setConnection does the error handling for us
216
217 manager()->setConnection(name, d);
218
219 return TQT_DBusConnection(name);
220}
TQT_DBusConnection()
Creates an empty/disconnected connection handle.
void setConnection(const TQString &name, TQT_DBusConnectionPrivate *c)
void setConnection(DBusConnection *connection)

References ActivationBus, TQT_DBusConnectionManager::connection(), d, TQT_DBusConnectionPrivate::error, manager(), SessionBus, TQT_DBusConnectionManager::setConnection(), TQT_DBusConnectionPrivate::setConnection(), SystemBus, and TQT_DBusConnection().

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

◆ addConnection() [2/2]

TQT_DBusConnection TQT_DBusConnection::addConnection ( const TQString &  address,
const TQString &  name = default_connection_name 
)
static

Add a connection to a bus at a specific address.

This is a factory method as it will create a connection for the given name if its not available yet, but return a previously created connection for that name if available.

Note
this requires to know the address of a D-Bus daemon to connect to
Parameters
addressthe address of the D-Bus daemon. Usually a Unix domain socket address
namethe name to use for TQT_DBusConnection's connection sharing
Returns
a connection handle. Check isConnected() to find out if the connection attempt has been successfull
See also
closeConnection()

Definition at line 222 of file tqdbusconnection.cpp.

224{
225// Q_ASSERT_X(TQCoreApplication::instance(), "TQT_DBusConnection::addConnection",
226// "Cannot create connection without a Q[Core]Application instance");
227
229 if (d)
230 return TQT_DBusConnection(name);
231
233 // setConnection does the error handling for us
234 d->setConnection(dbus_connection_open(address.utf8().data(), &d->error));
235
236 manager()->setConnection(name, d);
237
238 return TQT_DBusConnection(name);
239}

References TQT_DBusConnectionManager::connection(), d, TQT_DBusConnectionPrivate::error, manager(), TQT_DBusConnectionManager::setConnection(), TQT_DBusConnectionPrivate::setConnection(), and TQT_DBusConnection().

+ Here is the call graph for this function:

◆ closeConnection()

void TQT_DBusConnection::closeConnection ( const TQString &  name = default_connection_name)
static

Closes a connection with a given name.

Removes the name from the pool of shared connections, i.e. a call to addConnection() with the same name afterwards will create a new connection.

Parameters
namethe connection name as used in addConnection()

Definition at line 241 of file tqdbusconnection.cpp.

242{
243 manager()->removeConnection(name);
244}
void removeConnection(const TQString &name)

References manager(), and TQT_DBusConnectionManager::removeConnection().

+ Here is the call graph for this function:

◆ connect()

bool TQT_DBusConnection::connect ( TQObject *  object,
const char *  slot 
)

Connects an object to receive D-Bus signals.

This provides a basic access to all D-Bus signals received on this connection. For every D-Bus signal processed by the connection object a TQt signal is emitted and thus delivered to all receiver objects connected through this method.

The required slot signature is

void slotname(const TQT_DBusMessage&);
A message converts and transports data over D-Bus.

so a suitable receiver could look like this

class DBusSignalReceiver : public TQObject
{
TQ_OBJECT
public slots:
void dbusSignal(const TQT_DBusMessage&);
};

and would be connected like this

// assuming the following variables
TQT_DBusConnection connection;
DBusSignalReceiver* receiver;
connection.connect(receiver, TQ_SLOT(dbusSignal(const TQT_DBusMessage&)));
bool connect(TQObject *object, const char *slot)
Connects an object to receive D-Bus signals.

See TQT_DBusProxy::dbusSignal() for a more obvious way of connecting slots.

Parameters
objectthe receiver object
slotthe receiver slot (or signal for signal->signal connections)
Returns
true if the connection was successfull, otherwise false
See also
disconnect()

Definition at line 324 of file tqdbusconnection.cpp.

325{
326 if (!d || !d->connection || !object || !slot)
327 return false;
328
329 bool ok = object->connect(d, TQ_SIGNAL(dbusSignal(const TQT_DBusMessage&)), slot);
330
331 return ok;
332}

References TQT_DBusConnectionPrivate::connection, and d.

+ Here is the caller graph for this function:

◆ disconnect()

bool TQT_DBusConnection::disconnect ( TQObject *  object,
const char *  slot 
)

Disconnects a given receiver from the D-Bus signal handling.

Parameters
objectthe receiver object to disconnect from
slotthe receiver slot (or signal for signal->signal connections)
Returns
true if the disconnect was successfull, otherwise false
See also
connect()

Definition at line 334 of file tqdbusconnection.cpp.

335{
336 if (!d || !d->connection || !object || !slot)
337 return false;
338
339 bool ok = d->disconnect(object, slot);
340
341 return ok;
342}

References TQT_DBusConnectionPrivate::connection, and d.

+ Here is the caller graph for this function:

◆ dispatch()

void TQT_DBusConnection::dispatch ( ) const

Processes buffered inbound messages.

Attempts to process all enqueued inbound messages, e.g. replies to method calls or received signals.

Warning
dispatching message can result in TQt signals being emitted before this method returns. In case you just want to make sure no inbound message is forgotten, call scheduleDispatch() which will execute the dispatch delayed through the event loop.

Definition at line 310 of file tqdbusconnection.cpp.

311{
312 if (!d || !d->connection) return;
313
314 d->dispatch();
315}

References TQT_DBusConnectionPrivate::connection, d, and TQT_DBusConnectionPrivate::dispatch().

+ Here is the call graph for this function:

◆ flush()

void TQT_DBusConnection::flush ( ) const

Flushes buffered outgoing message.

Attempts to send all enqueued outgoing messages before returning.

Definition at line 303 of file tqdbusconnection.cpp.

304{
305 if (!d || !d->connection) return;
306
307 d->flush();
308}

References TQT_DBusConnectionPrivate::connection, d, and TQT_DBusConnectionPrivate::flush().

+ Here is the call graph for this function:

◆ isConnected()

bool TQT_DBusConnection::isConnected ( ) const

Returns whether the connection is connected to a bus.

Returns
true if the connection can be used, false if the handle does not have access to a shared connection object or if the connection to the bus could not be established or broke

Definition at line 370 of file tqdbusconnection.cpp.

371{
372 return d && d->connection && dbus_connection_get_is_connected(d->connection);
373}

References TQT_DBusConnectionPrivate::connection, and d.

+ Here is the caller graph for this function:

◆ lastError()

TQT_DBusError TQT_DBusConnection::lastError ( ) const

Returns the last error seen by the connection.

This can be a connection error, e.g. attempt to connect failed, or a transmission error or an error reported by a method call

Returns
the last error seen by the connection

Definition at line 375 of file tqdbusconnection.cpp.

376{
377 return d ? d->lastError : TQT_DBusError();
378}
Class for transporting D-Bus errors.
Definition tqdbuserror.h:41

References d, and TQT_DBusConnectionPrivate::lastError.

◆ operator=()

TQT_DBusConnection & TQT_DBusConnection::operator= ( const TQT_DBusConnection other)

Creates a shallow copy of the given connection.

Allows to pass connection handles around by value, similar to TQString thus avoiding problems like dangling pointers in application code

Parameters
otherthe connection to copy from
Returns
a reference to this instance as required by assigment operator semantics

Definition at line 168 of file tqdbusconnection.cpp.

169{
170 if (other.d)
171 other.d->ref.ref();
172/* FIXME-QT4
173 TQT_DBusConnectionPrivate *old = static_cast<TQT_DBusConnectionPrivate *>(
174 q_atomic_set_ptr(&d, other.d));*/
176 d = other.d;
177 if (old && !old->ref.deref())
178 delete old;
179
180 return *this;
181}

References d, Atomic::deref(), Atomic::ref(), and TQT_DBusConnectionPrivate::ref.

+ Here is the call graph for this function:

◆ registerObject()

bool TQT_DBusConnection::registerObject ( const TQString &  path,
TQT_DBusObjectBase object 
)

Registers a service object for a given path.

In order to receive method calls over the D-Bus connection the service objects path within its host application has to be registered with the connection. See section Object paths for details.

Only one objects can be registered for a single object path, i.e. the path -> object mapping is unambiguous, similar to mapping of filesystem paths to files.

If a service object offers more than one interface it is up to the service implementation if all are implemented in the object path to this method or if the passed object is just another demultiplexer which relays the message to the interface implementor.

Parameters
paththe object path to register the object for
objectthe service implementation object for that path
Returns
true if the given object is now registered for the given path or false if path is empty, object is null or another object is already registered for this path
See also
unregisterObject()

Definition at line 344 of file tqdbusconnection.cpp.

345{
346 if (!d || !d->connection || !object || path.isEmpty())
347 return false;
348
349 TQT_DBusConnectionPrivate::ObjectMap::const_iterator it = d->registeredObjects.find(path);
350 if (it != d->registeredObjects.end())
351 return false;
352
353 d->registeredObjects.insert(path, object);
354
355 return true;
356}

References TQT_DBusConnectionPrivate::connection, d, and TQT_DBusConnectionPrivate::registeredObjects.

◆ requestName()

bool TQT_DBusConnection::requestName ( const TQString &  name,
int  modeFlags = NoReplace 
)

Requests to be addressable on the bus by a given name.

Each connection to a bus gets a unique name once the connection is established. This is similar to getting an IP address when connecting to the Internet.

If an application's purpose is to provide services to other applications the other applications require to know how to address the service provider. Similar to a domain name on the Internet D-Bus allows to register names on the bus and be addressed through those names instead of the connection identifier.

Note
this is not required if the application only needs to acccess services or only implements generic service APIs

If more than one application request the same name, D-Bus will try to resolve this conflict as good as possible. The NameRequestMode flags allow to control how an application prefers to be treated in such a conflict.

Parameters
namethe name the connection should be addressable with. See section Service names
modeFlagsan OR'ed combination of NameRequestMode flags
Returns
true if the name request was successfull, false if the connection is not connected to a bus or the name is already taken and cannot be tranferred
See also
uniqueName()

Definition at line 387 of file tqdbusconnection.cpp.

388{
389 Q_ASSERT(modeFlags >= 0);
390
391 if (!d || !d->connection)
392 return false;
393
394 if (modeFlags < 0)
395 return false;
396
397 int dbusFlags = 0;
398 if (modeFlags & AllowReplace)
399 dbusFlags |= DBUS_NAME_FLAG_ALLOW_REPLACEMENT;
400 if (modeFlags & ReplaceExisting)
401 dbusFlags |= DBUS_NAME_FLAG_REPLACE_EXISTING;
402
403 dbus_bus_request_name(d->connection, name.utf8(), dbusFlags, &d->error);
404 bool res = !d->handleError();
405 res &= d->handleUnreadMessages();
406 return res;
407}

References AllowReplace, TQT_DBusConnectionPrivate::connection, d, TQT_DBusConnectionPrivate::error, TQT_DBusConnectionPrivate::handleError(), TQT_DBusConnectionPrivate::handleUnreadMessages(), and ReplaceExisting.

+ Here is the call graph for this function:

◆ scheduleDispatch()

void TQT_DBusConnection::scheduleDispatch ( ) const

Request a delayed check for inbound buffer processing.

Similar to dispatch() but delayed by a single shot timer to ensure the method has returned before the processing is started.

If a asynchronous method call is followed by a synchronous call without returning to the event loop in between, a call to scheduleDispatch() ensures that a pending reply to the asynchronous call is processed as soon as possible

Definition at line 317 of file tqdbusconnection.cpp.

318{
319 if (!d || !d->connection) return;
320
322}

References TQT_DBusConnectionPrivate::connection, d, and TQT_DBusConnectionPrivate::scheduleDispatch().

+ Here is the call graph for this function:

◆ send()

bool TQT_DBusConnection::send ( const TQT_DBusMessage message) const

Sends a message over the bus.

Sends a message composed through the TQT_DBusMessage API to the bus. This is the main method for service objects (see TQT_DBusObjectBase) to send replies and errors for method calls they accepted or for sending D-Bus signals.

Note
for doing method calls it is more convenient to use TQT_DBusProxy, see TQT_DBusProxy::send()
Parameters
messagethe message to send
Returns
true if sending succeeded, false if the connection is not connected, if the message lacks information about the recepient or if sending fails a at a lower level in the communication stack
See also
lastError()

Definition at line 252 of file tqdbusconnection.cpp.

253{
254 if (!d || !d->connection)
255 return false;
256
257 DBusMessage *msg = message.toDBusMessage();
258 if (!msg)
259 return false;
260
261 bool isOk = dbus_connection_send(d->connection, msg, 0);
262 dbus_message_unref(msg);
263 return isOk;
264}
DBusMessage * toDBusMessage() const
Creates a raw D-Bus message from this TQt3-bindings message.

References TQT_DBusConnectionPrivate::connection, d, and TQT_DBusMessage::toDBusMessage().

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

◆ sendWithAsyncReply()

int TQT_DBusConnection::sendWithAsyncReply ( const TQT_DBusMessage message,
TQObject *  receiver,
const char *  slot 
) const

Sends a message over the bus, specifying a receiver object for replies.

Sends a message composed through the TQT_DBusMessage API to the bus and returns an identifier number to associate with the reply once it is received by the given receiver. See TQT_DBusMessage::replySerialNumber()

The required slot signature is

void slotname(const TQT_DBusMessage&);
Note
for doing method calls it is more convenient to use TQT_DBusProxy, see TQT_DBusProxy::sendWithAsyncReply()
Parameters
messagethe message to send
receiverthe TQObject to relay the reply to
slotthe slot to invoke for the reply
Returns
a numeric identifier for association with the reply or 0 if sending failed
See also
lastError()

Definition at line 266 of file tqdbusconnection.cpp.

268{
269 if (!d || !d->connection)
270 return 0;
271
272 return d->sendWithReplyAsync(message, receiver, method);
273}
int sendWithReplyAsync(const TQT_DBusMessage &message, TQObject *receiver, const char *method)

References TQT_DBusConnectionPrivate::connection, d, and TQT_DBusConnectionPrivate::sendWithReplyAsync().

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

◆ sendWithReply()

TQT_DBusMessage TQT_DBusConnection::sendWithReply ( const TQT_DBusMessage message,
TQT_DBusError error = 0 
) const

Sends a message over the bus and waits for the reply.

Sends a message composed through the TQT_DBusMessage API to the bus. It then blocks and waits until the associated reply is received. Any message received in between is stored and can be processed by calling dispatch() or scheduleDispatch()

Note
for doing method calls it is more convenient to use TQT_DBusProxy, see TQT_DBusProxy::sendWithReply()
Parameters
messagethe message to send
erroran optional parameter to directly get any error that might occur during processing of the call
Returns
a message containing either the call's reply or an invalid message in case the call failed
See also
lastError()

Definition at line 275 of file tqdbusconnection.cpp.

276{
277 if (!d || !d->connection)
279
280 DBusMessage *msg = message.toDBusMessage();
281 if (!msg)
283
284 DBusMessage *reply = dbus_connection_send_with_reply_and_block(d->connection, msg, -1, &d->error);
285
286 if (d->handleError() && error)
287 *error = d->lastError;
288
289 dbus_message_unref(msg);
290
292 if (reply) {
293 dbus_message_unref(reply);
294 }
295
296 bool dbus_error_set = dbus_error_is_set(&d->error);
297 ret.d->error.setDBUSError(dbus_error_set);
298 if (error) error->setDBUSError(dbus_error_set);
299
300 return ret;
301}
void setDBUSError(bool err) const
TQT_DBusMessagePrivate * d
static TQT_DBusMessage fromDBusMessage(DBusMessage *dmsg)
Creates a TQt3-bindings message from the given raw D-Bus message.

References TQT_DBusConnectionPrivate::connection, d, TQT_DBusMessage::d, TQT_DBusConnectionPrivate::error, TQT_DBusMessagePrivate::error, TQT_DBusMessage::fromDBusMessage(), TQT_DBusConnectionPrivate::handleError(), TQT_DBusConnectionPrivate::lastError, TQT_DBusError::setDBUSError(), and TQT_DBusMessage::toDBusMessage().

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

◆ sessionBus()

TQT_DBusConnection TQT_DBusConnection::sessionBus ( )
static

Gets a connection to the session bus.

Convenience overload for creating the default shared connection to the D-Bus session bus.

Equivalent to calling addConnection(SessionBus);

Returns
a connection handle. Check isConnected() to find out if the connection attempt has been successfull
See also
addConnection(BusType,const TQString&);

Definition at line 183 of file tqdbusconnection.cpp.

References addConnection(), and SessionBus.

+ Here is the call graph for this function:

◆ systemBus()

TQT_DBusConnection TQT_DBusConnection::systemBus ( )
static

Gets a connection to the system bus.

Convenience overload for creating the default shared connection to the D-Bus system bus.

Equivalent to calling addConnection(SystemBus);

Returns
a connection handle. Check isConnected() to find out if the connection attempt has been successfull
See also
addConnection(BusType,const TQString&);

Definition at line 188 of file tqdbusconnection.cpp.

References addConnection(), and SystemBus.

+ Here is the call graph for this function:

◆ uniqueName()

TQString TQT_DBusConnection::uniqueName ( ) const

Returns the connection identifier assigned at connect.

The unique name is the connection address or identifier the bus assigned to this connection when it got established.

Returns
the connection's unique bus identifier
See also
requestName()

Definition at line 380 of file tqdbusconnection.cpp.

381{
382 return d && d->connection ?
383 TQString::fromUtf8(dbus_bus_get_unique_name(d->connection))
384 : TQString();
385}

References TQT_DBusConnectionPrivate::connection, and d.

◆ unregisterObject()

void TQT_DBusConnection::unregisterObject ( const TQString &  path)

Unregister a service object on a given path.

Removes any mapping of object path to service object previously registered by registerObject(). See section Object paths for details.

Warning
always(!) unregister a service object before deleting it
Parameters
paththe object path of the object to unregister
See also
registerObject()

Definition at line 358 of file tqdbusconnection.cpp.

359{
360 if (!d || !d->connection || path.isEmpty())
361 return;
362
363 TQT_DBusConnectionPrivate::ObjectMap::iterator it = d->registeredObjects.find(path);
364 if (it == d->registeredObjects.end())
365 return ;
366
367 d->registeredObjects.erase(it);
368}

References TQT_DBusConnectionPrivate::connection, d, and TQT_DBusConnectionPrivate::registeredObjects.

Member Data Documentation

◆ d

TQT_DBusConnectionPrivate* TQT_DBusConnection::d
private

Definition at line 660 of file tqdbusconnection.h.

◆ default_connection_name

const char * TQT_DBusConnection::default_connection_name = "qt_dbus_default_connection"
static

String used as the default parameter for connection names

Definition at line 657 of file tqdbusconnection.h.


The documentation for this class was generated from the following files: