diff -r 9ce7690c4dab -r 744b8e669d85 pep.c --- a/pep.c Sun Mar 14 18:13:31 2010 +0200 +++ b/pep.c Thu Mar 25 21:00:46 2010 +0200 @@ -37,7 +37,7 @@ static module_info_t info_pep_experimental = { .branch = "experimental", - .api = 5, + .api = 10, .version = PROJECT_VERSION, .description = DESCRIPTION, .requires = NULL, @@ -48,7 +48,7 @@ module_info_t info_pep = { .branch = "dev", - .api = 4, + .api = 11, .version = PROJECT_VERSION, .description = DESCRIPTION, .requires = NULL, @@ -68,6 +68,9 @@ static GSList *pep_xmlns_handlers = NULL; +static guint pep_hid_connect = 0; +static guint pep_hid_disconnect = 0; + static LmMessageHandler *pep_message_handler = NULL; static LmMessageHandler *pep_iq_handler = NULL; @@ -187,12 +190,16 @@ } // release handlers before reconnect -static void pep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) +static guint pep_hch (const gchar *hid, hk_arg_t *args, gpointer userdata) { - if (hid == HOOK_POST_CONNECT) - pep_register_handlers (); - else if (hid == HOOK_PRE_DISCONNECT) - pep_unregister_handlers (); + pep_register_handlers (); + return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS; +} + +static guint pep_hdh (const gchar *hid, hk_arg_t *args, gpointer userdata) +{ + pep_unregister_handlers (); + return HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS; } static void pep_init (void) @@ -202,7 +209,8 @@ pep_iq_handler = lm_message_handler_new (pep_iq_pubsub_handler, NULL, NULL); // register hook handler - hk_add_handler (pep_hh, HOOK_POST_CONNECT | HOOK_PRE_DISCONNECT, NULL); + pep_hid_connect = hk_add_handler (pep_hch, HOOK_POST_CONNECT, G_PRIORITY_DEFAULT, NULL); + pep_hid_disconnect = hk_add_handler (pep_hdh, HOOK_PRE_DISCONNECT, G_PRIORITY_DEFAULT, NULL); // register handlers to connection pep_register_handlers (); @@ -214,7 +222,8 @@ pep_unregister_handlers (); // remove hook - hk_del_handler (pep_hh, NULL); + hk_del_handler (HOOK_POST_CONNECT, pep_hid_connect); + hk_del_handler (HOOK_PRE_DISCONNECT, pep_hid_disconnect); { // unregister xmlns handlers GSList *hel;