Changeset 6b0b4f4 for aim.c


Ignore:
Timestamp:
Jun 22, 2011, 12:37:21 AM (13 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.8, release-1.9
Children:
72146c7
Parents:
4f746f8
git-author:
David Benjamin <davidben@mit.edu> (05/23/11 23:43:21)
git-committer:
David Benjamin <davidben@mit.edu> (06/22/11 00:37:21)
Message:
Convert AIM timers to glib timers

We do lose the timer tracking feature, but I think that's fine. Glib
does have some main loop debug spew to run, though admittedly it may
require a custom-built glib.

Glib 2.14 allows us to use g_timeout_add_seconds which synchronizes
wakeups at the seconds granularity to minimize CPU wakeups.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • aim.c

    rdc1edbd r6b0b4f4  
    113113}
    114114
    115 void owl_aim_send_nop(owl_timer *t, void *data) {
    116     if(owl_global_is_doaimevents(&g)) {
    117         aim_session_t *sess = owl_global_get_aimsess(&g);
    118         aim_flap_nop(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS));
    119     }
     115gboolean owl_aim_send_nop(gpointer data) {
     116  owl_global *g = data;
     117  if (owl_global_is_doaimevents(g)) {
     118    aim_session_t *sess = owl_global_get_aimsess(g);
     119    aim_flap_nop(sess, aim_getconn_type(sess, AIM_CONN_TYPE_BOS));
     120  }
     121  return TRUE;
    120122}
    121123
     
    183185  owl_function_debugmsg("owl_aim_login: connecting");
    184186
    185   g.aim_nop_timer = owl_select_add_timer("owl_aim_send_nop", 30, 30, owl_aim_send_nop, NULL, NULL);
     187  g.aim_nop_timer = g_timeout_add_seconds(30, owl_aim_send_nop, &g);
    186188
    187189  return(0);
    188190}
    189191
    190 static void owl_aim_unset_ignorelogin(owl_timer *t, void *data)
    191 {
    192     owl_global_unset_ignore_aimlogin(&g);
     192static gboolean owl_aim_unset_ignorelogin(void *data)
     193{
     194  owl_global *g = data;
     195  owl_global_unset_ignore_aimlogin(g);
     196  return FALSE;  /* only run once. */
    193197}
    194198
     
    209213  /* start the ingorelogin timer */
    210214  owl_global_set_ignore_aimlogin(&g);
    211   owl_select_add_timer("owl_aim_unset_ignorelogin",
    212                        owl_global_get_aim_ignorelogin_timer(&g),
    213                        0, owl_aim_unset_ignorelogin, NULL, NULL);
     215  g_timeout_add_seconds(owl_global_get_aim_ignorelogin_timer(&g),
     216                        owl_aim_unset_ignorelogin, &g);
    214217
    215218  /* aim_ssi_setpresence(owl_global_get_aimsess(&g), 0x00000400); */
     
    225228  owl_global_set_aimnologgedin(&g);
    226229  owl_global_set_no_doaimevents(&g);
    227   owl_select_remove_timer(g.aim_nop_timer);
     230  if (g.aim_nop_timer) {
     231    g_source_remove(g.aim_nop_timer);
     232    g.aim_nop_timer = 0;
     233  }
    228234}
    229235
     
    244250  owl_global_set_aimnologgedin(&g);
    245251  owl_global_set_no_doaimevents(&g);
    246   owl_select_remove_timer(g.aim_nop_timer);
     252  if (g.aim_nop_timer) {
     253    g_source_remove(g.aim_nop_timer);
     254    g.aim_nop_timer = 0;
     255  }
    247256}
    248257
Note: See TracChangeset for help on using the changeset viewer.