changeset 678:c72f58814e9f

[gaim-migrate @ 688] permit/deny stuff moved to prefs; permit/deny stuff works *properly* now, permit/deny stuff much more logical in preferences. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 15 Aug 2000 01:29:35 +0000
parents 05f6f7dabb7e
children 71b2477033cb
files src/buddy.c src/gaim.h src/prefs.c src/server.c src/toc.c
diffstat 5 files changed, 470 insertions(+), 325 deletions(-) [+]
line wrap: on
line diff
--- a/src/buddy.c	Tue Aug 15 00:04:14 2000 +0000
+++ b/src/buddy.c	Tue Aug 15 01:29:35 2000 +0000
@@ -70,10 +70,8 @@
 static GtkWidget *buddypane;
 static GtkWidget *permitpane;
 static GtkWidget *edittree;
-static GtkWidget *permtree;
 static GtkWidget *imbutton, *infobutton, *chatbutton;
 static GtkWidget *addbutton, *groupbutton, *rembutton;
-static GtkWidget *addpermbutton, *rempermbutton;
 
 static int last_lag_us;
 
@@ -241,25 +239,25 @@
 		adjust_pic(chatbutton, _("Chat"), (gchar **)daemon_buddychat_xpm);
 	        adjust_pic(imbutton, _("IM"), (gchar **)daemon_im_xpm);
 	        adjust_pic(infobutton, _("Info"), (gchar **)daemon_info_xpm);
-	        adjust_pic(addpermbutton, _("Add"), (gchar **)daemon_permadd_xpm);
+/*	        adjust_pic(addpermbutton, _("Add"), (gchar **)daemon_permadd_xpm);
 	        adjust_pic(rempermbutton, _("Remove"), (gchar **)daemon_permdel_xpm);
-	} else {
+*/	} else {
 	        adjust_pic(addbutton, _("Add"), (gchar **)buddyadd_xpm);
 	        adjust_pic(groupbutton, _("Group"), NULL);
 		adjust_pic(rembutton, _("Remove"), (gchar **)buddydel_xpm);
 		adjust_pic(chatbutton, _("Chat"), (gchar **)buddychat_xpm);
 	        adjust_pic(imbutton, _("IM"), (gchar **)im_xpm);
 	        adjust_pic(infobutton, _("Info"), (gchar **)info_xpm);
-	        adjust_pic(addpermbutton, _("Add"), (gchar **)permadd_xpm);
+/*	        adjust_pic(addpermbutton, _("Add"), (gchar **)permadd_xpm);
 	        adjust_pic(rempermbutton, _("Remove"), (gchar **)permdel_xpm);
-	}
+*/	}
 	gtk_widget_hide(addbutton->parent);
 	gtk_widget_show(addbutton->parent);
 	gtk_widget_hide(chatbutton->parent);
 	gtk_widget_show(chatbutton->parent);
-	gtk_widget_hide(addpermbutton->parent);
+/*	gtk_widget_hide(addpermbutton->parent);
 	gtk_widget_show(addpermbutton->parent);
-}
+*/}
 
 
 
@@ -554,48 +552,6 @@
 
 
 
-void build_permit_tree()
-{
-	GtkWidget *ti;
-        GtkWidget *sub;
-        GList *plist = permit;
-        GList *dlist = deny;
-
-        gtk_tree_clear_items(GTK_TREE(permtree), 0, -1);
-
-        ti = gtk_tree_item_new_with_label(_("Permit"));
-        sub = gtk_tree_new();
-        gtk_widget_show(ti);
-        gtk_widget_show(sub);
-        gtk_tree_prepend(GTK_TREE(permtree), ti);
-        gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), sub);
-        gtk_tree_item_expand(GTK_TREE_ITEM(ti));
-        
-        while(plist) {
-                ti = gtk_tree_item_new_with_label((char *)plist->data);
-                gtk_widget_show(ti);
-                gtk_tree_prepend(GTK_TREE(sub), ti);
-                plist = plist->next;
-        }
-
-
-        ti = gtk_tree_item_new_with_label(_("Deny"));
-        sub = gtk_tree_new();
-        gtk_widget_show(ti);
-        gtk_widget_show(sub);
-        gtk_tree_prepend(GTK_TREE(permtree), ti);
-        gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), sub);
-        gtk_tree_item_expand(GTK_TREE_ITEM(ti));
-        
-        while(dlist) {
-                ti = gtk_tree_item_new_with_label((char *)dlist->data);
-                gtk_widget_show(ti);
-                gtk_tree_prepend(GTK_TREE(sub), ti);
-                dlist = dlist->next;
-        }
-
-	
-}
 
 
 gboolean edit_drag_compare_func (GtkCTree *ctree, GtkCTreeNode *source_node,
@@ -988,66 +944,6 @@
         update_num_groups();
 }
 
