comparison src/protocols/zephyr/zephyr.c @ 9437:d9f8658b305d

[gaim-migrate @ 10258] " As wing had mentioned on #gaim, zephyr.c had declarations after statements, causing problems with pre-C99 compilers. I've moved the declarations around to fix this, and also properly un-indented code to improve readability. Oh, and my previous slash commands patch had mixed up the descriptions of /inst and /instance . This fixes it." --Arun A Tharuvai committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Thu, 01 Jul 2004 22:21:31 +0000
parents c5cf752acc4a
children 670daf18649b
comparison
equal deleted inserted replaced
9436:1ddcc9caa538 9437:d9f8658b305d
647 stripped_sender = zephyr_strip_foreign_realm(notice.z_sender); 647 stripped_sender = zephyr_strip_foreign_realm(notice.z_sender);
648 serv_got_im(zgc, stripped_sender, buf3, flags, time(NULL)); 648 serv_got_im(zgc, stripped_sender, buf3, flags, time(NULL));
649 g_free(stripped_sender); 649 g_free(stripped_sender);
650 } else { 650 } else {
651 zephyr_triple *zt1, *zt2; 651 zephyr_triple *zt1, *zt2;
652 652 GList *gltmp;
653 int found = 0;
654 gchar *send_inst_utf8;
655
653 zt1 = new_triple(notice.z_class, notice.z_class_inst, notice.z_recipient); 656 zt1 = new_triple(notice.z_class, notice.z_class_inst, notice.z_recipient);
654 zt2 = find_sub_by_triple(zt1); 657 zt2 = find_sub_by_triple(zt1);
655 if (!zt2) { 658 if (!zt2) {
656 /* This is a server supplied subscription */ 659 /* This is a server supplied subscription */
657 subscrips = g_slist_append(subscrips, zt1); 660 subscrips = g_slist_append(subscrips, zt1);
658 zt2 = find_sub_by_triple(zt1); 661 zt2 = find_sub_by_triple(zt1);
659 } 662 }
660 /*else { */
661 GList *gltmp;
662 int found = 0;
663 gchar *send_inst_utf8;
664 /* GError *err; */
665 663
666 if (!zt2->open) { 664 if (!zt2->open) {
667 zt2->open = TRUE; 665 zt2->open = TRUE;
668 serv_got_joined_chat(zgc, zt2->id, zt2->name); 666 serv_got_joined_chat(zgc, zt2->id, zt2->name);
669 zephyr_chat_set_topic(zgc,zt2->id,notice.z_class_inst); 667 zephyr_chat_set_topic(zgc,zt2->id,notice.z_class_inst);
670 } 668 }
671 g_free(sendertmp); /* fix memory leak? */ 669 g_free(sendertmp); /* fix memory leak? */
672 /* If the person is in the default Realm, then strip the 670 /* If the person is in the default Realm, then strip the
673 Realm from the sender field */ 671 Realm from the sender field */
674 sendertmp = zephyr_strip_foreign_realm(notice.z_sender); 672 sendertmp = zephyr_strip_foreign_realm(notice.z_sender);
675 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst); 673 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst);
676 send_inst_utf8 = zephyr_recv_convert(send_inst, strlen(send_inst)); 674 send_inst_utf8 = zephyr_recv_convert(send_inst, strlen(send_inst));
677 if (!send_inst_utf8) { 675 if (!send_inst_utf8) {
678 fprintf(stderr, "zephyr: send_inst %s became null\n",send_inst); 676 fprintf(stderr, "zephyr: send_inst %s became null\n",send_inst);
679 gaim_debug(GAIM_DEBUG_ERROR, "zephyr","send_inst %s became null\n", send_inst); 677 gaim_debug(GAIM_DEBUG_ERROR, "zephyr","send_inst %s became null\n", send_inst);
680 send_inst_utf8 = "malformed instance"; 678 send_inst_utf8 = "malformed instance";
681 } 679 }
682 680
683 serv_got_chat_in(zgc, zt2->id, send_inst_utf8, FALSE, buf3, time(NULL)); 681 serv_got_chat_in(zgc, zt2->id, send_inst_utf8, FALSE, buf3, time(NULL));
684 g_free(send_inst); 682 g_free(send_inst);
685 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account); 683 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account);
686 gcc = gaim_conversation_get_chat_data(gconv1); 684 gcc = gaim_conversation_get_chat_data(gconv1);
687 685
688 for (gltmp = gaim_conv_chat_get_users(gcc); gltmp; gltmp = gltmp->next) { 686 for (gltmp = gaim_conv_chat_get_users(gcc); gltmp; gltmp = gltmp->next) {
689 if (!g_ascii_strcasecmp(gltmp->data, sendertmp)) 687 if (!g_ascii_strcasecmp(gltmp->data, sendertmp))
690 found = 1; 688 found = 1;
691 } 689 }
692 if (!found) { 690 if (!found) {
693 /* force interpretation in network byte order */ 691 /* force interpretation in network byte order */
694 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr); 692 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr);
695 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0], 693 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0],
696 (unsigned char)addrs[1], (unsigned char)addrs[2], 694 (unsigned char)addrs[1], (unsigned char)addrs[2],
697 (unsigned char) addrs[3]); 695 (unsigned char) addrs[3]);
698 696
699 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr); 697 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr);
700 g_free(ipaddr); /* fix memory leak? */ 698 g_free(ipaddr); /* fix memory leak? */
701 699
702 } 700 }
703 g_free(sendertmp); 701 g_free(sendertmp);
704 g_free(send_inst_utf8); 702 g_free(send_inst_utf8);
705 703
706 /* } */
707 free_triple(zt1); 704 free_triple(zt1);
708 } 705 }
709 g_free(buf3); 706 g_free(buf3);
710 } 707 }
711 } 708 }
1474 zephyr_gaim_cmd_zlocate, _("zl &lt;nick&gt;: Locate user")); 1471 zephyr_gaim_cmd_zlocate, _("zl &lt;nick&gt;: Locate user"));
1475 1472
1476 gaim_cmd_register("instance","s", GAIM_CMD_P_PRPL, 1473 gaim_cmd_register("instance","s", GAIM_CMD_P_PRPL,
1477 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1474 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
1478 "prpl-zephyr", 1475 "prpl-zephyr",
1479 zephyr_gaim_cmd_instance, _("inst &lt;instance&gt;: Set the instance to be used on this class")); 1476 zephyr_gaim_cmd_instance, _("instance &lt;instance&gt;: Set the instance to be used on this class"));
1480 1477
1481 gaim_cmd_register("inst","s", GAIM_CMD_P_PRPL, 1478 gaim_cmd_register("inst","s", GAIM_CMD_P_PRPL,
1482 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1479 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
1483 "prpl-zephyr", 1480 "prpl-zephyr",
1484 zephyr_gaim_cmd_instance, _("instance &lt;instance&gt;: Set the instance to be used on this class")); 1481 zephyr_gaim_cmd_instance, _("inst &lt;instance&gt;: Set the instance to be used on this class"));
1485 1482
1486 gaim_cmd_register("sub", "www", GAIM_CMD_P_PRPL, 1483 gaim_cmd_register("sub", "www", GAIM_CMD_P_PRPL,
1487 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY, 1484 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
1488 "prpl-zephyr", 1485 "prpl-zephyr",
1489 zephyr_gaim_cmd_joinchat_cir, 1486 zephyr_gaim_cmd_joinchat_cir,