Mercurial > pidgin
annotate src/protocols/irc/irc.c @ 12645:fc28451f5d96
[gaim-migrate @ 14983]
SF Patch #1314512 from Sadrul (who has a patch for everything)
"This patch introduces a flag for protocol plugins that
support offline messages (like Y!M and ICQ). This was
encouraged by the following conversation:
<sadrul> should offline buddies be listed/enabled in
the send-to menu?
<rekkanoryo> i would think only for protocols that
support offline messaging, if it's indicated that the
buddy is offline
-- <snip> --
<Bleeter> sadrul: personally, I'd like to see a
'supports offline' flag of some description
<Bleeter> one could then redirect (via plugins) through
email or alternative methods
<Bleeter> just a thought
<Paco-Paco> yeah, that sounds like a reasonble thing to have
This patch uses this flag to disable the buddies in the
send-to menu who are offline and the protocol doesn't
support offline messages."
I made this make the label insensitive instead of the whole menuitem. This
should address SimGuy's concerns about inconsistency (i.e. you could create a
conversation with someone via the buddy list that you couldn't create via the
Send To menu). I also hacked up some voodoo to show the label as sensitive when
moused-over, as that looks better (given the label-insensitive thing is itself a
hack). I think this works quite well.
BUG NOTE:
This makes more obvious an existing bug. The Send To menu isn't updated when
buddies sign on or off or change status (at least under some circumstances).
We need to fix that anyway, so I'm not going to let it hold up this commit.
Switching tabs will clear it up. I'm thinking we just might want to build the
contents of that menu when it is selected. That would save us a mess of
inefficient signal callbacks that update the Send To menus in open windows all
the time.
AIM NOTE:
This assumes that AIM can't offline message. That's not strictly true. You can
message invisible users on AIM. However, by design, we can't tell when a user
is invisible without resorting to dirty hackery. In practice, this isn't a
problem, as you can still select the AIM user from the menu. And really, how
often will you be choosing the Invisible contact, rather than the user going
Invisible in the middle of a conversation or IMing you while they're Invisible?
JABBER NOTE:
This assumes that Jabber can always offline message. This isn't strictly true.
Sadrul said:
I have updated Jabber according to this link which seems to
talk about how to determine the existence offline-message
support in a server:
http://www.jabber.org/jeps/jep-0013.html#discover
However, jabber.org doesn't seem to send the required
info. So I am not sure about it.
He later said:
I talked to Nathan and he said offline message support is
mostly assumed for most jabber servers. GTalk doesn't yet
support it, but they are working on it. So I have made
jabber to always return TRUE.
If there is truly no way to detect offline messaging capability, then this is
an acceptable solution. We could special case Google Talk because of its
popularity, and remove that later. It's probably not worth it though.
MSN NOTE:
This assumes that MSN can never offline message. That's effectively true, but
to be technically correct, MSN can offline message if there's already a
switchboard conversation open with a user. We could write an offline_message
function in the MSN prpl to detect that, but it'd be of limited usefulness,
especially given that under most circumstances (where this might matter), the
switchboard connection will be closed almost immediately.
CVS NOTE:
I'm writing to share a tragic little story.
I have a PC that I use for Gaim development. One day, I was writing a commit
message on it, when all of a suddent it went berserk. The screen started
flashing, and the whole commit message just disappeared. All of it. And it was
a good commit message! I had to cram and rewrite it really quickly. Needless to
say, my rushed commit message wasn't nearly as good, and I blame the PC for that.
Seriously, though, what kind of version control system loses your commit
message on a broken connection to the server? Stupid!
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Fri, 23 Dec 2005 19:26:04 +0000 |
parents | e856f985a0b9 |
children | a0fd3ebcd6fa |
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 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12323
diff
changeset
|
166 type = gaim_status_type_new(GAIM_STATUS_OFFLINE, NULL, NULL, TRUE); |
9944 | 167 types = g_list_append(types, type); |
168 | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12323
diff
changeset
|
169 type = gaim_status_type_new(GAIM_STATUS_AVAILABLE, NULL, NULL, TRUE); |
9944 | 170 types = g_list_append(types, type); |
171 | |
172 type = gaim_status_type_new_with_attrs( | |
12595
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12323
diff
changeset
|
173 GAIM_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12323
diff
changeset
|
174 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), |
3169cd6727ad
[gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents:
12323
diff
changeset
|
175 NULL); |
9944 | 176 types = g_list_append(types, type); |
177 | |
178 return types; | |
3452 | 179 } |
180 | |
9015 | 181 static GList *irc_actions(GaimPlugin *plugin, gpointer context) |
7148 | 182 { |
183 GList *list = NULL; | |
9015 | 184 GaimPluginAction *act = NULL; |
7148 | 185 |
9015 | 186 act = gaim_plugin_action_new(_("View MOTD"), irc_view_motd); |
187 list = g_list_append(list, act); | |
7148 | 188 |
189 return list; | |
190 } | |
191 | |
6333 | 192 static GList *irc_chat_join_info(GaimConnection *gc) |
2086 | 193 { |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
194 GList *m = NULL; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
195 struct proto_chat_entry *pce; |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
196 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
197 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 198 pce->label = _("_Channel:"); |
5234 | 199 pce->identifier = "channel"; |
10954 | 200 pce->required = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
201 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
202 |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
203 pce = g_new0(struct proto_chat_entry, 1); |
7841 | 204 pce->label = _("_Password:"); |
5234 | 205 pce->identifier = "password"; |
6499 | 206 pce->secret = TRUE; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
207 m = g_list_append(m, pce); |
2170
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
208 |
c24595d3c364
[gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2167
diff
changeset
|
209 return m; |
2086 | 210 } |
211 | |
12323
fc464a0abccc
[gaim-migrate @ 14627]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
212 static GHashTable *irc_chat_info_defaults(GaimConnection *gc, const char *chat_name) |
9754 | 213 { |
214 GHashTable *defaults; | |
215 | |
216 defaults = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free); | |
217 | |
218 if (chat_name != NULL) | |
219 g_hash_table_insert(defaults, "channel", g_strdup(chat_name)); | |
220 | |
221 return defaults; | |
222 } | |
223 | |
11837 | 224 static void irc_login(GaimAccount *account) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
225 { |
6333 | 226 GaimConnection *gc; |
227 struct irc_conn *irc; | |
10494 | 228 char **userparts; |
6333 | 229 const char *username = gaim_account_get_username(account); |
230 int err; | |
231 | |
232 gc = gaim_account_get_connection(account); | |
8677 | 233 gc->flags |= GAIM_CONNECTION_NO_NEWLINES; |
6333 | 234 |
6752 | 235 if (strpbrk(username, " \t\v\r\n") != NULL) { |
236 gaim_connection_error(gc, _("IRC nicks may not contain whitespace")); | |
237 return; | |
238 } | |
239 | |
6333 | 240 gc->proto_data = irc = g_new0(struct irc_conn, 1); |
10960 | 241 irc->fd = -1; |
6333 | 242 irc->account = account; |
243 | |
244 userparts = g_strsplit(username, "@", 2); | |
245 gaim_connection_set_display_name(gc, userparts[0]); | |
246 irc->server = g_strdup(userparts[1]); | |
247 g_strfreev(userparts); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
248 |
10159 | 249 irc->buddies = g_hash_table_new_full((GHashFunc)irc_nick_hash, (GEqualFunc)irc_nick_equal, |
6333 | 250 NULL, (GDestroyNotify)irc_buddy_free); |
251 irc->cmds = g_hash_table_new(g_str_hash, g_str_equal); | |
252 irc_cmd_table_build(irc); | |
253 irc->msgs = g_hash_table_new(g_str_hash, g_str_equal); | |
254 irc_msg_table_build(irc); | |
255 | |
10494 | 256 gaim_connection_update_progress(gc, _("Connecting"), 1, 2); |
6333 | 257 |
10365 | 258 if (gaim_account_get_bool(account, "ssl", FALSE)) { |
259 if (gaim_ssl_is_supported()) { | |
260 irc->gsc = gaim_ssl_connect(account, irc->server, | |
261 gaim_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT), | |
262 irc_login_cb_ssl, irc_ssl_connect_failure, gc); | |
263 } else { | |
264 gaim_connection_error(gc, _("SSL support unavailable")); | |
265 } | |
266 } | |
267 | |
268 if (!irc->gsc) { | |
269 | |
270 err = gaim_proxy_connect(account, irc->server, | |
6333 | 271 gaim_account_get_int(account, "port", IRC_DEFAULT_PORT), |
272 irc_login_cb, gc); | |
273 | |
10555 | 274 if (err || !gaim_account_get_connection(account)) { |
10365 | 275 gaim_connection_error(gc, _("Couldn't create socket")); |
276 return; | |
277 } | |
278 } | |
279 } | |
280 | |
281 static gboolean do_login(GaimConnection *gc) { | |
282 char *buf; | |
283 char hostname[256]; | |
284 const char *username, *realname; | |
285 struct irc_conn *irc = gc->proto_data; | |
10740 | 286 const char *pass = gaim_connection_get_password(gc); |
10365 | 287 |
10555 | 288 if (pass && *pass) { |
289 buf = irc_format(irc, "vv", "PASS", pass); | |
10365 | 290 if (irc_send(irc, buf) < 0) { |
291 gaim_connection_error(gc, "Error sending password"); | |
10903 | 292 g_free(buf); |
10365 | 293 return FALSE; |
294 } | |
295 g_free(buf); | |
296 } | |
297 | |
298 gethostname(hostname, sizeof(hostname)); | |
299 hostname[sizeof(hostname) - 1] = '\0'; | |
300 username = gaim_account_get_string(irc->account, "username", ""); | |
301 realname = gaim_account_get_string(irc->account, "realname", ""); | |
302 buf = irc_format(irc, "vvvv:", "USER", strlen(username) ? username : g_get_user_name(), hostname, irc->server, | |
303 strlen(realname) ? realname : IRC_DEFAULT_ALIAS); | |
304 if (irc_send(irc, buf) < 0) { | |
305 gaim_connection_error(gc, "Error registering with server"); | |
10903 | 306 g_free(buf); |
10365 | 307 return FALSE; |
308 } | |
309 g_free(buf); | |
310 buf = irc_format(irc, "vn", "NICK", gaim_connection_get_display_name(gc)); | |
311 if (irc_send(irc, buf) < 0) { | |
312 gaim_connection_error(gc, "Error sending nickname"); | |
10903 | 313 g_free(buf); |
10365 | 314 return FALSE; |
315 } | |
316 g_free(buf); | |
317 | |
318 return TRUE; | |
319 } | |
320 | |
321 static void irc_login_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
322 GaimInputCondition cond) | |
323 { | |
324 GaimConnection *gc = data; | |
325 struct irc_conn *irc = gc->proto_data; | |
326 | |
327 if(!g_list_find(gaim_connections_get_all(), gc)) { | |
328 gaim_ssl_close(gsc); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
329 return; |
6333 | 330 } |
10365 | 331 |
332 irc->gsc = gsc; | |
333 | |
334 if (do_login(gc)) { | |
335 gaim_ssl_input_add(gsc, irc_input_cb_ssl, gc); | |
336 } | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
337 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
338 |
6333 | 339 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
|
340 { |
6333 | 341 GaimConnection *gc = data; |
342 struct irc_conn *irc = gc->proto_data; | |
343 GList *connections = gaim_connections_get_all(); | |
344 | |
8778 | 345 if (source < 0) { |
346 gaim_connection_error(gc, _("Couldn't connect to host")); | |
6333 | 347 return; |
8778 | 348 } |
6333 | 349 |
350 if (!g_list_find(connections, gc)) { | |
351 close(source); | |
352 return; | |
353 } | |
354 | |
355 irc->fd = source; | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
356 |
10365 | 357 if (do_login(gc)) { |
358 gc->inpa = gaim_input_add(irc->fd, GAIM_INPUT_READ, irc_input_cb, gc); | |
359 } | |
360 } | |
361 | |
362 static void | |
363 irc_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, | |
364 gpointer data) | |
365 { | |
366 GaimConnection *gc = data; | |
367 struct irc_conn *irc = gc->proto_data; | |
368 | |
369 switch(error) { | |
370 case GAIM_SSL_CONNECT_FAILED: | |
371 gaim_connection_error(gc, _("Connection Failed")); | |
372 break; | |
373 case GAIM_SSL_HANDSHAKE_FAILED: | |
374 gaim_connection_error(gc, _("SSL Handshake Failed")); | |
375 break; | |
6333 | 376 } |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
377 |
10365 | 378 irc->gsc = NULL; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
379 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
380 |
6333 | 381 static void irc_close(GaimConnection *gc) |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
382 { |
6333 | 383 struct irc_conn *irc = gc->proto_data; |
384 | |
6752 | 385 if (irc == NULL) |
386 return; | |
387 | |
6333 | 388 irc_cmd_quit(irc, "quit", NULL, NULL); |
389 | |
390 if (gc->inpa) | |
9441 | 391 gaim_input_remove(gc->inpa); |
6333 | 392 |
393 g_free(irc->inbuf); | |
10365 | 394 if (irc->gsc) { |
395 gaim_ssl_close(irc->gsc); | |
396 } else if (irc->fd > 0) { | |
397 close(irc->fd); | |
398 } | |
6333 | 399 if (irc->timer) |
8287
ef881489396e
[gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents:
8170
diff
changeset
|
400 gaim_timeout_remove(irc->timer); |
6333 | 401 g_hash_table_destroy(irc->cmds); |
402 g_hash_table_destroy(irc->msgs); | |
10504 | 403 g_hash_table_destroy(irc->buddies); |
6333 | 404 if (irc->motd) |
405 g_string_free(irc->motd, TRUE); | |
406 g_free(irc->server); | |
407 g_free(irc); | |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
408 } |
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
409 |
12216 | 410 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
|
411 { |
6333 | 412 struct irc_conn *irc = gc->proto_data; |
12216 | 413 char *plain; |
6333 | 414 const char *args[2]; |
415 | |
7711 | 416 if (strchr(status_chars, *who) != NULL) |
6333 | 417 args[0] = who + 1; |
418 else | |
419 args[0] = who; | |
12216 | 420 |
421 plain = gaim_unescape_html(what); | |
422 args[1] = plain; | |
9442 | 423 |
6333 | 424 irc_cmd_privmsg(irc, "msg", NULL, args); |
12216 | 425 g_free(plain); |
6333 | 426 return 1; |
2289
38e156136896
[gaim-migrate @ 2299]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2273
diff
changeset
|
427 } |
2086 | 428 |
6333 | 429 static void irc_get_info(GaimConnection *gc, const char *who) |
2086 | 430 { |
6333 | 431 struct irc_conn *irc = gc->proto_data; |
10618
9eb3b224face
[gaim-migrate @ 12083]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10555
diff
changeset
|
432 const char *args[2]; |
6333 | 433 args[0] = who; |
10624 | 434 args[1] = NULL; |
6333 | 435 irc_cmd_whois(irc, "whois", NULL, args); |
436 } | |
437 | |
9944 | 438 static void irc_set_status(GaimAccount *account, GaimStatus *status) |
6333 | 439 { |
9944 | 440 GaimConnection *gc = gaim_account_get_connection(account); |
10724
811f12c8a5e4
[gaim-migrate @ 12324]
Luke Schierer <lschiere@pidgin.im>
parents:
10646
diff
changeset
|
441 struct irc_conn *irc = NULL; |
6333 | 442 const char *args[1]; |
9944 | 443 const char *status_id = gaim_status_get_id(status); |
2086 | 444 |
10646 | 445 if (gc) |
446 irc = gc->proto_data; | |
447 | |
10504 | 448 if (!gaim_status_is_active(status)) |
449 return; | |
450 | |
451 args[0] = NULL; | |
452 | |
11718 | 453 if (!strcmp(status_id, "away")) { |
9944 | 454 args[0] = gaim_status_get_attr_string(status, "message"); |
12001 | 455 if ((args[0] == NULL) || (*args[0] == '\0')) |
456 args[0] = _("Away"); | |
10646 | 457 irc_cmd_away(irc, "away", NULL, args); |
12210 | 458 } else if (!strcmp(status_id, "available")) { |
459 irc_cmd_away(irc, "back", NULL, args); | |
10646 | 460 } |
4916 | 461 } |
462 | |
9285 | 463 static void irc_add_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
3029 | 464 { |
6333 | 465 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; |
466 struct irc_buddy *ib = g_new0(struct irc_buddy, 1); | |
9285 | 467 ib->name = g_strdup(buddy->name); |
6333 | 468 g_hash_table_insert(irc->buddies, ib->name, ib); |
9238 | 469 |
9553 | 470 /* if the timer isn't set, this is during signon, so we don't want to flood |
471 * ourself off with ISON's, so we don't, but after that we want to know when | |
472 * someone's online asap */ | |
473 if (irc->timer) | |
474 irc_ison_one(irc, ib); | |
3029 | 475 } |
3622 | 476 |
9285 | 477 static void irc_remove_buddy(GaimConnection *gc, GaimBuddy *buddy, GaimGroup *group) |
6333 | 478 { |
479 struct irc_conn *irc = (struct irc_conn *)gc->proto_data; | |
9285 | 480 g_hash_table_remove(irc->buddies, buddy->name); |
3616 | 481 } |
4514
7521e29658bc
[gaim-migrate @ 4792]
Christian Hammond <chipx86@chipx86.com>
parents:
4509
diff
changeset
|
482 |
10365 | 483 static void read_input(struct irc_conn *irc, int len) |
6333 | 484 { |
485 char *cur, *end; | |
6369 | 486 |
6333 | 487 irc->inbufused += len; |
488 irc->inbuf[irc->inbufused] = '\0'; | |
3616 | 489 |
8156 | 490 cur = irc->inbuf; |
491 while (cur < irc->inbuf + irc->inbufused && | |
492 ((end = strstr(cur, "\r\n")) || (end = strstr(cur, "\n")))) { | |
493 int step = (*end == '\r' ? 2 : 1); | |
6333 | 494 *end = '\0'; |
495 irc_parse_msg(irc, cur); | |
8156 | 496 cur = end + step; |
6333 | 497 } |
498 if (cur != irc->inbuf + irc->inbufused) { /* leftover */ | |
499 irc->inbufused -= (cur - irc->inbuf); | |
500 memmove(irc->inbuf, cur, irc->inbufused); | |
501 } else { | |
502 irc->inbufused = 0; | |
503 } | |
3616 | 504 } |
505 | |
10365 | 506 static void irc_input_cb_ssl(gpointer data, GaimSslConnection *gsc, |
507 GaimInputCondition cond) | |
508 { | |
509 | |
510 GaimConnection *gc = data; | |
511 struct irc_conn *irc = gc->proto_data; | |
512 int len; | |
513 | |
514 if(!g_list_find(gaim_connections_get_all(), gc)) { | |
515 gaim_ssl_close(gsc); | |
516 return; | |
517 } | |
518 | |
519 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { | |
520 irc->inbuflen += IRC_INITIAL_BUFSIZE; | |
521 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); | |
522 } | |
523 | |
524 if ((len = gaim_ssl_read(gsc, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) { | |
525 gaim_connection_error(gc, _("Read error")); | |
526 return; | |
527 } else if (len == 0) { | |
528 gaim_connection_error(gc, _("Server has disconnected")); | |
529 return; | |
530 } | |
531 | |
532 read_input(irc, len); | |
533 } | |
534 | |
535 static void irc_input_cb(gpointer data, gint source, GaimInputCondition cond) | |
536 { | |
537 GaimConnection *gc = data; | |
538 struct irc_conn *irc = gc->proto_data; | |
539 int len; | |
540 | |
541 if (irc->inbuflen < irc->inbufused + IRC_INITIAL_BUFSIZE) { | |
542 irc->inbuflen += IRC_INITIAL_BUFSIZE; | |
543 irc->inbuf = g_realloc(irc->inbuf, irc->inbuflen); | |
544 } | |
545 | |
546 if ((len = read(irc->fd, irc->inbuf + irc->inbufused, IRC_INITIAL_BUFSIZE - 1)) < 0) { | |
547 gaim_connection_error(gc, _("Read error")); | |
548 return; | |
549 } else if (len == 0) { | |
550 gaim_connection_error(gc, _("Server has disconnected")); | |
551 return; | |
552 } | |
553 | |
554 read_input(irc, len); | |
555 } | |
556 | |
6333 | 557 static void irc_chat_join (GaimConnection *gc, GHashTable *data) |
558 { | |
559 struct irc_conn *irc = gc->proto_data; | |
560 const char *args[2]; | |
3616 | 561 |
6333 | 562 args[0] = g_hash_table_lookup(data, "channel"); |
563 args[1] = g_hash_table_lookup(data, "password"); | |
564 irc_cmd_join(irc, "join", NULL, args); | |
3622 | 565 } |
566 | |
9917 | 567 static char *irc_get_chat_name(GHashTable *data) { |
568 return g_strdup(g_hash_table_lookup(data, "channel")); | |
569 } | |
570 | |
6333 | 571 static void irc_chat_invite(GaimConnection *gc, int id, const char *message, const char *name) |
3751 | 572 { |
6333 | 573 struct irc_conn *irc = gc->proto_data; |
574 GaimConversation *convo = gaim_find_chat(gc, id); | |
575 const char *args[2]; | |
3751 | 576 |
6333 | 577 if (!convo) { |
578 gaim_debug(GAIM_DEBUG_ERROR, "irc", "Got chat invite request for bogus chat\n"); | |
579 return; | |
580 } | |
581 args[0] = name; | |
582 args[1] = gaim_conversation_get_name(convo); | |
583 irc_cmd_invite(irc, "invite", gaim_conversation_get_name(convo), args); | |
3707 | 584 } |
585 | |
6333 | 586 |
587 static void irc_chat_leave (GaimConnection *gc, int id) | |
3707 | 588 { |
6333 | 589 struct irc_conn *irc = gc->proto_data; |
590 GaimConversation *convo = gaim_find_chat(gc, id); | |
591 const char *args[2]; | |
5298 | 592 |
6333 | 593 if (!convo) |
594 return; | |
3735 | 595 |
6333 | 596 args[0] = gaim_conversation_get_name(convo); |
597 args[1] = NULL; | |
598 irc_cmd_part(irc, "part", gaim_conversation_get_name(convo), args); | |
599 serv_got_chat_left(gc, id); | |
3735 | 600 } |
601 | |
12216 | 602 static int irc_chat_send(GaimConnection *gc, int id, const char *what, GaimMessageFlags flags) |
3735 | 603 { |
6333 | 604 struct irc_conn *irc = gc->proto_data; |
605 GaimConversation *convo = gaim_find_chat(gc, id); | |
606 const char *args[2]; | |
8163 | 607 char *tmp; |
6333 | 608 |
609 if (!convo) { | |
610 gaim_debug(GAIM_DEBUG_ERROR, "irc", "chat send on nonexistent chat\n"); | |
611 return -EINVAL; | |
612 } | |
9130 | 613 #if 0 |
6333 | 614 if (*what == '/') { |
615 return irc_parse_cmd(irc, convo->name, what + 1); | |
616 } | |
9130 | 617 #endif |
12216 | 618 tmp = gaim_unescape_html(what); |
6333 | 619 args[0] = convo->name; |
12216 | 620 args[1] = tmp; |
6333 | 621 |
622 irc_cmd_privmsg(irc, "msg", NULL, args); | |
8163 | 623 |
12216 | 624 serv_got_chat_in(gc, id, gaim_connection_get_display_name(gc), 0, what, time(NULL)); |
8163 | 625 g_free(tmp); |
6333 | 626 return 0; |
3707 | 627 } |
628 | |
6333 | 629 static guint irc_nick_hash(const char *nick) |
630 { | |
631 char *lc; | |
632 guint bucket; | |
6270
1bf6fd117797
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
633 |
6333 | 634 lc = g_utf8_strdown(nick, -1); |
635 bucket = g_str_hash(lc); | |
636 g_free(lc); | |
6270
1bf6fd117797
[gaim-migrate @ 6767]
Christian Hammond <chipx86@chipx86.com>
parents:
6240
diff
changeset
|
637 |
6333 | 638 return bucket; |
3029 | 639 } |
640 | |
6333 | 641 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
|
642 { |
6333 | 643 return (gaim_utf8_strcasecmp(nick1, nick2) == 0); |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
644 } |
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
645 |
6333 | 646 static void irc_buddy_free(struct irc_buddy *ib) |
2619
536198196dc6
[gaim-migrate @ 2632]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2617
diff
changeset
|
647 { |
6333 | 648 g_free(ib->name); |
649 g_free(ib); | |
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 |
9154 | 652 static void irc_chat_set_topic(GaimConnection *gc, int id, const char *topic) |
653 { | |
654 char *buf; | |
655 const char *name = NULL; | |
656 struct irc_conn *irc; | |
657 | |
658 irc = gc->proto_data; | |
659 name = gaim_conversation_get_name(gaim_find_chat(gc, id)); | |
660 | |
661 if (name == NULL) | |
662 return; | |
663 | |
664 buf = irc_format(irc, "vt:", "TOPIC", name, topic); | |
665 irc_send(irc, buf); | |
666 g_free(buf); | |
667 } | |
668 | |
8114 | 669 static GaimRoomlist *irc_roomlist_get_list(GaimConnection *gc) |
670 { | |
671 struct irc_conn *irc; | |
672 GList *fields = NULL; | |
673 GaimRoomlistField *f; | |
8352 | 674 char *buf; |
8114 | 675 |
676 irc = gc->proto_data; | |
677 | |
678 if (irc->roomlist) | |
679 gaim_roomlist_unref(irc->roomlist); | |
680 | |
681 irc->roomlist = gaim_roomlist_new(gaim_connection_get_account(gc)); | |
682 | |
683 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, "", "channel", TRUE); | |
684 fields = g_list_append(fields, f); | |
685 | |
686 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_INT, _("Users"), "users", FALSE); | |
687 fields = g_list_append(fields, f); | |
688 | |
689 f = gaim_roomlist_field_new(GAIM_ROOMLIST_FIELD_STRING, _("Topic"), "topic", FALSE); | |
690 fields = g_list_append(fields, f); | |
691 | |
692 gaim_roomlist_set_fields(irc->roomlist, fields); | |
693 | |
8352 | 694 buf = irc_format(irc, "v", "LIST"); |
695 irc_send(irc, buf); | |
696 g_free(buf); | |
8114 | 697 |
698 return irc->roomlist; | |
699 } | |
700 | |
701 static void irc_roomlist_cancel(GaimRoomlist *list) | |
702 { | |
703 GaimConnection *gc = gaim_account_get_connection(list->account); | |
704 struct irc_conn *irc; | |
705 | |
706 if (gc == NULL) | |
707 return; | |
708 | |
709 irc = gc->proto_data; | |
710 | |
711 gaim_roomlist_set_in_progress(list, FALSE); | |
712 | |
713 if (irc->roomlist == list) { | |
714 irc->roomlist = NULL; | |
715 gaim_roomlist_unref(list); | |
716 } | |
717 } | |
718 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
719 static GaimPluginProtocolInfo prpl_info = |
2086 | 720 { |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
721 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_PASSWORD_OPTIONAL, |
9475 | 722 NULL, /* user_splits */ |
723 NULL, /* protocol_options */ | |
9951 | 724 NO_BUDDY_ICONS, /* icon_spec */ |
725 irc_blist_icon, /* list_icon */ | |
726 irc_blist_emblems, /* list_emblems */ | |
9475 | 727 NULL, /* status_text */ |
728 NULL, /* tooltip_text */ | |
9951 | 729 irc_status_types, /* away_states */ |
9475 | 730 NULL, /* blist_node_menu */ |
9951 | 731 irc_chat_join_info, /* chat_info */ |
9754 | 732 irc_chat_info_defaults, /* chat_info_defaults */ |
9951 | 733 irc_login, /* login */ |
734 irc_close, /* close */ | |
735 irc_im_send, /* send_im */ | |
9475 | 736 NULL, /* set_info */ |
737 NULL, /* send_typing */ | |
9951 | 738 irc_get_info, /* get_info */ |
739 irc_set_status, /* set_status */ | |
9475 | 740 NULL, /* set_idle */ |
741 NULL, /* change_passwd */ | |
9951 | 742 irc_add_buddy, /* add_buddy */ |
9475 | 743 NULL, /* add_buddies */ |
9951 | 744 irc_remove_buddy, /* remove_buddy */ |
9475 | 745 NULL, /* remove_buddies */ |
9741 | 746 NULL, /* add_permit */ |
747 NULL, /* add_deny */ | |
748 NULL, /* rem_permit */ | |
749 NULL, /* rem_deny */ | |
750 NULL, /* set_permit_deny */ | |
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 */ |
12031 | 758 NULL, /* keepalive */ |
9475 | 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 */ | |
11153 | 767 gaim_normalize_nocase, /* normalize */ |
9475 | 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 */ | |
12143
cbebda5f019c
[gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents:
12130
diff
changeset
|
777 irc_dccsend_send_file, /* send_file */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
778 irc_dccsend_new_xfer, /* new_xfer */ |
12645
fc28451f5d96
[gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents:
12600
diff
changeset
|
779 NULL, /* offline_message */ |
12600
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
780 NULL, /* whiteboard_prpl_ops */ |
e856f985a0b9
[gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents:
12595
diff
changeset
|
781 NULL, /* media_prpl_ops */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
782 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
783 |
8114 | 784 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
785 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
786 { |
9943 | 787 GAIM_PLUGIN_MAGIC, |
788 GAIM_MAJOR_VERSION, | |
789 GAIM_MINOR_VERSION, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
790 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
791 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
792 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
793 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
794 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
795 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
796 "prpl-irc", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
797 "IRC", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
798 VERSION, /**< version */ |
6333 | 799 N_("IRC Protocol Plugin"), /** summary */ |
800 N_("The IRC Protocol Plugin that Sucks Less"), /** description */ | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
801 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6369
diff
changeset
|
802 GAIM_WEBSITE, /**< homepage */ |
5205
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, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
805 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
806 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
807 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
808 NULL, /**< ui_info */ |
8993 | 809 &prpl_info, /**< extra_info */ |
11763 | 810 NULL, /**< prefs_info */ |
9015 | 811 irc_actions |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
812 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
813 |
6333 | 814 static void _init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5150
diff
changeset
|
815 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
816 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
817 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
818 |
6333 | 819 split = gaim_account_user_split_new(_("Server"), IRC_DEFAULT_SERVER, '@'); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5618
diff
changeset
|
820 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
|
821 |
6459
b52870734c21
[gaim-migrate @ 6968]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
822 option = gaim_account_option_int_new(_("Port"), "port", IRC_DEFAULT_PORT); |
6333 | 823 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
|
824 |
10258 | 825 option = gaim_account_option_string_new(_("Encodings"), "encoding", IRC_DEFAULT_CHARSET); |
6333 | 826 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
|
827 |
7323 | 828 option = gaim_account_option_string_new(_("Username"), "username", ""); |
829 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
830 | |
10002 | 831 option = gaim_account_option_string_new(_("Real name"), "realname", ""); |
832 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
833 | |
11763 | 834 /* |
835 option = gaim_account_option_string_new(_("Quit message"), "quitmsg", IRC_DEFAULT_QUIT); | |
836 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
837 */ | |
838 | |
10365 | 839 option = gaim_account_option_bool_new(_("Use SSL"), "ssl", FALSE); |
840 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); | |
841 | |
6333 | 842 _irc_plugin = plugin; |
9130 | 843 |
11763 | 844 gaim_prefs_remove("/plugins/prpl/irc/quitmsg"); |
845 gaim_prefs_remove("/plugins/prpl/irc"); | |
11073 | 846 |
9130 | 847 irc_register_commands(); |
2086 | 848 } |
849 | |
6333 | 850 GAIM_INIT_PLUGIN(irc, _init_plugin, info); |