comparison plugins/jabber/jabber.c @ 1344:8b5ed2f0496c

[gaim-migrate @ 1354] jabber stuff. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 21 Dec 2000 10:31:42 +0000
parents f48cb8ddca59
children d6e6fcaa1f39
comparison
equal deleted inserted replaced
1343:a0d89bdc733e 1344:8b5ed2f0496c
47 #include "multi.h" 47 #include "multi.h"
48 #include "prpl.h" 48 #include "prpl.h"
49 #include "gaim.h" 49 #include "gaim.h"
50 #include <jabber/jabber.h> 50 #include <jabber/jabber.h>
51 51
52 #include "pixmaps/available.xpm"
53
52 /* The priv member of gjconn's is a gaim_connection for now. */ 54 /* The priv member of gjconn's is a gaim_connection for now. */
53 #define GJ_GC(x) ((struct gaim_connection *)(x)->priv) 55 #define GJ_GC(x) ((struct gaim_connection *)(x)->priv)
54 56
55 #define IQ_NONE -1 57 #define IQ_NONE -1
56 #define IQ_AUTH 0 58 #define IQ_AUTH 0
437 from = xmlnode_get_attrib(p->x, "from"); 439 from = xmlnode_get_attrib(p->x, "from");
438 type = xmlnode_get_attrib(p->x, "type"); 440 type = xmlnode_get_attrib(p->x, "type");
439 441
440 debug_printf("jabber: presence: %s, %s %s\n", to, from, type); 442 debug_printf("jabber: presence: %s, %s %s\n", to, from, type);
441 443
442 if (!(b = find_buddy(GJ_GC(j), from))) 444 if (!(b = find_buddy(GJ_GC(j), from))) {
443 add_buddy(GJ_GC(j), "Extra", from, from); 445 add_buddy(GJ_GC(j), "Buddies", from, from);
446 do_export(NULL, NULL);
447 }
444 448
445 if (type && (strcasecmp(type, "unavailable") == 0)) 449 if (type && (strcasecmp(type, "unavailable") == 0))
446 serv_got_update(GJ_GC(j), from, 0, 0, 0, 0, 0, 0); 450 serv_got_update(GJ_GC(j), from, 0, 0, 0, 0, 0, 0);
447 else 451 else
448 serv_got_update(GJ_GC(j), from, 1, 0, 0, 0, 0, 0); 452 serv_got_update(GJ_GC(j), from, 1, 0, 0, 0, 0, 0);
479 483
480 groupname = xmlnode_get_data(xmlnode_get_firstchild(g)); 484 groupname = xmlnode_get_data(xmlnode_get_firstchild(g));
481 if (!(b = find_buddy(GJ_GC(j), jid))) { 485 if (!(b = find_buddy(GJ_GC(j), jid))) {
482 debug_printf("adding buddy: %s\n", jid); 486 debug_printf("adding buddy: %s\n", jid);
483 b = add_buddy(GJ_GC(j), groupname, jid, name?name:jid); 487 b = add_buddy(GJ_GC(j), groupname, jid, name?name:jid);
488 do_export(0, 0);
484 } else { 489 } else {
485 debug_printf("updating buddy: %s/%s\n", jid, name); 490 debug_printf("updating buddy: %s/%s\n", jid, name);
486 g_snprintf(b->name, sizeof(b->name), "%s", jid); 491 g_snprintf(b->name, sizeof(b->name), "%s", jid);
487 g_snprintf(b->show, sizeof(b->show), "%s", name?name:jid); 492 g_snprintf(b->show, sizeof(b->show), "%s", name?name:jid);
488 } 493 }
491 g = xmlnode_get_nextsibling(g); 496 g = xmlnode_get_nextsibling(g);
492 } 497 }
493 } else { 498 } else {
494 struct buddy *b; 499 struct buddy *b;
495 if (!(b = find_buddy(GJ_GC(j), jid))) { 500 if (!(b = find_buddy(GJ_GC(j), jid))) {
496 b = add_buddy(GJ_GC(j), "Extra", jid, name?name:jid); 501 b = add_buddy(GJ_GC(j), "Buddies", jid, name?name:jid);
502 do_export(0, 0);
497 } 503 }
498 } 504 }
499 505
500 x = xmlnode_get_nextsibling(x); 506 x = xmlnode_get_nextsibling(x);
501 } 507 }
521 char *xmlns; 527 char *xmlns;
522 528
523 querynode = xmlnode_get_tag(p->x, "query"); 529 querynode = xmlnode_get_tag(p->x, "query");
524 xmlns = xmlnode_get_attrib(querynode, "xmlns"); 530 xmlns = xmlnode_get_attrib(querynode, "xmlns");
525 531
526 /* XXX this just doesn't look right */
527 if (!xmlns || NSCHECK(querynode, NS_AUTH)) { 532 if (!xmlns || NSCHECK(querynode, NS_AUTH)) {
528 debug_printf("auth success\n"); 533 debug_printf("auth success\n");
529 534
530 account_online(GJ_GC(j)); 535 account_online(GJ_GC(j));
531 serv_finish_login(GJ_GC(j)); 536 serv_finish_login(GJ_GC(j));
576 hide_login_progress(GJ_GC(j), "Unable to connect"); 581 hide_login_progress(GJ_GC(j), "Unable to connect");
577 signoff(GJ_GC(j)); 582 signoff(GJ_GC(j));
578 break; 583 break;
579 case JCONN_STATE_CONNECTED: 584 case JCONN_STATE_CONNECTED:
580 debug_printf("jabber: connected.\n"); 585 debug_printf("jabber: connected.\n");
581 set_login_progress(GJ_GC(j), 1, "Connected"); 586 set_login_progress(GJ_GC(j), 3, "Connected");
582 break; 587 break;
583 case JCONN_STATE_ON: 588 case JCONN_STATE_ON:
584 debug_printf("jabber: logging in...\n"); 589 debug_printf("jabber: logging in...\n");
585 set_login_progress(GJ_GC(j), 1, "Logging in..."); 590 set_login_progress(GJ_GC(j), 5, "Logging in...");
586 gjab_auth(j); 591 gjab_auth(j);
587 break; 592 break;
588 default: 593 default:
589 debug_printf("state change: %d\n", state); 594 debug_printf("state change: %d\n", state);
590 } 595 }
594 static void jabber_login(struct aim_user *user) { 599 static void jabber_login(struct aim_user *user) {
595 struct gaim_connection *gc = new_gaim_conn(user); 600 struct gaim_connection *gc = new_gaim_conn(user);
596 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1); 601 struct jabber_data *jd = gc->proto_data = g_new0(struct jabber_data, 1);
597 602
598 set_login_progress(gc, 1, "Connecting"); 603 set_login_progress(gc, 1, "Connecting");
599 while (gtk_events_pending())
600 gtk_main_iteration();
601 604
602 if (!(jd->jc = gjab_new(user->username, user->password, gc))) { 605 if (!(jd->jc = gjab_new(user->username, user->password, gc))) {
603 debug_printf("jabber: unable to connect (jab_new failed)\n"); 606 debug_printf("jabber: unable to connect (jab_new failed)\n");
604 hide_login_progress(gc, "Unable to connect"); 607 hide_login_progress(gc, "Unable to connect");
605 signoff(gc); 608 signoff(gc);
606 g_free(jd);
607 return; 609 return;
608 } 610 }
609 611
610 gjab_state_handler(jd->jc, jabber_handlestate); 612 gjab_state_handler(jd->jc, jabber_handlestate);
611 gjab_packet_handler(jd->jc, jabber_handlepacket); 613 gjab_packet_handler(jd->jc, jabber_handlepacket);