balsa



Oh my, i like balsa :)
  I wanted an option to enable/disable the servers that were checked
for messages,and an option to delete received messages off the server
so i wrote this code for that. It gives a nice `server options` frame
with some check buttons inside.
  I mostly duplicated the code for the existing check button (which appeared
overnight:) ), except for the create_pop_mailbox_page() function, where
i construct things differently. I make a vbox which is the returned object,
and i pack a table, and then a frame into that. And i pack the check buttons
into the frame. At least i think that is how it is working. If anyone can
correct me on how this should be done, please do :)
 The diffs are included here for anyone that wants to try nifty pop 
server options for themselves.
 Pavlov said the pop3 functionality of balsa wasn't well tested out yet,
so i'm using this with multiple pop3 servers and tons of messages from lists.
 I don't think i have any imap servers i can use, so i can't play around there.

 Harley Waagmeester
 verzee on #gimp
 linux@netamerica.com

--- libbalsa/mailbox.h	Thu Oct 15 16:31:29 1998
+++ ../balsa-mine/libbalsa/mailbox.h	Mon Oct 19 06:29:47 1998
@@ -148,6 +148,7 @@
     gchar *passwd;
     gchar *server;
     gboolean check;
+    gboolean delete;
   };
 
 
--- libbalsa/mailbox.c	Sat Oct 17 08:15:35 1998
+++ ../balsa-mine/libbalsa/mailbox.c	Mon Oct 19 08:07:31 1998
@@ -209,6 +209,10 @@
       mailbox = list->data;
       if (MAILBOX_POP3 (mailbox)->check)
 	{
+	  if (MAILBOX_POP3 (mailbox)->delete)
+	    set_option(OPTPOPDELETE);
+	  else
+	    unset_option(OPTPOPDELETE);
 	  PopHost = g_strdup (MAILBOX_POP3 (mailbox)->server);
 	  PopPort = 110;
 	  PopPass = g_strdup (MAILBOX_POP3 (mailbox)->passwd);
--- src/save-restore.c	Sat Oct 17 16:15:56 1998
+++ ../balsa-mine/src/save-restore.c	Mon Oct 19 06:36:19 1998
@@ -216,6 +216,12 @@
 	pl_dict_add_str_str (mbox_dict, "Check", tmp);
       }
 
+      {
+	char tmp[32];
+	snprintf (tmp, sizeof (tmp), "%d", MAILBOX_POP3 (mailbox)->delete);
+	pl_dict_add_str_str (mbox_dict, "Delete", tmp);
+      }
+
       break;
 
     case MAILBOX_IMAP:
@@ -485,6 +491,11 @@
 	MAILBOX_POP3 (mailbox)->check = FALSE;
       else
         MAILBOX_POP3 (mailbox)->check = atol (field);
+
+      if ((field = pl_dict_get_str (mbox, "Delete")) == NULL)
+	MAILBOX_POP3 (mailbox)->delete = FALSE;
+      else
+        MAILBOX_POP3 (mailbox)->delete = atol (field);
 
       balsa_app.inbox_input =
 	g_list_append (balsa_app.inbox_input, mailbox);
--- src/mailbox-conf.c	Mon Oct 19 09:37:13 1998
+++ ../balsa-mine/src/mailbox-conf.c	Mon Oct 19 09:33:53 1998
@@ -78,6 +78,7 @@
     GtkWidget *pop_username;
     GtkWidget *pop_password;
     GtkWidget *pop_check;
+    GtkWidget *pop_delete;
 
   };
 
@@ -357,6 +358,7 @@
 	  gtk_entry_set_text (GTK_ENTRY (mcw->pop_username), MAILBOX_POP3 (mailbox)->user);
 	  gtk_entry_set_text (GTK_ENTRY (mcw->pop_password), MAILBOX_POP3 (mailbox)->passwd);
 	  gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (mcw->pop_check), MAILBOX_POP3 (mailbox)->check);
+	  gtk_toggle_button_set_state (GTK_TOGGLE_BUTTON (mcw->pop_delete), MAILBOX_POP3 (mailbox)->delete);
 	}
       gtk_notebook_set_page (GTK_NOTEBOOK (mcw->notebook), MC_PAGE_POP3);
       break;
@@ -415,6 +417,7 @@
       MAILBOX_POP3 (mailbox)->passwd = g_strdup (gtk_entry_get_text (GTK_ENTRY (mcw->pop_password)));
       MAILBOX_POP3 (mailbox)->server = g_strdup (gtk_entry_get_text (GTK_ENTRY (mcw->pop_server)));
       MAILBOX_POP3 (mailbox)->check = GTK_TOGGLE_BUTTON (mcw->pop_check)->active;
