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