--- a/mcabber/doc/mcabber.1.txt Sat May 07 17:36:50 2005 +0000
+++ b/mcabber/doc/mcabber.1.txt Sat May 07 18:38:40 2005 +0000
@@ -91,6 +91,10 @@
/clear::
The 'clear' command is an alias for "/buffer clear".
+/del::
+ Delete the current buddy from our roster, unsubscribe from its presence
+ notification and unsubscribe it from ours.
+
/group expand|shrink|toggle::
The 'group' command changes the group display settings.
--- a/mcabber/src/TODO Sat May 07 17:36:50 2005 +0000
+++ b/mcabber/src/TODO Sat May 07 18:38:40 2005 +0000
@@ -7,7 +7,7 @@
TODO:
* Presence notification is always accepted. We should ask...
-* Display status
+* Display status / chat mode
* Get timestamp for offline messages
* /connect /disconnect ?
* Key bindings (ex: F5 <-> /group toggle)
@@ -15,6 +15,7 @@
maybe we could show it someway (maybe just a flag?).
* Show number of online contacts in folded groups
* Buddy buffer in full width (handy for cut'n paste!)
+* Create .mcabber and .mcabber/histo dirs if needed.
* Commands! :-)
- /roster <hide_offline|show_offline|top|bottom>
--- a/mcabber/src/commands.c Sat May 07 17:36:50 2005 +0000
+++ b/mcabber/src/commands.c Sat May 07 18:38:40 2005 +0000
@@ -35,6 +35,7 @@
void do_roster(char *arg);
void do_status(char *arg);
void do_add(char *arg);
+void do_del(char *arg);
void do_group(char *arg);
void do_say(char *arg);
void do_buffer(char *arg);
@@ -69,7 +70,7 @@
cmd_add("buffer", "Manipulate current buddy's buffer (chat window)",
COMPL_BUFFER, 0, &do_buffer);
cmd_add("clear", "Clear the dialog window", 0, 0, &do_clear);
- //cmd_add("del");
+ cmd_add("del", "Delete the current buddy", 0, 0, &do_del);
cmd_add("group", "Change group display settings", COMPL_GROUP, 0, &do_group);
cmd_add("help", "Display some help", COMPL_CMD, 0, NULL);
cmd_add("info", "Show basic infos on current buddy", 0, 0, &do_info);
@@ -405,3 +406,20 @@
g_free(buffer);
}
+void do_del(char *arg)
+{
+ const char *jid;
+
+ if (arg && (*arg)) {
+ scr_LogPrint("Wrong usage");
+ return;
+ }
+
+ if (!current_buddy) return;
+ jid = buddy_getjid(BUDDATA(current_buddy));
+ if (!jid) return;
+
+ scr_LogPrint("Removing <%s>...", jid);
+ jb_delbuddy(jid);
+}
+
--- a/mcabber/src/jabglue.c Sat May 07 17:36:50 2005 +0000
+++ b/mcabber/src/jabglue.c Sat May 07 18:38:40 2005 +0000
@@ -333,6 +333,50 @@
//update_roster = TRUE;
}
+void jb_delbuddy(const char *jid)
+{
+ xmlnode x, y, z;
+ char *cleanjid;
+
+ if (!online) return;
+
+ // XXX Check jid (but perhaps caller should do it)
+
+ cleanjid = jidtodisp(jid);
+
+ // If the current buddy is an agent, unsubscribe from it
+ if (roster_gettype(cleanjid) == ROSTER_TYPE_AGENT) {
+ scr_LogPrint("Unregistering from the %s agent", cleanjid);
+
+ x = jutil_iqnew(JPACKET__SET, NS_REGISTER);
+ xmlnode_put_attrib(x, "to", cleanjid);
+ y = xmlnode_get_tag(x, "query");
+ xmlnode_insert_tag(y, "remove");
+ jab_send(jc, x);
+ xmlnode_free(x);
+ }
+
+ // Unsubscribe this buddy from our presence notification
+ x = jutil_presnew(JPACKET__UNSUBSCRIBE, cleanjid, 0);
+ jab_send(jc, x);
+ xmlnode_free(x);
+
+ // Ask for removal from roster
+ x = jutil_iqnew(JPACKET__SET, NS_ROSTER);
+ y = xmlnode_get_tag(x, "query");
+ z = xmlnode_insert_tag(y, "item");
+ xmlnode_put_attrib(z, "jid", cleanjid);
+ xmlnode_put_attrib(z, "subscription", "remove");
+ jab_send(jc, x);
+ xmlnode_free(x);
+
+ roster_del_user(cleanjid);
+ g_free(cleanjid);
+ buddylist_build();
+
+ update_roster = TRUE;
+}
+
void postlogin()
{
//int i;
@@ -737,8 +781,8 @@
break;
case JPACKET_S10N:
- scr_LogPrint("Received subscription packet");
- if (type) scr_LogPrint("Type=%s", type);
+ scr_LogPrint("Received (un)subscription packet (type=%s)",
+ ((type) ? type : ""));
if (!strcmp(type, "subscribe")) {
int isagent;
--- a/mcabber/src/jabglue.h Sat May 07 17:36:50 2005 +0000
+++ b/mcabber/src/jabglue.h Sat May 07 18:38:40 2005 +0000
@@ -33,6 +33,7 @@
void jb_disconnect(void);
void jb_main();
void jb_addbuddy(const char *jid, const char *group);
+void jb_delbuddy(const char *jid);
inline enum imstatus jb_getstatus();
void jb_setstatus(enum imstatus st, char *msg);
void jb_send_msg(const char *, const char *);