gboolean ibus_connection_send_valist (IBusConnection *connection, gint message_type, const gchar *path, const gchar *interface, const gchar *name, GType first_arg_type, va_list args) { g_assert (IBUS_IS_CONNECTION (connection)); g_assert (interface != NULL); g_assert (name != NULL); gboolean retval; IBusMessage *message; message = ibus_message_new (message_type); ibus_message_set_path (message, path); ibus_message_set_interface (message, interface); ibus_message_set_member (message, name); ibus_message_append_args_valist (message, first_arg_type, args); retval = ibus_connection_send (connection, message); ibus_message_unref (message); return retval; }
gboolean ibus_proxy_call_with_reply (IBusProxy *proxy, const gchar *method, IBusPendingCall **pending, gint timeout_milliseconds, IBusError **error, GType first_arg_type, ...) { g_assert (IBUS_IS_PROXY (proxy)); g_assert (pending != NULL); g_assert (method != NULL); va_list args; gboolean retval; DBusMessage *message; IBusProxyPrivate *priv; priv = IBUS_PROXY_GET_PRIVATE (proxy); if (priv->connection == NULL || !ibus_connection_is_connected (priv->connection)) { if (error) { *error = ibus_error_new_from_printf (DBUS_ERROR_DISCONNECTED, "Connection of %s was disconnected.", G_OBJECT_TYPE_NAME (proxy)); } return FALSE; } message = ibus_message_new_method_call (priv->name, priv->path, priv->interface, method); va_start (args, first_arg_type); retval = ibus_message_append_args_valist (message, first_arg_type, args); va_end (args); *pending = NULL; retval = ibus_connection_send_with_reply (priv->connection, message, pending, timeout_milliseconds); ibus_message_unref (message); if (!retval && error != NULL) { *error = ibus_error_new_from_printf (DBUS_ERROR_NO_MEMORY, ""); } return retval; }
static IBusMessage * ibus_connection_call_with_reply_valist (IBusConnection *connection, const gchar *name, const gchar *path, const gchar *interface, const gchar *member, IBusError **error, GType first_arg_type, va_list va_args) { g_assert (IBUS_IS_CONNECTION (connection)); g_assert (name != NULL); g_assert (path != NULL); g_assert (interface != NULL); g_assert (member != NULL); g_assert (ibus_connection_is_connected (connection)); IBusConnectionPrivate *priv; priv = IBUS_CONNECTION_GET_PRIVATE (connection); IBusMessage *message, *reply; IBusError *tmp_error; message = ibus_message_new_method_call (name, path, interface, member); ibus_message_append_args_valist (message, first_arg_type, va_args); reply = ibus_connection_send_with_reply_and_block ( connection, message, -1, error); ibus_message_unref (message); if (reply == NULL) { return NULL; } if ((tmp_error = ibus_error_new_from_message (reply)) != NULL) { if (error) { *error = tmp_error; } else { ibus_error_free (tmp_error); } ibus_message_unref (reply); return NULL; } return reply; }
IBusMessage * ibus_bus_call_with_reply_valist (IBusBus *bus, const gchar *name, const gchar *path, const gchar *interface, const gchar *member, GType first_arg_type, va_list va_args) { g_assert (IBUS_IS_BUS (bus)); g_assert (name != NULL); g_assert (path != NULL); g_assert (interface != NULL); g_assert (member); IBusMessage *message, *reply; IBusError *error; IBusBusPrivate *priv; g_return_val_if_fail (ibus_bus_is_connected (bus), FALSE); priv = IBUS_BUS_GET_PRIVATE (bus); message = ibus_message_new_method_call (name, path, interface, member); ibus_message_append_args_valist (message, first_arg_type, va_args); reply = ibus_connection_send_with_reply_and_block ( priv->connection, message, -1, &error); ibus_message_unref (message); if (reply == NULL) { g_warning ("%s : %s", error->name, error->message); ibus_error_free (error); return NULL; } if ((error = ibus_error_new_from_message (reply)) != NULL) { g_warning ("%s : %s", error->name, error->message); ibus_error_free (error); ibus_message_unref (reply); return NULL; } return reply; }
gboolean ibus_message_append_args (IBusMessage *message, GType first_arg_type, ...) { gboolean retval; va_list va_args; va_start (va_args, first_arg_type); retval = ibus_message_append_args_valist (message, first_arg_type, va_args); va_end (va_args); return retval; }
gboolean ibus_proxy_call (IBusProxy *proxy, const gchar *method, GType first_arg_type, ...) { g_assert (IBUS_IS_PROXY (proxy)); g_assert (method != NULL); va_list args; gboolean retval; DBusMessage *message; IBusProxyPrivate *priv; priv = IBUS_PROXY_GET_PRIVATE (proxy); g_return_val_if_fail (priv->connection, FALSE); g_return_val_if_fail (ibus_connection_is_connected (priv->connection), FALSE); message = ibus_message_new_method_call (priv->name, priv->path, priv->interface, method); va_start (args, first_arg_type); retval = ibus_message_append_args_valist (message, first_arg_type, args); if (!retval) { ibus_message_unref (message); g_return_val_if_reached (FALSE); } va_end (args); retval = ibus_connection_send (priv->connection, message); ibus_message_unref (message); return retval; }
static gboolean ibus_bus_call (IBusBus *bus, const gchar *name, const gchar *path, const gchar *interface, const gchar *member, GType first_arg_type, ...) { g_assert (IBUS_IS_BUS (bus)); g_assert (name != NULL); g_assert (path != NULL); g_assert (interface != NULL); g_assert (member); IBusMessage *message, *reply; IBusError *error; va_list args; GType type; gboolean retval; IBusBusPrivate *priv; g_return_val_if_fail (ibus_bus_is_connected (bus), FALSE); priv = IBUS_BUS_GET_PRIVATE (bus); message = ibus_message_new_method_call (name, path, interface, member); va_start (args, first_arg_type); ibus_message_append_args_valist (message, first_arg_type, args); va_end (args); reply = ibus_connection_send_with_reply_and_block ( priv->connection, message, -1, &error); ibus_message_unref (message); if (reply == NULL) { g_warning ("%s : %s", error->name, error->message); ibus_error_free (error); return FALSE; } if ((error = ibus_error_new_from_message (reply)) != NULL) { g_warning ("%s : %s", error->name, error->message); ibus_error_free (error); ibus_message_unref (reply); return FALSE; } va_start (args, first_arg_type); type = first_arg_type; while (type != G_TYPE_INVALID) { va_arg (args, gpointer); type = va_arg (args, GType); } type = va_arg (args, GType); if (type != G_TYPE_INVALID) { retval = ibus_message_get_args_valist (reply, &error, type, args); } else { retval = TRUE; } va_end (args); ibus_message_unref (reply); if (!retval) { g_warning ("%s: %s", error->name, error->message); ibus_error_free (error); return FALSE; } return TRUE; }
gboolean ibus_connection_call (IBusConnection *connection, const gchar *name, const gchar *path, const gchar *interface, const gchar *member, IBusError **error, GType first_arg_type, ...) { g_assert (IBUS_IS_CONNECTION (connection)); g_assert (name != NULL); g_assert (path != NULL); g_assert (interface != NULL); g_assert (member != NULL); IBusConnectionPrivate *priv; priv = IBUS_CONNECTION_GET_PRIVATE (connection); g_assert (dbus_connection_get_is_connected (priv->connection)); IBusMessage *message, *reply; IBusError *tmp_error; va_list args; GType type; gboolean retval; message = ibus_message_new_method_call (name, path, interface, member); va_start (args, first_arg_type); ibus_message_append_args_valist (message, first_arg_type, args); va_end (args); reply = ibus_connection_send_with_reply_and_block ( connection, message, -1, error); ibus_message_unref (message); if (reply == NULL) { return FALSE; } if ((tmp_error = ibus_error_new_from_message (reply)) != NULL) { if (error) { *error = tmp_error; } else { ibus_error_free (tmp_error); } ibus_message_unref (reply); return FALSE; } va_start (args, first_arg_type); type = first_arg_type; while (type != G_TYPE_INVALID) { va_arg (args, gpointer); type = va_arg (args, GType); } type = va_arg (args, GType); if (type != G_TYPE_INVALID) { retval = ibus_message_get_args_valist (reply, error, type, args); } else { retval = TRUE; } va_end (args); ibus_message_unref (reply); return retval; }