comparison src/protocols/irc/msgs.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 a64febebdd1e
children b10d4c6ac7eb
comparison
equal deleted inserted replaced
9739:35f22ba01bd7 9740:2bb5e2cd64bd
26 #include "blist.h" 26 #include "blist.h"
27 #include "notify.h" 27 #include "notify.h"
28 #include "util.h" 28 #include "util.h"
29 #include "debug.h" 29 #include "debug.h"
30 #include "irc.h" 30 #include "irc.h"
31 #include "privacy.h"
31 32
32 #include <stdio.h> 33 #include <stdio.h>
33 34
34 static char *irc_mask_nick(const char *mask); 35 static char *irc_mask_nick(const char *mask);
35 static char *irc_mask_userhost(const char *mask); 36 static char *irc_mask_userhost(const char *mask);
844 { 845 {
845 GaimConnection *gc = gaim_account_get_connection(irc->account); 846 GaimConnection *gc = gaim_account_get_connection(irc->account);
846 GaimConversation *convo; 847 GaimConversation *convo;
847 char *nick = irc_mask_nick(from), *tmp, *msg; 848 char *nick = irc_mask_nick(from), *tmp, *msg;
848 int notice = 0; 849 int notice = 0;
850 GSList* l;
851 gboolean in_deny=0;
849 852
850 if (!args || !args[0] || !args[1] || !gc) { 853 if (!args || !args[0] || !args[1] || !gc) {
851 g_free(nick); 854 g_free(nick);
852 return; 855 return;
853 } 856 }
857 if (!tmp) { 860 if (!tmp) {
858 g_free(nick); 861 g_free(nick);
859 return; 862 return;
860 } 863 }
861 864
865
866 switch (gc->account->perm_deny) {
867 case GAIM_PRIVACY_ALLOW_ALL:
868 in_deny = 0; break;
869 case GAIM_PRIVACY_DENY_ALL:
870 in_deny = 1; break;
871 case GAIM_PRIVACY_ALLOW_USERS: /* See if stripped_sender is in gc->account->permit and allow appropriately */
872 in_deny = 1;
873 for(l=gc->account->permit;l!=NULL;l=l->next) {
874 if (!gaim_utf8_strcasecmp(nick, gaim_normalize(gc->account, (char *)l->data))) {
875 in_deny=0;
876 break;
877 }
878 }
879 break;
880 case GAIM_PRIVACY_DENY_USERS: /* See if nick is in gc->account->deny and deny if so */
881 in_deny = 0;
882 for(l=gc->account->deny;l!=NULL;l=l->next) {
883 if (!gaim_utf8_strcasecmp(nick, gaim_normalize(gc->account, (char *)l->data))) {
884 in_deny=1;
885 break;
886 }
887 }
888 break;
889 case GAIM_PRIVACY_ALLOW_BUDDYLIST:
890 in_deny = 1;
891 if (gaim_find_buddy(gc->account,nick)!=NULL) {
892 in_deny = 0;
893 }
894 break;
895 default:
896 in_deny=0; break;
897 }
898
862 msg = gaim_escape_html(tmp); 899 msg = gaim_escape_html(tmp);
863 g_free(tmp); 900 g_free(tmp);
864 901
865 tmp = irc_mirc2html(msg); 902 tmp = irc_mirc2html(msg);
866 g_free(msg); 903 g_free(msg);
870 g_free(msg); 907 g_free(msg);
871 msg = tmp; 908 msg = tmp;
872 } 909 }
873 910
874 if (!gaim_utf8_strcasecmp(args[0], gaim_connection_get_display_name(gc))) { 911 if (!gaim_utf8_strcasecmp(args[0], gaim_connection_get_display_name(gc))) {
912 if (!in_deny) {
875 serv_got_im(gc, nick, msg, 0, time(NULL)); 913 serv_got_im(gc, nick, msg, 0, time(NULL));
914 }
876 } else if (notice) { 915 } else if (notice) {
916 if(!in_deny) {
877 serv_got_im(gc, nick, msg, 0, time(NULL)); 917 serv_got_im(gc, nick, msg, 0, time(NULL));
918 }
878 } else { 919 } else {
879 convo = gaim_find_conversation_with_account(args[0], irc->account); 920 convo = gaim_find_conversation_with_account(args[0], irc->account);
880 if (convo) 921 if (convo)
881 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), nick, 0, msg, time(NULL)); 922 serv_got_chat_in(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(convo)), nick, 0, msg, time(NULL));
882 else 923 else