Mercurial > hg
comparison mcabber/modules/beep/beep.c @ 1986:ad77110343d6
Use a command ID with cmd_add/cmd_del (Myhailo Danylenko)
Patch merged from isbear's mcabber-experimental repository.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 27 Mar 2011 18:28:45 +0200 |
parents | c059c5c98de6 |
children | 0cb8ea02e472 |
comparison
equal
deleted
inserted
replaced
1985:0870005f7efc | 1986:ad77110343d6 |
---|---|
44 .init = beep_init, | 44 .init = beep_init, |
45 .uninit = beep_uninit, | 45 .uninit = beep_uninit, |
46 .next = NULL, | 46 .next = NULL, |
47 }; | 47 }; |
48 | 48 |
49 static guint beep_cid = 0; /* Command completion category id */ | 49 static guint beep_cid = 0; /* Command completion category id */ |
50 static guint beep_hid = 0; /* Hook handler id */ | 50 static gpointer beep_cmid = 0; /* Command id */ |
51 static guint beep_hid = 0; /* Hook handler id */ | |
51 | 52 |
52 /* Event handler */ | 53 /* Event handler */ |
53 static guint beep_hh(const gchar *hookname, hk_arg_t *args, gpointer userdata) | 54 static guint beep_hh(const gchar *hookname, hk_arg_t *args, gpointer userdata) |
54 { | 55 { |
55 /* Check if beeping is enabled */ | 56 /* Check if beeping is enabled */ |
92 if (beep_cid) { | 93 if (beep_cid) { |
93 compl_add_category_word(beep_cid, "enable"); | 94 compl_add_category_word(beep_cid, "enable"); |
94 compl_add_category_word(beep_cid, "disable"); | 95 compl_add_category_word(beep_cid, "disable"); |
95 } | 96 } |
96 /* Add command */ | 97 /* Add command */ |
97 cmd_add("beep", "", beep_cid, 0, do_beep, NULL); | 98 beep_cmid = cmd_add("beep", "", beep_cid, 0, do_beep, NULL); |
98 /* Add handler | 99 /* Add handler |
99 * We are only interested in incoming message events | 100 * We are only interested in incoming message events |
100 */ | 101 */ |
101 beep_hid = hk_add_handler(beep_hh, HOOK_POST_MESSAGE_IN, | 102 beep_hid = hk_add_handler(beep_hh, HOOK_POST_MESSAGE_IN, |
102 G_PRIORITY_DEFAULT_IDLE, NULL); | 103 G_PRIORITY_DEFAULT_IDLE, NULL); |
106 static void beep_uninit(void) | 107 static void beep_uninit(void) |
107 { | 108 { |
108 /* Unregister event handler */ | 109 /* Unregister event handler */ |
109 hk_del_handler(HOOK_POST_MESSAGE_IN, beep_hid); | 110 hk_del_handler(HOOK_POST_MESSAGE_IN, beep_hid); |
110 /* Unregister command */ | 111 /* Unregister command */ |
111 cmd_del("beep"); | 112 cmd_del(beep_cmid); |
112 /* Give back completion handle */ | 113 /* Give back completion handle */ |
113 if (beep_cid) | 114 if (beep_cid) |
114 compl_del_category(beep_cid); | 115 compl_del_category(beep_cid); |
115 } | 116 } |
116 | 117 |