69 return connection(senderName);
295 d = _q_manager()->connection(name);
331 if (
d && !
d->ref.deref())
346 if (
d && !
d->ref.deref())
373 DBusConnection *
c = 0;
377 c = q_dbus_bus_get_private(DBUS_BUS_SYSTEM, error);
380 c = q_dbus_bus_get_private(DBUS_BUS_SESSION, error);
383 c = q_dbus_bus_get_private(DBUS_BUS_STARTER, error);
388 _q_manager()->setConnection(name, d);
424 if (!q_dbus_bus_register(c, error)) {
425 q_dbus_connection_unref(c);
430 _q_manager()->setConnection(name, d);
471 _q_manager()->setConnection(name, d);
493 _q_manager()->removeConnection(name);
517 _q_manager()->removeConnection(name);
530 if (!
d || !
d->connection) {
537 return d->send(message) != 0;
560 const char *returnMethod,
const char *errorMethod,
563 if (!
d || !
d->connection) {
570 return d->sendWithReplyAsync(message, receiver, returnMethod, errorMethod, timeout) != 0;
594 const char *returnMethod,
int timeout)
const 596 return callWithCallback(message, receiver, returnMethod, 0, timeout);
624 if (!
d || !
d->connection) {
634 return d->sendWithReply(message, mode, timeout);
664 if (!
d || !
d->connection) {
686 return connect(service, path, interface, name,
QStringList(),
QString(), receiver, slot);
711 QObject *receiver,
const char *slot)
713 return connect(service, path, interface, name,
QStringList(), signature, receiver, slot);
744 QObject *receiver,
const char *slot)
747 if (!receiver || !slot || !
d || !
d->connection)
771 return d->connectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
784 return disconnect(service, path, interface, name,
QStringList(),
QString(), receiver, slot);
802 QObject *receiver,
const char *slot)
804 return disconnect(service, path, interface, name,
QStringList(), signature, receiver, slot);
823 QObject *receiver,
const char *slot)
825 if (!receiver || !slot || !
d || !
d->connection)
833 return d->disconnectSignal(service, path, interface, name, argumentMatch, signature, receiver, slot);
851 "Invalid object path given");
864 if (pathComponents.
count() == i) {
873 if (options & SubPath) {
885 node->
flags = options;
887 d->registerObject(node);
894 qDebug(
"Cannot register object at %s because QDBusVirtualObject handles all sub-paths.",
902 if (it != node->
children.
end() && it->name == pathComponents.
at(i)) {
907 if (node->
flags & ExportChildObjects) {
909 qDebug(
"Cannot register object at %s because %s exports its own child objects",
922 Q_ASSERT_X(
false,
"QDBusConnection::registerObject",
"The impossible happened");
941 return registerObject(path, (
QObject*) treeNode, (RegisterOptions) opts);
967 if (mode == UnregisterTree) {
978 if (it == node->
children.
end() || it->name != pathComponents.
at(i))
993 "Invalid object path given");
1007 if (pathComponents.
count() == i)
1033 return d->busService;
1048 return d ?
d->connection : 0;
1056 return d &&
d->connection && q_dbus_connection_get_is_connected(
d->connection);
1125 return d ?
d->capabilities : ConnectionCapabilities(0);
1137 if (interface() && interface()->registerService(serviceName)) {
1138 if (
d)
d->registerService(serviceName);
1153 if (interface()->unregisterService(serviceName)) {
1154 if (
d)
d->unregisterService(serviceName);
1173 qWarning(
"QDBusConnection: %s D-Bus connection created before QCoreApplication. Application may misbehave.",
1174 type == SessionBus ?
"session" : type == SystemBus ?
"system" :
"generic");
1191 return *_q_sessionBus();
1223 _q_manager()->setSender(s);
1258 char *dbus_machine_id = q_dbus_get_local_machine_id();
1260 q_dbus_free(dbus_machine_id);
1299 #endif // QT_NO_DBUS The QVariant class acts like a union for the most common Qt data types.
UnregisterMode
The mode for unregistering an object path:
QHash< QString, QDBusConnectionPrivate * > connectionHash
static QDBusMessage createError(const QString &name, const QString &msg)
Constructs a new DBus message representing an error, with the given name and msg. ...
The QDBusConnectionInterface class provides access to the D-Bus bus daemon service.
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
QDBusConnectionInterface * interface() const
Returns a QDBusConnectionInterface object that represents the D-Bus server interface on this connecti...
#define QT_END_NAMESPACE
This macro expands to.
void removeConnection(const QString &name)
bool isValidObjectPath(const QString &path)
Returns true if path is valid object path.
void clear()
Removes all items from the hash.
bool registerVirtualObject(const QString &path, QDBusVirtualObject *object, VirtualObjectRegisterOption options=SingleNode)
Registers a QDBusTreeNode for a path.
bool send(const QDBusMessage &message) const
Sends the message over this connection, without waiting for a reply.
#define it(className, varName)
bool registerObject(const QString &path, QObject *object, RegisterOptions options=ExportAdaptors)
Registers the object object at path path and returns true if the registration was successful...
CallMode
This enum describes the various ways of placing a function call.
QDBusPendingCall asyncCall(const QDBusMessage &message, int timeout=-1) const
Sends the message over this connection and returns immediately.
QByteArray toUtf8() const Q_REQUIRED_RESULT
Returns a UTF-8 representation of the string as a QByteArray.
QDBusConnection & operator=(const QDBusConnection &other)
Creates a copy of the connection other in this object.
static QDBusConnectionPrivate * d(const QDBusConnection &q)
The QByteArray class provides an array of bytes.
static QDBusConnection connectToPeer(const QString &address, const QString &name)
Opens a peer-to-peer connection on address address and associate with it the connection name name...
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
The QDBusError class represents an error received from the D-Bus bus or from remote applications foun...
void unregisterObject(const QString &path, UnregisterMode mode=UnregisterNode)
Unregisters an object that was registered with the registerObject() at the object path given by path ...
The QDBusPendingCall class refers to one pending asynchronous call.
void setSender(const QDBusConnectionPrivate *s)
QString baseService() const
Returns the unique connection name for this connection, if this QDBusConnection object is connected...
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...
void removeLast()
Removes the last item in the list.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
static QDBusConnection systemBus()
Returns a QDBusConnection object opened with the system bus.
int count(const T &t) const
Returns the number of occurrences of value in the list.
bool ref()
Atomically increments the value of this QAtomicInt.
static QDBusConnection sender()
Returns the connection that sent the signal, if called in a slot activated by QDBus; otherwise it ret...
The QString class provides a Unicode character string.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it...
QDBusDefaultConnection(BusType type, const char *name)
The QObject class is the base class of all Qt objects.
static void setSender(const QDBusConnectionPrivate *s)
ConnectionCapabilities connectionCapabilities() const
Returns the capabilities of this connection as negotiated with the bus server or peer.
bool unregisterService(const QString &serviceName)
Unregisters the service serviceName that was previously registered with registerService() and returns...
bool isValidInterfaceName(const QString &ifaceName)
Returns true if this is ifaceName is a valid interface name.
iterator Iterator
Qt-style synonym for QVector::iterator.
QString name() const
Returns the connection name for this connection, as given as the name parameter to connectToBus()...
const T value(const Key &key) const
Returns the value associated with the key.
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Q_CORE_EXPORT void qDebug(const char *,...)
static QDBusConnectionManager * instance()
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
void * internalPointer() const
QDBusConnection(const QString &name)
Creates a QDBusConnection object attached to the connection with name name.
#define QT_BEGIN_NAMESPACE
This macro expands to.
static void disconnectFromBus(const QString &name)
Closes the bus connection of name name.
bool registerService(const QString &serviceName)
Attempts to register the serviceName on the D-Bus server and returns true if the registration succeed...
void clear()
Removes all the elements from the vector and releases the memory used by the vector.
static const char _q_systemBusName[]
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...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
~QDBusDefaultConnection()
#define Q_GLOBAL_STATIC(TYPE, NAME)
Declares a global static variable with the given type and name.
const T & at(int i) const
Returns the item at index position i in the list.
bool deref()
Atomically decrements the value of this QAtomicInt.
The QStringList class provides a list of strings.
QDBusConnectionPrivate * sender() const
Q_CORE_EXPORT void qWarning(const char *,...)
void moveToThread(QThread *thread)
Changes the thread affinity for this object and its children.
void setConnection(const QString &name, QDBusConnectionPrivate *c)
BusType
Specifies the type of the bus connection.
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
QDBusError lastError() const
Returns the last error that happened in this connection.
The QDBusVirtualObject class is used to handle several DBus paths with one class. ...
QDBusConnectionPrivate * d
const char * constData() const
Returns a pointer to the data stored in the byte array.
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
Connects the signal specified by the service, path, interface and name parameters to the slot slot in...
The QCoreApplication class provides an event loop for console Qt applications.
static QByteArray localMachineId()
Returns the local machine ID as known to the D-Bus system.
#define Q_ASSERT_X(cond, where, what)
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
int compare(const QString &s) const
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
static QCoreApplication * instance()
Returns a pointer to the application's QCoreApplication (or QApplication) instance.
The QDBusConnection class represents a connection to the D-Bus bus daemon.
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Q_GLOBAL_STATIC_WITH_ARGS(QDBusDefaultConnection, _q_sessionBus,(QDBusConnection::SessionBus, _q_sessionBusName)) Q_GLOBAL_STATIC_WITH_ARGS(QDBusDefaultConnection
void setPeer(DBusConnection *connection, const QDBusErrorInternal &error)
T & last()
Returns a reference to the last item in the list.
static QReadWriteLock lock
static QDBusConnection connectToBus(BusType type, const QString &name)
Opens a connection of type type to one of the known busses and associate with it the connection name ...
if(void) toggleToolbarShown
QDBusConnectionPrivate * connection(const QString &name) const
The QDBusMessage class represents one message sent or received over the D-Bus bus.
QObject * objectRegisteredAt(const QString &path) const
Return the object that was registered with the registerObject() at the object path given by path...
const_iterator ConstIterator
Qt-style synonym for QVector::const_iterator.
~QDBusConnectionManager()
bool isEmpty() const
Returns true if the vector has size 0; otherwise returns false.
QStringList split(const QString &sep, SplitBehavior behavior=KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const Q_REQUIRED_RESULT
Splits the string into substrings wherever sep occurs, and returns the list of those strings...
VirtualObjectRegisterOption
Specifies the options for registering virtual objects with the connection.
QThread * thread() const
Returns the thread in which the object lives.
Q_DBUS_EXPORT void qDBusBindToApplication()
bool isConnected() const
Returns true if this QDBusConnection object is connected.
~QDBusConnection()
Disposes of this object.
bool disconnect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
Disconnects the signal specified by the service, path, interface and name parameters from the slot sl...
#define qPrintable(string)
void setBusService(const QDBusConnection &connection)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void setConnection(DBusConnection *connection, const QDBusErrorInternal &error)
static const char _q_sessionBusName[]
bool callWithCallback(const QDBusMessage &message, QObject *receiver, const char *returnMethod, const char *errorMethod, int timeout=-1) const
Sends the message over this connection and returns immediately.
static void disconnectFromPeer(const QString &name)
Closes the peer connection of name name.
bool isValidBusName(const QString &busName)
Returns true if busName is a valid bus name.