1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module gio.MountOperation;
26 
27 private import gio.c.functions;
28 public  import gio.c.types;
29 private import glib.ArrayG;
30 private import glib.ConstructionException;
31 private import glib.Str;
32 private import gobject.ObjectG;
33 private import gobject.Signals;
34 public  import gtkc.giotypes;
35 private import std.algorithm;
36 
37 
38 /**
39  * #GMountOperation provides a mechanism for interacting with the user.
40  * It can be used for authenticating mountable operations, such as loop
41  * mounting files, hard drive partitions or server locations. It can
42  * also be used to ask the user questions or show a list of applications
43  * preventing unmount or eject operations from completing.
44  * 
45  * Note that #GMountOperation is used for more than just #GMount
46  * objects – for example it is also used in g_drive_start() and
47  * g_drive_stop().
48  * 
49  * Users should instantiate a subclass of this that implements all the
50  * various callbacks to show the required dialogs, such as
51  * #GtkMountOperation. If no user interaction is desired (for example
52  * when automounting filesystems at login time), usually %NULL can be
53  * passed, see each method taking a #GMountOperation for details.
54  */
55 public class MountOperation : ObjectG
56 {
57 	/** the main Gtk struct */
58 	protected GMountOperation* gMountOperation;
59 
60 	/** Get the main Gtk struct */
61 	public GMountOperation* getMountOperationStruct(bool transferOwnership = false)
62 	{
63 		if (transferOwnership)
64 			ownedRef = false;
65 		return gMountOperation;
66 	}
67 
68 	/** the main Gtk struct as a void* */
69 	protected override void* getStruct()
70 	{
71 		return cast(void*)gMountOperation;
72 	}
73 
74 	/**
75 	 * Sets our main struct and passes it to the parent class.
76 	 */
77 	public this (GMountOperation* gMountOperation, bool ownedRef = false)
78 	{
79 		this.gMountOperation = gMountOperation;
80 		super(cast(GObject*)gMountOperation, ownedRef);
81 	}
82 
83 
84 	/** */
85 	public static GType getType()
86 	{
87 		return g_mount_operation_get_type();
88 	}
89 
90 	/**
91 	 * Creates a new mount operation.
92 	 *
93 	 * Returns: a #GMountOperation.
94 	 *
95 	 * Throws: ConstructionException GTK+ fails to create the object.
96 	 */
97 	public this()
98 	{
99 		auto p = g_mount_operation_new();
100 
101 		if(p is null)
102 		{
103 			throw new ConstructionException("null returned by new");
104 		}
105 
106 		this(cast(GMountOperation*) p, true);
107 	}
108 
109 	/**
110 	 * Check to see whether the mount operation is being used
111 	 * for an anonymous user.
112 	 *
113 	 * Returns: %TRUE if mount operation is anonymous.
114 	 */
115 	public bool getAnonymous()
116 	{
117 		return g_mount_operation_get_anonymous(gMountOperation) != 0;
118 	}
119 
120 	/**
121 	 * Gets a choice from the mount operation.
122 	 *
123 	 * Returns: an integer containing an index of the user's choice from
124 	 *     the choice's list, or %0.
125 	 */
126 	public int getChoice()
127 	{
128 		return g_mount_operation_get_choice(gMountOperation);
129 	}
130 
131 	/**
132 	 * Gets the domain of the mount operation.
133 	 *
134 	 * Returns: a string set to the domain.
135 	 */
136 	public string getDomain()
137 	{
138 		return Str.toString(g_mount_operation_get_domain(gMountOperation));
139 	}
140 
141 	/**
142 	 * Gets a password from the mount operation.
143 	 *
144 	 * Returns: a string containing the password within @op.
145 	 */
146 	public string getPassword()
147 	{
148 		return Str.toString(g_mount_operation_get_password(gMountOperation));
149 	}
150 
151 	/**
152 	 * Gets the state of saving passwords for the mount operation.
153 	 *
154 	 * Returns: a #GPasswordSave flag.
155 	 */
156 	public GPasswordSave getPasswordSave()
157 	{
158 		return g_mount_operation_get_password_save(gMountOperation);
159 	}
160 
161 	/**
162 	 * Get the user name from the mount operation.
163 	 *
164 	 * Returns: a string containing the user name.
165 	 */
166 	public string getUsername()
167 	{
168 		return Str.toString(g_mount_operation_get_username(gMountOperation));
169 	}
170 
171 	/**
172 	 * Emits the #GMountOperation::reply signal.
173 	 *
174 	 * Params:
175 	 *     result = a #GMountOperationResult
176 	 */
177 	public void reply(GMountOperationResult result)
178 	{
179 		g_mount_operation_reply(gMountOperation, result);
180 	}
181 
182 	/**
183 	 * Sets the mount operation to use an anonymous user if @anonymous is %TRUE.
184 	 *
185 	 * Params:
186 	 *     anonymous = boolean value.
187 	 */
188 	public void setAnonymous(bool anonymous)
189 	{
190 		g_mount_operation_set_anonymous(gMountOperation, anonymous);
191 	}
192 
193 	/**
194 	 * Sets a default choice for the mount operation.
195 	 *
196 	 * Params:
197 	 *     choice = an integer.
198 	 */
199 	public void setChoice(int choice)
200 	{
201 		g_mount_operation_set_choice(gMountOperation, choice);
202 	}
203 
204 	/**
205 	 * Sets the mount operation's domain.
206 	 *
207 	 * Params:
208 	 *     domain = the domain to set.
209 	 */
210 	public void setDomain(string domain)
211 	{
212 		g_mount_operation_set_domain(gMountOperation, Str.toStringz(domain));
213 	}
214 
215 	/**
216 	 * Sets the mount operation's password to @password.
217 	 *
218 	 * Params:
219 	 *     password = password to set.
220 	 */
221 	public void setPassword(string password)
222 	{
223 		g_mount_operation_set_password(gMountOperation, Str.toStringz(password));
224 	}
225 
226 	/**
227 	 * Sets the state of saving passwords for the mount operation.
228 	 *
229 	 * Params:
230 	 *     save = a set of #GPasswordSave flags.
231 	 */
232 	public void setPasswordSave(GPasswordSave save)
233 	{
234 		g_mount_operation_set_password_save(gMountOperation, save);
235 	}
236 
237 	/**
238 	 * Sets the user name within @op to @username.
239 	 *
240 	 * Params:
241 	 *     username = input username.
242 	 */
243 	public void setUsername(string username)
244 	{
245 		g_mount_operation_set_username(gMountOperation, Str.toStringz(username));
246 	}
247 
248 	/**
249 	 * Emitted by the backend when e.g. a device becomes unavailable
250 	 * while a mount operation is in progress.
251 	 *
252 	 * Implementations of GMountOperation should handle this signal
253 	 * by dismissing open password dialogs.
254 	 *
255 	 * Since: 2.20
256 	 */
257 	gulong addOnAborted(void delegate(MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
258 	{
259 		return Signals.connect(this, "aborted", dlg, connectFlags ^ ConnectFlags.SWAPPED);
260 	}
261 
262 	/**
263 	 * Emitted when a mount operation asks the user for a password.
264 	 *
265 	 * If the message contains a line break, the first line should be
266 	 * presented as a heading. For example, it may be used as the
267 	 * primary text in a #GtkMessageDialog.
268 	 *
269 	 * Params:
270 	 *     message = string containing a message to display to the user.
271 	 *     defaultUser = string containing the default user name.
272 	 *     defaultDomain = string containing the default domain.
273 	 *     flags = a set of #GAskPasswordFlags.
274 	 */
275 	gulong addOnAskPassword(void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
276 	{
277 		return Signals.connect(this, "ask-password", dlg, connectFlags ^ ConnectFlags.SWAPPED);
278 	}
279 
280 	/**
281 	 * Emitted when asking the user a question and gives a list of
282 	 * choices for the user to choose from.
283 	 *
284 	 * If the message contains a line break, the first line should be
285 	 * presented as a heading. For example, it may be used as the
286 	 * primary text in a #GtkMessageDialog.
287 	 *
288 	 * Params:
289 	 *     message = string containing a message to display to the user.
290 	 *     choices = an array of strings for each possible choice.
291 	 */
292 	gulong addOnAskQuestion(void delegate(string, string[], MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
293 	{
294 		return Signals.connect(this, "ask-question", dlg, connectFlags ^ ConnectFlags.SWAPPED);
295 	}
296 
297 	/**
298 	 * Emitted when the user has replied to the mount operation.
299 	 *
300 	 * Params:
301 	 *     result = a #GMountOperationResult indicating how the request was handled
302 	 */
303 	gulong addOnReply(void delegate(GMountOperationResult, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
304 	{
305 		return Signals.connect(this, "reply", dlg, connectFlags ^ ConnectFlags.SWAPPED);
306 	}
307 
308 	/**
309 	 * Emitted when one or more processes are blocking an operation
310 	 * e.g. unmounting/ejecting a #GMount or stopping a #GDrive.
311 	 *
312 	 * Note that this signal may be emitted several times to update the
313 	 * list of blocking processes as processes close files. The
314 	 * application should only respond with g_mount_operation_reply() to
315 	 * the latest signal (setting #GMountOperation:choice to the choice
316 	 * the user made).
317 	 *
318 	 * If the message contains a line break, the first line should be
319 	 * presented as a heading. For example, it may be used as the
320 	 * primary text in a #GtkMessageDialog.
321 	 *
322 	 * Params:
323 	 *     message = string containing a message to display to the user.
324 	 *     processes = an array of #GPid for processes
325 	 *         blocking the operation.
326 	 *     choices = an array of strings for each possible choice.
327 	 *
328 	 * Since: 2.22
329 	 */
330 	gulong addOnShowProcesses(void delegate(string, ArrayG, string[], MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
331 	{
332 		return Signals.connect(this, "show-processes", dlg, connectFlags ^ ConnectFlags.SWAPPED);
333 	}
334 
335 	/**
336 	 * Emitted when an unmount operation has been busy for more than some time
337 	 * (typically 1.5 seconds).
338 	 *
339 	 * When unmounting or ejecting a volume, the kernel might need to flush
340 	 * pending data in its buffers to the volume stable storage, and this operation
341 	 * can take a considerable amount of time. This signal may be emitted several
342 	 * times as long as the unmount operation is outstanding, and then one
343 	 * last time when the operation is completed, with @bytes_left set to zero.
344 	 *
345 	 * Implementations of GMountOperation should handle this signal by
346 	 * showing an UI notification, and then dismiss it, or show another notification
347 	 * of completion, when @bytes_left reaches zero.
348 	 *
349 	 * If the message contains a line break, the first line should be
350 	 * presented as a heading. For example, it may be used as the
351 	 * primary text in a #GtkMessageDialog.
352 	 *
353 	 * Params:
354 	 *     message = string containing a mesage to display to the user
355 	 *     timeLeft = the estimated time left before the operation completes,
356 	 *         in microseconds, or -1
357 	 *     bytesLeft = the amount of bytes to be written before the operation
358 	 *         completes (or -1 if such amount is not known), or zero if the operation
359 	 *         is completed
360 	 *
361 	 * Since: 2.34
362 	 */
363 	gulong addOnShowUnmountProgress(void delegate(string, long, long, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
364 	{
365 		return Signals.connect(this, "show-unmount-progress", dlg, connectFlags ^ ConnectFlags.SWAPPED);
366 	}
367 }