QtBase  v6.3.1
Public Types | Public Slots | Signals | Protected Member Functions | Properties | Friends | List of all members
QDBusConnectionInterface Class Reference

The QDBusConnectionInterface class provides access to the D-Bus bus daemon service. More...

#include <qdbusconnectioninterface.h>

Inheritance diagram for QDBusConnectionInterface:
Inheritance graph
[legend]
Collaboration diagram for QDBusConnectionInterface:
Collaboration graph
[legend]

Public Types

enum  ServiceQueueOptions { DontQueueService , QueueService , ReplaceExistingService }
 
enum  ServiceReplacementOptions { DontAllowReplacement , AllowReplacement }
 
enum  RegisterServiceReply { ServiceNotRegistered = 0 , ServiceRegistered , ServiceQueued }
 

Public Slots

QDBusReply< QStringListregisteredServiceNames () const
 
QDBusReply< QStringListactivatableServiceNames () const
 
QDBusReply< bool > isServiceRegistered (const QString &serviceName) const
 
QDBusReply< QStringserviceOwner (const QString &name) const
 
QDBusReply< bool > unregisterService (const QString &serviceName)
 
QDBusReply< QDBusConnectionInterface::RegisterServiceReplyregisterService (const QString &serviceName, ServiceQueueOptions qoption=DontQueueService, ServiceReplacementOptions roption=DontAllowReplacement)
 
QDBusReply< uintservicePid (const QString &serviceName) const
 
QDBusReply< uintserviceUid (const QString &serviceName) const
 
QDBusReply< voidstartService (const QString &name)
 
- Public Slots inherited from QObject
void deleteLater ()
 

Signals

void serviceRegistered (const QString &service)
 
void serviceUnregistered (const QString &service)
 
void serviceOwnerChanged (const QString &name, const QString &oldOwner, const QString &newOwner)
 
void callWithCallbackFailed (const QDBusError &error, const QDBusMessage &call)
 
void NameAcquired (const QString &)
 
void NameLost (const QString &)
 
void NameOwnerChanged (const QString &, const QString &, const QString &)
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 

Protected Member Functions

void connectNotify (const QMetaMethod &) override
 
void disconnectNotify (const QMetaMethod &) override
 
- Protected Member Functions inherited from QDBusAbstractInterface
 QDBusAbstractInterface (const QString &service, const QString &path, const char *interface, const QDBusConnection &connection, QObject *parent)
 
 QDBusAbstractInterface (QDBusAbstractInterfacePrivate &, QObject *parent)
 
QVariant internalPropGet (const char *propname) const
 
void internalPropSet (const char *propname, const QVariant &value)
 
QDBusMessage internalConstCall (QDBus::CallMode mode, const QString &method, const QList< QVariant > &args=QList< QVariant >()) const
 
- Protected Member Functions inherited from QDBusAbstractInterfaceBase
 QDBusAbstractInterfaceBase (QDBusAbstractInterfacePrivate &dd, QObject *parent)
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 

Properties

QDBusReply< QStringListregisteredServiceNames
 holds the registered service names More...
 
QDBusReply< QStringListactivatableServiceNames
 holds the activatable service names More...
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Friends

class QDBusConnectionPrivate
 

Additional Inherited Members

- Public Member Functions inherited from QDBusAbstractInterface
virtual ~QDBusAbstractInterface ()
 
bool isValid () const
 
QDBusConnection connection () const
 
QString service () const
 
QString path () const
 
QString interface () const
 
QDBusError lastError () const
 
void setTimeout (int timeout)
 
int timeout () const
 
QDBusMessage call (const QString &method)
 
template<typename... Args>
QDBusMessage call (const QString &method, Args &&...args)
 
QDBusMessage call (QDBus::CallMode mode, const QString &method)
 
template<typename... Args>
QDBusMessage call (QDBus::CallMode mode, const QString &method, Args &&...args)
 
