comparison 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
comparison
equal deleted inserted replaced
485:55aa45eb7ece 486:2a6a8ebb813b
353 if (type == ROSTER_TYPE_ROOM) 353 if (type == ROSTER_TYPE_ROOM)
354 strtype = TMSG_GROUPCHAT; 354 strtype = TMSG_GROUPCHAT;
355 else 355 else
356 strtype = TMSG_CHAT; 356 strtype = TMSG_CHAT;
357 357
358 x = jutil_msgnew(strtype, (char*)jid, 0, (char*)buffer); 358 x = jutil_msgnew(strtype, (char*)jid, NULL, (char*)buffer);
359 if (subject) { 359 if (subject) {
360 xmlnode y; 360 xmlnode y;
361 char *bs = to_utf8(subject); 361 char *bs = to_utf8(subject);
362 y = xmlnode_insert_tag(x, "subject"); 362 y = xmlnode_insert_tag(x, "subject");
363 xmlnode_insert_cdata(y, bs, (unsigned) -1); 363 xmlnode_insert_cdata(y, bs, (unsigned) -1);
533 xmlnode_put_attrib(x, "to", room); 533 xmlnode_put_attrib(x, "to", room);
534 y = xmlnode_get_tag(x, "query"); 534 y = xmlnode_get_tag(x, "query");
535 z = xmlnode_insert_tag(y, "x"); 535 z = xmlnode_insert_tag(y, "x");
536 xmlnode_put_attrib(z, "xmlns", "jabber:x:data"); 536 xmlnode_put_attrib(z, "xmlns", "jabber:x:data");
537 xmlnode_put_attrib(z, "type", "submit"); 537 xmlnode_put_attrib(z, "type", "submit");
538
539 jab_send(jc, x);
540 xmlnode_free(x);
541 jb_reset_keepalive();
542 }
543
544
545 // Invite a user to a MUC room
546 // room syntax: "room@server"
547 // reason can be null.
548 void jb_room_invite(const char *room, const char *jid, const char *reason)
549 {
550 xmlnode x, y, z;
551 gchar *utf8_reason;
552
553 if (!online || !room || !jid) return;
554
555 if (!reason) reason = "";
556
557 x = jutil_msgnew(NULL, (char*)room, NULL, NULL);
558
559 y = xmlnode_insert_tag(x, "x");
560 xmlnode_put_attrib(y, "xmlns", "http://jabber.org/protocol/muc#user");
561
562 z = xmlnode_insert_tag(y, "invite");
563 xmlnode_put_attrib(z, "to", jid);
564
565 utf8_reason = to_utf8(reason);
566 y = xmlnode_insert_tag(z, "reason");
567 xmlnode_insert_cdata(y, utf8_reason, (unsigned) -1);
568 g_free(utf8_reason);
538 569
539 jab_send(jc, x); 570 jab_send(jc, x);
540 xmlnode_free(x); 571 xmlnode_free(x);
541 jb_reset_keepalive(); 572 jb_reset_keepalive();
542 } 573 }