ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / doc / xml / gnome-vfs-module-callback.xml
1 <refentry id="gnome-vfs-20-gnome-vfs-module-callback">
2 <refmeta>
3 <refentrytitle>gnome-vfs-module-callback</refentrytitle>
4 <manvolnum>3</manvolnum>
5 <refmiscinfo>GNOME-VFS-2.0 Library</refmiscinfo>
6 </refmeta>
7
8 <refnamediv>
9 <refname>gnome-vfs-module-callback</refname><refpurpose>functions used by apps if they want to answer to callback invocations by gnome-vfs modules</refpurpose>
10 </refnamediv>
11
12 <refsynopsisdiv><title>Synopsis</title>
13
14 <synopsis>
15
16
17
18 <link linkend="void">void</link>        (<link linkend="GnomeVFSModuleCallback">*GnomeVFSModuleCallback</link>)       (<link linkend="gconstpointer">gconstpointer</link> in,
19                                              <link linkend="gsize">gsize</link> in_size,
20                                              <link linkend="gpointer">gpointer</link> out,
21                                              <link linkend="gsize">gsize</link> out_size,
22                                              <link linkend="gpointer">gpointer</link> callback_data);
23 <link linkend="void">void</link>        (<link linkend="GnomeVFSModuleCallbackResponse">*GnomeVFSModuleCallbackResponse</link>)
24                                             (<link linkend="gpointer">gpointer</link> response_data);
25 <link linkend="void">void</link>        (<link linkend="GnomeVFSAsyncModuleCallback">*GnomeVFSAsyncModuleCallback</link>)  (<link linkend="gconstpointer">gconstpointer</link> in,
26                                              <link linkend="gsize">gsize</link> in_size,
27                                              <link linkend="gpointer">gpointer</link> out,
28                                              <link linkend="gsize">gsize</link> out_size,
29                                              <link linkend="gpointer">gpointer</link> callback_data,
30                                              <link linkend="GnomeVFSModuleCallbackResponse">GnomeVFSModuleCallbackResponse</link> response,
31                                              <link linkend="gpointer">gpointer</link> response_data);
32 <link linkend="void">void</link>        <link linkend="gnome-vfs-module-callback-set-default">gnome_vfs_module_callback_set_default</link>
33                                             (const <link linkend="char">char</link> *callback_name,
34                                              <link linkend="GnomeVFSModuleCallback">GnomeVFSModuleCallback</link> callback,
35                                              <link linkend="gpointer">gpointer</link> callback_data,
36                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);
37 <link linkend="void">void</link>        <link linkend="gnome-vfs-module-callback-push">gnome_vfs_module_callback_push</link>  (const <link linkend="char">char</link> *callback_name,
38                                              <link linkend="GnomeVFSModuleCallback">GnomeVFSModuleCallback</link> callback,
39                                              <link linkend="gpointer">gpointer</link> callback_data,
40                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);
41 <link linkend="void">void</link>        <link linkend="gnome-vfs-module-callback-pop">gnome_vfs_module_callback_pop</link>   (const <link linkend="char">char</link> *callback_name);
42 <link linkend="void">void</link>        <link linkend="gnome-vfs-async-module-callback-set-default">gnome_vfs_async_module_callback_set_default</link>
43                                             (const <link linkend="char">char</link> *callback_name,
44                                              <link linkend="GnomeVFSAsyncModuleCallback">GnomeVFSAsyncModuleCallback</link> callback,
45                                              <link linkend="gpointer">gpointer</link> callback_data,
46                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);
47 <link linkend="void">void</link>        <link linkend="gnome-vfs-async-module-callback-push">gnome_vfs_async_module_callback_push</link>
48                                             (const <link linkend="char">char</link> *callback_name,
49                                              <link linkend="GnomeVFSAsyncModuleCallback">GnomeVFSAsyncModuleCallback</link> callback,
50                                              <link linkend="gpointer">gpointer</link> callback_data,
51                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);
52 <link linkend="void">void</link>        <link linkend="gnome-vfs-async-module-callback-pop">gnome_vfs_async_module_callback_pop</link>
53                                             (const <link linkend="char">char</link> *callback_name);
54 </synopsis>
55 </refsynopsisdiv>
56
57
58
59
60
61
62
63
64
65 <refsect1>
66 <title>Description</title>
67 <para>
68
69 </para>
70 </refsect1>
71
72 <refsect1>
73 <title>Details</title>
74 <refsect2>
75 <title><anchor id="GnomeVFSModuleCallback"/>GnomeVFSModuleCallback ()</title>
76 <indexterm><primary>GnomeVFSModuleCallback</primary></indexterm><programlisting><link linkend="void">void</link>        (*GnomeVFSModuleCallback)       (<link linkend="gconstpointer">gconstpointer</link> in,
77                                              <link linkend="gsize">gsize</link> in_size,
78                                              <link linkend="gpointer">gpointer</link> out,
79                                              <link linkend="gsize">gsize</link> out_size,
80                                              <link linkend="gpointer">gpointer</link> callback_data);</programlisting>
81 <para>
82 This is the type of a callback function that gets set for a module
83 callback. 
84 </para>
85 <para>
86 When the callback is invoked, the user function is called with an
87 <parameter>in</parameter> argument, the exact type of which depends on the specific
88 callback. It is generally a pointer to a struct with several fields
89 that provide information to the callback.
90 </para>
91 <para>
92 The <parameter>out</parameter> argument is used to return a values from the
93 callback. Once again the exact type depends on the specific
94 callback. It is generally a pointer to a pre-allocated struct with
95 several fields that the callback function should fill in before
96 returning.</para>
97 <para>
98
99 </para><variablelist role="params">
100 <varlistentry><term><parameter>in</parameter>&nbsp;:</term>
101 <listitem><simpara> The in argument for this callback; the exact type depends on the specific callback
102 </simpara></listitem></varlistentry>
103 <varlistentry><term><parameter>in_size</parameter>&nbsp;:</term>
104 <listitem><simpara> Size of the in argument; useful for sanity-checking
105 </simpara></listitem></varlistentry>
106 <varlistentry><term><parameter>out</parameter>&nbsp;:</term>
107 <listitem><simpara> The out argument for this callback; the exact type depends on the specific callback
108 </simpara></listitem></varlistentry>
109 <varlistentry><term><parameter>out_size</parameter>&nbsp;:</term>
110 <listitem><simpara> Size of the out argument; useful for sanity-checking
111 </simpara></listitem></varlistentry>
112 <varlistentry><term><parameter>callback_data</parameter>&nbsp;:</term>
113 <listitem><simpara> The <parameter>callback_data</parameter> specified when this callback was set
114 </simpara></listitem></varlistentry>
115 </variablelist></refsect2>
116 <refsect2>
117 <title><anchor id="GnomeVFSModuleCallbackResponse"/>GnomeVFSModuleCallbackResponse ()</title>
118 <indexterm><primary>GnomeVFSModuleCallbackResponse</primary></indexterm><programlisting><link linkend="void">void</link>        (*GnomeVFSModuleCallbackResponse)
119                                             (<link linkend="gpointer">gpointer</link> response_data);</programlisting>
120 <para>
121 This is the type of the response function passed to a
122 <link linkend="GnomeVFSAsyncModuleCallback"><function>GnomeVFSAsyncModuleCallback()</function></link>. It should be called when the async
123 callback has completed.</para>
124 <para>
125
126 </para><variablelist role="params">
127 <varlistentry><term><parameter>response_data</parameter>&nbsp;:</term>
128 <listitem><simpara> Pass the <parameter>response_data</parameter> argument originally passed to the async callback
129 </simpara></listitem></varlistentry>
130 </variablelist></refsect2>
131 <refsect2>
132 <title><anchor id="GnomeVFSAsyncModuleCallback"/>GnomeVFSAsyncModuleCallback ()</title>
133 <indexterm><primary>GnomeVFSAsyncModuleCallback</primary></indexterm><programlisting><link linkend="void">void</link>        (*GnomeVFSAsyncModuleCallback)  (<link linkend="gconstpointer">gconstpointer</link> in,
134                                              <link linkend="gsize">gsize</link> in_size,
135                                              <link linkend="gpointer">gpointer</link> out,
136                                              <link linkend="gsize">gsize</link> out_size,
137                                              <link linkend="gpointer">gpointer</link> callback_data,
138                                              <link linkend="GnomeVFSModuleCallbackResponse">GnomeVFSModuleCallbackResponse</link> response,
139                                              <link linkend="gpointer">gpointer</link> response_data);</programlisting>
140 <para>
141 This is the type of a callback function that gets set for an async
142 module callback. 
143 </para>
144 <para>
145 Such callbacks are useful when you are using the API and want
146 callbacks to be handled from the main thread, for instance if they
147 need to put up a dialog.
148 </para>
149 <para>
150 Like a <link linkend="GnomeVFSModuleCallback"><function>GnomeVFSModuleCallback()</function></link>, an async callback has <parameter>in</parameter> and <parameter>out</parameter>
151 arguments for passing data into and out of the callback. However,
152 an async callback does not need to fill in the <parameter>out</parameter> argument before
153 returning. Instead, it can arrange to have the work done from a
154 callback on the main loop, from another thread, etc. The <parameter>response</parameter>
155 function should be called by whatever code finishes the work of the
156 callback with <parameter>response_data</parameter> as an argument once the <parameter>out</parameter> argument
157 is filled in and the callback is done.
158 </para>
159 <para>
160 The <parameter>in</parameter> and <parameter>out</parameter> arguments are guaranteed to remain valid until the
161 <parameter>response</parameter> function is called.</para>
162 <para>
163
164 </para><variablelist role="params">
165 <varlistentry><term><parameter>in</parameter>&nbsp;:</term>
166 <listitem><simpara> The in argument for this callback; the exact type depends on the specific callback
167 </simpara></listitem></varlistentry>
168 <varlistentry><term><parameter>in_size</parameter>&nbsp;:</term>
169 <listitem><simpara> Size of the in argument; useful for sanity-checking
170 </simpara></listitem></varlistentry>
171 <varlistentry><term><parameter>out</parameter>&nbsp;:</term>
172 <listitem><simpara> The out argument for this callback; the exact type depends on the specific callback
173 </simpara></listitem></varlistentry>
174 <varlistentry><term><parameter>out_size</parameter>&nbsp;:</term>
175 <listitem><simpara> Size of the out argument; useful for sanity-checking
176 </simpara></listitem></varlistentry>
177 <varlistentry><term><parameter>callback_data</parameter>&nbsp;:</term>
178 <listitem><simpara> The <parameter>callback_data</parameter> specified when this callback was set
179 </simpara></listitem></varlistentry>
180 <varlistentry><term><parameter>response</parameter>&nbsp;:</term>
181 <listitem><simpara> Response function to call when the callback is completed
182 </simpara></listitem></varlistentry>
183 <varlistentry><term><parameter>response_data</parameter>&nbsp;:</term>
184 <listitem><simpara> Argument to pass to <parameter>response</parameter>
185 </simpara></listitem></varlistentry>
186 </variablelist></refsect2>
187 <refsect2>
188 <title><anchor id="gnome-vfs-module-callback-set-default"/>gnome_vfs_module_callback_set_default ()</title>
189 <indexterm><primary>gnome_vfs_module_callback_set_default</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_module_callback_set_default
190                                             (const <link linkend="char">char</link> *callback_name,
191                                              <link linkend="GnomeVFSModuleCallback">GnomeVFSModuleCallback</link> callback,
192                                              <link linkend="gpointer">gpointer</link> callback_data,
193                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);</programlisting>
194 <para>
195 Set the default callback for <parameter>callback_name</parameter> to
196 <parameter>callback</parameter>. <parameter>callback</parameter> will be called with <parameter>callback_data</parameter> on the
197 same thread as the gnome-vfs operation that invokes it. The default
198 value is shared for all threads, but setting it is thread-safe.
199 </para>
200 <para>
201 Use this function if you want to set a handler to be used by your
202 whole application. You can use <link linkend="gnome-vfs-module-callback-push"><function>gnome_vfs_module_callback_push()</function></link> to
203 set a callback function that will temporarily override the default
204 on the current thread instead. Or you can also use
205 <link linkend="gnome-vfs-async-module-callback-set-default"><function>gnome_vfs_async_module_callback_set_default()</function></link> to set an async
206 callback function.
207 </para>
208 <para>
209 Note: <parameter>destroy_notify</parameter> may be called on any thread - it is not
210 guaranteed to be called on the main thread.</para>
211 <para>
212
213 </para><variablelist role="params">
214 <varlistentry><term><parameter>callback_name</parameter>&nbsp;:</term>
215 <listitem><simpara> The name of the module callback to set
216 </simpara></listitem></varlistentry>
217 <varlistentry><term><parameter>callback</parameter>&nbsp;:</term>
218 <listitem><simpara> The function to call when the callback is invoked
219 </simpara></listitem></varlistentry>
220 <varlistentry><term><parameter>callback_data</parameter>&nbsp;:</term>
221 <listitem><simpara> Pointer to pass as the <parameter>callback_data</parameter> argument to <parameter>callback</parameter>
222 </simpara></listitem></varlistentry>
223 <varlistentry><term><parameter>destroy_notify</parameter>&nbsp;:</term>
224 <listitem><simpara> Function to call when <parameter>callback_data</parameter> is to be freed.
225 </simpara></listitem></varlistentry>
226 </variablelist></refsect2>
227 <refsect2>
228 <title><anchor id="gnome-vfs-module-callback-push"/>gnome_vfs_module_callback_push ()</title>
229 <indexterm><primary>gnome_vfs_module_callback_push</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_module_callback_push  (const <link linkend="char">char</link> *callback_name,
230                                              <link linkend="GnomeVFSModuleCallback">GnomeVFSModuleCallback</link> callback,
231                                              <link linkend="gpointer">gpointer</link> callback_data,
232                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);</programlisting>
233 <para>
234 Set <parameter>callback</parameter> as a temprary handler for <parameter>callback_name</parameter>. <parameter>callback</parameter>
235 will be called with <parameter>callback_data</parameter> on the same thread as the
236 gnome-vfs operation that invokes it. The temporary handler is set
237 per-thread.
238 </para>
239 <para>
240 <link linkend="gnome-vfs-module-callback-pop"><function>gnome_vfs_module_callback_pop()</function></link> removes the most recently set
241 temporary handler. The temporary handlers are treated as a first-in
242 first-out stack.
243 </para>
244 <para>
245 Use this function to set a temporary callback handler for a single
246 call or a few calls. You can use
247 <link linkend="gnome-vfs-module-callback-set-default"><function>gnome_vfs_module_callback_set_default()</function></link> to set a callback function
248 that will establish a permanent global setting for all threads
249 instead.
250 </para>
251 <para>
252 Note: <parameter>destroy_notify</parameter> may be called on any thread - it is not
253 guaranteed to be called on the main thread.</para>
254 <para>
255
256 </para><variablelist role="params">
257 <varlistentry><term><parameter>callback_name</parameter>&nbsp;:</term>
258 <listitem><simpara> The name of the module callback to set temporarily
259 </simpara></listitem></varlistentry>
260 <varlistentry><term><parameter>callback</parameter>&nbsp;:</term>
261 <listitem><simpara> The function to call when the callback is invoked
262 </simpara></listitem></varlistentry>
263 <varlistentry><term><parameter>callback_data</parameter>&nbsp;:</term>
264 <listitem><simpara> Pointer to pass as the <parameter>callback_data</parameter> argument to <parameter>callback</parameter>
265 </simpara></listitem></varlistentry>
266 <varlistentry><term><parameter>destroy_notify</parameter>&nbsp;:</term>
267 <listitem><simpara> Function to call when <parameter>callback_data</parameter> is to be freed.
268 </simpara></listitem></varlistentry>
269 </variablelist></refsect2>
270 <refsect2>
271 <title><anchor id="gnome-vfs-module-callback-pop"/>gnome_vfs_module_callback_pop ()</title>
272 <indexterm><primary>gnome_vfs_module_callback_pop</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_module_callback_pop   (const <link linkend="char">char</link> *callback_name);</programlisting>
273 <para>
274 Remove the temporary handler for <parameter>callback_name</parameter> most recently set
275 with <link linkend="gnome-vfs-module-callback-push"><function>gnome_vfs_module_callback_push()</function></link>.  If another temporary
276 handler was previously set on the same thread, it becomes the
277 current handler. Otherwise, the default handler, if any, becomes
278 current. 
279 </para>
280 <para>
281 The temporary handlers are treated as a first-in first-out
282 stack.</para>
283 <para>
284
285 </para><variablelist role="params">
286 <varlistentry><term><parameter>callback_name</parameter>&nbsp;:</term>
287 <listitem><simpara> The name of the module callback to remove a temporary handler for
288 </simpara></listitem></varlistentry>
289 </variablelist></refsect2>
290 <refsect2>
291 <title><anchor id="gnome-vfs-async-module-callback-set-default"/>gnome_vfs_async_module_callback_set_default ()</title>
292 <indexterm><primary>gnome_vfs_async_module_callback_set_default</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_async_module_callback_set_default
293                                             (const <link linkend="char">char</link> *callback_name,
294                                              <link linkend="GnomeVFSAsyncModuleCallback">GnomeVFSAsyncModuleCallback</link> callback,
295                                              <link linkend="gpointer">gpointer</link> callback_data,
296                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);</programlisting>
297 <para>
298 Set the default async callback for <parameter>callback_name</parameter> to
299 <parameter>callback</parameter>. <parameter>callback</parameter> will be called with <parameter>callback_data</parameter>
300 from a callback on the main thread. It will be passed a response
301 function which should be called to signal completion of the callback.
302 The callback function itself may return in the meantime.
303 </para>
304 <para>
305 The default value is shared for all threads, but setting it is
306 thread-safe.
307 </para>
308 <para>
309 Use this function if you want to globally set a callback handler
310 for use with async operations.
311 </para>
312 <para>
313 You can use <link linkend="gnome-vfs-async-module-callback-push"><function>gnome_vfs_async_module_callback_push()</function></link> to set an async
314 callback function that will temporarily override the default on the
315 current thread instead. Or you can also use
316 <link linkend="gnome-vfs-module-callback-set-default"><function>gnome_vfs_module_callback_set_default()</function></link> to set a regular callback
317 function.
318 </para>
319 <para>
320 Note: <parameter>destroy_notify</parameter> may be called on any thread - it is not
321 guaranteed to be called on the main thread.</para>
322 <para>
323
324 </para><variablelist role="params">
325 <varlistentry><term><parameter>callback_name</parameter>&nbsp;:</term>
326 <listitem><simpara> The name of the async module callback to set
327 </simpara></listitem></varlistentry>
328 <varlistentry><term><parameter>callback</parameter>&nbsp;:</term>
329 <listitem><simpara> The function to call when the callback is invoked
330 </simpara></listitem></varlistentry>
331 <varlistentry><term><parameter>callback_data</parameter>&nbsp;:</term>
332 <listitem><simpara> Pointer to pass as the <parameter>callback_data</parameter> argument to <parameter>callback</parameter>
333 </simpara></listitem></varlistentry>
334 <varlistentry><term><parameter>destroy_notify</parameter>&nbsp;:</term>
335 <listitem><simpara> Function to call when <parameter>callback_data</parameter> is to be freed.
336 </simpara></listitem></varlistentry>
337 </variablelist></refsect2>
338 <refsect2>
339 <title><anchor id="gnome-vfs-async-module-callback-push"/>gnome_vfs_async_module_callback_push ()</title>
340 <indexterm><primary>gnome_vfs_async_module_callback_push</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_async_module_callback_push
341                                             (const <link linkend="char">char</link> *callback_name,
342                                              <link linkend="GnomeVFSAsyncModuleCallback">GnomeVFSAsyncModuleCallback</link> callback,
343                                              <link linkend="gpointer">gpointer</link> callback_data,
344                                              <link linkend="GDestroyNotify">GDestroyNotify</link> destroy_notify);</programlisting>
345 <para>
346 Set <parameter>callback_func</parameter> as a temprary async handler for
347 <parameter>callback_name</parameter>. <parameter>callback</parameter> will be called with <parameter>callback_data</parameter>
348 from a callback on the main thread. It will be passed a response
349 function which should be called to signal completion of the
350 callback. The callback function itself may return in the meantime.
351 </para>
352 <para>
353 The temporary async handler is set per-thread.
354 </para>
355 <para>
356 <link linkend="gnome-vfs-async-module-callback-pop"><function>gnome_vfs_async_module_callback_pop()</function></link> removes the most recently set
357 temporary temporary handler. The temporary async handlers are
358 treated as a first-in first-out stack.
359 </para>
360 <para>
361 Use this function to set a temporary async callback handler for a
362 single call or a few calls. You can use
363 <link linkend="gnome-vfs-async-module-callback-set-default"><function>gnome_vfs_async_module_callback_set_default()</function></link> to set an async
364 callback function that will establish a permanent global setting
365 for all threads instead.
366 </para>
367 <para>
368 Note: <parameter>destroy_notify</parameter> may be called on any thread - it is not
369 guaranteed to be called on the main thread.</para>
370 <para>
371
372 </para><variablelist role="params">
373 <varlistentry><term><parameter>callback_name</parameter>&nbsp;:</term>
374 <listitem><simpara> The name of the module callback to set temporarily
375 </simpara></listitem></varlistentry>
376 <varlistentry><term><parameter>callback</parameter>&nbsp;:</term>
377 <listitem><simpara> The function to call when the callback is invoked
378 </simpara></listitem></varlistentry>
379 <varlistentry><term><parameter>callback_data</parameter>&nbsp;:</term>
380 <listitem><simpara> Pointer to pass as the <parameter>callback_data</parameter> argument to <parameter>callback</parameter>
381 </simpara></listitem></varlistentry>
382 <varlistentry><term><parameter>destroy_notify</parameter>&nbsp;:</term>
383 <listitem><simpara> Function to call when <parameter>callback_data</parameter> is to be freed.
384 </simpara></listitem></varlistentry>
385 </variablelist></refsect2>
386 <refsect2>
387 <title><anchor id="gnome-vfs-async-module-callback-pop"/>gnome_vfs_async_module_callback_pop ()</title>
388 <indexterm><primary>gnome_vfs_async_module_callback_pop</primary></indexterm><programlisting><link linkend="void">void</link>        gnome_vfs_async_module_callback_pop
389                                             (const <link linkend="char">char</link> *callback_name);</programlisting>
390 <para>
391 Remove the temporary async handler for <parameter>callback_name</parameter> most recently
392 set with <link linkend="gnome-vfs-async-module-callback-push"><function>gnome_vfs_async_module_callback_push()</function></link>.  If another
393 temporary async handler was previously set on the same thread, it
394 becomes the current handler. Otherwise, the default async handler,
395 if any, becomes current.
396 </para>
397 <para>
398 The temporary async handlers are treated as a first-in first-out
399 stack.</para>
400 <para>
401
402 </para><variablelist role="params">
403 <varlistentry><term><parameter>callback_name</parameter>&nbsp;:</term>
404 <listitem><simpara> The name of the module callback to remove a temporary handler for
405 </simpara></listitem></varlistentry>
406 </variablelist></refsect2>
407
408 </refsect1>
409
410
411
412
413 </refentry>