annotate src/protocols/irc/irc.c @ 9274:f5c08be60098

[gaim-migrate @ 10077] Bjoern Voigt writes "i18n62.patch: - display "Public Key Information" display contains an ASCII table with tabulators (after some discussion in gaim-i18n I reverted parts of my last patch) " he continues "i18n64.patch: - spelling in src/protocols/irc/parse.c and src/protocols/silc/silc.c - added a missing i18n string in src/protocols/irc/msgs.c" committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sun, 13 Jun 2004 17:26:45 +0000
parents f4f210e47b60
children 7a8aa87164ae
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"
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
32 #include "multi.h"
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
33 #include "notify.h"
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
34 #include "prpl.h"
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
35 #include "plugin.h"
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
36 #include "util.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);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6622
diff changeset
43 static void irc_blist_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
44 static GList *irc_away_states(GaimConnection *gc);
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); */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
47 static void irc_login(GaimAccount *account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
48 static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
49 static void irc_close(GaimConnection *gc);
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
50 static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
51 static int irc_chat_send(GaimConnection *gc, int id, const char *what);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
52 static void irc_chat_join (GaimConnection *gc, GHashTable *data);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
53 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
54
7711
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
55 static guint irc_nick_hash(const char *nick);
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
56 static gboolean irc_nick_equal(const char *nick1, const char *nick2);
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
57 static void irc_buddy_free(struct irc_buddy *ib);
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
58
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
59 static GaimPlugin *_irc_plugin = NULL;
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
60
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
61 static const char *status_chars = "@+%&";
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
62
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
63 static void irc_view_motd(GaimPluginAction *action)
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
64 {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
65 GaimConnection *gc = (GaimConnection *) action->context;
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
66 struct irc_conn *irc;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
67 char *title;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
68
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
69 if (gc == NULL || gc->proto_data == NULL) {
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
70 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
71 return;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
72 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
73 irc = gc->proto_data;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
74 if (irc->motd == NULL) {
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
75 gaim_notify_error(gc, _("Error displaying MOTD"), _("No MOTD available"),
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
76 _("There is no MOTD associated with this connection."));
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
77 return;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
78 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
79 title = g_strdup_printf(_("MOTD for %s"), irc->server);
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
80 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
81 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
82
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
83 int irc_send(struct irc_conn *irc, const char *buf)
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
84 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
85 if (irc->fd < 0)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
86 return -1;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
87
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
88 /* gaim_debug(GAIM_DEBUG_MISC, "irc", "sent: %s", buf); */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
89 return write(irc->fd, buf, strlen(buf));
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
90 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
91
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
92 /* XXX I don't like messing directly with these buddies */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
93 gboolean irc_blist_timeout(struct irc_conn *irc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
95 GString *string = g_string_sized_new(512);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
96 char *list, *buf;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
97
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
98 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
99
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
100 list = g_string_free(string, FALSE);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
101 if (!list || !strlen(list)) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
102 g_free(list);
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
103 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 }
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
105
8038
de9a93878469 [gaim-migrate @ 8719]
Ethan Blanton <elb@pidgin.im>
parents: 7956
diff changeset
106 buf = irc_format(irc, "vn", "ISON", list);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
107 g_free(list);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
108 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
109 g_free(buf);
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
110
2131
acc11216ec5d [gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
111 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
114 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
115 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
116 ib->flag = FALSE;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
117 g_string_append_printf(string, "%s ", name);
3511
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
118 }
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
119
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6622
diff changeset
120 static const char *irc_blist_icon(GaimAccount *a, GaimBuddy *b)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
121 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
122 return "irc";
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
123 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
124
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6622
diff changeset
125 static void irc_blist_emblems(GaimBuddy *b, char **se, char **sw, char **nw, char **ne)
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
126 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
127 if (b->present == GAIM_BUDDY_OFFLINE)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
128 *se = "offline";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
131 static GList *irc_away_states(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
133 return g_list_append(NULL, (gpointer)GAIM_AWAY_CUSTOM);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
134 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
135
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
136 static GList *irc_actions(GaimPlugin *plugin, gpointer context)
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
137 {
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
138 GList *list = NULL;
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
139 GaimPluginAction *act = NULL;
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
140
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
141 act = gaim_plugin_action_new(_("View MOTD"), irc_view_motd);
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
142 list = g_list_append(list, act);
7148
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
143
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
144 return list;
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
145 }
5c03e3e0d451 [gaim-migrate @ 7715]
Ethan Blanton <elb@pidgin.im>
parents: 7118
diff changeset
146
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
147
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
148 static void irc_dccsend_send_ask_menu(GaimBlistNode *node, gpointer data)
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
149 {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
150 GaimBuddy *buddy;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
151 GaimConnection *gc;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
152
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
153 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(node));
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
154
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
155 buddy = (GaimBuddy *) node;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
156 gc =gaim_account_get_connection(buddy->account);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
157
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
158 irc_dccsend_send_ask(gc, buddy->name);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
159 }
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
160
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
161
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
162 static GList *irc_blist_node_menu(GaimBlistNode *node)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 {
8351
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
164 GList *m = NULL;
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
165 GaimBlistNodeAction *act;
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
166
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
167 if(GAIM_BLIST_NODE_IS_BUDDY(node)) {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
168 act = gaim_blist_node_action_new(_("Send File"),
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
169 irc_dccsend_send_ask_menu, NULL);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
170 m = g_list_append(m, act);
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
171 }
8351
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
172
ffa642240fc1 [gaim-migrate @ 9075]
Nathan Walp <nwalp@pidgin.im>
parents: 8287
diff changeset
173 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
176 static GList *irc_chat_join_info(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
178 GList *m = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
179 struct proto_chat_entry *pce;
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
180
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
181 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7711
diff changeset
182 pce->label = _("_Channel:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5221
diff changeset
183 pce->identifier = "channel";
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
184 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
185
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
186 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7711
diff changeset
187 pce->label = _("_Password:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5221
diff changeset
188 pce->identifier = "password";
6499
17a9cdac508e [gaim-migrate @ 7014]
Nathan Walp <nwalp@pidgin.im>
parents: 6459
diff changeset
189 pce->secret = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
190 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
191
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
192 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
195 static void irc_login(GaimAccount *account)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
196 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
197 GaimConnection *gc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
198 struct irc_conn *irc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
199 char *buf, **userparts;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
200 const char *username = gaim_account_get_username(account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
201 int err;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
202
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
203 gc = gaim_account_get_connection(account);
8677
cc2ce209cc46 [gaim-migrate @ 9430]
Sean Egan <seanegan@gmail.com>
parents: 8589
diff changeset
204 gc->flags |= GAIM_CONNECTION_NO_NEWLINES;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
205
6752
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
206 if (strpbrk(username, " \t\v\r\n") != NULL) {
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
207 gaim_connection_error(gc, _("IRC nicks may not contain whitespace"));
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
208 return;
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
209 }
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
210
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
211 gc->proto_data = irc = g_new0(struct irc_conn, 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
212 irc->account = account;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
213
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
214 userparts = g_strsplit(username, "@", 2);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
215 gaim_connection_set_display_name(gc, userparts[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
216 irc->server = g_strdup(userparts[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
217 g_strfreev(userparts);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
218
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
219 irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
220 NULL, (GDestroyNotify)irc_buddy_free);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
221 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
222 irc_cmd_table_build(irc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
223 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
224 irc_msg_table_build(irc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
225
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
226 buf = g_strdup_printf(_("Signon: %s"), username);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
227 gaim_connection_update_progress(gc, buf, 1, 2);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
228 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
229
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
230 err = gaim_proxy_connect(account, irc->server,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
231 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT),
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
232 irc_login_cb, gc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
233
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
234 if (err || !account->gc) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
235 gaim_connection_error(gc, _("Couldn't create socket"));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
236 return;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
237 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
238 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
239
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
240 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
241 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
242 GaimConnection *gc = data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
243 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
244 char hostname[256];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
245 char *buf;
7323
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
246 const char *username;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
247 GList *connections = gaim_connections_get_all();
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
248
8778
8bf735cf9d1c [gaim-migrate @ 9540]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
249 if (source < 0) {
8bf735cf9d1c [gaim-migrate @ 9540]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
250 gaim_connection_error(gc, _("Couldn't connect to host"));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
251 return;
8778
8bf735cf9d1c [gaim-migrate @ 9540]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
252 }
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
253
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
254 if (!g_list_find(connections, gc)) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
255 close(source);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
256 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
257 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
258
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
259 irc->fd = source;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
260
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
261 if (gc->account->password && *gc->account->password) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
262 buf = irc_format(irc, "vv", "PASS", gc->account->password);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
263 if (irc_send(irc, buf) < 0) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
264 gaim_connection_error(gc, "Error sending password");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
265 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
266 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
267 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
268 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
269
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
270 gethostname(hostname, sizeof(hostname));
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
271 hostname[sizeof(hostname) - 1] = '\0';
7323
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
272 username = gaim_account_get_string(irc->account, "username", "");
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
273 buf = irc_format(irc, "vvvv:", "USER", strlen(username) ? username : g_get_user_name(), hostname, irc->server,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
274 gc->account->alias && *gc->account->alias ? gc->account->alias : IRC_DEFAULT_ALIAS);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
275 if (irc_send(irc, buf) < 0) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
276 gaim_connection_error(gc, "Error registering with server");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
277 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
278 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
279 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
280 buf = irc_format(irc, "vn", "NICK", gaim_connection_get_display_name(gc));
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
281 if (irc_send(irc, buf) < 0) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
282 gaim_connection_error(gc, "Error sending nickname");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
283 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
284 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
285 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
286
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
287 gc->inpa = gaim_input_add(irc->fd, GAIM_INPUT_READ, irc_input_cb, gc);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
288 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
289
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
290 static void irc_close(GaimConnection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
291 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
292 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
293
6752
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
294 if (irc == NULL)
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
295 return;
90fd056e755d [gaim-migrate @ 7284]
Ethan Blanton <elb@pidgin.im>
parents: 6695
diff changeset
296
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
297 irc_cmd_quit(irc, "quit", NULL, NULL);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
298
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
299 if (gc->inpa)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8170
diff changeset
300 gaim_timeout_remove(gc->inpa);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
301
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
302 g_free(irc->inbuf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
303 close(irc->fd);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
304 if (irc->timer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8170
diff changeset
305 gaim_timeout_remove(irc->timer);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
306 g_hash_table_destroy(irc->cmds);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
307 g_hash_table_destroy(irc->msgs);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
308 if (irc->motd)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
309 g_string_free(irc->motd, TRUE);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
310 g_free(irc->server);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
311 g_free(irc);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
312 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
313
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
314 static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
315 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
316 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
317 const char *args[2];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
318
7711
ebd43be54140 [gaim-migrate @ 8356]
Ethan Blanton <elb@pidgin.im>
parents: 7653
diff changeset
319 if (strchr(status_chars, *who) != NULL)
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
320 args[0] = who + 1;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
321 else
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
322 args[0] = who;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
323 args[1] = what;
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
324 #if 0
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
325 if (*what == '/') {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
326 return irc_parse_cmd(irc, who, what + 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
327 }
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
328 #endif
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
329 irc_cmd_privmsg(irc, "msg", NULL, args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
330 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
331 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
333 static void irc_get_info(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
335 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
336 const char *args[1];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
337 args[0] = who;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
338 irc_cmd_whois(irc, "whois", NULL, args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
339 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
340
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
341 static void irc_set_away(GaimConnection *gc, const char *state, const char *msg)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
342 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
343 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
344 const char *args[1];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
346 if (gc->away) {
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
347 g_free(gc->away);
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
348 gc->away = NULL;
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
349 }
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
350
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
351 if (msg)
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
352 gc->away = g_strdup(msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
354 args[0] = msg;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
355 irc_cmd_away(irc, "away", NULL, args);
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
356 }
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
357
6787
faa491042c66 [gaim-migrate @ 7326]
Christian Hammond <chipx86@chipx86.com>
parents: 6752
diff changeset
358 static void irc_add_buddy(GaimConnection *gc, const char *who, GaimGroup *group)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
359 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
360 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
361 struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
362 ib->name = g_strdup(who);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
363 g_hash_table_insert(irc->buddies, ib->name, ib);
9238
f4f210e47b60 [gaim-migrate @ 10036]
Ethan Blanton <elb@pidgin.im>
parents: 9154
diff changeset
364
f4f210e47b60 [gaim-migrate @ 10036]
Ethan Blanton <elb@pidgin.im>
parents: 9154
diff changeset
365 irc_blist_timeout(irc);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
366 }
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
367
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
368 static void irc_remove_buddy(GaimConnection *gc, const char *who, const char *group)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
369 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
370 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
371 g_hash_table_remove(irc->buddies, who);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
372 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
373
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
374
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
375 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
376 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
377 GaimConnection *gc = data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
378 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
379 char *cur, *end;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
380 int len;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
381
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
382 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
383 irc->inbuflen += IRC_INITIAL_BUFSIZE;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
384 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen);
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
385 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
386
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
387 if ((len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) {
7653
b34655144117 [gaim-migrate @ 8297]
Luke Schierer <lschiere@pidgin.im>
parents: 7323
diff changeset
388 gaim_connection_error(gc, _("Read error"));
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
389 return;
6369
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
390 } else if (len == 0) {
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
391 /* Remote closed the connection, probably */
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
392 return;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
393 }
6369
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
394
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
395 irc->inbufused += len;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
396 irc->inbuf[irc->inbufused] = '\0';
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
397
8156
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
398 cur = irc->inbuf;
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
399 while (cur < irc->inbuf + irc->inbufused &&
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
400 ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) {
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
401 int step = (*end == '\r' ? 2 : 1);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
402 *end = '\0';
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
403 irc_parse_msg(irc, cur);
8156
a0e7d0995156 [gaim-migrate @ 8868]
Ethan Blanton <elb@pidgin.im>
parents: 8114
diff changeset
404 cur = end + step;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
405 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
406 if (cur != irc->inbuf + irc->inbufused) { /* leftover */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
407 irc->inbufused -= (cur - irc->inbuf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
408 memmove(irc->inbuf, cur, irc->inbufused);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
409 } else {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
410 irc->inbufused = 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
411 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
412 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
413
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
414 static void irc_chat_join (GaimConnection *gc, GHashTable *data)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
415 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
416 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
417 const char *args[2];
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
418
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
419 args[0] = g_hash_table_lookup(data, "channel");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
420 args[1] = g_hash_table_lookup(data, "password");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
421 irc_cmd_join(irc, "join", NULL, args);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
422 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
423
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
424 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
425 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
426 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
427 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
428 const char *args[2];
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
429
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
430 if (!convo) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
431 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
432 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
433 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
434 args[0] = name;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
435 args[1] = gaim_conversation_get_name(convo);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
436 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
437 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
438
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
439
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
440 static void irc_chat_leave (GaimConnection *gc, int id)
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
441 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
442 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
443 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
444 const char *args[2];
5298
857106f8f971 [gaim-migrate @ 5670]
Nathan Walp <nwalp@pidgin.im>
parents: 5265
diff changeset
445
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
446 if (!convo)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
447 return;
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
448
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
449 args[0] = gaim_conversation_get_name(convo);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
450 args[1] = NULL;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
451 irc_cmd_part(irc, "part", gaim_conversation_get_name(convo), args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
452 serv_got_chat_left(gc, id);
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
453 }
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
454
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
455 static int irc_chat_send(GaimConnection *gc, int id, const char *what)
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
456 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
457 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
458 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
459 const char *args[2];
8163
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
460 char *tmp;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
461
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
462 if (!convo) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
463 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
464 return -EINVAL;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
465 }
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
466 #if 0
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
467 if (*what == '/') {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
468 return irc_parse_cmd(irc, convo->name, what + 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
469 }
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
470 #endif
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
471 args[0] = convo->name;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
472 args[1] = what;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
473
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
474 irc_cmd_privmsg(irc, "msg", NULL, args);
8163
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
475
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
476 tmp = gaim_escape_html(what);
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
477 serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, tmp, time(NULL));
da57fb60680a [gaim-migrate @ 8875]
Ethan Blanton <elb@pidgin.im>
parents: 8156
diff changeset
478 g_free(tmp);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
479 return 0;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
480 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
481
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
482 static guint irc_nick_hash(const char *nick)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
483 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
484 char *lc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
485 guint bucket;
6270
1bf6fd117797 [gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
486
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
487 lc = g_utf8_strdown(nick, -1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
488 bucket = g_str_hash(lc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
489 g_free(lc);
6270
1bf6fd117797 [gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
490
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
491 return bucket;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
492 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
493
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
494 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
495 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
496 return (gaim_utf8_strcasecmp(nick1, nick2) == 0);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
497 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
498
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
499 static void irc_buddy_free(struct irc_buddy *ib)
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
500 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
501 g_free(ib->name);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
502 g_free(ib);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
503 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
504
9154
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
505 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
506 {
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
507 char *buf;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
508 const char *name = NULL;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
509 struct irc_conn *irc;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
510
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
511 irc = gc->proto_data;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
512 name = gaim_conversation_get_name(gaim_find_chat(gc, id));
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
513
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
514 if (name == NULL)
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
515 return;
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
516
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
517 buf = irc_format(irc, "vt:", "TOPIC", name, topic);
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
518 irc_send(irc, buf);
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
519 g_free(buf);
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
520 }
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
521
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
522 static GaimRoomlist *irc_roomlist_get_list(GaimConnection *gc)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
523 {
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
524 struct irc_conn *irc;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
525 GList *fields = NULL;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
526 GaimRoomlistField *f;
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
527 char *buf;
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
528
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
529 irc = gc->proto_data;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
530
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
531 if (irc->roomlist)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
532 gaim_roomlist_unref(irc->roomlist);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
533
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
534 irc->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc));
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
535
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
536 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
537 fields = g_list_append(fields, f);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
538
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
539 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
540 fields = g_list_append(fields, f);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
541
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
542 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
543 fields = g_list_append(fields, f);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
544
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
545 gaim_roomlist_set_fields(irc->roomlist, fields);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
546
8352
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
547 buf = irc_format(irc, "v", "LIST");
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
548 irc_send(irc, buf);
77baefe979c6 [gaim-migrate @ 9076]
Nathan Walp <nwalp@pidgin.im>
parents: 8351
diff changeset
549 g_free(buf);
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
550
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
551 return irc->roomlist;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
552 }
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
553
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
554 static void irc_roomlist_cancel(GaimRoomlist *list)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
555 {
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
556 GaimConnection *gc = gaim_account_get_connection(list->account);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
557 struct irc_conn *irc;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
558
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
559 if (gc == NULL)
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
560 return;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
561
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
562 irc = gc->proto_data;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
563
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
564 gaim_roomlist_set_in_progress(list, FALSE);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
565
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
566 if (irc->roomlist == list) {
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
567 irc->roomlist = NULL;
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
568 gaim_roomlist_unref(list);
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
569 }
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
570 }
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
571
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
572 static GaimPluginProtocolInfo prpl_info =
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
574 GAIM_PRPL_API_VERSION,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
575 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
576 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
577 NULL,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
578 irc_blist_icon,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
579 irc_blist_emblems,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
580 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
581 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
582 irc_away_states,
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
583 irc_blist_node_menu,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
584 irc_chat_join_info,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
585 irc_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
586 irc_close,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
587 irc_im_send,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
588 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
589 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
590 irc_get_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
591 irc_set_away,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
592 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
593 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
594 irc_add_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
595 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
596 irc_remove_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
597 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
598 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
599 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
600 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
601 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
602 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
603 NULL,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
604 irc_chat_join,
8562
e3c059c3d92d [gaim-migrate @ 9306]
Luke Schierer <lschiere@pidgin.im>
parents: 8352
diff changeset
605 NULL, /* reject chat invite */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
606 irc_chat_invite,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
607 irc_chat_leave,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
608 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
609 irc_chat_send,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
610 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
611 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
612 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
613 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
614 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
615 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
616 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
617 NULL,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
618 NULL, /*irc_convo_closed,*/
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
619 NULL, /* normalize */
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
620 NULL, /* set buddy icon */
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
621 NULL, /* remove group */
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
622 NULL, /* get_cb_real_name */
9154
dcb290a0c970 [gaim-migrate @ 9938]
Ethan Blanton <elb@pidgin.im>
parents: 9130
diff changeset
623 irc_chat_set_topic,
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
624 NULL,
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
625 irc_roomlist_get_list,
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
626 irc_roomlist_cancel,
8589
72a0759a37a2 [gaim-migrate @ 9340]
Mark Doliner <mark@kingant.net>
parents: 8586
diff changeset
627 NULL
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
628 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
629
8114
7a6e30eb7aad [gaim-migrate @ 8818]
Ethan Blanton <elb@pidgin.im>
parents: 8038
diff changeset
630
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
631 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
632 {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
633 GAIM_PLUGIN_API_VERSION, /**< api_version */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
634 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
635 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
636 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
637 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
638 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
639
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
640 "prpl-irc", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
641 "IRC", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
642 VERSION, /**< version */
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
643 N_("IRC Protocol Plugin"), /** summary */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
644 N_("The IRC Protocol Plugin that Sucks Less"), /** description */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
645 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6369
diff changeset
646 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
647
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
648 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
649 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
650 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
651
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
652 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8950
diff changeset
653 &prpl_info, /**< extra_info */
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8950
diff changeset
654 NULL,
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
655 irc_actions
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
656 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
657
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
658 static void _init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
659 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
660 GaimAccountUserSplit *split;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
661 GaimAccountOption *option;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
662
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
663 split = gaim_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@');
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
664 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
665
6459
b52870734c21 [gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
666 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
667 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
668
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
669 option = gaim_account_option_string_new(_("Encoding"), "encoding", IRC_DEFAULT_CHARSET);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
670 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
671
7323
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
672 option = gaim_account_option_string_new(_("Username"), "username", "");
443fc7d6fbff [gaim-migrate @ 7909]
Ethan Blanton <elb@pidgin.im>
parents: 7156
diff changeset
673 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
674
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
675 _irc_plugin = plugin;
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
676
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
677 irc_register_commands();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
678 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
679
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
680 GAIM_INIT_PLUGIN(irc, _init_plugin, info);