changeset 18008:f22986db6e70

Wire everything up and document it.
author Richard Laager <rlaager@wiktel.com>
date Sun, 20 May 2007 13:56:28 +0000
parents a8b4444f2515
children 9ffa9af32854
files libpurple/eventloop.c libpurple/eventloop.h pidgin/gtkeventloop.c
diffstat 3 files changed, 44 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/eventloop.c	Sun May 20 13:48:45 2007 +0000
+++ b/libpurple/eventloop.c	Sun May 20 13:56:28 2007 +0000
@@ -36,9 +36,9 @@
 }
 
 guint
-gaim_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
+purple_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data)
 {
-	GaimEventLoopUiOps *ops = gaim_eventloop_get_ui_ops();
+	PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops();
 
 	if (ops->timeout_add_seconds)
 		return ops->timeout_add_seconds(interval, function, data);
--- a/libpurple/eventloop.h	Sun May 20 13:48:45 2007 +0000
+++ b/libpurple/eventloop.h	Sun May 20 13:56:28 2007 +0000
@@ -54,12 +54,6 @@
 	guint (*timeout_add)(guint interval, GSourceFunc function, gpointer data);
 
 	/**
-	 * Creates a callback timer with an interval measured in seconds.
-	 * @see g_timeout_add_seconds, purple_timeout_add_seconds
-	 **/
-	guint (*timeout_add_seconds)(guint interval, GSourceFunc function, gpointer data);
-
-	/**
 	 * Removes a callback timer.
 	 * @see purple_timeout_remove, g_source_remove
 	 */
@@ -87,7 +81,20 @@
 	 */
 	int (*input_get_error)(int fd, int *error);
 
-	void (*_purple_reserved1)(void);
+	/**
+	 * Creates a callback timer with an interval measured in seconds.
+	 *
+	 * This allows UIs to group timers for better power efficiency.  For
+	 * this reason, @a interval may be rounded by up to a second.
+	 *
+	 * Implementation of this UI op is optional.  If it's not implemented,
+	 * calls to purple_timeout_add_seconds() will be serviced by the
+	 * timeout_add UI op.
+	 *
+	 * @see g_timeout_add_seconds, purple_timeout_add_seconds()
+	 **/
+	guint (*timeout_add_seconds)(guint interval, GSourceFunc function, gpointer data);
+
 	void (*_purple_reserved2)(void);
 	void (*_purple_reserved3)(void);
 	void (*_purple_reserved4)(void);
@@ -99,10 +106,33 @@
 /*@{*/
 /**
  * Creates a callback timer.
+ * 
  * The timer will repeat until the function returns @c FALSE. The
  * first call will be at the end of the first interval.
+ *
+ * If the timer is in a multiple of seconds, use purple_timeout_add_seconds()
+ * instead as it allows UIs to group timers for power efficiency.
+ *
  * @param interval	The time between calls of the function, in
- *					milliseconds.
+ *                      milliseconds.
+ * @param function	The function to call.
+ * @param data		data to pass to @a function.
+ * @return A handle to the timer which can be passed to 
+ *         purple_timeout_remove to remove the timer.
+ */
+guint purple_timeout_add(guint interval, GSourceFunc function, gpointer data);
+
+/**
+ * Creates a callback timer.
+ *
+ * The timer will repeat until the function returns @c FALSE. The
+ * first call will be at the end of the first interval.
+ *
+ * This function allows UIs to group timers for better power efficiency.  For
+ * this reason, @a interval may be rounded by up to a second.
+ * 
+ * @param interval	The time between calls of the function, in
+ *                      seconds.
  * @param function	The function to call.
  * @param data		data to pass to @a function.
  * @return A handle to the timer which can be passed to 
--- a/pidgin/gtkeventloop.c	Sun May 20 13:48:45 2007 +0000
+++ b/pidgin/gtkeventloop.c	Sun May 20 13:56:28 2007 +0000
@@ -116,12 +116,15 @@
 static PurpleEventLoopUiOps eventloop_ops =
 {
 	g_timeout_add,
-	NULL,
 	g_source_remove,
 	pidgin_input_add,
 	g_source_remove,
 	NULL, /* input_get_error */
+#if GLIB_VERSION_CHECK(2,14,0)
+	g_timeout_add_seconds,
+#else
 	NULL,
+#endif
 	NULL,
 	NULL,
 	NULL