-static void do_del_perm(GtkWidget *w, GtkTree *permtree)
-{
-	GtkLabel *label, *plabel;
-	GtkWidget *item, *pitem;
-	char *c, *d;
-	GList *i;
-	
-        GList *plist;
-        GList *dlist;
-	int level;
-
-        plist = permit;
-        dlist = deny;
-        
-	i = GTK_TREE_SELECTION(permtree);
-	if (i) {
-		item = GTK_WIDGET(i->data);
-		gtk_tree_unselect_child(GTK_TREE(permtree), item);
-		label = GTK_LABEL(GTK_BIN(item)->child);
-		gtk_label_get(label, &c);
-		level = GTK_TREE(item->parent)->level;
-		if (level > 0) {
-			pitem = GTK_WIDGET(GTK_TREE(item->parent)->tree_owner);
-			plabel = GTK_LABEL(GTK_BIN(pitem)->child);
-			gtk_label_get(plabel, &d);
-                        if (!strcasecmp(d, _("Permit"))) {
-                                while(plist) {
-                                        if (!strcasecmp((char *)(plist->data), c)) {
-                                                permit = g_list_remove(permit, plist->data);
-                                                break;
-                                        }
-
-                                        plist = plist->next;
-                                }
-
-                        } else {
-                                while(dlist) {
-                                        if (!strcasecmp((char *)(dlist->data), c)) {
-                                                deny = g_list_remove(deny, dlist->data);
-                                                
-                                                break;
-                                        }
-                                        dlist = dlist->next;
-                                }
-
-                        }
-
-                        
-                } else {
-                        /* Can't delete groups here! :) */
-                        return;
-                }
-                serv_set_permit_deny();
-		gtk_tree_clear_items(GTK_TREE(permtree), 0, -1);
-                build_permit_tree();
-                serv_save_config();
-	}
-}
-
-
 
 void gaimreg_callback(GtkWidget *widget)
 {
@@ -1132,12 +1028,6 @@
 	show_add_group();
 }
 
-void add_perm_callback(GtkWidget *widget, void *dummy)
-{
-        show_add_perm(NULL);
-}
-
-
 static void info_callback(GtkWidget *widget, GtkTree *tree)
 {
 	GList *i;
@@ -1737,18 +1627,6 @@
 }
 
 
-static void set_permit(GtkWidget *w, int *data)
-{
-	permdeny = (int)data;
-/*	printf("BLAH BLAH %d %d", permdeny, (int) data); */
-	/* We don't save this 'at home', it's on the server.
-         * So, we gotta resend the config to the server. */
-        serv_save_config();
-	/* we do this here because we can :) */
-	serv_set_permit_deny();
-}
-
-
 static void move_blist_window(GtkWidget *w, GdkEventConfigure *e, void *dummy)
 {
         int x, y, width, height;
@@ -1830,8 +1708,6 @@
         GtkWidget *bbox;
         GtkWidget *permopt;
         GtkWidget *tbox;
-        GtkWidget *xbox;
-        GtkWidget *pbox;
 
 
 #ifdef USE_APPLET
@@ -2060,78 +1936,13 @@
 	gtk_widget_show(editpane);
 
 
-	/* Permit/Deny */
-
-	permitpane = gtk_vbox_new(FALSE, 0);
-
-        permopt = gtk_radio_button_new_with_label(NULL, _("Allow anyone"));
-        gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)1);
-	gtk_widget_show(permopt);
-	if (permdeny == 1)
-		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE);
-
-        permopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(permopt)), _("Permit some"));
-        gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)3);
-	gtk_widget_show(permopt);
-	if (permdeny == 3)
-		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE);
-
-
-        permopt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(permopt)), _("Deny some"));
-        gtk_box_pack_start(GTK_BOX(permitpane), permopt, FALSE, FALSE, 0);
-        gtk_signal_connect(GTK_OBJECT(permopt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)4);
-        gtk_widget_show(permopt);
-	if (permdeny == 4)
-		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(permopt), TRUE);
-
-
-
-        addpermbutton = gtk_button_new_with_label(_("Add"));
-        rempermbutton = gtk_button_new_with_label(_("Remove"));
-        
-	if (display_options & OPT_DISP_COOL_LOOK)
-	{
-		gtk_button_set_relief(GTK_BUTTON(addpermbutton), GTK_RELIEF_NONE);
-		gtk_button_set_relief(GTK_BUTTON(rempermbutton), GTK_RELIEF_NONE);
-	}
 	
