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