Qt 4.8
Public Functions | Protected Functions | List of all members
QDBusAbstractInterface Class Reference

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

#include <qdbusabstractinterface.h>

Inheritance diagram for QDBusAbstractInterface:
QObject QConnmanAgentInterface QConnmanCounterInterface QConnmanManagerInterface QConnmanProfileInterface QConnmanServiceInterface QConnmanTechnologyInterface QDBusConnectionInterface QDBusInterface QOfonoDataConnectionManagerInterface QOfonoManagerInterface QOfonoModemInterface QOfonoNetworkOperatorInterface QOfonoNetworkRegistrationInterface QOfonoPrimaryDataContextInterface QOfonoSimInterface QOfonoSmsInterface

Public Functions

QDBusPendingCall asyncCall (const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
 Calls the method method on this interface and passes the parameters to this function to the method. More...
 
QDBusPendingCall asyncCallWithArgumentList (const QString &method, const QList< QVariant > &args)
 Places a call to the remote method specified by method on this interface, using args as arguments. More...
 
QDBusMessage call (const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
 Calls the method method on this interface and passes the parameters to this function to the method. More...
 
QDBusMessage call (QDBus::CallMode mode, const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
 Calls the method method on this interface and passes the parameters to this function to the method. More...
 
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. More...
 
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. More...
 
bool callWithCallback (const QString &method, const QList< QVariant > &args, QObject *receiver, const char *member)
 This function is deprecated. More...
 
QDBusConnection connection () const
 Returns the connection this interface is assocated with. More...
 
QString interface () const
 Returns the name of this interface. More...
 
bool isValid () const
 Returns true if this is a valid reference to a remote object. More...
 
QDBusError lastError () const
 Returns the error the last operation produced, or an invalid error if the last operation did not produce an error. More...
 
QString path () const
 Returns the object path that this interface is associated with. More...
 
QString service () const
 Returns the name of the service this interface is associated with. More...
 
void setTimeout (int timeout)
 Sets the timeout in milliseconds for all future DBus calls to timeout. More...
 
int timeout () const
 Returns the current value of the timeout in milliseconds. More...
 
virtual ~QDBusAbstractInterface ()
 Releases this object's resources. More...
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) 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. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
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. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 

Protected Functions

void connectNotify (const char *signal)
 Catch signal connections. More...
 
void disconnectNotify (const char *signal)
 Catch signal disconnections. More...
 
QDBusMessage internalConstCall (QDBus::CallMode mode, const QString &method, const QList< QVariant > &args=QList< QVariant >()) const
 
QVariant internalPropGet (const char *propname) const
 Get the value of the property propname. More...
 
void internalPropSet (const char *propname, const QVariant &value)
 Set the value of the property propname to value. More...
 
 QDBusAbstractInterface (const QString &service, const QString &path, const char *interface, const QDBusConnection &connection, QObject *parent)
 This is the constructor called from static classes derived from QDBusAbstractInterface (i. More...
 
 QDBusAbstractInterface (QDBusAbstractInterfacePrivate &, QObject *parent)
 This is the constructor called from QDBusInterface::QDBusInterface. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

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

Attention
Module: 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 77 of file qdbusabstractinterface.h.

Constructors and Destructors

◆ ~QDBusAbstractInterface()

QDBusAbstractInterface::~QDBusAbstractInterface ( )
virtual

Releases this object's resources.

Definition at line 338 of file qdbusabstractinterface.cpp.

339 {
340 }

◆ QDBusAbstractInterface() [1/2]

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

This is the constructor called from static classes derived from QDBusAbstractInterface (i.

Warning
This function is not part of the public interface. e., those generated by dbusxml2cpp).

Definition at line 315 of file qdbusabstractinterface.cpp.

319  con, false), parent)
320 {
321  // keep track of the service owner
322  if (d_func()->isValid &&
323  d_func()->connection.isConnected()
324  && !service.isEmpty()
325  && !service.startsWith(QLatin1Char(':')))
326  d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service
327  QString(), // path
328  QLatin1String(DBUS_INTERFACE_DBUS), // interface
329  QLatin1String("NameOwnerChanged"),
330  QStringList() << service,
331  QString(), //signature
332  this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
333 }
bool isValid() const
Returns true if this is a valid reference to a remote object.
QDBusConnection connection() const
Returns the connection this interface is assocated with.
#define SLOT(a)
Definition: qobjectdefs.h:226
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
QString interface() const
Returns the name of this interface.
The QString class provides a Unicode character string.
Definition: qstring.h:83
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
bool isConnected() const
Returns true if this QDBusConnection object is connected.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ QDBusAbstractInterface() [2/2]

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

This is the constructor called from QDBusInterface::QDBusInterface.

Warning
This function is not part of the public interface.

Definition at line 290 of file qdbusabstractinterface.cpp.

291  : QDBusAbstractInterfaceBase(d, parent)
292 {
293  // keep track of the service owner
294  if (d.isValid &&
296  && !d.service.isEmpty()
297  && !d.service.startsWith(QLatin1Char(':')))
298  d_func()->connection.connect(QLatin1String(DBUS_SERVICE_DBUS), // service
299  QString(), // path
300  QLatin1String(DBUS_INTERFACE_DBUS), // interface
301  QLatin1String("NameOwnerChanged"),
302  QStringList() << d.service,
303  QString(), // signature
304  this, SLOT(_q_serviceOwnerChanged(QString,QString,QString)));
305 }
#define SLOT(a)
Definition: qobjectdefs.h:226
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition: qstring.cpp:3734
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
The QStringList class provides a list of strings.
Definition: qstringlist.h:66
bool isConnected() const
Returns true if this QDBusConnection object is connected.
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Functions

◆ asyncCall()

QDBusPendingCall QDBusAbstractInterface::asyncCall ( const QString method,
const QVariant arg1 = QVariant(),
const QVariant arg2 = QVariant(),
const QVariant arg3 = QVariant(),
const QVariant arg4 = QVariant(),
const QVariant arg5 = QVariant(),
const QVariant arg6 = QVariant(),
const QVariant arg7 = QVariant(),
const QVariant arg8 = QVariant() 
)

Calls the method method on this interface and passes the parameters to this function to the method.

Since
4.5

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.

This function can be used with up to 8 parameters, passed in arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7 and arg8. If you need more than 8 parameters or if you have a variable number of parameters to be passed, use asyncCallWithArgumentList().

It can be used the following way:

QString value = retrieveValue();
QDBusPendingCall pcall = interface->asyncCall(QLatin1String("Process"), value);
this, SLOT(callFinishedSlot(QDBusPendingCallWatcher*)));

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 783 of file qdbusabstractinterface.cpp.

