--- a/mcabber/Makefile.am Mon Jan 18 15:36:19 2010 +0200
+++ b/mcabber/Makefile.am Mon Jan 18 16:11:34 2010 +0200
@@ -1,2 +1,2 @@
-SUBDIRS = mcabber doc
+SUBDIRS = mcabber doc modules
ACLOCAL_AMFLAGS = -I macros
--- a/mcabber/configure.ac Mon Jan 18 15:36:19 2010 +0200
+++ b/mcabber/configure.ac Mon Jan 18 16:11:34 2010 +0200
@@ -8,7 +8,7 @@
AM_CONFIG_HEADER(mcabber/config.h)
AC_CONFIG_HEADER(include/config.h)
-#AC_PROG_LIBTOOL
+AC_PROG_LIBTOOL
AC_PROG_RANLIB
# Checks for programs.
@@ -260,6 +260,8 @@
CFLAGS="$CFLAGS -D_GNU_SOURCE"
AC_CONFIG_FILES([mcabber/Makefile
+ modules/Makefile
+ modules/beep/Makefile
doc/Makefile
doc/guide/Makefile
doc/help/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mcabber/modules/Makefile.am Mon Jan 18 16:11:34 2010 +0200
@@ -0,0 +1,1 @@
+SUBDIRS = beep
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mcabber/modules/beep/Makefile.am Mon Jan 18 16:11:34 2010 +0200
@@ -0,0 +1,10 @@
+
+if INSTALL_HEADERS
+pkglib_LTLIBRARIES = libbeep.la
+libbeep_la_SOURCES = beep.c
+libbeep_la_LDFLAGS = -module -avoid-version -shared
+
+LDADD = $(GLIB_LIBS)
+AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(LOUDMOUTH_CFLAGS)
+endif
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mcabber/modules/beep/beep.c Mon Jan 18 16:11:34 2010 +0200
@@ -0,0 +1,99 @@
+
+/* Copyright 2009 Myhailo Danylenko
+
+This file is part of mcabber module writing howto examples.
+
+Examples are free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+#include <glib.h>
+#include <gmodule.h>
+#include <string.h>
+
+#include <mcabber/logprint.h>
+#include <mcabber/commands.h>
+#include <mcabber/compl.h>
+#include <mcabber/hooks.h>
+#include <mcabber/screen.h>
+#include <mcabber/settings.h>
+
+static guint beep_cid = 0;
+
+/* Event handler */
+void beep_hh (guint32 hid, hk_arg_t *args, gpointer userdata)
+{
+ /* Check if beeping is enabled */
+ if (settings_opt_get_int ("beep_enable"))
+ /* *BEEP*! */
+ scr_Beep ();
+}
+
+/* beep command handler */
+void do_beep (char *args)
+{
+ /* Check arguments, and if recognized,
+ * set mcabber option accordingly */
+ if (!strcmp (args, "enable") ||
+ !strcmp (args, "on") ||
+ !strcmp (args, "yes") ||
+ !strcmp (args, "1"))
+ settings_set (SETTINGS_TYPE_OPTION,
+ "beep_enable", "1");
+ else if (!strcmp (args, "disable") ||
+ !strcmp (args, "off") ||
+ !strcmp (args, "no") ||
+ !strcmp (args, "0"))
+ settings_set (SETTINGS_TYPE_OPTION,
+ "beep_enable", "0");
+
+ /* Output current state, either if state is
+ * changed and if argument is not recognized */
+ if (settings_opt_get_int ("beep_enable"))
+ scr_LogPrint (LPRINT_NORMAL,
+ "Beep on messages is enabled");
+ else
+ scr_LogPrint (LPRINT_NORMAL,
+ "Beep on messages is disabled");
+}
+
+/* Initialization */
+const gchar* g_module_check_init (GModule *module)
+{
+ /* Create completions */
+ beep_cid = compl_new_category ();
+ if (beep_cid) {
+ compl_add_category_word (beep_cid, "enable");
+ compl_add_category_word (beep_cid, "disable");
+ }
+ /* Add command */
+ cmd_add ("beep", "", beep_cid, 0, do_beep, NULL);
+ /* Add handler
+ * We are only interested in incoming message events
+ */
+ hk_add_handler (beep_hh, HOOK_MESSAGE_IN, NULL);
+ return NULL;
+}
+
+/* Deinitialization */
+void g_module_unload (GModule *module)
+{
+ /* Unregister event handler */
+ hk_del_handler (beep_hh, NULL);
+ /* Unregister command */
+ cmd_del ("beep");
+ /* Give back completion handle */
+ if (beep_cid)
+ compl_del_category (beep_cid);
+}
+
+/* The End */