![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtDBus More...
#include <qdbusconnectioninterface.h>
Public Types | |
enum | ServiceQueueOptions { DontQueueService , QueueService , ReplaceExistingService } |
Flags for determining how a service registration should behave, in case the service name is already registered. More... | |
enum | ServiceReplacementOptions { DontAllowReplacement , AllowReplacement } |
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. More... | |
enum | RegisterServiceReply { ServiceNotRegistered = 0 , ServiceRegistered , ServiceQueued } |
The possible return values from registerService(): More... | |
Public Slots | |
QDBusReply< QStringList > | registeredServiceNames () const |
QDBusReply< QStringList > | activatableServiceNames () const |
QDBusReply< bool > | isServiceRegistered (const QString &serviceName) const |
Returns true if the service name serviceName has is currently registered. | |
QDBusReply< QString > | serviceOwner (const QString &name) const |
Returns the unique connection name of the primary owner of the name name. | |
QDBusReply< bool > | unregisterService (const QString &serviceName) |
Releases the claim on the bus service name serviceName, that had been previously registered with registerService(). | |
QDBusReply< QDBusConnectionInterface::RegisterServiceReply > | registerService (const QString &serviceName, ServiceQueueOptions qoption=DontQueueService, ServiceReplacementOptions roption=DontAllowReplacement) |
Requests to register the service name serviceName on the bus. | |
QDBusReply< uint > | servicePid (const QString &serviceName) const |
Returns the Unix Process ID (PID) for the process currently holding the bus service serviceName. | |
QDBusReply< uint > | serviceUid (const QString &serviceName) const |
Returns the Unix User ID (UID) for the process currently holding the bus service serviceName. | |
QDBusReply< void > | startService (const QString &name) |
Requests that the bus start the service given by the name name. | |
![]() | |
void | deleteLater () |
\threadsafe | |
Signals | |
void | serviceRegistered (const QString &service) |
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. | |
void | serviceUnregistered (const QString &service) |
This signal is emitted by the D-Bus server when this application loses ownership of the bus service name given by service. | |
void | serviceOwnerChanged (const QString &name, const QString &oldOwner, const QString &newOwner) |
void | callWithCallbackFailed (const QDBusError &error, const QDBusMessage &call) |
This signal is emitted when there is an error during a QDBusConnection::callWithCallback(). | |
void | NameAcquired (const QString &) |
void | NameLost (const QString &) |
void | NameOwnerChanged (const QString &, const QString &, const QString &) |
![]() | |
void | destroyed (QObject *=nullptr) |
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked. | |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
This signal is emitted after the object's name has been changed. | |
Protected Member Functions | |
void | connectNotify (const QMetaMethod &) override |
void | disconnectNotify (const QMetaMethod &) override |
![]() | |
QDBusAbstractInterface (const QString &service, const QString &path, const char *interface, const QDBusConnection &connection, QObject *parent) | |
QDBusAbstractInterface (QDBusAbstractInterfacePrivate &, QObject *parent) | |
void | connectNotify (const QMetaMethod &signal) override |
void | disconnectNotify (const QMetaMethod &signal) override |
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 |
![]() | |
QDBusAbstractInterfaceBase (QDBusAbstractInterfacePrivate &dd, QObject *parent) | |
![]() | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr. | |
int | senderSignalIndex () const |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. | |
bool | isSignalConnected (const QMetaMethod &signal) const |
virtual void | timerEvent (QTimerEvent *event) |
This event handler can be reimplemented in a subclass to receive timer events for the object. | |
virtual void | childEvent (QChildEvent *event) |
This event handler can be reimplemented in a subclass to receive child events. | |
virtual void | customEvent (QEvent *event) |
This event handler can be reimplemented in a subclass to receive custom events. | |
virtual void | connectNotify (const QMetaMethod &signal) |
virtual void | disconnectNotify (const QMetaMethod &signal) |
QObject (QObjectPrivate &dd, QObject *parent=nullptr) | |
Properties | |
QDBusReply< QStringList > | registeredServiceNames |
holds the registered service names | |
QDBusReply< QStringList > | activatableServiceNames |
holds the activatable service names | |
![]() | |
QString | objectName |
the name of this object | |
Friends | |
class | QDBusConnectionPrivate |
Additional Inherited Members | |
![]() | |
virtual | ~QDBusAbstractInterface () |
Releases this object's resources. | |
bool | isValid () const |
Returns true if this is a valid reference to a remote object. | |
QDBusConnection | connection () const |
Returns the connection this interface is associated with. | |
QString | service () const |
Returns the name of the service this interface is associated with. | |
QString | path () const |
Returns the object path that this interface is associated with. | |
QString | interface () const |
Returns the name of this interface. | |
QDBusError | lastError () const |
Returns the error the last operation produced, or an invalid error if the last operation did not produce an error. | |
void | setTimeout (int timeout) |
Sets the timeout in milliseconds for all future DBus calls to timeout. | |
int | timeout () const |
Returns the current value of the timeout in milliseconds. | |
QDBusMessage | call (const QString &method) |
template<typename... Args> | |
QDBusMessage | call (const QString &method, Args &&...args) |
Calls the method method on this interface and passes args to the method. | |
QDBusMessage | call (QDBus::CallMode mode, const QString &method) |
template<typename... Args> | |
QDBusMessage | call (QDBus::CallMode mode, const QString &method, Args &&...args) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Calls the method method on this interface and passes args to the method. | |
QDBusMessage | callWithArgumentList (QDBus::CallMode mode, const QString &method, const QList< QVariant > &args) |
Places a call to the remote method specified by method on this interface, using args as arguments. | |
bool | callWithCallback (const QString &method, const QList< QVariant > &args, QObject *receiver, const char *member, const char *errorSlot) |
Places a call to the remote method specified by method on this interface, using args as arguments. | |
bool | callWithCallback (const QString &method, const QList< QVariant > &args, QObject *receiver, const char *member) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.This function is deprecated. | |
QDBusPendingCall | asyncCall (const QString &method) |
template<typename... Args> | |
QDBusPendingCall | asyncCall (const QString &method, Args &&...args) |
Calls the method method on this interface and passes args to the method. | |
QDBusPendingCall | asyncCallWithArgumentList (const QString &method, const QList< QVariant > &args) |
![]() | |
int | qt_metacall (QMetaObject::Call, int, void **) override |
![]() | |
Q_INVOKABLE | QObject (QObject *parent=nullptr) |
Constructs an object with parent object parent. | |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. | |
virtual bool | event (QEvent *event) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. | |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
Filters events if this object has been installed as an event filter for the watched object. | |
QString | objectName () const |
Q_WEAK_OVERLOAD void | setObjectName (const QString &name) |
Sets the object's name to name. | |
void | setObjectName (QAnyStringView name) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
QBindable< QString > | bindableObjectName () |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false . | |
bool | isWindowType () const |
Returns true if the object is a window; otherwise returns false . | |
bool | isQuickItemType () const |
Returns true if the object is a QQuickItem; otherwise returns false . | |
bool | signalsBlocked () const noexcept |
Returns true if signals are blocked; otherwise returns false . | |
bool | blockSignals (bool b) noexcept |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). | |
QThread * | thread () const |
Returns the thread in which the object lives. | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. | |
int | startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer) |
This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds. | |
int | startTimer (std::chrono::milliseconds time, Qt::TimerType timerType=Qt::CoarseTimer) |
void | killTimer (int id) |
Kills the timer with timer identifier, id. | |
template<typename T > | |
T | findChild (const QString &aName=QString(), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object. | |
template<typename T > | |
QList< T > | findChildren (const QString &aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. | |
template<typename T > | |
QList< T > | findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
const QObjectList & | children () const |
Returns a list of child objects. | |
void | setParent (QObject *parent) |
Makes the object a child of parent. | |
void | installEventFilter (QObject *filterObj) |
Installs an event filter filterObj on this object. | |
void | removeEventFilter (QObject *obj) |
Removes an event filter object obj from this object. | |
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 |
Dumps a tree of children to the debug output. | |
void | dumpObjectInfo () const |
Dumps information about signal connections, etc. | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. | |
bool | setProperty (const char *name, QVariant &&value) |
QVariant | property (const char *name) const |
Returns the value of the object's name property. | |
QList< QByteArray > | dynamicPropertyNames () const |
QBindingStorage * | bindingStorage () |
const QBindingStorage * | bindingStorage () const |
QObject * | parent () const |
Returns a pointer to the parent object. | |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false . | |
![]() | |
static QMetaObject::Connection | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
\threadsafe | |
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::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection) |
template<typename Func1 , typename Func2 > | |
static QMetaObject::Connection | connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
\threadsafe | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static bool | disconnect (const QMetaObject::Connection &) |
Disconnect a 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) |
![]() | |
QScopedPointer< QObjectData > | d_ptr |
![]() | |
template< class T > T | qobject_cast (const QObject *object) |
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise returns \nullptr. | |
template< typename T > T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
template< typename T > QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QObjectList | |
\macro Q_CLASSINFO(Name, Value) | |
\inmodule QtDBus
The QDBusConnectionInterface class provides access to the D-Bus bus daemon service.
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 25 of file qdbusconnectioninterface.h.
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 49 of file qdbusconnectioninterface.h.
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.
Enumerator | |
---|---|
DontQueueService | |
QueueService | |
ReplaceExistingService |
Definition at line 38 of file qdbusconnectioninterface.h.
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.
Enumerator | |
---|---|
DontAllowReplacement | |
AllowReplacement |
Definition at line 44 of file qdbusconnectioninterface.h.
|
slot |
Definition at line 174 of file qdbusconnectioninterface.cpp.
References QDBus::AutoDetect, and QDBusAbstractInterface::internalConstCall().
|
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.
Referenced by QDBusConnectionPrivate::createBusService().
|
overrideprotectedvirtual |
Reimplemented from QDBusAbstractInterface.
Definition at line 308 of file qdbusconnectioninterface.cpp.
References QDBusAbstractInterface::connectNotify(), QMetaMethod::fromSignal(), NameAcquired(), NameLost(), NameOwnerChanged(), qWarning, serviceOwnerChanged(), serviceRegistered(), serviceUnregistered(), and signal.
|
overrideprotectedvirtual |
Reimplemented from QDBusAbstractInterface.
Definition at line 337 of file qdbusconnectioninterface.cpp.
References QDBusAbstractInterface::disconnectNotify(), QMetaMethod::fromSignal(), NameAcquired(), NameLost(), NameOwnerChanged(), serviceOwnerChanged(), serviceRegistered(), serviceUnregistered(), and signal.
|
slot |
Returns true
if the service name serviceName has is currently registered.
Definition at line 183 of file qdbusconnectioninterface.cpp.
References QDBus::AutoDetect, and QDBusAbstractInterface::internalConstCall().
|
slot |
Definition at line 162 of file qdbusconnectioninterface.cpp.
References QDBus::AutoDetect, and QDBusAbstractInterface::internalConstCall().
|
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.
Definition at line 233 of file qdbusconnectioninterface.cpp.
References AllowReplacement, QDBusAbstractInterface::call(), DBUS_NAME_FLAG_ALLOW_REPLACEMENT, DBUS_NAME_FLAG_DO_NOT_QUEUE, DBUS_NAME_FLAG_REPLACE_EXISTING, DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER, DBUS_REQUEST_NAME_REPLY_EXISTS, DBUS_REQUEST_NAME_REPLY_IN_QUEUE, DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER, DontAllowReplacement, DontQueueService, QueueService, ReplaceExistingService, reply, QDBusMessage::ReplyMessage, ServiceNotRegistered, ServiceQueued, and ServiceRegistered.
|
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 151 of file qdbusconnectioninterface.cpp.
References QDBus::AutoDetect, and QDBusAbstractInterface::internalConstCall().
|
signal |
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.
Referenced by connectNotify(), and disconnectNotify().
|
slot |
Returns the Unix Process ID (PID) for the process currently holding the bus service serviceName.
Definition at line 193 of file qdbusconnectioninterface.cpp.
References QDBus::AutoDetect, and QDBusAbstractInterface::internalConstCall().
Referenced by bluetoothdVersion().
|
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().
Referenced by connectNotify(), and disconnectNotify().
|
slot |
Returns the Unix User ID (UID) for the process currently holding the bus service serviceName.
Definition at line 203 of file qdbusconnectioninterface.cpp.
References QDBus::AutoDetect, and QDBusAbstractInterface::internalConstCall().
|
signal |
This signal is emitted by the D-Bus server when this application loses ownership of the bus service name given by service.
Referenced by connectNotify(), and disconnectNotify().
|
slot |
Requests that the bus start the service given by the name name.
Definition at line 212 of file qdbusconnectioninterface.cpp.
References QDBusAbstractInterface::call().
|
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 295 of file qdbusconnectioninterface.cpp.
References QDBusAbstractInterface::call(), DBUS_RELEASE_NAME_REPLY_RELEASED, reply, and QDBusMessage::ReplyMessage.
|
friend |
Definition at line 28 of file qdbusconnectioninterface.h.
|
read |
holds the activatable service names
Lists all names that can be activated on the bus.
Definition at line 32 of file qdbusconnectioninterface.h.
|
read |
holds the registered service names
Lists all names currently registered on the bus.
Definition at line 32 of file qdbusconnectioninterface.h.