[Composer] code cleanup

Frederic Crozat <[email protected]>
Newsgroups gmane.comp.gnome.evolution.patches
Organization Mandriva
Message-ID <[email protected]>
Hi,

while investigating bug from one of our customers regarding Cc headers,
I wrote this code cleanup patch, which factorize code used by
e_msg_composer_hdrs_get_to/cc/bcc (so, if code need to be fixed in the
future, it won't need to be fixed three times ;)

-- 
Frederic Crozat <[email protected]>
Mandriva

_______________________________________________
Evolution-patches mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/evolution-patches
evolution-composer-factorize.patch (text/x-patch, 3.3 KB)
Index: composer/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/composer/ChangeLog,v
retrieving revision 1.732
diff -u -p -r1.732 ChangeLog
--- composer/ChangeLog	30 Jan 2006 09:51:17 -0000	1.732
+++ composer/ChangeLog	6 Feb 2006 17:07:48 -0000
@@ -1,3 +1,9 @@
+2006-02-06  Frederic Crozat  <[email protected]>
+
+	* e-msg-composer-hdrs.c: (e_msg_composer_hdrs_get_internal),
+	(e_msg_composer_hdrs_get_to), (e_msg_composer_hdrs_get_cc),
+	(e_msg_composer_hdrs_get_bcc): Factorize some code.
+
 2006-01-24  Kjartan Maraas  <[email protected]>
 
 	* e-msg-composer-hdrs.c: (account_removed_cb),
Index: composer/e-msg-composer-hdrs.c
===================================================================
RCS file: /cvs/gnome/evolution/composer/e-msg-composer-hdrs.c,v
retrieving revision 1.148
diff -u -p -r1.148 e-msg-composer-hdrs.c
--- composer/e-msg-composer-hdrs.c	30 Jan 2006 09:51:18 -0000	1.148
+++ composer/e-msg-composer-hdrs.c	6 Feb 2006 17:07:48 -0000
@@ -1446,8 +1446,8 @@ destination_list_to_destv (GList *destin
 	return destv;
 }
 
-EDestination **
-e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs)
+static EDestination **
+e_msg_composer_hdrs_get_internal (EMsgComposerHdrs *hdrs, ENameSelectorEntry *entry)
 {
 	EDestinationStore *destination_store;
 	GList *destinations;
@@ -1455,8 +1455,7 @@ e_msg_composer_hdrs_get_to (EMsgComposer
 	
 	g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
 
-	destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (
-		 hdrs->priv->to.entry));
+	destination_store = e_name_selector_entry_peek_destination_store (entry);
 	destinations = e_destination_store_list_destinations (destination_store);
 
 	destv = destination_list_to_destv (destinations);
@@ -1466,41 +1465,21 @@ e_msg_composer_hdrs_get_to (EMsgComposer
 }
 
 EDestination **
-e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs)
+e_msg_composer_hdrs_get_to (EMsgComposerHdrs *hdrs)
 {
-	EDestinationStore *destination_store;
-	GList *destinations;
-	EDestination **destv = NULL;
-	
-	g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
-
-	destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (
-		 hdrs->priv->cc.entry));
-	destinations = e_destination_store_list_destinations (destination_store);
-
-	destv = destination_list_to_destv (destinations);
+	e_msg_composer_hdrs_get_internal (hdrs, E_NAME_SELECTOR_ENTRY (hdrs->priv->to.entry));
+}
 
-	g_list_free (destinations);
-	return destv;
+EDestination **
+e_msg_composer_hdrs_get_cc (EMsgComposerHdrs *hdrs)
+{
+	e_msg_composer_hdrs_get_internal (hdrs, E_NAME_SELECTOR_ENTRY (hdrs->priv->cc.entry));
 }
 
 EDestination **
 e_msg_composer_hdrs_get_bcc (EMsgComposerHdrs *hdrs)
 {
-	EDestinationStore *destination_store;
-	GList *destinations;
-	EDestination **destv = NULL;
-	
-	g_return_val_if_fail (E_IS_MSG_COMPOSER_HDRS (hdrs), NULL);
-
-	destination_store = e_name_selector_entry_peek_destination_store (E_NAME_SELECTOR_ENTRY (
-		 hdrs->priv->bcc.entry));
-	destinations = e_destination_store_list_destinations (destination_store);
-
-	destv = destination_list_to_destv (destinations);
-
-	g_list_free (destinations);
-	return destv;
+	e_msg_composer_hdrs_get_internal (hdrs, E_NAME_SELECTOR_ENTRY (hdrs->priv->bcc.entry));
 }
 
 EDestination **
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.