Mercurial > hg
comparison mcabber/src/jabglue.c @ 568:eb1df2371581
Add "/room kick"
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 03 Dec 2005 13:32:29 +0100 |
parents | 7fc678ac3bc6 |
children | 69afee8e1232 |
comparison
equal
deleted
inserted
replaced
567:6f490c725999 | 568:eb1df2371581 |
---|---|
582 jab_send(jc, x); | 582 jab_send(jc, x); |
583 xmlnode_free(x); | 583 xmlnode_free(x); |
584 jb_reset_keepalive(); | 584 jb_reset_keepalive(); |
585 } | 585 } |
586 | 586 |
587 // Kick or ban a MUC room member | |
588 // room syntax: "room@server" | |
589 // Either the jid or the nickname must be set (when banning, only the jid is | |
590 // allowed) | |
591 // kickban: 1=kick 2=ban | |
592 // The reason can be null | |
593 // Return 0 if everything is ok | |
594 int jb_room_kickban(const char *roomid, const char *jid, const char *nick, | |
595 int kickban, const char *reason) | |
596 { | |
597 xmlnode x, y, z; | |
598 | |
599 if (!online || !roomid) return 1; | |
600 if (kickban != 1 && kickban != 2) return 1; | |
601 | |
602 if (check_jid_syntax((char*)roomid)) { | |
603 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", roomid); | |
604 return 1; | |
605 } | |
606 if (jid && check_jid_syntax((char*)jid)) { | |
607 scr_LogPrint(LPRINT_NORMAL, "<%s> is not a valid Jabber id", jid); | |
608 return 1; | |
609 } | |
610 | |
611 if (kickban == 2 && !jid) | |
612 return 1; // Shouldn't happen | |
613 | |
614 x = jutil_iqnew(JPACKET__SET, "http://jabber.org/protocol/muc#admin"); | |
615 xmlnode_put_attrib(x, "id", "kick1"); // XXX | |
616 xmlnode_put_attrib(x, "to", roomid); | |
617 xmlnode_put_attrib(x, "type", "set"); | |
618 y = xmlnode_get_tag(x, "query"); | |
619 z = xmlnode_insert_tag(y, "item"); | |
620 | |
621 if (!jid) { | |
622 gchar *utf8_nickname = to_utf8(nick); | |
623 xmlnode_put_attrib(z, "nick", utf8_nickname); | |
624 g_free(utf8_nickname); | |
625 } else { | |
626 xmlnode_put_attrib(z, "jid", jid); | |
627 if (kickban == 2) | |
628 xmlnode_put_attrib(z, "affiliation", "outcast"); | |
629 } | |
630 if (kickban == 1) | |
631 xmlnode_put_attrib(z, "role", "none"); | |
632 | |
633 if (reason) { | |
634 gchar *utf8_reason = to_utf8(reason); | |
635 y = xmlnode_insert_tag(z, "reason"); | |
636 xmlnode_insert_cdata(y, utf8_reason, (unsigned) -1); | |
637 g_free(utf8_reason); | |
638 } | |
639 | |
640 jab_send(jc, x); | |
641 xmlnode_free(x); | |
642 jb_reset_keepalive(); | |
643 | |
644 return 0; | |
645 } | |
587 | 646 |
588 // Invite a user to a MUC room | 647 // Invite a user to a MUC room |
589 // room syntax: "room@server" | 648 // room syntax: "room@server" |
590 // reason can be null. | 649 // reason can be null. |
591 void jb_room_invite(const char *room, const char *jid, const char *reason) | 650 void jb_room_invite(const char *room, const char *jid, const char *reason) |