QDBusMessage callWithArgumentList (QDBus::CallMode mode, const QString &method, const QList< QVariant > &args)
 
bool callWithCallback (const QString &method, const QList< QVariant > &args, QObject *receiver, const char *member, const char *errorSlot)
 
bool callWithCallback (const QString &method, const QList< QVariant > &args, QObject *receiver, const char *member)
 
QDBusPendingCall asyncCall (const QString &method)
 
template<typename... Args>
QDBusPendingCall asyncCall (const QString &method, Args &&...args)
 
QDBusPendingCall asyncCallWithArgumentList (const QString &method, const QList< QVariant > &args)
 
- Public Member Functions inherited from QDBusAbstractInterfaceBase
int qt_metacall (QMetaObject::Call, int, void **) override
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 
virtual ~QObject ()
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const
 
void setObjectName (const QString &name)
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 
bool isWindowType () const
 
bool signalsBlocked () const noexcept
 
bool blockSignals (bool b) noexcept
 
QThreadthread () const
 
void moveToThread (QThread *thread)
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 
template<typename T >
T findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<typename T >
QList< TfindChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
const QObjectListchildren () const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 
void dumpObjectInfo () const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 
bool inherits (const char *classname) const
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
static QMetaObject::Connection ::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 slot)
 
template<typename Func1 , typename Func2 >
static std::enable_if< QtPrivate::FunctionPointer< Func2 >::ArgumentCount==-1 &&!std::is_convertible_v< Func2, const char * >, QMetaObject::Connection >::type connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *context, Func2 slot, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 

Detailed Description

The QDBusConnectionInterface class provides access to the D-Bus bus daemon service.

\inmodule QtDBus

Since
4.2

The D-Bus bus server daemon provides one special interface org.freedesktop.DBus that allows clients to access certain properties of the bus, such as the current list of clients connected. The QDBusConnectionInterface class provides access to that interface.

The most common uses of this class are to register and unregister service names on the bus using the registerService() and unregisterService() functions, query about existing names using the isServiceRegistered(), registeredServiceNames() and serviceOwner() functions, and to receive notification that a client has registered or de-registered through the serviceRegistered(), serviceUnregistered() and serviceOwnerChanged() signals.

Definition at line 61 of file qdbusconnectioninterface.h.

Member Enumeration Documentation

◆ RegisterServiceReply

The possible return values from registerService():

\value ServiceNotRegistered The call failed and the service name was not registered. \value ServiceRegistered The caller is now the owner of the service name. \value ServiceQueued The caller specified the QueueService flag and the service was already registered, so we are in queue.

The serviceRegistered() signal will be emitted when the service is acquired by this application.

Enumerator
ServiceNotRegistered 
ServiceRegistered 
ServiceQueued 

Definition at line 85 of file qdbusconnectioninterface.h.

◆ ServiceQueueOptions

Flags for determining how a service registration should behave, in case the service name is already registered.

\value DontQueueService If an application requests a name that is already owned, no queueing will be performed. The registeredService() call will simply fail. This is the default.

\value QueueService Attempts to register the requested service, but do not try to replace it if another application already has it registered. Instead, simply put this application in queue, until it is given up. The serviceRegistered() signal will be emitted when that happens.

\value ReplaceExistingService If another application already has the service name registered, attempt to replace it.

See also
ServiceReplacementOptions
Enumerator
DontQueueService 
QueueService 
ReplaceExistingService 

Definition at line 74 of file qdbusconnectioninterface.h.

◆ ServiceReplacementOptions

Flags for determining if the D-Bus server should allow another application to replace a name that this application has registered with the ReplaceExistingService option.

The possible values are:

\value DontAllowReplacement Do not allow another application to replace us. The service must be explicitly unregistered with unregisterService() for another application to acquire it. This is the default.

\value AllowReplacement Allow other applications to replace us with the ReplaceExistingService option to registerService() without intervention. If that happens, the serviceUnregistered() signal will be emitted.

