Add a function that returns the D-Bus local machine ID
authorThiago Macieira <thiago.macieira@nokia.com>
Tue, 21 Jun 2011 19:14:01 +0000 (21:14 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 23 Jun 2011 16:26:28 +0000 (18:26 +0200)
Cherry-picked from 4.8 59bd3bcd961fb3198dc9ba24996f7f9af67aeda3

Change-Id: Id3c8f9edbcbe9bbea83d4d54a6eb25500ab80b68
Reviewed-on: http://codereview.qt.nokia.com/655
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/dbus/qdbus_symbols_p.h
src/dbus/qdbusconnection.cpp
src/dbus/qdbusconnection.h

index 8b46e6a..a59c08a 100644 (file)
@@ -301,6 +301,8 @@ DEFINEFUNC(void          , dbus_get_version ,     (int *major_version_p,
                                                    int *minor_version_p,
                                                    int *micro_version_p),
            (major_version_p, minor_version_p, micro_version_p), )
+DEFINEFUNC(char*         , dbus_get_local_machine_id ,  (void), (), return)
+
 
 /* dbus-pending-call.h */
 DEFINEFUNC(dbus_bool_t  , dbus_pending_call_set_notify, (DBusPendingCall               *pending,
index 58c1caa..0b4133c 100644 (file)
@@ -1124,6 +1124,27 @@ void QDBusConnectionPrivate::setBusService(const QDBusConnection &connection)
 }
 
 /*!
+    \since 4.8
+    Returns the local machine ID as known to the D-Bus system. Each
+    node or host that runs D-Bus has a unique identifier that can be
+    used to distinguish it from other hosts if they are sharing
+    resources like the filesystem.
+
+    Note that the local machine ID is not guaranteed to be persistent
+    across boots of the system, so this identifier should not be
+    stored in persistent storage (like the filesystem). It is
+    guaranteed to remain constant only during the lifetime of this
+    boot session.
+*/
+QByteArray QDBusConnection::localMachineId()
+{
+    char *dbus_machine_id = q_dbus_get_local_machine_id();
+    QByteArray result = dbus_machine_id;
+    q_dbus_free(dbus_machine_id);
+    return result;
+}
+
+/*!
     \namespace QDBus
     \inmodule QtDBus
 
index 19418d6..4bdd055 100644 (file)
@@ -176,6 +176,8 @@ public:
     static void disconnectFromBus(const QString &name);
     static void disconnectFromPeer(const QString &name);
 
+    static QByteArray localMachineId();
+
     static QDBusConnection sessionBus();
     static QDBusConnection systemBus();