comparison mcabber/modules/beep/beep.c @ 1735:5093b5ca1572

New modules loading scheme
author Myhailo Danylenko <isbear@ukrpost.net>
date Thu, 04 Mar 2010 13:03:20 +0200
parents 411269409f34
children 14b4866cc9f2
comparison
equal deleted inserted replaced
1734:eae4a2637f2c 1735:5093b5ca1572
14 GNU General Public License for more details. 14 GNU General Public License for more details.
15 15
16 You should have received a copy of the GNU General Public License 16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */ 17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
18 18
19 #include <glib.h>
20 #include <gmodule.h>
21 #include <string.h> 19 #include <string.h>
22 20
23 #include <mcabber/logprint.h> 21 #include <mcabber/logprint.h>
24 #include <mcabber/commands.h> 22 #include <mcabber/commands.h>
25 #include <mcabber/compl.h> 23 #include <mcabber/compl.h>
26 #include <mcabber/hooks.h> 24 #include <mcabber/hooks.h>
27 #include <mcabber/screen.h> 25 #include <mcabber/screen.h>
28 #include <mcabber/settings.h> 26 #include <mcabber/settings.h>
27 #include <mcabber/modules.h>
28
29 static void beep_init (void);
30 static void beep_uninit (void);
31
32 /* Module description */
33 module_info_t info_beep = {
34 .mcabber_version = "0.10.0",
35 .requires = NULL,
36 .init = beep_init,
37 .uninit = beep_uninit,
38 };
29 39
30 static guint beep_cid = 0; 40 static guint beep_cid = 0;
31 41
32 /* Event handler */ 42 /* Event handler */
33 void beep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) 43 static void beep_hh (guint32 hid, hk_arg_t *args, gpointer userdata)
34 { 44 {
35 /* Check if beeping is enabled */ 45 /* Check if beeping is enabled */
36 if (settings_opt_get_int ("beep_enable")) 46 if (settings_opt_get_int ("beep_enable"))
37 /* *BEEP*! */ 47 /* *BEEP*! */
38 scr_Beep (); 48 scr_Beep ();
39 } 49 }
40 50
41 /* beep command handler */ 51 /* beep command handler */
42 void do_beep (char *args) 52 static void do_beep (char *args)
43 { 53 {
44 /* Check arguments, and if recognized, 54 /* Check arguments, and if recognized,
45 * set mcabber option accordingly */ 55 * set mcabber option accordingly */
46 if (!strcmp (args, "enable") || 56 if (!strcmp (args, "enable") ||
47 !strcmp (args, "on") || 57 !strcmp (args, "on") ||
65 scr_LogPrint (LPRINT_NORMAL, 75 scr_LogPrint (LPRINT_NORMAL,
66 "Beep on messages is disabled"); 76 "Beep on messages is disabled");
67 } 77 }
68 78
69 /* Initialization */ 79 /* Initialization */
70 const gchar* g_module_check_init (GModule *module) 80 static void beep_init (void)
71 { 81 {
72 /* Create completions */ 82 /* Create completions */
73 beep_cid = compl_new_category (); 83 beep_cid = compl_new_category ();
74 if (beep_cid) { 84 if (beep_cid) {
75 compl_add_category_word (beep_cid, "enable"); 85 compl_add_category_word (beep_cid, "enable");
79 cmd_add ("beep", "", beep_cid, 0, do_beep, NULL); 89 cmd_add ("beep", "", beep_cid, 0, do_beep, NULL);
80 /* Add handler 90 /* Add handler
81 * We are only interested in incoming message events 91 * We are only interested in incoming message events
82 */ 92 */
83 hk_add_handler (beep_hh, HOOK_MESSAGE_IN, NULL); 93 hk_add_handler (beep_hh, HOOK_MESSAGE_IN, NULL);
84 return NULL;
85 } 94 }
86 95
87 /* Deinitialization */ 96 /* Deinitialization */
88 void g_module_unload (GModule *module) 97 static void beep_uninit (void)
89 { 98 {
90 /* Unregister event handler */ 99 /* Unregister event handler */
91 hk_del_handler (beep_hh, NULL); 100 hk_del_handler (beep_hh, NULL);
92 /* Unregister command */ 101 /* Unregister command */
93 cmd_del ("beep"); 102 cmd_del ("beep");