Fixes of sleepyhead
* Actually register hook handler
* Find hook name the right way
--- a/disco.c Sun Nov 01 06:20:33 2009 +0200
+++ b/disco.c Sun Nov 01 16:48:06 2009 +0200
@@ -238,14 +238,14 @@
// release handlers before reconnect
static void disco_hh (guint32 hid, hk_arg_t *args, gpointer userdata)
{
- hk_arg_t *arg = args;
+ hk_arg_t *arg = args;
- for (arg = args; arg->name; arg++) {
- if (!strcmp (arg->name, "hook-pre-disconnect")) {
- disco_free_handlers ();
- return;
- }
+ for (arg = args; arg->name; arg++) {
+ if (!strcmp (arg->name, "name") && !strcmp (arg->value, "hook-pre-disconnect")) {
+ disco_free_handlers ();
+ return;
}
+ }
}
const gchar *g_module_check_init(GModule *module)
@@ -255,13 +255,16 @@
// completion
disco_cid = compl_new_category ();
if (disco_cid) {
- compl_add_category_word (disco_cid, "info");
- compl_add_category_word (disco_cid, "items");
+ compl_add_category_word (disco_cid, "info");
+ compl_add_category_word (disco_cid, "items");
}
// command
cmd_add ("disco", "", disco_cid, COMPL_JID, do_disco, NULL);
+ // register hook handler
+ hk_add_handler (disco_hh, HOOK_INTERNAL, NULL);
+
return NULL;
}
@@ -270,12 +273,15 @@
// release handlers
disco_free_handlers ();
+ // remove hook handler
+ hk_del_handler (disco_hh, NULL);
+
// command
cmd_del ("disco");
// completion
if (disco_cid)
- compl_del_category (disco_cid);
+ compl_del_category (disco_cid);
}
/* vim: se ts=4: */