changeset 8175:f347c8d25cf5

[gaim-migrate @ 8889] Make privacy stuff use an enum for different privacy options. This started with a fix to make the box for "allow the users below" show up when opening the privacy dialog when that option was selected. It might be a good idea for a few people to check their privacy settings after using this to make sure it's the same as what it used to be. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 28 Jan 2004 05:43:04 +0000
parents 4c34db6996d1
children c733bb72b002
files src/account.h src/blist.c src/gtkprivacy.c src/privacy.h src/protocols/msn/msn.c src/protocols/msn/notification.c src/protocols/oscar/oscar.c
diffstat 7 files changed, 54 insertions(+), 39 deletions(-) [+]
line wrap: on
line diff
--- a/src/account.h	Wed Jan 28 04:09:18 2004 +0000
+++ b/src/account.h	Wed Jan 28 05:43:04 2004 +0000
@@ -34,14 +34,6 @@
 #include "proxy.h"
 #include "prpl.h"
 
-enum
-{
-	PERMIT_ALL  = 1,
-	PERMIT_NONE,
-	PERMIT_SOME,
-	DENY_SOME
-};
-
 struct _GaimAccountUiOps
 {
 	void (*notify_added)(GaimAccount *account, const char *remote_user,
--- a/src/blist.c	Wed Jan 28 04:09:18 2004 +0000
+++ b/src/blist.c	Wed Jan 28 05:43:04 2004 +0000
@@ -1594,13 +1594,13 @@
 				gaim_debug(GAIM_DEBUG_MISC, "toc blist",
 						   "permdeny: %d\n", account->perm_deny);
 				if (account->perm_deny == 0)
-					account->perm_deny = 1;
+					account->perm_deny = GAIM_PRIVACY_ALLOW_ALL;
 			} else if (*c == 'm') {
 				sscanf(c + 2, "%d", &account->perm_deny);
 				gaim_debug(GAIM_DEBUG_MISC, "toc blist",
 						   "permdeny: %d\n", account->perm_deny);
 				if (account->perm_deny == 0)
-					account->perm_deny = 1;
+					account->perm_deny = GAIM_PRIVACY_ALLOW_ALL;
 			}
 		} while ((c = strtok(NULL, "\n")));
 
--- a/src/gtkprivacy.c	Wed Jan 28 04:09:18 2004 +0000
+++ b/src/gtkprivacy.c	Wed Jan 28 05:43:04 2004 +0000
@@ -33,16 +33,6 @@
 #include "gtkprivacy.h"
 #include "gtkutils.h"
 
-typedef enum
-{
-	GAIM_GTK_PRIVACY_ALLOW_ALL = 0,
-	GAIM_GTK_PRIVACY_ALLOW_BUDDYLIST,
-	GAIM_GTK_PRIVACY_ALLOW_USERS,
-	GAIM_GTK_PRIVACY_DENY_ALL,
-	GAIM_GTK_PRIVACY_DENY_USERS
-
-} GaimGtkPrivacyType;
-
 typedef struct
 {
 	GtkWidget *win;
@@ -84,11 +74,11 @@
 
 } menu_entries[] =
 {
-	{ N_("Allow all users to contact me"),         1 },
-	{ N_("Allow only the users on my buddy list"), 5 },
-	{ N_("Allow only the users below"),            3 },
-	{ N_("Block all users"),                       2 },
-	{ N_("Block the users below"),                 4 }
+	{ N_("Allow all users to contact me"),         GAIM_PRIVACY_ALLOW_ALL },
+	{ N_("Allow only the users on my buddy list"), GAIM_PRIVACY_ALLOW_BUDDYLIST },
+	{ N_("Allow only the users below"),            GAIM_PRIVACY_ALLOW_USERS },
+	{ N_("Block all users"),                       GAIM_PRIVACY_DENY_ALL },
+	{ N_("Block only the users below"),            GAIM_PRIVACY_DENY_USERS }
 };
 
 static size_t menu_entry_count = sizeof(menu_entries) / sizeof(*menu_entries);
@@ -260,12 +250,12 @@
 	gtk_widget_hide(dialog->block_widget);
 	gtk_widget_hide(dialog->button_box);
 
