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