--- a/Makefile.am Mon Mar 29 00:46:24 2010 +0200
+++ b/Makefile.am Wed Mar 31 22:58:04 2010 +0200
@@ -1,1 +1,1 @@
-SUBDIRS = clock comment extsay info_msgcount lastmsg
+SUBDIRS = clock comment extsay info_msgcount killpresence lastmsg
--- a/configure.ac Mon Mar 29 00:46:24 2010 +0200
+++ b/configure.ac Wed Mar 31 22:58:04 2010 +0200
@@ -110,6 +110,10 @@
AC_HELP_STRING([--enable-module-info_msgcount],
[enable module info_msgcount]),
enable_module_info_msgcount=$enableval)
+AC_ARG_ENABLE(module-killpresence,
+ AC_HELP_STRING([--enable-module-killpresence],
+ [enable module killpresence]),
+ enable_module_lastmsg=$enableval)
AC_ARG_ENABLE(module-lastmsg,
AC_HELP_STRING([--enable-module-lastmsg], [enable module lastmsg]),
enable_module_lastmsg=$enableval)
@@ -130,6 +134,10 @@
[test x"${enable_all_modules}" = x"yes" -o \
x"${enable_module_info_msgcount}" = x"yes"])
+AM_CONDITIONAL([INSTALL_MODULE_KILLPRESENCE],
+ [test x"${enable_all_modules}" = x"yes" -o \
+ x"${enable_module_killpresence}" = x"yes"])
+
AM_CONDITIONAL([INSTALL_MODULE_LASTMSG],
[test x"${enable_all_modules}" = x"yes" -o \
x"${enable_module_lastmsg}" = x"yes"])
@@ -138,6 +146,7 @@
comment/Makefile
extsay/Makefile
info_msgcount/Makefile
+ killpresence/Makefile
lastmsg/Makefile
Makefile])
AC_OUTPUT
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/killpresence/Makefile.am Wed Mar 31 22:58:04 2010 +0200
@@ -0,0 +1,11 @@
+
+if INSTALL_MODULE_KILLPRESENCE
+
+pkglib_LTLIBRARIES = libkillpresence.la
+libkillpresence_la_SOURCES = killpresence.c
+libkillpresence_la_LDFLAGS = -module -avoid-version -shared
+
+LDADD = $(GLIB_LIBS) $(MCABBER_LIBS)
+AM_CPPFLAGS = -I$(top_srcdir) $(GLIB_CFLAGS) $(MCABBER_CFLAGS)
+
+endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/killpresence/killpresence.c Wed Mar 31 22:58:04 2010 +0200
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2010 Mikael Berthe <mikael@lilotux.net>
+
+
+ Module "libkillpresence" -- Ignore current presence of an item
+
+This module is 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 <string.h>
+
+#include <mcabber/modules.h>
+#include <mcabber/commands.h>
+#include <mcabber/compl.h>
+#include <mcabber/roster.h>
+#include <mcabber/screen.h>
+#include <mcabber/utils.h>
+
+static void killpresence_init(void);
+static void killpresence_uninit(void);
+
+/* Module description */
+module_info_t info_killpresence = {
+ .branch = MCABBER_BRANCH,
+ .api = MCABBER_API_VERSION,
+ .version = "0.01",
+ .description = "Ignore an item's current presence",
+ .requires = NULL,
+ .init = killpresence_init,
+ .uninit = killpresence_uninit,
+ .next = NULL,
+};
+
+static void do_killpresence(char *args)
+{
+ char *jid_utf8, *res;
+
+ if (!args || !*args)
+ return;
+
+ jid_utf8 = to_utf8(args);
+ if (!jid_utf8)
+ return;
+
+ res = strchr(jid_utf8, JID_RESOURCE_SEPARATOR);
+ if (res)
+ *res++ = '\0';
+ else
+ return;
+
+ roster_setstatus(jid_utf8, res, 0,
+ offline, "Killed by killpresence.",
+ 0L, role_none, affil_none, NULL);
+ buddylist_build();
+ scr_draw_roster();
+
+ g_free(jid_utf8);
+}
+
+/* Initialization */
+static void killpresence_init(void)
+{
+ /* Add command */
+ cmd_add("killpresence", "Ignore presence", COMPL_JID, 0,
+ do_killpresence, NULL);
+}
+
+/* Uninitialization */
+static void killpresence_uninit(void)
+{
+ /* Unregister command */
+ cmd_del("killpresence");
+}
+
+/* vim: set expandtab cindent cinoptions=>2\:2(0 sw=2 ts=2: For Vim users... */