QtBase  v6.3.1
Public Member Functions | Protected Member Functions | List of all members
QDBusAbstractInterface Class Reference

The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the Qt D-Bus binding, allowing access to remote interfaces. More...

#include <qdbusabstractinterface.h>

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

Public Member Functions

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
 

Protected Member Functions

 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
 
- 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)
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 
- 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
 
- Properties inherited from QObject
QString objectName
 the name of this object More...
 

Detailed Description

The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the Qt D-Bus binding, allowing access to remote interfaces.

\inmodule QtDBus

Since
4.2

Generated-code classes also derive from QDBusAbstractInterface, all methods described here are also valid for generated-code classes. In addition to those described here, generated-code classes provide member functions for the remote methods, which allow for compile-time checking of the correct parameters and return values, as well as property type-matching and signal parameter-matching.

See also
{qdbusxml2cpp.html}{The QDBus compiler}, QDBusInterface

Definition at line 78 of file qdbusabstractinterface.h.

Constructor & Destructor Documentation

◆ ~QDBusAbstractInterface()

QDBusAbstractInterface::~QDBusAbstractInterface ( )
virtual

Releases this object's resources.

Definition at line 349 of file qdbusabstractinterface.cpp.

◆ QDBusAbstractInterface() [1/2]

QDBusAbstractInterface::QDBusAbstractInterface ( const QString service,
const QString path,
const char *  interface,
const QDBusConnection connection,
QObject parent 
)
protected

Definition at line 336 of file qdbusabstractinterface.cpp.

◆ QDBusAbstractInterface() [2/2]

QDBusAbstractInterface::QDBusAbstractInterface ( QDBusAbstractInterfacePrivate d,
QObject parent 
)
protected

Definition at line 325 of file qdbusabstractinterface.cpp.

Member Function Documentation

◆ asyncCall() [1/2]

QDBusAbstractInterface::asyncCall ( const QString method)
inline

Definition at line 137 of file qdbusabstractinterface.h.

Here is the caller graph for this function:

◆ asyncCall() [2/2]

template<typename... Args>
template< typename...Args > QDBusPendingCall QDBusAbstractInterface::asyncCall ( const QString method,
Args &&...  args 
)
inline

Calls the method method on this interface and passes args to the method. All args must be convertible to QVariant.

The parameters to call are passed on to the remote function via D-Bus as input arguments. The returned QDBusPendingCall object can be used to find out information about the reply.

It can be used the following way:

This example illustrates function calling with 0, 1 and 2 parameters and illustrates different parameter types passed in each (the first call to "ProcessWorkUnicode" will contain one Unicode string, the second call to "ProcessWork" will contain one string and one byte array).

Note
Before Qt 5.14, this function accepted a maximum of just eight (8) arguments.
See also
asyncCallWithArgumentList()

Definition at line 143 of file qdbusabstractinterface.h.

◆ asyncCallWithArgumentList()

QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList ( const QString method,
const QList< QVariant > &  args 
)
Since
4.5 Places a call to the remote method specified by method on this interface, using args as arguments. This function returns a QDBusPendingCall object that can be used to track the status of the reply and access its contents once it has arrived.

Normally, you should place calls using asyncCall().

\threadsafe

Definition at line 516 of file qdbusabstractinterface.cpp.

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

◆ call() [1/4]

QDBusAbstractInterface::call ( const QString method)
inline

Definition at line 102 of file qdbusabstractinterface.h.

Here is the caller graph for this function:

◆ call() [2/4]

template<typename... Args>
template< typename...Args > QDBusMessage QDBusAbstractInterface::call ( const QString method,
Args &&...  args 
)
inline

Calls the method method on this interface and passes args to the method. All args must be convertible to QVariant.

The parameters to call are passed on to the remote function via D-Bus as input arguments. Output arguments are returned in the QDBusMessage reply. If the reply is an error reply, lastError() will also be set to the contents of the error message.

It can be used the following way:

This example illustrates function calling with 0, 1 and 2 parameters and illustrates different parameter types passed in each (the first call to "ProcessWorkUnicode" will contain one Unicode string, the second call to "ProcessWork" will contain one string and one byte array).

Note
Before Qt 5.14, this function accepted a maximum of just eight (8) arguments.
See also
callWithArgumentList()

Definition at line 108 of file qdbusabstractinterface.h.

◆ call() [3/4]

QDBusAbstractInterface::call ( QDBus::CallMode  mode,
const QString method 
)
inline

Definition at line 114 of file qdbusabstractinterface.h.

◆ call() [4/4]

template<typename... Args>
template< typename...Args > QDBusMessage QDBusAbstractInterface::call ( QDBus::CallMode  mode,
const QString method,
Args &&...  args 
)
inline

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. All args must be convertible to QVariant.

If mode is NoWaitForReply, then this function will return immediately after placing the call, without waiting for a reply from the remote method. Otherwise, mode indicates whether this function should activate the Qt Event Loop while waiting for the reply to arrive.

If this function reenters the Qt event loop in order to wait for the reply, it will exclude user input. During the wait, it may deliver signals and other method calls to your application. Therefore, it must be prepared to handle a reentrancy whenever a call is placed with call().

Note
Before Qt 5.14, this function accepted a maximum of just eight (8) arguments.
See also
callWithArgumentList()

Definition at line 120 of file qdbusabstractinterface.h.

◆ callWithArgumentList()

