Remove !g_thread_supported() codepaths in gio
[platform/upstream/glib.git] / gio / gmountoperation.c
index 0635e75..525943a 100644 (file)
 
 #include "gmountoperation.h"
 #include "gioenumtypes.h"
-#include "gio-marshal.h"
 #include "glibintl.h"
 
-#include "gioalias.h"
 
-/** 
+/**
  * SECTION:gmountoperation
- * @short_description: Authentication methods for mountable locations
+ * @short_description: Object used for authentication and user interaction
  * @include: gio/gio.h
  *
- * #GMountOperation provides a mechanism for authenticating mountable 
- * operations, such as loop mounting files, hard drive partitions or 
- * server locations. 
+ * #GMountOperation provides a mechanism for interacting with the user.
+ * It can be used for authenticating mountable operations, such as loop
+ * mounting files, hard drive partitions or server locations. It can
+ * also be used to ask the user questions or show a list of applications
+ * preventing unmount or eject operations from completing.
  *
- * Mounting operations are handed a #GMountOperation that then can use 
- * if they require any privileges or authentication for their volumes 
- * to be mounted (e.g. a hard disk partition or an encrypted filesystem), 
- * or if they are implementing a remote server protocol which requires 
- * user credentials such as FTP or WebDAV.
+ * Note that #GMountOperation is used for more than just #GMount
+ * objects – for example it is also used in g_drive_start() and
+ * g_drive_stop().
  *
- * Users should instantiate a subclass of this that implements all
- * the various callbacks to show the required dialogs, such as 
- * #GtkMountOperation.
- **/
+ * Users should instantiate a subclass of this that implements all the
+ * various callbacks to show the required dialogs, such as
+ * #GtkMountOperation. If no user interaction is desired (for example
+ * when automounting filesystems at login time), usually %NULL can be
+ * passed, see each method taking a #GMountOperation for details.
+ */
 
 G_DEFINE_TYPE (GMountOperation, g_mount_operation, G_TYPE_OBJECT);
 
@@ -58,6 +58,7 @@ enum {
   ASK_QUESTION,
   REPLY,
   ABORTED,
+  SHOW_PROCESSES,
   LAST_SIGNAL
 };
 
@@ -227,6 +228,18 @@ ask_question (GMountOperation *op,
 }
 
 static void
+show_processes (GMountOperation      *op,
+                const gchar          *message,
+                GArray               *processes,
+                const gchar          *choices[])
+{
+  g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
+                  reply_non_handled_in_idle,
+                  g_object_ref (op),
+                  g_object_unref);
+}
+
+static void
 g_mount_operation_class_init (GMountOperationClass *klass)
 {
   GObjectClass *object_class;
@@ -240,6 +253,7 @@ g_mount_operation_class_init (GMountOperationClass *klass)
   
   klass->ask_password = ask_password;
   klass->ask_question = ask_question;
+  klass->show_processes = show_processes;
   
   /**
    * GMountOperation::ask-password:
@@ -248,8 +262,12 @@ g_mount_operation_class_init (GMountOperationClass *klass)
    * @default_user: string containing the default user name.
    * @default_domain: string containing the default domain.
    * @flags: a set of #GAskPasswordFlags.
-   * 
+   *
    * Emitted when a mount operation asks the user for a password.
+   *
+   * If the message contains a line break, the first line should be
+   * presented as a heading. For example, it may be used as the
+   * primary text in a #GtkMessageDialog.
    */
   signals[ASK_PASSWORD] =
     g_signal_new (I_("ask-password"),
@@ -257,7 +275,7 @@ g_mount_operation_class_init (GMountOperationClass *klass)
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GMountOperationClass, ask_password),
                  NULL, NULL,
-                 _gio_marshal_VOID__STRING_STRING_STRING_FLAGS,
+                 NULL,
                  G_TYPE_NONE, 4,
                  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ASK_PASSWORD_FLAGS);
                  
