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