X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=gio%2Fgdbuserror.c;h=8dd4b718136f4e13abd225dca5094cba9f416cda;hb=853692bdfd9f8a87aed70d21f643dc13b57c92d1;hp=064c67bd9c4535c9d63f9c1e5abb1cc0af7be611;hpb=1b033919845cef366842373da9f1cfb56f522d01;p=platform%2Fupstream%2Fglib.git
diff --git a/gio/gdbuserror.c b/gio/gdbuserror.c
index 064c67b..8dd4b71 100644
--- a/gio/gdbuserror.c
+++ b/gio/gdbuserror.c
@@ -13,9 +13,7 @@
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General
- * Public License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Public License along with this library; if not, see .
*
* Author: David Zeuthen
*/
@@ -57,8 +55,8 @@
* automatically map from D-Bus errors to #GError and back. This
* is typically done in the function returning the #GQuark for the
* error domain:
- * Error Registration
- * /* foo-bar-error.h: */
+ * |[
+ * // foo-bar-error.h:
*
* #define FOO_BAR_ERROR (foo_bar_error_quark ())
* GQuark foo_bar_error_quark (void);
@@ -68,9 +66,10 @@
* FOO_BAR_ERROR_FAILED,
* FOO_BAR_ERROR_ANOTHER_ERROR,
* FOO_BAR_ERROR_SOME_THIRD_ERROR,
+ * FOO_BAR_N_ERRORS / *< skip >* /
* } FooBarError;
*
- * /* foo-bar-error.c: */
+ * // foo-bar-error.c:
*
* static const GDBusErrorEntry foo_bar_error_entries[] =
* {
@@ -79,6 +78,9 @@
* {FOO_BAR_ERROR_SOME_THIRD_ERROR, "org.project.Foo.Bar.Error.SomeThirdError"},
* };
*
+ * // Ensure that every error code has an associated D-Bus error name
+ * G_STATIC_ASSERT (G_N_ELEMENTS (foo_bar_error_entries) == FOO_BAR_N_ERRORS);
+ *
* GQuark
* foo_bar_error_quark (void)
* {
@@ -87,15 +89,17 @@
* &quark_volatile,
* foo_bar_error_entries,
* G_N_ELEMENTS (foo_bar_error_entries));
- * G_STATIC_ASSERT (G_N_ELEMENTS (foo_bar_error_entries) - 1 == FOO_BAR_ERROR_SOME_THIRD_ERROR);
* return (GQuark) quark_volatile;
* }
- *
+ * ]|
* With this setup, a D-Bus peer can transparently pass e.g. %FOO_BAR_ERROR_ANOTHER_ERROR and
- * other peers will see the D-Bus error name org.project.Foo.Bar.Error.AnotherError.
- * If the other peer is using GDBus, the peer will see also %FOO_BAR_ERROR_ANOTHER_ERROR instead
+ * other peers will see the D-Bus error name org.project.Foo.Bar.Error.AnotherError.
+ *
+ * If the other peer is using GDBus, and has registered the association with
+ * g_dbus_error_register_error_domain() in advance (e.g. by invoking the %FOO_BAR_ERROR quark
+ * generation itself in the previous example) the peer will see also %FOO_BAR_ERROR_ANOTHER_ERROR instead
* of %G_IO_ERROR_DBUS_ERROR. Note that GDBus clients can still recover
- * org.project.Foo.Bar.Error.AnotherError using g_dbus_error_get_remote_error().
+ * org.project.Foo.Bar.Error.AnotherError using g_dbus_error_get_remote_error().
*
* Note that errors in the %G_DBUS_ERROR error domain is intended only
* for returning errors from a remote message bus process. Errors
@@ -146,12 +150,16 @@ static const GDBusErrorEntry g_dbus_error_entries[] =
{G_DBUS_ERROR_SELINUX_SECURITY_CONTEXT_UNKNOWN, "org.freedesktop.DBus.Error.SELinuxSecurityContextUnknown"},
{G_DBUS_ERROR_ADT_AUDIT_DATA_UNKNOWN, "org.freedesktop.DBus.Error.AdtAuditDataUnknown"},
{G_DBUS_ERROR_OBJECT_PATH_IN_USE, "org.freedesktop.DBus.Error.ObjectPathInUse"},
+ {G_DBUS_ERROR_UNKNOWN_OBJECT, "org.freedesktop.DBus.Error.UnknownObject"},
+ {G_DBUS_ERROR_UNKNOWN_INTERFACE, "org.freedesktop.DBus.Error.UnknownInterface"},
+ {G_DBUS_ERROR_UNKNOWN_PROPERTY, "org.freedesktop.DBus.Error.UnknownProperty"},
+ {G_DBUS_ERROR_PROPERTY_READ_ONLY, "org.freedesktop.DBus.Error.PropertyReadOnly"},
};
GQuark
g_dbus_error_quark (void)
{
- G_STATIC_ASSERT (G_N_ELEMENTS (g_dbus_error_entries) - 1 == G_DBUS_ERROR_OBJECT_PATH_IN_USE);
+ G_STATIC_ASSERT (G_N_ELEMENTS (g_dbus_error_entries) - 1 == G_DBUS_ERROR_PROPERTY_READ_ONLY);
static volatile gsize quark_volatile = 0;
g_dbus_error_register_error_domain ("g-dbus-error-quark",
&quark_volatile,
@@ -332,7 +340,7 @@ static GHashTable *dbus_error_name_to_re = NULL;
* @dbus_error_name: A D-Bus error name.
*
* Creates an association to map between @dbus_error_name and
- * #GErrors specified by @error_domain and @error_code.
+ * #GErrors specified by @error_domain and @error_code.
*
* This is typically done in the routine that returns the #GQuark for
* an error domain.
@@ -486,16 +494,17 @@ g_dbus_error_is_remote_error (const GError *error)
/**
* g_dbus_error_get_remote_error:
- * @error: A #GError.
+ * @error: a #GError
*
* Gets the D-Bus error name used for @error, if any.
*
* This function is guaranteed to return a D-Bus error name for all
- * #GErrors returned from functions handling remote method
- * calls (e.g. g_dbus_connection_call_finish()) unless
+ * #GErrors returned from functions handling remote method calls
+ * (e.g. g_dbus_connection_call_finish()) unless
* g_dbus_error_strip_remote_error() has been used on @error.
*
- * Returns: An allocated string or %NULL if the D-Bus error name could not be found. Free with g_free().
+ * Returns: an allocated string or %NULL if the D-Bus error name
+ * could not be found. Free with g_free().
*
* Since: 2.26
*/
@@ -650,7 +659,7 @@ g_dbus_error_new_for_dbus_error (const gchar *dbus_error_name,
* @error: A pointer to a #GError or %NULL.
* @dbus_error_name: D-Bus error name.
* @dbus_error_message: D-Bus error message.
- * @format: printf()-style format to prepend to @dbus_error_message or %NULL.
+ * @format: (allow-none): printf()-style format to prepend to @dbus_error_message or %NULL.
* @...: Arguments for @format.
*
* Does nothing if @error is %NULL. Otherwise sets *@error to
@@ -695,7 +704,7 @@ g_dbus_error_set_dbus_error (GError **error,
* @error: A pointer to a #GError or %NULL.
* @dbus_error_name: D-Bus error name.
* @dbus_error_message: D-Bus error message.
- * @format: printf()-style format to prepend to @dbus_error_message or %NULL.
+ * @format: (allow-none): printf()-style format to prepend to @dbus_error_message or %NULL.
* @var_args: Arguments for @format.
*
* Like g_dbus_error_set_dbus_error() but intended for language bindings.
@@ -785,7 +794,7 @@ g_dbus_error_strip_remote_error (GError *error)
* D-Bus error name will be returned.
*
* Otherwise the a name of the form
- * org.gtk.GDBus.UnmappedGError.Quark._ESCAPED_QUARK_NAME.Code_ERROR_CODE
+ * `org.gtk.GDBus.UnmappedGError.Quark._ESCAPED_QUARK_NAME.Code_ERROR_CODE`
* will be used. This allows other GDBus applications to map the error
* on the wire back to a #GError using g_dbus_error_new_for_dbus_error().
*
@@ -837,6 +846,10 @@ g_dbus_error_encode_gerror (const GError *error)
* hex-encode it for transport across the wire.
*/
domain_as_string = g_quark_to_string (error->domain);
+
+ /* 0 is not a domain; neither are non-quark integers */
+ g_return_val_if_fail (domain_as_string != NULL, NULL);
+
s = g_string_new ("org.gtk.GDBus.UnmappedGError.Quark._");
for (n = 0; domain_as_string[n] != 0; n++)
{