Qt 4.8
Public Functions | Public Variables | List of all members
QDBusAbstractInterfacePrivate Class Reference

#include <qdbusabstractinterface_p.h>

Inheritance diagram for QDBusAbstractInterfacePrivate:
QObjectPrivate QObjectData QDBusInterfacePrivate

Public Functions

void _q_serviceOwnerChanged (const QString &name, const QString &oldOwner, const QString &newOwner)
 
bool canMakeCalls () const
 
QDBusConnectionPrivateconnectionPrivate () const
 
void property (const QMetaProperty &mp, QVariant &where) const
 
 QDBusAbstractInterfacePrivate (const QString &serv, const QString &p, const QString &iface, const QDBusConnection &con, bool dynamic)
 
bool setProperty (const QMetaProperty &mp, const QVariant &value)
 
virtual ~QDBusAbstractInterfacePrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

QDBusConnection connection
 
QString currentOwner
 
QString interface
 
bool isValid
 
QDBusError lastError
 
QString path
 
QString service
 
int timeout
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 69 of file qdbusabstractinterface_p.h.

Constructors and Destructors

◆ QDBusAbstractInterfacePrivate()

QDBusAbstractInterfacePrivate::QDBusAbstractInterfacePrivate ( const QString serv,
const QString p,
const QString iface,
const QDBusConnection con,
bool  dynamic 
)

Definition at line 83 of file qdbusabstractinterface.cpp.

88  : connection(con), service(serv), path(p), interface(iface),
89  lastError(checkIfValid(serv, p, iface, isDynamic, (connectionPrivate() &&
91  timeout(-1),
93 {
94  if (!isValid)
95  return;
96 
97  if (!connection.isConnected()) {
99  QLatin1String("Not connected to D-Bus server"));
100  } else if (!service.isEmpty()) {
101  currentOwner = connectionPrivate()->getNameOwner(service); // verify the name owner
102  if (currentOwner.isEmpty()) {
104  }
105  }
106 }
bool isValid() const
Returns true if this is a valid error condition (i.e., if there was an error), otherwise false...
Definition: qdbuserror.cpp:356
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
static QDBusError checkIfValid(const QString &service, const QString &path, const QString &interface, bool isDynamic, bool isPeer)
bool isConnected() const
Returns true if this QDBusConnection object is connected.
QString getNameOwner(const QString &service)
QDBusConnectionPrivate * connectionPrivate() const

◆ ~QDBusAbstractInterfacePrivate()

virtual QDBusAbstractInterfacePrivate::~QDBusAbstractInterfacePrivate ( )
inlinevirtual

Definition at line 88 of file qdbusabstractinterface_p.h.

88 { }

Functions

◆ _q_serviceOwnerChanged()

void QDBusAbstractInterfacePrivate::_q_serviceOwnerChanged ( const QString name,
const QString oldOwner,
const QString newOwner 
)

Definition at line 223 of file qdbusabstractinterface.cpp.

Referenced by connectionPrivate().

226 {
227  Q_UNUSED(oldOwner);
228  //qDebug() << "QDBusAbstractInterfacePrivate serviceOwnerChanged" << name << oldOwner << newOwner;
229  if (name == service) {
230  currentOwner = newOwner;
231  }
232 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ canMakeCalls()

bool QDBusAbstractInterfacePrivate::canMakeCalls ( ) const

Definition at line 108 of file qdbusabstractinterface.cpp.

Referenced by property(), setProperty(), and ~QDBusAbstractInterfacePrivate().

109 {
110  // recheck only if we have a wildcard (i.e. empty) service or path
111  // if any are empty, set the error message according to QDBusUtil
114  if (path.isEmpty())
116  return true;
117 }
bool checkBusName(const QString &name, AllowEmptyFlag empty, QDBusError *error)
Definition: qdbusutil_p.h:111
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool checkObjectPath(const QString &path, AllowEmptyFlag empty, QDBusError *error)
Definition: qdbusutil_p.h:123
QDBusConnectionPrivate * connectionPrivate() const

◆ connectionPrivate()

QDBusConnectionPrivate* QDBusAbstractInterfacePrivate::connectionPrivate ( ) const
inline

Definition at line 96 of file qdbusabstractinterface_p.h.

Referenced by canMakeCalls(), QDBusAbstractInterfacePrivate(), and QDBusInterfacePrivate::QDBusInterfacePrivate().

static QDBusConnectionPrivate * d(const QDBusConnection &q)

◆ property()

void QDBusAbstractInterfacePrivate::property ( const QMetaProperty mp,
QVariant where 
) const

Definition at line 119 of file qdbusabstractinterface.cpp.

Referenced by ~QDBusAbstractInterfacePrivate().

120 {
121  if (!isValid || !canMakeCalls()) { // can't make calls
122  where.clear();
123  return;
124  }
125 
126  // is this metatype registered?
127  const char *expectedSignature = "";
128  if (mp.type() != 0xff) {
129  expectedSignature = QDBusMetaType::typeToSignature(where.userType());
130  if (expectedSignature == 0) {
131  qWarning("QDBusAbstractInterface: type %s must be registered with QtDBus before it can be "
132  "used to read property %s.%s",
133  mp.typeName(), qPrintable(interface), mp.name());
135  QString::fromLatin1("Unregistered type %1 cannot be handled")
136  .arg(QLatin1String(mp.typeName())));
137  where.clear();
138  return;
139  }
140  }
141 
142  // try to read this property
144  QLatin1String(DBUS_INTERFACE_PROPERTIES),
145  QLatin1String("Get"));
147  msg << interface << QString::fromUtf8(mp.name());
149 
150  if (reply.type() != QDBusMessage::ReplyMessage) {
151  lastError = reply;
152  where.clear();
153  return;
154  }
155  if (reply.signature() != QLatin1String("v")) {
156  QString errmsg = QLatin1String("Invalid signature `%1' in return from call to "
157  DBUS_INTERFACE_PROPERTIES);
158  lastError = QDBusError(QDBusError::InvalidSignature, errmsg.arg(reply.signature()));
159  where.clear();
160  return;
161  }
162 
163  QByteArray foundSignature;
164  const char *foundType = 0;
165  QVariant value = qvariant_cast<QDBusVariant>(reply.arguments().at(0)).variant();
166 
167  if (value.userType() == where.userType() || mp.type() == 0xff
168  || (expectedSignature[0] == 'v' && expectedSignature[1] == '\0')) {
169  // simple match
170  where = value;
171  return;
172  }
173 
174  if (value.userType() == qMetaTypeId<QDBusArgument>()) {
176 
177  foundType = "user type";
178  foundSignature = arg.currentSignature().toLatin1();
179  if (foundSignature == expectedSignature) {
180  // signatures match, we can demarshall
181  QDBusMetaType::demarshall(arg, where.userType(), where.data());
182  return;
183  }
184  } else {
185  foundType = value.typeName();
186  foundSignature = QDBusMetaType::typeToSignature(value.userType());
187  }
188 
189  // there was an error...
190  QString errmsg = QLatin1String("Unexpected `%1' (%2) when retrieving property `%3.%4' "
191  "(expected type `%5' (%6))");
193  errmsg.arg(QString::fromLatin1(foundType),
194  QString::fromLatin1(foundSignature),
195  interface,
196  QString::fromUtf8(mp.name()),
198  QString::fromLatin1(expectedSignature)));
199  where.clear();
200  return;
201 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
The QDBusArgument class is used to marshall and demarshall D-Bus arguments.
Definition: qdbusargument.h:69
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
Definition: qdbuserror.h:60
QString currentSignature() const
Returns the type signature of the D-Bus type this QDBusArgument object is currently pointing to...
QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode=QDBus::Block, int timeout=-1) const
Sends the message over this connection and blocks, waiting for a reply, for at most timeout milliseco...
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static void setParametersValidated(QDBusMessage &msg, bool enable)
static const char * typeToSignature(int type)
Returns the D-Bus signature equivalent to the supplied meta type id type.
void * data()
Definition: qvariant.cpp:3077
static bool demarshall(const QDBusArgument &, int id, void *data)
Executes the demarshalling of type id (whose data will be placed in data) from the D-Bus marshalling ...
const char * name
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
Q_CORE_EXPORT void qWarning(const char *,...)
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * typeName() const
Returns the name of the type stored in the variant.
Definition: qvariant.cpp:1984
void clear()
Convert this variant to type Invalid and free up any resources used.
Definition: qvariant.cpp:1993
QString arg(qlonglong a, int fieldwidth=0, int base=10, const QChar &fillChar=QLatin1Char(' ')) const Q_REQUIRED_RESULT
Definition: qstring.cpp:7186
int userType() const
Returns the storage type of the value stored in the variant.
Definition: qvariant.cpp:1913
const char * name() const
Returns this property&#39;s name.
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
static QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Constructs a new DBus message representing a method call.
T qvariant_cast(const QVariant &)
Definition: qvariant.h:571
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59
const char * variant
#define qPrintable(string)
Definition: qglobal.h:1750
const char * typeName() const
Returns the name of this property&#39;s type.
The QDBusVariant class enables the programmer to identify the variant type provided by the D-Bus type...
QVariant::Type type() const
Returns this property&#39;s type.