-       	permtree = gtk_tree_new();
-	build_permit_tree();
-       	pbox = gtk_hbox_new(TRUE, 10);
-       	xbox = gtk_scrolled_window_new(NULL, NULL);
-       	/* Put the buttons in the box */
-       	gtk_box_pack_start(GTK_BOX(pbox), addpermbutton, TRUE, TRUE, 10);
-        gtk_box_pack_start(GTK_BOX(pbox), rempermbutton, TRUE, TRUE, 10);
-        
-
-	gtk_tooltips_set_tip(tips, addpermbutton, _("Add buddy to permit/deny"), "Penguin");
-	gtk_tooltips_set_tip(tips, rempermbutton, _("Remove buddy from permit/deny"), "Penguin");
-       	/* And the boxes in the box */
-       	gtk_box_pack_start(GTK_BOX(permitpane), xbox, TRUE, TRUE, 5);
-       	gtk_box_pack_start(GTK_BOX(permitpane), pbox, FALSE, FALSE, 5);
-
-	/* Handle closes right */
-
-	
-
-       	/* Finish up */
-       	gtk_widget_show(addpermbutton);
-        gtk_widget_show(rempermbutton);
-       	gtk_widget_show(permtree);
-       	gtk_widget_show(xbox);
-       	gtk_widget_show(pbox);
-	gtk_widget_show(permitpane);
-
 
 
         label = gtk_label_new(_("Online"));
         gtk_notebook_append_page(GTK_NOTEBOOK(notebook), buddypane, label);
         label = gtk_label_new(_("Edit Buddies"));
 	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), editpane, label);
-	label = gtk_label_new(_("Permit"));
-	gtk_notebook_append_page(GTK_NOTEBOOK(notebook), permitpane, label);
 
         gtk_widget_show_all(notebook);
 
@@ -2149,8 +1960,6 @@
        	gtk_signal_connect(GTK_OBJECT(rembutton), "clicked", GTK_SIGNAL_FUNC(do_del_buddy), edittree);
        	gtk_signal_connect(GTK_OBJECT(addbutton), "clicked", GTK_SIGNAL_FUNC(add_buddy_callback), NULL);
        	gtk_signal_connect(GTK_OBJECT(groupbutton), "clicked", GTK_SIGNAL_FUNC(add_group_callback), NULL);
-        gtk_signal_connect(GTK_OBJECT(addpermbutton), "clicked", GTK_SIGNAL_FUNC(add_perm_callback), NULL);
-        gtk_signal_connect(GTK_OBJECT(rempermbutton), "clicked", GTK_SIGNAL_FUNC(do_del_perm), permtree);
         gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0);
 	gtk_box_pack_start(GTK_BOX(vbox), notebook, TRUE, TRUE, 0);
 
@@ -2172,11 +1981,6 @@
                                        GTK_POLICY_NEVER,GTK_POLICY_AUTOMATIC);
 
 
