[killpresence] Add option -p to /killpresence (to send a presence probe)
/killpresence -p fulljid is equivalent to both
/killpresence fulljid followed by
/probe barejid
--- a/killpresence/killpresence.c Sat Oct 13 14:34:18 2012 +0200
+++ b/killpresence/killpresence.c Sat Oct 13 17:26:43 2012 +0200
@@ -1,16 +1,21 @@
/*
* Module "killpresence" -- Ignore current presence of an item
*
- * /killpresence fulljid
+ * /killpresence [-p] fulljid
* Ignore current presence for the provided JID
* Useful for kicking ghosts from the roster...
* Shortcuts can be used for the full jid. Example:
* /killpresence ./resource
* Also, resource '*' stands for all resources.
+ * If the option -p is given, a presence probe will be sent
+ * to the user after removing the resource(s).
*
* /killchatstates fulljid
* Reset chat states for the provided JID
*
+ * /probe barejid
+ * Send a presence probe to the provided JID
+ *
*
* Copyright (C) 2010 Mikael Berthe <mikael@lilotux.net>
*
@@ -41,6 +46,8 @@
static void killpresence_init(void);
static void killpresence_uninit(void);
+static void do_probe(char *);
+
/* Module description */
module_info_t info_killpresence = {
.branch = MCABBER_BRANCH,
@@ -48,7 +55,7 @@
.version = "0.10",
.description = "Ignore an item's current presence(s)\n"
" Provides the following commands:\n"
- " /killpresence $fulljid\n"
+ " /killpresence [-p] $fulljid\n"
" /killchatstates $fulljid"
" /probe $barejid",
.requires = NULL,
@@ -65,12 +72,19 @@
{
char *jid_utf8, *res;
const char *targetjid = NULL;
+ bool probe = false;
if (!args || !*args) {
scr_log_print(LPRINT_NORMAL, "I need a full JID.");
return;
}
+ if (!strncmp(args, "-p ", 3)) {
+ for (args += 3; *args && *args == ' '; args++)
+ ;
+ probe = true;
+ }
+
jid_utf8 = to_utf8(args);
if (!jid_utf8)
return;
@@ -111,6 +125,9 @@
buddylist_build();
scr_draw_roster();
+ if (probe)
+ do_probe((char *)targetjid);
+
g_free(jid_utf8);
}