Mercurial > pidgin
comparison libpurple/protocols/jabber/chat.c @ 19697:481749fc0b6b
merge of '1c7910841138381c841363256ca3c7905b1f26b0'
and '5818cbd5fe95d6a167f1555b882526f36790b141'
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Mon, 10 Sep 2007 13:57:15 +0000 |
parents | 95affacf6f82 44b4e8bd759b |
children | 6a0d9fa477d4 53afc5cce143 bde477ec6a71 |
comparison
equal
deleted
inserted
replaced
19696:301f1597d41f | 19697:481749fc0b6b |
---|---|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 * GNU General Public License for more details. | 14 * GNU General Public License for more details. |
15 * | 15 * |
16 * You should have received a copy of the GNU General Public License | 16 * You should have received a copy of the GNU General Public License |
17 * along with this program; if not, write to the Free Software | 17 * along with this program; if not, write to the Free Software |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
19 * | 19 * |
20 */ | 20 */ |
21 #include "internal.h" | 21 #include "internal.h" |
22 #include "debug.h" | 22 #include "debug.h" |
23 #include "prpl.h" /* for proto_chat_entry */ | 23 #include "prpl.h" /* for proto_chat_entry */ |
831 g_hash_table_remove(chat->members, handle); | 831 g_hash_table_remove(chat->members, handle); |
832 } | 832 } |
833 | 833 |
834 gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why) | 834 gboolean jabber_chat_ban_user(JabberChat *chat, const char *who, const char *why) |
835 { | 835 { |
836 JabberChatMember *jcm; | |
837 const char *jid; | |
838 char *to; | |
836 JabberIq *iq; | 839 JabberIq *iq; |
837 JabberChatMember *jcm = g_hash_table_lookup(chat->members, who); | |
838 char *to; | |
839 xmlnode *query, *item, *reason; | 840 xmlnode *query, *item, *reason; |
840 | 841 |
841 if(!jcm || !jcm->jid) | 842 jcm = g_hash_table_lookup(chat->members, who); |
843 if (jcm && jcm->jid) | |
844 jid = jcm->jid; | |
845 else if (g_utf8_strchr(who, -1, '@') != NULL) | |
846 jid = who; | |
847 else | |
842 return FALSE; | 848 return FALSE; |
843 | 849 |
844 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | 850 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
845 "http://jabber.org/protocol/muc#admin"); | 851 "http://jabber.org/protocol/muc#admin"); |
846 | 852 |
848 xmlnode_set_attrib(iq->node, "to", to); | 854 xmlnode_set_attrib(iq->node, "to", to); |
849 g_free(to); | 855 g_free(to); |
850 | 856 |
851 query = xmlnode_get_child(iq->node, "query"); | 857 query = xmlnode_get_child(iq->node, "query"); |
852 item = xmlnode_new_child(query, "item"); | 858 item = xmlnode_new_child(query, "item"); |
853 xmlnode_set_attrib(item, "jid", jcm->jid); | 859 xmlnode_set_attrib(item, "jid", jid); |
854 xmlnode_set_attrib(item, "affiliation", "outcast"); | 860 xmlnode_set_attrib(item, "affiliation", "outcast"); |
855 if(why) { | 861 if(why) { |
856 reason = xmlnode_new_child(item, "reason"); | 862 reason = xmlnode_new_child(item, "reason"); |
857 xmlnode_insert_data(reason, why, -1); | 863 xmlnode_insert_data(reason, why, -1); |
858 } | 864 } |
862 return TRUE; | 868 return TRUE; |
863 } | 869 } |
864 | 870 |
865 gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation) | 871 gboolean jabber_chat_affiliate_user(JabberChat *chat, const char *who, const char *affiliation) |
866 { | 872 { |
873 JabberChatMember *jcm; | |
874 const char *jid; | |
867 char *to; | 875 char *to; |
868 JabberIq *iq; | 876 JabberIq *iq; |
869 xmlnode *query, *item; | 877 xmlnode *query, *item; |
870 JabberChatMember *jcm; | |
871 | 878 |
872 jcm = g_hash_table_lookup(chat->members, who); | 879 jcm = g_hash_table_lookup(chat->members, who); |
873 | 880 if (jcm && jcm->jid) |
874 if (!jcm || !jcm->jid) | 881 jid = jcm->jid; |
882 else if (g_utf8_strchr(who, -1, '@') != NULL) | |
883 jid = who; | |
884 else | |
875 return FALSE; | 885 return FALSE; |
876 | 886 |
877 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, | 887 iq = jabber_iq_new_query(chat->js, JABBER_IQ_SET, |
878 "http://jabber.org/protocol/muc#admin"); | 888 "http://jabber.org/protocol/muc#admin"); |
879 | 889 |
881 xmlnode_set_attrib(iq->node, "to", to); | 891 xmlnode_set_attrib(iq->node, "to", to); |
882 g_free(to); | 892 g_free(to); |
883 | 893 |
884 query = xmlnode_get_child(iq->node, "query"); | 894 query = xmlnode_get_child(iq->node, "query"); |
885 item = xmlnode_new_child(query, "item"); | 895 item = xmlnode_new_child(query, "item"); |
886 xmlnode_set_attrib(item, "jid", jcm->jid); | 896 xmlnode_set_attrib(item, "jid", jid); |
887 xmlnode_set_attrib(item, "affiliation", affiliation); | 897 xmlnode_set_attrib(item, "affiliation", affiliation); |
888 | 898 |
889 jabber_iq_send(iq); | 899 jabber_iq_send(iq); |
890 | 900 |
891 return TRUE; | 901 return TRUE; |