Mercurial > pidgin
changeset 18010:1fcd21ea6780
propagate from branch 'im.pidgin.rlaager.merging.timeout_add_seconds' (head d453bd44d21c7095921f98b2652b077a3fa99754)
to branch 'im.pidgin.rlaager.merging.for_2_1_0' (head 10e2cba1751897f4a9af4add42e94b73ceb43af4)
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sun, 20 May 2007 14:05:52 +0000 |
parents | a770353e7306 (current diff) 9ffa9af32854 (diff) |
children | 3cf22b52a942 |
files | |
diffstat | 14 files changed, 81 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/finch/finch.c Sat May 19 08:31:55 2007 +0000 +++ b/finch/finch.c Sun May 20 14:05:52 2007 +0000 @@ -156,11 +156,15 @@ gnt_input_add, g_source_remove, NULL, /* input_get_error */ +#if GLIB_VERSION_CHECK(2,14,0) + g_timeout_add_seconds, +#else + NULL, +#endif /* padding */ NULL, NULL, - NULL, NULL };
--- a/libpurple/account.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/account.c Sun May 20 14:05:52 2007 +0000 @@ -417,7 +417,7 @@ schedule_accounts_save() { if (save_timer == 0) - save_timer = purple_timeout_add(5000, save_cb, NULL); + save_timer = purple_timeout_add_seconds(5, save_cb, NULL); }
--- a/libpurple/blist.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/blist.c Sun May 20 14:05:52 2007 +0000 @@ -365,7 +365,7 @@ purple_blist_schedule_save() { if (save_timer == 0) - save_timer = purple_timeout_add(5000, save_cb, NULL); + save_timer = purple_timeout_add_seconds(5, save_cb, NULL); }
--- a/libpurple/connection.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/connection.c Sun May 20 14:05:52 2007 +0000 @@ -72,7 +72,7 @@ if (on && !gc->keepalive) { purple_debug_info("connection", "Activating keepalive.\n"); - gc->keepalive = purple_timeout_add(30000, send_keepalive, gc); + gc->keepalive = purple_timeout_add_seconds(30, send_keepalive, gc); } else if (!on && gc->keepalive > 0) {
--- a/libpurple/conversation.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/conversation.c Sun May 20 14:05:52 2007 +0000 @@ -1010,7 +1010,7 @@ conv = purple_conv_im_get_conversation(im); name = purple_conversation_get_name(conv); - im->typing_timeout = purple_timeout_add(timeout * 1000, reset_typing_cb, conv); + im->typing_timeout = purple_timeout_add_seconds(timeout, reset_typing_cb, conv); } void
--- a/libpurple/eventloop.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/eventloop.c Sun May 20 14:05:52 2007 +0000 @@ -35,6 +35,17 @@ return ops->timeout_add(interval, function, data); } +guint +purple_timeout_add_seconds(guint interval, GSourceFunc function, gpointer data) +{ + PurpleEventLoopUiOps *ops = purple_eventloop_get_ui_ops(); + + if (ops->timeout_add_seconds) + return ops->timeout_add_seconds(interval, function, data); + else + return ops->timeout_add(1000 * interval, function, data); +} + gboolean purple_timeout_remove(guint tag) {
--- a/libpurple/eventloop.h Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/eventloop.h Sun May 20 14:05:52 2007 +0000 @@ -48,7 +48,7 @@ struct _PurpleEventLoopUiOps { /** - * Creates a callback timer. + * Creates a callback timer with an interval measured in milliseconds. * @see g_timeout_add, purple_timeout_add **/ guint (*timeout_add)(guint interval, GSourceFunc function, gpointer data); @@ -81,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); @@ -93,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/libpurple/example/nullclient.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/example/nullclient.c Sun May 20 14:05:52 2007 +0000 @@ -108,11 +108,15 @@ glib_input_add, g_source_remove, NULL, +#if GLIB_VERSION_CHECK(2,14,0) + g_timeout_add_seconds, +#else + NULL, +#endif /* padding */ NULL, NULL, - NULL, NULL }; /*** End of the eventloop functions. ***/
--- a/libpurple/idle.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/idle.c Sun May 20 14:05:52 2007 +0000 @@ -230,7 +230,11 @@ if (time_until_next_idle_event == 0) idle_timer = 0; else - idle_timer = purple_timeout_add(1000 * (time_until_next_idle_event + 1), check_idleness_timer, NULL); + { + /* +1 for the boundary, + * +1 more for g_timeout_add_seconds rounding. */ + idle_timer = purple_timeout_add_seconds(time_until_next_idle_event + 2, check_idleness_timer, NULL); + } return FALSE; } @@ -309,8 +313,10 @@ void purple_idle_init() { - /* Add the timer to check if we're idle */ - idle_timer = purple_timeout_add(1000 * (IDLEMARK + 1), check_idleness_timer, NULL); + /* Add the timer to check if we're idle. + * IDLEMARK + 1 as the boundary, + * +1 more for g_timeout_add_seconds rounding. */ + idle_timer = purple_timeout_add_seconds((IDLEMARK + 2), check_idleness_timer, NULL); purple_signal_connect(purple_conversations_get_handle(), "sent-im-msg", purple_idle_get_handle(),
--- a/libpurple/pounce.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/pounce.c Sun May 20 14:05:52 2007 +0000 @@ -273,7 +273,7 @@ schedule_pounces_save(void) { if (save_timer == 0) - save_timer = purple_timeout_add(5000, save_cb, NULL); + save_timer = purple_timeout_add_seconds(5, save_cb, NULL); }
--- a/libpurple/prefs.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/prefs.c Sun May 20 14:05:52 2007 +0000 @@ -226,7 +226,7 @@ schedule_prefs_save(void) { if (save_timer == 0) - save_timer = purple_timeout_add(5000, save_cb, NULL); + save_timer = purple_timeout_add_seconds(5, save_cb, NULL); }
--- a/libpurple/savedstatuses.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/savedstatuses.c Sun May 20 14:05:52 2007 +0000 @@ -357,7 +357,7 @@ schedule_save(void) { if (save_timer == 0) - save_timer = purple_timeout_add(5000, save_cb, NULL); + save_timer = purple_timeout_add_seconds(5, save_cb, NULL); }
--- a/libpurple/server.c Sat May 19 08:31:55 2007 +0000 +++ b/libpurple/server.c Sun May 20 14:05:52 2007 +0000 @@ -92,7 +92,7 @@ /* because we're modifying or creating a lar, schedule the * function to expire them as the pref dictates */ - purple_timeout_add((SECS_BEFORE_RESENDING_AUTORESPONSE + 1) * 1000, expire_last_auto_responses, NULL); + purple_timeout_add_seconds((SECS_BEFORE_RESENDING_AUTORESPONSE + 1), expire_last_auto_responses, NULL); tmp = last_auto_responses;