comparison src/eventloop.h @ 8273:f24172f53650

[gaim-migrate @ 8997] This is Scott Lamb's eventloop abstraction patch. If it breaks things, Scott Lamb will be glad to take the punishment. If it doesn't, it should make integration into other event loops easier. Well, no, not easier, harder actually, but it'll be done more appropriately and less hackily.. er, hacky. Is hackily a word? committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Tue, 17 Feb 2004 02:17:48 +0000
parents
children 084ed9f7ac19
comparison
equal deleted inserted replaced
8272:9af78e73f0b2 8273:f24172f53650
1 /**
2 * @file eventloop.h Gaim Event Loop API
3 * @ingroup core
4 *
5 * gaim
6 *
7 * Gaim is the legal property of its developers, whose names are too numerous
8 * to list here. Please refer to the COPYRIGHT file distributed with this
9 * source distribution.
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 */
25 #ifndef _GAIM_EVENTLOOP_H_
26 #define _GAIM_EVENTLOOP_H_
27
28 #include <glib.h>
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 /**
35 * An input condition.
36 */
37 typedef enum
38 {
39 GAIM_INPUT_READ = 1 << 0, /**< A read condition. */
40 GAIM_INPUT_WRITE = 1 << 1 /**< A write condition. */
41
42 } GaimInputCondition;
43
44 typedef void (*GaimInputFunction)(gpointer, gint, GaimInputCondition);
45
46 typedef struct _GaimEventLoopUiOps GaimEventLoopUiOps;
47
48 struct _GaimEventLoopUiOps
49 {
50 /**
51 * Creates a callback timer.
52 * @see g_timeout_add, gaim_timeout_add
53 **/
54 guint (*timeout_add)(guint interval, GSourceFunc function, gpointer data);
55
56 /**
57 * Adds an input handler.
58 * @see gaim_input_add, g_io_add_watch_full
59 */
60 gint (*input_add)(int source, GaimInputCondition cond,
61 GaimInputFunction func, gpointer user_data);
62
63 /**
64 * Removes an input handler.
65 * @see gaim_input_remove, g_source_remove
66 */
67 void (*input_remove)(gint handle);
68 };
69
70 /**************************************************************************/
71 /** @name Event Loop API */
72 /**************************************************************************/
73 /*@{*/
74 /**
75 * Creates a callback timer.
76 * The timer will repeat until the function returns <tt>FALSE</tt>. The
77 * first call will be at the end of the first interval.
78 * @param interval The time between calls of the function, in
79 * milliseconds.
80 * @param function The function to call.
81 * @param data data to pass to <tt>function</tt>.
82 **/
83 guint gaim_timeout_add(guint interval, GSourceFunc function, gpointer data);
84
85 /**
86 * Adds an input handler.
87 *
88 * @param source The input source.
89 * @param cond The condition type.
90 * @param func The callback function for data.
91 * @param user_data User-specified data.
92 *
93 * @return The resulting handle.
94 * @see g_io_add_watch_full
95 */
96 gint gaim_input_add(int source, GaimInputCondition cond,
97 GaimInputFunction func, gpointer user_data);
98
99 /**
100 * Removes an input handler.
101 *
102 * @param handle The handle of the input handler.
103 */
104 void gaim_input_remove(gint handle);
105
106 /*@}*/
107
108
109 /**************************************************************************/
110 /** @name UI Registration Functions */
111 /**************************************************************************/
112 /*@{*/
113 /**
114 * Sets the UI operations structure to be used for accounts.
115 *
116 * @param ops The UI operations structure.
117 */
118 void gaim_eventloop_set_ui_ops(GaimEventLoopUiOps *ops);
119
120 /**
121 * Returns the UI operations structure used for accounts.
122 *
123 * @return The UI operations structure in use.
124 */
125 GaimEventLoopUiOps *gaim_eventloop_get_ui_ops(void);
126
127 /*@}*/
128
129 #ifdef __cplusplus
130 }
131 #endif
132
133 #endif /* _GAIM_EVENTLOOP_H_ */