13781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/* GIO - GLib Input, Output and Streaming Library
23781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
33781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Copyright (C) 2006-2007 Red Hat, Inc.
43781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
53781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * This library is free software; you can redistribute it and/or
63781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * modify it under the terms of the GNU Lesser General Public
73781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * License as published by the Free Software Foundation; either
83781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * version 2 of the License, or (at your option) any later version.
93781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
103781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * This library is distributed in the hope that it will be useful,
113781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * but WITHOUT ANY WARRANTY; without even the implied warranty of
123781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
133781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Lesser General Public License for more details.
143781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * You should have received a copy of the GNU Lesser General
163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Public License along with this library; if not, write to the
173781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
183781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Boston, MA 02111-1307, USA.
193781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Author: Alexander Larsson <alexl@redhat.com>
213781343738de4abddf56982325a77bd70a98cd26Alexander Larsson */
223781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
23761424465aaad736916b029383483b6ac419d831Johan Dahlin#include "config.h"
243781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
253781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include <string.h>
263781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
273781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include "gmountoperation.h"
28af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen#include "gioenumtypes.h"
293781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include "gio-marshal.h"
303781343738de4abddf56982325a77bd70a98cd26Alexander Larsson#include "glibintl.h"
313781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
327f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson#include "gioalias.h"
337f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson
345247f12f3649726471080440de0d37b78c1cec33Andrew Walton/**
355247f12f3649726471080440de0d37b78c1cec33Andrew Walton * SECTION:gmountoperation
3661582bd91cba508362d0e28db4d6e3f307b27b48Matthias Clasen * @short_description: Authentication methods for mountable locations
37f3144c7efe8c84f7a00bff9b796d5e73efc151cfMatthias Clasen * @include: gio/gio.h
385247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
395247f12f3649726471080440de0d37b78c1cec33Andrew Walton * #GMountOperation provides a mechanism for authenticating mountable
405247f12f3649726471080440de0d37b78c1cec33Andrew Walton * operations, such as loop mounting files, hard drive partitions or
415247f12f3649726471080440de0d37b78c1cec33Andrew Walton * server locations.
425247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
430debd52858ffb4f468e55cd2f3c7e4dec5455b94Matthias Clasen * Mounting operations are handed a #GMountOperation that then can use
440debd52858ffb4f468e55cd2f3c7e4dec5455b94Matthias Clasen * if they require any privileges or authentication for their volumes
450debd52858ffb4f468e55cd2f3c7e4dec5455b94Matthias Clasen * to be mounted (e.g. a hard disk partition or an encrypted filesystem),
460debd52858ffb4f468e55cd2f3c7e4dec5455b94Matthias Clasen * or if they are implementing a remote server protocol which requires
470debd52858ffb4f468e55cd2f3c7e4dec5455b94Matthias Clasen * user credentials such as FTP or WebDAV.
4841d1650c9b6b0b8368c0648d2885b83e18020303Alexander Larsson *
4941d1650c9b6b0b8368c0648d2885b83e18020303Alexander Larsson * Users should instantiate a subclass of this that implements all
5043db4fb1ddbd8bbb91f3323c94f5e9b8e5e9eb0dMatthias Clasen * the various callbacks to show the required dialogs, such as
5143db4fb1ddbd8bbb91f3323c94f5e9b8e5e9eb0dMatthias Clasen * #GtkMountOperation.
525247f12f3649726471080440de0d37b78c1cec33Andrew Walton **/
535247f12f3649726471080440de0d37b78c1cec33Andrew Walton
543781343738de4abddf56982325a77bd70a98cd26Alexander LarssonG_DEFINE_TYPE (GMountOperation, g_mount_operation, G_TYPE_OBJECT);
553781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
563781343738de4abddf56982325a77bd70a98cd26Alexander Larssonenum {
573781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  ASK_PASSWORD,
583781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  ASK_QUESTION,
593781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  REPLY,
6049cb04caf0d37d42ab8787739689906df831525fMatthias Clasen  ABORTED,
613781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  LAST_SIGNAL
623781343738de4abddf56982325a77bd70a98cd26Alexander Larsson};
633781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
643781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic guint signals[LAST_SIGNAL] = { 0 };
653781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
663781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstruct _GMountOperationPrivate {
673781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  char *password;
683781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  char *user;
693781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  char *domain;
703781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  gboolean anonymous;
713781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  GPasswordSave password_save;
723781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  int choice;
733781343738de4abddf56982325a77bd70a98cd26Alexander Larsson};
743781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
75af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasenenum {
76af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  PROP_0,
77af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  PROP_USERNAME,
78af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  PROP_PASSWORD,
79af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  PROP_ANONYMOUS,
80af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  PROP_DOMAIN,
81af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  PROP_PASSWORD_SAVE,
82af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  PROP_CHOICE
83af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen};
84af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
85af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasenstatic void
86af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Claseng_mount_operation_set_property (GObject      *object,
87af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                guint         prop_id,
88af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                const GValue *value,
89af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                GParamSpec   *pspec)
90af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen{
91af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  GMountOperation *operation;
92af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
93af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  operation = G_MOUNT_OPERATION (object);
94af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
95af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  switch (prop_id)
96af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    {
97af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_USERNAME:
98af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_mount_operation_set_username (operation,
99af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                      g_value_get_string (value));
100af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
101af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
102af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_PASSWORD:
103af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_mount_operation_set_password (operation,
104af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                      g_value_get_string (value));
105af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
106af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
107af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_ANONYMOUS:
108af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_mount_operation_set_anonymous (operation,
109af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                       g_value_get_boolean (value));
110af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
111af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
112af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_DOMAIN:
113af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_mount_operation_set_domain (operation,
114af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                    g_value_get_string (value));
115af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
116af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
117af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_PASSWORD_SAVE:
118af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_mount_operation_set_password_save (operation,
119af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                           g_value_get_enum (value));
120af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
121af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
122af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_CHOICE:
123af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_mount_operation_set_choice (operation,
124af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                    g_value_get_int (value));
125af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
126af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
127af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    default:
128af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
129af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
130af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    }
131af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen}
132af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
133af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
134af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasenstatic void
135af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Claseng_mount_operation_get_property (GObject    *object,
136af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                guint       prop_id,
137af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                GValue     *value,
138af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                GParamSpec *pspec)
139af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen{
140af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  GMountOperation *operation;
141af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  GMountOperationPrivate *priv;
142af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
143af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  operation = G_MOUNT_OPERATION (object);
144af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  priv = operation->priv;
145af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
146af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  switch (prop_id)
147af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    {
148af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_USERNAME:
149af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_value_set_string (value, priv->user);
150af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
151af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
152af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_PASSWORD:
153af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_value_set_string (value, priv->password);
154af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
155af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
156af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_ANONYMOUS:
157af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_value_set_boolean (value, priv->anonymous);
158af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
159af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
160af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_DOMAIN:
161af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_value_set_string (value, priv->domain);
162af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
163af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
164af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_PASSWORD_SAVE:
165af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_value_set_enum (value, priv->password_save);
166af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
167af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
168af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    case PROP_CHOICE:
169af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_value_set_int (value, priv->choice);
170af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
171af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
172af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    default:
173af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
174af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      break;
175af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    }
176af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen}
177af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
178af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
1793781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic void
1803781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_finalize (GObject *object)
1813781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
1823781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  GMountOperation *operation;
1833781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  GMountOperationPrivate *priv;
1843781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
1853781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  operation = G_MOUNT_OPERATION (object);
1863781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
1873781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  priv = operation->priv;
1883781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
1893781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_free (priv->password);
1903781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_free (priv->user);
1913781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_free (priv->domain);
192a4427bfff5d31499dc0b46fa3f734bc92f7d0dd5Michael Natterer
193a4427bfff5d31499dc0b46fa3f734bc92f7d0dd5Michael Natterer  G_OBJECT_CLASS (g_mount_operation_parent_class)->finalize (object);
1943781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
1953781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
1963781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic gboolean
197e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larssonreply_non_handled_in_idle (gpointer data)
1983781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
199e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson  GMountOperation *op = data;
200e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson
201e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson  g_mount_operation_reply (op, G_MOUNT_OPERATION_UNHANDLED);
202e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson  return FALSE;
2033781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
2043781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
205e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larssonstatic void
2063781343738de4abddf56982325a77bd70a98cd26Alexander Larssonask_password (GMountOperation *op,
2073781343738de4abddf56982325a77bd70a98cd26Alexander Larsson	      const char      *message,
2083781343738de4abddf56982325a77bd70a98cd26Alexander Larsson	      const char      *default_user,
2093781343738de4abddf56982325a77bd70a98cd26Alexander Larsson	      const char      *default_domain,
2104cb6eab803662aebb2a81fe97832dd7576391331Alexander Larsson	      GAskPasswordFlags flags)
2113781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
212e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson  g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
213e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		   reply_non_handled_in_idle,
214e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		   g_object_ref (op),
215e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		   g_object_unref);
2163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
2173781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
218e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larssonstatic void
2193781343738de4abddf56982325a77bd70a98cd26Alexander Larssonask_question (GMountOperation *op,
2203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson	      const char      *message,
2213781343738de4abddf56982325a77bd70a98cd26Alexander Larsson	      const char      *choices[])
2223781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
223e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson  g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
224e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		   reply_non_handled_in_idle,
225e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		   g_object_ref (op),
226e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		   g_object_unref);
2273781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
2283781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
2293781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic void
2303781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_class_init (GMountOperationClass *klass)
2313781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
232af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  GObjectClass *object_class;
2333781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
2343781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_type_class_add_private (klass, sizeof (GMountOperationPrivate));
235af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
236af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  object_class = G_OBJECT_CLASS (klass);
237af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  object_class->finalize = g_mount_operation_finalize;
238af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  object_class->get_property = g_mount_operation_get_property;
239af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  object_class->set_property = g_mount_operation_set_property;
2403781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
2413781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  klass->ask_password = ask_password;
2423781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  klass->ask_question = ask_question;
2433781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
2445247f12f3649726471080440de0d37b78c1cec33Andrew Walton  /**
2455247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * GMountOperation::ask-password:
2465247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @op: a #GMountOperation requesting a password.
2475247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @message: string containing a message to display to the user.
2485247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @default_user: string containing the default user name.
2495247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @default_domain: string containing the default domain.
2504cb6eab803662aebb2a81fe97832dd7576391331Alexander Larsson   * @flags: a set of #GAskPasswordFlags.
251474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   *
2525247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * Emitted when a mount operation asks the user for a password.
253474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   *
254474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * If the message contains a line break, the first line should be
255474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * presented as a heading. For example, it may be used as the
256474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * primary text in a #GtkMessageDialog.
2575247f12f3649726471080440de0d37b78c1cec33Andrew Walton   */
2583781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  signals[ASK_PASSWORD] =
2598d37a7964d3b41de330aa581b61eda374b093e71Sven Neumann    g_signal_new (I_("ask-password"),
260af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen		  G_TYPE_FROM_CLASS (object_class),
2613781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  G_SIGNAL_RUN_LAST,
2623781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  G_STRUCT_OFFSET (GMountOperationClass, ask_password),
263e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  NULL, NULL,
264e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  _gio_marshal_VOID__STRING_STRING_STRING_FLAGS,
265e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  G_TYPE_NONE, 4,
266361e0e9b1c8bfc4690a8522e33d607382812b621Alexander Larsson		  G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_ASK_PASSWORD_FLAGS);
2675247f12f3649726471080440de0d37b78c1cec33Andrew Walton
2685247f12f3649726471080440de0d37b78c1cec33Andrew Walton  /**
2695247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * GMountOperation::ask-question:
2705247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @op: a #GMountOperation asking a question.
2715247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @message: string containing a message to display to the user.
2725247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @choices: an array of strings for each possible choice.
273474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   *
274474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * Emitted when asking the user a question and gives a list of
275474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * choices for the user to choose from.
276474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   *
277474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * If the message contains a line break, the first line should be
278474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * presented as a heading. For example, it may be used as the
279474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * primary text in a #GtkMessageDialog.
2805247f12f3649726471080440de0d37b78c1cec33Andrew Walton   */
2813781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  signals[ASK_QUESTION] =
2828d37a7964d3b41de330aa581b61eda374b093e71Sven Neumann    g_signal_new (I_("ask-question"),
283af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen		  G_TYPE_FROM_CLASS (object_class),
2843781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  G_SIGNAL_RUN_LAST,
2853781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  G_STRUCT_OFFSET (GMountOperationClass, ask_question),
286e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  NULL, NULL,
287e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  _gio_marshal_VOID__STRING_BOXED,
288e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  G_TYPE_NONE, 2,
289361e0e9b1c8bfc4690a8522e33d607382812b621Alexander Larsson		  G_TYPE_STRING, G_TYPE_STRV);
2905247f12f3649726471080440de0d37b78c1cec33Andrew Walton
2915247f12f3649726471080440de0d37b78c1cec33Andrew Walton  /**
2925247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * GMountOperation::reply:
2935247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * @op: a #GMountOperation.
294d420020715103d209b49fbfd7e9b1e2781fd8512Matthias Clasen   * @result: a #GMountOperationResult indicating how the request was handled
295474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   *
2965247f12f3649726471080440de0d37b78c1cec33Andrew Walton   * Emitted when the user has replied to the mount operation.
2975247f12f3649726471080440de0d37b78c1cec33Andrew Walton   */
2983781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  signals[REPLY] =
2993781343738de4abddf56982325a77bd70a98cd26Alexander Larsson    g_signal_new (I_("reply"),
300af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen		  G_TYPE_FROM_CLASS (object_class),
3013781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  G_SIGNAL_RUN_LAST,
3023781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  G_STRUCT_OFFSET (GMountOperationClass, reply),
3033781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  NULL, NULL,
304e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  g_cclosure_marshal_VOID__ENUM,
3053781343738de4abddf56982325a77bd70a98cd26Alexander Larsson		  G_TYPE_NONE, 1,
306e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson		  G_TYPE_MOUNT_OPERATION_RESULT);
307af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
308af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  /**
30949cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   * GMountOperation::aborted:
31049cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   *
31149cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   * Emitted by the backend when e.g. a device becomes unavailable
312474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen   * while a mount operation is in progress.
31349cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   *
31449cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   * Implementations of GMountOperation should handle this signal
31549cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   * by dismissing open password dialogs.
31649cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   *
31749cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   * Since: 2.20
31849cb04caf0d37d42ab8787739689906df831525fMatthias Clasen   */
319474db07f6a5fe0fadc352948b12798635e419fddMatthias Clasen  signals[ABORTED] =
32049cb04caf0d37d42ab8787739689906df831525fMatthias Clasen    g_signal_new (I_("aborted"),
32149cb04caf0d37d42ab8787739689906df831525fMatthias Clasen		  G_TYPE_FROM_CLASS (object_class),
32249cb04caf0d37d42ab8787739689906df831525fMatthias Clasen		  G_SIGNAL_RUN_LAST,
32349cb04caf0d37d42ab8787739689906df831525fMatthias Clasen		  G_STRUCT_OFFSET (GMountOperationClass, aborted),
32449cb04caf0d37d42ab8787739689906df831525fMatthias Clasen		  NULL, NULL,
32549cb04caf0d37d42ab8787739689906df831525fMatthias Clasen		  g_cclosure_marshal_VOID__VOID,
32649cb04caf0d37d42ab8787739689906df831525fMatthias Clasen		  G_TYPE_NONE, 0);
32749cb04caf0d37d42ab8787739689906df831525fMatthias Clasen
32849cb04caf0d37d42ab8787739689906df831525fMatthias Clasen  /**
329af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * GMountOperation:username:
330af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   *
331af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * The user name that is used for authentication when carrying out
332af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * the mount operation.
333af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   */
334af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_class_install_property (object_class,
335af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   PROP_USERNAME,
336af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   g_param_spec_string ("username",
337af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        P_("Username"),
338af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        P_("The user name"),
339af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        NULL,
3402e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                        G_PARAM_READWRITE|
3412e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                        G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
342af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
343af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  /**
344af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * GMountOperation:password:
345af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   *
346af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * The password that is used for authentication when carrying out
347af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * the mount operation.
348af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   */
349af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_class_install_property (object_class,
350af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   PROP_PASSWORD,
351af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   g_param_spec_string ("password",
352af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        P_("Password"),
353af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        P_("The password"),
354af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        NULL,
3552e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                        G_PARAM_READWRITE|
3562e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                        G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
357af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
358af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  /**
359af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * GMountOperation:anonymous:
360af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   *
361af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * Whether to use an anonymous user when authenticating.
362af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   */
363af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_class_install_property (object_class,
364af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   PROP_ANONYMOUS,
365af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   g_param_spec_boolean ("anonymous",
366af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                         P_("Anonymous"),
367af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                         P_("Whether to use an anonymous user"),
368af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                         FALSE,
3692e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                         G_PARAM_READWRITE|
3702e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                         G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
371af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
372af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  /**
373af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * GMountOperation:domain:
374af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   *
375af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * The domain to use for the mount operation.
376af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   */
377af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_class_install_property (object_class,
378af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   PROP_DOMAIN,
379af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   g_param_spec_string ("domain",
380af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        P_("Domain"),
381af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        P_("The domain of the mount operation"),
382af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                        NULL,
3832e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                        G_PARAM_READWRITE|
3842e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                        G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
385af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
386af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  /**
387af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * GMountOperation:password-save:
388af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   *
389af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * Determines if and how the password information should be saved.
390af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   */
391af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_class_install_property (object_class,
392af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   PROP_PASSWORD_SAVE,
393af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   g_param_spec_enum ("password-save",
394af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                      P_("Password save"),
395af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                      P_("How passwords should be saved"),
396af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                      G_TYPE_PASSWORD_SAVE,
397af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                      G_PASSWORD_SAVE_NEVER,
3982e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                      G_PARAM_READWRITE|
3992e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                      G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
400af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
401af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  /**
402af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * GMountOperation:choice:
403af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   *
404af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * The index of the user's choice when a question is asked during the
405af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   * mount operation. See the #GMountOperation::ask-question signal.
406af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen   */
407af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_class_install_property (object_class,
408af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   PROP_CHOICE,
409af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                   g_param_spec_int ("choice",
410af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                     P_("Choice"),
411af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                     P_("The users choice"),
412af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen                                                     0, G_MAXINT, 0,
4132e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                     G_PARAM_READWRITE|
4142e67aabed7385b0fb4e0f3480099578ffde777a3Matthias Clasen                                                     G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB));
4153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
4163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
4173781343738de4abddf56982325a77bd70a98cd26Alexander Larssonstatic void
4183781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_init (GMountOperation *operation)
4193781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
4203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  operation->priv = G_TYPE_INSTANCE_GET_PRIVATE (operation,
4213781343738de4abddf56982325a77bd70a98cd26Alexander Larsson						 G_TYPE_MOUNT_OPERATION,
4223781343738de4abddf56982325a77bd70a98cd26Alexander Larsson						 GMountOperationPrivate);
4233781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
4243781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
4253781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
4263781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_new:
4273781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
4285247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Creates a new mount operation.
4295247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
4305247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Returns: a #GMountOperation.
4313781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
4323781343738de4abddf56982325a77bd70a98cd26Alexander LarssonGMountOperation *
4333781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_new (void)
4343781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
4353781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  return g_object_new (G_TYPE_MOUNT_OPERATION, NULL);
4363781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
4373781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
4383781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
4393781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_get_username
4405247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
4413781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
4425247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Get the user name from the mount operation.
4435247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
4445247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Returns: a string containing the user name.
4453781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
4463781343738de4abddf56982325a77bd70a98cd26Alexander Larssonconst char *
4473781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_get_username (GMountOperation *op)
4483781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
4493781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
4503781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  return op->priv->user;
4513781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
4523781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
4533781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
4543781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_set_username:
4555247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
4563781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * @username: input username.
4575247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
4585247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Sets the user name within @op to @username.
4593781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
4603781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid
4613781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_set_username (GMountOperation *op,
4623781343738de4abddf56982325a77bd70a98cd26Alexander Larsson				const char      *username)
4633781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
4643781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_if_fail (G_IS_MOUNT_OPERATION (op));
4653781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_free (op->priv->user);
4663781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  op->priv->user = g_strdup (username);
467af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_notify (G_OBJECT (op), "username");
4683781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
4693781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
4703781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
4713781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_get_password:
4725247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
4735247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
4745247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Gets a password from the mount operation.
4755247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
4765247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Returns: a string containing the password within @op.
4773781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
4783781343738de4abddf56982325a77bd70a98cd26Alexander Larssonconst char *
4793781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_get_password (GMountOperation *op)
4803781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
4813781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
4823781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  return op->priv->password;
4833781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
4843781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
4853781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
4863781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_set_password:
4875247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
4883781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * @password: password to set.
4893781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
4903781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Sets the mount operation's password to @password.
4913781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
4923781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
4933781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid
4943781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_set_password (GMountOperation *op,
4953781343738de4abddf56982325a77bd70a98cd26Alexander Larsson				const char      *password)
4963781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
4973781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_if_fail (G_IS_MOUNT_OPERATION (op));
4983781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_free (op->priv->password);
4993781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  op->priv->password = g_strdup (password);
500af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_notify (G_OBJECT (op), "password");
5013781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
5023781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
5033781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
5043781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_get_anonymous:
5055247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
5065247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
5075247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Check to see whether the mount operation is being used
5085247f12f3649726471080440de0d37b78c1cec33Andrew Walton * for an anonymous user.
5093781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
5103781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Returns: %TRUE if mount operation is anonymous.
5113781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
5123781343738de4abddf56982325a77bd70a98cd26Alexander Larssongboolean
5133781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_get_anonymous (GMountOperation *op)
5143781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
5153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), FALSE);
5163781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  return op->priv->anonymous;
5173781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
5183781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
5193781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
5203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_set_anonymous:
5215247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
5223781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * @anonymous: boolean value.
5233781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
5245247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Sets the mount operation to use an anonymous user if @anonymous is %TRUE.
5253781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
5263781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid
5273781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_set_anonymous (GMountOperation *op,
5283781343738de4abddf56982325a77bd70a98cd26Alexander Larsson				 gboolean         anonymous)
5293781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
530af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  GMountOperationPrivate *priv;
5313781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_if_fail (G_IS_MOUNT_OPERATION (op));
532af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  priv = op->priv;
533af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
534af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  if (priv->anonymous != anonymous)
535af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    {
536af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      priv->anonymous = anonymous;
537af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_object_notify (G_OBJECT (op), "anonymous");
538af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    }
5393781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
5403781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
5413781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
5423781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_get_domain:
5435247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
5445247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
5455247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Gets the domain of the mount operation.
5463781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
5475247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Returns: a string set to the domain.
5483781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
5493781343738de4abddf56982325a77bd70a98cd26Alexander Larssonconst char *
5503781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_get_domain (GMountOperation *op)
5513781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
5523781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), NULL);
5533781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  return op->priv->domain;
5543781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
5553781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
5563781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
5573781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_set_domain:
5585247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
5593781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * @domain: the domain to set.
5603781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
5613781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * Sets the mount operation's domain.
5623781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
5633781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid
5643781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_set_domain (GMountOperation *op,
5653781343738de4abddf56982325a77bd70a98cd26Alexander Larsson			      const char      *domain)
5663781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
5673781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_if_fail (G_IS_MOUNT_OPERATION (op));
5683781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_free (op->priv->domain);
5693781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  op->priv->domain = g_strdup (domain);
570af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  g_object_notify (G_OBJECT (op), "domain");
5713781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
5723781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
5733781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
5743781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_get_password_save:
5755247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
5765247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
5775247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Gets the state of saving passwords for the mount operation.
5783781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
5795247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Returns: a #GPasswordSave flag.
5803781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
5813781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
5823781343738de4abddf56982325a77bd70a98cd26Alexander LarssonGPasswordSave
5833781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_get_password_save (GMountOperation *op)
5843781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
5853781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), G_PASSWORD_SAVE_NEVER);
5863781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  return op->priv->password_save;
5873781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
5883781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
5893781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
5905247f12f3649726471080440de0d37b78c1cec33Andrew Walton * g_mount_operation_set_password_save:
5915247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
5925247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @save: a set of #GPasswordSave flags.
5935247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
5945247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Sets the state of saving passwords for the mount operation.
5953781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
5963781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
5973781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid
5983781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_set_password_save (GMountOperation *op,
5993781343738de4abddf56982325a77bd70a98cd26Alexander Larsson				     GPasswordSave    save)
6003781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
601af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  GMountOperationPrivate *priv;
6023781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_if_fail (G_IS_MOUNT_OPERATION (op));
603af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  priv = op->priv;
604af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen
605af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  if (priv->password_save != save)
606af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    {
607af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      priv->password_save = save;
608af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_object_notify (G_OBJECT (op), "password-save");
609af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    }
6103781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
6113781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
6123781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
6133781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_get_choice:
6145247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
6153781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
6165247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Gets a choice from the mount operation.
6175247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
6185247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Returns: an integer containing an index of the user's choice from
6195247f12f3649726471080440de0d37b78c1cec33Andrew Walton * the choice's list, or %0.
6203781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
6213781343738de4abddf56982325a77bd70a98cd26Alexander Larssonint
6223781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_get_choice (GMountOperation *op)
6233781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
6243781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_val_if_fail (G_IS_MOUNT_OPERATION (op), 0);
6253781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  return op->priv->choice;
6263781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
6273781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
6283781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
6293781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_set_choice:
6305247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @op: a #GMountOperation.
6315247f12f3649726471080440de0d37b78c1cec33Andrew Walton * @choice: an integer.
6325247f12f3649726471080440de0d37b78c1cec33Andrew Walton *
6335247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Sets a default choice for the mount operation.
6343781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
6353781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid
6363781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_set_choice (GMountOperation *op,
637a2ca589703273fca80cb126430a8b058aba3eb52Matthias Clasen			      int              choice)
6383781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
639af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  GMountOperationPrivate *priv;
6403781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_if_fail (G_IS_MOUNT_OPERATION (op));
641af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  priv = op->priv;
642af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen  if (priv->choice != choice)
643af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    {
644af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      priv->choice = choice;
645af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen      g_object_notify (G_OBJECT (op), "choice");
646af5372bfe270ee387392a7ea5fd43c69831ee175Matthias Clasen    }
6473781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
6483781343738de4abddf56982325a77bd70a98cd26Alexander Larsson
6493781343738de4abddf56982325a77bd70a98cd26Alexander Larsson/**
6503781343738de4abddf56982325a77bd70a98cd26Alexander Larsson * g_mount_operation_reply:
651d16037e0e7ff12577574ed41be893c90d4b3477cMatthias Clasen * @op: a #GMountOperation
652d16037e0e7ff12577574ed41be893c90d4b3477cMatthias Clasen * @result: a #GMountOperationResult
6533781343738de4abddf56982325a77bd70a98cd26Alexander Larsson *
6545247f12f3649726471080440de0d37b78c1cec33Andrew Walton * Emits the #GMountOperation::reply signal.
6553781343738de4abddf56982325a77bd70a98cd26Alexander Larsson **/
6563781343738de4abddf56982325a77bd70a98cd26Alexander Larssonvoid
6573781343738de4abddf56982325a77bd70a98cd26Alexander Larssong_mount_operation_reply (GMountOperation *op,
658e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson			 GMountOperationResult result)
6593781343738de4abddf56982325a77bd70a98cd26Alexander Larsson{
6603781343738de4abddf56982325a77bd70a98cd26Alexander Larsson  g_return_if_fail (G_IS_MOUNT_OPERATION (op));
661e6ca69069401c5739762a466291d5c9148b1bc76Alexander Larsson  g_signal_emit (op, signals[REPLY], 0, result);
6623781343738de4abddf56982325a77bd70a98cd26Alexander Larsson}
6637f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson
6647f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson#define __G_MOUNT_OPERATION_C__
6657f3280230bc9448a5750fc17a6eabef691ba25f4Alexander Larsson#include "gioaliasdef.c"
666