summaryrefslogtreecommitdiff
path: root/src/dbus-patches
diff options
context:
space:
mode:
Diffstat (limited to 'src/dbus-patches')
-rw-r--r--src/dbus-patches/capi-dbus-add-send-with-reply-set-notify.patch201
-rw-r--r--src/dbus-patches/capi-dbus-add-support-for-custom-marshalling.patch217
2 files changed, 418 insertions, 0 deletions
diff --git a/src/dbus-patches/capi-dbus-add-send-with-reply-set-notify.patch b/src/dbus-patches/capi-dbus-add-send-with-reply-set-notify.patch
new file mode 100644
index 0000000..3f92169
--- /dev/null
+++ b/src/dbus-patches/capi-dbus-add-send-with-reply-set-notify.patch
@@ -0,0 +1,201 @@
+From 1dcacc908826f59b580bd1d1a7541fb919d4bd97 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=BCrgen=20Gehring?= <juergen.gehring@bmw.de>
+Date: Thu, 23 Apr 2015 02:15:06 -0700
+Subject: [PATCH] Add dbus_connection_send_with_reply_set_notify function for
+ proper thread handling
+
+---
+ dbus/dbus-connection.c | 155 +++++++++++++++++++++++++++++++++++++++++++++++++
+ dbus/dbus-connection.h | 10 ++++
+ 2 files changed, 165 insertions(+)
+
+diff --git a/dbus/dbus-connection.c b/dbus/dbus-connection.c
+index e1068e3..233f179 100644
+--- a/dbus/dbus-connection.c
++++ b/dbus/dbus-connection.c
+@@ -3482,6 +3482,161 @@ dbus_connection_send_with_reply (DBusConnection *connection,
+ }
+
+ /**
++ * Queues a message to send, as with dbus_connection_send(),
++ * but also returns a #DBusPendingCall used to receive a reply to the
++ * message. If no reply is received in the given timeout_milliseconds,
++ * this function expires the pending reply and generates a synthetic
++ * error reply (generated in-process, not by the remote application)
++ * indicating that a timeout occurred.
++ *
++ * A #DBusPendingCall will see a reply message before any filters or
++ * registered object path handlers. See dbus_connection_dispatch() for
++ * details on when handlers are run.
++ *
++ * A #DBusPendingCall will always see exactly one reply message,
++ * unless it's cancelled with dbus_pending_call_cancel().
++ *
++ * If #NULL is passed for the pending_return, the #DBusPendingCall
++ * will still be generated internally, and used to track
++ * the message reply timeout. This means a timeout error will
++ * occur if no reply arrives, unlike with dbus_connection_send().
++ *
++ * If -1 is passed for the timeout, a sane default timeout is used. -1
++ * is typically the best value for the timeout for this reason, unless
++ * you want a very short or very long timeout. If #DBUS_TIMEOUT_INFINITE is
++ * passed for the timeout, no timeout will be set and the call will block
++ * forever.
++ *
++ * @warning if the connection is disconnected or you try to send Unix
++ * file descriptors on a connection that does not support them, the
++ * #DBusPendingCall will be set to #NULL, so be careful with this.
++ *
++ * @param connection the connection
++ * @param message the message to send
++ * @param pending_return return location for a #DBusPendingCall
++ * object, or #NULL if connection is disconnected or when you try to
++ * send Unix file descriptors on a connection that does not support
++ * them.
++ * @param timeout_milliseconds timeout in milliseconds, -1 (or
++ * #DBUS_TIMEOUT_USE_DEFAULT) for default or #DBUS_TIMEOUT_INFINITE for no
++ * timeout
++ * @returns #FALSE if no memory, #TRUE otherwise.
++ *
++ */
++dbus_bool_t
++dbus_connection_send_with_reply_set_notify (DBusConnection *connection,
++ DBusMessage *message,
++ DBusPendingCall **pending_return,
++ DBusPendingCallNotifyFunction function0,
++ void *user_data0,
++ DBusFreeFunction free_user_data0,
++ int timeout_milliseconds)
++{
++ DBusPendingCall *pending;
++ dbus_int32_t serial = -1;
++ DBusDispatchStatus status;
++
++ _dbus_return_val_if_fail (connection != NULL, FALSE);
++ _dbus_return_val_if_fail (message != NULL, FALSE);
++ _dbus_return_val_if_fail (timeout_milliseconds >= 0 || timeout_milliseconds == -1, FALSE);
++
++ if (pending_return)
++ *pending_return = NULL;
++
++ CONNECTION_LOCK (connection);
++
++#ifdef HAVE_UNIX_FD_PASSING
++
++ if (!_dbus_transport_can_pass_unix_fd(connection->transport) &&
++ message->n_unix_fds > 0)
++ {
++ /* Refuse to send fds on a connection that cannot handle
++ them. Unfortunately we cannot return a proper error here, so
++ the best we can do is return TRUE but leave *pending_return
++ as NULL. */
++ CONNECTION_UNLOCK (connection);
++ return TRUE;
++ }
++
++#endif
++
++ if (!_dbus_connection_get_is_connected_unlocked (connection))
++ {
++ CONNECTION_UNLOCK (connection);
++
++ return TRUE;
++ }
++
++ pending = _dbus_pending_call_new_unlocked (connection,
++ timeout_milliseconds,
++ reply_handler_timeout);
++
++ if (pending == NULL)
++ {
++ CONNECTION_UNLOCK (connection);
++ return FALSE;
++ }
++
++ if (!dbus_pending_call_set_notify(pending, function0, user_data0, free_user_data0))
++ {
++ CONNECTION_UNLOCK (connection);
++ return FALSE;
++ }
++
++ /* Assign a serial to the message */
++ serial = dbus_message_get_serial (message);
++ if (serial == 0)
++ {
++ serial = _dbus_connection_get_next_client_serial (connection);
++ dbus_message_set_serial (message, serial);
++ }
++
++ if (!_dbus_pending_call_set_timeout_error_unlocked (pending, message, serial))
++ goto error;
++
++ /* Insert the serial in the pending replies hash;
++ * hash takes a refcount on DBusPendingCall.
++ * Also, add the timeout.
++ */
++ if (!_dbus_connection_attach_pending_call_unlocked (connection,
++ pending))
++ goto error;
++
++ if (!_dbus_connection_send_unlocked_no_update (connection, message, NULL))
++ {
++ _dbus_connection_detach_pending_call_and_unlock (connection,
++ pending);
++ goto error_unlocked;
++ }
++
++ if (pending_return)
++ *pending_return = pending; /* hand off refcount */
++ else
++ {
++ _dbus_connection_detach_pending_call_unlocked (connection, pending);
++ /* we still have a ref to the pending call in this case, we unref
++ * after unlocking, below
++ */
++ }
++
++ status = _dbus_connection_get_dispatch_status_unlocked (connection);
++
++ /* this calls out to user code */
++ _dbus_connection_update_dispatch_status_and_unlock (connection, status);
++
++ if (pending_return == NULL)
++ dbus_pending_call_unref (pending);
++
++ return TRUE;
++
++ error:
++ CONNECTION_UNLOCK (connection);
++ error_unlocked:
++ dbus_pending_call_unref (pending);
++ return FALSE;
++}
++
++/**
+ * Sends a message and blocks a certain time period while waiting for
+ * a reply. This function does not reenter the main loop,
+ * i.e. messages other than the reply are queued up but not
+diff --git a/dbus/dbus-connection.h b/dbus/dbus-connection.h
+index fe4d04e..e8cedf1 100644
+--- a/dbus/dbus-connection.h
++++ b/dbus/dbus-connection.h
+@@ -229,6 +229,16 @@ dbus_bool_t dbus_connection_send_with_reply (DBusConnection
+ DBusMessage *message,
+ DBusPendingCall **pending_return,
+ int timeout_milliseconds);
++
++DBUS_EXPORT
++dbus_bool_t dbus_connection_send_with_reply_set_notify (DBusConnection *connection,
++ DBusMessage *message,
++ DBusPendingCall **pending_return,
++ DBusPendingCallNotifyFunction function0,
++ void * user_data0,
++ DBusFreeFunction free_user_data0,
++ int timeout_milliseconds);
++
+ DBUS_EXPORT
+ DBusMessage * dbus_connection_send_with_reply_and_block (DBusConnection *connection,
+ DBusMessage *message,
+--
+1.9.1
+
diff --git a/src/dbus-patches/capi-dbus-add-support-for-custom-marshalling.patch b/src/dbus-patches/capi-dbus-add-support-for-custom-marshalling.patch
new file mode 100644
index 0000000..78b073c
--- /dev/null
+++ b/src/dbus-patches/capi-dbus-add-support-for-custom-marshalling.patch
@@ -0,0 +1,217 @@
+From 7b0925938400b970bf699a9188fe03b7271eeead Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?J=C3=BCrgen=20Gehring?= <juergen.gehring@bmw.de>
+Date: Thu, 23 Apr 2015 01:18:11 -0700
+Subject: [PATCH] Add functions to support querying and manipulating the
+ message body and signature. This is useful for code generators, which can
+ generate custom marshaling functions based on a given IDL. Those functions
+ tend to be optimized and faster than the generic iterator based marshaling.
+
+---
+ dbus/dbus-message.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++++++++
+ dbus/dbus-message.h | 14 ++++++++
+ dbus/dbus-string.c | 16 +++++++++
+ dbus/dbus-string.h | 5 +++
+ 4 files changed, 134 insertions(+)
+
+diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
+index 43cb1be..d34663a 100644
+--- a/dbus/dbus-message.c
++++ b/dbus/dbus-message.c
+@@ -3445,6 +3445,47 @@ dbus_message_get_sender (DBusMessage *message)
+ }
+
+ /**
++ * Sets the signature of the message, i.e. the arguments in the
++ * message payload. The signature includes only "in" arguments for
++ * #DBUS_MESSAGE_TYPE_METHOD_CALL and only "out" arguments for
++ * #DBUS_MESSAGE_TYPE_METHOD_RETURN, so is slightly different from
++ * what you might expect (it does not include the signature of the
++ * entire C++-style method).
++ *
++ * The signature is a string made up of type codes such as
++ * #DBUS_TYPE_INT32. The string is terminated with nul (nul is also
++ * the value of #DBUS_TYPE_INVALID). The macros such as
++ * #DBUS_TYPE_INT32 evaluate to integers; to assemble a signature you
++ * may find it useful to use the string forms, such as
++ * #DBUS_TYPE_INT32_AS_STRING.
++ *
++ * An "unset" or #NULL signature is considered the same as an empty
++ * signature. In fact dbus_message_get_signature() will never return
++ * #NULL.
++ *
++ * @param message the message
++ * @param signature the type signature or #NULL to unset
++ * @returns #FALSE if no memory
++ */
++dbus_bool_t
++dbus_message_set_signature (DBusMessage *message,
++ const char *signature)
++{
++ _dbus_return_val_if_fail (message != NULL, FALSE);
++ _dbus_return_val_if_fail (!message->locked, FALSE);
++ _dbus_return_val_if_fail (signature == NULL ||
++ _dbus_check_is_valid_signature (signature), FALSE);
++ /* can't delete the signature if you have a message body */
++ _dbus_return_val_if_fail (_dbus_string_get_length (&message->body) == 0 ||
++ signature != NULL, FALSE);
++
++ return set_or_delete_string_field (message,
++ DBUS_HEADER_FIELD_SIGNATURE,
++ DBUS_TYPE_SIGNATURE,
++ signature);
++}
++
++/**
+ * Gets the type signature of the message, i.e. the arguments in the
+ * message payload. The signature includes only "in" arguments for
+ * #DBUS_MESSAGE_TYPE_METHOD_CALL and only "out" arguments for
+@@ -4632,6 +4673,64 @@ dbus_message_type_to_string (int type)
+ }
+
+ /**
++ * Returns pointer to the buffer used to store the message body.
++ *
++ * @param message the message
++ * @return pointer to the message body memory
++ */
++char*
++dbus_message_get_body (DBusMessage *message) {
++ _dbus_return_val_if_fail (message != NULL, NULL);
++
++ return _dbus_string_get_data(&(message->body));
++}
++
++/**
++ * Adjust the length of the message body buffer. The memory will be reallocated
++ * if the new length is bigger than the already allocated size.
++ *
++ * @see dbus_message_get_body_allocated
++ * @param message the message
++ * @param length the new length of the body
++ * @return #TRUE if successful
++ */
++dbus_bool_t
++dbus_message_set_body_length (DBusMessage *message,
++ int length) {
++ _dbus_return_val_if_fail (message != NULL, FALSE);
++ _dbus_return_val_if_fail (length >= 0, FALSE);
++
++ return _dbus_string_set_length(&(message->body), length);
++}
++
++/**
++ * Gets the length of the message body buffer.
++ *
++ * @param message the message
++ * @param length the new length of the body
++ * @return the length of the body buffer
++ */
++int
++dbus_message_get_body_length (DBusMessage *message) {
++ _dbus_return_val_if_fail (message != NULL, 0);
++
++ return _dbus_string_get_length(&(message->body));
++}
++
++/**
++ * Gets the allocated memory size used to hold the message body.
++ *
++ * @param message the message
++ * @return size of the allocated message body memory
++ */
++int
++dbus_message_get_body_allocated (DBusMessage *message) {
++ _dbus_return_val_if_fail (message != NULL, 0);
++
++ return _dbus_string_get_allocated(&(message->body));
++}
++
++/**
+ * Turn a DBusMessage into the marshalled form as described in the D-Bus
+ * specification.
+ *
+diff --git a/dbus/dbus-message.h b/dbus/dbus-message.h
+index 4fd44da..76377b8 100644
+--- a/dbus/dbus-message.h
++++ b/dbus/dbus-message.h
+@@ -138,6 +138,9 @@ dbus_bool_t dbus_message_set_sender (DBusMessage *message,
+ DBUS_EXPORT
+ const char* dbus_message_get_sender (DBusMessage *message);
+ DBUS_EXPORT
++dbus_bool_t dbus_message_set_signature (DBusMessage *message,
++ const char *signature);
++DBUS_EXPORT
+ const char* dbus_message_get_signature (DBusMessage *message);
+ DBUS_EXPORT
+ void dbus_message_set_no_reply (DBusMessage *message,
+@@ -262,6 +265,17 @@ dbus_bool_t dbus_message_iter_close_container (DBusMessageIter *iter,
+ DBUS_EXPORT
+ void dbus_message_iter_abandon_container (DBusMessageIter *iter,
+ DBusMessageIter *sub);
++DBUS_EXPORT
++char* dbus_message_get_body (DBusMessage *message);
++
++DBUS_EXPORT
++dbus_bool_t dbus_message_set_body_length (DBusMessage *message,
++ int length);
++DBUS_EXPORT
++int dbus_message_get_body_length (DBusMessage *message);
++
++DBUS_EXPORT
++int dbus_message_get_body_allocated (DBusMessage *message);
+
+ DBUS_EXPORT
+ void dbus_message_lock (DBusMessage *message);
+diff --git a/dbus/dbus-string.c b/dbus/dbus-string.c
+index 0f63612..a084eca 100644
+--- a/dbus/dbus-string.c
++++ b/dbus/dbus-string.c
+@@ -730,6 +730,22 @@ _dbus_string_get_length (const DBusString *str)
+ }
+ #endif /* !_dbus_string_get_length */
+
++/* Only have the function if we don't have the macro */
++#ifndef _dbus_string_get_allocated
++/**
++ * Gets the allocated length of a string (not including nul termination).
++ *
++ * @returns the allocated length.
++ */
++int
++_dbus_string_get_allocated(const DBusString *str)
++{
++ DBUS_CONST_STRING_PREAMBLE (str);
++
++ return real->allocated;
++}
++#endif /* !_dbus_string_get_allocated */
++
+ /**
+ * Makes a string longer by the given number of bytes. Checks whether
+ * adding additional_length to the current length would overflow an
+diff --git a/dbus/dbus-string.h b/dbus/dbus-string.h
+index 86fb8c3..bfa2a39 100644
+--- a/dbus/dbus-string.h
++++ b/dbus/dbus-string.h
+@@ -61,6 +61,7 @@ struct DBusString
+ */
+ #define _dbus_string_get_data(s) ((char*)(((DBusString*)(s))->dummy1))
+ #define _dbus_string_get_length(s) (((DBusString*)(s))->dummy2)
++#define _dbus_string_get_allocated(s) (((DBusString*)(s))->dummy3 - _DBUS_STRING_ALLOCATION_PADDING)
+ #define _dbus_string_set_byte(s, i, b) ((((unsigned char*)(((DBusString*)(s))->dummy1))[(i)]) = (unsigned char) (b))
+ #define _dbus_string_get_byte(s, i) (((const unsigned char*)(((DBusString*)(s))->dummy1))[(i)])
+ #define _dbus_string_get_const_data(s) ((const char*)(((DBusString*)(s))->dummy1))
+@@ -131,6 +132,10 @@ void _dbus_string_copy_to_buffer_with_nul (const DBusString *str,
+ int _dbus_string_get_length (const DBusString *str);
+ #endif /* !_dbus_string_get_length */
+
++#ifndef _dbus_string_get_allocated
++int _dbus_string_get_allocated (const DBusString *str);
++#endif /* !_dbus_string_get_allocated */
++
+ dbus_bool_t _dbus_string_lengthen (DBusString *str,
+ int additional_length);
+ void _dbus_string_shorten (DBusString *str,
+--
+1.9.1
+