示例#1
0
static void return_error(GDBusMethodInvocation *invocation, gint code, const gchar *format, ...) {
	va_list va;

	va_start(va, format);
	g_dbus_method_invocation_return_error_valist(invocation, G_DBUS_ERROR, code, format, va);
	va_end(va);
}
示例#2
0
文件: realms.c 项目: pdonlon/cockpit
static void
end_invocation_with_error (Realms *realms,
                           int code,
                           const gchar *msg,
                           ...)
{
  va_list ap;
  va_start (ap, msg);
  g_dbus_method_invocation_return_error_valist (realms->op_invocation,
                                                COCKPIT_ERROR,
                                                code, msg, ap);
  va_end (ap);
  clear_invocation (realms);
}
/**
 * g_dbus_method_invocation_return_error:
 * @invocation: A #GDBusMethodInvocation.
 * @domain: A #GQuark for the #GError error domain.
 * @code: The error code.
 * @format: printf()-style format.
 * @...: Parameters for @format.
 *
 * Finishes handling a D-Bus method call by returning an error.
 *
 * See g_dbus_error_encode_gerror() for details about what error name
 * will be returned on the wire. In a nutshell, if the given error is
 * registered using g_dbus_error_register_error() the name given
 * during registration is used. Otherwise, a name of the form
 * <literal>org.gtk.GDBus.UnmappedGError.Quark...</literal> is
 * used. This provides transparent mapping of #GError between
 * applications using GDBus.
 *
 * If you are writing an application intended to be portable,
 * <emphasis>always</emphasis> register errors with g_dbus_error_register_error()
 * or use g_dbus_method_invocation_return_dbus_error().
 *
 * This method will free @invocation, you cannot use it afterwards.
 *
 * Since: 2.26
 */
void
g_dbus_method_invocation_return_error (GDBusMethodInvocation *invocation,
                                       GQuark                 domain,
                                       gint                   code,
                                       const gchar           *format,
                                       ...)
{
  va_list var_args;

  g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation));
  g_return_if_fail (format != NULL);

  va_start (var_args, format);
  g_dbus_method_invocation_return_error_valist (invocation,
                                                domain,
                                                code,
                                                format,
                                                var_args);
  va_end (var_args);
}