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