src/dbus/qdbusmessage.cpp
changeset 30 5dc02b23752f
parent 18 2f34d5167611
--- a/src/dbus/qdbusmessage.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/dbus/qdbusmessage.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -53,6 +53,8 @@
 #include "qdbusconnection_p.h"
 #include "qdbusutil_p.h"
 
+#ifndef QT_NO_DBUS
+
 QT_BEGIN_NAMESPACE
 
 static inline const char *data(const QByteArray &arr)
@@ -63,7 +65,7 @@
 QDBusMessagePrivate::QDBusMessagePrivate()
     : msg(0), reply(0), type(DBUS_MESSAGE_TYPE_INVALID),
       timeout(-1), localReply(0), ref(1), delayedReply(false), localMessage(false),
-      parametersValidated(false)
+      parametersValidated(false), autoStartService(true)
 {
 }
 
@@ -129,6 +131,7 @@
 
         msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), d_ptr->path.toUtf8(),
                                              data(d_ptr->interface.toUtf8()), d_ptr->name.toUtf8());
+        q_dbus_message_set_auto_start( msg, d_ptr->autoStartService );
         break;
     case DBUS_MESSAGE_TYPE_METHOD_RETURN:
         msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN);
@@ -644,6 +647,45 @@
 }
 
 /*!
+    Sets the auto start flag to \a enable. This flag only makes sense
+    for method call messages, where it tells the D-Bus server to
+    either auto start the service responsible for the service name, or
+    not to auto start it.
+
+    By default this flag is true, i.e. a service is autostarted.
+    This means:
+
+    When the service that this method call is sent to is already
+    running, the method call is sent to it. If the service is not
+    running yet, the D-Bus daemon is requested to autostart the
+    service that is assigned to this service name. This is
+    handled by .service files that are placed in a directory known
+    to the D-Bus server. These files then each contain a service
+    name and the path to a program that should be executed when
+    this service name is requested.
+
+    \since 4.7
+*/
+void QDBusMessage::setAutoStartService(bool enable)
+{
+    d_ptr->autoStartService = enable;
+}
+
+/*!
+    Returns the auto start flag, as set by setAutoStartService(). By default, this
+    flag is true, which means QtDBus will auto start a service, if it is
+    not running already.
+
+    \sa setAutoStartService()
+
+    \since 4.7
+*/
+bool QDBusMessage::autoStartService() const
+{
+    return d_ptr->autoStartService;
+}
+
+/*!
     Sets the arguments that are going to be sent over D-Bus to \a arguments. Those
     will be the arguments to a method call or the parameters in the signal.
 
@@ -759,3 +801,4 @@
 
 QT_END_NAMESPACE
 
+#endif // QT_NO_DBUS