Mon, 18 Aug 2003 10:08:26 +0000
[gaim-migrate @ 7002]
Some documentation updates. Really nothing great.
| 6485 | 1 | /** |
|
6488
6a47a95e4dbb
[gaim-migrate @ 7002]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
2 | * @file signals.h Signal API |
| 6485 | 3 | * @ingroup core |
| 4 | * | |
| 5 | * gaim | |
| 6 | * | |
| 7 | * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org> | |
| 8 | * | |
| 9 | * This program is free software; you can redistribute it and/or modify | |
| 10 | * it under the terms of the GNU General Public License as published by | |
| 11 | * the Free Software Foundation; either version 2 of the License, or | |
| 12 | * (at your option) any later version. | |
| 13 | * | |
| 14 | * This program is distributed in the hope that it will be useful, | |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 | * GNU General Public License for more details. | |
| 18 | * | |
| 19 | * You should have received a copy of the GNU General Public License | |
| 20 | * along with this program; if not, write to the Free Software | |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 22 | */ | |
| 23 | #ifndef _GAIM_SIGNAL_H_ | |
| 24 | #define _GAIM_SIGNAL_H_ | |
| 25 | ||
| 26 | #include <glib.h> | |
| 27 | ||
| 28 | #if 0 | |
| 29 | /** | |
| 30 | * Event types | |
| 31 | */ | |
| 32 | typedef enum gaim_event | |
| 33 | { | |
| 34 | event_signon = 0, | |
| 35 | event_signoff, | |
| 36 | event_away, | |
| 37 | event_back, | |
| 38 | event_im_recv, | |
| 39 | event_im_send, | |
| 40 | event_buddy_signon, | |
| 41 | event_buddy_signoff, | |
| 42 | event_buddy_away, | |
| 43 | event_buddy_back, | |
| 44 | event_buddy_idle, | |
| 45 | event_buddy_unidle, | |
| 46 | event_blist_update, | |
| 47 | event_chat_invited, | |
| 48 | event_chat_join, | |
| 49 | event_chat_leave, | |
| 50 | event_chat_buddy_join, | |
| 51 | event_chat_buddy_leave, | |
| 52 | event_chat_recv, | |
| 53 | event_chat_send, | |
| 54 | event_warned, | |
| 55 | event_error, | |
| 56 | event_quit, | |
| 57 | event_new_conversation, | |
| 58 | event_set_info, | |
| 59 | event_draw_menu, | |
| 60 | event_im_displayed_sent, | |
| 61 | event_im_displayed_rcvd, | |
| 62 | event_chat_send_invite, | |
| 63 | event_got_typing, | |
| 64 | event_del_conversation, | |
| 65 | event_connecting, | |
| 66 | event_conversation_switch | |
| 67 | /* any others? it's easy to add... */ | |
| 68 | ||
| 69 | } GaimEvent; | |
| 70 | ||
| 71 | typedef int (*GaimSignalBroadcastFunc)(GaimEvent event, void *data, | |
| 72 | va_list args); | |
| 73 | #endif | |
| 74 | ||
| 75 | #define GAIM_CALLBACK(func) ((GaimCallback)func) | |
| 76 | ||
| 77 | typedef void (*GaimCallback)(void); | |
| 78 | typedef void (*GaimSignalMarshalFunc)(GaimCallback cb, va_list args, | |
| 79 | void *data, void **return_val); | |
| 80 | ||
| 81 | #ifdef __cplusplus | |
| 82 | extern "C" { | |
| 83 | #endif | |
| 84 | ||
| 85 | /**************************************************************************/ | |
| 86 | /** @name Signal API */ | |
| 87 | /**************************************************************************/ | |
| 88 | /*@{*/ | |
| 89 | ||
| 90 | /** | |
| 91 | * Registers a signal in an instance. | |
| 92 | * | |
| 93 | * @param instance The instance to register the signal for. | |
| 94 | * @param signal The signal name. | |
| 95 | * @param marshal The marshal function. | |
| 96 | * | |
| 97 | * @return The signal ID local to that instance, or 0 if the signal | |
| 98 | * couldn't be registered. | |
| 99 | */ | |
| 100 | gulong gaim_signal_register(void *instance, const char *signal, | |
| 101 | GaimSignalMarshalFunc marshal); | |
| 102 | ||
| 103 | /** | |
| 104 | * Unregisters a signal in an instance. | |
| 105 | * | |
| 106 | * @param instance The instance to unregister the signal for. | |
| 107 | * @param signal The signal name. | |
| 108 | */ | |
| 109 | void gaim_signal_unregister(void *instance, const char *signal); | |
| 110 | ||
| 111 | /** | |
| 112 | * Unregisters all signals in an instance. | |
| 113 | * | |
| 114 | * @param instance The instance to unregister the signal for. | |
| 115 | */ | |
| 116 | void gaim_signals_unregister_by_instance(void *instance); | |
| 117 | ||
| 118 | /** | |
| 119 | * Connects a signal handler to a signal for a particular object. | |
| 120 | * | |
| 121 | * Take care not to register a handler function twice. Gaim will | |
| 122 | * not correct any mistakes for you in this area. | |
| 123 | * | |
| 124 | * @param instance The instance to connect to. | |
| 125 | * @param signal The name of the signal to connect. | |
| 126 | * @param handle The handle of the receiver. | |
| 127 | * @param func The callback function. | |
| 128 | * @param data The data to pass to the callback function. | |
| 129 | * | |
| 130 | * @return The signal handler ID. | |
| 131 | * | |
| 132 | * @see gaim_signal_disconnect() | |
| 133 | */ | |
| 134 | gulong gaim_signal_connect(void *instance, const char *signal, | |
| 135 | void *handle, GaimCallback func, void *data); | |
| 136 | ||
| 137 | /** | |
| 138 | * Disconnects a signal handler from a signal on an object. | |
| 139 | * | |
| 140 | * @param instance The instance to disconnect from. | |
| 141 | * @param signal The name of the signal to disconnect. | |
| 142 | * @param handle The handle of the receiver. | |
| 143 | * @param func The registered function to disconnect. | |
| 144 | * | |
| 145 | * @see gaim_signal_connect() | |
| 146 | */ | |
| 147 | void gaim_signal_disconnect(void *instance, const char *signal, | |
| 148 | void *handle, GaimCallback func); | |
| 149 | ||
| 150 | /** | |
| 151 | * Removes all callbacks associated with a receiver handle. | |
| 152 | * | |
| 153 | * @param handle The receiver handle. | |
| 154 | */ | |
| 155 | void gaim_signals_disconnect_by_handle(void *handle); | |
| 156 | ||
| 157 | /** | |
| 158 | * Emits a signal. | |
| 159 | * | |
| 160 | * @param instance The instance emitting the signal. | |
| 161 | * @param signal The signal being emitted. | |
| 162 | * | |
| 163 | * @see gaim_signal_connect() | |
| 164 | * @see gaim_signal_disconnect() | |
| 165 | */ | |
| 166 | void gaim_signal_emit(void *instance, const char *signal, ...); | |
| 167 | ||
| 168 | /** | |
| 169 | * Emits a signal, using a va_list of arguments. | |
| 170 | * | |
| 171 | * @param instance The instance emitting the signal. | |
| 172 | * @param signal The signal being emitted. | |
| 173 | * @param args The arguments list. | |
| 174 | * | |
| 175 | * @see gaim_signal_connect() | |
| 176 | * @see gaim_signal_disconnect() | |
| 177 | */ | |
| 178 | void gaim_signal_emit_vargs(void *instance, const char *signal, va_list args); | |
| 179 | ||
| 180 | /** | |
| 181 | * Emits a signal and returns the return value from the last handler. | |
| 182 | * | |
| 183 | * @param instance The instance emitting the signal. | |
| 184 | * @param signal The signal being emitted. | |
| 185 | * | |
| 186 | * @return The return value from the last handler. | |
| 187 | */ | |
| 188 | void *gaim_signal_emit_return_1(void *instance, const char *signal, ...); | |
| 189 | ||
| 190 | /** | |
| 191 | * Emits a signal and returns the return value from the last handler. | |
| 192 | * | |
| 193 | * @param instance The instance emitting the signal. | |
| 194 | * @param signal The signal being emitted. | |
| 195 | * @param args The arguments list. | |
| 196 | * | |
| 197 | * @return The return value from the last handler. | |
| 198 | */ | |
| 199 | void *gaim_signal_emit_vargs_return_1(void *instance, const char *signal, | |
| 200 | va_list args); | |
| 201 | ||
| 202 | /** | |
| 203 | * Initializes the signals subsystem. | |
| 204 | */ | |
| 205 | void gaim_signals_init(); | |
| 206 | ||
| 207 | /** | |
| 208 | * Uninitializes the signals subsystem. | |
| 209 | */ | |
| 210 | void gaim_signals_uninit(); | |
| 211 | ||
| 212 | /*@}*/ | |
| 213 | ||
| 214 | /**************************************************************************/ | |
| 215 | /** @name Marshal Functions */ | |
| 216 | /**************************************************************************/ | |
| 217 | /*@{*/ | |
| 218 | ||
| 219 | void gaim_marshal_VOID( | |
| 220 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 221 | void gaim_marshal_VOID__POINTER( | |
| 222 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 223 | void gaim_marshal_VOID__POINTER_POINTER( | |
| 224 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 225 | void gaim_marshal_VOID__POINTER_POINTER_UINT( | |
| 226 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 227 | void gaim_marshal_VOID__POINTER_POINTER_POINTER( | |
| 228 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 229 | void gaim_marshal_VOID__POINTER_POINTER_POINTER_POINTER( | |
| 230 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 231 | void gaim_marshal_VOID__POINTER_POINTER_POINTER_UINT_UINT( | |
| 232 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 233 | ||
| 234 | void gaim_marshal_BOOLEAN__POINTER( | |
| 235 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 236 | void gaim_marshal_BOOLEAN__POINTER_POINTER( | |
| 237 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 238 | void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_UINT( | |
| 239 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 240 | void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER( | |
| 241 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 242 | void gaim_marshal_BOOLEAN__POINTER_POINTER_POINTER_POINTER_POINTER( | |
| 243 | GaimCallback cb, va_list args, void *data, void **return_val); | |
| 244 | ||
| 245 | /*@}*/ | |
| 246 | ||
| 247 | #ifdef __cplusplus | |
| 248 | } | |
| 249 | #endif | |
| 250 | ||
| 251 | #endif /* _GAIM_SIGNAL_H_ */ |