-        /* The permit tree */
-       	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(xbox), permtree);
-       	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(xbox),
-                                       GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC);
-
         gtk_window_set_title(GTK_WINDOW(blist), _("Gaim - Buddy List"));
 
         if (general_options & OPT_GEN_SAVED_WINDOWS) {
@@ -2192,7 +1996,7 @@
         setup_buddy_chats();
  
         build_edit_tree();
-        build_permit_tree();
+	build_permit_tree();
         
         update_button_pix();
         gtk_widget_show(blist);
--- a/src/gaim.h	Tue Aug 15 00:04:14 2000 +0000
+++ b/src/gaim.h	Tue Aug 15 01:29:35 2000 +0000
@@ -55,6 +55,13 @@
 #define BROWSER_MANUAL                2
 #define BROWSER_INTERNAL              3
 
+#define PERMIT_ALL	1
+#define PERMIT_NONE	2
+#define PERMIT_SOME	3
+#define DENY_SOME	4
+#define PERMIT_BUDDY	5 /* TOC doesn't have this,
+			     but we can fake it */
+
 #define UC_AOL		1
 #define UC_ADMIN 	2
 #define UC_UNCONFIRMED	4
@@ -386,7 +393,7 @@
 #define TYPE_SIGNOFF   4
 #define TYPE_KEEPALIVE 5
 
-#define REVISION "gaim:$Revision: 677 $"
+#define REVISION "gaim:$Revision: 688 $"
 #define FLAPON "FLAPON\r\n\r\n"
 
 #define ROAST "Tic/Toc"
@@ -675,7 +682,6 @@
 extern struct group *add_group(char *);
 extern void add_category(char *);
 extern void build_edit_tree();
-extern void build_permit_tree();
 extern void remove_person(struct group *, struct buddy *);
 extern void remove_category(struct group *);
 extern void do_pounce(char *);
@@ -729,6 +735,7 @@
 extern void set_option(GtkWidget *, int *);
 extern void show_prefs();
 extern void show_debug(GtkObject *);
+extern void build_permit_tree();
 extern GtkWidget *prefs_away_list;
 
 /* Functions in gaimrc.c */
--- a/src/prefs.c	Tue Aug 15 00:04:14 2000 +0000
+++ b/src/prefs.c	Tue Aug 15 01:29:35 2000 +0000
@@ -59,6 +59,12 @@
 static GtkWidget *debugbutton = NULL;
 GtkWidget *prefs_away_list = NULL;
 
+static void destdeb(GtkWidget *m, gpointer n)
+{
+	gtk_widget_destroy(debugbutton);
+	debugbutton = NULL;
+}
+
 static void general_page()
 {
 	GtkWidget *parent;
@@ -69,8 +75,6 @@
 	
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("General Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -96,6 +100,7 @@
 		general_options = general_options ^ OPT_GEN_DEBUG;
 	debugbutton = gaim_button(_("Show Debug Window"), &general_options, OPT_GEN_DEBUG, box);
 	gtk_signal_connect_object(GTK_OBJECT(debugbutton), "clicked", GTK_SIGNAL_FUNC(show_debug), 0);
+	gtk_signal_connect(GTK_OBJECT(debugbutton), "destroy", GTK_SIGNAL_FUNC(destdeb), 0);
 
 	sep = gtk_hseparator_new();
 	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
@@ -181,8 +186,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Connection Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -309,8 +312,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Buddy List Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -332,6 +333,241 @@
 	gtk_widget_show(prefdialog);
 }
 
+static GtkWidget *permtree = NULL;
+
+void build_permit_tree()
+{
+	GtkWidget *ti;
+        GtkWidget *sub;
+        GList *plist = permit;
+        GList *dlist = deny;
+
+	if (!permtree) return;
+
+        gtk_tree_clear_items(GTK_TREE(permtree), 0, -1);
+
+        ti = gtk_tree_item_new_with_label(_("Permit"));
+        sub = gtk_tree_new();
+        gtk_widget_show(ti);
+        gtk_widget_show(sub);
+        gtk_tree_prepend(GTK_TREE(permtree), ti);
+        gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), sub);
+        gtk_tree_item_expand(GTK_TREE_ITEM(ti));
+        
+        while(plist) {
+                ti = gtk_tree_item_new_with_label((char *)plist->data);
+                gtk_widget_show(ti);
+                gtk_tree_prepend(GTK_TREE(sub), ti);
+                plist = plist->next;
+        }
+
+
+        ti = gtk_tree_item_new_with_label(_("Deny"));
+        sub = gtk_tree_new();
+        gtk_widget_show(ti);
+        gtk_widget_show(sub);
+        gtk_tree_prepend(GTK_TREE(permtree), ti);
+        gtk_tree_item_set_subtree(GTK_TREE_ITEM(ti), sub);
+        gtk_tree_item_expand(GTK_TREE_ITEM(ti));
+        
+        while(dlist) {
+                ti = gtk_tree_item_new_with_label((char *)dlist->data);
+                gtk_widget_show(ti);
+                gtk_tree_prepend(GTK_TREE(sub), ti);
+                dlist = dlist->next;
+        }
+}
+
+static void do_del_perm(GtkWidget *w, GtkTree *ptree)
+{
+	GtkLabel *label, *plabel;
+	GtkWidget *item, *pitem;
+	char *c, *d;
+	GList *i;
+	
+        GList *plist;
+        GList *dlist;
+	int level;
+
+        plist = permit;
+        dlist = deny;
+        
+	i = GTK_TREE_SELECTION(ptree);
+	if (i) {
+		item = GTK_WIDGET(i->data);
+		gtk_tree_unselect_child(GTK_TREE(ptree), item);
+		label = GTK_LABEL(GTK_BIN(item)->child);
+		gtk_label_get(label, &c);
+		level = GTK_TREE(item->parent)->level;
+		if (level > 0) {
+			pitem = GTK_WIDGET(GTK_TREE(item->parent)->tree_owner);
+			plabel = GTK_LABEL(GTK_BIN(pitem)->child);
+			gtk_label_get(plabel, &d);
+                        if (!strcasecmp(d, _("Permit"))) {
+                                while(plist) {
+                                        if (!strcasecmp((char *)(plist->data), c)) {
+                                                permit = g_list_remove(permit, plist->data);
+                                                break;
+                                        }
+
+                                        plist = plist->next;
+                                }
+
+                        } else {
+                                while(dlist) {
+                                        if (!strcasecmp((char *)(dlist->data), c)) {
+                                                deny = g_list_remove(deny, dlist->data);
+                                                
+                                                break;
+                                        }
+                                        dlist = dlist->next;
+                                }
+
+                        }
+
+                        
+                } else {
+                        /* Can't delete groups here! :) */
+                        return;
+                }
+                serv_set_permit_deny();
+		gtk_tree_clear_items(GTK_TREE(ptree), 0, -1);
+                build_permit_tree();
+                serv_save_config();
+	}
+}
+
+
+static void set_permit(GtkWidget *w, int *data)
+{
+	permdeny = (int)data;
+        if (blist) {
+		/* We don't save this 'at home', it's on the server.
+		 * So, we gotta resend the config to the server. */
+		serv_save_config();
+		/* we do this here because we can :) */
+		serv_set_permit_deny();
+	}
+}
+
+static GtkWidget *deny_radio(char *label, int which, GtkWidget *box, GtkWidget *set)
+{
+	GtkWidget *opt;
+
+	if (!set)
+		opt = gtk_radio_button_new_with_label(NULL, label);
+	else
+		opt = gtk_radio_button_new_with_label(gtk_radio_button_group(GTK_RADIO_BUTTON(set)), label);
+	gtk_box_pack_start(GTK_BOX(box), opt, FALSE, FALSE, 0);
+	gtk_signal_connect(GTK_OBJECT(opt), "clicked", GTK_SIGNAL_FUNC(set_permit), (void *)which);
+	gtk_widget_show(opt);
+	if (permdeny == which)
+		gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(opt), TRUE);
+
+	return opt;
+}
+
+static void permdest(GtkWidget *m, gpointer n)
+{
+	gtk_widget_destroy(permtree);
+	permtree = NULL;
+}
+
+static void add_perm_callback(GtkWidget *widget, void *dummy)
+{
+	if (!blist)
+		do_error_dialog(_("Please sign on before editing the permit/deny lists."),
+				_("Please sign on"));
+	else
+	        show_add_perm(NULL);
+}
+
+static void deny_page()
+{
+	GtkWidget *parent;
+	GtkWidget *box;
+	GtkWidget *label;
+	GtkWidget *sep;
+	GtkWidget *hbox;
+	GtkWidget *vbox;
+	GtkWidget *xbox;
+	GtkWidget *opt;
+	GtkWidget *button;
+
+	parent = prefdialog->parent;
+	gtk_widget_destroy(prefdialog);
+
+	prefdialog = gtk_frame_new(_("Permit/Deny List Options"));
+	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
+
+	box = gtk_vbox_new(FALSE, 5);
+	gtk_container_add(GTK_CONTAINER(prefdialog), box);
+	gtk_widget_show(box);
+
+	label = gtk_label_new(_("All options take effect immediately unless otherwise noted."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	sep = gtk_hseparator_new();
+	gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 5);
+	gtk_widget_show(sep);
+
+	label = gtk_label_new(_("The permit/deny configuration will change between users,\n"
+				"and changes while you are signed off will not be saved."));
+	gtk_box_pack_start(GTK_BOX(box), label, FALSE, FALSE, 5);
+	gtk_widget_show(label);
+
+	hbox = gtk_hbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	vbox = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 5);
+	gtk_widget_show(vbox);
+
+	opt = deny_radio(_("Allow Anyone"), PERMIT_ALL, vbox, NULL);
+#if 0
+	/* This doesn't work because TOC doesn't have a PERMIT_BUDDY setting
+	 * and merging the two would be very difficult at best, most likely
+	 * impossible. If we can guarantee only Oscar than this is easy */
+	opt = deny_radio(_("Allow only users on Buddy List"), PERMIT_BUDDY, vbox, opt);
+#endif
+	opt = deny_radio(_("Allow only the users in \"Permit\""), PERMIT_SOME, vbox, opt);
+
+	vbox = gtk_vbox_new(FALSE, 0);
+	gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 5);
+	gtk_widget_show(vbox);
+
+	opt = deny_radio(_("Block all users"), PERMIT_NONE, vbox, opt);
+	opt = deny_radio(_("Block the users in \"Deny\""), DENY_SOME, vbox, opt);
+
+	xbox = gtk_scrolled_window_new(NULL, NULL);
+	gtk_box_pack_start(GTK_BOX(box), xbox, TRUE, TRUE, 5);
+	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(xbox),
+					GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+	gtk_widget_show(xbox);
+
+	permtree = gtk_tree_new();
+	build_permit_tree();
+	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(xbox), permtree);
+	gtk_signal_connect(GTK_OBJECT(permtree), "destroy", GTK_SIGNAL_FUNC(permdest), 0);
+	gtk_widget_show(permtree);
+
+	hbox = gtk_hbox_new(TRUE, 10);
+	gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 5);
+	gtk_widget_show(hbox);
+
+	button = picture_button(prefs, _("Add"), gnome_add_xpm);
+	gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(add_perm_callback), NULL);
+
+	button = picture_button(prefs, _("Remove"), gnome_remove_xpm);
+	gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 10);
+	gtk_signal_connect(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(do_del_perm), permtree);
+
+	gtk_widget_show(prefdialog);
+}
+
 static void convo_page()
 {
 	GtkWidget *parent;
@@ -341,8 +577,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Conversation Window Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -386,8 +620,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("IM Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -415,8 +647,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Chat Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -603,8 +833,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Chat Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -713,8 +941,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Font Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -796,8 +1022,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Sound Options"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -828,8 +1052,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Sound Events"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -902,6 +1124,12 @@
         rem_away_mess(NULL, a);
 }
 
+static void paldest(GtkWidget *m, gpointer n)
+{
+	gtk_widget_destroy(prefs_away_list);
+	prefs_away_list = NULL;
+}
+
 static void away_page()
 {
 	GtkWidget *parent;
@@ -919,8 +1147,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
-	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Away Messages"));
 	gtk_container_add(GTK_CONTAINER(parent), prefdialog);
@@ -941,6 +1167,7 @@
 
 	prefs_away_list = gtk_list_new();
 	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw), prefs_away_list);
