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  * Conversion parameters:
26  * inFile  = GMountOperation.html
27  * outPack = gio
28  * outFile = MountOperation
29  * strct   = GMountOperation
30  * realStrct=
31  * ctorStrct=
32  * clss    = MountOperation
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = GObject
38  * implements:
39  * prefixes:
40  * 	- g_mount_operation_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Str
47  * 	- glib.ArrayG
48  * structWrap:
49  * 	- GArray* -> ArrayG
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module gio.MountOperation;
56 
57 public  import gtkc.giotypes;
58 
59 private import gtkc.gio;
60 private import glib.ConstructionException;
61 private import gobject.ObjectG;
62 
63 private import gobject.Signals;
64 public  import gtkc.gdktypes;
65 
66 private import glib.Str;
67 private import glib.ArrayG;
68 
69 
70 
71 private import gobject.ObjectG;
72 
73 /**
74  * GMountOperation provides a mechanism for interacting with the user.
75  * It can be used for authenticating mountable operations, such as loop
76  * mounting files, hard drive partitions or server locations. It can
77  * also be used to ask the user questions or show a list of applications
78  * preventing unmount or eject operations from completing.
79  *
80  * Note that GMountOperation is used for more than just GMount
81  * objects – for example it is also used in g_drive_start() and
82  * g_drive_stop().
83  *
84  * Users should instantiate a subclass of this that implements all the
85  * various callbacks to show the required dialogs, such as
86  * GtkMountOperation. If no user interaction is desired (for example
87  * when automounting filesystems at login time), usually NULL can be
88  * passed, see each method taking a GMountOperation for details.
89  */
90 public class MountOperation : ObjectG
91 {
92 	
93 	/** the main Gtk struct */
94 	protected GMountOperation* gMountOperation;
95 	
96 	
97 	public GMountOperation* getMountOperationStruct()
98 	{
99 		return gMountOperation;
100 	}
101 	
102 	
103 	/** the main Gtk struct as a void* */
104 	protected override void* getStruct()
105 	{
106 		return cast(void*)gMountOperation;
107 	}
108 	
109 	/**
110 	 * Sets our main struct and passes it to the parent class
111 	 */
112 	public this (GMountOperation* gMountOperation)
113 	{
114 		super(cast(GObject*)gMountOperation);
115 		this.gMountOperation = gMountOperation;
116 	}
117 	
118 	protected override void setStruct(GObject* obj)
119 	{
120 		super.setStruct(obj);
121 		gMountOperation = cast(GMountOperation*)obj;
122 	}
123 	
124 	/**
125 	 */
126 	int[string] connectedSignals;
127 	
128 	void delegate(MountOperation)[] onAbortedListeners;
129 	/**
130 	 * Emitted by the backend when e.g. a device becomes unavailable
131 	 * while a mount operation is in progress.
132 	 * Implementations of GMountOperation should handle this signal
133 	 * by dismissing open password dialogs.
134 	 * Since 2.20
135 	 */
136 	void addOnAborted(void delegate(MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
137 	{
138 		if ( !("aborted" in connectedSignals) )
139 		{
140 			Signals.connectData(
141 			getStruct(),
142 			"aborted",
143 			cast(GCallback)&callBackAborted,
144 			cast(void*)this,
145 			null,
146 			connectFlags);
147 			connectedSignals["aborted"] = 1;
148 		}
149 		onAbortedListeners ~= dlg;
150 	}
151 	extern(C) static void callBackAborted(GMountOperation* arg0Struct, MountOperation _mountOperation)
152 	{
153 		foreach ( void delegate(MountOperation) dlg ; _mountOperation.onAbortedListeners )
154 		{
155 			dlg(_mountOperation);
156 		}
157 	}
158 	
159 	void delegate(string, string, string, GAskPasswordFlags, MountOperation)[] onAskPasswordListeners;
160 	/**
161 	 * Emitted when a mount operation asks the user for a password.
162 	 * If the message contains a line break, the first line should be
163 	 * presented as a heading. For example, it may be used as the
164 	 * primary text in a GtkMessageDialog.
165 	 */
166 	void addOnAskPassword(void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
167 	{
168 		if ( !("ask-password" in connectedSignals) )
169 		{
170 			Signals.connectData(
171 			getStruct(),
172 			"ask-password",
173 			cast(GCallback)&callBackAskPassword,
174 			cast(void*)this,
175 			null,
176 			connectFlags);
177 			connectedSignals["ask-password"] = 1;
178 		}
179 		onAskPasswordListeners ~= dlg;
180 	}
181 	extern(C) static void callBackAskPassword(GMountOperation* opStruct, gchar* message, gchar* defaultUser, gchar* defaultDomain, GAskPasswordFlags flags, MountOperation _mountOperation)
182 	{
183 		foreach ( void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg ; _mountOperation.onAskPasswordListeners )
184 		{
185 			dlg(Str.toString(message), Str.toString(defaultUser), Str.toString(defaultDomain), flags, _mountOperation);
186 		}
187 	}
188 	
189 	void delegate(string, GStrv, MountOperation)[] onAskQuestionListeners;
190 	/**
191 	 * Emitted when asking the user a question and gives a list of
192 	 * choices for the user to choose from.
193 	 * If the message contains a line break, the first line should be
194 	 * presented as a heading. For example, it may be used as the
195 	 * primary text in a GtkMessageDialog.
196 	 */
197 	void addOnAskQuestion(void delegate(string, GStrv, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
198 	{
199 		if ( !("ask-question" in connectedSignals) )
200 		{
201 			Signals.connectData(
202 			getStruct(),
203 			"ask-question",
204 			cast(GCallback)&callBackAskQuestion,
205 			cast(void*)this,
206 			null,
207 			connectFlags);
208 			connectedSignals["ask-question"] = 1;
209 		}
210 		onAskQuestionListeners ~= dlg;
211 	}
212 	extern(C) static void callBackAskQuestion(GMountOperation* opStruct, gchar* message, GStrv choices, MountOperation _mountOperation)
213 	{
214 		foreach ( void delegate(string, GStrv, MountOperation) dlg ; _mountOperation.onAskQuestionListeners )
215 		{
216 			dlg(Str.toString(message), choices, _mountOperation);
217 		}
218 	}
219 	
220 	void delegate(GMountOperationResult, MountOperation)[] onReplyListeners;
221 	/**
222 	 * Emitted when the user has replied to the mount operation.
223 	 */
224 	void addOnReply(void delegate(GMountOperationResult, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
225 	{
226 		if ( !("reply" in connectedSignals) )
227 		{
228 			Signals.connectData(
229 			getStruct(),
230 			"reply",
231 			cast(GCallback)&callBackReply,
232 			cast(void*)this,
233 			null,
234 			connectFlags);
235 			connectedSignals["reply"] = 1;
236 		}
237 		onReplyListeners ~= dlg;
238 	}
239 	extern(C) static void callBackReply(GMountOperation* opStruct, GMountOperationResult result, MountOperation _mountOperation)
240 	{
241 		foreach ( void delegate(GMountOperationResult, MountOperation) dlg ; _mountOperation.onReplyListeners )
242 		{
243 			dlg(result, _mountOperation);
244 		}
245 	}
246 	
247 	void delegate(string, ArrayG, GStrv, MountOperation)[] onShowProcessesListeners;
248 	/**
249 	 * Emitted when one or more processes are blocking an operation
250 	 * e.g. unmounting/ejecting a GMount or stopping a GDrive.
251 	 * Note that this signal may be emitted several times to update the
252 	 * list of blocking processes as processes close files. The
253 	 * application should only respond with g_mount_operation_reply() to
254 	 * the latest signal (setting "choice" to the choice
255 	 * the user made).
256 	 * If the message contains a line break, the first line should be
257 	 * presented as a heading. For example, it may be used as the
258 	 * primary text in a GtkMessageDialog.
259 	 * Since 2.22
260 	 */
261 	void addOnShowProcesses(void delegate(string, ArrayG, GStrv, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
262 	{
263 		if ( !("show-processes" in connectedSignals) )
264 		{
265 			Signals.connectData(
266 			getStruct(),
267 			"show-processes",
268 			cast(GCallback)&callBackShowProcesses,
269 			cast(void*)this,
270 			null,
271 			connectFlags);
272 			connectedSignals["show-processes"] = 1;
273 		}
274 		onShowProcessesListeners ~= dlg;
275 	}
276 	extern(C) static void callBackShowProcesses(GMountOperation* opStruct, gchar* message, GArray* processes, GStrv choices, MountOperation _mountOperation)
277 	{
278 		foreach ( void delegate(string, ArrayG, GStrv, MountOperation) dlg ; _mountOperation.onShowProcessesListeners )
279 		{
280 			dlg(Str.toString(message), ObjectG.getDObject!(ArrayG)(processes), choices, _mountOperation);
281 		}
282 	}
283 	
284 	void delegate(string, gint64, gint64, MountOperation)[] onShowUnmountProgressListeners;
285 	/**
286 	 * Emitted when an unmount operation has been busy for more than some time
287 	 * (typically 1.5 seconds).
288 	 * When unmounting or ejecting a volume, the kernel might need to flush
289 	 * pending data in its buffers to the volume stable storage, and this operation
290 	 * can take a considerable amount of time. This signal may be emitted several
291 	 * times as long as the unmount operation is outstanding, and then one
292 	 * last time when the operation is completed, with bytes_left set to zero.
293 	 * Implementations of GMountOperation should handle this signal by
294 	 * showing an UI notification, and then dismiss it, or show another notification
295 	 * of completion, when bytes_left reaches zero.
296 	 * If the message contains a line break, the first line should be
297 	 * presented as a heading. For example, it may be used as the
298 	 * primary text in a GtkMessageDialog.
299 	 * Since 2.34
300 	 */
301 	void addOnShowUnmountProgress(void delegate(string, gint64, gint64, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
302 	{
303 		if ( !("show-unmount-progress" in connectedSignals) )
304 		{
305 			Signals.connectData(
306 			getStruct(),
307 			"show-unmount-progress",
308 			cast(GCallback)&callBackShowUnmountProgress,
309 			cast(void*)this,
310 			null,
311 			connectFlags);
312 			connectedSignals["show-unmount-progress"] = 1;
313 		}
314 		onShowUnmountProgressListeners ~= dlg;
315 	}
316 	extern(C) static void callBackShowUnmountProgress(GMountOperation* opStruct, gchar* message, gint64 timeLeft, gint64 bytesLeft, MountOperation _mountOperation)
317 	{
318 		foreach ( void delegate(string, gint64, gint64, MountOperation) dlg ; _mountOperation.onShowUnmountProgressListeners )
319 		{
320 			dlg(Str.toString(message), timeLeft, bytesLeft, _mountOperation);
321 		}
322 	}
323 	
324 	
325 	/**
326 	 * Creates a new mount operation.
327 	 * Throws: ConstructionException GTK+ fails to create the object.
328 	 */
329 	public this ()
330 	{
331 		// GMountOperation * g_mount_operation_new (void);
332 		auto p = g_mount_operation_new();
333 		if(p is null)
334 		{
335 			throw new ConstructionException("null returned by g_mount_operation_new()");
336 		}
337 		this(cast(GMountOperation*) p);
338 	}
339 	
340 	/**
341 	 * Get the user name from the mount operation.
342 	 * Returns: a string containing the user name.
343 	 */
344 	public string getUsername()
345 	{
346 		// const char * g_mount_operation_get_username (GMountOperation *op);
347 		return Str.toString(g_mount_operation_get_username(gMountOperation));
348 	}
349 	
350 	/**
351 	 * Sets the user name within op to username.
352 	 * Params:
353 	 * username = input username.
354 	 */
355 	public void setUsername(string username)
356 	{
357 		// void g_mount_operation_set_username (GMountOperation *op,  const char *username);
358 		g_mount_operation_set_username(gMountOperation, Str.toStringz(username));
359 	}
360 	
361 	/**
362 	 * Gets a password from the mount operation.
363 	 * Returns: a string containing the password within op.
364 	 */
365 	public string getPassword()
366 	{
367 		// const char * g_mount_operation_get_password (GMountOperation *op);
368 		return Str.toString(g_mount_operation_get_password(gMountOperation));
369 	}
370 	
371 	/**
372 	 * Sets the mount operation's password to password.
373 	 * Params:
374 	 * password = password to set.
375 	 */
376 	public void setPassword(string password)
377 	{
378 		// void g_mount_operation_set_password (GMountOperation *op,  const char *password);
379 		g_mount_operation_set_password(gMountOperation, Str.toStringz(password));
380 	}
381 	
382 	/**
383 	 * Check to see whether the mount operation is being used
384 	 * for an anonymous user.
385 	 * Returns: TRUE if mount operation is anonymous.
386 	 */
387 	public int getAnonymous()
388 	{
389 		// gboolean g_mount_operation_get_anonymous (GMountOperation *op);
390 		return g_mount_operation_get_anonymous(gMountOperation);
391 	}
392 	
393 	/**
394 	 * Sets the mount operation to use an anonymous user if anonymous is TRUE.
395 	 * Params:
396 	 * anonymous = boolean value.
397 	 */
398 	public void setAnonymous(int anonymous)
399 	{
400 		// void g_mount_operation_set_anonymous (GMountOperation *op,  gboolean anonymous);
401 		g_mount_operation_set_anonymous(gMountOperation, anonymous);
402 	}
403 	
404 	/**
405 	 * Gets the domain of the mount operation.
406 	 * Returns: a string set to the domain.
407 	 */
408 	public string getDomain()
409 	{
410 		// const char * g_mount_operation_get_domain (GMountOperation *op);
411 		return Str.toString(g_mount_operation_get_domain(gMountOperation));
412 	}
413 	
414 	/**
415 	 * Sets the mount operation's domain.
416 	 * Params:
417 	 * domain = the domain to set.
418 	 */
419 	public void setDomain(string domain)
420 	{
421 		// void g_mount_operation_set_domain (GMountOperation *op,  const char *domain);
422 		g_mount_operation_set_domain(gMountOperation, Str.toStringz(domain));
423 	}
424 	
425 	/**
426 	 * Gets the state of saving passwords for the mount operation.
427 	 * Returns: a GPasswordSave flag.
428 	 */
429 	public GPasswordSave getPasswordSave()
430 	{
431 		// GPasswordSave g_mount_operation_get_password_save (GMountOperation *op);
432 		return g_mount_operation_get_password_save(gMountOperation);
433 	}
434 	
435 	/**
436 	 * Sets the state of saving passwords for the mount operation.
437 	 * Params:
438 	 * save = a set of GPasswordSave flags.
439 	 */
440 	public void setPasswordSave(GPasswordSave save)
441 	{
442 		// void g_mount_operation_set_password_save (GMountOperation *op,  GPasswordSave save);
443 		g_mount_operation_set_password_save(gMountOperation, save);
444 	}
445 	
446 	/**
447 	 * Gets a choice from the mount operation.
448 	 * Returns: an integer containing an index of the user's choice from the choice's list, or 0.
449 	 */
450 	public int getChoice()
451 	{
452 		// int g_mount_operation_get_choice (GMountOperation *op);
453 		return g_mount_operation_get_choice(gMountOperation);
454 	}
455 	
456 	/**
457 	 * Sets a default choice for the mount operation.
458 	 * Params:
459 	 * choice = an integer.
460 	 */
461 	public void setChoice(int choice)
462 	{
463 		// void g_mount_operation_set_choice (GMountOperation *op,  int choice);
464 		g_mount_operation_set_choice(gMountOperation, choice);
465 	}
466 	
467 	/**
468 	 * Emits the "reply" signal.
469 	 * Params:
470 	 * result = a GMountOperationResult
471 	 */
472 	public void reply(GMountOperationResult result)
473 	{
474 		// void g_mount_operation_reply (GMountOperation *op,  GMountOperationResult result);
475 		g_mount_operation_reply(gMountOperation, result);
476 	}
477 }