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