diff mcabber/src/jabglue.c @ 486:2a6a8ebb813b

Add "/room invite"
author Mikael Berthe <mikael@lilotux.net>
date Fri, 07 Oct 2005 18:54:52 +0200
parents 47cfa3779549
children 21ab22a60bcb
line wrap: on
line diff
--- 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;