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