◆ setProperty()

bool QDBusAbstractInterfacePrivate::setProperty ( const QMetaProperty mp,
const QVariant value 
)

Definition at line 203 of file qdbusabstractinterface.cpp.

Referenced by ~QDBusAbstractInterfacePrivate().

204 {
205  if (!isValid || !canMakeCalls()) // can't make calls
206  return false;
207 
208  // send the value
210  QLatin1String(DBUS_INTERFACE_PROPERTIES),
211  QLatin1String("Set"));
213  msg << interface << QString::fromUtf8(mp.name()) << QVariant::fromValue(QDBusVariant(value));
214  QDBusMessage reply = connection.call(msg, QDBus::Block, timeout);
215 
216  if (reply.type() != QDBusMessage::ReplyMessage) {
217  lastError = reply;
218  return false;
219  }
220  return true;
221 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static void setParametersValidated(QDBusMessage &msg, bool enable)
const char * name
static QString fromUtf8(const char *, int size=-1)
Returns a QString initialized with the first size bytes of the UTF-8 string str.
Definition: qstring.cpp:4302
static QDBusMessage createMethodCall(const QString &destination, const QString &path, const QString &interface, const QString &method)
Constructs a new DBus message representing a method call.
if(void) toggleToolbarShown
The QDBusMessage class represents one message sent or received over the D-Bus bus.
Definition: qdbusmessage.h:59

Properties

◆ connection

QDBusConnection QDBusAbstractInterfacePrivate::connection
mutable

◆ currentOwner

QString QDBusAbstractInterfacePrivate::currentOwner

◆ interface

QString QDBusAbstractInterfacePrivate::interface

◆ isValid

bool QDBusAbstractInterfacePrivate::isValid

◆ lastError

QDBusError QDBusAbstractInterfacePrivate::lastError
mutable

◆ path

QString QDBusAbstractInterfacePrivate::path

◆ service

QString QDBusAbstractInterfacePrivate::service

◆ timeout

int QDBusAbstractInterfacePrivate::timeout

Definition at line 80 of file qdbusabstractinterface_p.h.

Referenced by property().


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