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