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