changeset 11111:f03dce7ea408

[gaim-migrate @ 13163] Patch #1234440, from sadrul "Mark blocked users in the buddy-list" Patch #1234197, from sadrul "New API fn gaim_privacy_check" Plus changes by me. (Read as: blame me if it's busted, thank sadrul if it works) Basically, all this stuff boils down to the following: We composite a new blocked.png onto the prpl icon in the buddy list if the user is blocked. MSN was the only prpl that used the old blocked.png. However, it looks bad to overlay both icons, so I removed the use of blocked.png from the MSN prpl. As an MSN user, I think the result is intuitive. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sun, 17 Jul 2005 23:36:34 +0000
parents f7ce10cad83d
children 92f7b92e866b
files pixmaps/status/default/blocked.png plugins/ChangeLog.API src/gtkblist.c src/gtkprivacy.c src/privacy.c src/privacy.h src/protocols/msn/msn.c src/protocols/yahoo/yahoo.c
diffstat 8 files changed, 94 insertions(+), 58 deletions(-) [+]
line wrap: on
line diff
Binary file pixmaps/status/default/blocked.png has changed
--- a/plugins/ChangeLog.API	Sun Jul 17 21:38:59 2005 +0000
+++ b/plugins/ChangeLog.API	Sun Jul 17 23:36:34 2005 +0000
@@ -64,6 +64,9 @@
 	           parameters to bring the function up-to-date with GaimLogLogger
 	* Changed: gaim_conv_window_remove_conversation()'s last argument to
 	           be a GaimConversation.
+	* Added:   gaim_privacy_check(), to check if a given user is allowed to
+	           to send messages to the specified account
+	* Changed: A new blocked icon: pixmaps/status/default/blocked.png
 
 	Signals:
 	* Changed: "received-im-msg" and "received-chat-msg" to match, both
--- a/src/gtkblist.c	Sun Jul 17 21:38:59 2005 +0000
+++ b/src/gtkblist.c	Sun Jul 17 23:36:34 2005 +0000
@@ -3079,6 +3079,27 @@
 		{
 			gdk_pixbuf_saturate_and_pixelate(scale, scale, 0.25, FALSE);
 		}
+
+		if (!gaim_privacy_check(buddy->account, gaim_buddy_get_name(buddy)))
+		{
+			GdkPixbuf *emblem;
+			char *filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "blocked.png", NULL);
+
+			emblem = gdk_pixbuf_new_from_file(filename, NULL);
+			g_free(filename);
+
+			if (emblem)
+			{
+				gdk_pixbuf_composite(emblem, scale,
+						0, 0, scalesize, scalesize,
+						0, 0,
+						(double)scalesize / gdk_pixbuf_get_width(emblem),
+						(double)scalesize / gdk_pixbuf_get_height(emblem),
+						GDK_INTERP_BILINEAR,
+						224);
+				g_object_unref(emblem);
+			}
+		}
 	}
 
 	return scale;
--- a/src/gtkprivacy.c	Sun Jul 17 21:38:59 2005 +0000
+++ b/src/gtkprivacy.c	Sun Jul 17 23:36:34 2005 +0000
@@ -31,6 +31,7 @@
 #include "request.h"
 #include "util.h"
 
+#include "gtkblist.h"
 #include "gtkprivacy.h"
 #include "gtkutils.h"
 
@@ -271,6 +272,7 @@
 	}
 
 	gaim_blist_schedule_save();
+	gaim_gtk_blist_refresh(gaim_get_blist());
 }
 
 static void
--- a/src/privacy.c	Sun Jul 17 21:38:59 2005 +0000
+++ b/src/privacy.c	Sun Jul 17 23:36:34 2005 +0000
@@ -170,6 +170,40 @@
 	return TRUE;
 }
 
