Sun, 28 Jan 2007 17:02:31 +0000
This should fix up IRC logins for servers which do not provide an
MOTD, which is not required by the spec. All servers MUST send 251 &
255 numerics, so now we key off those. This fixes several IRC bugs in
the sourceforge tracker, which should be updated upon release.
| 6333 | 1 | /** |
| 2 | * @file msgs.c | |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
3 | * |
| 6333 | 4 | * gaim |
| 5 | * | |
| 6 | * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> | |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
7 | * |
| 6333 | 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 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
39 | static void irc_msg_handle_privmsg(struct irc_conn *irc, const char *name, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
40 | const char *from, const char *to, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
41 | const char *rawmsg, gboolean notice); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
42 | |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
43 | static char *mode_chars = NULL; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
44 | |
| 6333 | 45 | static char *irc_mask_nick(const char *mask) |
| 46 | { | |
| 47 | char *end, *buf; | |
| 48 | ||
| 49 | end = strchr(mask, '!'); | |
| 50 | if (!end) | |
| 51 | buf = g_strdup(mask); | |
| 52 | else | |
| 53 | buf = g_strndup(mask, end - mask); | |
| 54 | ||
| 55 | return buf; | |
| 56 | } | |
| 57 | ||
| 58 | static char *irc_mask_userhost(const char *mask) | |
| 59 | { | |
| 60 | return g_strdup(strchr(mask, '!') + 1); | |
| 61 | } | |
| 62 | ||
| 63 | static void irc_chat_remove_buddy(GaimConversation *convo, char *data[2]) | |
| 64 | { | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
65 | char *message; |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
66 | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
67 | message = g_strdup_printf("quit: %s", data[1]); |
| 6333 | 68 | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
69 | if (gaim_conv_chat_find_user(GAIM_CONV_CHAT(convo), data[0])) |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
70 | gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), data[0], message); |
| 6333 | 71 | |
| 72 | g_free(message); | |
| 73 | } | |
| 74 | ||
| 75 | void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 76 | { | |
| 77 | gaim_debug(GAIM_DEBUG_INFO, "irc", "Unrecognized message: %s\n", args[0]); | |
| 78 | } | |
| 79 | ||
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
80 | void irc_msg_features(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
81 | { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
82 | gchar **features; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
83 | int i; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
84 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
85 | if (!args || !args[0] || !args[1]) |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
86 | return; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
87 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
88 | features = g_strsplit(args[1], " ", -1); |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
89 | for (i = 0; features[i]; i++) { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
90 | char *val; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
91 | if (!strncmp(features[i], "PREFIX=", 7)) { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
92 | if ((val = strchr(features[i] + 7, ')')) != NULL) |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
93 | mode_chars = g_strdup(val + 1); |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
94 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
95 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
96 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
97 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
98 | void irc_msg_luser(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
99 | { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
100 | GaimConnection *gc; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
101 | GaimStatus *status; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
102 | GaimBlistNode *gnode, *cnode, *bnode; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
103 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
104 | if (!args || !args[0] || !args[1]) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
105 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
106 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
107 | gc = gaim_account_get_connection(irc->account); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
108 | if (!gc) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
109 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
110 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
111 | if (!strcmp(name, "251")) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
112 | /* 251 is required, so we pluck our nick from here */ |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
113 | gaim_connection_set_display_name(gc, args[0]); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
114 | } else if (!strcmp(name, "255")) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
115 | gaim_connection_set_state(gc, GAIM_CONNECTED); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
116 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
117 | /* If we're away then set our away message */ |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
118 | status = gaim_account_get_active_status(irc->account); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
119 | if (!gaim_status_get_type(status) != GAIM_STATUS_AVAILABLE) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
120 | GaimPluginProtocolInfo *prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
121 | prpl_info->set_status(irc->account, status); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
122 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
123 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
124 | /* this used to be in the core, but it's not now */ |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
125 | for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
126 | if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
127 | continue; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
128 | for(cnode = gnode->child; cnode; cnode = cnode->next) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
129 | if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
130 | continue; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
131 | for(bnode = cnode->child; bnode; bnode = bnode->next) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
132 | GaimBuddy *b; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
133 | if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
134 | continue; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
135 | b = (GaimBuddy *)bnode; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
136 | if(b->account == gc->account) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
137 | struct irc_buddy *ib = g_new0(struct irc_buddy, 1); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
138 | ib->name = g_strdup(b->name); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
139 | g_hash_table_insert(irc->buddies, ib->name, ib); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
140 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
141 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
142 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
143 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
144 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
145 | irc_blist_timeout(irc); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
146 | if (!irc->timer) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
147 | irc->timer = gaim_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
148 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
149 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
150 | |
| 6333 | 151 | void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 152 | { | |
| 153 | GaimConnection *gc; | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
154 | char *msg; |
| 6333 | 155 | |
| 156 | if (!args || !args[1]) | |
| 157 | return; | |
| 158 | ||
| 159 | if (irc->whois.nick && !gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
| 160 | /* We're doing a whois, show this in the whois dialog */ | |
| 161 | irc_msg_whois(irc, name, from, args); | |
| 162 | return; | |
| 163 | } | |
| 164 | ||
| 165 | gc = gaim_account_get_connection(irc->account); | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
166 | if (gc) { |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
167 | msg = g_markup_escape_text(args[2], -1); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12069
diff
changeset
|
168 | serv_got_im(gc, args[1], msg, GAIM_MESSAGE_AUTO_RESP, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
169 | g_free(msg); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
170 | } |
| 6333 | 171 | } |
| 172 | ||
| 173 | void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 174 | { | |
| 175 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 176 | ||
| 177 | if (!args || !args[1] || !gc) | |
| 178 | return; | |
| 179 | ||
| 180 | gaim_notify_error(gc, NULL, _("Bad mode"), args[1]); | |
| 181 | } | |
| 182 | ||
| 183 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 184 | { | |
| 185 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 186 | char *buf; | |
| 187 | ||
| 188 | if (!args || !args[1] || !gc) | |
| 189 | return; | |
| 190 | ||
| 191 | buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
| 192 | gaim_notify_error(gc, _("Banned"), _("Banned"), buf); | |
| 193 | g_free(buf); | |
| 194 | } | |
| 195 | ||
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
196 | void irc_msg_banfull(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
197 | { |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
198 | GaimConversation *convo; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
199 | char *buf, *nick; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
200 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
201 | if (!args || !args[0] || !args[1] || !args[2]) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
202 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
203 | |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
204 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
205 | if (!convo) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
206 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
207 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
208 | nick = g_markup_escape_text(args[2], -1); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
209 | buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
210 | g_free(nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
211 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
212 | GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
213 | time(NULL)); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
214 | g_free(buf); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
215 | } |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
216 | |
| 6333 | 217 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 218 | { | |
| 219 | GaimConversation *convo; | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
220 | char *buf, *escaped; |
| 6333 | 221 | |
| 222 | if (!args || !args[1] || !args[2]) | |
| 223 | return; | |
| 224 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
225 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 226 | if (!convo) /* XXX punt on channels we are not in for now */ |
| 227 | return; | |
| 228 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
229 | escaped = (args[3] != NULL) ? g_markup_escape_text(args[3], -1) : NULL; |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
230 | buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); |
|
12069
bf45000338cd
[gaim-migrate @ 14364]
Richard Laager <rlaager@pidgin.im>
parents:
12001
diff
changeset
|
231 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
232 | g_free(escaped); |
| 6333 | 233 | g_free(buf); |
| 234 | ||
| 235 | return; | |
| 236 | } | |
| 237 | ||
| 238 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 239 | { | |
| 240 | if (!irc->whois.nick) { | |
| 241 | gaim_debug(GAIM_DEBUG_WARNING, "irc", "Unexpected WHOIS reply for %s\n", args[1]); | |
| 242 | return; | |
| 243 | } | |
| 244 | ||
| 245 | if (gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
| 246 | gaim_debug(GAIM_DEBUG_WARNING, "irc", "Got WHOIS reply for %s while waiting for %s\n", args[1], irc->whois.nick); | |
| 247 | return; | |
| 248 | } | |
| 249 | ||
| 250 | if (!strcmp(name, "301")) { | |
| 251 | irc->whois.away = g_strdup(args[2]); | |
| 252 | } else if (!strcmp(name, "311")) { | |
| 253 | irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]); | |
| 254 | irc->whois.name = g_strdup(args[5]); | |
| 255 | } else if (!strcmp(name, "312")) { | |
| 256 | irc->whois.server = g_strdup(args[2]); | |
| 257 | irc->whois.serverinfo = g_strdup(args[3]); | |
| 258 | } else if (!strcmp(name, "313")) { | |
| 259 | irc->whois.ircop = 1; | |
| 260 | } else if (!strcmp(name, "317")) { | |
| 261 | irc->whois.idle = atoi(args[2]); | |
| 262 | if (args[3]) | |
| 263 | irc->whois.signon = (time_t)atoi(args[3]); | |
| 264 | } else if (!strcmp(name, "319")) { | |
| 265 | irc->whois.channels = g_strdup(args[2]); | |
| 266 | } else if (!strcmp(name, "320")) { | |
| 267 | irc->whois.identified = 1; | |
| 268 | } | |
| 269 | } | |
| 270 | ||
| 271 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 272 | { | |
| 273 | GaimConnection *gc; | |
|
15215
3b4c0490b8b0
[gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
274 | char *tmp, *tmp2; |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
275 | GaimNotifyUserInfo *user_info; |
| 6333 | 276 | |
| 277 | if (!irc->whois.nick) { | |
| 278 | gaim_debug(GAIM_DEBUG_WARNING, "irc", "Unexpected End of WHOIS for %s\n", args[1]); | |
| 279 | return; | |
| 280 | } | |
| 281 | if (gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
| 282 | gaim_debug(GAIM_DEBUG_WARNING, "irc", "Received end of WHOIS for %s, expecting %s\n", args[1], irc->whois.nick); | |
| 283 | return; | |
| 284 | } | |
| 285 | ||
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
286 | user_info = gaim_notify_user_info_new(); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
287 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
288 | tmp2 = g_markup_escape_text(args[1], -1); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
289 | tmp = g_strdup_printf("%s%s%s", tmp2, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
290 | (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
291 | (irc->whois.identified ? _(" <i>(identified)</i>") : "")); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
292 | gaim_notify_user_info_add_pair(user_info, _("Nick"), tmp); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
293 | g_free(tmp2); |
| 10634 | 294 | g_free(tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
295 | |
| 6333 | 296 | if (irc->whois.away) { |
| 10634 | 297 | tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); |
| 6333 | 298 | g_free(irc->whois.away); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
299 | gaim_notify_user_info_add_pair(user_info, _("Away"), tmp); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
300 | g_free(tmp); |
| 6333 | 301 | } |
| 302 | if (irc->whois.userhost) { | |
| 10634 | 303 | tmp = g_markup_escape_text(irc->whois.name, strlen(irc->whois.name)); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
304 | g_free(irc->whois.name); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
305 | gaim_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
306 | gaim_notify_user_info_add_pair(user_info, _("Real name"), tmp); |
| 6333 | 307 | g_free(irc->whois.userhost); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
308 | g_free(tmp); |
| 6333 | 309 | } |
| 310 | if (irc->whois.server) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
311 | tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
312 | gaim_notify_user_info_add_pair(user_info, _("Server"), tmp); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
313 | g_free(tmp); |
| 6333 | 314 | g_free(irc->whois.server); |
| 315 | g_free(irc->whois.serverinfo); | |
| 316 | } | |
| 317 | if (irc->whois.channels) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
318 | gaim_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels); |
| 6333 | 319 | g_free(irc->whois.channels); |
| 320 | } | |
| 321 | if (irc->whois.idle) { | |
|
7108
82655fa54acb
[gaim-migrate @ 7673]
Christian Hammond <chipx86@chipx86.com>
parents:
7062
diff
changeset
|
322 | gchar *timex = gaim_str_seconds_to_string(irc->whois.idle); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
323 | gaim_notify_user_info_add_pair(user_info, _("Idle for"), timex); |
|
6357
f83643b0a067
[gaim-migrate @ 6856]
Mark Doliner <markdoliner@pidgin.im>
parents:
6351
diff
changeset
|
324 | g_free(timex); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
325 | gaim_notify_user_info_add_pair(user_info, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
326 | _("Online since"), gaim_date_format_full(localtime(&irc->whois.signon))); |
| 6333 | 327 | } |
| 328 | if (!strcmp(irc->whois.nick, "Paco-Paco")) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
329 | gaim_notify_user_info_add_pair(user_info, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
330 | _("<b>Defining adjective:</b>"), _("Glorious")); |
| 6333 | 331 | } |
| 332 | ||
| 333 | gc = gaim_account_get_connection(irc->account); | |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
334 | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
335 | gaim_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
336 | gaim_notify_user_info_destroy(user_info); |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
337 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
338 | g_free(irc->whois.nick); |
| 6333 | 339 | memset(&irc->whois, 0, sizeof(irc->whois)); |
| 340 | } | |
| 341 | ||
| 8114 | 342 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 343 | { | |
| 344 | if (!irc->roomlist) | |
| 345 | return; | |
| 346 | ||
| 347 | if (!strcmp(name, "321")) { | |
| 348 | gaim_roomlist_set_in_progress(irc->roomlist, TRUE); | |
| 349 | return; | |
| 350 | } | |
| 351 | ||
| 352 | if (!strcmp(name, "323")) { | |
| 353 | gaim_roomlist_set_in_progress(irc->roomlist, FALSE); | |
| 354 | gaim_roomlist_unref(irc->roomlist); | |
| 355 | irc->roomlist = NULL; | |
|
13667
9ebf0007d912
[gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents:
13647
diff
changeset
|
356 | return; |
| 8114 | 357 | } |
| 358 | ||
| 359 | if (!strcmp(name, "322")) { | |
| 360 | GaimRoomlistRoom *room; | |
| 361 | ||
| 362 | if (!args[0] || !args[1] || !args[2] || !args[3]) | |
| 363 | return; | |
| 364 | ||
| 365 | room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); | |
| 366 | gaim_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
| 367 | gaim_roomlist_room_add_field(irc->roomlist, room, GINT_TO_POINTER(strtol(args[2], NULL, 10))); | |
| 368 | gaim_roomlist_room_add_field(irc->roomlist, room, args[3]); | |
| 369 | gaim_roomlist_room_add(irc->roomlist, room); | |
| 370 | } | |
| 371 | } | |
| 372 | ||
| 6333 | 373 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 374 | { | |
| 9762 | 375 | char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
| 6333 | 376 | GaimConversation *convo; |
| 377 | ||
| 378 | if (!strcmp(name, "topic")) { | |
| 379 | chan = args[0]; | |
| 8529 | 380 | topic = irc_mirc2txt (args[1]); |
| 6333 | 381 | } else { |
| 382 | chan = args[1]; | |
| 8529 | 383 | topic = irc_mirc2txt (args[2]); |
| 6333 | 384 | } |
| 385 | ||
|
13647
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
386 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, chan, irc->account); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
387 | if (!convo) { |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
388 | gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
389 | g_free(topic); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
390 | return; |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
391 | } |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
392 | |
| 6333 | 393 | /* If this is an interactive update, print it out */ |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
394 | tmp = g_markup_escape_text(topic, -1); |
| 9762 | 395 | tmp2 = gaim_markup_linkify(tmp); |
| 396 | g_free(tmp); | |
| 6333 | 397 | if (!strcmp(name, "topic")) { |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
398 | const char *current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(convo)); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
399 | if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0)) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
400 | { |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
401 | char *nick_esc; |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
402 | nick = irc_mask_nick(from); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
403 | nick_esc = g_markup_escape_text(nick, -1); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
404 | gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), nick, topic); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
405 | if (*tmp2) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
406 | msg = g_strdup_printf(_("%s has changed the topic to: %s"), nick_esc, tmp2); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
407 | else |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
408 | msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
409 | g_free(nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
410 | g_free(nick); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
411 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), from, msg, GAIM_MESSAGE_SYSTEM, time(NULL)); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
412 | g_free(msg); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
413 | } |
| 6333 | 414 | } else { |
|
13395
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
415 | char *chan_esc = g_markup_escape_text(chan, -1); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
416 | msg = g_strdup_printf(_("The topic for %s is: %s"), chan_esc, tmp2); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
417 | g_free(chan_esc); |
| 9518 | 418 | gaim_conv_chat_set_topic(GAIM_CONV_CHAT(convo), NULL, topic); |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
419 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 420 | g_free(msg); |
| 421 | } | |
| 9762 | 422 | g_free(tmp2); |
| 8529 | 423 | g_free(topic); |
| 6333 | 424 | } |
| 425 | ||
| 426 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 427 | { | |
| 428 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 429 | char *buf; | |
| 430 | ||
| 431 | if (!args || !args[1] || !gc) | |
| 432 | return; | |
| 433 | ||
| 434 | buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
|
15444
b793ef258d23
I think this changes every user-visible string that contains 'Gaim.' We probably want the UI to be able
Sean Egan <seanegan@pidgin.im>
parents:
15435
diff
changeset
|
435 | gaim_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand.")); |
| 6333 | 436 | g_free(buf); |
| 437 | } | |
| 438 | ||
| 439 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 440 | { | |
| 441 | char *names, *cur, *end, *tmp, *msg; | |
| 442 | GaimConversation *convo; | |
| 443 | ||
| 444 | if (!strcmp(name, "366")) { | |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
445 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, irc->nameconv ? irc->nameconv : args[1], irc->account); |
| 6333 | 446 | if (!convo) { |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
447 | gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); |
| 6333 | 448 | g_string_free(irc->names, TRUE); |
| 449 | irc->names = NULL; | |
| 450 | g_free(irc->nameconv); | |
| 451 | irc->nameconv = NULL; | |
| 452 | return; | |
| 453 | } | |
| 454 | ||
| 455 | names = cur = g_string_free(irc->names, FALSE); | |
| 456 | irc->names = NULL; | |
| 457 | if (irc->nameconv) { | |
|
11026
1f13c483db00
[gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents:
10816
diff
changeset
|
458 | msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
459 | if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
460 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 461 | else |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
462 | gaim_conv_im_write(GAIM_CONV_IM(convo), "", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 463 | g_free(msg); |
| 464 | g_free(irc->nameconv); | |
| 465 | irc->nameconv = NULL; | |
| 466 | } else { | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
467 | GList *users = NULL; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
468 | GList *flags = NULL; |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
469 | |
| 6333 | 470 | while (*cur) { |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
471 | GaimConvChatBuddyFlags f = GAIM_CBFLAGS_NONE; |
| 6333 | 472 | end = strchr(cur, ' '); |
| 473 | if (!end) | |
| 474 | end = cur + strlen(cur); | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
475 | if (*cur == '@') { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
476 | f = GAIM_CBFLAGS_OP; |
| 6333 | 477 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
478 | } else if (*cur == '%') { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
479 | f = GAIM_CBFLAGS_HALFOP; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
480 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
481 | } else if(*cur == '+') { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
482 | f = GAIM_CBFLAGS_VOICE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
483 | cur++; |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
484 | } else if(mode_chars |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
485 | && strchr(mode_chars, *cur)) { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
486 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
487 | } |
| 6333 | 488 | tmp = g_strndup(cur, end - cur); |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
489 | users = g_list_prepend(users, tmp); |
|
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
490 | flags = g_list_prepend(flags, GINT_TO_POINTER(f)); |
| 6333 | 491 | cur = end; |
| 492 | if (*cur) | |
| 493 | cur++; | |
| 494 | } | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
495 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
496 | if (users != NULL) { |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
497 | GList *l; |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
498 | |
|
11454
a604c2097a6e
[gaim-migrate @ 13693]
Richard Laager <rlaager@pidgin.im>
parents:
11386
diff
changeset
|
499 | gaim_conv_chat_add_users(GAIM_CONV_CHAT(convo), users, NULL, flags, FALSE); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
500 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
501 | for (l = users; l != NULL; l = l->next) |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
502 | g_free(l->data); |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
503 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
504 | g_list_free(users); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
505 | g_list_free(flags); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
506 | } |
| 6333 | 507 | } |
| 508 | g_free(names); | |
| 509 | } else { | |
| 510 | if (!irc->names) | |
| 511 | irc->names = g_string_new(""); | |
| 512 | ||
| 15313 | 513 | if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ') |
| 514 | irc->names = g_string_append_c(irc->names, ' '); | |
| 6333 | 515 | irc->names = g_string_append(irc->names, args[3]); |
| 516 | } | |
| 517 | } | |
| 518 | ||
| 519 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 520 | { | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
521 | char *escaped; |
| 6333 | 522 | |
| 523 | if (!irc->motd) | |
| 524 | irc->motd = g_string_new(""); | |
| 525 | ||
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
526 | if (!strcmp(name, "375")) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
527 | if (irc->motd) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
528 | g_string_free(irc->motd, TRUE); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
529 | irc->motd = g_string_new(""); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
530 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
531 | } else if (!strcmp(name, "376")) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
532 | /* We no longer have to do anything for ENDMOTD */ |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
533 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
534 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
535 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
536 | if (!irc->motd) { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
537 | gaim_debug_error("irc", "IRC server sent MOTD without STARTMOTD\n"); |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
538 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
539 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
540 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
541 | escaped = g_markup_escape_text(args[1], -1); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
542 | g_string_append_printf(irc->motd, "%s<br>", escaped); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
543 | g_free(escaped); |
| 6333 | 544 | } |
| 545 | ||
| 10564 | 546 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 547 | { | |
| 548 | GaimConnection *gc; | |
| 549 | ||
| 550 | gc = gaim_account_get_connection(irc->account); | |
| 551 | if (gc == NULL || args == NULL || args[2] == NULL) | |
| 552 | return; | |
| 553 | ||
| 554 | gaim_notify_message(gc, GAIM_NOTIFY_MSG_INFO, _("Time Response"), | |
| 555 | _("The IRC server's local time is:"), | |
| 556 | args[2], NULL, NULL); | |
| 557 | } | |
| 558 | ||
| 7877 | 559 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 560 | { | |
| 561 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 562 | ||
| 563 | if (gc == NULL || args == NULL || args[1] == NULL) | |
| 564 | return; | |
| 565 | ||
| 566 | gaim_notify_error(gc, NULL, _("No such channel"), args[1]); | |
| 567 | } | |
| 568 | ||
| 6333 | 569 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 570 | { | |
| 571 | GaimConnection *gc; | |
| 572 | GaimConversation *convo; | |
| 573 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
574 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 575 | if (convo) { |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
576 | if (gaim_conversation_get_type(convo) == GAIM_CONV_TYPE_CHAT) /* does this happen? */ |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
577 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], _("no such channel"), |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6407
diff
changeset
|
578 | GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 579 | else |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
580 | gaim_conv_im_write(GAIM_CONV_IM(convo), args[1], _("User is not logged in"), |
|
6621
2a18ef3e5224
[gaim-migrate @ 7145]
Robert McQueen <robot101@debian.org>
parents:
6407
diff
changeset
|
581 | GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 582 | } else { |
| 583 | if ((gc = gaim_account_get_connection(irc->account)) == NULL) | |
| 584 | return; | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
585 | gaim_notify_error(gc, NULL, _("No such nick or channel"), args[1]); |
| 6333 | 586 | } |
| 587 | ||
| 588 | if (irc->whois.nick && !gaim_utf8_strcasecmp(irc->whois.nick, args[1])) { | |
| 589 | g_free(irc->whois.nick); | |
| 590 | irc->whois.nick = NULL; | |
| 591 | } | |
| 592 | } | |
| 593 | ||
| 594 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 595 | { | |
| 596 | GaimConnection *gc; | |
| 597 | GaimConversation *convo; | |
| 598 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
599 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 600 | if (convo) { |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
601 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 602 | } else { |
| 603 | if ((gc = gaim_account_get_connection(irc->account)) == NULL) | |
| 604 | return; | |
| 605 | gaim_notify_error(gc, NULL, _("Could not send"), args[2]); | |
| 606 | } | |
| 607 | } | |
| 608 | ||
| 609 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 610 | { | |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
611 | GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 612 | |
| 613 | gaim_debug(GAIM_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); | |
| 614 | if (convo) { | |
| 615 | /*g_slist_remove(irc->gc->buddy_chats, convo); | |
| 616 | gaim_conversation_set_account(convo, NULL);*/ | |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
617 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[1], args[2], GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 618 | } |
| 619 | } | |
| 620 | ||
| 621 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 622 | { | |
| 623 | GaimConversation *convo; | |
| 624 | ||
| 625 | if (!args || !args[1] || !args[2]) | |
| 626 | return; | |
| 627 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
628 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 629 | if (!convo) |
| 630 | return; | |
| 631 | ||
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
632 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "", args[2], GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 633 | } |
| 634 | ||
| 635 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 636 | { | |
| 637 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 638 | GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); | |
| 639 | char *nick = irc_mask_nick(from); | |
| 640 | ||
| 641 | if (!args || !args[1] || !gc) { | |
| 642 | g_free(nick); | |
| 643 | g_hash_table_destroy(components); | |
| 644 | return; | |
| 645 | } | |
| 646 | ||
| 647 | g_hash_table_insert(components, strdup("channel"), strdup(args[1])); | |
| 648 | ||
| 649 | serv_got_chat_invite(gc, args[1], nick, NULL, components); | |
| 650 | g_free(nick); | |
| 651 | } | |
| 652 | ||
| 653 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 654 | { | |
| 655 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 656 | char *buf; | |
| 657 | ||
| 658 | if (!args || !args[1] || !gc) | |
| 659 | return; | |
| 660 | ||
| 661 | buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
| 662 | gaim_notify_error(gc, _("Invitation only"), _("Invitation only"), buf); | |
| 663 | g_free(buf); | |
| 664 | } | |
| 665 | ||
| 666 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 667 | { | |
| 668 | char **nicks; | |
| 669 | struct irc_buddy *ib; | |
| 670 | int i; | |
| 671 | ||
| 672 | if (!args || !args[1]) | |
| 673 | return; | |
| 674 | ||
| 675 | nicks = g_strsplit(args[1], " ", -1); | |
| 676 | ||
| 677 | for (i = 0; nicks[i]; i++) { | |
| 678 | if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
| 679 | continue; | |
| 680 | } | |
| 681 | ib->flag = TRUE; | |
| 682 | } | |
| 683 | ||
| 6350 | 684 | g_strfreev(nicks); |
| 685 | ||
| 6333 | 686 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
| 687 | } | |
| 688 | ||
| 689 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
| 690 | { | |
| 691 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 6695 | 692 | GaimBuddy *buddy = gaim_find_buddy(irc->account, name); |
| 6333 | 693 | |
| 694 | if (!gc || !buddy) | |
| 695 | return; | |
| 696 | ||
| 697 | if (ib->online && !ib->flag) { | |
| 10242 | 698 | gaim_prpl_got_user_status(irc->account, name, "offline", NULL); |
| 6333 | 699 | ib->online = FALSE; |
| 10242 | 700 | } else if (!ib->online && ib->flag) { |
|
11535
715d41fc7926
[gaim-migrate @ 13787]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11533
diff
changeset
|
701 | gaim_prpl_got_user_status(irc->account, name, "available", NULL); |
| 6333 | 702 | ib->online = TRUE; |
| 703 | } | |
| 704 | } | |
| 705 | ||
| 706 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 707 | { | |
| 708 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 709 | GaimConversation *convo; | |
| 710 | char *nick = irc_mask_nick(from), *userhost; | |
| 9238 | 711 | struct irc_buddy *ib; |
| 6333 | 712 | static int id = 1; |
| 713 | ||
| 714 | if (!gc) { | |
| 715 | g_free(nick); | |
| 716 | return; | |
| 717 | } | |
| 718 | ||
| 719 | if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { | |
| 720 | /* We are joining a channel for the first time */ | |
| 721 | serv_got_joined_chat(gc, id++, args[0]); | |
| 722 | g_free(nick); | |
| 13938 | 723 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, |
| 724 | args[0], | |
| 725 | irc->account); | |
| 726 | if (convo == NULL) { | |
| 727 | gaim_debug_error("irc", "tried to join %s but couldn't\n", args[0]); | |
| 728 | return; | |
| 729 | } | |
| 730 | gaim_conversation_present(convo); | |
| 6333 | 731 | return; |
| 732 | } | |
| 733 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
734 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 735 | if (convo == NULL) { |
| 736 | gaim_debug(GAIM_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); | |
| 737 | g_free(nick); | |
| 738 | return; | |
| 739 | } | |
| 740 | ||
| 741 | userhost = irc_mask_userhost(from); | |
|
9846
61f7349c153a
[gaim-migrate @ 10724]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9797
diff
changeset
|
742 | gaim_conv_chat_add_user(GAIM_CONV_CHAT(convo), nick, userhost, GAIM_CBFLAGS_NONE, TRUE); |
| 9238 | 743 | |
| 744 | if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { | |
| 745 | ib->flag = TRUE; | |
| 746 | irc_buddy_status(nick, ib, irc); | |
| 747 | } | |
| 748 | ||
| 6333 | 749 | g_free(userhost); |
| 750 | g_free(nick); | |
| 751 | } | |
| 752 | ||
| 753 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 754 | { | |
| 755 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
756 | GaimConversation *convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
757 | char *nick = irc_mask_nick(from), *buf; |
| 6333 | 758 | |
| 759 | if (!gc) { | |
| 760 | g_free(nick); | |
| 761 | return; | |
| 762 | } | |
| 763 | ||
| 764 | if (!convo) { | |
| 765 | gaim_debug(GAIM_DEBUG_ERROR, "irc", "Recieved a KICK for unknown channel %s\n", args[0]); | |
| 766 | g_free(nick); | |
| 767 | return; | |
| 768 | } | |
| 769 | ||
| 770 | if (!gaim_utf8_strcasecmp(gaim_connection_get_display_name(gc), args[1])) { | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
771 | buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
772 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 773 | g_free(buf); |
| 8256 | 774 | serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo))); |
| 6333 | 775 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
776 | buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
777 | gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), args[1], buf); |
| 6333 | 778 | g_free(buf); |
| 779 | } | |
| 780 | ||
| 781 | g_free(nick); | |
| 782 | return; | |
| 783 | } | |
| 784 | ||
| 785 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 786 | { | |
| 787 | GaimConversation *convo; | |
| 788 | char *nick = irc_mask_nick(from), *buf; | |
| 789 | ||
| 790 | if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
791 | char *escaped; |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
792 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 793 | if (!convo) { |
| 794 | gaim_debug(GAIM_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); | |
| 795 | g_free(nick); | |
| 796 | return; | |
| 797 | } | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
798 | escaped = (args[2] != NULL) ? g_markup_escape_text(args[2], -1) : NULL; |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
799 | buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); |
|
12069
bf45000338cd
[gaim-migrate @ 14364]
Richard Laager <rlaager@pidgin.im>
parents:
12001
diff
changeset
|
800 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], buf, GAIM_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
801 | g_free(escaped); |
| 6333 | 802 | g_free(buf); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
803 | if(args[2]) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
804 | GaimConvChatBuddyFlags newflag, flags; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
805 | char *mcur, *cur, *end, *user; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
806 | gboolean add = FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
807 | mcur = args[1]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
808 | cur = args[2]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
809 | while (*cur && *mcur) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
810 | if ((*mcur == '+') || (*mcur == '-')) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
811 | add = (*mcur == '+') ? TRUE : FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
812 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
813 | continue; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
814 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
815 | end = strchr(cur, ' '); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
816 | if (!end) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
817 | end = cur + strlen(cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
818 | user = g_strndup(cur, end - cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
819 | flags = gaim_conv_chat_user_get_flags(GAIM_CONV_CHAT(convo), user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
820 | newflag = GAIM_CBFLAGS_NONE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
821 | if (*mcur == 'o') |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
822 | newflag = GAIM_CBFLAGS_OP; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
823 | else if (*mcur =='h') |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
824 | newflag = GAIM_CBFLAGS_HALFOP; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
825 | else if (*mcur == 'v') |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
826 | newflag = GAIM_CBFLAGS_VOICE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
827 | if (newflag) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
828 | if (add) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
829 | flags |= newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
830 | else |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
831 | flags &= ~newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
832 | gaim_conv_chat_user_set_flags(GAIM_CONV_CHAT(convo), user, flags); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
833 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
834 | g_free(user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
835 | cur = end; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
836 | if (*cur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
837 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
838 | if (*mcur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
839 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
840 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
841 | } |
| 6333 | 842 | } else { /* User */ |
| 843 | } | |
| 844 | g_free(nick); | |
| 845 | } | |
| 846 | ||
| 847 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 848 | { | |
| 849 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 10617 | 850 | GaimConversation *conv; |
| 6333 | 851 | GSList *chats; |
| 852 | char *nick = irc_mask_nick(from); | |
| 853 | ||
| 854 | if (!gc) { | |
| 855 | g_free(nick); | |
| 856 | return; | |
| 857 | } | |
| 858 | chats = gc->buddy_chats; | |
| 859 | ||
| 860 | if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { | |
| 861 | gaim_connection_set_display_name(gc, args[0]); | |
| 862 | } | |
| 863 | ||
| 864 | while (chats) { | |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
865 | GaimConvChat *chat = GAIM_CONV_CHAT(chats->data); |
| 9593 | 866 | /* This is ugly ... */ |
| 867 | if (gaim_conv_chat_find_user(chat, nick)) | |
| 868 | gaim_conv_chat_rename_user(chat, nick, args[0]); | |
| 6333 | 869 | chats = chats->next; |
| 870 | } | |
| 10617 | 871 | |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
872 | conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, nick, |
| 10617 | 873 | irc->account); |
| 874 | if (conv != NULL) | |
| 875 | gaim_conversation_set_name(conv, args[0]); | |
| 876 | ||
| 6333 | 877 | g_free(nick); |
| 878 | } | |
| 879 | ||
| 10633 | 880 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 881 | { | |
| 13057 | 882 | GaimConnection *gc = gaim_account_get_connection(irc->account); |
| 883 | if (gaim_connection_get_state(gc) == GAIM_CONNECTED) { | |
| 884 | gaim_notify_error(gc, _("Invalid nickname"), | |
| 885 | _("Invalid nickname"), | |
| 886 | _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); | |
| 887 | ||
| 888 | } else { | |
|
14731
a557d0ef5152
[gaim-migrate @ 17415]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14254
diff
changeset
|
889 | gc->wants_to_die = TRUE; |
| 13057 | 890 | gaim_connection_error(gaim_account_get_connection(irc->account), |
| 891 | _("Your selected account name was rejected by the server. It probably contains invalid characters.")); | |
| 892 | } | |
| 10633 | 893 | } |
| 894 | ||
| 6333 | 895 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 896 | { | |
| 897 | char *newnick, *buf, *end; | |
| 898 | ||
| 899 | if (!args || !args[1]) | |
| 900 | return; | |
| 901 | ||
| 902 | newnick = strdup(args[1]); | |
| 903 | end = newnick + strlen(newnick) - 1; | |
|
11386
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
904 | /* try fallbacks */ |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
905 | if((*end < '9') && (*end >= '1')) { |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
906 | *end = *end + 1; |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
907 | } else *end = '1'; |
| 6333 | 908 | |
| 909 | buf = irc_format(irc, "vn", "NICK", newnick); | |
| 910 | irc_send(irc, buf); | |
| 911 | g_free(buf); | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
912 | g_free(newnick); |
| 6333 | 913 | } |
| 914 | ||
| 915 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 916 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
917 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
918 | return; |
| 6333 | 919 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
920 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE); |
| 6333 | 921 | } |
| 922 | ||
| 6718 | 923 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 924 | { | |
| 925 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 926 | ||
| 6753 | 927 | if (!args || !args[2] || !gc) |
| 6718 | 928 | return; |
| 929 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
930 | gaim_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]); |
| 6718 | 931 | } |
| 932 | ||
| 6333 | 933 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 934 | { | |
| 935 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 936 | GaimConversation *convo; | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
937 | char *nick, *msg; |
| 6333 | 938 | |
| 8186 | 939 | if (!args || !args[0] || !gc) |
| 6333 | 940 | return; |
| 941 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
942 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 943 | if (!convo) { |
| 944 | gaim_debug(GAIM_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", args[0]); | |
| 945 | return; | |
| 946 | } | |
| 947 | ||
| 948 | nick = irc_mask_nick(from); | |
| 949 | if (!gaim_utf8_strcasecmp(nick, gaim_connection_get_display_name(gc))) { | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
950 | char *escaped = g_markup_escape_text(args[1], -1); |
| 8186 | 951 | msg = g_strdup_printf(_("You have parted the channel%s%s"), |
|
10551
9a6a1e333609
[gaim-migrate @ 11926]
Daniel Atallah <datallah@pidgin.im>
parents:
10504
diff
changeset
|
952 | (args[1] && *args[1]) ? ": " : "", |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
953 | (escaped && *escaped) ? escaped : ""); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
954 | g_free(escaped); |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
955 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), args[0], msg, GAIM_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 956 | g_free(msg); |
| 8256 | 957 | serv_got_chat_left(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo))); |
| 6333 | 958 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
959 | gaim_conv_chat_remove_user(GAIM_CONV_CHAT(convo), nick, args[1]); |
| 6333 | 960 | } |
| 961 | g_free(nick); | |
| 962 | } | |
| 963 | ||
| 964 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 965 | { | |
| 966 | char *buf; | |
| 967 | if (!args || !args[0]) | |
| 968 | return; | |
| 969 | ||
| 970 | buf = irc_format(irc, "v:", "PONG", args[0]); | |
| 971 | irc_send(irc, buf); | |
| 972 | g_free(buf); | |
| 973 | } | |
| 974 | ||
| 975 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 976 | { | |
| 977 | GaimConversation *convo; | |
| 978 | GaimConnection *gc; | |
| 979 | char **parts, *msg; | |
| 980 | time_t oldstamp; | |
| 981 | ||
| 982 | if (!args || !args[1]) | |
| 983 | return; | |
| 984 | ||
| 985 | parts = g_strsplit(args[1], " ", 2); | |
| 986 | ||
| 987 | if (!parts[0] || !parts[1]) { | |
| 988 | g_strfreev(parts); | |
| 989 | return; | |
| 990 | } | |
| 991 | ||
| 992 | if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
| 993 | msg = g_strdup(_("Error: invalid PONG from server")); | |
| 994 | } else { | |
| 6350 | 995 | msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
| 6333 | 996 | } |
| 997 | ||
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
998 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_ANY, parts[0], irc->account); |
| 6333 | 999 | g_strfreev(parts); |
| 1000 | if (convo) { | |
|
11338
1a3663ac9b05
[gaim-migrate @ 13551]
Mark Doliner <markdoliner@pidgin.im>
parents:
11026
diff
changeset
|
1001 | if (gaim_conversation_get_type (convo) == GAIM_CONV_TYPE_CHAT) |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1002 | gaim_conv_chat_write(GAIM_CONV_CHAT(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 1003 | else |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1004 | gaim_conv_im_write(GAIM_CONV_IM(convo), "PONG", msg, GAIM_MESSAGE_SYSTEM|GAIM_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 1005 | } else { |
| 1006 | gc = gaim_account_get_connection(irc->account); | |
| 1007 | if (!gc) { | |
| 1008 | g_free(msg); | |
| 1009 | return; | |
| 1010 | } | |
| 1011 | gaim_notify_info(gc, NULL, "PONG", msg); | |
| 1012 | } | |
| 1013 | g_free(msg); | |
| 1014 | } | |
| 1015 | ||
| 1016 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1017 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1018 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1019 | return; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1020 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1021 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], FALSE); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1022 | } |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1023 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1024 | static void irc_msg_handle_privmsg(struct irc_conn *irc, const char *name, const char *from, const char *to, const char *rawmsg, gboolean notice) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1025 | { |
| 6333 | 1026 | GaimConnection *gc = gaim_account_get_connection(irc->account); |
| 1027 | GaimConversation *convo; | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1028 | char *tmp; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1029 | char *msg; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1030 | char *nick; |
| 6333 | 1031 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1032 | if (!gc) |
| 6333 | 1033 | return; |
| 1034 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1035 | nick = irc_mask_nick(from); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1036 | tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice); |
| 6333 | 1037 | if (!tmp) { |
| 1038 | g_free(nick); | |
| 1039 | return; | |
| 1040 | } | |
| 8163 | 1041 | |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
1042 | msg = g_markup_escape_text(tmp, -1); |
| 6333 | 1043 | g_free(tmp); |
| 8163 | 1044 | |
| 1045 | tmp = irc_mirc2html(msg); | |
| 1046 | g_free(msg); | |
| 1047 | msg = tmp; | |
| 6333 | 1048 | if (notice) { |
| 1049 | tmp = g_strdup_printf("(notice) %s", msg); | |
| 1050 | g_free(msg); | |
| 1051 | msg = tmp; | |
| 1052 | } | |
| 1053 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1054 | if (!gaim_utf8_strcasecmp(to, gaim_connection_get_display_name(gc))) { |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6753
diff
changeset
|
1055 | serv_got_im(gc, nick, msg, 0, time(NULL)); |
| 6333 | 1056 | } else { |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1057 | convo = gaim_find_conversation_with_account(GAIM_CONV_TYPE_CHAT, to, irc->account); |
| 6333 | 1058 | if (convo) |
|
7118
280b3b85a28a
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1059 | serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); |
| 6333 | 1060 | else |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1061 | gaim_debug_error("irc", "Got a %s on %s, which does not exist\n", |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1062 | notice ? "NOTICE" : "PRIVMSG", to); |
| 6333 | 1063 | } |
| 1064 | g_free(msg); | |
| 1065 | g_free(nick); | |
| 1066 | } | |
| 1067 | ||
| 6714 | 1068 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1069 | { | |
| 1070 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 1071 | char *msg; | |
| 1072 | ||
| 1073 | if (!args || !args[1] || !args[2] || !gc) | |
| 1074 | return; | |
| 1075 | ||
| 1076 | msg = g_strdup_printf(_("Cannot join %s:"), args[1]); | |
| 1077 | gaim_notify_error(gc, _("Cannot join channel"), msg, args[2]); | |
| 1078 | g_free(msg); | |
| 1079 | } | |
| 1080 | ||
| 6333 | 1081 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1082 | { | |
| 1083 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
| 9238 | 1084 | struct irc_buddy *ib; |
| 6333 | 1085 | char *data[2]; |
| 1086 | ||
| 1087 | if (!args || !args[0] || !gc) | |
| 1088 | return; | |
| 1089 | ||
| 1090 | data[0] = irc_mask_nick(from); | |
| 1091 | data[1] = args[0]; | |
| 1092 | /* XXX this should have an API, I shouldn't grab this directly */ | |
| 1093 | g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); | |
| 9238 | 1094 | |
| 1095 | if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) { | |
| 1096 | ib->flag = FALSE; | |
| 1097 | irc_buddy_status(data[0], ib, irc); | |
| 1098 | } | |
| 6333 | 1099 | g_free(data[0]); |
| 1100 | ||
| 1101 | return; | |
| 1102 | } | |
| 1103 | ||
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1104 | void irc_msg_unavailable(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1105 | { |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1106 | GaimConnection *gc = gaim_account_get_connection(irc->account); |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1107 | |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1108 | if (!args || !args[1]) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1109 | return; |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1110 | |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1111 | gaim_notify_error(gc, NULL, _("Nick or channel is temporarily unavailable."), args[1]); |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1112 | } |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1113 | |
| 6333 | 1114 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1115 | { | |
| 1116 | GaimConnection *gc = gaim_account_get_connection(irc->account); | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1117 | char *nick, *msg; |
| 6333 | 1118 | |
| 1119 | if (!args || !args[0] || !gc) | |
| 1120 | return; | |
| 1121 | ||
| 1122 | nick = irc_mask_nick(from); | |
| 1123 | msg = g_strdup_printf (_("Wallops from %s"), nick); | |
| 1124 | g_free(nick); | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1125 | gaim_notify_info(gc, NULL, msg, args[0]); |
| 6333 | 1126 | g_free(msg); |
| 1127 | } | |
| 1128 | ||
| 1129 | void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1130 | { | |
| 1131 | return; | |
| 1132 | } |