-	if (new_type == 2) {
+	if (new_type == GAIM_PRIVACY_ALLOW_USERS) {
 		gtk_widget_show(dialog->allow_widget);
 		gtk_widget_show(dialog->button_box);
 		dialog->in_allow_list = TRUE;
 	}
-	else if (new_type == 4) {
+	else if (new_type == GAIM_PRIVACY_DENY_USERS) {
 		gtk_widget_show(dialog->block_widget);
 		gtk_widget_show(dialog->button_box);
 		dialog->in_allow_list = FALSE;
@@ -487,12 +477,12 @@
 	g_signal_connect(G_OBJECT(button), "clicked",
 					 G_CALLBACK(close_cb), dialog);
 
-	if (dialog->account->perm_deny == 2) {
+	if (dialog->account->perm_deny == GAIM_PRIVACY_ALLOW_USERS) {
 		gtk_widget_show(dialog->allow_widget);
 		gtk_widget_show(dialog->button_box);
 		dialog->in_allow_list = TRUE;
 	}
-	else if (dialog->account->perm_deny == 4) {
+	else if (dialog->account->perm_deny == GAIM_PRIVACY_DENY_USERS) {
 		gtk_widget_show(dialog->block_widget);
 		gtk_widget_show(dialog->button_box);
 		dialog->in_allow_list = FALSE;
--- a/src/privacy.h	Wed Jan 28 04:09:18 2004 +0000
+++ b/src/privacy.h	Wed Jan 28 05:43:04 2004 +0000
@@ -27,6 +27,18 @@
 
 #include "account.h"
 
+/**
+ * Privacy data types.
+ */
+typedef enum _GaimPrivacyType
+{
+	GAIM_PRIVACY_ALLOW_ALL = 1,
+	GAIM_PRIVACY_DENY_ALL,
+	GAIM_PRIVACY_ALLOW_USERS,
+	GAIM_PRIVACY_DENY_USERS,
+	GAIM_PRIVACY_ALLOW_BUDDYLIST
+} GaimPrivacyType;
+
 #ifdef __cplusplus
 extern "C" {
 #endif
--- a/src/protocols/msn/msn.c	Wed Jan 28 04:09:18 2004 +0000
+++ b/src/protocols/msn/msn.c	Wed Jan 28 05:43:04 2004 +0000
@@ -871,8 +871,8 @@
 	char buf[MSN_BUF_LEN];
 	GSList *s, *t = NULL;
 
-	if (account->perm_deny == PERMIT_ALL ||
-		account->perm_deny == DENY_SOME) {
+	if (account->perm_deny == GAIM_PRIVACY_ALLOW_ALL ||
+		account->perm_deny == GAIM_PRIVACY_DENY_USERS) {
 
 		strcpy(buf, "AL");
 	}
--- a/src/protocols/msn/notification.c	Wed Jan 28 04:09:18 2004 +0000
+++ b/src/protocols/msn/notification.c	Wed Jan 28 05:43:04 2004 +0000
@@ -623,7 +623,7 @@
 		 *
 		 * In other words, deny some.
 		 */
-		gc->account->perm_deny = DENY_SOME;
+		gc->account->perm_deny = GAIM_PRIVACY_DENY_USERS;
 	}
 	else {
 		/* If the current setting is BL, only messages from people
@@ -631,7 +631,7 @@
 		 *
 		 * In other words, permit some.
 		 */
-		gc->account->perm_deny = PERMIT_SOME;
+		gc->account->perm_deny = GAIM_PRIVACY_ALLOW_USERS;
 	}
 
 	return TRUE;
--- a/src/protocols/oscar/oscar.c	Wed Jan 28 04:09:18 2004 +0000
+++ b/src/protocols/oscar/oscar.c	Wed Jan 28 05:43:04 2004 +0000
@@ -4918,6 +4918,7 @@
 				}
 			}
 		}
+
 		while (cur != NULL) {
 			b = cur->data;
 			cur = g_slist_remove(cur, b);
@@ -6061,13 +6062,13 @@
 	int at;
 
 	switch(account->perm_deny) {
-	case 1: 
+	case GAIM_PRIVACY_ALLOW_ALL: 
 		aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_DENYADD, gaim_account_get_username(account));
 		break;
-	case 2:
+	case GAIM_PRIVACY_DENY_ALL:
 		aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, gaim_account_get_username(account));
 		break;
-	case 3:
+	case GAIM_PRIVACY_ALLOW_USERS:
 		list = account->permit;
 		at = 0;
 		while (list) {
@@ -6076,7 +6077,7 @@
 		}
 		aim_bos_changevisibility(od->sess, od->conn, AIM_VISIBILITYCHANGE_PERMITADD, buf);
 		break;
-	case 4:
+	case GAIM_PRIVACY_DENY_USERS:
 		list = account->deny;
 		at = 0;
 		while (list) {
@@ -6089,8 +6090,28 @@
 		break;
 	}
 #else
-	if (od->sess->ssi.received_data)
-		aim_ssi_setpermdeny(od->sess, account->perm_deny, 0xffffffff);
+	if (od->sess->ssi.received_data) {
+		switch (account->perm_deny) {
+			case GAIM_PRIVACY_ALLOW_ALL:
+				aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff);
+				break;
+			case GAIM_PRIVACY_ALLOW_BUDDYLIST:
+				aim_ssi_setpermdeny(od->sess, 0x05, 0xffffffff);
+				break;
+			case GAIM_PRIVACY_ALLOW_USERS:
+				aim_ssi_setpermdeny(od->sess, 0x03, 0xffffffff);
+				break;
+			case GAIM_PRIVACY_DENY_ALL:
+				aim_ssi_setpermdeny(od->sess, 0x02, 0xffffffff);
+				break;
+			case GAIM_PRIVACY_DENY_USERS:
+				aim_ssi_setpermdeny(od->sess, 0x04, 0xffffffff);
+				break;
+			default:
+				aim_ssi_setpermdeny(od->sess, 0x01, 0xffffffff);
+				break;
+		}
+	}
 #endif
 }