Referenced by QNetworkManagerInterface::activateConnection(), QConnmanServiceInterface::connect(), and QNetworkSessionPrivateImpl::do_open().

791 {
792  QList<QVariant> argList;
793  int count = 0 + arg1.isValid() + arg2.isValid() + arg3.isValid() + arg4.isValid() +
794  arg5.isValid() + arg6.isValid() + arg7.isValid() + arg8.isValid();
795 
796  switch (count) {
797  case 8:
798  argList.prepend(arg8);
799  case 7:
800  argList.prepend(arg7);
801  case 6:
802  argList.prepend(arg6);
803  case 5:
804  argList.prepend(arg5);
805  case 4:
806  argList.prepend(arg4);
807  case 3:
808  argList.prepend(arg3);
809  case 2:
810  argList.prepend(arg2);
811  case 1:
812  argList.prepend(arg1);
813  }
814 
815  return asyncCallWithArgumentList(method, argList);
816 }
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
QDBusPendingCall asyncCallWithArgumentList(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 isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485

◆ asyncCallWithArgumentList()

QDBusPendingCall QDBusAbstractInterface::asyncCallWithArgumentList ( const QString method,
const QList< QVariant > &  args 
)

Places a call to the remote method specified by method on this interface, using args as arguments.

Since
4.5 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().

Note
This class or function is threadsafe.

Definition at line 502 of file qdbusabstractinterface.cpp.

Referenced by asyncCall(), QOfonoManagerInterface::getModems(), QOfonoNetworkRegistrationInterface::getOperators(), and QOfonoDataConnectionManagerInterface::getPrimaryContexts().

504 {
506 
507  if (!d->isValid || !d->canMakeCalls())
508  return QDBusPendingCall::fromError(d->lastError);
509 
512  msg.setArguments(args);
513  return d->connection.asyncCall(msg, d->timeout);
514 }
double d
Definition: qnumeric_p.h:62
QString path() const
Returns the object path that this interface is associated with.
QString interface() const
Returns the name of this interface.
#define Q_D(Class)
Definition: qglobal.h:2482
static void setParametersValidated(QDBusMessage &msg, bool enable)
The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding...
static QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Constructs a new DBus message representing a method call.
QString service() const
Returns the name of the service this interface is associated with.
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
void setArguments(const QList< QVariant > &arguments)
Sets the arguments that are going to be sent over D-Bus to arguments.
static QDBusPendingCall fromError(const QDBusError &error)
Creates a QDBusPendingCall object based on the error condition error.

◆ call() [1/2]

QDBusMessage QDBusAbstractInterface::call ( const QString method,
const QVariant arg1 = QVariant(),
const QVariant arg2 = QVariant(),
const QVariant arg3 = QVariant(),
const QVariant arg4 = QVariant(),
const QVariant arg5 = QVariant(),
const QVariant arg6 = QVariant(),
const QVariant arg7 = QVariant(),
const QVariant arg8 = QVariant() 
)

Calls the method method on this interface and passes the parameters to this function to the method.

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.

This function can be used with up to 8 parameters, passed in arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7 and arg8. If you need more than 8 parameters or if you have a variable number of parameters to be passed, use callWithArgumentList().

It can be used the following way:

QString value = retrieveValue();
QDBusReply<int> api = interface->call(QLatin1String("GetAPIVersion"));
if (api >= 14)
reply = interface->call(QLatin1String("ProcessWorkUnicode"), value);
else
reply = interface->call(QLatin1String("ProcessWork"), QLatin1String("UTF-8"), value.toUtf8());

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 685 of file qdbusabstractinterface.cpp.

Referenced by QIcdEngine::cancelAsyncConfigurationUpdate(), QIcdEngine::cleanup(), QNetworkSessionPrivateImpl::close(), QConnmanManagerInterface::connectService(), QNetworkManagerInterface::deactivateConnection(), QConnmanManagerInterface::disableTechnology(), QConnmanServiceInterface::disconnect(), QConnmanManagerInterface::enableTechnology(), QNetworkManagerInterfaceDeviceWireless::getAccessPoints(), QNetworkManagerInterface::getDevices(), QOfonoManagerInterface::getProperties(), QConnmanManagerInterface::getProperties(), QOfonoModemInterface::getProperties(), QConnmanProfileInterface::getProperties(), QOfonoNetworkRegistrationInterface::getProperties(), QConnmanServiceInterface::getProperties(), QOfonoNetworkOperatorInterface::getProperties(), QOfonoSimInterface::getProperties(), QConnmanTechnologyInterface::getProperties(), QOfonoDataConnectionManagerInterface::getProperties(), QOfonoPrimaryDataContextInterface::getProperties(), QOfonoSmsInterface::getProperties(), QConnmanManagerInterface::getServices(), QNetworkManagerSettingsConnection::getSettings(), QConnmanManagerInterface::getState(), QConnmanManagerInterface::getTechnologies(), QNetworkManagerSettings::listConnections(), QConnmanManagerInterface::lookupService(), QConnmanManagerInterface::registerCounter(), QDBusConnectionInterface::registerService(), QConnmanManagerInterface::releaseSession(), QConnmanServiceInterface::remove(), QConnmanManagerInterface::requestScan(), QConnmanManagerInterface::requestSession(), QIcdEngine::requestUpdate(), QOfonoSmsInterface::sendMessage(), QDBusConnectionInterface::startService(), QNetworkSessionPrivateImpl::stop(), QConnmanManagerInterface::unregisterCounter(), and QDBusConnectionInterface::unregisterService().

693 {
694  return call(QDBus::AutoDetect, method, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
695 }
QDBusMessage call(const QString &method, const QVariant &arg1=QVariant(), const QVariant &arg2=QVariant(), const QVariant &arg3=QVariant(), const QVariant &arg4=QVariant(), const QVariant &arg5=QVariant(), const QVariant &arg6=QVariant(), const QVariant &arg7=QVariant(), const QVariant &arg8=QVariant())
Calls the method method on this interface and passes the parameters to this function to the method...

◆ call() [2/2]

QDBusMessage QDBusAbstractInterface::call ( QDBus::CallMode  mode,
const QString method,
const QVariant arg1 = QVariant(),
const QVariant arg2 = QVariant(),
const QVariant arg3 = QVariant(),
const QVariant arg4 = QVariant(),
const QVariant arg5 = QVariant(),
const QVariant arg6 = QVariant(),
const QVariant arg7 = QVariant(),
const QVariant arg8 = QVariant() 
)

Calls the method method on this interface and passes the parameters to this function to the method.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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.

This function can be used with up to 8 parameters, passed in arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7 and arg8. If you need more than 8 parameters or if you have a variable number of parameters to be passed, use callWithArgumentList().

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 721 of file qdbusabstractinterface.cpp.

730 {
731  QList<QVariant> argList;
732  int count = 0 + arg1.isValid() + arg2.isValid() + arg3.isValid() + arg4.isValid() +
733  arg5.isValid() + arg6.isValid() + arg7.isValid() + arg8.isValid();
734 
735  switch (count) {
736  case 8:
737  argList.prepend(arg8);
738  case 7:
739  argList.prepend(arg7);
740  case 6:
741  argList.prepend(arg6);
742  case 5:
743  argList.prepend(arg5);
744  case 4:
745  argList.prepend(arg4);
746  case 3:
747  argList.prepend(arg3);
748  case 2:
749  argList.prepend(arg2);
750  case 1:
751  argList.prepend(arg1);
752  }
753 
754  return callWithArgumentList(mode, method, argList);
755 }
void prepend(const T &t)
Inserts value at the beginning of the list.
Definition: qlist.h:541
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 isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485

◆ 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.
Note
This class or function is threadsafe.

Definition at line 435 of file qdbusabstractinterface.cpp.

Referenced by call(), internalConstCall(), and QOfonoPrimaryDataContextInterface::setProp().

438 {
440 
441  if (!d->isValid || !d->canMakeCalls())
442  return QDBusMessage::createError(d->lastError);
443 
444  QString m = method;
445  // split out the signature from the method
446  int pos = method.indexOf(QLatin1Char('.'));
447  if (pos != -1)
448  m.truncate(pos);
449 
450  if (mode == QDBus::AutoDetect) {
451  // determine if this a sync or async call
452  mode = QDBus::Block;
453  const QMetaObject *mo = metaObject();
454  QByteArray match = m.toLatin1() + '(';
455 
456  for (int i = staticMetaObject.methodCount(); i < mo->methodCount(); ++i) {
457  QMetaMethod mm = mo->method(i);
458  if (QByteArray(mm.signature()).startsWith(match)) {
459  // found a method with the same name as what we're looking for
460  // hopefully, nobody is overloading asynchronous and synchronous methods with
461  // the same name
462 
463  QList<QByteArray> tags = QByteArray(mm.tag()).split(' ');
464  if (tags.contains("Q_NOREPLY"))
465  mode = QDBus::NoBlock;
466 
467  break;
468  }
469  }
470  }
471 
472 // qDebug() << "QDBusAbstractInterface" << "Service" << service() << "Path:" << path();
475  msg.setArguments(args);
476 
477  QDBusMessage reply = d->connection.call(msg, mode, d->timeout);
478  if (thread() == QThread::currentThread())
479  d->lastError = reply; // will clear if reply isn't an error
480 
481  // ensure that there is at least one element
482  if (reply.arguments().isEmpty())
483  reply << QVariant();
484 
485  return reply;
486 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double d
Definition: qnumeric_p.h:62
The QMetaObject class contains meta-information about Qt objects.
Definition: qobjectdefs.h:304
static QDBusMessage createError(const QString &name, const QString &msg)
Constructs a new DBus message representing an error, with the given name and msg. ...
QString path() const
Returns the object path that this interface is associated with.
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static bool match(const uchar *found, const char *target, uint len)
static const QMetaObject staticMetaObject
This variable stores the meta-object for the class.
Definition: qobject.h:128
QString interface() const
Returns the name of this interface.
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_D(Class)
Definition: qglobal.h:2482
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
static void setParametersValidated(QDBusMessage &msg, bool enable)
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
Definition: qthread.cpp:419
The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding...
QList< QVariant > arguments() const
Returns the list of arguments that are going to be sent or were received from D-Bus.
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
void truncate(int pos)
Truncates the string at the given position index.
Definition: qstring.cpp:4603
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
static void split(QT_FT_Vector *b)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * tag() const
Returns the tag associated with this method.
static QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Constructs a new DBus message representing a method call.
QString service() const
Returns the name of the service this interface is associated with.
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
void setArguments(const QList< QVariant > &arguments)
Sets the arguments that are going to be sent over D-Bus to arguments.
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.
const char * signature() const
Returns the signature of this method (e.g., setValue(double)).
QThread * thread() const
Returns the thread in which the object lives.
Definition: qobject.cpp:1419
int methodCount() const
Returns the number of methods known to the meta-object system in this class, including the number of ...
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
The QMetaMethod class provides meta-data about a member function.
Definition: qmetaobject.h:56
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ callWithCallback() [1/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 537 of file qdbusabstractinterface.cpp.

Referenced by callWithCallback().

542 {
544 
545  if (!d->isValid || !d->canMakeCalls())
546  return false;
547 
549  path(),
550  interface(),
551  method);
553  msg.setArguments(args);
554 
555  d->lastError = 0;
556  return d->connection.callWithCallback(msg,
557  receiver,
558  returnMethod,
559  errorMethod,
560  d->timeout);
561 }
double d
Definition: qnumeric_p.h:62
QString path() const
Returns the object path that this interface is associated with.
QString interface() const
Returns the name of this interface.
#define Q_D(Class)
Definition: qglobal.h:2482
static void setParametersValidated(QDBusMessage &msg, bool enable)
The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding...
static QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Constructs a new DBus message representing a method call.
QString service() const
Returns the name of the service this interface is associated with.
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
void setArguments(const QList< QVariant > &arguments)
Sets the arguments that are going to be sent over D-Bus to arguments.

◆ callWithCallback() [2/2]

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

This function is deprecated.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

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 584 of file qdbusabstractinterface.cpp.

588 {
589  return callWithCallback(method, args, receiver, slot, 0);
590 }
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...

◆ connection()

QDBusConnection QDBusAbstractInterface::connection ( ) const

◆ connectNotify()

void QDBusAbstractInterface::connectNotify ( const char *  signal)
protectedvirtual

Catch signal connections.

Warning
This function is not part of the public interface.

Reimplemented from QObject.

Reimplemented in QOfonoSmsInterface, QOfonoPrimaryDataContextInterface, QConnmanAgentInterface, QOfonoDataConnectionManagerInterface, QConnmanTechnologyInterface, QOfonoSimInterface, QConnmanServiceInterface, QOfonoNetworkOperatorInterface, QOfonoNetworkRegistrationInterface, QConnmanProfileInterface, QOfonoModemInterface, QConnmanManagerInterface, and QOfonoManagerInterface.

Definition at line 599 of file qdbusabstractinterface.cpp.

Referenced by QDBusConnectionInterface::unregisterService().

600 {
601  // someone connecting to one of our signals
603  if (!d->isValid)
604  return;
605 
606  // we end up recursing here, so optimize away
607  if (qstrcmp(signal + 1, "destroyed(QObject*)") == 0)
608  return;
609 
610  QDBusConnectionPrivate *conn = d->connectionPrivate();
611  if (conn) {
612  conn->connectRelay(d->service, d->path, d->interface,
613  this, signal);
614  }
615 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding...
void connectRelay(const QString &service, const QString &path, const QString &interface, QDBusAbstractInterface *receiver, const char *signal)
int qstrcmp(const QByteArray &str1, const char *str2)
Definition: qbytearray.cpp:336

◆ disconnectNotify()

void QDBusAbstractInterface::disconnectNotify ( const char *  signal)
protectedvirtual

Catch signal disconnections.

Warning
This function is not part of the public interface.

Reimplemented from QObject.

Reimplemented in QOfonoSmsInterface, QOfonoPrimaryDataContextInterface, QConnmanAgentInterface, QOfonoDataConnectionManagerInterface, QConnmanTechnologyInterface, QOfonoSimInterface, QConnmanServiceInterface, QOfonoNetworkOperatorInterface, QOfonoNetworkRegistrationInterface, QConnmanProfileInterface, QOfonoModemInterface, QConnmanManagerInterface, and QOfonoManagerInterface.

Definition at line 624 of file qdbusabstractinterface.cpp.

Referenced by QDBusConnectionInterface::unregisterService().

625 {
626  // someone disconnecting from one of our signals
628  if (!d->isValid)
629  return;
630 
631  QDBusConnectionPrivate *conn = d->connectionPrivate();
632  if (conn)
633  conn->disconnectRelay(d->service, d->path, d->interface,
634  this, signal);
635 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding...
void disconnectRelay(const QString &service, const QString &path, const QString &interface, QDBusAbstractInterface *receiver, const char *signal)

◆ interface()

QString QDBusAbstractInterface::interface ( ) const

Returns the name of this interface.

Definition at line 382 of file qdbusabstractinterface.cpp.

Referenced by asyncCallWithArgumentList(), callWithArgumentList(), callWithCallback(), do_dbus_call(), and setupDBusInterface().

383 {
384  return d_func()->interface;
385 }

◆ internalConstCall()

QDBusMessage QDBusAbstractInterface::internalConstCall ( QDBus::CallMode  mode,
const QString method,
const QList< QVariant > &  args = QList<QVariant>() 
) const
protected
Warning
This function is not part of the public interface.

Definition at line 821 of file qdbusabstractinterface.cpp.

Referenced by QDBusConnectionInterface::isServiceRegistered(), QDBusConnectionInterface::serviceOwner(), QDBusConnectionInterface::servicePid(), and QDBusConnectionInterface::serviceUid().

824 {
825  // ### move the code here, and make the other functions call this
826  return const_cast<QDBusAbstractInterface*>(this)->callWithArgumentList(mode, method, args);
827 }
The QDBusAbstractInterface class is the base class for all D-Bus interfaces in the QtDBus binding...
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...

◆ internalPropGet()

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

Get the value of the property propname.

Warning
This function is not part of the public interface.

Definition at line 644 of file qdbusabstractinterface.cpp.

645 {
646  // assume this property exists and is readable
647  // we're only called from generated code anyways
648 
649  return property(propname);
650 }
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807

◆ internalPropSet()

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

Set the value of the property propname to value.

Warning
This function is not part of the public interface.

Definition at line 659 of file qdbusabstractinterface.cpp.

660 {
661  setProperty(propname, value);
662 }
bool setProperty(const char *name, const QVariant &value)
Sets the value of the object&#39;s name property to value.
Definition: qobject.cpp:3755

◆ isValid()

bool QDBusAbstractInterface::isValid ( ) const

◆ 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 391 of file qdbusabstractinterface.cpp.

Referenced by QDBusInterfacePrivate::metacall().

392 {
393  return d_func()->lastError;
394 }

◆ path()

QString QDBusAbstractInterface::path ( ) const

◆ service()

QString QDBusAbstractInterface::service ( ) const

◆ 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 402 of file qdbusabstractinterface.cpp.

403 {
404  d_func()->timeout = timeout;
405 }
int timeout() const
Returns the current value of the timeout in milliseconds.

◆ 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 413 of file qdbusabstractinterface.cpp.

Referenced by setTimeout().

414 {
415  return d_func()->timeout;
416 }

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