See also
ServiceQueueOptions
Enumerator
DontAllowReplacement 
AllowReplacement 

Definition at line 80 of file qdbusconnectioninterface.h.

Member Function Documentation

◆ activatableServiceNames

QDBusReply< QStringList > QDBusConnectionInterface::activatableServiceNames ( ) const
slot

Definition at line 208 of file qdbusconnectioninterface.cpp.

Here is the call graph for this function:

◆ callWithCallbackFailed

void QDBusConnectionInterface::callWithCallbackFailed ( const QDBusError error,
const QDBusMessage call 
)
signal

This signal is emitted when there is an error during a QDBusConnection::callWithCallback(). error specifies the error. call is the message that couldn't be delivered.

See also
QDBusConnection::callWithCallback()
Here is the caller graph for this function:

◆ connectNotify()

void QDBusConnectionInterface::connectNotify ( const QMetaMethod signal)
overrideprotectedvirtual
Since
5.0

This virtual function is called when something has been connected to signal in this object.

If you want to compare signal with a specific signal, you can use QMetaMethod::fromSignal() as follows:

Warning
This function violates the object-oriented principle of modularity. However, it might be useful when you need to perform expensive initialization only if something is connected to a signal.
This function is called from the thread which performs the connection, which may be a different thread from the thread in which this object lives.
See also
connect(), disconnectNotify()

Reimplemented from QDBusAbstractInterface.

Definition at line 342 of file qdbusconnectioninterface.cpp.

Here is the call graph for this function:

◆ disconnectNotify()

void QDBusConnectionInterface::disconnectNotify ( const QMetaMethod signal)
overrideprotectedvirtual
Since
5.0

This virtual function is called when something has been disconnected from signal in this object.

See connectNotify() for an example of how to compare signal with a specific signal.

If all signals were disconnected from this object (e.g., the signal argument to disconnect() was \nullptr), disconnectNotify() is only called once, and the signal will be an invalid QMetaMethod (QMetaMethod::isValid() returns false).

Warning
This function violates the object-oriented principle of modularity. However, it might be useful for optimizing access to expensive resources.
This function is called from the thread which performs the disconnection, which may be a different thread from the thread in which this object lives. This function may also be called with a QObject internal mutex locked. It is therefore not allowed to re-enter any of any QObject functions from your reimplementation and if you lock a mutex in your reimplementation, make sure that you don't call QObject functions with that mutex held in other places or it will result in a deadlock.
See also
disconnect(), connectNotify()

Reimplemented from QDBusAbstractInterface.

Definition at line 371 of file qdbusconnectioninterface.cpp.

Here is the call graph for this function:

◆ isServiceRegistered

QDBusReply< bool > QDBusConnectionInterface::isServiceRegistered ( const QString serviceName) const
slot

Returns true if the service name serviceName has is currently registered.

Definition at line 217 of file qdbusconnectioninterface.cpp.

Here is the caller graph for this function:

◆ NameAcquired

void QDBusConnectionInterface::NameAcquired ( const QString )
signal
Here is the caller graph for this function:

◆ NameLost

void QDBusConnectionInterface::NameLost ( const QString )
signal
Here is the caller graph for this function:

◆ NameOwnerChanged

void QDBusConnectionInterface::NameOwnerChanged ( const QString ,
const QString ,
const QString  
)
signal
Here is the caller graph for this function:

◆ registeredServiceNames

QDBusReply< QStringList > QDBusConnectionInterface::registeredServiceNames ( ) const
slot

Definition at line 196 of file qdbusconnectioninterface.cpp.

Here is the call graph for this function:

◆ registerService

QDBusReply< QDBusConnectionInterface::RegisterServiceReply > QDBusConnectionInterface::registerService ( const QString serviceName,
ServiceQueueOptions  qoption = DontQueueService,
ServiceReplacementOptions  roption = DontAllowReplacement 
)
slot

Requests to register the service name serviceName on the bus. The qoption flag specifies how the D-Bus server should behave if serviceName is already registered. The roption flag specifies if the server should allow another application to replace our registered name.

