1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>HAL Support Functions</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.75.2">
<link rel="home" href="index.html" title="exo Reference Manual">
<link rel="up" href="exo-miscelleanous.html" title="Part VI. Miscelleanous">
<link rel="prev" href="exo-Miscellaneous-Utility-Functions.html" title="Miscellaneous Utility Functions">
<link rel="next" href="ExoXsessionClient.html" title="ExoXsessionClient">
<meta name="generator" content="GTK-Doc V1.14 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="exo-Miscellaneous-Utility-Functions.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="exo-miscelleanous.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">exo Reference Manual</th>
<td><a accesskey="n" href="ExoXsessionClient.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#exo-HAL-Support-Functions.synopsis" class="shortcut">Top</a>
|
<a href="#exo-HAL-Support-Functions.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry" title="HAL Support Functions">
<a name="exo-HAL-Support-Functions"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="exo-HAL-Support-Functions.top_of_page"></a>HAL Support Functions</span></h2>
<p>HAL Support Functions — Miscellaneous Utility Functions for HAL integration</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv" title="Synopsis">
<a name="exo-HAL-Support-Functions.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include <exo-hal/exo-hal.h>
<span class="returnvalue">gboolean</span> <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-init" title="exo_hal_init ()">exo_hal_init</a> (<em class="parameter"><code><span class="type">void</span></code></em>);
<span class="returnvalue">gboolean</span> <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-udi-validate" title="exo_hal_udi_validate ()">exo_hal_udi_validate</a> (<em class="parameter"><code>const <span class="type">gchar</span> *udi</code></em>,
<em class="parameter"><code><span class="type">gssize</span> len</code></em>,
<em class="parameter"><code><span class="type">gchar</span> **end</code></em>);
<span class="returnvalue">gchar</span> * <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-drive-compute-display-name" title="exo_hal_drive_compute_display_name ()">exo_hal_drive_compute_display_name</a> (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);
<span class="returnvalue">GList</span> * <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-drive-compute-icon-list" title="exo_hal_drive_compute_icon_list ()">exo_hal_drive_compute_icon_list</a> (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);
<span class="returnvalue">gchar</span> * <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-volume-compute-display-name" title="exo_hal_volume_compute_display_name ()">exo_hal_volume_compute_display_name</a> (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalVolume_s</span> *volume</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);
<span class="returnvalue">GList</span> * <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-volume-compute-icon-list" title="exo_hal_volume_compute_icon_list ()">exo_hal_volume_compute_icon_list</a> (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalVolume_s</span> *volume</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);
</pre>
</div>
<div class="refsect1" title="Description">
<a name="exo-HAL-Support-Functions.description"></a><h2>Description</h2>
<p>
This is an additional library that ships with the <span class="application">exo</span> package and
offers support functions for HAL integration, that are used by <span class="command"><strong>exo-mount</strong></span>
and <span class="command"><strong>Thunar</strong></span> to figure out display names and icons to visually
present HAL devices to the user. The library may also be used by other components to offer
smooth integration between various parts of the desktop, making sure that the same names
and icons are used for devices everywhere.
</p>
<p>
Since HAL is currently an optional dependency for Xfce, you should first check whether HAL support is
really available by calling the <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-init" title="exo_hal_init ()"><code class="function"><a class="link" href="exo-HAL-Support-Functions.html#exo-hal-init" title="exo_hal_init ()"><code class="function">exo_hal_init()</code></a></code></a>
function, which returns <code class="literal">TRUE</code> if HAL support is available and the other functions will
be able to do their work, or <code class="literal">FALSE</code> if the functions will return hardcoded default
values instead. The <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-init" title="exo_hal_init ()"><code class="function"><a class="link" href="exo-HAL-Support-Functions.html#exo-hal-init" title="exo_hal_init ()"><code class="function">exo_hal_init()</code></a></code></a> also takes
care of setting up the internationalization support, so make sure you call it first.
</p>
<p>
The HAL support module is not part of the main <code class="filename">exo</code> library, so you if you want to
use any of these functions you will need to explicitly link to the <code class="filename">exo-hal</code> library.
This is done with the <span class="command"><strong>pkg-config</strong></span> utility, using <code class="filename">exo-hal-0.3</code> as
the package name.
</p>
</div>
<div class="refsect1" title="Details">
<a name="exo-HAL-Support-Functions.details"></a><h2>Details</h2>
<div class="refsect2" title="exo_hal_init ()">
<a name="exo-hal-init"></a><h3>exo_hal_init ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> exo_hal_init (<em class="parameter"><code><span class="type">void</span></code></em>);</pre>
<p>
Initializes the HAL support module, which includes setting up the
internationalization support. Returns <code class="literal">TRUE</code> if support for HAL was
enabled at compile time, <code class="literal">FALSE</code> otherwise.
</p>
<p>
Make sure you call this function first prior to calling any of the
functions below.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <code class="literal">TRUE</code> if HAL support is available, <code class="literal">FALSE</code> otherwise.
</td>
</tr></tbody>
</table></div>
<p class="since">Since 0.3.1.13</p>
</div>
<hr>
<div class="refsect2" title="exo_hal_udi_validate ()">
<a name="exo-hal-udi-validate"></a><h3>exo_hal_udi_validate ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span> exo_hal_udi_validate (<em class="parameter"><code>const <span class="type">gchar</span> *udi</code></em>,
<em class="parameter"><code><span class="type">gssize</span> len</code></em>,
<em class="parameter"><code><span class="type">gchar</span> **end</code></em>);</pre>
<p>
Checks that the given range of the <em class="parameter"><code>udi</code></em> is a valid HAL device UDI (i.e. a valid
D-BUS object path name in the D-BUS protocol). Part of the validation ensures
that the <em class="parameter"><code>udi</code></em> contains only ASCII.
</p>
<p>
If <em class="parameter"><code>end</code></em> is non-<a href="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a>, then then end of the valid range will be stored there (i.e. the
start of the first invalid character if some bytes were invalid, or the end of the
text being validated otherwise).
</p>
<p>
Returns <code class="literal">TRUE</code> if all of <em class="parameter"><code>udi</code></em> was valid. All HAL routines <span class="emphasis"><em>require</em></span>
valid UDIs as input; so data read from a file or the command line should be checked
with <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-udi-validate" title="exo_hal_udi_validate ()"><code class="function">exo_hal_udi_validate()</code></a> before doing anything else with it.
</p>
<p>
Note that <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-udi-validate" title="exo_hal_udi_validate ()"><code class="function">exo_hal_udi_validate()</code></a> is always available, no matter if HAL support was
enabled at compile time.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>udi</code></em> :</span></p></td>
<td>the HAL device UDI.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>len</code></em> :</span></p></td>
<td>the max number of bytes to validate, or <code class="literal">-1</code> to go until NUL.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>end</code></em> :</span></p></td>
<td>return location for end of valid data.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> <code class="literal">TRUE</code> if <em class="parameter"><code>udi</code></em> was a valid HAL device UDI.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.3.1.13</p>
</div>
<hr>
<div class="refsect2" title="exo_hal_drive_compute_display_name ()">
<a name="exo-hal-drive-compute-display-name"></a><h3>exo_hal_drive_compute_display_name ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> * exo_hal_drive_compute_display_name (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);</pre>
<p>
Computes a usable display name that should be used to present
<em class="parameter"><code>drive</code></em> to the user. May return <a href="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if it's unable to determine
a display name (i.e. if HAL support is not available), in which
case the caller should try to come up with a fallback name on
it's own (i.e. using the basename of the <em class="parameter"><code>drive</code></em>s device
file or something like that).
</p>
<p>
The caller is responsible to free the returned string using
<code class="function">g_free()</code> when no longer needed.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal/libhal-libhal.html#LibHalContext"><span class="type">LibHalContext</span></a>, connected to the HAL daemon.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>drive</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal-storage/libhal-storage-libhal-storage.html#LibHalDrive"><span class="type">LibHalDrive</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a display name for the <em class="parameter"><code>drive</code></em> that should be used
to present the <em class="parameter"><code>drive</code></em> to the user or <a href="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if the
function is unable to come up with a usable name
and the caller should figure out a fallback name
on its own.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.3.1.13</p>
</div>
<hr>
<div class="refsect2" title="exo_hal_drive_compute_icon_list ()">
<a name="exo-hal-drive-compute-icon-list"></a><h3>exo_hal_drive_compute_icon_list ()</h3>
<pre class="programlisting"><span class="returnvalue">GList</span> * exo_hal_drive_compute_icon_list (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);</pre>
<p>
Tries to find a list of icon names that may be used to visually present <em class="parameter"><code>drive</code></em>
to the user. The list is sorted by relevance, with the best icon matches
appearing first in the list.
</p>
<p>
The caller is responsible to free the returned list using
</p>
<div class="informalexample"><pre class="programlisting">
g_list_foreach (list, (GFunc) g_free, NULL);
g_list_free (list);
</pre></div>
<p>
when no longer needed.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal/libhal-libhal.html#LibHalContext"><span class="type">LibHalContext</span></a>, connected to the HAL daemon.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>drive</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal-storage/libhal-storage-libhal-storage.html#LibHalDrive"><span class="type">LibHalDrive</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a list of icon names for icons that can be used to visually
represent the <em class="parameter"><code>drive</code></em> to the user.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.3.1.13</p>
</div>
<hr>
<div class="refsect2" title="exo_hal_volume_compute_display_name ()">
<a name="exo-hal-volume-compute-display-name"></a><h3>exo_hal_volume_compute_display_name ()</h3>
<pre class="programlisting"><span class="returnvalue">gchar</span> * exo_hal_volume_compute_display_name (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalVolume_s</span> *volume</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);</pre>
<p>
Similar to <a class="link" href="exo-HAL-Support-Functions.html#exo-hal-drive-compute-display-name" title="exo_hal_drive_compute_display_name ()"><code class="function">exo_hal_drive_compute_display_name()</code></a>, but tries to find a
suitable display name for the <em class="parameter"><code>volume</code></em> first, falling back to <em class="parameter"><code>drive</code></em>
under certain conditions. This function may return <a href="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if no
suitable display name was found.
</p>
<p>
The caller is responsible to free the returned string using <code class="function">g_free()</code>
when no longer needed.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal/libhal-libhal.html#LibHalContext"><span class="type">LibHalContext</span></a>, connected to the HAL daemon.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>volume</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal-storage/libhal-storage-libhal-storage.html#LibHalVolume"><span class="type">LibHalVolume</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>drive</code></em> :</span></p></td>
<td>the <a href="/usr/share/gtk-doc/html/libhal-storage/libhal-storage-libhal-storage.html#LibHalDrive"><span class="type">LibHalDrive</span></a> of the <em class="parameter"><code>volume</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> the display name for the <em class="parameter"><code>volume</code></em> or <a href="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL--CAPS"><code class="literal">NULL</code></a> if the
function is unable to determine the display name.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.3.1.13</p>
</div>
<hr>
<div class="refsect2" title="exo_hal_volume_compute_icon_list ()">
<a name="exo-hal-volume-compute-icon-list"></a><h3>exo_hal_volume_compute_icon_list ()</h3>
<pre class="programlisting"><span class="returnvalue">GList</span> * exo_hal_volume_compute_icon_list (<em class="parameter"><code><span class="type">struct LibHalContext_s</span> *context</code></em>,
<em class="parameter"><code><span class="type">struct LibHalVolume_s</span> *volume</code></em>,
<em class="parameter"><code><span class="type">struct LibHalDrive_s</span> *drive</code></em>);</pre>
<p>
Similar to <code class="function">exo_hal_drive_compute_icon_name()</code>, but first looks for
icons for <em class="parameter"><code>volume</code></em>, falling back to an icons for <em class="parameter"><code>drive</code></em>.
</p>
<p>
The caller is responsible to free the returned list using
</p>
<div class="informalexample"><pre class="programlisting">
g_list_foreach (list, (GFunc) g_free, NULL);
g_list_free (list);
</pre></div>
<p>
when no longer needed.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>context</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal/libhal-libhal.html#LibHalContext"><span class="type">LibHalContext</span></a>, connected to the HAL daemon.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>volume</code></em> :</span></p></td>
<td>a <a href="/usr/share/gtk-doc/html/libhal-storage/libhal-storage-libhal-storage.html#LibHalVolume"><span class="type">LibHalVolume</span></a>.
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>drive</code></em> :</span></p></td>
<td>the <a href="/usr/share/gtk-doc/html/libhal-storage/libhal-storage-libhal-storage.html#LibHalDrive"><span class="type">LibHalDrive</span></a> of the <em class="parameter"><code>volume</code></em>.
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td> a list of icon names for icons that can be used to visually
represent the <em class="parameter"><code>volume</code></em> to the user.
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 0.3.1.13</p>
</div>
</div>
<div class="refsect1" title="See Also">
<a name="exo-HAL-Support-Functions.see-also"></a><h2>See Also</h2>
<p>
<a class="ulink" href="http://gitweb.freedesktop.org/?p=hal.git;a=blob_plain;f=doc/spec/hal-spec.html" target="_top">HAL
Specification</a>
</p>
</div>
</div>
<div class="footer">
<hr>
Generated by GTK-Doc V1.14</div>
</body>
</html>
|