Tue, 02 Oct 2007 17:16:16 +0000
Rename PURPLE_REASON_INVALID_USERNAME to PURPLE_REASON_INVALID_SETTINGS, so it
can be used when a server parameter is required but not supplied (for example).
| 6333 | 1 | /** |
| 2 | * @file msgs.c | |
|
13786
ec07d27800aa
[gaim-migrate @ 16196]
Daniel Atallah <datallah@pidgin.im>
parents:
13667
diff
changeset
|
3 | * |
| 15884 | 4 | * purple |
| 6333 | 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 | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
17409
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 6333 | 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); | |
| 15884 | 36 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]); |
| 6333 | 37 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc); |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
38 | static void irc_connected(struct irc_conn *irc, const char *nick); |
| 6333 | 39 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
40 | 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
|
41 | const char *from, const char *to, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
42 | const char *rawmsg, gboolean notice); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
43 | |
| 6333 | 44 | static char *irc_mask_nick(const char *mask) |
| 45 | { | |
| 46 | char *end, *buf; | |
| 47 | ||
| 48 | end = strchr(mask, '!'); | |
| 49 | if (!end) | |
| 50 | buf = g_strdup(mask); | |
| 51 | else | |
| 52 | buf = g_strndup(mask, end - mask); | |
| 53 | ||
| 54 | return buf; | |
| 55 | } | |
| 56 | ||
| 57 | static char *irc_mask_userhost(const char *mask) | |
| 58 | { | |
| 59 | return g_strdup(strchr(mask, '!') + 1); | |
| 60 | } | |
| 61 | ||
| 15884 | 62 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]) |
| 6333 | 63 | { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
64 | char *message; |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
65 | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
66 | message = g_strdup_printf("quit: %s", data[1]); |
| 6333 | 67 | |
| 15884 | 68 | if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(convo), data[0])) |
| 69 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), data[0], message); | |
| 6333 | 70 | |
| 71 | g_free(message); | |
| 72 | } | |
| 73 | ||
|
17170
609d6acda6aa
Oops; I made some errors in the last commit. This is a fix of my
Ethan Blanton <elb@pidgin.im>
parents:
17169
diff
changeset
|
74 | static void irc_connected(struct irc_conn *irc, const char *nick) |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
75 | { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
76 | PurpleConnection *gc; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
77 | PurpleStatus *status; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
78 | PurpleBlistNode *gnode, *cnode, *bnode; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
79 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
80 | if ((gc = purple_account_get_connection(irc->account)) == NULL |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
81 | || PURPLE_CONNECTION_IS_CONNECTED(gc)) |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
82 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
83 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
84 | purple_connection_set_display_name(gc, nick); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
85 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
86 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
87 | /* If we're away then set our away message */ |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
88 | status = purple_account_get_active_status(irc->account); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
89 | if (!purple_status_get_type(status) != PURPLE_STATUS_AVAILABLE) { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
90 | PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(gc->prpl); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
91 | prpl_info->set_status(irc->account, status); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
92 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
93 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
94 | /* this used to be in the core, but it's not now */ |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
95 | for (gnode = purple_get_blist()->root; gnode; gnode = gnode->next) { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
96 | if(!PURPLE_BLIST_NODE_IS_GROUP(gnode)) |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
97 | continue; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
98 | for(cnode = gnode->child; cnode; cnode = cnode->next) { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
99 | if(!PURPLE_BLIST_NODE_IS_CONTACT(cnode)) |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
100 | continue; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
101 | for(bnode = cnode->child; bnode; bnode = bnode->next) { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
102 | PurpleBuddy *b; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
103 | if(!PURPLE_BLIST_NODE_IS_BUDDY(bnode)) |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
104 | continue; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
105 | b = (PurpleBuddy *)bnode; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
106 | if(b->account == gc->account) { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
107 | struct irc_buddy *ib = g_new0(struct irc_buddy, 1); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
108 | ib->name = g_strdup(b->name); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
109 | g_hash_table_insert(irc->buddies, ib->name, ib); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
110 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
111 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
112 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
113 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
114 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
115 | irc_blist_timeout(irc); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
116 | if (!irc->timer) |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
117 | irc->timer = purple_timeout_add(45000, (GSourceFunc)irc_blist_timeout, (gpointer)irc); |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
118 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
119 | |
| 6333 | 120 | void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 121 | { | |
| 15884 | 122 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", args[0]); |
| 6333 | 123 | } |
| 124 | ||
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
125 | 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
|
126 | { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
127 | gchar **features; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
128 | int i; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
129 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
130 | 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
|
131 | return; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
132 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
133 | 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
|
134 | 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
|
135 | char *val; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
136 | 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
|
137 | if ((val = strchr(features[i] + 7, ')')) != NULL) |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
138 | irc->mode_chars = g_strdup(val + 1); |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
139 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
140 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
141 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
142 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
143 | 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
|
144 | { |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
145 | if (!args || !args[0]) |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
146 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
147 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
148 | if (!strcmp(name, "251")) { |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
149 | /* 251 is required, so we pluck our nick from here and |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
150 | * finalize connection */ |
|
17170
609d6acda6aa
Oops; I made some errors in the last commit. This is a fix of my
Ethan Blanton <elb@pidgin.im>
parents:
17169
diff
changeset
|
151 | irc_connected(irc, args[0]); |
|
16893
f7c5d28375a8
Fix broken IRC servers which do not send a 255 numeric
Ethan Blanton <elb@pidgin.im>
parents:
16474
diff
changeset
|
152 | /* Some IRC servers seem to not send a 255 numeric, so |
|
f7c5d28375a8
Fix broken IRC servers which do not send a 255 numeric
Ethan Blanton <elb@pidgin.im>
parents:
16474
diff
changeset
|
153 | * I guess we can't require it; 251 will do. */ |
|
f7c5d28375a8
Fix broken IRC servers which do not send a 255 numeric
Ethan Blanton <elb@pidgin.im>
parents:
16474
diff
changeset
|
154 | /* } else if (!strcmp(name, "255")) { */ |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
155 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
156 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
157 | |
| 6333 | 158 | void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 159 | { | |
| 15884 | 160 | PurpleConnection *gc; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
161 | char *msg; |
| 6333 | 162 | |
| 163 | if (!args || !args[1]) | |
| 164 | return; | |
| 165 | ||
| 15884 | 166 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 167 | /* We're doing a whois, show this in the whois dialog */ |
| 168 | irc_msg_whois(irc, name, from, args); | |
| 169 | return; | |
| 170 | } | |
| 171 | ||
| 15884 | 172 | gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
173 | if (gc) { |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
174 | msg = g_markup_escape_text(args[2], -1); |
| 15884 | 175 | serv_got_im(gc, args[1], msg, PURPLE_MESSAGE_AUTO_RESP, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
176 | g_free(msg); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
177 | } |
| 6333 | 178 | } |
| 179 | ||
| 180 | void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 181 | { | |
| 15884 | 182 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 183 | |
| 184 | if (!args || !args[1] || !gc) | |
| 185 | return; | |
| 186 | ||
| 15884 | 187 | purple_notify_error(gc, NULL, _("Bad mode"), args[1]); |
| 6333 | 188 | } |
| 189 | ||
| 190 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 191 | { | |
| 15884 | 192 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 193 | char *buf; |
| 194 | ||
| 195 | if (!args || !args[1] || !gc) | |
| 196 | return; | |
| 197 | ||
| 198 | buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
| 15884 | 199 | purple_notify_error(gc, _("Banned"), _("Banned"), buf); |
| 6333 | 200 | g_free(buf); |
| 201 | } | |
| 202 | ||
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
203 | 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
|
204 | { |
| 15884 | 205 | PurpleConversation *convo; |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
206 | char *buf, *nick; |
|
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 | if (!args || !args[0] || !args[1] || !args[2]) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
209 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
210 | |
| 15884 | 211 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
212 | if (!convo) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
213 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
214 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
215 | nick = g_markup_escape_text(args[2], -1); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
216 | buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
217 | g_free(nick); |
| 15884 | 218 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, |
| 219 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, | |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
220 | time(NULL)); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
221 | g_free(buf); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
222 | } |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
223 | |
| 6333 | 224 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 225 | { | |
| 15884 | 226 | PurpleConversation *convo; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
227 | char *buf, *escaped; |
| 6333 | 228 | |
| 229 | if (!args || !args[1] || !args[2]) | |
| 230 | return; | |
| 231 | ||
| 15884 | 232 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 233 | if (!convo) /* XXX punt on channels we are not in for now */ |
| 234 | return; | |
| 235 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
236 | 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
|
237 | buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); |
| 15884 | 238 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
239 | g_free(escaped); |
| 6333 | 240 | g_free(buf); |
| 241 | ||
| 242 | return; | |
| 243 | } | |
| 244 | ||
| 245 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 246 | { | |
| 247 | if (!irc->whois.nick) { | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
248 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected %s reply for %s\n", !strcmp(name, "314") ? "WHOWAS" : "WHOIS" |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
249 | , args[1]); |
| 6333 | 250 | return; |
| 251 | } | |
| 252 | ||
| 15884 | 253 | if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
254 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Got %s reply for %s while waiting for %s\n", !strcmp(name, "314") ? "WHOWAS" : "WHOIS" |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
255 | , args[1], irc->whois.nick); |
| 6333 | 256 | return; |
| 257 | } | |
| 258 | ||
| 259 | if (!strcmp(name, "301")) { | |
| 260 | irc->whois.away = g_strdup(args[2]); | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
261 | } else if (!strcmp(name, "311") || !strcmp(name, "314")) { |
| 6333 | 262 | irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]); |
| 263 | irc->whois.name = g_strdup(args[5]); | |
| 264 | } else if (!strcmp(name, "312")) { | |
| 265 | irc->whois.server = g_strdup(args[2]); | |
| 266 | irc->whois.serverinfo = g_strdup(args[3]); | |
| 267 | } else if (!strcmp(name, "313")) { | |
| 268 | irc->whois.ircop = 1; | |
| 269 | } else if (!strcmp(name, "317")) { | |
| 270 | irc->whois.idle = atoi(args[2]); | |
| 271 | if (args[3]) | |
| 272 | irc->whois.signon = (time_t)atoi(args[3]); | |
| 273 | } else if (!strcmp(name, "319")) { | |
| 274 | irc->whois.channels = g_strdup(args[2]); | |
| 275 | } else if (!strcmp(name, "320")) { | |
| 276 | irc->whois.identified = 1; | |
| 277 | } | |
| 278 | } | |
| 279 | ||
| 280 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 281 | { | |
| 15884 | 282 | PurpleConnection *gc; |
|
15215
3b4c0490b8b0
[gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
283 | char *tmp, *tmp2; |
| 15884 | 284 | PurpleNotifyUserInfo *user_info; |
| 6333 | 285 | |
| 286 | if (!irc->whois.nick) { | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
287 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of %s for %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
288 | , args[1]); |
| 6333 | 289 | return; |
| 290 | } | |
| 15884 | 291 | if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
292 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of %s for %s, expecting %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" |
|
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
293 | , args[1], irc->whois.nick); |
| 6333 | 294 | return; |
| 295 | } | |
| 296 | ||
| 15884 | 297 | user_info = purple_notify_user_info_new(); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
298 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
299 | tmp2 = g_markup_escape_text(args[1], -1); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
300 | tmp = g_strdup_printf("%s%s%s", tmp2, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
301 | (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
302 | (irc->whois.identified ? _(" <i>(identified)</i>") : "")); |
| 15884 | 303 | purple_notify_user_info_add_pair(user_info, _("Nick"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
304 | g_free(tmp2); |
| 10634 | 305 | g_free(tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
306 | |
| 6333 | 307 | if (irc->whois.away) { |
| 10634 | 308 | tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); |
| 6333 | 309 | g_free(irc->whois.away); |
| 15884 | 310 | purple_notify_user_info_add_pair(user_info, _("Away"), tmp); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
311 | g_free(tmp); |
| 6333 | 312 | } |
| 313 | if (irc->whois.userhost) { | |
| 10634 | 314 | 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
|
315 | g_free(irc->whois.name); |
| 15884 | 316 | purple_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); |
| 317 | purple_notify_user_info_add_pair(user_info, _("Real name"), tmp); | |
| 6333 | 318 | g_free(irc->whois.userhost); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
319 | g_free(tmp); |
| 6333 | 320 | } |
| 321 | if (irc->whois.server) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
322 | tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); |
| 15884 | 323 | purple_notify_user_info_add_pair(user_info, _("Server"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
324 | g_free(tmp); |
| 6333 | 325 | g_free(irc->whois.server); |
| 326 | g_free(irc->whois.serverinfo); | |
| 327 | } | |
| 328 | if (irc->whois.channels) { | |
| 15884 | 329 | purple_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels); |
| 6333 | 330 | g_free(irc->whois.channels); |
| 331 | } | |
| 332 | if (irc->whois.idle) { | |
| 15884 | 333 | gchar *timex = purple_str_seconds_to_string(irc->whois.idle); |
| 334 | purple_notify_user_info_add_pair(user_info, _("Idle for"), timex); | |
|
6357
f83643b0a067
[gaim-migrate @ 6856]
Mark Doliner <markdoliner@pidgin.im>
parents:
6351
diff
changeset
|
335 | g_free(timex); |
| 15884 | 336 | purple_notify_user_info_add_pair(user_info, |
| 337 | _("Online since"), purple_date_format_full(localtime(&irc->whois.signon))); | |
| 6333 | 338 | } |
| 339 | if (!strcmp(irc->whois.nick, "Paco-Paco")) { | |
| 15884 | 340 | purple_notify_user_info_add_pair(user_info, |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
341 | _("<b>Defining adjective:</b>"), _("Glorious")); |
| 6333 | 342 | } |
| 343 | ||
| 15884 | 344 | gc = purple_account_get_connection(irc->account); |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
345 | |
| 15884 | 346 | purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); |
| 347 | purple_notify_user_info_destroy(user_info); | |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
348 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
349 | g_free(irc->whois.nick); |
| 6333 | 350 | memset(&irc->whois, 0, sizeof(irc->whois)); |
| 351 | } | |
| 352 | ||
| 8114 | 353 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 354 | { | |
| 355 | if (!irc->roomlist) | |
| 356 | return; | |
| 357 | ||
| 358 | if (!strcmp(name, "321")) { | |
| 15884 | 359 | purple_roomlist_set_in_progress(irc->roomlist, TRUE); |
| 8114 | 360 | return; |
| 361 | } | |
| 362 | ||
| 363 | if (!strcmp(name, "323")) { | |
| 15884 | 364 | purple_roomlist_set_in_progress(irc->roomlist, FALSE); |
| 365 | purple_roomlist_unref(irc->roomlist); | |
| 8114 | 366 | irc->roomlist = NULL; |
|
13667
9ebf0007d912
[gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents:
13647
diff
changeset
|
367 | return; |
| 8114 | 368 | } |
| 369 | ||
| 370 | if (!strcmp(name, "322")) { | |
| 15884 | 371 | PurpleRoomlistRoom *room; |
|
17409
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
372 | char *topic; |
| 8114 | 373 | |
| 374 | if (!args[0] || !args[1] || !args[2] || !args[3]) | |
| 375 | return; | |
| 376 | ||
| 15884 | 377 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); |
| 378 | purple_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
| 379 | purple_roomlist_room_add_field(irc->roomlist, room, GINT_TO_POINTER(strtol(args[2], NULL, 10))); | |
|
17409
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
380 | topic = irc_mirc2txt(args[3]); |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
381 | purple_roomlist_room_add_field(irc->roomlist, room, topic); |
|
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
382 | g_free(topic); |
| 15884 | 383 | purple_roomlist_room_add(irc->roomlist, room); |
| 8114 | 384 | } |
| 385 | } | |
| 386 | ||
| 6333 | 387 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 388 | { | |
| 9762 | 389 | char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
| 15884 | 390 | PurpleConversation *convo; |
| 6333 | 391 | |
| 392 | if (!strcmp(name, "topic")) { | |
| 393 | chan = args[0]; | |
| 8529 | 394 | topic = irc_mirc2txt (args[1]); |
| 6333 | 395 | } else { |
| 396 | chan = args[1]; | |
| 8529 | 397 | topic = irc_mirc2txt (args[2]); |
| 6333 | 398 | } |
| 399 | ||
| 15884 | 400 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chan, irc->account); |
|
13647
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
401 | if (!convo) { |
| 15884 | 402 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a topic for %s, which doesn't exist\n", chan); |
|
13647
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
403 | g_free(topic); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
404 | return; |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
405 | } |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
406 | |
| 6333 | 407 | /* If this is an interactive update, print it out */ |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
408 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 409 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 410 | g_free(tmp); |
| 6333 | 411 | if (!strcmp(name, "topic")) { |
| 15884 | 412 | const char *current_topic = purple_conv_chat_get_topic(PURPLE_CONV_CHAT(convo)); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
413 | if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0)) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
414 | { |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
415 | char *nick_esc; |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
416 | nick = irc_mask_nick(from); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
417 | nick_esc = g_markup_escape_text(nick, -1); |
| 15884 | 418 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), nick, topic); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
419 | if (*tmp2) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
420 | 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
|
421 | else |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
422 | msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
423 | g_free(nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
424 | g_free(nick); |
| 15884 | 425 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), from, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
426 | g_free(msg); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
427 | } |
| 6333 | 428 | } else { |
|
13395
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
429 | char *chan_esc = g_markup_escape_text(chan, -1); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
430 | 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
|
431 | g_free(chan_esc); |
| 15884 | 432 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic); |
| 433 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
| 6333 | 434 | g_free(msg); |
| 435 | } | |
| 9762 | 436 | g_free(tmp2); |
| 8529 | 437 | g_free(topic); |
| 6333 | 438 | } |
| 439 | ||
| 440 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 441 | { | |
| 15884 | 442 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 443 | char *buf; |
| 444 | ||
| 445 | if (!args || !args[1] || !gc) | |
| 446 | return; | |
| 447 | ||
| 448 | buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
| 15884 | 449 | purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand.")); |
| 6333 | 450 | g_free(buf); |
| 451 | } | |
| 452 | ||
| 453 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 454 | { | |
| 455 | char *names, *cur, *end, *tmp, *msg; | |
| 15884 | 456 | PurpleConversation *convo; |
| 6333 | 457 | |
| 458 | if (!strcmp(name, "366")) { | |
| 15884 | 459 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 460 | if (!convo) { |
| 15884 | 461 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); |
| 6333 | 462 | g_string_free(irc->names, TRUE); |
| 463 | irc->names = NULL; | |
| 464 | return; | |
| 465 | } | |
| 466 | ||
| 467 | names = cur = g_string_free(irc->names, FALSE); | |
| 468 | irc->names = NULL; | |
| 15884 | 469 | if (purple_conversation_get_data(convo, IRC_NAMES_FLAG)) { |
|
11026
1f13c483db00
[gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents:
10816
diff
changeset
|
470 | msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
| 15884 | 471 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) |
| 472 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 473 | else |
| 15884 | 474 | purple_conv_im_write(PURPLE_CONV_IM(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 475 | g_free(msg); |
| 476 | } else { | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
477 | GList *users = NULL; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
478 | GList *flags = NULL; |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
479 | |
| 6333 | 480 | while (*cur) { |
| 15884 | 481 | PurpleConvChatBuddyFlags f = PURPLE_CBFLAGS_NONE; |
| 6333 | 482 | end = strchr(cur, ' '); |
| 483 | if (!end) | |
| 484 | end = cur + strlen(cur); | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
485 | if (*cur == '@') { |
| 15884 | 486 | f = PURPLE_CBFLAGS_OP; |
| 6333 | 487 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
488 | } else if (*cur == '%') { |
| 15884 | 489 | f = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
490 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
491 | } else if(*cur == '+') { |
| 15884 | 492 | f = PURPLE_CBFLAGS_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
493 | cur++; |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
494 | } else if(irc->mode_chars |
|
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
495 | && strchr(irc->mode_chars, *cur)) { |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
496 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
497 | } |
| 6333 | 498 | tmp = g_strndup(cur, end - cur); |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
499 | users = g_list_prepend(users, tmp); |
|
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
500 | flags = g_list_prepend(flags, GINT_TO_POINTER(f)); |
| 6333 | 501 | cur = end; |
| 502 | if (*cur) | |
| 503 | cur++; | |
| 504 | } | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
505 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
506 | if (users != NULL) { |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
507 | GList *l; |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
508 | |
| 15884 | 509 | purple_conv_chat_add_users(PURPLE_CONV_CHAT(convo), users, NULL, flags, FALSE); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
510 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
511 | for (l = users; l != NULL; l = l->next) |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
512 | g_free(l->data); |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
513 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
514 | g_list_free(users); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
515 | g_list_free(flags); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
516 | } |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
517 | |
| 15884 | 518 | purple_conversation_set_data(convo, IRC_NAMES_FLAG, |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
519 | GINT_TO_POINTER(TRUE)); |
| 6333 | 520 | } |
| 521 | g_free(names); | |
| 522 | } else { | |
| 523 | if (!irc->names) | |
| 524 | irc->names = g_string_new(""); | |
| 525 | ||
| 15313 | 526 | if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ') |
| 527 | irc->names = g_string_append_c(irc->names, ' '); | |
| 6333 | 528 | irc->names = g_string_append(irc->names, args[3]); |
| 529 | } | |
| 530 | } | |
| 531 | ||
| 532 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 533 | { | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
534 | char *escaped; |
| 6333 | 535 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
536 | if (!args || !args[0]) |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
537 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
538 | |
| 6333 | 539 | if (!irc->motd) |
| 540 | irc->motd = g_string_new(""); | |
| 541 | ||
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
542 | 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
|
543 | 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
|
544 | 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
|
545 | 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
|
546 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
547 | } else if (!strcmp(name, "376")) { |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
548 | /* dircproxy 1.0.5 does not send 251 on reconnection, so |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
549 | * finalize the connection here if it is not already done. */ |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
550 | irc_connected(irc, args[0]); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
551 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
552 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
553 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
554 | if (!irc->motd) { |
| 15884 | 555 | purple_debug_error("irc", "IRC server sent MOTD without STARTMOTD\n"); |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
556 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
557 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
558 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
559 | if (!args[1]) |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
560 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
561 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
562 | escaped = g_markup_escape_text(args[1], -1); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
563 | g_string_append_printf(irc->motd, "%s<br>", escaped); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
564 | g_free(escaped); |
| 6333 | 565 | } |
| 566 | ||
| 10564 | 567 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 568 | { | |
| 15884 | 569 | PurpleConnection *gc; |
| 10564 | 570 | |
| 15884 | 571 | gc = purple_account_get_connection(irc->account); |
| 10564 | 572 | if (gc == NULL || args == NULL || args[2] == NULL) |
| 573 | return; | |
| 574 | ||
| 15884 | 575 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"), |
| 10564 | 576 | _("The IRC server's local time is:"), |
| 577 | args[2], NULL, NULL); | |
| 578 | } | |
| 579 | ||
| 7877 | 580 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 581 | { | |
| 15884 | 582 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 7877 | 583 | |
| 584 | if (gc == NULL || args == NULL || args[1] == NULL) | |
| 585 | return; | |
| 586 | ||
| 15884 | 587 | purple_notify_error(gc, NULL, _("No such channel"), args[1]); |
| 7877 | 588 | } |
| 589 | ||
| 6333 | 590 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 591 | { | |
| 15884 | 592 | PurpleConnection *gc; |
| 593 | PurpleConversation *convo; | |
| 6333 | 594 | |
| 15884 | 595 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 596 | if (convo) { |
| 15884 | 597 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) /* does this happen? */ |
| 598 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], _("no such channel"), | |
| 599 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 600 | else |
| 15884 | 601 | purple_conv_im_write(PURPLE_CONV_IM(convo), args[1], _("User is not logged in"), |
| 602 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 603 | } else { |
| 15884 | 604 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 605 | return; |
| 15884 | 606 | purple_notify_error(gc, NULL, _("No such nick or channel"), args[1]); |
| 6333 | 607 | } |
| 608 | ||
| 15884 | 609 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 610 | g_free(irc->whois.nick); |
| 611 | irc->whois.nick = NULL; | |
| 612 | } | |
| 613 | } | |
| 614 | ||
| 615 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 616 | { | |
| 15884 | 617 | PurpleConnection *gc; |
| 618 | PurpleConversation *convo; | |
| 6333 | 619 | |
| 15884 | 620 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 621 | if (convo) { |
| 15884 | 622 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 623 | } else { |
| 15884 | 624 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 625 | return; |
| 15884 | 626 | purple_notify_error(gc, NULL, _("Could not send"), args[2]); |
| 6333 | 627 | } |
| 628 | } | |
| 629 | ||
| 630 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 631 | { | |
| 15884 | 632 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 633 | |
| 15884 | 634 | purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); |
| 6333 | 635 | if (convo) { |
| 636 | /*g_slist_remove(irc->gc->buddy_chats, convo); | |
| 15884 | 637 | purple_conversation_set_account(convo, NULL);*/ |
| 638 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 639 | } |
| 640 | } | |
| 641 | ||
| 642 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 643 | { | |
| 15884 | 644 | PurpleConversation *convo; |
| 6333 | 645 | |
| 646 | if (!args || !args[1] || !args[2]) | |
| 647 | return; | |
| 648 | ||
| 15884 | 649 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 650 | if (!convo) |
| 651 | return; | |
| 652 | ||
| 15884 | 653 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 654 | } |
| 655 | ||
| 656 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 657 | { | |
| 15884 | 658 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 659 | GHashTable *components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
| 660 | char *nick = irc_mask_nick(from); | |
| 661 | ||
| 662 | if (!args || !args[1] || !gc) { | |
| 663 | g_free(nick); | |
| 664 | g_hash_table_destroy(components); | |
| 665 | return; | |
| 666 | } | |
| 667 | ||
| 668 | g_hash_table_insert(components, strdup("channel"), strdup(args[1])); | |
| 669 | ||
| 670 | serv_got_chat_invite(gc, args[1], nick, NULL, components); | |
| 671 | g_free(nick); | |
| 672 | } | |
| 673 | ||
| 674 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 675 | { | |
| 15884 | 676 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 677 | char *buf; |
| 678 | ||
| 679 | if (!args || !args[1] || !gc) | |
| 680 | return; | |
| 681 | ||
| 682 | buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
| 15884 | 683 | purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf); |
| 6333 | 684 | g_free(buf); |
| 685 | } | |
| 686 | ||
| 687 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 688 | { | |
| 689 | char **nicks; | |
| 690 | struct irc_buddy *ib; | |
| 691 | int i; | |
| 692 | ||
| 693 | if (!args || !args[1]) | |
| 694 | return; | |
| 695 | ||
| 696 | nicks = g_strsplit(args[1], " ", -1); | |
| 697 | ||
| 698 | for (i = 0; nicks[i]; i++) { | |
| 699 | if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
| 700 | continue; | |
| 701 | } | |
| 702 | ib->flag = TRUE; | |
| 703 | } | |
| 704 | ||
| 6350 | 705 | g_strfreev(nicks); |
| 706 | ||
| 6333 | 707 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
| 708 | } | |
| 709 | ||
| 710 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
| 711 | { | |
| 15884 | 712 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 713 | PurpleBuddy *buddy = purple_find_buddy(irc->account, name); | |
| 6333 | 714 | |
| 715 | if (!gc || !buddy) | |
| 716 | return; | |
| 717 | ||
| 718 | if (ib->online && !ib->flag) { | |
| 15884 | 719 | purple_prpl_got_user_status(irc->account, name, "offline", NULL); |
| 6333 | 720 | ib->online = FALSE; |
| 10242 | 721 | } else if (!ib->online && ib->flag) { |
| 15884 | 722 | purple_prpl_got_user_status(irc->account, name, "available", NULL); |
| 6333 | 723 | ib->online = TRUE; |
| 724 | } | |
| 725 | } | |
| 726 | ||
| 727 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 728 | { | |
| 15884 | 729 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 730 | PurpleConversation *convo; | |
| 6333 | 731 | char *nick = irc_mask_nick(from), *userhost; |
| 9238 | 732 | struct irc_buddy *ib; |
| 6333 | 733 | static int id = 1; |
| 734 | ||
| 735 | if (!gc) { | |
| 736 | g_free(nick); | |
| 737 | return; | |
| 738 | } | |
| 739 | ||
| 15884 | 740 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 6333 | 741 | /* We are joining a channel for the first time */ |
| 742 | serv_got_joined_chat(gc, id++, args[0]); | |
| 743 | g_free(nick); | |
| 15884 | 744 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
| 13938 | 745 | args[0], |
| 746 | irc->account); | |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
747 | |
| 13938 | 748 | if (convo == NULL) { |
| 15884 | 749 | purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]); |
| 13938 | 750 | return; |
| 751 | } | |
| 15884 | 752 | purple_conversation_set_data(convo, IRC_NAMES_FLAG, |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
753 | GINT_TO_POINTER(FALSE)); |
| 15884 | 754 | purple_conversation_present(convo); |
| 6333 | 755 | return; |
| 756 | } | |
| 757 | ||
| 15884 | 758 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 759 | if (convo == NULL) { |
| 15884 | 760 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); |
| 6333 | 761 | g_free(nick); |
| 762 | return; | |
| 763 | } | |
| 764 | ||
| 765 | userhost = irc_mask_userhost(from); | |
| 15884 | 766 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE); |
| 9238 | 767 | |
| 768 | if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { | |
| 769 | ib->flag = TRUE; | |
| 770 | irc_buddy_status(nick, ib, irc); | |
| 771 | } | |
| 772 | ||
| 6333 | 773 | g_free(userhost); |
| 774 | g_free(nick); | |
| 775 | } | |
| 776 | ||
| 777 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 778 | { | |
| 15884 | 779 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 780 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
781 | char *nick = irc_mask_nick(from), *buf; |
| 6333 | 782 | |
| 783 | if (!gc) { | |
| 784 | g_free(nick); | |
| 785 | return; | |
| 786 | } | |
| 787 | ||
| 788 | if (!convo) { | |
| 15884 | 789 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Recieved a KICK for unknown channel %s\n", args[0]); |
| 6333 | 790 | g_free(nick); |
| 791 | return; | |
| 792 | } | |
| 793 | ||
| 15884 | 794 | if (!purple_utf8_strcasecmp(purple_connection_get_display_name(gc), args[1])) { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
795 | buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
| 15884 | 796 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 797 | g_free(buf); |
| 15884 | 798 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 799 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
800 | buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
| 15884 | 801 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), args[1], buf); |
| 6333 | 802 | g_free(buf); |
| 803 | } | |
| 804 | ||
| 805 | g_free(nick); | |
| 806 | return; | |
| 807 | } | |
| 808 | ||
| 809 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 810 | { | |
| 15884 | 811 | PurpleConversation *convo; |
| 6333 | 812 | char *nick = irc_mask_nick(from), *buf; |
| 813 | ||
| 814 | if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
815 | char *escaped; |
| 15884 | 816 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 817 | if (!convo) { |
| 15884 | 818 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); |
| 6333 | 819 | g_free(nick); |
| 820 | return; | |
| 821 | } | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
822 | 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
|
823 | buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); |
| 15884 | 824 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
825 | g_free(escaped); |
| 6333 | 826 | g_free(buf); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
827 | if(args[2]) { |
| 15884 | 828 | PurpleConvChatBuddyFlags newflag, flags; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
829 | char *mcur, *cur, *end, *user; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
830 | gboolean add = FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
831 | mcur = args[1]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
832 | cur = args[2]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
833 | while (*cur && *mcur) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
834 | if ((*mcur == '+') || (*mcur == '-')) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
835 | add = (*mcur == '+') ? TRUE : FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
836 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
837 | continue; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
838 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
839 | end = strchr(cur, ' '); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
840 | if (!end) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
841 | end = cur + strlen(cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
842 | user = g_strndup(cur, end - cur); |
| 15884 | 843 | flags = purple_conv_chat_user_get_flags(PURPLE_CONV_CHAT(convo), user); |
| 844 | newflag = PURPLE_CBFLAGS_NONE; | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
845 | if (*mcur == 'o') |
| 15884 | 846 | newflag = PURPLE_CBFLAGS_OP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
847 | else if (*mcur =='h') |
| 15884 | 848 | newflag = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
849 | else if (*mcur == 'v') |
| 15884 | 850 | newflag = PURPLE_CBFLAGS_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
851 | if (newflag) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
852 | if (add) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
853 | flags |= newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
854 | else |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
855 | flags &= ~newflag; |
| 15884 | 856 | purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(convo), user, flags); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
857 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
858 | g_free(user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
859 | cur = end; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
860 | if (*cur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
861 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
862 | if (*mcur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
863 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
864 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
865 | } |
| 6333 | 866 | } else { /* User */ |
| 867 | } | |
| 868 | g_free(nick); | |
| 869 | } | |
| 870 | ||
| 871 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 872 | { | |
| 15884 | 873 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 874 | PurpleConversation *conv; | |
| 6333 | 875 | GSList *chats; |
| 876 | char *nick = irc_mask_nick(from); | |
| 877 | ||
| 878 | if (!gc) { | |
| 879 | g_free(nick); | |
| 880 | return; | |
| 881 | } | |
| 882 | chats = gc->buddy_chats; | |
| 883 | ||
| 15884 | 884 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 885 | purple_connection_set_display_name(gc, args[0]); | |
| 6333 | 886 | } |
| 887 | ||
| 888 | while (chats) { | |
| 15884 | 889 | PurpleConvChat *chat = PURPLE_CONV_CHAT(chats->data); |
| 9593 | 890 | /* This is ugly ... */ |
| 15884 | 891 | if (purple_conv_chat_find_user(chat, nick)) |
| 892 | purple_conv_chat_rename_user(chat, nick, args[0]); | |
| 6333 | 893 | chats = chats->next; |
| 894 | } | |
| 10617 | 895 | |
| 15884 | 896 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, nick, |
| 10617 | 897 | irc->account); |
| 898 | if (conv != NULL) | |
| 15884 | 899 | purple_conversation_set_name(conv, args[0]); |
| 10617 | 900 | |
| 6333 | 901 | g_free(nick); |
| 902 | } | |
| 903 | ||
| 10633 | 904 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 905 | { | |
| 15884 | 906 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 907 | if (purple_connection_get_state(gc) == PURPLE_CONNECTED) { | |
| 908 | purple_notify_error(gc, _("Invalid nickname"), | |
| 13057 | 909 | _("Invalid nickname"), |
| 910 | _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); | |
| 911 | ||
| 912 | } else { | |
|
14731
a557d0ef5152
[gaim-migrate @ 17415]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
14254
diff
changeset
|
913 | gc->wants_to_die = TRUE; |
|
20456
77550b97ebf2
Rename PURPLE_REASON_INVALID_USERNAME to PURPLE_REASON_INVALID_SETTINGS, so it
Will Thompson <resiak@pidgin.im>
parents:
20440
diff
changeset
|
914 | purple_connection_error_reason (gc, PURPLE_REASON_INVALID_SETTINGS, |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
915 | _("Your selected account name was rejected by the server. It probably contains invalid characters.")); |
| 13057 | 916 | } |
| 10633 | 917 | } |
| 918 | ||
| 6333 | 919 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 920 | { | |
| 921 | char *newnick, *buf, *end; | |
| 922 | ||
| 923 | if (!args || !args[1]) | |
| 924 | return; | |
| 925 | ||
| 926 | newnick = strdup(args[1]); | |
| 927 | end = newnick + strlen(newnick) - 1; | |
|
11386
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
928 | /* try fallbacks */ |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
929 | if((*end < '9') && (*end >= '1')) { |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
930 | *end = *end + 1; |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
931 | } else *end = '1'; |
| 6333 | 932 | |
| 933 | buf = irc_format(irc, "vn", "NICK", newnick); | |
| 934 | irc_send(irc, buf); | |
| 935 | g_free(buf); | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
936 | g_free(newnick); |
| 6333 | 937 | } |
| 938 | ||
| 939 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 940 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
941 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
942 | return; |
| 6333 | 943 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
944 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE); |
| 6333 | 945 | } |
| 946 | ||
| 6718 | 947 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 948 | { | |
| 15884 | 949 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6718 | 950 | |
| 6753 | 951 | if (!args || !args[2] || !gc) |
| 6718 | 952 | return; |
| 953 | ||
| 15884 | 954 | purple_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]); |
| 6718 | 955 | } |
| 956 | ||
| 6333 | 957 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 958 | { | |
| 15884 | 959 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 960 | PurpleConversation *convo; | |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
961 | char *nick, *msg; |
| 6333 | 962 | |
| 8186 | 963 | if (!args || !args[0] || !gc) |
| 6333 | 964 | return; |
| 965 | ||
| 15884 | 966 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 967 | if (!convo) { |
| 15884 | 968 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", args[0]); |
| 6333 | 969 | return; |
| 970 | } | |
| 971 | ||
| 972 | nick = irc_mask_nick(from); | |
| 15884 | 973 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
974 | char *escaped = g_markup_escape_text(args[1], -1); |
| 8186 | 975 | 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
|
976 | (args[1] && *args[1]) ? ": " : "", |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
977 | (escaped && *escaped) ? escaped : ""); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
978 | g_free(escaped); |
| 15884 | 979 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 980 | g_free(msg); |
| 15884 | 981 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 982 | } else { |
| 15884 | 983 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nick, args[1]); |
| 6333 | 984 | } |
| 985 | g_free(nick); | |
| 986 | } | |
| 987 | ||
| 988 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 989 | { | |
| 990 | char *buf; | |
| 991 | if (!args || !args[0]) | |
| 992 | return; | |
| 993 | ||
| 994 | buf = irc_format(irc, "v:", "PONG", args[0]); | |
| 995 | irc_send(irc, buf); | |
| 996 | g_free(buf); | |
| 997 | } | |
| 998 | ||
| 999 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1000 | { | |
| 15884 | 1001 | PurpleConversation *convo; |
| 1002 | PurpleConnection *gc; | |
| 6333 | 1003 | char **parts, *msg; |
| 1004 | time_t oldstamp; | |
| 1005 | ||
| 1006 | if (!args || !args[1]) | |
| 1007 | return; | |
| 1008 | ||
| 1009 | parts = g_strsplit(args[1], " ", 2); | |
| 1010 | ||
| 1011 | if (!parts[0] || !parts[1]) { | |
| 1012 | g_strfreev(parts); | |
| 1013 | return; | |
| 1014 | } | |
| 1015 | ||
| 1016 | if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
| 1017 | msg = g_strdup(_("Error: invalid PONG from server")); | |
| 1018 | } else { | |
| 6350 | 1019 | msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
| 6333 | 1020 | } |
| 1021 | ||
| 15884 | 1022 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, parts[0], irc->account); |
| 6333 | 1023 | g_strfreev(parts); |
| 1024 | if (convo) { | |
| 15884 | 1025 | if (purple_conversation_get_type (convo) == PURPLE_CONV_TYPE_CHAT) |
| 1026 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 1027 | else |
| 15884 | 1028 | purple_conv_im_write(PURPLE_CONV_IM(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 1029 | } else { |
| 15884 | 1030 | gc = purple_account_get_connection(irc->account); |
| 6333 | 1031 | if (!gc) { |
| 1032 | g_free(msg); | |
| 1033 | return; | |
| 1034 | } | |
| 15884 | 1035 | purple_notify_info(gc, NULL, "PONG", msg); |
| 6333 | 1036 | } |
| 1037 | g_free(msg); | |
| 1038 | } | |
| 1039 | ||
| 1040 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1041 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1042 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1043 | return; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1044 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1045 | 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
|
1046 | } |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1047 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1048 | 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
|
1049 | { |
| 15884 | 1050 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1051 | PurpleConversation *convo; | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1052 | char *tmp; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1053 | char *msg; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1054 | char *nick; |
| 6333 | 1055 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1056 | if (!gc) |
| 6333 | 1057 | return; |
| 1058 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1059 | nick = irc_mask_nick(from); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1060 | tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice); |
| 6333 | 1061 | if (!tmp) { |
| 1062 | g_free(nick); | |
| 1063 | return; | |
| 1064 | } | |
| 8163 | 1065 | |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
1066 | msg = g_markup_escape_text(tmp, -1); |
| 6333 | 1067 | g_free(tmp); |
| 8163 | 1068 | |
| 1069 | tmp = irc_mirc2html(msg); | |
| 1070 | g_free(msg); | |
| 1071 | msg = tmp; | |
| 6333 | 1072 | if (notice) { |
| 1073 | tmp = g_strdup_printf("(notice) %s", msg); | |
| 1074 | g_free(msg); | |
| 1075 | msg = tmp; | |
| 1076 | } | |
| 1077 | ||
| 15884 | 1078 | if (!purple_utf8_strcasecmp(to, purple_connection_get_display_name(gc))) { |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6753
diff
changeset
|
1079 | serv_got_im(gc, nick, msg, 0, time(NULL)); |
| 6333 | 1080 | } else { |
| 15884 | 1081 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, to, irc->account); |
| 6333 | 1082 | if (convo) |
| 15884 | 1083 | serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); |
| 6333 | 1084 | else |
| 15884 | 1085 | purple_debug_error("irc", "Got a %s on %s, which does not exist\n", |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1086 | notice ? "NOTICE" : "PRIVMSG", to); |
| 6333 | 1087 | } |
| 1088 | g_free(msg); | |
| 1089 | g_free(nick); | |
| 1090 | } | |
| 1091 | ||
| 6714 | 1092 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1093 | { | |
| 15884 | 1094 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
17297
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1095 | PurpleConversation *convo; |
| 6714 | 1096 | char *msg; |
| 1097 | ||
| 1098 | if (!args || !args[1] || !args[2] || !gc) | |
| 1099 | return; | |
| 1100 | ||
|
17297
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1101 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1102 | if (convo) { |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1103 | /* This is a channel we're already in; for some reason, |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1104 | * freenode feels the need to notify us that in some |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1105 | * hypothetical other situation this might not have |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1106 | * succeeded. Suppress that. */ |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1107 | return; |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1108 | } |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1109 | |
|
16993
536c1485c139
Handle channel joins when registration is required more gracefully.
Ethan Blanton <elb@pidgin.im>
parents:
16893
diff
changeset
|
1110 | msg = g_strdup_printf(_("Cannot join %s: Registration is required."), args[1]); |
| 15884 | 1111 | purple_notify_error(gc, _("Cannot join channel"), msg, args[2]); |
| 6714 | 1112 | g_free(msg); |
| 1113 | } | |
| 1114 | ||
| 6333 | 1115 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1116 | { | |
| 15884 | 1117 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 9238 | 1118 | struct irc_buddy *ib; |
| 6333 | 1119 | char *data[2]; |
| 1120 | ||
| 1121 | if (!args || !args[0] || !gc) | |
| 1122 | return; | |
| 1123 | ||
| 1124 | data[0] = irc_mask_nick(from); | |
| 1125 | data[1] = args[0]; | |
| 1126 | /* XXX this should have an API, I shouldn't grab this directly */ | |
| 1127 | g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); | |
| 9238 | 1128 | |
| 1129 | if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) { | |
| 1130 | ib->flag = FALSE; | |
| 1131 | irc_buddy_status(data[0], ib, irc); | |
| 1132 | } | |
| 6333 | 1133 | g_free(data[0]); |
| 1134 | ||
| 1135 | return; | |
| 1136 | } | |
| 1137 | ||
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1138 | 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
|
1139 | { |
| 15884 | 1140 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1141 | |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1142 | if (!args || !args[1]) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1143 | return; |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1144 | |
| 15884 | 1145 | purple_notify_error(gc, NULL, _("Nick or channel is temporarily unavailable."), args[1]); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1146 | } |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1147 | |
| 6333 | 1148 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1149 | { | |
| 15884 | 1150 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1151 | char *nick, *msg; |
| 6333 | 1152 | |
| 1153 | if (!args || !args[0] || !gc) | |
| 1154 | return; | |
| 1155 | ||
| 1156 | nick = irc_mask_nick(from); | |
| 1157 | msg = g_strdup_printf (_("Wallops from %s"), nick); | |
| 1158 | g_free(nick); | |
| 15884 | 1159 | purple_notify_info(gc, NULL, msg, args[0]); |
| 6333 | 1160 | g_free(msg); |
| 1161 | } | |
| 1162 | ||
| 1163 | void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1164 | { | |
| 1165 | return; | |
| 1166 | } |