annotate src/protocols/irc/irc.c @ 6622:a4622f1fb5a1

[gaim-migrate @ 7146] (10:10:23) Robot101: kills off OPT_CONN_* in favour of an enum, and deprecates all the IM_FLAGS_* except IM_FLAG_AWAY which is made into GAIM_IM_AUTO_RESP in a GaimImFlags enum. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 25 Aug 2003 14:12:28 +0000
parents 17a9cdac508e
children 0c5637b5462e
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 *
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
6 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu>
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
7 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com>
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net>
6459
b52870734c21 [gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
9 *
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * 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
12 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 */
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
24
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
25 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
26
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
27 #include "plugin.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
28 #include "accountopt.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
29 #include "multi.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5791
diff changeset
30 #include "prpl.h"
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
31 #include "conversation.h"
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
32 #include "debug.h"
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
33 #include "blist.h"
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
34 #include "util.h"
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
35 #include "irc.h"
4422
2fd80799d8f4 [gaim-migrate @ 4695]
Luke Schierer <lschiere@pidgin.im>
parents: 4416
diff changeset
36
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
37 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
38
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
39 static const char *irc_blist_icon(GaimAccount *a, struct buddy *b);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
40 static void irc_blist_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
41 static GList *irc_away_states(GaimConnection *gc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
42 /* static GList *irc_chat_info(GaimConnection *gc); */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
43 static void irc_login(GaimAccount *account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
44 static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
45 static void irc_close(GaimConnection *gc);
6622
a4622f1fb5a1 [gaim-migrate @ 7146]
Luke Schierer <lschiere@pidgin.im>
parents: 6499
diff changeset
46 static int irc_im_send(GaimConnection *gc, const char *who, const char *what, int len, GaimImFlags flags);
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
47 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
48 static void irc_chat_join (GaimConnection *gc, GHashTable *data);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
49 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
50
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
51 static guint irc_nick_hash(const char *nick);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
52 static gboolean irc_nick_equal(const char *nick1, const char *nick2);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
53 static void irc_buddy_free(struct irc_buddy *ib);
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
54
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
55 static GaimPlugin *_irc_plugin = NULL;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
56
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
57 int irc_send(struct irc_conn *irc, const char *buf)
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
58 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
59 if (irc->fd < 0)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
60 return -1;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
61
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
62 /* gaim_debug(GAIM_DEBUG_MISC, "irc", "sent: %s", buf); */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
63 return write(irc->fd, buf, strlen(buf));
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
64 }
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2171
diff changeset
65
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
66 /* XXX I don't like messing directly with these buddies */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
67 gboolean irc_blist_timeout(struct irc_conn *irc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
69 GString *string = g_string_sized_new(512);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
70 char *list, *buf;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
71
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
72 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
73
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
74 list = g_string_free(string, FALSE);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
75 if (!list || !strlen(list)) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
76 g_free(list);
2137
18722ae5b882 [gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2131
diff changeset
77 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 }
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
79
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
80 buf = irc_format(irc, "v:", "ISON", list);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
81 g_free(list);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
82 irc_send(irc, buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
83 g_free(buf);
4416
8e62cee6d738 [gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents: 4373
diff changeset
84
2131
acc11216ec5d [gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2123
diff changeset
85 return TRUE;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
88 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
89 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
90 ib->flag = FALSE;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
91 g_string_append_printf(string, "%s ", name);
3511
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
92 }
7e1c6c16dd41 [gaim-migrate @ 3583]
Sean Egan <seanegan@gmail.com>
parents: 3501
diff changeset
93
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
94 static const char *irc_blist_icon(GaimAccount *a, struct buddy *b)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
95 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
96 return "irc";
2339
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
97 }
9bda60d2d2e6 [gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2331
diff changeset
98
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
99 static void irc_blist_emblems(struct buddy *b, char **se, char **sw, char **nw, char **ne)
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
100 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
101 if (b->present == GAIM_BUDDY_OFFLINE)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
102 *se = "offline";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
105 static GList *irc_away_states(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
107 return g_list_append(NULL, (gpointer)GAIM_AWAY_CUSTOM);
3452
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
108 }
12202a328adf [gaim-migrate @ 3497]
Sean Egan <seanegan@gmail.com>
parents: 3427
diff changeset
109
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
110 static GList *irc_buddy_menu(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
112 return NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
115 static GList *irc_chat_join_info(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
117 GList *m = NULL;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
118 struct proto_chat_entry *pce;
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
119
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
120 pce = g_new0(struct proto_chat_entry, 1);
2466
f8eb5f120603 [gaim-migrate @ 2479]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2459
diff changeset
121 pce->label = _("Channel:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5221
diff changeset
122 pce->identifier = "channel";
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
123 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
124
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
125 pce = g_new0(struct proto_chat_entry, 1);
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
126 pce->label = _("Password:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5221
diff changeset
127 pce->identifier = "password";
6499
17a9cdac508e [gaim-migrate @ 7014]
Nathan Walp <nwalp@pidgin.im>
parents: 6459
diff changeset
128 pce->secret = TRUE;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
129 m = g_list_append(m, pce);
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
130
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
131 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
134 static void irc_login(GaimAccount *account)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
135 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
136 GaimConnection *gc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
137 struct irc_conn *irc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
138 char *buf, **userparts;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
139 const char *username = gaim_account_get_username(account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
140 int err;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
141
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
142 gc = gaim_account_get_connection(account);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
143
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
144 gc->proto_data = irc = g_new0(struct irc_conn, 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
145 irc->account = account;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
146
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
147 userparts = g_strsplit(username, "@", 2);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
148 gaim_connection_set_display_name(gc, userparts[0]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
149 irc->server = g_strdup(userparts[1]);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
150 g_strfreev(userparts);
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
151
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
152 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
153 NULL, (GDestroyNotify)irc_buddy_free);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
154 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
155 irc_cmd_table_build(irc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
156 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
157 irc_msg_table_build(irc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
158
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
159 buf = g_strdup_printf(_("Signon: %s"), username);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
160 gaim_connection_update_progress(gc, buf, 1, 2);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
161 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
162
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
163 err = gaim_proxy_connect(account, irc->server,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
164 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT),
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
165 irc_login_cb, gc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
166
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
167 if (err || !account->gc) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
168 gaim_connection_error(gc, _("Couldn't create socket"));
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
169 return;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
170 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
171 }
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
172
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
173 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
174 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
175 GaimConnection *gc = data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
176 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
177 char hostname[256];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
178 char *buf;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
179 GList *connections = gaim_connections_get_all();
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
180
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
181 if (source < 0)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
182 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
183
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
184 if (!g_list_find(connections, gc)) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
185 close(source);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
186 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
187 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
188
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
189 irc->fd = source;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
190
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
191 if (gc->account->password && *gc->account->password) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
192 buf = irc_format(irc, "vv", "PASS", gc->account->password);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
193 if (irc_send(irc, buf) < 0) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
194 gaim_connection_error(gc, "Error sending password");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
195 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
196 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
197 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
198 }
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
199
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
200 gethostname(hostname, sizeof(hostname));
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
201 hostname[sizeof(hostname) - 1] = '\0';
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
202 buf = irc_format(irc, "vvvv:", "USER", g_get_user_name(), hostname, irc->server,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
203 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
204 if (irc_send(irc, buf) < 0) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
205 gaim_connection_error(gc, "Error registering with server");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
206 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
207 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
208 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
209 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
210 if (irc_send(irc, buf) < 0) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
211 gaim_connection_error(gc, "Error sending nickname");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
212 return;
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 g_free(buf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
215
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
216 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
217 }
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 static void irc_close(GaimConnection *gc)
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
220 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
221 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
222
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
223 irc_cmd_quit(irc, "quit", NULL, NULL);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
224
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
225 if (gc->inpa)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
226 g_source_remove(gc->inpa);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
227
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
228 g_free(irc->inbuf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
229 close(irc->fd);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
230 if (irc->timer)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
231 g_source_remove(irc->timer);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
232 g_hash_table_destroy(irc->cmds);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
233 g_hash_table_destroy(irc->msgs);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
234 if (irc->motd)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
235 g_string_free(irc->motd, TRUE);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
236 g_free(irc->server);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
237 g_free(irc);
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
6622
a4622f1fb5a1 [gaim-migrate @ 7146]
Luke Schierer <lschiere@pidgin.im>
parents: 6499
diff changeset
240 static int irc_im_send(GaimConnection *gc, const char *who, const char *what, int len, GaimImFlags flags)
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 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
243 const char *args[2];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
244
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
245 if (*who == '@' || *who == '%' || *who == '+')
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
246 args[0] = who + 1;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
247 else
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
248 args[0] = who;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
249 args[1] = what;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
250
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
251 if (*what == '/') {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
252 return irc_parse_cmd(irc, who, what + 1);
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
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
255 irc_cmd_privmsg(irc, "msg", NULL, args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
256 return 1;
2289
38e156136896 [gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2273
diff changeset
257 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
259 static void irc_get_info(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
261 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
262 const char *args[1];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
263 args[0] = who;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
264 irc_cmd_whois(irc, "whois", NULL, args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
265 }
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 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
268 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
269 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
270 const char *args[1];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
272 if (gc->away) {
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
273 g_free(gc->away);
2394
579f8d4347ad [gaim-migrate @ 2407]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2393
diff changeset
274 gc->away = NULL;
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
275 }
2393
a7ecfd3f7714 [gaim-migrate @ 2406]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2382
diff changeset
276
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
277 if (msg)
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 4067
diff changeset
278 gc->away = g_strdup(msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
280 args[0] = msg;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
281 irc_cmd_away(irc, "away", NULL, args);
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
282 }
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4834
diff changeset
283
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
284 static void irc_add_buddy(GaimConnection *gc, const char *who)
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
285 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
286 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
287 struct irc_buddy *ib = g_new0(struct irc_buddy, 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
288 ib->name = g_strdup(who);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
289 g_hash_table_insert(irc->buddies, ib->name, ib);
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
290 }
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
291
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
292 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
293 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
294 struct irc_conn *irc = (struct irc_conn *)gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
295 g_hash_table_remove(irc->buddies, who);
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
296 }
4514
7521e29658bc [gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents: 4509
diff changeset
297
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
298
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
299 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond)
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 GaimConnection *gc = data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
302 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
303 char *cur, *end;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
304 int len;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
305
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
306 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
307 irc->inbuflen += IRC_INITIAL_BUFSIZE;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
308 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen);
3708
da6e3c984985 [gaim-migrate @ 3841]
Luke Schierer <lschiere@pidgin.im>
parents: 3707
diff changeset
309 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
310
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
311 if ((len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
312 gaim_connection_error(gc, "Read error");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
313 return;
6369
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
314 } else if (len == 0) {
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
315 /* Remote closed the connection, probably */
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
316 return;
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
317 }
6369
1cdc8a11eea5 [gaim-migrate @ 6874]
Luke Schierer <lschiere@pidgin.im>
parents: 6364
diff changeset
318
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
319 irc->inbufused += len;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
320 irc->inbuf[irc->inbufused] = '\0';
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
321
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
322 for (cur = irc->inbuf; cur < irc->inbuf + irc->inbufused && (end = strstr(cur, "\r\n")); cur = end + 2) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
323 *end = '\0';
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
324 irc_parse_msg(irc, cur);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
325 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
326 if (cur != irc->inbuf + irc->inbufused) { /* leftover */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
327 irc->inbufused -= (cur - irc->inbuf);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
328 memmove(irc->inbuf, cur, irc->inbufused);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
329 } else {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
330 irc->inbufused = 0;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
331 }
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
332 }
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
333
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
334 static void irc_chat_join (GaimConnection *gc, GHashTable *data)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
335 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
336 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
337 const char *args[2];
3616
9e776fde2fed [gaim-migrate @ 3730]
Rob Flynn <gaim@robflynn.com>
parents: 3605
diff changeset
338
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
339 args[0] = g_hash_table_lookup(data, "channel");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
340 args[1] = g_hash_table_lookup(data, "password");
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
341 irc_cmd_join(irc, "join", NULL, args);
3622
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
342 }
2ef75915a13c [gaim-migrate @ 3743]
Rob Flynn <gaim@robflynn.com>
parents: 3619
diff changeset
343
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
344 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
345 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
346 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
347 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
348 const char *args[2];
3751
e25577506dec [gaim-migrate @ 3889]
Luke Schierer <lschiere@pidgin.im>
parents: 3735
diff changeset
349
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
350 if (!convo) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
351 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
352 return;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
353 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
354 args[0] = name;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
355 args[1] = gaim_conversation_get_name(convo);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
356 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
357 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
358
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
359
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
360 static void irc_chat_leave (GaimConnection *gc, int id)
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
361 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
362 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
363 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
364 const char *args[2];
5298
857106f8f971 [gaim-migrate @ 5670]
Nathan Walp <nwalp@pidgin.im>
parents: 5265
diff changeset
365
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
366 if (!convo)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
367 return;
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
368
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
369 args[0] = gaim_conversation_get_name(convo);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
370 args[1] = NULL;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
371 irc_cmd_part(irc, "part", gaim_conversation_get_name(convo), args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
372 serv_got_chat_left(gc, id);
3735
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
373 }
242e52b37a78 [gaim-migrate @ 3873]
Luke Schierer <lschiere@pidgin.im>
parents: 3730
diff changeset
374
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
375 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
376 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
377 struct irc_conn *irc = gc->proto_data;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
378 GaimConversation *convo = gaim_find_chat(gc, id);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
379 const char *args[2];
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
380
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
381 if (!convo) {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
382 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
383 return -EINVAL;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
384 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
385
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
386 if (*what == '/') {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
387 return irc_parse_cmd(irc, convo->name, what + 1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
388 }
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
389
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
390 args[0] = convo->name;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
391 args[1] = what;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
392
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
393 irc_cmd_privmsg(irc, "msg", NULL, args);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
394 serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, what, time(NULL));
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
395 return 0;
3707
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
396 }
c1254110070a [gaim-migrate @ 3840]
Luke Schierer <lschiere@pidgin.im>
parents: 3665
diff changeset
397
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
398 static guint irc_nick_hash(const char *nick)
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
399 {
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
400 char *lc;
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
401 guint bucket;
6270
1bf6fd117797 [gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
402
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
403 lc = g_utf8_strdown(nick, -1);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
404 bucket = g_str_hash(lc);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
405 g_free(lc);
6270
1bf6fd117797 [gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents: 6240
diff changeset
406
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
407 return bucket;
3029
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
408 }
21895719464c [gaim-migrate @ 3042]
Sean Egan <seanegan@gmail.com>
parents: 3028
diff changeset
409
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
410 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
411 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
412 return (gaim_utf8_strcasecmp(nick1, nick2) == 0);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
413 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
414
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
415 static void irc_buddy_free(struct irc_buddy *ib)
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
416 {
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
417 g_free(ib->name);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
418 g_free(ib);
2619
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
419 }
536198196dc6 [gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2617
diff changeset
420
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
421 static GaimPluginProtocolInfo prpl_info =
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 {
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
423 GAIM_PROTO_IRC,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
424 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
425 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
426 NULL,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
427 irc_blist_icon,
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
428 irc_blist_emblems,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
429 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
430 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
431 irc_away_states,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
432 NULL,
6350
34c07f5f34a0 [gaim-migrate @ 6849]
Mark Doliner <mark@kingant.net>
parents: 6333
diff changeset
433 irc_buddy_menu,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
434 irc_chat_join_info,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
435 irc_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
436 irc_close,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
437 irc_im_send,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
438 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
439 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
440 irc_get_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
441 irc_set_away,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
442 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
443 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
444 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
445 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
446 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
447 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
448 irc_add_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
449 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
450 irc_remove_buddy,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
451 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
452 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
453 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
454 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
455 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
456 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
457 NULL,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
458 irc_chat_join,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
459 irc_chat_invite,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
460 irc_chat_leave,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
461 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
462 irc_chat_send,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
463 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
464 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
465 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
466 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
467 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
468 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
469 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
470 NULL,
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
471 NULL, /*irc_convo_closed,*/
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
472 NULL
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
473 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
474
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
475 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
476 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
477 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
478 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
479 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
480 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
481 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
482 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
483
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
484 "prpl-irc", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
485 "IRC", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
486 VERSION, /**< version */
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
487 N_("IRC Protocol Plugin"), /** summary */
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
488 N_("The IRC Protocol Plugin that Sucks Less"), /** description */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
489 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6369
diff changeset
490 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
491
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
492 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
493 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
494 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
495
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
496 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
497 &prpl_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
498 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
499
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
500 static void _init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5150
diff changeset
501 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
502 GaimAccountUserSplit *split;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
503 GaimAccountOption *option;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
504
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
505 split = gaim_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@');
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5618
diff changeset
506 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
507
6459
b52870734c21 [gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
508 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
509 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
510
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
511 option = gaim_account_option_string_new(_("Encoding"), "encoding", IRC_DEFAULT_CHARSET);
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
512 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
513
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
514 _irc_plugin = plugin;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516
6333
e06e04e44914 [gaim-migrate @ 6832]
Luke Schierer <lschiere@pidgin.im>
parents: 6321
diff changeset
517 GAIM_INIT_PLUGIN(irc, _init_plugin, info);