Tue, 31 May 2022 00:07:27 -0500
Emit the irc-sending-text signal for all irc messages.
This was accidentally broken with the priority message sending stuff when the
rate limiter was added.
Testing Done:
Connected to libera and everything seemed to be fine. Waited for the antispam timer and verified that both part and quit messages which use `irc_priority_send` worked via the `irc-more` plugin.
Bugs closed: PIDGIN-17626
Reviewed at https://reviews.imfreedom.org/r/1483/
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
1 | /** |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
2 | * @file irc.c |
|
6459
b5169664b142
[gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
3 | * |
| 15884 | 4 | * purple |
| 2086 | 5 | * |
| 15884 | 6 | * Copyright (C) 2003, Robbert Haarman <purple@inglorion.net> |
|
32117
6d49fa9e996c
Remove periodic WHO on IRC.
Ethan Blanton <elb@pidgin.im>
parents:
31950
diff
changeset
|
7 | * Copyright (C) 2003, 2012 Ethan Blanton <elb@pidgin.im> |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
8 | * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> |
| 2086 | 9 | * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
|
6459
b5169664b142
[gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
10 | * |
| 2086 | 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by | |
| 13 | * the Free Software Foundation; either version 2 of the License, or | |
| 14 | * (at your option) any later version. | |
| 15 | * | |
| 16 | * This program is distributed in the hope that it will be useful, | |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 19 | * GNU General Public License for more details. | |
| 20 | * | |
| 21 | * You should have received a copy of the GNU General Public License | |
| 22 | * 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:
19785
diff
changeset
|
23 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 2086 | 24 | */ |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
25 | |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5791
diff
changeset
|
26 | #include "internal.h" |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5791
diff
changeset
|
27 | |
|
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5791
diff
changeset
|
28 | #include "accountopt.h" |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
29 | #include "blist.h" |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
30 | #include "conversation.h" |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
31 | #include "debug.h" |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
32 | #include "glibcompat.h" |
| 7148 | 33 | #include "notify.h" |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
34 | #include "prpl.h" |
|
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
35 | #include "plugin.h" |
| 6350 | 36 | #include "util.h" |
| 9943 | 37 | #include "version.h" |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
38 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
39 | #include "irc.h" |
|
4422
d7d5938502f0
[gaim-migrate @ 4695]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4416
diff
changeset
|
40 | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
41 | #define PING_TIMEOUT 60 |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
42 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
43 | static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list); |
| 2086 | 44 | |
| 15884 | 45 | static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b); |
| 46 | static GList *irc_status_types(PurpleAccount *account); | |
| 47 | static GList *irc_actions(PurplePlugin *plugin, gpointer context); | |
| 48 | /* static GList *irc_chat_info(PurpleConnection *gc); */ | |
| 49 | static void irc_login(PurpleAccount *account); | |
| 50 | static void irc_login_cb_ssl(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond); | |
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
51 | static void irc_login_cb(gpointer data, gint source, const gchar *error_message); |
| 15884 | 52 | static void irc_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error, gpointer data); |
| 53 | static void irc_close(PurpleConnection *gc); | |
| 54 | static int irc_im_send(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags); | |
| 55 | static int irc_chat_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags); | |
| 56 | static void irc_chat_join (PurpleConnection *gc, GHashTable *data); | |
| 57 | static void irc_input_cb(gpointer data, gint source, PurpleInputCondition cond); | |
| 58 | static void irc_input_cb_ssl(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond); | |
| 3751 | 59 | |
| 7711 | 60 | static guint irc_nick_hash(const char *nick); |
| 61 | static gboolean irc_nick_equal(const char *nick1, const char *nick2); | |
| 62 | static void irc_buddy_free(struct irc_buddy *ib); | |
| 63 | ||
| 15884 | 64 | PurplePlugin *_irc_plugin = NULL; |
| 7711 | 65 | |
| 15884 | 66 | static void irc_view_motd(PurplePluginAction *action) |
| 7148 | 67 | { |
| 15884 | 68 | PurpleConnection *gc = (PurpleConnection *) action->context; |
| 7148 | 69 | struct irc_conn *irc; |
|
36261
88ce4f534696
Display IRC MOTD in font-family: monospace. Fixes #13727
Ethan Blanton <elb@fiji-systems.com>
parents:
35171
diff
changeset
|
70 | char *title, *body; |
| 7148 | 71 | |
| 72 | if (gc == NULL || gc->proto_data == NULL) { | |
| 15884 | 73 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "got MOTD request for NULL gc\n"); |
| 7148 | 74 | return; |
| 75 | } | |
| 76 | irc = gc->proto_data; | |
| 77 | if (irc->motd == NULL) { | |
| 15884 | 78 | purple_notify_error(gc, _("Error displaying MOTD"), _("No MOTD available"), |
| 7148 | 79 | _("There is no MOTD associated with this connection.")); |
| 80 | return; | |
| 81 | } | |
| 82 | title = g_strdup_printf(_("MOTD for %s"), irc->server); | |
|
36261
88ce4f534696
Display IRC MOTD in font-family: monospace. Fixes #13727
Ethan Blanton <elb@fiji-systems.com>
parents:
35171
diff
changeset
|
83 | body = g_strdup_printf("<span style=\"font-family: monospace;\">%s</span>", irc->motd->str); |
|
88ce4f534696
Display IRC MOTD in font-family: monospace. Fixes #13727
Ethan Blanton <elb@fiji-systems.com>
parents:
35171
diff
changeset
|
84 | purple_notify_formatted(gc, title, title, NULL, body, NULL, NULL); |
|
14534
c9d0843d8c19
[gaim-migrate @ 17188]
Daniel Atallah <datallah@pidgin.im>
parents:
14324
diff
changeset
|
85 | g_free(title); |
|
36264
14555e001a59
Fix leak in previous commit.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
36261
diff
changeset
|
86 | g_free(body); |
| 7148 | 87 | } |
| 88 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
89 | static int do_send(struct irc_conn *irc, const char *buf, gsize len) |
| 3751 | 90 | { |
|
41419
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
91 | gchar *tosend = g_strndup(buf, len); |
| 9440 | 92 | int ret; |
| 93 | ||
|
41419
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
94 | purple_signal_emit(_irc_plugin, "irc-sending-text", purple_account_get_connection(irc->account), &tosend); |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
95 | |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
96 | if(tosend == NULL) { |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
97 | return 0; |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
98 | } |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
99 | |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
100 | if(purple_debug_is_verbose()) { |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
101 | char *clean = purple_utf8_salvage(tosend); |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
102 | clean = g_strstrip(clean); |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
103 | purple_debug_misc("irc", "<< %s\n", clean); |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
104 | g_free(clean); |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
105 | } |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
106 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
107 | if (irc->gsc) { |
|
41419
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
108 | ret = purple_ssl_write(irc->gsc, tosend, strlen(tosend)); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
109 | } else { |
|
41419
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
110 | ret = write(irc->fd, tosend, strlen(tosend)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
111 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
112 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
113 | irc->send_time = time(NULL); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
114 | |
|
41419
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
115 | g_free(tosend); |
|
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
116 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
117 | return ret; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
118 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
119 | |
|
41339
3230f4408394
Make all irc login time commands skip the rate limiter.
Gary Kramlich <grim@reaperworld.com>
parents:
41335
diff
changeset
|
120 | int irc_priority_send(struct irc_conn *irc, const char *buf) |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
121 | { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
122 | if(irc->sent_partial) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
123 | g_queue_insert_after(irc->send_queue, irc->send_queue->head, |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
124 | g_strdup(buf)); |
|
41339
3230f4408394
Make all irc login time commands skip the rate limiter.
Gary Kramlich <grim@reaperworld.com>
parents:
41335
diff
changeset
|
125 | return 0; |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
126 | } else { |
|
41339
3230f4408394
Make all irc login time commands skip the rate limiter.
Gary Kramlich <grim@reaperworld.com>
parents:
41335
diff
changeset
|
127 | return do_send(irc, buf, strlen(buf)); |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
128 | } |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
129 | } |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
130 | |
| 15884 | 131 | static int irc_send_raw(PurpleConnection *gc, const char *buf, int len) |
| 14604 | 132 | { |
| 133 | struct irc_conn *irc = (struct irc_conn*)gc->proto_data; | |
|
31929
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
134 | if (len == -1) { |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
135 | len = strlen(buf); |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
136 | } |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
137 | irc_send_len(irc, buf, len); |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
138 | return len; |
| 14604 | 139 | } |
| 140 | ||
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
141 | static gboolean |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
142 | irc_send_handler_cb(gpointer data) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
143 | struct irc_conn *irc = (struct irc_conn *)data; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
144 | gint available = 0; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
145 | gint interval = 0; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
146 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
147 | interval = purple_account_get_int(irc->account, "ratelimit-interval", |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
148 | IRC_DEFAULT_COMMAND_INTERVAL); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
149 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
150 | /* Check if we're enabled. */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
151 | if(interval < 1) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
152 | available = G_MAXINT; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
153 | } else { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
154 | gint burst = purple_account_get_int(irc->account, "ratelimit-burst", |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
155 | IRC_DEFAULT_COMMAND_MAX_BURST); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
156 | available = (time(NULL) - irc->send_time) / interval; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
157 | if(available > burst) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
158 | available = burst; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
159 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
160 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
161 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
162 | while(available > 0) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
163 | gchar *msg = NULL; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
164 | gpointer raw = NULL; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
165 | gint length = 0, ret = 0; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
166 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
167 | /* No message in the queue should be NULL, so a NULL value means the |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
168 | * queue is empty. |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
169 | */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
170 | raw = g_queue_pop_head(irc->send_queue); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
171 | if(raw == NULL) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
172 | break; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
173 | } |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
174 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
175 | msg = (gchar *)raw; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
176 | length = strlen(msg); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
177 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
178 | ret = do_send(irc, msg, length); |
|
41419
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
179 | if(ret < 0 && errno != EAGAIN) { |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
180 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
181 | gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
182 | g_strerror(errno)); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
183 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
184 | purple_connection_error_reason(gc, |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
185 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
186 | tmp); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
187 | g_free(tmp); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
188 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
189 | g_free(msg); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
190 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
191 | irc->send_handler = 0; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
192 | |
|
41341
e5b052dbc09f
G_SOURCE_REMOVE and G_SOURCE_CONTINUE were added in 2.32 but our windows build only has 2.16
Gary Kramlich <grim@reaperworld.com>
parents:
41339
diff
changeset
|
193 | return FALSE; |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
194 | } else if(ret < length) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
195 | gchar *partial = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
196 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
197 | /* The preceeding conditional allows EAGAIN to fall through to |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
198 | * here so that we can retransmit it. There shouldn't even be a |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
199 | * case where ret < 0 and != EAGAIN, which is why we have the |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
200 | * assert. |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
201 | */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
202 | if(ret < 0) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
203 | if(ret == EAGAIN) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
204 | ret = 0; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
205 | } else { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
206 | g_assert_not_reached(); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
207 | } |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
208 | } |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
209 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
210 | /* We need to move past the characters we already wrote and requeue |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
211 | * the rest of the string. We know ret is less than length, so the |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
212 | * starting address of msg plus ret can never get outside of the |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
213 | * string, and likewise, length minus ret will always be < length |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
214 | * because ret is less than length and if it was somehow negative, |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
215 | * it has been reset to zero. |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
216 | */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
217 | partial = g_strndup(msg + ret, length - ret); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
218 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
219 | /* requeue the item to the start of the queue */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
220 | g_queue_push_head(irc->send_queue, partial); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
221 | irc->sent_partial = TRUE; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
222 | } else { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
223 | /* We successfully sent a message so decrement the counter. */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
224 | available -= 1; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
225 | irc->sent_partial = FALSE; |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
226 | } |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
227 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
228 | /* Message was processed successfully or a partial message was |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
229 | * allocated and requeued so we can free the one we popped off. |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
230 | */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
231 | g_free(msg); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
232 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
233 | |
|
41341
e5b052dbc09f
G_SOURCE_REMOVE and G_SOURCE_CONTINUE were added in 2.32 but our windows build only has 2.16
Gary Kramlich <grim@reaperworld.com>
parents:
41339
diff
changeset
|
234 | return TRUE; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
235 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
236 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
237 | void irc_send(struct irc_conn *irc, const char *buf) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
238 | { |
|
31929
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
239 | return irc_send_len(irc, buf, strlen(buf)); |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
240 | } |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
241 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
242 | void |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
243 | irc_send_len(struct irc_conn *irc, const char *buf, int buflen) { |
|
41419
e53e50de3444
Emit the irc-sending-text signal for all irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41341
diff
changeset
|
244 | g_queue_push_tail(irc->send_queue, g_strdup(buf)); |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2171
diff
changeset
|
245 | } |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2171
diff
changeset
|
246 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
247 | /* XXX I don't like messing directly with these buddies */ |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
248 | gboolean irc_blist_timeout(struct irc_conn *irc) |
| 2086 | 249 | { |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
250 | if (irc->ison_outstanding) { |
|
2137
b0c18ea1dee8
[gaim-migrate @ 2147]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2131
diff
changeset
|
251 | return TRUE; |
| 2086 | 252 | } |
|
4416
008b56d257e1
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
253 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
254 | g_hash_table_foreach(irc->buddies, (GHFunc)irc_ison_buddy_init, |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
255 | (gpointer *)&irc->buddies_outstanding); |
|
4416
008b56d257e1
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
256 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
257 | irc_buddy_query(irc); |
|
21736
8de85200908d
applied changes from 5dc4cf40c038206bcf06fe7407e1e308b0264e32
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21503
diff
changeset
|
258 | |
|
2131
ef072ae1b2b8
[gaim-migrate @ 2141]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2123
diff
changeset
|
259 | return TRUE; |
| 2086 | 260 | } |
| 261 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
262 | void irc_buddy_query(struct irc_conn *irc) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
263 | { |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
264 | GList *lp; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
265 | GString *string; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
266 | struct irc_buddy *ib; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
267 | char *buf; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
268 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
269 | string = g_string_sized_new(512); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
270 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
271 | while ((lp = g_list_first(irc->buddies_outstanding))) { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
272 | ib = (struct irc_buddy *)lp->data; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
273 | if (string->len + strlen(ib->name) + 1 > 450) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
274 | break; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
275 | g_string_append_printf(string, "%s ", ib->name); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
276 | ib->new_online_status = FALSE; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
277 | irc->buddies_outstanding = g_list_remove_link(irc->buddies_outstanding, lp); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
278 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
279 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
280 | if (string->len) { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
281 | buf = irc_format(irc, "vn", "ISON", string->str); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
282 | irc_send(irc, buf); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
283 | g_free(buf); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
284 | irc->ison_outstanding = TRUE; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
285 | } else |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
286 | irc->ison_outstanding = FALSE; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
287 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
288 | g_string_free(string, TRUE); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
289 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
290 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
291 | static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list) |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
292 | { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
293 | *list = g_list_append(*list, ib); |
| 3511 | 294 | } |
| 295 | ||
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
296 | |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
297 | static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib) |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
298 | { |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
299 | char *buf; |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
300 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
301 | if (irc->buddies_outstanding != NULL) { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
302 | irc->buddies_outstanding = g_list_append(irc->buddies_outstanding, ib); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
303 | return; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
304 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
305 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
306 | ib->new_online_status = FALSE; |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
307 | buf = irc_format(irc, "vn", "ISON", ib->name); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
308 | irc_send(irc, buf); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
309 | g_free(buf); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
310 | } |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
311 | |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
312 | |
| 15884 | 313 | static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b) |
| 3029 | 314 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
315 | return "irc"; |
|
2339
b42203c69d52
[gaim-migrate @ 2352]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2331
diff
changeset
|
316 | } |
|
b42203c69d52
[gaim-migrate @ 2352]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2331
diff
changeset
|
317 | |
| 15884 | 318 | static GList *irc_status_types(PurpleAccount *account) |
| 2086 | 319 | { |
| 15884 | 320 | PurpleStatusType *type; |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
321 | GList *types = NULL; |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
322 | |
| 15884 | 323 | type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE); |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
324 | types = g_list_append(types, type); |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
325 | |
| 15884 | 326 | type = purple_status_type_new_with_attrs( |
| 327 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
| 328 | "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING), | |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
329 | NULL); |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
330 | types = g_list_append(types, type); |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
331 | |
| 15884 | 332 | type = purple_status_type_new(PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE); |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
333 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
334 | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
335 | return types; |
| 3452 | 336 | } |
| 337 | ||
| 15884 | 338 | static GList *irc_actions(PurplePlugin *plugin, gpointer context) |
| 7148 | 339 | { |
| 340 | GList *list = NULL; | |
| 15884 | 341 | PurplePluginAction *act = NULL; |
| 7148 | 342 | |
| 15884 | 343 | act = purple_plugin_action_new(_("View MOTD"), irc_view_motd); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
344 | list = g_list_append(list, act); |
| 7148 | 345 | |
| 346 | return list; | |
| 347 | } | |
| 348 | ||
| 15884 | 349 | static GList *irc_chat_join_info(PurpleConnection *gc) |
| 2086 | 350 | { |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
351 | GList *m = NULL; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
352 | struct proto_chat_entry *pce; |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
353 | |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
354 | pce = g_new0(struct proto_chat_entry, 1); |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7711
diff
changeset
|
355 | pce->label = _("_Channel:"); |
| 5234 | 356 | pce->identifier = "channel"; |
|
10954
cd5771cb6cf8
[gaim-migrate @ 12754]
Richard Laager <rlaager@pidgin.im>
parents:
10903
diff
changeset
|
357 | pce->required = TRUE; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
358 | m = g_list_append(m, pce); |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
359 | |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
360 | pce = g_new0(struct proto_chat_entry, 1); |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7711
diff
changeset
|
361 | pce->label = _("_Password:"); |
| 5234 | 362 | pce->identifier = "password"; |
| 6499 | 363 | pce->secret = TRUE; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
364 | m = g_list_append(m, pce); |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
365 | |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
366 | return m; |
| 2086 | 367 | } |
| 368 | ||
| 15884 | 369 | static GHashTable *irc_chat_info_defaults(PurpleConnection *gc, const char *chat_name) |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
370 | { |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
371 | GHashTable *defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
372 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
373 | defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
374 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
375 | if (chat_name != NULL) |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
376 | g_hash_table_insert(defaults, "channel", g_strdup(chat_name)); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
377 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
378 | return defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
379 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
380 | |
| 15884 | 381 | static void irc_login(PurpleAccount *account) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
382 | { |
| 15884 | 383 | PurpleConnection *gc; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
384 | struct irc_conn *irc; |
| 10494 | 385 | char **userparts; |
| 15884 | 386 | const char *username = purple_account_get_username(account); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
387 | |
| 15884 | 388 | gc = purple_account_get_connection(account); |
| 389 | gc->flags |= PURPLE_CONNECTION_NO_NEWLINES; | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
390 | |
| 6752 | 391 | if (strpbrk(username, " \t\v\r\n") != NULL) { |
| 21279 | 392 | purple_connection_error_reason (gc, |
| 393 | PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, | |
|
27184
13344d18390e
Clarify the error message when an IRC server contains spaces.
Paul Aurich <darkrain42@pidgin.im>
parents:
26611
diff
changeset
|
394 | _("IRC nick and server may not contain whitespace")); |
| 6752 | 395 | return; |
| 396 | } | |
| 397 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
398 | gc->proto_data = irc = g_new0(struct irc_conn, 1); |
|
10960
add2b4dbaa36
[gaim-migrate @ 12763]
Richard Laager <rlaager@pidgin.im>
parents:
10954
diff
changeset
|
399 | irc->fd = -1; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
400 | irc->account = account; |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
401 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
402 | irc->send_queue = g_queue_new(); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
403 | irc->sent_partial = FALSE; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
404 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
405 | userparts = g_strsplit(username, "@", 2); |
| 15884 | 406 | purple_connection_set_display_name(gc, userparts[0]); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
407 | irc->server = g_strdup(userparts[1]); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
408 | g_strfreev(userparts); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
409 | |
|
10159
5e8afc7db137
[gaim-migrate @ 11240]
Mark Doliner <markdoliner@pidgin.im>
parents:
10010
diff
changeset
|
410 | irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal, |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
411 | NULL, (GDestroyNotify)irc_buddy_free); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
412 | irc->cmds = g_hash_table_new(g_str_hash, g_str_equal); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
413 | irc_cmd_table_build(irc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
414 | irc->msgs = g_hash_table_new(g_str_hash, g_str_equal); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
415 | irc_msg_table_build(irc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
416 | |
| 15884 | 417 | purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
418 | |
| 15884 | 419 | if (purple_account_get_bool(account, "ssl", FALSE)) { |
| 420 | if (purple_ssl_is_supported()) { | |
| 421 | irc->gsc = purple_ssl_connect(account, irc->server, | |
| 422 | purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT), | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
423 | irc_login_cb_ssl, irc_ssl_connect_failure, gc); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
424 | } else { |
| 21279 | 425 | purple_connection_error_reason (gc, |
| 426 | PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT, | |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
427 | _("SSL support unavailable")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
428 | return; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
429 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
430 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
431 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
432 | if (!irc->gsc) { |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
433 | |
| 15884 | 434 | if (purple_proxy_connect(gc, account, irc->server, |
| 435 | purple_account_get_int(account, "port", IRC_DEFAULT_PORT), | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14684
diff
changeset
|
436 | irc_login_cb, gc) == NULL) |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14684
diff
changeset
|
437 | { |
| 21279 | 438 | purple_connection_error_reason (gc, |
| 439 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27627
diff
changeset
|
440 | _("Unable to connect")); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
441 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
442 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
443 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
444 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
445 | |
| 15884 | 446 | static gboolean do_login(PurpleConnection *gc) { |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
447 | char *buf, *tmp = NULL; |
|
31646
ebe3510fbdb1
Send * as our local hostname for the USER message at signon.
Ethan Blanton <elb@pidgin.im>
parents:
31595
diff
changeset
|
448 | char *server; |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
449 | const char *nickname, *identname, *realname; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
450 | struct irc_conn *irc = gc->proto_data; |
| 15884 | 451 | const char *pass = purple_connection_get_password(gc); |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
452 | gint interval, burst; |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
453 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
454 | const gboolean use_sasl = purple_account_get_bool(irc->account, "sasl", FALSE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
455 | #endif |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
456 | |
| 10555 | 457 | if (pass && *pass) { |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
458 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
459 | if (use_sasl) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
460 | buf = irc_format(irc, "vv:", "CAP", "REQ", "sasl"); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
461 | else /* intended to fall through */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
462 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
463 | buf = irc_format(irc, "v:", "PASS", pass); |
|
41339
3230f4408394
Make all irc login time commands skip the rate limiter.
Gary Kramlich <grim@reaperworld.com>
parents:
41335
diff
changeset
|
464 | if (irc_priority_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
465 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
466 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
467 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
468 | g_free(buf); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
469 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
470 | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
471 | realname = purple_account_get_string(irc->account, "realname", ""); |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
472 | identname = purple_account_get_string(irc->account, "username", ""); |
|
41332
770040cb6000
Set realname and identname to nickname by default in IRC
Belgin Știrbu <belginstirbu@hotmail.com>
parents:
40427
diff
changeset
|
473 | nickname = purple_connection_get_display_name(gc); |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
474 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
475 | if (identname == NULL || *identname == '\0') { |
|
41332
770040cb6000
Set realname and identname to nickname by default in IRC
Belgin Știrbu <belginstirbu@hotmail.com>
parents:
40427
diff
changeset
|
476 | identname = nickname; |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
477 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
478 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
479 | if (identname != NULL && strchr(identname, ' ') != NULL) { |
|
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
480 | tmp = g_strdup(identname); |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
481 | while ((buf = strchr(tmp, ' ')) != NULL) { |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
482 | *buf = '_'; |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
483 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
484 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
485 | |
|
23905
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
486 | if (*irc->server == ':') { |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
487 | /* Same as hostname, above. */ |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
488 | server = g_strdup_printf("0%s", irc->server); |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
489 | } else { |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
490 | server = g_strdup(irc->server); |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
491 | } |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
492 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
493 | buf = irc_format(irc, "vvvv:", "USER", tmp ? tmp : identname, "*", server, |
|
41332
770040cb6000
Set realname and identname to nickname by default in IRC
Belgin Știrbu <belginstirbu@hotmail.com>
parents:
40427
diff
changeset
|
494 | strlen(realname) ? realname : nickname); |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
495 | g_free(tmp); |
|
23905
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
496 | g_free(server); |
|
41339
3230f4408394
Make all irc login time commands skip the rate limiter.
Gary Kramlich <grim@reaperworld.com>
parents:
41335
diff
changeset
|
497 | if (irc_priority_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
498 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
499 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
500 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
501 | g_free(buf); |
|
41332
770040cb6000
Set realname and identname to nickname by default in IRC
Belgin Știrbu <belginstirbu@hotmail.com>
parents:
40427
diff
changeset
|
502 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
503 | buf = irc_format(irc, "vn", "NICK", nickname); |
|
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
504 | irc->reqnick = g_strdup(nickname); |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
505 | irc->nickused = FALSE; |
|
41339
3230f4408394
Make all irc login time commands skip the rate limiter.
Gary Kramlich <grim@reaperworld.com>
parents:
41335
diff
changeset
|
506 | if (irc_priority_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
507 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
508 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
509 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
510 | g_free(buf); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
511 | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
512 | irc->recv_time = time(NULL); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
513 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
514 | /* Give ourselves one full burst for startup commands. */ |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
515 | interval = purple_account_get_int(irc->account, "ratelimit-interval", |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
516 | IRC_DEFAULT_COMMAND_INTERVAL); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
517 | burst = purple_account_get_int(irc->account, "ratelimit-burst", |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
518 | IRC_DEFAULT_COMMAND_MAX_BURST); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
519 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
520 | irc->send_time = time(NULL) - (interval * burst); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
521 | irc->send_handler = g_timeout_add_seconds(1, irc_send_handler_cb, irc); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
522 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
523 | return TRUE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
524 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
525 | |
| 15884 | 526 | static void irc_login_cb_ssl(gpointer data, PurpleSslConnection *gsc, |
| 527 | PurpleInputCondition cond) | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
528 | { |
| 15884 | 529 | PurpleConnection *gc = data; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
530 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
531 | if (do_login(gc)) { |
| 15884 | 532 | purple_ssl_input_add(gsc, irc_input_cb_ssl, gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
533 | } |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
534 | } |
|
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
535 | |
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
536 | static void irc_login_cb(gpointer data, gint source, const gchar *error_message) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
537 | { |
| 15884 | 538 | PurpleConnection *gc = data; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
539 | struct irc_conn *irc = gc->proto_data; |
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
540 | |
| 8778 | 541 | if (source < 0) { |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
542 | gchar *tmp = g_strdup_printf(_("Unable to connect: %s"), |
|
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
543 | error_message); |
| 21279 | 544 | purple_connection_error_reason (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
545 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
546 | g_free(tmp); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
547 | return; |
| 8778 | 548 | } |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
549 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
550 | irc->fd = source; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
551 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
552 | if (do_login(gc)) { |
| 15884 | 553 | gc->inpa = purple_input_add(irc->fd, PURPLE_INPUT_READ, irc_input_cb, gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
554 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
555 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
556 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
557 | static void |
| 15884 | 558 | irc_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error, |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
559 | gpointer data) |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
560 | { |
| 15884 | 561 | PurpleConnection *gc = data; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
562 | struct irc_conn *irc = gc->proto_data; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
563 | |
|
14310
a71aba2f6249
[gaim-migrate @ 16930]
Mark Doliner <markdoliner@pidgin.im>
parents:
14309
diff
changeset
|
564 | irc->gsc = NULL; |
|
a71aba2f6249
[gaim-migrate @ 16930]
Mark Doliner <markdoliner@pidgin.im>
parents:
14309
diff
changeset
|
565 | |
|
20444
cc02f15b7a91
Use purple_connection_ssl_error in prpl-irc
Will Thompson <resiak@pidgin.im>
parents:
20441
diff
changeset
|
566 | purple_connection_ssl_error (gc, error); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
567 | } |
|
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
568 | |
| 15884 | 569 | static void irc_close(PurpleConnection *gc) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
570 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
571 | struct irc_conn *irc = gc->proto_data; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
572 | |
| 6752 | 573 | if (irc == NULL) |
| 574 | return; | |
| 575 | ||
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
576 | if (irc->gsc || (irc->fd >= 0)) |
|
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
577 | irc_cmd_quit(irc, "quit", NULL, NULL); |
|
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
578 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
579 | if (gc->inpa) |
| 15884 | 580 | purple_input_remove(gc->inpa); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
581 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
582 | g_free(irc->inbuf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
583 | if (irc->gsc) { |
| 15884 | 584 | purple_ssl_close(irc->gsc); |
|
14222
71d8761db708
[gaim-migrate @ 16808]
Mark Doliner <markdoliner@pidgin.im>
parents:
14173
diff
changeset
|
585 | } else if (irc->fd >= 0) { |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
586 | close(irc->fd); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
587 | } |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
588 | if (irc->timer) |
| 15884 | 589 | purple_timeout_remove(irc->timer); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
590 | g_hash_table_destroy(irc->cmds); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
591 | g_hash_table_destroy(irc->msgs); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
592 | g_hash_table_destroy(irc->buddies); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
593 | if (irc->motd) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
594 | g_string_free(irc->motd, TRUE); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
595 | g_free(irc->server); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
596 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
597 | g_queue_free_full(irc->send_queue, g_free); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
598 | if(irc->send_handler != 0) { |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
599 | g_source_remove(irc->send_handler); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
600 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
601 | |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
602 | g_free(irc->mode_chars); |
|
23118
7ba846a8187f
Fix irc nick collision handling, as requested by that demanding user elb.
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22277
diff
changeset
|
603 | g_free(irc->reqnick); |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
604 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
605 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
606 | if (irc->sasl_conn) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
607 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
608 | irc->sasl_conn = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
609 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
610 | g_free(irc->sasl_cb); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
611 | if(irc->sasl_mechs) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
612 | g_string_free(irc->sasl_mechs, TRUE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
613 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
614 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
615 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
616 | g_free(irc); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
617 | } |
|
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
618 | |
| 15884 | 619 | static int irc_im_send(PurpleConnection *gc, const char *who, const char *what, PurpleMessageFlags flags) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
620 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
621 | struct irc_conn *irc = gc->proto_data; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
622 | char *plain; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
623 | const char *args[2]; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
624 | |
|
24574
4ee71b4f335f
Strip multiple leading mode characters from incoming nicknames.
Marcos García Ochoa <magao@bigfoot.com>
parents:
23906
diff
changeset
|
625 | args[0] = irc_nick_skip_mode(irc, who); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
626 | |
|
16168
5a602ddb698f
Fix the HTML-on-IRC issues observed as a result of the bi-di text support
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16167
diff
changeset
|
627 | purple_markup_html_to_xhtml(what, NULL, &plain); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
628 | args[1] = plain; |
| 9442 | 629 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
630 | irc_cmd_privmsg(irc, "msg", NULL, args); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
631 | g_free(plain); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
632 | return 1; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
633 | } |
| 2086 | 634 | |
| 15884 | 635 | static void irc_get_info(PurpleConnection *gc, const char *who) |
| 2086 | 636 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
637 | struct irc_conn *irc = gc->proto_data; |
|
10618
6613664e683c
[gaim-migrate @ 12083]
Daniel Atallah <datallah@pidgin.im>
parents:
10555
diff
changeset
|
638 | const char *args[2]; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
639 | args[0] = who; |
| 10624 | 640 | args[1] = NULL; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
641 | irc_cmd_whois(irc, "whois", NULL, args); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
642 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
643 | |
| 15884 | 644 | static void irc_set_status(PurpleAccount *account, PurpleStatus *status) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
645 | { |
| 15884 | 646 | PurpleConnection *gc = purple_account_get_connection(account); |
|
13438
f57f4ecc3302
[gaim-migrate @ 15812]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
647 | struct irc_conn *irc; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
648 | const char *args[1]; |
| 15884 | 649 | const char *status_id = purple_status_get_id(status); |
| 2086 | 650 | |
|
13438
f57f4ecc3302
[gaim-migrate @ 15812]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
651 | g_return_if_fail(gc != NULL); |
|
f57f4ecc3302
[gaim-migrate @ 15812]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
652 | irc = gc->proto_data; |
| 10646 | 653 | |
| 15884 | 654 | if (!purple_status_is_active(status)) |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
655 | return; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
656 | |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
657 | args[0] = NULL; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
658 | |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36264
diff
changeset
|
659 | if (purple_strequal(status_id, "away")) { |
| 15884 | 660 | args[0] = purple_status_get_attr_string(status, "message"); |
|
12001
512c45efaccb
[gaim-migrate @ 14294]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
661 | if ((args[0] == NULL) || (*args[0] == '\0')) |
|
512c45efaccb
[gaim-migrate @ 14294]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
662 | args[0] = _("Away"); |
| 10646 | 663 | irc_cmd_away(irc, "away", NULL, args); |
|
38258
9a6551eba09c
Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents:
36264
diff
changeset
|
664 | } else if (purple_strequal(status_id, "available")) { |
|
12210
d7e2c9f73e16
[gaim-migrate @ 14512]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
665 | irc_cmd_away(irc, "back", NULL, args); |
| 10646 | 666 | } |
| 4916 | 667 | } |
| 668 | ||
| 15884 | 669 | static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
| 3029 | 670 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
671 | struct irc_conn *irc = (struct irc_conn *)gc->proto_data; |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
672 | struct irc_buddy *ib; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
673 | const char *bname = purple_buddy_get_name(buddy); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
674 | |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
675 | ib = g_hash_table_lookup(irc->buddies, bname); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
676 | if (ib != NULL) { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
677 | ib->ref++; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
678 | purple_prpl_got_user_status(irc->account, bname, |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
679 | ib->online ? "available" : "offline", NULL); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
680 | } else { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
681 | ib = g_new0(struct irc_buddy, 1); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
682 | ib->name = g_strdup(bname); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
683 | ib->ref = 1; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
684 | g_hash_table_replace(irc->buddies, ib->name, ib); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
685 | } |
| 9238 | 686 | |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
687 | /* if the timer isn't set, this is during signon, so we don't want to flood |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
688 | * ourself off with ISON's, so we don't, but after that we want to know when |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
689 | * someone's online asap */ |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
690 | if (irc->timer) |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
691 | irc_ison_one(irc, ib); |
| 3029 | 692 | } |
| 3622 | 693 | |
| 15884 | 694 | static void irc_remove_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
695 | { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
696 | struct irc_conn *irc = (struct irc_conn *)gc->proto_data; |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
697 | struct irc_buddy *ib; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
698 | |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
699 | ib = g_hash_table_lookup(irc->buddies, purple_buddy_get_name(buddy)); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
700 | if (ib && --ib->ref == 0) { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
701 | g_hash_table_remove(irc->buddies, purple_buddy_get_name(buddy)); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
702 | } |
| 3616 | 703 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
704 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
705 | static void read_input(struct irc_conn *irc, int len) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
706 | { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
707 | char *cur, *end; |
| 6369 | 708 | |
|
22277
7c386db62c81
Don't send keep-alives if we've received data since in the last KEEPALIVE_INTERVAL seconds
Sean Egan <seanegan@pidgin.im>
parents:
21736
diff
changeset
|
709 | irc->account->gc->last_received = time(NULL); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
710 | irc->inbufused += len; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
711 | irc->inbuf[irc->inbufused] = '\0'; |
| 3616 | 712 | |
| 8156 | 713 | cur = irc->inbuf; |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
714 | |
| 12752 | 715 | /* This is a hack to work around the fact that marv gets messages |
| 716 | * with null bytes in them while using some weird irc server at work | |
| 717 | */ | |
| 718 | while ((cur < (irc->inbuf + irc->inbufused)) && !*cur) | |
| 719 | cur++; | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
720 | |
| 8156 | 721 | while (cur < irc->inbuf + irc->inbufused && |
| 722 | ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) { | |
| 723 | int step = (*end == '\r' ? 2 : 1); | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
724 | *end = '\0'; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
725 | irc_parse_msg(irc, cur); |
| 8156 | 726 | cur = end + step; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
727 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
728 | if (cur != irc->inbuf + irc->inbufused) { /* leftover */ |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
729 | irc->inbufused -= (cur - irc->inbuf); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
730 | memmove(irc->inbuf, cur, irc->inbufused); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
731 | } else { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
732 | irc->inbufused = 0; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
733 | } |
| 3616 | 734 | } |
| 735 | ||
| 15884 | 736 | static void irc_input_cb_ssl(gpointer data, PurpleSslConnection *gsc, |
| 737 | PurpleInputCondition cond) | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
738 | { |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
739 | |
| 15884 | 740 | PurpleConnection *gc = data; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
741 | struct irc_conn *irc = gc->proto_data; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
742 | int len; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
743 | |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
744 | if(!g_list_find(purple_connections_get_all(), gc)) { |
| 15884 | 745 | purple_ssl_close(gsc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
746 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
747 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
748 | |
|
38758
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
749 | do { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
750 | // resize buffer upwards so we have at least IRC_BUFSIZE_INCREMENT |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
751 | // bytes free in inbuf |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
752 | if (irc->inbuflen < irc->inbufused + IRC_BUFSIZE_INCREMENT) { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
753 | if (irc->inbuflen + IRC_BUFSIZE_INCREMENT <= IRC_MAX_BUFSIZE) { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
754 | irc->inbuflen += IRC_BUFSIZE_INCREMENT; |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
755 | irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
756 | } else { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
757 | // discard unparseable data from the buffer |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
758 | irc->inbufused = 0; |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
759 | } |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
760 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
761 | |
|
38759
37192dfc65d7
review fix: do the maximum allowable read each time
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38758
diff
changeset
|
762 | len = purple_ssl_read(gsc, irc->inbuf + irc->inbufused, irc->inbuflen - irc->inbufused - 1); |
|
38758
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
763 | if (len > 0) { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
764 | read_input(irc, len); |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
765 | } |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
766 | } while (len > 0); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
767 | |
|
38758
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
768 | if (len < 0 && errno != EAGAIN) { |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
769 | gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
|
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
770 | g_strerror(errno)); |
| 21279 | 771 | purple_connection_error_reason (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
772 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
773 | g_free(tmp); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
774 | } else if (len == 0) { |
| 21279 | 775 | purple_connection_error_reason (gc, |
| 776 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
777 | _("Server closed the connection")); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
778 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
779 | |
|
38758
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
780 | /* else: len < 0 && errno == EAGAIN; this is fine, try again later */ |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
781 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
782 | |
| 15884 | 783 | static void irc_input_cb(gpointer data, gint source, PurpleInputCondition cond) |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
784 | { |
| 15884 | 785 | PurpleConnection *gc = data; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
786 | struct irc_conn *irc = gc->proto_data; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
787 | int len; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
788 | |
|
38758
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
789 | /* see irc_input_cb_ssl */ |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
790 | if (irc->inbuflen < irc->inbufused + IRC_BUFSIZE_INCREMENT) { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
791 | if (irc->inbuflen + IRC_BUFSIZE_INCREMENT <= IRC_MAX_BUFSIZE) { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
792 | irc->inbuflen += IRC_BUFSIZE_INCREMENT; |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
793 | irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
794 | } else { |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
795 | irc->inbufused = 0; |
|
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
796 | } |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
797 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
798 | |
|
38759
37192dfc65d7
review fix: do the maximum allowable read each time
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38758
diff
changeset
|
799 | len = read(irc->fd, irc->inbuf + irc->inbufused, irc->inbuflen - irc->inbufused - 1); |
|
38758
5ef4de93fc90
fixes to IRC buffer handling
Shivaram Lingamneni <slingamn@cs.stanford.edu>
parents:
38302
diff
changeset
|
800 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
801 | if (len < 0 && errno == EAGAIN) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
802 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
803 | } else if (len < 0) { |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
804 | gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
|
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
805 | g_strerror(errno)); |
| 21279 | 806 | purple_connection_error_reason (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
807 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp); |
|
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
808 | g_free(tmp); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
809 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
810 | } else if (len == 0) { |
| 21279 | 811 | purple_connection_error_reason (gc, |
| 812 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
813 | _("Server closed the connection")); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
814 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
815 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
816 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
817 | read_input(irc, len); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
818 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
819 | |
| 15884 | 820 | static void irc_chat_join (PurpleConnection *gc, GHashTable *data) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
821 | { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
822 | struct irc_conn *irc = gc->proto_data; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
823 | const char *args[2]; |
| 3616 | 824 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
825 | args[0] = g_hash_table_lookup(data, "channel"); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
826 | args[1] = g_hash_table_lookup(data, "password"); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
827 | irc_cmd_join(irc, "join", NULL, args); |
| 3622 | 828 | } |
| 829 | ||
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
830 | static char *irc_get_chat_name(GHashTable *data) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
831 | return g_strdup(g_hash_table_lookup(data, "channel")); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
832 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
833 | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
834 | static void irc_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name) |
| 3751 | 835 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
836 | struct irc_conn *irc = gc->proto_data; |
| 15884 | 837 | PurpleConversation *convo = purple_find_chat(gc, id); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
838 | const char *args[2]; |
| 3751 | 839 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
840 | if (!convo) { |
| 15884 | 841 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "Got chat invite request for bogus chat\n"); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
842 | return; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
843 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
844 | args[0] = name; |
| 15884 | 845 | args[1] = purple_conversation_get_name(convo); |
| 846 | irc_cmd_invite(irc, "invite", purple_conversation_get_name(convo), args); | |
| 3707 | 847 | } |
| 848 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
849 | |
| 15884 | 850 | static void irc_chat_leave (PurpleConnection *gc, int id) |
| 3707 | 851 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
852 | struct irc_conn *irc = gc->proto_data; |
| 15884 | 853 | PurpleConversation *convo = purple_find_chat(gc, id); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
854 | const char *args[2]; |
| 5298 | 855 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
856 | if (!convo) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
857 | return; |
| 3735 | 858 | |
| 15884 | 859 | args[0] = purple_conversation_get_name(convo); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
860 | args[1] = NULL; |
| 15884 | 861 | irc_cmd_part(irc, "part", purple_conversation_get_name(convo), args); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
862 | serv_got_chat_left(gc, id); |
| 3735 | 863 | } |
| 864 | ||
| 15884 | 865 | static int irc_chat_send(PurpleConnection *gc, int id, const char *what, PurpleMessageFlags flags) |
| 3735 | 866 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
867 | struct irc_conn *irc = gc->proto_data; |
| 15884 | 868 | PurpleConversation *convo = purple_find_chat(gc, id); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
869 | const char *args[2]; |
| 8163 | 870 | char *tmp; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
871 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
872 | if (!convo) { |
| 15884 | 873 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "chat send on nonexistent chat\n"); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
874 | return -EINVAL; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
875 | } |
| 9130 | 876 | #if 0 |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
877 | if (*what == '/') { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
878 | return irc_parse_cmd(irc, convo->name, what + 1); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
879 | } |
| 9130 | 880 | #endif |
|
16168
5a602ddb698f
Fix the HTML-on-IRC issues observed as a result of the bi-di text support
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16167
diff
changeset
|
881 | purple_markup_html_to_xhtml(what, NULL, &tmp); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
882 | args[0] = convo->name; |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
883 | args[1] = tmp; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
884 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
885 | irc_cmd_privmsg(irc, "msg", NULL, args); |
| 8163 | 886 | |
|
23295
5d3a2fd59439
When calling serv_got_chat_in() after sending a group chat message (to let
Evan Schoenberg <evands@pidgin.im>
parents:
23277
diff
changeset
|
887 | serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), flags, what, time(NULL)); |
| 8163 | 888 | g_free(tmp); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
889 | return 0; |
| 3707 | 890 | } |
| 891 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
892 | static guint irc_nick_hash(const char *nick) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
893 | { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
894 | char *lc; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
895 | guint bucket; |
|
6270
e3cb3b0c6c82
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
896 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
897 | lc = g_utf8_strdown(nick, -1); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
898 | bucket = g_str_hash(lc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
899 | g_free(lc); |
|
6270
e3cb3b0c6c82
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
900 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
901 | return bucket; |
| 3029 | 902 | } |
| 903 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
904 | static gboolean irc_nick_equal(const char *nick1, const char *nick2) |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
905 | { |
| 15884 | 906 | return (purple_utf8_strcasecmp(nick1, nick2) == 0); |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
907 | } |
|
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
908 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
909 | static void irc_buddy_free(struct irc_buddy *ib) |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
910 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
911 | g_free(ib->name); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
912 | g_free(ib); |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
913 | } |
|
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
914 | |
| 15884 | 915 | static void irc_chat_set_topic(PurpleConnection *gc, int id, const char *topic) |
| 9154 | 916 | { |
| 917 | char *buf; | |
| 918 | const char *name = NULL; | |
| 919 | struct irc_conn *irc; | |
| 920 | ||
| 921 | irc = gc->proto_data; | |
| 15884 | 922 | name = purple_conversation_get_name(purple_find_chat(gc, id)); |
| 9154 | 923 | |
| 924 | if (name == NULL) | |
| 925 | return; | |
| 926 | ||
| 927 | buf = irc_format(irc, "vt:", "TOPIC", name, topic); | |
| 928 | irc_send(irc, buf); | |
| 929 | g_free(buf); | |
| 930 | } | |
| 931 | ||
| 15884 | 932 | static PurpleRoomlist *irc_roomlist_get_list(PurpleConnection *gc) |
| 8114 | 933 | { |
| 934 | struct irc_conn *irc; | |
| 935 | GList *fields = NULL; | |
| 15884 | 936 | PurpleRoomlistField *f; |
| 8352 | 937 | char *buf; |
| 8114 | 938 | |
| 939 | irc = gc->proto_data; | |
| 940 | ||
| 941 | if (irc->roomlist) | |
| 15884 | 942 | purple_roomlist_unref(irc->roomlist); |
| 8114 | 943 | |
| 15884 | 944 | irc->roomlist = purple_roomlist_new(purple_connection_get_account(gc)); |
| 8114 | 945 | |
| 15884 | 946 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "channel", TRUE); |
| 8114 | 947 | fields = g_list_append(fields, f); |
| 948 | ||
| 15884 | 949 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE); |
| 8114 | 950 | fields = g_list_append(fields, f); |
| 951 | ||
| 15884 | 952 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE); |
| 8114 | 953 | fields = g_list_append(fields, f); |
| 954 | ||
| 15884 | 955 | purple_roomlist_set_fields(irc->roomlist, fields); |
| 8114 | 956 | |
| 8352 | 957 | buf = irc_format(irc, "v", "LIST"); |
| 958 | irc_send(irc, buf); | |
| 959 | g_free(buf); | |
| 8114 | 960 | |
| 961 | return irc->roomlist; | |
| 962 | } | |
| 963 | ||
| 15884 | 964 | static void irc_roomlist_cancel(PurpleRoomlist *list) |
| 8114 | 965 | { |
| 15884 | 966 | PurpleConnection *gc = purple_account_get_connection(list->account); |
| 8114 | 967 | struct irc_conn *irc; |
| 968 | ||
| 969 | if (gc == NULL) | |
| 970 | return; | |
| 971 | ||
| 972 | irc = gc->proto_data; | |
| 973 | ||
| 15884 | 974 | purple_roomlist_set_in_progress(list, FALSE); |
| 8114 | 975 | |
| 976 | if (irc->roomlist == list) { | |
| 977 | irc->roomlist = NULL; | |
| 15884 | 978 | purple_roomlist_unref(list); |
| 8114 | 979 | } |
| 980 | } | |
| 981 | ||
| 15884 | 982 | static void irc_keepalive(PurpleConnection *gc) |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
983 | { |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
984 | struct irc_conn *irc = gc->proto_data; |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
985 | if ((time(NULL) - irc->recv_time) > PING_TIMEOUT) |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
986 | irc_cmd_ping(irc, NULL, NULL, NULL); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
987 | } |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
988 | |
| 15884 | 989 | static PurplePluginProtocolInfo prpl_info = |
| 2086 | 990 | { |
|
18092
1a2362194473
Mostly taken from the patch on ticket #410, don't send unknown slash
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17077
diff
changeset
|
991 | OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL | |
|
1a2362194473
Mostly taken from the patch on ticket #410, don't send unknown slash
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17077
diff
changeset
|
992 | OPT_PROTO_SLASH_COMMANDS_NATIVE, |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
993 | NULL, /* user_splits */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
994 | NULL, /* protocol_options */ |
| 9951 | 995 | NO_BUDDY_ICONS, /* icon_spec */ |
| 996 | irc_blist_icon, /* list_icon */ | |
| 15524 | 997 | NULL, /* list_emblems */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
998 | NULL, /* status_text */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
999 | NULL, /* tooltip_text */ |
| 9951 | 1000 | irc_status_types, /* away_states */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1001 | NULL, /* blist_node_menu */ |
| 9951 | 1002 | irc_chat_join_info, /* chat_info */ |
|
9754
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
1003 | irc_chat_info_defaults, /* chat_info_defaults */ |
| 9951 | 1004 | irc_login, /* login */ |
| 1005 | irc_close, /* close */ | |
| 1006 | irc_im_send, /* send_im */ | |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1007 | NULL, /* set_info */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1008 | NULL, /* send_typing */ |
| 9951 | 1009 | irc_get_info, /* get_info */ |
| 1010 | irc_set_status, /* set_status */ | |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1011 | NULL, /* set_idle */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1012 | NULL, /* change_passwd */ |
| 9951 | 1013 | irc_add_buddy, /* add_buddy */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1014 | NULL, /* add_buddies */ |
| 9951 | 1015 | irc_remove_buddy, /* remove_buddy */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1016 | NULL, /* remove_buddies */ |
| 9741 | 1017 | NULL, /* add_permit */ |
| 1018 | NULL, /* add_deny */ | |
| 1019 | NULL, /* rem_permit */ | |
| 1020 | NULL, /* rem_deny */ | |
| 1021 | NULL, /* set_permit_deny */ | |
| 9951 | 1022 | irc_chat_join, /* join_chat */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1023 | NULL, /* reject_chat */ |
| 9951 | 1024 | irc_get_chat_name, /* get_chat_name */ |
| 1025 | irc_chat_invite, /* chat_invite */ | |
| 1026 | irc_chat_leave, /* chat_leave */ | |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1027 | NULL, /* chat_whisper */ |
| 9951 | 1028 | irc_chat_send, /* chat_send */ |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
1029 | irc_keepalive, /* keepalive */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1030 | NULL, /* register_user */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1031 | NULL, /* get_cb_info */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1032 | NULL, /* get_cb_away */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1033 | NULL, /* alias_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1034 | NULL, /* group_buddy */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1035 | NULL, /* rename_group */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1036 | NULL, /* buddy_free */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1037 | NULL, /* convo_closed */ |
| 15884 | 1038 | purple_normalize_nocase, /* normalize */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1039 | NULL, /* set_buddy_icon */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1040 | NULL, /* remove_group */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1041 | NULL, /* get_cb_real_name */ |
| 9951 | 1042 | irc_chat_set_topic, /* set_chat_topic */ |
|
9475
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1043 | NULL, /* find_blist_chat */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1044 | irc_roomlist_get_list, /* roomlist_get_list */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1045 | irc_roomlist_cancel, /* roomlist_cancel */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1046 | NULL, /* roomlist_expand_category */ |
|
8c8d4ac992a6
[gaim-migrate @ 10300]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9466
diff
changeset
|
1047 | NULL, /* can_receive_file */ |
|
12143
09f216663302
[gaim-migrate @ 14444]
Evan Schoenberg <evands@pidgin.im>
parents:
12130
diff
changeset
|
1048 | irc_dccsend_send_file, /* send_file */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1049 | irc_dccsend_new_xfer, /* new_xfer */ |
|
12645
a907ba243930
[gaim-migrate @ 14983]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12600
diff
changeset
|
1050 | NULL, /* offline_message */ |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12595
diff
changeset
|
1051 | NULL, /* whiteboard_prpl_ops */ |
| 15185 | 1052 | irc_send_raw, /* send_raw */ |
| 1053 | NULL, /* roomlist_room_serialize */ | |
|
22071
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
1054 | NULL, /* unregister_user */ |
|
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
1055 | NULL, /* send_attention */ |
|
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
1056 | NULL, /* get_attention_types */ |
|
4c47e360e467
Fix the prplinfo structs and get rid of some compile warnings.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22069
diff
changeset
|
1057 | sizeof(PurplePluginProtocolInfo), /* struct_size */ |
| 23708 | 1058 | NULL, /* get_account_text_table */ |
|
22648
e286d795c5f9
Patch from Marcus Lundblad ('mlundblad') to improve audio support in xmpp.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22398
diff
changeset
|
1059 | NULL, /* initiate_media */ |
|
29757
f137c1386384
Add a NULL for PurplePluginProtocolInfo::get_moods to all the plugins I build
Paul Aurich <darkrain42@pidgin.im>
parents:
28118
diff
changeset
|
1060 | NULL, /* get_media_caps */ |
|
30138
cca9685df785
Add purple_account_[gs]et_public_alias functions, per discussion in d@cpi
Paul Aurich <darkrain42@pidgin.im>
parents:
29812
diff
changeset
|
1061 | NULL, /* get_moods */ |
|
cca9685df785
Add purple_account_[gs]et_public_alias functions, per discussion in d@cpi
Paul Aurich <darkrain42@pidgin.im>
parents:
29812
diff
changeset
|
1062 | NULL, /* set_public_alias */ |
|
31595
ffc150f21bec
Update PRPL structs with new fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31565
diff
changeset
|
1063 | NULL, /* get_public_alias */ |
|
ffc150f21bec
Update PRPL structs with new fields.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31565
diff
changeset
|
1064 | NULL, /* add_buddy_with_invite */ |
|
38967
303c75b86d86
Add get_cb_alias() to PRPLs
David Woodhouse <dwmw2@infradead.org>
parents:
38907
diff
changeset
|
1065 | NULL, /* add_buddies_with_invite */ |
|
303c75b86d86
Add get_cb_alias() to PRPLs
David Woodhouse <dwmw2@infradead.org>
parents:
38907
diff
changeset
|
1066 | NULL, /* get_cb_alias */ |
|
40427
93bf0203f935
Add chat_send_file() facility
David Woodhouse <dwmw2@infradead.org>
parents:
38967
diff
changeset
|
1067 | NULL, /* chat_can_receive_file */ |
|
93bf0203f935
Add chat_send_file() facility
David Woodhouse <dwmw2@infradead.org>
parents:
38967
diff
changeset
|
1068 | NULL, /* chat_send_file */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1069 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1070 | |
| 15884 | 1071 | static gboolean load_plugin (PurplePlugin *plugin) { |
| 14683 | 1072 | |
| 15884 | 1073 | purple_signal_register(plugin, "irc-sending-text", |
| 1074 | purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 1075 | purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 1076 | purple_value_new_outgoing(PURPLE_TYPE_STRING)); | |
| 1077 | purple_signal_register(plugin, "irc-receiving-text", | |
| 1078 | purple_marshal_VOID__POINTER_POINTER, NULL, 2, | |
| 1079 | purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION), | |
| 1080 | purple_value_new_outgoing(PURPLE_TYPE_STRING)); | |
| 14683 | 1081 | return TRUE; |
| 1082 | } | |
| 1083 | ||
| 8114 | 1084 | |
| 15884 | 1085 | static PurplePluginInfo info = |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1086 | { |
| 15884 | 1087 | PURPLE_PLUGIN_MAGIC, |
| 1088 | PURPLE_MAJOR_VERSION, | |
| 1089 | PURPLE_MINOR_VERSION, | |
| 1090 | PURPLE_PLUGIN_PROTOCOL, /**< type */ | |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1091 | NULL, /**< ui_requirement */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1092 | 0, /**< flags */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1093 | NULL, /**< dependencies */ |
| 15884 | 1094 | PURPLE_PRIORITY_DEFAULT, /**< priority */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1095 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1096 | "prpl-irc", /**< id */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1097 | "IRC", /**< name */ |
|
20288
5ca925a094e2
applied changes from 03b709ec2a153e7e82719df0ba4635108bb1d3c6
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19859
diff
changeset
|
1098 | DISPLAY_VERSION, /**< version */ |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
1099 | N_("IRC Protocol Plugin"), /** summary */ |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
1100 | N_("The IRC Protocol Plugin that Sucks Less"), /** description */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1101 | NULL, /**< author */ |
| 15884 | 1102 | PURPLE_WEBSITE, /**< homepage */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1103 | |
| 14683 | 1104 | load_plugin, /**< load */ |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1105 | NULL, /**< unload */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1106 | NULL, /**< destroy */ |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1107 | |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1108 | NULL, /**< ui_info */ |
| 8993 | 1109 | &prpl_info, /**< extra_info */ |
| 11763 | 1110 | NULL, /**< prefs_info */ |
|
16746
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16168
diff
changeset
|
1111 | irc_actions, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16168
diff
changeset
|
1112 | |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16168
diff
changeset
|
1113 | /* padding */ |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16168
diff
changeset
|
1114 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16168
diff
changeset
|
1115 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16168
diff
changeset
|
1116 | NULL, |
|
72faf41c3c4f
And now the protocols
Gary Kramlich <grim@reaperworld.com>
parents:
16168
diff
changeset
|
1117 | NULL |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1118 | }; |
|
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1119 | |
| 15884 | 1120 | static void _init_plugin(PurplePlugin *plugin) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1121 | { |
| 15884 | 1122 | PurpleAccountUserSplit *split; |
| 1123 | PurpleAccountOption *option; | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1124 | |
| 15884 | 1125 | split = purple_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@'); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1126 | prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
|
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1127 | |
| 15884 | 1128 | option = purple_account_option_int_new(_("Port"), "port", IRC_DEFAULT_PORT); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
1129 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
1130 | |
| 15884 | 1131 | option = purple_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
1132 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1133 | |
|
23906
6962e96ddd38
This adds an "auto-detect UTF-8" option to IRC which, when enabled,
Ethan Blanton <elb@pidgin.im>
parents:
23905
diff
changeset
|
1134 | option = purple_account_option_bool_new(_("Auto-detect incoming UTF-8"), "autodetect_utf8", IRC_DEFAULT_AUTODETECT); |
|
6962e96ddd38
This adds an "auto-detect UTF-8" option to IRC which, when enabled,
Ethan Blanton <elb@pidgin.im>
parents:
23905
diff
changeset
|
1135 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
6962e96ddd38
This adds an "auto-detect UTF-8" option to IRC which, when enabled,
Ethan Blanton <elb@pidgin.im>
parents:
23905
diff
changeset
|
1136 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
1137 | option = purple_account_option_string_new(_("Ident name"), "username", ""); |
| 7323 | 1138 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 1139 | ||
| 15884 | 1140 | option = purple_account_option_string_new(_("Real name"), "realname", ""); |
| 10002 | 1141 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 1142 | ||
| 11763 | 1143 | /* |
| 15884 | 1144 | option = purple_account_option_string_new(_("Quit message"), "quitmsg", IRC_DEFAULT_QUIT); |
| 11763 | 1145 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
| 1146 | */ | |
| 1147 | ||
| 15884 | 1148 | option = purple_account_option_bool_new(_("Use SSL"), "ssl", FALSE); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
1149 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
1150 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1151 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1152 | option = purple_account_option_bool_new(_("Authenticate with SASL"), "sasl", FALSE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1153 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1154 | |
|
41333
ed2b25ccdf2c
Add a field in IRC where users can explicitly set the SASL login name
Belgin Știrbu <belginstirbu@hotmail.com>
parents:
41332
diff
changeset
|
1155 | option = purple_account_option_string_new(_("SASL login name"), "saslname", ""); |
|
ed2b25ccdf2c
Add a field in IRC where users can explicitly set the SASL login name
Belgin Știrbu <belginstirbu@hotmail.com>
parents:
41332
diff
changeset
|
1156 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
ed2b25ccdf2c
Add a field in IRC where users can explicitly set the SASL login name
Belgin Știrbu <belginstirbu@hotmail.com>
parents:
41332
diff
changeset
|
1157 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1158 | option = purple_account_option_bool_new( |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1159 | _("Allow plaintext SASL auth over unencrypted connection"), |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1160 | "auth_plain_in_clear", FALSE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1161 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1162 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1163 | |
|
41335
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1164 | option = purple_account_option_int_new(_("Seconds between sending messages"), |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1165 | "ratelimit-interval", |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1166 | IRC_DEFAULT_COMMAND_INTERVAL); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1167 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1168 | |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1169 | option = purple_account_option_int_new(_("Maximum messages to send at once"), |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1170 | "ratelimit-burst", |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1171 | IRC_DEFAULT_COMMAND_MAX_BURST); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1172 | prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); |
|
c49dcf00bee6
Use the leaky bucket algorithm to rate limit irc messages.
Gary Kramlich <grim@reaperworld.com>
parents:
41333
diff
changeset
|
1173 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
1174 | _irc_plugin = plugin; |
| 9130 | 1175 | |
| 15884 | 1176 | purple_prefs_remove("/plugins/prpl/irc/quitmsg"); |
| 1177 | purple_prefs_remove("/plugins/prpl/irc"); | |
| 11073 | 1178 | |
| 9130 | 1179 | irc_register_commands(); |
| 2086 | 1180 | } |
| 1181 | ||
| 15884 | 1182 | PURPLE_INIT_PLUGIN(irc, _init_plugin, info); |