@@ -266,9 +284,13 @@ g_mount_operation_class_init (GMountOperationClass *klass)
    * @op: a #GMountOperation asking a question.
    * @message: string containing a message to display to the user.
    * @choices: an array of strings for each possible choice.
-   * 
-   * Emitted when asking the user a question and gives a list of 
-   * choices for the user to choose from. 
+   *
+   * Emitted when asking the user a question and gives a list of
+   * choices for the user to choose from.
+   *
+   * If the message contains a line break, the first line should be
+   * presented as a heading. For example, it may be used as the
+   * primary text in a #GtkMessageDialog.
    */
   signals[ASK_QUESTION] =
     g_signal_new (I_("ask-question"),
@@ -276,7 +298,7 @@ g_mount_operation_class_init (GMountOperationClass *klass)
                  G_SIGNAL_RUN_LAST,
                  G_STRUCT_OFFSET (GMountOperationClass, ask_question),
                  NULL, NULL,
-                 _gio_marshal_VOID__STRING_BOXED,
+                 NULL,
                  G_TYPE_NONE, 2,
                  G_TYPE_STRING, G_TYPE_STRV);
                  
@@ -284,7 +306,7 @@ g_mount_operation_class_init (GMountOperationClass *klass)
    * GMountOperation::reply:
    * @op: a #GMountOperation.
    * @result: a #GMountOperationResult indicating how the request was handled
-   * 
+   *
    * Emitted when the user has replied to the mount operation.
    */
   signals[REPLY] =
@@ -301,14 +323,14 @@ g_mount_operation_class_init (GMountOperationClass *klass)
    * GMountOperation::aborted:
    *
    * Emitted by the backend when e.g. a device becomes unavailable
-   * while a mount operation is in progress. 
+   * while a mount operation is in progress.
    *
    * Implementations of GMountOperation should handle this signal
    * by dismissing open password dialogs.
    *
    * Since: 2.20
    */
-  signals[ABORTED] = 
+  signals[ABORTED] =
     g_signal_new (I_("aborted"),
                  G_TYPE_FROM_CLASS (object_class),
                  G_SIGNAL_RUN_LAST,
@@ -318,6 +340,38 @@ g_mount_operation_class_init (GMountOperationClass *klass)
                  G_TYPE_NONE, 0);
 
   /**
+   * GMountOperation::show-processes:
+   * @op: a #GMountOperation.
+   * @message: string containing a message to display to the user.
+   * @processes: an array of #GPid for processes blocking the operation.
+   * @choices: an array of strings for each possible choice.
+   *
+   * Emitted when one or more processes are blocking an operation
+   * e.g. unmounting/ejecting a #GMount or stopping a #GDrive.
+   *
+   * Note that this signal may be emitted several times to update the
+   * list of blocking processes as processes close files. The
+   * application should only respond with g_mount_operation_reply() to
+   * the latest signal (setting #GMountOperation:choice to the choice
+   * the user made).
+   *
+   * If the message contains a line break, the first line should be
+   * presented as a heading. For example, it may be used as the
+   * primary text in a #GtkMessageDialog.
+   *
+   * Since: 2.22
+   */
+  signals[SHOW_PROCESSES] =
+    g_signal_new (I_("show-processes"),
+                 G_TYPE_FROM_CLASS (object_class),
+                 G_SIGNAL_RUN_LAST,
+                 G_STRUCT_OFFSET (GMountOperationClass, show_processes),
+                 NULL, NULL,
+                 NULL,
+                 G_TYPE_NONE, 3,
+                 G_TYPE_STRING, G_TYPE_ARRAY, G_TYPE_STRV);
+
+  /**
    * GMountOperation:username:
    *
    * The user name that is used for authentication when carrying out
@@ -652,6 +706,3 @@ g_mount_operation_reply (GMountOperation *op,
   g_return_if_fail (G_IS_MOUNT_OPERATION (op));
   g_signal_emit (op, signals[REPLY], 0, result);
 }
-
-#define __G_MOUNT_OPERATION_C__
-#include "gioaliasdef.c"