Tue, 25 Sep 2012 22:58:51 +0200
Implement SASL support for IRC, using Cyrus.
This is compatible with Freenode etc. That means
only PLAIN currently works, as Freenode only
offers PLAIN and DH-BLOWFISH, but we try a number
of others (as we can't query what the server
supports...) in case a server adds them.
Credit goes to Andy Spencer for the original patch.
Fixes #13270
| 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 | * |
|
32117
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
6 | * Copyright (C) 2003, 2012 Ethan Blanton <elb@pidgin.im> |
|
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 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
35 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
36 | #include <sasl/sasl.h> |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
37 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
38 | |
| 6333 | 39 | static char *irc_mask_nick(const char *mask); |
| 40 | static char *irc_mask_userhost(const char *mask); | |
| 15884 | 41 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]); |
| 6333 | 42 | 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
|
43 | static void irc_connected(struct irc_conn *irc, const char *nick); |
| 6333 | 44 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
45 | 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
|
46 | const char *from, const char *to, |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
47 | const char *rawmsg, gboolean notice); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
48 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
49 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
50 | static void irc_sasl_finish(struct irc_conn *irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
51 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
52 | |
| 6333 | 53 | static char *irc_mask_nick(const char *mask) |
| 54 | { | |
| 55 | char *end, *buf; | |
| 56 | ||
| 57 | end = strchr(mask, '!'); | |
| 58 | if (!end) | |
| 59 | buf = g_strdup(mask); | |
| 60 | else | |
| 61 | buf = g_strndup(mask, end - mask); | |
| 62 | ||
| 63 | return buf; | |
| 64 | } | |
| 65 | ||
| 66 | static char *irc_mask_userhost(const char *mask) | |
| 67 | { | |
| 68 | return g_strdup(strchr(mask, '!') + 1); | |
| 69 | } | |
| 70 | ||
| 15884 | 71 | static void irc_chat_remove_buddy(PurpleConversation *convo, char *data[2]) |
| 6333 | 72 | { |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
73 | char *message, *stripped; |
|
10730
cc7807276e53
[gaim-migrate @ 12331]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10712
diff
changeset
|
74 | |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
75 | 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
|
76 | 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
|
77 | g_free(stripped); |
| 6333 | 78 | |
| 15884 | 79 | if (purple_conv_chat_find_user(PURPLE_CONV_CHAT(convo), data[0])) |
| 80 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), data[0], message); | |
| 6333 | 81 | |
| 82 | g_free(message); | |
| 83 | } | |
| 84 | ||
|
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
|
85 | 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
|
86 | { |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
87 | PurpleConnection *gc; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
88 | PurpleStatus *status; |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
89 | GSList *buddies; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23582
diff
changeset
|
90 | 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
|
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 ((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
|
93 | || 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
|
94 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
95 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
96 | 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
|
97 | 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
|
98 | 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
|
99 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
100 | /* 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
|
101 | 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
|
102 | 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
|
103 | 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
|
104 | 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
|
105 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
106 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
107 | /* 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
|
108 | 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
|
109 | 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
|
110 | { |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
111 | PurpleBuddy *b = buddies->data; |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27044
diff
changeset
|
112 | 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
|
113 | ib->name = g_strdup(purple_buddy_get_name(b)); |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27361
diff
changeset
|
114 | ib->ref = 1; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27361
diff
changeset
|
115 | g_hash_table_replace(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
|
116 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
117 | |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
118 | 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
|
119 | if (!irc->timer) |
|
25716
1b5be208d5ba
applied changes from a336cc1fd3a1ce815f97303b8d5ae8988f8cbd5b
Ethan Blanton <elb@pidgin.im>
parents:
25707
diff
changeset
|
120 | 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
|
121 | } |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
122 | |
|
32127
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
123 | /* This function is ugly, but it's really an error handler. */ |
| 6333 | 124 | void irc_msg_default(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 125 | { | |
|
32127
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
126 | int i; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
127 | const char *end, *cur, *numeric = NULL; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
128 | char *clean, *tmp, *convname; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
129 | PurpleConversation *convo; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
130 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
131 | for (cur = args[0], i = 0; i < 4; i++) { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
132 | end = strchr(cur, ' '); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
133 | if (end == NULL) { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
134 | goto undirected; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
135 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
136 | /* Check for 3-digit numeric in second position */ |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
137 | if (i == 1) { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
138 | if (end - cur != 3 |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
139 | || !isdigit(cur[0]) || !isdigit(cur[1]) |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
140 | || !isdigit(cur[2])) { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
141 | goto undirected; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
142 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
143 | /* Save the numeric for printing to the channel */ |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
144 | numeric = cur; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
145 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
146 | /* Don't advance cur if we're on the final iteration. */ |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
147 | if (i != 3) { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
148 | cur = end + 1; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
149 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
150 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
151 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
152 | /* At this point, cur is the beginning of the fourth position, |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
153 | * end is the following space, and there are remaining |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
154 | * arguments. We'll check to see if this argument is a |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
155 | * currently active conversation (private message or channel, |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
156 | * either one), and print the numeric to that conversation if it |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
157 | * is. */ |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
158 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
159 | tmp = g_strndup(cur, end - cur); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
160 | convname = purple_utf8_salvage(tmp); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
161 | g_free(tmp); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
162 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
163 | /* Check for an existing conversation */ |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
164 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
165 | convname, |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
166 | irc->account); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
167 | g_free(convname); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
168 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
169 | if (convo == NULL) { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
170 | goto undirected; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
171 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
172 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
173 | /* end + 1 is the first argument past the target. The initial |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
174 | * arguments we've skipped are routing info, numeric, recipient |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
175 | * (this account's nick, most likely), and target (this |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
176 | * channel). If end + 1 is an ASCII :, skip it, because it's |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
177 | * meaningless in this context. This won't catch all |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
178 | * :-arguments, but it'll catch the easy case. */ |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
179 | if (*++end == ':') { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
180 | end++; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
181 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
182 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
183 | /* We then print "numeric: remainder". */ |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
184 | clean = purple_utf8_salvage(end); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
185 | tmp = g_strdup_printf("%.3s: %s", numeric, clean); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
186 | g_free(clean); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
187 | purple_conversation_write(convo, "", tmp, |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
188 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
189 | |PURPLE_MESSAGE_RAW|PURPLE_MESSAGE_NO_LINKIFY, |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
190 | time(NULL)); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
191 | g_free(tmp); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
192 | return; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
193 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
194 | undirected: |
|
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
|
195 | /* This, too, should be escaped somehow (smarter) */ |
|
32119
86a4c1ba3c1f
disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents:
32118
diff
changeset
|
196 | clean = purple_utf8_salvage(args[0]); |
|
86a4c1ba3c1f
disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents:
32118
diff
changeset
|
197 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Unrecognized message: %s\n", clean); |
|
86a4c1ba3c1f
disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents:
32118
diff
changeset
|
198 | g_free(clean); |
| 6333 | 199 | } |
| 200 | ||
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
201 | 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
|
202 | { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
203 | gchar **features; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
204 | int i; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
205 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
206 | 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
|
207 | return; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
208 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
209 | 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
|
210 | 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
|
211 | char *val; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
212 | 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
|
213 | 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
|
214 | 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
|
215 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
216 | } |
|
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
|
217 | |
|
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
|
218 | 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
|
219 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
220 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
221 | 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
|
222 | { |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
223 | 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
|
224 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
225 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
226 | 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
|
227 | /* 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
|
228 | * 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
|
229 | 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
|
230 | /* 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
|
231 | * 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
|
232 | /* } 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
|
233 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
234 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
235 | |
| 6333 | 236 | void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 237 | { | |
| 15884 | 238 | PurpleConnection *gc; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
239 | char *msg; |
| 6333 | 240 | |
| 241 | if (!args || !args[1]) | |
| 242 | return; | |
| 243 | ||
| 15884 | 244 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 245 | /* We're doing a whois, show this in the whois dialog */ |
| 246 | irc_msg_whois(irc, name, from, args); | |
| 247 | return; | |
| 248 | } | |
| 249 | ||
| 15884 | 250 | gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
251 | if (gc) { |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
252 | msg = g_markup_escape_text(args[2], -1); |
| 15884 | 253 | 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
|
254 | g_free(msg); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
255 | } |
| 6333 | 256 | } |
| 257 | ||
| 258 | void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 259 | { | |
| 15884 | 260 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 261 | |
| 262 | if (!args || !args[1] || !gc) | |
| 263 | return; | |
| 264 | ||
| 15884 | 265 | purple_notify_error(gc, NULL, _("Bad mode"), args[1]); |
| 6333 | 266 | } |
| 267 | ||
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
268 | 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
|
269 | { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
270 | PurpleConversation *convo; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
271 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
272 | 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
|
273 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
274 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
275 | 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
|
276 | 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
|
277 | |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
278 | 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
|
279 | 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
|
280 | /* 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
|
281 | 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
|
282 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
283 | 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
|
284 | /* 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
|
285 | 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
|
286 | time_t t2 = time(NULL); |
| 24416 | 287 | 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
|
288 | msg = g_strdup_printf(_("Ban on %s by %s, set %s ago"), |
| 24416 | 289 | args[2], args[3], time); |
| 290 | 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
|
291 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
292 | 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
|
293 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
294 | if (convo) { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
295 | 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
|
296 | 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
|
297 | time(NULL)); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
298 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
299 | 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
|
300 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
301 | 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
|
302 | } 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
|
303 | if (!convo) |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
304 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
305 | /* 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
|
306 | 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
|
307 | _("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
|
308 | 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
|
309 | time(NULL)); |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
310 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
311 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
312 | |
| 6333 | 313 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 314 | { | |
| 15884 | 315 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 316 | char *buf; |
| 317 | ||
| 318 | if (!args || !args[1] || !gc) | |
| 319 | return; | |
| 320 | ||
| 321 | buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
| 15884 | 322 | purple_notify_error(gc, _("Banned"), _("Banned"), buf); |
| 6333 | 323 | g_free(buf); |
| 324 | } | |
| 325 | ||
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
326 | 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
|
327 | { |
| 15884 | 328 | PurpleConversation *convo; |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
329 | char *buf, *nick; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
330 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
331 | if (!args || !args[0] || !args[1] || !args[2]) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
332 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
333 | |
| 15884 | 334 | 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
|
335 | if (!convo) |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
336 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
337 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
338 | nick = g_markup_escape_text(args[2], -1); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
339 | buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
340 | g_free(nick); |
| 15884 | 341 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", buf, |
| 342 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, | |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
343 | time(NULL)); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
344 | g_free(buf); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
345 | } |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
346 | |
| 6333 | 347 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 348 | { | |
| 15884 | 349 | PurpleConversation *convo; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
350 | char *buf, *escaped; |
| 6333 | 351 | |
| 352 | if (!args || !args[1] || !args[2]) | |
| 353 | return; | |
| 354 | ||
| 15884 | 355 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 356 | if (!convo) /* XXX punt on channels we are not in for now */ |
| 357 | return; | |
| 358 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
359 | 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
|
360 | buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); |
| 15884 | 361 | 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
|
362 | g_free(escaped); |
| 6333 | 363 | g_free(buf); |
| 364 | ||
| 365 | return; | |
| 366 | } | |
| 367 | ||
| 368 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 369 | { | |
| 370 | if (!irc->whois.nick) { | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
371 | 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
|
372 | , args[1]); |
| 6333 | 373 | return; |
| 374 | } | |
| 375 | ||
| 15884 | 376 | 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
|
377 | 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
|
378 | , args[1], irc->whois.nick); |
| 6333 | 379 | return; |
| 380 | } | |
| 381 | ||
| 382 | if (!strcmp(name, "301")) { | |
| 383 | irc->whois.away = g_strdup(args[2]); | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
384 | } else if (!strcmp(name, "311") || !strcmp(name, "314")) { |
| 6333 | 385 | irc->whois.userhost = g_strdup_printf("%s@%s", args[2], args[3]); |
| 386 | irc->whois.name = g_strdup(args[5]); | |
| 387 | } else if (!strcmp(name, "312")) { | |
| 388 | irc->whois.server = g_strdup(args[2]); | |
| 389 | irc->whois.serverinfo = g_strdup(args[3]); | |
| 390 | } else if (!strcmp(name, "313")) { | |
| 391 | irc->whois.ircop = 1; | |
| 392 | } else if (!strcmp(name, "317")) { | |
| 393 | irc->whois.idle = atoi(args[2]); | |
| 394 | if (args[3]) | |
| 395 | irc->whois.signon = (time_t)atoi(args[3]); | |
| 396 | } else if (!strcmp(name, "319")) { | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
397 | if (irc->whois.channels == NULL) { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
398 | irc->whois.channels = g_string_new(args[2]); |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
399 | } else { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
400 | 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
|
401 | } |
| 6333 | 402 | } else if (!strcmp(name, "320")) { |
| 403 | irc->whois.identified = 1; | |
| 404 | } | |
| 405 | } | |
| 406 | ||
| 407 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 408 | { | |
| 15884 | 409 | PurpleConnection *gc; |
|
15215
3b4c0490b8b0
[gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
410 | char *tmp, *tmp2; |
| 15884 | 411 | PurpleNotifyUserInfo *user_info; |
| 6333 | 412 | |
| 413 | if (!irc->whois.nick) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
414 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of %s for %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
415 | , args[1]); |
| 6333 | 416 | return; |
| 417 | } | |
| 15884 | 418 | if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
419 | purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of %s for %s, expecting %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
420 | , args[1], irc->whois.nick); |
| 6333 | 421 | return; |
| 422 | } | |
| 423 | ||
| 15884 | 424 | user_info = purple_notify_user_info_new(); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
425 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
426 | tmp2 = g_markup_escape_text(args[1], -1); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
427 | tmp = g_strdup_printf("%s%s%s", tmp2, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
428 | (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
429 | (irc->whois.identified ? _(" <i>(identified)</i>") : "")); |
| 15884 | 430 | purple_notify_user_info_add_pair(user_info, _("Nick"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
431 | g_free(tmp2); |
| 10634 | 432 | g_free(tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
433 | |
| 6333 | 434 | if (irc->whois.away) { |
| 10634 | 435 | tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); |
| 6333 | 436 | g_free(irc->whois.away); |
| 15884 | 437 | purple_notify_user_info_add_pair(user_info, _("Away"), tmp); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
438 | g_free(tmp); |
| 6333 | 439 | } |
| 440 | if (irc->whois.userhost) { | |
| 10634 | 441 | 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
|
442 | g_free(irc->whois.name); |
| 15884 | 443 | purple_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); |
| 444 | purple_notify_user_info_add_pair(user_info, _("Real name"), tmp); | |
| 6333 | 445 | g_free(irc->whois.userhost); |
|
9589
229d4c811c01
[gaim-migrate @ 10432]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9558
diff
changeset
|
446 | g_free(tmp); |
| 6333 | 447 | } |
| 448 | if (irc->whois.server) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
449 | tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); |
| 15884 | 450 | purple_notify_user_info_add_pair(user_info, _("Server"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
451 | g_free(tmp); |
| 6333 | 452 | g_free(irc->whois.server); |
| 453 | g_free(irc->whois.serverinfo); | |
| 454 | } | |
| 455 | if (irc->whois.channels) { | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
456 | 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
|
457 | g_string_free(irc->whois.channels, TRUE); |
| 6333 | 458 | } |
| 459 | if (irc->whois.idle) { | |
| 15884 | 460 | gchar *timex = purple_str_seconds_to_string(irc->whois.idle); |
| 461 | 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
|
462 | g_free(timex); |
| 15884 | 463 | purple_notify_user_info_add_pair(user_info, |
| 464 | _("Online since"), purple_date_format_full(localtime(&irc->whois.signon))); | |
| 6333 | 465 | } |
| 466 | if (!strcmp(irc->whois.nick, "Paco-Paco")) { | |
| 15884 | 467 | purple_notify_user_info_add_pair(user_info, |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
468 | _("<b>Defining adjective:</b>"), _("Glorious")); |
| 6333 | 469 | } |
| 470 | ||
| 15884 | 471 | gc = purple_account_get_connection(irc->account); |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
472 | |
| 15884 | 473 | purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); |
| 474 | purple_notify_user_info_destroy(user_info); | |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
475 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
476 | g_free(irc->whois.nick); |
| 6333 | 477 | memset(&irc->whois, 0, sizeof(irc->whois)); |
| 478 | } | |
| 479 | ||
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
480 | void irc_msg_who(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
481 | { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
482 | if (!strcmp(name, "352")) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
483 | PurpleConversation *conv; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
484 | PurpleConvChat *chat; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
485 | PurpleConvChatBuddy *cb; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
486 | |
|
32037
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
487 | char *cur, *userhost, *realname; |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
488 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
489 | PurpleConvChatBuddyFlags flags; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
490 | GList *keys = NULL, *values = NULL; |
|
32037
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
491 | |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
492 | if (!args || !args[0] || !args[1] || !args[2] || !args[3] |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
493 | || !args[4] || !args[5] || !args[6] || !args[7]) { |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
494 | purple_debug(PURPLE_DEBUG_ERROR, "irc", |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
495 | "Got a WHO response with not enough arguments\n"); |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
496 | return; |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
497 | } |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
498 | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
499 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
500 | if (!conv) { |
|
32037
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
501 | purple_debug(PURPLE_DEBUG_ERROR, "irc","Got a WHO response for %s, which doesn't exist\n", args[1]); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
502 | return; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
503 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
504 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
505 | cb = purple_conv_chat_cb_find(PURPLE_CONV_CHAT(conv), args[5]); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
506 | if (!cb) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
507 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a WHO response for %s who isn't a buddy.\n", args[5]); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
508 | return; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
509 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
510 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
511 | chat = PURPLE_CONV_CHAT(conv); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
512 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
513 | userhost = g_strdup_printf("%s@%s", args[2], args[3]); |
|
32037
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
514 | |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
515 | /* The final argument is a :-argument, but annoyingly |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
516 | * contains two "words", the hop count and real name. */ |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
517 | for (cur = args[7]; *cur; cur++) { |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
518 | if (*cur == ' ') { |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
519 | cur++; |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
520 | break; |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
521 | } |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
522 | } |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
523 | realname = g_strdup(cur); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
524 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
525 | keys = g_list_prepend(keys, "userhost"); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
526 | values = g_list_prepend(values, userhost); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
527 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
528 | keys = g_list_prepend(keys, "realname"); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
529 | values = g_list_prepend(values, realname); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
530 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
531 | purple_conv_chat_cb_set_attributes(chat, cb, keys, values); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
532 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
533 | g_list_free(keys); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
534 | g_list_free(values); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
535 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
536 | g_free(userhost); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
537 | g_free(realname); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
538 | |
|
31936
ca4f3c0aa125
irc: Save one useless hash table lookup
Paul Aurich <darkrain42@pidgin.im>
parents:
31565
diff
changeset
|
539 | flags = cb->flags; |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
540 | |
|
32117
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
541 | /* FIXME: I'm not sure this is really a good idea, now |
|
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
542 | * that we no longer do periodic WHO. It seems to me |
|
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
543 | * like it's more likely to be confusing than not. |
|
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
544 | * Comments? */ |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
545 | if (args[6][0] == 'G' && !(flags & PURPLE_CBFLAGS_AWAY)) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
546 | purple_conv_chat_user_set_flags(chat, cb->name, flags | PURPLE_CBFLAGS_AWAY); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
547 | } else if(args[6][0] == 'H' && (flags & PURPLE_CBFLAGS_AWAY)) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
548 | purple_conv_chat_user_set_flags(chat, cb->name, flags & ~PURPLE_CBFLAGS_AWAY); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
549 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
550 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
551 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
552 | |
| 8114 | 553 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 554 | { | |
| 555 | if (!irc->roomlist) | |
| 556 | return; | |
| 557 | ||
| 558 | if (!strcmp(name, "321")) { | |
| 15884 | 559 | purple_roomlist_set_in_progress(irc->roomlist, TRUE); |
| 8114 | 560 | return; |
| 561 | } | |
| 562 | ||
| 563 | if (!strcmp(name, "323")) { | |
| 15884 | 564 | purple_roomlist_set_in_progress(irc->roomlist, FALSE); |
| 565 | purple_roomlist_unref(irc->roomlist); | |
| 8114 | 566 | irc->roomlist = NULL; |
|
13667
9ebf0007d912
[gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents:
13647
diff
changeset
|
567 | return; |
| 8114 | 568 | } |
| 569 | ||
| 570 | if (!strcmp(name, "322")) { | |
| 15884 | 571 | PurpleRoomlistRoom *room; |
|
17409
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
572 | char *topic; |
| 8114 | 573 | |
| 574 | if (!args[0] || !args[1] || !args[2] || !args[3]) | |
| 575 | return; | |
| 576 | ||
|
22994
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
577 | 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
|
578 | 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
|
579 | 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
|
580 | } |
|
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
581 | |
| 15884 | 582 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); |
| 583 | purple_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
| 584 | 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
|
585 | 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
|
586 | 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
|
587 | g_free(topic); |
| 15884 | 588 | purple_roomlist_room_add(irc->roomlist, room); |
| 8114 | 589 | } |
| 590 | } | |
| 591 | ||
| 6333 | 592 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 593 | { | |
| 9762 | 594 | char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
| 15884 | 595 | PurpleConversation *convo; |
| 6333 | 596 | |
| 597 | if (!strcmp(name, "topic")) { | |
|
28465
615584769b59
Fix parsing of invalid IRC TOPIC messages which contain no actual topic
Ethan Blanton <elb@pidgin.im>
parents:
28118
diff
changeset
|
598 | if (!args[0] || !args[1]) |
|
615584769b59
Fix parsing of invalid IRC TOPIC messages which contain no actual topic
Ethan Blanton <elb@pidgin.im>
parents:
28118
diff
changeset
|
599 | return; |
| 6333 | 600 | chan = args[0]; |
| 8529 | 601 | topic = irc_mirc2txt (args[1]); |
| 6333 | 602 | } else { |
|
28465
615584769b59
Fix parsing of invalid IRC TOPIC messages which contain no actual topic
Ethan Blanton <elb@pidgin.im>
parents:
28118
diff
changeset
|
603 | if (!args[0] || !args[1] || !args[2]) |
|
28493
52da59867b93
Oh boy, fix a missing semi-colon
Mark Doliner <markdoliner@pidgin.im>
parents:
28465
diff
changeset
|
604 | return; |
| 6333 | 605 | chan = args[1]; |
| 8529 | 606 | topic = irc_mirc2txt (args[2]); |
| 6333 | 607 | } |
| 608 | ||
| 15884 | 609 | 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
|
610 | if (!convo) { |
| 15884 | 611 | 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
|
612 | g_free(topic); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
613 | return; |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
614 | } |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
615 | |
| 6333 | 616 | /* If this is an interactive update, print it out */ |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
617 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 618 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 619 | g_free(tmp); |
| 6333 | 620 | if (!strcmp(name, "topic")) { |
| 15884 | 621 | 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
|
622 | if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0)) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
623 | { |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
624 | char *nick_esc; |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
625 | nick = irc_mask_nick(from); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
626 | nick_esc = g_markup_escape_text(nick, -1); |
| 15884 | 627 | 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
|
628 | if (*tmp2) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
629 | 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
|
630 | else |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
631 | msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
632 | g_free(nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
633 | g_free(nick); |
| 15884 | 634 | 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
|
635 | g_free(msg); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
636 | } |
| 6333 | 637 | } else { |
|
13395
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
638 | char *chan_esc = g_markup_escape_text(chan, -1); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
639 | 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
|
640 | g_free(chan_esc); |
| 15884 | 641 | purple_conv_chat_set_topic(PURPLE_CONV_CHAT(convo), NULL, topic); |
| 642 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); | |
| 6333 | 643 | g_free(msg); |
| 644 | } | |
| 9762 | 645 | g_free(tmp2); |
| 8529 | 646 | g_free(topic); |
| 6333 | 647 | } |
| 648 | ||
| 649 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 650 | { | |
| 15884 | 651 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 652 | char *buf; |
| 653 | ||
| 654 | if (!args || !args[1] || !gc) | |
| 655 | return; | |
| 656 | ||
| 657 | buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
| 15884 | 658 | purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server received a message it did not understand.")); |
| 6333 | 659 | g_free(buf); |
| 660 | } | |
| 661 | ||
| 662 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 663 | { | |
| 664 | char *names, *cur, *end, *tmp, *msg; | |
| 15884 | 665 | PurpleConversation *convo; |
| 6333 | 666 | |
| 667 | if (!strcmp(name, "366")) { | |
| 15884 | 668 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 669 | if (!convo) { |
| 15884 | 670 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); |
| 6333 | 671 | g_string_free(irc->names, TRUE); |
| 672 | irc->names = NULL; | |
| 673 | return; | |
| 674 | } | |
| 675 | ||
| 676 | names = cur = g_string_free(irc->names, FALSE); | |
| 677 | irc->names = NULL; | |
| 15884 | 678 | if (purple_conversation_get_data(convo, IRC_NAMES_FLAG)) { |
|
11026
1f13c483db00
[gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents:
10816
diff
changeset
|
679 | msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
| 15884 | 680 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) |
| 681 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 682 | else |
| 15884 | 683 | purple_conv_im_write(PURPLE_CONV_IM(convo), "", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 684 | g_free(msg); |
|
32019
15434d17f320
Fix potential crash when NAMES is empty.
James McLaughlin <jamie@lacewing-project.org>
parents:
31936
diff
changeset
|
685 | } else if (cur != NULL) { |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
686 | GList *users = NULL; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
687 | GList *flags = NULL; |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
688 | |
| 6333 | 689 | while (*cur) { |
| 15884 | 690 | PurpleConvChatBuddyFlags f = PURPLE_CBFLAGS_NONE; |
| 6333 | 691 | end = strchr(cur, ' '); |
| 692 | if (!end) | |
| 693 | end = cur + strlen(cur); | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
694 | if (*cur == '@') { |
| 15884 | 695 | f = PURPLE_CBFLAGS_OP; |
| 6333 | 696 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
697 | } else if (*cur == '%') { |
| 15884 | 698 | f = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
699 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
700 | } else if(*cur == '+') { |
| 15884 | 701 | f = PURPLE_CBFLAGS_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
702 | cur++; |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
703 | } 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
|
704 | && 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
|
705 | if (*cur == '~') |
|
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
706 | 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
|
707 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
708 | } |
| 6333 | 709 | tmp = g_strndup(cur, end - cur); |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
710 | users = g_list_prepend(users, tmp); |
|
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
711 | flags = g_list_prepend(flags, GINT_TO_POINTER(f)); |
| 6333 | 712 | cur = end; |
| 713 | if (*cur) | |
| 714 | cur++; | |
| 715 | } | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
716 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
717 | if (users != NULL) { |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
718 | GList *l; |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
719 | |
| 15884 | 720 | 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
|
721 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
722 | for (l = users; l != NULL; l = l->next) |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
723 | g_free(l->data); |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
724 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
725 | g_list_free(users); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
726 | g_list_free(flags); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
727 | } |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
728 | |
| 15884 | 729 | 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
|
730 | GINT_TO_POINTER(TRUE)); |
| 6333 | 731 | } |
| 732 | g_free(names); | |
| 733 | } else { | |
| 734 | if (!irc->names) | |
| 735 | irc->names = g_string_new(""); | |
| 736 | ||
| 15313 | 737 | if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ') |
| 738 | irc->names = g_string_append_c(irc->names, ' '); | |
| 6333 | 739 | irc->names = g_string_append(irc->names, args[3]); |
| 740 | } | |
| 741 | } | |
| 742 | ||
| 743 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 744 | { | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
745 | char *escaped; |
| 6333 | 746 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
747 | 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
|
748 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
749 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
750 | 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
|
751 | 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
|
752 | 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
|
753 | 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
|
754 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
755 | } 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
|
756 | /* 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
|
757 | * 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
|
758 | 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
|
759 | return; |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
760 | } else if (!strcmp(name, "422")) { |
|
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
761 | /* in case there is no 251, and no MOTD set, finalize the connection. |
|
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
762 | * (and clear the motd for good measure). */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
763 | |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
764 | if (irc->motd) |
|
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
765 | g_string_free(irc->motd, TRUE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
766 | |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
767 | irc_connected(irc, args[0]); |
|
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
768 | return; |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
769 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
770 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
771 | if (!irc->motd) { |
| 15884 | 772 | 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
|
773 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
774 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
775 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
776 | 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
|
777 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
778 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
779 | escaped = g_markup_escape_text(args[1], -1); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
780 | g_string_append_printf(irc->motd, "%s<br>", escaped); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
781 | g_free(escaped); |
| 6333 | 782 | } |
| 783 | ||
| 10564 | 784 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 785 | { | |
| 15884 | 786 | PurpleConnection *gc; |
| 10564 | 787 | |
| 15884 | 788 | gc = purple_account_get_connection(irc->account); |
| 10564 | 789 | if (gc == NULL || args == NULL || args[2] == NULL) |
| 790 | return; | |
| 791 | ||
| 15884 | 792 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"), |
| 10564 | 793 | _("The IRC server's local time is:"), |
| 794 | args[2], NULL, NULL); | |
| 795 | } | |
| 796 | ||
| 7877 | 797 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 798 | { | |
| 15884 | 799 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 7877 | 800 | |
| 801 | if (gc == NULL || args == NULL || args[1] == NULL) | |
| 802 | return; | |
| 803 | ||
| 15884 | 804 | purple_notify_error(gc, NULL, _("No such channel"), args[1]); |
| 7877 | 805 | } |
| 806 | ||
| 6333 | 807 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 808 | { | |
| 15884 | 809 | PurpleConnection *gc; |
| 810 | PurpleConversation *convo; | |
| 6333 | 811 | |
| 15884 | 812 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, args[1], irc->account); |
| 6333 | 813 | if (convo) { |
| 15884 | 814 | if (purple_conversation_get_type(convo) == PURPLE_CONV_TYPE_CHAT) /* does this happen? */ |
| 815 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], _("no such channel"), | |
| 816 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 817 | else |
| 15884 | 818 | purple_conv_im_write(PURPLE_CONV_IM(convo), args[1], _("User is not logged in"), |
| 819 | PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 820 | } else { |
| 15884 | 821 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 822 | return; |
| 15884 | 823 | purple_notify_error(gc, NULL, _("No such nick or channel"), args[1]); |
| 6333 | 824 | } |
| 825 | ||
| 15884 | 826 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 827 | g_free(irc->whois.nick); |
| 828 | irc->whois.nick = NULL; | |
| 829 | } | |
| 830 | } | |
| 831 | ||
| 832 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 833 | { | |
| 15884 | 834 | PurpleConnection *gc; |
| 835 | PurpleConversation *convo; | |
| 6333 | 836 | |
| 15884 | 837 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 838 | if (convo) { |
| 15884 | 839 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 840 | } else { |
| 15884 | 841 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 842 | return; |
| 15884 | 843 | purple_notify_error(gc, NULL, _("Could not send"), args[2]); |
| 6333 | 844 | } |
| 845 | } | |
| 846 | ||
| 847 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 848 | { | |
| 15884 | 849 | PurpleConversation *convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 850 | |
| 15884 | 851 | purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); |
| 6333 | 852 | if (convo) { |
| 853 | /*g_slist_remove(irc->gc->buddy_chats, convo); | |
| 15884 | 854 | purple_conversation_set_account(convo, NULL);*/ |
| 855 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[1], args[2], PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 856 | } |
| 857 | } | |
| 858 | ||
| 859 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 860 | { | |
| 15884 | 861 | PurpleConversation *convo; |
| 6333 | 862 | |
| 863 | if (!args || !args[1] || !args[2]) | |
| 864 | return; | |
| 865 | ||
| 15884 | 866 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[1], irc->account); |
| 6333 | 867 | if (!convo) |
| 868 | return; | |
| 869 | ||
| 15884 | 870 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "", args[2], PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 871 | } |
| 872 | ||
| 873 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 874 | { | |
| 15884 | 875 | 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
|
876 | GHashTable *components; |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
877 | gchar *nick; |
| 6333 | 878 | |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
879 | if (!args || !args[1] || !gc) |
| 6333 | 880 | return; |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
881 | |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
882 | 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
|
883 | nick = irc_mask_nick(from); |
| 6333 | 884 | |
|
22870
25b482330fec
Use g_strdup to match the subsequent g_free.
Daniel Atallah <datallah@pidgin.im>
parents:
22798
diff
changeset
|
885 | g_hash_table_insert(components, g_strdup("channel"), g_strdup(args[1])); |
| 6333 | 886 | |
| 887 | serv_got_chat_invite(gc, args[1], nick, NULL, components); | |
| 888 | g_free(nick); | |
| 889 | } | |
| 890 | ||
| 891 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 892 | { | |
| 15884 | 893 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 894 | char *buf; |
| 895 | ||
| 896 | if (!args || !args[1] || !gc) | |
| 897 | return; | |
| 898 | ||
| 899 | buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
| 15884 | 900 | purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf); |
| 6333 | 901 | g_free(buf); |
| 902 | } | |
| 903 | ||
| 904 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 905 | { | |
| 906 | char **nicks; | |
| 907 | struct irc_buddy *ib; | |
| 908 | int i; | |
| 909 | ||
| 910 | if (!args || !args[1]) | |
| 911 | return; | |
| 912 | ||
| 913 | nicks = g_strsplit(args[1], " ", -1); | |
| 914 | for (i = 0; nicks[i]; i++) { | |
| 915 | if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
| 916 | continue; | |
| 917 | } | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
918 | ib->new_online_status = TRUE; |
| 6333 | 919 | } |
| 6350 | 920 | g_strfreev(nicks); |
| 921 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
922 | if (irc->ison_outstanding) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
923 | irc_buddy_query(irc); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
924 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
925 | if (!irc->ison_outstanding) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
926 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
| 6333 | 927 | } |
| 928 | ||
| 929 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
| 930 | { | |
| 15884 | 931 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 932 | PurpleBuddy *buddy = purple_find_buddy(irc->account, name); | |
| 6333 | 933 | |
| 934 | if (!gc || !buddy) | |
| 935 | return; | |
| 936 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
937 | if (ib->online && !ib->new_online_status) { |
| 15884 | 938 | purple_prpl_got_user_status(irc->account, name, "offline", NULL); |
| 6333 | 939 | ib->online = FALSE; |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
940 | } else if (!ib->online && ib->new_online_status) { |
| 15884 | 941 | purple_prpl_got_user_status(irc->account, name, "available", NULL); |
| 6333 | 942 | ib->online = TRUE; |
| 943 | } | |
| 944 | } | |
| 945 | ||
| 946 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 947 | { | |
| 15884 | 948 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 949 | PurpleConversation *convo; | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
950 | PurpleConvChat *chat; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
951 | PurpleConvChatBuddy *cb; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
952 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
953 | char *nick = irc_mask_nick(from), *userhost, *buf; |
| 9238 | 954 | struct irc_buddy *ib; |
| 6333 | 955 | static int id = 1; |
| 956 | ||
| 957 | if (!gc) { | |
| 958 | g_free(nick); | |
| 959 | return; | |
| 960 | } | |
| 961 | ||
| 15884 | 962 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 6333 | 963 | /* We are joining a channel for the first time */ |
| 964 | serv_got_joined_chat(gc, id++, args[0]); | |
| 965 | g_free(nick); | |
| 15884 | 966 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, |
| 13938 | 967 | args[0], |
| 968 | irc->account); | |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
969 | |
| 13938 | 970 | if (convo == NULL) { |
| 15884 | 971 | purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]); |
| 13938 | 972 | return; |
| 973 | } | |
| 15884 | 974 | 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
|
975 | GINT_TO_POINTER(FALSE)); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
976 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
977 | // Get the real name and user host for all participants. |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
978 | buf = irc_format(irc, "vc", "WHO", args[0]); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
979 | irc_send(irc, buf); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
980 | g_free(buf); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
981 | |
|
20194
fee478bb059b
applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents:
19859
diff
changeset
|
982 | /* 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
|
983 | * 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
|
984 | * behavior both for the /join and auto-join cases. */ |
|
20194
fee478bb059b
applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents:
19859
diff
changeset
|
985 | /* purple_conversation_present(convo); */ |
| 6333 | 986 | return; |
| 987 | } | |
| 988 | ||
| 15884 | 989 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 990 | if (convo == NULL) { |
| 15884 | 991 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); |
| 6333 | 992 | g_free(nick); |
| 993 | return; | |
| 994 | } | |
| 995 | ||
| 996 | userhost = irc_mask_userhost(from); | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
997 | chat = PURPLE_CONV_CHAT(convo); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
998 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
999 | purple_conv_chat_add_user(chat, nick, userhost, PURPLE_CBFLAGS_NONE, TRUE); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
1000 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
1001 | cb = purple_conv_chat_cb_find(chat, nick); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
1002 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
1003 | if (cb) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
1004 | purple_conv_chat_cb_set_attribute(chat, cb, "userhost", userhost); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
1005 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
1006 | |
| 9238 | 1007 | if ((ib = g_hash_table_lookup(irc->buddies, nick)) != NULL) { |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
1008 | ib->new_online_status = TRUE; |
| 9238 | 1009 | irc_buddy_status(nick, ib, irc); |
| 1010 | } | |
| 1011 | ||
| 6333 | 1012 | g_free(userhost); |
| 1013 | g_free(nick); | |
| 1014 | } | |
| 1015 | ||
| 1016 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1017 | { | |
| 15884 | 1018 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1019 | 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
|
1020 | char *nick = irc_mask_nick(from), *buf; |
| 6333 | 1021 | |
| 1022 | if (!gc) { | |
| 1023 | g_free(nick); | |
| 1024 | return; | |
| 1025 | } | |
| 1026 | ||
| 1027 | if (!convo) { | |
|
30270
8380aae8b132
I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29286
diff
changeset
|
1028 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Received a KICK for unknown channel %s\n", args[0]); |
| 6333 | 1029 | g_free(nick); |
| 1030 | return; | |
| 1031 | } | |
| 1032 | ||
| 15884 | 1033 | 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
|
1034 | buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
| 15884 | 1035 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), args[0], buf, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 1036 | g_free(buf); |
| 15884 | 1037 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 1038 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
1039 | buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
| 15884 | 1040 | purple_conv_chat_remove_user(PURPLE_CONV_CHAT(convo), args[1], buf); |
| 6333 | 1041 | g_free(buf); |
| 1042 | } | |
| 1043 | ||
| 1044 | g_free(nick); | |
| 1045 | return; | |
| 1046 | } | |
| 1047 | ||
| 1048 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1049 | { | |
| 15884 | 1050 | PurpleConversation *convo; |
| 6333 | 1051 | char *nick = irc_mask_nick(from), *buf; |
| 1052 | ||
| 1053 | if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1054 | char *escaped; |
| 15884 | 1055 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, args[0], irc->account); |
| 6333 | 1056 | if (!convo) { |
| 15884 | 1057 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); |
| 6333 | 1058 | g_free(nick); |
| 1059 | return; | |
| 1060 | } | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1061 | 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
|
1062 | buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); |
| 15884 | 1063 | 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
|
1064 | g_free(escaped); |
| 6333 | 1065 | g_free(buf); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1066 | if(args[2]) { |
| 15884 | 1067 | PurpleConvChatBuddyFlags newflag, flags; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1068 | char *mcur, *cur, *end, *user; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1069 | gboolean add = FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1070 | mcur = args[1]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1071 | cur = args[2]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1072 | while (*cur && *mcur) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1073 | if ((*mcur == '+') || (*mcur == '-')) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1074 | add = (*mcur == '+') ? TRUE : FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1075 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1076 | continue; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1077 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1078 | end = strchr(cur, ' '); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1079 | if (!end) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1080 | end = cur + strlen(cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1081 | user = g_strndup(cur, end - cur); |
| 15884 | 1082 | flags = purple_conv_chat_user_get_flags(PURPLE_CONV_CHAT(convo), user); |
| 1083 | newflag = PURPLE_CBFLAGS_NONE; | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1084 | if (*mcur == 'o') |
| 15884 | 1085 | newflag = PURPLE_CBFLAGS_OP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1086 | else if (*mcur =='h') |
| 15884 | 1087 | newflag = PURPLE_CBFLAGS_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1088 | else if (*mcur == 'v') |
| 15884 | 1089 | 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
|
1090 | 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
|
1091 | && 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
|
1092 | newflag = PURPLE_CBFLAGS_FOUNDER; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1093 | if (newflag) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1094 | if (add) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1095 | flags |= newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1096 | else |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1097 | flags &= ~newflag; |
| 15884 | 1098 | 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
|
1099 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1100 | g_free(user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1101 | cur = end; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1102 | if (*cur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1103 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1104 | if (*mcur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1105 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1106 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1107 | } |
| 6333 | 1108 | } else { /* User */ |
| 1109 | } | |
| 1110 | g_free(nick); | |
| 1111 | } | |
| 1112 | ||
| 1113 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1114 | { | |
| 15884 | 1115 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1116 | PurpleConversation *conv; | |
| 6333 | 1117 | GSList *chats; |
| 1118 | char *nick = irc_mask_nick(from); | |
| 1119 | ||
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1120 | 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
|
1121 | |
| 6333 | 1122 | if (!gc) { |
| 1123 | g_free(nick); | |
| 1124 | return; | |
| 1125 | } | |
| 1126 | chats = gc->buddy_chats; | |
| 1127 | ||
| 15884 | 1128 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 1129 | purple_connection_set_display_name(gc, args[0]); | |
| 6333 | 1130 | } |
| 1131 | ||
| 1132 | while (chats) { | |
| 15884 | 1133 | PurpleConvChat *chat = PURPLE_CONV_CHAT(chats->data); |
| 9593 | 1134 | /* This is ugly ... */ |
| 15884 | 1135 | if (purple_conv_chat_find_user(chat, nick)) |
| 1136 | purple_conv_chat_rename_user(chat, nick, args[0]); | |
| 6333 | 1137 | chats = chats->next; |
| 1138 | } | |
| 10617 | 1139 | |
| 15884 | 1140 | conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, nick, |
| 10617 | 1141 | irc->account); |
| 1142 | if (conv != NULL) | |
| 15884 | 1143 | purple_conversation_set_name(conv, args[0]); |
| 10617 | 1144 | |
| 6333 | 1145 | g_free(nick); |
| 1146 | } | |
| 1147 | ||
| 10633 | 1148 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1149 | { | |
| 15884 | 1150 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1151 | if (purple_connection_get_state(gc) == PURPLE_CONNECTED) { | |
| 1152 | purple_notify_error(gc, _("Invalid nickname"), | |
| 13057 | 1153 | _("Invalid nickname"), |
| 1154 | _("Your selected nickname was rejected by the server. It probably contains invalid characters.")); | |
| 1155 | ||
| 1156 | } else { | |
| 21279 | 1157 | purple_connection_error_reason (gc, |
| 1158 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, | |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
1159 | _("Your selected account name was rejected by the server. It probably contains invalid characters.")); |
| 13057 | 1160 | } |
| 10633 | 1161 | } |
| 1162 | ||
| 6333 | 1163 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1164 | { | |
| 1165 | char *newnick, *buf, *end; | |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1166 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 1167 | |
| 1168 | if (!args || !args[1]) | |
| 1169 | return; | |
| 1170 | ||
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1171 | if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTED) { |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1172 | /* 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
|
1173 | has not been successfully completed. If it has, just |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1174 | 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
|
1175 | 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
|
1176 | 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
|
1177 | 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
|
1178 | _("Nickname in use"), buf); |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1179 | g_free(buf); |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1180 | g_free(irc->reqnick); |
|
25706
cbaf3afc17c6
applied changes from 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25705
diff
changeset
|
1181 | irc->reqnick = NULL; |
|
25707
e1b69b86aa3c
Hand-pluck of 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25706
diff
changeset
|
1182 | return; |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1183 | } |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1184 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1185 | 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
|
1186 | 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
|
1187 | else |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1188 | newnick = g_strdup_printf("%s0", args[1]); |
| 6333 | 1189 | end = newnick + strlen(newnick) - 1; |
|
11386
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1190 | /* try fallbacks */ |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1191 | if((*end < '9') && (*end >= '1')) { |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1192 | *end = *end + 1; |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1193 | } else *end = '1'; |
| 6333 | 1194 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1195 | 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
|
1196 | 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
|
1197 | 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
|
1198 | |
|
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
|
1199 | 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
|
1200 | 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
|
1201 | |
| 6333 | 1202 | buf = irc_format(irc, "vn", "NICK", newnick); |
| 1203 | irc_send(irc, buf); | |
| 1204 | g_free(buf); | |
| 1205 | } | |
| 1206 | ||
| 1207 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1208 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1209 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1210 | return; |
| 6333 | 1211 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1212 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE); |
| 6333 | 1213 | } |
| 1214 | ||
| 6718 | 1215 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1216 | { | |
| 15884 | 1217 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6718 | 1218 | |
| 6753 | 1219 | if (!args || !args[2] || !gc) |
| 6718 | 1220 | return; |
| 1221 | ||
| 15884 | 1222 | purple_notify_error(gc, _("Cannot change nick"), _("Could not change nick"), args[2]); |
| 6718 | 1223 | } |
| 1224 | ||
| 6333 | 1225 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1226 | { | |
| 15884 | 1227 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1228 | 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
|
1229 | char *nick, *msg, *channel; |
| 6333 | 1230 | |
| 8186 | 1231 | if (!args || !args[0] || !gc) |
| 6333 | 1232 | return; |
| 1233 | ||
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1234 | /* 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
|
1235 | * 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
|
1236 | 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
|
1237 | |
|
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1238 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, channel, irc->account); |
| 6333 | 1239 | 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
|
1240 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel); |
| 6333 | 1241 | return; |
| 1242 | } | |
| 1243 | ||
| 1244 | nick = irc_mask_nick(from); | |
| 15884 | 1245 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
|
29286
f9996ff32055
irc: Avoid a g_log error when parting a chatroom.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28493
diff
changeset
|
1246 | char *escaped = args[1] ? g_markup_escape_text(args[1], -1) : NULL; |
| 8186 | 1247 | 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
|
1248 | (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
|
1249 | (escaped && *escaped) ? escaped : ""); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
1250 | 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
|
1251 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), channel, msg, PURPLE_MESSAGE_SYSTEM, time(NULL)); |
| 6333 | 1252 | g_free(msg); |
| 15884 | 1253 | serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo))); |
| 6333 | 1254 | } else { |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1255 | 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
|
1256 | 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
|
1257 | g_free(msg); |
| 6333 | 1258 | } |
| 1259 | g_free(nick); | |
| 1260 | } | |
| 1261 | ||
| 1262 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1263 | { | |
| 1264 | char *buf; | |
| 1265 | if (!args || !args[0]) | |
| 1266 | return; | |
| 1267 | ||
| 1268 | buf = irc_format(irc, "v:", "PONG", args[0]); | |
| 1269 | irc_send(irc, buf); | |
| 1270 | g_free(buf); | |
| 1271 | } | |
| 1272 | ||
| 1273 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1274 | { | |
| 15884 | 1275 | PurpleConversation *convo; |
| 1276 | PurpleConnection *gc; | |
| 6333 | 1277 | char **parts, *msg; |
| 1278 | time_t oldstamp; | |
| 1279 | ||
| 1280 | if (!args || !args[1]) | |
| 1281 | return; | |
| 1282 | ||
| 1283 | parts = g_strsplit(args[1], " ", 2); | |
| 1284 | ||
| 1285 | if (!parts[0] || !parts[1]) { | |
| 1286 | g_strfreev(parts); | |
| 1287 | return; | |
| 1288 | } | |
| 1289 | ||
| 1290 | if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
| 1291 | msg = g_strdup(_("Error: invalid PONG from server")); | |
| 1292 | } else { | |
| 6350 | 1293 | msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
| 6333 | 1294 | } |
| 1295 | ||
| 15884 | 1296 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_ANY, parts[0], irc->account); |
| 6333 | 1297 | g_strfreev(parts); |
| 1298 | if (convo) { | |
| 15884 | 1299 | if (purple_conversation_get_type (convo) == PURPLE_CONV_TYPE_CHAT) |
| 1300 | purple_conv_chat_write(PURPLE_CONV_CHAT(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); | |
| 6333 | 1301 | else |
| 15884 | 1302 | purple_conv_im_write(PURPLE_CONV_IM(convo), "PONG", msg, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NO_LOG, time(NULL)); |
| 6333 | 1303 | } else { |
| 15884 | 1304 | gc = purple_account_get_connection(irc->account); |
| 6333 | 1305 | if (!gc) { |
| 1306 | g_free(msg); | |
| 1307 | return; | |
| 1308 | } | |
| 15884 | 1309 | purple_notify_info(gc, NULL, "PONG", msg); |
| 6333 | 1310 | } |
| 1311 | g_free(msg); | |
| 1312 | } | |
| 1313 | ||
| 1314 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1315 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1316 | if (!args || !args[0] || !args[1]) |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1317 | return; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1318 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1319 | 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
|
1320 | } |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1321 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1322 | 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
|
1323 | { |
| 15884 | 1324 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 1325 | PurpleConversation *convo; | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1326 | char *tmp; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1327 | char *msg; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1328 | char *nick; |
| 6333 | 1329 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1330 | if (!gc) |
| 6333 | 1331 | return; |
| 1332 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1333 | nick = irc_mask_nick(from); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1334 | tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice); |
| 6333 | 1335 | if (!tmp) { |
| 1336 | g_free(nick); | |
| 1337 | return; | |
| 1338 | } | |
| 8163 | 1339 | |
|
20217
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
20194
diff
changeset
|
1340 | msg = irc_escape_privmsg(tmp, -1); |
| 6333 | 1341 | g_free(tmp); |
| 8163 | 1342 | |
| 1343 | tmp = irc_mirc2html(msg); | |
| 1344 | g_free(msg); | |
| 1345 | msg = tmp; | |
| 6333 | 1346 | if (notice) { |
| 1347 | tmp = g_strdup_printf("(notice) %s", msg); | |
| 1348 | g_free(msg); | |
| 1349 | msg = tmp; | |
| 1350 | } | |
| 1351 | ||
| 15884 | 1352 | 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
|
1353 | serv_got_im(gc, nick, msg, 0, time(NULL)); |
| 6333 | 1354 | } 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
|
1355 | convo = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, irc_nick_skip_mode(irc, to), irc->account); |
| 6333 | 1356 | if (convo) |
| 15884 | 1357 | serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); |
| 6333 | 1358 | else |
| 15884 | 1359 | 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
|
1360 | notice ? "NOTICE" : "PRIVMSG", to); |
| 6333 | 1361 | } |
| 1362 | g_free(msg); | |
| 1363 | g_free(nick); | |
| 1364 | } | |
| 1365 | ||
| 6714 | 1366 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1367 | { | |
| 15884 | 1368 | 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
|
1369 | PurpleConversation *convo; |
| 6714 | 1370 | char *msg; |
| 1371 | ||
| 1372 | if (!args || !args[1] || !args[2] || !gc) | |
| 1373 | return; | |
| 1374 | ||
|
17297
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1375 | 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
|
1376 | if (convo) { |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1377 | /* 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
|
1378 | * 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
|
1379 | * 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
|
1380 | * 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
|
1381 | return; |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1382 | } |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1383 | |
|
16993
536c1485c139
Handle channel joins when registration is required more gracefully.
Ethan Blanton <elb@pidgin.im>
parents:
16893
diff
changeset
|
1384 | msg = g_strdup_printf(_("Cannot join %s: Registration is required."), args[1]); |
| 15884 | 1385 | purple_notify_error(gc, _("Cannot join channel"), msg, args[2]); |
| 6714 | 1386 | g_free(msg); |
| 1387 | } | |
| 1388 | ||
| 6333 | 1389 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1390 | { | |
| 15884 | 1391 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 9238 | 1392 | struct irc_buddy *ib; |
| 6333 | 1393 | char *data[2]; |
| 1394 | ||
| 1395 | if (!args || !args[0] || !gc) | |
| 1396 | return; | |
| 1397 | ||
| 1398 | data[0] = irc_mask_nick(from); | |
| 1399 | data[1] = args[0]; | |
| 1400 | /* XXX this should have an API, I shouldn't grab this directly */ | |
| 1401 | g_slist_foreach(gc->buddy_chats, (GFunc)irc_chat_remove_buddy, data); | |
| 9238 | 1402 | |
| 1403 | if ((ib = g_hash_table_lookup(irc->buddies, data[0])) != NULL) { | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
1404 | ib->new_online_status = FALSE; |
| 9238 | 1405 | irc_buddy_status(data[0], ib, irc); |
| 1406 | } | |
| 6333 | 1407 | g_free(data[0]); |
| 1408 | ||
| 1409 | return; | |
| 1410 | } | |
| 1411 | ||
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1412 | 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
|
1413 | { |
| 15884 | 1414 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1415 | |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1416 | if (!args || !args[1]) |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1417 | return; |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1418 | |
| 15884 | 1419 | 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
|
1420 | } |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1421 | |
| 6333 | 1422 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1423 | { | |
| 15884 | 1424 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1425 | char *nick, *msg; |
| 6333 | 1426 | |
| 1427 | if (!args || !args[0] || !gc) | |
| 1428 | return; | |
| 1429 | ||
| 1430 | nick = irc_mask_nick(from); | |
| 1431 | msg = g_strdup_printf (_("Wallops from %s"), nick); | |
| 1432 | g_free(nick); | |
| 15884 | 1433 | purple_notify_info(gc, NULL, msg, args[0]); |
| 6333 | 1434 | g_free(msg); |
| 1435 | } | |
| 1436 | ||
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1437 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1438 | static int |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1439 | irc_sasl_cb_secret(sasl_conn_t *conn, void *ctx, int id, sasl_secret_t **secret) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1440 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1441 | struct irc_conn *irc = ctx; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1442 | const char *pw; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1443 | size_t len; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1444 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1445 | pw = purple_account_get_password(irc->account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1446 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1447 | if (!conn || !secret || id != SASL_CB_PASS) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1448 | return SASL_BADPARAM; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1449 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1450 | len = strlen(pw); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1451 | /* Not an off-by-one because sasl_secret_t defines char data[1] */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1452 | /* TODO: This can probably be moved to glib's allocator */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1453 | sasl_secret_t *sasl_secret = malloc(sizeof(sasl_secret_t) + len); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1454 | if (!sasl_secret) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1455 | return SASL_NOMEM; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1456 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1457 | sasl_secret->len = len; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1458 | strcpy((char*)sasl_secret->data, pw); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1459 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1460 | *secret = sasl_secret; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1461 | return SASL_OK; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1462 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1463 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1464 | static int |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1465 | irc_sasl_cb_log(void *context, int level, const char *message) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1466 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1467 | if(level <= SASL_LOG_TRACE) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1468 | purple_debug_info("sasl", "%s\n", message); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1469 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1470 | return SASL_OK; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1471 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1472 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1473 | static int |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1474 | irc_sasl_cb_simple(void *ctx, int id, const char **res, unsigned *len) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1475 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1476 | struct irc_conn *irc = ctx; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1477 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1478 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1479 | switch(id) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1480 | case SASL_CB_AUTHNAME: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1481 | *res = purple_connection_get_display_name(gc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1482 | break; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1483 | case SASL_CB_USER: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1484 | *res = ""; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1485 | break; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1486 | default: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1487 | return SASL_BADPARAM; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1488 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1489 | if (len) *len = strlen((char *)*res); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1490 | return SASL_OK; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1491 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1492 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1493 | static void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1494 | irc_auth_start_cyrus(struct irc_conn *irc) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1495 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1496 | int ret = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1497 | char *buf; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1498 | sasl_security_properties_t secprops; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1499 | PurpleAccount *account = irc->account; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1500 | PurpleConnection *gc = purple_account_get_connection(account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1501 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1502 | gboolean plaintext; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1503 | gboolean again = FALSE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1504 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1505 | /* Set up security properties and options */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1506 | secprops.min_ssf = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1507 | secprops.security_flags = SASL_SEC_NOANONYMOUS; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1508 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1509 | if (!irc->gsc) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1510 | secprops.max_ssf = -1; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1511 | secprops.maxbufsize = 4096; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1512 | plaintext = purple_account_get_bool(account, "auth_plain_in_clear", FALSE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1513 | if (!plaintext) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1514 | secprops.security_flags |= SASL_SEC_NOPLAINTEXT; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1515 | } else { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1516 | secprops.max_ssf = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1517 | secprops.maxbufsize = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1518 | plaintext = TRUE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1519 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1520 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1521 | secprops.property_names = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1522 | secprops.property_values = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1523 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1524 | do { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1525 | gchar *tmp = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1526 | again = FALSE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1527 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1528 | ret = sasl_client_new("irc", irc->server, NULL, NULL, irc->sasl_cb, 0, &irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1529 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1530 | if (ret != SASL_OK) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1531 | purple_debug_error("irc", "sasl_client_new failed: %d\n", ret); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1532 | tmp = g_strdup_printf(_("Failed to initialize SASL authentication: %s"), |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1533 | sasl_errdetail(irc->sasl_conn)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1534 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1535 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1536 | g_free(tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1537 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1538 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1539 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1540 | sasl_setprop(irc->sasl_conn, SASL_AUTH_EXTERNAL, irc->account->username); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1541 | sasl_setprop(irc->sasl_conn, SASL_SEC_PROPS, &secprops); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1542 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1543 | ret = sasl_client_start(irc->sasl_conn, irc->sasl_mechs->str, NULL, NULL, NULL, &irc->current_mech); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1544 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1545 | switch (ret) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1546 | case SASL_OK: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1547 | case SASL_CONTINUE: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1548 | irc->mech_works = FALSE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1549 | break; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1550 | case SASL_NOMECH: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1551 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1552 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1553 | _("SASL authentication failed: No worthy authentication mechanisms found.")); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1554 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1555 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1556 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1557 | case SASL_BADPARAM: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1558 | case SASL_NOMEM: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1559 | tmp = g_strdup_printf(_("SASL authentication failed: %s"), sasl_errdetail(irc->sasl_conn)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1560 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1561 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1562 | g_free(tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1563 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1564 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1565 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1566 | default: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1567 | purple_debug_error("irc", "sasl_client_start failed: %s\n", sasl_errdetail(irc->sasl_conn)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1568 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1569 | if (irc->current_mech && *irc->current_mech) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1570 | char *pos; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1571 | if ((pos = strstr(irc->sasl_mechs->str, irc->current_mech))) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1572 | size_t index = pos - irc->sasl_mechs->str; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1573 | g_string_erase(irc->sasl_mechs, index, strlen(irc->current_mech)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1574 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1575 | /* Remove space which separated this mech from the next */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1576 | if ((irc->sasl_mechs->str)[index] == ' ') { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1577 | g_string_erase(irc->sasl_mechs, index, 1); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1578 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1579 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1580 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1581 | again = TRUE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1582 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1583 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1584 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1585 | } while (again); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1586 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1587 | purple_debug_info("irc", "Using SASL: %s\n", irc->current_mech); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1588 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1589 | buf = irc_format(irc, "vv", "AUTHENTICATE", irc->current_mech); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1590 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1591 | g_free(buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1592 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1593 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1594 | /* SASL authentication */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1595 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1596 | irc_msg_cap(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1597 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1598 | int ret = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1599 | int id = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1600 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1601 | const char *mech_list = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1602 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1603 | if (!args[1] || !args[2] || strncmp(args[2], "sasl ", 6)) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1604 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1605 | if (strncmp(args[1], "ACK", 4)) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1606 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1607 | gchar *tmp = g_strdup_printf(_("SASL authentication failed: Server does not support SASL authentication.")); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1608 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1609 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1610 | g_free(tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1611 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1612 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1613 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1614 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1615 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1616 | if ((ret = sasl_client_init(NULL)) != SASL_OK) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1617 | gchar *tmp = g_strdup_printf(_("SASL authentication failed: Initializing SASL failed.")); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1618 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1619 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1620 | g_free(tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1621 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1622 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1623 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1624 | irc->sasl_cb = g_new0(sasl_callback_t, 5); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1625 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1626 | irc->sasl_cb[id].id = SASL_CB_AUTHNAME; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1627 | irc->sasl_cb[id].proc = irc_sasl_cb_simple; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1628 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1629 | id++; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1630 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1631 | irc->sasl_cb[id].id = SASL_CB_USER; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1632 | irc->sasl_cb[id].proc = irc_sasl_cb_simple; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1633 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1634 | id++; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1635 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1636 | irc->sasl_cb[id].id = SASL_CB_PASS; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1637 | irc->sasl_cb[id].proc = irc_sasl_cb_secret; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1638 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1639 | id++; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1640 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1641 | irc->sasl_cb[id].id = SASL_CB_LOG; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1642 | irc->sasl_cb[id].proc = irc_sasl_cb_log; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1643 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1644 | id++; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1645 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1646 | irc->sasl_cb[id].id = SASL_CB_LIST_END; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1647 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1648 | /* We need to do this to be able to list the mechanisms. */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1649 | ret = sasl_client_new("irc", irc->server, NULL, NULL, irc->sasl_cb, 0, &irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1650 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1651 | sasl_listmech(irc->sasl_conn, NULL, "", " ", "", &mech_list, NULL, NULL); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1652 | purple_debug_info("irc", "SASL: we have available: %s\n", mech_list); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1653 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1654 | if (ret != SASL_OK) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1655 | gchar *tmp; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1656 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1657 | purple_debug_error("irc", "sasl_client_new failed: %d\n", ret); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1658 | tmp = g_strdup_printf(_("Failed to initialize SASL authentication: %s"), |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1659 | sasl_errdetail(irc->sasl_conn)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1660 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1661 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1662 | g_free(tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1663 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1664 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1665 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1666 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1667 | irc->sasl_mechs = g_string_new(mech_list); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1668 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1669 | irc_auth_start_cyrus(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1670 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1671 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1672 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1673 | irc_msg_auth(struct irc_conn *irc, char *arg) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1674 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1675 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1676 | char *buf, *authinfo; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1677 | char *serverin = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1678 | unsigned serverinlen = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1679 | const gchar *c_out; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1680 | unsigned int clen; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1681 | int ret; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1682 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1683 | irc->mech_works = TRUE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1684 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1685 | if (!arg) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1686 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1687 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1688 | if (arg[0] != '+') { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1689 | serverin = arg; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1690 | serverinlen = strlen(serverin); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1691 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1692 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1693 | ret = sasl_client_step(irc->sasl_conn, serverin, serverinlen, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1694 | NULL, &c_out, &clen); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1695 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1696 | if (ret != SASL_OK && ret != SASL_CONTINUE) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1697 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1698 | gchar *tmp = g_strdup_printf(_("SASL authentication failed: %s"), |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1699 | sasl_errdetail(irc->sasl_conn)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1700 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1701 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1702 | g_free(tmp); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1703 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1704 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1705 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1706 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1707 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1708 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1709 | authinfo = purple_base64_encode((const guchar*)c_out, clen); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1710 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1711 | buf = irc_format(irc, "vv", "AUTHENTICATE", authinfo); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1712 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1713 | g_free(buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1714 | g_free(authinfo); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1715 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1716 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1717 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1718 | irc_msg_authok(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1719 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1720 | char *buf; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1721 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1722 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1723 | irc->sasl_conn = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1724 | purple_debug_info("irc", "Succesfully authenticated using SASL.\n"); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1725 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1726 | /* Finish auth session */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1727 | buf = irc_format(irc, "vv", "CAP", "END"); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1728 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1729 | g_free(buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1730 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1731 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1732 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1733 | irc_msg_authtryagain(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1734 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1735 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1736 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1737 | /* We already received at least one AUTHENTICATE reply from the |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1738 | * server. This suggests it supports this mechanism, but the |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1739 | * password was incorrect. It would be better to abort and inform |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1740 | * the user than to try again with a different mechanism, so they |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1741 | * aren't told the server supports no worthy mechanisms. |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1742 | */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1743 | if (irc->mech_works) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1744 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1745 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Incorrect Password")); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1746 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1747 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1748 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1749 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1750 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1751 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1752 | if (irc->current_mech) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1753 | char *pos; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1754 | if ((pos = strstr(irc->sasl_mechs->str, irc->current_mech))) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1755 | size_t index = pos - irc->sasl_mechs->str; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1756 | g_string_erase(irc->sasl_mechs, index, strlen(irc->current_mech)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1757 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1758 | /* Remove space which separated this mech from the next */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1759 | if ((irc->sasl_mechs->str)[index] == ' ') { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1760 | g_string_erase(irc->sasl_mechs, index, 1); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1761 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1762 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1763 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1764 | if (*irc->sasl_mechs->str) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1765 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1766 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1767 | purple_debug_info("irc", "Now trying with %s\n", irc->sasl_mechs->str); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1768 | irc_auth_start_cyrus(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1769 | } else { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1770 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1771 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1772 | _("SASL authentication failed: No worthy mechanisms found")); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1773 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1774 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1775 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1776 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1777 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1778 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1779 | irc_msg_authfail(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1780 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1781 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1782 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1783 | /* Only show an error if we did not abort ourselves. */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1784 | if (irc->sasl_conn) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1785 | purple_debug_info("irc", "SASL authentication failed: %s", sasl_errdetail(irc->sasl_conn)); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1786 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1787 | purple_connection_error_reason (gc, |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1788 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, _("Incorrect Password")); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1789 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1790 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1791 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1792 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1793 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1794 | static void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1795 | irc_sasl_finish(struct irc_conn *irc) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1796 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1797 | char *buf; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1798 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1799 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1800 | irc->sasl_conn = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1801 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1802 | g_free(irc->sasl_cb); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1803 | irc->sasl_cb = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1804 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1805 | /* Auth failed, abort */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1806 | buf = irc_format(irc, "vv", "CAP", "END"); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1807 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1808 | g_free(buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1809 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1810 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1811 | |
| 6333 | 1812 | void irc_msg_ignore(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1813 | { | |
| 1814 | return; | |
| 1815 | } |