If the service registration succeeds, the serviceRegistered() signal will be emitted. If we are placed in queue, the signal will be emitted when we obtain the name. If roption is AllowReplacement, the serviceUnregistered() signal will be emitted if another application replaces this one.

See also
unregisterService()

Definition at line 267 of file qdbusconnectioninterface.cpp.

◆ serviceOwner

QDBusReply< QString > QDBusConnectionInterface::serviceOwner ( const QString name) const
slot

Returns the unique connection name of the primary owner of the name name. If the requested name doesn't have an owner, returns a org.freedesktop.DBus.Error.NameHasNoOwner error.

Definition at line 185 of file qdbusconnectioninterface.cpp.

Here is the call graph for this function:

◆ serviceOwnerChanged

QDBusConnectionInterface::serviceOwnerChanged ( const QString name,
const QString oldOwner,
const QString newOwner 
)
signal
Deprecated:

Use QDBusServiceWatcher instead.

This signal is emitted by the D-Bus server whenever a service ownership change happens in the bus, including apparition and disparition of names.

This signal means the application oldOwner lost ownership of bus name name to application newOwner. If oldOwner is an empty string, it means the name name has just been created; if newOwner is empty, the name name has no current owner and is no longer available.

Note
connecting to this signal will make the application listen for and receive every single service ownership change on the bus. Depending on how many services are running, this make the application be activated to receive more signals than it needs. To avoid this problem, use the QDBusServiceWatcher class, which can listen for specific changes.
Here is the caller graph for this function:

◆ servicePid

QDBusReply< uint > QDBusConnectionInterface::servicePid ( const QString serviceName) const
slot

Returns the Unix Process ID (PID) for the process currently holding the bus service serviceName.

Definition at line 227 of file qdbusconnectioninterface.cpp.

◆ serviceRegistered

QDBusConnectionInterface::serviceRegistered ( const QString service)
signal

This signal is emitted by the D-Bus server when the bus service name (unique connection name or well-known service name) given by service is acquired by this application.

Acquisition happens after this application has requested a name using registerService().

Here is the caller graph for this function:

◆ serviceUid

QDBusReply< uint > QDBusConnectionInterface::serviceUid ( const QString serviceName) const
slot

Returns the Unix User ID (UID) for the process currently holding the bus service serviceName.

Definition at line 237 of file qdbusconnectioninterface.cpp.

◆ serviceUnregistered

QDBusConnectionInterface::serviceUnregistered ( const QString service)
signal

This signal is emitted by the D-Bus server when this application loses ownership of the bus service name given by service.

Here is the caller graph for this function:

◆ startService

QDBusReply< void > QDBusConnectionInterface::startService ( const QString name)
slot

Requests that the bus start the service given by the name name.

Definition at line 246 of file qdbusconnectioninterface.cpp.

Here is the call graph for this function:

◆ unregisterService

QDBusReply< bool > QDBusConnectionInterface::unregisterService ( const QString serviceName)
slot

Releases the claim on the bus service name serviceName, that had been previously registered with registerService(). If this application had ownership of the name, it will be released for other applications to claim. If it only had the name queued, it gives up its position in the queue.

Definition at line 329 of file qdbusconnectioninterface.cpp.

Friends And Related Function Documentation

◆ QDBusConnectionPrivate

friend class QDBusConnectionPrivate
friend

Definition at line 64 of file qdbusconnectioninterface.h.

Property Documentation

◆ activatableServiceNames

QDBusConnectionInterface::activatableServiceNames
read

holds the activatable service names

Since
5.14

Lists all names that can be activated on the bus.

Definition at line 68 of file qdbusconnectioninterface.h.

◆ registeredServiceNames

QDBusConnectionInterface::registeredServiceNames
read

holds the registered service names

Lists all names currently registered on the bus.

Definition at line 68 of file qdbusconnectioninterface.h.


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