annotate src/protocols/jabber/jabber.c @ 13242:cdd107258f11

[gaim-migrate @ 15608] Special handling of disconnection when we were forcibly disconnected is only needed when using OpenSSL, since Mozilla NSS and GnuTLS work fine. I moved the special handling into #ifdef HAVE_OPENSSL blocks and added avoidance of calling gaim_ssl_close() when we were forcibly disconnected since it also causes a crash. Not calling gaim_ssl_close() means that every forced disconnection when using OpenSSL will leak the host name string, since that's released ingaim_ssl_close()... a small leak is prefereable to a crash, but not optimal. committer: Tailor Script <tailor@pidgin.im>
author Evan Schoenberg <evan.s@dreskin.net>
date Sun, 12 Feb 2006 16:25:54 +0000
parents b0d020a66144
children 6ae034aa4485
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"
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
25 #include "blist.h"
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
26 #include "cmds.h"
10740
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
27 #include "connection.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
28 #include "debug.h"
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
29 #include "dnssrv.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
30 #include "message.h"
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
31 #include "notify.h"
8713
7024b595b6ae [gaim-migrate @ 9467]
Luke Schierer <lschiere@pidgin.im>
parents: 8591
diff changeset
32 #include "pluginpref.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
33 #include "prpl.h"
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
34 #include "request.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
35 #include "server.h"
7095
c8bf2da398e3 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7072
diff changeset
36 #include "util.h"
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
37 #include "version.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
38
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
39 #include "auth.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
40 #include "buddy.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
41 #include "chat.h"
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
42 #include "disco.h"
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
43 #include "iq.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
44 #include "jutil.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
45 #include "message.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
46 #include "parser.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
47 #include "presence.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
48 #include "jabber.h"
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
49 #include "roster.h"
9466
d27156c9c876 [gaim-migrate @ 10291]
Luke Schierer <lschiere@pidgin.im>
parents: 9414
diff changeset
50 #include "si.h"
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
51 #include "xdata.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5685
diff changeset
52
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
53 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
55 static GaimPlugin *my_protocol = NULL;
4249
9c7fcb211886 [gaim-migrate @ 4499]
Mark Doliner <mark@kingant.net>
parents: 4245
diff changeset
56
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
57 static void jabber_stream_init(JabberStream *js)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
58 {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
59 char *open_stream;
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
60
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
61 open_stream = g_strdup_printf("<stream:stream to='%s' "
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
62 "xmlns='jabber:client' "
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
63 "xmlns:stream='http://etherx.jabber.org/streams' "
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
64 "version='1.0'>",
7291
632cee95cc5c [gaim-migrate @ 7872]
Nathan Walp <nwalp@pidgin.im>
parents: 7274
diff changeset
65 js->user->domain);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
66
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
67 jabber_send_raw(js, open_stream, -1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
69 g_free(open_stream);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
72 static void
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
73 jabber_session_initialized_cb(JabberStream *js, xmlnode *packet, gpointer data)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
74 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
75 const char *type = xmlnode_get_attrib(packet, "type");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
76 if(type && !strcmp(type, "result")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
77 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
78 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
79 gaim_connection_error(js->gc, _("Error initializing session"));
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
80 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
81 }
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 static void jabber_session_init(JabberStream *js)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
84 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
85 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
86 xmlnode *session;
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
87
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
88 jabber_iq_set_callback(iq, jabber_session_initialized_cb, NULL);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
89
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
90 session = xmlnode_new_child(iq->node, "session");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
91 xmlnode_set_attrib(session, "xmlns", "urn:ietf:params:xml:ns:xmpp-session");
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
92
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
93 jabber_iq_send(iq);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
94 }
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
95
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
96 static void jabber_bind_result_cb(JabberStream *js, xmlnode *packet,
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
97 gpointer data)
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
98 {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
99 const char *type = xmlnode_get_attrib(packet, "type");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
100 xmlnode *bind;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
101
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
102 if(type && !strcmp(type, "result") &&
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
103 (bind = xmlnode_get_child_with_namespace(packet, "bind", "urn:ietf:params:xml:ns:xmpp-bind"))) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
104 xmlnode *jid;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
105 char *full_jid;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
106 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) {
10289
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
107 JabberBuddy *my_jb = NULL;
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
108 jabber_id_free(js->user);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
109 if(!(js->user = jabber_id_new(full_jid))) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
110 gaim_connection_error(js->gc, _("Invalid response from server."));
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
111 }
10289
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
112 if((my_jb = jabber_buddy_find(js, full_jid, TRUE)))
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
113 my_jb->subscription |= JABBER_SUB_BOTH;
10504
1a97d5e88d12 [gaim-migrate @ 11796]
Stu Tomlinson <stu@nosnilmot.com>
parents: 10490
diff changeset
114 g_free(full_jid);
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
115 }
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
116 } else {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
117 char *msg = jabber_parse_error(js, packet);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
118 gaim_connection_error(js->gc, msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
119 g_free(msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
120 }
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
121
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
122 jabber_session_init(js);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
123 }
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
124
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
125 static void jabber_stream_features_parse(JabberStream *js, xmlnode *packet)
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
126 {
8296
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
127 if(xmlnode_get_child(packet, "starttls")) {
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
128 if(jabber_process_starttls(js, packet))
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
129 return;
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
130 }
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
131
10988
27f0322f06f7 [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
132 if(js->registration) {
27f0322f06f7 [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
133 jabber_register_start(js);
27f0322f06f7 [gaim-migrate @ 12825]
Nathan Walp <nwalp@pidgin.im>
parents: 10941
diff changeset
134 } else if(xmlnode_get_child(packet, "mechanisms")) {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
135 jabber_auth_start(js, packet);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
136 } else if(xmlnode_get_child(packet, "bind")) {
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
137 xmlnode *bind, *resource;
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
138 JabberIq *iq = jabber_iq_new(js, JABBER_IQ_SET);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
139 bind = xmlnode_new_child(iq->node, "bind");
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
140 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
141 resource = xmlnode_new_child(bind, "resource");
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
142 xmlnode_insert_data(resource, js->user->resource, -1);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
143
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
144 jabber_iq_set_callback(iq, jabber_bind_result_cb, NULL);
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
145
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
146 jabber_iq_send(iq);
8296
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
147 } else /* if(xmlnode_get_child_with_namespace(packet, "auth")) */ {
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
148 /* If we get an empty stream:features packet, or we explicitly get
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
149 * an auth feature with namespace http://jabber.org/features/iq-auth
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
150 * we should revert back to iq:auth authentication, even though we're
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
151 * connecting to an XMPP server. */
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
152 js->auth_type = JABBER_AUTH_IQ_AUTH;
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
153 jabber_stream_set_state(js, JABBER_STREAM_AUTHENTICATING);
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
154 }
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
155 }
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
156
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
157 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet)
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
158 {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
159 char *msg = jabber_parse_error(js, packet);
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
160
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
161 gaim_connection_error(js->gc, msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
162 g_free(msg);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
165 static void tls_init(JabberStream *js);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
167 void jabber_process_packet(JabberStream *js, xmlnode *packet)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
169 if(!strcmp(packet->name, "iq")) {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
170 jabber_iq_parse(js, packet);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
171 } else if(!strcmp(packet->name, "presence")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
172 jabber_presence_parse(js, packet);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
173 } else if(!strcmp(packet->name, "message")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
174 jabber_message_parse(js, packet);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
175 } else if(!strcmp(packet->name, "stream:features")) {
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
176 jabber_stream_features_parse(js, packet);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
177 } else if(!strcmp(packet->name, "stream:error")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
178 jabber_stream_handle_error(js, packet);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
179 } else if(!strcmp(packet->name, "challenge")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
180 if(js->state == JABBER_STREAM_AUTHENTICATING)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
181 jabber_auth_handle_challenge(js, packet);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
182 } else if(!strcmp(packet->name, "success")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
183 if(js->state == JABBER_STREAM_AUTHENTICATING)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
184 jabber_auth_handle_success(js, packet);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
185 } else if(!strcmp(packet->name, "failure")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
186 if(js->state == JABBER_STREAM_AUTHENTICATING)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
187 jabber_auth_handle_failure(js, packet);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
188 } else if(!strcmp(packet->name, "proceed")) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
189 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
190 tls_init(js);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
191 } else {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
192 gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n",
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
193 packet->name);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
197 static int jabber_do_send(JabberStream *js, const char *data, int len)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
198 {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
199 int ret;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
201 if (js->gsc)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
202 ret = gaim_ssl_write(js->gsc, data, len);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
203 else
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
204 ret = write(js->fd, data, len);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
205
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
206 return ret;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
207 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
208
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
209 static void jabber_send_cb(gpointer data, gint source, GaimInputCondition cond)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
210 {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
211 JabberStream *js = data;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
212 int ret, writelen;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
213 writelen = gaim_circ_buffer_get_max_read(js->write_buffer);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
214
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
215 if (writelen == 0) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
216 gaim_input_remove(js->writeh);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
217 js->writeh = -1;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
218 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
219 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
220
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
221 ret = jabber_do_send(js, js->write_buffer->outptr, writelen);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
222
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
223 if (ret < 0 && errno == EAGAIN)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
224 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
225 else if (ret <= 0) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
226 gaim_connection_error(js->gc, _("Write error"));
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
227 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
228 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
229
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
230 gaim_circ_buffer_mark_read(js->write_buffer, ret);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
231 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
232
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
233 void jabber_send_raw(JabberStream *js, const char *data, int len)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
235 int ret;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
237 /* because printing a tab to debug every minute gets old */
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
238 if(strcmp(data, "\t"))
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
239 gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n",
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
240 js->gsc ? " (ssl)" : "", data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241
12508
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
242 /* If we've got a security layer, we need to encode the data,
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
243 * splitting it on the maximum buffer length negotiated */
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
244
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
245 #ifdef HAVE_CYRUS_SASL
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
246 if (js->sasl_maxbuf>0) {
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
247 int pos;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
248
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
249 if (!js->gsc && js->fd<0)
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
250 return;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
251 pos = 0;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
252 if (len == -1)
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
253 len = strlen(data);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
254 while (pos < len) {
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
255 int towrite;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
256 const char *out;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
257 unsigned olen;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
258
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
259 if ((len - pos) < js->sasl_maxbuf)
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
260 towrite = len - pos;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
261 else
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
262 towrite = js->sasl_maxbuf;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
263
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
264 sasl_encode(js->sasl, &data[pos], towrite, &out, &olen);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
265 pos += towrite;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
266
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
267 if (js->writeh != -1)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
268 ret = jabber_do_send(js, out, olen);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
269 else {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
270 ret = -1;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
271 errno = EAGAIN;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
272 }
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
273
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
274 if (ret < 0 && errno != EAGAIN)
12508
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
275 gaim_connection_error(js->gc, _("Write error"));
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
276 else if (ret < olen) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
277 if (ret < 0)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
278 ret = 0;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
279 if (js->writeh == -1)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
280 js->writeh = gaim_input_add(
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
281 js->gsc ? js->gsc->fd : js->fd,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
282 GAIM_INPUT_WRITE,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
283 jabber_send_cb, js);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
284 gaim_circ_buffer_append(js->write_buffer,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
285 out + ret, olen - ret);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
286 }
12508
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
287 }
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
288 return;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
289 }
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
290 #endif
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
291
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
292 if (len == -1)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
293 len = strlen(data);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
294
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
295 if (js->writeh == -1)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
296 ret = jabber_do_send(js, data, len);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
297 else {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
298 ret = -1;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
299 errno = EAGAIN;
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
300 }
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
301
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
302 if (ret < 0 && errno != EAGAIN)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
303 gaim_connection_error(js->gc, _("Write error"));
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
304 else if (ret < len) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
305 if (ret < 0)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
306 ret = 0;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
307 if (js->writeh == -1)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
308 js->writeh = gaim_input_add(
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
309 js->gsc ? js->gsc->fd : js->fd,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
310 GAIM_INPUT_WRITE, jabber_send_cb, js);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
311 gaim_circ_buffer_append(js->write_buffer,
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
312 data + ret, len - ret);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
313 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
314
2814
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
315 }
f4f9e5a01890 [gaim-migrate @ 2827]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2800
diff changeset
316
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
317 void jabber_send(JabberStream *js, xmlnode *packet)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
319 char *txt;
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
320 int len;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
322 txt = xmlnode_to_str(packet, &len);
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
323 jabber_send_raw(js, txt, len);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
324 g_free(txt);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 }
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 static void jabber_keepalive(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 {
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
329 jabber_send_raw(gc->proto_data, "\t", -1);
2086
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 static void
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
333 jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc,
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
334 GaimInputCondition cond)
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
335 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
336 GaimConnection *gc = data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
337 JabberStream *js = gc->proto_data;
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
338 int len;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
339 static char buf[4096];
6768
d6b8bf263903 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
340
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
341 if(!g_list_find(gaim_connections_get_all(), gc)) {
6768
d6b8bf263903 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
342 gaim_ssl_close(gsc);
d6b8bf263903 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
343 return;
d6b8bf263903 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
344 }
d6b8bf263903 [gaim-migrate @ 7305]
Nathan Walp <nwalp@pidgin.im>
parents: 6764
diff changeset
345
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
346 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
347 buf[len] = '\0';
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
348 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
349 jabber_parser_process(js, buf, len);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
350 } else if(errno == EAGAIN)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
351 return;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
352 else {
7177
4200828dc06c [gaim-migrate @ 7745]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
353 gaim_connection_error(gc, _("Read Error"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
357 static void
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
358 jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
360 GaimConnection *gc = data;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
361 JabberStream *js = gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
362 int len;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
363 static char buf[4096];
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
365 if(!g_list_find(gaim_connections_get_all(), gc))
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
366 return;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
367
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
368 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
12508
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
369 #ifdef HAVE_CYRUS_SASL
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
370 if (js->sasl_maxbuf>0) {
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
371 const char *out;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
372 int olen;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
373 sasl_decode(js->sasl, buf, len, &out, &olen);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
374 if (olen>0) {
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
375 gaim_debug(GAIM_DEBUG_INFO, "jabber", "RecvSASL (%d): %s\n", olen, out);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
376 jabber_parser_process(js,out,olen);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
377 }
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
378 return;
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
379 }
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
380 #endif
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
381 buf[len] = '\0';
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
382 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
383 jabber_parser_process(js, buf, len);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
384 } else if(errno == EAGAIN) {
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
385 return;
7177
4200828dc06c [gaim-migrate @ 7745]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
386 } else {
4200828dc06c [gaim-migrate @ 7745]
Nathan Walp <nwalp@pidgin.im>
parents: 7147
diff changeset
387 gaim_connection_error(gc, _("Read Error"));
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
388 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
391 static void
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
392 jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc,
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
393 GaimInputCondition cond)
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
394 {
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
395 GaimConnection *gc = data;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
396 JabberStream *js = gc->proto_data;
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
397
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
398 if(!g_list_find(gaim_connections_get_all(), gc)) {
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
399 gaim_ssl_close(gsc);
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
400 return;
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
401 }
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
402
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
403 js->gsc = gsc;
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
404
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
405 if(js->state == JABBER_STREAM_CONNECTING)
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
406 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
407
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
408 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
409 gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
410 }
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
411
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
412
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
413 static void
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
414 jabber_login_callback(gpointer data, gint source, GaimInputCondition cond)
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
415 {
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
416 GaimConnection *gc = data;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
417 JabberStream *js = gc->proto_data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418
8783
ab295b8a95a0 [gaim-migrate @ 9545]
Mark Doliner <mark@kingant.net>
parents: 8778
diff changeset
419 if (source < 0) {
ab295b8a95a0 [gaim-migrate @ 9545]
Mark Doliner <mark@kingant.net>
parents: 8778
diff changeset
420 gaim_connection_error(gc, _("Couldn't connect to host"));
ab295b8a95a0 [gaim-migrate @ 9545]
Mark Doliner <mark@kingant.net>
parents: 8778
diff changeset
421 return;
ab295b8a95a0 [gaim-migrate @ 9545]
Mark Doliner <mark@kingant.net>
parents: 8778
diff changeset
422 }
ab295b8a95a0 [gaim-migrate @ 9545]
Mark Doliner <mark@kingant.net>
parents: 8778
diff changeset
423
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
424 if(!g_list_find(gaim_connections_get_all(), gc)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 close(source);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 return;
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
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
429 js->fd = source;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
430
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
431 if(js->state == JABBER_STREAM_CONNECTING)
7642
9008b5be4275 [gaim-migrate @ 8285]
Nathan Walp <nwalp@pidgin.im>
parents: 7630
diff changeset
432 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
2300
d2686f757d6e [gaim-migrate @ 2310]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2289
diff changeset
433
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
434 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
435 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
436 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
438 static void
7426
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
439 jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error,
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
440 gpointer data)
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
441 {
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
442 GaimConnection *gc = data;
8360
8d012c803411 [gaim-migrate @ 9084]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
443 JabberStream *js = gc->proto_data;
7426
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
444
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
445 switch(error) {
8362
1976914caa51 [gaim-migrate @ 9087]
Nathan Walp <nwalp@pidgin.im>
parents: 8360
diff changeset
446 case GAIM_SSL_CONNECT_FAILED:
1976914caa51 [gaim-migrate @ 9087]
Nathan Walp <nwalp@pidgin.im>
parents: 8360
diff changeset
447 gaim_connection_error(gc, _("Connection Failed"));
1976914caa51 [gaim-migrate @ 9087]
Nathan Walp <nwalp@pidgin.im>
parents: 8360
diff changeset
448 break;
7426
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
449 case GAIM_SSL_HANDSHAKE_FAILED:
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
450 gaim_connection_error(gc, _("SSL Handshake Failed"));
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
451 break;
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
452 }
8360
8d012c803411 [gaim-migrate @ 9084]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
453
8d012c803411 [gaim-migrate @ 9084]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
454 js->gsc = NULL;
7426
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
455 }
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
456
7427
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
457 static void tls_init(JabberStream *js)
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
458 {
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
459 gaim_input_remove(js->gc->inpa);
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
460 js->gc->inpa = 0;
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
461 js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd,
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
462 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc);
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
463 }
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
464
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
465 static void jabber_login_connect(JabberStream *js, const char *server, int port)
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
466 {
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
467 int rc;
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
468
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
469 rc = gaim_proxy_connect(js->gc->account, server,
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
470 port, jabber_login_callback, js->gc);
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
471
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
472 if (rc != 0)
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
473 gaim_connection_error(js->gc, _("Unable to create socket"));
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
474 }
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
475
12686
5f65a0cca87c [gaim-migrate @ 15029]
Richard Laager <rlaager@wiktel.com>
parents: 12658
diff changeset
476 static void srv_resolved_cb(GaimSrvResponse *resp, int results, gpointer data)
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
477 {
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
478 JabberStream *js = (JabberStream*)data;
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
479
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
480 if(results) {
12810
b0ede7907dd0 [gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12686
diff changeset
481 jabber_login_connect(js, resp->hostname, resp->port);
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
482 g_free(resp);
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
483 } else {
12810
b0ede7907dd0 [gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12686
diff changeset
484 jabber_login_connect(js, js->user->domain,
b0ede7907dd0 [gaim-migrate @ 15158]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 12686
diff changeset
485 gaim_account_get_int(js->gc->account, "port", 0));
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
486 }
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
487 }
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
488
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
489
7427
30bbf20b4ef1 [gaim-migrate @ 8030]
Nathan Walp <nwalp@pidgin.im>
parents: 7426
diff changeset
490
7426
d3711f98f568 [gaim-migrate @ 8029]
Nathan Walp <nwalp@pidgin.im>
parents: 7417
diff changeset
491 static void
11837
fa742ad8068c [gaim-migrate @ 14128]
Mark Doliner <mark@kingant.net>
parents: 11675
diff changeset
492 jabber_login(GaimAccount *account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
494 GaimConnection *gc = gaim_account_get_connection(account);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
495 const char *connect_server = gaim_account_get_string(account,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
496 "connect_server", "");
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
497 JabberStream *js;
10289
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
498 JabberBuddy *my_jb = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
500 gc->flags |= GAIM_CONNECTION_HTML;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
501 js = gc->proto_data = g_new0(JabberStream, 1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
502 js->gc = gc;
8013
03a689c3b3b7 [gaim-migrate @ 8693]
Nathan Walp <nwalp@pidgin.im>
parents: 8011
diff changeset
503 js->fd = -1;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
504 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
505 g_free, g_free);
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
506 js->disco_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
507 g_free, g_free);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
508 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
509 g_free, (GDestroyNotify)jabber_buddy_free);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
510 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal,
8396
387ba791d5f9 [gaim-migrate @ 9125]
Nathan Walp <nwalp@pidgin.im>
parents: 8362
diff changeset
511 g_free, (GDestroyNotify)jabber_chat_free);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
512 js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org"));
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
513 js->user = jabber_id_new(gaim_account_get_username(account));
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
514 js->next_id = g_random_int();
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
515 js->write_buffer = gaim_circ_buffer_new(512);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
516 js->writeh = -1;
5613
3d0a2b9f5a8e [gaim-migrate @ 6019]
Nathan Walp <nwalp@pidgin.im>
parents: 5599
diff changeset
517
7310
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
518 if(!js->user) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
519 gaim_connection_error(gc, _("Invalid Jabber ID"));
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
520 return;
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
521 }
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
522
7147
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
523 if(!js->user->resource) {
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
524 char *me;
11939
85c25a32bb48 [gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11837
diff changeset
525 js->user->resource = g_strdup("Home");
7147
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
526 if(!js->user->node) {
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
527 js->user->node = js->user->domain;
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
528 js->user->domain = g_strdup("jabber.org");
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
529 }
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
530 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
531 js->user->resource);
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
532 gaim_account_set_username(account, me);
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
533 g_free(me);
7145
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7124
diff changeset
534 }
0e4894b3e2a6 [gaim-migrate @ 7712]
Nathan Walp <nwalp@pidgin.im>
parents: 7124
diff changeset
535
10289
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
536 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE)))
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
537 my_jb->subscription |= JABBER_SUB_BOTH;
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
538
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
539 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
540
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
541 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
542 if(gaim_account_get_bool(js->gc->account, "old_ssl", FALSE)) {
7630
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
543 if(gaim_ssl_is_supported()) {
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
544 js->gsc = gaim_ssl_connect(js->gc->account,
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
545 connect_server[0] ? connect_server : js->user->domain,
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
546 gaim_account_get_int(account, "port", 5223), jabber_login_callback_ssl,
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
547 jabber_ssl_connect_failure, js->gc);
7630
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
548 } else {
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
549 gaim_connection_error(js->gc, _("SSL support unavailable"));
7630
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
550 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
551 }
3770
a72e303e6f5c [gaim-migrate @ 3909]
Sean Egan <seanegan@gmail.com>
parents: 3769
diff changeset
552
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
553 /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
554 * invoke the magic of SRV lookups, to figure out host and port */
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
555 if(!js->gsc) {
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
556 if(connect_server[0]) {
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
557 jabber_login_connect(js, connect_server, gaim_account_get_int(account, "port", 5222));
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
558 } else {
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
559 gaim_srv_resolve("xmpp-client", "tcp", js->user->domain, srv_resolved_cb, js);
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
560 }
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
561 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
564
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
565 static gboolean
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
566 conn_close_cb(gpointer data)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
567 {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
568 JabberStream *js = data;
10740
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
569 GaimAccount *account = gaim_connection_get_account(js->gc);
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
570
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
571 gaim_account_disconnect(account);
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
572
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
573 return FALSE;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
574 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
575
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
576 static void
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
577 jabber_connection_schedule_close(JabberStream *js)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
578 {
8273
f24172f53650 [gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents: 8194
diff changeset
579 gaim_timeout_add(0, conn_close_cb, js);
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
580 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
581
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
582 static void
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
583 jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
7072
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 const char *type = xmlnode_get_attrib(packet, "type");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
586 char *buf;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
587
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
588 if(!strcmp(type, "result")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
589 buf = g_strdup_printf(_("Registration of %s@%s successful"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
590 js->user->node, js->user->domain);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
591 gaim_notify_info(NULL, _("Registration Successful"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
592 _("Registration Successful"), buf);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
593 g_free(buf);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
594 } else {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
595 char *msg = jabber_parse_error(js, packet);
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
596
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
597 if(!msg)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
598 msg = g_strdup(_("Unknown Error"));
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
599
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
600 gaim_notify_error(NULL, _("Registration Failed"),
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
601 _("Registration Failed"), msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
602 g_free(msg);
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
603 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
604 jabber_connection_schedule_close(js);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
605 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
606
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
607 static void
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
608 jabber_register_cb(JabberStream *js, GaimRequestFields *fields)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
609 {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
610 GList *groups, *flds;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
611 xmlnode *query, *y;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
612 JabberIq *iq;
7264
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
613 char *username;
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
614
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
615 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
616 query = xmlnode_get_child(iq->node, "query");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
617
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
618 for(groups = gaim_request_fields_get_groups(fields); groups;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
619 groups = groups->next) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
620 for(flds = gaim_request_field_group_get_fields(groups->data);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
621 flds; flds = flds->next) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
622 GaimRequestField *field = flds->data;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
623 const char *id = gaim_request_field_get_id(field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
624 const char *value = gaim_request_field_string_get_value(field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
625
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
626 if(!strcmp(id, "username")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
627 y = xmlnode_new_child(query, "username");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
628 } else if(!strcmp(id, "password")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
629 y = xmlnode_new_child(query, "password");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
630 } else if(!strcmp(id, "name")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
631 y = xmlnode_new_child(query, "name");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
632 } else if(!strcmp(id, "email")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
633 y = xmlnode_new_child(query, "email");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
634 } else if(!strcmp(id, "nick")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
635 y = xmlnode_new_child(query, "nick");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
636 } else if(!strcmp(id, "first")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
637 y = xmlnode_new_child(query, "first");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
638 } else if(!strcmp(id, "last")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
639 y = xmlnode_new_child(query, "last");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
640 } else if(!strcmp(id, "address")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
641 y = xmlnode_new_child(query, "address");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
642 } else if(!strcmp(id, "city")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
643 y = xmlnode_new_child(query, "city");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
644 } else if(!strcmp(id, "state")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
645 y = xmlnode_new_child(query, "state");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
646 } else if(!strcmp(id, "zip")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
647 y = xmlnode_new_child(query, "zip");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
648 } else if(!strcmp(id, "phone")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
649 y = xmlnode_new_child(query, "phone");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
650 } else if(!strcmp(id, "url")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
651 y = xmlnode_new_child(query, "url");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
652 } else if(!strcmp(id, "date")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
653 y = xmlnode_new_child(query, "date");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
654 } else {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
655 continue;
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 xmlnode_insert_data(y, value, -1);
7264
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
658 if(!strcmp(id, "username")) {
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
659 if(js->user->node)
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
660 g_free(js->user->node);
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
661 js->user->node = g_strdup(value);
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
662 }
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
663 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
664 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
665
7264
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
666 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
667 js->user->resource);
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
668 gaim_account_set_username(js->gc->account, username);
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
669 g_free(username);
deab8d8bbb4e [gaim-migrate @ 7841]
Nathan Walp <nwalp@pidgin.im>
parents: 7261
diff changeset
670
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
671 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL);
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
672
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
673 jabber_iq_send(iq);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
674
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
675 }
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 static void
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
678 jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
679 {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
680 jabber_connection_schedule_close(js);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
681 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
682
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
683 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
684 {
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
685 xmlnode *query;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
686 JabberIq *iq;
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
687
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
688 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
689 query = xmlnode_get_child(iq->node, "query");
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
690
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
691 xmlnode_insert_child(query, result);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
692
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
693 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
694 jabber_iq_send(iq);
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
695 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
696
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
697 void jabber_register_parse(JabberStream *js, xmlnode *packet)
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 if(js->registration) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
700 GaimRequestFields *fields;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
701 GaimRequestFieldGroup *group;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
702 GaimRequestField *field;
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
703 xmlnode *query, *x, *y;
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
704 char *instructions;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
705
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
706 /* get rid of the login thingy */
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
707 gaim_connection_set_state(js->gc, GAIM_CONNECTED);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
708
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
709 query = xmlnode_get_child(packet, "query");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
710
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
711 if(xmlnode_get_child(query, "registered")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
712 gaim_notify_error(NULL, _("Already Registered"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
713 _("Already Registered"), NULL);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
714 jabber_connection_schedule_close(js);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
715 return;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
716 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
717
8398
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
718 if((x = xmlnode_get_child_with_namespace(packet, "x",
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
719 "jabber:x:data"))) {
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
720 jabber_x_data_request(js, x, jabber_register_x_data_cb, NULL);
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
721 return;
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
722 } else if((x = xmlnode_get_child_with_namespace(packet, "x",
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
723 "jabber:x:oob"))) {
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
724 xmlnode *url;
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
725
8398
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
726 if((url = xmlnode_get_child(x, "url"))) {
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
727 char *href;
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
728 if((href = xmlnode_get_data(url))) {
10240
95ca0db2d01d [gaim-migrate @ 11377]
Herman Bloggs <hermanator12002@yahoo.com>
parents: 10216
diff changeset
729 gaim_notify_uri(NULL, href);
8398
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
730 g_free(href);
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
731 js->gc->wants_to_die = TRUE;
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
732 jabber_connection_schedule_close(js);
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
733 return;
66db94ff619c [gaim-migrate @ 9127]
Nathan Walp <nwalp@pidgin.im>
parents: 8396
diff changeset
734 }
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
735 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
736 }
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
737
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
738 /* as a last resort, use the old jabber:iq:register syntax */
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
739
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
740 fields = gaim_request_fields_new();
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
741 group = gaim_request_field_group_new(NULL);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
742 gaim_request_fields_add_group(fields, group);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
743
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
744 field = gaim_request_field_string_new("username", _("Username"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
745 js->user->node, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
746 gaim_request_field_group_add_field(group, field);
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 field = gaim_request_field_string_new("password", _("Password"),
10740
94cc67130789 [gaim-migrate @ 12342]
Mark Doliner <mark@kingant.net>
parents: 10504
diff changeset
749 gaim_connection_get_password(js->gc), FALSE);
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
750 gaim_request_field_string_set_masked(field, TRUE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
751 gaim_request_field_group_add_field(group, field);
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(xmlnode_get_child(query, "name")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
754 field = gaim_request_field_string_new("name", _("Name"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
755 gaim_account_get_alias(js->gc->account), FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
756 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
757 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
758 if(xmlnode_get_child(query, "email")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
759 field = gaim_request_field_string_new("email", _("E-Mail"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
760 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
761 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
762 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
763 if(xmlnode_get_child(query, "nick")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
764 field = gaim_request_field_string_new("nick", _("Nickname"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
765 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
766 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
767 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
768 if(xmlnode_get_child(query, "first")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
769 field = gaim_request_field_string_new("first", _("First Name"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
770 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
771 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
772 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
773 if(xmlnode_get_child(query, "last")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
774 field = gaim_request_field_string_new("last", _("Last Name"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
775 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
776 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
777 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
778 if(xmlnode_get_child(query, "address")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
779 field = gaim_request_field_string_new("address", _("Address"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
780 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
781 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
782 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
783 if(xmlnode_get_child(query, "city")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
784 field = gaim_request_field_string_new("city", _("City"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
785 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
786 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
787 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
788 if(xmlnode_get_child(query, "state")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
789 field = gaim_request_field_string_new("state", _("State"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
790 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
791 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
792 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
793 if(xmlnode_get_child(query, "zip")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
794 field = gaim_request_field_string_new("zip", _("Postal Code"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
795 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
796 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
797 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
798 if(xmlnode_get_child(query, "phone")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
799 field = gaim_request_field_string_new("phone", _("Phone"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
800 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
801 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
802 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
803 if(xmlnode_get_child(query, "url")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
804 field = gaim_request_field_string_new("url", _("URL"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
805 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
806 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
807 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
808 if(xmlnode_get_child(query, "date")) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
809 field = gaim_request_field_string_new("date", _("Date"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
810 NULL, FALSE);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
811 gaim_request_field_group_add_field(group, field);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
812 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
813
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
814 if((y = xmlnode_get_child(query, "instructions")))
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
815 instructions = xmlnode_get_data(y);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
816 else
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
817 instructions = g_strdup(_("Please fill out the information below "
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
818 "to register your new account."));
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
819
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
820 gaim_request_fields(js->gc, _("Register New Jabber Account"),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
821 _("Register New Jabber Account"), instructions, fields,
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
822 _("Register"), G_CALLBACK(jabber_register_cb),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
823 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
824 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
825 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
826
8016
7bae464195c4 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 8013
diff changeset
827 void jabber_register_start(JabberStream *js)
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
828 {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
829 JabberIq *iq;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
830
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
831 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
832 jabber_iq_send(iq);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
833 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
834
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
835 static void jabber_register_account(GaimAccount *account)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
836 {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
837 GaimConnection *gc = gaim_account_get_connection(account);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
838 JabberStream *js;
10289
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
839 JabberBuddy *my_jb = NULL;
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
840 const char *connect_server = gaim_account_get_string(account,
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
841 "connect_server", "");
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
842 const char *server;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
843 int rc;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
844
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
845 js = gc->proto_data = g_new0(JabberStream, 1);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
846 js->gc = gc;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
847 js->registration = TRUE;
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
848 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
849 g_free, g_free);
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
850 js->disco_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
851 g_free, g_free);
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
852 js->user = jabber_id_new(gaim_account_get_username(account));
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
853 js->next_id = g_random_int();
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
854
7310
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
855 if(!js->user) {
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
856 gaim_connection_error(gc, _("Invalid Jabber ID"));
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
857 return;
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
858 }
dd4b4a187171 [gaim-migrate @ 7894]
Nathan Walp <nwalp@pidgin.im>
parents: 7291
diff changeset
859
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
860 js->write_buffer = gaim_circ_buffer_new(512);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
861 js->writeh = -1;
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
862
7147
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
863 if(!js->user->resource) {
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
864 char *me;
11939
85c25a32bb48 [gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11837
diff changeset
865 js->user->resource = g_strdup("Home");
7147
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
866 if(!js->user->node) {
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
867 js->user->node = js->user->domain;
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
868 js->user->domain = g_strdup("jabber.org");
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
869 }
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
870 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
871 js->user->resource);
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
872 gaim_account_set_username(account, me);
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
873 g_free(me);
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
874 }
e9867cdeb0fd [gaim-migrate @ 7714]
Nathan Walp <nwalp@pidgin.im>
parents: 7145
diff changeset
875
10289
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
876 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE)))
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
877 my_jb->subscription |= JABBER_SUB_BOTH;
5683613ea692 [gaim-migrate @ 11464]
Nathan Walp <nwalp@pidgin.im>
parents: 10240
diff changeset
878
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
879 server = connect_server[0] ? connect_server : js->user->domain;
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
880
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
881 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
882
7630
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
883 if(gaim_account_get_bool(account, "old_ssl", FALSE)) {
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
884 if(gaim_ssl_is_supported()) {
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
885 js->gsc = gaim_ssl_connect(account, server,
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
886 gaim_account_get_int(account, "port", 5222),
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
887 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
888 } else {
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
889 gaim_connection_error(gc, _("SSL support unavailable"));
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
890 }
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
891 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
892
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
893 if(!js->gsc) {
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
894 rc = gaim_proxy_connect(account, server,
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
895 gaim_account_get_int(account, "port", 5222),
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
896 jabber_login_callback, gc);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
897
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
898 if (rc != 0)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
899 gaim_connection_error(gc, _("Unable to create socket"));
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
900 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
901 }
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
902
5572
dfdea22a7153 [gaim-migrate @ 5974]
Nathan Walp <nwalp@pidgin.im>
parents: 5498
diff changeset
903 static void jabber_close(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
905 JabberStream *js = gc->proto_data;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
906
13242
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
907 #ifdef HAVE_OPENSSL
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
908 /* If using OpenSSL, don't perform any actions on the ssl connection if we were forcibly disconnected
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
909 * because it will crash.
13153
caee920323e2 [gaim-migrate @ 15516]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13051
diff changeset
910 */
caee920323e2 [gaim-migrate @ 15516]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13051
diff changeset
911 if (!gc->disconnect_timeout)
caee920323e2 [gaim-migrate @ 15516]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13051
diff changeset
912 jabber_send_raw(js, "</stream:stream>", -1);
13242
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
913 #else
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
914 jabber_send_raw(js, "</stream:stream>", -1);
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
915 #endif
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
916
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
917 if(js->gsc) {
13242
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
918 #ifdef HAVE_OPENSSL
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
919 if (!gc->disconnect_timeout)
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
920 gaim_ssl_close(js->gsc);
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
921 #else
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
922 gaim_ssl_close(js->gsc);
cdd107258f11 [gaim-migrate @ 15608]
Evan Schoenberg <evan.s@dreskin.net>
parents: 13237
diff changeset
923 #endif
8360
8d012c803411 [gaim-migrate @ 9084]
Nathan Walp <nwalp@pidgin.im>
parents: 8312
diff changeset
924 } else if (js->fd > 0) {
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
925 if(js->gc->inpa)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
926 gaim_input_remove(js->gc->inpa);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
927 close(js->fd);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
928 }
3311
522f37c9f9d2 [gaim-migrate @ 3329]
Jim Seymour <jseymour>
parents: 3260
diff changeset
929
7587
1d9698ab5465 [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
930 if(js->context)
1d9698ab5465 [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
931 g_markup_parse_context_free(js->context);
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
932 if(js->iq_callbacks)
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
933 g_hash_table_destroy(js->iq_callbacks);
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
934 if(js->disco_callbacks)
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
935 g_hash_table_destroy(js->disco_callbacks);
7072
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
936 if(js->buddies)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
937 g_hash_table_destroy(js->buddies);
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
938 if(js->chats)
1350352f5818 [gaim-migrate @ 7637]
Nathan Walp <nwalp@pidgin.im>
parents: 7020
diff changeset
939 g_hash_table_destroy(js->chats);
8043
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
940 while(js->chat_servers) {
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
941 g_free(js->chat_servers->data);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
942 js->chat_servers = g_list_delete_link(js->chat_servers, js->chat_servers);
9a6df4d567e0 [gaim-migrate @ 8727]
Nathan Walp <nwalp@pidgin.im>
parents: 8016
diff changeset
943 }
11675
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
944 while(js->user_directories) {
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
945 g_free(js->user_directories->data);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
946 js->user_directories = g_list_delete_link(js->user_directories, js->user_directories);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
947 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
948 if(js->stream_id)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
949 g_free(js->stream_id);
7587
1d9698ab5465 [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
950 if(js->user)
1d9698ab5465 [gaim-migrate @ 8205]
Nathan Walp <nwalp@pidgin.im>
parents: 7514
diff changeset
951 jabber_id_free(js->user);
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10009
diff changeset
952 if(js->avatar_hash)
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10009
diff changeset
953 g_free(js->avatar_hash);
13200
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
954 gaim_circ_buffer_destroy(js->write_buffer);
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
955 if(js->writeh)
33bef17125c2 [gaim-migrate @ 15563]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 13153
diff changeset
956 gaim_input_remove(js->writeh);
12508
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
957 #ifdef HAVE_CYRUS_SASL
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
958 if(js->sasl)
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
959 sasl_dispose(&js->sasl);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
960 if(js->sasl_mechs)
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
961 g_string_free(js->sasl_mechs, TRUE);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
962 if(js->sasl_cb)
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
963 g_free(js->sasl_cb);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
964 #endif
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
965 g_free(js);
11389
098cfd8152bc [gaim-migrate @ 13617]
Nathan Walp <nwalp@pidgin.im>
parents: 11387
diff changeset
966
098cfd8152bc [gaim-migrate @ 13617]
Nathan Walp <nwalp@pidgin.im>
parents: 11387
diff changeset
967 gc->proto_data = NULL;
5093
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
968 }
89c0c811befa [gaim-migrate @ 5455]
Nathan Walp <nwalp@pidgin.im>
parents: 5068
diff changeset
969
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
970 void jabber_stream_set_state(JabberStream *js, JabberStreamState state)
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
971 {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
972 GaimPresence *gpresence;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
973 GaimStatus *status;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
974
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
975 js->state = state;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
976 switch(state) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
977 case JABBER_STREAM_OFFLINE:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
978 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
979 case JABBER_STREAM_CONNECTING:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
980 gaim_connection_update_progress(js->gc, _("Connecting"), 1,
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
981 JABBER_CONNECT_STEPS);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
982 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
983 case JABBER_STREAM_INITIALIZING:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
984 gaim_connection_update_progress(js->gc, _("Initializing Stream"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
985 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
986 jabber_stream_init(js);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
987 jabber_parser_setup(js);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
988 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
989 case JABBER_STREAM_AUTHENTICATING:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
990 gaim_connection_update_progress(js->gc, _("Authenticating"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
991 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS);
8296
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
992 if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) {
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
993 jabber_register_start(js);
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
994 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) {
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
995 jabber_auth_start_old(js);
8016
7bae464195c4 [gaim-migrate @ 8696]
Nathan Walp <nwalp@pidgin.im>
parents: 8013
diff changeset
996 }
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
997 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
998 case JABBER_STREAM_REINITIALIZING:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
999 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"),
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1000 6, JABBER_CONNECT_STEPS);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1001 jabber_stream_init(js);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1002 break;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1003 case JABBER_STREAM_CONNECTED:
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1004 jabber_roster_request(js);
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1005 gpresence = gaim_account_get_presence(js->gc->account);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1006 status = gaim_presence_get_active_status(gpresence);
10216
09876d57c520 [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10209
diff changeset
1007 jabber_presence_send(js->gc->account, status);
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10751
diff changeset
1008 gaim_connection_set_state(js->gc, GAIM_CONNECTED);
8312
ba12d8b12ab0 [gaim-migrate @ 9036]
Nathan Walp <nwalp@pidgin.im>
parents: 8296
diff changeset
1009 jabber_disco_items_server(js);
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1010 break;
3105
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1011 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1012 }
da324fe688b3 [gaim-migrate @ 3119]
Sean Egan <seanegan@gmail.com>
parents: 3074
diff changeset
1013
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1014 char *jabber_get_next_id(JabberStream *js)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 {
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7310
diff changeset
1016 return g_strdup_printf("gaim%x", js->next_id++);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1018
7923
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1019
e87e7d9d0132 [gaim-migrate @ 8592]
Nathan Walp <nwalp@pidgin.im>
parents: 7642
diff changeset
1020 static void jabber_idle_set(GaimConnection *gc, int idle)
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
1021 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1022 JabberStream *js = gc->proto_data;
3340
f56b36347375 [gaim-migrate @ 3359]
Jim Seymour <jseymour>
parents: 3337
diff changeset
1023
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1024 js->idle = idle ? time(NULL) - idle : idle;
3314
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
1025 }
52db87ab4083 [gaim-migrate @ 3332]
Jim Seymour <jseymour>
parents: 3311
diff changeset
1026
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6640
diff changeset
1027 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1028 {
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1029 return "jabber";
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4675
diff changeset
1030 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
1031
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1032 static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw,
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1033 const char **nw, const char **ne)
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
1034 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1035 JabberStream *js;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1036 JabberBuddy *jb;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1037
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1038 if(!b->account->gc)
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1039 return;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1040 js = b->account->gc->proto_data;
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1041 jb = jabber_buddy_find(js, b->name, FALSE);
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1042
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1043 if(!GAIM_BUDDY_IS_ONLINE(b)) {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1044 if(jb && jb->error_msg)
4927
afffba7c292e [gaim-migrate @ 5261]
Nathan Walp <nwalp@pidgin.im>
parents: 4921
diff changeset
1045 *nw = "error";
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1046
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1047 if(jb && (jb->subscription & JABBER_SUB_PENDING ||
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1048 !(jb->subscription & JABBER_SUB_TO)))
5135
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1049 *se = "notauthorized";
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1050 else
102135caa225 [gaim-migrate @ 5499]
Nathan Walp <nwalp@pidgin.im>
parents: 5112
diff changeset
1051 *se = "offline";
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
1052 } else {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1053 GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b)));
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1054 GaimStatusPrimitive primitive = gaim_status_type_get_primitive(status_type);
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1055
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1056 if(primitive > GAIM_STATUS_AVAILABLE) {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1057 *se = gaim_status_type_get_id(status_type);
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
1058 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 }
4916
d9b6b5ae34e4 [gaim-migrate @ 5250]
Sean Egan <seanegan@gmail.com>
parents: 4915
diff changeset
1060 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1062 static char *jabber_status_text(GaimBuddy *b)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1063 {
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1064 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
1065 FALSE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1066 char *ret = NULL;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5223
diff changeset
1067
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1068 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
1069 ret = g_strdup(_("Not Authorized"));
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1070 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1071 ret = g_strdup(jb->error_msg);
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1072 } else {
7095
c8bf2da398e3 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7072
diff changeset
1073 char *stripped;
c8bf2da398e3 [gaim-migrate @ 7660]
Christian Hammond <chipx86@chipx86.com>
parents: 7072
diff changeset
1074
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1075 if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) {
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1076 GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b));
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1077
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1078 if(!gaim_status_is_available(status))
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1079 stripped = g_strdup(gaim_status_get_name(status));
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1080 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1081
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1082 if(stripped) {
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1083 ret = g_markup_escape_text(stripped, -1);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1084 g_free(stripped);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1085 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1087
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1088 return ret;
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1089 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1090
12970
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1091 static void jabber_tooltip_text(GaimBuddy *b, GString *str, gboolean full)
4744
a0746ffce599 [gaim-migrate @ 5059]
Sean Egan <seanegan@gmail.com>
parents: 4732
diff changeset
1092 {
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1093 JabberBuddy *jb;
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1094
12970
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1095 g_return_if_fail(b != NULL);
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1096 g_return_if_fail(b->account != NULL);
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1097 g_return_if_fail(b->account->gc != NULL);
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1098 g_return_if_fail(b->account->gc->proto_data != NULL);
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1099
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1100 jb = jabber_buddy_find(b->account->gc->proto_data, b->name,
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1101 FALSE);
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1102
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1103 if(jb) {
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1104 JabberBuddyResource *jbr = NULL;
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1105 const char *sub;
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1106 GList *l;
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1107
12948
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1108 if (full) {
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1109 if(jb->subscription & JABBER_SUB_FROM) {
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1110 if(jb->subscription & JABBER_SUB_TO)
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1111 sub = _("Both");
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1112 else if(jb->subscription & JABBER_SUB_PENDING)
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1113 sub = _("From (To pending)");
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1114 else
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1115 sub = _("From");
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1116 } else {
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1117 if(jb->subscription & JABBER_SUB_TO)
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1118 sub = _("To");
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1119 else if(jb->subscription & JABBER_SUB_PENDING)
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1120 sub = _("None (To pending)");
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1121 else
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1122 sub = _("None");
563fb4f1e9fc [gaim-migrate @ 15301]
Richard Laager <rlaager@wiktel.com>
parents: 12944
diff changeset
1123 }
12970
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1124 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Subscription"), sub);
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1125 }
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1126
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1127 for(l=jb->resources; l; l = l->next) {
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1128 char *text = NULL;
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1129 char *res = NULL;
12944
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1130 const char *state;
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1131
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1132 jbr = l->data;
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1133
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1134 if(jbr->status) {
11646
42ce5c68870a [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1135 char *tmp;
42ce5c68870a [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1136 text = gaim_strreplace(jbr->status, "\n", "<br />\n");
42ce5c68870a [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1137 tmp = gaim_markup_strip_html(text);
42ce5c68870a [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1138 g_free(text);
42ce5c68870a [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1139 text = g_markup_escape_text(tmp, -1);
42ce5c68870a [gaim-migrate @ 13924]
Nathan Walp <nwalp@pidgin.im>
parents: 11610
diff changeset
1140 g_free(tmp);
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1141 }
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1142
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1143 if(jbr->name)
11610
69bd7af50d31 [gaim-migrate @ 13881]
Nathan Walp <nwalp@pidgin.im>
parents: 11609
diff changeset
1144 res = g_strdup_printf(" (%s)", jbr->name);
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1145
12944
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1146 state = jabber_buddy_state_get_name(jbr->state);
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1147 if (text != NULL && !gaim_utf8_strcasecmp(state, text)) {
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1148 g_free(text);
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1149 text = NULL;
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1150 }
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1151
12970
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1152 g_string_append_printf(str, "\n<b>%s%s:</b> %s%s%s",
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1153 _("Status"),
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1154 res ? res : "",
12944
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1155 state,
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1156 text ? ": " : "",
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1157 text ? text : "");
12944
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1158
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1159 g_free(text);
07eaae27e674 [gaim-migrate @ 15297]
Richard Laager <rlaager@wiktel.com>
parents: 12943
diff changeset
1160 g_free(res);
11609
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1161 }
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1162
f38655b98ba0 [gaim-migrate @ 13880]
Nathan Walp <nwalp@pidgin.im>
parents: 11569
diff changeset
1163 if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) {
12970
ec9b92104904 [gaim-migrate @ 15323]
Richard Laager <rlaager@wiktel.com>
parents: 12948
diff changeset
1164 g_string_append_printf(str, "\n<b>%s:</b> %s",
8194
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1165 _("Error"), jb->error_msg);
22b3974dc1af [gaim-migrate @ 8916]
Nathan Walp <nwalp@pidgin.im>
parents: 8193
diff changeset
1166 }
4745
01cae9259e2f [gaim-migrate @ 5060]
Nathan Walp <nwalp@pidgin.im>
parents: 4744
diff changeset
1167 }
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
1168 }
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4705
diff changeset
1169
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1170 static GList *jabber_status_types(GaimAccount *account)
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1171 {
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1172 GaimStatusType *type;
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1173 GList *types = NULL;
11568
e36f0f9debb5 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11522
diff changeset
1174 GaimValue *priority_value;
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1175
11568
e36f0f9debb5 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11522
diff changeset
1176 priority_value = gaim_value_new(GAIM_TYPE_INT);
11569
ea98c27f1a34 [gaim-migrate @ 13836]
Nathan Walp <nwalp@pidgin.im>
parents: 11568
diff changeset
1177 gaim_value_set_int(priority_value, 1);
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1178 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1179 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1180 NULL, TRUE, TRUE, FALSE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1181 "priority", _("Priority"), priority_value,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1182 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1183 NULL);
9980
1cad29047886 [gaim-migrate @ 10891]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1184 types = g_list_append(types, type);
1cad29047886 [gaim-migrate @ 10891]
Nathan Walp <nwalp@pidgin.im>
parents: 9954
diff changeset
1185
11568
e36f0f9debb5 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11522
diff changeset
1186 priority_value = gaim_value_new(GAIM_TYPE_INT);
11569
ea98c27f1a34 [gaim-migrate @ 13836]
Nathan Walp <nwalp@pidgin.im>
parents: 11568
diff changeset
1187 gaim_value_set_int(priority_value, 1);
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1188 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1189 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1190 _("Chatty"), TRUE, TRUE, FALSE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1191 "priority", _("Priority"), priority_value,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1192 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1193 NULL);
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1194 types = g_list_append(types, type);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1195
11568
e36f0f9debb5 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11522
diff changeset
1196 priority_value = gaim_value_new(GAIM_TYPE_INT);
11569
ea98c27f1a34 [gaim-migrate @ 13836]
Nathan Walp <nwalp@pidgin.im>
parents: 11568
diff changeset
1197 gaim_value_set_int(priority_value, 0);
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1198 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1199 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1200 NULL, TRUE, TRUE, FALSE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1201 "priority", _("Priority"), priority_value,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1202 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1203 NULL);
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1204 types = g_list_append(types, type);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1205
11568
e36f0f9debb5 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11522
diff changeset
1206 priority_value = gaim_value_new(GAIM_TYPE_INT);
11569
ea98c27f1a34 [gaim-migrate @ 13836]
Nathan Walp <nwalp@pidgin.im>
parents: 11568
diff changeset
1207 gaim_value_set_int(priority_value, 0);
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1208 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1209 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1210 NULL, TRUE, TRUE, FALSE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1211 "priority", _("Priority"), priority_value,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1212 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1213 NULL);
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1214 types = g_list_append(types, type);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1215
11568
e36f0f9debb5 [gaim-migrate @ 13835]
Nathan Walp <nwalp@pidgin.im>
parents: 11522
diff changeset
1216 priority_value = gaim_value_new(GAIM_TYPE_INT);
11569
ea98c27f1a34 [gaim-migrate @ 13836]
Nathan Walp <nwalp@pidgin.im>
parents: 11568
diff changeset
1217 gaim_value_set_int(priority_value, 0);
12595
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1218 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1219 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1220 _("Do Not Disturb"), TRUE, TRUE, FALSE,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1221 "priority", _("Priority"), priority_value,
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1222 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
3169cd6727ad [gaim-migrate @ 14925]
Richard Laager <rlaager@wiktel.com>
parents: 12554
diff changeset
1223 NULL);
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1224 types = g_list_append(types, type);
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1225
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1226 /*
8166
ac7bf273bd66 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
1227 if(js->protocol_version == JABBER_PROTO_0_9)
ac7bf273bd66 [gaim-migrate @ 8878]
Nathan Walp <nwalp@pidgin.im>
parents: 8158
diff changeset
1228 m = g_list_append(m, _("Invisible"));
10009
c124bef68132 [gaim-migrate @ 10926]
Mark Doliner <mark@kingant.net>
parents: 9980
diff changeset
1229 */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230
12658
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12646
diff changeset
1231 type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE,
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12646
diff changeset
1232 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE),
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12646
diff changeset
1233 NULL, FALSE, TRUE, FALSE,
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12646
diff changeset
1234 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12646
diff changeset
1235 NULL);
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12646
diff changeset
1236 types = g_list_append(types, type);
a0fd3ebcd6fa [gaim-migrate @ 15001]
Mark Doliner <mark@kingant.net>
parents: 12646
diff changeset
1237
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1238 return types;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1241 static void
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1242 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet,
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1243 gpointer data)
7124
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1244 {
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1245 const char *type;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1246
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1247 type = xmlnode_get_attrib(packet, "type");
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1248
9414
f55fa0a2277e [gaim-migrate @ 10229]
Nathan Walp <nwalp@pidgin.im>
parents: 9308
diff changeset
1249 if(type && !strcmp(type, "result")) {
7124
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1250 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1251 _("Your password has been changed."));
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1252 } else {
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1253 char *msg = jabber_parse_error(js, packet);
7124
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1254
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1255 gaim_notify_error(js->gc, _("Error changing password"),
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1256 _("Error changing password"), msg);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1257 g_free(msg);
7124
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1258 }
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1259 }
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1260
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1261 static void jabber_password_change_cb(JabberStream *js,
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1262 GaimRequestFields *fields)
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1263 {
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1264 const char *p1, *p2;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1265 JabberIq *iq;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1266 xmlnode *query, *y;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1267
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1268 p1 = gaim_request_fields_get_string(fields, "password1");
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1269 p2 = gaim_request_fields_get_string(fields, "password2");
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1270
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1271 if(strcmp(p1, p2)) {
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1272 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
1273 return;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1274 }
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1275
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1276 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
1277
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1278 xmlnode_set_attrib(iq->node, "to", js->user->domain);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1279
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1280 query = xmlnode_get_child(iq->node, "query");
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1281
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1282 y = xmlnode_new_child(query, "username");
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1283 xmlnode_insert_data(y, js->user->node, -1);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1284 y = xmlnode_new_child(query, "password");
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1285 xmlnode_insert_data(y, p1, -1);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1286
7395
b250288fa948 [gaim-migrate @ 7990]
Nathan Walp <nwalp@pidgin.im>
parents: 7322
diff changeset
1287 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
1288
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1289 jabber_iq_send(iq);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1290
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1291 gaim_account_set_password(js->gc->account, p1);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1292 }
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1293
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1294 static void jabber_password_change(GaimPluginAction *action)
7124
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1295 {
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1296
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1297 GaimConnection *gc = (GaimConnection *) action->context;
7124
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1298 JabberStream *js = gc->proto_data;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1299 GaimRequestFields *fields;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1300 GaimRequestFieldGroup *group;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1301 GaimRequestField *field;
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1302
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1303 fields = gaim_request_fields_new();
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1304 group = gaim_request_field_group_new(NULL);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1305 gaim_request_fields_add_group(fields, group);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1306
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1307 field = gaim_request_field_string_new("password1", _("Password"),
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1308 "", FALSE);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1309 gaim_request_field_string_set_masked(field, TRUE);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1310 gaim_request_field_group_add_field(group, field);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1311
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1312 field = gaim_request_field_string_new("password2", _("Password (again)"),
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1313 "", FALSE);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1314 gaim_request_field_string_set_masked(field, TRUE);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1315 gaim_request_field_group_add_field(group, field);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1316
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1317 gaim_request_fields(js->gc, _("Change Jabber Password"),
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1318 _("Change Jabber Password"), _("Please enter your new password"),
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1319 fields, _("OK"), G_CALLBACK(jabber_password_change_cb),
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1320 _("Cancel"), NULL, js);
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1321 }
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1322
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1323 static GList *jabber_actions(GaimPlugin *plugin, gpointer context)
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1324 {
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1325 GList *m = NULL;
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1326 GaimPluginAction *act;
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
1327
12243
d3cb077caf3e [gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents: 12143
diff changeset
1328 act = gaim_plugin_action_new(_("Set User Info..."),
12286
255e6912607b [gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12284
diff changeset
1329 jabber_setup_set_info);
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1330 m = g_list_append(m, act);
4333
cc2f780c0505 [gaim-migrate @ 4597]
Mark Doliner <mark@kingant.net>
parents: 4316
diff changeset
1331
8296
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1332 /* if (js->protocol_options & CHANGE_PASSWORD) { */
12243
d3cb077caf3e [gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents: 12143
diff changeset
1333 act = gaim_plugin_action_new(_("Change Password..."),
12286
255e6912607b [gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12284
diff changeset
1334 jabber_password_change);
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1335 m = g_list_append(m, act);
8296
dd6fe7d965aa [gaim-migrate @ 9020]
Nathan Walp <nwalp@pidgin.im>
parents: 8273
diff changeset
1336 /* } */
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1337
12243
d3cb077caf3e [gaim-migrate @ 14545]
Richard Laager <rlaager@wiktel.com>
parents: 12143
diff changeset
1338 act = gaim_plugin_action_new(_("Search for Users..."),
12286
255e6912607b [gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents: 12284
diff changeset
1339 jabber_user_search_begin);
11675
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1340 m = g_list_append(m, act);
828802f2251b [gaim-migrate @ 13961]
Nathan Walp <nwalp@pidgin.im>
parents: 11646
diff changeset
1341
2956
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1342 return m;
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1343 }
b68c648618a3 [gaim-migrate @ 2969]
Rob Flynn <gaim@robflynn.com>
parents: 2856
diff changeset
1344
7999
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1345 static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name)
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1346 {
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1347 GaimBlistNode *gnode, *cnode;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1348 JabberID *jid;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1349
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1350 if(!(jid = jabber_id_new(name)))
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1351 return NULL;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1352
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1353 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1354 for(cnode = gnode->child; cnode; cnode = cnode->next) {
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1355 GaimChat *chat = (GaimChat*)cnode;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1356 const char *room, *server;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1357 if(!GAIM_BLIST_NODE_IS_CHAT(cnode))
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1358 continue;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1359
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1360 if(chat->account != account)
8011
335a54c6fd90 [gaim-migrate @ 8691]
Nathan Walp <nwalp@pidgin.im>
parents: 8010
diff changeset
1361 continue;
7999
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1362
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1363 if(!(room = g_hash_table_lookup(chat->components, "room")))
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1364 continue;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1365 if(!(server = g_hash_table_lookup(chat->components, "server")))
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1366 continue;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1367
8158
e283be34aadf [gaim-migrate @ 8870]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1368 if(jid->node && jid->domain &&
e283be34aadf [gaim-migrate @ 8870]
Nathan Walp <nwalp@pidgin.im>
parents: 8135
diff changeset
1369 !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) {
7999
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1370 jabber_id_free(jid);
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1371 return chat;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1372 }
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1373 }
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1374 }
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1375 jabber_id_free(jid);
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1376 return NULL;
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1377 }
38df71d58500 [gaim-migrate @ 8676]
Nathan Walp <nwalp@pidgin.im>
parents: 7971
diff changeset
1378
8400
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1379 static void jabber_convo_closed(GaimConnection *gc, const char *who)
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1380 {
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1381 JabberStream *js = gc->proto_data;
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1382 JabberID *jid;
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1383 JabberBuddy *jb;
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1384 JabberBuddyResource *jbr;
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1385
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1386 if(!(jid = jabber_id_new(who)))
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1387 return;
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1388
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1389 if((jb = jabber_buddy_find(js, who, TRUE)) &&
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1390 (jbr = jabber_buddy_find_resource(jb, jid->resource))) {
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1391 if(jbr->thread_id) {
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1392 g_free(jbr->thread_id);
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1393 jbr->thread_id = NULL;
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1394 }
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1395 }
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1396
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1397 jabber_id_free(jid);
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1398 }
0383e55cd658 [gaim-migrate @ 9129]
Nathan Walp <nwalp@pidgin.im>
parents: 8399
diff changeset
1399
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1400
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1401 char *jabber_parse_error(JabberStream *js, xmlnode *packet)
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1402 {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1403 xmlnode *error;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1404 const char *code = NULL, *text = NULL;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1405 const char *xmlns = xmlnode_get_attrib(packet, "xmlns");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1406 char *cdata = NULL;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1407
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1408 if((error = xmlnode_get_child(packet, "error"))) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1409 cdata = xmlnode_get_data(error);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1410 code = xmlnode_get_attrib(error, "code");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1411
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1412 /* Stanza errors */
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1413 if(xmlnode_get_child(error, "bad-request")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1414 text = _("Bad Request");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1415 } else if(xmlnode_get_child(error, "conflict")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1416 text = _("Conflict");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1417 } else if(xmlnode_get_child(error, "feature-not-implemented")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1418 text = _("Feature Not Implemented");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1419 } else if(xmlnode_get_child(error, "forbidden")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1420 text = _("Forbidden");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1421 } else if(xmlnode_get_child(error, "gone")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1422 text = _("Gone");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1423 } else if(xmlnode_get_child(error, "internal-server-error")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1424 text = _("Internal Server Error");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1425 } else if(xmlnode_get_child(error, "item-not-found")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1426 text = _("Item Not Found");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1427 } else if(xmlnode_get_child(error, "jid-malformed")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1428 text = _("Malformed Jabber ID");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1429 } else if(xmlnode_get_child(error, "not-acceptable")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1430 text = _("Not Acceptable");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1431 } else if(xmlnode_get_child(error, "not-allowed")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1432 text = _("Not Allowed");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1433 } else if(xmlnode_get_child(error, "not-authorized")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1434 text = _("Not Authorized");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1435 } else if(xmlnode_get_child(error, "payment-required")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1436 text = _("Payment Required");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1437 } else if(xmlnode_get_child(error, "recipient-unavailable")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1438 text = _("Recipient Unavailable");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1439 } else if(xmlnode_get_child(error, "redirect")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1440 /* XXX */
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1441 } else if(xmlnode_get_child(error, "registration-required")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1442 text = _("Registration Required");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1443 } else if(xmlnode_get_child(error, "remote-server-not-found")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1444 text = _("Remote Server Not Found");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1445 } else if(xmlnode_get_child(error, "remote-server-timeout")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1446 text = _("Remote Server Timeout");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1447 } else if(xmlnode_get_child(error, "resource-constraint")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1448 text = _("Server Overloaded");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1449 } else if(xmlnode_get_child(error, "service-unavailable")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1450 text = _("Service Unavailable");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1451 } else if(xmlnode_get_child(error, "subscription-required")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1452 text = _("Subscription Required");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1453 } else if(xmlnode_get_child(error, "unexpected-request")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1454 text = _("Unexpected Request");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1455 } else if(xmlnode_get_child(error, "undefined-condition")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1456 text = _("Unknown Error");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1457 }
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1458 } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1459 if(xmlnode_get_child(packet, "aborted")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1460 js->gc->wants_to_die = TRUE;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1461 text = _("Authorization Aborted");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1462 } else if(xmlnode_get_child(error, "incorrect-encoding")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1463 text = _("Incorrect encoding in authorization");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1464 } else if(xmlnode_get_child(error, "invalid-authzid")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1465 js->gc->wants_to_die = TRUE;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1466 text = _("Invalid authzid");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1467 } else if(xmlnode_get_child(error, "invalid-mechanism")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1468 js->gc->wants_to_die = TRUE;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1469 text = _("Invalid Authorization Mechanism");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1470 } else if(xmlnode_get_child(error, "mechanism-too-weak")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1471 js->gc->wants_to_die = TRUE;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1472 text = _("Authorization mechanism too weak");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1473 } else if(xmlnode_get_child(error, "not-authorized")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1474 js->gc->wants_to_die = TRUE;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1475 text = _("Not Authorized");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1476 } else if(xmlnode_get_child(error, "temporary-auth-failure")) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1477 text = _("Temporary Authentication Failure");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1478 } else {
13051
7d8da9d4da49 [gaim-migrate @ 15412]
Ethan Blanton <elb@pidgin.im>
parents: 12970
diff changeset
1479 js->gc->wants_to_die = TRUE;
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1480 text = _("Authentication Failure");
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1481 }
8402
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1482 } else if(!strcmp(packet->name, "stream:error")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1483 if(xmlnode_get_child(packet, "bad-format")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1484 text = _("Bad Format");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1485 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1486 text = _("Bad Namespace Prefix");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1487 } else if(xmlnode_get_child(packet, "conflict")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1488 js->gc->wants_to_die = TRUE;
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1489 text = _("Resource Conflict");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1490 } else if(xmlnode_get_child(packet, "connection-timeout")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1491 text = _("Connection Timeout");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1492 } else if(xmlnode_get_child(packet, "host-gone")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1493 text = _("Host Gone");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1494 } else if(xmlnode_get_child(packet, "host-unknown")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1495 text = _("Host Unknown");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1496 } else if(xmlnode_get_child(packet, "improper-addressing")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1497 text = _("Improper Addressing");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1498 } else if(xmlnode_get_child(packet, "internal-server-error")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1499 text = _("Internal Server Error");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1500 } else if(xmlnode_get_child(packet, "invalid-id")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1501 text = _("Invalid ID");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1502 } else if(xmlnode_get_child(packet, "invalid-namespace")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1503 text = _("Invalid Namespace");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1504 } else if(xmlnode_get_child(packet, "invalid-xml")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1505 text = _("Invalid XML");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1506 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1507 text = _("Non-matching Hosts");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1508 } else if(xmlnode_get_child(packet, "not-authorized")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1509 text = _("Not Authorized");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1510 } else if(xmlnode_get_child(packet, "policy-violation")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1511 text = _("Policy Violation");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1512 } else if(xmlnode_get_child(packet, "remote-connection-failed")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1513 text = _("Remote Connection Failed");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1514 } else if(xmlnode_get_child(packet, "resource-constraint")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1515 text = _("Resource Constraint");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1516 } else if(xmlnode_get_child(packet, "restricted-xml")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1517 text = _("Restricted XML");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1518 } else if(xmlnode_get_child(packet, "see-other-host")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1519 text = _("See Other Host");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1520 } else if(xmlnode_get_child(packet, "system-shutdown")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1521 text = _("System Shutdown");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1522 } else if(xmlnode_get_child(packet, "undefined-condition")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1523 text = _("Undefined Condition");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1524 } else if(xmlnode_get_child(packet, "unsupported-encoding")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1525 text = _("Unsupported Encoding");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1526 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1527 text = _("Unsupported Stanza Type");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1528 } else if(xmlnode_get_child(packet, "unsupported-version")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1529 text = _("Unsupported Version");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1530 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1531 text = _("XML Not Well Formed");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1532 } else {
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1533 text = _("Stream Error");
fcfb1c08d402 [gaim-migrate @ 9131]
Nathan Walp <nwalp@pidgin.im>
parents: 8401
diff changeset
1534 }
8401
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1535 }
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1536
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1537 if(text || cdata) {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1538 char *ret = g_strdup_printf("%s%s%s", code ? code : "",
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1539 code ? ": " : "", text ? text : cdata);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1540 g_free(cdata);
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1541 return ret;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1542 } else {
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1543 return NULL;
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1544 }
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1545 }
c13a4913a071 [gaim-migrate @ 9130]
Nathan Walp <nwalp@pidgin.im>
parents: 8400
diff changeset
1546
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1547 static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1548 const char *cmd, char **args, char **error, void *data)
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1549 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1550 JabberChat *chat = jabber_chat_find_by_conv(conv);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1551 jabber_chat_request_room_configure(chat);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1552 return GAIM_CMD_RET_OK;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1553 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1554
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1555 static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1556 const char *cmd, char **args, char **error, void *data)
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1557 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1558 JabberChat *chat = jabber_chat_find_by_conv(conv);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1559 jabber_chat_register(chat);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1560 return GAIM_CMD_RET_OK;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1561 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1562
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1563 static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1564 const char *cmd, char **args, char **error, void *data)
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1565 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1566 JabberChat *chat = jabber_chat_find_by_conv(conv);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1567 jabber_chat_change_topic(chat, args ? args[0] : NULL);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1568 return GAIM_CMD_RET_OK;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1569 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1570
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1571 static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1572 const char *cmd, char **args, char **error, void *data)
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1573 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1574 JabberChat *chat = jabber_chat_find_by_conv(conv);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1575
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1576 if(!args || !args[0])
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1577 return GAIM_CMD_RET_FAILED;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1578
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1579 jabber_chat_change_nick(chat, args[0]);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1580 return GAIM_CMD_RET_OK;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1581 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1582
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1583 static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1584 const char *cmd, char **args, char **error, void *data)
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1585 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1586 JabberChat *chat = jabber_chat_find_by_conv(conv);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1587 jabber_chat_part(chat, args ? args[0] : NULL);
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1588 return GAIM_CMD_RET_OK;
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1589 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1590
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1591 static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1592 const char *cmd, char **args, char **error, void *data)
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1593 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1594 JabberChat *chat = jabber_chat_find_by_conv(conv);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1595
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1596 if(!args || !args[0])
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1597 return GAIM_CMD_RET_FAILED;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1598
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1599 if(!jabber_chat_ban_user(chat, args[0], args[1])) {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1600 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1601 return GAIM_CMD_RET_FAILED;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1602 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1603
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1604 return GAIM_CMD_RET_OK;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1605 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1606
11393
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1607 static GaimCmdRet jabber_cmd_chat_affiliate(GaimConversation *conv,
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1608 const char *cmd, char **args, char **error, void *data)
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1609 {
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1610 JabberChat *chat = jabber_chat_find_by_conv(conv);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1611
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1612 if (!args || !args[0] || !args[1])
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1613 return GAIM_CMD_RET_FAILED;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1614
13237
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1615 if (strcmp(args[1], "owner") != 0 &&
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1616 strcmp(args[1], "admin") != 0 &&
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1617 strcmp(args[1], "member") != 0 &&
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1618 strcmp(args[1], "outcast") != 0 &&
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1619 strcmp(args[1], "none") != 0) {
11393
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1620 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1621 return GAIM_CMD_RET_FAILED;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1622 }
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1623
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1624 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) {
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1625 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]);
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1626 return GAIM_CMD_RET_FAILED;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1627 }
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1628
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1629 return GAIM_CMD_RET_OK;
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1630 }
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1631
13237
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1632 static GaimCmdRet jabber_cmd_chat_role(GaimConversation *conv,
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1633 const char *cmd, char **args, char **error, void *data)
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1634 {
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1635 JabberChat *chat;
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1636
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1637 if (!args || !args[0] || !args[1])
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1638 return GAIM_CMD_RET_FAILED;
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1639
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1640 if (strcmp(args[1], "moderator") != 0 &&
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1641 strcmp(args[1], "participant") != 0 &&
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1642 strcmp(args[1], "visitor") != 0 &&
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1643 strcmp(args[1], "none") != 0) {
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1644 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]);
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1645 return GAIM_CMD_RET_FAILED;
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1646 }
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1647
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1648 chat = jabber_chat_find_by_conv(conv);
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1649
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1650 if (!jabber_chat_role_user(chat, args[0], args[1])) {
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1651 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1652 args[1], args[0]);
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1653 return GAIM_CMD_RET_FAILED;
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1654 }
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1655
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1656 return GAIM_CMD_RET_OK;
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1657 }
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1658
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1659 static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1660 const char *cmd, char **args, char **error, void *data)
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1661 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1662 if(!args || !args[0])
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1663 return GAIM_CMD_RET_FAILED;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1664
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1665 jabber_chat_invite(gaim_conversation_get_gc(conv),
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1666 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "",
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1667 args[0]);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1668
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1669 return GAIM_CMD_RET_OK;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1670 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1671
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1672 static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1673 const char *cmd, char **args, char **error, void *data)
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1674 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1675 JabberChat *chat = jabber_chat_find_by_conv(conv);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1676 GHashTable *components;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1677
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1678 if(!args || !args[0])
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1679 return GAIM_CMD_RET_FAILED;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1680
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1681 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1682
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1683 g_hash_table_replace(components, "room", args[0]);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1684 g_hash_table_replace(components, "server", chat->server);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1685 g_hash_table_replace(components, "handle", chat->handle);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1686 if(args[1])
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1687 g_hash_table_replace(components, "password", args[1]);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1688
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1689 jabber_chat_join(gaim_conversation_get_gc(conv), components);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1690
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1691 g_hash_table_destroy(components);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1692 return GAIM_CMD_RET_OK;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1693 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1694
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1695 static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1696 const char *cmd, char **args, char **error, void *data)
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1697 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1698 JabberChat *chat = jabber_chat_find_by_conv(conv);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1699
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1700 if(!args || !args[0])
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1701 return GAIM_CMD_RET_FAILED;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1702
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1703 if(!jabber_chat_kick_user(chat, args[0], args[1])) {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1704 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1705 return GAIM_CMD_RET_FAILED;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1706 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1707
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1708 return GAIM_CMD_RET_OK;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1709 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1710
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1711 static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1712 const char *cmd, char **args, char **error, void *data)
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1713 {
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1714 JabberChat *chat = jabber_chat_find_by_conv(conv);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1715 char *who;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1716
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1717 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1718
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1719 jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1720
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1721 g_free(who);
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1722 return GAIM_CMD_RET_OK;
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1723 }
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1724
12646
5c5e03b9aed6 [gaim-migrate @ 14984]
Richard Laager <rlaager@wiktel.com>
parents: 12645
diff changeset
1725 static gboolean jabber_offline_message(const GaimBuddy *buddy)
12645
fc28451f5d96 [gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
1726 {
fc28451f5d96 [gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
1727 return TRUE;
fc28451f5d96 [gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
1728 }
fc28451f5d96 [gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
1729
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1730 static void jabber_register_commands(void)
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1731 {
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1732 gaim_cmd_register("config", "", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1733 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1734 "prpl-jabber", jabber_cmd_chat_config,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1735 _("config: Configure a chat room."), NULL);
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1736 gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1737 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1738 "prpl-jabber", jabber_cmd_chat_config,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1739 _("configure: Configure a chat room."), NULL);
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1740 gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1741 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1742 "prpl-jabber", jabber_cmd_chat_nick,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1743 _("nick &lt;new nickname&gt;: Change your nickname."),
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1744 NULL);
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1745 gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1746 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1747 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1748 jabber_cmd_chat_part, _("part [room]: Leave the room."),
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1749 NULL);
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1750 gaim_cmd_register("register", "", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1751 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1752 "prpl-jabber", jabber_cmd_chat_register,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1753 _("register: Register with a chat room."), NULL);
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1754 /* XXX: there needs to be a core /topic cmd, methinks */
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1755 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1756 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1757 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1758 jabber_cmd_chat_topic,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1759 _("topic [new topic]: View or change the topic."),
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1760 NULL);
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1761 gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1762 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1763 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1764 jabber_cmd_chat_ban,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1765 _("ban &lt;user&gt; [room]: Ban a user from the room."),
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1766 NULL);
11393
1e756e251dc3 [gaim-migrate @ 13623]
Nathan Walp <nwalp@pidgin.im>
parents: 11389
diff changeset
1767 gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL,
13237
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1768 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1769 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1770 jabber_cmd_chat_affiliate,
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1771 _("affiliate &lt;user&gt; &lt;owner|admin|member|outcast|none&gt;: Set a user's affiliation with the room."),
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1772 NULL);
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1773 gaim_cmd_register("role", "ws", GAIM_CMD_P_PRPL,
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1774 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1775 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1776 jabber_cmd_chat_role,
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1777 _("role &lt;user&gt; &lt;moderator|participant|visitor|none&gt;: Set a user's role in the room."),
b0d020a66144 [gaim-migrate @ 15603]
Etan Reisner <pidgin@unreliablesource.net>
parents: 13200
diff changeset
1778 NULL);
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1779 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1780 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1781 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1782 jabber_cmd_chat_invite,
11158
2c930d591492 [gaim-migrate @ 13245]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11033
diff changeset
1783 _("invite &lt;user&gt; [message]: Invite a user to the room."),
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1784 NULL);
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1785 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1786 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1787 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1788 jabber_cmd_chat_join,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1789 _("join: &lt;room&gt; [server]: Join a chat on this server."),
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1790 NULL);
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1791 gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1792 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1793 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1794 jabber_cmd_chat_kick,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1795 _("kick &lt;user&gt; [room]: Kick a user from the room."),
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1796 NULL);
9152
f65be7c97812 [gaim-migrate @ 9936]
Nathan Walp <nwalp@pidgin.im>
parents: 9130
diff changeset
1797 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL,
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1798 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1799 "prpl-jabber", jabber_cmd_chat_msg,
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1800 _("msg &lt;user&gt; &lt;message&gt;: Send a private message to another user."),
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9475
diff changeset
1801 NULL);
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1802 }
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1803
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1804 static GaimPluginProtocolInfo prpl_info =
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805 {
12554
9d9030dfd689 [gaim-migrate @ 14872]
Nathan Walp <nwalp@pidgin.im>
parents: 12508
diff changeset
1806 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME,
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1807 NULL, /* user_splits */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1808 NULL, /* protocol_options */
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10009
diff changeset
1809 {"jpeg,gif,png", 0, 0, 96, 96, GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1810 jabber_list_icon, /* list_icon */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1811 jabber_list_emblems, /* list_emblems */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1812 jabber_status_text, /* status_text */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1813 jabber_tooltip_text, /* tooltip_text */
9954
a9fb4493ae22 [gaim-migrate @ 10851]
Nathan Walp <nwalp@pidgin.im>
parents: 9943
diff changeset
1814 jabber_status_types, /* status_types */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1815 jabber_blist_node_menu, /* blist_node_menu */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1816 jabber_chat_info, /* chat_info */
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1817 jabber_chat_info_defaults, /* chat_info_defaults */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1818 jabber_login, /* login */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1819 jabber_close, /* close */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1820 jabber_message_send_im, /* send_im */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1821 jabber_set_info, /* set_info */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1822 jabber_send_typing, /* send_typing */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1823 jabber_buddy_get_info, /* get_info */
10216
09876d57c520 [gaim-migrate @ 11343]
Nathan Walp <nwalp@pidgin.im>
parents: 10209
diff changeset
1824 jabber_presence_send, /* set_away */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1825 jabber_idle_set, /* set_idle */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1826 NULL, /* change_passwd */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1827 jabber_roster_add_buddy, /* add_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1828 NULL, /* add_buddies */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1829 jabber_roster_remove_buddy, /* remove_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1830 NULL, /* remove_buddies */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1831 NULL, /* add_permit */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1832 NULL, /* add_deny */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1833 NULL, /* rem_permit */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1834 NULL, /* rem_deny */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1835 NULL, /* set_permit_deny */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1836 jabber_chat_join, /* join_chat */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1837 NULL, /* reject_chat */
9917
e74eb0d11f86 [gaim-migrate @ 10809]
Luke Schierer <lschiere@pidgin.im>
parents: 9754
diff changeset
1838 jabber_get_chat_name, /* get_chat_name */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1839 jabber_chat_invite, /* chat_invite */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1840 jabber_chat_leave, /* chat_leave */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1841 NULL, /* chat_whisper */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1842 jabber_message_send_chat, /* chat_send */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1843 jabber_keepalive, /* keepalive */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1844 jabber_register_account, /* register_user */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1845 jabber_buddy_get_info_chat, /* get_cb_info */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1846 NULL, /* get_cb_away */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1847 jabber_roster_alias_change, /* alias_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1848 jabber_roster_group_change, /* group_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1849 jabber_roster_group_rename, /* rename_group */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1850 NULL, /* buddy_free */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1851 jabber_convo_closed, /* convo_closed */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1852 jabber_normalize, /* normalize */
10189
4e7249591251 [gaim-migrate @ 11304]
Nathan Walp <nwalp@pidgin.im>
parents: 10009
diff changeset
1853 jabber_set_buddy_icon, /* set_buddy_icon */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1854 NULL, /* remove_group */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1855 jabber_chat_buddy_real_name, /* get_cb_real_name */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1856 jabber_chat_set_topic, /* set_chat_topic */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1857 jabber_find_blist_chat, /* find_blist_chat */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1858 jabber_roomlist_get_list, /* roomlist_get_list */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1859 jabber_roomlist_cancel, /* roomlist_cancel */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1860 NULL, /* roomlist_expand_category */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9466
diff changeset
1861 NULL, /* can_receive_file */
12143
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 11939
diff changeset
1862 jabber_si_xfer_send, /* send_file */
cbebda5f019c [gaim-migrate @ 14444]
Richard Laager <rlaager@wiktel.com>
parents: 11939
diff changeset
1863 jabber_si_new_xfer, /* new_xfer */
12645
fc28451f5d96 [gaim-migrate @ 14983]
Richard Laager <rlaager@wiktel.com>
parents: 12600
diff changeset
1864 jabber_offline_message, /* offline_message */
12600
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12595
diff changeset
1865 NULL, /* whiteboard_prpl_ops */
e856f985a0b9 [gaim-migrate @ 14934]
Richard Laager <rlaager@wiktel.com>
parents: 12595
diff changeset
1866 NULL, /* media_prpl_ops */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1867 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1868
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1869 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1870 {
9943
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
1871 GAIM_PLUGIN_MAGIC,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
1872 GAIM_MAJOR_VERSION,
f8e395a054e2 [gaim-migrate @ 10835]
Nathan Walp <nwalp@pidgin.im>
parents: 9917
diff changeset
1873 GAIM_MINOR_VERSION,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1874 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1875 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1876 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1877 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1878 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1879
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1880 "prpl-jabber", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1881 "Jabber", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1882 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1883 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1884 N_("Jabber Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1885 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1886 N_("Jabber Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1887 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6357
diff changeset
1888 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1889
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1890 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1891 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1892 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1893
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1894 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8950
diff changeset
1895 &prpl_info, /**< extra_info */
10487
659edfcac14e [gaim-migrate @ 11777]
Sean Egan <seanegan@gmail.com>
parents: 10486
diff changeset
1896 NULL, /**< prefs_info */
9015
67421e0dc497 [gaim-migrate @ 9791]
Luke Schierer <lschiere@pidgin.im>
parents: 8993
diff changeset
1897 jabber_actions
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1898 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1899
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1900 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5894
diff changeset
1901 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1902 {
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1903 GaimAccountUserSplit *split;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1904 GaimAccountOption *option;
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1905
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1906 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@');
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1907 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
1908
11939
85c25a32bb48 [gaim-migrate @ 14230]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11837
diff changeset
1909 split = gaim_account_user_split_new(_("Resource"), "Home", '/');
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1910 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
1911
7630
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1912 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
1913 TRUE);
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1914 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1915 option);
2df4d470c12a [gaim-migrate @ 8254]
Nathan Walp <nwalp@pidgin.im>
parents: 7587
diff changeset
1916
10941
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10751
diff changeset
1917 option = gaim_account_option_bool_new(_("Require TLS"), "require_tls", TRUE);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10751
diff changeset
1918 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10751
diff changeset
1919
cef48e318125 [gaim-migrate @ 12731]
Nathan Walp <nwalp@pidgin.im>
parents: 10751
diff changeset
1920 option = gaim_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE);
7124
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1921 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
be4ca65b3b48 [gaim-migrate @ 7691]
Nathan Walp <nwalp@pidgin.im>
parents: 7116
diff changeset
1922 option);
6764
6d0d4e9149b9 [gaim-migrate @ 7296]
Nathan Walp <nwalp@pidgin.im>
parents: 6695
diff changeset
1923
8086
55431e80a783 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
1924 option = gaim_account_option_bool_new(
55431e80a783 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
1925 _("Allow plaintext auth over unencrypted streams"),
55431e80a783 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
1926 "auth_plain_in_clear", FALSE);
55431e80a783 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
1927 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
55431e80a783 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
1928 option);
55431e80a783 [gaim-migrate @ 8785]
Nathan Walp <nwalp@pidgin.im>
parents: 8043
diff changeset
1929
11387
012bb2eed54b [gaim-migrate @ 13615]
Nathan Walp <nwalp@pidgin.im>
parents: 11257
diff changeset
1930 option = gaim_account_option_int_new(_("Connect port"), "port", 5222);
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1931 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
1932 option);
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1933
5685
43ea75092684 [gaim-migrate @ 6106]
Christian Hammond <chipx86@chipx86.com>
parents: 5681
diff changeset
1934 option = gaim_account_option_string_new(_("Connect server"),
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1935 "connect_server", NULL);
5638
0bdfa28c678e [gaim-migrate @ 6047]
Christian Hammond <chipx86@chipx86.com>
parents: 5613
diff changeset
1936 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
1937 option);
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1938
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5174
diff changeset
1939 my_protocol = plugin;
7014
67c4e9d39242 [gaim-migrate @ 7577]
Nathan Walp <nwalp@pidgin.im>
parents: 6982
diff changeset
1940
10487
659edfcac14e [gaim-migrate @ 11777]
Sean Egan <seanegan@gmail.com>
parents: 10486
diff changeset
1941 gaim_prefs_remove("/plugins/prpl/jabber");
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1942
12508
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
1943 /* XXX - If any other plugin wants SASL this won't be good ... */
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
1944 #ifdef HAVE_CYRUS_SASL
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
1945 sasl_client_init(NULL);
5cfc53ead482 [gaim-migrate @ 14820]
Nathan Walp <nwalp@pidgin.im>
parents: 12394
diff changeset
1946 #endif
9130
933a19e3a6b3 [gaim-migrate @ 9908]
Nathan Walp <nwalp@pidgin.im>
parents: 9030
diff changeset
1947 jabber_register_commands();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1948 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1949
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5894
diff changeset
1950 GAIM_INIT_PLUGIN(jabber, init_plugin, info);