comparison mcabber/src/jabglue.c @ 91:60eac956ce18

[/trunk] Changeset 105 by mikael * Jabber agents support * TODO update
author mikael
date Mon, 18 Apr 2005 18:12:50 +0000
parents 0bd578421ce9
children edb5591e2e64
comparison
equal deleted inserted replaced
90:ac48ace7ee19 91:60eac956ce18
396 previous_state = state; 396 previous_state = state;
397 } 397 }
398 398
399 void packethandler(jconn conn, jpacket packet) 399 void packethandler(jconn conn, jpacket packet)
400 { 400 {
401 char *p; 401 char *p, *r;
402 xmlnode x, y; 402 xmlnode x, y;
403 // string from, type, body, enc, ns, id, u, h, s; 403 // string from, type, body, enc, ns, id, u, h, s;
404 char *from=NULL, *type=NULL, *body=NULL, *enc=NULL; 404 char *from=NULL, *type=NULL, *body=NULL, *enc=NULL;
405 char *ns=NULL; 405 char *ns=NULL;
406 char *id=NULL; 406 char *id=NULL;
407 enum imstatus ust; 407 enum imstatus ust;
408 // int npos; 408 // int npos;
409 // bool isagent;
410 409
411 jpacket_reset(packet); 410 jpacket_reset(packet);
412 411
413 p = xmlnode_get_attrib(packet->x, "from"); if (p) from = p; 412 p = xmlnode_get_attrib(packet->x, "from"); if (p) from = p;
414 p = xmlnode_get_attrib(packet->x, "type"); if (p) type = p; 413 p = xmlnode_get_attrib(packet->x, "type"); if (p) type = p;
625 } 624 }
626 625
627 if (type && !strcmp(type, "unavailable")) { 626 if (type && !strcmp(type, "unavailable")) {
628 ust = offline; 627 ust = offline;
629 } 628 }
630 // scr_LogPrint("New status: ust=%d (%s)", ust, from); 629
631 630 r = jidtodisp(from);
632 roster_setstatus(jidtodisp(from), ust); // XXX memory leak 631 if (ust != roster_getstatus(r))
632 scr_LogPrint("Buddy status has changed: [%c>%c] <%s>",
633 imstatus2char[roster_getstatus(r)], imstatus2char[ust], r);
634 roster_setstatus(r, ust);
635 free(r);
633 buddylist_build(); 636 buddylist_build();
634 scr_DrawRoster(); 637 scr_DrawRoster();
635 /* 638 /*
636 if (x = xmlnode_get_tag(packet->x, "status")) 639 if (x = xmlnode_get_tag(packet->x, "status"))
637 if (p = xmlnode_get_data(x)) 640 if (p = xmlnode_get_data(x))
642 case JPACKET_S10N: 645 case JPACKET_S10N:
643 scr_LogPrint("Received subscription packet"); 646 scr_LogPrint("Received subscription packet");
644 if (type) scr_LogPrint("Type=%s", type); 647 if (type) scr_LogPrint("Type=%s", type);
645 648
646 if (!strcmp(type, "subscribe")) { 649 if (!strcmp(type, "subscribe")) {
647 // if (!isagent) { 650 int isagent;
651 r = jidtodisp(from);
652 isagent = (roster_gettype(r) & ROSTER_TYPE_AGENT) != 0;
653 free(r);
654 scr_LogPrint("isagent=%d", isagent); // XXX DBG
655 if (!isagent) {
648 scr_LogPrint("<%s> wants to subscribe " 656 scr_LogPrint("<%s> wants to subscribe "
649 "to your network presence updates", from); 657 "to your network presence updates", from);
650 /*} else { 658 } else {
651 auto_ptr<char> cfrom(strdup(from.c_str())); 659 x = jutil_presnew(JPACKET__SUBSCRIBED, from, 0);
652 x = jutil_presnew(JPACKET__SUBSCRIBED, cfrom.get(), 0);
653 jab_send(jc, x); 660 jab_send(jc, x);
654 xmlnode_free(x); 661 xmlnode_free(x);
655 }*/ 662 }
656 } else if (!strcmp(type, "unsubscribe")) { 663 } else if (!strcmp(type, "unsubscribe")) {
657 x = jutil_presnew(JPACKET__UNSUBSCRIBED, from, 0); 664 x = jutil_presnew(JPACKET__UNSUBSCRIBED, from, 0);
658 jab_send(jc, x); 665 jab_send(jc, x);
659 xmlnode_free(x); 666 xmlnode_free(x);
660 scr_LogPrint("<%s> has unsubscribed to your presence updates", from); 667 scr_LogPrint("<%s> has unsubscribed to your presence updates", from);