Mercurial > pidgin
annotate src/protocols/irc/irc.c @ 12024:e67993da8a22
[gaim-migrate @ 14317]
I strongly suspect CruiseControl is going to yell at me for this.
A voice chat API, GUI + mediastreamer. This is what I'm using for Google Talk.
This doesn't actually do anything at all. There's no code in the Jabber plugin yet
to use this API (although it Works For Me). All it will do is compile and link.
If you're lucky.
To build this, you should install oRTP from Linphone, Speex and iLBC (also
from linphone, I believe). To not build this, ./configure --disable-vv.
Most of the configure.ac and Makefile.am hackery was lifted right out of
Linphone with a few modifications. It seems to work if you have everything
installed or if you --disable-vv. I haven't really tested not having
everything installed and not --disabling-vv.
It's kinda funky to include all of mediastreamer in the source tree like this,
but linphone doesn't build it as a separate library. I'll probably wind up
writing them a patch to build it as a .so so we can link it dynamically instead.
This code certainly isn't finished. It'll adapt as I progress on the Google code,
but it's certainly of more use here in CVS than in my personal tree.
committer: Tailor Script <tailor@pidgin.im>
| author | Sean Egan <seanegan@gmail.com> |
|---|---|
| date | Wed, 09 Nov 2005 08:07:20 +0000 |
| parents | 8bcccf2988fa |
| children | bef758a67e48 |
| 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); */ |
| 11837 | 47 static void irc_login(GaimAccount *account); |
| 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_AVAILABLE, "available", | |
| 172 _("Available"), TRUE); | |
| 173 types = g_list_append(types, type); | |
| 174 | |
| 175 type = gaim_status_type_new_with_attrs( | |
| 176 GAIM_STATUS_AWAY, "away", _("Away"), TRUE, TRUE, FALSE, | |
| 10009 | 177 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), NULL); |
| 9944 | 178 types = g_list_append(types, type); |
| 179 | |
| 180 return types; | |
| 3452 | 181 } |
| 182 | |
| 9015 | 183 static GList *irc_actions(GaimPlugin *plugin, gpointer context) |
| 7148 | 184 { |
| 185 GList *list = NULL; | |
| 9015 | 186 GaimPluginAction *act = NULL; |
| 7148 | 187 |
| 9015 | 188 act = gaim_plugin_action_new(_("View MOTD"), irc_view_motd); |
| 189 list = g_list_append(list, act); | |
| 7148 | 190 |
| 191 return list; | |
| 192 } | |
| 193 | |
| 6333 | 194 static GList *irc_chat_join_info(GaimConnection *gc) |
| 2086 | 195 { |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
196 GList *m = NULL; |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
197 struct proto_chat_entry *pce; |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
198 |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
199 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 200 pce->label = _("_Channel:"); |
| 5234 | 201 pce->identifier = "channel"; |
| 10954 | 202 pce->required = TRUE; |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
203 m = g_list_append(m, pce); |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
204 |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
205 pce = g_new0(struct proto_chat_entry, 1); |
| 7841 | 206 pce->label = _("_Password:"); |
| 5234 | 207 pce->identifier = "password"; |
| 6499 | 208 pce->secret = TRUE; |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
209 m = g_list_append(m, pce); |
|
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
210 |
|
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
211 return m; |
| 2086 | 212 } |
| 213 | |
| 9754 | 214 GHashTable *irc_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
| 215 { | |
| 216 GHashTable *defaults; | |
| 217 | |
| 218 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
| 219 | |
| 220 if (chat_name != NULL) | |
| 221 g_hash_table_insert(defaults, "channel", g_strdup(chat_name)); | |
| 222 | |
| 223 return defaults; | |
| 224 } | |
| 225 | |
| 11837 | 226 static void irc_login(GaimAccount *account) |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
227 { |
| 6333 | 228 GaimConnection *gc; |
| 229 struct irc_conn *irc; | |
| 10494 | 230 char **userparts; |
| 6333 | 231 const char *username = gaim_account_get_username(account); |
| 232 int err; | |
| 233 | |
| 234 gc = gaim_account_get_connection(account); | |
| 8677 | 235 gc->flags |= GAIM_CONNECTION_NO_NEWLINES; |
| 6333 | 236 |
| 6752 | 237 if (strpbrk(username, " \t\v\r\n") != NULL) { |
| 238 gaim_connection_error(gc, _("IRC nicks may not contain whitespace")); | |
| 239 return; | |
| 240 } | |
| 241 | |
| 6333 | 242 gc->proto_data = irc = g_new0(struct irc_conn, 1); |
| 10960 | 243 irc->fd = -1; |
| 6333 | 244 irc->account = account; |
| 245 | |
| 246 userparts = g_strsplit(username, "@", 2); | |
| 247 gaim_connection_set_display_name(gc, userparts[0]); | |
| 248 irc->server = g_strdup(userparts[1]); | |
| 249 g_strfreev(userparts); | |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
250 |
| 10159 | 251 irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal, |
| 6333 | 252 NULL, (GDestroyNotify)irc_buddy_free); |
| 253 irc->cmds = g_hash_table_new(g_str_hash, g_str_equal); | |
| 254 irc_cmd_table_build(irc); | |
| 255 irc->msgs = g_hash_table_new(g_str_hash, g_str_equal); | |
| 256 irc_msg_table_build(irc); | |
| 257 | |
| 10494 | 258 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
| 6333 | 259 |
| 10365 | 260 if (gaim_account_get_bool(account, "ssl", FALSE)) { |
| 261 if (gaim_ssl_is_supported()) { | |
| 262 irc->gsc = gaim_ssl_connect(account, irc->server, | |
| 263 gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT), | |
| 264 irc_login_cb_ssl, irc_ssl_connect_failure, gc); | |
| 265 } else { | |
| 266 gaim_connection_error(gc, _("SSL support unavailable")); | |
| 267 } | |
| 268 } | |
| 269 | |
| 270 if (!irc->gsc) { | |
| 271 | |
| 272 err = gaim_proxy_connect(account, irc->server, | |
| 6333 | 273 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), |
| 274 irc_login_cb, gc); | |
| 275 | |
| 10555 | 276 if (err || !gaim_account_get_connection(account)) { |
| 10365 | 277 gaim_connection_error(gc, _("Couldn't create socket")); |
| 278 return; | |
| 279 } | |
| 280 } | |
| 281 } | |
| 282 | |
| 283 static gboolean do_login(GaimConnection *gc) { | |
| 284 char *buf; | |
| 285 char hostname[256]; | |
| 286 const char *username, *realname; | |
| 287 struct irc_conn *irc = gc->proto_data; | |
| 10740 | 288 const char *pass = gaim_connection_get_password(gc); |
| 10365 | 289 |
| 10555 | 290 if (pass && *pass) { |
| 291 buf = irc_format(irc, "vv", "PASS", pass); | |
| 10365 | 292 if (irc_send(irc, buf) < 0) { |
| 293 gaim_connection_error(gc, "Error sending password"); | |
| 10903 | 294 g_free(buf); |
| 10365 | 295 return FALSE; |
| 296 } | |
| 297 g_free(buf); | |
| 298 } | |
| 299 | |
| 300 gethostname(hostname, sizeof(hostname)); | |
| 301 hostname[sizeof(hostname) - 1] = '\0'; | |
| 302 username = gaim_account_get_string(irc->account, "username", ""); | |
| 303 realname = gaim_account_get_string(irc->account, "realname", ""); | |
| 304 buf = irc_format(irc, "vvvv:", "USER", strlen(username) ? username : g_get_user_name(), hostname, irc->server, | |
| 305 strlen(realname) ? realname : IRC_DEFAULT_ALIAS); | |
| 306 if (irc_send(irc, buf) < 0) { | |
| 307 gaim_connection_error(gc, "Error registering with server"); | |
| 10903 | 308 g_free(buf); |
| 10365 | 309 return FALSE; |
| 310 } | |
| 311 g_free(buf); | |
| 312 buf = irc_format(irc, "vn", "NICK", gaim_connection_get_display_name(gc)); | |
| 313 if (irc_send(irc, buf) < 0) { | |
| 314 gaim_connection_error(gc, "Error sending nickname"); | |
| 10903 | 315 g_free(buf); |
| 10365 | 316 return FALSE; |
| 317 } | |
| 318 g_free(buf); | |
| 319 | |
| 320 return TRUE; | |
| 321 } | |
| 322 | |
| 323 static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
| 324 GaimInputCondition cond) | |
| 325 { | |
| 326 GaimConnection *gc = data; | |
| 327 struct irc_conn *irc = gc->proto_data; | |
| 328 | |
| 329 if(!g_list_find(gaim_connections_get_all(), gc)) { | |
| 330 gaim_ssl_close(gsc); | |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
331 return; |
| 6333 | 332 } |
| 10365 | 333 |
| 334 irc->gsc = gsc; | |
| 335 | |
| 336 if (do_login(gc)) { | |
| 337 gaim_ssl_input_add(gsc, irc_input_cb_ssl, gc); | |
| 338 } | |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
339 } |
|
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
340 |
| 6333 | 341 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
|
342 { |
| 6333 | 343 GaimConnection *gc = data; |
| 344 struct irc_conn *irc = gc->proto_data; | |
| 345 GList *connections = gaim_connections_get_all(); | |
| 346 | |
| 8778 | 347 if (source < 0) { |
| 348 gaim_connection_error(gc, _("Couldn't connect to host")); | |
| 6333 | 349 return; |
| 8778 | 350 } |
| 6333 | 351 |
| 352 if (!g_list_find(connections, gc)) { | |
| 353 close(source); | |
| 354 return; | |
| 355 } | |
| 356 | |
| 357 irc->fd = source; | |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
358 |
| 10365 | 359 if (do_login(gc)) { |
| 360 gc->inpa = gaim_input_add(irc->fd, GAIM_INPUT_READ, irc_input_cb, gc); | |
| 361 } | |
| 362 } | |
| 363 | |
| 364 static void | |
| 365 irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, | |
| 366 gpointer data) | |
| 367 { | |
| 368 GaimConnection *gc = data; | |
| 369 struct irc_conn *irc = gc->proto_data; | |
| 370 | |
| 371 switch(error) { | |
| 372 case GAIM_SSL_CONNECT_FAILED: | |
| 373 gaim_connection_error(gc, _("Connection Failed")); | |
| 374 break; | |
| 375 case GAIM_SSL_HANDSHAKE_FAILED: | |
| 376 gaim_connection_error(gc, _("SSL Handshake Failed")); | |
| 377 break; | |
| 6333 | 378 } |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
379 |
| 10365 | 380 irc->gsc = NULL; |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
381 } |
|
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
382 |
| 6333 | 383 static void irc_close(GaimConnection *gc) |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
384 { |
| 6333 | 385 struct irc_conn *irc = gc->proto_data; |
| 386 | |
| 6752 | 387 if (irc == NULL) |
| 388 return; | |
| 389 | |
| 6333 | 390 irc_cmd_quit(irc, "quit", NULL, NULL); |
| 391 | |
| 392 if (gc->inpa) | |
| 9441 | 393 gaim_input_remove(gc->inpa); |
| 6333 | 394 |
| 395 g_free(irc->inbuf); | |
| 10365 | 396 if (irc->gsc) { |
| 397 gaim_ssl_close(irc->gsc); | |
| 398 } else if (irc->fd > 0) { | |
| 399 close(irc->fd); | |
| 400 } | |
| 6333 | 401 if (irc->timer) |
|
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
402 gaim_timeout_remove(irc->timer); |
| 6333 | 403 g_hash_table_destroy(irc->cmds); |
| 404 g_hash_table_destroy(irc->msgs); | |
| 10504 | 405 g_hash_table_destroy(irc->buddies); |
| 6333 | 406 if (irc->motd) |
| 407 g_string_free(irc->motd, TRUE); | |
| 408 g_free(irc->server); | |
| 409 g_free(irc); | |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
410 } |
|
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
411 |
|
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
412 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
|
413 { |
| 6333 | 414 struct irc_conn *irc = gc->proto_data; |
| 415 const char *args[2]; | |
| 416 | |
| 7711 | 417 if (strchr(status_chars, *who) != NULL) |
| 6333 | 418 args[0] = who + 1; |
| 419 else | |
| 420 args[0] = who; | |
| 421 args[1] = what; | |
| 9442 | 422 |
| 6333 | 423 irc_cmd_privmsg(irc, "msg", NULL, args); |
| 424 return 1; | |
|
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
425 } |
| 2086 | 426 |
| 6333 | 427 static void irc_get_info(GaimConnection *gc, const char *who) |
| 2086 | 428 { |
| 6333 | 429 struct irc_conn *irc = gc->proto_data; |
|
10618
9eb3b224face
[gaim-migrate @ 12083]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10555
diff
changeset
|
430 const char *args[2]; |
| 6333 | 431 args[0] = who; |
| 10624 | 432 args[1] = NULL; |
| 6333 | 433 irc_cmd_whois(irc, "whois", NULL, args); |
| 434 } | |
| 435 | |
| 9944 | 436 static void irc_set_status(GaimAccount *account, GaimStatus *status) |
| 6333 | 437 { |
| 9944 | 438 GaimConnection *gc = gaim_account_get_connection(account); |
|
10724
811f12c8a5e4
[gaim-migrate @ 12324]
Luke Schierer <lschiere@pidgin.im>
parents:
10646
diff
changeset
|
439 struct irc_conn *irc = NULL; |
| 6333 | 440 const char *args[1]; |
| 9944 | 441 const char *status_id = gaim_status_get_id(status); |
| 2086 | 442 |
| 10646 | 443 if (gc) |
| 444 irc = gc->proto_data; | |
| 445 | |
| 10504 | 446 if (!gaim_status_is_active(status)) |
| 447 return; | |
| 448 | |
| 449 args[0] = NULL; | |
| 450 | |
| 11718 | 451 if (!strcmp(status_id, "away")) { |
| 9944 | 452 args[0] = gaim_status_get_attr_string(status, "message"); |
| 12001 | 453 if ((args[0] == NULL) || (*args[0] == '\0')) |
| 454 args[0] = _("Away"); | |
| 10646 | 455 irc_cmd_away(irc, "away", NULL, args); |
| 456 } | |
| 4916 | 457 } |
| 458 | |
| 9285 | 459 static void irc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 3029 | 460 { |
| 6333 | 461 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; |
| 462 struct irc_buddy *ib = g_new0(struct irc_buddy, 1); | |
| 9285 | 463 ib->name = g_strdup(buddy->name); |
| 6333 | 464 g_hash_table_insert(irc->buddies, ib->name, ib); |
| 9238 | 465 |
| 9553 | 466 /* if the timer isn't set, this is during signon, so we don't want to flood |
| 467 * ourself off with ISON's, so we don't, but after that we want to know when | |
| 468 * someone's online asap */ | |
| 469 if (irc->timer) | |
| 470 irc_ison_one(irc, ib); | |
| 3029 | 471 } |
| 3622 | 472 |
| 9285 | 473 static void irc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
| 6333 | 474 { |
| 475 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; | |
| 9285 | 476 g_hash_table_remove(irc->buddies, buddy->name); |
| 3616 | 477 } |
|
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
478 |
| 10365 | 479 static void read_input(struct irc_conn *irc, int len) |
| 6333 | 480 { |
| 481 char *cur, *end; | |
| 6369 | 482 |
| 6333 | 483 irc->inbufused += len; |
| 484 irc->inbuf[irc->inbufused] = '\0'; | |
| 3616 | 485 |
| 8156 | 486 cur = irc->inbuf; |
| 487 while (cur < irc->inbuf + irc->inbufused && | |
| 488 ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) { | |
| 489 int step = (*end == '\r' ? 2 : 1); | |
| 6333 | 490 *end = '\0'; |
| 491 irc_parse_msg(irc, cur); | |
| 8156 | 492 cur = end + step; |
| 6333 | 493 } |
| 494 if (cur != irc->inbuf + irc->inbufused) { /* leftover */ | |
| 495 irc->inbufused -= (cur - irc->inbuf); | |
| 496 memmove(irc->inbuf, cur, irc->inbufused); | |
| 497 } else { | |
| 498 irc->inbufused = 0; | |
| 499 } | |
| 3616 | 500 } |
| 501 | |
| 10365 | 502 static void irc_input_cb_ssl(gpointer data, GaimSslConnection *gsc, |
| 503 GaimInputCondition cond) | |
| 504 { | |
| 505 | |
| 506 GaimConnection *gc = data; | |
| 507 struct irc_conn *irc = gc->proto_data; | |
| 508 int len; | |
| 509 | |
| 510 if(!g_list_find(gaim_connections_get_all(), gc)) { | |
| 511 gaim_ssl_close(gsc); | |
| 512 return; | |
| 513 } | |
| 514 | |
| 515 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { | |
| 516 irc->inbuflen += IRC_INITIAL_BUFSIZE; | |
| 517 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); | |
| 518 } | |
| 519 | |
| 520 if ((len = gaim_ssl_read(gsc, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) { | |
| 521 gaim_connection_error(gc, _("Read error")); | |
| 522 return; | |
| 523 } else if (len == 0) { | |
| 524 gaim_connection_error(gc, _("Server has disconnected")); | |
| 525 return; | |
| 526 } | |
| 527 | |
| 528 read_input(irc, len); | |
| 529 } | |
| 530 | |
| 531 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond) | |
| 532 { | |
| 533 GaimConnection *gc = data; | |
| 534 struct irc_conn *irc = gc->proto_data; | |
| 535 int len; | |
| 536 | |
| 537 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { | |
| 538 irc->inbuflen += IRC_INITIAL_BUFSIZE; | |
| 539 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); | |
| 540 } | |
| 541 | |
| 542 if ((len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) { | |
| 543 gaim_connection_error(gc, _("Read error")); | |
| 544 return; | |
| 545 } else if (len == 0) { | |
| 546 gaim_connection_error(gc, _("Server has disconnected")); | |
| 547 return; | |
| 548 } | |
| 549 | |
| 550 read_input(irc, len); | |
| 551 } | |
| 552 | |
| 6333 | 553 static void irc_chat_join (GaimConnection *gc, GHashTable *data) |
| 554 { | |
| 555 struct irc_conn *irc = gc->proto_data; | |
| 556 const char *args[2]; | |
| 3616 | 557 |
| 6333 | 558 args[0] = g_hash_table_lookup(data, "channel"); |
| 559 args[1] = g_hash_table_lookup(data, "password"); | |
| 560 irc_cmd_join(irc, "join", NULL, args); | |
| 3622 | 561 } |
| 562 | |
| 9917 | 563 static char *irc_get_chat_name(GHashTable *data) { |
| 564 return g_strdup(g_hash_table_lookup(data, "channel")); | |
| 565 } | |
| 566 | |
| 6333 | 567 static void irc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) |
| 3751 | 568 { |
| 6333 | 569 struct irc_conn *irc = gc->proto_data; |
| 570 GaimConversation *convo = gaim_find_chat(gc, id); | |
| 571 const char *args[2]; | |
| 3751 | 572 |
| 6333 | 573 if (!convo) { |
| 574 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got chat invite request for bogus chat\n"); | |
| 575 return; | |
| 576 } | |
| 577 args[0] = name; | |
| 578 args[1] = gaim_conversation_get_name(convo); | |
| 579 irc_cmd_invite(irc, "invite", gaim_conversation_get_name(convo), args); | |
| 3707 | 580 } |
| 581 | |
| 6333 | 582 |
| 583 static void irc_chat_leave (GaimConnection *gc, int id) | |
| 3707 | 584 { |
| 6333 | 585 struct irc_conn *irc = gc->proto_data; |
| 586 GaimConversation *convo = gaim_find_chat(gc, id); | |
| 587 const char *args[2]; | |
| 5298 | 588 |
| 6333 | 589 if (!convo) |
| 590 return; | |
| 3735 | 591 |
| 6333 | 592 args[0] = gaim_conversation_get_name(convo); |
| 593 args[1] = NULL; | |
| 594 irc_cmd_part(irc, "part", gaim_conversation_get_name(convo), args); | |
| 595 serv_got_chat_left(gc, id); | |
| 3735 | 596 } |
| 597 | |
| 6333 | 598 static int irc_chat_send(GaimConnection *gc, int id, const char *what) |
| 3735 | 599 { |
| 6333 | 600 struct irc_conn *irc = gc->proto_data; |
| 601 GaimConversation *convo = gaim_find_chat(gc, id); | |
| 602 const char *args[2]; | |
| 8163 | 603 char *tmp; |
| 6333 | 604 |
| 605 if (!convo) { | |
| 606 gaim_debug(GAIM_DEBUG_ERROR, "irc", "chat send on nonexistent chat\n"); | |
| 607 return -EINVAL; | |
| 608 } | |
| 9130 | 609 #if 0 |
| 6333 | 610 if (*what == '/') { |
| 611 return irc_parse_cmd(irc, convo->name, what + 1); | |
| 612 } | |
| 9130 | 613 #endif |
| 6333 | 614 args[0] = convo->name; |
| 615 args[1] = what; | |
| 616 | |
| 617 irc_cmd_privmsg(irc, "msg", NULL, args); | |
| 8163 | 618 |
|
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10724
diff
changeset
|
619 tmp = g_markup_escape_text(what, -1); |
| 8163 | 620 serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, tmp, time(NULL)); |
| 621 g_free(tmp); | |
| 6333 | 622 return 0; |
| 3707 | 623 } |
| 624 | |
| 11083 | 625 static void irc_ping_server(GaimConnection *gc) |
| 626 { | |
| 627 struct irc_conn *irc = gc->proto_data; | |
| 628 gchar *buf; | |
| 629 | |
| 630 buf = irc_format(irc, "vv", "PING", irc->server); | |
| 631 irc_send(irc, buf); | |
| 632 g_free(buf); | |
| 633 } | |
| 634 | |
| 6333 | 635 static guint irc_nick_hash(const char *nick) |
| 636 { | |
| 637 char *lc; | |
| 638 guint bucket; | |
|
6270
1bf6fd117797
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
639 |
| 6333 | 640 lc = g_utf8_strdown(nick, -1); |
| 641 bucket = g_str_hash(lc); | |
| 642 g_free(lc); | |
|
6270
1bf6fd117797
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
643 |
| 6333 | 644 return bucket; |
| 3029 | 645 } |
| 646 | |
| 6333 | 647 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
|
648 { |
| 6333 | 649 return (gaim_utf8_strcasecmp(nick1, nick2) == 0); |
|
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
650 } |
|
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
651 |
| 6333 | 652 static void irc_buddy_free(struct irc_buddy *ib) |
|
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
653 { |
| 6333 | 654 g_free(ib->name); |
| 655 g_free(ib); | |
|
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 |
| 9154 | 658 static void irc_chat_set_topic(GaimConnection *gc, int id, const char *topic) |
| 659 { | |
| 660 char *buf; | |
| 661 const char *name = NULL; | |
| 662 struct irc_conn *irc; | |
| 663 | |
| 664 irc = gc->proto_data; | |
| 665 name = gaim_conversation_get_name(gaim_find_chat(gc, id)); | |
| 666 | |
| 667 if (name == NULL) | |
| 668 return; | |
| 669 | |
| 670 buf = irc_format(irc, "vt:", "TOPIC", name, topic); | |
| 671 irc_send(irc, buf); | |
| 672 g_free(buf); | |
| 673 } | |
| 674 | |
| 8114 | 675 static GaimRoomlist *irc_roomlist_get_list(GaimConnection *gc) |
| 676 { | |
| 677 struct irc_conn *irc; | |
| 678 GList *fields = NULL; | |
| 679 GaimRoomlistField *f; | |
| 8352 | 680 char *buf; |
| 8114 | 681 |
| 682 irc = gc->proto_data; | |
| 683 | |
| 684 if (irc->roomlist) | |
| 685 gaim_roomlist_unref(irc->roomlist); | |
| 686 | |
| 687 irc->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc)); | |
| 688 | |
| 689 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE); | |
| 690 fields = g_list_append(fields, f); | |
| 691 | |
| 692 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE); | |
| 693 fields = g_list_append(fields, f); | |
| 694 | |
| 695 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE); | |
| 696 fields = g_list_append(fields, f); | |
| 697 | |
| 698 gaim_roomlist_set_fields(irc->roomlist, fields); | |
| 699 | |
| 8352 | 700 buf = irc_format(irc, "v", "LIST"); |
| 701 irc_send(irc, buf); | |
| 702 g_free(buf); | |
| 8114 | 703 |
| 704 return irc->roomlist; | |
| 705 } | |
| 706 | |
| 707 static void irc_roomlist_cancel(GaimRoomlist *list) | |
| 708 { | |
| 709 GaimConnection *gc = gaim_account_get_connection(list->account); | |
| 710 struct irc_conn *irc; | |
| 711 | |
| 712 if (gc == NULL) | |
| 713 return; | |
| 714 | |
| 715 irc = gc->proto_data; | |
| 716 | |
| 717 gaim_roomlist_set_in_progress(list, FALSE); | |
| 718 | |
| 719 if (irc->roomlist == list) { | |
| 720 irc->roomlist = NULL; | |
| 721 gaim_roomlist_unref(list); | |
| 722 } | |
| 723 } | |
| 724 | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
725 static GaimPluginProtocolInfo prpl_info = |
| 2086 | 726 { |
|
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
727 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL, |
| 9475 | 728 NULL, /* user_splits */ |
| 729 NULL, /* protocol_options */ | |
| 9951 | 730 NO_BUDDY_ICONS, /* icon_spec */ |
| 731 irc_blist_icon, /* list_icon */ | |
| 732 irc_blist_emblems, /* list_emblems */ | |
| 9475 | 733 NULL, /* status_text */ |
| 734 NULL, /* tooltip_text */ | |
| 9951 | 735 irc_status_types, /* away_states */ |
| 9475 | 736 NULL, /* blist_node_menu */ |
| 9951 | 737 irc_chat_join_info, /* chat_info */ |
| 9754 | 738 irc_chat_info_defaults, /* chat_info_defaults */ |
| 9951 | 739 irc_login, /* login */ |
| 740 irc_close, /* close */ | |
| 741 irc_im_send, /* send_im */ | |
| 9475 | 742 NULL, /* set_info */ |
| 743 NULL, /* send_typing */ | |
| 9951 | 744 irc_get_info, /* get_info */ |
| 745 irc_set_status, /* set_status */ | |
| 9475 | 746 NULL, /* set_idle */ |
| 747 NULL, /* change_passwd */ | |
| 9951 | 748 irc_add_buddy, /* add_buddy */ |
| 9475 | 749 NULL, /* add_buddies */ |
| 9951 | 750 irc_remove_buddy, /* remove_buddy */ |
| 9475 | 751 NULL, /* remove_buddies */ |
| 9741 | 752 NULL, /* add_permit */ |
| 753 NULL, /* add_deny */ | |
| 754 NULL, /* rem_permit */ | |
| 755 NULL, /* rem_deny */ | |
| 756 NULL, /* set_permit_deny */ | |
| 9951 | 757 irc_chat_join, /* join_chat */ |
| 9475 | 758 NULL, /* reject_chat */ |
| 9951 | 759 irc_get_chat_name, /* get_chat_name */ |
| 760 irc_chat_invite, /* chat_invite */ | |
| 761 irc_chat_leave, /* chat_leave */ | |
| 9475 | 762 NULL, /* chat_whisper */ |
| 9951 | 763 irc_chat_send, /* chat_send */ |
| 11083 | 764 irc_ping_server, /* keepalive */ |
| 9475 | 765 NULL, /* register_user */ |
| 766 NULL, /* get_cb_info */ | |
| 767 NULL, /* get_cb_away */ | |
| 768 NULL, /* alias_buddy */ | |
| 769 NULL, /* group_buddy */ | |
| 770 NULL, /* rename_group */ | |
| 771 NULL, /* buddy_free */ | |
| 772 NULL, /* convo_closed */ | |
| 11153 | 773 gaim_normalize_nocase, /* normalize */ |
| 9475 | 774 NULL, /* set_buddy_icon */ |
| 775 NULL, /* remove_group */ | |
| 776 NULL, /* get_cb_real_name */ | |
| 9951 | 777 irc_chat_set_topic, /* set_chat_topic */ |
| 9475 | 778 NULL, /* find_blist_chat */ |
| 779 irc_roomlist_get_list, /* roomlist_get_list */ | |
| 780 irc_roomlist_cancel, /* roomlist_cancel */ | |
| 781 NULL, /* roomlist_expand_category */ | |
| 782 NULL, /* can_receive_file */ | |
| 783 irc_dccsend_send_file /* send_file */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
784 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
785 |
| 8114 | 786 |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
787 static GaimPluginInfo info = |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
788 { |
| 9943 | 789 GAIM_PLUGIN_MAGIC, |
| 790 GAIM_MAJOR_VERSION, | |
| 791 GAIM_MINOR_VERSION, | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
792 GAIM_PLUGIN_PROTOCOL, /**< type */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
793 NULL, /**< ui_requirement */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
794 0, /**< flags */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
795 NULL, /**< dependencies */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
796 GAIM_PRIORITY_DEFAULT, /**< priority */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
797 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
798 "prpl-irc", /**< id */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
799 "IRC", /**< name */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
800 VERSION, /**< version */ |
| 6333 | 801 N_("IRC Protocol Plugin"), /** summary */ |
| 802 N_("The IRC Protocol Plugin that Sucks Less"), /** description */ | |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
803 NULL, /**< author */ |
|
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6369
diff
changeset
|
804 GAIM_WEBSITE, /**< homepage */ |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
805 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
806 NULL, /**< load */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
807 NULL, /**< unload */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
808 NULL, /**< destroy */ |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
809 |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
810 NULL, /**< ui_info */ |
| 8993 | 811 &prpl_info, /**< extra_info */ |
| 11763 | 812 NULL, /**< prefs_info */ |
| 9015 | 813 irc_actions |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
814 }; |
|
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
815 |
| 6333 | 816 static void _init_plugin(GaimPlugin *plugin) |
|
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
817 { |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
818 GaimAccountUserSplit *split; |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
819 GaimAccountOption *option; |
|
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
820 |
| 6333 | 821 split = gaim_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@'); |
|
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
822 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
|
823 |
|
6459
b52870734c21
[gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
824 option = gaim_account_option_int_new(_("Port"), "port", IRC_DEFAULT_PORT); |
| 6333 | 825 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
|
826 |
| 10258 | 827 option = gaim_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET); |
| 6333 | 828 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
|
829 |
| 7323 | 830 option = gaim_account_option_string_new(_("Username"), "username", ""); |
| 831 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 832 | |
| 10002 | 833 option = gaim_account_option_string_new(_("Real name"), "realname", ""); |
| 834 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 835 | |
| 11763 | 836 /* |
| 837 option = gaim_account_option_string_new(_("Quit message"), "quitmsg", IRC_DEFAULT_QUIT); | |
| 838 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 839 */ | |
| 840 | |
| 10365 | 841 option = gaim_account_option_bool_new(_("Use SSL"), "ssl", FALSE); |
| 842 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
| 843 | |
| 6333 | 844 _irc_plugin = plugin; |
| 9130 | 845 |
| 11763 | 846 gaim_prefs_remove("/plugins/prpl/irc/quitmsg"); |
| 847 gaim_prefs_remove("/plugins/prpl/irc"); | |
| 11073 | 848 |
| 9130 | 849 irc_register_commands(); |
| 2086 | 850 } |
| 851 | |
| 6333 | 852 GAIM_INIT_PLUGIN(irc, _init_plugin, info); |
