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" | |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34678
diff
changeset
|
32 | #include "buddylist.h" |
| 6333 | 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); | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
47 | static void irc_chat_remove_buddy(PurpleChatConversation *chat, 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 | ||
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
77 | static void irc_chat_remove_buddy(PurpleChatConversation *chat, 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 | |
|
34653
88ae47a7d595
Updated protocols for the API changes
Ankit Vani <a@nevitus.org>
parents:
34632
diff
changeset
|
85 | if (purple_chat_conversation_has_user(chat, data[0])) |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
86 | purple_chat_conversation_remove_user(chat, 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); |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
103 | purple_connection_set_state(gc, PURPLE_CONNECTION_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); |
|
34855
9c289149eed4
Global replaces according to GObject status API
Ankit Vani <a@nevitus.org>
parents:
34750
diff
changeset
|
108 | if (purple_status_type_get_primitive(purple_status_get_status_type(status)) != PURPLE_STATUS_AVAILABLE) { |
|
36623
caaadef03507
Renamed purple_connection_get_protocol_info() to purple_connection_get_protocol()
Ankit Vani <a@nevitus.org>
parents:
36579
diff
changeset
|
109 | PurpleProtocol *protocol = purple_connection_get_protocol(gc); |
| 36719 | 110 | purple_protocol_server_iface_set_status(protocol, irc->account, status); |
|
17169
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 */ |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
114 | for (buddies = purple_blist_find_buddies(account, NULL); buddies; |
|
27199
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 */ |
|
34629
3c3bed0fd13c
Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
170 | convo = purple_conversations_find_with_account(convname, irc->account); |
|
32127
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
171 | g_free(convname); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
172 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
173 | if (convo == NULL) { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
174 | goto undirected; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
175 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
176 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
177 | /* 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
|
178 | * 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
|
179 | * (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
|
180 | * 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
|
181 | * 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
|
182 | * :-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
|
183 | if (*++end == ':') { |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
184 | end++; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
185 | } |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
186 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
187 | /* 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
|
188 | 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
|
189 | 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
|
190 | g_free(clean); |
|
36089
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
191 | purple_conversation_write_system_message(convo, tmp, |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
192 | PURPLE_MESSAGE_NO_LOG | PURPLE_MESSAGE_RAW | |
|
c035b9a63457
Use purple_conversation_write_system_message where appropriate
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36088
diff
changeset
|
193 | PURPLE_MESSAGE_NO_LINKIFY); |
|
32127
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
194 | g_free(tmp); |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
195 | return; |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
196 | |
|
9c23321e1b68
Print unknown IRC numerics to channels if we can associate them.
Ethan Blanton <elb@pidgin.im>
parents:
32123
diff
changeset
|
197 | 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
|
198 | /* This, too, should be escaped somehow (smarter) */ |
|
32119
86a4c1ba3c1f
disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents:
32118
diff
changeset
|
199 | clean = purple_utf8_salvage(args[0]); |
|
86a4c1ba3c1f
disapproval of revision '708334868aba738134af61e8dab50f6f14a1e872'
Ethan Blanton <elb@pidgin.im>
parents:
32118
diff
changeset
|
200 | 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
|
201 | g_free(clean); |
| 6333 | 202 | } |
| 203 | ||
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
204 | 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
|
205 | { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
206 | gchar **features; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
207 | int i; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
208 | |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
209 | features = g_strsplit(args[1], " ", -1); |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
210 | for (i = 0; features[i]; i++) { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
211 | char *val; |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
212 | if (!strncmp(features[i], "PREFIX=", 7)) { |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
213 | if ((val = strchr(features[i] + 7, ')')) != NULL) |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
214 | irc->mode_chars = g_strdup(val + 1); |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
215 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
216 | } |
|
21684
c7881e1b73c7
another patch from my coworker Andrew Gaul that plugged a leak, I fixed it
Ka-Hing Cheung <khc@pidgin.im>
parents:
21279
diff
changeset
|
217 | |
|
c7881e1b73c7
another patch from my coworker Andrew Gaul that plugged a leak, I fixed it
Ka-Hing Cheung <khc@pidgin.im>
parents:
21279
diff
changeset
|
218 | g_strfreev(features); |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
219 | } |
|
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
220 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
221 | void irc_msg_luser(struct irc_conn *irc, const char *name, const char *from, char **args) |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
222 | { |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
223 | 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
|
224 | /* 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
|
225 | * 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
|
226 | 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
|
227 | /* 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
|
228 | * 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
|
229 | /* } 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
|
230 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
231 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
232 | |
| 6333 | 233 | void irc_msg_away(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 234 | { | |
| 15884 | 235 | PurpleConnection *gc; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
236 | char *msg; |
| 6333 | 237 | |
| 15884 | 238 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 239 | /* We're doing a whois, show this in the whois dialog */ |
| 240 | irc_msg_whois(irc, name, from, args); | |
| 241 | return; | |
| 242 | } | |
| 243 | ||
| 15884 | 244 | gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
245 | if (gc) { |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
246 | msg = g_markup_escape_text(args[2], -1); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35297
diff
changeset
|
247 | purple_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
|
248 | g_free(msg); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
249 | } |
| 6333 | 250 | } |
| 251 | ||
| 252 | void irc_msg_badmode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 253 | { | |
| 15884 | 254 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 255 | |
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
256 | g_return_if_fail(gc); |
| 6333 | 257 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
258 | purple_notify_error(gc, NULL, _("Bad mode"), args[1], |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
259 | purple_request_cpar_from_connection(gc)); |
| 6333 | 260 | } |
| 261 | ||
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
262 | 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
|
263 | { |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
264 | PurpleChatConversation *chat; |
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
265 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
266 | chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
|
22798
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 | 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
|
269 | 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
|
270 | /* 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
|
271 | 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
|
272 | /* 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
|
273 | 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
|
274 | time_t t2 = time(NULL); |
| 24416 | 275 | 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
|
276 | msg = g_strdup_printf(_("Ban on %s by %s, set %s ago"), |
| 24416 | 277 | args[2], args[3], time); |
| 278 | 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
|
279 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
280 | 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
|
281 | } |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
282 | if (chat) { |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
283 | purple_conversation_write_system_message( |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
284 | PURPLE_CONVERSATION(chat), msg, PURPLE_MESSAGE_NO_LOG); |
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
285 | } else { |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
286 | 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
|
287 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
288 | 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
|
289 | } else if (!strcmp(name, "368")) { |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
290 | if (!chat) |
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
291 | return; |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
292 | /* End of ban list */ |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
293 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
294 | _("End of ban list"), PURPLE_MESSAGE_NO_LOG); |
|
22798
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
295 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
296 | } |
|
a501b4137c64
Handle IRC ban lists in-channel. Channels which are not joined are
Ethan Blanton <elb@pidgin.im>
parents:
22795
diff
changeset
|
297 | |
| 6333 | 298 | void irc_msg_banned(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 299 | { | |
| 15884 | 300 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 301 | char *buf; |
| 302 | ||
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
303 | g_return_if_fail(gc); |
| 6333 | 304 | |
| 305 | buf = g_strdup_printf(_("You are banned from %s."), args[1]); | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
306 | purple_notify_error(gc, _("Banned"), _("Banned"), buf, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
307 | purple_request_cpar_from_connection(gc)); |
| 6333 | 308 | g_free(buf); |
| 309 | } | |
| 310 | ||
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
311 | 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
|
312 | { |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
313 | PurpleChatConversation *chat; |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
314 | char *buf, *nick; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
315 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
316 | chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
317 | if (!chat) |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
318 | return; |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
319 | |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
320 | nick = g_markup_escape_text(args[2], -1); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
321 | buf = g_strdup_printf(_("Cannot ban %s: banlist is full"), nick); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
322 | g_free(nick); |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
323 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
324 | buf, PURPLE_MESSAGE_NO_LOG); |
|
10659
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
325 | g_free(buf); |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
326 | } |
|
caf16376fba0
[gaim-migrate @ 12192]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10637
diff
changeset
|
327 | |
| 6333 | 328 | void irc_msg_chanmode(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 329 | { | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
330 | PurpleChatConversation *chat; |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
331 | char *buf, *escaped; |
| 6333 | 332 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
333 | chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
334 | if (!chat) /* XXX punt on channels we are not in for now */ |
| 6333 | 335 | return; |
| 336 | ||
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
337 | 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
|
338 | buf = g_strdup_printf("mode for %s: %s %s", args[1], args[2], escaped ? escaped : ""); |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
339 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
340 | g_free(escaped); |
| 6333 | 341 | g_free(buf); |
| 342 | ||
| 343 | return; | |
| 344 | } | |
| 345 | ||
| 346 | void irc_msg_whois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 347 | { | |
| 348 | if (!irc->whois.nick) { | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
349 | 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
|
350 | , args[1]); |
| 6333 | 351 | return; |
| 352 | } | |
| 353 | ||
| 15884 | 354 | 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
|
355 | 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
|
356 | , args[1], irc->whois.nick); |
| 6333 | 357 | return; |
| 358 | } | |
| 359 | ||
| 360 | if (!strcmp(name, "301")) { | |
| 361 | irc->whois.away = g_strdup(args[2]); | |
|
16474
bc8580a69dba
/whowas for IRC. Thanks, achris.
Ethan Blanton <elb@pidgin.im>
parents:
16167
diff
changeset
|
362 | } else if (!strcmp(name, "311") || !strcmp(name, "314")) { |
|
35182
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
363 | irc->whois.ident = g_strdup(args[2]); |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
364 | irc->whois.host = g_strdup(args[3]); |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
365 | irc->whois.real = g_strdup(args[5]); |
| 6333 | 366 | } else if (!strcmp(name, "312")) { |
| 367 | irc->whois.server = g_strdup(args[2]); | |
| 368 | irc->whois.serverinfo = g_strdup(args[3]); | |
| 369 | } else if (!strcmp(name, "313")) { | |
| 370 | irc->whois.ircop = 1; | |
| 371 | } else if (!strcmp(name, "317")) { | |
| 372 | irc->whois.idle = atoi(args[2]); | |
| 373 | if (args[3]) | |
| 374 | irc->whois.signon = (time_t)atoi(args[3]); | |
| 375 | } else if (!strcmp(name, "319")) { | |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
376 | if (irc->whois.channels == NULL) { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
377 | irc->whois.channels = g_string_new(args[2]); |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
378 | } else { |
|
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
379 | 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
|
380 | } |
| 6333 | 381 | } else if (!strcmp(name, "320")) { |
| 382 | irc->whois.identified = 1; | |
|
35182
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
383 | } 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
|
384 | 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
|
385 | name, args[1], args[2], args[3]); |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
386 | if (!strcmp(args[3], "is logged in as")) |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
387 | irc->whois.login = g_strdup(args[2]); |
| 6333 | 388 | } |
| 389 | } | |
| 390 | ||
| 391 | void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 392 | { | |
| 15884 | 393 | PurpleConnection *gc; |
|
15215
3b4c0490b8b0
[gaim-migrate @ 17939]
Mark Doliner <markdoliner@pidgin.im>
parents:
15205
diff
changeset
|
394 | char *tmp, *tmp2; |
| 15884 | 395 | PurpleNotifyUserInfo *user_info; |
| 6333 | 396 | |
| 397 | if (!irc->whois.nick) { | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
398 | 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
|
399 | , args[1]); |
| 6333 | 400 | return; |
| 401 | } | |
| 15884 | 402 | if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
403 | 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
|
404 | , args[1], irc->whois.nick); |
| 6333 | 405 | return; |
| 406 | } | |
| 407 | ||
| 15884 | 408 | user_info = purple_notify_user_info_new(); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
409 | |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
410 | tmp2 = g_markup_escape_text(args[1], -1); |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
411 | tmp = g_strdup_printf("%s%s%s", tmp2, |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
412 | (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), |
|
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
413 | (irc->whois.identified ? _(" <i>(identified)</i>") : "")); |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32162
diff
changeset
|
414 | purple_notify_user_info_add_pair_html(user_info, _("Nick"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
415 | g_free(tmp2); |
| 10634 | 416 | g_free(tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
417 | |
| 6333 | 418 | if (irc->whois.away) { |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
419 | purple_notify_user_info_add_pair_plaintext(user_info, _("Away"), irc->whois.away); |
| 6333 | 420 | g_free(irc->whois.away); |
| 421 | } | |
|
35182
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
422 | if (irc->whois.real) { |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
423 | 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
|
424 | g_free(irc->whois.real); |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
425 | } |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
426 | if (irc->whois.login) { |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
427 | 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
|
428 | g_free(irc->whois.login); |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
429 | } |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
430 | if (irc->whois.ident) { |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
431 | 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
|
432 | g_free(irc->whois.ident); |
|
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.host) { |
|
639ec03ba1ba
Improve IRC whois command
Andy Spencer <andy753421@gmail.com>
parents:
35169
diff
changeset
|
435 | 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
|
436 | g_free(irc->whois.host); |
| 6333 | 437 | } |
| 438 | if (irc->whois.server) { | |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
439 | tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
440 | purple_notify_user_info_add_pair_plaintext(user_info, _("Server"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
441 | g_free(tmp); |
| 6333 | 442 | g_free(irc->whois.server); |
| 443 | g_free(irc->whois.serverinfo); | |
| 444 | } | |
| 445 | if (irc->whois.channels) { | |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
446 | purple_notify_user_info_add_pair_plaintext(user_info, _("Currently on"), irc->whois.channels->str); |
|
25703
5e04772797b3
applied changes from 0064869870b3507952491598f4d4b8d4a99fbc6b
Ethan Blanton <elb@pidgin.im>
parents:
24763
diff
changeset
|
447 | g_string_free(irc->whois.channels, TRUE); |
| 6333 | 448 | } |
| 449 | if (irc->whois.idle) { | |
| 15884 | 450 | gchar *timex = purple_str_seconds_to_string(irc->whois.idle); |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
451 | purple_notify_user_info_add_pair_plaintext(user_info, _("Idle for"), timex); |
|
6357
f83643b0a067
[gaim-migrate @ 6856]
Mark Doliner <markdoliner@pidgin.im>
parents:
6351
diff
changeset
|
452 | g_free(timex); |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
453 | purple_notify_user_info_add_pair_plaintext(user_info, |
| 15884 | 454 | _("Online since"), purple_date_format_full(localtime(&irc->whois.signon))); |
| 6333 | 455 | } |
|
32162
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
456 | if (!strcmp(irc->whois.nick, "elb")) { |
|
cf848cd25330
Use purple_notify_user_info_add_pair_plaintext in some places where we
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
457 | purple_notify_user_info_add_pair_plaintext(user_info, |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
14731
diff
changeset
|
458 | _("<b>Defining adjective:</b>"), _("Glorious")); |
| 6333 | 459 | } |
| 460 | ||
| 15884 | 461 | gc = purple_account_get_connection(irc->account); |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
462 | |
| 15884 | 463 | purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); |
| 464 | purple_notify_user_info_destroy(user_info); | |
|
7062
26abb8b189ce
[gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
465 | |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10246
diff
changeset
|
466 | g_free(irc->whois.nick); |
| 6333 | 467 | memset(&irc->whois, 0, sizeof(irc->whois)); |
| 468 | } | |
| 469 | ||
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
470 | 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
|
471 | { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
472 | if (!strcmp(name, "352")) { |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34169
diff
changeset
|
473 | PurpleChatConversation *chat; |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
474 | PurpleChatUser *cb; |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
475 | |
|
32037
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
476 | char *cur, *userhost, *realname; |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
477 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
478 | PurpleChatUserFlags flags; |
|
32037
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
479 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
480 | chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
481 | if (!chat) { |
|
32037
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
482 | 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
|
483 | return; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
484 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
485 | |
|
34671
ca9b45be7a63
Renamed chat buddy to chat user in a few more places
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
486 | cb = purple_chat_conversation_find_user(chat, args[5]); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
487 | if (!cb) { |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
488 | 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
|
489 | return; |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
490 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
491 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
492 | 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
|
493 | |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
494 | /* 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
|
495 | * 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
|
496 | 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
|
497 | if (*cur == ' ') { |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
498 | cur++; |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
499 | break; |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
500 | } |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
501 | } |
|
619f32df41f1
Fix a crash when remote users have certain characters in their
Mark Doliner <markdoliner@pidgin.im>
parents:
32019
diff
changeset
|
502 | realname = g_strdup(cur); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
503 | |
|
34676
b70177e7a8b7
Removed attributes from PurpleChatUser. Used g_object_[gs]et_data()/g_object_[gs]et_data_full() instead
Ankit Vani <a@nevitus.org>
parents:
34671
diff
changeset
|
504 | g_object_set_data_full(G_OBJECT(cb), "userhost", userhost, (GDestroyNotify)g_free); |
|
b70177e7a8b7
Removed attributes from PurpleChatUser. Used g_object_[gs]et_data()/g_object_[gs]et_data_full() instead
Ankit Vani <a@nevitus.org>
parents:
34671
diff
changeset
|
505 | g_object_set_data_full(G_OBJECT(cb), "realname", realname, (GDestroyNotify)g_free); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
506 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
507 | flags = purple_chat_user_get_flags(cb); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
508 | |
|
32117
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
32037
diff
changeset
|
509 | /* 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
|
510 | * 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
|
511 | * 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
|
512 | * Comments? */ |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
513 | if (args[6][0] == 'G' && !(flags & PURPLE_CHAT_USER_AWAY)) { |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
514 | purple_chat_user_set_flags(cb, flags | PURPLE_CHAT_USER_AWAY); |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
515 | } else if(args[6][0] == 'H' && (flags & PURPLE_CHAT_USER_AWAY)) { |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
516 | purple_chat_user_set_flags(cb, flags & ~PURPLE_CHAT_USER_AWAY); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
517 | } |
|
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 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
520 | |
| 8114 | 521 | void irc_msg_list(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 522 | { | |
| 523 | if (!irc->roomlist) | |
| 524 | return; | |
| 525 | ||
| 526 | if (!strcmp(name, "321")) { | |
| 15884 | 527 | purple_roomlist_set_in_progress(irc->roomlist, TRUE); |
| 8114 | 528 | return; |
| 529 | } | |
| 530 | ||
| 531 | if (!strcmp(name, "323")) { | |
| 15884 | 532 | purple_roomlist_set_in_progress(irc->roomlist, FALSE); |
|
34932
1b74e5c63144
Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34855
diff
changeset
|
533 | g_object_unref(irc->roomlist); |
| 8114 | 534 | irc->roomlist = NULL; |
|
13667
9ebf0007d912
[gaim-migrate @ 16068]
Richard Laager <rlaager@pidgin.im>
parents:
13647
diff
changeset
|
535 | return; |
| 8114 | 536 | } |
| 537 | ||
| 538 | if (!strcmp(name, "322")) { | |
| 15884 | 539 | PurpleRoomlistRoom *room; |
|
17409
1205b4f7bb82
This performs mIRC formatting code stripping for the room list, as
Ethan Blanton <elb@pidgin.im>
parents:
17297
diff
changeset
|
540 | char *topic; |
| 8114 | 541 | |
|
22994
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
542 | 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
|
543 | 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
|
544 | 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
|
545 | } |
|
b30be6210442
Patch from sadrul to fix IRC servers which neglect to send RPL_LISTSTART
Ethan Blanton <elb@pidgin.im>
parents:
22983
diff
changeset
|
546 | |
| 15884 | 547 | room = purple_roomlist_room_new(PURPLE_ROOMLIST_ROOMTYPE_ROOM, args[1], NULL); |
| 548 | purple_roomlist_room_add_field(irc->roomlist, room, args[1]); | |
| 549 | 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
|
550 | 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
|
551 | 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
|
552 | g_free(topic); |
| 15884 | 553 | purple_roomlist_room_add(irc->roomlist, room); |
| 8114 | 554 | } |
| 555 | } | |
| 556 | ||
| 6333 | 557 | void irc_msg_topic(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 558 | { | |
| 9762 | 559 | char *chan, *topic, *msg, *nick, *tmp, *tmp2; |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
560 | PurpleChatConversation *chat; |
| 6333 | 561 | |
| 562 | if (!strcmp(name, "topic")) { | |
| 563 | chan = args[0]; | |
| 8529 | 564 | topic = irc_mirc2txt (args[1]); |
| 6333 | 565 | } else { |
| 566 | chan = args[1]; | |
| 8529 | 567 | topic = irc_mirc2txt (args[2]); |
| 6333 | 568 | } |
| 569 | ||
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
570 | chat = purple_conversations_find_chat_with_account(chan, irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
571 | if (!chat) { |
| 15884 | 572 | 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
|
573 | g_free(topic); |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
574 | return; |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
575 | } |
|
c0dd11a3254c
[gaim-migrate @ 16047]
Daniel Atallah <datallah@pidgin.im>
parents:
13638
diff
changeset
|
576 | |
| 6333 | 577 | /* If this is an interactive update, print it out */ |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10730
diff
changeset
|
578 | tmp = g_markup_escape_text(topic, -1); |
| 15884 | 579 | tmp2 = purple_markup_linkify(tmp); |
| 9762 | 580 | g_free(tmp); |
| 6333 | 581 | if (!strcmp(name, "topic")) { |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
582 | const char *current_topic = purple_chat_conversation_get_topic(chat); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
583 | if (!(current_topic != NULL && strcmp(tmp2, current_topic) == 0)) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
584 | { |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
585 | char *nick_esc; |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
586 | nick = irc_mask_nick(from); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
587 | nick_esc = g_markup_escape_text(nick, -1); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
588 | purple_chat_conversation_set_topic(chat, nick, topic); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
589 | if (*tmp2) |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
590 | 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
|
591 | else |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
592 | msg = g_strdup_printf(_("%s has cleared the topic."), nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
593 | g_free(nick_esc); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
594 | g_free(nick); |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
595 | purple_conversation_write_system_message( |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
596 | PURPLE_CONVERSATION(chat), msg, 0); |
|
13534
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
597 | g_free(msg); |
|
637a369ac8b0
[gaim-migrate @ 15910]
Richard Laager <rlaager@pidgin.im>
parents:
13525
diff
changeset
|
598 | } |
| 6333 | 599 | } else { |
|
13395
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
600 | char *chan_esc = g_markup_escape_text(chan, -1); |
|
3174cf554db2
[gaim-migrate @ 15767]
Richard Laager <rlaager@pidgin.im>
parents:
13120
diff
changeset
|
601 | 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
|
602 | g_free(chan_esc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
603 | purple_chat_conversation_set_topic(chat, NULL, topic); |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
604 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), msg, 0); |
| 6333 | 605 | g_free(msg); |
| 606 | } | |
| 9762 | 607 | g_free(tmp2); |
| 8529 | 608 | g_free(topic); |
| 6333 | 609 | } |
| 610 | ||
|
33544
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
611 | 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
|
612 | { |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
613 | PurpleChatConversation *chat; |
|
33544
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
614 | struct tm *tm; |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
615 | time_t t; |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
616 | char *msg, *timestamp, *datestamp; |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
617 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
618 | chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
619 | if (!chat) { |
|
33544
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
620 | 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
|
621 | return; |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
622 | } |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
623 | |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
624 | t = (time_t)atol(args[3]); |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
625 | if (t == 0) { |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
626 | 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
|
627 | return; |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
628 | } |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
629 | tm = localtime(&t); |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
630 | |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
631 | timestamp = g_strdup(purple_time_format(tm)); |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
632 | 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
|
633 | msg = g_strdup_printf(_("Topic for %s set by %s at %s on %s"), args[1], args[2], timestamp, datestamp); |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
634 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), |
|
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
635 | msg, PURPLE_MESSAGE_NO_LINKIFY); |
|
33544
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
636 | g_free(timestamp); |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
637 | g_free(datestamp); |
|
3780e4cb9738
Print topic setter information at channel join.
Ethan Blanton <elb@pidgin.im>
parents:
33407
diff
changeset
|
638 | g_free(msg); |
|
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 | |
| 6333 | 641 | void irc_msg_unknown(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 642 | { | |
| 15884 | 643 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 644 | char *buf; |
| 645 | ||
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
646 | g_return_if_fail(gc); |
| 6333 | 647 | |
| 648 | buf = g_strdup_printf(_("Unknown message '%s'"), args[1]); | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
649 | purple_notify_error(gc, _("Unknown message"), buf, _("The IRC server " |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
650 | "received a message it did not understand."), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
651 | purple_request_cpar_from_connection(gc)); |
| 6333 | 652 | g_free(buf); |
| 653 | } | |
| 654 | ||
| 655 | void irc_msg_names(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 656 | { | |
| 657 | char *names, *cur, *end, *tmp, *msg; | |
| 15884 | 658 | PurpleConversation *convo; |
| 6333 | 659 | |
| 660 | if (!strcmp(name, "366")) { | |
|
34625
03d62b1660fc
Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
661 | convo = purple_conversations_find_with_account(args[1], irc->account); |
| 6333 | 662 | if (!convo) { |
| 15884 | 663 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got a NAMES list for %s, which doesn't exist\n", args[1]); |
| 6333 | 664 | g_string_free(irc->names, TRUE); |
| 665 | irc->names = NULL; | |
| 666 | return; | |
| 667 | } | |
| 668 | ||
| 669 | names = cur = g_string_free(irc->names, FALSE); | |
| 670 | irc->names = NULL; | |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34676
diff
changeset
|
671 | if (g_object_get_data(G_OBJECT(convo), IRC_NAMES_FLAG)) { |
|
11026
1f13c483db00
[gaim-migrate @ 12901]
Daniel Atallah <datallah@pidgin.im>
parents:
10816
diff
changeset
|
672 | msg = g_strdup_printf(_("Users on %s: %s"), args[1], names ? names : ""); |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
673 | purple_conversation_write_system_message(convo, msg, PURPLE_MESSAGE_NO_LOG); |
| 6333 | 674 | g_free(msg); |
|
32019
15434d17f320
Fix potential crash when NAMES is empty.
James McLaughlin <jamie@lacewing-project.org>
parents:
31936
diff
changeset
|
675 | } else if (cur != NULL) { |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
676 | GList *users = NULL; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
677 | GList *flags = NULL; |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
678 | |
| 6333 | 679 | while (*cur) { |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
680 | PurpleChatUserFlags f = PURPLE_CHAT_USER_NONE; |
| 6333 | 681 | end = strchr(cur, ' '); |
| 682 | if (!end) | |
| 683 | end = cur + strlen(cur); | |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
684 | if (*cur == '@') { |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
685 | f = PURPLE_CHAT_USER_OP; |
| 6333 | 686 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
687 | } else if (*cur == '%') { |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
688 | f = PURPLE_CHAT_USER_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
689 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
690 | } else if(*cur == '+') { |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
691 | f = PURPLE_CHAT_USER_VOICE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
692 | cur++; |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
693 | } 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
|
694 | && 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
|
695 | if (*cur == '~') |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
696 | f = PURPLE_CHAT_USER_FOUNDER; |
|
15501
8547fa591578
Recognize non-standard mode characters communicated in an 005 numeric for IRC
Ethan Blanton <elb@pidgin.im>
parents:
15444
diff
changeset
|
697 | cur++; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
698 | } |
| 6333 | 699 | tmp = g_strndup(cur, end - cur); |
|
11869
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
700 | users = g_list_prepend(users, tmp); |
|
e77f2f29b09d
[gaim-migrate @ 14160]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11535
diff
changeset
|
701 | flags = g_list_prepend(flags, GINT_TO_POINTER(f)); |
| 6333 | 702 | cur = end; |
| 703 | if (*cur) | |
| 704 | cur++; | |
| 705 | } | |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
706 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
707 | if (users != NULL) { |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
708 | GList *l; |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
709 | |
|
34629
3c3bed0fd13c
Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
710 | purple_chat_conversation_add_users(PURPLE_CHAT_CONVERSATION(convo), users, NULL, flags, FALSE); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
711 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
712 | for (l = users; l != NULL; l = l->next) |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
713 | g_free(l->data); |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
714 | |
|
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
715 | g_list_free(users); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
716 | g_list_free(flags); |
|
6407
d67b6a6ba7d2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
717 | } |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
718 | |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34676
diff
changeset
|
719 | g_object_set_data(G_OBJECT(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
|
720 | GINT_TO_POINTER(TRUE)); |
| 6333 | 721 | } |
| 722 | g_free(names); | |
| 723 | } else { | |
| 724 | if (!irc->names) | |
| 725 | irc->names = g_string_new(""); | |
| 726 | ||
| 15313 | 727 | if (irc->names->len && irc->names->str[irc->names->len - 1] != ' ') |
| 728 | irc->names = g_string_append_c(irc->names, ' '); | |
| 6333 | 729 | irc->names = g_string_append(irc->names, args[3]); |
| 730 | } | |
| 731 | } | |
| 732 | ||
| 733 | void irc_msg_motd(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 734 | { | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
735 | char *escaped; |
| 6333 | 736 | |
|
15508
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
737 | 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
|
738 | 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
|
739 | 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
|
740 | 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
|
741 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
742 | } 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
|
743 | /* 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
|
744 | * 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
|
745 | 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
|
746 | return; |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
747 | } 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
|
748 | /* 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
|
749 | * (and clear the motd for good measure). */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
750 | |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
751 | 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
|
752 | g_string_free(irc->motd, TRUE); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31284
diff
changeset
|
753 | |
|
31229
4bef370d8a92
Process 422 (ERR_NOMOTD) as a valid replacement for an actual MOTD
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
30270
diff
changeset
|
754 | 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
|
755 | 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
|
756 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
757 | |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
758 | if (!irc->motd) { |
| 15884 | 759 | 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
|
760 | return; |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
761 | } |
|
51a669b06193
This should fix up IRC logins for servers which do not provide an
Ethan Blanton <elb@pidgin.im>
parents:
15501
diff
changeset
|
762 | |
|
17169
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
763 | 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
|
764 | return; |
|
daa8fdad4564
Fix up IRC connections with dircproxy by allowing 376 to indicate success.
Ethan Blanton <elb@pidgin.im>
parents:
16993
diff
changeset
|
765 | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
766 | escaped = g_markup_escape_text(args[1], -1); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
767 | g_string_append_printf(irc->motd, "%s<br>", escaped); |
|
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
768 | g_free(escaped); |
| 6333 | 769 | } |
| 770 | ||
| 10564 | 771 | void irc_msg_time(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 772 | { | |
| 15884 | 773 | PurpleConnection *gc; |
| 10564 | 774 | |
| 15884 | 775 | gc = purple_account_get_connection(irc->account); |
| 10564 | 776 | |
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
777 | g_return_if_fail(gc); |
| 10564 | 778 | |
| 15884 | 779 | purple_notify_message(gc, PURPLE_NOTIFY_MSG_INFO, _("Time Response"), |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
780 | _("The IRC server's local time is:"), args[2], NULL, NULL, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
781 | purple_request_cpar_from_connection(gc)); |
| 10564 | 782 | } |
| 783 | ||
| 7877 | 784 | void irc_msg_nochan(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 785 | { | |
| 15884 | 786 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 7877 | 787 | |
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
788 | g_return_if_fail(gc); |
| 7877 | 789 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
790 | purple_notify_error(gc, NULL, _("No such channel"), args[1], |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
791 | purple_request_cpar_from_connection(gc)); |
| 7877 | 792 | } |
| 793 | ||
| 6333 | 794 | void irc_msg_nonick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 795 | { | |
| 15884 | 796 | PurpleConnection *gc; |
| 797 | PurpleConversation *convo; | |
| 6333 | 798 | |
|
34625
03d62b1660fc
Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
799 | convo = purple_conversations_find_with_account(args[1], irc->account); |
| 6333 | 800 | if (convo) { |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
801 | purple_conversation_write_system_message(convo, |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
802 | PURPLE_IS_IM_CONVERSATION(convo) ? _("User is not logged in") : _("no such channel"), |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
803 | PURPLE_MESSAGE_NO_LOG); |
|
34629
3c3bed0fd13c
Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
804 | |
| 6333 | 805 | } else { |
| 15884 | 806 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 807 | return; |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
808 | purple_notify_error(gc, NULL, _("No such nick or channel"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
809 | args[1], purple_request_cpar_from_connection(gc)); |
| 6333 | 810 | } |
| 811 | ||
| 15884 | 812 | if (irc->whois.nick && !purple_utf8_strcasecmp(irc->whois.nick, args[1])) { |
| 6333 | 813 | g_free(irc->whois.nick); |
| 814 | irc->whois.nick = NULL; | |
| 815 | } | |
| 816 | } | |
| 817 | ||
| 818 | void irc_msg_nosend(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 819 | { | |
| 15884 | 820 | PurpleConnection *gc; |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
821 | PurpleChatConversation *chat; |
| 6333 | 822 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
823 | chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
824 | if (chat) { |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
825 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), args[2], |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
826 | PURPLE_MESSAGE_NO_LOG); |
| 6333 | 827 | } else { |
| 15884 | 828 | if ((gc = purple_account_get_connection(irc->account)) == NULL) |
| 6333 | 829 | return; |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
830 | purple_notify_error(gc, NULL, _("Could not send"), args[2], |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
831 | purple_request_cpar_from_connection(gc)); |
| 6333 | 832 | } |
| 833 | } | |
| 834 | ||
| 835 | void irc_msg_notinchan(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 836 | { | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
837 | PurpleChatConversation *chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
| 6333 | 838 | |
| 15884 | 839 | purple_debug(PURPLE_DEBUG_INFO, "irc", "We're apparently not in %s, but tried to use it\n", args[1]); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
840 | if (chat) { |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
841 | /*g_slist_remove(irc->gc->buddy_chats, chat); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
842 | purple_conversation_set_account(chat, NULL);*/ |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
843 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), |
|
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
844 | args[2], PURPLE_MESSAGE_NO_LOG); |
| 6333 | 845 | } |
| 846 | } | |
| 847 | ||
| 848 | void irc_msg_notop(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 849 | { | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
850 | PurpleChatConversation *chat; |
| 6333 | 851 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
852 | chat = purple_conversations_find_chat_with_account(args[1], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
853 | if (!chat) |
| 6333 | 854 | return; |
| 855 | ||
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
856 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), args[2], 0); |
| 6333 | 857 | } |
| 858 | ||
| 859 | void irc_msg_invite(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 860 | { | |
| 15884 | 861 | 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
|
862 | GHashTable *components; |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
863 | gchar *nick; |
| 6333 | 864 | |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
865 | g_return_if_fail(gc); |
|
22876
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
866 | |
|
824abbeefcc2
Avoid allocating and freeing stuff unnecessarily.
Daniel Atallah <datallah@pidgin.im>
parents:
22870
diff
changeset
|
867 | 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
|
868 | nick = irc_mask_nick(from); |
| 6333 | 869 | |
|
22870
25b482330fec
Use g_strdup to match the subsequent g_free.
Daniel Atallah <datallah@pidgin.im>
parents:
22798
diff
changeset
|
870 | g_hash_table_insert(components, g_strdup("channel"), g_strdup(args[1])); |
| 6333 | 871 | |
| 35501 | 872 | purple_serv_got_chat_invite(gc, args[1], nick, NULL, components); |
| 6333 | 873 | g_free(nick); |
| 874 | } | |
| 875 | ||
| 876 | void irc_msg_inviteonly(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 877 | { | |
| 15884 | 878 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 879 | char *buf; |
| 880 | ||
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
881 | g_return_if_fail(gc); |
| 6333 | 882 | |
| 883 | buf = g_strdup_printf(_("Joining %s requires an invitation."), args[1]); | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
884 | purple_notify_error(gc, _("Invitation only"), _("Invitation only"), buf, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
885 | purple_request_cpar_from_connection(gc)); |
| 6333 | 886 | g_free(buf); |
| 887 | } | |
| 888 | ||
| 889 | void irc_msg_ison(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 890 | { | |
| 891 | char **nicks; | |
| 892 | struct irc_buddy *ib; | |
| 893 | int i; | |
| 894 | ||
| 895 | nicks = g_strsplit(args[1], " ", -1); | |
| 896 | for (i = 0; nicks[i]; i++) { | |
| 897 | if ((ib = g_hash_table_lookup(irc->buddies, (gconstpointer)nicks[i])) == NULL) { | |
| 898 | continue; | |
| 899 | } | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
900 | ib->new_online_status = TRUE; |
| 6333 | 901 | } |
| 6350 | 902 | g_strfreev(nicks); |
| 903 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
904 | if (irc->ison_outstanding) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
905 | irc_buddy_query(irc); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
906 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
907 | if (!irc->ison_outstanding) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
908 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_status, (gpointer)irc); |
| 6333 | 909 | } |
| 910 | ||
| 911 | static void irc_buddy_status(char *name, struct irc_buddy *ib, struct irc_conn *irc) | |
| 912 | { | |
| 15884 | 913 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34706
diff
changeset
|
914 | PurpleBuddy *buddy = purple_blist_find_buddy(irc->account, name); |
| 6333 | 915 | |
| 916 | if (!gc || !buddy) | |
| 917 | return; | |
| 918 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
919 | if (ib->online && !ib->new_online_status) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
920 | purple_protocol_got_user_status(irc->account, name, "offline", NULL); |
| 6333 | 921 | ib->online = FALSE; |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
31229
diff
changeset
|
922 | } else if (!ib->online && ib->new_online_status) { |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
923 | purple_protocol_got_user_status(irc->account, name, "available", NULL); |
| 6333 | 924 | ib->online = TRUE; |
| 925 | } | |
| 926 | } | |
| 927 | ||
| 928 | void irc_msg_join(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 929 | { | |
| 15884 | 930 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34169
diff
changeset
|
931 | PurpleChatConversation *chat; |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
932 | PurpleChatUser *cb; |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
933 | |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
934 | char *nick, *userhost, *buf; |
| 9238 | 935 | struct irc_buddy *ib; |
| 6333 | 936 | static int id = 1; |
| 937 | ||
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
938 | g_return_if_fail(gc); |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
939 | |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
940 | nick = irc_mask_nick(from); |
| 6333 | 941 | |
| 15884 | 942 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 6333 | 943 | /* We are joining a channel for the first time */ |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35297
diff
changeset
|
944 | purple_serv_got_joined_chat(gc, id++, args[0]); |
| 6333 | 945 | g_free(nick); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
946 | chat = purple_conversations_find_chat_with_account(args[0], irc->account); |
|
15516
07e9a078cc06
This makes IRC /names handling generally more robust, as well as
Ethan Blanton <elb@pidgin.im>
parents:
15508
diff
changeset
|
947 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
948 | if (chat == NULL) { |
| 15884 | 949 | purple_debug_error("irc", "tried to join %s but couldn't\n", args[0]); |
| 13938 | 950 | return; |
| 951 | } | |
|
34678
40a30f74a7b8
Removed purple_conversation_[gs]et_data(). Used g_object_[gs]et_data() instead.
Ankit Vani <a@nevitus.org>
parents:
34676
diff
changeset
|
952 | g_object_set_data(G_OBJECT(chat), 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
|
953 | GINT_TO_POINTER(FALSE)); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
954 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
955 | // 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
|
956 | 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
|
957 | irc_send(irc, buf); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
958 | g_free(buf); |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
959 | |
|
20194
fee478bb059b
applied changes from 26c05ed157a02643cbb12b04045422b123312bcf
Ethan Blanton <elb@pidgin.im>
parents:
19859
diff
changeset
|
960 | /* 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
|
961 | * 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
|
962 | * behavior both for the /join and auto-join cases. */ |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
963 | /* purple_conversation_present(chat); */ |
| 6333 | 964 | return; |
| 965 | } | |
| 966 | ||
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
967 | chat = purple_conversations_find_chat_with_account(args[0], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
968 | if (chat == NULL) { |
| 15884 | 969 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "JOIN for %s failed\n", args[0]); |
| 6333 | 970 | g_free(nick); |
| 971 | return; | |
| 972 | } | |
| 973 | ||
| 974 | userhost = irc_mask_userhost(from); | |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
975 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
976 | purple_chat_conversation_add_user(chat, nick, userhost, PURPLE_CHAT_USER_NONE, TRUE); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
977 | |
|
34671
ca9b45be7a63
Renamed chat buddy to chat user in a few more places
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
978 | cb = purple_chat_conversation_find_user(chat, nick); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
979 | |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
980 | if (cb) { |
|
34676
b70177e7a8b7
Removed attributes from PurpleChatUser. Used g_object_[gs]et_data()/g_object_[gs]et_data_full() instead
Ankit Vani <a@nevitus.org>
parents:
34671
diff
changeset
|
981 | g_object_set_data_full(G_OBJECT(cb), "userhost", userhost, (GDestroyNotify)g_free); |
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
982 | } |
|
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
983 | |
| 9238 | 984 | 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
|
985 | ib->new_online_status = TRUE; |
| 9238 | 986 | irc_buddy_status(nick, ib, irc); |
| 987 | } | |
| 988 | ||
| 6333 | 989 | g_free(nick); |
| 990 | } | |
| 991 | ||
| 992 | void irc_msg_kick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 993 | { | |
| 15884 | 994 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
995 | PurpleChatConversation *chat = purple_conversations_find_chat_with_account(args[0], irc->account); |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
996 | char *nick, *buf; |
| 6333 | 997 | |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
998 | g_return_if_fail(gc); |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
999 | |
|
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
1000 | nick = irc_mask_nick(from); |
| 6333 | 1001 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1002 | if (!chat) { |
|
30270
8380aae8b132
I before E, except after C
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
29286
diff
changeset
|
1003 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Received a KICK for unknown channel %s\n", args[0]); |
| 6333 | 1004 | g_free(nick); |
| 1005 | return; | |
| 1006 | } | |
| 1007 | ||
| 15884 | 1008 | 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
|
1009 | buf = g_strdup_printf(_("You have been kicked by %s: (%s)"), nick, args[2]); |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
1010 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0); |
| 6333 | 1011 | g_free(buf); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35297
diff
changeset
|
1012 | purple_serv_got_chat_left(gc, purple_chat_conversation_get_id(chat)); |
| 6333 | 1013 | } else { |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
1014 | buf = g_strdup_printf(_("Kicked by %s (%s)"), nick, args[2]); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1015 | purple_chat_conversation_remove_user(chat, args[1], buf); |
| 6333 | 1016 | g_free(buf); |
| 1017 | } | |
| 1018 | ||
| 1019 | g_free(nick); | |
| 1020 | return; | |
| 1021 | } | |
| 1022 | ||
| 1023 | void irc_msg_mode(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1024 | { | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1025 | PurpleChatConversation *chat; |
| 6333 | 1026 | char *nick = irc_mask_nick(from), *buf; |
| 1027 | ||
| 1028 | if (*args[0] == '#' || *args[0] == '&') { /* Channel */ | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1029 | char *escaped; |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1030 | chat = purple_conversations_find_chat_with_account(args[0], irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1031 | if (!chat) { |
| 15884 | 1032 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "MODE received for %s, which we are not in\n", args[0]); |
| 6333 | 1033 | g_free(nick); |
| 1034 | return; | |
| 1035 | } | |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1036 | 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
|
1037 | buf = g_strdup_printf(_("mode (%s %s) by %s"), args[1], escaped ? escaped : "", nick); |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
1038 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), buf, 0); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1039 | g_free(escaped); |
| 6333 | 1040 | g_free(buf); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1041 | if(args[2]) { |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1042 | PurpleChatUser *cb; |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1043 | PurpleChatUserFlags newflag, flags; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1044 | char *mcur, *cur, *end, *user; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1045 | gboolean add = FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1046 | mcur = args[1]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1047 | cur = args[2]; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1048 | while (*cur && *mcur) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1049 | if ((*mcur == '+') || (*mcur == '-')) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1050 | add = (*mcur == '+') ? TRUE : FALSE; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1051 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1052 | continue; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1053 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1054 | end = strchr(cur, ' '); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1055 | if (!end) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1056 | end = cur + strlen(cur); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1057 | user = g_strndup(cur, end - cur); |
|
34671
ca9b45be7a63
Renamed chat buddy to chat user in a few more places
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1058 | cb = purple_chat_conversation_find_user(chat, user); |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1059 | flags = purple_chat_user_get_flags(cb); |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1060 | newflag = PURPLE_CHAT_USER_NONE; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1061 | if (*mcur == 'o') |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1062 | newflag = PURPLE_CHAT_USER_OP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1063 | else if (*mcur =='h') |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1064 | newflag = PURPLE_CHAT_USER_HALFOP; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1065 | else if (*mcur == 'v') |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1066 | newflag = PURPLE_CHAT_USER_VOICE; |
|
22471
aa32d9ed764d
Give IRC channel owners the founder icon on networks that report supporting
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21736
diff
changeset
|
1067 | 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
|
1068 | && strchr(irc->mode_chars, '~') && (*mcur == 'q')) |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1069 | newflag = PURPLE_CHAT_USER_FOUNDER; |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1070 | if (newflag) { |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1071 | if (add) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1072 | flags |= newflag; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1073 | else |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1074 | flags &= ~newflag; |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34653
diff
changeset
|
1075 | purple_chat_user_set_flags(cb, flags); |
|
9554
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1076 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1077 | g_free(user); |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1078 | cur = end; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1079 | if (*cur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1080 | cur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1081 | if (*mcur) |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1082 | mcur++; |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1083 | } |
|
1609ba3612c3
[gaim-migrate @ 10387]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9518
diff
changeset
|
1084 | } |
| 6333 | 1085 | } else { /* User */ |
| 1086 | } | |
| 1087 | g_free(nick); | |
| 1088 | } | |
| 1089 | ||
| 1090 | void irc_msg_nick(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1091 | { | |
| 15884 | 1092 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1093 | PurpleIMConversation *im; |
| 6333 | 1094 | GSList *chats; |
| 1095 | char *nick = irc_mask_nick(from); | |
| 1096 | ||
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1097 | 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
|
1098 | |
| 6333 | 1099 | if (!gc) { |
| 1100 | g_free(nick); | |
| 1101 | return; | |
| 1102 | } | |
|
34750
826c1611ef90
Refactored protocols to use the initial GObject connection API.
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
1103 | chats = purple_connection_get_active_chats(gc); |
| 6333 | 1104 | |
| 15884 | 1105 | if (!purple_utf8_strcasecmp(nick, purple_connection_get_display_name(gc))) { |
| 1106 | purple_connection_set_display_name(gc, args[0]); | |
| 6333 | 1107 | } |
| 1108 | ||
| 1109 | while (chats) { | |
|
34629
3c3bed0fd13c
Refactored gg and irc protocols to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
1110 | PurpleChatConversation *chat = PURPLE_CHAT_CONVERSATION(chats->data); |
| 9593 | 1111 | /* This is ugly ... */ |
|
34653
88ae47a7d595
Updated protocols for the API changes
Ankit Vani <a@nevitus.org>
parents:
34632
diff
changeset
|
1112 | if (purple_chat_conversation_has_user(chat, nick)) |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34169
diff
changeset
|
1113 | purple_chat_conversation_rename_user(chat, nick, args[0]); |
| 6333 | 1114 | chats = chats->next; |
| 1115 | } | |
| 10617 | 1116 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1117 | im = purple_conversations_find_im_with_account(nick, |
| 10617 | 1118 | irc->account); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1119 | if (im != NULL) |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1120 | purple_conversation_set_name(PURPLE_CONVERSATION(im), args[0]); |
| 10617 | 1121 | |
| 6333 | 1122 | g_free(nick); |
| 1123 | } | |
| 1124 | ||
| 10633 | 1125 | void irc_msg_badnick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1126 | { | |
| 15884 | 1127 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1128 | if (purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED) { |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1129 | purple_notify_error(gc, _("Invalid nickname"), _("Invalid " |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1130 | "nickname"), _("Your selected nickname was rejected by " |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1131 | "the server. It probably contains invalid characters."), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1132 | purple_request_cpar_from_connection(gc)); |
| 13057 | 1133 | |
| 1134 | } else { | |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1135 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1136 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1137 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1138 | _("Your selected account name was rejected by the server. It probably contains invalid characters."))); |
| 13057 | 1139 | } |
| 10633 | 1140 | } |
| 1141 | ||
| 6333 | 1142 | void irc_msg_nickused(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1143 | { | |
| 1144 | char *newnick, *buf, *end; | |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1145 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6333 | 1146 | |
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
1147 | if (gc && purple_connection_get_state(gc) == PURPLE_CONNECTION_CONNECTED) { |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1148 | /* 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
|
1149 | has not been successfully completed. If it has, just |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1150 | 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
|
1151 | 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
|
1152 | irc->reqnick); |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1153 | purple_notify_error(gc, _("Nickname in use"), _("Nickname in " |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1154 | "use"), buf, purple_request_cpar_from_connection(gc)); |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1155 | g_free(buf); |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1156 | g_free(irc->reqnick); |
|
25706
cbaf3afc17c6
applied changes from 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25705
diff
changeset
|
1157 | irc->reqnick = NULL; |
|
25707
e1b69b86aa3c
Hand-pluck of 68cb5581c551eabb57bcdf437642ee9e6786bc64
Ethan Blanton <elb@pidgin.im>
parents:
25706
diff
changeset
|
1158 | return; |
|
25705
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1159 | } |
|
8bb42bb17cc8
applied changes from 4b0e16d96a9ee2554770c4400445bee7ceb49d9a
Ethan Blanton <elb@pidgin.im>
parents:
25703
diff
changeset
|
1160 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1161 | 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
|
1162 | 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
|
1163 | else |
|
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1164 | newnick = g_strdup_printf("%s0", args[1]); |
| 6333 | 1165 | end = newnick + strlen(newnick) - 1; |
|
11386
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1166 | /* try fallbacks */ |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1167 | if((*end < '9') && (*end >= '1')) { |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1168 | *end = *end + 1; |
|
89c0c029ecfd
[gaim-migrate @ 13614]
Thomas Butter <tbutter@users.sourceforge.net>
parents:
11338
diff
changeset
|
1169 | } else *end = '1'; |
| 6333 | 1170 | |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22994
diff
changeset
|
1171 | 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
|
1172 | 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
|
1173 | 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
|
1174 | |
|
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
|
1175 | 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
|
1176 | 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
|
1177 | |
| 6333 | 1178 | buf = irc_format(irc, "vn", "NICK", newnick); |
| 1179 | irc_send(irc, buf); | |
| 1180 | g_free(buf); | |
| 1181 | } | |
| 1182 | ||
| 1183 | void irc_msg_notice(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1184 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1185 | irc_msg_handle_privmsg(irc, name, from, args[0], args[1], TRUE); |
| 6333 | 1186 | } |
| 1187 | ||
| 6718 | 1188 | void irc_msg_nochangenick(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1189 | { | |
| 15884 | 1190 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6718 | 1191 | |
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
1192 | g_return_if_fail(gc); |
| 6718 | 1193 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1194 | purple_notify_error(gc, _("Cannot change nick"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1195 | _("Could not change nick"), args[2], |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1196 | purple_request_cpar_from_connection(gc)); |
| 6718 | 1197 | } |
| 1198 | ||
| 6333 | 1199 | void irc_msg_part(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1200 | { | |
| 15884 | 1201 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1202 | PurpleChatConversation *chat; |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1203 | char *nick, *msg, *channel; |
| 6333 | 1204 | |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
1205 | g_return_if_fail(gc); |
| 6333 | 1206 | |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1207 | /* 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
|
1208 | * 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
|
1209 | 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
|
1210 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1211 | chat = purple_conversations_find_chat_with_account(channel, irc->account); |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1212 | if (!chat) { |
|
22983
861402a1fe68
Fix IRC handling of PART without a part message on Undernet IRCds.
Ethan Blanton <elb@pidgin.im>
parents:
22876
diff
changeset
|
1213 | purple_debug(PURPLE_DEBUG_INFO, "irc", "Got a PART on %s, which doesn't exist -- probably closed\n", channel); |
| 6333 | 1214 | return; |
| 1215 | } | |
| 1216 | ||
| 1217 | nick = irc_mask_nick(from); | |
| 15884 | 1218 | 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
|
1219 | char *escaped = args[1] ? g_markup_escape_text(args[1], -1) : NULL; |
| 8186 | 1220 | 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
|
1221 | (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
|
1222 | (escaped && *escaped) ? escaped : ""); |
|
12855
5215e8d13a49
[gaim-migrate @ 15206]
Richard Laager <rlaager@pidgin.im>
parents:
12216
diff
changeset
|
1223 | g_free(escaped); |
|
36088
4c386387f6f3
Switch purple_conversation_write_message to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36084
diff
changeset
|
1224 | purple_conversation_write_system_message(PURPLE_CONVERSATION(chat), msg, 0); |
| 6333 | 1225 | g_free(msg); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35297
diff
changeset
|
1226 | purple_serv_got_chat_left(gc, purple_chat_conversation_get_id(chat)); |
| 6333 | 1227 | } else { |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1228 | msg = args[1] ? irc_mirc2txt(args[1]) : NULL; |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1229 | purple_chat_conversation_remove_user(chat, nick, msg); |
|
22795
2b1d41a575f5
Strip mIRC formatting codes from PART and QUIT messages.
Ethan Blanton <elb@pidgin.im>
parents:
22471
diff
changeset
|
1230 | g_free(msg); |
| 6333 | 1231 | } |
| 1232 | g_free(nick); | |
| 1233 | } | |
| 1234 | ||
| 1235 | void irc_msg_ping(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1236 | { | |
| 1237 | char *buf; | |
| 1238 | ||
| 1239 | buf = irc_format(irc, "v:", "PONG", args[0]); | |
| 1240 | irc_send(irc, buf); | |
| 1241 | g_free(buf); | |
| 1242 | } | |
| 1243 | ||
| 1244 | void irc_msg_pong(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1245 | { | |
| 15884 | 1246 | PurpleConversation *convo; |
| 1247 | PurpleConnection *gc; | |
| 6333 | 1248 | char **parts, *msg; |
| 1249 | time_t oldstamp; | |
| 1250 | ||
| 1251 | parts = g_strsplit(args[1], " ", 2); | |
| 1252 | ||
| 1253 | if (!parts[0] || !parts[1]) { | |
| 1254 | g_strfreev(parts); | |
| 1255 | return; | |
| 1256 | } | |
| 1257 | ||
| 1258 | if (sscanf(parts[1], "%lu", &oldstamp) != 1) { | |
| 1259 | msg = g_strdup(_("Error: invalid PONG from server")); | |
| 1260 | } else { | |
| 6350 | 1261 | msg = g_strdup_printf(_("PING reply -- Lag: %lu seconds"), time(NULL) - oldstamp); |
| 6333 | 1262 | } |
| 1263 | ||
|
34625
03d62b1660fc
Refactor code to remove conversation type from some instances of purple_conversations_find_with_account()
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
1264 | convo = purple_conversations_find_with_account(parts[0], irc->account); |
| 6333 | 1265 | g_strfreev(parts); |
| 1266 | if (convo) { | |
|
36084
2172bd6dad3e
Add purple_conversation_write_system_message
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35688
diff
changeset
|
1267 | purple_conversation_write_system_message(convo, msg, PURPLE_MESSAGE_NO_LOG); |
| 6333 | 1268 | } else { |
| 15884 | 1269 | gc = purple_account_get_connection(irc->account); |
| 6333 | 1270 | if (!gc) { |
| 1271 | g_free(msg); | |
| 1272 | return; | |
| 1273 | } | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1274 | purple_notify_info(gc, NULL, "PONG", msg, |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1275 | purple_request_cpar_from_connection(gc)); |
| 6333 | 1276 | } |
| 1277 | g_free(msg); | |
| 1278 | } | |
| 1279 | ||
| 1280 | void irc_msg_privmsg(struct irc_conn *irc, const char *name, const char *from, char **args) | |
| 1281 | { | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1282 | 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
|
1283 | } |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1284 | |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1285 | 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
|
1286 | { |
| 15884 | 1287 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1288 | PurpleChatConversation *chat; |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1289 | char *tmp; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1290 | char *msg; |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1291 | char *nick; |
| 6333 | 1292 | |
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1293 | if (!gc) |
| 6333 | 1294 | return; |
| 1295 | ||
|
13525
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1296 | nick = irc_mask_nick(from); |
|
e5dc8090a9b0
[gaim-migrate @ 15900]
Richard Laager <rlaager@pidgin.im>
parents:
13523
diff
changeset
|
1297 | tmp = irc_parse_ctcp(irc, nick, to, rawmsg, notice); |
| 6333 | 1298 | if (!tmp) { |
| 1299 | g_free(nick); | |
| 1300 | return; | |
| 1301 | } | |
| 8163 | 1302 | |
|
20217
9249f67ef61e
applied changes from 6c08c628ee64e16c824829c25befc0ca09338f9d
Luke Schierer <lschiere@pidgin.im>
parents:
20194
diff
changeset
|
1303 | msg = irc_escape_privmsg(tmp, -1); |
| 6333 | 1304 | g_free(tmp); |
| 8163 | 1305 | |
| 1306 | tmp = irc_mirc2html(msg); | |
| 1307 | g_free(msg); | |
| 1308 | msg = tmp; | |
| 6333 | 1309 | if (notice) { |
| 1310 | tmp = g_strdup_printf("(notice) %s", msg); | |
| 1311 | g_free(msg); | |
| 1312 | msg = tmp; | |
| 1313 | } | |
| 1314 | ||
| 15884 | 1315 | if (!purple_utf8_strcasecmp(to, purple_connection_get_display_name(gc))) { |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35297
diff
changeset
|
1316 | purple_serv_got_im(gc, nick, msg, 0, time(NULL)); |
| 6333 | 1317 | } else { |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1318 | chat = purple_conversations_find_chat_with_account(irc_nick_skip_mode(irc, to), irc->account); |
|
36092
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
1319 | if (chat) { |
|
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
1320 | purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(chat), |
|
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
1321 | nick, PURPLE_MESSAGE_RECV, msg, time(NULL)); |
|
cf0a11121049
Fix message flags
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36089
diff
changeset
|
1322 | } else |
| 15884 | 1323 | 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
|
1324 | notice ? "NOTICE" : "PRIVMSG", to); |
| 6333 | 1325 | } |
| 1326 | g_free(msg); | |
| 1327 | g_free(nick); | |
| 1328 | } | |
| 1329 | ||
| 6714 | 1330 | void irc_msg_regonly(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1331 | { | |
| 15884 | 1332 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 6714 | 1333 | char *msg; |
| 1334 | ||
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
1335 | g_return_if_fail(gc); |
| 6714 | 1336 | |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34629
diff
changeset
|
1337 | if (purple_conversations_find_chat_with_account(args[1], 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
|
1338 | /* 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
|
1339 | * 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
|
1340 | * 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
|
1341 | * 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
|
1342 | return; |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1343 | } |
|
4541badae267
This should suppress an annoying 477 numeric on channel joins if you
Ethan Blanton <elb@pidgin.im>
parents:
17170
diff
changeset
|
1344 | |
|
16993
536c1485c139
Handle channel joins when registration is required more gracefully.
Ethan Blanton <elb@pidgin.im>
parents:
16893
diff
changeset
|
1345 | msg = g_strdup_printf(_("Cannot join %s: Registration is required."), args[1]); |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1346 | purple_notify_error(gc, _("Cannot join channel"), msg, args[2], |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1347 | purple_request_cpar_from_connection(gc)); |
| 6714 | 1348 | g_free(msg); |
| 1349 | } | |
| 1350 | ||
| 6333 | 1351 | void irc_msg_quit(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1352 | { | |
| 15884 | 1353 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
| 9238 | 1354 | struct irc_buddy *ib; |
| 6333 | 1355 | char *data[2]; |
| 1356 | ||
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
1357 | g_return_if_fail(gc); |
| 6333 | 1358 | |
| 1359 | data[0] = irc_mask_nick(from); | |
| 1360 | data[1] = args[0]; | |
| 1361 | /* XXX this should have an API, I shouldn't grab this directly */ | |
|
34750
826c1611ef90
Refactored protocols to use the initial GObject connection API.
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
1362 | g_slist_foreach(purple_connection_get_active_chats(gc), |
|
826c1611ef90
Refactored protocols to use the initial GObject connection API.
Ankit Vani <a@nevitus.org>
parents:
34746
diff
changeset
|
1363 | (GFunc)irc_chat_remove_buddy, data); |
| 9238 | 1364 | |
| 1365 | 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
|
1366 | ib->new_online_status = FALSE; |
| 9238 | 1367 | irc_buddy_status(data[0], ib, irc); |
| 1368 | } | |
| 6333 | 1369 | g_free(data[0]); |
| 1370 | ||
| 1371 | return; | |
| 1372 | } | |
| 1373 | ||
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1374 | 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
|
1375 | { |
| 15884 | 1376 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1377 | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1378 | purple_notify_error(gc, NULL, _("Nick or channel is temporarily " |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1379 | "unavailable."), args[1], |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1380 | purple_request_cpar_from_connection(gc)); |
|
10712
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1381 | } |
|
2aded9e9abd4
[gaim-migrate @ 12306]
Richard Laager <rlaager@pidgin.im>
parents:
10659
diff
changeset
|
1382 | |
| 6333 | 1383 | void irc_msg_wallops(struct irc_conn *irc, const char *name, const char *from, char **args) |
| 1384 | { | |
| 15884 | 1385 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
10774
f4238d6312ff
[gaim-migrate @ 12383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10751
diff
changeset
|
1386 | char *nick, *msg; |
| 6333 | 1387 | |
|
35254
7d0fb0c6d8d4
Add back some checks for gc!=NULL.
Mark Doliner <mark@kingant.net>
parents:
35250
diff
changeset
|
1388 | g_return_if_fail(gc); |
| 6333 | 1389 | |
| 1390 | nick = irc_mask_nick(from); | |
| 1391 | msg = g_strdup_printf (_("Wallops from %s"), nick); | |
| 1392 | g_free(nick); | |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1393 | purple_notify_info(gc, NULL, msg, args[0], |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34169
diff
changeset
|
1394 | purple_request_cpar_from_connection(gc)); |
| 6333 | 1395 | g_free(msg); |
| 1396 | } | |
| 1397 | ||
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1398 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1399 | static int |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1400 | 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
|
1401 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1402 | 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
|
1403 | sasl_secret_t *sasl_secret; |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1404 | const char *pw; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1405 | size_t len; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1406 | |
|
34169
488d3280e151
Replace g_free with purple_str_wipe, correct line breaking
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34149
diff
changeset
|
1407 | pw = purple_connection_get_password(purple_account_get_connection( |
|
488d3280e151
Replace g_free with purple_str_wipe, correct line breaking
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
34149
diff
changeset
|
1408 | irc->account)); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1409 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1410 | if (!conn || !secret || id != SASL_CB_PASS) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1411 | return SASL_BADPARAM; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1412 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1413 | len = strlen(pw); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1414 | /* 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
|
1415 | /* 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
|
1416 | 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
|
1417 | if (!sasl_secret) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1418 | return SASL_NOMEM; |
|
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 | sasl_secret->len = len; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1421 | strcpy((char*)sasl_secret->data, pw); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1422 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1423 | *secret = sasl_secret; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1424 | return SASL_OK; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1425 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1426 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1427 | static int |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1428 | 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
|
1429 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1430 | if(level <= SASL_LOG_TRACE) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1431 | purple_debug_info("sasl", "%s\n", message); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1432 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1433 | return SASL_OK; |
|
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 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1436 | static int |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1437 | 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
|
1438 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1439 | struct irc_conn *irc = ctx; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1440 | 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
|
1441 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1442 | switch(id) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1443 | case SASL_CB_AUTHNAME: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1444 | *res = purple_connection_get_display_name(gc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1445 | break; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1446 | case SASL_CB_USER: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1447 | *res = ""; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1448 | break; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1449 | default: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1450 | return SASL_BADPARAM; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1451 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1452 | if (len) *len = strlen((char *)*res); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1453 | return SASL_OK; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1454 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1455 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1456 | static void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1457 | 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
|
1458 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1459 | int ret = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1460 | char *buf; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1461 | sasl_security_properties_t secprops; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1462 | PurpleAccount *account = irc->account; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1463 | PurpleConnection *gc = purple_account_get_connection(account); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1464 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1465 | gboolean again = FALSE; |
|
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 | /* Set up security properties and options */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1468 | secprops.min_ssf = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1469 | secprops.security_flags = SASL_SEC_NOANONYMOUS; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1470 | |
|
37892
0c19895fef84
irc: Fix compiling no member gsc in irc_conn
Mike Ruprecht <cmaiku@gmail.com>
parents:
37148
diff
changeset
|
1471 | if (!G_IS_TLS_CONNECTION(irc->conn)) { |
|
35688
3d727b2e6f82
Fix most of libpurple clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35578
diff
changeset
|
1472 | gboolean plaintext; |
|
3d727b2e6f82
Fix most of libpurple clang scan-build warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35578
diff
changeset
|
1473 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1474 | secprops.max_ssf = -1; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1475 | secprops.maxbufsize = 4096; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1476 | 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
|
1477 | if (!plaintext) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1478 | secprops.security_flags |= SASL_SEC_NOPLAINTEXT; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1479 | } else { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1480 | secprops.max_ssf = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1481 | secprops.maxbufsize = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1482 | } |
|
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 | secprops.property_names = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1485 | secprops.property_values = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1486 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1487 | do { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1488 | again = FALSE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1489 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1490 | 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
|
1491 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1492 | if (ret != SASL_OK) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1493 | purple_debug_error("irc", "sasl_client_new failed: %d\n", ret); |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1494 | purple_connection_take_error(gc, g_error_new( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1495 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1496 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1497 | ("Failed to initialize SASL authentication: %s"), |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1498 | sasl_errdetail(irc->sasl_conn))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1499 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1500 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1501 | |
| 34977 | 1502 | sasl_setprop(irc->sasl_conn, SASL_AUTH_EXTERNAL, purple_account_get_username(irc->account)); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1503 | 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
|
1504 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1505 | 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
|
1506 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1507 | switch (ret) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1508 | case SASL_OK: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1509 | case SASL_CONTINUE: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1510 | irc->mech_works = FALSE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1511 | break; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1512 | case SASL_NOMECH: |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1513 | purple_connection_take_error(gc, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1514 | g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1515 | PURPLE_CONNECTION_ERROR, |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1516 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1517 | _("SASL authentication failed: No worthy authentication mechanisms found."))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1518 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1519 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1520 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1521 | case SASL_BADPARAM: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1522 | case SASL_NOMEM: |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1523 | purple_connection_take_error(gc, g_error_new( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1524 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1525 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1526 | _("SASL authentication failed: %s"), |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1527 | sasl_errdetail(irc->sasl_conn))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1528 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1529 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1530 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1531 | default: |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1532 | 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
|
1533 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1534 | if (irc->current_mech && *irc->current_mech) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1535 | char *pos; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1536 | 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
|
1537 | 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
|
1538 | 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
|
1539 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1540 | /* 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
|
1541 | if ((irc->sasl_mechs->str)[index] == ' ') { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1542 | 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
|
1543 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1544 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1545 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1546 | again = TRUE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1547 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1548 | irc_sasl_finish(irc); |
|
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 | } while (again); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1551 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1552 | 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
|
1553 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1554 | 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
|
1555 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1556 | g_free(buf); |
|
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 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1559 | /* SASL authentication */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1560 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1561 | 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
|
1562 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1563 | int ret = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1564 | int id = 0; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1565 | 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
|
1566 | const char *mech_list = NULL; |
|
38135
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1567 | char *pos; |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1568 | size_t index; |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1569 | |
|
35248
9f132a6855cd
IRC: fill required command parameter counts (part 1)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
33803
diff
changeset
|
1570 | if (strncmp(args[2], "sasl ", 6)) |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1571 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1572 | if (strncmp(args[1], "ACK", 4)) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1573 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1574 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1575 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1576 | _("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
|
1577 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1578 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1579 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1580 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1581 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1582 | if ((ret = sasl_client_init(NULL)) != SASL_OK) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1583 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1584 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1585 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1586 | _("SASL authentication failed: Initializing SASL failed."))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1587 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1588 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1589 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1590 | 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
|
1591 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1592 | irc->sasl_cb[id].id = SASL_CB_AUTHNAME; |
|
33891
8b4a41b6fe60
Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
1593 | irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_simple; /* sasl_getsimple_t */ |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1594 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1595 | id++; |
|
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 | irc->sasl_cb[id].id = SASL_CB_USER; |
|
33891
8b4a41b6fe60
Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
1598 | irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_simple; /* sasl_getsimple_t */ |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1599 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1600 | id++; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1601 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1602 | irc->sasl_cb[id].id = SASL_CB_PASS; |
|
33891
8b4a41b6fe60
Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
1603 | irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_secret; /* sasl_getsecret_t */ |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1604 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1605 | id++; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1606 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1607 | irc->sasl_cb[id].id = SASL_CB_LOG; |
|
33891
8b4a41b6fe60
Fix warnings in irc, msn and mxit protocols
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33811
diff
changeset
|
1608 | irc->sasl_cb[id].proc = (int (*)(void))irc_sasl_cb_log; /* sasl_log_t */ |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1609 | irc->sasl_cb[id].context = (void *)irc; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1610 | id++; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1611 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1612 | irc->sasl_cb[id].id = SASL_CB_LIST_END; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1613 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1614 | /* 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
|
1615 | 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
|
1616 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1617 | 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
|
1618 | 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
|
1619 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1620 | if (ret != SASL_OK) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1621 | purple_debug_error("irc", "sasl_client_new failed: %d\n", ret); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1622 | |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1623 | purple_connection_take_error(gc, g_error_new( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1624 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1625 | PURPLE_CONNECTION_ERROR_OTHER_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1626 | _("Failed to initialize SASL authentication: %s"), |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1627 | sasl_errdetail(irc->sasl_conn))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1628 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1629 | return; |
|
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 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1632 | irc->sasl_mechs = g_string_new(mech_list); |
|
38135
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1633 | /* Drop EXTERNAL mechanism since we don't support it */ |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1634 | if ((pos = strstr(irc->sasl_mechs->str, "EXTERNAL"))) { |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1635 | index = pos - irc->sasl_mechs->str; |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1636 | g_string_erase(irc->sasl_mechs, index, strlen("EXTERNAL")); |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1637 | /* Remove space which separated this mech from the next */ |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1638 | if ((irc->sasl_mechs->str)[index] == ' ') { |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1639 | g_string_erase(irc->sasl_mechs, index, 1); |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1640 | } |
|
610656636af6
IRC: Skip EXTERNAL SASL auth mechanism
Kernc <kerncece@gmail.com>
parents:
37966
diff
changeset
|
1641 | } |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1642 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1643 | irc_auth_start_cyrus(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1644 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1645 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1646 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1647 | 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
|
1648 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1649 | 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
|
1650 | char *buf, *authinfo; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1651 | 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
|
1652 | gsize serverinlen = 0; |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1653 | const gchar *c_out; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1654 | unsigned int clen; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1655 | int ret; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1656 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1657 | irc->mech_works = TRUE; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1658 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1659 | if (!arg) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1660 | return; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1661 | |
|
37695
d24505afc83a
irc: Base64-decode SASL messages before passing to libsasl
Mantas Mikulėnas <grawity@nullroute.eu.org>
parents:
35518
diff
changeset
|
1662 | if (arg[0] != '+') |
|
d24505afc83a
irc: Base64-decode SASL messages before passing to libsasl
Mantas Mikulėnas <grawity@nullroute.eu.org>
parents:
35518
diff
changeset
|
1663 | 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
|
1664 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1665 | 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
|
1666 | NULL, &c_out, &clen); |
|
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 (ret != SASL_OK && ret != SASL_CONTINUE) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1669 | purple_connection_take_error(gc, g_error_new( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1670 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1671 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1672 | _("SASL authentication failed: %s"), |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1673 | sasl_errdetail(irc->sasl_conn))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1674 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1675 | 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
|
1676 | g_free(serverin); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1677 | return; |
|
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 | |
|
35169
44348822264a
Correctly send empty IRC SASL responses. Fixes #15452
Mantas MikulÄ—nas <grawity@nullroute.eu.org>
parents:
33803
diff
changeset
|
1680 | if (clen > 0) |
|
44348822264a
Correctly send empty IRC SASL responses. Fixes #15452
Mantas MikulÄ—nas <grawity@nullroute.eu.org>
parents:
33803
diff
changeset
|
1681 | 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
|
1682 | else |
|
44348822264a
Correctly send empty IRC SASL responses. Fixes #15452
Mantas MikulÄ—nas <grawity@nullroute.eu.org>
parents:
33803
diff
changeset
|
1683 | authinfo = g_strdup("+"); |
|
33404
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 | buf = irc_format(irc, "vv", "AUTHENTICATE", authinfo); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1686 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1687 | g_free(buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1688 | 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
|
1689 | g_free(serverin); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1690 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1691 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1692 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1693 | 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
|
1694 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1695 | char *buf; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1696 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1697 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1698 | irc->sasl_conn = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1699 | 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
|
1700 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1701 | /* Finish auth session */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1702 | buf = irc_format(irc, "vv", "CAP", "END"); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1703 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1704 | g_free(buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1705 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1706 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1707 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1708 | 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
|
1709 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1710 | 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
|
1711 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1712 | /* 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
|
1713 | * 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
|
1714 | * 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
|
1715 | * 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
|
1716 | * 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
|
1717 | */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1718 | if (irc->mech_works) { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1719 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1720 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1721 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1722 | _("Incorrect Password"))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1723 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1724 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1725 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1726 | return; |
|
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 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1729 | if (irc->current_mech) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1730 | char *pos; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1731 | 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
|
1732 | 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
|
1733 | 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
|
1734 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1735 | /* 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
|
1736 | if ((irc->sasl_mechs->str)[index] == ' ') { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1737 | 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
|
1738 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1739 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1740 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1741 | if (*irc->sasl_mechs->str) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1742 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1743 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1744 | 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
|
1745 | irc_auth_start_cyrus(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1746 | } else { |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1747 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1748 | PURPLE_CONNECTION_ERROR, |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1749 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_IMPOSSIBLE, |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1750 | _("SASL authentication failed: No worthy mechanisms found"))); |
|
33404
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 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1753 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1754 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1755 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1756 | void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1757 | 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
|
1758 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1759 | 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
|
1760 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1761 | /* 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
|
1762 | if (irc->sasl_conn) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1763 | 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
|
1764 | |
|
37966
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1765 | purple_connection_take_error(gc, g_error_new_literal( |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1766 | PURPLE_CONNECTION_ERROR, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1767 | PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED, |
|
956640da6944
irc: Pass PurpleConnection errors as GErrors
Mike Ruprecht <cmaiku@gmail.com>
parents:
37901
diff
changeset
|
1768 | _("Incorrect Password"))); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1769 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1770 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1771 | irc_sasl_finish(irc); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1772 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1773 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1774 | static void |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1775 | irc_sasl_finish(struct irc_conn *irc) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1776 | { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1777 | char *buf; |
|
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 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1780 | irc->sasl_conn = NULL; |
|
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 | g_free(irc->sasl_cb); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1783 | irc->sasl_cb = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1784 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1785 | /* Auth failed, abort */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1786 | buf = irc_format(irc, "vv", "CAP", "END"); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1787 | irc_send(irc, buf); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32127
diff
changeset
|
1788 | g_free(buf); |
|
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 | #endif |