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.UnixMountEntry;
26 
27 private import gio.IconIF;
28 private import gio.c.functions;
29 public  import gio.c.types;
30 private import glib.ListG;
31 private import glib.Str;
32 private import gobject.ObjectG;
33 public  import gtkc.giotypes;
34 
35 
36 /**
37  * Defines a Unix mount entry (e.g. <filename>/media/cdrom</filename>).
38  * This corresponds roughly to a mtab entry.
39  */
40 public class UnixMountEntry
41 {
42 	/** the main Gtk struct */
43 	protected GUnixMountEntry* gUnixMountEntry;
44 	protected bool ownedRef;
45 
46 	/** Get the main Gtk struct */
47 	public GUnixMountEntry* getUnixMountEntryStruct(bool transferOwnership = false)
48 	{
49 		if (transferOwnership)
50 			ownedRef = false;
51 		return gUnixMountEntry;
52 	}
53 
54 	/** the main Gtk struct as a void* */
55 	protected void* getStruct()
56 	{
57 		return cast(void*)gUnixMountEntry;
58 	}
59 
60 	/**
61 	 * Sets our main struct and passes it to the parent class.
62 	 */
63 	public this (GUnixMountEntry* gUnixMountEntry, bool ownedRef = false)
64 	{
65 		this.gUnixMountEntry = gUnixMountEntry;
66 		this.ownedRef = ownedRef;
67 	}
68 
69 
70 	/** */
71 	public static GType getType()
72 	{
73 		return g_unix_mount_entry_get_type();
74 	}
75 
76 	/**
77 	 * Determines if @mount_path is considered an implementation of the
78 	 * OS. This is primarily used for hiding mountable and mounted volumes
79 	 * that only are used in the OS and has little to no relevance to the
80 	 * casual user.
81 	 *
82 	 * Params:
83 	 *     mountPath = a mount path, e.g. `/media/disk` or `/usr`
84 	 *
85 	 * Returns: %TRUE if @mount_path is considered an implementation detail
86 	 *     of the OS.
87 	 */
88 	public static bool isMountPathSystemInternal(string mountPath)
89 	{
90 		return g_unix_is_mount_path_system_internal(Str.toStringz(mountPath)) != 0;
91 	}
92 
93 	/**
94 	 * Gets a #GUnixMountEntry for a given mount path. If @time_read
95 	 * is set, it will be filled with a unix timestamp for checking
96 	 * if the mounts have changed since with g_unix_mounts_changed_since().
97 	 *
98 	 * Params:
99 	 *     mountPath = path for a possible unix mount.
100 	 *     timeRead = guint64 to contain a timestamp.
101 	 *
102 	 * Returns: a #GUnixMountEntry.
103 	 */
104 	public static UnixMountEntry at(string mountPath, out ulong timeRead)
105 	{
106 		auto p = g_unix_mount_at(Str.toStringz(mountPath), &timeRead);
107 
108 		if(p is null)
109 		{
110 			return null;
111 		}
112 
113 		return ObjectG.getDObject!(UnixMountEntry)(cast(GUnixMountEntry*) p, true);
114 	}
115 
116 	/**
117 	 * Compares two unix mounts.
118 	 *
119 	 * Params:
120 	 *     mount2 = second #GUnixMountEntry to compare.
121 	 *
122 	 * Returns: 1, 0 or -1 if @mount1 is greater than, equal to,
123 	 *     or less than @mount2, respectively.
124 	 */
125 	public int compare(UnixMountEntry mount2)
126 	{
127 		return g_unix_mount_compare(gUnixMountEntry, (mount2 is null) ? null : mount2.getUnixMountEntryStruct());
128 	}
129 
130 	/**
131 	 * Frees a unix mount.
132 	 */
133 	public void free()
134 	{
135 		g_unix_mount_free(gUnixMountEntry);
136 	}
137 
138 	/**
139 	 * Gets the device path for a unix mount.
140 	 *
141 	 * Returns: a string containing the device path.
142 	 */
143 	public string getDevicePath()
144 	{
145 		return Str.toString(g_unix_mount_get_device_path(gUnixMountEntry));
146 	}
147 
148 	/**
149 	 * Gets the filesystem type for the unix mount.
150 	 *
151 	 * Returns: a string containing the file system type.
152 	 */
153 	public string getFsType()
154 	{
155 		return Str.toString(g_unix_mount_get_fs_type(gUnixMountEntry));
156 	}
157 
158 	/**
159 	 * Gets the mount path for a unix mount.
160 	 *
161 	 * Returns: the mount path for @mount_entry.
162 	 */
163 	public string getMountPath()
164 	{
165 		return Str.toString(g_unix_mount_get_mount_path(gUnixMountEntry));
166 	}
167 
168 	/**
169 	 * Guesses whether a Unix mount can be ejected.
170 	 *
171 	 * Returns: %TRUE if @mount_entry is deemed to be ejectable.
172 	 */
173 	public bool guessCanEject()
174 	{
175 		return g_unix_mount_guess_can_eject(gUnixMountEntry) != 0;
176 	}
177 
178 	/**
179 	 * Guesses the icon of a Unix mount.
180 	 *
181 	 * Returns: a #GIcon
182 	 */
183 	public IconIF guessIcon()
184 	{
185 		auto p = g_unix_mount_guess_icon(gUnixMountEntry);
186 
187 		if(p is null)
188 		{
189 			return null;
190 		}
191 
192 		return ObjectG.getDObject!(IconIF)(cast(GIcon*) p, true);
193 	}
194 
195 	/**
196 	 * Guesses the name of a Unix mount.
197 	 * The result is a translated string.
198 	 *
199 	 * Returns: A newly allocated string that must
200 	 *     be freed with g_free()
201 	 */
202 	public string guessName()
203 	{
204 		auto retStr = g_unix_mount_guess_name(gUnixMountEntry);
205 
206 		scope(exit) Str.freeString(retStr);
207 		return Str.toString(retStr);
208 	}
209 
210 	/**
211 	 * Guesses whether a Unix mount should be displayed in the UI.
212 	 *
213 	 * Returns: %TRUE if @mount_entry is deemed to be displayable.
214 	 */
215 	public bool guessShouldDisplay()
216 	{
217 		return g_unix_mount_guess_should_display(gUnixMountEntry) != 0;
218 	}
219 
220 	/**
221 	 * Guesses the symbolic icon of a Unix mount.
222 	 *
223 	 * Returns: a #GIcon
224 	 *
225 	 * Since: 2.34
226 	 */
227 	public IconIF guessSymbolicIcon()
228 	{
229 		auto p = g_unix_mount_guess_symbolic_icon(gUnixMountEntry);
230 
231 		if(p is null)
232 		{
233 			return null;
234 		}
235 
236 		return ObjectG.getDObject!(IconIF)(cast(GIcon*) p, true);
237 	}
238 
239 	/**
240 	 * Checks if a unix mount is mounted read only.
241 	 *
242 	 * Returns: %TRUE if @mount_entry is read only.
243 	 */
244 	public bool isReadonly()
245 	{
246 		return g_unix_mount_is_readonly(gUnixMountEntry) != 0;
247 	}
248 
249 	/**
250 	 * Checks if a Unix mount is a system mount. This is the Boolean OR of
251 	 * g_unix_is_system_fs_type(), g_unix_is_system_device_path() and
252 	 * g_unix_is_mount_path_system_internal() on @mount_entry’s properties.
253 	 *
254 	 * The definition of what a ‘system’ mount entry is may change over time as new
255 	 * file system types and device paths are ignored.
256 	 *
257 	 * Returns: %TRUE if the unix mount is for a system path.
258 	 */
259 	public bool isSystemInternal()
260 	{
261 		return g_unix_mount_is_system_internal(gUnixMountEntry) != 0;
262 	}
263 
264 	/**
265 	 * Checks if the unix mount points have changed since a given unix time.
266 	 *
267 	 * Params:
268 	 *     time = guint64 to contain a timestamp.
269 	 *
270 	 * Returns: %TRUE if the mount points have changed since @time.
271 	 */
272 	public static bool pointsChangedSince(ulong time)
273 	{
274 		return g_unix_mount_points_changed_since(time) != 0;
275 	}
276 
277 	/**
278 	 * Gets a #GList of #GUnixMountPoint containing the unix mount points.
279 	 * If @time_read is set, it will be filled with the mount timestamp,
280 	 * allowing for checking if the mounts have changed with
281 	 * g_unix_mount_points_changed_since().
282 	 *
283 	 * Params:
284 	 *     timeRead = guint64 to contain a timestamp.
285 	 *
286 	 * Returns: a #GList of the UNIX mountpoints.
287 	 */
288 	public static ListG mountPointsGet(out ulong timeRead)
289 	{
290 		auto p = g_unix_mount_points_get(&timeRead);
291 
292 		if(p is null)
293 		{
294 			return null;
295 		}
296 
297 		return new ListG(cast(GList*) p, true);
298 	}
299 
300 	/**
301 	 * Checks if the unix mounts have changed since a given unix time.
302 	 *
303 	 * Params:
304 	 *     time = guint64 to contain a timestamp.
305 	 *
306 	 * Returns: %TRUE if the mounts have changed since @time.
307 	 */
308 	public static bool mountsChangedSince(ulong time)
309 	{
310 		return g_unix_mounts_changed_since(time) != 0;
311 	}
312 
313 	/**
314 	 * Gets a #GList of #GUnixMountEntry containing the unix mounts.
315 	 * If @time_read is set, it will be filled with the mount
316 	 * timestamp, allowing for checking if the mounts have changed
317 	 * with g_unix_mounts_changed_since().
318 	 *
319 	 * Params:
320 	 *     timeRead = guint64 to contain a timestamp, or %NULL
321 	 *
322 	 * Returns: a #GList of the UNIX mounts.
323 	 */
324 	public static ListG mountsGet(out ulong timeRead)
325 	{
326 		auto p = g_unix_mounts_get(&timeRead);
327 
328 		if(p is null)
329 		{
330 			return null;
331 		}
332 
333 		return new ListG(cast(GList*) p, true);
334 	}
335 
336 	/**
337 	 * Makes a copy of @mount_entry.
338 	 *
339 	 * Returns: a new #GUnixMountEntry
340 	 *
341 	 * Since: 2.54
342 	 */
343 	public UnixMountEntry copy()
344 	{
345 		auto p = g_unix_mount_copy(gUnixMountEntry);
346 
347 		if(p is null)
348 		{
349 			return null;
350 		}
351 
352 		return ObjectG.getDObject!(UnixMountEntry)(cast(GUnixMountEntry*) p, true);
353 	}
354 
355 	/**
356 	 * Gets a #GUnixMountEntry for a given file path. If @time_read
357 	 * is set, it will be filled with a unix timestamp for checking
358 	 * if the mounts have changed since with g_unix_mounts_changed_since().
359 	 *
360 	 * Params:
361 	 *     filePath = file path on some unix mount.
362 	 *     timeRead = guint64 to contain a timestamp.
363 	 *
364 	 * Returns: a #GUnixMountEntry.
365 	 *
366 	 * Since: 2.52
367 	 */
368 	public static UnixMountEntry mountFor(string filePath, out ulong timeRead)
369 	{
370 		auto p = g_unix_mount_for(Str.toStringz(filePath), &timeRead);
371 
372 		if(p is null)
373 		{
374 			return null;
375 		}
376 
377 		return ObjectG.getDObject!(UnixMountEntry)(cast(GUnixMountEntry*) p, true);
378 	}
379 }