Frameworks/libpurple.framework/Versions/0.6.0/Headers/eventloop.h
changeset 2592 e8d15275025e
parent 2591 f66a716bfc79
child 2593 b4bd28402abc
     1.1 --- a/Frameworks/libpurple.framework/Versions/0.6.0/Headers/eventloop.h	Fri Aug 21 13:24:36 2009 -0700
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,276 +0,0 @@
     1.4 -/**
     1.5 - * @file eventloop.h Purple Event Loop API
     1.6 - * @ingroup core
     1.7 - */
     1.8 -
     1.9 -/* purple
    1.10 - *
    1.11 - * Purple is the legal property of its developers, whose names are too numerous
    1.12 - * to list here.  Please refer to the COPYRIGHT file distributed with this
    1.13 - * source distribution.
    1.14 - *
    1.15 - * This program is free software; you can redistribute it and/or modify
    1.16 - * it under the terms of the GNU General Public License as published by
    1.17 - * the Free Software Foundation; either version 2 of the License, or
    1.18 - * (at your option) any later version.
    1.19 - *
    1.20 - * This program is distributed in the hope that it will be useful,
    1.21 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.22 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.23 - * GNU General Public License for more details.
    1.24 - *
    1.25 - * You should have received a copy of the GNU General Public License
    1.26 - * along with this program; if not, write to the Free Software
    1.27 - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    1.28 - */
    1.29 -#ifndef _PURPLE_EVENTLOOP_H_
    1.30 -#define _PURPLE_EVENTLOOP_H_
    1.31 -
    1.32 -#include <glib.h>
    1.33 -
    1.34 -#ifdef __cplusplus
    1.35 -extern "C" {
    1.36 -#endif
    1.37 -
    1.38 -/**
    1.39 - * An input condition.
    1.40 - */
    1.41 -typedef enum
    1.42 -{
    1.43 -	PURPLE_INPUT_READ  = 1 << 0,  /**< A read condition.  */
    1.44 -	PURPLE_INPUT_WRITE = 1 << 1   /**< A write condition. */
    1.45 -
    1.46 -} PurpleInputCondition;
    1.47 -
    1.48 -/** The type of callbacks to handle events on file descriptors, as passed to
    1.49 - *  purple_input_add().  The callback will receive the @c user_data passed to
    1.50 - *  purple_input_add(), the file descriptor on which the event occurred, and the
    1.51 - *  condition that was satisfied to cause the callback to be invoked.
    1.52 - */
    1.53 -typedef void (*PurpleInputFunction)(gpointer, gint, PurpleInputCondition);
    1.54 -
    1.55 -/** @copydoc _PurpleEventLoopUiOps */
    1.56 -typedef struct _PurpleEventLoopUiOps PurpleEventLoopUiOps;
    1.57 -
    1.58 -/** An abstraction of an application's mainloop; libpurple will use this to
    1.59 - *  watch file descriptors and schedule timed callbacks.  If your application
    1.60 - *  uses the glib mainloop, there is an implementation of this struct in
    1.61 - *  <tt>libpurple/example/nullclient.c</tt> which you can use verbatim.
    1.62 - */
    1.63 -struct _PurpleEventLoopUiOps
    1.64 -{
    1.65 -	/**
    1.66 -	 * Should create a callback timer with an interval measured in
    1.67 -	 * milliseconds.  The supplied @a function should be called every @a
    1.68 -	 * interval seconds until it returns @c FALSE, after which it should not
    1.69 -	 * be called again.
    1.70 -	 *
    1.71 -	 * Analogous to g_timeout_add in glib.
    1.72 -	 *
    1.73 -	 * Note: On Win32, this function may be called from a thread other than
    1.74 -	 * the libpurple thread.  You should make sure to detect this situation
    1.75 -	 * and to only call "function" from the libpurple thread.
    1.76 -	 *
    1.77 -	 * @param interval the interval in <em>milliseconds</em> between calls
    1.78 -	 *                 to @a function.
    1.79 -	 * @param data     arbitrary data to be passed to @a function at each
    1.80 -	 *                 call.
    1.81 -	 * @todo Who is responsible for freeing @a data?
    1.82 -	 *
    1.83 -	 * @return a handle for the timeout, which can be passed to
    1.84 -	 *         #timeout_remove.
    1.85 -	 *
    1.86 -	 * @see purple_timeout_add
    1.87 -	 **/
    1.88 -	guint (*timeout_add)(guint interval, GSourceFunc function, gpointer data);
    1.89 -
    1.90 -	/**
    1.91 -	 * Should remove a callback timer.  Analogous to g_source_remove in glib.
    1.92 -	 * @param handle an identifier for a timeout, as returned by
    1.93 -	 *               #timeout_add.
    1.94 -	 * @return       @c TRUE if the timeout identified by @a handle was
    1.95 -	 *               found and removed.
    1.96 -	 * @see purple_timeout_remove
    1.97 -	 */
    1.98 -	gboolean (*timeout_remove)(guint handle);
    1.99 -
   1.100 -	/**
   1.101 -	 * Should add an input handler.  Analogous to g_io_add_watch_full in
   1.102 -	 * glib.
   1.103 -	 *
   1.104 -	 * @param fd        a file descriptor to watch for events
   1.105 -	 * @param cond      a bitwise OR of events on @a fd for which @a func
   1.106 -	 *                  should be called.
   1.107 -	 * @param func      a callback to fire whenever a relevant event on @a
   1.108 -	 *                  fd occurs.
   1.109 -	 * @param user_data arbitrary data to pass to @a fd.
   1.110 -	 * @return          an identifier for this input handler, which can be
   1.111 -	 *                  passed to #input_remove.
   1.112 -	 *
   1.113 -	 * @see purple_input_add
   1.114 -	 */
   1.115 -	guint (*input_add)(int fd, PurpleInputCondition cond,
   1.116 -	                   PurpleInputFunction func, gpointer user_data);
   1.117 -
   1.118 -	/**
   1.119 -	 * Should remove an input handler.  Analogous to g_source_remove in glib.
   1.120 -	 * @param handle an identifier, as returned by #input_add.
   1.121 -	 * @return       @c TRUE if the input handler was found and removed.
   1.122 -	 * @see purple_input_remove
   1.123 -	 */
   1.124 -	gboolean (*input_remove)(guint handle);
   1.125 -
   1.126 -
   1.127 -	/**
   1.128 -	 * If implemented, should get the current error status for an input.
   1.129 -	 *
   1.130 -	 * Implementation of this UI op is optional. Implement it if the UI's
   1.131 -	 * sockets or event loop needs to customize determination of socket
   1.132 -	 * error status.  If unimplemented, <tt>getsockopt(2)</tt> will be used
   1.133 -	 * instead.
   1.134 -	 *
   1.135 -	 * @see purple_input_get_error
   1.136 -	 */
   1.137 -	int (*input_get_error)(int fd, int *error);
   1.138 -
   1.139 -	/**
   1.140 -	 * If implemented, should create a callback timer with an interval
   1.141 -	 * measured in seconds.  Analogous to g_timeout_add_seconds in glib.
   1.142 -	 *
   1.143 -	 * This allows UIs to group timers for better power efficiency.  For
   1.144 -	 * this reason, @a interval may be rounded by up to a second.
   1.145 -	 *
   1.146 -	 * Implementation of this UI op is optional.  If it's not implemented,
   1.147 -	 * calls to purple_timeout_add_seconds() will be serviced by
   1.148 -	 * #timeout_add.
   1.149 -	 *
   1.150 -	 * @see purple_timeout_add_seconds()
   1.151 -	 * @since 2.1.0
   1.152 -	 **/
   1.153 -	guint (*timeout_add_seconds)(guint interval, GSourceFunc function,
   1.154 -	                             gpointer data);
   1.155 -
   1.156 -	void (*_purple_reserved2)(void);
   1.157 -	void (*_purple_reserved3)(void);
   1.158 -	void (*_purple_reserved4)(void);
   1.159 -};
   1.160 -
   1.161 -/**************************************************************************/
   1.162 -/** @name Event Loop API                                                  */
   1.163 -/**************************************************************************/
   1.164 -/*@{*/
   1.165 -/**
   1.166 - * Creates a callback timer.
   1.167 - *
   1.168 - * The timer will repeat until the function returns @c FALSE. The
   1.169 - * first call will be at the end of the first interval.
   1.170 - *
   1.171 - * If the timer is in a multiple of seconds, use purple_timeout_add_seconds()
   1.172 - * instead as it allows UIs to group timers for power efficiency.
   1.173 - *
   1.174 - * @param interval	The time between calls of the function, in
   1.175 - *                      milliseconds.
   1.176 - * @param function	The function to call.
   1.177 - * @param data		data to pass to @a function.
   1.178 - * @return A handle to the timer which can be passed to
   1.179 - *         purple_timeout_remove() to remove the timer.
   1.180 - */
   1.181 -guint purple_timeout_add(guint interval, GSourceFunc function, gpointer data);
   1.182 -
   1.183 -/**
   1.184 - * Creates a callback timer.
   1.185 - *
   1.186 - * The timer will repeat until the function returns @c FALSE. The
   1.187 - * first call will be at the end of the first interval.
   1.188 - *
   1.189 - * This function allows UIs to group timers for better power efficiency.  For
   1.190 - * this reason, @a interval may be rounded by up to a second.
   1.191 - *
   1.192 - * @param interval	The time between calls of the function, in
   1.193 - *                      seconds.
   1.194 - * @param function	The function to call.
   1.195 - * @param data		data to pass to @a function.
   1.196 - * @return A handle to the timer which can be passed to
   1.197 - *         purple_timeout_remove() to remove the timer.
   1.198 - *
   1.199 - * @since 2.1.0
   1.200 - */
   1.201 -guint purple_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data);
   1.202 -
   1.203 -/**
   1.204 - * Removes a timeout handler.
   1.205 - *
   1.206 - * @param handle The handle, as returned by purple_timeout_add().
   1.207 - *
   1.208 - * @return @c TRUE if the handler was successfully removed.
   1.209 - */
   1.210 -gboolean purple_timeout_remove(guint handle);
   1.211 -
   1.212 -/**
   1.213 - * Adds an input handler.
   1.214 - *
   1.215 - * @param fd        The input file descriptor.
   1.216 - * @param cond      The condition type.
   1.217 - * @param func      The callback function for data.
   1.218 - * @param user_data User-specified data.
   1.219 - *
   1.220 - * @return The resulting handle (will be greater than 0).
   1.221 - * @see g_io_add_watch_full
   1.222 - */
   1.223 -guint purple_input_add(int fd, PurpleInputCondition cond,
   1.224 -                       PurpleInputFunction func, gpointer user_data);
   1.225 -
   1.226 -/**
   1.227 - * Removes an input handler.
   1.228 - *
   1.229 - * @param handle The handle of the input handler. Note that this is the return
   1.230 - *               value from purple_input_add(), <i>not</i> the file descriptor.
   1.231 - */
   1.232 -gboolean purple_input_remove(guint handle);
   1.233 -
   1.234 -/**
   1.235 - * Get the current error status for an input.
   1.236 - *
   1.237 - * The return value and error follow getsockopt() with a level of SOL_SOCKET and an
   1.238 - * option name of SO_ERROR, and this is how the error is determined if the UI does not
   1.239 - * implement the input_get_error UI op.
   1.240 - *
   1.241 - * @param fd        The input file descriptor.
   1.242 - * @param error     A pointer to an @c int which on return will have the error, or
   1.243 - *                  @c 0 if no error.
   1.244 - *
   1.245 - * @return @c 0 if there is no error; @c -1 if there is an error, in which case
   1.246 - *         @a errno will be set.
   1.247 - */
   1.248 -int
   1.249 -purple_input_get_error(int fd, int *error);
   1.250 -
   1.251 -
   1.252 -/*@}*/
   1.253 -
   1.254 -
   1.255 -/**************************************************************************/
   1.256 -/** @name UI Registration Functions                                       */
   1.257 -/**************************************************************************/
   1.258 -/*@{*/
   1.259 -/**
   1.260 - * Sets the UI operations structure to be used for accounts.
   1.261 - *
   1.262 - * @param ops The UI operations structure.
   1.263 - */
   1.264 -void purple_eventloop_set_ui_ops(PurpleEventLoopUiOps *ops);
   1.265 -
   1.266 -/**
   1.267 - * Returns the UI operations structure used for accounts.
   1.268 - *
   1.269 - * @return The UI operations structure in use.
   1.270 - */
   1.271 -PurpleEventLoopUiOps *purple_eventloop_get_ui_ops(void);
   1.272 -
   1.273 -/*@}*/
   1.274 -
   1.275 -#ifdef __cplusplus
   1.276 -}
   1.277 -#endif
   1.278 -
   1.279 -#endif /* _PURPLE_EVENTLOOP_H_ */