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.DriveIF;
26 
27 private import gio.AsyncResultIF;
28 private import gio.Cancellable;
29 private import gio.IconIF;
30 private import gio.MountOperation;
31 private import gio.c.functions;
32 public  import gio.c.types;
33 private import glib.ErrorG;
34 private import glib.GException;
35 private import glib.ListG;
36 private import glib.Str;
37 private import gobject.ObjectG;
38 private import gobject.Signals;
39 public  import gtkc.giotypes;
40 private import std.algorithm;
41 
42 
43 /**
44  * #GDrive - this represent a piece of hardware connected to the machine.
45  * It's generally only created for removable hardware or hardware with
46  * removable media.
47  * 
48  * #GDrive is a container class for #GVolume objects that stem from
49  * the same piece of media. As such, #GDrive abstracts a drive with
50  * (or without) removable media and provides operations for querying
51  * whether media is available, determining whether media change is
52  * automatically detected and ejecting the media.
53  * 
54  * If the #GDrive reports that media isn't automatically detected, one
55  * can poll for media; typically one should not do this periodically
56  * as a poll for media operation is potententially expensive and may
57  * spin up the drive creating noise.
58  * 
59  * #GDrive supports starting and stopping drives with authentication
60  * support for the former. This can be used to support a diverse set
61  * of use cases including connecting/disconnecting iSCSI devices,
62  * powering down external disk enclosures and starting/stopping
63  * multi-disk devices such as RAID devices. Note that the actual
64  * semantics and side-effects of starting/stopping a #GDrive may vary
65  * according to implementation. To choose the correct verbs in e.g. a
66  * file manager, use g_drive_get_start_stop_type().
67  * 
68  * For porting from GnomeVFS note that there is no equivalent of
69  * #GDrive in that API.
70  */
71 public interface DriveIF{
72 	/** Get the main Gtk struct */
73 	public GDrive* getDriveStruct(bool transferOwnership = false);
74 
75 	/** the main Gtk struct as a void* */
76 	protected void* getStruct();
77 
78 
79 	/** */
80 	public static GType getType()
81 	{
82 		return g_drive_get_type();
83 	}
84 
85 	/**
86 	 * Checks if a drive can be ejected.
87 	 *
88 	 * Returns: %TRUE if the @drive can be ejected, %FALSE otherwise.
89 	 */
90 	public bool canEject();
91 
92 	/**
93 	 * Checks if a drive can be polled for media changes.
94 	 *
95 	 * Returns: %TRUE if the @drive can be polled for media changes,
96 	 *     %FALSE otherwise.
97 	 */
98 	public bool canPollForMedia();
99 
100 	/**
101 	 * Checks if a drive can be started.
102 	 *
103 	 * Returns: %TRUE if the @drive can be started, %FALSE otherwise.
104 	 *
105 	 * Since: 2.22
106 	 */
107 	public bool canStart();
108 
109 	/**
110 	 * Checks if a drive can be started degraded.
111 	 *
112 	 * Returns: %TRUE if the @drive can be started degraded, %FALSE otherwise.
113 	 *
114 	 * Since: 2.22
115 	 */
116 	public bool canStartDegraded();
117 
118 	/**
119 	 * Checks if a drive can be stopped.
120 	 *
121 	 * Returns: %TRUE if the @drive can be stopped, %FALSE otherwise.
122 	 *
123 	 * Since: 2.22
124 	 */
125 	public bool canStop();
126 
127 	/**
128 	 * Asynchronously ejects a drive.
129 	 *
130 	 * When the operation is finished, @callback will be called.
131 	 * You can then call g_drive_eject_finish() to obtain the
132 	 * result of the operation.
133 	 *
134 	 * Deprecated: Use g_drive_eject_with_operation() instead.
135 	 *
136 	 * Params:
137 	 *     flags = flags affecting the unmount if required for eject
138 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
139 	 *     callback = a #GAsyncReadyCallback, or %NULL.
140 	 *     userData = user data to pass to @callback
141 	 */
142 	public void eject(GMountUnmountFlags flags, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
143 
144 	/**
145 	 * Finishes ejecting a drive.
146 	 *
147 	 * Deprecated: Use g_drive_eject_with_operation_finish() instead.
148 	 *
149 	 * Params:
150 	 *     result = a #GAsyncResult.
151 	 *
152 	 * Returns: %TRUE if the drive has been ejected successfully,
153 	 *     %FALSE otherwise.
154 	 *
155 	 * Throws: GException on failure.
156 	 */
157 	public bool ejectFinish(AsyncResultIF result);
158 
159 	/**
160 	 * Ejects a drive. This is an asynchronous operation, and is
161 	 * finished by calling g_drive_eject_with_operation_finish() with the @drive
162 	 * and #GAsyncResult data returned in the @callback.
163 	 *
164 	 * Params:
165 	 *     flags = flags affecting the unmount if required for eject
166 	 *     mountOperation = a #GMountOperation or %NULL to avoid
167 	 *         user interaction.
168 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
169 	 *     callback = a #GAsyncReadyCallback, or %NULL.
170 	 *     userData = user data passed to @callback.
171 	 *
172 	 * Since: 2.22
173 	 */
174 	public void ejectWithOperation(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
175 
176 	/**
177 	 * Finishes ejecting a drive. If any errors occurred during the operation,
178 	 * @error will be set to contain the errors and %FALSE will be returned.
179 	 *
180 	 * Params:
181 	 *     result = a #GAsyncResult.
182 	 *
183 	 * Returns: %TRUE if the drive was successfully ejected. %FALSE otherwise.
184 	 *
185 	 * Since: 2.22
186 	 *
187 	 * Throws: GException on failure.
188 	 */
189 	public bool ejectWithOperationFinish(AsyncResultIF result);
190 
191 	/**
192 	 * Gets the kinds of identifiers that @drive has.
193 	 * Use g_drive_get_identifier() to obtain the identifiers
194 	 * themselves.
195 	 *
196 	 * Returns: a %NULL-terminated
197 	 *     array of strings containing kinds of identifiers. Use g_strfreev()
198 	 *     to free.
199 	 */
200 	public string[] enumerateIdentifiers();
201 
202 	/**
203 	 * Gets the icon for @drive.
204 	 *
205 	 * Returns: #GIcon for the @drive.
206 	 *     Free the returned object with g_object_unref().
207 	 */
208 	public IconIF getIcon();
209 
210 	/**
211 	 * Gets the identifier of the given kind for @drive. The only
212 	 * identifier currently available is
213 	 * #G_DRIVE_IDENTIFIER_KIND_UNIX_DEVICE.
214 	 *
215 	 * Params:
216 	 *     kind = the kind of identifier to return
217 	 *
218 	 * Returns: a newly allocated string containing the
219 	 *     requested identifier, or %NULL if the #GDrive
220 	 *     doesn't have this kind of identifier.
221 	 */
222 	public string getIdentifier(string kind);
223 
224 	/**
225 	 * Gets the name of @drive.
226 	 *
227 	 * Returns: a string containing @drive's name. The returned
228 	 *     string should be freed when no longer needed.
229 	 */
230 	public string getName();
231 
232 	/**
233 	 * Gets the sort key for @drive, if any.
234 	 *
235 	 * Returns: Sorting key for @drive or %NULL if no such key is available.
236 	 *
237 	 * Since: 2.32
238 	 */
239 	public string getSortKey();
240 
241 	/**
242 	 * Gets a hint about how a drive can be started/stopped.
243 	 *
244 	 * Returns: A value from the #GDriveStartStopType enumeration.
245 	 *
246 	 * Since: 2.22
247 	 */
248 	public GDriveStartStopType getStartStopType();
249 
250 	/**
251 	 * Gets the icon for @drive.
252 	 *
253 	 * Returns: symbolic #GIcon for the @drive.
254 	 *     Free the returned object with g_object_unref().
255 	 *
256 	 * Since: 2.34
257 	 */
258 	public IconIF getSymbolicIcon();
259 
260 	/**
261 	 * Get a list of mountable volumes for @drive.
262 	 *
263 	 * The returned list should be freed with g_list_free(), after
264 	 * its elements have been unreffed with g_object_unref().
265 	 *
266 	 * Returns: #GList containing any #GVolume objects on the given @drive.
267 	 */
268 	public ListG getVolumes();
269 
270 	/**
271 	 * Checks if the @drive has media. Note that the OS may not be polling
272 	 * the drive for media changes; see g_drive_is_media_check_automatic()
273 	 * for more details.
274 	 *
275 	 * Returns: %TRUE if @drive has media, %FALSE otherwise.
276 	 */
277 	public bool hasMedia();
278 
279 	/**
280 	 * Check if @drive has any mountable volumes.
281 	 *
282 	 * Returns: %TRUE if the @drive contains volumes, %FALSE otherwise.
283 	 */
284 	public bool hasVolumes();
285 
286 	/**
287 	 * Checks if @drive is capabable of automatically detecting media changes.
288 	 *
289 	 * Returns: %TRUE if the @drive is capabable of automatically detecting
290 	 *     media changes, %FALSE otherwise.
291 	 */
292 	public bool isMediaCheckAutomatic();
293 
294 	/**
295 	 * Checks if the @drive supports removable media.
296 	 *
297 	 * Returns: %TRUE if @drive supports removable media, %FALSE otherwise.
298 	 */
299 	public bool isMediaRemovable();
300 
301 	/**
302 	 * Checks if the #GDrive and/or its media is considered removable by the user.
303 	 * See g_drive_is_media_removable().
304 	 *
305 	 * Returns: %TRUE if @drive and/or its media is considered removable, %FALSE otherwise.
306 	 *
307 	 * Since: 2.50
308 	 */
309 	public bool isRemovable();
310 
311 	/**
312 	 * Asynchronously polls @drive to see if media has been inserted or removed.
313 	 *
314 	 * When the operation is finished, @callback will be called.
315 	 * You can then call g_drive_poll_for_media_finish() to obtain the
316 	 * result of the operation.
317 	 *
318 	 * Params:
319 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
320 	 *     callback = a #GAsyncReadyCallback, or %NULL.
321 	 *     userData = user data to pass to @callback
322 	 */
323 	public void pollForMedia(Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
324 
325 	/**
326 	 * Finishes an operation started with g_drive_poll_for_media() on a drive.
327 	 *
328 	 * Params:
329 	 *     result = a #GAsyncResult.
330 	 *
331 	 * Returns: %TRUE if the drive has been poll_for_mediaed successfully,
332 	 *     %FALSE otherwise.
333 	 *
334 	 * Throws: GException on failure.
335 	 */
336 	public bool pollForMediaFinish(AsyncResultIF result);
337 
338 	/**
339 	 * Asynchronously starts a drive.
340 	 *
341 	 * When the operation is finished, @callback will be called.
342 	 * You can then call g_drive_start_finish() to obtain the
343 	 * result of the operation.
344 	 *
345 	 * Params:
346 	 *     flags = flags affecting the start operation.
347 	 *     mountOperation = a #GMountOperation or %NULL to avoid
348 	 *         user interaction.
349 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
350 	 *     callback = a #GAsyncReadyCallback, or %NULL.
351 	 *     userData = user data to pass to @callback
352 	 *
353 	 * Since: 2.22
354 	 */
355 	public void start(GDriveStartFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
356 
357 	/**
358 	 * Finishes starting a drive.
359 	 *
360 	 * Params:
361 	 *     result = a #GAsyncResult.
362 	 *
363 	 * Returns: %TRUE if the drive has been started successfully,
364 	 *     %FALSE otherwise.
365 	 *
366 	 * Since: 2.22
367 	 *
368 	 * Throws: GException on failure.
369 	 */
370 	public bool startFinish(AsyncResultIF result);
371 
372 	/**
373 	 * Asynchronously stops a drive.
374 	 *
375 	 * When the operation is finished, @callback will be called.
376 	 * You can then call g_drive_stop_finish() to obtain the
377 	 * result of the operation.
378 	 *
379 	 * Params:
380 	 *     flags = flags affecting the unmount if required for stopping.
381 	 *     mountOperation = a #GMountOperation or %NULL to avoid
382 	 *         user interaction.
383 	 *     cancellable = optional #GCancellable object, %NULL to ignore.
384 	 *     callback = a #GAsyncReadyCallback, or %NULL.
385 	 *     userData = user data to pass to @callback
386 	 *
387 	 * Since: 2.22
388 	 */
389 	public void stop(GMountUnmountFlags flags, MountOperation mountOperation, Cancellable cancellable, GAsyncReadyCallback callback, void* userData);
390 
391 	/**
392 	 * Finishes stopping a drive.
393 	 *
394 	 * Params:
395 	 *     result = a #GAsyncResult.
396 	 *
397 	 * Returns: %TRUE if the drive has been stopped successfully,
398 	 *     %FALSE otherwise.
399 	 *
400 	 * Since: 2.22
401 	 *
402 	 * Throws: GException on failure.
403 	 */
404 	public bool stopFinish(AsyncResultIF result);
405 
406 	/**
407 	 * Emitted when the drive's state has changed.
408 	 */
409 	gulong addOnChanged(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
410 
411 	/**
412 	 * This signal is emitted when the #GDrive have been
413 	 * disconnected. If the recipient is holding references to the
414 	 * object they should release them so the object can be
415 	 * finalized.
416 	 */
417 	gulong addOnDisconnected(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
418 
419 	/**
420 	 * Emitted when the physical eject button (if any) of a drive has
421 	 * been pressed.
422 	 */
423 	gulong addOnEjectButton(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
424 
425 	/**
426 	 * Emitted when the physical stop button (if any) of a drive has
427 	 * been pressed.
428 	 *
429 	 * Since: 2.22
430 	 */
431 	gulong addOnStopButton(void delegate(DriveIF) dlg, ConnectFlags connectFlags=cast(ConnectFlags)0);
432 }