annotate src/protocols/irc/irc.c @ 13507:702107dd58f1

[gaim-migrate @ 15883] I noticed that we were writing "FOO has signed off" noticed to the system log after we disconnected. With the HTML logger, this results in a new <html>...</html> block being added, with a duplicate header and everything. It seems we shouldn't be writing these messages after the system log has been closed. "Fixing" the HTML logger might be a good idea as well. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Tue, 14 Mar 2006 06:59:14 +0000
parents 4bfb720a8fc2
children 10e8eb6a4910
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
1 /**
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
2 * @file irc.c
6459
b52870734c21 [gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
3 *
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
4 * gaim
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
8351
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
6 * Copyright (C) 2003, Robbert Haarman <gaim@inglorion.net>
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
7 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu>
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
8 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
6459
b52870734c21 [gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
10 *
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 */
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
25
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
26 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
27
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
28 #include "accountopt.h"
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
29 #include "blist.h"
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
30 #include "conversation.h"
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
31 #include "debug.h"
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
32 #include "notify.h"
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
33 #include "prpl.h"
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
34 #include "plugin.h"
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
35 #include "util.h"
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
36 #include "version.h"
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
37
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
38 #include "irc.h"
4422
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
39
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
40 static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6622
diff changeset
42 static const char *irc_blist_icon(GaimAccount *a, GaimBuddy *b);
9953
d908907d9441 [gaim-migrate @ 10849]
Nathan Walp <nwalp@pidgin.im>
parents: 9951
diff changeset
43 static void irc_blist_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne);
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
44 static GList *irc_status_types(GaimAccount *account);
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
45 static GList *irc_actions(GaimPlugin *plugin, gpointer context);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
46 /* static GList *irc_chat_info(GaimConnection *gc); */
11837
fa742ad8068c [gaim-migrate @ 14128]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
47 static void irc_login(GaimAccount *account);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
48 static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
49 static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
50 static void irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, gpointer data);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
51 static void irc_close(GaimConnection *gc);
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
52 static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimMessageFlags flags);
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
53 static int irc_chat_send(GaimConnection *gc, int id, const char *what, GaimMessageFlags flags);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
54 static void irc_chat_join (GaimConnection *gc, GHashTable *data);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
55 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
56 static void irc_input_cb_ssl(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
57
7711
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
58 static guint irc_nick_hash(const char *nick);
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
59 static gboolean irc_nick_equal(const char *nick1, const char *nick2);
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
60 static void irc_buddy_free(struct irc_buddy *ib);
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
61
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
62 static GaimPlugin *_irc_plugin = NULL;
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
63
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
64 static const char *status_chars = "@+%&";
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
65
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
66 static void irc_view_motd(GaimPluginAction *action)
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
67 {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
68 GaimConnection *gc = (GaimConnection *) action->context;
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
69 struct irc_conn *irc;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
70 char *title;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
71
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
72 if (gc == NULL || gc->proto_data == NULL) {
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
73 gaim_debug(GAIM_DEBUG_ERROR, "irc", "got MOTD request for NULL gc\n");
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
74 return;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
75 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
76 irc = gc->proto_data;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
77 if (irc->motd == NULL) {
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
78 gaim_notify_error(gc, _("Error displaying MOTD"), _("No MOTD available"),
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
79 _("There is no MOTD associated with this connection."));
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
80 return;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
81 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
82 title = g_strdup_printf(_("MOTD for %s"), irc->server);
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
83 gaim_notify_formatted(gc, title, title, NULL, irc->motd->str, NULL, NULL);
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
84 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
85
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
86 static int do_send(struct irc_conn *irc, const char *buf, gsize len)
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
87 {
9440
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
88 int ret;
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
89
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
90 if (irc->gsc) {
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
91 ret = gaim_ssl_write(irc->gsc, buf, len);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
92 } else {
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
93 ret = write(irc->fd, buf, len);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
94 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
95
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
96 return ret;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
97 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
98
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
99 static void
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
100 irc_send_cb(gpointer data, gint source, GaimInputCondition cond)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
101 {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
102 struct irc_conn *irc = data;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
103 int ret, writelen;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
104
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
105 writelen = gaim_circ_buffer_get_max_read(irc->outbuf);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
106
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
107 if (writelen == 0) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
108 gaim_input_remove(irc->writeh);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
109 irc->writeh = 0;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
110 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
111 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
112
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
113 ret = do_send(irc, irc->outbuf->outptr, writelen);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
114
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
115 if (ret < 0 && errno == EAGAIN)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
116 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
117 else if (ret <= 0) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
118 gaim_connection_error(gaim_account_get_connection(irc->account),
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
119 _("Server has disconnected"));
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
120 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
121 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
122
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
123 gaim_circ_buffer_mark_read(irc->outbuf, ret);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
124
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
125 #if 0
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
126 /* We *could* try to write more if we wrote it all */
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
127 if (ret == write_len) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
128 irc_send_cb(data, source, cond);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
129 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
130 #endif
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
131 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
132
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
133 int irc_send(struct irc_conn *irc, const char *buf)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
134 {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
135 int ret, buflen = strlen(buf);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
136
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
137 /* If we're not buffering writes, try to send immediately */
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
138 if (!irc->writeh)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
139 ret = do_send(irc, buf, buflen);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
140 else {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
141 ret = -1;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
142 errno = EAGAIN;
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
143 }
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
144
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
145 /* gaim_debug(GAIM_DEBUG_MISC, "irc", "sent%s: %s",
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
146 irc->gsc ? " (ssl)" : "", buf); */
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
147 if (ret <= 0 && errno != EAGAIN) {
9440
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
148 gaim_connection_error(gaim_account_get_connection(irc->account),
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
149 _("Server has disconnected"));
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
150 } else if (ret < buflen) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
151 if (ret < 0)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
152 ret = 0;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
153 if (!irc->writeh)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
154 irc->writeh = gaim_input_add(
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
155 irc->gsc ? irc->gsc->fd : irc->fd,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
156 GAIM_INPUT_WRITE, irc_send_cb, irc);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
157 gaim_circ_buffer_append(irc->outbuf, buf + ret,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
158 buflen - ret);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
159 }
9440
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
160
00242c2419c3 [gaim-migrate @ 10261]
Ethan Blanton <elb@pidgin.im>
parents: 9308
diff changeset
161 return ret;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
162 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
163
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
164 /* XXX I don't like messing directly with these buddies */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
165 gboolean irc_blist_timeout(struct irc_conn *irc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
167 GString *string = g_string_sized_new(512);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
168 char *list, *buf;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
169
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
170 g_hash_table_foreach(irc->buddies, (GHFunc)irc_buddy_append, (gpointer)string);
4359
5fb47ec9bfe4 [gaim-migrate @ 4625]
Christian Hammond <chipx86@chipx86.com>
parents: 4349
diff changeset
171
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
172 list = g_string_free(string, FALSE);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
173 if (!list || !strlen(list)) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
174 g_free(list);
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
175 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 }
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
177
8038
de9a93878469 [gaim-migrate @ 8719]
Ethan Blanton <elb@pidgin.im>
parents: 7956
diff changeset
178 buf = irc_format(irc, "vn", "ISON", list);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
179 g_free(list);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
180 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
181 g_free(buf);
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
182
2131
acc11216ec5d [gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
183 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
186 static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
187 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
188 ib->flag = FALSE;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
189 g_string_append_printf(string, "%s ", name);
3511
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
190 }
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
191
9553
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
192 static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib)
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
193 {
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
194 char *buf;
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
195
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
196 ib->flag = FALSE;
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
197 buf = irc_format(irc, "vn", "ISON", ib->name);
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
198 irc_send(irc, buf);
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
199 g_free(buf);
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
200 }
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
201
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
202
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6622
diff changeset
203 static const char *irc_blist_icon(GaimAccount *a, GaimBuddy *b)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
204 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
205 return "irc";
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
206 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
207
9953
d908907d9441 [gaim-migrate @ 10849]
Nathan Walp <nwalp@pidgin.im>
parents: 9951
diff changeset
208 static void irc_blist_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne)
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
209 {
10244
13cb42ebb537 [gaim-migrate @ 11384]
Tim Ringenbach <marv@pidgin.im>
parents: 10159
diff changeset
210 GaimPresence *presence = gaim_buddy_get_presence(b);
13cb42ebb537 [gaim-migrate @ 11384]
Tim Ringenbach <marv@pidgin.im>
parents: 10159
diff changeset
211
13cb42ebb537 [gaim-migrate @ 11384]
Tim Ringenbach <marv@pidgin.im>
parents: 10159
diff changeset
212 if (gaim_presence_is_online(presence) == FALSE) {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
213 *se = "offline";
10244
13cb42ebb537 [gaim-migrate @ 11384]
Tim Ringenbach <marv@pidgin.im>
parents: 10159
diff changeset
214 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
217 static GList *irc_status_types(GaimAccount *account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 {
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
219 GaimStatusType *type;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
220 GList *types = NULL;
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
221
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12323
diff changeset
222 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, NULL, NULL, TRUE);
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
223 types = g_list_append(types, type);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
224
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
225 type = gaim_status_type_new_with_attrs(
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12323
diff changeset
226 GAIM_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12323
diff changeset
227 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12323
diff changeset
228 NULL);
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
229 types = g_list_append(types, type);
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
230
12658
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12645
diff changeset
231 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, NULL, NULL, TRUE);
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12645
diff changeset
232 types = g_list_append(types, type);
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12645
diff changeset
233
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
234 return types;
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
235 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
236
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
237 static GList *irc_actions(GaimPlugin *plugin, gpointer context)
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
238 {
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
239 GList *list = NULL;
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
240 GaimPluginAction *act = NULL;
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
241
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
242 act = gaim_plugin_action_new(_("View MOTD"), irc_view_motd);
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
243 list = g_list_append(list, act);
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
244
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
245 return list;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
246 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
247
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
248 static GList *irc_chat_join_info(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
250 GList *m = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
251 struct proto_chat_entry *pce;
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
252
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
253 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7711
diff changeset
254 pce->label = _("_Channel:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5221
diff changeset
255 pce->identifier = "channel";
10954
ec90b7d126be [gaim-migrate @ 12754]
Mark Doliner <mark@kingant.net>
parents: 10903
diff changeset
256 pce->required = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
257 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
258
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
259 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7711
diff changeset
260 pce->label = _("_Password:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5221
diff changeset
261 pce->identifier = "password";
6499
17a9cdac508e [gaim-migrate @ 7014]
Nathan Walp <nwalp@pidgin.im>
parents: 6459
diff changeset
262 pce->secret = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
263 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
264
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
265 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
12323
fc464a0abccc [gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents: 12216
diff changeset
268 static GHashTable *irc_chat_info_defaults(GaimConnection *gc, const char *chat_name)
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
269 {
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
270 GHashTable *defaults;
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
271
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
272 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
273
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
274 if (chat_name != NULL)
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
275 g_hash_table_insert(defaults, "channel", g_strdup(chat_name));
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
276
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
277 return defaults;
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
278 }
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
279
11837
fa742ad8068c [gaim-migrate @ 14128]
Mark Doliner <mark@kingant.net>
parents: 11763
diff changeset
280 static void irc_login(GaimAccount *account)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
281 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
282 GaimConnection *gc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
283 struct irc_conn *irc;
10494
93dab54c7bb6 [gaim-migrate @ 11785]
Ethan Blanton <elb@pidgin.im>
parents: 10401
diff changeset
284 char **userparts;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
285 const char *username = gaim_account_get_username(account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
286 int err;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
287
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
288 gc = gaim_account_get_connection(account);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8589
diff changeset
289 gc->flags |= GAIM_CONNECTION_NO_NEWLINES;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
290
6752
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
291 if (strpbrk(username, " \t\v\r\n") != NULL) {
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
292 gaim_connection_error(gc, _("IRC nicks may not contain whitespace"));
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
293 return;
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
294 }
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
295
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
296 gc->proto_data = irc = g_new0(struct irc_conn, 1);
10960
a7f182589325 [gaim-migrate @ 12763]
Mark Doliner <mark@kingant.net>
parents: 10954
diff changeset
297 irc->fd = -1;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
298 irc->account = account;
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
299 irc->outbuf = gaim_circ_buffer_new(512);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
300
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
301 userparts = g_strsplit(username, "@", 2);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
302 gaim_connection_set_display_name(gc, userparts[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
303 irc->server = g_strdup(userparts[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
304 g_strfreev(userparts);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
305
10159
952fb08c60b0 [gaim-migrate @ 11240]
Mark Doliner <mark@kingant.net>
parents: 10010
diff changeset
306 irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
307 NULL, (GDestroyNotify)irc_buddy_free);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
308 irc->cmds = g_hash_table_new(g_str_hash, g_str_equal);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
309 irc_cmd_table_build(irc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
310 irc->msgs = g_hash_table_new(g_str_hash, g_str_equal);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
311 irc_msg_table_build(irc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
312
10494
93dab54c7bb6 [gaim-migrate @ 11785]
Ethan Blanton <elb@pidgin.im>
parents: 10401
diff changeset
313 gaim_connection_update_progress(gc, _("Connecting"), 1, 2);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
314
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
315 if (gaim_account_get_bool(account, "ssl", FALSE)) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
316 if (gaim_ssl_is_supported()) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
317 irc->gsc = gaim_ssl_connect(account, irc->server,
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
318 gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
319 irc_login_cb_ssl, irc_ssl_connect_failure, gc);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
320 } else {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
321 gaim_connection_error(gc, _("SSL support unavailable"));
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
322 return;
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
323 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
324 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
325
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
326 if (!irc->gsc) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
327
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
328 err = gaim_proxy_connect(account, irc->server,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
329 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT),
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
330 irc_login_cb, gc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
331
10555
761822c6f7ca [gaim-migrate @ 11932]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
332 if (err || !gaim_account_get_connection(account)) {
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
333 gaim_connection_error(gc, _("Couldn't create socket"));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
334 return;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
335 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
336 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
337 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
338
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
339 static gboolean do_login(GaimConnection *gc) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
340 char *buf;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
341 char hostname[256];
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
342 const char *username, *realname;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
343 struct irc_conn *irc = gc->proto_data;
10740
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10738
diff changeset
344 const char *pass = gaim_connection_get_password(gc);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
345
10555
761822c6f7ca [gaim-migrate @ 11932]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
346 if (pass && *pass) {
761822c6f7ca [gaim-migrate @ 11932]
Nathan Walp <nwalp@pidgin.im>
parents: 10504
diff changeset
347 buf = irc_format(irc, "vv", "PASS", pass);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
348 if (irc_send(irc, buf) < 0) {
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
349 /* gaim_connection_error(gc, "Error sending password"); */
10903
c153119be7d0 [gaim-migrate @ 12630]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10740
diff changeset
350 g_free(buf);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
351 return FALSE;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
352 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
353 g_free(buf);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
354 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
355
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
356 gethostname(hostname, sizeof(hostname));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
357 hostname[sizeof(hostname) - 1] = '\0';
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
358 username = gaim_account_get_string(irc->account, "username", "");
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
359 realname = gaim_account_get_string(irc->account, "realname", "");
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
360 buf = irc_format(irc, "vvvv:", "USER", strlen(username) ? username : g_get_user_name(), hostname, irc->server,
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
361 strlen(realname) ? realname : IRC_DEFAULT_ALIAS);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
362 if (irc_send(irc, buf) < 0) {
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
363 /* gaim_connection_error(gc, "Error registering with server");*/
10903
c153119be7d0 [gaim-migrate @ 12630]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10740
diff changeset
364 g_free(buf);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
365 return FALSE;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
366 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
367 g_free(buf);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
368 buf = irc_format(irc, "vn", "NICK", gaim_connection_get_display_name(gc));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
369 if (irc_send(irc, buf) < 0) {
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
370 /* gaim_connection_error(gc, "Error sending nickname");*/
10903
c153119be7d0 [gaim-migrate @ 12630]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10740
diff changeset
371 g_free(buf);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
372 return FALSE;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
373 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
374 g_free(buf);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
375
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
376 return TRUE;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
377 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
378
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
379 static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc,
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
380 GaimInputCondition cond)
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
381 {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
382 GaimConnection *gc = data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
383 struct irc_conn *irc = gc->proto_data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
384
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
385 if(!g_list_find(gaim_connections_get_all(), gc)) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
386 gaim_ssl_close(gsc);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
387 return;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
388 }
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
389
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
390 irc->gsc = gsc;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
391
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
392 if (do_login(gc)) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
393 gaim_ssl_input_add(gsc, irc_input_cb_ssl, gc);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
394 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
395 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
396
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
397 static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
398 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
399 GaimConnection *gc = data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
400 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
401 GList *connections = gaim_connections_get_all();
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
402
8778
8bf735cf9d1c [gaim-migrate @ 9540]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
403 if (source < 0) {
8bf735cf9d1c [gaim-migrate @ 9540]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
404 gaim_connection_error(gc, _("Couldn't connect to host"));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
405 return;
8778
8bf735cf9d1c [gaim-migrate @ 9540]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
406 }
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
407
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
408 if (!g_list_find(connections, gc)) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
409 close(source);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
410 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
411 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
412
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
413 irc->fd = source;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
414
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
415 if (do_login(gc)) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
416 gc->inpa = gaim_input_add(irc->fd, GAIM_INPUT_READ, irc_input_cb, gc);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
417 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
418 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
419
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
420 static void
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
421 irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error,
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
422 gpointer data)
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
423 {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
424 GaimConnection *gc = data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
425 struct irc_conn *irc = gc->proto_data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
426
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
427 switch(error) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
428 case GAIM_SSL_CONNECT_FAILED:
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
429 gaim_connection_error(gc, _("Connection Failed"));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
430 break;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
431 case GAIM_SSL_HANDSHAKE_FAILED:
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
432 gaim_connection_error(gc, _("SSL Handshake Failed"));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
433 break;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
434 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
435
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
436 irc->gsc = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
437 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
438
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
439 static void irc_close(GaimConnection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
440 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
441 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
442
6752
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
443 if (irc == NULL)
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
444 return;
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
445
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
446 irc_cmd_quit(irc, "quit", NULL, NULL);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
447
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
448 if (gc->inpa)
9441
eaa9aa1fad61 [gaim-migrate @ 10262]
Ethan Blanton <elb@pidgin.im>
parents: 9440
diff changeset
449 gaim_input_remove(gc->inpa);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
450
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
451 g_free(irc->inbuf);
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
452 if (irc->gsc) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
453 gaim_ssl_close(irc->gsc);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
454 } else if (irc->fd > 0) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
455 close(irc->fd);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
456 }
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
457 if (irc->timer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8170
diff changeset
458 gaim_timeout_remove(irc->timer);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
459 g_hash_table_destroy(irc->cmds);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
460 g_hash_table_destroy(irc->msgs);
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10494
diff changeset
461 g_hash_table_destroy(irc->buddies);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
462 if (irc->motd)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
463 g_string_free(irc->motd, TRUE);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
464 g_free(irc->server);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
465
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
466 if (irc->writeh)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
467 gaim_input_remove(irc->writeh);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
468
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
469 gaim_circ_buffer_destroy(irc->outbuf);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
470
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
471 g_free(irc);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
472 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
473
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
474 static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimMessageFlags flags)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
475 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
476 struct irc_conn *irc = gc->proto_data;
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
477 char *plain;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
478 const char *args[2];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
479
7711
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
480 if (strchr(status_chars, *who) != NULL)
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
481 args[0] = who + 1;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
482 else
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
483 args[0] = who;
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
484
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
485 plain = gaim_unescape_html(what);
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
486 args[1] = plain;
9442
1e6bba55447c [gaim-migrate @ 10263]
Ethan Blanton <elb@pidgin.im>
parents: 9441
diff changeset
487
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
488 irc_cmd_privmsg(irc, "msg", NULL, args);
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
489 g_free(plain);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
490 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
491 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
493 static void irc_get_info(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
495 struct irc_conn *irc = gc->proto_data;
10618
9eb3b224face [gaim-migrate @ 12083]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 10555
diff changeset
496 const char *args[2];
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
497 args[0] = who;
10624
235e72d7bb0a [gaim-migrate @ 12096]
Ethan Blanton <elb@pidgin.im>
parents: 10618
diff changeset
498 args[1] = NULL;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
499 irc_cmd_whois(irc, "whois", NULL, args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
500 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
501
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
502 static void irc_set_status(GaimAccount *account, GaimStatus *status)
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
503 {
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
504 GaimConnection *gc = gaim_account_get_connection(account);
13437
4bfb720a8fc2 [gaim-migrate @ 15812]
Richard Laager <rlaager@wiktel.com>
parents: 13296
diff changeset
505 struct irc_conn *irc;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
506 const char *args[1];
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
507 const char *status_id = gaim_status_get_id(status);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508
13437
4bfb720a8fc2 [gaim-migrate @ 15812]
Richard Laager <rlaager@wiktel.com>
parents: 13296
diff changeset
509 g_return_if_fail(gc != NULL);
4bfb720a8fc2 [gaim-migrate @ 15812]
Richard Laager <rlaager@wiktel.com>
parents: 13296
diff changeset
510 irc = gc->proto_data;
10646
6a618db0a404 [gaim-migrate @ 12162]
Sean Egan <seanegan@gmail.com>
parents: 10624
diff changeset
511
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10494
diff changeset
512 if (!gaim_status_is_active(status))
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10494
diff changeset
513 return;
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10494
diff changeset
514
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10494
diff changeset
515 args[0] = NULL;
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10494
diff changeset
516
11718
11e95968c9ff [gaim-migrate @ 14009]
Mark Doliner <mark@kingant.net>
parents: 11522
diff changeset
517 if (!strcmp(status_id, "away")) {
9944
e4a27c9aec4c [gaim-migrate @ 10838]
Luke Schierer <lschiere@pidgin.im>
parents: 9943
diff changeset
518 args[0] = gaim_status_get_attr_string(status, "message");
12001
8bcccf2988fa [gaim-migrate @ 14294]
Mark Doliner <mark@kingant.net>
parents: 11837
diff changeset
519 if ((args[0] == NULL) || (*args[0] == '\0'))
8bcccf2988fa [gaim-migrate @ 14294]
Mark Doliner <mark@kingant.net>
parents: 11837
diff changeset
520 args[0] = _("Away");
10646
6a618db0a404 [gaim-migrate @ 12162]
Sean Egan <seanegan@gmail.com>
parents: 10624
diff changeset
521 irc_cmd_away(irc, "away", NULL, args);
12210
5ae6ab7846a5 [gaim-migrate @ 14512]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12143
diff changeset
522 } else if (!strcmp(status_id, "available")) {
5ae6ab7846a5 [gaim-migrate @ 14512]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12143
diff changeset
523 irc_cmd_away(irc, "back", NULL, args);
10646
6a618db0a404 [gaim-migrate @ 12162]
Sean Egan <seanegan@gmail.com>
parents: 10624
diff changeset
524 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
525 }
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
526
9285
7a8aa87164ae [gaim-migrate @ 10088]
Mark Doliner <mark@kingant.net>
parents: 9238
diff changeset
527 static void irc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
528 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
529 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
530 struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
9285
7a8aa87164ae [gaim-migrate @ 10088]
Mark Doliner <mark@kingant.net>
parents: 9238
diff changeset
531 ib->name = g_strdup(buddy->name);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
532 g_hash_table_insert(irc->buddies, ib->name, ib);
9238
f4f210e47b60 [gaim-migrate @ 10036]
Ethan Blanton <elb@pidgin.im>
parents: 9154
diff changeset
533
9553
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
534 /* if the timer isn't set, this is during signon, so we don't want to flood
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
535 * ourself off with ISON's, so we don't, but after that we want to know when
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
536 * someone's online asap */
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
537 if (irc->timer)
8a64666476e6 [gaim-migrate @ 10386]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
538 irc_ison_one(irc, ib);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
539 }
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
540
9285
7a8aa87164ae [gaim-migrate @ 10088]
Mark Doliner <mark@kingant.net>
parents: 9238
diff changeset
541 static void irc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group)
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
542 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
543 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
9285
7a8aa87164ae [gaim-migrate @ 10088]
Mark Doliner <mark@kingant.net>
parents: 9238
diff changeset
544 g_hash_table_remove(irc->buddies, buddy->name);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
545 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
546
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
547 static void read_input(struct irc_conn *irc, int len)
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
548 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
549 char *cur, *end;
6369
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
550
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
551 irc->inbufused += len;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
552 irc->inbuf[irc->inbufused] = '\0';
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
553
8156
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
554 cur = irc->inbuf;
12752
91424393b70b [gaim-migrate @ 15099]
Tim Ringenbach <marv@pidgin.im>
parents: 12658
diff changeset
555
91424393b70b [gaim-migrate @ 15099]
Tim Ringenbach <marv@pidgin.im>
parents: 12658
diff changeset
556 /* This is a hack to work around the fact that marv gets messages
91424393b70b [gaim-migrate @ 15099]
Tim Ringenbach <marv@pidgin.im>
parents: 12658
diff changeset
557 * with null bytes in them while using some weird irc server at work
91424393b70b [gaim-migrate @ 15099]
Tim Ringenbach <marv@pidgin.im>
parents: 12658
diff changeset
558 */
91424393b70b [gaim-migrate @ 15099]
Tim Ringenbach <marv@pidgin.im>
parents: 12658
diff changeset
559 while ((cur < (irc->inbuf + irc->inbufused)) && !*cur)
91424393b70b [gaim-migrate @ 15099]
Tim Ringenbach <marv@pidgin.im>
parents: 12658
diff changeset
560 cur++;
91424393b70b [gaim-migrate @ 15099]
Tim Ringenbach <marv@pidgin.im>
parents: 12658
diff changeset
561
8156
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
562 while (cur < irc->inbuf + irc->inbufused &&
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
563 ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) {
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
564 int step = (*end == '\r' ? 2 : 1);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
565 *end = '\0';
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
566 irc_parse_msg(irc, cur);
8156
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
567 cur = end + step;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
568 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
569 if (cur != irc->inbuf + irc->inbufused) { /* leftover */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
570 irc->inbufused -= (cur - irc->inbuf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
571 memmove(irc->inbuf, cur, irc->inbufused);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
572 } else {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
573 irc->inbufused = 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
574 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
575 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
576
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
577 static void irc_input_cb_ssl(gpointer data, GaimSslConnection *gsc,
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
578 GaimInputCondition cond)
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
579 {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
580
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
581 GaimConnection *gc = data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
582 struct irc_conn *irc = gc->proto_data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
583 int len;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
584
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
585 if(!g_list_find(gaim_connections_get_all(), gc)) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
586 gaim_ssl_close(gsc);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
587 return;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
588 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
589
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
590 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
591 irc->inbuflen += IRC_INITIAL_BUFSIZE;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
592 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
593 }
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
594
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
595 len = gaim_ssl_read(gsc, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
596
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
597 if (len < 0 && errno == EAGAIN) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
598 /* Try again later */
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
599 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
600 } else if (len < 0) {
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
601 gaim_connection_error(gc, _("Read error"));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
602 return;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
603 } else if (len == 0) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
604 gaim_connection_error(gc, _("Server has disconnected"));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
605 return;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
606 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
607
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
608 read_input(irc, len);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
609 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
610
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
611 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond)
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
612 {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
613 GaimConnection *gc = data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
614 struct irc_conn *irc = gc->proto_data;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
615 int len;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
616
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
617 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
618 irc->inbuflen += IRC_INITIAL_BUFSIZE;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
619 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
620 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
621
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
622 len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
623 if (len < 0 && errno == EAGAIN) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
624 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12752
diff changeset
625 } else if (len < 0) {
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
626 gaim_connection_error(gc, _("Read error"));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
627 return;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
628 } else if (len == 0) {
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
629 gaim_connection_error(gc, _("Server has disconnected"));
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
630 return;
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
631 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
632
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
633 read_input(irc, len);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
634 }
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
635
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
636 static void irc_chat_join (GaimConnection *gc, GHashTable *data)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
637 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
638 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
639 const char *args[2];
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
640
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
641 args[0] = g_hash_table_lookup(data, "channel");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
642 args[1] = g_hash_table_lookup(data, "password");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
643 irc_cmd_join(irc, "join", NULL, args);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
644 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
645
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9754
diff changeset
646 static char *irc_get_chat_name(GHashTable *data) {
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9754
diff changeset
647 return g_strdup(g_hash_table_lookup(data, "channel"));
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9754
diff changeset
648 }
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9754
diff changeset
649
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
650 static void irc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name)
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
651 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
652 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
653 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
654 const char *args[2];
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
655
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
656 if (!convo) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
657 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got chat invite request for bogus chat\n");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
658 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
659 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
660 args[0] = name;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
661 args[1] = gaim_conversation_get_name(convo);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
662 irc_cmd_invite(irc, "invite", gaim_conversation_get_name(convo), args);
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
663 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
664
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
665
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
666 static void irc_chat_leave (GaimConnection *gc, int id)
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
667 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
668 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
669 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
670 const char *args[2];
5298
857106f8f971 [gaim-migrate @ 5670]
Nathan Walp <nwalp@pidgin.im>
parents: 5265
diff changeset
671
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
672 if (!convo)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
673 return;
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
674
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
675 args[0] = gaim_conversation_get_name(convo);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
676 args[1] = NULL;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
677 irc_cmd_part(irc, "part", gaim_conversation_get_name(convo), args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
678 serv_got_chat_left(gc, id);
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
679 }
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
680
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
681 static int irc_chat_send(GaimConnection *gc, int id, const char *what, GaimMessageFlags flags)
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
682 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
683 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
684 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
685 const char *args[2];
8163
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
686 char *tmp;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
687
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
688 if (!convo) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
689 gaim_debug(GAIM_DEBUG_ERROR, "irc", "chat send on nonexistent chat\n");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
690 return -EINVAL;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
691 }
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
692 #if 0
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
693 if (*what == '/') {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
694 return irc_parse_cmd(irc, convo->name, what + 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
695 }
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
696 #endif
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
697 tmp = gaim_unescape_html(what);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
698 args[0] = convo->name;
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
699 args[1] = tmp;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
700
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
701 irc_cmd_privmsg(irc, "msg", NULL, args);
8163
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
702
12216
4d3119205a33 [gaim-migrate @ 14518]
Stu Tomlinson <stu@nosnilmot.com>
parents: 12210
diff changeset
703 serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, what, time(NULL));
8163
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
704 g_free(tmp);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
705 return 0;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
706 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
707
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
708 static guint irc_nick_hash(const char *nick)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
709 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
710 char *lc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
711 guint bucket;
6270
1bf6fd117797 [gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
712
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
713 lc = g_utf8_strdown(nick, -1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
714 bucket = g_str_hash(lc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
715 g_free(lc);
6270
1bf6fd117797 [gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
716
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
717 return bucket;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
718 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
719
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
720 static gboolean irc_nick_equal(const char *nick1, const char *nick2)
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
721 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
722 return (gaim_utf8_strcasecmp(nick1, nick2) == 0);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
723 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
724
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
725 static void irc_buddy_free(struct irc_buddy *ib)
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
726 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
727 g_free(ib->name);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
728 g_free(ib);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
729 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
730
9154
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
731 static void irc_chat_set_topic(GaimConnection *gc, int id, const char *topic)
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
732 {
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
733 char *buf;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
734 const char *name = NULL;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
735 struct irc_conn *irc;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
736
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
737 irc = gc->proto_data;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
738 name = gaim_conversation_get_name(gaim_find_chat(gc, id));
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
739
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
740 if (name == NULL)
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
741 return;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
742
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
743 buf = irc_format(irc, "vt:", "TOPIC", name, topic);
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
744 irc_send(irc, buf);
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
745 g_free(buf);
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
746 }
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
747
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
748 static GaimRoomlist *irc_roomlist_get_list(GaimConnection *gc)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
749 {
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
750 struct irc_conn *irc;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
751 GList *fields = NULL;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
752 GaimRoomlistField *f;
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
753 char *buf;
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
754
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
755 irc = gc->proto_data;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
756
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
757 if (irc->roomlist)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
758 gaim_roomlist_unref(irc->roomlist);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
759
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
760 irc->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc));
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
761
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
762 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
763 fields = g_list_append(fields, f);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
764
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
765 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
766 fields = g_list_append(fields, f);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
767
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
768 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
769 fields = g_list_append(fields, f);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
770
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
771 gaim_roomlist_set_fields(irc->roomlist, fields);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
772
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
773 buf = irc_format(irc, "v", "LIST");
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
774 irc_send(irc, buf);
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
775 g_free(buf);
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
776
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
777 return irc->roomlist;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
778 }
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
779
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
780 static void irc_roomlist_cancel(GaimRoomlist *list)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
781 {
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
782 GaimConnection *gc = gaim_account_get_connection(list->account);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
783 struct irc_conn *irc;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
784
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
785 if (gc == NULL)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
786 return;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
787
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
788 irc = gc->proto_data;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
789
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
790 gaim_roomlist_set_in_progress(list, FALSE);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
791
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
792 if (irc->roomlist == list) {
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
793 irc->roomlist = NULL;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
794 gaim_roomlist_unref(list);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
795 }
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
796 }
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
797
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
798 static GaimPluginProtocolInfo prpl_info =
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
799 {
11500
9fc7d0153332 [gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents: 11454
diff changeset
800 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL,
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
801 NULL, /* user_splits */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
802 NULL, /* protocol_options */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
803 NO_BUDDY_ICONS, /* icon_spec */
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
804 irc_blist_icon, /* list_icon */
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
805 irc_blist_emblems, /* list_emblems */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
806 NULL, /* status_text */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
807 NULL, /* tooltip_text */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
808 irc_status_types, /* away_states */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
809 NULL, /* blist_node_menu */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
810 irc_chat_join_info, /* chat_info */
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
811 irc_chat_info_defaults, /* chat_info_defaults */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
812 irc_login, /* login */
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
813 irc_close, /* close */
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
814 irc_im_send, /* send_im */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
815 NULL, /* set_info */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
816 NULL, /* send_typing */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
817 irc_get_info, /* get_info */
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
818 irc_set_status, /* set_status */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
819 NULL, /* set_idle */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
820 NULL, /* change_passwd */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
821 irc_add_buddy, /* add_buddy */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
822 NULL, /* add_buddies */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
823 irc_remove_buddy, /* remove_buddy */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
824 NULL, /* remove_buddies */
9741
b10d4c6ac7eb [gaim-migrate @ 10606]
Luke Schierer <lschiere@pidgin.im>
parents: 9740
diff changeset
825 NULL, /* add_permit */
b10d4c6ac7eb [gaim-migrate @ 10606]
Luke Schierer <lschiere@pidgin.im>
parents: 9740
diff changeset
826 NULL, /* add_deny */
b10d4c6ac7eb [gaim-migrate @ 10606]
Luke Schierer <lschiere@pidgin.im>
parents: 9740
diff changeset
827 NULL, /* rem_permit */
b10d4c6ac7eb [gaim-migrate @ 10606]
Luke Schierer <lschiere@pidgin.im>
parents: 9740
diff changeset
828 NULL, /* rem_deny */
b10d4c6ac7eb [gaim-migrate @ 10606]
Luke Schierer <lschiere@pidgin.im>
parents: 9740
diff changeset
829 NULL, /* set_permit_deny */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
830 irc_chat_join, /* join_chat */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
831 NULL, /* reject_chat */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
832 irc_get_chat_name, /* get_chat_name */
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
833 irc_chat_invite, /* chat_invite */
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
834 irc_chat_leave, /* chat_leave */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
835 NULL, /* chat_whisper */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
836 irc_chat_send, /* chat_send */
12031
bef758a67e48 [gaim-migrate @ 14324]
Ethan Blanton <elb@pidgin.im>
parents: 12001
diff changeset
837 NULL, /* keepalive */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
838 NULL, /* register_user */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
839 NULL, /* get_cb_info */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
840 NULL, /* get_cb_away */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
841 NULL, /* alias_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
842 NULL, /* group_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
843 NULL, /* rename_group */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
844 NULL, /* buddy_free */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
845 NULL, /* convo_closed */
11153
8e600ee6ec61 [gaim-migrate @ 13235]
Mark Doliner <mark@kingant.net>
parents: 11083
diff changeset
846 gaim_normalize_nocase, /* normalize */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
847 NULL, /* set_buddy_icon */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
848 NULL, /* remove_group */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
849 NULL, /* get_cb_real_name */
9951
42cdec4f639b [gaim-migrate @ 10847]
Nathan Walp <nwalp@pidgin.im>
parents: 9944
diff changeset
850 irc_chat_set_topic, /* set_chat_topic */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
851 NULL, /* find_blist_chat */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
852 irc_roomlist_get_list, /* roomlist_get_list */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
853 irc_roomlist_cancel, /* roomlist_cancel */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
854 NULL, /* roomlist_expand_category */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
855 NULL, /* can_receive_file */
12143
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 12130
diff changeset
856 irc_dccsend_send_file, /* send_file */
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12595
diff changeset
857 irc_dccsend_new_xfer, /* new_xfer */
12645
fc28451f5d96 [gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
858 NULL, /* offline_message */
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12595
diff changeset
859 NULL, /* whiteboard_prpl_ops */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
860 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
861
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
862
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
863 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
864 {
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
865 GAIM_PLUGIN_MAGIC,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
866 GAIM_MAJOR_VERSION,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
867 GAIM_MINOR_VERSION,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
868 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
869 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
870 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
871 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
872 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
873
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
874 "prpl-irc", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
875 "IRC", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
876 VERSION, /**< version */
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
877 N_("IRC Protocol Plugin"), /** summary */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
878 N_("The IRC Protocol Plugin that Sucks Less"), /** description */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
879 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6369
diff changeset
880 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
881
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
882 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
883 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
884 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
885
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
886 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8950
diff changeset
887 &prpl_info, /**< extra_info */
11763
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
888 NULL, /**< prefs_info */
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
889 irc_actions
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
890 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
891
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
892 static void _init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
893 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
894 GaimAccountUserSplit *split;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
895 GaimAccountOption *option;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
896
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
897 split = gaim_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@');
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
898 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
899
6459
b52870734c21 [gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
900 option = gaim_account_option_int_new(_("Port"), "port", IRC_DEFAULT_PORT);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
901 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
902
10258
357d4fa1bfbe [gaim-migrate @ 11400]
Ethan Blanton <elb@pidgin.im>
parents: 10244
diff changeset
903 option = gaim_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
904 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
905
7323
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
906 option = gaim_account_option_string_new(_("Username"), "username", "");
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
907 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
908
10002
8ba9a9048d73 [gaim-migrate @ 10919]
Ethan Blanton <elb@pidgin.im>
parents: 9953
diff changeset
909 option = gaim_account_option_string_new(_("Real name"), "realname", "");
8ba9a9048d73 [gaim-migrate @ 10919]
Ethan Blanton <elb@pidgin.im>
parents: 9953
diff changeset
910 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
8ba9a9048d73 [gaim-migrate @ 10919]
Ethan Blanton <elb@pidgin.im>
parents: 9953
diff changeset
911
11763
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
912 /*
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
913 option = gaim_account_option_string_new(_("Quit message"), "quitmsg", IRC_DEFAULT_QUIT);
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
914 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
915 */
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
916
10365
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
917 option = gaim_account_option_bool_new(_("Use SSL"), "ssl", FALSE);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
918 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
d2f999970f91 [gaim-migrate @ 11583]
Ethan Blanton <elb@pidgin.im>
parents: 10258
diff changeset
919
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
920 _irc_plugin = plugin;
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
921
11763
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
922 gaim_prefs_remove("/plugins/prpl/irc/quitmsg");
ddb7520d57bd [gaim-migrate @ 14054]
Mark Doliner <mark@kingant.net>
parents: 11718
diff changeset
923 gaim_prefs_remove("/plugins/prpl/irc");
11073
634fec5ed0f2 [gaim-migrate @ 13082]
Mark Doliner <mark@kingant.net>
parents: 11033
diff changeset
924
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
925 irc_register_commands();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
928 GAIM_INIT_PLUGIN(irc, _init_plugin, info);