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