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