+gboolean
+gaim_privacy_check(GaimAccount *account, const char *who)
+{
+	GSList *list;
+
+	switch (account->perm_deny) {
+		case GAIM_PRIVACY_ALLOW_ALL:
+			return TRUE;
+
+		case GAIM_PRIVACY_DENY_ALL:
+			return FALSE;
+
+		case GAIM_PRIVACY_ALLOW_USERS:
+			for (list=account->permit; list!=NULL; list=list->next) {
+				if (!gaim_utf8_strcasecmp(who, gaim_normalize(account, (char *)list->data)))
+					return TRUE;
+			}
+			return FALSE;
+
+		case GAIM_PRIVACY_DENY_USERS:
+			for (list=account->deny; list!=NULL; list=list->next) {
+				if (!gaim_utf8_strcasecmp(who, gaim_normalize( account, (char *)list->data )))
+					return FALSE;
+			}
+			return TRUE;
+
+		case GAIM_PRIVACY_ALLOW_BUDDYLIST:
+			return (gaim_find_buddy(account, who) != NULL);
+
+		default:
+			g_return_val_if_reached(TRUE);
+	}
+}
+
 void
 gaim_privacy_set_ui_ops(GaimPrivacyUiOps *ops)
 {
--- a/src/privacy.h	Sun Jul 17 21:38:59 2005 +0000
+++ b/src/privacy.h	Sun Jul 17 23:36:34 2005 +0000
@@ -107,6 +107,17 @@
 gboolean gaim_privacy_deny_remove(GaimAccount *account, const char *name,
 								  gboolean local_only);
 
+
+/**
+ * Check the privacy-setting for a user.
+ *
+ * @param account	The account.
+ * @param who		The name of the user.
+ *
+ * @return TRUE if the user is allowed to send messages, or @c FALSE otherwise.
+ */
+gboolean gaim_privacy_check(GaimAccount *account, const char *who);
+
 /**
  * Sets the UI operations structure for the privacy subsystem.
  *
--- a/src/protocols/msn/msn.c	Sun Jul 17 21:38:59 2005 +0000
+++ b/src/protocols/msn/msn.c	Sun Jul 17 23:36:34 2005 +0000
@@ -458,8 +458,6 @@
 	{
 		if (user->mobile)
 			emblems[i++] = "wireless";
-		if (user->list_op & (1 << MSN_LIST_BL))
-			emblems[i++] = "blocked";
 		if (!(user->list_op & (1 << MSN_LIST_RL)))
 			emblems[i++] = "nr";
 	}
--- a/src/protocols/yahoo/yahoo.c	Sun Jul 17 21:38:59 2005 +0000
+++ b/src/protocols/yahoo/yahoo.c	Sun Jul 17 23:36:34 2005 +0000
@@ -73,63 +73,30 @@
 gboolean yahoo_privacy_check(GaimConnection *gc, const char *who)
 {
 	/* returns TRUE if allowed through, FALSE otherwise */
-	GSList *list;
-	gboolean permitted=FALSE;
-
-	switch (gc->account->perm_deny) {
-		case GAIM_PRIVACY_ALLOW_ALL:
-			permitted = TRUE;
-			break;
-
-		case GAIM_PRIVACY_DENY_ALL:
+	gboolean permitted;
+
+	permitted = gaim_privacy_check(gc->account, who);
+
+	/* print some debug info */
+	if (!permitted) {
+		char *deb = NULL;
+		switch (gc->account->perm_deny)
+		{
+			case GAIM_PRIVACY_DENY_ALL:
+				deb = "GAIM_PRIVACY_DENY_ALL";		break;
+			case GAIM_PRIVACY_DENY_USERS:
+				deb = "GAIM_PRIVACY_DENY_USERS";	break;
+			case GAIM_PRIVACY_ALLOW_BUDDYLIST:
+				deb = "GAIM_PRIVACY_ALLOW_BUDDYLIST"; break;
+		}
+		if(deb)
 			gaim_debug_info("yahoo",
-			    "%s blocked data received from %s (GAIM_PRIVACY_DENY_ALL)\n",
-			    gc->account->username,who);
-			break;
-
-		case GAIM_PRIVACY_ALLOW_USERS:
-			for( list=gc->account->permit; list!=NULL; list=list->next ) {
-				if ( !gaim_utf8_strcasecmp(who, gaim_normalize(gc->account,
-					      (char *)list->data)) ) {
-					permitted=TRUE;
-					gaim_debug_info("yahoo",
-					    "%s allowed data received from %s (GAIM_PRIVACY_ALLOW_USERS)\n",
-					    gc->account->username,who);
-					break;
-				}
-			}
-			break;
-
-		case GAIM_PRIVACY_DENY_USERS:
-			/* seeing we're letting everyone through, except the deny list*/
-			permitted=TRUE;
-			for( list=gc->account->deny; list!=NULL; list=list->next ) {
-				if ( !gaim_utf8_strcasecmp(who, gaim_normalize( gc->account,
-					      (char *)list->data )) ) {
-					permitted=FALSE;
-					gaim_debug_info("yahoo",
-					    "%s blocked data received from %s (GAIM_PRIVACY_DENY_USERS)\n",
-					    gc->account->username,who);
-					break;
-				}
-			}
-			break;
-
-		case GAIM_PRIVACY_ALLOW_BUDDYLIST:
-			if ( gaim_find_buddy(gc->account,who) != NULL ) {
-				permitted = TRUE;
-			} else {
-				gaim_debug_info("yahoo",
-				    "%s blocked data received from %s (GAIM_PRIVACY_ALLOW_BUDDYLIST)\n",
-				    gc->account->username,who);
-			}
-		break;
-
-		default:
-			gaim_debug_warning("yahoo", "Privacy setting was unknown.  If you can "
-							   "reproduce this, please file a bug report.\n");
-			permitted = FALSE;
-			break;
+				"%s blocked data received from %s (%s)\n",
+				gc->account->username,who, deb);
+	} else if (gc->account->perm_deny == GAIM_PRIVACY_ALLOW_USERS) {
+		gaim_debug_info("yahoo",
+			"%s allowed data received from %s (GAIM_PRIVACY_ALLOW_USERS)\n",
+			gc->account->username,who);
 	}
 
 	return permitted;