+	gtk_signal_connect(GTK_OBJECT(prefs_away_list), "destroy", GTK_SIGNAL_FUNC(paldest), 0);
 	gtk_widget_show(prefs_away_list);
 
 	sw2 = gtk_scrolled_window_new(NULL, NULL);
@@ -1051,7 +1278,6 @@
 
 	parent = prefdialog->parent;
 	gtk_widget_destroy(prefdialog);
-	debugbutton = NULL;
 	prefs_away_list = NULL;
 
 	prefdialog = gtk_frame_new(_("Browser Options"));
@@ -1344,13 +1570,19 @@
 
 void prefs_build_buddy(GtkWidget *preftree)
 {
-	GtkCTreeNode *parent;
+	GtkCTreeNode *parent, *node;
 	char *text[1];
 
 	text[0] = _("Buddy List");
 	parent = gtk_ctree_insert_node(GTK_CTREE(preftree), NULL, NULL,
 					text, 5, NULL, NULL, NULL, NULL, 0, 1);
 	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), parent, buddy_page);
+
+	/* FIXME ! We shouldn't be showing this if we're not signed on */
+	text[0] = _("Permit/Deny");
+	node = gtk_ctree_insert_node(GTK_CTREE(preftree), parent, NULL,
+					text, 5, NULL, NULL, NULL, NULL, 0, 1);
+	gtk_ctree_node_set_row_data(GTK_CTREE(preftree), node, deny_page);
 }
 
 void prefs_build_convo(GtkWidget *preftree)
