1 /* GDBus - GLib D-Bus Library 2 * 3 * Copyright (C) 2008-2010 Red Hat, Inc. 4 * 5 * This library is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public 7 * License as published by the Free Software Foundation; either 8 * version 2.1 of the License, or (at your option) any later version. 9 * 10 * This library is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 * Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General 16 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>. 17 * 18 * Author: David Zeuthen <davidz@redhat.com> 19 */ 20 21 #ifndef __G_DBUS_ERROR_H__ 22 #define __G_DBUS_ERROR_H__ 23 24 #if !defined (__GIO_GIO_H_INSIDE__) && !defined (GIO_COMPILATION) 25 #error "Only <gio/gio.h> can be included directly." 26 #endif 27 28 #include <gio/giotypes.h> 29 30 G_BEGIN_DECLS 31 32 /** 33 * G_DBUS_ERROR: 34 * 35 * Error domain for errors generated by a remote message bus. Errors 36 * in this domain will be from the #GDBusError enumeration. See 37 * #GError for more information on error domains. 38 * 39 * Note that this error domain is intended only for 40 * returning errors from a remote message bus process. Errors 41 * generated locally in-process by e.g. #GDBusConnection should use the 42 * %G_IO_ERROR domain. 43 * 44 * Since: 2.26 45 */ 46 #define G_DBUS_ERROR g_dbus_error_quark() 47 48 GLIB_AVAILABLE_IN_ALL 49 GQuark g_dbus_error_quark (void); 50 51 /* Used by applications to check, get and strip the D-Bus error name */ 52 GLIB_AVAILABLE_IN_ALL 53 gboolean g_dbus_error_is_remote_error (const GError *error); 54 GLIB_AVAILABLE_IN_ALL 55 gchar *g_dbus_error_get_remote_error (const GError *error); 56 GLIB_AVAILABLE_IN_ALL 57 gboolean g_dbus_error_strip_remote_error (GError *error); 58 59 /** 60 * GDBusErrorEntry: 61 * @error_code: An error code. 62 * @dbus_error_name: The D-Bus error name to associate with @error_code. 63 * 64 * Struct used in g_dbus_error_register_error_domain(). 65 * 66 * Since: 2.26 67 */ 68 struct _GDBusErrorEntry 69 { 70 gint error_code; 71 const gchar *dbus_error_name; 72 }; 73 74 GLIB_AVAILABLE_IN_ALL 75 gboolean g_dbus_error_register_error (GQuark error_domain, 76 gint error_code, 77 const gchar *dbus_error_name); 78 GLIB_AVAILABLE_IN_ALL 79 gboolean g_dbus_error_unregister_error (GQuark error_domain, 80 gint error_code, 81 const gchar *dbus_error_name); 82 GLIB_AVAILABLE_IN_ALL 83 void g_dbus_error_register_error_domain (const gchar *error_domain_quark_name, 84 volatile gsize *quark_volatile, 85 const GDBusErrorEntry *entries, 86 guint num_entries); 87 88 /* Only used by object mappings to map back and forth to GError */ 89 GLIB_AVAILABLE_IN_ALL 90 GError *g_dbus_error_new_for_dbus_error (const gchar *dbus_error_name, 91 const gchar *dbus_error_message); 92 GLIB_AVAILABLE_IN_ALL 93 void g_dbus_error_set_dbus_error (GError **error, 94 const gchar *dbus_error_name, 95 const gchar *dbus_error_message, 96 const gchar *format, 97 ...) G_GNUC_PRINTF(4, 5); 98 GLIB_AVAILABLE_IN_ALL 99 void g_dbus_error_set_dbus_error_valist (GError **error, 100 const gchar *dbus_error_name, 101 const gchar *dbus_error_message, 102 const gchar *format, 103 va_list var_args) G_GNUC_PRINTF(4, 0); 104 GLIB_AVAILABLE_IN_ALL 105 gchar *g_dbus_error_encode_gerror (const GError *error); 106 107 G_END_DECLS 108 109 #endif /* __G_DBUS_ERROR_H__ */ 110