From 64c1eba19788ecd7af80663c64a5d6a9e2f1d8a2 Mon Sep 17 00:00:00 2001 From: David Zeuthen Date: Thu, 24 Jul 2008 21:21:22 +0000 Subject: [PATCH] Also export a g_mount_guess_content_type_sync() function. 2008-07-24 David Zeuthen * gmount.[ch]: * gio.symbols: Also export a g_mount_guess_content_type_sync() function. svn path=/trunk/; revision=7252 --- docs/reference/gio/gio-sections.txt | 1 + gio/ChangeLog | 6 ++++ gio/gio.symbols | 1 + gio/gmount.c | 56 +++++++++++++++++++++++++++++++++++-- gio/gmount.h | 10 +++++++ 5 files changed, 71 insertions(+), 3 deletions(-) diff --git a/docs/reference/gio/gio-sections.txt b/docs/reference/gio/gio-sections.txt index 891d7f5..2306731 100644 --- a/docs/reference/gio/gio-sections.txt +++ b/docs/reference/gio/gio-sections.txt @@ -816,6 +816,7 @@ g_mount_eject g_mount_eject_finish g_mount_guess_content_type g_mount_guess_content_type_finish +g_mount_guess_content_type_sync G_IS_MOUNT G_MOUNT diff --git a/gio/ChangeLog b/gio/ChangeLog index 51c46e4..a53a943 100644 --- a/gio/ChangeLog +++ b/gio/ChangeLog @@ -1,3 +1,9 @@ +2008-07-24 David Zeuthen + + * gmount.[ch]: + * gio.symbols: + Also export a g_mount_guess_content_type_sync() function. + 2008-07-23 Matthias Clasen 529694 – SELinux context setting support diff --git a/gio/gio.symbols b/gio/gio.symbols index 9d8f8c4..445d8bc 100644 --- a/gio/gio.symbols +++ b/gio/gio.symbols @@ -718,6 +718,7 @@ g_mount_remount g_mount_remount_finish g_mount_guess_content_type g_mount_guess_content_type_finish +g_mount_guess_content_type_sync #endif #endif diff --git a/gio/gmount.c b/gio/gmount.c index a5545a4..3c8ae61 100644 --- a/gio/gmount.c +++ b/gio/gmount.c @@ -570,9 +570,10 @@ g_mount_remount_finish (GMount *mount, * memory cards. See the shared-mime-info * 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. + * This is an asynchronous operation (see + * g_mount_guess_content_type_sync() for the synchronous version), and + * is finished by calling g_mount_guess_content_type_finish() with the + * @mount and #GAsyncResult data returned in the @callback. * * Since: 2.18 */ @@ -644,6 +645,55 @@ g_mount_guess_content_type_finish (GMount *mount, return (* iface->guess_content_type_finish) (mount, result, error); } +/** + * g_mount_guess_content_type_sync: + * @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 + * @error: a #GError location to store the error occuring, or %NULL to + * ignore + * + * 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 shared-mime-info + * specification for more on x-content types. + * + * This is an synchronous operation and as such may block doing IO; + * see g_mount_guess_content_type() for the asynchronous version. + * + * 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 + */ +char ** +g_mount_guess_content_type_sync (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GError **error) +{ + GMountIface *iface; + + g_return_val_if_fail (G_IS_MOUNT (mount), NULL); + + iface = G_MOUNT_GET_IFACE (mount); + + if (iface->guess_content_type_sync == NULL) + { + g_set_error_literal (error, + 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 synchronous content type guessing")); + + return NULL; + } + + return (* iface->guess_content_type_sync) (mount, force_rescan, cancellable, error); +} #define __G_MOUNT_C__ #include "gioaliasdef.c" diff --git a/gio/gmount.h b/gio/gmount.h index e9438fd..6f0213d 100644 --- a/gio/gmount.h +++ b/gio/gmount.h @@ -119,6 +119,11 @@ struct _GMountIface gchar ** (*guess_content_type_finish) (GMount *mount, GAsyncResult *result, GError **error); + + gchar ** (*guess_content_type_sync) (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GError **error); }; GType g_mount_get_type (void) G_GNUC_CONST; @@ -166,6 +171,11 @@ gchar ** g_mount_guess_content_type_finish (GMount *mount, GAsyncResult *result, GError **error); +gchar ** g_mount_guess_content_type_sync (GMount *mount, + gboolean force_rescan, + GCancellable *cancellable, + GError **error); + G_END_DECLS #endif /* __G_MOUNT_H__ */ -- 2.7.4