--- a/src/server.c	Tue Aug 15 00:04:14 2000 +0000
+++ b/src/server.c	Tue Aug 15 01:29:35 2000 +0000
@@ -378,78 +378,178 @@
 void serv_set_permit_deny()
 {
 	if (!USE_OSCAR) {
-	char buf[MSG_LEN];
-	int at;
-	GList *list;
-
-        if (permdeny == 1 || permdeny == 4) {
-        	g_snprintf(buf, sizeof(buf), "toc_add_deny");
-                sflap_send(buf, -1, TYPE_DATA);
-        } else {
-                g_snprintf(buf, sizeof(buf), "toc_add_permit");
-                sflap_send(buf, -1, TYPE_DATA);
-        }
-
+		char buf[MSG_LEN];
+		int at;
+		int cnt;
+		GList *list;
+		GList *mem;
+		struct buddy *b;
+		struct group *g;
 
-	if (permit) {
-		at = g_snprintf(buf, sizeof(buf), "toc_add_permit");
-		list = permit;
-		while(list) {
-	                at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data));
-	                list = list->next;
+		switch (permdeny) {
+		case PERMIT_ALL:
+			/* toc_add_permit current_user to go to permit mode,
+			   toc_add_deny <none> to deny none */
+			sprintf(buf, "toc_add_deny %s", current_user->username);
+			sflap_send(buf, -1, TYPE_DATA);
+			break;
+		case PERMIT_NONE:
+			/* toc_add_deny current_user to go to deny mode,
+			   toc_add_permit <none> to permit none */
+			sprintf(buf, "toc_add_permit %s", current_user->username);
+			sflap_send(buf, -1, TYPE_DATA);
+			break;
+		case PERMIT_SOME:
+			/* toc_add_permit <permit> */
+			/* if permit is empty this is the same as PERMIT_NONE */
+			if (permit) {
+				at = g_snprintf(buf, sizeof(buf), "toc_add_permit");
+				list = permit;
+				while (list) {
+					at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data));
+					list = list->next;
+				}
+				buf[at] = 0; /* is this necessary? */
+				sflap_send(buf, -1, TYPE_DATA);
+			} else {
+				sprintf(buf, "toc_add_deny %s", current_user->username);
+				sflap_send(buf, -1, TYPE_DATA);
+				sprintf(buf, "toc_add_permit");
+				sflap_send(buf, -1, TYPE_DATA);
+			}
+			break;
+		case DENY_SOME:
+			/* toc_add_deny <deny> */
+			/* if deny is empty this is the same as PERMIT_ALL */
+			if (deny) {
+				at = g_snprintf(buf, sizeof(buf), "toc_add_deny");
+				list = deny;
+				while (list) {
+					at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data));
+					list = list->next;
+				}
+				buf[at] = 0; /* is this necessary? */
+				sflap_send(buf, -1, TYPE_DATA);
+			} else {
+				sprintf(buf, "toc_add_permit %s", current_user->username);
+				sflap_send(buf, -1, TYPE_DATA);
+				sprintf(buf, "toc_add_deny");
+				sflap_send(buf, -1, TYPE_DATA);
+			}
+			break;
+		case PERMIT_BUDDY:
+			/* toc_add_permit <bud> */
+			/* if there are no buddies this is the same as PERMIT_NONE */
+			at = g_snprintf(buf, sizeof(buf), "toc_add_permit");
+			list = groups;
+			cnt = 0;
+			while (list) {
+				g = (struct group *)list->data;
+				mem = g->members;
+				while (mem) {
+					b = (struct buddy *)mem->data;
+					at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(b->name));
+					cnt++;
+					mem = mem->next;
+				}
+				list = list->next;
+			}
+			if (cnt) {
+				sflap_send(buf, -1, TYPE_DATA);
+			} else {
+				sprintf(buf, "toc_add_deny %s", current_user->username);
+				sflap_send(buf, -1, TYPE_DATA);
+				sprintf(buf, "toc_add_permit");
+				sflap_send(buf, -1, TYPE_DATA);
+			}
 		}
