annotate src/protocols/jabber/jabber.c @ 8042:7fa6ddec6e30

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