comparison libpurple/protocols/jabber/jabber.c @ 15822:32c366eeeb99

sed -ie 's/gaim/purple/g'
author Sean Egan <seanegan@gmail.com>
date Mon, 19 Mar 2007 07:01:17 +0000
parents 51dd9ae01585
children 87ea711b9781
comparison
equal deleted inserted replaced
15821:84b0f9b23ede 15822:32c366eeeb99
1 /* 1 /*
2 * gaim - Jabber Protocol Plugin 2 * purple - Jabber Protocol Plugin
3 * 3 *
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> 4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com>
5 * 5 *
6 * This program is free software; you can redistribute it and/or modify 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 7 * it under the terms of the GNU General Public License as published by
52 #include "si.h" 52 #include "si.h"
53 #include "xdata.h" 53 #include "xdata.h"
54 54
55 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5) 55 #define JABBER_CONNECT_STEPS (js->gsc ? 8 : 5)
56 56
57 static GaimPlugin *my_protocol = NULL; 57 static PurplePlugin *my_protocol = NULL;
58 58
59 static void jabber_stream_init(JabberStream *js) 59 static void jabber_stream_init(JabberStream *js)
60 { 60 {
61 char *open_stream; 61 char *open_stream;
62 62
77 { 77 {
78 const char *type = xmlnode_get_attrib(packet, "type"); 78 const char *type = xmlnode_get_attrib(packet, "type");
79 if(type && !strcmp(type, "result")) { 79 if(type && !strcmp(type, "result")) {
80 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED); 80 jabber_stream_set_state(js, JABBER_STREAM_CONNECTED);
81 } else { 81 } else {
82 gaim_connection_error(js->gc, _("Error initializing session")); 82 purple_connection_error(js->gc, _("Error initializing session"));
83 } 83 }
84 } 84 }
85 85
86 static void jabber_session_init(JabberStream *js) 86 static void jabber_session_init(JabberStream *js)
87 { 87 {
108 char *full_jid; 108 char *full_jid;
109 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) { 109 if((jid = xmlnode_get_child(bind, "jid")) && (full_jid = xmlnode_get_data(jid))) {
110 JabberBuddy *my_jb = NULL; 110 JabberBuddy *my_jb = NULL;
111 jabber_id_free(js->user); 111 jabber_id_free(js->user);
112 if(!(js->user = jabber_id_new(full_jid))) { 112 if(!(js->user = jabber_id_new(full_jid))) {
113 gaim_connection_error(js->gc, _("Invalid response from server.")); 113 purple_connection_error(js->gc, _("Invalid response from server."));
114 } 114 }
115 if((my_jb = jabber_buddy_find(js, full_jid, TRUE))) 115 if((my_jb = jabber_buddy_find(js, full_jid, TRUE)))
116 my_jb->subscription |= JABBER_SUB_BOTH; 116 my_jb->subscription |= JABBER_SUB_BOTH;
117 g_free(full_jid); 117 g_free(full_jid);
118 } 118 }
119 } else { 119 } else {
120 char *msg = jabber_parse_error(js, packet); 120 char *msg = jabber_parse_error(js, packet);
121 gaim_connection_error(js->gc, msg); 121 purple_connection_error(js->gc, msg);
122 g_free(msg); 122 g_free(msg);
123 } 123 }
124 124
125 jabber_session_init(js); 125 jabber_session_init(js);
126 } 126 }
159 159
160 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet) 160 static void jabber_stream_handle_error(JabberStream *js, xmlnode *packet)
161 { 161 {
162 char *msg = jabber_parse_error(js, packet); 162 char *msg = jabber_parse_error(js, packet);
163 163
164 gaim_connection_error(js->gc, msg); 164 purple_connection_error(js->gc, msg);
165 g_free(msg); 165 g_free(msg);
166 } 166 }
167 167
168 static void tls_init(JabberStream *js); 168 static void tls_init(JabberStream *js);
169 169
170 void jabber_process_packet(JabberStream *js, xmlnode *packet) 170 void jabber_process_packet(JabberStream *js, xmlnode *packet)
171 { 171 {
172 gaim_signal_emit(my_protocol, "jabber-receiving-xmlnode", js->gc, &packet); 172 purple_signal_emit(my_protocol, "jabber-receiving-xmlnode", js->gc, &packet);
173 173
174 /* if the signal leaves us with a null packet, we're done */ 174 /* if the signal leaves us with a null packet, we're done */
175 if(NULL == packet) 175 if(NULL == packet)
176 return; 176 return;
177 177
202 jabber_auth_handle_failure(js, packet); 202 jabber_auth_handle_failure(js, packet);
203 } else if(!strcmp(packet->name, "proceed")) { 203 } else if(!strcmp(packet->name, "proceed")) {
204 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc) 204 if(js->state == JABBER_STREAM_AUTHENTICATING && !js->gsc)
205 tls_init(js); 205 tls_init(js);
206 } else { 206 } else {
207 gaim_debug(GAIM_DEBUG_WARNING, "jabber", "Unknown packet: %s\n", 207 purple_debug(PURPLE_DEBUG_WARNING, "jabber", "Unknown packet: %s\n",
208 packet->name); 208 packet->name);
209 } 209 }
210 } 210 }
211 211
212 static int jabber_do_send(JabberStream *js, const char *data, int len) 212 static int jabber_do_send(JabberStream *js, const char *data, int len)
213 { 213 {
214 int ret; 214 int ret;
215 215
216 if (js->gsc) 216 if (js->gsc)
217 ret = gaim_ssl_write(js->gsc, data, len); 217 ret = purple_ssl_write(js->gsc, data, len);
218 else 218 else
219 ret = write(js->fd, data, len); 219 ret = write(js->fd, data, len);
220 220
221 return ret; 221 return ret;
222 } 222 }
223 223
224 static void jabber_send_cb(gpointer data, gint source, GaimInputCondition cond) 224 static void jabber_send_cb(gpointer data, gint source, PurpleInputCondition cond)
225 { 225 {
226 JabberStream *js = data; 226 JabberStream *js = data;
227 int ret, writelen; 227 int ret, writelen;
228 writelen = gaim_circ_buffer_get_max_read(js->write_buffer); 228 writelen = purple_circ_buffer_get_max_read(js->write_buffer);
229 229
230 if (writelen == 0) { 230 if (writelen == 0) {
231 gaim_input_remove(js->writeh); 231 purple_input_remove(js->writeh);
232 js->writeh = 0; 232 js->writeh = 0;
233 return; 233 return;
234 } 234 }
235 235
236 ret = jabber_do_send(js, js->write_buffer->outptr, writelen); 236 ret = jabber_do_send(js, js->write_buffer->outptr, writelen);
237 237
238 if (ret < 0 && errno == EAGAIN) 238 if (ret < 0 && errno == EAGAIN)
239 return; 239 return;
240 else if (ret <= 0) { 240 else if (ret <= 0) {
241 gaim_connection_error(js->gc, _("Write error")); 241 purple_connection_error(js->gc, _("Write error"));
242 return; 242 return;
243 } 243 }
244 244
245 gaim_circ_buffer_mark_read(js->write_buffer, ret); 245 purple_circ_buffer_mark_read(js->write_buffer, ret);
246 } 246 }
247 247
248 void jabber_send_raw(JabberStream *js, const char *data, int len) 248 void jabber_send_raw(JabberStream *js, const char *data, int len)
249 { 249 {
250 int ret; 250 int ret;
251 251
252 /* because printing a tab to debug every minute gets old */ 252 /* because printing a tab to debug every minute gets old */
253 if(strcmp(data, "\t")) 253 if(strcmp(data, "\t"))
254 gaim_debug(GAIM_DEBUG_MISC, "jabber", "Sending%s: %s\n", 254 purple_debug(PURPLE_DEBUG_MISC, "jabber", "Sending%s: %s\n",
255 js->gsc ? " (ssl)" : "", data); 255 js->gsc ? " (ssl)" : "", data);
256 256
257 /* If we've got a security layer, we need to encode the data, 257 /* If we've got a security layer, we need to encode the data,
258 * splitting it on the maximum buffer length negotiated */ 258 * splitting it on the maximum buffer length negotiated */
259 259
260 gaim_signal_emit(my_protocol, "jabber-sending-text", js->gc, &data); 260 purple_signal_emit(my_protocol, "jabber-sending-text", js->gc, &data);
261 if (data == NULL) 261 if (data == NULL)
262 return; 262 return;
263 263
264 #ifdef HAVE_CYRUS_SASL 264 #ifdef HAVE_CYRUS_SASL
265 if (js->sasl_maxbuf>0) { 265 if (js->sasl_maxbuf>0) {
289 ret = -1; 289 ret = -1;
290 errno = EAGAIN; 290 errno = EAGAIN;
291 } 291 }
292 292
293 if (ret < 0 && errno != EAGAIN) 293 if (ret < 0 && errno != EAGAIN)
294 gaim_connection_error(js->gc, _("Write error")); 294 purple_connection_error(js->gc, _("Write error"));
295 else if (ret < olen) { 295 else if (ret < olen) {
296 if (ret < 0) 296 if (ret < 0)
297 ret = 0; 297 ret = 0;
298 if (js->writeh == 0) 298 if (js->writeh == 0)
299 js->writeh = gaim_input_add( 299 js->writeh = purple_input_add(
300 js->gsc ? js->gsc->fd : js->fd, 300 js->gsc ? js->gsc->fd : js->fd,
301 GAIM_INPUT_WRITE, 301 PURPLE_INPUT_WRITE,
302 jabber_send_cb, js); 302 jabber_send_cb, js);
303 gaim_circ_buffer_append(js->write_buffer, 303 purple_circ_buffer_append(js->write_buffer,
304 out + ret, olen - ret); 304 out + ret, olen - ret);
305 } 305 }
306 } 306 }
307 return; 307 return;
308 } 308 }
317 ret = -1; 317 ret = -1;
318 errno = EAGAIN; 318 errno = EAGAIN;
319 } 319 }
320 320
321 if (ret < 0 && errno != EAGAIN) 321 if (ret < 0 && errno != EAGAIN)
322 gaim_connection_error(js->gc, _("Write error")); 322 purple_connection_error(js->gc, _("Write error"));
323 else if (ret < len) { 323 else if (ret < len) {
324 if (ret < 0) 324 if (ret < 0)
325 ret = 0; 325 ret = 0;
326 if (js->writeh == 0) 326 if (js->writeh == 0)
327 js->writeh = gaim_input_add( 327 js->writeh = purple_input_add(
328 js->gsc ? js->gsc->fd : js->fd, 328 js->gsc ? js->gsc->fd : js->fd,
329 GAIM_INPUT_WRITE, jabber_send_cb, js); 329 PURPLE_INPUT_WRITE, jabber_send_cb, js);
330 gaim_circ_buffer_append(js->write_buffer, 330 purple_circ_buffer_append(js->write_buffer,
331 data + ret, len - ret); 331 data + ret, len - ret);
332 } 332 }
333 return; 333 return;
334 } 334 }
335 335
336 static int jabber_prpl_send_raw(GaimConnection *gc, const char *buf, int len) 336 static int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len)
337 { 337 {
338 JabberStream *js = (JabberStream*)gc->proto_data; 338 JabberStream *js = (JabberStream*)gc->proto_data;
339 jabber_send_raw(js, buf, len); 339 jabber_send_raw(js, buf, len);
340 return len; 340 return len;
341 } 341 }
343 void jabber_send(JabberStream *js, xmlnode *packet) 343 void jabber_send(JabberStream *js, xmlnode *packet)
344 { 344 {
345 char *txt; 345 char *txt;
346 int len; 346 int len;
347 347
348 gaim_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet); 348 purple_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet);
349 349
350 /* if we get NULL back, we're done processing */ 350 /* if we get NULL back, we're done processing */
351 if(NULL == packet) 351 if(NULL == packet)
352 return; 352 return;
353 353
354 txt = xmlnode_to_str(packet, &len); 354 txt = xmlnode_to_str(packet, &len);
355 jabber_send_raw(js, txt, len); 355 jabber_send_raw(js, txt, len);
356 g_free(txt); 356 g_free(txt);
357 } 357 }
358 358
359 static void jabber_keepalive(GaimConnection *gc) 359 static void jabber_keepalive(PurpleConnection *gc)
360 { 360 {
361 jabber_send_raw(gc->proto_data, "\t", -1); 361 jabber_send_raw(gc->proto_data, "\t", -1);
362 } 362 }
363 363
364 static void 364 static void
365 jabber_recv_cb_ssl(gpointer data, GaimSslConnection *gsc, 365 jabber_recv_cb_ssl(gpointer data, PurpleSslConnection *gsc,
366 GaimInputCondition cond) 366 PurpleInputCondition cond)
367 { 367 {
368 GaimConnection *gc = data; 368 PurpleConnection *gc = data;
369 JabberStream *js = gc->proto_data; 369 JabberStream *js = gc->proto_data;
370 int len; 370 int len;
371 static char buf[4096]; 371 static char buf[4096];
372 372
373 /* TODO: It should be possible to make this check unnecessary */ 373 /* TODO: It should be possible to make this check unnecessary */
374 if(!GAIM_CONNECTION_IS_VALID(gc)) { 374 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
375 gaim_ssl_close(gsc); 375 purple_ssl_close(gsc);
376 return; 376 return;
377 } 377 }
378 378
379 while((len = gaim_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) { 379 while((len = purple_ssl_read(gsc, buf, sizeof(buf) - 1)) > 0) {
380 buf[len] = '\0'; 380 buf[len] = '\0';
381 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf); 381 purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (ssl)(%d): %s\n", len, buf);
382 jabber_parser_process(js, buf, len); 382 jabber_parser_process(js, buf, len);
383 if(js->reinit) 383 if(js->reinit)
384 jabber_stream_init(js); 384 jabber_stream_init(js);
385 } 385 }
386 386
387 if(errno == EAGAIN) 387 if(errno == EAGAIN)
388 return; 388 return;
389 else 389 else
390 gaim_connection_error(gc, _("Read Error")); 390 purple_connection_error(gc, _("Read Error"));
391 } 391 }
392 392
393 static void 393 static void
394 jabber_recv_cb(gpointer data, gint source, GaimInputCondition condition) 394 jabber_recv_cb(gpointer data, gint source, PurpleInputCondition condition)
395 { 395 {
396 GaimConnection *gc = data; 396 PurpleConnection *gc = data;
397 JabberStream *js = gc->proto_data; 397 JabberStream *js = gc->proto_data;
398 int len; 398 int len;
399 static char buf[4096]; 399 static char buf[4096];
400 400
401 if(!GAIM_CONNECTION_IS_VALID(gc)) 401 if(!PURPLE_CONNECTION_IS_VALID(gc))
402 return; 402 return;
403 403
404 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) { 404 if((len = read(js->fd, buf, sizeof(buf) - 1)) > 0) {
405 #ifdef HAVE_CYRUS_SASL 405 #ifdef HAVE_CYRUS_SASL
406 if (js->sasl_maxbuf>0) { 406 if (js->sasl_maxbuf>0) {
407 const char *out; 407 const char *out;
408 unsigned int olen; 408 unsigned int olen;
409 sasl_decode(js->sasl, buf, len, &out, &olen); 409 sasl_decode(js->sasl, buf, len, &out, &olen);
410 if (olen>0) { 410 if (olen>0) {
411 gaim_debug(GAIM_DEBUG_INFO, "jabber", "RecvSASL (%u): %s\n", olen, out); 411 purple_debug(PURPLE_DEBUG_INFO, "jabber", "RecvSASL (%u): %s\n", olen, out);
412 jabber_parser_process(js,out,olen); 412 jabber_parser_process(js,out,olen);
413 if(js->reinit) 413 if(js->reinit)
414 jabber_stream_init(js); 414 jabber_stream_init(js);
415 } 415 }
416 return; 416 return;
417 } 417 }
418 #endif 418 #endif
419 buf[len] = '\0'; 419 buf[len] = '\0';
420 gaim_debug(GAIM_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf); 420 purple_debug(PURPLE_DEBUG_INFO, "jabber", "Recv (%d): %s\n", len, buf);
421 jabber_parser_process(js, buf, len); 421 jabber_parser_process(js, buf, len);
422 if(js->reinit) 422 if(js->reinit)
423 jabber_stream_init(js); 423 jabber_stream_init(js);
424 } else if(errno == EAGAIN) { 424 } else if(errno == EAGAIN) {
425 return; 425 return;
426 } else { 426 } else {
427 gaim_connection_error(gc, _("Read Error")); 427 purple_connection_error(gc, _("Read Error"));
428 } 428 }
429 } 429 }
430 430
431 static void 431 static void
432 jabber_login_callback_ssl(gpointer data, GaimSslConnection *gsc, 432 jabber_login_callback_ssl(gpointer data, PurpleSslConnection *gsc,
433 GaimInputCondition cond) 433 PurpleInputCondition cond)
434 { 434 {
435 GaimConnection *gc = data; 435 PurpleConnection *gc = data;
436 JabberStream *js; 436 JabberStream *js;
437 437
438 /* TODO: It should be possible to make this check unnecessary */ 438 /* TODO: It should be possible to make this check unnecessary */
439 if(!GAIM_CONNECTION_IS_VALID(gc)) { 439 if(!PURPLE_CONNECTION_IS_VALID(gc)) {
440 gaim_ssl_close(gsc); 440 purple_ssl_close(gsc);
441 return; 441 return;
442 } 442 }
443 443
444 js = gc->proto_data; 444 js = gc->proto_data;
445 445
446 if(js->state == JABBER_STREAM_CONNECTING) 446 if(js->state == JABBER_STREAM_CONNECTING)
447 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); 447 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
448 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); 448 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
449 gaim_ssl_input_add(gsc, jabber_recv_cb_ssl, gc); 449 purple_ssl_input_add(gsc, jabber_recv_cb_ssl, gc);
450 } 450 }
451 451
452 452
453 static void 453 static void
454 jabber_login_callback(gpointer data, gint source, const gchar *error) 454 jabber_login_callback(gpointer data, gint source, const gchar *error)
455 { 455 {
456 GaimConnection *gc = data; 456 PurpleConnection *gc = data;
457 JabberStream *js = gc->proto_data; 457 JabberStream *js = gc->proto_data;
458 458
459 if (source < 0) { 459 if (source < 0) {
460 gaim_connection_error(gc, _("Couldn't connect to host")); 460 purple_connection_error(gc, _("Couldn't connect to host"));
461 return; 461 return;
462 } 462 }
463 463
464 js->fd = source; 464 js->fd = source;
465 465
466 if(js->state == JABBER_STREAM_CONNECTING) 466 if(js->state == JABBER_STREAM_CONNECTING)
467 jabber_send_raw(js, "<?xml version='1.0' ?>", -1); 467 jabber_send_raw(js, "<?xml version='1.0' ?>", -1);
468 468
469 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING); 469 jabber_stream_set_state(js, JABBER_STREAM_INITIALIZING);
470 gc->inpa = gaim_input_add(js->fd, GAIM_INPUT_READ, jabber_recv_cb, gc); 470 gc->inpa = purple_input_add(js->fd, PURPLE_INPUT_READ, jabber_recv_cb, gc);
471 } 471 }
472 472
473 static void 473 static void
474 jabber_ssl_connect_failure(GaimSslConnection *gsc, GaimSslErrorType error, 474 jabber_ssl_connect_failure(PurpleSslConnection *gsc, PurpleSslErrorType error,
475 gpointer data) 475 gpointer data)
476 { 476 {
477 GaimConnection *gc = data; 477 PurpleConnection *gc = data;
478 JabberStream *js; 478 JabberStream *js;
479 479
480 /* If the connection is already disconnected, we don't need to do anything else */ 480 /* If the connection is already disconnected, we don't need to do anything else */
481 if(!GAIM_CONNECTION_IS_VALID(gc)) 481 if(!PURPLE_CONNECTION_IS_VALID(gc))
482 return; 482 return;
483 483
484 js = gc->proto_data; 484 js = gc->proto_data;
485 js->gsc = NULL; 485 js->gsc = NULL;
486 486
487 switch(error) { 487 switch(error) {
488 case GAIM_SSL_CONNECT_FAILED: 488 case PURPLE_SSL_CONNECT_FAILED:
489 gaim_connection_error(gc, _("Connection Failed")); 489 purple_connection_error(gc, _("Connection Failed"));
490 break; 490 break;
491 case GAIM_SSL_HANDSHAKE_FAILED: 491 case PURPLE_SSL_HANDSHAKE_FAILED:
492 gaim_connection_error(gc, _("SSL Handshake Failed")); 492 purple_connection_error(gc, _("SSL Handshake Failed"));
493 break; 493 break;
494 } 494 }
495 } 495 }
496 496
497 static void tls_init(JabberStream *js) 497 static void tls_init(JabberStream *js)
498 { 498 {
499 gaim_input_remove(js->gc->inpa); 499 purple_input_remove(js->gc->inpa);
500 js->gc->inpa = 0; 500 js->gc->inpa = 0;
501 js->gsc = gaim_ssl_connect_fd(js->gc->account, js->fd, 501 js->gsc = purple_ssl_connect_fd(js->gc->account, js->fd,
502 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc); 502 jabber_login_callback_ssl, jabber_ssl_connect_failure, js->gc);
503 } 503 }
504 504
505 static void jabber_login_connect(JabberStream *js, const char *server, int port) 505 static void jabber_login_connect(JabberStream *js, const char *server, int port)
506 { 506 {
507 #ifdef HAVE_CYRUS_SASL 507 #ifdef HAVE_CYRUS_SASL
508 js->serverFQDN = g_strdup(server); 508 js->serverFQDN = g_strdup(server);
509 #endif 509 #endif
510 510
511 if (gaim_proxy_connect(js->gc, js->gc->account, server, 511 if (purple_proxy_connect(js->gc, js->gc->account, server,
512 port, jabber_login_callback, js->gc) == NULL) 512 port, jabber_login_callback, js->gc) == NULL)
513 gaim_connection_error(js->gc, _("Unable to create socket")); 513 purple_connection_error(js->gc, _("Unable to create socket"));
514 } 514 }
515 515
516 static void srv_resolved_cb(GaimSrvResponse *resp, int results, gpointer data) 516 static void srv_resolved_cb(PurpleSrvResponse *resp, int results, gpointer data)
517 { 517 {
518 JabberStream *js; 518 JabberStream *js;
519 519
520 js = data; 520 js = data;
521 js->srv_query_data = NULL; 521 js->srv_query_data = NULL;
523 if(results) { 523 if(results) {
524 jabber_login_connect(js, resp->hostname, resp->port); 524 jabber_login_connect(js, resp->hostname, resp->port);
525 g_free(resp); 525 g_free(resp);
526 } else { 526 } else {
527 jabber_login_connect(js, js->user->domain, 527 jabber_login_connect(js, js->user->domain,
528 gaim_account_get_int(js->gc->account, "port", 5222)); 528 purple_account_get_int(js->gc->account, "port", 5222));
529 } 529 }
530 } 530 }
531 531
532 532
533 533
534 static void 534 static void
535 jabber_login(GaimAccount *account) 535 jabber_login(PurpleAccount *account)
536 { 536 {
537 GaimConnection *gc = gaim_account_get_connection(account); 537 PurpleConnection *gc = purple_account_get_connection(account);
538 const char *connect_server = gaim_account_get_string(account, 538 const char *connect_server = purple_account_get_string(account,
539 "connect_server", ""); 539 "connect_server", "");
540 JabberStream *js; 540 JabberStream *js;
541 JabberBuddy *my_jb = NULL; 541 JabberBuddy *my_jb = NULL;
542 542
543 gc->flags |= GAIM_CONNECTION_HTML; 543 gc->flags |= PURPLE_CONNECTION_HTML;
544 js = gc->proto_data = g_new0(JabberStream, 1); 544 js = gc->proto_data = g_new0(JabberStream, 1);
545 js->gc = gc; 545 js->gc = gc;
546 js->fd = -1; 546 js->fd = -1;
547 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, 547 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
548 g_free, g_free); 548 g_free, g_free);
551 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal, 551 js->buddies = g_hash_table_new_full(g_str_hash, g_str_equal,
552 g_free, (GDestroyNotify)jabber_buddy_free); 552 g_free, (GDestroyNotify)jabber_buddy_free);
553 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal, 553 js->chats = g_hash_table_new_full(g_str_hash, g_str_equal,
554 g_free, (GDestroyNotify)jabber_chat_free); 554 g_free, (GDestroyNotify)jabber_chat_free);
555 js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org")); 555 js->chat_servers = g_list_append(NULL, g_strdup("conference.jabber.org"));
556 js->user = jabber_id_new(gaim_account_get_username(account)); 556 js->user = jabber_id_new(purple_account_get_username(account));
557 js->next_id = g_random_int(); 557 js->next_id = g_random_int();
558 js->write_buffer = gaim_circ_buffer_new(512); 558 js->write_buffer = purple_circ_buffer_new(512);
559 559
560 if(!js->user) { 560 if(!js->user) {
561 gaim_connection_error(gc, _("Invalid Jabber ID")); 561 purple_connection_error(gc, _("Invalid Jabber ID"));
562 return; 562 return;
563 } 563 }
564 564
565 if(!js->user->resource) { 565 if(!js->user->resource) {
566 char *me; 566 char *me;
569 js->user->node = js->user->domain; 569 js->user->node = js->user->domain;
570 js->user->domain = g_strdup("jabber.org"); 570 js->user->domain = g_strdup("jabber.org");
571 } 571 }
572 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, 572 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain,
573 js->user->resource); 573 js->user->resource);
574 gaim_account_set_username(account, me); 574 purple_account_set_username(account, me);
575 g_free(me); 575 g_free(me);
576 } 576 }
577 577
578 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) 578 if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE)))
579 my_jb->subscription |= JABBER_SUB_BOTH; 579 my_jb->subscription |= JABBER_SUB_BOTH;
580 580
581 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); 581 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
582 582
583 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */ 583 /* if they've got old-ssl mode going, we probably want to ignore SRV lookups */
584 if(gaim_account_get_bool(js->gc->account, "old_ssl", FALSE)) { 584 if(purple_account_get_bool(js->gc->account, "old_ssl", FALSE)) {
585 if(gaim_ssl_is_supported()) { 585 if(purple_ssl_is_supported()) {
586 js->gsc = gaim_ssl_connect(js->gc->account, 586 js->gsc = purple_ssl_connect(js->gc->account,
587 connect_server[0] ? connect_server : js->user->domain, 587 connect_server[0] ? connect_server : js->user->domain,
588 gaim_account_get_int(account, "port", 5223), jabber_login_callback_ssl, 588 purple_account_get_int(account, "port", 5223), jabber_login_callback_ssl,
589 jabber_ssl_connect_failure, js->gc); 589 jabber_ssl_connect_failure, js->gc);
590 } else { 590 } else {
591 gaim_connection_error(js->gc, _("SSL support unavailable")); 591 purple_connection_error(js->gc, _("SSL support unavailable"));
592 } 592 }
593 } 593 }
594 594
595 /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll 595 /* no old-ssl, so if they've specified a connect server, we'll use that, otherwise we'll
596 * invoke the magic of SRV lookups, to figure out host and port */ 596 * invoke the magic of SRV lookups, to figure out host and port */
597 if(!js->gsc) { 597 if(!js->gsc) {
598 if(connect_server[0]) { 598 if(connect_server[0]) {
599 jabber_login_connect(js, connect_server, gaim_account_get_int(account, "port", 5222)); 599 jabber_login_connect(js, connect_server, purple_account_get_int(account, "port", 5222));
600 } else { 600 } else {
601 js->srv_query_data = gaim_srv_resolve("xmpp-client", 601 js->srv_query_data = purple_srv_resolve("xmpp-client",
602 "tcp", js->user->domain, srv_resolved_cb, js); 602 "tcp", js->user->domain, srv_resolved_cb, js);
603 } 603 }
604 } 604 }
605 } 605 }
606 606
607 607
608 static gboolean 608 static gboolean
609 conn_close_cb(gpointer data) 609 conn_close_cb(gpointer data)
610 { 610 {
611 JabberStream *js = data; 611 JabberStream *js = data;
612 GaimAccount *account = gaim_connection_get_account(js->gc); 612 PurpleAccount *account = purple_connection_get_account(js->gc);
613 613
614 gaim_account_disconnect(account); 614 purple_account_disconnect(account);
615 615
616 return FALSE; 616 return FALSE;
617 } 617 }
618 618
619 static void 619 static void
620 jabber_connection_schedule_close(JabberStream *js) 620 jabber_connection_schedule_close(JabberStream *js)
621 { 621 {
622 gaim_timeout_add(0, conn_close_cb, js); 622 purple_timeout_add(0, conn_close_cb, js);
623 } 623 }
624 624
625 static void 625 static void
626 jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data) 626 jabber_registration_result_cb(JabberStream *js, xmlnode *packet, gpointer data)
627 { 627 {
629 char *buf; 629 char *buf;
630 630
631 if(!strcmp(type, "result")) { 631 if(!strcmp(type, "result")) {
632 buf = g_strdup_printf(_("Registration of %s@%s successful"), 632 buf = g_strdup_printf(_("Registration of %s@%s successful"),
633 js->user->node, js->user->domain); 633 js->user->node, js->user->domain);
634 gaim_notify_info(NULL, _("Registration Successful"), 634 purple_notify_info(NULL, _("Registration Successful"),
635 _("Registration Successful"), buf); 635 _("Registration Successful"), buf);
636 g_free(buf); 636 g_free(buf);
637 } else { 637 } else {
638 char *msg = jabber_parse_error(js, packet); 638 char *msg = jabber_parse_error(js, packet);
639 639
640 if(!msg) 640 if(!msg)
641 msg = g_strdup(_("Unknown Error")); 641 msg = g_strdup(_("Unknown Error"));
642 642
643 gaim_notify_error(NULL, _("Registration Failed"), 643 purple_notify_error(NULL, _("Registration Failed"),
644 _("Registration Failed"), msg); 644 _("Registration Failed"), msg);
645 g_free(msg); 645 g_free(msg);
646 } 646 }
647 jabber_connection_schedule_close(js); 647 jabber_connection_schedule_close(js);
648 } 648 }
649 649
650 static void 650 static void
651 jabber_register_cb(JabberStream *js, GaimRequestFields *fields) 651 jabber_register_cb(JabberStream *js, PurpleRequestFields *fields)
652 { 652 {
653 GList *groups, *flds; 653 GList *groups, *flds;
654 xmlnode *query, *y; 654 xmlnode *query, *y;
655 JabberIq *iq; 655 JabberIq *iq;
656 char *username; 656 char *username;
657 657
658 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); 658 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
659 query = xmlnode_get_child(iq->node, "query"); 659 query = xmlnode_get_child(iq->node, "query");
660 660
661 for(groups = gaim_request_fields_get_groups(fields); groups; 661 for(groups = purple_request_fields_get_groups(fields); groups;
662 groups = groups->next) { 662 groups = groups->next) {
663 for(flds = gaim_request_field_group_get_fields(groups->data); 663 for(flds = purple_request_field_group_get_fields(groups->data);
664 flds; flds = flds->next) { 664 flds; flds = flds->next) {
665 GaimRequestField *field = flds->data; 665 PurpleRequestField *field = flds->data;
666 const char *id = gaim_request_field_get_id(field); 666 const char *id = purple_request_field_get_id(field);
667 const char *value = gaim_request_field_string_get_value(field); 667 const char *value = purple_request_field_string_get_value(field);
668 668
669 if(!strcmp(id, "username")) { 669 if(!strcmp(id, "username")) {
670 y = xmlnode_new_child(query, "username"); 670 y = xmlnode_new_child(query, "username");
671 } else if(!strcmp(id, "password")) { 671 } else if(!strcmp(id, "password")) {
672 y = xmlnode_new_child(query, "password"); 672 y = xmlnode_new_child(query, "password");
706 } 706 }
707 } 707 }
708 708
709 username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, 709 username = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain,
710 js->user->resource); 710 js->user->resource);
711 gaim_account_set_username(js->gc->account, username); 711 purple_account_set_username(js->gc->account, username);
712 g_free(username); 712 g_free(username);
713 713
714 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL); 714 jabber_iq_set_callback(iq, jabber_registration_result_cb, NULL);
715 715
716 jabber_iq_send(iq); 716 jabber_iq_send(iq);
717 717
718 } 718 }
719 719
720 static void 720 static void
721 jabber_register_cancel_cb(JabberStream *js, GaimRequestFields *fields) 721 jabber_register_cancel_cb(JabberStream *js, PurpleRequestFields *fields)
722 { 722 {
723 jabber_connection_schedule_close(js); 723 jabber_connection_schedule_close(js);
724 } 724 }
725 725
726 static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data) 726 static void jabber_register_x_data_cb(JabberStream *js, xmlnode *result, gpointer data)
742 const char *type; 742 const char *type;
743 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) 743 if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result"))
744 return; 744 return;
745 745
746 if(js->registration) { 746 if(js->registration) {
747 GaimRequestFields *fields; 747 PurpleRequestFields *fields;
748 GaimRequestFieldGroup *group; 748 PurpleRequestFieldGroup *group;
749 GaimRequestField *field; 749 PurpleRequestField *field;
750 xmlnode *query, *x, *y; 750 xmlnode *query, *x, *y;
751 char *instructions; 751 char *instructions;
752 752
753 /* get rid of the login thingy */ 753 /* get rid of the login thingy */
754 gaim_connection_set_state(js->gc, GAIM_CONNECTED); 754 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
755 755
756 query = xmlnode_get_child(packet, "query"); 756 query = xmlnode_get_child(packet, "query");
757 757
758 if(xmlnode_get_child(query, "registered")) { 758 if(xmlnode_get_child(query, "registered")) {
759 gaim_notify_error(NULL, _("Already Registered"), 759 purple_notify_error(NULL, _("Already Registered"),
760 _("Already Registered"), NULL); 760 _("Already Registered"), NULL);
761 jabber_connection_schedule_close(js); 761 jabber_connection_schedule_close(js);
762 return; 762 return;
763 } 763 }
764 764
771 xmlnode *url; 771 xmlnode *url;
772 772
773 if((url = xmlnode_get_child(x, "url"))) { 773 if((url = xmlnode_get_child(x, "url"))) {
774 char *href; 774 char *href;
775 if((href = xmlnode_get_data(url))) { 775 if((href = xmlnode_get_data(url))) {
776 gaim_notify_uri(NULL, href); 776 purple_notify_uri(NULL, href);
777 g_free(href); 777 g_free(href);
778 js->gc->wants_to_die = TRUE; 778 js->gc->wants_to_die = TRUE;
779 jabber_connection_schedule_close(js); 779 jabber_connection_schedule_close(js);
780 return; 780 return;
781 } 781 }
782 } 782 }
783 } 783 }
784 784
785 /* as a last resort, use the old jabber:iq:register syntax */ 785 /* as a last resort, use the old jabber:iq:register syntax */
786 786
787 fields = gaim_request_fields_new(); 787 fields = purple_request_fields_new();
788 group = gaim_request_field_group_new(NULL); 788 group = purple_request_field_group_new(NULL);
789 gaim_request_fields_add_group(fields, group); 789 purple_request_fields_add_group(fields, group);
790 790
791 field = gaim_request_field_string_new("username", _("Username"), 791 field = purple_request_field_string_new("username", _("Username"),
792 js->user->node, FALSE); 792 js->user->node, FALSE);
793 gaim_request_field_group_add_field(group, field); 793 purple_request_field_group_add_field(group, field);
794 794
795 field = gaim_request_field_string_new("password", _("Password"), 795 field = purple_request_field_string_new("password", _("Password"),
796 gaim_connection_get_password(js->gc), FALSE); 796 purple_connection_get_password(js->gc), FALSE);
797 gaim_request_field_string_set_masked(field, TRUE); 797 purple_request_field_string_set_masked(field, TRUE);
798 gaim_request_field_group_add_field(group, field); 798 purple_request_field_group_add_field(group, field);
799 799
800 if(xmlnode_get_child(query, "name")) { 800 if(xmlnode_get_child(query, "name")) {
801 field = gaim_request_field_string_new("name", _("Name"), 801 field = purple_request_field_string_new("name", _("Name"),
802 gaim_account_get_alias(js->gc->account), FALSE); 802 purple_account_get_alias(js->gc->account), FALSE);
803 gaim_request_field_group_add_field(group, field); 803 purple_request_field_group_add_field(group, field);
804 } 804 }
805 if(xmlnode_get_child(query, "email")) { 805 if(xmlnode_get_child(query, "email")) {
806 field = gaim_request_field_string_new("email", _("E-mail"), 806 field = purple_request_field_string_new("email", _("E-mail"),
807 NULL, FALSE); 807 NULL, FALSE);
808 gaim_request_field_group_add_field(group, field); 808 purple_request_field_group_add_field(group, field);
809 } 809 }
810 if(xmlnode_get_child(query, "nick")) { 810 if(xmlnode_get_child(query, "nick")) {
811 field = gaim_request_field_string_new("nick", _("Nickname"), 811 field = purple_request_field_string_new("nick", _("Nickname"),
812 NULL, FALSE); 812 NULL, FALSE);
813 gaim_request_field_group_add_field(group, field); 813 purple_request_field_group_add_field(group, field);
814 } 814 }
815 if(xmlnode_get_child(query, "first")) { 815 if(xmlnode_get_child(query, "first")) {
816 field = gaim_request_field_string_new("first", _("First name"), 816 field = purple_request_field_string_new("first", _("First name"),
817 NULL, FALSE); 817 NULL, FALSE);
818 gaim_request_field_group_add_field(group, field); 818 purple_request_field_group_add_field(group, field);
819 } 819 }
820 if(xmlnode_get_child(query, "last")) { 820 if(xmlnode_get_child(query, "last")) {
821 field = gaim_request_field_string_new("last", _("Last name"), 821 field = purple_request_field_string_new("last", _("Last name"),
822 NULL, FALSE); 822 NULL, FALSE);
823 gaim_request_field_group_add_field(group, field); 823 purple_request_field_group_add_field(group, field);
824 } 824 }
825 if(xmlnode_get_child(query, "address")) { 825 if(xmlnode_get_child(query, "address")) {
826 field = gaim_request_field_string_new("address", _("Address"), 826 field = purple_request_field_string_new("address", _("Address"),
827 NULL, FALSE); 827 NULL, FALSE);
828 gaim_request_field_group_add_field(group, field); 828 purple_request_field_group_add_field(group, field);
829 } 829 }
830 if(xmlnode_get_child(query, "city")) { 830 if(xmlnode_get_child(query, "city")) {
831 field = gaim_request_field_string_new("city", _("City"), 831 field = purple_request_field_string_new("city", _("City"),
832 NULL, FALSE); 832 NULL, FALSE);
833 gaim_request_field_group_add_field(group, field); 833 purple_request_field_group_add_field(group, field);
834 } 834 }
835 if(xmlnode_get_child(query, "state")) { 835 if(xmlnode_get_child(query, "state")) {
836 field = gaim_request_field_string_new("state", _("State"), 836 field = purple_request_field_string_new("state", _("State"),
837 NULL, FALSE); 837 NULL, FALSE);
838 gaim_request_field_group_add_field(group, field); 838 purple_request_field_group_add_field(group, field);
839 } 839 }
840 if(xmlnode_get_child(query, "zip")) { 840 if(xmlnode_get_child(query, "zip")) {
841 field = gaim_request_field_string_new("zip", _("Postal code"), 841 field = purple_request_field_string_new("zip", _("Postal code"),
842 NULL, FALSE); 842 NULL, FALSE);
843 gaim_request_field_group_add_field(group, field); 843 purple_request_field_group_add_field(group, field);
844 } 844 }
845 if(xmlnode_get_child(query, "phone")) { 845 if(xmlnode_get_child(query, "phone")) {
846 field = gaim_request_field_string_new("phone", _("Phone"), 846 field = purple_request_field_string_new("phone", _("Phone"),
847 NULL, FALSE); 847 NULL, FALSE);
848 gaim_request_field_group_add_field(group, field); 848 purple_request_field_group_add_field(group, field);
849 } 849 }
850 if(xmlnode_get_child(query, "url")) { 850 if(xmlnode_get_child(query, "url")) {
851 field = gaim_request_field_string_new("url", _("URL"), 851 field = purple_request_field_string_new("url", _("URL"),
852 NULL, FALSE); 852 NULL, FALSE);
853 gaim_request_field_group_add_field(group, field); 853 purple_request_field_group_add_field(group, field);
854 } 854 }
855 if(xmlnode_get_child(query, "date")) { 855 if(xmlnode_get_child(query, "date")) {
856 field = gaim_request_field_string_new("date", _("Date"), 856 field = purple_request_field_string_new("date", _("Date"),
857 NULL, FALSE); 857 NULL, FALSE);
858 gaim_request_field_group_add_field(group, field); 858 purple_request_field_group_add_field(group, field);
859 } 859 }
860 860
861 if((y = xmlnode_get_child(query, "instructions"))) 861 if((y = xmlnode_get_child(query, "instructions")))
862 instructions = xmlnode_get_data(y); 862 instructions = xmlnode_get_data(y);
863 else 863 else
864 instructions = g_strdup(_("Please fill out the information below " 864 instructions = g_strdup(_("Please fill out the information below "
865 "to register your new account.")); 865 "to register your new account."));
866 866
867 gaim_request_fields(js->gc, _("Register New Jabber Account"), 867 purple_request_fields(js->gc, _("Register New Jabber Account"),
868 _("Register New Jabber Account"), instructions, fields, 868 _("Register New Jabber Account"), instructions, fields,
869 _("Register"), G_CALLBACK(jabber_register_cb), 869 _("Register"), G_CALLBACK(jabber_register_cb),
870 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js); 870 _("Cancel"), G_CALLBACK(jabber_register_cancel_cb), js);
871 871
872 g_free(instructions); 872 g_free(instructions);
879 879
880 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register"); 880 iq = jabber_iq_new_query(js, JABBER_IQ_GET, "jabber:iq:register");
881 jabber_iq_send(iq); 881 jabber_iq_send(iq);
882 } 882 }
883 883
884 static void jabber_register_account(GaimAccount *account) 884 static void jabber_register_account(PurpleAccount *account)
885 { 885 {
886 GaimConnection *gc = gaim_account_get_connection(account); 886 PurpleConnection *gc = purple_account_get_connection(account);
887 JabberStream *js; 887 JabberStream *js;
888 JabberBuddy *my_jb = NULL; 888 JabberBuddy *my_jb = NULL;
889 const char *connect_server = gaim_account_get_string(account, 889 const char *connect_server = purple_account_get_string(account,
890 "connect_server", ""); 890 "connect_server", "");
891 const char *server; 891 const char *server;
892 892
893 js = gc->proto_data = g_new0(JabberStream, 1); 893 js = gc->proto_data = g_new0(JabberStream, 1);
894 js->gc = gc; 894 js->gc = gc;
895 js->registration = TRUE; 895 js->registration = TRUE;
896 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, 896 js->iq_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
897 g_free, g_free); 897 g_free, g_free);
898 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal, 898 js->disco_callbacks = g_hash_table_new_full(g_str_hash, g_str_equal,
899 g_free, g_free); 899 g_free, g_free);
900 js->user = jabber_id_new(gaim_account_get_username(account)); 900 js->user = jabber_id_new(purple_account_get_username(account));
901 js->next_id = g_random_int(); 901 js->next_id = g_random_int();
902 902
903 if(!js->user) { 903 if(!js->user) {
904 gaim_connection_error(gc, _("Invalid Jabber ID")); 904 purple_connection_error(gc, _("Invalid Jabber ID"));
905 return; 905 return;
906 } 906 }
907 907
908 js->write_buffer = gaim_circ_buffer_new(512); 908 js->write_buffer = purple_circ_buffer_new(512);
909 909
910 if(!js->user->resource) { 910 if(!js->user->resource) {
911 char *me; 911 char *me;
912 js->user->resource = g_strdup("Home"); 912 js->user->resource = g_strdup("Home");
913 if(!js->user->node) { 913 if(!js->user->node) {
914 js->user->node = js->user->domain; 914 js->user->node = js->user->domain;
915 js->user->domain = g_strdup("jabber.org"); 915 js->user->domain = g_strdup("jabber.org");
916 } 916 }
917 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, 917 me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain,
918 js->user->resource); 918 js->user->resource);
919 gaim_account_set_username(account, me); 919 purple_account_set_username(account, me);
920 g_free(me); 920 g_free(me);
921 } 921 }
922 922
923 if((my_jb = jabber_buddy_find(js, gaim_account_get_username(account), TRUE))) 923 if((my_jb = jabber_buddy_find(js, purple_account_get_username(account), TRUE)))
924 my_jb->subscription |= JABBER_SUB_BOTH; 924 my_jb->subscription |= JABBER_SUB_BOTH;
925 925
926 server = connect_server[0] ? connect_server : js->user->domain; 926 server = connect_server[0] ? connect_server : js->user->domain;
927 927
928 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING); 928 jabber_stream_set_state(js, JABBER_STREAM_CONNECTING);
929 929
930 if(gaim_account_get_bool(account, "old_ssl", FALSE)) { 930 if(purple_account_get_bool(account, "old_ssl", FALSE)) {
931 if(gaim_ssl_is_supported()) { 931 if(purple_ssl_is_supported()) {
932 js->gsc = gaim_ssl_connect(account, server, 932 js->gsc = purple_ssl_connect(account, server,
933 gaim_account_get_int(account, "port", 5222), 933 purple_account_get_int(account, "port", 5222),
934 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc); 934 jabber_login_callback_ssl, jabber_ssl_connect_failure, gc);
935 } else { 935 } else {
936 gaim_connection_error(gc, _("SSL support unavailable")); 936 purple_connection_error(gc, _("SSL support unavailable"));
937 } 937 }
938 } 938 }
939 939
940 if(!js->gsc) { 940 if(!js->gsc) {
941 if (connect_server[0]) { 941 if (connect_server[0]) {
942 jabber_login_connect(js, server, 942 jabber_login_connect(js, server,
943 gaim_account_get_int(account, 943 purple_account_get_int(account,
944 "port", 5222)); 944 "port", 5222));
945 } else { 945 } else {
946 js->srv_query_data = gaim_srv_resolve("xmpp-client", 946 js->srv_query_data = purple_srv_resolve("xmpp-client",
947 "tcp", 947 "tcp",
948 js->user->domain, 948 js->user->domain,
949 srv_resolved_cb, 949 srv_resolved_cb,
950 js); 950 js);
951 } 951 }
952 } 952 }
953 } 953 }
954 954
955 static void jabber_close(GaimConnection *gc) 955 static void jabber_close(PurpleConnection *gc)
956 { 956 {
957 JabberStream *js = gc->proto_data; 957 JabberStream *js = gc->proto_data;
958 958
959 /* Don't perform any actions on the ssl connection 959 /* Don't perform any actions on the ssl connection
960 * if we were forcibly disconnected because it will crash 960 * if we were forcibly disconnected because it will crash
962 */ 962 */
963 if (!gc->disconnect_timeout) 963 if (!gc->disconnect_timeout)
964 jabber_send_raw(js, "</stream:stream>", -1); 964 jabber_send_raw(js, "</stream:stream>", -1);
965 965
966 if (js->srv_query_data) 966 if (js->srv_query_data)
967 gaim_srv_cancel(js->srv_query_data); 967 purple_srv_cancel(js->srv_query_data);
968 968
969 if(js->gsc) { 969 if(js->gsc) {
970 #ifdef HAVE_OPENSSL 970 #ifdef HAVE_OPENSSL
971 if (!gc->disconnect_timeout) 971 if (!gc->disconnect_timeout)
972 #endif 972 #endif
973 gaim_ssl_close(js->gsc); 973 purple_ssl_close(js->gsc);
974 } else if (js->fd > 0) { 974 } else if (js->fd > 0) {
975 if(js->gc->inpa) 975 if(js->gc->inpa)
976 gaim_input_remove(js->gc->inpa); 976 purple_input_remove(js->gc->inpa);
977 close(js->fd); 977 close(js->fd);
978 } 978 }
979 979
980 jabber_buddy_remove_all_pending_buddy_info_requests(js); 980 jabber_buddy_remove_all_pending_buddy_info_requests(js);
981 981
999 g_free(js->stream_id); 999 g_free(js->stream_id);
1000 if(js->user) 1000 if(js->user)
1001 jabber_id_free(js->user); 1001 jabber_id_free(js->user);
1002 if(js->avatar_hash) 1002 if(js->avatar_hash)
1003 g_free(js->avatar_hash); 1003 g_free(js->avatar_hash);
1004 gaim_circ_buffer_destroy(js->write_buffer); 1004 purple_circ_buffer_destroy(js->write_buffer);
1005 if(js->writeh) 1005 if(js->writeh)
1006 gaim_input_remove(js->writeh); 1006 purple_input_remove(js->writeh);
1007 #ifdef HAVE_CYRUS_SASL 1007 #ifdef HAVE_CYRUS_SASL
1008 if(js->sasl) 1008 if(js->sasl)
1009 sasl_dispose(&js->sasl); 1009 sasl_dispose(&js->sasl);
1010 if(js->sasl_mechs) 1010 if(js->sasl_mechs)
1011 g_string_free(js->sasl_mechs, TRUE); 1011 g_string_free(js->sasl_mechs, TRUE);
1027 js->state = state; 1027 js->state = state;
1028 switch(state) { 1028 switch(state) {
1029 case JABBER_STREAM_OFFLINE: 1029 case JABBER_STREAM_OFFLINE:
1030 break; 1030 break;
1031 case JABBER_STREAM_CONNECTING: 1031 case JABBER_STREAM_CONNECTING:
1032 gaim_connection_update_progress(js->gc, _("Connecting"), 1, 1032 purple_connection_update_progress(js->gc, _("Connecting"), 1,
1033 JABBER_CONNECT_STEPS); 1033 JABBER_CONNECT_STEPS);
1034 break; 1034 break;
1035 case JABBER_STREAM_INITIALIZING: 1035 case JABBER_STREAM_INITIALIZING:
1036 gaim_connection_update_progress(js->gc, _("Initializing Stream"), 1036 purple_connection_update_progress(js->gc, _("Initializing Stream"),
1037 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS); 1037 js->gsc ? 5 : 2, JABBER_CONNECT_STEPS);
1038 jabber_stream_init(js); 1038 jabber_stream_init(js);
1039 break; 1039 break;
1040 case JABBER_STREAM_AUTHENTICATING: 1040 case JABBER_STREAM_AUTHENTICATING:
1041 gaim_connection_update_progress(js->gc, _("Authenticating"), 1041 purple_connection_update_progress(js->gc, _("Authenticating"),
1042 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS); 1042 js->gsc ? 6 : 3, JABBER_CONNECT_STEPS);
1043 if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) { 1043 if(js->protocol_version == JABBER_PROTO_0_9 && js->registration) {
1044 jabber_register_start(js); 1044 jabber_register_start(js);
1045 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) { 1045 } else if(js->auth_type == JABBER_AUTH_IQ_AUTH) {
1046 jabber_auth_start_old(js); 1046 jabber_auth_start_old(js);
1047 } 1047 }
1048 break; 1048 break;
1049 case JABBER_STREAM_REINITIALIZING: 1049 case JABBER_STREAM_REINITIALIZING:
1050 gaim_connection_update_progress(js->gc, _("Re-initializing Stream"), 1050 purple_connection_update_progress(js->gc, _("Re-initializing Stream"),
1051 (js->gsc ? 7 : 4), JABBER_CONNECT_STEPS); 1051 (js->gsc ? 7 : 4), JABBER_CONNECT_STEPS);
1052 1052
1053 /* The stream will be reinitialized later, in jabber_recv_cb_ssl() */ 1053 /* The stream will be reinitialized later, in jabber_recv_cb_ssl() */
1054 js->reinit = TRUE; 1054 js->reinit = TRUE;
1055 1055
1056 break; 1056 break;
1057 case JABBER_STREAM_CONNECTED: 1057 case JABBER_STREAM_CONNECTED:
1058 gaim_connection_set_state(js->gc, GAIM_CONNECTED); 1058 purple_connection_set_state(js->gc, PURPLE_CONNECTED);
1059 jabber_disco_items_server(js); 1059 jabber_disco_items_server(js);
1060 break; 1060 break;
1061 } 1061 }
1062 } 1062 }
1063 1063
1064 char *jabber_get_next_id(JabberStream *js) 1064 char *jabber_get_next_id(JabberStream *js)
1065 { 1065 {
1066 return g_strdup_printf("gaim%x", js->next_id++); 1066 return g_strdup_printf("purple%x", js->next_id++);
1067 } 1067 }
1068 1068
1069 1069
1070 static void jabber_idle_set(GaimConnection *gc, int idle) 1070 static void jabber_idle_set(PurpleConnection *gc, int idle)
1071 { 1071 {
1072 JabberStream *js = gc->proto_data; 1072 JabberStream *js = gc->proto_data;
1073 1073
1074 js->idle = idle ? time(NULL) - idle : idle; 1074 js->idle = idle ? time(NULL) - idle : idle;
1075 } 1075 }
1076 1076
1077 static const char *jabber_list_icon(GaimAccount *a, GaimBuddy *b) 1077 static const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b)
1078 { 1078 {
1079 return "jabber"; 1079 return "jabber";
1080 } 1080 }
1081 1081
1082 static const char* jabber_list_emblem(GaimBuddy *b) 1082 static const char* jabber_list_emblem(PurpleBuddy *b)
1083 { 1083 {
1084 JabberStream *js; 1084 JabberStream *js;
1085 JabberBuddy *jb = NULL; 1085 JabberBuddy *jb = NULL;
1086 1086
1087 if(!b->account->gc) 1087 if(!b->account->gc)
1089 1089
1090 js = b->account->gc->proto_data; 1090 js = b->account->gc->proto_data;
1091 if(js) 1091 if(js)
1092 jb = jabber_buddy_find(js, b->name, FALSE); 1092 jb = jabber_buddy_find(js, b->name, FALSE);
1093 1093
1094 if(!GAIM_BUDDY_IS_ONLINE(b)) { 1094 if(!PURPLE_BUDDY_IS_ONLINE(b)) {
1095 if(jb && (jb->subscription & JABBER_SUB_PENDING || 1095 if(jb && (jb->subscription & JABBER_SUB_PENDING ||
1096 !(jb->subscription & JABBER_SUB_TO))) 1096 !(jb->subscription & JABBER_SUB_TO)))
1097 return "not-authorized"; 1097 return "not-authorized";
1098 } 1098 }
1099 return NULL; 1099 return NULL;
1100 } 1100 }
1101 1101
1102 static char *jabber_status_text(GaimBuddy *b) 1102 static char *jabber_status_text(PurpleBuddy *b)
1103 { 1103 {
1104 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name, 1104 JabberBuddy *jb = jabber_buddy_find(b->account->gc->proto_data, b->name,
1105 FALSE); 1105 FALSE);
1106 char *ret = NULL; 1106 char *ret = NULL;
1107 1107
1108 if(jb && !GAIM_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) { 1108 if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && (jb->subscription & JABBER_SUB_PENDING || !(jb->subscription & JABBER_SUB_TO))) {
1109 ret = g_strdup(_("Not Authorized")); 1109 ret = g_strdup(_("Not Authorized"));
1110 } else if(jb && !GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { 1110 } else if(jb && !PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
1111 ret = g_strdup(jb->error_msg); 1111 ret = g_strdup(jb->error_msg);
1112 } else { 1112 } else {
1113 char *stripped; 1113 char *stripped;
1114 1114
1115 if(!(stripped = gaim_markup_strip_html(jabber_buddy_get_status_msg(jb)))) { 1115 if(!(stripped = purple_markup_strip_html(jabber_buddy_get_status_msg(jb)))) {
1116 GaimStatus *status = gaim_presence_get_active_status(gaim_buddy_get_presence(b)); 1116 PurpleStatus *status = purple_presence_get_active_status(purple_buddy_get_presence(b));
1117 1117
1118 if(!gaim_status_is_available(status)) 1118 if(!purple_status_is_available(status))
1119 stripped = g_strdup(gaim_status_get_name(status)); 1119 stripped = g_strdup(purple_status_get_name(status));
1120 } 1120 }
1121 1121
1122 if(stripped) { 1122 if(stripped) {
1123 ret = g_markup_escape_text(stripped, -1); 1123 ret = g_markup_escape_text(stripped, -1);
1124 g_free(stripped); 1124 g_free(stripped);
1126 } 1126 }
1127 1127
1128 return ret; 1128 return ret;
1129 } 1129 }
1130 1130
1131 static void jabber_tooltip_text(GaimBuddy *b, GaimNotifyUserInfo *user_info, gboolean full) 1131 static void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full)
1132 { 1132 {
1133 JabberBuddy *jb; 1133 JabberBuddy *jb;
1134 1134
1135 g_return_if_fail(b != NULL); 1135 g_return_if_fail(b != NULL);
1136 g_return_if_fail(b->account != NULL); 1136 g_return_if_fail(b->account != NULL);
1160 sub = _("None (To pending)"); 1160 sub = _("None (To pending)");
1161 else 1161 else
1162 sub = _("None"); 1162 sub = _("None");
1163 } 1163 }
1164 1164
1165 gaim_notify_user_info_add_pair(user_info, _("Subscription"), sub); 1165 purple_notify_user_info_add_pair(user_info, _("Subscription"), sub);
1166 } 1166 }
1167 1167
1168 for(l=jb->resources; l; l = l->next) { 1168 for(l=jb->resources; l; l = l->next) {
1169 char *text = NULL; 1169 char *text = NULL;
1170 char *res = NULL; 1170 char *res = NULL;
1173 1173
1174 jbr = l->data; 1174 jbr = l->data;
1175 1175
1176 if(jbr->status) { 1176 if(jbr->status) {
1177 char *tmp; 1177 char *tmp;
1178 text = gaim_strreplace(jbr->status, "\n", "<br />\n"); 1178 text = purple_strreplace(jbr->status, "\n", "<br />\n");
1179 tmp = gaim_markup_strip_html(text); 1179 tmp = purple_markup_strip_html(text);
1180 g_free(text); 1180 g_free(text);
1181 text = g_markup_escape_text(tmp, -1); 1181 text = g_markup_escape_text(tmp, -1);
1182 g_free(tmp); 1182 g_free(tmp);
1183 } 1183 }
1184 1184
1185 if(jbr->name) 1185 if(jbr->name)
1186 res = g_strdup_printf(" (%s)", jbr->name); 1186 res = g_strdup_printf(" (%s)", jbr->name);
1187 1187
1188 state = jabber_buddy_state_get_name(jbr->state); 1188 state = jabber_buddy_state_get_name(jbr->state);
1189 if (text != NULL && !gaim_utf8_strcasecmp(state, text)) { 1189 if (text != NULL && !purple_utf8_strcasecmp(state, text)) {
1190 g_free(text); 1190 g_free(text);
1191 text = NULL; 1191 text = NULL;
1192 } 1192 }
1193 1193
1194 label = g_strdup_printf("%s%s", 1194 label = g_strdup_printf("%s%s",
1196 value = g_strdup_printf("%s%s%s", 1196 value = g_strdup_printf("%s%s%s",
1197 state, 1197 state,
1198 (text ? ": " : ""), 1198 (text ? ": " : ""),
1199 (text ? text : "")); 1199 (text ? text : ""));
1200 1200
1201 gaim_notify_user_info_add_pair(user_info, label, value); 1201 purple_notify_user_info_add_pair(user_info, label, value);
1202 1202
1203 g_free(label); 1203 g_free(label);
1204 g_free(value); 1204 g_free(value);
1205 g_free(text); 1205 g_free(text);
1206 g_free(res); 1206 g_free(res);
1207 } 1207 }
1208 1208
1209 if(!GAIM_BUDDY_IS_ONLINE(b) && jb->error_msg) { 1209 if(!PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) {
1210 gaim_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg); 1210 purple_notify_user_info_add_pair(user_info, _("Error"), jb->error_msg);
1211 } 1211 }
1212 } 1212 }
1213 } 1213 }
1214 1214
1215 static GList *jabber_status_types(GaimAccount *account) 1215 static GList *jabber_status_types(PurpleAccount *account)
1216 { 1216 {
1217 GaimStatusType *type; 1217 PurpleStatusType *type;
1218 GList *types = NULL; 1218 GList *types = NULL;
1219 GaimValue *priority_value; 1219 PurpleValue *priority_value;
1220 1220
1221 priority_value = gaim_value_new(GAIM_TYPE_INT); 1221 priority_value = purple_value_new(PURPLE_TYPE_INT);
1222 gaim_value_set_int(priority_value, 1); 1222 purple_value_set_int(priority_value, 1);
1223 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, 1223 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
1224 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE), 1224 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_ONLINE),
1225 NULL, TRUE, TRUE, FALSE, 1225 NULL, TRUE, TRUE, FALSE,
1226 "priority", _("Priority"), priority_value, 1226 "priority", _("Priority"), priority_value,
1227 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), 1227 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
1228 NULL); 1228 NULL);
1229 types = g_list_append(types, type); 1229 types = g_list_append(types, type);
1230 1230
1231 priority_value = gaim_value_new(GAIM_TYPE_INT); 1231 priority_value = purple_value_new(PURPLE_TYPE_INT);
1232 gaim_value_set_int(priority_value, 1); 1232 purple_value_set_int(priority_value, 1);
1233 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AVAILABLE, 1233 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AVAILABLE,
1234 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT), 1234 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_CHAT),
1235 _("Chatty"), TRUE, TRUE, FALSE, 1235 _("Chatty"), TRUE, TRUE, FALSE,
1236 "priority", _("Priority"), priority_value, 1236 "priority", _("Priority"), priority_value,
1237 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), 1237 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
1238 NULL); 1238 NULL);
1239 types = g_list_append(types, type); 1239 types = g_list_append(types, type);
1240 1240
1241 priority_value = gaim_value_new(GAIM_TYPE_INT); 1241 priority_value = purple_value_new(PURPLE_TYPE_INT);
1242 gaim_value_set_int(priority_value, 0); 1242 purple_value_set_int(priority_value, 0);
1243 type = gaim_status_type_new_with_attrs(GAIM_STATUS_AWAY, 1243 type = purple_status_type_new_with_attrs(PURPLE_STATUS_AWAY,
1244 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY), 1244 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_AWAY),
1245 NULL, TRUE, TRUE, FALSE, 1245 NULL, TRUE, TRUE, FALSE,
1246 "priority", _("Priority"), priority_value, 1246 "priority", _("Priority"), priority_value,
1247 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), 1247 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
1248 NULL); 1248 NULL);
1249 types = g_list_append(types, type); 1249 types = g_list_append(types, type);
1250 1250
1251 priority_value = gaim_value_new(GAIM_TYPE_INT); 1251 priority_value = purple_value_new(PURPLE_TYPE_INT);
1252 gaim_value_set_int(priority_value, 0); 1252 purple_value_set_int(priority_value, 0);
1253 type = gaim_status_type_new_with_attrs(GAIM_STATUS_EXTENDED_AWAY, 1253 type = purple_status_type_new_with_attrs(PURPLE_STATUS_EXTENDED_AWAY,
1254 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA), 1254 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_XA),
1255 NULL, TRUE, TRUE, FALSE, 1255 NULL, TRUE, TRUE, FALSE,
1256 "priority", _("Priority"), priority_value, 1256 "priority", _("Priority"), priority_value,
1257 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), 1257 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
1258 NULL); 1258 NULL);
1259 types = g_list_append(types, type); 1259 types = g_list_append(types, type);
1260 1260
1261 priority_value = gaim_value_new(GAIM_TYPE_INT); 1261 priority_value = purple_value_new(PURPLE_TYPE_INT);
1262 gaim_value_set_int(priority_value, 0); 1262 purple_value_set_int(priority_value, 0);
1263 type = gaim_status_type_new_with_attrs(GAIM_STATUS_UNAVAILABLE, 1263 type = purple_status_type_new_with_attrs(PURPLE_STATUS_UNAVAILABLE,
1264 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND), 1264 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_DND),
1265 _("Do Not Disturb"), TRUE, TRUE, FALSE, 1265 _("Do Not Disturb"), TRUE, TRUE, FALSE,
1266 "priority", _("Priority"), priority_value, 1266 "priority", _("Priority"), priority_value,
1267 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), 1267 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
1268 NULL); 1268 NULL);
1269 types = g_list_append(types, type); 1269 types = g_list_append(types, type);
1270 1270
1271 /* 1271 /*
1272 if(js->protocol_version == JABBER_PROTO_0_9) 1272 if(js->protocol_version == JABBER_PROTO_0_9)
1273 m = g_list_append(m, _("Invisible")); 1273 m = g_list_append(m, _("Invisible"));
1274 */ 1274 */
1275 1275
1276 type = gaim_status_type_new_with_attrs(GAIM_STATUS_OFFLINE, 1276 type = purple_status_type_new_with_attrs(PURPLE_STATUS_OFFLINE,
1277 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE), 1277 jabber_buddy_state_get_status_id(JABBER_BUDDY_STATE_UNAVAILABLE),
1278 NULL, FALSE, TRUE, FALSE, 1278 NULL, FALSE, TRUE, FALSE,
1279 "message", _("Message"), gaim_value_new(GAIM_TYPE_STRING), 1279 "message", _("Message"), purple_value_new(PURPLE_TYPE_STRING),
1280 NULL); 1280 NULL);
1281 types = g_list_append(types, type); 1281 types = g_list_append(types, type);
1282 1282
1283 return types; 1283 return types;
1284 } 1284 }
1290 const char *type; 1290 const char *type;
1291 1291
1292 type = xmlnode_get_attrib(packet, "type"); 1292 type = xmlnode_get_attrib(packet, "type");
1293 1293
1294 if(type && !strcmp(type, "result")) { 1294 if(type && !strcmp(type, "result")) {
1295 gaim_notify_info(js->gc, _("Password Changed"), _("Password Changed"), 1295 purple_notify_info(js->gc, _("Password Changed"), _("Password Changed"),
1296 _("Your password has been changed.")); 1296 _("Your password has been changed."));
1297 } else { 1297 } else {
1298 char *msg = jabber_parse_error(js, packet); 1298 char *msg = jabber_parse_error(js, packet);
1299 1299
1300 gaim_notify_error(js->gc, _("Error changing password"), 1300 purple_notify_error(js->gc, _("Error changing password"),
1301 _("Error changing password"), msg); 1301 _("Error changing password"), msg);
1302 g_free(msg); 1302 g_free(msg);
1303 } 1303 }
1304 } 1304 }
1305 1305
1306 static void jabber_password_change_cb(JabberStream *js, 1306 static void jabber_password_change_cb(JabberStream *js,
1307 GaimRequestFields *fields) 1307 PurpleRequestFields *fields)
1308 { 1308 {
1309 const char *p1, *p2; 1309 const char *p1, *p2;
1310 JabberIq *iq; 1310 JabberIq *iq;
1311 xmlnode *query, *y; 1311 xmlnode *query, *y;
1312 1312
1313 p1 = gaim_request_fields_get_string(fields, "password1"); 1313 p1 = purple_request_fields_get_string(fields, "password1");
1314 p2 = gaim_request_fields_get_string(fields, "password2"); 1314 p2 = purple_request_fields_get_string(fields, "password2");
1315 1315
1316 if(strcmp(p1, p2)) { 1316 if(strcmp(p1, p2)) {
1317 gaim_notify_error(js->gc, NULL, _("New passwords do not match."), NULL); 1317 purple_notify_error(js->gc, NULL, _("New passwords do not match."), NULL);
1318 return; 1318 return;
1319 } 1319 }
1320 1320
1321 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register"); 1321 iq = jabber_iq_new_query(js, JABBER_IQ_SET, "jabber:iq:register");
1322 1322
1331 1331
1332 jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL); 1332 jabber_iq_set_callback(iq, jabber_password_change_result_cb, NULL);
1333 1333
1334 jabber_iq_send(iq); 1334 jabber_iq_send(iq);
1335 1335
1336 gaim_account_set_password(js->gc->account, p1); 1336 purple_account_set_password(js->gc->account, p1);
1337 } 1337 }
1338 1338
1339 static void jabber_password_change(GaimPluginAction *action) 1339 static void jabber_password_change(PurplePluginAction *action)
1340 { 1340 {
1341 1341
1342 GaimConnection *gc = (GaimConnection *) action->context; 1342 PurpleConnection *gc = (PurpleConnection *) action->context;
1343 JabberStream *js = gc->proto_data; 1343 JabberStream *js = gc->proto_data;
1344 GaimRequestFields *fields; 1344 PurpleRequestFields *fields;
1345 GaimRequestFieldGroup *group; 1345 PurpleRequestFieldGroup *group;
1346 GaimRequestField *field; 1346 PurpleRequestField *field;
1347 1347
1348 fields = gaim_request_fields_new(); 1348 fields = purple_request_fields_new();
1349 group = gaim_request_field_group_new(NULL); 1349 group = purple_request_field_group_new(NULL);
1350 gaim_request_fields_add_group(fields, group); 1350 purple_request_fields_add_group(fields, group);
1351 1351
1352 field = gaim_request_field_string_new("password1", _("Password"), 1352 field = purple_request_field_string_new("password1", _("Password"),
1353 "", FALSE); 1353 "", FALSE);
1354 gaim_request_field_string_set_masked(field, TRUE); 1354 purple_request_field_string_set_masked(field, TRUE);
1355 gaim_request_field_group_add_field(group, field); 1355 purple_request_field_group_add_field(group, field);
1356 1356
1357 field = gaim_request_field_string_new("password2", _("Password (again)"), 1357 field = purple_request_field_string_new("password2", _("Password (again)"),
1358 "", FALSE); 1358 "", FALSE);
1359 gaim_request_field_string_set_masked(field, TRUE); 1359 purple_request_field_string_set_masked(field, TRUE);
1360 gaim_request_field_group_add_field(group, field); 1360 purple_request_field_group_add_field(group, field);
1361 1361
1362 gaim_request_fields(js->gc, _("Change Jabber Password"), 1362 purple_request_fields(js->gc, _("Change Jabber Password"),
1363 _("Change Jabber Password"), _("Please enter your new password"), 1363 _("Change Jabber Password"), _("Please enter your new password"),
1364 fields, _("OK"), G_CALLBACK(jabber_password_change_cb), 1364 fields, _("OK"), G_CALLBACK(jabber_password_change_cb),
1365 _("Cancel"), NULL, js); 1365 _("Cancel"), NULL, js);
1366 } 1366 }
1367 1367
1368 static GList *jabber_actions(GaimPlugin *plugin, gpointer context) 1368 static GList *jabber_actions(PurplePlugin *plugin, gpointer context)
1369 { 1369 {
1370 GList *m = NULL; 1370 GList *m = NULL;
1371 GaimPluginAction *act; 1371 PurplePluginAction *act;
1372 1372
1373 act = gaim_plugin_action_new(_("Set User Info..."), 1373 act = purple_plugin_action_new(_("Set User Info..."),
1374 jabber_setup_set_info); 1374 jabber_setup_set_info);
1375 m = g_list_append(m, act); 1375 m = g_list_append(m, act);
1376 1376
1377 /* if (js->protocol_options & CHANGE_PASSWORD) { */ 1377 /* if (js->protocol_options & CHANGE_PASSWORD) { */
1378 act = gaim_plugin_action_new(_("Change Password..."), 1378 act = purple_plugin_action_new(_("Change Password..."),
1379 jabber_password_change); 1379 jabber_password_change);
1380 m = g_list_append(m, act); 1380 m = g_list_append(m, act);
1381 /* } */ 1381 /* } */
1382 1382
1383 act = gaim_plugin_action_new(_("Search for Users..."), 1383 act = purple_plugin_action_new(_("Search for Users..."),
1384 jabber_user_search_begin); 1384 jabber_user_search_begin);
1385 m = g_list_append(m, act); 1385 m = g_list_append(m, act);
1386 1386
1387 return m; 1387 return m;
1388 } 1388 }
1389 1389
1390 static GaimChat *jabber_find_blist_chat(GaimAccount *account, const char *name) 1390 static PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name)
1391 { 1391 {
1392 GaimBlistNode *gnode, *cnode; 1392 PurpleBlistNode *gnode, *cnode;
1393 JabberID *jid; 1393 JabberID *jid;
1394 1394
1395 if(!(jid = jabber_id_new(name))) 1395 if(!(jid = jabber_id_new(name)))
1396 return NULL; 1396 return NULL;
1397 1397
1398 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { 1398 for(gnode = purple_get_blist()->root; gnode; gnode = gnode->next) {
1399 for(cnode = gnode->child; cnode; cnode = cnode->next) { 1399 for(cnode = gnode->child; cnode; cnode = cnode->next) {
1400 GaimChat *chat = (GaimChat*)cnode; 1400 PurpleChat *chat = (PurpleChat*)cnode;
1401 const char *room, *server; 1401 const char *room, *server;
1402 if(!GAIM_BLIST_NODE_IS_CHAT(cnode)) 1402 if(!PURPLE_BLIST_NODE_IS_CHAT(cnode))
1403 continue; 1403 continue;
1404 1404
1405 if(chat->account != account) 1405 if(chat->account != account)
1406 continue; 1406 continue;
1407 1407
1419 } 1419 }
1420 jabber_id_free(jid); 1420 jabber_id_free(jid);
1421 return NULL; 1421 return NULL;
1422 } 1422 }
1423 1423
1424 static void jabber_convo_closed(GaimConnection *gc, const char *who) 1424 static void jabber_convo_closed(PurpleConnection *gc, const char *who)
1425 { 1425 {
1426 JabberStream *js = gc->proto_data; 1426 JabberStream *js = gc->proto_data;
1427 JabberID *jid; 1427 JabberID *jid;
1428 JabberBuddy *jb; 1428 JabberBuddy *jb;
1429 JabberBuddyResource *jbr; 1429 JabberBuddyResource *jbr;
1589 } else { 1589 } else {
1590 return NULL; 1590 return NULL;
1591 } 1591 }
1592 } 1592 }
1593 1593
1594 static GaimCmdRet jabber_cmd_chat_config(GaimConversation *conv, 1594 static PurpleCmdRet jabber_cmd_chat_config(PurpleConversation *conv,
1595 const char *cmd, char **args, char **error, void *data) 1595 const char *cmd, char **args, char **error, void *data)
1596 { 1596 {
1597 JabberChat *chat = jabber_chat_find_by_conv(conv); 1597 JabberChat *chat = jabber_chat_find_by_conv(conv);
1598 jabber_chat_request_room_configure(chat); 1598 jabber_chat_request_room_configure(chat);
1599 return GAIM_CMD_RET_OK; 1599 return PURPLE_CMD_RET_OK;
1600 } 1600 }
1601 1601
1602 static GaimCmdRet jabber_cmd_chat_register(GaimConversation *conv, 1602 static PurpleCmdRet jabber_cmd_chat_register(PurpleConversation *conv,
1603 const char *cmd, char **args, char **error, void *data) 1603 const char *cmd, char **args, char **error, void *data)
1604 { 1604 {
1605 JabberChat *chat = jabber_chat_find_by_conv(conv); 1605 JabberChat *chat = jabber_chat_find_by_conv(conv);
1606 jabber_chat_register(chat); 1606 jabber_chat_register(chat);
1607 return GAIM_CMD_RET_OK; 1607 return PURPLE_CMD_RET_OK;
1608 } 1608 }
1609 1609
1610 static GaimCmdRet jabber_cmd_chat_topic(GaimConversation *conv, 1610 static PurpleCmdRet jabber_cmd_chat_topic(PurpleConversation *conv,
1611 const char *cmd, char **args, char **error, void *data) 1611 const char *cmd, char **args, char **error, void *data)
1612 { 1612 {
1613 JabberChat *chat = jabber_chat_find_by_conv(conv); 1613 JabberChat *chat = jabber_chat_find_by_conv(conv);
1614 jabber_chat_change_topic(chat, args ? args[0] : NULL); 1614 jabber_chat_change_topic(chat, args ? args[0] : NULL);
1615 return GAIM_CMD_RET_OK; 1615 return PURPLE_CMD_RET_OK;
1616 } 1616 }
1617 1617
1618 static GaimCmdRet jabber_cmd_chat_nick(GaimConversation *conv, 1618 static PurpleCmdRet jabber_cmd_chat_nick(PurpleConversation *conv,
1619 const char *cmd, char **args, char **error, void *data) 1619 const char *cmd, char **args, char **error, void *data)
1620 { 1620 {
1621 JabberChat *chat = jabber_chat_find_by_conv(conv); 1621 JabberChat *chat = jabber_chat_find_by_conv(conv);
1622 1622
1623 if(!args || !args[0]) 1623 if(!args || !args[0])
1624 return GAIM_CMD_RET_FAILED; 1624 return PURPLE_CMD_RET_FAILED;
1625 1625
1626 jabber_chat_change_nick(chat, args[0]); 1626 jabber_chat_change_nick(chat, args[0]);
1627 return GAIM_CMD_RET_OK; 1627 return PURPLE_CMD_RET_OK;
1628 } 1628 }
1629 1629
1630 static GaimCmdRet jabber_cmd_chat_part(GaimConversation *conv, 1630 static PurpleCmdRet jabber_cmd_chat_part(PurpleConversation *conv,
1631 const char *cmd, char **args, char **error, void *data) 1631 const char *cmd, char **args, char **error, void *data)
1632 { 1632 {
1633 JabberChat *chat = jabber_chat_find_by_conv(conv); 1633 JabberChat *chat = jabber_chat_find_by_conv(conv);
1634 jabber_chat_part(chat, args ? args[0] : NULL); 1634 jabber_chat_part(chat, args ? args[0] : NULL);
1635 return GAIM_CMD_RET_OK; 1635 return PURPLE_CMD_RET_OK;
1636 } 1636 }
1637 1637
1638 static GaimCmdRet jabber_cmd_chat_ban(GaimConversation *conv, 1638 static PurpleCmdRet jabber_cmd_chat_ban(PurpleConversation *conv,
1639 const char *cmd, char **args, char **error, void *data) 1639 const char *cmd, char **args, char **error, void *data)
1640 { 1640 {
1641 JabberChat *chat = jabber_chat_find_by_conv(conv); 1641 JabberChat *chat = jabber_chat_find_by_conv(conv);
1642 1642
1643 if(!args || !args[0]) 1643 if(!args || !args[0])
1644 return GAIM_CMD_RET_FAILED; 1644 return PURPLE_CMD_RET_FAILED;
1645 1645
1646 if(!jabber_chat_ban_user(chat, args[0], args[1])) { 1646 if(!jabber_chat_ban_user(chat, args[0], args[1])) {
1647 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]); 1647 *error = g_strdup_printf(_("Unable to ban user %s"), args[0]);
1648 return GAIM_CMD_RET_FAILED; 1648 return PURPLE_CMD_RET_FAILED;
1649 } 1649 }
1650 1650
1651 return GAIM_CMD_RET_OK; 1651 return PURPLE_CMD_RET_OK;
1652 } 1652 }
1653 1653
1654 static GaimCmdRet jabber_cmd_chat_affiliate(GaimConversation *conv, 1654 static PurpleCmdRet jabber_cmd_chat_affiliate(PurpleConversation *conv,
1655 const char *cmd, char **args, char **error, void *data) 1655 const char *cmd, char **args, char **error, void *data)
1656 { 1656 {
1657 JabberChat *chat = jabber_chat_find_by_conv(conv); 1657 JabberChat *chat = jabber_chat_find_by_conv(conv);
1658 1658
1659 if (!args || !args[0] || !args[1]) 1659 if (!args || !args[0] || !args[1])
1660 return GAIM_CMD_RET_FAILED; 1660 return PURPLE_CMD_RET_FAILED;
1661 1661
1662 if (strcmp(args[1], "owner") != 0 && 1662 if (strcmp(args[1], "owner") != 0 &&
1663 strcmp(args[1], "admin") != 0 && 1663 strcmp(args[1], "admin") != 0 &&
1664 strcmp(args[1], "member") != 0 && 1664 strcmp(args[1], "member") != 0 &&
1665 strcmp(args[1], "outcast") != 0 && 1665 strcmp(args[1], "outcast") != 0 &&
1666 strcmp(args[1], "none") != 0) { 1666 strcmp(args[1], "none") != 0) {
1667 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]); 1667 *error = g_strdup_printf(_("Unknown affiliation: \"%s\""), args[1]);
1668 return GAIM_CMD_RET_FAILED; 1668 return PURPLE_CMD_RET_FAILED;
1669 } 1669 }
1670 1670
1671 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) { 1671 if (!jabber_chat_affiliate_user(chat, args[0], args[1])) {
1672 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]); 1672 *error = g_strdup_printf(_("Unable to affiliate user %s as \"%s\""), args[0], args[1]);
1673 return GAIM_CMD_RET_FAILED; 1673 return PURPLE_CMD_RET_FAILED;
1674 } 1674 }
1675 1675
1676 return GAIM_CMD_RET_OK; 1676 return PURPLE_CMD_RET_OK;
1677 } 1677 }
1678 1678
1679 static GaimCmdRet jabber_cmd_chat_role(GaimConversation *conv, 1679 static PurpleCmdRet jabber_cmd_chat_role(PurpleConversation *conv,
1680 const char *cmd, char **args, char **error, void *data) 1680 const char *cmd, char **args, char **error, void *data)
1681 { 1681 {
1682 JabberChat *chat; 1682 JabberChat *chat;
1683 1683
1684 if (!args || !args[0] || !args[1]) 1684 if (!args || !args[0] || !args[1])
1685 return GAIM_CMD_RET_FAILED; 1685 return PURPLE_CMD_RET_FAILED;
1686 1686
1687 if (strcmp(args[1], "moderator") != 0 && 1687 if (strcmp(args[1], "moderator") != 0 &&
1688 strcmp(args[1], "participant") != 0 && 1688 strcmp(args[1], "participant") != 0 &&
1689 strcmp(args[1], "visitor") != 0 && 1689 strcmp(args[1], "visitor") != 0 &&
1690 strcmp(args[1], "none") != 0) { 1690 strcmp(args[1], "none") != 0) {
1691 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]); 1691 *error = g_strdup_printf(_("Unknown role: \"%s\""), args[1]);
1692 return GAIM_CMD_RET_FAILED; 1692 return PURPLE_CMD_RET_FAILED;
1693 } 1693 }
1694 1694
1695 chat = jabber_chat_find_by_conv(conv); 1695 chat = jabber_chat_find_by_conv(conv);
1696 1696
1697 if (!jabber_chat_role_user(chat, args[0], args[1])) { 1697 if (!jabber_chat_role_user(chat, args[0], args[1])) {
1698 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"), 1698 *error = g_strdup_printf(_("Unable to set role \"%s\" for user: %s"),
1699 args[1], args[0]); 1699 args[1], args[0]);
1700 return GAIM_CMD_RET_FAILED; 1700 return PURPLE_CMD_RET_FAILED;
1701 } 1701 }
1702 1702
1703 return GAIM_CMD_RET_OK; 1703 return PURPLE_CMD_RET_OK;
1704 } 1704 }
1705 1705
1706 static GaimCmdRet jabber_cmd_chat_invite(GaimConversation *conv, 1706 static PurpleCmdRet jabber_cmd_chat_invite(PurpleConversation *conv,
1707 const char *cmd, char **args, char **error, void *data) 1707 const char *cmd, char **args, char **error, void *data)
1708 { 1708 {
1709 if(!args || !args[0]) 1709 if(!args || !args[0])
1710 return GAIM_CMD_RET_FAILED; 1710 return PURPLE_CMD_RET_FAILED;
1711 1711
1712 jabber_chat_invite(gaim_conversation_get_gc(conv), 1712 jabber_chat_invite(purple_conversation_get_gc(conv),
1713 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), args[1] ? args[1] : "", 1713 purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv)), args[1] ? args[1] : "",
1714 args[0]); 1714 args[0]);
1715 1715
1716 return GAIM_CMD_RET_OK; 1716 return PURPLE_CMD_RET_OK;
1717 } 1717 }
1718 1718
1719 static GaimCmdRet jabber_cmd_chat_join(GaimConversation *conv, 1719 static PurpleCmdRet jabber_cmd_chat_join(PurpleConversation *conv,
1720 const char *cmd, char **args, char **error, void *data) 1720 const char *cmd, char **args, char **error, void *data)
1721 { 1721 {
1722 JabberChat *chat = jabber_chat_find_by_conv(conv); 1722 JabberChat *chat = jabber_chat_find_by_conv(conv);
1723 GHashTable *components; 1723 GHashTable *components;
1724 1724
1725 if(!args || !args[0]) 1725 if(!args || !args[0])
1726 return GAIM_CMD_RET_FAILED; 1726 return PURPLE_CMD_RET_FAILED;
1727 1727
1728 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL); 1728 components = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, NULL);
1729 1729
1730 g_hash_table_replace(components, "room", args[0]); 1730 g_hash_table_replace(components, "room", args[0]);
1731 g_hash_table_replace(components, "server", chat->server); 1731 g_hash_table_replace(components, "server", chat->server);
1732 g_hash_table_replace(components, "handle", chat->handle); 1732 g_hash_table_replace(components, "handle", chat->handle);
1733 if(args[1]) 1733 if(args[1])
1734 g_hash_table_replace(components, "password", args[1]); 1734 g_hash_table_replace(components, "password", args[1]);
1735 1735
1736 jabber_chat_join(gaim_conversation_get_gc(conv), components); 1736 jabber_chat_join(purple_conversation_get_gc(conv), components);
1737 1737
1738 g_hash_table_destroy(components); 1738 g_hash_table_destroy(components);
1739 return GAIM_CMD_RET_OK; 1739 return PURPLE_CMD_RET_OK;
1740 } 1740 }
1741 1741
1742 static GaimCmdRet jabber_cmd_chat_kick(GaimConversation *conv, 1742 static PurpleCmdRet jabber_cmd_chat_kick(PurpleConversation *conv,
1743 const char *cmd, char **args, char **error, void *data) 1743 const char *cmd, char **args, char **error, void *data)
1744 { 1744 {
1745 JabberChat *chat = jabber_chat_find_by_conv(conv); 1745 JabberChat *chat = jabber_chat_find_by_conv(conv);
1746 1746
1747 if(!args || !args[0]) 1747 if(!args || !args[0])
1748 return GAIM_CMD_RET_FAILED; 1748 return PURPLE_CMD_RET_FAILED;
1749 1749
1750 if(!jabber_chat_kick_user(chat, args[0], args[1])) { 1750 if(!jabber_chat_kick_user(chat, args[0], args[1])) {
1751 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]); 1751 *error = g_strdup_printf(_("Unable to kick user %s"), args[0]);
1752 return GAIM_CMD_RET_FAILED; 1752 return PURPLE_CMD_RET_FAILED;
1753 } 1753 }
1754 1754
1755 return GAIM_CMD_RET_OK; 1755 return PURPLE_CMD_RET_OK;
1756 } 1756 }
1757 1757
1758 static GaimCmdRet jabber_cmd_chat_msg(GaimConversation *conv, 1758 static PurpleCmdRet jabber_cmd_chat_msg(PurpleConversation *conv,
1759 const char *cmd, char **args, char **error, void *data) 1759 const char *cmd, char **args, char **error, void *data)
1760 { 1760 {
1761 JabberChat *chat = jabber_chat_find_by_conv(conv); 1761 JabberChat *chat = jabber_chat_find_by_conv(conv);
1762 char *who; 1762 char *who;
1763 1763
1764 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]); 1764 who = g_strdup_printf("%s@%s/%s", chat->room, chat->server, args[0]);
1765 1765
1766 jabber_message_send_im(gaim_conversation_get_gc(conv), who, args[1], 0); 1766 jabber_message_send_im(purple_conversation_get_gc(conv), who, args[1], 0);
1767 1767
1768 g_free(who); 1768 g_free(who);
1769 return GAIM_CMD_RET_OK; 1769 return PURPLE_CMD_RET_OK;
1770 } 1770 }
1771 1771
1772 static gboolean jabber_offline_message(const GaimBuddy *buddy) 1772 static gboolean jabber_offline_message(const PurpleBuddy *buddy)
1773 { 1773 {
1774 return TRUE; 1774 return TRUE;
1775 } 1775 }
1776 1776
1777 static void jabber_register_commands(void) 1777 static void jabber_register_commands(void)
1778 { 1778 {
1779 gaim_cmd_register("config", "", GAIM_CMD_P_PRPL, 1779 purple_cmd_register("config", "", PURPLE_CMD_P_PRPL,
1780 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1780 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
1781 "prpl-jabber", jabber_cmd_chat_config, 1781 "prpl-jabber", jabber_cmd_chat_config,
1782 _("config: Configure a chat room."), NULL); 1782 _("config: Configure a chat room."), NULL);
1783 gaim_cmd_register("configure", "", GAIM_CMD_P_PRPL, 1783 purple_cmd_register("configure", "", PURPLE_CMD_P_PRPL,
1784 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1784 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
1785 "prpl-jabber", jabber_cmd_chat_config, 1785 "prpl-jabber", jabber_cmd_chat_config,
1786 _("configure: Configure a chat room."), NULL); 1786 _("configure: Configure a chat room."), NULL);
1787 gaim_cmd_register("nick", "s", GAIM_CMD_P_PRPL, 1787 purple_cmd_register("nick", "s", PURPLE_CMD_P_PRPL,
1788 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1788 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
1789 "prpl-jabber", jabber_cmd_chat_nick, 1789 "prpl-jabber", jabber_cmd_chat_nick,
1790 _("nick &lt;new nickname&gt;: Change your nickname."), 1790 _("nick &lt;new nickname&gt;: Change your nickname."),
1791 NULL); 1791 NULL);
1792 gaim_cmd_register("part", "s", GAIM_CMD_P_PRPL, 1792 purple_cmd_register("part", "s", PURPLE_CMD_P_PRPL,
1793 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1793 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1794 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1794 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1795 jabber_cmd_chat_part, _("part [room]: Leave the room."), 1795 jabber_cmd_chat_part, _("part [room]: Leave the room."),
1796 NULL); 1796 NULL);
1797 gaim_cmd_register("register", "", GAIM_CMD_P_PRPL, 1797 purple_cmd_register("register", "", PURPLE_CMD_P_PRPL,
1798 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1798 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
1799 "prpl-jabber", jabber_cmd_chat_register, 1799 "prpl-jabber", jabber_cmd_chat_register,
1800 _("register: Register with a chat room."), NULL); 1800 _("register: Register with a chat room."), NULL);
1801 /* XXX: there needs to be a core /topic cmd, methinks */ 1801 /* XXX: there needs to be a core /topic cmd, methinks */
1802 gaim_cmd_register("topic", "s", GAIM_CMD_P_PRPL, 1802 purple_cmd_register("topic", "s", PURPLE_CMD_P_PRPL,
1803 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1803 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1804 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1804 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1805 jabber_cmd_chat_topic, 1805 jabber_cmd_chat_topic,
1806 _("topic [new topic]: View or change the topic."), 1806 _("topic [new topic]: View or change the topic."),
1807 NULL); 1807 NULL);
1808 gaim_cmd_register("ban", "ws", GAIM_CMD_P_PRPL, 1808 purple_cmd_register("ban", "ws", PURPLE_CMD_P_PRPL,
1809 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1809 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1810 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1810 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1811 jabber_cmd_chat_ban, 1811 jabber_cmd_chat_ban,
1812 _("ban &lt;user&gt; [room]: Ban a user from the room."), 1812 _("ban &lt;user&gt; [room]: Ban a user from the room."),
1813 NULL); 1813 NULL);
1814 gaim_cmd_register("affiliate", "ws", GAIM_CMD_P_PRPL, 1814 purple_cmd_register("affiliate", "ws", PURPLE_CMD_P_PRPL,
1815 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1815 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1816 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1816 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1817 jabber_cmd_chat_affiliate, 1817 jabber_cmd_chat_affiliate,
1818 _("affiliate &lt;user&gt; &lt;owner|admin|member|outcast|none&gt;: Set a user's affiliation with the room."), 1818 _("affiliate &lt;user&gt; &lt;owner|admin|member|outcast|none&gt;: Set a user's affiliation with the room."),
1819 NULL); 1819 NULL);
1820 gaim_cmd_register("role", "ws", GAIM_CMD_P_PRPL, 1820 purple_cmd_register("role", "ws", PURPLE_CMD_P_PRPL,
1821 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1821 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1822 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1822 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1823 jabber_cmd_chat_role, 1823 jabber_cmd_chat_role,
1824 _("role &lt;user&gt; &lt;moderator|participant|visitor|none&gt;: Set a user's role in the room."), 1824 _("role &lt;user&gt; &lt;moderator|participant|visitor|none&gt;: Set a user's role in the room."),
1825 NULL); 1825 NULL);
1826 gaim_cmd_register("invite", "ws", GAIM_CMD_P_PRPL, 1826 purple_cmd_register("invite", "ws", PURPLE_CMD_P_PRPL,
1827 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1827 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1828 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1828 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1829 jabber_cmd_chat_invite, 1829 jabber_cmd_chat_invite,
1830 _("invite &lt;user&gt; [message]: Invite a user to the room."), 1830 _("invite &lt;user&gt; [message]: Invite a user to the room."),
1831 NULL); 1831 NULL);
1832 gaim_cmd_register("join", "ws", GAIM_CMD_P_PRPL, 1832 purple_cmd_register("join", "ws", PURPLE_CMD_P_PRPL,
1833 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1833 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1834 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1834 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1835 jabber_cmd_chat_join, 1835 jabber_cmd_chat_join,
1836 _("join: &lt;room&gt; [server]: Join a chat on this server."), 1836 _("join: &lt;room&gt; [server]: Join a chat on this server."),
1837 NULL); 1837 NULL);
1838 gaim_cmd_register("kick", "ws", GAIM_CMD_P_PRPL, 1838 purple_cmd_register("kick", "ws", PURPLE_CMD_P_PRPL,
1839 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY | 1839 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY |
1840 GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber", 1840 PURPLE_CMD_FLAG_ALLOW_WRONG_ARGS, "prpl-jabber",
1841 jabber_cmd_chat_kick, 1841 jabber_cmd_chat_kick,
1842 _("kick &lt;user&gt; [room]: Kick a user from the room."), 1842 _("kick &lt;user&gt; [room]: Kick a user from the room."),
1843 NULL); 1843 NULL);
1844 gaim_cmd_register("msg", "ws", GAIM_CMD_P_PRPL, 1844 purple_cmd_register("msg", "ws", PURPLE_CMD_P_PRPL,
1845 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1845 PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PRPL_ONLY,
1846 "prpl-jabber", jabber_cmd_chat_msg, 1846 "prpl-jabber", jabber_cmd_chat_msg,
1847 _("msg &lt;user&gt; &lt;message&gt;: Send a private message to another user."), 1847 _("msg &lt;user&gt; &lt;message&gt;: Send a private message to another user."),
1848 NULL); 1848 NULL);
1849 } 1849 }
1850 1850
1851 static GaimPluginProtocolInfo prpl_info = 1851 static PurplePluginProtocolInfo prpl_info =
1852 { 1852 {
1853 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK, 1853 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_UNIQUE_CHATNAME | OPT_PROTO_MAIL_CHECK,
1854 NULL, /* user_splits */ 1854 NULL, /* user_splits */
1855 NULL, /* protocol_options */ 1855 NULL, /* protocol_options */
1856 {"png,gif,jpeg", 32, 32, 96, 96, 8191, GAIM_ICON_SCALE_SEND | GAIM_ICON_SCALE_DISPLAY}, /* icon_spec */ 1856 {"png,gif,jpeg", 32, 32, 96, 96, 8191, PURPLE_ICON_SCALE_SEND | PURPLE_ICON_SCALE_DISPLAY}, /* icon_spec */
1857 jabber_list_icon, /* list_icon */ 1857 jabber_list_icon, /* list_icon */
1858 jabber_list_emblem, /* list_emblems */ 1858 jabber_list_emblem, /* list_emblems */
1859 jabber_status_text, /* status_text */ 1859 jabber_status_text, /* status_text */
1860 jabber_tooltip_text, /* tooltip_text */ 1860 jabber_tooltip_text, /* tooltip_text */
1861 jabber_status_types, /* status_types */ 1861 jabber_status_types, /* status_types */
1912 NULL, /* whiteboard_prpl_ops */ 1912 NULL, /* whiteboard_prpl_ops */
1913 jabber_prpl_send_raw, /* send_raw */ 1913 jabber_prpl_send_raw, /* send_raw */
1914 jabber_roomlist_room_serialize, /* roomlist_room_serialize */ 1914 jabber_roomlist_room_serialize, /* roomlist_room_serialize */
1915 }; 1915 };
1916 1916
1917 static gboolean load_plugin(GaimPlugin *plugin) 1917 static gboolean load_plugin(PurplePlugin *plugin)
1918 { 1918 {
1919 gaim_signal_register(plugin, "jabber-receiving-xmlnode", 1919 purple_signal_register(plugin, "jabber-receiving-xmlnode",
1920 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, 1920 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
1921 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION), 1921 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
1922 gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE)); 1922 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
1923 1923
1924 gaim_signal_register(plugin, "jabber-sending-xmlnode", 1924 purple_signal_register(plugin, "jabber-sending-xmlnode",
1925 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, 1925 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
1926 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION), 1926 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
1927 gaim_value_new_outgoing(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_XMLNODE)); 1927 purple_value_new_outgoing(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_XMLNODE));
1928 1928
1929 gaim_signal_register(plugin, "jabber-sending-text", 1929 purple_signal_register(plugin, "jabber-sending-text",
1930 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, 1930 purple_marshal_VOID__POINTER_POINTER, NULL, 2,
1931 gaim_value_new(GAIM_TYPE_SUBTYPE, GAIM_SUBTYPE_CONNECTION), 1931 purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONNECTION),
1932 gaim_value_new_outgoing(GAIM_TYPE_STRING)); 1932 purple_value_new_outgoing(PURPLE_TYPE_STRING));
1933 1933
1934 1934
1935 return TRUE; 1935 return TRUE;
1936 } 1936 }
1937 1937
1938 static gboolean unload_plugin(GaimPlugin *plugin) 1938 static gboolean unload_plugin(PurplePlugin *plugin)
1939 { 1939 {
1940 gaim_signal_unregister(plugin, "jabber-receiving-xmlnode"); 1940 purple_signal_unregister(plugin, "jabber-receiving-xmlnode");
1941 1941
1942 gaim_signal_unregister(plugin, "jabber-sending-xmlnode"); 1942 purple_signal_unregister(plugin, "jabber-sending-xmlnode");
1943 1943
1944 gaim_signal_unregister(plugin, "jabber-sending-text"); 1944 purple_signal_unregister(plugin, "jabber-sending-text");
1945 1945
1946 return TRUE; 1946 return TRUE;
1947 } 1947 }
1948 1948
1949 static GaimPluginInfo info = 1949 static PurplePluginInfo info =
1950 { 1950 {
1951 GAIM_PLUGIN_MAGIC, 1951 PURPLE_PLUGIN_MAGIC,
1952 GAIM_MAJOR_VERSION, 1952 PURPLE_MAJOR_VERSION,
1953 GAIM_MINOR_VERSION, 1953 PURPLE_MINOR_VERSION,
1954 GAIM_PLUGIN_PROTOCOL, /**< type */ 1954 PURPLE_PLUGIN_PROTOCOL, /**< type */
1955 NULL, /**< ui_requirement */ 1955 NULL, /**< ui_requirement */
1956 0, /**< flags */ 1956 0, /**< flags */
1957 NULL, /**< dependencies */ 1957 NULL, /**< dependencies */
1958 GAIM_PRIORITY_DEFAULT, /**< priority */ 1958 PURPLE_PRIORITY_DEFAULT, /**< priority */
1959 1959
1960 "prpl-jabber", /**< id */ 1960 "prpl-jabber", /**< id */
1961 "Jabber", /**< name */ 1961 "Jabber", /**< name */
1962 VERSION, /**< version */ 1962 VERSION, /**< version */
1963 /** summary */ 1963 /** summary */
1964 N_("Jabber Protocol Plugin"), 1964 N_("Jabber Protocol Plugin"),
1965 /** description */ 1965 /** description */
1966 N_("Jabber Protocol Plugin"), 1966 N_("Jabber Protocol Plugin"),
1967 NULL, /**< author */ 1967 NULL, /**< author */
1968 GAIM_WEBSITE, /**< homepage */ 1968 PURPLE_WEBSITE, /**< homepage */
1969 1969
1970 load_plugin, /**< load */ 1970 load_plugin, /**< load */
1971 unload_plugin, /**< unload */ 1971 unload_plugin, /**< unload */
1972 NULL, /**< destroy */ 1972 NULL, /**< destroy */
1973 1973
1976 NULL, /**< prefs_info */ 1976 NULL, /**< prefs_info */
1977 jabber_actions 1977 jabber_actions
1978 }; 1978 };
1979 1979
1980 static void 1980 static void
1981 init_plugin(GaimPlugin *plugin) 1981 init_plugin(PurplePlugin *plugin)
1982 { 1982 {
1983 GaimAccountUserSplit *split; 1983 PurpleAccountUserSplit *split;
1984 GaimAccountOption *option; 1984 PurpleAccountOption *option;
1985 1985
1986 split = gaim_account_user_split_new(_("Server"), "jabber.org", '@'); 1986 split = purple_account_user_split_new(_("Server"), "jabber.org", '@');
1987 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); 1987 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
1988 1988
1989 split = gaim_account_user_split_new(_("Resource"), "Home", '/'); 1989 split = purple_account_user_split_new(_("Resource"), "Home", '/');
1990 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split); 1990 prpl_info.user_splits = g_list_append(prpl_info.user_splits, split);
1991 1991
1992 option = gaim_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE); 1992 option = purple_account_option_bool_new(_("Force old (port 5223) SSL"), "old_ssl", FALSE);
1993 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 1993 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
1994 option); 1994 option);
1995 1995
1996 option = gaim_account_option_bool_new( 1996 option = purple_account_option_bool_new(
1997 _("Allow plaintext auth over unencrypted streams"), 1997 _("Allow plaintext auth over unencrypted streams"),
1998 "auth_plain_in_clear", FALSE); 1998 "auth_plain_in_clear", FALSE);
1999 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 1999 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2000 option); 2000 option);
2001 2001
2002 option = gaim_account_option_int_new(_("Connect port"), "port", 5222); 2002 option = purple_account_option_int_new(_("Connect port"), "port", 5222);
2003 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2003 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2004 option); 2004 option);
2005 2005
2006 option = gaim_account_option_string_new(_("Connect server"), 2006 option = purple_account_option_string_new(_("Connect server"),
2007 "connect_server", NULL); 2007 "connect_server", NULL);
2008 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, 2008 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
2009 option); 2009 option);
2010 2010
2011 my_protocol = plugin; 2011 my_protocol = plugin;
2012 2012
2013 gaim_prefs_remove("/plugins/prpl/jabber"); 2013 purple_prefs_remove("/plugins/prpl/jabber");
2014 2014
2015 /* XXX - If any other plugin wants SASL this won't be good ... */ 2015 /* XXX - If any other plugin wants SASL this won't be good ... */
2016 #ifdef HAVE_CYRUS_SASL 2016 #ifdef HAVE_CYRUS_SASL
2017 sasl_client_init(NULL); 2017 sasl_client_init(NULL);
2018 #endif 2018 #endif
2019 jabber_register_commands(); 2019 jabber_register_commands();
2020 2020
2021 jabber_iq_init(); 2021 jabber_iq_init();
2022 } 2022 }
2023 2023
2024 GAIM_INIT_PLUGIN(jabber, init_plugin, info); 2024 PURPLE_INIT_PLUGIN(jabber, init_plugin, info);