Mercurial > pidgin.yaz
annotate src/protocols/jabber/jabber.c @ 7291:632cee95cc5c
[gaim-migrate @ 7872]
disable jabber SASL for the moment, until the RFCs are actually approved,
since the authentication stuff is still in a state of flux
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 17 Oct 2003 20:03:44 +0000 |
parents | 448e39ace278 |
children | dd4b4a187171 |
rev | line source |
---|---|
2086 | 1 /* |
7014 | 2 * gaim - Jabber Protocol Plugin |
2086 | 3 * |
7014 | 4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> |
2086 | 5 * |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
7014 | 10 * |
2086 | 11 * This program is distributed in the hope that it will be useful, |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
21 #include "internal.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
22 |
7014 | 23 /* |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
24 #include "conversation.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
25 #include "ft.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
26 #include "multi.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
27 #include "notify.h" |
7014 | 28 #include "proxy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
29 #include "request.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
30 #include "util.h" |
7014 | 31 |
32 */ | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
33 |
7014 | 34 #include "account.h" |
35 #include "accountopt.h" | |
36 #include "debug.h" | |
37 #include "message.h" | |
38 #include "multi.h" | |
7072 | 39 #include "notify.h" |
7014 | 40 #include "prpl.h" |
7072 | 41 #include "request.h" |
7014 | 42 #include "server.h" |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
43 #include "util.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
44 |
7014 | 45 #include "auth.h" |
46 #include "buddy.h" | |
47 #include "chat.h" | |
48 #include "iq.h" | |
49 #include "jutil.h" | |
50 #include "message.h" | |
51 #include "parser.h" | |
52 #include "presence.h" | |
53 #include "jabber.h" | |
54 #include "roster.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5685
diff
changeset
|
55 |
7014 | 56 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) |
2086 | 57 |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
58 static GaimPlugin *my_protocol = NULL; |
4249 | 59 |
7014 | 60 static void jabber_stream_init(JabberStream *js) |
61 { | |
62 char *open_stream; | |
3340 | 63 |
7014 | 64 open_stream = g_strdup_printf("<stream:stream to='%s' " |
65 "xmlns='jabber:client' " | |
7291 | 66 "xmlns:stream='http://etherx.jabber.org/streams'>", |
67 /* "version='1.0'>" */ | |
68 js->user->domain); | |
3311 | 69 |
7014 | 70 jabber_send_raw(js, open_stream); |
2086 | 71 |
7014 | 72 g_free(open_stream); |
2086 | 73 } |
74 | |
7014 | 75 static void jabber_session_initialized_cb(JabberStream *js, xmlnode *packet) |
3311 | 76 { |
7014 | 77 const char *type = xmlnode_get_attrib(packet, "type"); |
78 if(type && !strcmp(type, "result")) { | |
79 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); | |
80 } else { | |
81 gaim_connection_error(js->gc, _("Error initializing session")); | |
3311 | 82 } |
83 } | |
84 | |
7014 | 85 static void jabber_session_init(JabberStream *js) |
3311 | 86 { |
7014 | 87 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET); |
88 xmlnode *session; | |
3311 | 89 |
7014 | 90 jabber_iq_set_callback(iq, jabber_session_initialized_cb); |
3311 | 91 |
7014 | 92 session = xmlnode_new_child(iq->node, "session"); |
93 xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session"); | |
3311 | 94 |
7014 | 95 jabber_iq_send(iq); |
3311 | 96 } |
97 | |
7014 | 98 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) |
3311 | 99 { |
7014 | 100 xmlnode *textnode; |
101 char *error_text = NULL; | |
102 const char *text; | |
103 char *buf; | |
3311 | 104 |
7014 | 105 if(xmlnode_get_child(packet, "bad-format")) { |
106 text = _("Bad Format"); | |
107 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) { | |
108 text = _("Bad Namespace Prefix"); | |
109 } else if(xmlnode_get_child(packet, "conflict")) { | |
110 js->gc->wants_to_die = TRUE; | |
111 text = _("Resource Conflict"); | |
112 } else if(xmlnode_get_child(packet, "connection-timeout")) { | |
113 text = _("Connection Timeout"); | |
114 } else if(xmlnode_get_child(packet, "host-gone")) { | |
115 text = _("Host Gone"); | |
116 } else if(xmlnode_get_child(packet, "host-unknown")) { | |
117 text = _("Host Unknown"); | |
118 } else if(xmlnode_get_child(packet, "improper-addressing")) { | |
119 text = _("Improper Addressing"); | |
120 } else if(xmlnode_get_child(packet, "internal-server-error")) { | |
121 text = _("Internal Server Error"); | |
122 } else if(xmlnode_get_child(packet, "invalid-id")) { | |
123 text = _("Invalid ID"); | |
124 } else if(xmlnode_get_child(packet, "invalid-namespace")) { | |
125 text = _("Invalid Namespace"); | |
126 } else if(xmlnode_get_child(packet, "invalid-xml")) { | |
127 text = _("Invalid XML"); | |
128 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) { | |
129 text = _("Non-matching Hosts"); | |
130 } else if(xmlnode_get_child(packet, "not-authorized")) { | |
131 text = _("Not Authorized"); | |
132 } else if(xmlnode_get_child(packet, "policy-violation")) { | |
133 text = _("Policy Violation"); | |
134 } else if(xmlnode_get_child(packet, "remote-connection-failed")) { | |
135 text = _("Remote Connection Failed"); | |
136 } else if(xmlnode_get_child(packet, "resource-constraint")) { | |
137 text = _("Resource Constraint"); | |
138 } else if(xmlnode_get_child(packet, "restricted-xml")) { | |
139 text = _("Restricted XML"); | |
140 } else if(xmlnode_get_child(packet, "see-other-host")) { | |
141 text = _("See Other Host"); | |
142 } else if(xmlnode_get_child(packet, "system-shutdown")) { | |
143 text = _("System Shutdown"); | |
144 } else if(xmlnode_get_child(packet, "undefined-condition")) { | |
145 text = _("Undefined Condition"); | |
146 } else if(xmlnode_get_child(packet, "unsupported-encoding")) { | |
147 text = _("Unsupported Condition"); | |
148 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) { | |
149 text = _("Unsupported Stanza Type"); | |
150 } else if(xmlnode_get_child(packet, "unsupported-version")) { | |
151 text = _("Unsupported Version"); | |
152 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) { | |
153 text = _("XML Not Well Formed"); | |
3311 | 154 } else { |
7014 | 155 text = _("Stream Error"); |
3311 | 156 } |
157 | |
7014 | 158 if((textnode = xmlnode_get_child(packet, "text"))) |
159 error_text = xmlnode_get_data(textnode); | |
2086 | 160 |
7014 | 161 buf = g_strdup_printf("%s%s%s", text, |
162 error_text ? ": " : "", | |
163 error_text ? error_text : ""); | |
164 gaim_connection_error(js->gc, buf); | |
165 g_free(buf); | |
166 if(error_text) | |
167 g_free(error_text); | |
2086 | 168 } |
169 | |
7014 | 170 static void tls_init(JabberStream *js); |
2086 | 171 |
7014 | 172 void jabber_process_packet(JabberStream *js, xmlnode *packet) |
2086 | 173 { |
7014 | 174 const char *id = xmlnode_get_attrib(packet, "id"); |
175 const char *type = xmlnode_get_attrib(packet, "type"); | |
176 JabberCallback *callback; | |
2086 | 177 |
7014 | 178 if(!strcmp(packet->name, "iq")) { |
179 if(type && (!strcmp(type, "result") || !strcmp(type, "error")) && id | |
180 && *id && (callback = g_hash_table_lookup(js->callbacks, id))) | |
181 callback(js, packet); | |
182 else | |
183 jabber_iq_parse(js, packet); | |
184 } else if(!strcmp(packet->name, "presence")) { | |
185 jabber_presence_parse(js, packet); | |
186 } else if(!strcmp(packet->name, "message")) { | |
187 jabber_message_parse(js, packet); | |
188 } else if(!strcmp(packet->name, "stream:features")) { | |
7124 | 189 if(!js->registration && js->state == JABBER_STREAM_AUTHENTICATING) { |
7014 | 190 jabber_auth_start(js, packet); |
191 } else if(js->state == JABBER_STREAM_REINITIALIZING) { | |
192 jabber_session_init(js); | |
193 } else { | |
194 gaim_debug(GAIM_DEBUG_WARNING, "jabber", | |
195 "Unexpected stream:features packet, ignoring\n", js->state); | |
6076 | 196 } |
7014 | 197 } else if(!strcmp(packet->name, "stream:error")) { |
198 jabber_stream_handle_error(js, packet); | |
199 } else if(!strcmp(packet->name, "challenge")) { | |
200 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
201 jabber_auth_handle_challenge(js, packet); | |
202 } else if(!strcmp(packet->name, "success")) { | |
203 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
204 jabber_auth_handle_success(js, packet); | |
205 } else if(!strcmp(packet->name, "failure")) { | |
206 if(js->state == JABBER_STREAM_AUTHENTICATING) | |
207 jabber_auth_handle_failure(js, packet); | |
208 } else if(!strcmp(packet->name, "proceed")) { | |
209 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) | |
210 tls_init(js); | |
211 } else { | |
212 gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", | |
213 packet->name); | |
2086 | 214 } |
215 } | |
216 | |
7014 | 217 void jabber_send_raw(JabberStream *js, const char *data) |
2086 | 218 { |
7014 | 219 int ret; |
2086 | 220 |
7014 | 221 /* because printing a tab to debug every minute gets old */ |
222 if(strcmp(data, "\t")) | |
223 gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", | |
224 js->gsc ? " (ssl)" : "", data); | |
2086 | 225 |
7014 | 226 if(js->gsc) { |
227 ret = gaim_ssl_write(js->gsc, data, strlen(data)); | |
228 } else { | |
229 ret = write(js->fd, data, strlen(data)); | |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
230 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
231 |
7014 | 232 if(ret < 0) |
233 gaim_connection_error(js->gc, _("Write error")); | |
234 | |
2814
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
235 } |
f4f9e5a01890
[gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2800
diff
changeset
|
236 |
7014 | 237 void jabber_send(JabberStream *js, xmlnode *packet) |
2086 | 238 { |
7014 | 239 char *txt; |
2086 | 240 |
7014 | 241 txt = xmlnode_to_str(packet); |
242 jabber_send_raw(js, txt); | |
243 g_free(txt); | |
2086 | 244 } |
245 | |
7014 | 246 static void jabber_keepalive(GaimConnection *gc) |
2086 | 247 { |
7014 | 248 jabber_send_raw(gc->proto_data, "\t"); |
2086 | 249 } |
250 | |
7014 | 251 static void |
252 jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 253 GaimInputCondition cond) |
254 { | |
7014 | 255 GaimConnection *gc = data; |
256 JabberStream *js = gc->proto_data; | |
6764 | 257 int len; |
7014 | 258 static char buf[4096]; |
6768 | 259 |
7014 | 260 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6768 | 261 gaim_ssl_close(gsc); |
262 return; | |
263 } | |
264 | |
7014 | 265 if((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { |
6764 | 266 buf[len] = '\0'; |
7014 | 267 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); |
268 jabber_parser_process(js, buf, len); | |
7177 | 269 } else { |
270 gaim_connection_error(gc, _("Read Error")); | |
2086 | 271 } |
272 } | |
273 | |
7014 | 274 static void |
275 jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) | |
2086 | 276 { |
5572 | 277 GaimConnection *gc = data; |
7014 | 278 JabberStream *js = gc->proto_data; |
279 int len; | |
280 static char buf[4096]; | |
2086 | 281 |
7014 | 282 if(!g_list_find(gaim_connections_get_all(), gc)) |
283 return; | |
2956 | 284 |
7014 | 285 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { |
286 buf[len] = '\0'; | |
287 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); | |
288 jabber_parser_process(js, buf, len); | |
7177 | 289 } else { |
290 gaim_connection_error(gc, _("Read Error")); | |
7014 | 291 } |
2086 | 292 } |
293 | |
7014 | 294 static void |
295 jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, | |
6764 | 296 GaimInputCondition cond) |
297 { | |
298 GaimConnection *gc = data; | |
7014 | 299 JabberStream *js = gc->proto_data; |
6764 | 300 |
7014 | 301 if(!g_list_find(gaim_connections_get_all(), gc)) { |
6764 | 302 gaim_ssl_close(gsc); |
303 return; | |
304 } | |
305 | |
7014 | 306 js->gsc = gsc; |
6764 | 307 |
7014 | 308 if(js->state == JABBER_STREAM_CONNECTING) |
309 jabber_send_raw(js, "<?xml version='1.0' ?>"); | |
6764 | 310 |
7014 | 311 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
312 gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); | |
6764 | 313 } |
314 | |
7014 | 315 |
316 static void | |
317 jabber_login_callback(gpointer data, gint source, GaimInputCondition cond) | |
6764 | 318 { |
5572 | 319 GaimConnection *gc = data; |
7014 | 320 JabberStream *js = gc->proto_data; |
2086 | 321 |
7014 | 322 if(!g_list_find(gaim_connections_get_all(), gc)) { |
2086 | 323 close(source); |
324 return; | |
325 } | |
326 | |
7014 | 327 js->fd = source; |
2956 | 328 |
7014 | 329 if(js->state == JABBER_STREAM_CONNECTING) |
330 jabber_send_raw(js, "<?xml version='1.0' ?>"); | |
2300
d2686f757d6e
[gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2289
diff
changeset
|
331 |
7014 | 332 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); |
333 gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); | |
334 } | |
2086 | 335 |
7014 | 336 static void tls_init(JabberStream *js) |
337 { | |
338 gaim_input_remove(js->gc->inpa); | |
339 js->gc->inpa = 0; | |
340 js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7264
diff
changeset
|
341 jabber_login_callback_ssl, NULL, js->gc); |
2086 | 342 } |
343 | |
7014 | 344 static void |
345 jabber_login(GaimAccount *account) | |
2086 | 346 { |
7014 | 347 int rc; |
348 GaimConnection *gc = gaim_account_get_connection(account); | |
349 const char *connect_server = gaim_account_get_string(account, | |
350 "connect_server", ""); | |
5572 | 351 const char *server; |
7014 | 352 JabberStream *js; |
2086 | 353 |
7014 | 354 gc->flags |= GAIM_CONNECTION_HTML; |
355 js = gc->proto_data = g_new0(JabberStream, 1); | |
356 js->gc = gc; | |
357 js->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
358 g_free, NULL); | |
359 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, | |
7116 | 360 g_free, (GDestroyNotify)jabber_buddy_free); |
7014 | 361 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, |
362 g_free, NULL); | |
363 js->user = jabber_id_new(gaim_account_get_username(account)); | |
5613 | 364 |
7147 | 365 if(!js->user->resource) { |
366 char *me; | |
367 js->user->resource = g_strdup("Gaim"); | |
368 if(!js->user->node) { | |
369 js->user->node = js->user->domain; | |
370 js->user->domain = g_strdup("jabber.org"); | |
371 } | |
372 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
373 js->user->resource); | |
374 gaim_account_set_username(account, me); | |
375 g_free(me); | |
7145 | 376 } |
377 | |
7014 | 378 server = connect_server[0] ? connect_server : js->user->domain; |
2086 | 379 |
7014 | 380 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); |
2956 | 381 |
6880 | 382 if(gaim_account_get_bool(account, "old_ssl", FALSE) |
6764 | 383 && gaim_ssl_is_supported()) { |
7014 | 384 js->gsc = gaim_ssl_connect(account, server, |
385 gaim_account_get_int(account, "port", 5222), | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7264
diff
changeset
|
386 jabber_login_callback_ssl, NULL, gc); |
3311 | 387 } |
3770 | 388 |
7014 | 389 if(!js->gsc) { |
390 rc = gaim_proxy_connect(account, server, | |
391 gaim_account_get_int(account, "port", 5222), | |
392 jabber_login_callback, gc); | |
2086 | 393 |
7014 | 394 if (rc != 0) |
395 gaim_connection_error(gc, _("Unable to create socket")); | |
2956 | 396 } |
2086 | 397 } |
398 | |
7072 | 399 static gboolean |
400 conn_close_cb(gpointer data) | |
401 { | |
402 JabberStream *js = data; | |
403 gaim_connection_destroy(js->gc); | |
404 return FALSE; | |
405 } | |
406 | |
407 static void | |
408 jabber_connection_schedule_close(JabberStream *js) | |
409 { | |
410 g_timeout_add(0, conn_close_cb, js); | |
411 } | |
412 | |
413 static void | |
414 jabber_registration_result_cb(JabberStream *js, xmlnode *packet) | |
415 { | |
416 const char *type = xmlnode_get_attrib(packet, "type"); | |
417 char *buf; | |
418 | |
419 if(!strcmp(type, "result")) { | |
420 buf = g_strdup_printf(_("Registration of %s@%s successful"), | |
421 js->user->node, js->user->domain); | |
422 gaim_notify_info(NULL, _("Registration Successful"), | |
423 _("Registration Successful"), buf); | |
424 g_free(buf); | |
425 } else { | |
426 char *error; | |
427 xmlnode *y; | |
428 | |
429 if((y = xmlnode_get_child(packet, "error"))) { | |
430 error = xmlnode_get_data(y); | |
431 } else { | |
432 error = g_strdup(_("Unknown Error")); | |
433 } | |
434 | |
435 buf = g_strdup_printf(_("Registration of %s@%s failed: %s"), | |
436 js->user->node, js->user->domain, error); | |
437 gaim_notify_error(NULL, _("Registration Failed"), | |
438 _("Registration Failed"), buf); | |
439 g_free(buf); | |
440 g_free(error); | |
441 } | |
442 jabber_connection_schedule_close(js); | |
443 } | |
444 | |
445 static void | |
446 jabber_register_cb(JabberStream *js, GaimRequestFields *fields) | |
447 { | |
448 GList *groups, *flds; | |
449 xmlnode *query, *y; | |
450 JabberIq *iq; | |
7264 | 451 char *username; |
7072 | 452 |
453 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
454 query = xmlnode_get_child(iq->node, "query"); | |
455 | |
456 for(groups = gaim_request_fields_get_groups(fields); groups; | |
457 groups = groups->next) { | |
458 for(flds = gaim_request_field_group_get_fields(groups->data); | |
459 flds; flds = flds->next) { | |
460 GaimRequestField *field = flds->data; | |
461 const char *id = gaim_request_field_get_id(field); | |
462 const char *value = gaim_request_field_string_get_value(field); | |
463 | |
464 if(!strcmp(id, "username")) { | |
465 y = xmlnode_new_child(query, "username"); | |
466 } else if(!strcmp(id, "password")) { | |
467 y = xmlnode_new_child(query, "password"); | |
468 } else if(!strcmp(id, "name")) { | |
469 y = xmlnode_new_child(query, "name"); | |
470 } else if(!strcmp(id, "email")) { | |
471 y = xmlnode_new_child(query, "email"); | |
472 } else if(!strcmp(id, "nick")) { | |
473 y = xmlnode_new_child(query, "nick"); | |
474 } else if(!strcmp(id, "first")) { | |
475 y = xmlnode_new_child(query, "first"); | |
476 } else if(!strcmp(id, "last")) { | |
477 y = xmlnode_new_child(query, "last"); | |
478 } else if(!strcmp(id, "address")) { | |
479 y = xmlnode_new_child(query, "address"); | |
480 } else if(!strcmp(id, "city")) { | |
481 y = xmlnode_new_child(query, "city"); | |
482 } else if(!strcmp(id, "state")) { | |
483 y = xmlnode_new_child(query, "state"); | |
484 } else if(!strcmp(id, "zip")) { | |
485 y = xmlnode_new_child(query, "zip"); | |
486 } else if(!strcmp(id, "phone")) { | |
487 y = xmlnode_new_child(query, "phone"); | |
488 } else if(!strcmp(id, "url")) { | |
489 y = xmlnode_new_child(query, "url"); | |
490 } else if(!strcmp(id, "date")) { | |
491 y = xmlnode_new_child(query, "date"); | |
492 } else { | |
493 continue; | |
494 } | |
495 xmlnode_insert_data(y, value, -1); | |
7264 | 496 if(!strcmp(id, "username")) { |
497 if(js->user->node) | |
498 g_free(js->user->node); | |
499 js->user->node = g_strdup(value); | |
500 } | |
7072 | 501 } |
502 } | |
503 | |
7264 | 504 username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, |
505 js->user->resource); | |
506 gaim_account_set_username(js->gc->account, username); | |
507 g_free(username); | |
508 | |
7072 | 509 jabber_iq_set_callback(iq, jabber_registration_result_cb); |
510 | |
511 jabber_iq_send(iq); | |
512 | |
513 } | |
514 | |
515 static void | |
516 jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) | |
517 { | |
518 jabber_connection_schedule_close(js); | |
519 } | |
520 | |
521 void jabber_register_parse(JabberStream *js, xmlnode *packet) | |
522 { | |
523 if(js->registration) { | |
524 GaimRequestFields *fields; | |
525 GaimRequestFieldGroup *group; | |
526 GaimRequestField *field; | |
527 xmlnode *query, *y; | |
528 char *instructions; | |
529 | |
530 /* get rid of the login thingy */ | |
531 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
532 | |
533 query = xmlnode_get_child(packet, "query"); | |
534 | |
535 if(xmlnode_get_child(query, "registered")) { | |
536 gaim_notify_error(NULL, _("Already Registered"), | |
537 _("Already Registered"), NULL); | |
538 jabber_connection_schedule_close(js); | |
539 return; | |
540 } | |
541 | |
542 fields = gaim_request_fields_new(); | |
543 group = gaim_request_field_group_new(NULL); | |
544 gaim_request_fields_add_group(fields, group); | |
545 | |
546 field = gaim_request_field_string_new("username", _("Username"), | |
547 js->user->node, FALSE); | |
548 gaim_request_field_group_add_field(group, field); | |
549 | |
550 field = gaim_request_field_string_new("password", _("Password"), | |
551 gaim_account_get_password(js->gc->account), FALSE); | |
552 gaim_request_field_string_set_masked(field, TRUE); | |
553 gaim_request_field_group_add_field(group, field); | |
554 | |
555 if(xmlnode_get_child(query, "name")) { | |
556 field = gaim_request_field_string_new("name", _("Name"), | |
557 gaim_account_get_alias(js->gc->account), FALSE); | |
558 gaim_request_field_group_add_field(group, field); | |
559 } | |
560 if(xmlnode_get_child(query, "email")) { | |
561 field = gaim_request_field_string_new("email", _("E-Mail"), | |
562 NULL, FALSE); | |
563 gaim_request_field_group_add_field(group, field); | |
564 } | |
565 if(xmlnode_get_child(query, "nick")) { | |
566 field = gaim_request_field_string_new("nick", _("Nickname"), | |
567 NULL, FALSE); | |
568 gaim_request_field_group_add_field(group, field); | |
569 } | |
570 if(xmlnode_get_child(query, "first")) { | |
571 field = gaim_request_field_string_new("first", _("First Name"), | |
572 NULL, FALSE); | |
573 gaim_request_field_group_add_field(group, field); | |
574 } | |
575 if(xmlnode_get_child(query, "last")) { | |
576 field = gaim_request_field_string_new("last", _("Last Name"), | |
577 NULL, FALSE); | |
578 gaim_request_field_group_add_field(group, field); | |
579 } | |
580 if(xmlnode_get_child(query, "address")) { | |
581 field = gaim_request_field_string_new("address", _("Address"), | |
582 NULL, FALSE); | |
583 gaim_request_field_group_add_field(group, field); | |
584 } | |
585 if(xmlnode_get_child(query, "city")) { | |
586 field = gaim_request_field_string_new("city", _("City"), | |
587 NULL, FALSE); | |
588 gaim_request_field_group_add_field(group, field); | |
589 } | |
590 if(xmlnode_get_child(query, "state")) { | |
591 field = gaim_request_field_string_new("state", _("State"), | |
592 NULL, FALSE); | |
593 gaim_request_field_group_add_field(group, field); | |
594 } | |
595 if(xmlnode_get_child(query, "zip")) { | |
596 field = gaim_request_field_string_new("zip", _("Postal Code"), | |
597 NULL, FALSE); | |
598 gaim_request_field_group_add_field(group, field); | |
599 } | |
600 if(xmlnode_get_child(query, "phone")) { | |
601 field = gaim_request_field_string_new("phone", _("Phone"), | |
602 NULL, FALSE); | |
603 gaim_request_field_group_add_field(group, field); | |
604 } | |
605 if(xmlnode_get_child(query, "url")) { | |
606 field = gaim_request_field_string_new("url", _("URL"), | |
607 NULL, FALSE); | |
608 gaim_request_field_group_add_field(group, field); | |
609 } | |
610 if(xmlnode_get_child(query, "date")) { | |
611 field = gaim_request_field_string_new("date", _("Date"), | |
612 NULL, FALSE); | |
613 gaim_request_field_group_add_field(group, field); | |
614 } | |
615 | |
616 if((y = xmlnode_get_child(query, "instructions"))) | |
617 instructions = xmlnode_get_data(y); | |
618 else | |
619 instructions = g_strdup(_("Please fill out the information below " | |
620 "to register your new account.")); | |
621 | |
622 gaim_request_fields(js->gc, _("Register New Jabber Account"), | |
623 _("Register New Jabber Account"), instructions, fields, | |
624 _("Register"), G_CALLBACK(jabber_register_cb), | |
625 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); | |
626 } | |
627 } | |
628 | |
629 static void jabber_register_start(JabberStream *js) | |
630 { | |
631 JabberIq *iq; | |
632 | |
633 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); | |
634 jabber_iq_send(iq); | |
635 } | |
636 | |
637 static void jabber_register_account(GaimAccount *account) | |
638 { | |
639 GaimConnection *gc = gaim_account_get_connection(account); | |
640 JabberStream *js; | |
641 const char *connect_server = gaim_account_get_string(account, | |
642 "connect_server", ""); | |
643 const char *server; | |
644 int rc; | |
645 | |
646 js = gc->proto_data = g_new0(JabberStream, 1); | |
647 js->gc = gc; | |
648 js->registration = TRUE; | |
649 js->callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, | |
650 g_free, NULL); | |
651 js->user = jabber_id_new(gaim_account_get_username(account)); | |
652 | |
7147 | 653 if(!js->user->resource) { |
654 char *me; | |
655 js->user->resource = g_strdup("Gaim"); | |
656 if(!js->user->node) { | |
657 js->user->node = js->user->domain; | |
658 js->user->domain = g_strdup("jabber.org"); | |
659 } | |
660 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, | |
661 js->user->resource); | |
662 gaim_account_set_username(account, me); | |
663 g_free(me); | |
664 } | |
665 | |
7072 | 666 server = connect_server[0] ? connect_server : js->user->domain; |
667 | |
668 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); | |
669 | |
670 if(gaim_account_get_bool(account, "old_ssl", FALSE) | |
671 && gaim_ssl_is_supported()) { | |
672 js->gsc = gaim_ssl_connect(account, server, | |
673 gaim_account_get_int(account, "port", 5222), | |
7274
448e39ace278
[gaim-migrate @ 7851]
Christian Hammond <chipx86@chipx86.com>
parents:
7264
diff
changeset
|
674 jabber_login_callback_ssl, NULL, gc); |
7072 | 675 } |
676 | |
677 if(!js->gsc) { | |
678 rc = gaim_proxy_connect(account, server, | |
679 gaim_account_get_int(account, "port", 5222), | |
680 jabber_login_callback, gc); | |
681 | |
682 if (rc != 0) | |
683 gaim_connection_error(gc, _("Unable to create socket")); | |
684 } | |
685 } | |
686 | |
5572 | 687 static void jabber_close(GaimConnection *gc) |
2086 | 688 { |
7014 | 689 JabberStream *js = gc->proto_data; |
2956 | 690 |
7014 | 691 jabber_send_raw(js, "</stream:stream>"); |
3311 | 692 |
7014 | 693 if(js->gsc) { |
694 gaim_ssl_close(js->gsc); | |
695 } else { | |
7072 | 696 if(js->gc->inpa) |
697 gaim_input_remove(js->gc->inpa); | |
7014 | 698 close(js->fd); |
699 } | |
3311 | 700 |
7014 | 701 g_markup_parse_context_free(js->context); |
5093 | 702 |
7072 | 703 if(js->callbacks) |
704 g_hash_table_destroy(js->callbacks); | |
705 if(js->buddies) | |
706 g_hash_table_destroy(js->buddies); | |
707 if(js->chats) | |
708 g_hash_table_destroy(js->chats); | |
7014 | 709 if(js->stream_id) |
710 g_free(js->stream_id); | |
711 jabber_id_free(js->user); | |
712 g_free(js); | |
5093 | 713 } |
714 | |
7014 | 715 void jabber_stream_set_state(JabberStream *js, JabberStreamState state) |
3105 | 716 { |
7014 | 717 js->state = state; |
718 switch(state) { | |
719 case JABBER_STREAM_OFFLINE: | |
720 break; | |
721 case JABBER_STREAM_CONNECTING: | |
722 gaim_connection_update_progress(js->gc, _("Connecting"), 1, | |
723 JABBER_CONNECT_STEPS); | |
724 break; | |
725 case JABBER_STREAM_INITIALIZING: | |
726 gaim_connection_update_progress(js->gc, _("Initializing Stream"), | |
727 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); | |
728 jabber_stream_init(js); | |
729 jabber_parser_setup(js); | |
730 break; | |
731 case JABBER_STREAM_AUTHENTICATING: | |
732 gaim_connection_update_progress(js->gc, _("Authenticating"), | |
733 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); | |
7072 | 734 if(js->registration) |
735 jabber_register_start(js); | |
736 else if(js->protocol_version == JABBER_PROTO_0_9) | |
7014 | 737 jabber_auth_start_old(js); |
738 break; | |
739 case JABBER_STREAM_REINITIALIZING: | |
740 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), | |
741 6, JABBER_CONNECT_STEPS); | |
742 jabber_stream_init(js); | |
743 break; | |
744 case JABBER_STREAM_CONNECTED: | |
745 gaim_connection_set_state(js->gc, GAIM_CONNECTED); | |
746 jabber_roster_request(js); | |
747 jabber_presence_send(js->gc, js->gc->away_state, js->gc->away); | |
748 serv_finish_login(js->gc); | |
749 break; | |
3105 | 750 } |
751 } | |
752 | |
7014 | 753 char *jabber_get_next_id(JabberStream *js) |
2086 | 754 { |
7014 | 755 return g_strdup_printf("gaim%d", js->next_id++); |
2086 | 756 } |
757 | |
7014 | 758 void jabber_idle_set(GaimConnection *gc, int idle) |
3340 | 759 { |
7014 | 760 JabberStream *js = gc->proto_data; |
3340 | 761 |
7014 | 762 js->idle = idle ? time(NULL) - idle : idle; |
3314 | 763 } |
764 | |
6695 | 765 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) |
2086 | 766 { |
4687 | 767 return "jabber"; |
768 } | |
4916 | 769 |
7014 | 770 static void jabber_list_emblems(GaimBuddy *b, char **se, char **sw, |
771 char **nw, char **ne) | |
4916 | 772 { |
7014 | 773 JabberStream *js; |
774 JabberBuddy *jb; | |
775 | |
776 if(!b->account->gc) | |
777 return; | |
778 js = b->account->gc->proto_data; | |
779 jb = jabber_buddy_find(js, b->name, FALSE); | |
5135 | 780 |
781 if(!GAIM_BUDDY_IS_ONLINE(b)) { | |
7014 | 782 if(jb && jb->error_msg) |
4927 | 783 *nw = "error"; |
5135 | 784 |
7014 | 785 if(jb && (jb->subscription & JABBER_SUB_PENDING || |
786 !(jb->subscription & JABBER_SUB_TO))) | |
5135 | 787 *se = "notauthorized"; |
788 else | |
789 *se = "offline"; | |
4916 | 790 } else { |
791 switch (b->uc) { | |
7014 | 792 case JABBER_STATE_AWAY: |
793 *se = "away"; | |
794 break; | |
795 case JABBER_STATE_CHAT: | |
796 *se = "chat"; | |
797 break; | |
798 case JABBER_STATE_XA: | |
799 *se = "extendedaway"; | |
800 break; | |
801 case JABBER_STATE_DND: | |
802 *se = "extendedaway"; | |
803 break; | |
804 case JABBER_STATE_ERROR: | |
805 *se = "error"; | |
806 break; | |
4916 | 807 } |
2086 | 808 } |
4916 | 809 } |
2086 | 810 |
7014 | 811 static char *jabber_status_text(GaimBuddy *b) |
2205
cff4fbe01c7b
[gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
2170
diff
changeset
|
812 { |
7014 | 813 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
814 FALSE); | |
815 char *ret = NULL; | |
5234 | 816 |
7014 | 817 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { |
818 ret = g_strdup(_("Not Authorized")); | |
819 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { | |
820 ret = g_strdup(jb->error_msg); | |
2956 | 821 } else { |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
822 char *stripped; |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
823 |
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
824 stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)); |
2956 | 825 |
7014 | 826 if(!stripped && b->uc & UC_UNAVAILABLE) |
827 stripped = g_strdup(jabber_get_state_string(b->uc)); | |
2086 | 828 |
7014 | 829 if(stripped) { |
830 ret = g_markup_escape_text(stripped, -1); | |
831 g_free(stripped); | |
832 } | |
2086 | 833 } |
834 | |
7014 | 835 return ret; |
2956 | 836 } |
837 | |
6695 | 838 static char *jabber_tooltip_text(GaimBuddy *b) |
4744 | 839 { |
7014 | 840 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, |
841 FALSE); | |
842 JabberBuddyResource *jbr = jabber_buddy_find_resource(jb, NULL); | |
5135 | 843 char *ret = NULL; |
7014 | 844 |
845 if(jbr) { | |
4777 | 846 char *text = NULL; |
7014 | 847 if(jbr->status) { |
848 char *stripped; | |
7095
c8bf2da398e3
[gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents:
7072
diff
changeset
|
849 stripped = gaim_markup_strip_html(jbr->status); |
7014 | 850 text = g_markup_escape_text(stripped, -1); |
851 g_free(stripped); | |
852 } | |
853 | |
5236 | 854 ret = g_strdup_printf("<b>%s:</b> %s%s%s", |
855 _("Status"), | |
7014 | 856 jabber_get_state_string(jbr->state), |
857 text ? ": " : "", | |
4745 | 858 text ? text : ""); |
7014 | 859 if(text) |
4745 | 860 g_free(text); |
7014 | 861 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { |
862 ret = g_strdup_printf("<b>%s:</b> %s", | |
863 _("Error"), jb->error_msg); | |
864 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && | |
865 (jb->subscription & JABBER_SUB_PENDING || | |
866 !(jb->subscription & JABBER_SUB_TO))) { | |
867 ret = g_strdup_printf("<b>%s:</b> %s", | |
868 _("Status"), _("Not Authorized")); | |
4745 | 869 } |
4744 | 870 |
5135 | 871 return ret; |
4732 | 872 } |
873 | |
7014 | 874 static GList *jabber_away_states(GaimConnection *gc) |
875 { | |
2086 | 876 GList *m = NULL; |
877 | |
4982 | 878 m = g_list_append(m, _("Online")); |
879 m = g_list_append(m, _("Chatty")); | |
880 m = g_list_append(m, _("Away")); | |
881 m = g_list_append(m, _("Extended Away")); | |
882 m = g_list_append(m, _("Do Not Disturb")); | |
883 m = g_list_append(m, _("Invisible")); | |
4110 | 884 m = g_list_append(m, GAIM_AWAY_CUSTOM); |
2086 | 885 |
886 return m; | |
887 } | |
888 | |
7124 | 889 static void jabber_password_change_result_cb(JabberStream *js, xmlnode *packet) |
890 { | |
891 const char *type; | |
892 | |
893 type = xmlnode_get_attrib(packet, "type"); | |
894 | |
895 if(!strcmp(type, "result")) { | |
896 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), | |
897 _("Your password has been changed.")); | |
898 } else { | |
899 xmlnode *error; | |
900 char *buf, *error_txt = NULL; | |
901 | |
902 | |
903 if((error = xmlnode_get_child(packet, "error"))) | |
904 error_txt = xmlnode_get_data(error); | |
905 | |
906 if(error_txt) { | |
907 buf = g_strdup_printf(_("Error changing password: %s"), | |
908 error_txt); | |
909 g_free(error_txt); | |
910 } else { | |
911 buf = g_strdup(_("Unknown error occurred changing password")); | |
912 } | |
913 | |
914 gaim_notify_error(js->gc, _("Error"), _("Error"), buf); | |
915 g_free(buf); | |
916 } | |
917 } | |
918 | |
919 static void jabber_password_change_cb(JabberStream *js, | |
920 GaimRequestFields *fields) | |
921 { | |
922 const char *p1, *p2; | |
923 JabberIq *iq; | |
924 xmlnode *query, *y; | |
925 | |
926 p1 = gaim_request_fields_get_string(fields, "password1"); | |
927 p2 = gaim_request_fields_get_string(fields, "password2"); | |
928 | |
929 if(strcmp(p1, p2)) { | |
930 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); | |
931 return; | |
932 } | |
933 | |
934 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); | |
935 | |
936 xmlnode_set_attrib(iq->node, "to", js->user->domain); | |
937 | |
938 query = xmlnode_get_child(iq->node, "query"); | |
939 | |
940 y = xmlnode_new_child(query, "username"); | |
941 xmlnode_insert_data(y, js->user->node, -1); | |
942 y = xmlnode_new_child(query, "password"); | |
943 xmlnode_insert_data(y, p1, -1); | |
944 | |
945 jabber_iq_set_callback(iq, jabber_password_change_result_cb); | |
946 | |
947 jabber_iq_send(iq); | |
948 | |
949 gaim_account_set_password(js->gc->account, p1); | |
950 } | |
951 | |
952 static void jabber_password_change(GaimConnection *gc) | |
953 { | |
954 JabberStream *js = gc->proto_data; | |
955 GaimRequestFields *fields; | |
956 GaimRequestFieldGroup *group; | |
957 GaimRequestField *field; | |
958 | |
959 fields = gaim_request_fields_new(); | |
960 group = gaim_request_field_group_new(NULL); | |
961 gaim_request_fields_add_group(fields, group); | |
962 | |
963 field = gaim_request_field_string_new("password1", _("Password"), | |
964 "", FALSE); | |
965 gaim_request_field_string_set_masked(field, TRUE); | |
966 gaim_request_field_group_add_field(group, field); | |
967 | |
968 field = gaim_request_field_string_new("password2", _("Password (again)"), | |
969 "", FALSE); | |
970 gaim_request_field_string_set_masked(field, TRUE); | |
971 gaim_request_field_group_add_field(group, field); | |
972 | |
973 gaim_request_fields(js->gc, _("Change Jabber Password"), | |
974 _("Change Jabber Password"), _("Please enter your new password"), | |
975 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), | |
976 _("Cancel"), NULL, js); | |
977 } | |
978 | |
5572 | 979 static GList *jabber_actions(GaimConnection *gc) |
2956 | 980 { |
7124 | 981 JabberStream *js = gc->proto_data; |
2956 | 982 GList *m = NULL; |
4333 | 983 struct proto_actions_menu *pam; |
984 | |
985 pam = g_new0(struct proto_actions_menu, 1); | |
986 pam->label = _("Set User Info"); | |
987 pam->callback = jabber_setup_set_info; | |
988 pam->gc = gc; | |
989 m = g_list_append(m, pam); | |
990 | |
7124 | 991 if(js->protocol_version == JABBER_PROTO_0_9) { |
992 pam = g_new0(struct proto_actions_menu, 1); | |
993 pam->label = _("Change Password"); | |
994 pam->callback = jabber_password_change; | |
995 pam->gc = gc; | |
996 m = g_list_append(m, pam); | |
997 } | |
2956 | 998 |
999 return m; | |
1000 } | |
1001 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1002 static GaimPluginProtocolInfo prpl_info = |
2086 | 1003 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1004 GAIM_PROTO_JABBER, |
7014 | 1005 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1006 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1007 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1008 jabber_list_icon, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1009 jabber_list_emblems, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1010 jabber_status_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1011 jabber_tooltip_text, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1012 jabber_away_states, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1013 jabber_actions, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1014 jabber_buddy_menu, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1015 jabber_chat_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1016 jabber_login, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1017 jabber_close, |
7014 | 1018 jabber_message_send_im, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1019 jabber_set_info, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1020 jabber_send_typing, |
7014 | 1021 jabber_buddy_get_info, |
1022 jabber_presence_send, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1023 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1024 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1025 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1026 NULL, |
7014 | 1027 jabber_idle_set, |
1028 NULL, /* change_passwd */ /* XXX */ | |
1029 jabber_roster_add_buddy, | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1030 NULL, |
7014 | 1031 jabber_roster_remove_buddy, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1032 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1033 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1034 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1035 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1036 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1037 NULL, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1038 NULL, |
7014 | 1039 jabber_chat_join, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1040 jabber_chat_invite, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1041 jabber_chat_leave, |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1042 jabber_chat_whisper, |
7014 | 1043 jabber_message_send_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1044 jabber_keepalive, |
7072 | 1045 jabber_register_account, |
7014 | 1046 jabber_buddy_get_info_chat, |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1047 NULL, |
7014 | 1048 jabber_roster_alias_change, |
1049 jabber_roster_group_change, | |
1050 jabber_roster_group_rename, | |
1051 NULL, | |
1052 NULL, /* convo_closed */ /* XXX: thread_ids */ | |
7261 | 1053 jabber_normalize /* normalize */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1054 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1055 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1056 static GaimPluginInfo info = |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1057 { |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1058 2, /**< api_version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1059 GAIM_PLUGIN_PROTOCOL, /**< type */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1060 NULL, /**< ui_requirement */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1061 0, /**< flags */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1062 NULL, /**< dependencies */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1063 GAIM_PRIORITY_DEFAULT, /**< priority */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1064 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1065 "prpl-jabber", /**< id */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1066 "Jabber", /**< name */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1067 VERSION, /**< version */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1068 /** summary */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1069 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1070 /** description */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1071 N_("Jabber Protocol Plugin"), |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1072 NULL, /**< author */ |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6357
diff
changeset
|
1073 GAIM_WEBSITE, /**< homepage */ |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1074 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1075 NULL, /**< load */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1076 NULL, /**< unload */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1077 NULL, /**< destroy */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1078 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1079 NULL, /**< ui_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1080 &prpl_info /**< extra_info */ |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1081 }; |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1082 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1083 static void |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1084 init_plugin(GaimPlugin *plugin) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1085 { |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1086 GaimAccountUserSplit *split; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1087 GaimAccountOption *option; |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1088 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1089 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1090 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1091 |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1092 split = gaim_account_user_split_new(_("Resource"), "Gaim", '/'); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1093 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); |
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1094 |
7124 | 1095 option = gaim_account_option_bool_new(_("Force Old SSL"), "old_ssl", FALSE); |
1096 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, | |
1097 option); | |
6764 | 1098 |
7014 | 1099 option = gaim_account_option_int_new(_("Port"), "port", 5222); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1100 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1101 option); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1102 |
5685
43ea75092684
[gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents:
5681
diff
changeset
|
1103 option = gaim_account_option_string_new(_("Connect server"), |
7014 | 1104 "connect_server", NULL); |
5638
0bdfa28c678e
[gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents:
5613
diff
changeset
|
1105 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, |
7014 | 1106 option); |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1107 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5174
diff
changeset
|
1108 my_protocol = plugin; |
7014 | 1109 |
1110 gaim_prefs_add_none("/plugins/prpl/jabber"); | |
1111 gaim_prefs_add_bool("/plugins/prpl/jabber/hide_os", FALSE); | |
2086 | 1112 } |
1113 | |
5920
7d385de2f9cd
[gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents:
5894
diff
changeset
|
1114 GAIM_INIT_PLUGIN(jabber, init_plugin, info); |