Mercurial > pidgin
annotate src/eventloop.h @ 8280:084ed9f7ac19
[gaim-migrate @ 9004]
Soem tweaks from Scott Lamb for the event loop code.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Tue, 17 Feb 2004 08:43:44 +0000 |
| parents | f24172f53650 |
| children | ef881489396e |
| rev | line source |
|---|---|
| 8273 | 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 */ | |
|
8280
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
60 guint (*input_add)(int fd, GaimInputCondition cond, |
|
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
61 GaimInputFunction func, gpointer user_data); |
| 8273 | 62 |
| 63 /** | |
| 64 * Removes an input handler. | |
| 65 * @see gaim_input_remove, g_source_remove | |
| 66 */ | |
|
8280
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
67 void (*input_remove)(guint handle); |
| 8273 | 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 * | |
|
8280
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
88 * @param fd The input file descriptor. |
| 8273 | 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 */ | |
|
8280
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
96 guint gaim_input_add(int fd, GaimInputCondition cond, |
|
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
97 GaimInputFunction func, gpointer user_data); |
| 8273 | 98 |
| 99 /** | |
| 100 * Removes an input handler. | |
| 101 * | |
|
8280
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
102 * @param handle The handle of the input handler. Note that this is the return |
|
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
103 * value from gaim_input_add, <i>not</i> the file descriptor. |
| 8273 | 104 */ |
|
8280
084ed9f7ac19
[gaim-migrate @ 9004]
Christian Hammond <chipx86@chipx86.com>
parents:
8273
diff
changeset
|
105 void gaim_input_remove(guint handle); |
| 8273 | 106 |
| 107 /*@}*/ | |
| 108 | |
| 109 | |
| 110 /**************************************************************************/ | |
| 111 /** @name UI Registration Functions */ | |
| 112 /**************************************************************************/ | |
| 113 /*@{*/ | |
| 114 /** | |
| 115 * Sets the UI operations structure to be used for accounts. | |
| 116 * | |
| 117 * @param ops The UI operations structure. | |
| 118 */ | |
| 119 void gaim_eventloop_set_ui_ops(GaimEventLoopUiOps *ops); | |
| 120 | |
| 121 /** | |
| 122 * Returns the UI operations structure used for accounts. | |
| 123 * | |
| 124 * @return The UI operations structure in use. | |
| 125 */ | |
| 126 GaimEventLoopUiOps *gaim_eventloop_get_ui_ops(void); | |
| 127 | |
| 128 /*@}*/ | |
| 129 | |
| 130 #ifdef __cplusplus | |
| 131 } | |
| 132 #endif | |
| 133 | |
| 134 #endif /* _GAIM_EVENTLOOP_H_ */ |
