Tue, 04 Aug 2009 04:03:41 +0000
merge of '5cc8bb002fd80dded75fbe9e34ae56a95033d295'
and 'afcf938f83caa730df0ff19a8bb92f14f88c9d0e'
| 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> | |
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
33 | #include <stdlib.h> |
| 6333 | 34 | |
| 35 | static char *irc_mask_nick(const char *mask); | |
| 36 | static char *irc_mask_userhost(const char *mask); | |
| 15884 | 37 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]); |
| 6333 | 38 | 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
|
39 | static void irc_connected(struct irc_conn *irc, const char *nick); |
| 6333 | 40 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
41 | 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
|
42 | const char *from, const char *to, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
43 | const char *rawmsg, gboolean notice); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
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 | ||
| 15884 | 63 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]) |
| 6333 | 64 | { |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
65 | char *message, *stripped; |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
66 | |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
67 | stripped = data[1] ? irc_mirc2txt(data[1]) : NULL; |
|
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
68 | message = g_strdup_printf("quit: %s", stripped); |
|
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
69 | g_free(stripped); |
| 6333 | 70 | |
| 15884 | 71 | if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(convo), data[0])) |
| 72 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), data[0], message); | |
| 6333 | 73 | |
| 74 | g_free(message); | |
| 75 | } | |
| 76 | ||
|
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
|
77 | 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
|
78 | { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
79 | PurpleConnection *gc; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
80 | PurpleStatus *status; |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
81 | GSList *buddies; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23582
diff
changeset
|
82 | PurpleAccount *account; |
|
17169
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 | 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
|
85 | || 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
|
86 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
87 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
88 | 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
|
89 | purple_connection_set_state(gc, PURPLE_CONNECTED); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23582
diff
changeset
|
90 | account = purple_connection_get_account(gc); |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
91 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
92 | /* 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
|
93 | 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
|
94 | 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
|
95 | 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
|
96 | 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
|
97 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
98 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
99 | /* this used to be in the core, but it's not now */ |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
100 | for (buddies = purple_find_buddies(account, NULL); buddies; |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
101 | buddies = g_slist_delete_link(buddies, buddies)) |
|
24940
d4e0dc304741
updated irc to use the api rather than structs directly
Gary Kramlich <grim@reaperworld.com>
parents:
24416
diff
changeset
|
102 | { |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
103 | PurpleBuddy *b = buddies->data; |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
104 | struct irc_buddy *ib = g_new0(struct irc_buddy, 1); |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
105 | ib->name = g_strdup(purple_buddy_get_name(b)); |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
106 | g_hash_table_insert(irc->buddies, ib->name, ib); |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
107 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
108 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
109 | 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
|
110 | if (!irc->timer) |
|
25716
1b5be208d5ba
applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents:
25707
diff
changeset
|
111 | irc->timer = purple_timeout_add_seconds(45, (GSourceFunc)irc_blist_timeout, (gpointer)irc); |
|
17169
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 | |
| 6333 | 114 | void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 115 | { | |
|
23168
2928661d7518
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23118
diff
changeset
|
116 | char *clean; |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
117 | /* This, too, should be escaped somehow (smarter) */ |
|
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
118 | clean = purple_utf8_salvage(args[0]); |
|
23168
2928661d7518
applied changes from 904a276588f7de13ba13b578905c82c0493184ce
Daniel Atallah <datallah@pidgin.im>
parents:
23118
diff
changeset
|
119 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", clean); |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
120 | g_free(clean); |
| 6333 | 121 | } |
| 122 | ||
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
123 | 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
|
124 | { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
125 | gchar **features; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
126 | int i; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
127 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
128 | 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
|
129 | return; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
130 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
131 | 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
|
132 | 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
|
133 | char *val; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
134 | 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
|
135 | 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
|
136 | 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
|
137 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
138 | } |
|
21684
c7881e1b73c7
another patch from my coworker Andrew Gaul that plugged a leak, I fixed it
Ka-Hing Cheung <khc@pidgin.im>
parents:
21279
diff
changeset
|
139 | |
|
c7881e1b73c7
another patch from my coworker Andrew Gaul that plugged a leak, I fixed it
Ka-Hing Cheung <khc@pidgin.im>
parents:
21279
diff
changeset
|
140 | g_strfreev(features); |
|
15501
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 | ||
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
190 | void irc_msg_ban(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
191 | { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
192 | PurpleConversation *convo; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
193 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
194 | if (!args || !args[0] || !args[1]) |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
195 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
196 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
197 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
198 | args[1], irc->account); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
199 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
200 | if (!strcmp(name, "367")) { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
201 | char *msg = NULL; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
202 | /* Ban list entry */ |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
203 | if (!args[2]) |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
204 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
205 | if (args[3] && args[4]) { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
206 | /* This is an extended syntax, not in RFC 1459 */ |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
207 | int t1 = atoi(args[4]); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
208 | time_t t2 = time(NULL); |
| 24416 | 209 | char *time = purple_str_seconds_to_string(t2 - t1); |
|
23582
5b97b0d87d34
Use a more friendly format for the timestamp in the banlist.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23576
diff
changeset
|
210 | msg = g_strdup_printf(_("Ban on %s by %s, set %s ago"), |
| 24416 | 211 | args[2], args[3], time); |
| 212 | g_free(time); | |
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
213 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
214 | msg = g_strdup_printf(_("Ban on %s"), args[2]); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
215 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
216 | if (convo) { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
217 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
218 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
219 | time(NULL)); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
220 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
221 | purple_debug_info("irc", "%s\n", msg); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
222 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
223 | g_free(msg); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
224 | } else if (!strcmp(name, "368")) { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
225 | if (!convo) |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
226 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
227 | /* End of ban list */ |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
228 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
229 | _("End of ban list"), |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
230 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
231 | time(NULL)); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
232 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
233 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
234 | |
| 6333 | 235 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 236 | { | |
| 15884 | 237 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 238 | char *buf; |
| 239 | ||
| 240 | if (!args || !args[1] || !gc) | |
| 241 | return; | |
| 242 | ||
| 243 | buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
| 15884 | 244 | purple_notify_error(gc, _("Banned"), _("Banned"), buf); |
| 6333 | 245 | g_free(buf); |
| 246 | } | |
| 247 | ||
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
248 | 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
|
249 | { |
| 15884 | 250 | PurpleConversation *convo; |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
251 | char *buf, *nick; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
252 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
253 | if (!args || !args[0] || !args[1] || !args[2]) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
254 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
255 | |
| 15884 | 256 | 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
|
257 | if (!convo) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
258 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
259 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
260 | nick = g_markup_escape_text(args[2], -1); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
261 | buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
262 | g_free(nick); |
| 15884 | 263 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, |
| 264 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, | |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
265 | time(NULL)); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
266 | g_free(buf); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
267 | } |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
268 | |
| 6333 | 269 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 270 | { | |
| 15884 | 271 | PurpleConversation *convo; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
272 | char *buf, *escaped; |
| 6333 | 273 | |
| 274 | if (!args || !args[1] || !args[2]) | |
| 275 | return; | |
| 276 | ||
| 15884 | 277 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 278 | if (!convo) /* XXX punt on channels we are not in for now */ |
| 279 | return; | |
| 280 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
281 | 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
|
282 | buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); |
| 15884 | 283 | 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
|
284 | g_free(escaped); |
| 6333 | 285 | g_free(buf); |
| 286 | ||
| 287 | return; | |
| 288 | } | |
| 289 | ||
| 290 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 291 | { | |
| 292 | if (!irc->whois.nick) { | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
293 | 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
|
294 | , args[1]); |
| 6333 | 295 | return; |
| 296 | } | |
| 297 | ||
| 15884 | 298 | 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
|
299 | 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
|
300 | , args[1], irc->whois.nick); |
| 6333 | 301 | return; |
| 302 | } | |
| 303 | ||
| 304 | if (!strcmp(name, "301")) { | |
| 305 | irc->whois.away = g_strdup(args[2]); | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
306 | } else if (!strcmp(name, "311") || !strcmp(name, "314")) { |
| 6333 | 307 | irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]); |
| 308 | irc->whois.name = g_strdup(args[5]); | |
| 309 | } else if (!strcmp(name, "312")) { | |
| 310 | irc->whois.server = g_strdup(args[2]); | |
| 311 | irc->whois.serverinfo = g_strdup(args[3]); | |
| 312 | } else if (!strcmp(name, "313")) { | |
| 313 | irc->whois.ircop = 1; | |
| 314 | } else if (!strcmp(name, "317")) { | |
| 315 | irc->whois.idle = atoi(args[2]); | |
| 316 | if (args[3]) | |
| 317 | irc->whois.signon = (time_t)atoi(args[3]); | |
| 318 | } else if (!strcmp(name, "319")) { | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
319 | if (irc->whois.channels == NULL) { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
320 | irc->whois.channels = g_string_new(args[2]); |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
321 | } else { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
322 | irc->whois.channels = g_string_append(irc->whois.channels, args[2]); |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
323 | } |
| 6333 | 324 | } else if (!strcmp(name, "320")) { |
| 325 | irc->whois.identified = 1; | |
| 326 | } | |
| 327 | } | |
| 328 | ||
| 329 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 330 | { | |
| 15884 | 331 | PurpleConnection *gc; |
|
15215
3b4c0490b8b0
[gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
332 | char *tmp, *tmp2; |
| 15884 | 333 | PurpleNotifyUserInfo *user_info; |
| 6333 | 334 | |
| 335 | if (!irc->whois.nick) { | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
336 | 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
|
337 | , args[1]); |
| 6333 | 338 | return; |
| 339 | } | |
| 15884 | 340 | 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
|
341 | 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
|
342 | , args[1], irc->whois.nick); |
| 6333 | 343 | return; |
| 344 | } | |
| 345 | ||
| 15884 | 346 | user_info = purple_notify_user_info_new(); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
347 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
348 | tmp2 = g_markup_escape_text(args[1], -1); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
349 | tmp = g_strdup_printf("%s%s%s", tmp2, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
350 | (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
351 | (irc->whois.identified ? _(" <i>(identified)</i>") : "")); |
| 15884 | 352 | purple_notify_user_info_add_pair(user_info, _("Nick"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
353 | g_free(tmp2); |
| 10634 | 354 | g_free(tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
355 | |
| 6333 | 356 | if (irc->whois.away) { |
| 10634 | 357 | tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); |
| 6333 | 358 | g_free(irc->whois.away); |
| 15884 | 359 | purple_notify_user_info_add_pair(user_info, _("Away"), tmp); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
360 | g_free(tmp); |
| 6333 | 361 | } |
| 362 | if (irc->whois.userhost) { | |
| 10634 | 363 | 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
|
364 | g_free(irc->whois.name); |
| 15884 | 365 | purple_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); |
| 366 | purple_notify_user_info_add_pair(user_info, _("Real name"), tmp); | |
| 6333 | 367 | g_free(irc->whois.userhost); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
368 | g_free(tmp); |
| 6333 | 369 | } |
| 370 | if (irc->whois.server) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
371 | tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); |
| 15884 | 372 | purple_notify_user_info_add_pair(user_info, _("Server"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
373 | g_free(tmp); |
| 6333 | 374 | g_free(irc->whois.server); |
| 375 | g_free(irc->whois.serverinfo); | |
| 376 | } | |
| 377 | if (irc->whois.channels) { | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
378 | purple_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels->str); |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
379 | g_string_free(irc->whois.channels, TRUE); |
| 6333 | 380 | } |
| 381 | if (irc->whois.idle) { | |
| 15884 | 382 | gchar *timex = purple_str_seconds_to_string(irc->whois.idle); |
| 383 | 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
|
384 | g_free(timex); |
| 15884 | 385 | purple_notify_user_info_add_pair(user_info, |
| 386 | _("Online since"), purple_date_format_full(localtime(&irc->whois.signon))); | |
| 6333 | 387 | } |
| 388 | if (!strcmp(irc->whois.nick, "Paco-Paco")) { | |
| 15884 | 389 | purple_notify_user_info_add_pair(user_info, |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
390 | _("<b>Defining adjective:</b>"), _("Glorious")); |
| 6333 | 391 | } |
| 392 | ||
| 15884 | 393 | gc = purple_account_get_connection(irc->account); |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
394 | |
| 15884 | 395 | purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); |
| 396 | purple_notify_user_info_destroy(user_info); | |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
397 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
398 | g_free(irc->whois.nick); |
| 6333 | 399 | memset(&irc->whois, 0, sizeof(irc->whois)); |
| 400 | } | |
| 401 | ||
| 8114 | 402 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 403 | { | |
| 404 | if (!irc->roomlist) | |
| 405 | return; | |
| 406 | ||
| 407 | if (!strcmp(name, "321")) { | |
| 15884 | 408 | purple_roomlist_set_in_progress(irc->roomlist, TRUE); |
| 8114 | 409 | return; |
| 410 | } | |
| 411 | ||
| 412 | if (!strcmp(name, "323")) { | |
| 15884 | 413 | purple_roomlist_set_in_progress(irc->roomlist, FALSE); |
| 414 | purple_roomlist_unref(irc->roomlist); | |
| 8114 | 415 | irc->roomlist = NULL; |
|
13667
9ebf0007d912
[gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents:
13647
diff
changeset
|
416 | return; |
| 8114 | 417 | } |
| 418 | ||
| 419 | if (!strcmp(name, "322")) { | |
| 15884 | 420 | PurpleRoomlistRoom *room; |
|
17409
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
421 | char *topic; |
| 8114 | 422 | |
| 423 | if (!args[0] || !args[1] || !args[2] || !args[3]) | |
| 424 | return; | |
| 425 | ||
|
22994
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
426 | if (!purple_roomlist_get_in_progress(irc->roomlist)) { |
|
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
427 | purple_debug_warning("irc", "Buggy server didn't send RPL_LISTSTART.\n"); |
|
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
428 | purple_roomlist_set_in_progress(irc->roomlist, TRUE); |
|
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
429 | } |
|
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
430 | |
| 15884 | 431 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); |
| 432 | purple_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
| 433 | 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
|
434 | 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
|
435 | 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
|
436 | g_free(topic); |
| 15884 | 437 | purple_roomlist_room_add(irc->roomlist, room); |
| 8114 | 438 | } |
| 439 | } | |
| 440 | ||
| 6333 | 441 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 442 | { | |
| 9762 | 443 | char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
| 15884 | 444 | PurpleConversation *convo; |
| 6333 | 445 | |
| 446 | if (!strcmp(name, "topic")) { | |
| 447 | chan = args[0]; | |
| 8529 | 448 | topic = irc_mirc2txt (args[1]); |
| 6333 | 449 | } else { |
| 450 | chan = args[1]; | |
| 8529 | 451 | topic = irc_mirc2txt (args[2]); |
| 6333 | 452 | } |
| 453 | ||
| 15884 | 454 | 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
|
455 | if (!convo) { |
| 15884 | 456 | 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
|
457 | g_free(topic); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
458 | return; |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
459 | } |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
460 | |
| 6333 | 461 | /* If this is an interactive update, print it out */ |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
462 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 463 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 464 | g_free(tmp); |
| 6333 | 465 | if (!strcmp(name, "topic")) { |
| 15884 | 466 | 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
|
467 | if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0)) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
468 | { |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
469 | char *nick_esc; |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
470 | nick = irc_mask_nick(from); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
471 | nick_esc = g_markup_escape_text(nick, -1); |
| 15884 | 472 | 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
|
473 | if (*tmp2) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
474 | 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
|
475 | else |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
476 | msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
477 | g_free(nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
478 | g_free(nick); |
| 15884 | 479 | 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
|
480 | g_free(msg); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
481 | } |
| 6333 | 482 | } else { |
|
13395
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
483 | char *chan_esc = g_markup_escape_text(chan, -1); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
484 | 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
|
485 | g_free(chan_esc); |
| 15884 | 486 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic); |
| 487 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
| 6333 | 488 | g_free(msg); |
| 489 | } | |
| 9762 | 490 | g_free(tmp2); |
| 8529 | 491 | g_free(topic); |
| 6333 | 492 | } |
| 493 | ||
| 494 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 495 | { | |
| 15884 | 496 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 497 | char *buf; |
| 498 | ||
| 499 | if (!args || !args[1] || !gc) | |
| 500 | return; | |
| 501 | ||
| 502 | buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
| 15884 | 503 | purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand.")); |
| 6333 | 504 | g_free(buf); |
| 505 | } | |
| 506 | ||
| 507 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 508 | { | |
| 509 | char *names, *cur, *end, *tmp, *msg; | |
| 15884 | 510 | PurpleConversation *convo; |
| 6333 | 511 | |
| 512 | if (!strcmp(name, "366")) { | |
| 15884 | 513 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 514 | if (!convo) { |
| 15884 | 515 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); |
| 6333 | 516 | g_string_free(irc->names, TRUE); |
| 517 | irc->names = NULL; | |
| 518 | return; | |
| 519 | } | |
| 520 | ||
| 521 | names = cur = g_string_free(irc->names, FALSE); | |
| 522 | irc->names = NULL; | |
| 15884 | 523 | if (purple_conversation_get_data(convo, IRC_NAMES_FLAG)) { |
|
11026
1f13c483db00
[gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents:
10816
diff
changeset
|
524 | msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
| 15884 | 525 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) |
| 526 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 527 | else |
| 15884 | 528 | purple_conv_im_write(PURPLE_CONV_IM(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 529 | g_free(msg); |
| 530 | } else { | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
531 | GList *users = NULL; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
532 | GList *flags = NULL; |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
533 | |
| 6333 | 534 | while (*cur) { |
| 15884 | 535 | PurpleConvChatBuddyFlags f = PURPLE_CBFLAGS_NONE; |
| 6333 | 536 | end = strchr(cur, ' '); |
| 537 | if (!end) | |
| 538 | end = cur + strlen(cur); | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
539 | if (*cur == '@') { |
| 15884 | 540 | f = PURPLE_CBFLAGS_OP; |
| 6333 | 541 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
542 | } else if (*cur == '%') { |
| 15884 | 543 | f = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
544 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
545 | } else if(*cur == '+') { |
| 15884 | 546 | f = PURPLE_CBFLAGS_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
547 | cur++; |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
548 | } 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
|
549 | && strchr(irc->mode_chars, *cur)) { |
|
22471
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
550 | if (*cur == '~') |
|
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
551 | f = PURPLE_CBFLAGS_FOUNDER; |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
552 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
553 | } |
| 6333 | 554 | tmp = g_strndup(cur, end - cur); |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
555 | users = g_list_prepend(users, tmp); |
|
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
556 | flags = g_list_prepend(flags, GINT_TO_POINTER(f)); |
| 6333 | 557 | cur = end; |
| 558 | if (*cur) | |
| 559 | cur++; | |
| 560 | } | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
561 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
562 | if (users != NULL) { |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
563 | GList *l; |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
564 | |
| 15884 | 565 | 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
|
566 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
567 | for (l = users; l != NULL; l = l->next) |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
568 | g_free(l->data); |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
569 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
570 | g_list_free(users); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
571 | g_list_free(flags); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
572 | } |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
573 | |
| 15884 | 574 | 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
|
575 | GINT_TO_POINTER(TRUE)); |
| 6333 | 576 | } |
| 577 | g_free(names); | |
| 578 | } else { | |
| 579 | if (!irc->names) | |
| 580 | irc->names = g_string_new(""); | |
| 581 | ||
| 15313 | 582 | if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ') |
| 583 | irc->names = g_string_append_c(irc->names, ' '); | |
| 6333 | 584 | irc->names = g_string_append(irc->names, args[3]); |
| 585 | } | |
| 586 | } | |
| 587 | ||
| 588 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 589 | { | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
590 | char *escaped; |
| 6333 | 591 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
592 | 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
|
593 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
594 | |
| 6333 | 595 | if (!irc->motd) |
| 596 | irc->motd = g_string_new(""); | |
| 597 | ||
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
598 | 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
|
599 | 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
|
600 | 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
|
601 | 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
|
602 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
603 | } 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
|
604 | /* 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
|
605 | * 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
|
606 | 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
|
607 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
608 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
609 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
610 | if (!irc->motd) { |
| 15884 | 611 | 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
|
612 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
613 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
614 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
615 | 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
|
616 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
617 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
618 | escaped = g_markup_escape_text(args[1], -1); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
619 | g_string_append_printf(irc->motd, "%s<br>", escaped); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
620 | g_free(escaped); |
| 6333 | 621 | } |
| 622 | ||
| 10564 | 623 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 624 | { | |
| 15884 | 625 | PurpleConnection *gc; |
| 10564 | 626 | |
| 15884 | 627 | gc = purple_account_get_connection(irc->account); |
| 10564 | 628 | if (gc == NULL || args == NULL || args[2] == NULL) |
| 629 | return; | |
| 630 | ||
| 15884 | 631 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"), |
| 10564 | 632 | _("The IRC server's local time is:"), |
| 633 | args[2], NULL, NULL); | |
| 634 | } | |
| 635 | ||
| 7877 | 636 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 637 | { | |
| 15884 | 638 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 7877 | 639 | |
| 640 | if (gc == NULL || args == NULL || args[1] == NULL) | |
| 641 | return; | |
| 642 | ||
| 15884 | 643 | purple_notify_error(gc, NULL, _("No such channel"), args[1]); |
| 7877 | 644 | } |
| 645 | ||
| 6333 | 646 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 647 | { | |
| 15884 | 648 | PurpleConnection *gc; |
| 649 | PurpleConversation *convo; | |
| 6333 | 650 | |
| 15884 | 651 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 652 | if (convo) { |
| 15884 | 653 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) /* does this happen? */ |
| 654 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], _("no such channel"), | |
| 655 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 656 | else |
| 15884 | 657 | purple_conv_im_write(PURPLE_CONV_IM(convo), args[1], _("User is not logged in"), |
| 658 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 659 | } else { |
| 15884 | 660 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 661 | return; |
| 15884 | 662 | purple_notify_error(gc, NULL, _("No such nick or channel"), args[1]); |
| 6333 | 663 | } |
| 664 | ||
| 15884 | 665 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 666 | g_free(irc->whois.nick); |
| 667 | irc->whois.nick = NULL; | |
| 668 | } | |
| 669 | } | |
| 670 | ||
| 671 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 672 | { | |
| 15884 | 673 | PurpleConnection *gc; |
| 674 | PurpleConversation *convo; | |
| 6333 | 675 | |
| 15884 | 676 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 677 | if (convo) { |
| 15884 | 678 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 679 | } else { |
| 15884 | 680 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 681 | return; |
| 15884 | 682 | purple_notify_error(gc, NULL, _("Could not send"), args[2]); |
| 6333 | 683 | } |
| 684 | } | |
| 685 | ||
| 686 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 687 | { | |
| 15884 | 688 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 689 | |
| 15884 | 690 | purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); |
| 6333 | 691 | if (convo) { |
| 692 | /*g_slist_remove(irc->gc->buddy_chats, convo); | |
| 15884 | 693 | purple_conversation_set_account(convo, NULL);*/ |
| 694 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 695 | } |
| 696 | } | |
| 697 | ||
| 698 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 699 | { | |
| 15884 | 700 | PurpleConversation *convo; |
| 6333 | 701 | |
| 702 | if (!args || !args[1] || !args[2]) | |
| 703 | return; | |
| 704 | ||
| 15884 | 705 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 706 | if (!convo) |
| 707 | return; | |
| 708 | ||
| 15884 | 709 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 710 | } |
| 711 | ||
| 712 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 713 | { | |
| 15884 | 714 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
715 | GHashTable *components; |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
716 | gchar *nick; |
| 6333 | 717 | |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
718 | if (!args || !args[1] || !gc) |
| 6333 | 719 | return; |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
720 | |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
721 | components = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
722 | nick = irc_mask_nick(from); |
| 6333 | 723 | |
|
22870
25b482330fec
Use g_strdup to match the subsequent g_free.
Daniel Atallah <datallah@pidgin.im>
parents:
22798
diff
changeset
|
724 | g_hash_table_insert(components, g_strdup("channel"), g_strdup(args[1])); |
| 6333 | 725 | |
| 726 | serv_got_chat_invite(gc, args[1], nick, NULL, components); | |
| 727 | g_free(nick); | |
| 728 | } | |
| 729 | ||
| 730 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 731 | { | |
| 15884 | 732 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 733 | char *buf; |
| 734 | ||
| 735 | if (!args || !args[1] || !gc) | |
| 736 | return; | |
| 737 | ||
| 738 | buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
| 15884 | 739 | purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf); |
| 6333 | 740 | g_free(buf); |
| 741 | } | |
| 742 | ||
| 743 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 744 | { | |
| 745 | char **nicks; | |
| 746 | struct irc_buddy *ib; | |
| 747 | int i; | |
| 748 | ||
| 749 | if (!args || !args[1]) | |
| 750 | return; | |
| 751 | ||
| 752 | nicks = g_strsplit(args[1], " ", -1); | |
| 753 | ||
| 754 | for (i = 0; nicks[i]; i++) { | |
| 755 | if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
| 756 | continue; | |
| 757 | } | |
| 758 | ib->flag = TRUE; | |
| 759 | } | |
| 760 | ||
| 6350 | 761 | g_strfreev(nicks); |
| 762 | ||
| 6333 | 763 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
|
21736
8de85200908d
applied changes from 5dc4cf40c038206bcf06fe7407e1e308b0264e32
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21684
diff
changeset
|
764 | irc->ison_outstanding = FALSE; |
| 6333 | 765 | } |
| 766 | ||
| 767 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
| 768 | { | |
| 15884 | 769 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 770 | PurpleBuddy *buddy = purple_find_buddy(irc->account, name); | |
| 6333 | 771 | |
| 772 | if (!gc || !buddy) | |
| 773 | return; | |
| 774 | ||
| 775 | if (ib->online && !ib->flag) { | |
| 15884 | 776 | purple_prpl_got_user_status(irc->account, name, "offline", NULL); |
| 6333 | 777 | ib->online = FALSE; |
| 10242 | 778 | } else if (!ib->online && ib->flag) { |
| 15884 | 779 | purple_prpl_got_user_status(irc->account, name, "available", NULL); |
| 6333 | 780 | ib->online = TRUE; |
| 781 | } | |
| 782 | } | |
| 783 | ||
| 784 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 785 | { | |
| 15884 | 786 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 787 | PurpleConversation *convo; | |
| 6333 | 788 | char *nick = irc_mask_nick(from), *userhost; |
| 9238 | 789 | struct irc_buddy *ib; |
| 6333 | 790 | static int id = 1; |
| 791 | ||
| 792 | if (!gc) { | |
| 793 | g_free(nick); | |
| 794 | return; | |
| 795 | } | |
| 796 | ||
| 15884 | 797 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 6333 | 798 | /* We are joining a channel for the first time */ |
| 799 | serv_got_joined_chat(gc, id++, args[0]); | |
| 800 | g_free(nick); | |
| 15884 | 801 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
| 13938 | 802 | args[0], |
| 803 | irc->account); | |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
804 | |
| 13938 | 805 | if (convo == NULL) { |
| 15884 | 806 | purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]); |
| 13938 | 807 | return; |
| 808 | } | |
| 15884 | 809 | 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
|
810 | GINT_TO_POINTER(FALSE)); |
|
20194
fee478bb059b
applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents:
19859
diff
changeset
|
811 | /* Until purple_conversation_present does something that |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
812 | * one would expect in Pidgin, this call produces buggy |
|
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
813 | * behavior both for the /join and auto-join cases. */ |
|
20194
fee478bb059b
applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents:
19859
diff
changeset
|
814 | /* purple_conversation_present(convo); */ |
| 6333 | 815 | return; |
| 816 | } | |
| 817 | ||
| 15884 | 818 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 819 | if (convo == NULL) { |
| 15884 | 820 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); |
| 6333 | 821 | g_free(nick); |
| 822 | return; | |
| 823 | } | |
| 824 | ||
| 825 | userhost = irc_mask_userhost(from); | |
| 15884 | 826 | purple_conv_chat_add_user(PURPLE_CONV_CHAT(convo), nick, userhost, PURPLE_CBFLAGS_NONE, TRUE); |
| 9238 | 827 | |
| 828 | if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { | |
| 829 | ib->flag = TRUE; | |
| 830 | irc_buddy_status(nick, ib, irc); | |
| 831 | } | |
| 832 | ||
| 6333 | 833 | g_free(userhost); |
| 834 | g_free(nick); | |
| 835 | } | |
| 836 | ||
| 837 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 838 | { | |
| 15884 | 839 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 840 | 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
|
841 | char *nick = irc_mask_nick(from), *buf; |
| 6333 | 842 | |
| 843 | if (!gc) { | |
| 844 | g_free(nick); | |
| 845 | return; | |
| 846 | } | |
| 847 | ||
| 848 | if (!convo) { | |
| 15884 | 849 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Recieved a KICK for unknown channel %s\n", args[0]); |
| 6333 | 850 | g_free(nick); |
| 851 | return; | |
| 852 | } | |
| 853 | ||
| 15884 | 854 | 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
|
855 | buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
| 15884 | 856 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 857 | g_free(buf); |
| 15884 | 858 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 859 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
860 | buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
| 15884 | 861 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), args[1], buf); |
| 6333 | 862 | g_free(buf); |
| 863 | } | |
| 864 | ||
| 865 | g_free(nick); | |
| 866 | return; | |
| 867 | } | |
| 868 | ||
| 869 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 870 | { | |
| 15884 | 871 | PurpleConversation *convo; |
| 6333 | 872 | char *nick = irc_mask_nick(from), *buf; |
| 873 | ||
| 874 | if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
875 | char *escaped; |
| 15884 | 876 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 877 | if (!convo) { |
| 15884 | 878 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); |
| 6333 | 879 | g_free(nick); |
| 880 | return; | |
| 881 | } | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
882 | 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
|
883 | buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); |
| 15884 | 884 | 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
|
885 | g_free(escaped); |
| 6333 | 886 | g_free(buf); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
887 | if(args[2]) { |
| 15884 | 888 | PurpleConvChatBuddyFlags newflag, flags; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
889 | char *mcur, *cur, *end, *user; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
890 | gboolean add = FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
891 | mcur = args[1]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
892 | cur = args[2]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
893 | while (*cur && *mcur) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
894 | if ((*mcur == '+') || (*mcur == '-')) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
895 | add = (*mcur == '+') ? TRUE : FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
896 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
897 | continue; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
898 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
899 | end = strchr(cur, ' '); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
900 | if (!end) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
901 | end = cur + strlen(cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
902 | user = g_strndup(cur, end - cur); |
| 15884 | 903 | flags = purple_conv_chat_user_get_flags(PURPLE_CONV_CHAT(convo), user); |
| 904 | newflag = PURPLE_CBFLAGS_NONE; | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
905 | if (*mcur == 'o') |
| 15884 | 906 | newflag = PURPLE_CBFLAGS_OP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
907 | else if (*mcur =='h') |
| 15884 | 908 | newflag = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
909 | else if (*mcur == 'v') |
| 15884 | 910 | newflag = PURPLE_CBFLAGS_VOICE; |
|
22471
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
911 | else if(irc->mode_chars |
|
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
912 | && strchr(irc->mode_chars, '~') && (*mcur == 'q')) |
|
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
913 | newflag = PURPLE_CBFLAGS_FOUNDER; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
914 | if (newflag) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
915 | if (add) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
916 | flags |= newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
917 | else |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
918 | flags &= ~newflag; |
| 15884 | 919 | 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
|
920 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
921 | g_free(user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
922 | cur = end; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
923 | if (*cur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
924 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
925 | if (*mcur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
926 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
927 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
928 | } |
| 6333 | 929 | } else { /* User */ |
| 930 | } | |
| 931 | g_free(nick); | |
| 932 | } | |
| 933 | ||
| 934 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 935 | { | |
| 15884 | 936 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 937 | PurpleConversation *conv; | |
| 6333 | 938 | GSList *chats; |
| 939 | char *nick = irc_mask_nick(from); | |
| 940 | ||
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
941 | irc->nickused = FALSE; |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
942 | |
| 6333 | 943 | if (!gc) { |
| 944 | g_free(nick); | |
| 945 | return; | |
| 946 | } | |
| 947 | chats = gc->buddy_chats; | |
| 948 | ||
| 15884 | 949 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 950 | purple_connection_set_display_name(gc, args[0]); | |
| 6333 | 951 | } |
| 952 | ||
| 953 | while (chats) { | |
| 15884 | 954 | PurpleConvChat *chat = PURPLE_CONV_CHAT(chats->data); |
| 9593 | 955 | /* This is ugly ... */ |
| 15884 | 956 | if (purple_conv_chat_find_user(chat, nick)) |
| 957 | purple_conv_chat_rename_user(chat, nick, args[0]); | |
| 6333 | 958 | chats = chats->next; |
| 959 | } | |
| 10617 | 960 | |
| 15884 | 961 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, nick, |
| 10617 | 962 | irc->account); |
| 963 | if (conv != NULL) | |
| 15884 | 964 | purple_conversation_set_name(conv, args[0]); |
| 10617 | 965 | |
| 6333 | 966 | g_free(nick); |
| 967 | } | |
| 968 | ||
| 10633 | 969 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 970 | { | |
| 15884 | 971 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 972 | if (purple_connection_get_state(gc) == PURPLE_CONNECTED) { | |
| 973 | purple_notify_error(gc, _("Invalid nickname"), | |
| 13057 | 974 | _("Invalid nickname"), |
| 975 | _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); | |
| 976 | ||
| 977 | } else { | |
| 21279 | 978 | purple_connection_error_reason (gc, |
| 979 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, | |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
980 | _("Your selected account name was rejected by the server. It probably contains invalid characters.")); |
| 13057 | 981 | } |
| 10633 | 982 | } |
| 983 | ||
| 6333 | 984 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 985 | { | |
| 986 | char *newnick, *buf, *end; | |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
987 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 988 | |
| 989 | if (!args || !args[1]) | |
| 990 | return; | |
| 991 | ||
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
992 | if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTED) { |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
993 | /* We only want to do the following dance if the connection |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
994 | has not been successfully completed. If it has, just |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
995 | notify the user that their /nick command didn't go. */ |
|
26825
6d3bb5625183
Notify the user if an IRC /nick command fails, rather than trying fallbacks.
Ethan Blanton <elb@pidgin.im>
parents:
26752
diff
changeset
|
996 | buf = g_strdup_printf(_("The nickname \"%s\" is already being used."), |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
997 | irc->reqnick); |
|
26825
6d3bb5625183
Notify the user if an IRC /nick command fails, rather than trying fallbacks.
Ethan Blanton <elb@pidgin.im>
parents:
26752
diff
changeset
|
998 | purple_notify_error(gc, _("Nickname in use"), |
|
6d3bb5625183
Notify the user if an IRC /nick command fails, rather than trying fallbacks.
Ethan Blanton <elb@pidgin.im>
parents:
26752
diff
changeset
|
999 | _("Nickname in use"), buf); |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1000 | g_free(buf); |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1001 | g_free(irc->reqnick); |
|
25706
cbaf3afc17c6
applied changes from 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25705
diff
changeset
|
1002 | irc->reqnick = NULL; |
|
25707
e1b69b86aa3c
Hand-pluck of 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25706
diff
changeset
|
1003 | return; |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1004 | } |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1005 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1006 | if (strlen(args[1]) < strlen(irc->reqnick) || irc->nickused) |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1007 | newnick = g_strdup(args[1]); |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1008 | else |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1009 | newnick = g_strdup_printf("%s0", args[1]); |
| 6333 | 1010 | end = newnick + strlen(newnick) - 1; |
|
11386
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1011 | /* try fallbacks */ |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1012 | if((*end < '9') && (*end >= '1')) { |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1013 | *end = *end + 1; |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1014 | } else *end = '1'; |
| 6333 | 1015 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1016 | g_free(irc->reqnick); |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1017 | irc->reqnick = newnick; |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1018 | irc->nickused = TRUE; |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1019 | |
|
23576
e2978ee98aa7
set the purple connection name to the one we are about to try
Ka-Hing Cheung <khc@pidgin.im>
parents:
23475
diff
changeset
|
1020 | purple_connection_set_display_name( |
|
e2978ee98aa7
set the purple connection name to the one we are about to try
Ka-Hing Cheung <khc@pidgin.im>
parents:
23475
diff
changeset
|
1021 | purple_account_get_connection(irc->account), newnick); |
|
e2978ee98aa7
set the purple connection name to the one we are about to try
Ka-Hing Cheung <khc@pidgin.im>
parents:
23475
diff
changeset
|
1022 | |
| 6333 | 1023 | buf = irc_format(irc, "vn", "NICK", newnick); |
| 1024 | irc_send(irc, buf); | |
| 1025 | g_free(buf); | |
| 1026 | } | |
| 1027 | ||
| 1028 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1029 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1030 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1031 | return; |
| 6333 | 1032 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1033 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE); |
| 6333 | 1034 | } |
| 1035 | ||
| 6718 | 1036 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1037 | { | |
| 15884 | 1038 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6718 | 1039 | |
| 6753 | 1040 | if (!args || !args[2] || !gc) |
| 6718 | 1041 | return; |
| 1042 | ||
| 15884 | 1043 | purple_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]); |
| 6718 | 1044 | } |
| 1045 | ||
| 6333 | 1046 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1047 | { | |
| 15884 | 1048 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1049 | PurpleConversation *convo; | |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1050 | char *nick, *msg, *channel; |
| 6333 | 1051 | |
| 8186 | 1052 | if (!args || !args[0] || !gc) |
| 6333 | 1053 | return; |
| 1054 | ||
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1055 | /* Undernet likes to :-quote the channel name, for no good reason |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
1056 | * that I can see. This catches that. */ |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1057 | channel = (args[0][0] == ':') ? &args[0][1] : args[0]; |
|
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1058 | |
|
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1059 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, channel, irc->account); |
| 6333 | 1060 | if (!convo) { |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1061 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel); |
| 6333 | 1062 | return; |
| 1063 | } | |
| 1064 | ||
| 1065 | nick = irc_mask_nick(from); | |
| 15884 | 1066 | 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
|
1067 | char *escaped = g_markup_escape_text(args[1], -1); |
| 8186 | 1068 | msg = g_strdup_printf(_("You have parted the channel%s%s"), |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
1069 | (args[1] && *args[1]) ? ": " : "", |
|
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
1070 | (escaped && *escaped) ? escaped : ""); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
1071 | g_free(escaped); |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1072 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), channel, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 1073 | g_free(msg); |
| 15884 | 1074 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 1075 | } else { |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1076 | msg = args[1] ? irc_mirc2txt(args[1]) : NULL; |
|
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1077 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), nick, msg); |
|
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1078 | g_free(msg); |
| 6333 | 1079 | } |
| 1080 | g_free(nick); | |
| 1081 | } | |
| 1082 | ||
| 1083 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1084 | { | |
| 1085 | char *buf; | |
| 1086 | if (!args || !args[0]) | |
| 1087 | return; | |
| 1088 | ||
| 1089 | buf = irc_format(irc, "v:", "PONG", args[0]); | |
| 1090 | irc_send(irc, buf); | |
| 1091 | g_free(buf); | |
| 1092 | } | |
| 1093 | ||
| 1094 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1095 | { | |
| 15884 | 1096 | PurpleConversation *convo; |
| 1097 | PurpleConnection *gc; | |
| 6333 | 1098 | char **parts, *msg; |
| 1099 | time_t oldstamp; | |
| 1100 | ||
| 1101 | if (!args || !args[1]) | |
| 1102 | return; | |
| 1103 | ||
| 1104 | parts = g_strsplit(args[1], " ", 2); | |
| 1105 | ||
| 1106 | if (!parts[0] || !parts[1]) { | |
| 1107 | g_strfreev(parts); | |
| 1108 | return; | |
| 1109 | } | |
| 1110 | ||
| 1111 | if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
| 1112 | msg = g_strdup(_("Error: invalid PONG from server")); | |
| 1113 | } else { | |
| 6350 | 1114 | msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
| 6333 | 1115 | } |
| 1116 | ||
| 15884 | 1117 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, parts[0], irc->account); |
| 6333 | 1118 | g_strfreev(parts); |
| 1119 | if (convo) { | |
| 15884 | 1120 | if (purple_conversation_get_type (convo) == PURPLE_CONV_TYPE_CHAT) |
| 1121 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 1122 | else |
| 15884 | 1123 | purple_conv_im_write(PURPLE_CONV_IM(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 1124 | } else { |
| 15884 | 1125 | gc = purple_account_get_connection(irc->account); |
| 6333 | 1126 | if (!gc) { |
| 1127 | g_free(msg); | |
| 1128 | return; | |
| 1129 | } | |
| 15884 | 1130 | purple_notify_info(gc, NULL, "PONG", msg); |
| 6333 | 1131 | } |
| 1132 | g_free(msg); | |
| 1133 | } | |
| 1134 | ||
| 1135 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1136 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1137 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1138 | return; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1139 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1140 | 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
|
1141 | } |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1142 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1143 | 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
|
1144 | { |
| 15884 | 1145 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1146 | PurpleConversation *convo; | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1147 | char *tmp; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1148 | char *msg; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1149 | char *nick; |
| 6333 | 1150 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1151 | if (!gc) |
| 6333 | 1152 | return; |
| 1153 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1154 | nick = irc_mask_nick(from); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1155 | tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice); |
| 6333 | 1156 | if (!tmp) { |
| 1157 | g_free(nick); | |
| 1158 | return; | |
| 1159 | } | |
| 8163 | 1160 | |
|
20217
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
20194
diff
changeset
|
1161 | msg = irc_escape_privmsg(tmp, -1); |
| 6333 | 1162 | g_free(tmp); |
| 8163 | 1163 | |
| 1164 | tmp = irc_mirc2html(msg); | |
| 1165 | g_free(msg); | |
| 1166 | msg = tmp; | |
| 6333 | 1167 | if (notice) { |
| 1168 | tmp = g_strdup_printf("(notice) %s", msg); | |
| 1169 | g_free(msg); | |
| 1170 | msg = tmp; | |
| 1171 | } | |
| 1172 | ||
| 15884 | 1173 | 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
|
1174 | serv_got_im(gc, nick, msg, 0, time(NULL)); |
| 6333 | 1175 | } else { |
|
27044
bc111170ee11
This allows incoming channel messages with op/voice/etc. mode characters.
Marcos García Ochoa <magao@bigfoot.com>
parents:
26855
diff
changeset
|
1176 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, irc_nick_skip_mode(irc, to), irc->account); |
| 6333 | 1177 | if (convo) |
| 15884 | 1178 | serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); |
| 6333 | 1179 | else |
| 15884 | 1180 | purple_debug_error("irc", "Got a %s on %s, which does not exist\n", |
|
24763
67d9d4c975c0
Replace spaces wth tabs in indentation and tabs with spaces in line continuations.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
24416
diff
changeset
|
1181 | notice ? "NOTICE" : "PRIVMSG", to); |
| 6333 | 1182 | } |
| 1183 | g_free(msg); | |
| 1184 | g_free(nick); | |
| 1185 | } | |
| 1186 | ||
| 6714 | 1187 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1188 | { | |
| 15884 | 1189 | 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
|
1190 | PurpleConversation *convo; |
| 6714 | 1191 | char *msg; |
| 1192 | ||
| 1193 | if (!args || !args[1] || !args[2] || !gc) | |
| 1194 | return; | |
| 1195 | ||
|
17297
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1196 | 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
|
1197 | if (convo) { |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1198 | /* 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
|
1199 | * 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
|
1200 | * 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
|
1201 | * 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
|
1202 | return; |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1203 | } |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1204 | |
|
16993
536c1485c139
Handle channel joins when registration is required more gracefully.
Ethan Blanton <elb@pidgin.im>
parents:
16893
diff
changeset
|
1205 | msg = g_strdup_printf(_("Cannot join %s: Registration is required."), args[1]); |
| 15884 | 1206 | purple_notify_error(gc, _("Cannot join channel"), msg, args[2]); |
| 6714 | 1207 | g_free(msg); |
| 1208 | } | |
| 1209 | ||
| 6333 | 1210 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1211 | { | |
| 15884 | 1212 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 9238 | 1213 | struct irc_buddy *ib; |
| 6333 | 1214 | char *data[2]; |
| 1215 | ||
| 1216 | if (!args || !args[0] || !gc) | |
| 1217 | return; | |
| 1218 | ||
| 1219 | data[0] = irc_mask_nick(from); | |
| 1220 | data[1] = args[0]; | |
| 1221 | /* XXX this should have an API, I shouldn't grab this directly */ | |
| 1222 | g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); | |
| 9238 | 1223 | |
| 1224 | if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) { | |
| 1225 | ib->flag = FALSE; | |
| 1226 | irc_buddy_status(data[0], ib, irc); | |
| 1227 | } | |
| 6333 | 1228 | g_free(data[0]); |
| 1229 | ||
| 1230 | return; | |
| 1231 | } | |
| 1232 | ||
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1233 | 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
|
1234 | { |
| 15884 | 1235 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1236 | |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1237 | if (!args || !args[1]) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1238 | return; |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1239 | |
| 15884 | 1240 | 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
|
1241 | } |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1242 | |
| 6333 | 1243 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1244 | { | |
| 15884 | 1245 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1246 | char *nick, *msg; |
| 6333 | 1247 | |
| 1248 | if (!args || !args[0] || !gc) | |
| 1249 | return; | |
| 1250 | ||
| 1251 | nick = irc_mask_nick(from); | |
| 1252 | msg = g_strdup_printf (_("Wallops from %s"), nick); | |
| 1253 | g_free(nick); | |
| 15884 | 1254 | purple_notify_info(gc, NULL, msg, args[0]); |
| 6333 | 1255 | g_free(msg); |
| 1256 | } | |
| 1257 | ||
| 1258 | void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1259 | { | |
| 1260 | return; | |
| 1261 | } |