comparison src/protocols/zephyr/zephyr.c @ 9740:2bb5e2cd64bd

[gaim-migrate @ 10605] " A few days back, someone on #gaim was wondering how to block IM's from IRC, which isn't supported by gaim, as this isn't supported at a protocol level. I decided to implement gaim's privacy options (permit lists, deny lists, block all users, and permit people on buddy list) at a local level for IRC and Zephyr. Jabber, SILC, and Trepia don't seem to support deny or permit lists in Gaim, but I don't use the latter two protocols and wasn't sure about how to implemnt in in Jabber. When implementing it, I noticed that changes in privacy settings didn't automatically cause blist.xml to get scheduled for writing (even on exit). To fix this, I needed to make schedule_blist_save in blist.c non-static and call it from serv_set_permit_deny() in server.c, and gaim_privacy_{permit,deny}_{add,remove} in privacy.c ." --Arun A Tharuvai committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Wed, 11 Aug 2004 23:52:48 +0000
parents db62420a53a2
children b10d4c6ac7eb
comparison
equal deleted inserted replaced
9739:35f22ba01bd7 9740:2bb5e2cd64bd
30 #include "notify.h" 30 #include "notify.h"
31 #include "prpl.h" 31 #include "prpl.h"
32 #include "server.h" 32 #include "server.h"
33 #include "util.h" 33 #include "util.h"
34 #include "cmds.h" 34 #include "cmds.h"
35 #include "privacy.h"
35 36
36 #include "zephyr/zephyr.h" 37 #include "zephyr/zephyr.h"
37 #include "internal.h" 38 #include "internal.h"
38 39
39 #include <strings.h> 40 #include <strings.h>
689 flags |= GAIM_CONV_IM_AUTO_RESP; 690 flags |= GAIM_CONV_IM_AUTO_RESP;
690 stripped_sender = zephyr_strip_foreign_realm(notice.z_sender); 691 stripped_sender = zephyr_strip_foreign_realm(notice.z_sender);
691 692
692 if (!g_ascii_strcasecmp(notice.z_opcode,"PING")) 693 if (!g_ascii_strcasecmp(notice.z_opcode,"PING"))
693 serv_got_typing(gc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, GAIM_TYPING); 694 serv_got_typing(gc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, GAIM_TYPING);
694 else 695 else {
695 serv_got_im(gc, stripped_sender, buf3, flags, time(NULL)); 696 GSList* l;
696 697 gboolean in_deny;
698
699 switch (gc->account->perm_deny) {
700 case GAIM_PRIVACY_ALLOW_ALL:
701 in_deny = 0; break;
702 case GAIM_PRIVACY_DENY_ALL:
703 in_deny = 1; break;
704 case GAIM_PRIVACY_ALLOW_USERS: /* See if stripped_sender is in gc->account->permit and allow appropriately */
705 in_deny = 1;
706 for(l=gc->account->permit;l!=NULL;l=l->next) {
707 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) {
708 fprintf(stderr,"stripped sender %s l->data %sf\n",stripped_sender, (char *)l->data);
709 in_deny=0;
710 break;
711 }
712 }
713 break;
714 case GAIM_PRIVACY_DENY_USERS: /* See if stripped_sender is in gc->account->deny and deny if so */
715 in_deny = 0;
716 for(l=gc->account->deny;l!=NULL;l=l->next) {
717 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) {
718 fprintf(stderr,"stripped sender %s l->data %sf\n",stripped_sender, (char *)l->data);
719 in_deny=1;
720 break;
721 }
722 }
723 break;
724 case GAIM_PRIVACY_ALLOW_BUDDYLIST:
725 in_deny = 1;
726 if (gaim_find_buddy(gc->account,stripped_sender)!=NULL) {
727 in_deny = 0;
728 }
729 break;
730 default:
731 in_deny=0; break;
732 }
733
734 if (!in_deny) {
735 serv_got_im(gc, stripped_sender, buf3, flags, time(NULL));
736 }
737 }
697 g_free(stripped_sender); 738 g_free(stripped_sender);
739
698 } else { 740 } else {
699 zephyr_triple *zt1, *zt2; 741 zephyr_triple *zt1, *zt2;
700 gchar *send_inst_utf8; 742 gchar *send_inst_utf8;
701 zephyr_account *zephyr = gc->proto_data; 743 zephyr_account *zephyr = gc->proto_data;
702 zt1 = new_triple(gc->proto_data,notice.z_class, notice.z_class_inst, notice.z_recipient); 744 zt1 = new_triple(gc->proto_data,notice.z_class, notice.z_class_inst, notice.z_recipient);
1729 zephyr_gaim_cmd_zc, _("zc &lt;class&gt;: Send a message to &lt;<i>class</i>,PERSONAL,*&gt;"), NULL); 1771 zephyr_gaim_cmd_zc, _("zc &lt;class&gt;: Send a message to &lt;<i>class</i>,PERSONAL,*&gt;"), NULL);
1730 1772
1731 } 1773 }
1732 1774
1733 1775
1776 static void
1777 zephyr_add_deny(GaimConnection *gc, const char *who)
1778 {
1779 gaim_privacy_deny_add(gc->account,who,1);
1780 }
1781
1782 static void
1783 zephyr_remove_deny(GaimConnection *gc, const char *who)
1784 {
1785 gaim_privacy_deny_remove(gc->account,who,1);
1786 }
1787
1788 static void
1789 zephyr_add_permit(GaimConnection *gc, const char *who)
1790 {
1791 gaim_privacy_permit_add(gc->account,who,1);
1792 }
1793
1794 static void
1795 zephyr_remove_permit(GaimConnection *gc, const char *who)
1796 {
1797 gaim_privacy_permit_remove(gc->account,who,1);
1798 }
1799
1800 static void
1801 zephyr_set_permit_deny(GaimConnection *gc)
1802 {
1803 /* This doesn't have to do anything, since really, we can just check account->perm_deny when deciding whether to di */
1804 return;
1805 }
1734 static int zephyr_resubscribe(GaimConnection *gc) 1806 static int zephyr_resubscribe(GaimConnection *gc)
1735 { 1807 {
1736 /* Resubscribe to the in-memory list of subscriptions and also 1808 /* Resubscribe to the in-memory list of subscriptions and also
1737 unsubscriptions*/ 1809 unsubscriptions*/
1738 zephyr_account *zephyr = gc->proto_data; 1810 zephyr_account *zephyr = gc->proto_data;
1837 NULL, /* change password */ 1909 NULL, /* change password */
1838 NULL, /* add_buddy */ 1910 NULL, /* add_buddy */
1839 NULL, /* add_buddies */ 1911 NULL, /* add_buddies */
1840 NULL, /* remove_buddy */ 1912 NULL, /* remove_buddy */
1841 NULL, /* remove_buddies */ 1913 NULL, /* remove_buddies */
1842 NULL, /* add_permit -- not useful, since anyone can zephyr you by default*/ 1914 zephyr_add_permit, /* add_permit -- not useful, since anyone can zephyr you by default*/
1843 NULL, /* XXX add deny -- maybe put an auto "I'm ignoring your zephyrs*/ 1915 zephyr_add_deny, /* XXX add_deny -- maybe put an auto "I'm ignoring your zephyrs*/
1844 NULL, /* remove_permit -- not useful, see add permit */ 1916 zephyr_remove_permit, /* remove_permit -- not useful, see add permit */
1845 NULL, /* XXX remove deny -- remove above deny, */ 1917 zephyr_remove_deny, /* XXX remove deny -- remove above deny, */
1846 NULL, /* ??? set permit deny */ 1918 zephyr_set_permit_deny, /* ??? set permit deny */
1847 NULL, /* --- warn */ 1919 NULL, /* --- warn */
1848 zephyr_join_chat, /* join_chat */ 1920 zephyr_join_chat, /* join_chat */
1849 NULL, /* reject_chat */ 1921 NULL, /* reject_chat */
1850 NULL, /* chat_invite */ 1922 NULL, /* chat_invite */
1851 zephyr_chat_leave, /* chat_leave */ 1923 zephyr_chat_leave, /* chat_leave */