comparison plugins/jabber/jabber.c @ 1316:d5069ad0b6b1

[gaim-migrate @ 1326] getting it to look pretty. this is probably bad, but eh. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 19 Dec 2000 14:48:42 +0000
parents 7f7e3bfb1af7
children f48cb8ddca59
comparison
equal deleted inserted replaced
1315:7f7e3bfb1af7 1316:d5069ad0b6b1
411 } 411 }
412 412
413 static void jabber_handlemessage(gjconn j, jpacket p) 413 static void jabber_handlemessage(gjconn j, jpacket p)
414 { 414 {
415 xmlnode y; 415 xmlnode y;
416 char *x, *m;
416 417
417 char *from = NULL, *msg = NULL; 418 char *from = NULL, *msg = NULL;
418 419
419 from = jid_full(p->from); 420 from = jid_full(p->from);
420 if ((y = xmlnode_get_tag(p->x, "body"))) { 421 if ((y = xmlnode_get_tag(p->x, "body"))) {
423 424
424 if (!from || !msg) { 425 if (!from || !msg) {
425 return; 426 return;
426 } 427 }
427 428
429 x = strchr(from, '@');
430 if (x) {
431 *x++ = '\0';
432 m = strchr(x, '/');
433 *m = '\0';
434 if (strcmp(j->user->server, x)) {
435 x--;
436 *x = '@';
437 *m = '/';
438 }
439 }
428 debug_printf("jabber: msg from %s: %s\n", from, msg); 440 debug_printf("jabber: msg from %s: %s\n", from, msg);
429 441
430 serv_got_im(GJ_GC(j), from, msg, 0); 442 serv_got_im(GJ_GC(j), from, msg, 0);
431 443
432 return; 444 return;
639 g_free(jd); 651 g_free(jd);
640 } 652 }
641 653
642 static void jabber_send_im(struct gaim_connection *gc, char *who, char *message, int away) { 654 static void jabber_send_im(struct gaim_connection *gc, char *who, char *message, int away) {
643 xmlnode x, y; 655 xmlnode x, y;
656 char *realwho;
657 gjconn j = ((struct jabber_data *)gc->proto_data)->jc;
644 658
645 if (!who || !message) 659 if (!who || !message)
646 return; 660 return;
647 661
648 x = xmlnode_new_tag("message"); 662 x = xmlnode_new_tag("message");
649 xmlnode_put_attrib(x, "to", who); 663 if (!strchr(who, '@'))
664 realwho = g_strdup_printf("%s@%s", who, j->user->server);
665 else
666 realwho = g_strdup(who);
667 xmlnode_put_attrib(x, "to", realwho);
668 g_free(realwho);
650 669
651 xmlnode_put_attrib(x, "type", "chat"); 670 xmlnode_put_attrib(x, "type", "chat");
652 671
653 if (message && strlen(message)) { 672 if (message && strlen(message)) {
654 y = xmlnode_insert_tag(x, "body"); 673 y = xmlnode_insert_tag(x, "body");