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  = GVolume.html
27  * outPack = gio
28  * outFile = VolumeT
29  * strct   = GVolume
30  * realStrct=
31  * ctorStrct=
32  * clss    = VolumeT
33  * interf  = VolumeIF
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * 	- TStruct
38  * extend  = 
39  * implements:
40  * prefixes:
41  * 	- g_volume_
42  * omit structs:
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * 	- glib.Str
48  * 	- glib.ErrorG
49  * 	- glib.GException
50  * 	- gobject.Signals
51  * 	- gio.AsyncResultIF
52  * 	- gio.Cancellable
53  * 	- gio.Drive
54  * 	- gio.DriveIF
55  * 	- gio.File
56  * 	- gio.Icon
57  * 	- gio.IconIF
58  * 	- gio.Mount
59  * 	- gio.MountIF
60  * 	- gio.MountOperation
61  * structWrap:
62  * 	- GAsyncResult* -> AsyncResultIF
63  * 	- GCancellable* -> Cancellable
64  * 	- GDrive* -> DriveIF
65  * 	- GFile* -> File
66  * 	- GIcon* -> IconIF
67  * 	- GMount* -> MountIF
68  * 	- GMountOperation* -> MountOperation
69  * module aliases:
70  * local aliases:
71  * overrides:
72  */
73 
74 module gio.VolumeT;
75 
76 public  import gtkc.giotypes;
77 
78 public import gtkc.gio;
79 public import glib.ConstructionException;
80 public import gobject.ObjectG;
81 
82 public import gobject.Signals;
83 public  import gtkc.gdktypes;
84 
85 public import glib.Str;
86 public import glib.ErrorG;
87 public import glib.GException;
88 public import gobject.Signals;
89 public import gio.AsyncResultIF;
90 public import gio.Cancellable;
91 public import gio.Drive;
92 public import gio.DriveIF;
93 public import gio.File;
94 public import gio.Icon;
95 public import gio.IconIF;
96 public import gio.Mount;
97 public import gio.MountIF;
98 public import gio.MountOperation;
99 
100 
101 
102 
103 /**
104  * Description
105  * The GVolume interface represents user-visible objects that can be
106  * mounted. Note, when porting from GnomeVFS, GVolume is the moral
107  * equivalent of GnomeVFSDrive.
108  * Mounting a GVolume instance is an asynchronous operation. For more
109  * information about asynchronous operations, see GAsyncReady and
110  * GSimpleAsyncReady. To mount a GVolume, first call
111  * g_volume_mount() with (at least) the GVolume instance, optionally
112  * a GMountOperation object and a GAsyncReadyCallback.
113  * Typically, one will only want to pass NULL for the
114  * GMountOperation if automounting all volumes when a desktop session
115  * starts since it's not desirable to put up a lot of dialogs asking
116  * for credentials.
117  * The callback will be fired when the operation has resolved (either
118  * with success or failure), and a GAsyncReady structure will be
119  * passed to the callback. That callback should then call
120  * g_volume_mount_finish() with the GVolume instance and the
121  * GAsyncReady data to see if the operation was completed
122  * successfully. If an error is present when g_volume_mount_finish()
123  * is called, then it will be filled with any error information.
124  * It is sometimes necessary to directly access the underlying
125  * operating system object behind a volume (e.g. for passing a volume
126  * to an application via the commandline). For this purpose, GIO
127  * allows to obtain an 'identifier' for the volume. There can be
128  * different kinds of identifiers, such as Hal UDIs, filesystem labels,
129  * traditional Unix devices (e.g. /dev/sda2),
130  * uuids. GIO uses predefind strings as names for the different kinds
131  * of identifiers: G_VOLUME_IDENTIFIER_KIND_HAL_UDI,
132  * G_VOLUME_IDENTIFIER_KIND_LABEL, etc. Use g_volume_get_identifier()
133  * to obtain an identifier for a volume.
134  * Note that G_VOLUME_IDENTIFIER_KIND_HAL_UDI will only be available
135  * when the gvfs hal volume monitor is in use. Other volume monitors
136  * will generally be able to provide the G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE
137  * identifier, which can be used to obtain a hal device by means of
138  * libhal_manger_find_device_string_match().
139  */
140 public template VolumeT(TStruct)
141 {
142 	
143 	/** the main Gtk struct */
144 	protected GVolume* gVolume;
145 	
146 	
147 	public GVolume* getVolumeTStruct()
148 	{
149 		return cast(GVolume*)getStruct();
150 	}
151 	
152 	
153 	/**
154 	 */
155 	int[string] connectedSignals;
156 	
157 	void delegate(VolumeIF)[] _onChangedListeners;
158 	void delegate(VolumeIF)[] onChangedListeners()
159 	{
160 		return  _onChangedListeners;
161 	}
162 	/**
163 	 * Emitted when the volume has been changed.
164 	 */
165 	void addOnChanged(void delegate(VolumeIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
166 	{
167 		if ( !("changed" in connectedSignals) )
168 		{
169 			Signals.connectData(
170 			getStruct(),
171 			"changed",
172 			cast(GCallback)&callBackChanged,
173 			cast(void*)cast(VolumeIF)this,
174 			null,
175 			connectFlags);
176 			connectedSignals["changed"] = 1;
177 		}
178 		_onChangedListeners ~= dlg;
179 	}
180 	extern(C) static void callBackChanged(GVolume* arg0Struct, VolumeIF _volumeIF)
181 	{
182 		foreach ( void delegate(VolumeIF) dlg ; _volumeIF.onChangedListeners )
183 		{
184 			dlg(_volumeIF);
185 		}
186 	}
187 	
188 	void delegate(VolumeIF)[] _onRemovedListeners;
189 	void delegate(VolumeIF)[] onRemovedListeners()
190 	{
191 		return  _onRemovedListeners;
192 	}
193 	/**
194 	 * This signal is emitted when the GVolume have been removed. If
195 	 * the recipient is holding references to the object they should
196 	 * release them so the object can be finalized.
197 	 */
198 	void addOnRemoved(void delegate(VolumeIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0)
199 	{
200 		if ( !("removed" in connectedSignals) )
201 		{
202 			Signals.connectData(
203 			getStruct(),
204 			"removed",
205 			cast(GCallback)&callBackRemoved,
206 			cast(void*)cast(VolumeIF)this,
207 			null,
208 			connectFlags);
209 			connectedSignals["removed"] = 1;
210 		}
211 		_onRemovedListeners ~= dlg;
212 	}
213 	extern(C) static void callBackRemoved(GVolume* arg0Struct, VolumeIF _volumeIF)
214 	{
215 		foreach ( void delegate(VolumeIF) dlg ; _volumeIF.onRemovedListeners )
216 		{
217 			dlg(_volumeIF);
218 		}
219 	}
220 	
221 	
222 	/**
223 	 * Gets the name of volume.
224 	 * Returns: the name for the given volume. The returned string should be freed with g_free() when no longer needed.
225 	 */
226 	public string getName()
227 	{
228 		// char * g_volume_get_name (GVolume *volume);
229 		return Str.toString(g_volume_get_name(getVolumeTStruct()));
230 	}
231 	
232 	/**
233 	 * Gets the UUID for the volume. The reference is typically based on
234 	 * the file system UUID for the volume in question and should be
235 	 * considered an opaque string. Returns NULL if there is no UUID
236 	 * available.
237 	 * Returns: the UUID for volume or NULL if no UUID can be computed. The returned string should be freed with g_free() when no longer needed.
238 	 */
239 	public string getUuid()
240 	{
241 		// char * g_volume_get_uuid (GVolume *volume);
242 		return Str.toString(g_volume_get_uuid(getVolumeTStruct()));
243 	}
244 	
245 	/**
246 	 * Gets the icon for volume.
247 	 * Returns: a GIcon. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full]
248 	 */
249 	public IconIF getIcon()
250 	{
251 		// GIcon * g_volume_get_icon (GVolume *volume);
252 		auto p = g_volume_get_icon(getVolumeTStruct());
253 		
254 		if(p is null)
255 		{
256 			return null;
257 		}
258 		
259 		return ObjectG.getDObject!(Icon, IconIF)(cast(GIcon*) p);
260 	}
261 	
262 	/**
263 	 * Gets the drive for the volume.
264 	 * Returns: a GDrive or NULL if volume is not associated with a drive. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full]
265 	 */
266 	public DriveIF getDrive()
267 	{
268 		// GDrive * g_volume_get_drive (GVolume *volume);
269 		auto p = g_volume_get_drive(getVolumeTStruct());
270 		
271 		if(p is null)
272 		{
273 			return null;
274 		}
275 		
276 		return ObjectG.getDObject!(Drive, DriveIF)(cast(GDrive*) p);
277 	}
278 	
279 	/**
280 	 * Gets the mount for the volume.
281 	 * Returns: a GMount or NULL if volume isn't mounted. The returned object should be unreffed with g_object_unref() when no longer needed. [transfer full]
282 	 */
283 	public MountIF getMount()
284 	{
285 		// GMount * g_volume_get_mount (GVolume *volume);
286 		auto p = g_volume_get_mount(getVolumeTStruct());
287 		
288 		if(p is null)
289 		{
290 			return null;
291 		}
292 		
293 		return ObjectG.getDObject!(Mount, MountIF)(cast(GMount*) p);
294 	}
295 	
296 	/**
297 	 * Checks if a volume can be mounted.
298 	 * Returns: TRUE if the volume can be mounted. FALSE otherwise.
299 	 */
300 	public int canMount()
301 	{
302 		// gboolean g_volume_can_mount (GVolume *volume);
303 		return g_volume_can_mount(getVolumeTStruct());
304 	}
305 	
306 	/**
307 	 * Returns whether the volume should be automatically mounted.
308 	 * Returns: TRUE if the volume should be automatically mounted.
309 	 */
310 	public int shouldAutomount()
311 	{
312 		// gboolean g_volume_should_automount (GVolume *volume);
313 		return g_volume_should_automount(getVolumeTStruct());
314 	}
315 	
316 	/**
317 	 * Gets the activation root for a GVolume if it is known ahead of
318 	 * mount time. Returns NULL otherwise. If not NULL and if volume
319 	 * is mounted, then the result of g_mount_get_root() on the
320 	 * GMount object obtained from g_volume_get_mount() will always
321 	 * either be equal or a prefix of what this function returns. In
322 	 * other words, in code
323 	 *  GMount *mount;
324 	 *  GFile *mount_root
325 	 *  GFile *volume_activation_root;
326 	 *  mount = g_volume_get_mount (volume); /+* mounted, so never NULL +/
327 	 *  mount_root = g_mount_get_root (mount);
328 	 *  volume_activation_root = g_volume_get_activation_root(volume); /+* assume not NULL +/
329 	 * then the expression
330 	 *  (g_file_has_prefix (volume_activation_root, mount_root) ||
331 	 *  g_file_equal (volume_activation_root, mount_root))
332 	 * will always be TRUE.
333 	 * Activation roots are typically used in GVolumeMonitor
334 	 * implementations to find the underlying mount to shadow, see
335 	 * g_mount_is_shadowed() for more details.
336 	 * Since 2.18
337 	 * Returns: the activation root of volume or NULL. Use g_object_unref() to free. [transfer full]
338 	 */
339 	public File getActivationRoot()
340 	{
341 		// GFile * g_volume_get_activation_root (GVolume *volume);
342 		auto p = g_volume_get_activation_root(getVolumeTStruct());
343 		
344 		if(p is null)
345 		{
346 			return null;
347 		}
348 		
349 		return ObjectG.getDObject!(File)(cast(GFile*) p);
350 	}
351 	
352 	/**
353 	 * Mounts a volume. This is an asynchronous operation, and is
354 	 * finished by calling g_volume_mount_finish() with the volume
355 	 * and GAsyncResult returned in the callback.
356 	 * Virtual: mount_fn
357 	 * Params:
358 	 * flags = flags affecting the operation
359 	 * mountOperation = a GMountOperation or NULL to avoid user interaction. [allow-none]
360 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
361 	 * callback = a GAsyncReadyCallback, or NULL. [allow-none]
362 	 * userData = user data that gets passed to callback
363 	 */
364 	public void mount(GMountMountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
365 	{
366 		// void g_volume_mount (GVolume *volume,  GMountMountFlags flags,  GMountOperation *mount_operation,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
367 		g_volume_mount(getVolumeTStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
368 	}
369 	
370 	/**
371 	 * Finishes mounting a volume. If any errors occured during the operation,
372 	 * error will be set to contain the errors and FALSE will be returned.
373 	 * If the mount operation succeeded, g_volume_get_mount() on volume
374 	 * is guaranteed to return the mount right after calling this
375 	 * function; there's no need to listen for the 'mount-added' signal on
376 	 * GVolumeMonitor.
377 	 * Params:
378 	 * result = a GAsyncResult
379 	 * Returns: TRUE, FALSE if operation failed.
380 	 * Throws: GException on failure.
381 	 */
382 	public int mountFinish(AsyncResultIF result)
383 	{
384 		// gboolean g_volume_mount_finish (GVolume *volume,  GAsyncResult *result,  GError **error);
385 		GError* err = null;
386 		
387 		auto p = g_volume_mount_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
388 		
389 		if (err !is null)
390 		{
391 			throw new GException( new ErrorG(err) );
392 		}
393 		
394 		return p;
395 	}
396 	
397 	/**
398 	 * Checks if a volume can be ejected.
399 	 * Returns: TRUE if the volume can be ejected. FALSE otherwise.
400 	 */
401 	public int canEject()
402 	{
403 		// gboolean g_volume_can_eject (GVolume *volume);
404 		return g_volume_can_eject(getVolumeTStruct());
405 	}
406 	
407 	/**
408 	 * Warning
409 	 * g_volume_eject has been deprecated since version 2.22 and should not be used in newly-written code. Use g_volume_eject_with_operation() instead.
410 	 * Ejects a volume. This is an asynchronous operation, and is
411 	 * finished by calling g_volume_eject_finish() with the volume
412 	 * and GAsyncResult returned in the callback.
413 	 * Params:
414 	 * flags = flags affecting the unmount if required for eject
415 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
416 	 * callback = a GAsyncReadyCallback, or NULL. [allow-none]
417 	 * userData = user data that gets passed to callback
418 	 */
419 	public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
420 	{
421 		// void g_volume_eject (GVolume *volume,  GMountUnmountFlags flags,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
422 		g_volume_eject(getVolumeTStruct(), flags, (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
423 	}
424 	
425 	/**
426 	 * Warning
427 	 * g_volume_eject_finish has been deprecated since version 2.22 and should not be used in newly-written code. Use g_volume_eject_with_operation_finish() instead.
428 	 * Finishes ejecting a volume. If any errors occured during the operation,
429 	 * error will be set to contain the errors and FALSE will be returned.
430 	 * Params:
431 	 * result = a GAsyncResult.
432 	 * Returns: TRUE, FALSE if operation failed.
433 	 * Throws: GException on failure.
434 	 */
435 	public int ejectFinish(AsyncResultIF result)
436 	{
437 		// gboolean g_volume_eject_finish (GVolume *volume,  GAsyncResult *result,  GError **error);
438 		GError* err = null;
439 		
440 		auto p = g_volume_eject_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
441 		
442 		if (err !is null)
443 		{
444 			throw new GException( new ErrorG(err) );
445 		}
446 		
447 		return p;
448 	}
449 	
450 	/**
451 	 * Ejects a volume. This is an asynchronous operation, and is
452 	 * finished by calling g_volume_eject_with_operation_finish() with the volume
453 	 * and GAsyncResult data returned in the callback.
454 	 * Since 2.22
455 	 * Params:
456 	 * flags = flags affecting the unmount if required for eject
457 	 * mountOperation = a GMountOperation or NULL to
458 	 * avoid user interaction. [allow-none]
459 	 * cancellable = optional GCancellable object, NULL to ignore. [allow-none]
460 	 * callback = a GAsyncReadyCallback, or NULL.
461 	 * userData = user data passed to callback.
462 	 */
463 	public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData)
464 	{
465 		// void g_volume_eject_with_operation (GVolume *volume,  GMountUnmountFlags flags,  GMountOperation *mount_operation,  GCancellable *cancellable,  GAsyncReadyCallback callback,  gpointer user_data);
466 		g_volume_eject_with_operation(getVolumeTStruct(), flags, (mountOperation is null) ? null : mountOperation.getMountOperationStruct(), (cancellable is null) ? null : cancellable.getCancellableStruct(), callback, userData);
467 	}
468 	
469 	/**
470 	 * Finishes ejecting a volume. If any errors occurred during the operation,
471 	 * error will be set to contain the errors and FALSE will be returned.
472 	 * Since 2.22
473 	 * Params:
474 	 * result = a GAsyncResult.
475 	 * Returns: TRUE if the volume was successfully ejected. FALSE otherwise.
476 	 * Throws: GException on failure.
477 	 */
478 	public int ejectWithOperationFinish(AsyncResultIF result)
479 	{
480 		// gboolean g_volume_eject_with_operation_finish  (GVolume *volume,  GAsyncResult *result,  GError **error);
481 		GError* err = null;
482 		
483 		auto p = g_volume_eject_with_operation_finish(getVolumeTStruct(), (result is null) ? null : result.getAsyncResultTStruct(), &err);
484 		
485 		if (err !is null)
486 		{
487 			throw new GException( new ErrorG(err) );
488 		}
489 		
490 		return p;
491 	}
492 	
493 	/**
494 	 * Gets the kinds of identifiers
495 	 * that volume has. Use g_volume_get_identifer() to obtain
496 	 * the identifiers themselves.
497 	 * Returns: a NULL-terminated array of strings containing kinds of identifiers. Use g_strfreev() to free. [array zero-terminated=1][transfer full]
498 	 */
499 	public string[] enumerateIdentifiers()
500 	{
501 		// char ** g_volume_enumerate_identifiers (GVolume *volume);
502 		return Str.toStringArray(g_volume_enumerate_identifiers(getVolumeTStruct()));
503 	}
504 	
505 	/**
506 	 * Gets the identifier of the given kind for volume.
507 	 * See the introduction
508 	 * for more information about volume identifiers.
509 	 * Params:
510 	 * kind = the kind of identifier to return
511 	 * Returns: a newly allocated string containing the requested identfier, or NULL if the GVolume doesn't have this kind of identifier Signal Details The "changed" signal void user_function (GVolume *arg0, gpointer user_data) : Run Last Emitted when the volume has been changed.
512 	 */
513 	public string getIdentifier(string kind)
514 	{
515 		// char * g_volume_get_identifier (GVolume *volume,  const char *kind);
516 		return Str.toString(g_volume_get_identifier(getVolumeTStruct(), Str.toStringz(kind)));
517 	}
518 }