Mercurial > pidgin
annotate src/protocols/irc/irc.c @ 11163:4cf257598691
[gaim-migrate @ 13264]
Get rid of the last of the gcc4 warnings in jabber
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 29 Jul 2005 01:22:06 +0000 |
parents | 8e600ee6ec61 |
children | bb0d7b719af2 |
rev | line source |
---|---|
6333 | 1 /** |
2 * @file irc.c | |
6459
b52870734c21
[gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
3 * |
6333 | 4 * gaim |
2086 | 5 * |
8351 | 6 * Copyright (C) 2003, Robbert Haarman <gaim@inglorion.net> |
6333 | 7 * Copyright (C) 2003, Ethan Blanton <eblanton@cs.purdue.edu> |
8 * Copyright (C) 2000-2003, Rob Flynn <rob@tgflinux.com> | |
2086 | 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 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 */ | |
6333 | 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 | 29 #include "blist.h" |
6333 | 30 #include "conversation.h" |
9030 | 31 #include "debug.h" |
7148 | 32 #include "notify.h" |
9030 | 33 #include "prpl.h" |
34 #include "plugin.h" | |
6350 | 35 #include "util.h" |
9943 | 36 #include "version.h" |
9030 | 37 |
6333 | 38 #include "irc.h" |
4422 | 39 |
6333 | 40 static void irc_buddy_append(char *name, struct irc_buddy *ib, GString *string); |
2086 | 41 |
6695 | 42 static const char *irc_blist_icon(GaimAccount *a, GaimBuddy *b); |
9953 | 43 static void irc_blist_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne); |
9951 | 44 static GList *irc_status_types(GaimAccount *account); |
9015 | 45 static GList *irc_actions(GaimPlugin *plugin, gpointer context); |
6333 | 46 /* static GList *irc_chat_info(GaimConnection *gc); */ |
10401 | 47 static void irc_login(GaimAccount *account, GaimStatus *status); |
10365 | 48 static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond); |
6333 | 49 static void irc_login_cb(gpointer data, gint source, GaimInputCondition cond); |
10365 | 50 static void irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, gpointer data); |
6333 | 51 static void irc_close(GaimConnection *gc); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
52 static int irc_im_send(GaimConnection *gc, const char *who, const char *what, GaimConvImFlags flags); |
6333 | 53 static int irc_chat_send(GaimConnection *gc, int id, const char *what); |
11083 | 54 static void irc_ping_server(GaimConnection *gc); |
6333 | 55 static void irc_chat_join (GaimConnection *gc, GHashTable *data); |
56 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond); | |
10365 | 57 static void irc_input_cb_ssl(gpointer data, GaimSslConnection *gsc, GaimInputCondition cond); |
3751 | 58 |
7711 | 59 static guint irc_nick_hash(const char *nick); |
60 static gboolean irc_nick_equal(const char *nick1, const char *nick2); | |
61 static void irc_buddy_free(struct irc_buddy *ib); | |
62 | |
63 static GaimPlugin *_irc_plugin = NULL; | |
64 | |
65 static const char *status_chars = "@+%&"; | |
66 | |
9015 | 67 static void irc_view_motd(GaimPluginAction *action) |
7148 | 68 { |
9015 | 69 GaimConnection *gc = (GaimConnection *) action->context; |
7148 | 70 struct irc_conn *irc; |
71 char *title; | |
72 | |
73 if (gc == NULL || gc->proto_data == NULL) { | |
74 gaim_debug(GAIM_DEBUG_ERROR, "irc", "got MOTD request for NULL gc\n"); | |
75 return; | |
76 } | |
77 irc = gc->proto_data; | |
78 if (irc->motd == NULL) { | |
79 gaim_notify_error(gc, _("Error displaying MOTD"), _("No MOTD available"), | |
80 _("There is no MOTD associated with this connection.")); | |
81 return; | |
82 } | |
83 title = g_strdup_printf(_("MOTD for %s"), irc->server); | |
84 gaim_notify_formatted(gc, title, title, NULL, irc->motd->str, NULL, NULL); | |
85 } | |
86 | |
6333 | 87 int irc_send(struct irc_conn *irc, const char *buf) |
3751 | 88 { |
9440 | 89 int ret; |
90 | |
10365 | 91 if (irc->gsc) { |
92 ret = gaim_ssl_write(irc->gsc, buf, strlen(buf)); | |
93 } else { | |
94 if (irc->fd < 0) | |
95 return -1; | |
96 ret = write(irc->fd, buf, strlen(buf)); | |
97 } | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
98 |
10365 | 99 /* gaim_debug(GAIM_DEBUG_MISC, "irc", "sent%s: %s", |
100 irc->gsc ? " (ssl)" : "", buf); */ | |
101 if (ret < 0) { | |
9440 | 102 gaim_connection_error(gaim_account_get_connection(irc->account), |
103 _("Server has disconnected")); | |
10365 | 104 } |
9440 | 105 |
106 return ret; | |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
107 } |
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2171
diff
changeset
|
108 |
6333 | 109 /* XXX I don't like messing directly with these buddies */ |
110 gboolean irc_blist_timeout(struct irc_conn *irc) | |
2086 | 111 { |
6333 | 112 GString *string = g_string_sized_new(512); |
113 char *list, *buf; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
114 |
6333 | 115 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
|
116 |
6333 | 117 list = g_string_free(string, FALSE); |
118 if (!list || !strlen(list)) { | |
119 g_free(list); | |
2137
18722ae5b882
[gaim-migrate @ 2147]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2131
diff
changeset
|
120 return TRUE; |
2086 | 121 } |
4416
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
122 |
8038 | 123 buf = irc_format(irc, "vn", "ISON", list); |
6333 | 124 g_free(list); |
125 irc_send(irc, buf); | |
126 g_free(buf); | |
4416
8e62cee6d738
[gaim-migrate @ 4689]
Christian Hammond <chipx86@chipx86.com>
parents:
4373
diff
changeset
|
127 |
2131
acc11216ec5d
[gaim-migrate @ 2141]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2123
diff
changeset
|
128 return TRUE; |
2086 | 129 } |
130 | |
6333 | 131 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
|
132 { |
6333 | 133 ib->flag = FALSE; |
134 g_string_append_printf(string, "%s ", name); | |
3511 | 135 } |
136 | |
9553 | 137 static void irc_ison_one(struct irc_conn *irc, struct irc_buddy *ib) |
138 { | |
139 char *buf; | |
140 | |
141 ib->flag = FALSE; | |
142 buf = irc_format(irc, "vn", "ISON", ib->name); | |
143 irc_send(irc, buf); | |
144 g_free(buf); | |
145 } | |
146 | |
147 | |
6695 | 148 static const char *irc_blist_icon(GaimAccount *a, GaimBuddy *b) |
3029 | 149 { |
6333 | 150 return "irc"; |
2339
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
151 } |
9bda60d2d2e6
[gaim-migrate @ 2352]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2331
diff
changeset
|
152 |
9953 | 153 static void irc_blist_emblems(GaimBuddy *b, const char **se, const char **sw, const char **nw, const char **ne) |
3751 | 154 { |
10244 | 155 GaimPresence *presence = gaim_buddy_get_presence(b); |
156 | |
157 if (gaim_presence_is_online(presence) == FALSE) { | |
6333 | 158 *se = "offline"; |
10244 | 159 } |
2086 | 160 } |
161 | |
9944 | 162 static GList *irc_status_types(GaimAccount *account) |
2086 | 163 { |
9944 | 164 GaimStatusType *type; |
165 GList *types = NULL; | |
166 | |
167 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, "offline", | |
168 _("Offline"), FALSE); | |
169 types = g_list_append(types, type); | |
170 | |
171 type = gaim_status_type_new(GAIM_STATUS_ONLINE, "online", | |
172 _("Online"), FALSE); | |
173 types = g_list_append(types, type); | |
174 | |
175 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, "available", | |
176 _("Available"), TRUE); | |
177 types = g_list_append(types, type); | |
178 | |
179 type = gaim_status_type_new_with_attrs( | |
180 GAIM_STATUS_AWAY, "away", _("Away"), TRUE, TRUE, FALSE, | |
10009 | 181 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
9944 | 182 types = g_list_append(types, type); |
183 | |
184 return types; | |
3452 | 185 } |
186 | |
9015 | 187 static GList *irc_actions(GaimPlugin *plugin, gpointer context) |
7148 | 188 { |
189 GList *list = NULL; | |
9015 | 190 GaimPluginAction *act = NULL; |
7148 | 191 |
9015 | 192 act = gaim_plugin_action_new(_("View MOTD"), irc_view_motd); |
193 list = g_list_append(list, act); | |
7148 | 194 |
195 return list; | |
196 } | |
197 | |
6333 | 198 static GList *irc_chat_join_info(GaimConnection *gc) |
2086 | 199 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
200 GList *m = NULL; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
201 struct proto_chat_entry *pce; |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
202 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
203 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 204 pce->label = _("_Channel:"); |
5234 | 205 pce->identifier = "channel"; |
10954 | 206 pce->required = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
207 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
208 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
209 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 210 pce->label = _("_Password:"); |
5234 | 211 pce->identifier = "password"; |
6499 | 212 pce->secret = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
213 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
214 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
215 return m; |
2086 | 216 } |
217 | |
9754 | 218 GHashTable *irc_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
219 { | |
220 GHashTable *defaults; | |
221 | |
222 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
223 | |
224 if (chat_name != NULL) | |
225 g_hash_table_insert(defaults, "channel", g_strdup(chat_name)); | |
226 | |
227 return defaults; | |
228 } | |
229 | |
10401 | 230 static void irc_login(GaimAccount *account, GaimStatus *status) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
231 { |
6333 | 232 GaimConnection *gc; |
233 struct irc_conn *irc; | |
10494 | 234 char **userparts; |
6333 | 235 const char *username = gaim_account_get_username(account); |
236 int err; | |
237 | |
238 gc = gaim_account_get_connection(account); | |
8677 | 239 gc->flags |= GAIM_CONNECTION_NO_NEWLINES; |
6333 | 240 |
6752 | 241 if (strpbrk(username, " \t\v\r\n") != NULL) { |
242 gaim_connection_error(gc, _("IRC nicks may not contain whitespace")); | |
243 return; | |
244 } | |
245 | |
6333 | 246 gc->proto_data = irc = g_new0(struct irc_conn, 1); |
10960 | 247 irc->fd = -1; |
6333 | 248 irc->account = account; |
249 | |
250 userparts = g_strsplit(username, "@", 2); | |
251 gaim_connection_set_display_name(gc, userparts[0]); | |
252 irc->server = g_strdup(userparts[1]); | |
253 g_strfreev(userparts); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
254 |
10159 | 255 irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal, |
6333 | 256 NULL, (GDestroyNotify)irc_buddy_free); |
257 irc->cmds = g_hash_table_new(g_str_hash, g_str_equal); | |
258 irc_cmd_table_build(irc); | |
259 irc->msgs = g_hash_table_new(g_str_hash, g_str_equal); | |
260 irc_msg_table_build(irc); | |
261 | |
10494 | 262 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
6333 | 263 |
10365 | 264 if (gaim_account_get_bool(account, "ssl", FALSE)) { |
265 if (gaim_ssl_is_supported()) { | |
266 irc->gsc = gaim_ssl_connect(account, irc->server, | |
267 gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT), | |
268 irc_login_cb_ssl, irc_ssl_connect_failure, gc); | |
269 } else { | |
270 gaim_connection_error(gc, _("SSL support unavailable")); | |
271 } | |
272 } | |
273 | |
274 if (!irc->gsc) { | |
275 | |
276 err = gaim_proxy_connect(account, irc->server, | |
6333 | 277 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), |
278 irc_login_cb, gc); | |
279 | |
10555 | 280 if (err || !gaim_account_get_connection(account)) { |
10365 | 281 gaim_connection_error(gc, _("Couldn't create socket")); |
282 return; | |
283 } | |
284 } | |
285 } | |
286 | |
287 static gboolean do_login(GaimConnection *gc) { | |
288 char *buf; | |
289 char hostname[256]; | |
290 const char *username, *realname; | |
291 struct irc_conn *irc = gc->proto_data; | |
10740 | 292 const char *pass = gaim_connection_get_password(gc); |
10365 | 293 |
10555 | 294 if (pass && *pass) { |
295 buf = irc_format(irc, "vv", "PASS", pass); | |
10365 | 296 if (irc_send(irc, buf) < 0) { |
297 gaim_connection_error(gc, "Error sending password"); | |
10903 | 298 g_free(buf); |
10365 | 299 return FALSE; |
300 } | |
301 g_free(buf); | |
302 } | |
303 | |
304 gethostname(hostname, sizeof(hostname)); | |
305 hostname[sizeof(hostname) - 1] = '\0'; | |
306 username = gaim_account_get_string(irc->account, "username", ""); | |
307 realname = gaim_account_get_string(irc->account, "realname", ""); | |
308 buf = irc_format(irc, "vvvv:", "USER", strlen(username) ? username : g_get_user_name(), hostname, irc->server, | |
309 strlen(realname) ? realname : IRC_DEFAULT_ALIAS); | |
310 if (irc_send(irc, buf) < 0) { | |
311 gaim_connection_error(gc, "Error registering with server"); | |
10903 | 312 g_free(buf); |
10365 | 313 return FALSE; |
314 } | |
315 g_free(buf); | |
316 buf = irc_format(irc, "vn", "NICK", gaim_connection_get_display_name(gc)); | |
317 if (irc_send(irc, buf) < 0) { | |
318 gaim_connection_error(gc, "Error sending nickname"); | |
10903 | 319 g_free(buf); |
10365 | 320 return FALSE; |
321 } | |
322 g_free(buf); | |
323 | |
324 return TRUE; | |
325 } | |
326 | |
327 static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
328 GaimInputCondition cond) | |
329 { | |
330 GaimConnection *gc = data; | |
331 struct irc_conn *irc = gc->proto_data; | |
332 | |
333 if(!g_list_find(gaim_connections_get_all(), gc)) { | |
334 gaim_ssl_close(gsc); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
335 return; |
6333 | 336 } |
10365 | 337 |
338 irc->gsc = gsc; | |
339 | |
340 if (do_login(gc)) { | |
341 gaim_ssl_input_add(gsc, irc_input_cb_ssl, gc); | |
342 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
343 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
344 |
6333 | 345 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
|
346 { |
6333 | 347 GaimConnection *gc = data; |
348 struct irc_conn *irc = gc->proto_data; | |
349 GList *connections = gaim_connections_get_all(); | |
350 | |
8778 | 351 if (source < 0) { |
352 gaim_connection_error(gc, _("Couldn't connect to host")); | |
6333 | 353 return; |
8778 | 354 } |
6333 | 355 |
356 if (!g_list_find(connections, gc)) { | |
357 close(source); | |
358 return; | |
359 } | |
360 | |
361 irc->fd = source; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
362 |
10365 | 363 if (do_login(gc)) { |
364 gc->inpa = gaim_input_add(irc->fd, GAIM_INPUT_READ, irc_input_cb, gc); | |
365 } | |
366 } | |
367 | |
368 static void | |
369 irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, | |
370 gpointer data) | |
371 { | |
372 GaimConnection *gc = data; | |
373 struct irc_conn *irc = gc->proto_data; | |
374 | |
375 switch(error) { | |
376 case GAIM_SSL_CONNECT_FAILED: | |
377 gaim_connection_error(gc, _("Connection Failed")); | |
378 break; | |
379 case GAIM_SSL_HANDSHAKE_FAILED: | |
380 gaim_connection_error(gc, _("SSL Handshake Failed")); | |
381 break; | |
6333 | 382 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
383 |
10365 | 384 irc->gsc = NULL; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
385 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
386 |
6333 | 387 static void irc_close(GaimConnection *gc) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
388 { |
6333 | 389 struct irc_conn *irc = gc->proto_data; |
390 | |
6752 | 391 if (irc == NULL) |
392 return; | |
393 | |
6333 | 394 irc_cmd_quit(irc, "quit", NULL, NULL); |
395 | |
396 if (gc->inpa) | |
9441 | 397 gaim_input_remove(gc->inpa); |
6333 | 398 |
399 g_free(irc->inbuf); | |
10365 | 400 if (irc->gsc) { |
401 gaim_ssl_close(irc->gsc); | |
402 } else if (irc->fd > 0) { | |
403 close(irc->fd); | |
404 } | |
6333 | 405 if (irc->timer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
406 gaim_timeout_remove(irc->timer); |
6333 | 407 g_hash_table_destroy(irc->cmds); |
408 g_hash_table_destroy(irc->msgs); | |
10504 | 409 g_hash_table_destroy(irc->buddies); |
6333 | 410 if (irc->motd) |
411 g_string_free(irc->motd, TRUE); | |
412 g_free(irc->server); | |
413 g_free(irc); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
414 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
415 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
416 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
|
417 { |
6333 | 418 struct irc_conn *irc = gc->proto_data; |
419 const char *args[2]; | |
420 | |
7711 | 421 if (strchr(status_chars, *who) != NULL) |
6333 | 422 args[0] = who + 1; |
423 else | |
424 args[0] = who; | |
425 args[1] = what; | |
9442 | 426 |
6333 | 427 irc_cmd_privmsg(irc, "msg", NULL, args); |
428 return 1; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
429 } |
2086 | 430 |
6333 | 431 static void irc_get_info(GaimConnection *gc, const char *who) |
2086 | 432 { |
6333 | 433 struct irc_conn *irc = gc->proto_data; |
10618
9eb3b224face
[gaim-migrate @ 12083]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10555
diff
changeset
|
434 const char *args[2]; |
6333 | 435 args[0] = who; |
10624 | 436 args[1] = NULL; |
6333 | 437 irc_cmd_whois(irc, "whois", NULL, args); |
438 } | |
439 | |
9944 | 440 static void irc_set_status(GaimAccount *account, GaimStatus *status) |
6333 | 441 { |
9944 | 442 GaimConnection *gc = gaim_account_get_connection(account); |
10724
811f12c8a5e4
[gaim-migrate @ 12324]
Luke Schierer <lschiere@pidgin.im>
parents:
10646
diff
changeset
|
443 struct irc_conn *irc = NULL; |
6333 | 444 const char *args[1]; |
9944 | 445 const char *status_id = gaim_status_get_id(status); |
2086 | 446 |
10646 | 447 if (gc) |
448 irc = gc->proto_data; | |
449 | |
10504 | 450 if (!gaim_status_is_active(status)) |
451 return; | |
452 | |
453 args[0] = NULL; | |
454 | |
10646 | 455 if (strcmp(status_id, "offline") && !gc) { |
10738 | 456 gaim_account_connect(account); |
11079 | 457 } else if (!strcmp(status_id, "offline") && gc) { |
458 gaim_account_disconnect(account); | |
10646 | 459 } else if (!strcmp(status_id, "away")) { |
9944 | 460 args[0] = gaim_status_get_attr_string(status, "message"); |
10646 | 461 irc_cmd_away(irc, "away", NULL, args); |
462 } | |
4916 | 463 } |
464 | |
9285 | 465 static void irc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
3029 | 466 { |
6333 | 467 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; |
468 struct irc_buddy *ib = g_new0(struct irc_buddy, 1); | |
9285 | 469 ib->name = g_strdup(buddy->name); |
6333 | 470 g_hash_table_insert(irc->buddies, ib->name, ib); |
9238 | 471 |
9553 | 472 /* if the timer isn't set, this is during signon, so we don't want to flood |
473 * ourself off with ISON's, so we don't, but after that we want to know when | |
474 * someone's online asap */ | |
475 if (irc->timer) | |
476 irc_ison_one(irc, ib); | |
3029 | 477 } |
3622 | 478 |
9285 | 479 static void irc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
6333 | 480 { |
481 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; | |
9285 | 482 g_hash_table_remove(irc->buddies, buddy->name); |
3616 | 483 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
484 |
10365 | 485 static void read_input(struct irc_conn *irc, int len) |
6333 | 486 { |
487 char *cur, *end; | |
6369 | 488 |
6333 | 489 irc->inbufused += len; |
490 irc->inbuf[irc->inbufused] = '\0'; | |
3616 | 491 |
8156 | 492 cur = irc->inbuf; |
493 while (cur < irc->inbuf + irc->inbufused && | |
494 ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) { | |
495 int step = (*end == '\r' ? 2 : 1); | |
6333 | 496 *end = '\0'; |
497 irc_parse_msg(irc, cur); | |
8156 | 498 cur = end + step; |
6333 | 499 } |
500 if (cur != irc->inbuf + irc->inbufused) { /* leftover */ | |
501 irc->inbufused -= (cur - irc->inbuf); | |
502 memmove(irc->inbuf, cur, irc->inbufused); | |
503 } else { | |
504 irc->inbufused = 0; | |
505 } | |
3616 | 506 } |
507 | |
10365 | 508 static void irc_input_cb_ssl(gpointer data, GaimSslConnection *gsc, |
509 GaimInputCondition cond) | |
510 { | |
511 | |
512 GaimConnection *gc = data; | |
513 struct irc_conn *irc = gc->proto_data; | |
514 int len; | |
515 | |
516 if(!g_list_find(gaim_connections_get_all(), gc)) { | |
517 gaim_ssl_close(gsc); | |
518 return; | |
519 } | |
520 | |
521 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { | |
522 irc->inbuflen += IRC_INITIAL_BUFSIZE; | |
523 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); | |
524 } | |
525 | |
526 if ((len = gaim_ssl_read(gsc, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) { | |
527 gaim_connection_error(gc, _("Read error")); | |
528 return; | |
529 } else if (len == 0) { | |
530 gaim_connection_error(gc, _("Server has disconnected")); | |
531 return; | |
532 } | |
533 | |
534 read_input(irc, len); | |
535 } | |
536 | |
537 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond) | |
538 { | |
539 GaimConnection *gc = data; | |
540 struct irc_conn *irc = gc->proto_data; | |
541 int len; | |
542 | |
543 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { | |
544 irc->inbuflen += IRC_INITIAL_BUFSIZE; | |
545 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); | |
546 } | |
547 | |
548 if ((len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) { | |
549 gaim_connection_error(gc, _("Read error")); | |
550 return; | |
551 } else if (len == 0) { | |
552 gaim_connection_error(gc, _("Server has disconnected")); | |
553 return; | |
554 } | |
555 | |
556 read_input(irc, len); | |
557 } | |
558 | |
6333 | 559 static void irc_chat_join (GaimConnection *gc, GHashTable *data) |
560 { | |
561 struct irc_conn *irc = gc->proto_data; | |
562 const char *args[2]; | |
3616 | 563 |
6333 | 564 args[0] = g_hash_table_lookup(data, "channel"); |
565 args[1] = g_hash_table_lookup(data, "password"); | |
566 irc_cmd_join(irc, "join", NULL, args); | |
3622 | 567 } |
568 | |
9917 | 569 static char *irc_get_chat_name(GHashTable *data) { |
570 return g_strdup(g_hash_table_lookup(data, "channel")); | |
571 } | |
572 | |
6333 | 573 static void irc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) |
3751 | 574 { |
6333 | 575 struct irc_conn *irc = gc->proto_data; |
576 GaimConversation *convo = gaim_find_chat(gc, id); | |
577 const char *args[2]; | |
3751 | 578 |
6333 | 579 if (!convo) { |
580 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got chat invite request for bogus chat\n"); | |
581 return; | |
582 } | |
583 args[0] = name; | |
584 args[1] = gaim_conversation_get_name(convo); | |
585 irc_cmd_invite(irc, "invite", gaim_conversation_get_name(convo), args); | |
3707 | 586 } |
587 | |
6333 | 588 |
589 static void irc_chat_leave (GaimConnection *gc, int id) | |
3707 | 590 { |
6333 | 591 struct irc_conn *irc = gc->proto_data; |
592 GaimConversation *convo = gaim_find_chat(gc, id); | |
593 const char *args[2]; | |
5298 | 594 |
6333 | 595 if (!convo) |
596 return; | |
3735 | 597 |
6333 | 598 args[0] = gaim_conversation_get_name(convo); |
599 args[1] = NULL; | |
600 irc_cmd_part(irc, "part", gaim_conversation_get_name(convo), args); | |
601 serv_got_chat_left(gc, id); | |
3735 | 602 } |
603 | |
6333 | 604 static int irc_chat_send(GaimConnection *gc, int id, const char *what) |
3735 | 605 { |
6333 | 606 struct irc_conn *irc = gc->proto_data; |
607 GaimConversation *convo = gaim_find_chat(gc, id); | |
608 const char *args[2]; | |
8163 | 609 char *tmp; |
6333 | 610 |
611 if (!convo) { | |
612 gaim_debug(GAIM_DEBUG_ERROR, "irc", "chat send on nonexistent chat\n"); | |
613 return -EINVAL; | |
614 } | |
9130 | 615 #if 0 |
6333 | 616 if (*what == '/') { |
617 return irc_parse_cmd(irc, convo->name, what + 1); | |
618 } | |
9130 | 619 #endif |
6333 | 620 args[0] = convo->name; |
621 args[1] = what; | |
622 | |
623 irc_cmd_privmsg(irc, "msg", NULL, args); | |
8163 | 624 |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10724
diff
changeset
|
625 tmp = g_markup_escape_text(what, -1); |
8163 | 626 serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, tmp, time(NULL)); |
627 g_free(tmp); | |
6333 | 628 return 0; |
3707 | 629 } |
630 | |
11083 | 631 static void irc_ping_server(GaimConnection *gc) |
632 { | |
633 struct irc_conn *irc = gc->proto_data; | |
634 gchar *buf; | |
635 | |
636 buf = irc_format(irc, "vv", "PING", irc->server); | |
637 irc_send(irc, buf); | |
638 g_free(buf); | |
639 } | |
640 | |
6333 | 641 static guint irc_nick_hash(const char *nick) |
642 { | |
643 char *lc; | |
644 guint bucket; | |
6270
1bf6fd117797
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
645 |
6333 | 646 lc = g_utf8_strdown(nick, -1); |
647 bucket = g_str_hash(lc); | |
648 g_free(lc); | |
6270
1bf6fd117797
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
649 |
6333 | 650 return bucket; |
3029 | 651 } |
652 | |
6333 | 653 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
|
654 { |
6333 | 655 return (gaim_utf8_strcasecmp(nick1, nick2) == 0); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
656 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
657 |
6333 | 658 static void irc_buddy_free(struct irc_buddy *ib) |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
659 { |
6333 | 660 g_free(ib->name); |
661 g_free(ib); | |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
662 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
663 |
9154 | 664 static void irc_chat_set_topic(GaimConnection *gc, int id, const char *topic) |
665 { | |
666 char *buf; | |
667 const char *name = NULL; | |
668 struct irc_conn *irc; | |
669 | |
670 irc = gc->proto_data; | |
671 name = gaim_conversation_get_name(gaim_find_chat(gc, id)); | |
672 | |
673 if (name == NULL) | |
674 return; | |
675 | |
676 buf = irc_format(irc, "vt:", "TOPIC", name, topic); | |
677 irc_send(irc, buf); | |
678 g_free(buf); | |
679 } | |
680 | |
8114 | 681 static GaimRoomlist *irc_roomlist_get_list(GaimConnection *gc) |
682 { | |
683 struct irc_conn *irc; | |
684 GList *fields = NULL; | |
685 GaimRoomlistField *f; | |
8352 | 686 char *buf; |
8114 | 687 |
688 irc = gc->proto_data; | |
689 | |
690 if (irc->roomlist) | |
691 gaim_roomlist_unref(irc->roomlist); | |
692 | |
693 irc->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc)); | |
694 | |
695 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE); | |
696 fields = g_list_append(fields, f); | |
697 | |
698 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE); | |
699 fields = g_list_append(fields, f); | |
700 | |
701 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE); | |
702 fields = g_list_append(fields, f); | |
703 | |
704 gaim_roomlist_set_fields(irc->roomlist, fields); | |
705 | |
8352 | 706 buf = irc_format(irc, "v", "LIST"); |
707 irc_send(irc, buf); | |
708 g_free(buf); | |
8114 | 709 |
710 return irc->roomlist; | |
711 } | |
712 | |
713 static void irc_roomlist_cancel(GaimRoomlist *list) | |
714 { | |
715 GaimConnection *gc = gaim_account_get_connection(list->account); | |
716 struct irc_conn *irc; | |
717 | |
718 if (gc == NULL) | |
719 return; | |
720 | |
721 irc = gc->proto_data; | |
722 | |
723 gaim_roomlist_set_in_progress(list, FALSE); | |
724 | |
725 if (irc->roomlist == list) { | |
726 irc->roomlist = NULL; | |
727 gaim_roomlist_unref(list); | |
728 } | |
729 } | |
730 | |
11073 | 731 static GaimPluginPrefFrame * |
732 irc_pref_frame(GaimPlugin *plugin) { | |
733 GaimPluginPrefFrame *frame; | |
734 GaimPluginPref *ppref; | |
735 | |
736 frame = gaim_plugin_pref_frame_new(); | |
737 | |
738 ppref = gaim_plugin_pref_new_with_label(_("IRC")); | |
739 gaim_plugin_pref_frame_add(frame, ppref); | |
740 | |
741 ppref = gaim_plugin_pref_new_with_name_and_label("/plugins/prpl/irc/quitmsg", | |
742 _("Quit message")); | |
743 gaim_plugin_pref_frame_add(frame, ppref); | |
744 | |
745 return frame; | |
746 } | |
747 | |
748 static GaimPluginUiInfo prefs_info = { | |
749 irc_pref_frame | |
750 }; | |
751 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
752 static GaimPluginProtocolInfo prpl_info = |
2086 | 753 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
754 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL, |
9475 | 755 NULL, /* user_splits */ |
756 NULL, /* protocol_options */ | |
9951 | 757 NO_BUDDY_ICONS, /* icon_spec */ |
758 irc_blist_icon, /* list_icon */ | |
759 irc_blist_emblems, /* list_emblems */ | |
9475 | 760 NULL, /* status_text */ |
761 NULL, /* tooltip_text */ | |
9951 | 762 irc_status_types, /* away_states */ |
9475 | 763 NULL, /* blist_node_menu */ |
9951 | 764 irc_chat_join_info, /* chat_info */ |
9754 | 765 irc_chat_info_defaults, /* chat_info_defaults */ |
9951 | 766 irc_login, /* login */ |
767 irc_close, /* close */ | |
768 irc_im_send, /* send_im */ | |
9475 | 769 NULL, /* set_info */ |
770 NULL, /* send_typing */ | |
9951 | 771 irc_get_info, /* get_info */ |
772 irc_set_status, /* set_status */ | |
9475 | 773 NULL, /* set_idle */ |
774 NULL, /* change_passwd */ | |
9951 | 775 irc_add_buddy, /* add_buddy */ |
9475 | 776 NULL, /* add_buddies */ |
9951 | 777 irc_remove_buddy, /* remove_buddy */ |
9475 | 778 NULL, /* remove_buddies */ |
9741 | 779 NULL, /* add_permit */ |
780 NULL, /* add_deny */ | |
781 NULL, /* rem_permit */ | |
782 NULL, /* rem_deny */ | |
783 NULL, /* set_permit_deny */ | |
9475 | 784 NULL, /* warn */ |
9951 | 785 irc_chat_join, /* join_chat */ |
9475 | 786 NULL, /* reject_chat */ |
9951 | 787 irc_get_chat_name, /* get_chat_name */ |
788 irc_chat_invite, /* chat_invite */ | |
789 irc_chat_leave, /* chat_leave */ | |
9475 | 790 NULL, /* chat_whisper */ |
9951 | 791 irc_chat_send, /* chat_send */ |
11083 | 792 irc_ping_server, /* keepalive */ |
9475 | 793 NULL, /* register_user */ |
794 NULL, /* get_cb_info */ | |
795 NULL, /* get_cb_away */ | |
796 NULL, /* alias_buddy */ | |
797 NULL, /* group_buddy */ | |
798 NULL, /* rename_group */ | |
799 NULL, /* buddy_free */ | |
800 NULL, /* convo_closed */ | |
11153 | 801 gaim_normalize_nocase, /* normalize */ |
9475 | 802 NULL, /* set_buddy_icon */ |
803 NULL, /* remove_group */ | |
804 NULL, /* get_cb_real_name */ | |
9951 | 805 irc_chat_set_topic, /* set_chat_topic */ |
9475 | 806 NULL, /* find_blist_chat */ |
807 irc_roomlist_get_list, /* roomlist_get_list */ | |
808 irc_roomlist_cancel, /* roomlist_cancel */ | |
809 NULL, /* roomlist_expand_category */ | |
810 NULL, /* can_receive_file */ | |
811 irc_dccsend_send_file /* send_file */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
812 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
813 |
8114 | 814 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
815 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
816 { |
9943 | 817 GAIM_PLUGIN_MAGIC, |
818 GAIM_MAJOR_VERSION, | |
819 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
820 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
821 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
822 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
823 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
824 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
825 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
826 "prpl-irc", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
827 "IRC", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
828 VERSION, /**< version */ |
6333 | 829 N_("IRC Protocol Plugin"), /** summary */ |
830 N_("The IRC Protocol Plugin that Sucks Less"), /** description */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
831 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6369
diff
changeset
|
832 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
833 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
834 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
835 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
836 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
837 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
838 NULL, /**< ui_info */ |
8993 | 839 &prpl_info, /**< extra_info */ |
11073 | 840 &prefs_info, /**< prefs_info */ |
9015 | 841 irc_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
842 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
843 |
6333 | 844 static void _init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
845 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
846 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
847 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
848 |
11033
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10960
diff
changeset
|
849 gaim_debug_register_category("irc"); |
50224ac8184d
[gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10960
diff
changeset
|
850 |
6333 | 851 split = gaim_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@'); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
852 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
|
853 |
6459
b52870734c21
[gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
854 option = gaim_account_option_int_new(_("Port"), "port", IRC_DEFAULT_PORT); |
6333 | 855 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
|
856 |
10258 | 857 option = gaim_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET); |
6333 | 858 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
|
859 |
7323 | 860 option = gaim_account_option_string_new(_("Username"), "username", ""); |
861 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
862 | |
10002 | 863 option = gaim_account_option_string_new(_("Real name"), "realname", ""); |
864 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
865 | |
10365 | 866 option = gaim_account_option_bool_new(_("Use SSL"), "ssl", FALSE); |
867 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
868 | |
6333 | 869 _irc_plugin = plugin; |
9130 | 870 |
11073 | 871 gaim_prefs_add_none("/plugins/prpl/irc"); |
872 gaim_prefs_add_string("/plugins/prpl/irc/quitmsg", IRC_DEFAULT_QUIT); | |
873 | |
9130 | 874 irc_register_commands(); |
2086 | 875 } |
876 | |
6333 | 877 GAIM_INIT_PLUGIN(irc, _init_plugin, info); |