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