glib r7171 - in trunk: docs/reference docs/reference/gio gio



Author: matthiasc
Date: Tue Jul  8 16:02:08 2008
New Revision: 7171
URL: http://svn.gnome.org/viewvc/glib?rev=7171&view=rev

Log:
Add g_mount_guess_content_type


Modified:
   trunk/docs/reference/ChangeLog
   trunk/docs/reference/gio/gio-sections.txt
   trunk/gio/ChangeLog
   trunk/gio/gio.symbols
   trunk/gio/gmount.c
   trunk/gio/gmount.h

Modified: trunk/docs/reference/gio/gio-sections.txt
==============================================================================
--- trunk/docs/reference/gio/gio-sections.txt	(original)
+++ trunk/docs/reference/gio/gio-sections.txt	Tue Jul  8 16:02:08 2008
@@ -814,6 +814,8 @@
 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

Modified: trunk/gio/gio.symbols
==============================================================================
--- trunk/gio/gio.symbols	(original)
+++ trunk/gio/gio.symbols	Tue Jul  8 16:02:08 2008
@@ -715,6 +715,8 @@
 g_mount_eject_finish 
 g_mount_remount 
 g_mount_remount_finish 
+g_mount_guess_content_type
+g_mount_guess_content_type_finish
 #endif
 #endif
 

Modified: trunk/gio/gmount.c
==============================================================================
--- trunk/gio/gmount.c	(original)
+++ trunk/gio/gmount.c	Tue Jul  8 16:02:08 2008
@@ -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 @@
 
   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 @@
   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"

Modified: trunk/gio/gmount.h
==============================================================================
--- trunk/gio/gmount.h	(original)
+++ trunk/gio/gmount.h	Tue Jul  8 16:02:08 2008
@@ -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 @@
  * @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 @@
                                               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 @@
                                                  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__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]