# HG changeset patch # User foss@abala.me # Date 1239344288 0 # Node ID b87843de7c6ad7741fb1936e891de149c9d10200 # Parent 8a0797f40695827e83c1d03c27b9905df894d324 A patch from Arunan Balasubramaniam to use timeouts in seconds instead of milliseconds in libpurple. This enables grouping of timers for greater power efficiency. Fixes #8875. committer: Elliott Sales de Andrade diff -r 8a0797f40695 -r b87843de7c6a libpurple/conversation.c --- a/libpurple/conversation.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/conversation.c Fri Apr 10 06:18:08 2009 +0000 @@ -33,7 +33,7 @@ #include "signals.h" #include "util.h" -#define SEND_TYPED_TIMEOUT 5000 +#define SEND_TYPED_TIMEOUT_SECONDS 5 static GList *conversations = NULL; static GList *ims = NULL; @@ -1122,8 +1122,9 @@ { g_return_if_fail(im != NULL); - im->send_typed_timeout = purple_timeout_add(SEND_TYPED_TIMEOUT, send_typed_cb, - purple_conv_im_get_conversation(im)); + im->send_typed_timeout = purple_timeout_add_seconds(SEND_TYPED_TIMEOUT_SECONDS, + send_typed_cb, + purple_conv_im_get_conversation(im)); } void diff -r 8a0797f40695 -r b87843de7c6a libpurple/plugins/filectl.c --- a/libpurple/plugins/filectl.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/plugins/filectl.c Fri Apr 10 06:18:08 2009 +0000 @@ -220,7 +220,7 @@ plugin_load(PurplePlugin *plugin) { init_file(); - check = purple_timeout_add(5000, (GSourceFunc)check_file, NULL); + check = purple_timeout_add_seconds(5, (GSourceFunc)check_file, NULL); return TRUE; } diff -r 8a0797f40695 -r b87843de7c6a libpurple/plugins/joinpart.c --- a/libpurple/plugins/joinpart.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/plugins/joinpart.c Fri Apr 10 06:18:08 2009 +0000 @@ -194,7 +194,7 @@ PURPLE_CALLBACK(received_chat_msg_cb), users); /* Cleanup every 5 minutes */ - id = purple_timeout_add(1000 * 60 * 5, (GSourceFunc)clean_users_hash, users); + id = purple_timeout_add_seconds(60 * 5, (GSourceFunc)clean_users_hash, users); data = g_new(gpointer, 2); data[0] = users; diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/irc/msgs.c --- a/libpurple/protocols/irc/msgs.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/irc/msgs.c Fri Apr 10 06:18:08 2009 +0000 @@ -128,7 +128,7 @@ irc_blist_timeout(irc); if (!irc->timer) - irc->timer = purple_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc); + irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc); } void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/jabber/buddy.c --- a/libpurple/protocols/jabber/buddy.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/jabber/buddy.c Fri Apr 10 06:18:08 2009 +0000 @@ -1866,7 +1866,7 @@ } js->pending_buddy_info_requests = g_slist_prepend(js->pending_buddy_info_requests, jbi); - jbi->timeout_handle = purple_timeout_add(30000, jabber_buddy_get_info_timeout, jbi); + jbi->timeout_handle = purple_timeout_add_seconds(30, jabber_buddy_get_info_timeout, jbi); } void jabber_buddy_get_info(PurpleConnection *gc, const char *who) diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/msnp9/httpconn.c --- a/libpurple/protocols/msnp9/httpconn.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/msnp9/httpconn.c Fri Apr 10 06:18:08 2009 +0000 @@ -703,7 +703,7 @@ httpconn->inpa = purple_input_add(httpconn->fd, PURPLE_INPUT_READ, read_cb, data); - httpconn->timer = purple_timeout_add(2000, msn_httpconn_poll, httpconn); + httpconn->timer = purple_timeout_add_seconds(3, msn_httpconn_poll, httpconn); msn_httpconn_process_queue(httpconn); } diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/msnp9/slp.c --- a/libpurple/protocols/msnp9/slp.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/msnp9/slp.c Fri Apr 10 06:18:08 2009 +0000 @@ -33,8 +33,8 @@ #include "smiley.h" -/* ms to delay between sending buddy icon requests to the server. */ -#define BUDDY_ICON_DELAY 20000 +/* Seconds to delay between sending buddy icon requests to the server. */ +#define BUDDY_ICON_DELAY 20 static void send_ok(MsnSlpCall *slpcall, const char *branch, const char *type, const char *content); @@ -1058,8 +1058,8 @@ purple_timeout_remove(userlist->buddy_icon_request_timer); } - /* Wait BUDDY_ICON_DELAY ms before freeing our window slot and requesting the next icon. */ - userlist->buddy_icon_request_timer = purple_timeout_add(BUDDY_ICON_DELAY, + /* Wait BUDDY_ICON_DELAY_S seconds before freeing our window slot and requesting the next icon. */ + userlist->buddy_icon_request_timer = purple_timeout_add_seconds(BUDDY_ICON_DELAY, msn_release_buddy_icon_request_timeout, userlist); } diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/msnp9/slpcall.c --- a/libpurple/protocols/msnp9/slpcall.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/msnp9/slpcall.c Fri Apr 10 06:18:08 2009 +0000 @@ -68,7 +68,7 @@ msn_slplink_add_slpcall(slplink, slpcall); - slpcall->timer = purple_timeout_add(MSN_SLPCALL_TIMEOUT, msn_slp_call_timeout, slpcall); + slpcall->timer = purple_timeout_add_seconds(MSN_SLPCALL_TIMEOUT, msn_slp_call_timeout, slpcall); return slpcall; } diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/msnp9/slpcall.h --- a/libpurple/protocols/msnp9/slpcall.h Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/msnp9/slpcall.h Fri Apr 10 06:18:08 2009 +0000 @@ -33,7 +33,7 @@ #include "slpsession.h" /* The official client seems to timeout slp calls after 5 minutes */ -#define MSN_SLPCALL_TIMEOUT 300000 +#define MSN_SLPCALL_TIMEOUT 300 typedef enum { diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/msnp9/transaction.c --- a/libpurple/protocols/msnp9/transaction.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/msnp9/transaction.c Fri Apr 10 06:18:08 2009 +0000 @@ -211,7 +211,7 @@ purple_timeout_remove(trans->timer); } trans->timeout_cb = cb; - trans->timer = purple_timeout_add(60000, transaction_timeout, trans); + trans->timer = purple_timeout_add_seconds(60, transaction_timeout, trans); } void diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/myspace/myspace.c --- a/libpurple/protocols/myspace/myspace.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/myspace/myspace.c Fri Apr 10 06:18:08 2009 +0000 @@ -1245,7 +1245,7 @@ /* Disable due to problems with timeouts. TODO: fix. */ #ifdef MSIM_USE_KEEPALIVE - purple_timeout_add(MSIM_KEEPALIVE_INTERVAL_CHECK, + purple_timeout_add_seconds(MSIM_KEEPALIVE_INTERVAL_CHECK, (GSourceFunc)msim_check_alive, session); #endif diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/myspace/myspace.h --- a/libpurple/protocols/myspace/myspace.h Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/myspace/myspace.h Fri Apr 10 06:18:08 2009 +0000 @@ -114,8 +114,8 @@ #define MSIM_KEEPALIVE_INTERVAL (3 * 60) /*#define MSIM_USE_KEEPALIVE*/ -/* Time to check if alive (milliseconds) */ -#define MSIM_KEEPALIVE_INTERVAL_CHECK (30 * 1000) +/* Time to check if alive (seconds) */ +#define MSIM_KEEPALIVE_INTERVAL_CHECK 30 /* Time to check for new mail (milliseconds) */ #define MSIM_MAIL_INTERVAL_CHECK (60 * 1000) diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/oscar/oscar.c --- a/libpurple/protocols/oscar/oscar.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/oscar/oscar.c Fri Apr 10 06:18:08 2009 +0000 @@ -1268,7 +1268,7 @@ aim_ssi_reqdata(od); if (od->getblisttimer > 0) purple_timeout_remove(od->getblisttimer); - od->getblisttimer = purple_timeout_add(30000, purple_ssi_rerequestdata, od); + od->getblisttimer = purple_timeout_add_seconds(30, purple_ssi_rerequestdata, od); aim_locate_reqrights(od); aim_buddylist_reqrights(od, conn); @@ -5047,7 +5047,7 @@ _("The AIM servers were temporarily unable to send " "your buddy list. Your buddy list is not lost, and " "will probably become available in a few minutes.")); - od->getblisttimer = purple_timeout_add(30000, purple_ssi_rerequestdata, od); + od->getblisttimer = purple_timeout_add_seconds(30, purple_ssi_rerequestdata, od); return 1; } diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/oscar/peer.c --- a/libpurple/protocols/oscar/peer.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/oscar/peer.c Fri Apr 10 06:18:08 2009 +0000 @@ -812,7 +812,7 @@ (conn->client_connect_data != NULL)) { /* Connecting... */ - conn->connect_timeout_timer = purple_timeout_add(5000, + conn->connect_timeout_timer = purple_timeout_add_seconds(5, peer_connection_tooktoolong, conn); return; } diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/sametime/sametime.c --- a/libpurple/protocols/sametime/sametime.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/sametime/sametime.c Fri Apr 10 06:18:08 2009 +0000 @@ -808,7 +808,7 @@ static void blist_schedule(struct mwPurplePluginData *pd) { if(pd->save_event) return; - pd->save_event = purple_timeout_add(BLIST_SAVE_SECONDS * 1000, + pd->save_event = purple_timeout_add_seconds(BLIST_SAVE_SECONDS, blist_save_cb, pd); } diff -r 8a0797f40695 -r b87843de7c6a libpurple/protocols/zephyr/zephyr.c --- a/libpurple/protocols/zephyr/zephyr.c Fri Apr 10 05:57:23 2009 +0000 +++ b/libpurple/protocols/zephyr/zephyr.c Fri Apr 10 06:18:08 2009 +0000 @@ -1880,7 +1880,7 @@ } else if (use_tzc(zephyr)) { zephyr->nottimer = purple_timeout_add(100, check_notify_tzc, gc); } - zephyr->loctimer = purple_timeout_add(20000, check_loc, gc); + zephyr->loctimer = purple_timeout_add_seconds(20, check_loc, gc); }