Sat, 24 May 2014 02:32:01 +0530
Merged default branch
|
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" |
|
34706
02cb08146888
Renamed blist.[ch] to buddylist.[ch]
Ankit Vani <a@nevitus.org>
parents:
34632
diff
changeset
|
29 | #include "buddylist.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" |
| 7148 | 32 | #include "notify.h" |
|
36543
a8c3fecee2d3
Renamed prpl.[ch] to protocol.[ch]
Ankit Vani <a@nevitus.org>
parents:
36536
diff
changeset
|
33 | #include "protocol.h" |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34815
diff
changeset
|
34 | #include "plugins.h" |
| 6350 | 35 | #include "util.h" |
| 9943 | 36 | #include "version.h" |
|
9030
7b574a641391
[gaim-migrate @ 9806]
Mark Doliner <markdoliner@pidgin.im>
parents:
9015
diff
changeset
|
37 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
38 | #include "irc.h" |
|
4422
d7d5938502f0
[gaim-migrate @ 4695]
Nicolás Lichtmaier <nico@lichtmaier.com.ar>
parents:
4416
diff
changeset
|
39 | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
40 | #define PING_TIMEOUT 60 |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
41 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
42 | static void irc_ison_buddy_init(char *name, struct irc_buddy *ib, GList **list); |
| 2086 | 43 | |
| 15884 | 44 | static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b); |
| 45 | static GList *irc_status_types(PurpleAccount *account); | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
46 | static GList *irc_get_actions(PurpleConnection *gc); |
| 15884 | 47 | /* static GList *irc_chat_info(PurpleConnection *gc); */ |
| 48 | static void irc_login(PurpleAccount *account); | |
| 49 | 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
|
50 | static void irc_login_cb(gpointer data, gint source, const gchar *error_message); |
| 15884 | 51 | static void irc_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error, gpointer data); |
| 52 | static void irc_close(PurpleConnection *gc); | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
53 | static int irc_im_send(PurpleConnection *gc, PurpleMessage *msg); |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
54 | static int irc_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg); |
| 15884 | 55 | static void irc_chat_join (PurpleConnection *gc, GHashTable *data); |
| 56 | static void irc_input_cb(gpointer data, gint source, PurpleInputCondition cond); | |
| 57 | static void irc_input_cb_ssl(gpointer data, PurpleSslConnection *gsc, PurpleInputCondition cond); | |
| 3751 | 58 | |
| 7711 | 59 | static guint irc_nick_hash(const char *nick); |
| 60 | static gboolean irc_nick_equal(const char *nick1, const char *nick2); | |
| 61 | static void irc_buddy_free(struct irc_buddy *ib); | |
| 62 | ||
|
36544
1bf8b6ef5aea
Renamed PurplePluginProtocolInfo to PurpleProtocol
Ankit Vani <a@nevitus.org>
parents:
36543
diff
changeset
|
63 | PurpleProtocol *_irc_protocol = NULL; |
| 7711 | 64 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
65 | static void irc_view_motd(PurpleProtocolAction *action) |
| 7148 | 66 | { |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
67 | PurpleConnection *gc = action->connection; |
| 7148 | 68 | struct irc_conn *irc; |
| 69 | char *title; | |
| 70 | ||
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
71 | if (gc == NULL || purple_connection_get_protocol_data(gc) == NULL) { |
| 15884 | 72 | purple_debug(PURPLE_DEBUG_ERROR, "irc", "got MOTD request for NULL gc\n"); |
| 7148 | 73 | return; |
| 74 | } | |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
75 | irc = purple_connection_get_protocol_data(gc); |
| 7148 | 76 | if (irc->motd == NULL) { |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
77 | purple_notify_error(gc, _("Error displaying MOTD"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
78 | _("No MOTD available"), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
79 | _("There is no MOTD associated with this connection."), |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34321
diff
changeset
|
80 | purple_request_cpar_from_connection(gc)); |
| 7148 | 81 | return; |
| 82 | } | |
| 83 | title = g_strdup_printf(_("MOTD for %s"), irc->server); | |
| 15884 | 84 | purple_notify_formatted(gc, title, title, NULL, irc->motd->str, NULL, NULL); |
|
14534
c9d0843d8c19
[gaim-migrate @ 17188]
Daniel Atallah <datallah@pidgin.im>
parents:
14324
diff
changeset
|
85 | g_free(title); |
| 7148 | 86 | } |
| 87 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
88 | static int do_send(struct irc_conn *irc, const char *buf, gsize len) |
| 3751 | 89 | { |
| 9440 | 90 | int ret; |
| 91 | ||
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
92 | if (irc->gsc) { |
| 15884 | 93 | ret = purple_ssl_write(irc->gsc, buf, len); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
94 | } else { |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
95 | ret = write(irc->fd, buf, len); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
96 | } |
|
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 | return ret; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
99 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
100 | |
| 15884 | 101 | static int irc_send_raw(PurpleConnection *gc, const char *buf, int len) |
| 14604 | 102 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
103 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
31929
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
104 | if (len == -1) { |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
105 | len = strlen(buf); |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
106 | } |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
107 | 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
|
108 | return len; |
| 14604 | 109 | } |
| 110 | ||
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
111 | static void |
| 15884 | 112 | irc_send_cb(gpointer data, gint source, PurpleInputCondition cond) |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
113 | { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
114 | struct irc_conn *irc = data; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
115 | int ret, writelen; |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
116 | const gchar *buffer = NULL; |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
117 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
118 | writelen = purple_circular_buffer_get_max_read(irc->outbuf); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
119 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
120 | if (writelen == 0) { |
| 15884 | 121 | purple_input_remove(irc->writeh); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
122 | irc->writeh = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
123 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
124 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
125 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
126 | buffer = purple_circular_buffer_get_output(irc->outbuf); |
|
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
127 | |
|
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
128 | ret = do_send(irc, buffer, writelen); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
129 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
130 | if (ret < 0 && errno == EAGAIN) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
131 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
132 | else if (ret <= 0) { |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
133 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
134 | 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
|
135 | g_strerror(errno)); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
136 | purple_connection_error (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
137 | 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
|
138 | g_free(tmp); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
139 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
140 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
141 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
142 | purple_circular_buffer_mark_read(irc->outbuf, ret); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
143 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
144 | #if 0 |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
145 | /* We *could* try to write more if we wrote it all */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
146 | if (ret == write_len) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
147 | irc_send_cb(data, source, cond); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
148 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
149 | #endif |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
150 | } |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
151 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
152 | int irc_send(struct irc_conn *irc, const char *buf) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
153 | { |
|
31929
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
154 | 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
|
155 | } |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
156 | |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
157 | int irc_send_len(struct irc_conn *irc, const char *buf, int buflen) |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
158 | { |
|
3c1f2bba1933
Fix races between irc_send_raw() and normal prpl-internal sends.
Ethan Blanton <elb@pidgin.im>
parents:
31646
diff
changeset
|
159 | int ret; |
| 14683 | 160 | char *tosend= g_strdup(buf); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
161 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
162 | purple_signal_emit(_irc_protocol, "irc-sending-text", purple_account_get_connection(irc->account), &tosend); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
163 | |
| 14683 | 164 | if (tosend == NULL) |
| 165 | return 0; | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
166 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
167 | /* If we're not buffering writes, try to send immediately */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
168 | if (!irc->writeh) |
| 14683 | 169 | ret = do_send(irc, tosend, buflen); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
170 | else { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
171 | ret = -1; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
172 | errno = EAGAIN; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
173 | } |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2171
diff
changeset
|
174 | |
| 15884 | 175 | /* purple_debug(PURPLE_DEBUG_MISC, "irc", "sent%s: %s", |
| 14683 | 176 | irc->gsc ? " (ssl)" : "", tosend); */ |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
177 | if (ret <= 0 && errno != EAGAIN) { |
|
20440
42e5e5445a2f
Move prpl-irc to purple_connection_error_reason.
Will Thompson <resiak@pidgin.im>
parents:
19859
diff
changeset
|
178 | PurpleConnection *gc = purple_account_get_connection(irc->account); |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
179 | 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
|
180 | g_strerror(errno)); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
181 | purple_connection_error (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
182 | 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
|
183 | g_free(tmp); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
184 | } else if (ret < buflen) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
185 | if (ret < 0) |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
186 | ret = 0; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
187 | if (!irc->writeh) |
| 15884 | 188 | irc->writeh = purple_input_add( |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
189 | irc->gsc ? irc->gsc->fd : irc->fd, |
| 15884 | 190 | PURPLE_INPUT_WRITE, irc_send_cb, irc); |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
191 | purple_circular_buffer_append(irc->outbuf, tosend + ret, |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
192 | buflen - ret); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
193 | } |
| 14683 | 194 | g_free(tosend); |
| 9440 | 195 | return ret; |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2171
diff
changeset
|
196 | } |
|
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2171
diff
changeset
|
197 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
198 | /* XXX I don't like messing directly with these buddies */ |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
199 | gboolean irc_blist_timeout(struct irc_conn *irc) |
| 2086 | 200 | { |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
201 | if (irc->ison_outstanding) { |
|
2137
b0c18ea1dee8
[gaim-migrate @ 2147]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2131
diff
changeset
|
202 | return TRUE; |
| 2086 | 203 | } |
|
4416
008b56d257e1
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
204 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
205 | 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
|
206 | (gpointer *)&irc->buddies_outstanding); |
|
4416
008b56d257e1
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
207 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
208 | irc_buddy_query(irc); |
|
21736
8de85200908d
applied changes from 5dc4cf40c038206bcf06fe7407e1e308b0264e32
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21503
diff
changeset
|
209 | |
|
2131
ef072ae1b2b8
[gaim-migrate @ 2141]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2123
diff
changeset
|
210 | return TRUE; |
| 2086 | 211 | } |
| 212 | ||
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
213 | void irc_buddy_query(struct irc_conn *irc) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
214 | { |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
215 | GList *lp; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
216 | GString *string; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
217 | struct irc_buddy *ib; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
218 | char *buf; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
219 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
220 | 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
|
221 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
222 | 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
|
223 | 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
|
224 | 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
|
225 | break; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
226 | 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
|
227 | ib->new_online_status = FALSE; |
|
35758
87c51487e197
Fix g_slist_remove_link misuse, remove debug printfs
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35499
diff
changeset
|
228 | irc->buddies_outstanding = g_list_delete_link(irc->buddies_outstanding, lp); |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
229 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
230 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
231 | if (string->len) { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
232 | 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
|
233 | irc_send(irc, buf); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
234 | g_free(buf); |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
235 | irc->ison_outstanding = TRUE; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
236 | } else |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
237 | irc->ison_outstanding = FALSE; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
238 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
239 | 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
|
240 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
241 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
242 | 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
|
243 | { |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
244 | *list = g_list_append(*list, ib); |
| 3511 | 245 | } |
| 246 | ||
|
31565
1138b2c998ec
propagate from branch 'im.pidgin.pidgin' (head e131c2da768d5bd01e4bcb33b488a43ffd378208)
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
31451
diff
changeset
|
247 | |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
248 | 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
|
249 | { |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
250 | char *buf; |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
251 | |
|
31284
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
252 | 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
|
253 | 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
|
254 | return; |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
255 | } |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
256 | |
|
893f2d78d438
Prevent sending ISON messages larger than 512 bytes. Fixes #9692.
Jeffrey Honig <jch@honig.net>
parents:
30138
diff
changeset
|
257 | ib->new_online_status = FALSE; |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
258 | buf = irc_format(irc, "vn", "ISON", ib->name); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
259 | irc_send(irc, buf); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
260 | g_free(buf); |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
261 | } |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
262 | |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
263 | |
| 15884 | 264 | static const char *irc_blist_icon(PurpleAccount *a, PurpleBuddy *b) |
| 3029 | 265 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
266 | return "irc"; |
|
2339
b42203c69d52
[gaim-migrate @ 2352]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2331
diff
changeset
|
267 | } |
|
b42203c69d52
[gaim-migrate @ 2352]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2331
diff
changeset
|
268 | |
| 15884 | 269 | static GList *irc_status_types(PurpleAccount *account) |
| 2086 | 270 | { |
| 15884 | 271 | PurpleStatusType *type; |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
272 | GList *types = NULL; |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
273 | |
| 15884 | 274 | 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
|
275 | types = g_list_append(types, type); |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
276 | |
| 15884 | 277 | type = purple_status_type_new_with_attrs( |
| 278 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
|
35005
bff56dfca65d
Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
279 | "message", _("Message"), purple_value_new(G_TYPE_STRING), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12323
diff
changeset
|
280 | NULL); |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
281 | types = g_list_append(types, type); |
|
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
282 | |
| 15884 | 283 | 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
|
284 | types = g_list_append(types, type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
285 | |
|
9944
71ef020ec4b0
[gaim-migrate @ 10838]
Christian Hammond <chipx86@chipx86.com>
parents:
9943
diff
changeset
|
286 | return types; |
| 3452 | 287 | } |
| 288 | ||
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
289 | static GList *irc_get_actions(PurpleConnection *gc) |
| 7148 | 290 | { |
| 291 | GList *list = NULL; | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
292 | PurpleProtocolAction *act = NULL; |
| 7148 | 293 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
294 | act = purple_protocol_action_new(_("View MOTD"), irc_view_motd); |
|
9015
3c27e9074fa2
[gaim-migrate @ 9791]
Christopher O'Brien <siege@pidgin.im>
parents:
8993
diff
changeset
|
295 | list = g_list_append(list, act); |
| 7148 | 296 | |
| 297 | return list; | |
| 298 | } | |
| 299 | ||
| 15884 | 300 | static GList *irc_chat_join_info(PurpleConnection *gc) |
| 2086 | 301 | { |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
302 | GList *m = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
303 | PurpleProtocolChatEntry *pce; |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
304 | |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
305 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7711
diff
changeset
|
306 | pce->label = _("_Channel:"); |
| 5234 | 307 | pce->identifier = "channel"; |
|
10954
cd5771cb6cf8
[gaim-migrate @ 12754]
Richard Laager <rlaager@pidgin.im>
parents:
10903
diff
changeset
|
308 | pce->required = TRUE; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
309 | m = g_list_append(m, pce); |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
310 | |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
311 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7711
diff
changeset
|
312 | pce->label = _("_Password:"); |
| 5234 | 313 | pce->identifier = "password"; |
| 6499 | 314 | pce->secret = TRUE; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
315 | m = g_list_append(m, pce); |
|
2170
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
316 | |
|
5c93594ff522
[gaim-migrate @ 2180]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2167
diff
changeset
|
317 | return m; |
| 2086 | 318 | } |
| 319 | ||
| 15884 | 320 | 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
|
321 | { |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
322 | GHashTable *defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
323 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
324 | 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
|
325 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
326 | if (chat_name != NULL) |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
327 | g_hash_table_insert(defaults, "channel", g_strdup(chat_name)); |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
328 | |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
329 | return defaults; |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
330 | } |
|
3a17eee239b2
[gaim-migrate @ 10621]
Nathan Fredrickson <nathan@silverorange.com>
parents:
9741
diff
changeset
|
331 | |
| 15884 | 332 | static void irc_login(PurpleAccount *account) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
333 | { |
| 15884 | 334 | PurpleConnection *gc; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
335 | struct irc_conn *irc; |
| 10494 | 336 | char **userparts; |
| 15884 | 337 | const char *username = purple_account_get_username(account); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
338 | |
| 15884 | 339 | gc = purple_account_get_connection(account); |
|
36055
33978dc8ef6f
Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
340 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_NO_NEWLINES | |
|
33978dc8ef6f
Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35758
diff
changeset
|
341 | PURPLE_CONNECTION_FLAG_NO_IMAGES); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
342 | |
| 6752 | 343 | if (strpbrk(username, " \t\v\r\n") != NULL) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
344 | purple_connection_error (gc, |
| 21279 | 345 | 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
|
346 | _("IRC nick and server may not contain whitespace")); |
| 6752 | 347 | return; |
| 348 | } | |
| 349 | ||
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
350 | irc = g_new0(struct irc_conn, 1); |
|
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
351 | purple_connection_set_protocol_data(gc, irc); |
|
10960
add2b4dbaa36
[gaim-migrate @ 12763]
Richard Laager <rlaager@pidgin.im>
parents:
10954
diff
changeset
|
352 | irc->fd = -1; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
353 | irc->account = account; |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
354 | irc->outbuf = purple_circular_buffer_new(512); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
355 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
356 | userparts = g_strsplit(username, "@", 2); |
| 15884 | 357 | purple_connection_set_display_name(gc, userparts[0]); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
358 | irc->server = g_strdup(userparts[1]); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
359 | g_strfreev(userparts); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
360 | |
|
10159
5e8afc7db137
[gaim-migrate @ 11240]
Mark Doliner <markdoliner@pidgin.im>
parents:
10010
diff
changeset
|
361 | 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
|
362 | NULL, (GDestroyNotify)irc_buddy_free); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
363 | 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
|
364 | irc_cmd_table_build(irc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
365 | 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
|
366 | irc_msg_table_build(irc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
367 | |
| 15884 | 368 | purple_connection_update_progress(gc, _("Connecting"), 1, 2); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
369 | |
| 15884 | 370 | if (purple_account_get_bool(account, "ssl", FALSE)) { |
| 371 | if (purple_ssl_is_supported()) { | |
| 372 | irc->gsc = purple_ssl_connect(account, irc->server, | |
| 373 | purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT), | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
374 | irc_login_cb_ssl, irc_ssl_connect_failure, gc); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
375 | } else { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
376 | purple_connection_error (gc, |
| 21279 | 377 | 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
|
378 | _("SSL support unavailable")); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
379 | return; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
380 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
381 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
382 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
383 | if (!irc->gsc) { |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
384 | |
| 15884 | 385 | if (purple_proxy_connect(gc, account, irc->server, |
| 386 | purple_account_get_int(account, "port", IRC_DEFAULT_PORT), | |
|
14899
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14684
diff
changeset
|
387 | irc_login_cb, gc) == NULL) |
|
c65f0b4fb351
[gaim-migrate @ 17606]
Mark Doliner <markdoliner@pidgin.im>
parents:
14684
diff
changeset
|
388 | { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
389 | purple_connection_error (gc, |
| 21279 | 390 | PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
|
27635
0cd19038c417
More uniformity among disconnect error messages
Mark Doliner <markdoliner@pidgin.im>
parents:
27627
diff
changeset
|
391 | _("Unable to connect")); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
392 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
393 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
394 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
395 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
396 | |
| 15884 | 397 | 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
|
398 | 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
|
399 | char *server; |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
400 | const char *nickname, *identname, *realname; |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
401 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
| 15884 | 402 | const char *pass = purple_connection_get_password(gc); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
403 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
404 | 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
|
405 | #endif |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
406 | |
| 10555 | 407 | if (pass && *pass) { |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
408 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
409 | if (use_sasl) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
410 | 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
|
411 | else /* intended to fall through */ |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
412 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
413 | buf = irc_format(irc, "v:", "PASS", pass); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
414 | if (irc_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
415 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
416 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
417 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
418 | g_free(buf); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
419 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
420 | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
421 | 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
|
422 | identname = purple_account_get_string(irc->account, "username", ""); |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
423 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
424 | if (identname == NULL || *identname == '\0') { |
|
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
425 | identname = g_get_user_name(); |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
426 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
427 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
428 | if (identname != NULL && strchr(identname, ' ') != NULL) { |
|
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
429 | 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
|
430 | 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
|
431 | *buf = '_'; |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
432 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
433 | } |
|
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
434 | |
|
23905
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
435 | if (*irc->server == ':') { |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
436 | /* Same as hostname, above. */ |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
437 | 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
|
438 | } else { |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
439 | 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
|
440 | } |
|
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
441 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
442 | buf = irc_format(irc, "vvvv:", "USER", tmp ? tmp : identname, "*", server, |
|
23905
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
443 | strlen(realname) ? realname : IRC_DEFAULT_ALIAS); |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
444 | g_free(tmp); |
|
23905
5c736d337ee0
Escape IRC hostnames beginning with : in the USER command. This
Ethan Blanton <elb@pidgin.im>
parents:
23850
diff
changeset
|
445 | g_free(server); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
446 | if (irc_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
447 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
448 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
449 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
450 | g_free(buf); |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
451 | nickname = purple_connection_get_display_name(gc); |
|
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
452 | buf = irc_format(irc, "vn", "NICK", nickname); |
|
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
453 | 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
|
454 | irc->nickused = FALSE; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
455 | if (irc_send(irc, buf) < 0) { |
|
10903
7d32f4448a95
[gaim-migrate @ 12630]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10740
diff
changeset
|
456 | g_free(buf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
457 | return FALSE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
458 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
459 | g_free(buf); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
460 | |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
461 | irc->recv_time = time(NULL); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
462 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
463 | return TRUE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
464 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
465 | |
| 15884 | 466 | static void irc_login_cb_ssl(gpointer data, PurpleSslConnection *gsc, |
| 467 | PurpleInputCondition cond) | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
468 | { |
| 15884 | 469 | PurpleConnection *gc = data; |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
470 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
471 | if (do_login(gc)) { |
| 15884 | 472 | purple_ssl_input_add(gsc, irc_input_cb_ssl, gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
473 | } |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
474 | } |
|
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
475 | |
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
476 | 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
|
477 | { |
| 15884 | 478 | PurpleConnection *gc = data; |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
479 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
480 | |
| 8778 | 481 | if (source < 0) { |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
482 | 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
|
483 | error_message); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
484 | purple_connection_error (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
485 | 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
|
486 | g_free(tmp); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
487 | return; |
| 8778 | 488 | } |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
489 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
490 | irc->fd = source; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
491 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
492 | if (do_login(gc)) { |
|
32682
d52f33b99db7
IRC: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32679
diff
changeset
|
493 | irc->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
|
494 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
495 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
496 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
497 | static void |
| 15884 | 498 | irc_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error, |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
499 | gpointer data) |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
500 | { |
| 15884 | 501 | PurpleConnection *gc = data; |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
502 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
503 | |
|
14310
a71aba2f6249
[gaim-migrate @ 16930]
Mark Doliner <markdoliner@pidgin.im>
parents:
14309
diff
changeset
|
504 | irc->gsc = NULL; |
|
a71aba2f6249
[gaim-migrate @ 16930]
Mark Doliner <markdoliner@pidgin.im>
parents:
14309
diff
changeset
|
505 | |
|
20444
cc02f15b7a91
Use purple_connection_ssl_error in prpl-irc
Will Thompson <resiak@pidgin.im>
parents:
20441
diff
changeset
|
506 | purple_connection_ssl_error (gc, error); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
507 | } |
|
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
508 | |
| 15884 | 509 | static void irc_close(PurpleConnection *gc) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
510 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
511 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
512 | |
| 6752 | 513 | if (irc == NULL) |
| 514 | return; | |
| 515 | ||
|
14173
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
516 | if (irc->gsc || (irc->fd >= 0)) |
|
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
517 | irc_cmd_quit(irc, "quit", NULL, NULL); |
|
78aeb8fa1113
[gaim-migrate @ 16745]
Mark Doliner <markdoliner@pidgin.im>
parents:
14170
diff
changeset
|
518 | |
|
32682
d52f33b99db7
IRC: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32679
diff
changeset
|
519 | if (irc->inpa) { |
|
d52f33b99db7
IRC: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32679
diff
changeset
|
520 | purple_input_remove(irc->inpa); |
|
d52f33b99db7
IRC: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32679
diff
changeset
|
521 | irc->inpa = 0; |
|
d52f33b99db7
IRC: Move the "inpa" input watcher into protocol_data.
Andrew Victor <andrew.victor@mxit.com>
parents:
32679
diff
changeset
|
522 | } |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
523 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
524 | g_free(irc->inbuf); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
525 | if (irc->gsc) { |
| 15884 | 526 | purple_ssl_close(irc->gsc); |
|
14222
71d8761db708
[gaim-migrate @ 16808]
Mark Doliner <markdoliner@pidgin.im>
parents:
14173
diff
changeset
|
527 | } else if (irc->fd >= 0) { |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
528 | close(irc->fd); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
529 | } |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
530 | if (irc->timer) |
| 15884 | 531 | purple_timeout_remove(irc->timer); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
532 | g_hash_table_destroy(irc->cmds); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
533 | g_hash_table_destroy(irc->msgs); |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
534 | g_hash_table_destroy(irc->buddies); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
535 | if (irc->motd) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
536 | g_string_free(irc->motd, TRUE); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
537 | g_free(irc->server); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
538 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
539 | if (irc->writeh) |
| 15884 | 540 | purple_input_remove(irc->writeh); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
541 | |
|
34529
68cf25486001
GObjectify PurpleCircBuffer as PurpleCircularBuffer (from gobjectification branch)
Ankit Vani <a@nevitus.org>
parents:
33600
diff
changeset
|
542 | g_object_unref(G_OBJECT(irc->outbuf)); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
543 | |
|
16167
8536102557ba
Make non-standard mode characters support connection-specific instead of
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15884
diff
changeset
|
544 | 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
|
545 | 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
|
546 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
547 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
548 | if (irc->sasl_conn) { |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
549 | sasl_dispose(&irc->sasl_conn); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
550 | irc->sasl_conn = NULL; |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
551 | } |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
552 | g_free(irc->sasl_cb); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
553 | if(irc->sasl_mechs) |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
554 | g_string_free(irc->sasl_mechs, TRUE); |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
555 | #endif |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
556 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
557 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
558 | g_free(irc); |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
559 | } |
|
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
560 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
561 | static int irc_im_send(PurpleConnection *gc, PurpleMessage *msg) |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
562 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
563 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
564 | char *plain; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
565 | const char *args[2]; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
566 | |
|
36098
4951752ad038
Split PurpleMessage into incoming, outgoing and system
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36078
diff
changeset
|
567 | args[0] = irc_nick_skip_mode(irc, purple_message_get_recipient(msg)); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
568 | |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
569 | purple_markup_html_to_xhtml(purple_message_get_contents(msg), |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
570 | NULL, &plain); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
571 | args[1] = plain; |
| 9442 | 572 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
573 | irc_cmd_privmsg(irc, "msg", NULL, args); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
574 | g_free(plain); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
575 | return 1; |
|
2289
0af7cf95a25d
[gaim-migrate @ 2299]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2273
diff
changeset
|
576 | } |
| 2086 | 577 | |
| 15884 | 578 | static void irc_get_info(PurpleConnection *gc, const char *who) |
| 2086 | 579 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
580 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
10618
6613664e683c
[gaim-migrate @ 12083]
Daniel Atallah <datallah@pidgin.im>
parents:
10555
diff
changeset
|
581 | const char *args[2]; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
582 | args[0] = who; |
| 10624 | 583 | args[1] = NULL; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
584 | irc_cmd_whois(irc, "whois", NULL, args); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
585 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
586 | |
| 15884 | 587 | static void irc_set_status(PurpleAccount *account, PurpleStatus *status) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
588 | { |
| 15884 | 589 | PurpleConnection *gc = purple_account_get_connection(account); |
|
13438
f57f4ecc3302
[gaim-migrate @ 15812]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
590 | struct irc_conn *irc; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
591 | const char *args[1]; |
| 15884 | 592 | const char *status_id = purple_status_get_id(status); |
| 2086 | 593 | |
|
13438
f57f4ecc3302
[gaim-migrate @ 15812]
Richard Laager <rlaager@pidgin.im>
parents:
13297
diff
changeset
|
594 | g_return_if_fail(gc != NULL); |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
595 | irc = purple_connection_get_protocol_data(gc); |
| 10646 | 596 | |
| 15884 | 597 | if (!purple_status_is_active(status)) |
|
10504
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
598 | return; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
599 | |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
600 | args[0] = NULL; |
|
eae130eefbfe
[gaim-migrate @ 11796]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10494
diff
changeset
|
601 | |
|
11718
90804d019837
[gaim-migrate @ 14009]
Mark Doliner <markdoliner@pidgin.im>
parents:
11522
diff
changeset
|
602 | if (!strcmp(status_id, "away")) { |
| 15884 | 603 | args[0] = purple_status_get_attr_string(status, "message"); |
|
12001
512c45efaccb
[gaim-migrate @ 14294]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
604 | if ((args[0] == NULL) || (*args[0] == '\0')) |
|
512c45efaccb
[gaim-migrate @ 14294]
Mark Doliner <markdoliner@pidgin.im>
parents:
11837
diff
changeset
|
605 | args[0] = _("Away"); |
| 10646 | 606 | irc_cmd_away(irc, "away", NULL, args); |
|
12210
d7e2c9f73e16
[gaim-migrate @ 14512]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
607 | } else if (!strcmp(status_id, "available")) { |
|
d7e2c9f73e16
[gaim-migrate @ 14512]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12143
diff
changeset
|
608 | irc_cmd_away(irc, "back", NULL, args); |
| 10646 | 609 | } |
| 4916 | 610 | } |
| 611 | ||
|
32315
2550a39e0285
Rename the _with_invite functions to their counterparts.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32276
diff
changeset
|
612 | static void irc_add_buddy(PurpleConnection *gc, PurpleBuddy *buddy, PurpleGroup *group, const char *message) |
| 3029 | 613 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
614 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
615 | struct irc_buddy *ib; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
616 | 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
|
617 | |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
618 | 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
|
619 | if (ib != NULL) { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
620 | ib->ref++; |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
621 | purple_protocol_got_user_status(irc->account, bname, |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
622 | ib->online ? "available" : "offline", NULL); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
623 | } else { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
624 | 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
|
625 | ib->name = g_strdup(bname); |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
626 | ib->ref = 1; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
627 | 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
|
628 | } |
| 9238 | 629 | |
|
9553
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
630 | /* 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
|
631 | * 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
|
632 | * someone's online asap */ |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
633 | if (irc->timer) |
|
146d83b7512b
[gaim-migrate @ 10386]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9475
diff
changeset
|
634 | irc_ison_one(irc, ib); |
| 3029 | 635 | } |
| 3622 | 636 | |
| 15884 | 637 | 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
|
638 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
639 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
28118
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
640 | struct irc_buddy *ib; |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
641 | |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
642 | 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
|
643 | if (ib && --ib->ref == 0) { |
|
ba26e203a9ca
irc: Handle a buddy appearing in multiple groups properly.
Paul Aurich <darkrain42@pidgin.im>
parents:
27635
diff
changeset
|
644 | 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
|
645 | } |
| 3616 | 646 | } |
|
4514
40e3588a280f
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
647 | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
648 | static void read_input(struct irc_conn *irc, int len) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
649 | { |
|
32624
f957ad287bcc
Convert code to use the purple_account accessor functions.
Andrew Victor <andrew.victor@mxit.com>
parents:
32617
diff
changeset
|
650 | PurpleConnection *connection = purple_account_get_connection(irc->account); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
651 | char *cur, *end; |
| 6369 | 652 | |
|
32679
fd936a0b84f7
Add a purple_connection_update_last_received() function to update the
Andrew Victor <andrew.victor@mxit.com>
parents:
32678
diff
changeset
|
653 | purple_connection_update_last_received(connection); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
654 | irc->inbufused += len; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
655 | irc->inbuf[irc->inbufused] = '\0'; |
| 3616 | 656 | |
| 8156 | 657 | cur = irc->inbuf; |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
658 | |
| 12752 | 659 | /* This is a hack to work around the fact that marv gets messages |
| 660 | * with null bytes in them while using some weird irc server at work | |
| 661 | */ | |
| 662 | while ((cur < (irc->inbuf + irc->inbufused)) && !*cur) | |
| 663 | cur++; | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
664 | |
| 8156 | 665 | while (cur < irc->inbuf + irc->inbufused && |
| 666 | ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) { | |
| 667 | int step = (*end == '\r' ? 2 : 1); | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
668 | *end = '\0'; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
669 | irc_parse_msg(irc, cur); |
| 8156 | 670 | cur = end + step; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
671 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
672 | if (cur != irc->inbuf + irc->inbufused) { /* leftover */ |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
673 | irc->inbufused -= (cur - irc->inbuf); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
674 | memmove(irc->inbuf, cur, irc->inbufused); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
675 | } else { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
676 | irc->inbufused = 0; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
677 | } |
| 3616 | 678 | } |
| 679 | ||
| 15884 | 680 | static void irc_input_cb_ssl(gpointer data, PurpleSslConnection *gsc, |
| 681 | PurpleInputCondition cond) | |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
682 | { |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
683 | |
| 15884 | 684 | PurpleConnection *gc = data; |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
685 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
686 | int len; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
687 | |
|
18122
9bf9970c1b6a
disapproval of revision '2d8ea56b90971e7851442d96b7d74ecb4f052126'
Richard Laager <rlaager@pidgin.im>
parents:
18121
diff
changeset
|
688 | if(!g_list_find(purple_connections_get_all(), gc)) { |
| 15884 | 689 | purple_ssl_close(gsc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
690 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
691 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
692 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
693 | if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
694 | irc->inbuflen += IRC_INITIAL_BUFSIZE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
695 | irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
696 | } |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
697 | |
| 15884 | 698 | len = purple_ssl_read(gsc, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1); |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
699 | |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
700 | if (len < 0 && errno == EAGAIN) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
701 | /* Try again later */ |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
702 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
703 | } 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
|
704 | 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
|
705 | g_strerror(errno)); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
706 | purple_connection_error (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
707 | 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
|
708 | g_free(tmp); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
709 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
710 | } else if (len == 0) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
711 | purple_connection_error (gc, |
| 21279 | 712 | 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
|
713 | _("Server closed the connection")); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
714 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
715 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
716 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
717 | read_input(irc, len); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
718 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
719 | |
| 15884 | 720 | 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
|
721 | { |
| 15884 | 722 | PurpleConnection *gc = data; |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
723 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
724 | int len; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
725 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
726 | if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
727 | irc->inbuflen += IRC_INITIAL_BUFSIZE; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
728 | irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
729 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
730 | |
|
13201
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
731 | len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1); |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
732 | if (len < 0 && errno == EAGAIN) { |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
733 | return; |
|
8c224ef70efa
[gaim-migrate @ 15563]
Daniel Atallah <datallah@pidgin.im>
parents:
12752
diff
changeset
|
734 | } 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
|
735 | 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
|
736 | g_strerror(errno)); |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
737 | purple_connection_error (gc, |
|
27627
244455b1897f
Similar connection error message changes for IRC. These are hopefully
Mark Doliner <markdoliner@pidgin.im>
parents:
27184
diff
changeset
|
738 | 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
|
739 | g_free(tmp); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
740 | return; |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
741 | } else if (len == 0) { |
|
32157
39ba2e2492ee
Rename purple_connection_error_reason to purple_connection_error
Mark Doliner <markdoliner@pidgin.im>
parents:
31950
diff
changeset
|
742 | purple_connection_error (gc, |
| 21279 | 743 | 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
|
744 | _("Server closed the connection")); |
|
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 | |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
748 | read_input(irc, len); |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
749 | } |
|
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
750 | |
| 15884 | 751 | static void irc_chat_join (PurpleConnection *gc, GHashTable *data) |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
752 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
753 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
754 | const char *args[2]; |
| 3616 | 755 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
756 | args[0] = g_hash_table_lookup(data, "channel"); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
757 | args[1] = g_hash_table_lookup(data, "password"); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
758 | irc_cmd_join(irc, "join", NULL, args); |
| 3622 | 759 | } |
| 760 | ||
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
761 | static char *irc_get_chat_name(GHashTable *data) { |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
762 | return g_strdup(g_hash_table_lookup(data, "channel")); |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
763 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
764 | |
|
17077
87eae71a31a5
Don't allow IRC username to contain spaces. Fixes #443.
Daniel Atallah <datallah@pidgin.im>
parents:
16746
diff
changeset
|
765 | static void irc_chat_invite(PurpleConnection *gc, int id, const char *message, const char *name) |
| 3751 | 766 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
767 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
768 | PurpleConversation *convo = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, id)); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
769 | const char *args[2]; |
| 3751 | 770 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
771 | if (!convo) { |
| 15884 | 772 | 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
|
773 | return; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
774 | } |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
775 | args[0] = name; |
| 15884 | 776 | args[1] = purple_conversation_get_name(convo); |
| 777 | irc_cmd_invite(irc, "invite", purple_conversation_get_name(convo), args); | |
| 3707 | 778 | } |
| 779 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
780 | |
| 15884 | 781 | static void irc_chat_leave (PurpleConnection *gc, int id) |
| 3707 | 782 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
783 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
784 | PurpleConversation *convo = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, id)); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
785 | const char *args[2]; |
| 5298 | 786 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
787 | if (!convo) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
788 | return; |
| 3735 | 789 | |
| 15884 | 790 | args[0] = purple_conversation_get_name(convo); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
791 | args[1] = NULL; |
| 15884 | 792 | irc_cmd_part(irc, "part", purple_conversation_get_name(convo), args); |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35265
diff
changeset
|
793 | purple_serv_got_chat_left(gc, id); |
| 3735 | 794 | } |
| 795 | ||
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
796 | static int irc_chat_send(PurpleConnection *gc, int id, PurpleMessage *msg) |
| 3735 | 797 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
798 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
799 | PurpleConversation *convo = PURPLE_CONVERSATION(purple_conversations_find_chat(gc, id)); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
800 | const char *args[2]; |
| 8163 | 801 | char *tmp; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
802 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
803 | if (!convo) { |
| 15884 | 804 | 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
|
805 | return -EINVAL; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
806 | } |
| 9130 | 807 | #if 0 |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
808 | if (*what == '/') { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
809 | return irc_parse_cmd(irc, convo->name, what + 1); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
810 | } |
| 9130 | 811 | #endif |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
812 | purple_markup_html_to_xhtml(purple_message_get_contents(msg), NULL, &tmp); |
|
32617
c74b4bd27e37
Use purple_conversation accessor methods.
Andrew Victor <andrew.victor@mxit.com>
parents:
32338
diff
changeset
|
813 | args[0] = purple_conversation_get_name(convo); |
|
12216
d80739091a63
[gaim-migrate @ 14518]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
12210
diff
changeset
|
814 | args[1] = tmp; |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
815 | |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
816 | irc_cmd_privmsg(irc, "msg", NULL, args); |
| 8163 | 817 | |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
818 | /* TODO: use msg */ |
|
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
819 | purple_serv_got_chat_in(gc, id, purple_connection_get_display_name(gc), |
|
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
820 | purple_message_get_flags(msg), |
|
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
821 | purple_message_get_contents(msg), time(NULL)); |
| 8163 | 822 | g_free(tmp); |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
823 | return 0; |
| 3707 | 824 | } |
| 825 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
826 | static guint irc_nick_hash(const char *nick) |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
827 | { |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
828 | char *lc; |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
829 | guint bucket; |
|
6270
e3cb3b0c6c82
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
830 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
831 | lc = g_utf8_strdown(nick, -1); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
832 | bucket = g_str_hash(lc); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
833 | g_free(lc); |
|
6270
e3cb3b0c6c82
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
834 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
835 | return bucket; |
| 3029 | 836 | } |
| 837 | ||
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
838 | 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
|
839 | { |
| 15884 | 840 | return (purple_utf8_strcasecmp(nick1, nick2) == 0); |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
841 | } |
|
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
842 | |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
843 | static void irc_buddy_free(struct irc_buddy *ib) |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
844 | { |
|
6333
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
845 | g_free(ib->name); |
|
551f4a5b3c33
[gaim-migrate @ 6832]
Robert McQueen <robot101@debian.org>
parents:
6321
diff
changeset
|
846 | g_free(ib); |
|
2619
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
847 | } |
|
5d8a8feb4ad1
[gaim-migrate @ 2632]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2617
diff
changeset
|
848 | |
| 15884 | 849 | static void irc_chat_set_topic(PurpleConnection *gc, int id, const char *topic) |
| 9154 | 850 | { |
| 851 | char *buf; | |
| 852 | const char *name = NULL; | |
| 853 | struct irc_conn *irc; | |
| 854 | ||
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
855 | irc = purple_connection_get_protocol_data(gc); |
|
34632
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
856 | name = purple_conversation_get_name(PURPLE_CONVERSATION( |
|
ebe6b2a60305
Changed all arguments and return types of Chat and IMs to PurpleChatConversation and PurpleIMConversation.
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
857 | purple_conversations_find_chat(gc, id))); |
| 9154 | 858 | |
| 859 | if (name == NULL) | |
| 860 | return; | |
| 861 | ||
| 862 | buf = irc_format(irc, "vt:", "TOPIC", name, topic); | |
| 863 | irc_send(irc, buf); | |
| 864 | g_free(buf); | |
| 865 | } | |
| 866 | ||
| 15884 | 867 | static PurpleRoomlist *irc_roomlist_get_list(PurpleConnection *gc) |
| 8114 | 868 | { |
| 869 | struct irc_conn *irc; | |
| 870 | GList *fields = NULL; | |
| 15884 | 871 | PurpleRoomlistField *f; |
| 8352 | 872 | char *buf; |
| 8114 | 873 | |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
874 | irc = purple_connection_get_protocol_data(gc); |
| 8114 | 875 | |
| 876 | if (irc->roomlist) | |
|
34932
1b74e5c63144
Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34904
diff
changeset
|
877 | g_object_unref(irc->roomlist); |
| 8114 | 878 | |
| 15884 | 879 | irc->roomlist = purple_roomlist_new(purple_connection_get_account(gc)); |
| 8114 | 880 | |
| 15884 | 881 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, "", "channel", TRUE); |
| 8114 | 882 | fields = g_list_append(fields, f); |
| 883 | ||
| 15884 | 884 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE); |
| 8114 | 885 | fields = g_list_append(fields, f); |
| 886 | ||
| 15884 | 887 | f = purple_roomlist_field_new(PURPLE_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE); |
| 8114 | 888 | fields = g_list_append(fields, f); |
| 889 | ||
| 15884 | 890 | purple_roomlist_set_fields(irc->roomlist, fields); |
| 8114 | 891 | |
| 8352 | 892 | buf = irc_format(irc, "v", "LIST"); |
| 893 | irc_send(irc, buf); | |
| 894 | g_free(buf); | |
| 8114 | 895 | |
| 896 | return irc->roomlist; | |
| 897 | } | |
| 898 | ||
| 15884 | 899 | static void irc_roomlist_cancel(PurpleRoomlist *list) |
| 8114 | 900 | { |
|
32218
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
901 | PurpleAccount *account = purple_roomlist_get_account(list); |
|
f27b05250351
Some struct hiding. What a pain.
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
902 | PurpleConnection *gc = purple_account_get_connection(account); |
| 8114 | 903 | struct irc_conn *irc; |
| 904 | ||
| 905 | if (gc == NULL) | |
| 906 | return; | |
| 907 | ||
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
908 | irc = purple_connection_get_protocol_data(gc); |
| 8114 | 909 | |
| 15884 | 910 | purple_roomlist_set_in_progress(list, FALSE); |
| 8114 | 911 | |
| 912 | if (irc->roomlist == list) { | |
| 913 | irc->roomlist = NULL; | |
|
34932
1b74e5c63144
Use g_object_{ref|unref} instead of purple_roomlist_{ref|unref}
Ankit Vani <a@nevitus.org>
parents:
34904
diff
changeset
|
914 | g_object_unref(list); |
| 8114 | 915 | } |
| 916 | } | |
| 917 | ||
| 15884 | 918 | static void irc_keepalive(PurpleConnection *gc) |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
919 | { |
|
32276
abc0b7c0cb86
Convert irc prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32218
diff
changeset
|
920 | struct irc_conn *irc = purple_connection_get_protocol_data(gc); |
|
14544
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
921 | if ((time(NULL) - irc->recv_time) > PING_TIMEOUT) |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
922 | irc_cmd_ping(irc, NULL, NULL, NULL); |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
923 | } |
|
847944da3ca0
[gaim-migrate @ 17201]
Daniel Atallah <datallah@pidgin.im>
parents:
14534
diff
changeset
|
924 | |
|
34321
f60fcab02bd4
Reconsidered characters count callback for prpl API: make it per-conversation and distinguish infinite from undefined
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
925 | static gssize |
|
f60fcab02bd4
Reconsidered characters count callback for prpl API: make it per-conversation and distinguish infinite from undefined
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
926 | irc_get_max_message_size(PurpleConversation *conv) |
|
34312
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33600
diff
changeset
|
927 | { |
|
34321
f60fcab02bd4
Reconsidered characters count callback for prpl API: make it per-conversation and distinguish infinite from undefined
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
928 | /* TODO: this static value is got from pidgin-otr, but it depends on |
|
f60fcab02bd4
Reconsidered characters count callback for prpl API: make it per-conversation and distinguish infinite from undefined
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
929 | * some factors, for example IRC channel name. */ |
|
34312
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33600
diff
changeset
|
930 | return 417; |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33600
diff
changeset
|
931 | } |
|
4461d5c1e61c
Extend prpl with max message length callback
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
33600
diff
changeset
|
932 | |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
933 | static void |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
934 | irc_protocol_init(PurpleProtocol *protocol) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
935 | { |
| 15884 | 936 | PurpleAccountUserSplit *split; |
| 937 | PurpleAccountOption *option; | |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
938 | |
| 37004 | 939 | protocol->id = "prpl-irc"; |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
940 | protocol->name = "IRC"; |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
941 | protocol->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
942 | OPT_PROTO_SLASH_COMMANDS_NATIVE; |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
943 | |
| 15884 | 944 | split = purple_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@'); |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
945 | protocol->user_splits = g_list_append(protocol->user_splits, split); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
946 | |
| 15884 | 947 | option = purple_account_option_int_new(_("Port"), "port", IRC_DEFAULT_PORT); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
948 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
5638
53e752c88ea1
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
949 | |
| 15884 | 950 | option = purple_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
951 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
952 | |
|
23906
6962e96ddd38
This adds an "auto-detect UTF-8" option to IRC which, when enabled,
Ethan Blanton <elb@pidgin.im>
parents:
23905
diff
changeset
|
953 | option = purple_account_option_bool_new(_("Auto-detect incoming UTF-8"), "autodetect_utf8", IRC_DEFAULT_AUTODETECT); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
954 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
23906
6962e96ddd38
This adds an "auto-detect UTF-8" option to IRC which, when enabled,
Ethan Blanton <elb@pidgin.im>
parents:
23905
diff
changeset
|
955 | |
|
35171
01b5caa9d79b
Change IRC Username label to Ident name
Andy Spencer <andy753421@gmail.com>
parents:
33404
diff
changeset
|
956 | option = purple_account_option_string_new(_("Ident name"), "username", ""); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
957 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 7323 | 958 | |
| 15884 | 959 | option = purple_account_option_string_new(_("Real name"), "realname", ""); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
960 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 10002 | 961 | |
| 11763 | 962 | /* |
| 15884 | 963 | option = purple_account_option_string_new(_("Quit message"), "quitmsg", IRC_DEFAULT_QUIT); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
964 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 11763 | 965 | */ |
| 966 | ||
| 15884 | 967 | option = purple_account_option_bool_new(_("Use SSL"), "ssl", FALSE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
968 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
10365
5b329161c730
[gaim-migrate @ 11583]
Daniel Atallah <datallah@pidgin.im>
parents:
10258
diff
changeset
|
969 | |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
970 | #ifdef HAVE_CYRUS_SASL |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
971 | option = purple_account_option_bool_new(_("Authenticate with SASL"), "sasl", FALSE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
972 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
973 | |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
974 | option = purple_account_option_bool_new( |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
975 | _("Allow plaintext SASL auth over unencrypted connection"), |
|
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
976 | "auth_plain_in_clear", FALSE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37016
diff
changeset
|
977 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
978 | #endif |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
979 | } |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
980 | |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
981 | static void |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
982 | irc_protocol_class_init(PurpleProtocolClass *klass) |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
983 | { |
|
36731
38de3f22e864
Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents:
36730
diff
changeset
|
984 | klass->login = irc_login; |
|
38de3f22e864
Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents:
36730
diff
changeset
|
985 | klass->close = irc_close; |
|
38de3f22e864
Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents:
36730
diff
changeset
|
986 | klass->status_types = irc_status_types; |
|
38de3f22e864
Renamed close_connection back to close
Ankit Vani <a@nevitus.org>
parents:
36730
diff
changeset
|
987 | klass->list_icon = irc_blist_icon; |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
988 | } |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
989 | |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
990 | static void |
|
36729
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
991 | irc_protocol_client_iface_init(PurpleProtocolClientIface *client_iface) |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
992 | { |
|
36729
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
993 | client_iface->get_actions = irc_get_actions; |
|
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
994 | client_iface->normalize = purple_normalize_nocase; |
|
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
995 | client_iface->get_max_message_size = irc_get_max_message_size; |
| 2086 | 996 | } |
| 9130 | 997 | |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
998 | static void |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
999 | irc_protocol_server_iface_init(PurpleProtocolServerIface *server_iface) |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1000 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1001 | server_iface->set_status = irc_set_status; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1002 | server_iface->get_info = irc_get_info; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1003 | server_iface->add_buddy = irc_add_buddy; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1004 | server_iface->remove_buddy = irc_remove_buddy; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1005 | server_iface->keepalive = irc_keepalive; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1006 | server_iface->send_raw = irc_send_raw; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1007 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1008 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1009 | static void |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1010 | irc_protocol_im_iface_init(PurpleProtocolIMIface *im_iface) |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1011 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1012 | im_iface->send = irc_im_send; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1013 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1014 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1015 | static void |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1016 | irc_protocol_chat_iface_init(PurpleProtocolChatIface *chat_iface) |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1017 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1018 | chat_iface->info = irc_chat_join_info; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1019 | chat_iface->info_defaults = irc_chat_info_defaults; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1020 | chat_iface->join = irc_chat_join; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1021 | chat_iface->get_name = irc_get_chat_name; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1022 | chat_iface->invite = irc_chat_invite; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1023 | chat_iface->leave = irc_chat_leave; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1024 | chat_iface->send = irc_chat_send; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1025 | chat_iface->set_topic = irc_chat_set_topic; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1026 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1027 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1028 | static void |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1029 | irc_protocol_roomlist_iface_init(PurpleProtocolRoomlistIface *roomlist_iface) |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1030 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1031 | roomlist_iface->get_list = irc_roomlist_get_list; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1032 | roomlist_iface->cancel = irc_roomlist_cancel; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1033 | } |
|
33404
bbd52f93184e
Implement SASL support for IRC, using Cyrus.
Thijs Alkemade <thijsalkemade@gmail.com>
parents:
32117
diff
changeset
|
1034 | |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1035 | static void |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1036 | irc_protocol_xfer_iface_init(PurpleProtocolXferIface *xfer_iface) |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1037 | { |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1038 | xfer_iface->send = irc_dccsend_send_file; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1039 | xfer_iface->new_xfer = irc_dccsend_new_xfer; |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1040 | } |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1041 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1042 | PURPLE_DEFINE_TYPE_EXTENDED( |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1043 | IRCProtocol, irc_protocol, PURPLE_TYPE_PROTOCOL, 0, |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1044 | |
|
36729
7f9fac14ed60
Temporarily replaced PurpleProtocolInterface with PurpleProtocolClientIface in protocols
Ankit Vani <a@nevitus.org>
parents:
36714
diff
changeset
|
1045 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CLIENT_IFACE, |
| 36733 | 1046 | irc_protocol_client_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1047 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1048 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_SERVER_IFACE, |
| 36733 | 1049 | irc_protocol_server_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1050 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1051 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_IM_IFACE, |
| 36733 | 1052 | irc_protocol_im_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1053 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1054 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_CHAT_IFACE, |
| 36733 | 1055 | irc_protocol_chat_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1056 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1057 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_ROOMLIST_IFACE, |
| 36733 | 1058 | irc_protocol_roomlist_iface_init) |
|
36730
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1059 | |
|
66018273528a
Refactored bonjour, gg, irc to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1060 | PURPLE_IMPLEMENT_INTERFACE_STATIC(PURPLE_TYPE_PROTOCOL_XFER_IFACE, |
| 36733 | 1061 | irc_protocol_xfer_iface_init) |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1062 | ); |
| 9130 | 1063 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1064 | static PurplePluginInfo * |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1065 | plugin_query(GError **error) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1066 | { |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1067 | return purple_plugin_info_new( |
|
36985
9faafe43603e
Rename protocol plugin IDs to prpl-*
Ankit Vani <a@nevitus.org>
parents:
36984
diff
changeset
|
1068 | "id", "prpl-irc", |
|
36638
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
1069 | "name", "IRC Protocol", |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1070 | "version", DISPLAY_VERSION, |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1071 | "category", N_("Protocol"), |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1072 | "summary", N_("IRC Protocol Plugin"), |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1073 | "description", N_("The IRC Protocol Plugin that Sucks Less"), |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1074 | "website", PURPLE_WEBSITE, |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1075 | "abi-version", PURPLE_ABI_VERSION, |
|
36653
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36648
diff
changeset
|
1076 | "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL | |
|
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36648
diff
changeset
|
1077 | PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD, |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1078 | NULL |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1079 | ); |
| 36522 | 1080 | } |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1081 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1082 | static gboolean |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1083 | plugin_load(PurplePlugin *plugin, GError **error) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
1084 | { |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1085 | irc_protocol_register_type(plugin); |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1086 | |
|
36628
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36621
diff
changeset
|
1087 | _irc_protocol = purple_protocols_add(IRC_TYPE_PROTOCOL, error); |
|
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36621
diff
changeset
|
1088 | if (!_irc_protocol) |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
1089 | return FALSE; |
| 9130 | 1090 | |
| 15884 | 1091 | purple_prefs_remove("/plugins/prpl/irc/quitmsg"); |
| 1092 | purple_prefs_remove("/plugins/prpl/irc"); | |
| 11073 | 1093 | |
| 9130 | 1094 | irc_register_commands(); |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1095 | |
|
36648
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1096 | purple_signal_register(_irc_protocol, "irc-sending-text", |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1097 | purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1098 | PURPLE_TYPE_CONNECTION, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1099 | G_TYPE_POINTER); /* pointer to a string */ |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1100 | purple_signal_register(_irc_protocol, "irc-receiving-text", |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1101 | purple_marshal_VOID__POINTER_POINTER, G_TYPE_NONE, 2, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1102 | PURPLE_TYPE_CONNECTION, |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1103 | G_TYPE_POINTER); /* pointer to a string */ |
|
b77b3a8401c5
Moved irc signal registrations to plugin_load, so that _irc_protocol is initialized
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1104 | |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1105 | return TRUE; |
| 2086 | 1106 | } |
| 1107 | ||
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1108 | static gboolean |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1109 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1110 | { |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1111 | irc_unregister_commands(); |
|
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1112 | |
|
36628
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36621
diff
changeset
|
1113 | if (!purple_protocols_remove(_irc_protocol, error)) |
|
36579
37b5e4a9e18e
Refactored irc to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36555
diff
changeset
|
1114 | return FALSE; |
|
36520
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1115 | |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1116 | return TRUE; |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1117 | } |
|
42a876472506
Refactored irc to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36367
diff
changeset
|
1118 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36690
diff
changeset
|
1119 | PURPLE_PLUGIN_INIT(irc, plugin_query, plugin_load, plugin_unload); |