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