diff options
author | Matthias Clasen <matthiasc@src.gnome.org> | 2008-07-08 16:02:08 +0000 |
---|---|---|
committer | Matthias Clasen <matthiasc@src.gnome.org> | 2008-07-08 16:02:08 +0000 |
commit | d6e4fe5ae9bee035896f874b369de1ace66328fd (patch) | |
tree | dc3c02803a4dfc32156d9e4a2c80a99ba642bcc4 | |
parent | c8c5188fd511d46d45356c866459976ab442ab8b (diff) |
Add g_mount_guess_content_type
svn path=/trunk/; revision=7171
-rw-r--r-- | docs/reference/ChangeLog | 4 | ||||
-rw-r--r-- | docs/reference/gio/gio-sections.txt | 2 | ||||
-rw-r--r-- | gio/ChangeLog | 5 | ||||
-rw-r--r-- | gio/gio.symbols | 2 | ||||
-rw-r--r-- | gio/gmount.c | 93 | ||||
-rw-r--r-- | gio/gmount.h | 29 |
6 files changed, 130 insertions, 5 deletions
diff --git a/docs/reference/ChangeLog b/docs/reference/ChangeLog index 74b57e59d..ee5f03e55 100644 --- a/docs/reference/ChangeLog +++ b/docs/reference/ChangeLog @@ -1,3 +1,7 @@ +2008-07-08 Matthias Clasen <mclasen@redhat.com> + + * gio/gio-sections.txt: Add new GMount functions + 2008-07-05 Matthias Clasen <mclasen@redhat.com> Bug 521589 – [RFC] gobject documentation should mention Vala diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index 7e6ba7131..96ee513fe 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -814,6 +814,8 @@ g_mount_remount_finish g_mount_can_eject g_mount_eject g_mount_eject_finish +g_mount_guess_content_type +g_mount_guess_content_type_finish <SUBSECTION Standard> G_IS_MOUNT G_MOUNT diff --git a/gio/ChangeLog b/gio/ChangeLog index c5441e133..16534755b 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,8 @@ +2008-07-08 Matthias Clasen <mclasen@redhat.com> + + * gio.symbols: + * gmount.[hc]: Add g_mount_guess_content_type(). + 2008-07-06 David Zeuthen <davidz@redhat.com> * gio.symbols: diff --git a/gio/gio.symbols b/gio/gio.symbols index 260b2548e..5c472ceb1 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -715,6 +715,8 @@ g_mount_eject g_mount_eject_finish g_mount_remount g_mount_remount_finish +g_mount_guess_content_type +g_mount_guess_content_type_finish #endif #endif diff --git a/gio/gmount.c b/gio/gmount.c index 172ad3bee..e304dd376 100644 --- a/gio/gmount.c +++ b/gio/gmount.c @@ -2,7 +2,7 @@ /* GIO - GLib Input, Output and Streaming Library * - * Copyright (C) 2006-2007 Red Hat, Inc. + * Copyright (C) 2006-2008 Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -494,7 +494,7 @@ g_mount_remount (GMount *mount, if (iface->remount == NULL) { - g_simple_async_report_error_in_idle (G_OBJECT (mount), + g_simple_async_report_error_in_idle (G_OBJECT (mount), callback, user_data, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, /* Translators: This is an error @@ -541,6 +541,95 @@ g_mount_remount_finish (GMount *mount, return (* iface->remount_finish) (mount, result, error); } +/** + * g_mount_guess_content_type: + * @mount: a #GMount + * @force_rescan: Whether to force a rescan of the content. + * Otherwise a cached result will be used if available + * @cancellable: optional #GCancellable object, %NULL to ignore + * @callback: a #GAsyncReadyCallback + * @user_data: user data passed to @callback + * + * Tries to guess the type of content stored on @mount. Returns one or + * more textual identifiers of well-known content types (typically + * prefixed with "x-content/"), e.g. x-content/image-dcf for camera + * memory cards. See the <ulink url="http://www.freedesktop.org/wiki/Specifications/shared-mime-info-spec">shared-mime-info</ulink> + * specification for more on x-content types. + * + * This is an asynchronous operation, and is finished by calling + * g_mount_guess_content_type_finish() with the @mount and #GAsyncResult + * data returned in the @callback. + * + * Since: 2.18 + */ +void +g_mount_guess_content_type (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GMountIface *iface; + + g_return_if_fail (G_IS_MOUNT (mount)); + + iface = G_MOUNT_GET_IFACE (mount); + + if (iface->guess_content_type == NULL) + { + g_simple_async_report_error_in_idle (G_OBJECT (mount), + callback, user_data, + G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + /* Translators: This is an error + * message for mount objects that + * don't implement content type guessing. */ + _("mount doesn't implement content type guessing")); + + return; + } + + (* iface->guess_content_type) (mount, force_rescan, cancellable, callback, user_data); +} + +/** + * g_mount_guess_content_type_finish: + * @mount: a #GMount + * @result: a #GAsyncResult + * @error: a #GError location to store the error occuring, or %NULL to + * ignore + * + * Finishes guessing content types of @mount. If any errors occured + * during the operation, @error will be set to contain the errors and + * %FALSE will be returned. In particular, you may get an + * %G_IO_ERROR_NOT_SUPPORTED if the mount does not support content + * guessing. + * + * Returns: a %NULL-terminated array of content types or %NULL on error. + * Caller should free this array with g_strfreev() when done with it. + * + * Since: 2.18 + **/ +gchar ** +g_mount_guess_content_type_finish (GMount *mount, + GAsyncResult *result, + GError **error) +{ + GMountIface *iface; + + g_return_val_if_fail (G_IS_MOUNT (mount), FALSE); + g_return_val_if_fail (G_IS_ASYNC_RESULT (result), FALSE); + + if (G_IS_SIMPLE_ASYNC_RESULT (result)) + { + GSimpleAsyncResult *simple = G_SIMPLE_ASYNC_RESULT (result); + if (g_simple_async_result_propagate_error (simple, error)) + return FALSE; + } + + iface = G_MOUNT_GET_IFACE (mount); + return (* iface->guess_content_type_finish) (mount, result, error); +} + #define __G_MOUNT_C__ #include "gioaliasdef.c" diff --git a/gio/gmount.h b/gio/gmount.h index fe4934478..e9438fd2c 100644 --- a/gio/gmount.h +++ b/gio/gmount.h @@ -1,7 +1,7 @@ /* GIO - GLib Input, Output and Streaming Library * - * Copyright (C) 2006-2007 Red Hat, Inc. - * + * Copyright (C) 2006-2008 Red Hat, Inc. + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -58,6 +58,10 @@ typedef struct _GMountIface GMountIface; * @eject_finish: Finishes an eject operation. * @remount: Starts remounting a #GMount. * @remount_finish: Finishes a remounting operation. + * @guess_content_type: Starts guessing the type of the content of a #GMount. + * See g_mount_guess_content_type() for more information on content + * type guessing. This operation was added in 2.18. + * @guess_content_type_finish: Finishes a contenet type guessing operation. * * Interface for implementing operations for mounts. **/ @@ -102,9 +106,19 @@ struct _GMountIface GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); - gboolean (*remount_finish) (GMount *mount, + gboolean (*remount_finish) (GMount *mount, GAsyncResult *result, GError **error); + + void (*guess_content_type) (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); + + gchar ** (*guess_content_type_finish) (GMount *mount, + GAsyncResult *result, + GError **error); }; GType g_mount_get_type (void) G_GNUC_CONST; @@ -143,6 +157,15 @@ gboolean g_mount_remount_finish (GMount *mount, GAsyncResult *result, GError **error); +void g_mount_guess_content_type (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data); +gchar ** g_mount_guess_content_type_finish (GMount *mount, + GAsyncResult *result, + GError **error); + G_END_DECLS #endif /* __G_MOUNT_H__ */ |