Sat, 14 Apr 2007 16:32:42 +0000
Make non-standard mode characters support connection-specific instead of
IRC prpl-wide.
| 6333 | 1 | /** |
| 2 | * @file msgs.c | |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
3 | * |
| 15884 | 4 | * purple |
| 6333 | 5 | * |
| 6 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
7 | * |
| 6333 | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * along with this program; if not, write to the Free Software | |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 21 | */ | |
| 22 | ||
| 23 | #include "internal.h" | |
| 24 | ||
| 25 | #include "conversation.h" | |
| 26 | #include "blist.h" | |
| 27 | #include "notify.h" | |
| 28 | #include "util.h" | |
| 29 | #include "debug.h" | |
| 30 | #include "irc.h" | |
| 31 | ||
| 32 | #include <stdio.h> | |
| 33 | ||
| 34 | static char *irc_mask_nick(const char *mask); | |
| 35 | static char *irc_mask_userhost(const char *mask); | |
| 15884 | 36 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]); |
| 6333 | 37 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc); |
| 38 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
39 | static void irc_msg_handle_privmsg(struct irc_conn *irc, const char *name, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
40 | const char *from, const char *to, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
41 | const char *rawmsg, gboolean notice); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
42 | |
| 6333 | 43 | static char *irc_mask_nick(const char *mask) |
| 44 | { | |
| 45 | char *end, *buf; | |
| 46 | ||
| 47 | end = strchr(mask, '!'); | |
| 48 | if (!end) | |
| 49 | buf = g_strdup(mask); | |
| 50 | else | |
| 51 | buf = g_strndup(mask, end - mask); | |
| 52 | ||
| 53 | return buf; | |
| 54 | } | |
| 55 | ||
| 56 | static char *irc_mask_userhost(const char *mask) | |
| 57 | { | |
| 58 | return g_strdup(strchr(mask, '!') + 1); | |
| 59 | } | |
| 60 | ||
| 15884 | 61 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]) |
| 6333 | 62 | { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
63 | char *message; |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
64 | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
65 | message = g_strdup_printf("quit: %s", data[1]); |
| 6333 | 66 | |
| 15884 | 67 | if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(convo), data[0])) |
| 68 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), data[0], message); | |
| 6333 | 69 | |
| 70 | g_free(message); | |
| 71 | } | |
| 72 | ||
| 73 | void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 74 | { | |
| 15884 | 75 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", args[0]); |
| 6333 | 76 | } |
| 77 | ||
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
78 | void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
79 | { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
80 | gchar **features; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
81 | int i; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
82 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
83 | if (!args || !args[0] || !args[1]) |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
84 | return; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
85 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
86 | features = g_strsplit(args[1], " ", -1); |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
87 | for (i = 0; features[i]; i++) { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
88 | char *val; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
89 | if (!strncmp(features[i], "PREFIX=", 7)) { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
90 | if ((val = strchr(features[i] + 7, ')')) != NULL) |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
91 | irc->mode_chars = g_strdup(val + 1); |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
92 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
93 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
94 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
95 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
96 | void irc_msg_luser(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
97 | { |
| 15884 | 98 | PurpleConnection *gc; |
| 99 | PurpleStatus *status; | |
| 100 | PurpleBlistNode *gnode, *cnode, *bnode; | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
101 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
102 | if (!args || !args[0] || !args[1]) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
103 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
104 | |
| 15884 | 105 | gc = purple_account_get_connection(irc->account); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
106 | if (!gc) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
107 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
108 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
109 | if (!strcmp(name, "251")) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
110 | /* 251 is required, so we pluck our nick from here */ |
| 15884 | 111 | purple_connection_set_display_name(gc, args[0]); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
112 | } else if (!strcmp(name, "255")) { |
| 15884 | 113 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
114 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
115 | /* If we're away then set our away message */ |
| 15884 | 116 | status = purple_account_get_active_status(irc->account); |
| 117 | if (!purple_status_get_type(status) != PURPLE_STATUS_AVAILABLE) { | |
| 118 | PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
119 | prpl_info->set_status(irc->account, status); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
120 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
121 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
122 | /* this used to be in the core, but it's not now */ |
| 15884 | 123 | for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
| 124 | if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
125 | continue; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
126 | for(cnode = gnode->child; cnode; cnode = cnode->next) { |
| 15884 | 127 | if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
128 | continue; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
129 | for(bnode = cnode->child; bnode; bnode = bnode->next) { |
| 15884 | 130 | PurpleBuddy *b; |
| 131 | if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
132 | continue; |
| 15884 | 133 | b = (PurpleBuddy *)bnode; |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
134 | if(b->account == gc->account) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
135 | struct irc_buddy *ib = g_new0(struct irc_buddy, 1); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
136 | ib->name = g_strdup(b->name); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
137 | g_hash_table_insert(irc->buddies, ib->name, ib); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
138 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
139 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
140 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
141 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
142 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
143 | irc_blist_timeout(irc); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
144 | if (!irc->timer) |
| 15884 | 145 | irc->timer = purple_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
146 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
147 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
148 | |
| 6333 | 149 | void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 150 | { | |
| 15884 | 151 | PurpleConnection *gc; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
152 | char *msg; |
| 6333 | 153 | |
| 154 | if (!args || !args[1]) | |
| 155 | return; | |
| 156 | ||
| 15884 | 157 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 158 | /* We're doing a whois, show this in the whois dialog */ |
| 159 | irc_msg_whois(irc, name, from, args); | |
| 160 | return; | |
| 161 | } | |
| 162 | ||
| 15884 | 163 | gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
164 | if (gc) { |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
165 | msg = g_markup_escape_text(args[2], -1); |
| 15884 | 166 | serv_got_im(gc, args[1], msg, PURPLE_MESSAGE_AUTO_RESP, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
167 | g_free(msg); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
168 | } |
| 6333 | 169 | } |
| 170 | ||
| 171 | void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 172 | { | |
| 15884 | 173 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 174 | |
| 175 | if (!args || !args[1] || !gc) | |
| 176 | return; | |
| 177 | ||
| 15884 | 178 | purple_notify_error(gc, NULL, _("Bad mode"), args[1]); |
| 6333 | 179 | } |
| 180 | ||
| 181 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 182 | { | |
| 15884 | 183 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 184 | char *buf; |
| 185 | ||
| 186 | if (!args || !args[1] || !gc) | |
| 187 | return; | |
| 188 | ||
| 189 | buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
| 15884 | 190 | purple_notify_error(gc, _("Banned"), _("Banned"), buf); |
| 6333 | 191 | g_free(buf); |
| 192 | } | |
| 193 | ||
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
194 | void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
195 | { |
| 15884 | 196 | PurpleConversation *convo; |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
197 | char *buf, *nick; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
198 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
199 | if (!args || !args[0] || !args[1] || !args[2]) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
200 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
201 | |
| 15884 | 202 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
203 | if (!convo) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
204 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
205 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
206 | nick = g_markup_escape_text(args[2], -1); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
207 | buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
208 | g_free(nick); |
| 15884 | 209 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, |
| 210 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, | |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
211 | time(NULL)); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
212 | g_free(buf); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
213 | } |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
214 | |
| 6333 | 215 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 216 | { | |
| 15884 | 217 | PurpleConversation *convo; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
218 | char *buf, *escaped; |
| 6333 | 219 | |
| 220 | if (!args || !args[1] || !args[2]) | |
| 221 | return; | |
| 222 | ||
| 15884 | 223 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 224 | if (!convo) /* XXX punt on channels we are not in for now */ |
| 225 | return; | |
| 226 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
227 | escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL; |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
228 | buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); |
| 15884 | 229 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
230 | g_free(escaped); |
| 6333 | 231 | g_free(buf); |
| 232 | ||
| 233 | return; | |
| 234 | } | |
| 235 | ||
| 236 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 237 | { | |
| 238 | if (!irc->whois.nick) { | |
| 15884 | 239 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected WHOIS reply for %s\n", args[1]); |
| 6333 | 240 | return; |
| 241 | } | |
| 242 | ||
| 15884 | 243 | if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 244 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Got WHOIS reply for %s while waiting for %s\n", args[1], irc->whois.nick); | |
| 6333 | 245 | return; |
| 246 | } | |
| 247 | ||
| 248 | if (!strcmp(name, "301")) { | |
| 249 | irc->whois.away = g_strdup(args[2]); | |
| 250 | } else if (!strcmp(name, "311")) { | |
| 251 | irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]); | |
| 252 | irc->whois.name = g_strdup(args[5]); | |
| 253 | } else if (!strcmp(name, "312")) { | |
| 254 | irc->whois.server = g_strdup(args[2]); | |
| 255 | irc->whois.serverinfo = g_strdup(args[3]); | |
| 256 | } else if (!strcmp(name, "313")) { | |
| 257 | irc->whois.ircop = 1; | |
| 258 | } else if (!strcmp(name, "317")) { | |
| 259 | irc->whois.idle = atoi(args[2]); | |
| 260 | if (args[3]) | |
| 261 | irc->whois.signon = (time_t)atoi(args[3]); | |
| 262 | } else if (!strcmp(name, "319")) { | |
| 263 | irc->whois.channels = g_strdup(args[2]); | |
| 264 | } else if (!strcmp(name, "320")) { | |
| 265 | irc->whois.identified = 1; | |
| 266 | } | |
| 267 | } | |
| 268 | ||
| 269 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 270 | { | |
| 15884 | 271 | PurpleConnection *gc; |
|
15215
3b4c0490b8b0
[gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
272 | char *tmp, *tmp2; |
| 15884 | 273 | PurpleNotifyUserInfo *user_info; |
| 6333 | 274 | |
| 275 | if (!irc->whois.nick) { | |
| 15884 | 276 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of WHOIS for %s\n", args[1]); |
| 6333 | 277 | return; |
| 278 | } | |
| 15884 | 279 | if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 280 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of WHOIS for %s, expecting %s\n", args[1], irc->whois.nick); | |
| 6333 | 281 | return; |
| 282 | } | |
| 283 | ||
| 15884 | 284 | user_info = purple_notify_user_info_new(); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
285 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
286 | tmp2 = g_markup_escape_text(args[1], -1); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
287 | tmp = g_strdup_printf("%s%s%s", tmp2, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
288 | (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
289 | (irc->whois.identified ? _(" <i>(identified)</i>") : "")); |
| 15884 | 290 | purple_notify_user_info_add_pair(user_info, _("Nick"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
291 | g_free(tmp2); |
| 10634 | 292 | g_free(tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
293 | |
| 6333 | 294 | if (irc->whois.away) { |
| 10634 | 295 | tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); |
| 6333 | 296 | g_free(irc->whois.away); |
| 15884 | 297 | purple_notify_user_info_add_pair(user_info, _("Away"), tmp); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
298 | g_free(tmp); |
| 6333 | 299 | } |
| 300 | if (irc->whois.userhost) { | |
| 10634 | 301 | tmp = g_markup_escape_text(irc->whois.name, strlen(irc->whois.name)); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
302 | g_free(irc->whois.name); |
| 15884 | 303 | purple_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); |
| 304 | purple_notify_user_info_add_pair(user_info, _("Real name"), tmp); | |
| 6333 | 305 | g_free(irc->whois.userhost); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
306 | g_free(tmp); |
| 6333 | 307 | } |
| 308 | if (irc->whois.server) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
309 | tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); |
| 15884 | 310 | purple_notify_user_info_add_pair(user_info, _("Server"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
311 | g_free(tmp); |
| 6333 | 312 | g_free(irc->whois.server); |
| 313 | g_free(irc->whois.serverinfo); | |
| 314 | } | |
| 315 | if (irc->whois.channels) { | |
| 15884 | 316 | purple_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels); |
| 6333 | 317 | g_free(irc->whois.channels); |
| 318 | } | |
| 319 | if (irc->whois.idle) { | |
| 15884 | 320 | gchar *timex = purple_str_seconds_to_string(irc->whois.idle); |
| 321 | purple_notify_user_info_add_pair(user_info, _("Idle for"), timex); | |
|
6357
f83643b0a067
[gaim-migrate @ 6856]
Mark Doliner <markdoliner@pidgin.im>
parents:
6351
diff
changeset
|
322 | g_free(timex); |
| 15884 | 323 | purple_notify_user_info_add_pair(user_info, |
| 324 | _("Online since"), purple_date_format_full(localtime(&irc->whois.signon))); | |
| 6333 | 325 | } |
| 326 | if (!strcmp(irc->whois.nick, "Paco-Paco")) { | |
| 15884 | 327 | purple_notify_user_info_add_pair(user_info, |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
328 | _("<b>Defining adjective:</b>"), _("Glorious")); |
| 6333 | 329 | } |
| 330 | ||
| 15884 | 331 | gc = purple_account_get_connection(irc->account); |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
332 | |
| 15884 | 333 | purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); |
| 334 | purple_notify_user_info_destroy(user_info); | |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
335 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
336 | g_free(irc->whois.nick); |
| 6333 | 337 | memset(&irc->whois, 0, sizeof(irc->whois)); |
| 338 | } | |
| 339 | ||
| 8114 | 340 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 341 | { | |
| 342 | if (!irc->roomlist) | |
| 343 | return; | |
| 344 | ||
| 345 | if (!strcmp(name, "321")) { | |
| 15884 | 346 | purple_roomlist_set_in_progress(irc->roomlist, TRUE); |
| 8114 | 347 | return; |
| 348 | } | |
| 349 | ||
| 350 | if (!strcmp(name, "323")) { | |
| 15884 | 351 | purple_roomlist_set_in_progress(irc->roomlist, FALSE); |
| 352 | purple_roomlist_unref(irc->roomlist); | |
| 8114 | 353 | irc->roomlist = NULL; |
|
13667
9ebf0007d912
[gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents:
13647
diff
changeset
|
354 | return; |
| 8114 | 355 | } |
| 356 | ||
| 357 | if (!strcmp(name, "322")) { | |
| 15884 | 358 | PurpleRoomlistRoom *room; |
| 8114 | 359 | |
| 360 | if (!args[0] || !args[1] || !args[2] || !args[3]) | |
| 361 | return; | |
| 362 | ||
| 15884 | 363 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); |
| 364 | purple_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
| 365 | purple_roomlist_room_add_field(irc->roomlist, room, GINT_TO_POINTER(strtol(args[2], NULL, 10))); | |
| 366 | purple_roomlist_room_add_field(irc->roomlist, room, args[3]); | |
| 367 | purple_roomlist_room_add(irc->roomlist, room); | |
| 8114 | 368 | } |
| 369 | } | |
| 370 | ||
| 6333 | 371 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 372 | { | |
| 9762 | 373 | char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
| 15884 | 374 | PurpleConversation *convo; |
| 6333 | 375 | |
| 376 | if (!strcmp(name, "topic")) { | |
| 377 | chan = args[0]; | |
| 8529 | 378 | topic = irc_mirc2txt (args[1]); |
| 6333 | 379 | } else { |
| 380 | chan = args[1]; | |
| 8529 | 381 | topic = irc_mirc2txt (args[2]); |
| 6333 | 382 | } |
| 383 | ||
| 15884 | 384 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chan, irc->account); |
|
13647
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
385 | if (!convo) { |
| 15884 | 386 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan); |
|
13647
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
387 | g_free(topic); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
388 | return; |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
389 | } |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
390 | |
| 6333 | 391 | /* If this is an interactive update, print it out */ |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
392 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 393 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 394 | g_free(tmp); |
| 6333 | 395 | if (!strcmp(name, "topic")) { |
| 15884 | 396 | const char *current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(convo)); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
397 | if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0)) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
398 | { |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
399 | char *nick_esc; |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
400 | nick = irc_mask_nick(from); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
401 | nick_esc = g_markup_escape_text(nick, -1); |
| 15884 | 402 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), nick, topic); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
403 | if (*tmp2) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
404 | msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
405 | else |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
406 | msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
407 | g_free(nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
408 | g_free(nick); |
| 15884 | 409 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), from, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
410 | g_free(msg); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
411 | } |
| 6333 | 412 | } else { |
|
13395
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
413 | char *chan_esc = g_markup_escape_text(chan, -1); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
414 | msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
415 | g_free(chan_esc); |
| 15884 | 416 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic); |
| 417 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
| 6333 | 418 | g_free(msg); |
| 419 | } | |
| 9762 | 420 | g_free(tmp2); |
| 8529 | 421 | g_free(topic); |
| 6333 | 422 | } |
| 423 | ||
| 424 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 425 | { | |
| 15884 | 426 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 427 | char *buf; |
| 428 | ||
| 429 | if (!args || !args[1] || !gc) | |
| 430 | return; | |
| 431 | ||
| 432 | buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
| 15884 | 433 | purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand.")); |
| 6333 | 434 | g_free(buf); |
| 435 | } | |
| 436 | ||
| 437 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 438 | { | |
| 439 | char *names, *cur, *end, *tmp, *msg; | |
| 15884 | 440 | PurpleConversation *convo; |
| 6333 | 441 | |
| 442 | if (!strcmp(name, "366")) { | |
| 15884 | 443 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 444 | if (!convo) { |
| 15884 | 445 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); |
| 6333 | 446 | g_string_free(irc->names, TRUE); |
| 447 | irc->names = NULL; | |
| 448 | return; | |
| 449 | } | |
| 450 | ||
| 451 | names = cur = g_string_free(irc->names, FALSE); | |
| 452 | irc->names = NULL; | |
| 15884 | 453 | if (purple_conversation_get_data(convo, IRC_NAMES_FLAG)) { |
|
11026
1f13c483db00
[gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents:
10816
diff
changeset
|
454 | msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
| 15884 | 455 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) |
| 456 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 457 | else |
| 15884 | 458 | purple_conv_im_write(PURPLE_CONV_IM(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 459 | g_free(msg); |
| 460 | } else { | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
461 | GList *users = NULL; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
462 | GList *flags = NULL; |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
463 | |
| 6333 | 464 | while (*cur) { |
| 15884 | 465 | PurpleConvChatBuddyFlags f = PURPLE_CBFLAGS_NONE; |
| 6333 | 466 | end = strchr(cur, ' '); |
| 467 | if (!end) | |
| 468 | end = cur + strlen(cur); | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
469 | if (*cur == '@') { |
| 15884 | 470 | f = PURPLE_CBFLAGS_OP; |
| 6333 | 471 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
472 | } else if (*cur == '%') { |
| 15884 | 473 | f = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
474 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
475 | } else if(*cur == '+') { |
| 15884 | 476 | f = PURPLE_CBFLAGS_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
477 | cur++; |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
478 | } else if(irc->mode_chars |
|
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
479 | && strchr(irc->mode_chars, *cur)) { |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
480 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
481 | } |
| 6333 | 482 | tmp = g_strndup(cur, end - cur); |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
483 | users = g_list_prepend(users, tmp); |
|
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
484 | flags = g_list_prepend(flags, GINT_TO_POINTER(f)); |
| 6333 | 485 | cur = end; |
| 486 | if (*cur) | |
| 487 | cur++; | |
| 488 | } | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
489 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
490 | if (users != NULL) { |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
491 | GList *l; |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
492 | |
| 15884 | 493 | purple_conv_chat_add_users(PURPLE_CONV_CHAT(convo), users, NULL, flags, FALSE); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
494 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
495 | for (l = users; l != NULL; l = l->next) |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
496 | g_free(l->data); |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
497 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
498 | g_list_free(users); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
499 | g_list_free(flags); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
500 | } |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
501 | |
| 15884 | 502 | purple_conversation_set_data(convo, IRC_NAMES_FLAG, |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
503 | GINT_TO_POINTER(TRUE)); |
| 6333 | 504 | } |
| 505 | g_free(names); | |
| 506 | } else { | |
| 507 | if (!irc->names) | |
| 508 | irc->names = g_string_new(""); | |
| 509 | ||
| 15313 | 510 | if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ') |
| 511 | irc->names = g_string_append_c(irc->names, ' '); | |
| 6333 | 512 | irc->names = g_string_append(irc->names, args[3]); |
| 513 | } | |
| 514 | } | |
| 515 | ||
| 516 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 517 | { | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
518 | char *escaped; |
| 6333 | 519 | |
| 520 | if (!irc->motd) | |
| 521 | irc->motd = g_string_new(""); | |
| 522 | ||
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
523 | if (!strcmp(name, "375")) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
524 | if (irc->motd) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
525 | g_string_free(irc->motd, TRUE); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
526 | irc->motd = g_string_new(""); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
527 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
528 | } else if (!strcmp(name, "376")) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
529 | /* We no longer have to do anything for ENDMOTD */ |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
530 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
531 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
532 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
533 | if (!irc->motd) { |
| 15884 | 534 | purple_debug_error("irc", "IRC server sent MOTD without STARTMOTD\n"); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
535 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
536 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
537 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
538 | escaped = g_markup_escape_text(args[1], -1); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
539 | g_string_append_printf(irc->motd, "%s<br>", escaped); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
540 | g_free(escaped); |
| 6333 | 541 | } |
| 542 | ||
| 10564 | 543 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 544 | { | |
| 15884 | 545 | PurpleConnection *gc; |
| 10564 | 546 | |
| 15884 | 547 | gc = purple_account_get_connection(irc->account); |
| 10564 | 548 | if (gc == NULL || args == NULL || args[2] == NULL) |
| 549 | return; | |
| 550 | ||
| 15884 | 551 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"), |
| 10564 | 552 | _("The IRC server's local time is:"), |
| 553 | args[2], NULL, NULL); | |
| 554 | } | |
| 555 | ||
| 7877 | 556 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 557 | { | |
| 15884 | 558 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 7877 | 559 | |
| 560 | if (gc == NULL || args == NULL || args[1] == NULL) | |
| 561 | return; | |
| 562 | ||
| 15884 | 563 | purple_notify_error(gc, NULL, _("No such channel"), args[1]); |
| 7877 | 564 | } |
| 565 | ||
| 6333 | 566 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 567 | { | |
| 15884 | 568 | PurpleConnection *gc; |
| 569 | PurpleConversation *convo; | |
| 6333 | 570 | |
| 15884 | 571 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 572 | if (convo) { |
| 15884 | 573 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) /* does this happen? */ |
| 574 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], _("no such channel"), | |
| 575 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 576 | else |
| 15884 | 577 | purple_conv_im_write(PURPLE_CONV_IM(convo), args[1], _("User is not logged in"), |
| 578 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 579 | } else { |
| 15884 | 580 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 581 | return; |
| 15884 | 582 | purple_notify_error(gc, NULL, _("No such nick or channel"), args[1]); |
| 6333 | 583 | } |
| 584 | ||
| 15884 | 585 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 586 | g_free(irc->whois.nick); |
| 587 | irc->whois.nick = NULL; | |
| 588 | } | |
| 589 | } | |
| 590 | ||
| 591 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 592 | { | |
| 15884 | 593 | PurpleConnection *gc; |
| 594 | PurpleConversation *convo; | |
| 6333 | 595 | |
| 15884 | 596 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 597 | if (convo) { |
| 15884 | 598 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 599 | } else { |
| 15884 | 600 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 601 | return; |
| 15884 | 602 | purple_notify_error(gc, NULL, _("Could not send"), args[2]); |
| 6333 | 603 | } |
| 604 | } | |
| 605 | ||
| 606 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 607 | { | |
| 15884 | 608 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 609 | |
| 15884 | 610 | purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); |
| 6333 | 611 | if (convo) { |
| 612 | /*g_slist_remove(irc->gc->buddy_chats, convo); | |
| 15884 | 613 | purple_conversation_set_account(convo, NULL);*/ |
| 614 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 615 | } |
| 616 | } | |
| 617 | ||
| 618 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 619 | { | |
| 15884 | 620 | PurpleConversation *convo; |
| 6333 | 621 | |
| 622 | if (!args || !args[1] || !args[2]) | |
| 623 | return; | |
| 624 | ||
| 15884 | 625 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 626 | if (!convo) |
| 627 | return; | |
| 628 | ||
| 15884 | 629 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 630 | } |
| 631 | ||
| 632 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 633 | { | |
| 15884 | 634 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 635 | GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 636 | char *nick = irc_mask_nick(from); | |
| 637 | ||
| 638 | if (!args || !args[1] || !gc) { | |
| 639 | g_free(nick); | |
| 640 | g_hash_table_destroy(components); | |
| 641 | return; | |
| 642 | } | |
| 643 | ||
| 644 | g_hash_table_insert(components, strdup("channel"), strdup(args[1])); | |
| 645 | ||
| 646 | serv_got_chat_invite(gc, args[1], nick, NULL, components); | |
| 647 | g_free(nick); | |
| 648 | } | |
| 649 | ||
| 650 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 651 | { | |
| 15884 | 652 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 653 | char *buf; |
| 654 | ||
| 655 | if (!args || !args[1] || !gc) | |
| 656 | return; | |
| 657 | ||
| 658 | buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
| 15884 | 659 | purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf); |
| 6333 | 660 | g_free(buf); |
| 661 | } | |
| 662 | ||
| 663 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 664 | { | |
| 665 | char **nicks; | |
| 666 | struct irc_buddy *ib; | |
| 667 | int i; | |
| 668 | ||
| 669 | if (!args || !args[1]) | |
| 670 | return; | |
| 671 | ||
| 672 | nicks = g_strsplit(args[1], " ", -1); | |
| 673 | ||
| 674 | for (i = 0; nicks[i]; i++) { | |
| 675 | if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
| 676 | continue; | |
| 677 | } | |
| 678 | ib->flag = TRUE; | |
| 679 | } | |
| 680 | ||
| 6350 | 681 | g_strfreev(nicks); |
| 682 | ||
| 6333 | 683 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
| 684 | } | |
| 685 | ||
| 686 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
| 687 | { | |
| 15884 | 688 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 689 | PurpleBuddy *buddy = purple_find_buddy(irc->account, name); | |
| 6333 | 690 | |
| 691 | if (!gc || !buddy) | |
| 692 | return; | |
| 693 | ||
| 694 | if (ib->online && !ib->flag) { | |
| 15884 | 695 | purple_prpl_got_user_status(irc->account, name, "offline", NULL); |
| 6333 | 696 | ib->online = FALSE; |
| 10242 | 697 | } else if (!ib->online && ib->flag) { |
| 15884 | 698 | purple_prpl_got_user_status(irc->account, name, "available", NULL); |
| 6333 | 699 | ib->online = TRUE; |
| 700 | } | |
| 701 | } | |
| 702 | ||
| 703 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 704 | { | |
| 15884 | 705 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 706 | PurpleConversation *convo; | |
| 6333 | 707 | char *nick = irc_mask_nick(from), *userhost; |
| 9238 | 708 | struct irc_buddy *ib; |
| 6333 | 709 | static int id = 1; |
| 710 | ||
| 711 | if (!gc) { | |
| 712 | g_free(nick); | |
| 713 | return; | |
| 714 | } | |
| 715 | ||
| 15884 | 716 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 6333 | 717 | /* We are joining a channel for the first time */ |
| 718 | serv_got_joined_chat(gc, id++, args[0]); | |
| 719 | g_free(nick); | |
| 15884 | 720 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
| 13938 | 721 | args[0], |
| 722 | irc->account); | |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
723 | |
| 13938 | 724 | if (convo == NULL) { |
| 15884 | 725 | purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]); |
| 13938 | 726 | return; |
| 727 | } | |
| 15884 | 728 | purple_conversation_set_data(convo, IRC_NAMES_FLAG, |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
729 | GINT_TO_POINTER(FALSE)); |
| 15884 | 730 | purple_conversation_present(convo); |
| 6333 | 731 | return; |
| 732 | } | |
| 733 | ||
| 15884 | 734 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 735 | if (convo == NULL) { |
| 15884 | 736 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); |
| 6333 | 737 | g_free(nick); |
| 738 | return; | |
| 739 | } | |
| 740 | ||
| 741 | userhost = irc_mask_userhost(from); | |
| 15884 | 742 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE); |
| 9238 | 743 | |
| 744 | if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { | |
| 745 | ib->flag = TRUE; | |
| 746 | irc_buddy_status(nick, ib, irc); | |
| 747 | } | |
| 748 | ||
| 6333 | 749 | g_free(userhost); |
| 750 | g_free(nick); | |
| 751 | } | |
| 752 | ||
| 753 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 754 | { | |
| 15884 | 755 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 756 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
757 | char *nick = irc_mask_nick(from), *buf; |
| 6333 | 758 | |
| 759 | if (!gc) { | |
| 760 | g_free(nick); | |
| 761 | return; | |
| 762 | } | |
| 763 | ||
| 764 | if (!convo) { | |
| 15884 | 765 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Recieved a KICK for unknown channel %s\n", args[0]); |
| 6333 | 766 | g_free(nick); |
| 767 | return; | |
| 768 | } | |
| 769 | ||
| 15884 | 770 | if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
771 | buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
| 15884 | 772 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 773 | g_free(buf); |
| 15884 | 774 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 775 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
776 | buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
| 15884 | 777 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), args[1], buf); |
| 6333 | 778 | g_free(buf); |
| 779 | } | |
| 780 | ||
| 781 | g_free(nick); | |
| 782 | return; | |
| 783 | } | |
| 784 | ||
| 785 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 786 | { | |
| 15884 | 787 | PurpleConversation *convo; |
| 6333 | 788 | char *nick = irc_mask_nick(from), *buf; |
| 789 | ||
| 790 | if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
791 | char *escaped; |
| 15884 | 792 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 793 | if (!convo) { |
| 15884 | 794 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); |
| 6333 | 795 | g_free(nick); |
| 796 | return; | |
| 797 | } | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
798 | escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL; |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
799 | buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); |
| 15884 | 800 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
801 | g_free(escaped); |
| 6333 | 802 | g_free(buf); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
803 | if(args[2]) { |
| 15884 | 804 | PurpleConvChatBuddyFlags newflag, flags; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
805 | char *mcur, *cur, *end, *user; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
806 | gboolean add = FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
807 | mcur = args[1]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
808 | cur = args[2]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
809 | while (*cur && *mcur) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
810 | if ((*mcur == '+') || (*mcur == '-')) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
811 | add = (*mcur == '+') ? TRUE : FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
812 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
813 | continue; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
814 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
815 | end = strchr(cur, ' '); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
816 | if (!end) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
817 | end = cur + strlen(cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
818 | user = g_strndup(cur, end - cur); |
| 15884 | 819 | flags = purple_conv_chat_user_get_flags(PURPLE_CONV_CHAT(convo), user); |
| 820 | newflag = PURPLE_CBFLAGS_NONE; | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
821 | if (*mcur == 'o') |
| 15884 | 822 | newflag = PURPLE_CBFLAGS_OP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
823 | else if (*mcur =='h') |
| 15884 | 824 | newflag = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
825 | else if (*mcur == 'v') |
| 15884 | 826 | newflag = PURPLE_CBFLAGS_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
827 | if (newflag) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
828 | if (add) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
829 | flags |= newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
830 | else |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
831 | flags &= ~newflag; |
| 15884 | 832 | purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(convo), user, flags); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
833 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
834 | g_free(user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
835 | cur = end; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
836 | if (*cur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
837 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
838 | if (*mcur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
839 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
840 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
841 | } |
| 6333 | 842 | } else { /* User */ |
| 843 | } | |
| 844 | g_free(nick); | |
| 845 | } | |
| 846 | ||
| 847 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 848 | { | |
| 15884 | 849 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 850 | PurpleConversation *conv; | |
| 6333 | 851 | GSList *chats; |
| 852 | char *nick = irc_mask_nick(from); | |
| 853 | ||
| 854 | if (!gc) { | |
| 855 | g_free(nick); | |
| 856 | return; | |
| 857 | } | |
| 858 | chats = gc->buddy_chats; | |
| 859 | ||
| 15884 | 860 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 861 | purple_connection_set_display_name(gc, args[0]); | |
| 6333 | 862 | } |
| 863 | ||
| 864 | while (chats) { | |
| 15884 | 865 | PurpleConvChat *chat = PURPLE_CONV_CHAT(chats->data); |
| 9593 | 866 | /* This is ugly ... */ |
| 15884 | 867 | if (purple_conv_chat_find_user(chat, nick)) |
| 868 | purple_conv_chat_rename_user(chat, nick, args[0]); | |
| 6333 | 869 | chats = chats->next; |
| 870 | } | |
| 10617 | 871 | |
| 15884 | 872 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, nick, |
| 10617 | 873 | irc->account); |
| 874 | if (conv != NULL) | |
| 15884 | 875 | purple_conversation_set_name(conv, args[0]); |
| 10617 | 876 | |
| 6333 | 877 | g_free(nick); |
| 878 | } | |
| 879 | ||
| 10633 | 880 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 881 | { | |
| 15884 | 882 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 883 | if (purple_connection_get_state(gc) == PURPLE_CONNECTED) { | |
| 884 | purple_notify_error(gc, _("Invalid nickname"), | |
| 13057 | 885 | _("Invalid nickname"), |
| 886 | _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); | |
| 887 | ||
| 888 | } else { | |
|
14731
a557d0ef5152
[gaim-migrate @ 17415]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14254
diff
changeset
|
889 | gc->wants_to_die = TRUE; |
| 15884 | 890 | purple_connection_error(purple_account_get_connection(irc->account), |
| 13057 | 891 | _("Your selected account name was rejected by the server. It probably contains invalid characters.")); |
| 892 | } | |
| 10633 | 893 | } |
| 894 | ||
| 6333 | 895 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 896 | { | |
| 897 | char *newnick, *buf, *end; | |
| 898 | ||
| 899 | if (!args || !args[1]) | |
| 900 | return; | |
| 901 | ||
| 902 | newnick = strdup(args[1]); | |
| 903 | end = newnick + strlen(newnick) - 1; | |
|
11386
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
904 | /* try fallbacks */ |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
905 | if((*end < '9') && (*end >= '1')) { |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
906 | *end = *end + 1; |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
907 | } else *end = '1'; |
| 6333 | 908 | |
| 909 | buf = irc_format(irc, "vn", "NICK", newnick); | |
| 910 | irc_send(irc, buf); | |
| 911 | g_free(buf); | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
912 | g_free(newnick); |
| 6333 | 913 | } |
| 914 | ||
| 915 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 916 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
917 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
918 | return; |
| 6333 | 919 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
920 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE); |
| 6333 | 921 | } |
| 922 | ||
| 6718 | 923 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 924 | { | |
| 15884 | 925 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6718 | 926 | |
| 6753 | 927 | if (!args || !args[2] || !gc) |
| 6718 | 928 | return; |
| 929 | ||
| 15884 | 930 | purple_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]); |
| 6718 | 931 | } |
| 932 | ||
| 6333 | 933 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 934 | { | |
| 15884 | 935 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 936 | PurpleConversation *convo; | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
937 | char *nick, *msg; |
| 6333 | 938 | |
| 8186 | 939 | if (!args || !args[0] || !gc) |
| 6333 | 940 | return; |
| 941 | ||
| 15884 | 942 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 943 | if (!convo) { |
| 15884 | 944 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", args[0]); |
| 6333 | 945 | return; |
| 946 | } | |
| 947 | ||
| 948 | nick = irc_mask_nick(from); | |
| 15884 | 949 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
950 | char *escaped = g_markup_escape_text(args[1], -1); |
| 8186 | 951 | msg = g_strdup_printf(_("You have parted the channel%s%s"), |
|
10551
9a6a1e333609
[gaim-migrate @ 11926]
Daniel Atallah <datallah@pidgin.im>
parents:
10504
diff
changeset
|
952 | (args[1] && *args[1]) ? ": " : "", |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
953 | (escaped && *escaped) ? escaped : ""); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
954 | g_free(escaped); |
| 15884 | 955 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 956 | g_free(msg); |
| 15884 | 957 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 958 | } else { |
| 15884 | 959 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nick, args[1]); |
| 6333 | 960 | } |
| 961 | g_free(nick); | |
| 962 | } | |
| 963 | ||
| 964 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 965 | { | |
| 966 | char *buf; | |
| 967 | if (!args || !args[0]) | |
| 968 | return; | |
| 969 | ||
| 970 | buf = irc_format(irc, "v:", "PONG", args[0]); | |
| 971 | irc_send(irc, buf); | |
| 972 | g_free(buf); | |
| 973 | } | |
| 974 | ||
| 975 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 976 | { | |
| 15884 | 977 | PurpleConversation *convo; |
| 978 | PurpleConnection *gc; | |
| 6333 | 979 | char **parts, *msg; |
| 980 | time_t oldstamp; | |
| 981 | ||
| 982 | if (!args || !args[1]) | |
| 983 | return; | |
| 984 | ||
| 985 | parts = g_strsplit(args[1], " ", 2); | |
| 986 | ||
| 987 | if (!parts[0] || !parts[1]) { | |
| 988 | g_strfreev(parts); | |
| 989 | return; | |
| 990 | } | |
| 991 | ||
| 992 | if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
| 993 | msg = g_strdup(_("Error: invalid PONG from server")); | |
| 994 | } else { | |
| 6350 | 995 | msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
| 6333 | 996 | } |
| 997 | ||
| 15884 | 998 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, parts[0], irc->account); |
| 6333 | 999 | g_strfreev(parts); |
| 1000 | if (convo) { | |
| 15884 | 1001 | if (purple_conversation_get_type (convo) == PURPLE_CONV_TYPE_CHAT) |
| 1002 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 1003 | else |
| 15884 | 1004 | purple_conv_im_write(PURPLE_CONV_IM(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 1005 | } else { |
| 15884 | 1006 | gc = purple_account_get_connection(irc->account); |
| 6333 | 1007 | if (!gc) { |
| 1008 | g_free(msg); | |
| 1009 | return; | |
| 1010 | } | |
| 15884 | 1011 | purple_notify_info(gc, NULL, "PONG", msg); |
| 6333 | 1012 | } |
| 1013 | g_free(msg); | |
| 1014 | } | |
| 1015 | ||
| 1016 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1017 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1018 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1019 | return; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1020 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1021 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], FALSE); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1022 | } |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1023 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1024 | static void irc_msg_handle_privmsg(struct irc_conn *irc, const char *name, const char *from, const char *to, const char *rawmsg, gboolean notice) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1025 | { |
| 15884 | 1026 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1027 | PurpleConversation *convo; | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1028 | char *tmp; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1029 | char *msg; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1030 | char *nick; |
| 6333 | 1031 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1032 | if (!gc) |
| 6333 | 1033 | return; |
| 1034 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1035 | nick = irc_mask_nick(from); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1036 | tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice); |
| 6333 | 1037 | if (!tmp) { |
| 1038 | g_free(nick); | |
| 1039 | return; | |
| 1040 | } | |
| 8163 | 1041 | |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
1042 | msg = g_markup_escape_text(tmp, -1); |
| 6333 | 1043 | g_free(tmp); |
| 8163 | 1044 | |
| 1045 | tmp = irc_mirc2html(msg); | |
| 1046 | g_free(msg); | |
| 1047 | msg = tmp; | |
| 6333 | 1048 | if (notice) { |
| 1049 | tmp = g_strdup_printf("(notice) %s", msg); | |
| 1050 | g_free(msg); | |
| 1051 | msg = tmp; | |
| 1052 | } | |
| 1053 | ||
| 15884 | 1054 | if (!purple_utf8_strcasecmp(to, purple_connection_get_display_name(gc))) { |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6753
diff
changeset
|
1055 | serv_got_im(gc, nick, msg, 0, time(NULL)); |
| 6333 | 1056 | } else { |
| 15884 | 1057 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, to, irc->account); |
| 6333 | 1058 | if (convo) |
| 15884 | 1059 | serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); |
| 6333 | 1060 | else |
| 15884 | 1061 | purple_debug_error("irc", "Got a %s on %s, which does not exist\n", |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1062 | notice ? "NOTICE" : "PRIVMSG", to); |
| 6333 | 1063 | } |
| 1064 | g_free(msg); | |
| 1065 | g_free(nick); | |
| 1066 | } | |
| 1067 | ||
| 6714 | 1068 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1069 | { | |
| 15884 | 1070 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6714 | 1071 | char *msg; |
| 1072 | ||
| 1073 | if (!args || !args[1] || !args[2] || !gc) | |
| 1074 | return; | |
| 1075 | ||
| 1076 | msg = g_strdup_printf(_("Cannot join %s:"), args[1]); | |
| 15884 | 1077 | purple_notify_error(gc, _("Cannot join channel"), msg, args[2]); |
| 6714 | 1078 | g_free(msg); |
| 1079 | } | |
| 1080 | ||
| 6333 | 1081 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1082 | { | |
| 15884 | 1083 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 9238 | 1084 | struct irc_buddy *ib; |
| 6333 | 1085 | char *data[2]; |
| 1086 | ||
| 1087 | if (!args || !args[0] || !gc) | |
| 1088 | return; | |
| 1089 | ||
| 1090 | data[0] = irc_mask_nick(from); | |
| 1091 | data[1] = args[0]; | |
| 1092 | /* XXX this should have an API, I shouldn't grab this directly */ | |
| 1093 | g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); | |
| 9238 | 1094 | |
| 1095 | if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) { | |
| 1096 | ib->flag = FALSE; | |
| 1097 | irc_buddy_status(data[0], ib, irc); | |
| 1098 | } | |
| 6333 | 1099 | g_free(data[0]); |
| 1100 | ||
| 1101 | return; | |
| 1102 | } | |
| 1103 | ||
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1104 | void irc_msg_unavailable(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1105 | { |
| 15884 | 1106 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1107 | |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1108 | if (!args || !args[1]) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1109 | return; |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1110 | |
| 15884 | 1111 | purple_notify_error(gc, NULL, _("Nick or channel is temporarily unavailable."), args[1]); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1112 | } |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1113 | |
| 6333 | 1114 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1115 | { | |
| 15884 | 1116 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1117 | char *nick, *msg; |
| 6333 | 1118 | |
| 1119 | if (!args || !args[0] || !gc) | |
| 1120 | return; | |
| 1121 | ||
| 1122 | nick = irc_mask_nick(from); | |
| 1123 | msg = g_strdup_printf (_("Wallops from %s"), nick); | |
| 1124 | g_free(nick); | |
| 15884 | 1125 | purple_notify_info(gc, NULL, msg, args[0]); |
| 6333 | 1126 | g_free(msg); |
| 1127 | } | |
| 1128 | ||
| 1129 | void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1130 | { | |
| 1131 | return; | |
| 1132 | } |