Mercurial > pidgin
comparison plugins/jabber/jabber.c @ 1362:3cea00ca7a34
[gaim-migrate @ 1372]
yay.
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Fri, 22 Dec 2000 10:48:19 +0000 |
parents | f0c2d6b88b14 |
children | b454b1d084ce |
comparison
equal
deleted
inserted
replaced
1361:5d4464379703 | 1362:3cea00ca7a34 |
---|---|
108 static void gjab_recv(gjconn j); | 108 static void gjab_recv(gjconn j); |
109 static char *gjab_auth(gjconn j); | 109 static char *gjab_auth(gjconn j); |
110 | 110 |
111 struct jabber_data { | 111 struct jabber_data { |
112 gjconn jc; | 112 gjconn jc; |
113 gboolean did_import; | |
113 }; | 114 }; |
114 | 115 |
115 static char *jabber_name() | 116 static char *jabber_name() |
116 { | 117 { |
117 return "Jabber"; | 118 return "Jabber"; |
420 } | 421 } |
421 | 422 |
422 static void jabber_handlemessage(gjconn j, jpacket p) | 423 static void jabber_handlemessage(gjconn j, jpacket p) |
423 { | 424 { |
424 xmlnode y; | 425 xmlnode y; |
426 gboolean same = TRUE; | |
425 | 427 |
426 char *from = NULL, *msg = NULL; | 428 char *from = NULL, *msg = NULL; |
427 | 429 |
428 from = jid_full(p->from); | 430 from = jid_full(p->from); |
429 if ((y = xmlnode_get_tag(p->x, "body"))) { | 431 if ((y = xmlnode_get_tag(p->x, "body"))) { |
432 | 434 |
433 if (!from || !msg) { | 435 if (!from || !msg) { |
434 return; | 436 return; |
435 } | 437 } |
436 | 438 |
437 from = g_strdup_printf("%s@%s", p->from->user, p->from->server); | 439 if (jid_cmp(p->from, jid_new(j->p, GJ_GC(j)->username))) { |
440 from = g_strdup_printf("%s@%s", p->from->user, p->from->server); | |
441 same = FALSE; | |
442 } | |
438 | 443 |
439 serv_got_im(GJ_GC(j), from, msg, 0); | 444 serv_got_im(GJ_GC(j), from, msg, 0); |
440 | 445 |
441 g_free(from); | 446 if (!same) |
447 g_free(from); | |
442 | 448 |
443 return; | 449 return; |
444 } | 450 } |
445 | 451 |
446 static void jabber_handlepresence(gjconn j, jpacket p) | 452 static void jabber_handlepresence(gjconn j, jpacket p) |
521 | 527 |
522 g = xmlnode_new_tag("presence"); | 528 g = xmlnode_new_tag("presence"); |
523 xmlnode_put_attrib(g, "to", Jid); | 529 xmlnode_put_attrib(g, "to", Jid); |
524 if (!strcmp(ask, "subscribe")) | 530 if (!strcmp(ask, "subscribe")) |
525 xmlnode_put_attrib(g, "type", "subscribed"); | 531 xmlnode_put_attrib(g, "type", "subscribed"); |
532 else if (!strcmp(ask, "unsubscribe")) | |
533 xmlnode_put_attrib(g, "type", "unsubscribed"); | |
526 else | 534 else |
527 xmlnode_put_attrib(g, "type", "unsubscribed"); | 535 return; |
528 | 536 |
529 gjab_send(j, g); | 537 gjab_send(j, g); |
530 } | 538 } |
531 | 539 |
532 static void jabber_handleroster(gjconn j, xmlnode querynode) | 540 static void jabber_handleroster(gjconn j, xmlnode querynode) |
542 Jid = xmlnode_get_attrib(x, "jid"); | 550 Jid = xmlnode_get_attrib(x, "jid"); |
543 name = xmlnode_get_attrib(x, "name"); | 551 name = xmlnode_get_attrib(x, "name"); |
544 sub = xmlnode_get_attrib(x, "subscription"); | 552 sub = xmlnode_get_attrib(x, "subscription"); |
545 ask = xmlnode_get_attrib(x, "ask"); | 553 ask = xmlnode_get_attrib(x, "ask"); |
546 who = jid_new(j->p, Jid); | 554 who = jid_new(j->p, Jid); |
547 | |
548 if (ask) { | |
549 g = xmlnode_new_tag("presence"); | |
550 xmlnode_put_attrib(g, "to", Jid); | |
551 if (!strcmp(ask, "subscribe")) | |
552 xmlnode_put_attrib(g, "type", "subscribed"); | |
553 else | |
554 xmlnode_put_attrib(g, "type", "unsubscribed"); | |
555 } | |
556 | 555 |
557 if ((g = xmlnode_get_firstchild(x))) { | 556 if ((g = xmlnode_get_firstchild(x))) { |
558 while (g) { | 557 while (g) { |
559 if (strncasecmp(xmlnode_get_name(g), "group", 5) == 0) { | 558 if (strncasecmp(xmlnode_get_name(g), "group", 5) == 0) { |
560 struct buddy *b; | 559 struct buddy *b; |
623 debug_printf("jpacket_subtype: %d\n", jpacket_subtype(p)); | 622 debug_printf("jpacket_subtype: %d\n", jpacket_subtype(p)); |
624 | 623 |
625 if (jpacket_subtype(p) == JPACKET__SET) { | 624 if (jpacket_subtype(p) == JPACKET__SET) { |
626 } else if (jpacket_subtype(p) == JPACKET__RESULT) { | 625 } else if (jpacket_subtype(p) == JPACKET__RESULT) { |
627 xmlnode querynode; | 626 xmlnode querynode; |
628 char *xmlns; | 627 char *xmlns, *from; |
629 | 628 |
629 from = xmlnode_get_attrib(p->x, "from"); | |
630 querynode = xmlnode_get_tag(p->x, "query"); | 630 querynode = xmlnode_get_tag(p->x, "query"); |
631 xmlns = xmlnode_get_attrib(querynode, "xmlns"); | 631 xmlns = xmlnode_get_attrib(querynode, "xmlns"); |
632 | 632 |
633 if (!xmlns || NSCHECK(querynode, NS_AUTH)) { | 633 if ((!xmlns && !from) || NSCHECK(querynode, NS_AUTH)) { |
634 debug_printf("auth success\n"); | 634 debug_printf("auth success\n"); |
635 | 635 |
636 account_online(GJ_GC(j)); | 636 account_online(GJ_GC(j)); |
637 serv_finish_login(GJ_GC(j)); | 637 serv_finish_login(GJ_GC(j)); |
638 | 638 |
639 /* | |
640 if (bud_list_cache_exists(GJ_GC(j))) | 639 if (bud_list_cache_exists(GJ_GC(j))) |
641 do_import(NULL, GJ_GC(j)); | 640 do_import(NULL, GJ_GC(j)); |
642 */ | 641 |
642 ((struct jabber_data *)GJ_GC(j)->proto_data)->did_import = TRUE; | |
643 | 643 |
644 gjab_reqroster(j); | 644 gjab_reqroster(j); |
645 | 645 |
646 } else if (NSCHECK(querynode, NS_ROSTER)) { | 646 } else if (NSCHECK(querynode, NS_ROSTER)) { |
647 jabber_handleroster(j, querynode); | 647 jabber_handleroster(j, querynode); |
760 static void jabber_add_buddy(struct gaim_connection *gc, char *name) | 760 static void jabber_add_buddy(struct gaim_connection *gc, char *name) |
761 { | 761 { |
762 xmlnode x, y; | 762 xmlnode x, y; |
763 char *realwho; | 763 char *realwho; |
764 gjconn j = ((struct jabber_data *)gc->proto_data)->jc; | 764 gjconn j = ((struct jabber_data *)gc->proto_data)->jc; |
765 | |
766 if (!((struct jabber_data *)gc->proto_data)->did_import) | |
767 return; | |
765 | 768 |
766 if (!name) | 769 if (!name) |
767 return; | 770 return; |
768 | 771 |
769 if (!strcmp(gc->username, name)) | 772 if (!strcmp(gc->username, name)) |