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