Per mailbox identity patch



Hi all,

I've done half a patch for setting a per mailbox default identity fro use when 
replying to messages.  Half a patch because its only the basic mechanism and 
no UI changes.  I've tested it by manually editing ~/.gnome/balsa, so far it 
works OK for me.

Now all I need is a UI for it (unless there are any volunteers - I'm half 
serious here, I'm on holiday for about 6 days after today ;)

Brian
Index: libbalsa/mailbox.c
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/mailbox.c,v
retrieving revision 1.195
diff -u -r1.195 mailbox.c
--- libbalsa/mailbox.c	2002/03/31 22:38:01	1.195
+++ libbalsa/mailbox.c	2002/04/10 12:04:58
@@ -285,6 +285,8 @@
 #ifdef BALSA_SHOW_ALL
     mailbox->filters=NULL;
 #endif
+
+    mailbox->identity=NULL;
 }
 
 /* libbalsa_mailbox_destroy:
@@ -315,6 +317,9 @@
 
     if (GTK_OBJECT_CLASS(parent_class)->destroy)
 	(*GTK_OBJECT_CLASS(parent_class)->destroy) (GTK_OBJECT(object));
+
+    g_free(mailbox->identity);
+    mailbox->identity = NULL;
 }
 
 /* Create a new mailbox by loading it from a config entry... */
@@ -590,6 +595,8 @@
     }
     g_free(mailbox->config_prefix);
     mailbox->config_prefix = g_strdup(prefix);
+
+    gnome_config_set_string("Identity", mailbox->identity);
 }
 
 static void
@@ -616,6 +623,9 @@
             libbalsa_address_new_from_string(address);
     }
     g_free(address);
+
+    g_free(mailbox->identity);
+    mailbox->identity = gnome_config_get_string("Identity=Default");
 }
 
 /* libbalsa_mailbox_link_message:
Index: libbalsa/mailbox.h
===================================================================
RCS file: /cvs/gnome/balsa/libbalsa/mailbox.h,v
retrieving revision 1.83
diff -u -r1.83 mailbox.h
--- libbalsa/mailbox.h	2002/03/31 22:38:01	1.83
+++ libbalsa/mailbox.h	2002/04/10 12:04:58
@@ -100,6 +100,9 @@
     /* Associated filters (struct mailbox_filter) */
     GSList * filters;
 #endif
+
+    /* Default identity associated with the mailbox */
+    gchar *identity;
 };
 
 struct _LibBalsaMailboxClass {
Index: src/sendmsg-window.c
===================================================================
RCS file: /cvs/gnome/balsa/src/sendmsg-window.c,v
retrieving revision 1.348
diff -u -r1.348 sendmsg-window.c
--- src/sendmsg-window.c	2002/04/05 09:00:01	1.348
+++ src/sendmsg-window.c	2002/04/10 12:04:59
@@ -2471,6 +2471,36 @@
 
 
 /* 
+ * set_identity_from_mailbox
+ * 
+ * Attempt to determine the default identity from the mailbox containing
+ * the message.
+ **/
+static gboolean
+set_identity_from_mailbox(BalsaSendmsg* msg)
+{
+    gchar *identity;
+    LibBalsaMessage *message = msg->orig_message;
+    LibBalsaIdentity* ident;
+    GList *ilist;
+
+    if( message && message->mailbox && balsa_app.identities) {
+	identity = message->mailbox->identity;
+	for (ilist = balsa_app.identities;
+	     ilist != NULL;
+	     ilist = g_list_next(ilist)) {
+	    ident = LIBBALSA_IDENTITY(ilist->data);
+	    if (!g_strcasecmp(identity, ident->identity_name)) {
+		msg->ident = ident;
+		return TRUE;
+		}
+	    }
+        }
+
+    return FALSE; /* use default */
+}
+
+/* 
  * guess_identity
  * 
  * Attempt to determine if a message should be associated with a
@@ -2655,6 +2685,9 @@
 	list = g_list_prepend(
 	    list, get_tool_widget(window, 1, main_toolbar_spell_disable[i]));
     msg->spell_check_disable_list = list;
+
+    /* Set up the default identity */
+    set_identity_from_mailbox(msg);
 
     /* Get the identity from the To: field of the original message */
     guess_identity(msg);


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