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  * Description
75  * GMountOperation provides a mechanism for interacting with the user.
76  * It can be used for authenticating mountable operations, such as loop
77  * mounting files, hard drive partitions or server locations. It can
78  * also be used to ask the user questions or show a list of applications
79  * preventing unmount or eject operations from completing.
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  * Users should instantiate a subclass of this that implements all the
84  * various callbacks to show the required dialogs, such as
85  * GtkMountOperation. If no user interaction is desired (for example
86  * when automounting filesystems at login time), usually NULL can be
87  * passed, see each method taking a GMountOperation for details.
88  */
89 public class MountOperation : ObjectG
90 {
91 	
92 	/** the main Gtk struct */
93 	protected GMountOperation* gMountOperation;
94 	
95 	
96 	public GMountOperation* getMountOperationStruct()
97 	{
98 		return gMountOperation;
99 	}
100 	
101 	
102 	/** the main Gtk struct as a void* */
103 	protected override void* getStruct()
104 	{
105 		return cast(void*)gMountOperation;
106 	}
107 	
108 	/**
109 	 * Sets our main struct and passes it to the parent class
110 	 */
111 	public this (GMountOperation* gMountOperation)
112 	{
113 		super(cast(GObject*)gMountOperation);
114 		this.gMountOperation = gMountOperation;
115 	}
116 	
117 	protected override void setStruct(GObject* obj)
118 	{
119 		super.setStruct(obj);
120 		gMountOperation = cast(GMountOperation*)obj;
121 	}
122 	
123 	/**
124 	 */
125 	int[string] connectedSignals;
126 	
127 	void delegate(MountOperation)[] onAbortedListeners;
128 	/**
129 	 * Emitted by the backend when e.g. a device becomes unavailable
130 	 * while a mount operation is in progress.
131 	 * Implementations of GMountOperation should handle this signal
132 	 * by dismissing open password dialogs.
133 	 * Since 2.20
134 	 */
135 	void addOnAborted(void delegate(MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
136 	{
137 		if ( !("aborted" in connectedSignals) )
138 		{
139 			Signals.connectData(
140 			getStruct(),
141 			"aborted",
142 			cast(GCallback)&callBackAborted,
143 			cast(void*)this,
144 			null,
145 			connectFlags);
146 			connectedSignals["aborted"] = 1;
147 		}
148 		onAbortedListeners ~= dlg;
149 	}
150 	extern(C) static void callBackAborted(GMountOperation* arg0Struct, MountOperation _mountOperation)
151 	{
152 		foreach ( void delegate(MountOperation) dlg ; _mountOperation.onAbortedListeners )
153 		{
154 			dlg(_mountOperation);
155 		}
156 	}
157 	
158 	void delegate(string, string, string, GAskPasswordFlags, MountOperation)[] onAskPasswordListeners;
159 	/**
160 	 * Emitted when a mount operation asks the user for a password.
161 	 * If the message contains a line break, the first line should be
162 	 * presented as a heading. For example, it may be used as the
163 	 * primary text in a GtkMessageDialog.
164 	 */
165 	void addOnAskPassword(void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
166 	{
167 		if ( !("ask-password" in connectedSignals) )
168 		{
169 			Signals.connectData(
170 			getStruct(),
171 			"ask-password",
172 			cast(GCallback)&callBackAskPassword,
173 			cast(void*)this,
174 			null,
175 			connectFlags);
176 			connectedSignals["ask-password"] = 1;
177 		}
178 		onAskPasswordListeners ~= dlg;
179 	}
180 	extern(C) static void callBackAskPassword(GMountOperation* opStruct, gchar* message, gchar* defaultUser, gchar* defaultDomain, GAskPasswordFlags flags, MountOperation _mountOperation)
181 	{
182 		foreach ( void delegate(string, string, string, GAskPasswordFlags, MountOperation) dlg ; _mountOperation.onAskPasswordListeners )
183 		{
184 			dlg(Str.toString(message), Str.toString(defaultUser), Str.toString(defaultDomain), flags, _mountOperation);
185 		}
186 	}
187 	
188 	void delegate(string, GStrv, MountOperation)[] onAskQuestionListeners;
189 	/**
190 	 * Emitted when asking the user a question and gives a list of
191 	 * choices for the user to choose from.
192 	 * If the message contains a line break, the first line should be
193 	 * presented as a heading. For example, it may be used as the
194 	 * primary text in a GtkMessageDialog.
195 	 */
196 	void addOnAskQuestion(void delegate(string, GStrv, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
197 	{
198 		if ( !("ask-question" in connectedSignals) )
199 		{
200 			Signals.connectData(
201 			getStruct(),
202 			"ask-question",
203 			cast(GCallback)&callBackAskQuestion,
204 			cast(void*)this,
205 			null,
206 			connectFlags);
207 			connectedSignals["ask-question"] = 1;
208 		}
209 		onAskQuestionListeners ~= dlg;
210 	}
211 	extern(C) static void callBackAskQuestion(GMountOperation* opStruct, gchar* message, GStrv choices, MountOperation _mountOperation)
212 	{
213 		foreach ( void delegate(string, GStrv, MountOperation) dlg ; _mountOperation.onAskQuestionListeners )
214 		{
215 			dlg(Str.toString(message), choices, _mountOperation);
216 		}
217 	}
218 	
219 	void delegate(GMountOperationResult, MountOperation)[] onReplyListeners;
220 	/**
221 	 * Emitted when the user has replied to the mount operation.
222 	 */
223 	void addOnReply(void delegate(GMountOperationResult, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
224 	{
225 		if ( !("reply" in connectedSignals) )
226 		{
227 			Signals.connectData(
228 			getStruct(),
229 			"reply",
230 			cast(GCallback)&callBackReply,
231 			cast(void*)this,
232 			null,
233 			connectFlags);
234 			connectedSignals["reply"] = 1;
235 		}
236 		onReplyListeners ~= dlg;
237 	}
238 	extern(C) static void callBackReply(GMountOperation* opStruct, GMountOperationResult result, MountOperation _mountOperation)
239 	{
240 		foreach ( void delegate(GMountOperationResult, MountOperation) dlg ; _mountOperation.onReplyListeners )
241 		{
242 			dlg(result, _mountOperation);
243 		}
244 	}
245 	
246 	void delegate(string, ArrayG, GStrv, MountOperation)[] onShowProcessesListeners;
247 	/**
248 	 * Emitted when one or more processes are blocking an operation
249 	 * e.g. unmounting/ejecting a GMount or stopping a GDrive.
250 	 * Note that this signal may be emitted several times to update the
251 	 * list of blocking processes as processes close files. The
252 	 * application should only respond with g_mount_operation_reply() to
253 	 * the latest signal (setting "choice" to the choice
254 	 * the user made).
255 	 * If the message contains a line break, the first line should be
256 	 * presented as a heading. For example, it may be used as the
257 	 * primary text in a GtkMessageDialog.
258 	 * Since 2.22
259 	 */
260 	void addOnShowProcesses(void delegate(string, ArrayG, GStrv, MountOperation) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
261 	{
262 		if ( !("show-processes" in connectedSignals) )
263 		{
264 			Signals.connectData(
265 			getStruct(),
266 			"show-processes",
267 			cast(GCallback)&callBackShowProcesses,
268 			cast(void*)this,
269 			null,
270 			connectFlags);
271 			connectedSignals["show-processes"] = 1;
272 		}
273 		onShowProcessesListeners ~= dlg;
274 	}
275 	extern(C) static void callBackShowProcesses(GMountOperation* opStruct, gchar* message, GArray* processes, GStrv choices, MountOperation _mountOperation)
276 	{
277 		foreach ( void delegate(string, ArrayG, GStrv, MountOperation) dlg ; _mountOperation.onShowProcessesListeners )
278 		{
279 			dlg(Str.toString(message), ObjectG.getDObject!(ArrayG)(processes), choices, _mountOperation);
280 		}
281 	}
282 	
283 	
284 	/**
285 	 * Creates a new mount operation.
286 	 * Throws: ConstructionException GTK+ fails to create the object.
287 	 */
288 	public this ()
289 	{
290 		// GMountOperation * g_mount_operation_new (void);
291 		auto p = g_mount_operation_new();
292 		if(p is null)
293 		{
294 			throw new ConstructionException("null returned by g_mount_operation_new()");
295 		}
296 		this(cast(GMountOperation*) p);
297 	}
298 	
299 	/**
300 	 * Get the user name from the mount operation.
301 	 * Returns: a string containing the user name.
302 	 */
303 	public string getUsername()
304 	{
305 		// const char * g_mount_operation_get_username (GMountOperation *op);
306 		return Str.toString(g_mount_operation_get_username(gMountOperation));
307 	}
308 	
309 	/**
310 	 * Sets the user name within op to username.
311 	 * Params:
312 	 * username = input username.
313 	 */
314 	public void setUsername(string username)
315 	{
316 		// void g_mount_operation_set_username (GMountOperation *op,  const char *username);
317 		g_mount_operation_set_username(gMountOperation, Str.toStringz(username));
318 	}
319 	
320 	/**
321 	 * Gets a password from the mount operation.
322 	 * Returns: a string containing the password within op.
323 	 */
324 	public string getPassword()
325 	{
326 		// const char * g_mount_operation_get_password (GMountOperation *op);
327 		return Str.toString(g_mount_operation_get_password(gMountOperation));
328 	}
329 	
330 	/**
331 	 * Sets the mount operation's password to password.
332 	 * Params:
333 	 * password = password to set.
334 	 */
335 	public void setPassword(string password)
336 	{
337 		// void g_mount_operation_set_password (GMountOperation *op,  const char *password);
338 		g_mount_operation_set_password(gMountOperation, Str.toStringz(password));
339 	}
340 	
341 	/**
342 	 * Check to see whether the mount operation is being used
343 	 * for an anonymous user.
344 	 * Returns: TRUE if mount operation is anonymous.
345 	 */
346 	public int getAnonymous()
347 	{
348 		// gboolean g_mount_operation_get_anonymous (GMountOperation *op);
349 		return g_mount_operation_get_anonymous(gMountOperation);
350 	}
351 	
352 	/**
353 	 * Sets the mount operation to use an anonymous user if anonymous is TRUE.
354 	 * Params:
355 	 * anonymous = boolean value.
356 	 */
357 	public void setAnonymous(int anonymous)
358 	{
359 		// void g_mount_operation_set_anonymous (GMountOperation *op,  gboolean anonymous);
360 		g_mount_operation_set_anonymous(gMountOperation, anonymous);
361 	}
362 	
363 	/**
364 	 * Gets the domain of the mount operation.
365 	 * Returns: a string set to the domain.
366 	 */
367 	public string getDomain()
368 	{
369 		// const char * g_mount_operation_get_domain (GMountOperation *op);
370 		return Str.toString(g_mount_operation_get_domain(gMountOperation));
371 	}
372 	
373 	/**
374 	 * Sets the mount operation's domain.
375 	 * Params:
376 	 * domain = the domain to set.
377 	 */
378 	public void setDomain(string domain)
379 	{
380 		// void g_mount_operation_set_domain (GMountOperation *op,  const char *domain);
381 		g_mount_operation_set_domain(gMountOperation, Str.toStringz(domain));
382 	}
383 	
384 	/**
385 	 * Gets the state of saving passwords for the mount operation.
386 	 * Returns: a GPasswordSave flag.
387 	 */
388 	public GPasswordSave getPasswordSave()
389 	{
390 		// GPasswordSave g_mount_operation_get_password_save (GMountOperation *op);
391 		return g_mount_operation_get_password_save(gMountOperation);
392 	}
393 	
394 	/**
395 	 * Sets the state of saving passwords for the mount operation.
396 	 * Params:
397 	 * save = a set of GPasswordSave flags.
398 	 */
399 	public void setPasswordSave(GPasswordSave save)
400 	{
401 		// void g_mount_operation_set_password_save (GMountOperation *op,  GPasswordSave save);
402 		g_mount_operation_set_password_save(gMountOperation, save);
403 	}
404 	
405 	/**
406 	 * Gets a choice from the mount operation.
407 	 * Returns: an integer containing an index of the user's choice from the choice's list, or 0.
408 	 */
409 	public int getChoice()
410 	{
411 		// int g_mount_operation_get_choice (GMountOperation *op);
412 		return g_mount_operation_get_choice(gMountOperation);
413 	}
414 	
415 	/**
416 	 * Sets a default choice for the mount operation.
417 	 * Params:
418 	 * choice = an integer.
419 	 */
420 	public void setChoice(int choice)
421 	{
422 		// void g_mount_operation_set_choice (GMountOperation *op,  int choice);
423 		g_mount_operation_set_choice(gMountOperation, choice);
424 	}
425 	
426 	/**
427 	 * Emits the "reply" signal.
428 	 * Params:
429 	 * result = a GMountOperationResult
430 	 */
431 	public void reply(GMountOperationResult result)
432 	{
433 		// void g_mount_operation_reply (GMountOperation *op,  GMountOperationResult result);
434 		g_mount_operation_reply(gMountOperation, result);
435 	}
436 }