diff options
| -rw-r--r-- | ChangeLog | 13 | ||||
| -rw-r--r-- | dbus/dbus-glib.h | 16 | ||||
| -rw-r--r-- | glib/dbus-gobject.c | 119 | ||||
| -rw-r--r-- | glib/dbus-gproxy.c | 1 | 
4 files changed, 90 insertions, 59 deletions
@@ -1,3 +1,16 @@ +2005-06-14  Ross Burton <ross@burtonini.com>. + +	* glib/dbus-glib.h: Make DBusGMethodInvocation +	a private structure.  Rearrange prototypes a bit. +	 +	* glib/dbus-gproxy.c (dbus_g_proxy_invoke): Add +	documentation for first_arg_type. +	 +	* glib/dbus-gobject.c: Move DBusGMethodInvocation +	here, add documentation.  Move dbus_g_method_return +	and dbus_g_method_return_error into public API +	section. +  2005-06-14  Colin Walters  <walters@verbum.org>  	* glib/dbus-gobject.c (_dbus_gobject_lookup_marshaller): diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h index 7921c917..80ed7f4f 100644 --- a/dbus/dbus-glib.h +++ b/dbus/dbus-glib.h @@ -267,22 +267,18 @@ gboolean          dbus_g_proxy_invoke                (DBusGProxy        *proxy,  						      GType              first_arg_type,  						      ...); +typedef struct DBusGMethodInvocation DBusGMethodInvocation; + +void dbus_g_method_return (DBusGMethodInvocation *context, ...); + +void dbus_g_method_return_error (DBusGMethodInvocation *context, GError *error); +  typedef struct {    DBusGProxy *proxy;    gpointer cb;    gpointer userdata;  } DBusGAsyncData; -typedef struct { -  DBusGConnection *connection; -  DBusGMessage *message; -  const DBusGObjectInfo *object; -  const DBusGMethodInfo *method; -} DBusGMethodInvocation; - -void dbus_g_method_return (DBusGMethodInvocation *context, ...); -void dbus_g_method_return_error (DBusGMethodInvocation *context, GError *error); -  #undef DBUS_INSIDE_DBUS_GLIB_H  G_END_DECLS diff --git a/glib/dbus-gobject.c b/glib/dbus-gobject.c index 4495c6c0..5928e261 100644 --- a/glib/dbus-gobject.c +++ b/glib/dbus-gobject.c @@ -724,6 +724,17 @@ gerror_to_dbus_error_message (const DBusGObjectInfo *object_info,    return reply;  } +/** + * The context of an asynchronous method call.  See dbus_g_method_return() and + * dbus_g_method_return_error(). + */ +struct DBusGMethodInvocation { +  DBusGConnection *connection; /**< The connection */ +  DBusGMessage *message; /**< The message which generated the method call */ +  const DBusGObjectInfo *object; /**< The object the method was called on */ +  const DBusGMethodInfo *method; /**< The method called */ +}; +  static DBusHandlerResult  invoke_object_method (GObject         *object,  		      const DBusGObjectInfo *object_info, @@ -946,55 +957,6 @@ invoke_object_method (GObject         *object,    goto done;  } -void -dbus_g_method_return (DBusGMethodInvocation *context, ...) -{ -  DBusMessage *reply; -  DBusMessageIter iter; -  va_list args; -  char *out_sig; -  GArray *argsig; -  guint i; - -  reply = dbus_message_new_method_return (dbus_g_message_get_message (context->message)); -  out_sig = method_output_signature_from_object_info (context->object, context->method); -  argsig = dbus_gtypes_from_arg_signature (out_sig, FALSE); - -  dbus_message_iter_init_append (reply, &iter); - -  va_start (args, context); -  for (i = 0; i < argsig->len; i++) { -    GValue value = {0,}; -    char *error; -    g_value_init (&value, g_array_index (argsig, GType, i)); -    error = NULL; -    G_VALUE_COLLECT (&value, args, 0, &error); -    if (error) { -      g_warning(error); -      g_free (error); -    } -    dbus_gvalue_marshal (&iter, &value); -  } -  va_end (args); - -  dbus_connection_send (dbus_g_connection_get_connection (context->connection), reply, NULL); -  dbus_message_unref (reply); - -  dbus_g_connection_unref (context->connection); -  dbus_g_message_unref (context->message); -  g_free (context); -} - -void -dbus_g_method_return_error (DBusGMethodInvocation *context, GError *error) -{ -  DBusMessage *reply; -  reply = gerror_to_dbus_error_message (context->object, dbus_g_message_get_message (context->message), error); -  dbus_connection_send (dbus_g_connection_get_connection (context->connection), reply, NULL); -  dbus_message_unref (reply); -} - -  static DBusHandlerResult  gobject_message_function (DBusConnection  *connection,                            DBusMessage     *message, @@ -1486,6 +1448,65 @@ dbus_g_object_register_marshaller (GType            rettype,    g_static_rw_lock_writer_unlock (&globals_lock);  } +/** + * Send a return message for a given method invocation, with arguments. + * + * @param context the method context + */ +void +dbus_g_method_return (DBusGMethodInvocation *context, ...) +{ +  DBusMessage *reply; +  DBusMessageIter iter; +  va_list args; +  char *out_sig; +  GArray *argsig; +  guint i; + +  reply = dbus_message_new_method_return (dbus_g_message_get_message (context->message)); +  out_sig = method_output_signature_from_object_info (context->object, context->method); +  argsig = dbus_gtypes_from_arg_signature (out_sig, FALSE); + +  dbus_message_iter_init_append (reply, &iter); + +  va_start (args, context); +  for (i = 0; i < argsig->len; i++) { +    GValue value = {0,}; +    char *error; +    g_value_init (&value, g_array_index (argsig, GType, i)); +    error = NULL; +    G_VALUE_COLLECT (&value, args, 0, &error); +    if (error) { +      g_warning(error); +      g_free (error); +    } +    dbus_gvalue_marshal (&iter, &value); +  } +  va_end (args); + +  dbus_connection_send (dbus_g_connection_get_connection (context->connection), reply, NULL); +  dbus_message_unref (reply); + +  dbus_g_connection_unref (context->connection); +  dbus_g_message_unref (context->message); +  g_free (context); +} + +/** + * Send a error message for a given method invocation. + * + * @param context the method context + * @param error the error to send. + */ +void +dbus_g_method_return_error (DBusGMethodInvocation *context, GError *error) +{ +  DBusMessage *reply; +  reply = gerror_to_dbus_error_message (context->object, dbus_g_message_get_message (context->message), error); +  dbus_connection_send (dbus_g_connection_get_connection (context->connection), reply, NULL); +  dbus_message_unref (reply); +} +  /** @} */ /* end of public API */  const char * _dbus_gobject_get_path (GObject *obj) diff --git a/glib/dbus-gproxy.c b/glib/dbus-gproxy.c index 42bfca8e..efb8292d 100644 --- a/glib/dbus-gproxy.c +++ b/glib/dbus-gproxy.c @@ -1595,6 +1595,7 @@ dbus_g_proxy_end_call (DBusGProxy          *proxy,   * @param proxy a proxy for a remote interface   * @param method method to invoke   * @param error return location for an error + * @param first_arg_type type of first "in" argument   * @returns #FALSE if an error is set, TRUE otherwise   */  gboolean  | 
