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