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