QDBusMessage QDBusAbstractInterface::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. This function returns the message that was received as a reply, which can be a normal QDBusMessage::ReplyMessage (indicating success) or QDBusMessage::ErrorMessage (if the call failed). The mode parameter specifies how this call should be placed.

If the call succeeds, lastError() will be cleared; otherwise, it will contain the error this call produced.

Normally, you should place calls using call().

Warning
If you use UseEventLoop, your code must be prepared to deal with any reentrancy: other method calls and signals may be delivered before this function returns, as well as other Qt queued signals and events.

\threadsafe

Definition at line 452 of file qdbusabstractinterface.cpp.

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

◆ callWithCallback() [1/2]

bool QDBusAbstractInterface::callWithCallback ( const QString method,
const QList< QVariant > &  args,
QObject receiver,
const char *  slot 
)

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. Please use the overloaded version.

Places a call to the remote method specified by method on this interface, using args as arguments. This function returns immediately after queueing the call. The reply from the remote function or any errors emitted by it are delivered to the slot slot on object receiver.

This function returns true if the queueing succeeded: it does not indicate that the call succeeded. If it failed, the slot will be called with an error message. lastError() will not be set under those circumstances.

See also
QDBusError, QDBusMessage

Definition at line 595 of file qdbusabstractinterface.cpp.

Here is the call graph for this function:

◆ callWithCallback() [2/2]

bool QDBusAbstractInterface::callWithCallback ( const QString method,
const QList< QVariant > &  args,
QObject receiver,
const char *  returnMethod,
const char *  errorMethod 
)

Places a call to the remote method specified by method on this interface, using args as arguments. This function returns immediately after queueing the call. The reply from the remote function is delivered to the returnMethod on object receiver. If an error occurs, the errorMethod on object receiver is called instead.

This function returns true if the queueing succeeds. It does not indicate that the executed call succeeded. If it fails, the errorMethod is called. If the queueing failed, this function returns false and no slot will be called.

The returnMethod must have as its parameters the types returned by the function call. Optionally, it may have a QDBusMessage parameter as its last or only parameter. The errorMethod must have a QDBusError as its only parameter.

Since
4.3
See also
QDBusError, QDBusMessage

Definition at line 551 of file qdbusabstractinterface.cpp.

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

◆ connection()

QDBusConnection QDBusAbstractInterface::connection ( ) const

Returns the connection this interface is associated with.

Definition at line 375 of file qdbusabstractinterface.cpp.

Here is the caller graph for this function:

◆ connectNotify()

void QDBusAbstractInterface::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 QObject.

Reimplemented in QDBusConnectionInterface.

Definition at line 607 of file qdbusabstractinterface.cpp.

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

◆ disconnectNotify()

void QDBusAbstractInterface::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 QObject.

Reimplemented in QDBusConnectionInterface.

Definition at line 630 of file qdbusabstractinterface.cpp.

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

◆ interface()

QString QDBusAbstractInterface::interface ( ) const

Returns the name of this interface.

Definition at line 399 of file qdbusabstractinterface.cpp.

Here is the caller graph for this function:

◆ internalConstCall()

QDBusMessage QDBusAbstractInterface::internalConstCall ( QDBus::CallMode  mode,
const QString method,
const QList< QVariant > &  args = QList<QVariant>() 
) const
protected

Definition at line 782 of file qdbusabstractinterface.cpp.

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

◆ internalPropGet()

QVariant QDBusAbstractInterface::internalPropGet ( const char *  propname) const
protected

Definition at line 676 of file qdbusabstractinterface.cpp.

Here is the call graph for this function:

◆ internalPropSet()

void QDBusAbstractInterface::internalPropSet ( const char *  propname,
const QVariant value 
)
protected

Definition at line 688 of file qdbusabstractinterface.cpp.

Here is the call graph for this function:

◆ isValid()

bool QDBusAbstractInterface::isValid ( ) const

Returns true if this is a valid reference to a remote object. It returns false if there was an error during the creation of this interface (for instance, if the remote application does not exist).

Note: when dealing with remote objects, it is not always possible to determine if it exists when creating a QDBusInterface.

Definition at line 361 of file qdbusabstractinterface.cpp.

Here is the caller graph for this function:

◆ lastError()

QDBusError QDBusAbstractInterface::lastError ( ) const

Returns the error the last operation produced, or an invalid error if the last operation did not produce an error.

Definition at line 408 of file qdbusabstractinterface.cpp.

Here is the caller graph for this function:

◆ path()

QString QDBusAbstractInterface::path ( ) const

Returns the object path that this interface is associated with.

Definition at line 391 of file qdbusabstractinterface.cpp.

Here is the caller graph for this function:

◆ service()

QString QDBusAbstractInterface::service ( ) const

Returns the name of the service this interface is associated with.

Definition at line 383 of file qdbusabstractinterface.cpp.

Here is the caller graph for this function:

◆ setTimeout()

void QDBusAbstractInterface::setTimeout ( int  timeout)

Sets the timeout in milliseconds for all future DBus calls to timeout. -1 means the default DBus timeout (usually 25 seconds).

Since
4.8

Definition at line 419 of file qdbusabstractinterface.cpp.

Here is the call graph for this function:

◆ timeout()

int QDBusAbstractInterface::timeout ( ) const

Returns the current value of the timeout in milliseconds. -1 means the default DBus timeout (usually 25 seconds).

Since
4.8

Definition at line 430 of file qdbusabstractinterface.cpp.

Here is the caller graph for this function:

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