![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtDBus More...
#include <qdbusabstractinterface.h>
Public Member Functions | |
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 . | |
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 |
![]() | |
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) | |
Additional Inherited Members | |
![]() | |
void | deleteLater () |
\threadsafe | |
![]() | |
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. | |
![]() | |
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 |
![]() | |
QString | objectName |
the name of this object | |
![]() | |
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 QDBusAbstractInterface class is the base class for all D-Bus interfaces in the Qt D-Bus binding, allowing access to remote interfaces.
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.
Definition at line 42 of file qdbusabstractinterface.h.
|
virtual |
Releases this object's resources.
Definition at line 314 of file qdbusabstractinterface.cpp.
|
protected |
This is the constructor called from static classes derived from QDBusAbstractInterface (i.e., those generated by dbusxml2cpp).
Definition at line 301 of file qdbusabstractinterface.cpp.
|
protected |
This is the constructor called from QDBusInterface::QDBusInterface.
Definition at line 290 of file qdbusabstractinterface.cpp.
References d.
|
inline |
Definition at line 101 of file qdbusabstractinterface.h.
References method.
Referenced by DBus_PendingCall_Interface::callInterfaceMain(), QDBusMenuRegistrarInterface::GetMenuForWindow(), DBus_PendingReply_Interface::PendingReplyBool(), DBus_PendingReply_Interface::PendingReplyString(), QDBusMenuRegistrarInterface::RegisterWindow(), and QDBusMenuRegistrarInterface::UnregisterWindow().
|
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).
Definition at line 107 of file qdbusabstractinterface.h.
QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList | ( | const QString & | method, |
const QList< QVariant > & | args | ||
) |
Normally, you should place calls using asyncCall().
\threadsafe
Definition at line 481 of file qdbusabstractinterface.cpp.
References args, QDBusMessage::createMethodCall(), d, QDBusPendingCall::fromError(), interface(), method, path(), service(), QDBusMessage::setArguments(), and QDBusMessagePrivate::setParametersValidated().
Referenced by OrgBluezDevice1Interface::CancelPairing(), OrgBluezDevice1Interface::Connect(), OrgBluezDevice1Interface::ConnectProfile(), QIBusProxy::CreateInputContext(), QIBusProxyPortal::CreateInputContext(), QIBusInputContextProxy::Destroy(), QIBusInputContextProxy::Disable(), OrgBluezDevice1Interface::Disconnect(), OrgBluezDevice1Interface::DisconnectProfile(), QIBusInputContextProxy::Enable(), QIBusProxy::Exit(), QIBusInputContextProxy::FocusIn(), QIBusInputContextProxy::FocusOut(), OrgFreedesktopDBusPropertiesInterface::Get(), OrgFreedesktopDBusPropertiesInterface::GetAll(), QIBusInputContextProxy::GetEngine(), OrgFreedesktopDBusObjectManagerInterface::GetManagedObjects(), QIBusInputContextProxy::IsEnabled(), OrgBluezProfile1Interface::NewConnection(), OrgBluezDevice1Interface::Pair(), QIBusProxy::Ping(), QIBusInputContextProxy::ProcessKeyEvent(), QIBusInputContextProxy::PropertyActivate(), OrgBluezGattCharacteristic1Interface::ReadValue(), OrgBluezGattDescriptor1Interface::ReadValue(), OrgBluezLEAdvertisingManager1Interface::RegisterAdvertisement(), OrgBluezGattManager1Interface::RegisterApplication(), QIBusProxy::RegisterComponent(), OrgBluezProfileManager1Interface::RegisterProfile(), OrgBluezAdapter1Interface::RemoveDevice(), OrgBluezProfile1Interface::RequestDisconnection(), QIBusInputContextProxy::Reset(), OrgFreedesktopDBusPropertiesInterface::Set(), QIBusInputContextProxy::SetCapabilities(), QIBusInputContextProxy::SetCursorLocation(), QIBusInputContextProxy::SetCursorLocationRelative(), OrgBluezAdapter1Interface::SetDiscoveryFilter(), QIBusInputContextProxy::SetEngine(), QIBusInputContextProxy::SetSurroundingText(), OrgBluezAdapter1Interface::StartDiscovery(), OrgBluezGattCharacteristic1Interface::StartNotify(), OrgBluezAdapter1Interface::StopDiscovery(), OrgBluezGattCharacteristic1Interface::StopNotify(), OrgBluezLEAdvertisingManager1Interface::UnregisterAdvertisement(), OrgBluezGattManager1Interface::UnregisterApplication(), OrgBluezProfileManager1Interface::UnregisterProfile(), OrgBluezGattCharacteristic1Interface::WriteValue(), and OrgBluezGattDescriptor1Interface::WriteValue().
|
inline |
Definition at line 66 of file qdbusabstractinterface.h.
References QDBus::AutoDetect, and method.
Referenced by DBusInterface_main(), QDBusMenuRegistrarInterface::GetMenuForWindow(), QDBusConnectionInterface::registerService(), QDBusConnectionInterface::startService(), and QDBusConnectionInterface::unregisterService().
|
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).
Definition at line 72 of file qdbusabstractinterface.h.
References args, QDBus::AutoDetect, and method.
|
inline |
Definition at line 78 of file qdbusabstractinterface.h.
References method.
|
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().
Definition at line 84 of file qdbusabstractinterface.h.
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().
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 417 of file qdbusabstractinterface.cpp.
References args, QDBus::AutoDetect, QDBus::Block, QListSpecialMethodsBase< T >::contains(), QDBusMessage::createError(), QDBusMessage::createMethodCall(), QThread::currentThread(), d, i, interface(), match(), metaObject(), method, mo, QMetaMethod::name(), QDBus::NoBlock, path(), pos, reply, service(), QDBusMessage::setArguments(), QDBusMessagePrivate::setParametersValidated(), QByteArray::split(), QMetaMethod::tag(), and QObject::thread().
Referenced by QNetworkManagerInterface::QNetworkManagerInterface(), internalConstCall(), and OrgBluezProfile1Interface::Release().
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.
Definition at line 560 of file qdbusabstractinterface.cpp.
References args, callWithCallback(), and method.
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.
Definition at line 516 of file qdbusabstractinterface.cpp.
References args, QDBusMessage::createMethodCall(), d, interface(), method, path(), service(), QDBusMessage::setArguments(), and QDBusMessagePrivate::setParametersValidated().
Referenced by callWithCallback().
QDBusConnection QDBusAbstractInterface::connection | ( | ) | const |
Returns the connection this interface is associated with.
Definition at line 340 of file qdbusabstractinterface.cpp.
Referenced by QIBusProxy::QIBusProxy(), and QIBusProxy::GetProperty().
|
overrideprotectedvirtual |
Catch signal connections.
Reimplemented from QObject.
Reimplemented in QDBusConnectionInterface.
Definition at line 572 of file qdbusabstractinterface.cpp.
References QDBusConnectionPrivate::connectRelay(), d, QObject::destroyed(), QMetaMethod::fromSignal(), and signal.
Referenced by QDBusConnectionInterface::connectNotify().
|
overrideprotectedvirtual |
Catch signal disconnections.
Reimplemented from QObject.
Reimplemented in QDBusConnectionInterface.
Definition at line 595 of file qdbusabstractinterface.cpp.
References d, QCoreApplication::postEvent(), and signal.
Referenced by QDBusConnectionInterface::disconnectNotify().
QString QDBusAbstractInterface::interface | ( | ) | const |
Returns the name of this interface.
Definition at line 364 of file qdbusabstractinterface.cpp.
Referenced by QIBusProxy::QIBusProxy(), asyncCallWithArgumentList(), callWithArgumentList(), callWithCallback(), OrgFreedesktopDBusPropertiesInterface::Get(), OrgFreedesktopDBusPropertiesInterface::GetAll(), QIBusProxy::GetProperty(), and OrgFreedesktopDBusPropertiesInterface::Set().
|
protected |
Definition at line 747 of file qdbusabstractinterface.cpp.
References args, callWithArgumentList(), and method.
Referenced by QDBusConnectionInterface::activatableServiceNames(), QDBusConnectionInterface::isServiceRegistered(), QDBusConnectionInterface::registeredServiceNames(), QDBusConnectionInterface::serviceOwner(), QDBusConnectionInterface::servicePid(), and QDBusConnectionInterface::serviceUid().
|
protected |
Get the value of the property propname.
Definition at line 641 of file qdbusabstractinterface.cpp.
References property.
|
protected |
Set the value of the property propname to value.
Definition at line 653 of file qdbusabstractinterface.cpp.
References QObject::setProperty().
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 326 of file qdbusabstractinterface.cpp.
References d, and QDBusConnectionPrivate::PeerMode.
Referenced by QNetworkManagerInterface::QNetworkManagerInterface(), QIBusProxy::GetProperty(), QNetworkManagerNetworkInformationBackend::isValid(), QNetworkManagerInterfaceBase::networkManagerAvailable(), and QDBusInterface::qt_metacall().
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 373 of file qdbusabstractinterface.cpp.
Referenced by QIBusProxy::GetProperty().
QString QDBusAbstractInterface::path | ( | ) | const |
Returns the object path that this interface is associated with.
Definition at line 356 of file qdbusabstractinterface.cpp.
Referenced by asyncCallWithArgumentList(), callWithArgumentList(), callWithCallback(), QIBusProxy::GetProperty(), and QLeDBusAdvertiser::startAdvertising().
QString QDBusAbstractInterface::service | ( | ) | const |
Returns the name of the service this interface is associated with.
Definition at line 348 of file qdbusabstractinterface.cpp.
Referenced by asyncCallWithArgumentList(), callWithArgumentList(), callWithCallback(), and QIBusProxy::GetProperty().
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).
Definition at line 384 of file qdbusabstractinterface.cpp.
References timeout().
int QDBusAbstractInterface::timeout | ( | ) | const |
Returns the current value of the timeout in milliseconds.
-1 means the default DBus timeout (usually 25 seconds).
Definition at line 395 of file qdbusabstractinterface.cpp.
Referenced by QIBusProxy::GetProperty(), and setTimeout().