+      MAILBOX_POP3 (mailbox)->delete = GTK_TOGGLE_BUTTON (mcw->pop_delete)->active;
 
       config_mailbox_update (mailbox, old_mbox_name);
       break;
@@ -506,6 +509,7 @@
       MAILBOX_POP3 (mailbox)->passwd = g_strdup (gtk_entry_get_text (GTK_ENTRY (mcw->pop_password)));
       MAILBOX_POP3 (mailbox)->server = g_strdup (gtk_entry_get_text (GTK_ENTRY (mcw->pop_server)));
       MAILBOX_POP3 (mailbox)->check = GTK_TOGGLE_BUTTON (mcw->pop_check)->active;
+      MAILBOX_POP3 (mailbox)->delete = GTK_TOGGLE_BUTTON (mcw->pop_delete)->active;
       balsa_app.inbox_input = g_list_append (balsa_app.inbox_input, mailbox);
       config_mailbox_add (mailbox, NULL);
       add_mailboxes_for_checking (mailbox);
@@ -675,6 +679,7 @@
   return vbox;
 }
 
+#if 0
 static GtkWidget *
 create_pop_mailbox_page (void)
 {
@@ -761,6 +766,91 @@
 
   return return_widget;
 }
+#endif
+
+static GtkWidget *
+create_pop_mailbox_page (void)
+{
+
+  GtkWidget *return_widget;
+  GtkWidget *table;
+  GtkWidget *label;
+  GtkWidget *frame;
+  GtkWidget *vbox;
+
+  return_widget = gtk_vbox_new (FALSE, 0);
+
+  table = gtk_table_new (4, 2, FALSE);
+  gtk_box_pack_start (GTK_BOX (return_widget), table, FALSE, FALSE, 0);
+
+  /* mailbox name */
+
+  label = gtk_label_new ("Mailbox Name:");
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+		    GTK_FILL, GTK_FILL,
+		    10, 10);
+  mcw->pop_mailbox_name = gtk_entry_new ();
+  gtk_table_attach (GTK_TABLE (table), mcw->pop_mailbox_name, 1, 2, 0, 1,
+		    GTK_EXPAND | GTK_FILL, GTK_FILL,
+		    0, 10);
+
+  /* pop server */
+
+  label = gtk_label_new ("Server:");
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
+		    GTK_FILL, GTK_FILL,
+		    10, 10);
+  mcw->pop_server = gtk_entry_new ();
+  gtk_table_attach (GTK_TABLE (table), mcw->pop_server, 1, 2, 1, 2,
+		    GTK_EXPAND | GTK_FILL, GTK_FILL,
+		    0, 10);
+  gtk_entry_append_text (GTK_ENTRY (mcw->pop_server), "localhost");
+
+  /* username  */
+
+  label = gtk_label_new ("Username:");
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
+		    GTK_FILL, GTK_FILL,
+		    10, 10);
+  mcw->pop_username = gtk_entry_new ();
+  gtk_table_attach (GTK_TABLE (table), mcw->pop_username, 1, 2, 3, 4,
+		    GTK_EXPAND | GTK_FILL, GTK_FILL,
+		    0, 10);
+  gtk_entry_append_text (GTK_ENTRY (mcw->pop_username), g_get_user_name ());
+
+  /* password field */
+
+  label = gtk_label_new ("Password:");
+  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
+  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
+		    GTK_FILL, GTK_FILL,
+		    10, 10);
+  mcw->pop_password = gtk_entry_new ();
+  gtk_table_attach (GTK_TABLE (table), mcw->pop_password, 1, 2, 4, 5,
+		    GTK_EXPAND | GTK_FILL, GTK_FILL,
+		    0, 10);
+  gtk_entry_set_visibility (GTK_ENTRY (mcw->pop_password), FALSE);
+
+  /* Server Options */
+
+  frame = gtk_frame_new("Server Options");
+  gtk_box_pack_start (GTK_BOX (return_widget), frame, FALSE, FALSE, 5);
+
+  vbox = gtk_vbox_new (FALSE, 0);
+  gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (vbox));
+
+  mcw->pop_check = gtk_check_button_new_with_label ("Add this pop3 server to the list of active servers.");
+  gtk_box_pack_start (GTK_BOX (vbox), mcw->pop_check, TRUE, TRUE, 1);
+
+  mcw->pop_delete = gtk_check_button_new_with_label ("Delete received messages from the pop3 server.");
+  gtk_box_pack_start (GTK_BOX (vbox), mcw->pop_delete, TRUE, TRUE, 1);
+
+  return return_widget;
+}
+
 
 static GtkWidget *
 create_imap_mailbox_page (void)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]