--- a/mcabber/src/commands.c Fri Oct 07 18:52:37 2005 +0200
+++ b/mcabber/src/commands.c Fri Oct 07 18:54:52 2005 +0200
@@ -153,6 +153,7 @@
compl_add_category_word(COMPL_MULTILINE, "verbatim");
// Room category
+ compl_add_category_word(COMPL_ROOM, "invite");
compl_add_category_word(COMPL_ROOM, "join");
compl_add_category_word(COMPL_ROOM, "leave");
compl_add_category_word(COMPL_ROOM, "names");
@@ -1081,6 +1082,36 @@
g_free(roomname);
buddylist_build();
update_roster = TRUE;
+ } else if (!strncasecmp(arg, "invite", 6)) {
+ const gchar *roomname;
+ gchar*jid;
+ arg += 6;
+ if (*arg++ != ' ') {
+ scr_LogPrint(LPRINT_NORMAL, "Wrong or missing parameter");
+ return;
+ }
+ for (; *arg && *arg == ' '; arg++)
+ ;
+ if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) {
+ scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom");
+ return;
+ }
+ if (!*arg) {
+ scr_LogPrint(LPRINT_NORMAL, "Missing parameter");
+ return;
+ }
+ jid = g_strdup(arg);
+ arg = strchr(jid, ' ');
+ if (arg) {
+ *arg++ = 0;
+ for (; *arg && *arg == ' '; arg++)
+ ;
+ if (!*arg) arg = NULL;
+ }
+ roomname = buddy_getjid(bud);
+ jb_room_invite(roomname, jid, arg);
+ scr_LogPrint(LPRINT_LOGNORM, "Invitation sent to <%s>", jid);
+ g_free(jid);
} else if (!strncasecmp(arg, "leave", 5)) {
gchar *roomid, *utf8_nickname;
arg += 5;
@@ -1097,7 +1128,7 @@
g_free(roomid);
buddy_setnickname(bud, NULL);
buddy_del_all_resources(bud);
- scr_LogPrint(LPRINT_NORMAL, "You have left %s", buddy_getjid(bud));
+ scr_LogPrint(LPRINT_LOGNORM, "You have left %s", buddy_getjid(bud));
} else if (!strcasecmp(arg, "names")) {
if (!(buddy_gettype(bud) & ROSTER_TYPE_ROOM)) {
scr_LogPrint(LPRINT_NORMAL, "This isn't a chatroom");
--- a/mcabber/src/jabglue.c Fri Oct 07 18:52:37 2005 +0200
+++ b/mcabber/src/jabglue.c Fri Oct 07 18:54:52 2005 +0200
@@ -355,7 +355,7 @@
else
strtype = TMSG_CHAT;
- x = jutil_msgnew(strtype, (char*)jid, 0, (char*)buffer);
+ x = jutil_msgnew(strtype, (char*)jid, NULL, (char*)buffer);
if (subject) {
xmlnode y;
char *bs = to_utf8(subject);
@@ -541,6 +541,37 @@
jb_reset_keepalive();
}
+
+// Invite a user to a MUC room
+// room syntax: "room@server"
+// reason can be null.
+void jb_room_invite(const char *room, const char *jid, const char *reason)
+{
+ xmlnode x, y, z;
+ gchar *utf8_reason;
+
+ if (!online || !room || !jid) return;
+
+ if (!reason) reason = "";
+
+ x = jutil_msgnew(NULL, (char*)room, NULL, NULL);
+
+ y = xmlnode_insert_tag(x, "x");
+ xmlnode_put_attrib(y, "xmlns", "http://jabber.org/protocol/muc#user");
+
+ z = xmlnode_insert_tag(y, "invite");
+ xmlnode_put_attrib(z, "to", jid);
+
+ utf8_reason = to_utf8(reason);
+ y = xmlnode_insert_tag(z, "reason");
+ xmlnode_insert_cdata(y, utf8_reason, (unsigned) -1);
+ g_free(utf8_reason);
+
+ jab_send(jc, x);
+ xmlnode_free(x);
+ jb_reset_keepalive();
+}
+
void postlogin()
{
//int i;
--- a/mcabber/src/jabglue.h Fri Oct 07 18:52:37 2005 +0200
+++ b/mcabber/src/jabglue.h Fri Oct 07 18:54:52 2005 +0200
@@ -57,5 +57,6 @@
inline void jb_set_priority(unsigned int priority);
void jb_room_join(const char *room, const char *nickname);
void jb_room_unlock(const char *room);
+void jb_room_invite(const char *room, const char *jid, const char *reason);
#endif /* __JABGLUE_H__ */