-		buf[at] = 0;
-		sflap_send(buf, -1, TYPE_DATA);
-	}
-
-	if (deny) {
-		at = g_snprintf(buf, sizeof(buf), "toc_add_deny");
-		list = deny;
-		while(list) {
-	                at += g_snprintf(&buf[at], sizeof(buf) - at, " %s", normalize(list->data));
-			list = list->next;
-		}
-		buf[at] = 0;
-		sflap_send(buf, -1, TYPE_DATA);
-	}
 	} else {
-	/* oscar requires us to do everyone at once (?) */
-	/* I think this code is OK now. */
-	char buf[BUF_LONG]; int at; GList *list, *grp, *bud;
-	if (permdeny == 3) { /* Permit Some : Only people on buddy list and
-				on permit list */
-		struct group *g; struct buddy *b;
-		at = 0; list = permit; grp = groups;
-		debug_print("Setting permit list...\n");
-		while (grp) {
-			g = (struct group *)grp->data;
-			bud = g->members;
-			while (bud) {
-				b = (struct buddy *)bud->data;
-				at += g_snprintf(&buf[at], sizeof(buf) - at,
-					"%s&", b->name);
-				bud = bud->next;
+		int at;
+		GList *list;
+		GList *mem;
+		struct buddy *b;
+		struct group *g;
+		char buf[MSG_LEN];
+		int cnt;
+
+		switch (permdeny) {
+		/* aim_bos_changevisibility(gaim_sess, gaim_conn, type, list) */
+		case PERMIT_ALL:
+			/* AIM_VISIBILITYCHANGE_DENYADD current_user */
+			aim_bos_changevisibility(gaim_sess, gaim_conn,
+			   AIM_VISIBILITYCHANGE_DENYADD, current_user->username);
+			break;
+		case PERMIT_NONE:
+			/* AIM_VISIBILITY_PERMITADD current_user */
+			aim_bos_changevisibility(gaim_sess, gaim_conn,
+			   AIM_VISIBILITYCHANGE_PERMITADD, current_user->username);
+			break;
+		case PERMIT_SOME:
+			/* PERMIT <permit> */
+			/* if permit is empty this is the same as PERMIT_NONE */
+			if (permit) {
+				at = 0;
+				list = permit;
+				while (list) {
+					at += g_snprintf(&buf[at], sizeof(buf) - at, "%s", list->data);
+					list = list->next;
+					if (list)
+						at += g_snprintf(&buf[at], sizeof(buf) - at, "&");
+				}
+				aim_bos_changevisibility(gaim_sess, gaim_conn,
+				   AIM_VISIBILITYCHANGE_PERMITADD, buf);
+			} else {
+				aim_bos_changevisibility(gaim_sess, gaim_conn,
+				   AIM_VISIBILITYCHANGE_PERMITADD, current_user->username);
 			}
-			grp = grp->next;
+			break;
+		case DENY_SOME:
+			/* DENY <deny> */
+			/* if deny is empty this is the same as PERMIT_ALL */
+			if (deny) {
+				at = 0;
+				list = permit;
+				while (list) {
+					at += g_snprintf(&buf[at], sizeof(buf) - at, "%s", list->data);
+					list = list->next;
+					if (list)
+						at += g_snprintf(&buf[at], sizeof(buf) - at, "&");
+				}
+				aim_bos_changevisibility(gaim_sess, gaim_conn,
+				   AIM_VISIBILITYCHANGE_DENYADD, buf);
+			} else {
+				aim_bos_changevisibility(gaim_sess, gaim_conn,
+				   AIM_VISIBILITYCHANGE_DENYADD, current_user->username);
+			}
+			break;
+		case PERMIT_BUDDY:
+			/* PERMIT <bud> */
+			/* if there are no buddies this is the same as PERMIT_NONE */
+			at = 0;
+			list = groups;
+			cnt = 0;
+			while (list) {
+				g = (struct group *)list->data;
+				mem = g->members;
+				while (mem) {
+					b = (struct buddy *)mem->data;
+					if (at)
+						at += g_snprintf(&buf[at], sizeof(buf) - at, "&");
+					at += g_snprintf(&buf[at], sizeof(buf) - at, "%s", b->name);
+					cnt++;
+					mem = mem->next;
+				}
+				list = list->next;
+			}
+			if (cnt) {
+				aim_bos_changevisibility(gaim_sess, gaim_conn,
+				   AIM_VISIBILITYCHANGE_PERMITADD, buf);
+			} else {
+				aim_bos_changevisibility(gaim_sess, gaim_conn,
+				   AIM_VISIBILITYCHANGE_PERMITADD, current_user->username);
+			}
+			break;
 		}
-		while (list) {
-			at += g_snprintf(&buf[at], sizeof(buf) - at, "%s&",
-					(char *)list->data);
-			list = list->next;
-		}
-		aim_bos_changevisibility(gaim_sess, gaim_conn,
-					AIM_VISIBILITYCHANGE_PERMITADD, buf);
-	} else { /* Deny Some : Deny people on deny list */
-		list = deny; at = 0;
-		if (list == NULL) return;
-		while (list) {
-			at += g_snprintf(&buf[at], sizeof(buf) - at, "%s&",
-					(char *)list->data);
-			list = list->next;
-		}
-		aim_bos_changevisibility(gaim_sess, gaim_conn,
-					AIM_VISIBILITYCHANGE_DENYADD, buf);
-	}
 	}
 }
 
--- a/src/toc.c	Tue Aug 15 00:04:14 2000 +0000
+++ b/src/toc.c	Tue Aug 15 01:29:35 2000 +0000
@@ -829,38 +829,40 @@
 
 void toc_build_config(char *s, int len)
 {
-    GList *grp = groups;
-    GList *mem;
-    struct group *g;
-        struct buddy *b;
-        GList *plist = permit;
-        GList *dlist = deny;
+	GList *grp = groups;
+	GList *mem;
+	struct group *g;
+	struct buddy *b;
+	GList *plist = permit;
+	GList *dlist = deny;
 
-    int pos=0;
+	int pos=0;
+
+	if (!permdeny)
+		permdeny = 1;
 
-    if (!permdeny)
-                permdeny = 1;
-    pos += g_snprintf(&s[pos], len - pos, "m %d\n", permdeny);
-    while(grp) {
-        g = (struct group *)grp->data;
-        pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name);
-        mem = g->members;
-        while(mem) {
-            b = (struct buddy *)mem->data;
-            pos += g_snprintf(&s[pos], len - pos, "b %s\n", b->name);
-            mem = mem->next;
-        }
-        grp = grp ->next;
-        }
-        while(plist) {
-                pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data);
-                plist=plist->next;
+	pos += g_snprintf(&s[pos], len - pos, "m %d\n", permdeny);
+	while(grp) {
+		g = (struct group *)grp->data;
+		pos += g_snprintf(&s[pos], len - pos, "g %s\n", g->name);
+		mem = g->members;
+		while(mem) {
+			b = (struct buddy *)mem->data;
+			pos += g_snprintf(&s[pos], len - pos, "b %s\n", b->name);
+			mem = mem->next;
+		}
+		grp = grp ->next;
+	}
 
-        }
-        while(dlist) {
-                pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data);
-                dlist=dlist->next;
-        }
+	while(plist) {
+		pos += g_snprintf(&s[pos], len - pos, "p %s\n", (char *)plist->data);
+		plist=plist->next;
+	}
+
+	while(dlist) {
+		pos += g_snprintf(&s[pos], len - pos, "d %s\n", (char *)dlist->data);
+		dlist=dlist->next;
+	}
 }
 
 void parse_toc_buddy_list(char *config, int from_do_import)