summaryrefslogtreecommitdiffstats
path: root/dbus/dbus-message.c
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@codefactory.se>2003-01-28 14:26:49 +0000
committerAnders Carlsson <andersca@codefactory.se>2003-01-28 14:26:49 +0000
commitdec1fa3bd5f106ba5b2c749372231e3dd4bf9e7b (patch)
tree9a579d3d5b908ee5712249b4de696b89a72ffca7 /dbus/dbus-message.c
parentbec3c093cab742a953e39f1726c37345873990dc (diff)
2003-01-28 Anders Carlsson <set EMAIL_ADDRESS environment variable>
* dbus/dbus-connection-internal.h: * dbus/dbus-connection.c: (_dbus_connection_add_timeout), (_dbus_connection_remove_timeout): Add functions for adding and removing timeouts. * dbus/dbus-message.c: (dbus_message_new_from_message): Add new function that takes a message and creates an exact copy of it, but with the refcount set to 1. (check_message_handling): Fix build error. * dbus/dbus-server-protected.h: * dbus/dbus-server.c: (_dbus_server_init_base), (_dbus_server_finalize_base), (_dbus_server_add_timeout), (dbus_server_set_timeout_functions): (_dbus_server_remove_timeout): New functions so that a server can add and remove timeouts. (dbus_server_listen): Add commented out call to dbus_server_debug_new. * dbus/dbus-timeout.c: (_dbus_timeout_new): Actually set the handler, doh. * dbus/dbus-transport.c: (_dbus_transport_open): Add commented out call to dbus_transport_debug_client_new. * dbus/Makefile.am: Add dbus-transport-debug.[ch] and dbus-server-debug.[ch]
Diffstat (limited to 'dbus/dbus-message.c')
-rw-r--r--dbus/dbus-message.c56
1 files changed, 55 insertions, 1 deletions
diff --git a/dbus/dbus-message.c b/dbus/dbus-message.c
index 08dc45e5..95baa7b2 100644
--- a/dbus/dbus-message.c
+++ b/dbus/dbus-message.c
@@ -721,6 +721,60 @@ dbus_message_new_reply (const char *name,
return message;
}
+DBusMessage *
+dbus_message_new_from_message (const DBusMessage *message)
+{
+ DBusMessage *retval;
+ int i;
+
+ retval = dbus_new0 (DBusMessage, 1);
+ if (retval == NULL)
+ return NULL;
+
+ retval->refcount = 1;
+ retval->byte_order = message->byte_order;
+
+ if (!_dbus_string_init (&retval->header, _DBUS_INT_MAX))
+ {
+ dbus_free (retval);
+ return NULL;
+ }
+
+ if (!_dbus_string_init (&retval->body, _DBUS_INT_MAX))
+ {
+ _dbus_string_free (&retval->header);
+ dbus_free (retval);
+ return NULL;
+ }
+
+ if (!_dbus_string_copy (&message->header, 0,
+ &retval->header, 0))
+ {
+ _dbus_string_free (&retval->header);
+ _dbus_string_free (&retval->body);
+ dbus_free (retval);
+
+ return NULL;
+ }
+
+ if (!_dbus_string_copy (&message->body, 0,
+ &retval->body, 0))
+ {
+ _dbus_string_free (&retval->header);
+ _dbus_string_free (&retval->body);
+ dbus_free (retval);
+
+ return NULL;
+ }
+
+ for (i = 0; i < FIELD_LAST; i++)
+ {
+ retval->header_fields[i].offset = message->header_fields[i].offset;
+ }
+
+ return retval;
+}
+
/**
* Increments the reference count of a DBusMessage.
@@ -2043,7 +2097,7 @@ check_message_handling (DBusMessage *message)
iter = NULL;
client_serial = _dbus_message_get_client_serial (message);
- _dbus_message_set_client_serial (message);
+ _dbus_message_set_client_serial (message, client_serial);
if (client_serial != _dbus_message_get_client_serial (message))
{