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
|
14391
|
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 }
|
|
1050
|
|
1051 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b)
|
|
1052 {
|
|
1053 return "jabber";
|
|
1054 }
|
|
1055
|
|
1056 static void jabber_list_emblems(GaimBuddy *b, const char **se, const char **sw,
|
|
1057 const char **nw, const char **ne)
|
|
1058 {
|
|
1059 JabberStream *js;
|
|
1060 JabberBuddy *jb = NULL;
|
|
1061
|
|
1062 if(!b->account->gc)
|
|
1063 return;
|
|
1064 js = b->account->gc->proto_data;
|
|
1065 if(js)
|
|
1066 jb = jabber_buddy_find(js, b->name, FALSE);
|
|
1067
|
|
1068 if(!GAIM_BUDDY_IS_ONLINE(b)) {
|
|
1069 if(jb && jb->error_msg)
|
|
1070 *nw = "error";
|
|
1071
|
|
1072 if(jb && (jb->subscription & JABBER_SUB_PENDING ||
|
|
1073 !(jb->subscription & JABBER_SUB_TO)))
|
|
1074 *se = "notauthorized";
|
|
1075 else
|
|
1076 *se = "offline";
|
|
1077 } else {
|
|
1078 GaimStatusType *status_type = gaim_status_get_type(gaim_presence_get_active_status(gaim_buddy_get_presence(b)));
|
|
1079 GaimStatusPrimitive primitive = gaim_status_type_get_primitive(status_type);
|
|
1080
|
|
1081 if(primitive > GAIM_STATUS_AVAILABLE) {
|
|
1082 *se = gaim_status_type_get_id(status_type);
|
|
1083 }
|
|
1084 }
|
|
1085 }
|
|
1086
|
|
1087 static char *jabber_status_text(GaimBuddy *b)
|
|
1088 {
|
|
1089 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name,
|
|
1090 FALSE);
|
|
1091 char *ret = NULL;
|
|
1092
|
|
1093 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) {
|
|
1094 ret = g_strdup(_("Not Authorized"));
|
|
1095 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) {
|
|
1096 ret = g_strdup(jb->error_msg);
|
|
1097 } else {
|
|
1098 char *stripped;
|
|
1099
|
|
1100 if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) {
|
|
1101 GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b));
|
|
1102
|
|
1103 if(!gaim_status_is_available(status))
|
|
1104 stripped = g_strdup(gaim_status_get_name(status));
|
|
1105 }
|
|
1106
|
|
1107 if(stripped) {
|
|
1108 ret = g_markup_escape_text(stripped, -1);
|
|
1109 g_free(stripped);
|
|
1110 }
|
|
1111 }
|
|
1112
|
|
1113 return ret;
|
|
1114 }
|
|
1115
|
|
1116 static void jabber_tooltip_text(GaimBuddy *b, GString *str, gboolean full)
|
|
1117 {
|
|
1118 JabberBuddy *jb;
|
|
1119
|
|
1120 g_return_if_fail(b != NULL);
|
|
1121 g_return_if_fail(b->account != NULL);
|
|
1122 g_return_if_fail(b->account->gc != NULL);
|
|
1123 g_return_if_fail(b->account->gc->proto_data != NULL);
|
|
1124
|
|
1125 jb = jabber_buddy_find(b->account->gc->proto_data, b->name,
|
|
1126 FALSE);
|
|
1127
|
|
1128 if(jb) {
|
|
1129 JabberBuddyResource *jbr = NULL;
|
|
1130 const char *sub;
|
|
1131 GList *l;
|
|
1132
|
|
1133 if (full) {
|
|
1134 if(jb->subscription & JABBER_SUB_FROM) {
|
|
1135 if(jb->subscription & JABBER_SUB_TO)
|
|
1136 sub = _("Both");
|
|
1137 else if(jb->subscription & JABBER_SUB_PENDING)
|
|
1138 sub = _("From (To pending)");
|
|
1139 else
|
|
1140 sub = _("From");
|
|
1141 } else {
|
|
1142 if(jb->subscription & JABBER_SUB_TO)
|
|
1143 sub = _("To");
|
|
1144 else if(jb->subscription & JABBER_SUB_PENDING)
|
|
1145 sub = _("None (To pending)");
|
|
1146 else
|
|
1147 sub = _("None");
|
|
1148 }
|
|
1149 g_string_append_printf(str, "\n<b>%s:</b> %s", _("Subscription"), sub);
|
|
1150 }
|
|
1151
|
|
1152 for(l=jb->resources; l; l = l->next) {
|
|
1153 char *text = NULL;
|
|
1154 char *res = NULL;
|
|
1155 const char *state;
|
|
1156
|
|
1157 jbr = l->data;
|
|
1158
|
|
1159 if(jbr->status) {
|
|
1160 char *tmp;
|
|
1161 text = gaim_strreplace(jbr->status, "\n", "<br />\n");
|
|
1162 tmp = gaim_markup_strip_html(text);
|
|
1163 g_free(text);
|
|
1164 text = g_markup_escape_text(tmp, -1);
|
|
1165 g_free(tmp);
|
|
1166 }
|
|
1167
|
|
1168 if(jbr->name)
|
|
1169 res = g_strdup_printf(" (%s)", jbr->name);
|
|
1170
|
|
1171 state = jabber_buddy_state_get_name(jbr->state);
|
|
1172 if (text != NULL && !gaim_utf8_strcasecmp(state, text)) {
|
|
1173 g_free(text);
|
|
1174 text = NULL;
|
|
1175 }
|
|
1176
|
|
1177 g_string_append_printf(str, "\n<b>%s%s:</b> %s%s%s",
|
|
1178 _("Status"),
|
|
1179 res ? res : "",
|
|
1180 state,
|
|
1181 text ? ": " : "",
|
|
1182 text ? text : "");
|
|
1183
|
|
1184 g_free(text);
|
|
1185 g_free(res);
|
|
1186 }
|
|
1187
|
|
1188 if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) {
|
|
1189 g_string_append_printf(str, "\n<b>%s:</b> %s",
|
|
1190 _("Error"), jb->error_msg);
|
|
1191 }
|
|
1192 }
|
|
1193 }
|
|
1194
|
|
1195 static GList *jabber_status_types(GaimAccount *account)
|
|
1196 {
|
|
1197 GaimStatusType *type;
|
|
1198 GList *types = NULL;
|
|
1199 GaimValue *priority_value;
|
|
1200
|
|
1201 priority_value = gaim_value_new(GAIM_TYPE_INT);
|
|
1202 gaim_value_set_int(priority_value, 1);
|
|
1203 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE,
|
|
1204 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
|
|
1205 NULL, TRUE, TRUE, FALSE,
|
|
1206 "priority", _("Priority"), priority_value,
|
|
1207 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
|
|
1208 NULL);
|
|
1209 types = g_list_append(types, type);
|
|
1210
|
|
1211 priority_value = gaim_value_new(GAIM_TYPE_INT);
|
|
1212 gaim_value_set_int(priority_value, 1);
|
|
1213 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE,
|
|
1214 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
|
|
1215 _("Chatty"), TRUE, TRUE, FALSE,
|
|
1216 "priority", _("Priority"), priority_value,
|
|
1217 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
|
|
1218 NULL);
|
|
1219 types = g_list_append(types, type);
|
|
1220
|
|
1221 priority_value = gaim_value_new(GAIM_TYPE_INT);
|
|
1222 gaim_value_set_int(priority_value, 0);
|
|
1223 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY,
|
|
1224 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
|
|
1225 NULL, TRUE, TRUE, FALSE,
|
|
1226 "priority", _("Priority"), priority_value,
|
|
1227 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
|
|
1228 NULL);
|
|
1229 types = g_list_append(types, type);
|
|
1230
|
|
1231 priority_value = gaim_value_new(GAIM_TYPE_INT);
|
|
1232 gaim_value_set_int(priority_value, 0);
|
|
1233 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY,
|
|
1234 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
|
|
1235 NULL, TRUE, TRUE, FALSE,
|
|
1236 "priority", _("Priority"), priority_value,
|
|
1237 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
|
|
1238 NULL);
|
|
1239 types = g_list_append(types, type);
|
|
1240
|
|
1241 priority_value = gaim_value_new(GAIM_TYPE_INT);
|
|
1242 gaim_value_set_int(priority_value, 0);
|
|
1243 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE,
|
|
1244 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND),
|
|
1245 _("Do Not Disturb"), TRUE, TRUE, FALSE,
|
|
1246 "priority", _("Priority"), priority_value,
|
|
1247 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
|
|
1248 NULL);
|
|
1249 types = g_list_append(types, type);
|
|
1250
|
|
1251 /*
|
|
1252 if(js->protocol_version == JABBER_PROTO_0_9)
|
|
1253 m = g_list_append(m, _("Invisible"));
|
|
1254 */
|
|
1255
|
|
1256 type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE,
|
|
1257 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE),
|
|
1258 NULL, FALSE, TRUE, FALSE,
|
|
1259 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING),
|
|
1260 NULL);
|
|
1261 types = g_list_append(types, type);
|
|
1262
|
|
1263 return types;
|
|
1264 }
|
|
1265
|
|
1266 static void
|
|
1267 jabber_password_change_result_cb(JabberStream *js, xmlnode *packet,
|
|
1268 gpointer data)
|
|
1269 {
|
|
1270 const char *type;
|
|
1271
|
|
1272 type = xmlnode_get_attrib(packet, "type");
|
|
1273
|
|
1274 if(type && !strcmp(type, "result")) {
|
|
1275 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
|
|
1276 _("Your password has been changed."));
|
|
1277 } else {
|
|
1278 char *msg = jabber_parse_error(js, packet);
|
|
1279
|
|
1280 gaim_notify_error(js->gc, _("Error changing password"),
|
|
1281 _("Error changing password"), msg);
|
|
1282 g_free(msg);
|
|
1283 }
|
|
1284 }
|
|
1285
|
|
1286 static void jabber_password_change_cb(JabberStream *js,
|
|
1287 GaimRequestFields *fields)
|
|
1288 {
|
|
1289 const char *p1, *p2;
|
|
1290 JabberIq *iq;
|
|
1291 xmlnode *query, *y;
|
|
1292
|
|
1293 p1 = gaim_request_fields_get_string(fields, "password1");
|
|
1294 p2 = gaim_request_fields_get_string(fields, "password2");
|
|
1295
|
|
1296 if(strcmp(p1, p2)) {
|
|
1297 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL);
|
|
1298 return;
|
|
1299 }
|
|
1300
|
|
1301 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
|
|
1302
|
|
1303 xmlnode_set_attrib(iq->node, "to", js->user->domain);
|
|
1304
|
|
1305 query = xmlnode_get_child(iq->node, "query");
|
|
1306
|
|
1307 y = xmlnode_new_child(query, "username");
|
|
1308 xmlnode_insert_data(y, js->user->node, -1);
|
|
1309 y = xmlnode_new_child(query, "password");
|
|
1310 xmlnode_insert_data(y, p1, -1);
|
|
1311
|
|
1312 jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL);
|
|
1313
|
|
1314 jabber_iq_send(iq);
|
|
1315
|
|
1316 gaim_account_set_password(js->gc->account, p1);
|
|
1317 }
|
|
1318
|
|
1319 static void jabber_password_change(GaimPluginAction *action)
|
|
1320 {
|
|
1321
|
|
1322 GaimConnection *gc = (GaimConnection *) action->context;
|
|
1323 JabberStream *js = gc->proto_data;
|
|
1324 GaimRequestFields *fields;
|
|
1325 GaimRequestFieldGroup *group;
|
|
1326 GaimRequestField *field;
|
|
1327
|
|
1328 fields = gaim_request_fields_new();
|
|
1329 group = gaim_request_field_group_new(NULL);
|
|
1330 gaim_request_fields_add_group(fields, group);
|
|
1331
|
|
1332 field = gaim_request_field_string_new("password1", _("Password"),
|
|
1333 "", FALSE);
|
|
1334 gaim_request_field_string_set_masked(field, TRUE);
|
|
1335 gaim_request_field_group_add_field(group, field);
|
|
1336
|
|
1337 field = gaim_request_field_string_new("password2", _("Password (again)"),
|
|
1338 "", FALSE);
|
|
1339 gaim_request_field_string_set_masked(field, TRUE);
|
|
1340 gaim_request_field_group_add_field(group, field);
|
|
1341
|
|
1342 gaim_request_fields(js->gc, _("Change Jabber Password"),
|
|
1343 _("Change Jabber Password"), _("Please enter your new password"),
|
|
1344 fields, _("OK"), G_CALLBACK(jabber_password_change_cb),
|
|
1345 _("Cancel"), NULL, js);
|
|
1346 }
|
|
1347
|
|
1348 static GList *jabber_actions(GaimPlugin *plugin, gpointer context)
|
|
1349 {
|
|
1350 GList *m = NULL;
|
|
1351 GaimPluginAction *act;
|
|
1352
|
|
1353 act = gaim_plugin_action_new(_("Set User Info..."),
|
|
1354 jabber_setup_set_info);
|
|
1355 m = g_list_append(m, act);
|
|
1356
|
|
1357 /* if (js->protocol_options & CHANGE_PASSWORD) { */
|
|
1358 act = gaim_plugin_action_new(_("Change Password..."),
|
|
1359 jabber_password_change);
|
|
1360 m = g_list_append(m, act);
|
|
1361 /* } */
|
|
1362
|
|
1363 act = gaim_plugin_action_new(_("Search for Users..."),
|
|
1364 jabber_user_search_begin);
|
|
1365 m = g_list_append(m, act);
|
|
1366
|
|
1367 return m;
|
|
1368 }
|
|
1369
|
|
1370 static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name)
|
|
1371 {
|
|
1372 GaimBlistNode *gnode, *cnode;
|
|
1373 JabberID *jid;
|
|
1374
|
|
1375 if(!(jid = jabber_id_new(name)))
|
|
1376 return NULL;
|
|
1377
|
|
1378 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
|
|
1379 for(cnode = gnode->child; cnode; cnode = cnode->next) {
|
|
1380 GaimChat *chat = (GaimChat*)cnode;
|
|
1381 const char *room, *server;
|
|
1382 if(!GAIM_BLIST_NODE_IS_CHAT(cnode))
|
|
1383 continue;
|
|
1384
|
|
1385 if(chat->account != account)
|
|
1386 continue;
|
|
1387
|
|
1388 if(!(room = g_hash_table_lookup(chat->components, "room")))
|
|
1389 continue;
|
|
1390 if(!(server = g_hash_table_lookup(chat->components, "server")))
|
|
1391 continue;
|
|
1392
|
|
1393 if(jid->node && jid->domain &&
|
|
1394 !g_utf8_collate(room, jid->node) && !g_utf8_collate(server, jid->domain)) {
|
|
1395 jabber_id_free(jid);
|
|
1396 return chat;
|
|
1397 }
|
|
1398 }
|
|
1399 }
|
|
1400 jabber_id_free(jid);
|
|
1401 return NULL;
|
|
1402 }
|
|
1403
|
|
1404 static void jabber_convo_closed(GaimConnection *gc, const char *who)
|
|
1405 {
|
|
1406 JabberStream *js = gc->proto_data;
|
|
1407 JabberID *jid;
|
|
1408 JabberBuddy *jb;
|
|
1409 JabberBuddyResource *jbr;
|
|
1410
|
|
1411 if(!(jid = jabber_id_new(who)))
|
|
1412 return;
|
|
1413
|
|
1414 if((jb = jabber_buddy_find(js, who, TRUE)) &&
|
|
1415 (jbr = jabber_buddy_find_resource(jb, jid->resource))) {
|
|
1416 if(jbr->thread_id) {
|
|
1417 g_free(jbr->thread_id);
|
|
1418 jbr->thread_id = NULL;
|
|
1419 }
|
|
1420 }
|
|
1421
|
|
1422 jabber_id_free(jid);
|
|
1423 }
|
|
1424
|
|
1425
|
|
1426 char *jabber_parse_error(JabberStream *js, xmlnode *packet)
|
|
1427 {
|
|
1428 xmlnode *error;
|
|
1429 const char *code = NULL, *text = NULL;
|
|
1430 const char *xmlns = xmlnode_get_namespace(packet);
|
|
1431 char *cdata = NULL;
|
|
1432
|
|
1433 if((error = xmlnode_get_child(packet, "error"))) {
|
|
1434 cdata = xmlnode_get_data(error);
|
|
1435 code = xmlnode_get_attrib(error, "code");
|
|
1436
|
|
1437 /* Stanza errors */
|
|
1438 if(xmlnode_get_child(error, "bad-request")) {
|
|
1439 text = _("Bad Request");
|
|
1440 } else if(xmlnode_get_child(error, "conflict")) {
|
|
1441 text = _("Conflict");
|
|
1442 } else if(xmlnode_get_child(error, "feature-not-implemented")) {
|
|
1443 text = _("Feature Not Implemented");
|
|
1444 } else if(xmlnode_get_child(error, "forbidden")) {
|
|
1445 text = _("Forbidden");
|
|
1446 } else if(xmlnode_get_child(error, "gone")) {
|
|
1447 text = _("Gone");
|
|
1448 } else if(xmlnode_get_child(error, "internal-server-error")) {
|
|
1449 text = _("Internal Server Error");
|
|
1450 } else if(xmlnode_get_child(error, "item-not-found")) {
|
|
1451 text = _("Item Not Found");
|
|
1452 } else if(xmlnode_get_child(error, "jid-malformed")) {
|
|
1453 text = _("Malformed Jabber ID");
|
|
1454 } else if(xmlnode_get_child(error, "not-acceptable")) {
|
|
1455 text = _("Not Acceptable");
|
|
1456 } else if(xmlnode_get_child(error, "not-allowed")) {
|
|
1457 text = _("Not Allowed");
|
|
1458 } else if(xmlnode_get_child(error, "not-authorized")) {
|
|
1459 text = _("Not Authorized");
|
|
1460 } else if(xmlnode_get_child(error, "payment-required")) {
|
|
1461 text = _("Payment Required");
|
|
1462 } else if(xmlnode_get_child(error, "recipient-unavailable")) {
|
|
1463 text = _("Recipient Unavailable");
|
|
1464 } else if(xmlnode_get_child(error, "redirect")) {
|
|
1465 /* XXX */
|
|
1466 } else if(xmlnode_get_child(error, "registration-required")) {
|
|
1467 text = _("Registration Required");
|
|
1468 } else if(xmlnode_get_child(error, "remote-server-not-found")) {
|
|
1469 text = _("Remote Server Not Found");
|
|
1470 } else if(xmlnode_get_child(error, "remote-server-timeout")) {
|
|
1471 text = _("Remote Server Timeout");
|
|
1472 } else if(xmlnode_get_child(error, "resource-constraint")) {
|
|
1473 text = _("Server Overloaded");
|
|
1474 } else if(xmlnode_get_child(error, "service-unavailable")) {
|
|
1475 text = _("Service Unavailable");
|
|
1476 } else if(xmlnode_get_child(error, "subscription-required")) {
|
|
1477 text = _("Subscription Required");
|
|
1478 } else if(xmlnode_get_child(error, "unexpected-request")) {
|
|
1479 text = _("Unexpected Request");
|
|
1480 } else if(xmlnode_get_child(error, "undefined-condition")) {
|
|
1481 text = _("Unknown Error");
|
|
1482 }
|
|
1483 } else if(xmlns && !strcmp(xmlns, "urn:ietf:params:xml:ns:xmpp-sasl")) {
|
|
1484 if(xmlnode_get_child(packet, "aborted")) {
|
|
1485 js->gc->wants_to_die = TRUE;
|
|
1486 text = _("Authorization Aborted");
|
|
1487 } else if(xmlnode_get_child(packet, "incorrect-encoding")) {
|
|
1488 text = _("Incorrect encoding in authorization");
|
|
1489 } else if(xmlnode_get_child(packet, "invalid-authzid")) {
|
|
1490 js->gc->wants_to_die = TRUE;
|
|
1491 text = _("Invalid authzid");
|
|
1492 } else if(xmlnode_get_child(packet, "invalid-mechanism")) {
|
|
1493 js->gc->wants_to_die = TRUE;
|
|
1494 text = _("Invalid Authorization Mechanism");
|
|
1495 } else if(xmlnode_get_child(packet, "mechanism-too-weak")) {
|
|
1496 js->gc->wants_to_die = TRUE;
|
|
1497 text = _("Authorization mechanism too weak");
|
|
1498 } else if(xmlnode_get_child(packet, "not-authorized")) {
|
|
1499 js->gc->wants_to_die = TRUE;
|
|
1500 text = _("Not Authorized");
|
|
1501 } else if(xmlnode_get_child(packet, "temporary-auth-failure")) {
|
|
1502 text = _("Temporary Authentication Failure");
|
|
1503 } else {
|
|
1504 js->gc->wants_to_die = TRUE;
|
|
1505 text = _("Authentication Failure");
|
|
1506 }
|
|
1507 } else if(!strcmp(packet->name, "stream:error")) {
|
|
1508 if(xmlnode_get_child(packet, "bad-format")) {
|
|
1509 text = _("Bad Format");
|
|
1510 } else if(xmlnode_get_child(packet, "bad-namespace-prefix")) {
|
|
1511 text = _("Bad Namespace Prefix");
|
|
1512 } else if(xmlnode_get_child(packet, "conflict")) {
|
|
1513 js->gc->wants_to_die = TRUE;
|
|
1514 text = _("Resource Conflict");
|
|
1515 } else if(xmlnode_get_child(packet, "connection-timeout")) {
|
|
1516 text = _("Connection Timeout");
|
|
1517 } else if(xmlnode_get_child(packet, "host-gone")) {
|
|
1518 text = _("Host Gone");
|
|
1519 } else if(xmlnode_get_child(packet, "host-unknown")) {
|
|
1520 text = _("Host Unknown");
|
|
1521 } else if(xmlnode_get_child(packet, "improper-addressing")) {
|
|
1522 text = _("Improper Addressing");
|
|
1523 } else if(xmlnode_get_child(packet, "internal-server-error")) {
|
|
1524 text = _("Internal Server Error");
|
|
1525 } else if(xmlnode_get_child(packet, "invalid-id")) {
|
|
1526 text = _("Invalid ID");
|
|
1527 } else if(xmlnode_get_child(packet, "invalid-namespace")) {
|
|
1528 text = _("Invalid Namespace");
|
|
1529 } else if(xmlnode_get_child(packet, "invalid-xml")) {
|
|
1530 text = _("Invalid XML");
|
|
1531 } else if(xmlnode_get_child(packet, "nonmatching-hosts")) {
|
|
1532 text = _("Non-matching Hosts");
|
|
1533 } else if(xmlnode_get_child(packet, "not-authorized")) {
|
|
1534 text = _("Not Authorized");
|
|
1535 } else if(xmlnode_get_child(packet, "policy-violation")) {
|
|
1536 text = _("Policy Violation");
|
|
1537 } else if(xmlnode_get_child(packet, "remote-connection-failed")) {
|
|
1538 text = _("Remote Connection Failed");
|
|
1539 } else if(xmlnode_get_child(packet, "resource-constraint")) {
|
|
1540 text = _("Resource Constraint");
|
|
1541 } else if(xmlnode_get_child(packet, "restricted-xml")) {
|
|
1542 text = _("Restricted XML");
|
|
1543 } else if(xmlnode_get_child(packet, "see-other-host")) {
|
|
1544 text = _("See Other Host");
|
|
1545 } else if(xmlnode_get_child(packet, "system-shutdown")) {
|
|
1546 text = _("System Shutdown");
|
|
1547 } else if(xmlnode_get_child(packet, "undefined-condition")) {
|
|
1548 text = _("Undefined Condition");
|
|
1549 } else if(xmlnode_get_child(packet, "unsupported-encoding")) {
|
|
1550 text = _("Unsupported Encoding");
|
|
1551 } else if(xmlnode_get_child(packet, "unsupported-stanza-type")) {
|
|
1552 text = _("Unsupported Stanza Type");
|
|
1553 } else if(xmlnode_get_child(packet, "unsupported-version")) {
|
|
1554 text = _("Unsupported Version");
|
|
1555 } else if(xmlnode_get_child(packet, "xml-not-well-formed")) {
|
|
1556 text = _("XML Not Well Formed");
|
|
1557 } else {
|
|
1558 text = _("Stream Error");
|
|
1559 }
|
|
1560 }
|
|
1561
|
|
1562 if(text || cdata) {
|
|
1563 char *ret = g_strdup_printf("%s%s%s", code ? code : "",
|
|
1564 code ? ": " : "", text ? text : cdata);
|
|
1565 g_free(cdata);
|
|
1566 return ret;
|
|
1567 } else {
|
|
1568 return NULL;
|
|
1569 }
|
|
1570 }
|
|
1571
|
|
1572 static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv,
|
|
1573 const char *cmd, char **args, char **error, void *data)
|
|
1574 {
|
|
1575 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1576 jabber_chat_request_room_configure(chat);
|
|
1577 return GAIM_CMD_RET_OK;
|
|
1578 }
|
|
1579
|
|
1580 static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv,
|
|
1581 const char *cmd, char **args, char **error, void *data)
|
|
1582 {
|
|
1583 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1584 jabber_chat_register(chat);
|
|
1585 return GAIM_CMD_RET_OK;
|
|
1586 }
|
|
1587
|
|
1588 static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv,
|
|
1589 const char *cmd, char **args, char **error, void *data)
|
|
1590 {
|
|
1591 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1592 jabber_chat_change_topic(chat, args ? args[0] : NULL);
|
|
1593 return GAIM_CMD_RET_OK;
|
|
1594 }
|
|
1595
|
|
1596 static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv,
|
|
1597 const char *cmd, char **args, char **error, void *data)
|
|
1598 {
|
|
1599 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1600
|
|
1601 if(!args || !args[0])
|
|
1602 return GAIM_CMD_RET_FAILED;
|
|
1603
|
|
1604 jabber_chat_change_nick(chat, args[0]);
|
|
1605 return GAIM_CMD_RET_OK;
|
|
1606 }
|
|
1607
|
|
1608 static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv,
|
|
1609 const char *cmd, char **args, char **error, void *data)
|
|
1610 {
|
|
1611 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1612 jabber_chat_part(chat, args ? args[0] : NULL);
|
|
1613 return GAIM_CMD_RET_OK;
|
|
1614 }
|
|
1615
|
|
1616 static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv,
|
|
1617 const char *cmd, char **args, char **error, void *data)
|
|
1618 {
|
|
1619 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1620
|
|
1621 if(!args || !args[0])
|
|
1622 return GAIM_CMD_RET_FAILED;
|
|
1623
|
|
1624 if(!jabber_chat_ban_user(chat, args[0], args[1])) {
|
|
1625 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]);
|
|
1626 return GAIM_CMD_RET_FAILED;
|
|
1627 }
|
|
1628
|
|
1629 return GAIM_CMD_RET_OK;
|
|
1630 }
|
|
1631
|
|
1632 static GaimCmdRet jabber_cmd_chat_affiliate(GaimConversation *conv,
|
|
1633 const char *cmd, char **args, char **error, void *data)
|
|
1634 {
|
|
1635 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1636
|
|
1637 if (!args || !args[0] || !args[1])
|
|
1638 return GAIM_CMD_RET_FAILED;
|
|
1639
|
|
1640 if (strcmp(args[1], "owner") != 0 &&
|
|
1641 strcmp(args[1], "admin") != 0 &&
|
|
1642 strcmp(args[1], "member") != 0 &&
|
|
1643 strcmp(args[1], "outcast") != 0 &&
|
|
1644 strcmp(args[1], "none") != 0) {
|
|
1645 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]);
|
|
1646 return GAIM_CMD_RET_FAILED;
|
|
1647 }
|
|
1648
|
|
1649 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) {
|
|
1650 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]);
|
|
1651 return GAIM_CMD_RET_FAILED;
|
|
1652 }
|
|
1653
|
|
1654 return GAIM_CMD_RET_OK;
|
|
1655 }
|
|
1656
|
|
1657 static GaimCmdRet jabber_cmd_chat_role(GaimConversation *conv,
|
|
1658 const char *cmd, char **args, char **error, void *data)
|
|
1659 {
|
|
1660 JabberChat *chat;
|
|
1661
|
|
1662 if (!args || !args[0] || !args[1])
|
|
1663 return GAIM_CMD_RET_FAILED;
|
|
1664
|
|
1665 if (strcmp(args[1], "moderator") != 0 &&
|
|
1666 strcmp(args[1], "participant") != 0 &&
|
|
1667 strcmp(args[1], "visitor") != 0 &&
|
|
1668 strcmp(args[1], "none") != 0) {
|
|
1669 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]);
|
|
1670 return GAIM_CMD_RET_FAILED;
|
|
1671 }
|
|
1672
|
|
1673 chat = jabber_chat_find_by_conv(conv);
|
|
1674
|
|
1675 if (!jabber_chat_role_user(chat, args[0], args[1])) {
|
|
1676 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
|
|
1677 args[1], args[0]);
|
|
1678 return GAIM_CMD_RET_FAILED;
|
|
1679 }
|
|
1680
|
|
1681 return GAIM_CMD_RET_OK;
|
|
1682 }
|
|
1683
|
|
1684 static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv,
|
|
1685 const char *cmd, char **args, char **error, void *data)
|
|
1686 {
|
|
1687 if(!args || !args[0])
|
|
1688 return GAIM_CMD_RET_FAILED;
|
|
1689
|
|
1690 jabber_chat_invite(gaim_conversation_get_gc(conv),
|
|
1691 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "",
|
|
1692 args[0]);
|
|
1693
|
|
1694 return GAIM_CMD_RET_OK;
|
|
1695 }
|
|
1696
|
|
1697 static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv,
|
|
1698 const char *cmd, char **args, char **error, void *data)
|
|
1699 {
|
|
1700 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1701 GHashTable *components;
|
|
1702
|
|
1703 if(!args || !args[0])
|
|
1704 return GAIM_CMD_RET_FAILED;
|
|
1705
|
|
1706 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
|
|
1707
|
|
1708 g_hash_table_replace(components, "room", args[0]);
|
|
1709 g_hash_table_replace(components, "server", chat->server);
|
|
1710 g_hash_table_replace(components, "handle", chat->handle);
|
|
1711 if(args[1])
|
|
1712 g_hash_table_replace(components, "password", args[1]);
|
|
1713
|
|
1714 jabber_chat_join(gaim_conversation_get_gc(conv), components);
|
|
1715
|
|
1716 g_hash_table_destroy(components);
|
|
1717 return GAIM_CMD_RET_OK;
|
|
1718 }
|
|
1719
|
|
1720 static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv,
|
|
1721 const char *cmd, char **args, char **error, void *data)
|
|
1722 {
|
|
1723 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1724
|
|
1725 if(!args || !args[0])
|
|
1726 return GAIM_CMD_RET_FAILED;
|
|
1727
|
|
1728 if(!jabber_chat_kick_user(chat, args[0], args[1])) {
|
|
1729 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]);
|
|
1730 return GAIM_CMD_RET_FAILED;
|
|
1731 }
|
|
1732
|
|
1733 return GAIM_CMD_RET_OK;
|
|
1734 }
|
|
1735
|
|
1736 static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv,
|
|
1737 const char *cmd, char **args, char **error, void *data)
|
|
1738 {
|
|
1739 JabberChat *chat = jabber_chat_find_by_conv(conv);
|
|
1740 char *who;
|
|
1741
|
|
1742 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
|
|
1743
|
|
1744 jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0);
|
|
1745
|
|
1746 g_free(who);
|
|
1747 return GAIM_CMD_RET_OK;
|
|
1748 }
|
|
1749
|
|
1750 static gboolean jabber_offline_message(const GaimBuddy *buddy)
|
|
1751 {
|
|
1752 return TRUE;
|
|
1753 }
|
|
1754
|
|
1755 static void jabber_register_commands(void)
|
|
1756 {
|
|
1757 gaim_cmd_register("config", "", GAIM_CMD_P_PRPL,
|
|
1758 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1759 "prpl-jabber", jabber_cmd_chat_config,
|
|
1760 _("config: Configure a chat room."), NULL);
|
|
1761 gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL,
|
|
1762 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1763 "prpl-jabber", jabber_cmd_chat_config,
|
|
1764 _("configure: Configure a chat room."), NULL);
|
|
1765 gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL,
|
|
1766 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1767 "prpl-jabber", jabber_cmd_chat_nick,
|
|
1768 _("nick <new nickname>: Change your nickname."),
|
|
1769 NULL);
|
|
1770 gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL,
|
|
1771 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1772 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1773 jabber_cmd_chat_part, _("part [room]: Leave the room."),
|
|
1774 NULL);
|
|
1775 gaim_cmd_register("register", "", GAIM_CMD_P_PRPL,
|
|
1776 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1777 "prpl-jabber", jabber_cmd_chat_register,
|
|
1778 _("register: Register with a chat room."), NULL);
|
|
1779 /* XXX: there needs to be a core /topic cmd, methinks */
|
|
1780 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL,
|
|
1781 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1782 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1783 jabber_cmd_chat_topic,
|
|
1784 _("topic [new topic]: View or change the topic."),
|
|
1785 NULL);
|
|
1786 gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL,
|
|
1787 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1788 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1789 jabber_cmd_chat_ban,
|
|
1790 _("ban <user> [room]: Ban a user from the room."),
|
|
1791 NULL);
|
|
1792 gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL,
|
|
1793 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1794 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1795 jabber_cmd_chat_affiliate,
|
|
1796 _("affiliate <user> <owner|admin|member|outcast|none>: Set a user's affiliation with the room."),
|
|
1797 NULL);
|
|
1798 gaim_cmd_register("role", "ws", GAIM_CMD_P_PRPL,
|
|
1799 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1800 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1801 jabber_cmd_chat_role,
|
|
1802 _("role <user> <moderator|participant|visitor|none>: Set a user's role in the room."),
|
|
1803 NULL);
|
|
1804 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL,
|
|
1805 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1806 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1807 jabber_cmd_chat_invite,
|
|
1808 _("invite <user> [message]: Invite a user to the room."),
|
|
1809 NULL);
|
|
1810 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL,
|
|
1811 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1812 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1813 jabber_cmd_chat_join,
|
|
1814 _("join: <room> [server]: Join a chat on this server."),
|
|
1815 NULL);
|
|
1816 gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL,
|
|
1817 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY |
|
|
1818 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
|
|
1819 jabber_cmd_chat_kick,
|
|
1820 _("kick <user> [room]: Kick a user from the room."),
|
|
1821 NULL);
|
|
1822 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL,
|
|
1823 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
|
|
1824 "prpl-jabber", jabber_cmd_chat_msg,
|
|
1825 _("msg <user> <message>: Send a private message to another user."),
|
|
1826 NULL);
|
|
1827 }
|
|
1828
|
|
1829 static GaimPluginProtocolInfo prpl_info =
|
|
1830 {
|
|
1831 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME,
|
|
1832 NULL, /* user_splits */
|
|
1833 NULL, /* protocol_options */
|
14412
|
1834 {"png,jpg,gif", 0, 0, 96, 96, GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */
|
14192
|
1835 jabber_list_icon, /* list_icon */
|
|
1836 jabber_list_emblems, /* list_emblems */
|
|
1837 jabber_status_text, /* status_text */
|
|
1838 jabber_tooltip_text, /* tooltip_text */
|
|
1839 jabber_status_types, /* status_types */
|
|
1840 jabber_blist_node_menu, /* blist_node_menu */
|
|
1841 jabber_chat_info, /* chat_info */
|
|
1842 jabber_chat_info_defaults, /* chat_info_defaults */
|
|
1843 jabber_login, /* login */
|
|
1844 jabber_close, /* close */
|
|
1845 jabber_message_send_im, /* send_im */
|
|
1846 jabber_set_info, /* set_info */
|
|
1847 jabber_send_typing, /* send_typing */
|
|
1848 jabber_buddy_get_info, /* get_info */
|
|
1849 jabber_presence_send, /* set_away */
|
14391
|
1850 jabber_idle_set, /* set_idle */
|
14192
|
1851 NULL, /* change_passwd */
|
|
1852 jabber_roster_add_buddy, /* add_buddy */
|
|
1853 NULL, /* add_buddies */
|
|
1854 jabber_roster_remove_buddy, /* remove_buddy */
|
|
1855 NULL, /* remove_buddies */
|
|
1856 NULL, /* add_permit */
|
|
1857 NULL, /* add_deny */
|
|
1858 NULL, /* rem_permit */
|
|
1859 NULL, /* rem_deny */
|
|
1860 NULL, /* set_permit_deny */
|
|
1861 jabber_chat_join, /* join_chat */
|
|
1862 NULL, /* reject_chat */
|
|
1863 jabber_get_chat_name, /* get_chat_name */
|
|
1864 jabber_chat_invite, /* chat_invite */
|
|
1865 jabber_chat_leave, /* chat_leave */
|
|
1866 NULL, /* chat_whisper */
|
|
1867 jabber_message_send_chat, /* chat_send */
|
|
1868 jabber_keepalive, /* keepalive */
|
|
1869 jabber_register_account, /* register_user */
|
|
1870 jabber_buddy_get_info_chat, /* get_cb_info */
|
|
1871 NULL, /* get_cb_away */
|
|
1872 jabber_roster_alias_change, /* alias_buddy */
|
|
1873 jabber_roster_group_change, /* group_buddy */
|
|
1874 jabber_roster_group_rename, /* rename_group */
|
|
1875 NULL, /* buddy_free */
|
|
1876 jabber_convo_closed, /* convo_closed */
|
|
1877 jabber_normalize, /* normalize */
|
|
1878 jabber_set_buddy_icon, /* set_buddy_icon */
|
|
1879 NULL, /* remove_group */
|
|
1880 jabber_chat_buddy_real_name, /* get_cb_real_name */
|
|
1881 jabber_chat_set_topic, /* set_chat_topic */
|
|
1882 jabber_find_blist_chat, /* find_blist_chat */
|
|
1883 jabber_roomlist_get_list, /* roomlist_get_list */
|
|
1884 jabber_roomlist_cancel, /* roomlist_cancel */
|
|
1885 NULL, /* roomlist_expand_category */
|
|
1886 NULL, /* can_receive_file */
|
|
1887 jabber_si_xfer_send, /* send_file */
|
|
1888 jabber_si_new_xfer, /* new_xfer */
|
|
1889 jabber_offline_message, /* offline_message */
|
|
1890 NULL, /* whiteboard_prpl_ops */
|
|
1891 };
|
|
1892
|
14296
|
1893 static gboolean load_plugin(GaimPlugin *plugin)
|
|
1894 {
|
|
1895 gaim_signal_register(plugin, "jabber-receiving-xmlnode",
|
|
1896 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
|
|
1897 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION),
|
|
1898 gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE));
|
|
1899
|
|
1900 gaim_signal_register(plugin, "jabber-sending-xmlnode",
|
|
1901 gaim_marshal_VOID__POINTER_POINTER, NULL, 2,
|
|
1902 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION),
|
|
1903 gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE));
|
|
1904
|
|
1905 return TRUE;
|
|
1906 }
|
|
1907
|
|
1908 static gboolean unload_plugin(GaimPlugin *plugin)
|
|
1909 {
|
|
1910 gaim_signal_unregister(plugin, "jabber-receiving-xmlnode");
|
|
1911
|
|
1912 gaim_signal_unregister(plugin, "jabber-sending-xmlnode");
|
|
1913
|
|
1914 return TRUE;
|
|
1915 }
|
|
1916
|
14192
|
1917 static GaimPluginInfo info =
|
|
1918 {
|
|
1919 GAIM_PLUGIN_MAGIC,
|
|
1920 GAIM_MAJOR_VERSION,
|
|
1921 GAIM_MINOR_VERSION,
|
|
1922 GAIM_PLUGIN_PROTOCOL, /**< type */
|
|
1923 NULL, /**< ui_requirement */
|
|
1924 0, /**< flags */
|
|
1925 NULL, /**< dependencies */
|
|
1926 GAIM_PRIORITY_DEFAULT, /**< priority */
|
|
1927
|
|
1928 "prpl-jabber", /**< id */
|
|
1929 "Jabber", /**< name */
|
|
1930 VERSION, /**< version */
|
|
1931 /** summary */
|
|
1932 N_("Jabber Protocol Plugin"),
|
|
1933 /** description */
|
|
1934 N_("Jabber Protocol Plugin"),
|
|
1935 NULL, /**< author */
|
|
1936 GAIM_WEBSITE, /**< homepage */
|
|
1937
|
14296
|
1938 load_plugin, /**< load */
|
|
1939 unload_plugin, /**< unload */
|
14192
|
1940 NULL, /**< destroy */
|
|
1941
|
|
1942 NULL, /**< ui_info */
|
|
1943 &prpl_info, /**< extra_info */
|
|
1944 NULL, /**< prefs_info */
|
|
1945 jabber_actions
|
|
1946 };
|
|
1947
|
|
1948 static void
|
|
1949 init_plugin(GaimPlugin *plugin)
|
|
1950 {
|
|
1951 GaimAccountUserSplit *split;
|
|
1952 GaimAccountOption *option;
|
|
1953
|
|
1954 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@');
|
|
1955 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
|
|
1956
|
|
1957 split = gaim_account_user_split_new(_("Resource"), "Home", '/');
|
|
1958 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
|
|
1959
|
|
1960 option = gaim_account_option_bool_new(_("Use TLS if available"), "use_tls",
|
|
1961 TRUE);
|
|
1962 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
|
|
1963 option);
|
|
1964
|
|
1965 option = gaim_account_option_bool_new(_("Require TLS"), "require_tls", TRUE);
|
|
1966 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
|
|
1967
|
|
1968 option = gaim_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE);
|
|
1969 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
|
|
1970 option);
|
|
1971
|
|
1972 option = gaim_account_option_bool_new(
|
|
1973 _("Allow plaintext auth over unencrypted streams"),
|
|
1974 "auth_plain_in_clear", FALSE);
|
|
1975 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
|
|
1976 option);
|
|
1977
|
|
1978 option = gaim_account_option_int_new(_("Connect port"), "port", 5222);
|
|
1979 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
|
|
1980 option);
|
|
1981
|
|
1982 option = gaim_account_option_string_new(_("Connect server"),
|
|
1983 "connect_server", NULL);
|
|
1984 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
|
|
1985 option);
|
|
1986
|
|
1987 my_protocol = plugin;
|
|
1988
|
|
1989 gaim_prefs_remove("/plugins/prpl/jabber");
|
|
1990
|
|
1991 /* XXX - If any other plugin wants SASL this won't be good ... */
|
|
1992 #ifdef HAVE_CYRUS_SASL
|
|
1993 sasl_client_init(NULL);
|
|
1994 #endif
|
|
1995 jabber_register_commands();
|
14294
|
1996
|
|
1997 jabber_iq_init();
|
14192
|
1998 }
|
|
1999
|
|
2000 GAIM_INIT_PLUGIN(jabber, init_plugin, info);
|