Mercurial > pidgin.yaz
annotate src/protocols/irc/msgs.c @ 13516:4279e5b5e9ac
[gaim-migrate @ 15892]
Bring MSN HTTP method closer to working again. Thanks to wabs in #gaim for noticing my braindead mistakes and pointing me in the right direction. This still needs more work.
committer: Tailor Script <tailor@pidgin.im>
author | Daniel Atallah <daniel.atallah@gmail.com> |
---|---|
date | Wed, 15 Mar 2006 04:51:59 +0000 |
parents | eb0ce960ff60 |
children | 5ddae6fe983e |
rev | line source |
---|---|
6333 | 1 /** |
2 * @file msgs.c | |
3 * | |
4 * gaim | |
5 * | |
6 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
7 * | |
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); | |
36 static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2]); | |
37 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc); | |
38 | |
39 static char *irc_mask_nick(const char *mask) | |
40 { | |
41 char *end, *buf; | |
42 | |
43 end = strchr(mask, '!'); | |
44 if (!end) | |
45 buf = g_strdup(mask); | |
46 else | |
47 buf = g_strndup(mask, end - mask); | |
48 | |
49 return buf; | |
50 } | |
51 | |
52 static char *irc_mask_userhost(const char *mask) | |
53 { | |
54 return g_strdup(strchr(mask, '!') + 1); | |
55 } | |
56 | |
57 static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2]) | |
58 { | |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
59 char *message; |
10730 | 60 |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
61 message = g_strdup_printf("quit: %s", data[1]); |
6333 | 62 |
9554 | 63 if (gaim_conv_chat_find_user(GAIM_CONV_CHAT(convo), data[0])) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
64 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), data[0], message); |
6333 | 65 |
66 g_free(message); | |
67 } | |
68 | |
69 void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) | |
70 { | |
71 gaim_debug(GAIM_DEBUG_INFO, "irc", "Unrecognized message: %s\n", args[0]); | |
72 } | |
73 | |
74 void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) | |
75 { | |
76 GaimConnection *gc; | |
10774 | 77 char *msg; |
6333 | 78 |
79 if (!args || !args[1]) | |
80 return; | |
81 | |
82 if (irc->whois.nick && !gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
83 /* We're doing a whois, show this in the whois dialog */ | |
84 irc_msg_whois(irc, name, from, args); | |
85 return; | |
86 } | |
87 | |
88 gc = gaim_account_get_connection(irc->account); | |
10774 | 89 if (gc) { |
90 msg = g_markup_escape_text(args[2], -1); | |
12216 | 91 serv_got_im(gc, args[1], msg, GAIM_MESSAGE_AUTO_RESP, time(NULL)); |
10774 | 92 g_free(msg); |
93 } | |
6333 | 94 } |
95 | |
96 void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
97 { | |
98 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
99 | |
100 if (!args || !args[1] || !gc) | |
101 return; | |
102 | |
103 gaim_notify_error(gc, NULL, _("Bad mode"), args[1]); | |
104 } | |
105 | |
106 void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) | |
107 { | |
108 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
109 char *buf; | |
110 | |
111 if (!args || !args[1] || !gc) | |
112 return; | |
113 | |
114 buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
115 gaim_notify_error(gc, _("Banned"), _("Banned"), buf); | |
116 g_free(buf); | |
117 } | |
118 | |
10659 | 119 void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args) |
120 { | |
121 GaimConversation *convo; | |
122 char *buf, *nick; | |
123 | |
124 if (!args || !args[0] || !args[1] || !args[2]) | |
125 return; | |
126 | |
11338 | 127 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
10659 | 128 if (!convo) |
129 return; | |
130 | |
131 nick = g_markup_escape_text(args[2], -1); | |
132 buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); | |
133 g_free(nick); | |
134 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, | |
135 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, | |
136 time(NULL)); | |
137 g_free(buf); | |
138 } | |
139 | |
6333 | 140 void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
141 { | |
142 GaimConversation *convo; | |
10774 | 143 char *buf, *escaped; |
6333 | 144 |
145 if (!args || !args[1] || !args[2]) | |
146 return; | |
147 | |
11338 | 148 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
6333 | 149 if (!convo) /* XXX punt on channels we are not in for now */ |
150 return; | |
151 | |
10774 | 152 escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL; |
153 buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); | |
12069
1019f1d510d6
[gaim-migrate @ 14364]
Richard Laager <rlaager@wiktel.com>
parents:
12001
diff
changeset
|
154 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
10774 | 155 g_free(escaped); |
6333 | 156 g_free(buf); |
157 | |
158 return; | |
159 } | |
160 | |
161 void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
162 { | |
163 if (!irc->whois.nick) { | |
164 gaim_debug(GAIM_DEBUG_WARNING, "irc", "Unexpected WHOIS reply for %s\n", args[1]); | |
165 return; | |
166 } | |
167 | |
168 if (gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
169 gaim_debug(GAIM_DEBUG_WARNING, "irc", "Got WHOIS reply for %s while waiting for %s\n", args[1], irc->whois.nick); | |
170 return; | |
171 } | |
172 | |
173 if (!strcmp(name, "301")) { | |
174 irc->whois.away = g_strdup(args[2]); | |
175 } else if (!strcmp(name, "311")) { | |
176 irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]); | |
177 irc->whois.name = g_strdup(args[5]); | |
178 } else if (!strcmp(name, "312")) { | |
179 irc->whois.server = g_strdup(args[2]); | |
180 irc->whois.serverinfo = g_strdup(args[3]); | |
181 } else if (!strcmp(name, "313")) { | |
182 irc->whois.ircop = 1; | |
183 } else if (!strcmp(name, "317")) { | |
184 irc->whois.idle = atoi(args[2]); | |
185 if (args[3]) | |
186 irc->whois.signon = (time_t)atoi(args[3]); | |
187 } else if (!strcmp(name, "319")) { | |
188 irc->whois.channels = g_strdup(args[2]); | |
189 } else if (!strcmp(name, "320")) { | |
190 irc->whois.identified = 1; | |
191 } | |
192 } | |
193 | |
194 void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
195 { | |
196 GaimConnection *gc; | |
197 GString *info; | |
10634 | 198 char *str, *tmp; |
6333 | 199 |
200 if (!irc->whois.nick) { | |
201 gaim_debug(GAIM_DEBUG_WARNING, "irc", "Unexpected End of WHOIS for %s\n", args[1]); | |
202 return; | |
203 } | |
204 if (gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
205 gaim_debug(GAIM_DEBUG_WARNING, "irc", "Received end of WHOIS for %s, expecting %s\n", args[1], irc->whois.nick); | |
206 return; | |
207 } | |
208 | |
209 info = g_string_new(""); | |
10634 | 210 tmp = g_markup_escape_text(args[1], -1); |
211 g_string_append_printf(info, _("<b>%s:</b> %s"), _("Nick"), tmp); | |
212 g_free(tmp); | |
9558 | 213 g_string_append_printf(info, "%s%s<br>", |
6333 | 214 irc->whois.ircop ? _(" <i>(ircop)</i>") : "", |
215 irc->whois.identified ? _(" <i>(identified)</i>") : ""); | |
216 if (irc->whois.away) { | |
10634 | 217 tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); |
6333 | 218 g_free(irc->whois.away); |
9589 | 219 g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Away"), tmp); |
220 g_free(tmp); | |
6333 | 221 } |
222 if (irc->whois.userhost) { | |
10634 | 223 tmp = g_markup_escape_text(irc->whois.name, strlen(irc->whois.name)); |
9589 | 224 g_free(irc->whois.name); |
9558 | 225 g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Username"), irc->whois.userhost); |
9589 | 226 g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Realname"), tmp); |
6333 | 227 g_free(irc->whois.userhost); |
9589 | 228 g_free(tmp); |
6333 | 229 } |
230 if (irc->whois.server) { | |
9558 | 231 g_string_append_printf(info, _("<b>%s:</b> %s"), _("Server"), irc->whois.server); |
232 g_string_append_printf(info, " (%s)<br>", irc->whois.serverinfo); | |
6333 | 233 g_free(irc->whois.server); |
234 g_free(irc->whois.serverinfo); | |
235 } | |
236 if (irc->whois.channels) { | |
9558 | 237 g_string_append_printf(info, _("<b>%s:</b> %s<br>"), _("Currently on"), irc->whois.channels); |
6333 | 238 g_free(irc->whois.channels); |
239 } | |
240 if (irc->whois.idle) { | |
7108
6faeeecab0dc
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
241 gchar *timex = gaim_str_seconds_to_string(irc->whois.idle); |
6357 | 242 g_string_append_printf(info, _("<b>Idle for:</b> %s<br>"), timex); |
243 g_free(timex); | |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
244 g_string_append_printf(info, _("<b>%s:</b> %s"), _("Online since"), |
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
245 gaim_date_format_full(localtime(&irc->whois.signon))); |
6333 | 246 } |
247 if (!strcmp(irc->whois.nick, "Paco-Paco")) { | |
248 g_string_append_printf(info, _("<br><b>Defining adjective:</b> Glorious<br>")); | |
249 } | |
250 | |
251 gc = gaim_account_get_connection(irc->account); | |
252 str = g_string_free(info, FALSE); | |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
253 |
11533
c9b815aeddc1
[gaim-migrate @ 13782]
Richard Laager <rlaager@wiktel.com>
parents:
11531
diff
changeset
|
254 gaim_notify_userinfo(gc, irc->whois.nick, str, NULL, NULL); |
7062
86ed8b2aa665
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
255 |
10504 | 256 g_free(irc->whois.nick); |
6333 | 257 g_free(str); |
258 memset(&irc->whois, 0, sizeof(irc->whois)); | |
259 } | |
260 | |
8114 | 261 void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
262 { | |
263 if (!irc->roomlist) | |
264 return; | |
265 | |
266 if (!strcmp(name, "321")) { | |
267 gaim_roomlist_set_in_progress(irc->roomlist, TRUE); | |
268 return; | |
269 } | |
270 | |
271 if (!strcmp(name, "323")) { | |
272 gaim_roomlist_set_in_progress(irc->roomlist, FALSE); | |
273 gaim_roomlist_unref(irc->roomlist); | |
274 irc->roomlist = NULL; | |
275 } | |
276 | |
277 if (!strcmp(name, "322")) { | |
278 GaimRoomlistRoom *room; | |
279 | |
280 if (!args[0] || !args[1] || !args[2] || !args[3]) | |
281 return; | |
282 | |
283 room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); | |
284 gaim_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
285 gaim_roomlist_room_add_field(irc->roomlist, room, GINT_TO_POINTER(strtol(args[2], NULL, 10))); | |
286 gaim_roomlist_room_add_field(irc->roomlist, room, args[3]); | |
287 gaim_roomlist_room_add(irc->roomlist, room); | |
288 } | |
289 } | |
290 | |
6333 | 291 void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
292 { | |
9762 | 293 char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
6333 | 294 GaimConversation *convo; |
295 | |
296 if (!strcmp(name, "topic")) { | |
297 chan = args[0]; | |
8529 | 298 topic = irc_mirc2txt (args[1]); |
6333 | 299 } else { |
300 chan = args[1]; | |
8529 | 301 topic = irc_mirc2txt (args[2]); |
6333 | 302 } |
303 | |
11338 | 304 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, chan, irc->account); |
6333 | 305 if (!convo) { |
306 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan); | |
307 } | |
9518 | 308 |
6333 | 309 /* If this is an interactive update, print it out */ |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10730
diff
changeset
|
310 tmp = g_markup_escape_text(topic, -1); |
9762 | 311 tmp2 = gaim_markup_linkify(tmp); |
312 g_free(tmp); | |
6333 | 313 if (!strcmp(name, "topic")) { |
13394
eb0ce960ff60
[gaim-migrate @ 15767]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
314 char *nick_esc; |
6333 | 315 nick = irc_mask_nick(from); |
13394
eb0ce960ff60
[gaim-migrate @ 15767]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
316 nick_esc = g_markup_escape_text(nick, -1); |
9518 | 317 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), nick, topic); |
13394
eb0ce960ff60
[gaim-migrate @ 15767]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
318 msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2); |
eb0ce960ff60
[gaim-migrate @ 15767]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
319 g_free(nick_esc); |
6333 | 320 g_free(nick); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
321 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), from, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); |
6333 | 322 g_free(msg); |
323 } else { | |
13394
eb0ce960ff60
[gaim-migrate @ 15767]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
324 char *chan_esc = g_markup_escape_text(chan, -1); |
eb0ce960ff60
[gaim-migrate @ 15767]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
325 msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2); |
eb0ce960ff60
[gaim-migrate @ 15767]
Richard Laager <rlaager@wiktel.com>
parents:
13119
diff
changeset
|
326 g_free(chan_esc); |
9518 | 327 gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, topic); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
328 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM, time(NULL)); |
6333 | 329 g_free(msg); |
330 } | |
9762 | 331 g_free(tmp2); |
8529 | 332 g_free(topic); |
6333 | 333 } |
334 | |
335 void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) | |
336 { | |
337 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
338 char *buf; | |
339 | |
340 if (!args || !args[1] || !gc) | |
341 return; | |
342 | |
343 buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
344 gaim_notify_error(gc, _("Unknown message"), buf, _("Gaim has sent a message the IRC server did not understand.")); | |
345 g_free(buf); | |
346 } | |
347 | |
348 void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
349 { | |
350 char *names, *cur, *end, *tmp, *msg; | |
351 GaimConversation *convo; | |
352 | |
353 if (!strcmp(name, "366")) { | |
11338 | 354 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, irc->nameconv ? irc->nameconv : args[1], irc->account); |
6333 | 355 if (!convo) { |
356 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[2]); | |
357 g_string_free(irc->names, TRUE); | |
358 irc->names = NULL; | |
359 g_free(irc->nameconv); | |
360 irc->nameconv = NULL; | |
361 return; | |
362 } | |
363 | |
364 names = cur = g_string_free(irc->names, FALSE); | |
365 irc->names = NULL; | |
366 if (irc->nameconv) { | |
11026
a659e6bac294
[gaim-migrate @ 12901]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10816
diff
changeset
|
367 msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
11338 | 368 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
369 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 370 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
371 gaim_conv_im_write(GAIM_CONV_IM(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 372 g_free(msg); |
373 g_free(irc->nameconv); | |
374 irc->nameconv = NULL; | |
375 } else { | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
376 GList *users = NULL; |
9554 | 377 GList *flags = NULL; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
378 |
6333 | 379 while (*cur) { |
9554 | 380 GaimConvChatBuddyFlags f = GAIM_CBFLAGS_NONE; |
6333 | 381 end = strchr(cur, ' '); |
382 if (!end) | |
383 end = cur + strlen(cur); | |
9554 | 384 if (*cur == '@') { |
385 f = GAIM_CBFLAGS_OP; | |
6333 | 386 cur++; |
9554 | 387 } else if (*cur == '%') { |
388 f = GAIM_CBFLAGS_HALFOP; | |
389 cur++; | |
390 } else if(*cur == '+') { | |
391 f = GAIM_CBFLAGS_VOICE; | |
392 cur++; | |
393 } | |
6333 | 394 tmp = g_strndup(cur, end - cur); |
11869 | 395 users = g_list_prepend(users, tmp); |
396 flags = g_list_prepend(flags, GINT_TO_POINTER(f)); | |
6333 | 397 cur = end; |
398 if (*cur) | |
399 cur++; | |
400 } | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
401 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
402 if (users != NULL) { |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
403 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
404 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11386
diff
changeset
|
405 gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users, NULL, flags, FALSE); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
406 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
407 for (l = users; l != NULL; l = l->next) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
408 g_free(l->data); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
409 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
410 g_list_free(users); |
9554 | 411 g_list_free(flags); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
412 } |
6333 | 413 } |
414 g_free(names); | |
415 } else { | |
416 if (!irc->names) | |
417 irc->names = g_string_new(""); | |
418 | |
419 irc->names = g_string_append(irc->names, args[3]); | |
420 } | |
421 } | |
422 | |
423 void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
424 { | |
425 GaimConnection *gc; | |
10774 | 426 char *escaped; |
6333 | 427 if (!strcmp(name, "375")) { |
428 gc = gaim_account_get_connection(irc->account); | |
429 if (gc) | |
430 gaim_connection_set_display_name(gc, args[0]); | |
431 } | |
432 | |
433 if (!irc->motd) | |
434 irc->motd = g_string_new(""); | |
435 | |
10774 | 436 escaped = g_markup_escape_text(args[1], -1); |
437 g_string_append_printf(irc->motd, "%s<br>", escaped); | |
438 g_free(escaped); | |
6333 | 439 } |
440 | |
441 void irc_msg_endmotd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
442 { | |
443 GaimConnection *gc; | |
12001 | 444 GaimStatus *status; |
11489 | 445 GaimBlistNode *gnode, *cnode, *bnode; |
6333 | 446 |
447 gc = gaim_account_get_connection(irc->account); | |
448 if (!gc) | |
449 return; | |
450 | |
451 gaim_connection_set_state(gc, GAIM_CONNECTED); | |
452 | |
12001 | 453 /* If we're away then set our away message */ |
454 status = gaim_account_get_active_status(irc->account); | |
455 if (!gaim_status_get_type(status) != GAIM_STATUS_AVAILABLE) | |
456 { | |
457 GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
458 prpl_info->set_status(irc->account, status); | |
459 } | |
460 | |
11489 | 461 /* this used to be in the core, but it's not now */ |
462 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { | |
463 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
464 continue; | |
465 for(cnode = gnode->child; cnode; cnode = cnode->next) { | |
466 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
467 continue; | |
468 for(bnode = cnode->child; bnode; bnode = bnode->next) { | |
469 GaimBuddy *b; | |
470 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
471 continue; | |
472 b = (GaimBuddy *)bnode; | |
473 if(b->account == gc->account) { | |
474 struct irc_buddy *ib = g_new0(struct irc_buddy, 1); | |
475 ib->name = g_strdup(b->name); | |
476 g_hash_table_insert(irc->buddies, ib->name, ib); | |
477 } | |
478 } | |
479 } | |
480 } | |
481 | |
6333 | 482 irc_blist_timeout(irc); |
8872 | 483 if (!irc->timer) |
484 irc->timer = gaim_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc); | |
6333 | 485 } |
486 | |
10564 | 487 void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
488 { | |
489 GaimConnection *gc; | |
490 | |
491 gc = gaim_account_get_connection(irc->account); | |
492 if (gc == NULL || args == NULL || args[2] == NULL) | |
493 return; | |
494 | |
495 gaim_notify_message(gc, GAIM_NOTIFY_MSG_INFO, _("Time Response"), | |
496 _("The IRC server's local time is:"), | |
497 args[2], NULL, NULL); | |
498 } | |
499 | |
7877 | 500 void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
501 { | |
502 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
503 | |
504 if (gc == NULL || args == NULL || args[1] == NULL) | |
505 return; | |
506 | |
507 gaim_notify_error(gc, NULL, _("No such channel"), args[1]); | |
508 } | |
509 | |
6333 | 510 void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
511 { | |
512 GaimConnection *gc; | |
513 GaimConversation *convo; | |
514 | |
11338 | 515 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, args[1], irc->account); |
6333 | 516 if (convo) { |
11338 | 517 if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) /* does this happen? */ |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
518 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], _("no such channel"), |
6621 | 519 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 520 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
521 gaim_conv_im_write(GAIM_CONV_IM(convo), args[1], _("User is not logged in"), |
6621 | 522 GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 523 } else { |
524 if ((gc = gaim_account_get_connection(irc->account)) == NULL) | |
525 return; | |
10774 | 526 gaim_notify_error(gc, NULL, _("No such nick or channel"), args[1]); |
6333 | 527 } |
528 | |
529 if (irc->whois.nick && !gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
530 g_free(irc->whois.nick); | |
531 irc->whois.nick = NULL; | |
532 } | |
533 } | |
534 | |
535 void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
536 { | |
537 GaimConnection *gc; | |
538 GaimConversation *convo; | |
539 | |
11338 | 540 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
6333 | 541 if (convo) { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
542 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 543 } else { |
544 if ((gc = gaim_account_get_connection(irc->account)) == NULL) | |
545 return; | |
546 gaim_notify_error(gc, NULL, _("Could not send"), args[2]); | |
547 } | |
548 } | |
549 | |
550 void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
551 { | |
11338 | 552 GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
6333 | 553 |
554 gaim_debug(GAIM_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); | |
555 if (convo) { | |
556 /*g_slist_remove(irc->gc->buddy_chats, convo); | |
557 gaim_conversation_set_account(convo, NULL);*/ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
558 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 559 } |
560 } | |
561 | |
562 void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
563 { | |
564 GaimConversation *convo; | |
565 | |
566 if (!args || !args[1] || !args[2]) | |
567 return; | |
568 | |
11338 | 569 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
6333 | 570 if (!convo) |
571 return; | |
572 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
573 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", args[2], GAIM_MESSAGE_SYSTEM, time(NULL)); |
6333 | 574 } |
575 | |
576 void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
577 { | |
578 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
579 GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
580 char *nick = irc_mask_nick(from); | |
581 | |
582 if (!args || !args[1] || !gc) { | |
583 g_free(nick); | |
584 g_hash_table_destroy(components); | |
585 return; | |
586 } | |
587 | |
588 g_hash_table_insert(components, strdup("channel"), strdup(args[1])); | |
589 | |
590 serv_got_chat_invite(gc, args[1], nick, NULL, components); | |
591 g_free(nick); | |
592 } | |
593 | |
594 void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
595 { | |
596 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
597 char *buf; | |
598 | |
599 if (!args || !args[1] || !gc) | |
600 return; | |
601 | |
602 buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
603 gaim_notify_error(gc, _("Invitation only"), _("Invitation only"), buf); | |
604 g_free(buf); | |
605 } | |
606 | |
607 void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
608 { | |
609 char **nicks; | |
610 struct irc_buddy *ib; | |
611 int i; | |
612 | |
613 if (!args || !args[1]) | |
614 return; | |
615 | |
616 nicks = g_strsplit(args[1], " ", -1); | |
617 | |
618 for (i = 0; nicks[i]; i++) { | |
619 if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
620 continue; | |
621 } | |
622 ib->flag = TRUE; | |
623 } | |
624 | |
6350 | 625 g_strfreev(nicks); |
626 | |
6333 | 627 g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
628 } | |
629 | |
630 static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
631 { | |
632 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
6695 | 633 GaimBuddy *buddy = gaim_find_buddy(irc->account, name); |
6333 | 634 |
635 if (!gc || !buddy) | |
636 return; | |
637 | |
638 if (ib->online && !ib->flag) { | |
10242 | 639 gaim_prpl_got_user_status(irc->account, name, "offline", NULL); |
6333 | 640 ib->online = FALSE; |
10242 | 641 } else if (!ib->online && ib->flag) { |
11535 | 642 gaim_prpl_got_user_status(irc->account, name, "available", NULL); |
6333 | 643 ib->online = TRUE; |
644 } | |
645 } | |
646 | |
647 void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
648 { | |
649 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
650 GaimConversation *convo; | |
651 char *nick = irc_mask_nick(from), *userhost; | |
9238 | 652 struct irc_buddy *ib; |
6333 | 653 static int id = 1; |
654 | |
655 if (!gc) { | |
656 g_free(nick); | |
657 return; | |
658 } | |
659 | |
660 if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { | |
661 /* We are joining a channel for the first time */ | |
662 serv_got_joined_chat(gc, id++, args[0]); | |
663 g_free(nick); | |
664 return; | |
665 } | |
666 | |
11338 | 667 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
6333 | 668 if (convo == NULL) { |
669 gaim_debug(GAIM_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); | |
670 g_free(nick); | |
671 return; | |
672 } | |
673 | |
674 userhost = irc_mask_userhost(from); | |
9846 | 675 gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo), nick, userhost, GAIM_CBFLAGS_NONE, TRUE); |
9238 | 676 |
677 if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { | |
678 ib->flag = TRUE; | |
679 irc_buddy_status(nick, ib, irc); | |
680 } | |
681 | |
6333 | 682 g_free(userhost); |
683 g_free(nick); | |
684 } | |
685 | |
686 void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
687 { | |
688 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
11338 | 689 GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
690 char *nick = irc_mask_nick(from), *buf; |
6333 | 691 |
692 if (!gc) { | |
693 g_free(nick); | |
694 return; | |
695 } | |
696 | |
697 if (!convo) { | |
698 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Recieved a KICK for unknown channel %s\n", args[0]); | |
699 g_free(nick); | |
700 return; | |
701 } | |
702 | |
703 if (!gaim_utf8_strcasecmp(gaim_connection_get_display_name(gc), args[1])) { | |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
704 buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
705 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
6333 | 706 g_free(buf); |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8186
diff
changeset
|
707 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo))); |
6333 | 708 } else { |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
709 buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
710 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), args[1], buf); |
6333 | 711 g_free(buf); |
712 } | |
713 | |
714 g_free(nick); | |
715 return; | |
716 } | |
717 | |
718 void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
719 { | |
720 GaimConversation *convo; | |
721 char *nick = irc_mask_nick(from), *buf; | |
722 | |
723 if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
10774 | 724 char *escaped; |
11338 | 725 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
6333 | 726 if (!convo) { |
727 gaim_debug(GAIM_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); | |
728 g_free(nick); | |
729 return; | |
730 } | |
10774 | 731 escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL; |
732 buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); | |
12069
1019f1d510d6
[gaim-migrate @ 14364]
Richard Laager <rlaager@wiktel.com>
parents:
12001
diff
changeset
|
733 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
10774 | 734 g_free(escaped); |
6333 | 735 g_free(buf); |
9554 | 736 if(args[2]) { |
737 GaimConvChatBuddyFlags newflag, flags; | |
738 char *mcur, *cur, *end, *user; | |
739 gboolean add = FALSE; | |
740 mcur = args[1]; | |
741 cur = args[2]; | |
742 while (*cur && *mcur) { | |
743 if ((*mcur == '+') || (*mcur == '-')) { | |
744 add = (*mcur == '+') ? TRUE : FALSE; | |
745 mcur++; | |
746 continue; | |
747 } | |
748 end = strchr(cur, ' '); | |
749 if (!end) | |
750 end = cur + strlen(cur); | |
751 user = g_strndup(cur, end - cur); | |
752 flags = gaim_conv_chat_user_get_flags(GAIM_CONV_CHAT(convo), user); | |
753 newflag = GAIM_CBFLAGS_NONE; | |
754 if (*mcur == 'o') | |
755 newflag = GAIM_CBFLAGS_OP; | |
756 else if (*mcur =='h') | |
757 newflag = GAIM_CBFLAGS_HALFOP; | |
758 else if (*mcur == 'v') | |
759 newflag = GAIM_CBFLAGS_VOICE; | |
760 if (newflag) { | |
761 if (add) | |
762 flags |= newflag; | |
763 else | |
764 flags &= ~newflag; | |
765 gaim_conv_chat_user_set_flags(GAIM_CONV_CHAT(convo), user, flags); | |
766 } | |
767 g_free(user); | |
768 cur = end; | |
769 if (*cur) | |
770 cur++; | |
771 if (*mcur) | |
772 mcur++; | |
773 } | |
774 } | |
6333 | 775 } else { /* User */ |
776 } | |
777 g_free(nick); | |
778 } | |
779 | |
780 void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
781 { | |
782 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
10617 | 783 GaimConversation *conv; |
6333 | 784 GSList *chats; |
785 char *nick = irc_mask_nick(from); | |
786 | |
787 if (!gc) { | |
788 g_free(nick); | |
789 return; | |
790 } | |
791 chats = gc->buddy_chats; | |
792 | |
793 if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { | |
794 gaim_connection_set_display_name(gc, args[0]); | |
795 } | |
796 | |
797 while (chats) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
798 GaimConvChat *chat = GAIM_CONV_CHAT(chats->data); |
9593 | 799 /* This is ugly ... */ |
800 if (gaim_conv_chat_find_user(chat, nick)) | |
801 gaim_conv_chat_rename_user(chat, nick, args[0]); | |
6333 | 802 chats = chats->next; |
803 } | |
10617 | 804 |
11338 | 805 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, nick, |
10617 | 806 irc->account); |
807 if (conv != NULL) | |
808 gaim_conversation_set_name(conv, args[0]); | |
809 | |
6333 | 810 g_free(nick); |
811 } | |
812 | |
10633 | 813 void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
814 { | |
13057 | 815 GaimConnection *gc = gaim_account_get_connection(irc->account); |
816 if (gaim_connection_get_state(gc) == GAIM_CONNECTED) { | |
817 gaim_notify_error(gc, _("Invalid nickname"), | |
818 _("Invalid nickname"), | |
819 _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); | |
820 | |
821 } else { | |
822 gaim_connection_error(gaim_account_get_connection(irc->account), | |
823 _("Your selected account name was rejected by the server. It probably contains invalid characters.")); | |
824 } | |
10633 | 825 } |
826 | |
6333 | 827 void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
828 { | |
829 char *newnick, *buf, *end; | |
830 | |
831 if (!args || !args[1]) | |
832 return; | |
833 | |
834 newnick = strdup(args[1]); | |
835 end = newnick + strlen(newnick) - 1; | |
11386 | 836 /* try fallbacks */ |
837 if((*end < '9') && (*end >= '1')) { | |
838 *end = *end + 1; | |
839 } else *end = '1'; | |
6333 | 840 |
841 buf = irc_format(irc, "vn", "NICK", newnick); | |
842 irc_send(irc, buf); | |
843 g_free(buf); | |
10504 | 844 g_free(newnick); |
6333 | 845 } |
846 | |
847 void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
848 { | |
849 char *newargs[2]; | |
850 | |
851 newargs[0] = " notice "; /* The spaces are magic, leave 'em in! */ | |
852 newargs[1] = args[1]; | |
853 irc_msg_privmsg(irc, name, from, newargs); | |
854 } | |
855 | |
6718 | 856 void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
857 { | |
858 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
859 | |
6753 | 860 if (!args || !args[2] || !gc) |
6718 | 861 return; |
862 | |
10774 | 863 gaim_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]); |
6718 | 864 } |
865 | |
6333 | 866 void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
867 { | |
868 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
869 GaimConversation *convo; | |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
870 char *nick, *msg; |
6333 | 871 |
8186 | 872 if (!args || !args[0] || !gc) |
6333 | 873 return; |
874 | |
11338 | 875 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
6333 | 876 if (!convo) { |
877 gaim_debug(GAIM_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", args[0]); | |
878 return; | |
879 } | |
880 | |
881 nick = irc_mask_nick(from); | |
882 if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { | |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
883 char *escaped = g_markup_escape_text(args[1], -1); |
8186 | 884 msg = g_strdup_printf(_("You have parted the channel%s%s"), |
10551
6ef7be688140
[gaim-migrate @ 11926]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10504
diff
changeset
|
885 (args[1] && *args[1]) ? ": " : "", |
10730 | 886 (escaped && *escaped) ? escaped : ""); |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
887 g_free(escaped); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
888 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], msg, GAIM_MESSAGE_SYSTEM, time(NULL)); |
6333 | 889 g_free(msg); |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8186
diff
changeset
|
890 serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo))); |
6333 | 891 } else { |
12855
f9401180115a
[gaim-migrate @ 15206]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
892 gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), nick, args[1]); |
6333 | 893 } |
894 g_free(nick); | |
895 } | |
896 | |
897 void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
898 { | |
899 char *buf; | |
900 if (!args || !args[0]) | |
901 return; | |
902 | |
903 buf = irc_format(irc, "v:", "PONG", args[0]); | |
904 irc_send(irc, buf); | |
905 g_free(buf); | |
906 } | |
907 | |
908 void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
909 { | |
910 GaimConversation *convo; | |
911 GaimConnection *gc; | |
912 char **parts, *msg; | |
913 time_t oldstamp; | |
914 | |
915 if (!args || !args[1]) | |
916 return; | |
917 | |
918 parts = g_strsplit(args[1], " ", 2); | |
919 | |
920 if (!parts[0] || !parts[1]) { | |
921 g_strfreev(parts); | |
922 return; | |
923 } | |
924 | |
925 if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
926 msg = g_strdup(_("Error: invalid PONG from server")); | |
927 } else { | |
6350 | 928 msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
6333 | 929 } |
930 | |
11338 | 931 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, parts[0], irc->account); |
6333 | 932 g_strfreev(parts); |
933 if (convo) { | |
11338 | 934 if (gaim_conversation_get_type (convo) == GAIM_CONV_TYPE_CHAT) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
935 gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 936 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
937 gaim_conv_im_write(GAIM_CONV_IM(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
6333 | 938 } else { |
939 gc = gaim_account_get_connection(irc->account); | |
940 if (!gc) { | |
941 g_free(msg); | |
942 return; | |
943 } | |
944 gaim_notify_info(gc, NULL, "PONG", msg); | |
945 } | |
946 g_free(msg); | |
947 } | |
948 | |
949 void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
950 { | |
951 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
952 GaimConversation *convo; | |
953 char *nick = irc_mask_nick(from), *tmp, *msg; | |
954 int notice = 0; | |
955 | |
956 if (!args || !args[0] || !args[1] || !gc) { | |
957 g_free(nick); | |
958 return; | |
959 } | |
960 | |
961 notice = !strcmp(args[0], " notice "); | |
962 tmp = irc_parse_ctcp(irc, nick, args[0], args[1], notice); | |
963 if (!tmp) { | |
964 g_free(nick); | |
965 return; | |
966 } | |
8163 | 967 |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10730
diff
changeset
|
968 msg = g_markup_escape_text(tmp, -1); |
6333 | 969 g_free(tmp); |
8163 | 970 |
971 tmp = irc_mirc2html(msg); | |
972 g_free(msg); | |
973 msg = tmp; | |
6333 | 974 if (notice) { |
975 tmp = g_strdup_printf("(notice) %s", msg); | |
976 g_free(msg); | |
977 msg = tmp; | |
978 } | |
979 | |
980 if (!gaim_utf8_strcasecmp(args[0], gaim_connection_get_display_name(gc))) { | |
6982 | 981 serv_got_im(gc, nick, msg, 0, time(NULL)); |
6333 | 982 } else if (notice) { |
6982 | 983 serv_got_im(gc, nick, msg, 0, time(NULL)); |
6333 | 984 } else { |
11338 | 985 convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
6333 | 986 if (convo) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
987 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); |
6333 | 988 else |
989 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a PRIVMSG on %s, which does not exist\n", args[0]); | |
990 } | |
991 g_free(msg); | |
992 g_free(nick); | |
993 } | |
994 | |
6714 | 995 void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
996 { | |
997 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
998 char *msg; | |
999 | |
1000 if (!args || !args[1] || !args[2] || !gc) | |
1001 return; | |
1002 | |
1003 msg = g_strdup_printf(_("Cannot join %s:"), args[1]); | |
1004 gaim_notify_error(gc, _("Cannot join channel"), msg, args[2]); | |
1005 g_free(msg); | |
1006 } | |
1007 | |
6333 | 1008 void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
1009 { | |
1010 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
9238 | 1011 struct irc_buddy *ib; |
6333 | 1012 char *data[2]; |
1013 | |
1014 if (!args || !args[0] || !gc) | |
1015 return; | |
1016 | |
1017 data[0] = irc_mask_nick(from); | |
1018 data[1] = args[0]; | |
1019 /* XXX this should have an API, I shouldn't grab this directly */ | |
1020 g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); | |
9238 | 1021 |
1022 if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) { | |
1023 ib->flag = FALSE; | |
1024 irc_buddy_status(data[0], ib, irc); | |
1025 } | |
6333 | 1026 g_free(data[0]); |
1027 | |
1028 return; | |
1029 } | |
1030 | |
10712 | 1031 void irc_msg_unavailable(struct irc_conn *irc, const char *name, const char *from, char **args) |
1032 { | |
1033 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
1034 | |
1035 if (!args || !args[1]) | |
1036 return; | |
1037 | |
1038 gaim_notify_error(gc, NULL, _("Nick or channel is temporarily unavailable."), args[1]); | |
1039 } | |
1040 | |
6333 | 1041 void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
1042 { | |
1043 GaimConnection *gc = gaim_account_get_connection(irc->account); | |
10774 | 1044 char *nick, *msg; |
6333 | 1045 |
1046 if (!args || !args[0] || !gc) | |
1047 return; | |
1048 | |
1049 nick = irc_mask_nick(from); | |
1050 msg = g_strdup_printf (_("Wallops from %s"), nick); | |
1051 g_free(nick); | |
10774 | 1052 gaim_notify_info(gc, NULL, msg, args[0]); |
6333 | 1053 g_free(msg); |
1054 } | |
1055 | |
1056 void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args) | |
1057 { | |
1058 return; | |
1059 } |