51 #include "qdbusmessage_p.h" |
51 #include "qdbusmessage_p.h" |
52 #include "qdbusmetatype.h" |
52 #include "qdbusmetatype.h" |
53 #include "qdbusconnection_p.h" |
53 #include "qdbusconnection_p.h" |
54 #include "qdbusutil_p.h" |
54 #include "qdbusutil_p.h" |
55 |
55 |
|
56 #ifndef QT_NO_DBUS |
|
57 |
56 QT_BEGIN_NAMESPACE |
58 QT_BEGIN_NAMESPACE |
57 |
59 |
58 static inline const char *data(const QByteArray &arr) |
60 static inline const char *data(const QByteArray &arr) |
59 { |
61 { |
60 return arr.isEmpty() ? 0 : arr.constData(); |
62 return arr.isEmpty() ? 0 : arr.constData(); |
61 } |
63 } |
62 |
64 |
63 QDBusMessagePrivate::QDBusMessagePrivate() |
65 QDBusMessagePrivate::QDBusMessagePrivate() |
64 : msg(0), reply(0), type(DBUS_MESSAGE_TYPE_INVALID), |
66 : msg(0), reply(0), type(DBUS_MESSAGE_TYPE_INVALID), |
65 timeout(-1), localReply(0), ref(1), delayedReply(false), localMessage(false), |
67 timeout(-1), localReply(0), ref(1), delayedReply(false), localMessage(false), |
66 parametersValidated(false) |
68 parametersValidated(false), autoStartService(true) |
67 { |
69 { |
68 } |
70 } |
69 |
71 |
70 QDBusMessagePrivate::~QDBusMessagePrivate() |
72 QDBusMessagePrivate::~QDBusMessagePrivate() |
71 { |
73 { |
127 return 0; |
129 return 0; |
128 } |
130 } |
129 |
131 |
130 msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), d_ptr->path.toUtf8(), |
132 msg = q_dbus_message_new_method_call(data(d_ptr->service.toUtf8()), d_ptr->path.toUtf8(), |
131 data(d_ptr->interface.toUtf8()), d_ptr->name.toUtf8()); |
133 data(d_ptr->interface.toUtf8()), d_ptr->name.toUtf8()); |
|
134 q_dbus_message_set_auto_start( msg, d_ptr->autoStartService ); |
132 break; |
135 break; |
133 case DBUS_MESSAGE_TYPE_METHOD_RETURN: |
136 case DBUS_MESSAGE_TYPE_METHOD_RETURN: |
134 msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); |
137 msg = q_dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN); |
135 if (!d_ptr->localMessage) { |
138 if (!d_ptr->localMessage) { |
136 q_dbus_message_set_destination(msg, q_dbus_message_get_sender(d_ptr->reply)); |
139 q_dbus_message_set_destination(msg, q_dbus_message_get_sender(d_ptr->reply)); |
642 { |
645 { |
643 return d_ptr->delayedReply; |
646 return d_ptr->delayedReply; |
644 } |
647 } |
645 |
648 |
646 /*! |
649 /*! |
|
650 Sets the auto start flag to \a enable. This flag only makes sense |
|
651 for method call messages, where it tells the D-Bus server to |
|
652 either auto start the service responsible for the service name, or |
|
653 not to auto start it. |
|
654 |
|
655 By default this flag is true, i.e. a service is autostarted. |
|
656 This means: |
|
657 |
|
658 When the service that this method call is sent to is already |
|
659 running, the method call is sent to it. If the service is not |
|
660 running yet, the D-Bus daemon is requested to autostart the |
|
661 service that is assigned to this service name. This is |
|
662 handled by .service files that are placed in a directory known |
|
663 to the D-Bus server. These files then each contain a service |
|
664 name and the path to a program that should be executed when |
|
665 this service name is requested. |
|
666 |
|
667 \since 4.7 |
|
668 */ |
|
669 void QDBusMessage::setAutoStartService(bool enable) |
|
670 { |
|
671 d_ptr->autoStartService = enable; |
|
672 } |
|
673 |
|
674 /*! |
|
675 Returns the auto start flag, as set by setAutoStartService(). By default, this |
|
676 flag is true, which means QtDBus will auto start a service, if it is |
|
677 not running already. |
|
678 |
|
679 \sa setAutoStartService() |
|
680 |
|
681 \since 4.7 |
|
682 */ |
|
683 bool QDBusMessage::autoStartService() const |
|
684 { |
|
685 return d_ptr->autoStartService; |
|
686 } |
|
687 |
|
688 /*! |
647 Sets the arguments that are going to be sent over D-Bus to \a arguments. Those |
689 Sets the arguments that are going to be sent over D-Bus to \a arguments. Those |
648 will be the arguments to a method call or the parameters in the signal. |
690 will be the arguments to a method call or the parameters in the signal. |
649 |
691 |
650 \sa arguments() |
692 \sa arguments() |
651 */ |
693 */ |