[evolution-patches] 68459, newsgroup followup-to ignored




I think this does what it should

includes cleanups to make the interface partly more sane.  camelnntpaddress should proably be used throughout e-msg-composer, but this is easier for now

? camel/a.out
? camel/camel-mime-tables.c
? camel/testurl.c
? camel/tests/folder/test10
? camel/tests/folder/test11
? camel/tests/message/test4
? camel/tests/mime-filter/test-tohtml
? camel/tests/misc/test2
? camel/tests/misc/url-scan
Index: camel/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/ChangeLog,v
retrieving revision 1.2431
diff -u -p -r1.2431 ChangeLog
--- camel/ChangeLog	15 Feb 2005 11:12:51 -0000	1.2431
+++ camel/ChangeLog	24 Feb 2005 07:36:02 -0000
@@ -1,3 +1,10 @@
+2005-02-24  Not Zed  <NotZed Ximian com>
+
+	** See bug #68459
+
+	* camel-nntp-address.[ch]: cameladdress implementation for list of
+	newsgroups.
+
 2005-02-11  Radek Doulik  <rodo novell com>
 
 	* camel-filter-search.c (junk_test): use camel debug
Index: camel/Makefile.am
===================================================================
RCS file: /cvs/gnome/evolution-data-server/camel/Makefile.am,v
retrieving revision 1.207
diff -u -p -r1.207 Makefile.am
--- camel/Makefile.am	6 Jan 2005 21:18:30 -0000	1.207
+++ camel/Makefile.am	24 Feb 2005 07:36:02 -0000
@@ -171,6 +171,7 @@ libcamel_1_2_la_SOURCES = 				\
 	camel-multipart-signed.c		\
 	camel-multipart.c			\
 	camel-net-utils.c			\
+	camel-nntp-address.c			\
 	camel-object.c				\
 	camel-operation.c			\
 	camel-partition-table.c			\
@@ -236,6 +237,7 @@ libcamelinclude_HEADERS =			\
 	camel-multipart-signed.h		\
 	camel-multipart.h			\
 	camel-net-utils.h			\
+	camel-nntp-address.h			\
 	camel-object.h				\
 	camel-operation.h			\
 	camel-partition-table.h			\
Index: camel/camel-nntp-address.c
===================================================================
RCS file: camel/camel-nntp-address.c
diff -N camel/camel-nntp-address.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ camel/camel-nntp-address.c	24 Feb 2005 07:36:02 -0000
@@ -0,0 +1,210 @@
+/*
+ * Copyright (C) 2005 Novell Inc.
+ *
+ * Authors: Michael Zucchi <notzed ximian com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "camel-mime-utils.h"
+#include "camel-nntp-address.h"
+
+#define d(x)
+
+static int    nntp_decode		(CamelAddress *, const char *raw);
+static char * nntp_encode		(CamelAddress *);
+static int    nntp_cat		(CamelAddress *dest, const CamelAddress *source);
+static void   nntp_remove		(CamelAddress *, int index);
+
+static void camel_nntp_address_class_init (CamelNNTPAddressClass *klass);
+static void camel_nntp_address_init       (CamelNNTPAddress *obj);
+
+static CamelAddressClass *camel_nntp_address_parent;
+
+struct _address {
+	char *name;
+	char *address;
+};
+
+static void
+camel_nntp_address_class_init(CamelNNTPAddressClass *klass)
+{
+	CamelAddressClass *address = (CamelAddressClass *) klass;
+
+	camel_nntp_address_parent = CAMEL_ADDRESS_CLASS(camel_type_get_global_classfuncs(camel_address_get_type()));
+
+	address->decode = nntp_decode;
+	address->encode = nntp_encode;
+	address->unformat = nntp_decode;
+	address->format = nntp_encode;
+	address->remove = nntp_remove;
+	address->cat = nntp_cat;
+}
+
+static void
+camel_nntp_address_init(CamelNNTPAddress *obj)
+{
+}
+
+CamelType
+camel_nntp_address_get_type(void)
+{
+	static CamelType type = CAMEL_INVALID_TYPE;
+	
+	if (type == CAMEL_INVALID_TYPE) {
+		type = camel_type_register(camel_address_get_type(), "CamelNNTPAddress",
+					   sizeof (CamelNNTPAddress),
+					   sizeof (CamelNNTPAddressClass),
+					   (CamelObjectClassInitFunc) camel_nntp_address_class_init,
+					   NULL,
+					   (CamelObjectInitFunc) camel_nntp_address_init,
+					   NULL);
+	}
+	
+	return type;
+}
+
+/* since newsgropus are 7bit ascii, decode/unformat are the same */
+static int
+nntp_decode(CamelAddress *a, const char *raw)
+{
+	struct _camel_header_newsgroup *ha, *n;
+	int count = a->addresses->len;
+
+	ha = camel_header_newsgroups_decode(raw);
+	if (ha) {
+		for (n = ha;n;n=n->next)
+			camel_nntp_address_add((CamelNNTPAddress *)a, n->newsgroup);
+		camel_header_newsgroups_free(ha);
+	}
+	
+	return a->addresses->len - count;
+}
+
+/* since newsgropus are 7bit ascii, encode/format are the same */
+static char *
+nntp_encode(CamelAddress *a)
+{
+	int i;
+	GString *out;
+	char *ret;
+	
+	if (a->addresses->len == 0)
+		return NULL;
+	
+	out = g_string_new("");
+	
+	for (i = 0;i < a->addresses->len; i++) {
+		if (i != 0)
+			g_string_append(out, ", ");
+
+		g_string_append(out, g_ptr_array_index(a->addresses, i));
+	}
+	
+	ret = out->str;
+	g_string_free(out, FALSE);
+	
+	return ret;
+}
+
+static int
+nntp_cat (CamelAddress *dest, const CamelAddress *source)
+{
+	int i;
+
+	g_assert(CAMEL_IS_NNTP_ADDRESS(source));
+
+	for (i=0;i<source->addresses->len;i++)
+		camel_nntp_address_add((CamelNNTPAddress *)dest, g_ptr_array_index(source->addresses, i));
+
+	return i;
+}
+
+static void
+nntp_remove	(CamelAddress *a, int index)
+{
+	if (index < 0 || index >= a->addresses->len)
+		return;
+	
+	g_free(g_ptr_array_index(a->addresses, index));
+	g_ptr_array_remove_index(a->addresses, index);
+}
+
+/**
+ * camel_nntp_address_new:
+ *
+ * Create a new CamelNNTPAddress object.
+ * 
+ * Return value: A new CamelNNTPAddress object.
+ **/
+CamelNNTPAddress *
+camel_nntp_address_new (void)
+{
+	CamelNNTPAddress *new = CAMEL_NNTP_ADDRESS(camel_object_new(camel_nntp_address_get_type()));
+	return new;
+}
+
+/**
+ * camel_nntp_address_add:
+ * @a: nntp address object
+ * @name: 
+ * 
+ * Add a new nntp address to the address object.  Duplicates are not added twice.
+ * 
+ * Return value: Index of added entry, or existing matching entry.
+ **/
+int
+camel_nntp_address_add (CamelNNTPAddress *a, const char *name)
+{
+	int index, i;
+
+	g_assert(CAMEL_IS_NNTP_ADDRESS(a));
+
+	index = ((CamelAddress *)a)->addresses->len;
+	for (i=0;i<index;i++)
+		if (!strcmp(g_ptr_array_index(((CamelAddress *)a)->addresses, i), name))
+			return i;
+
+	g_ptr_array_add(((CamelAddress *)a)->addresses, g_strdup(name));
+
+	return index;
+}
+
+/**
+ * camel_nntp_address_get:
+ * @a: nntp address object
+ * @index: address's array index
+ * @addressp: Holder for the returned address, or NULL, if not required.
+ * 
+ * Get the address at @index.
+ * 
+ * Return value: TRUE if such an address exists, or FALSE otherwise.
+ **/
+gboolean
+camel_nntp_address_get (const CamelNNTPAddress *a, int index, const char **namep)
+{
+	g_assert(CAMEL_IS_NNTP_ADDRESS(a));
+
+	if (index < 0 || index >= ((CamelAddress *)a)->addresses->len)
+		return FALSE;
+
+	if (namep)
+		*namep = g_ptr_array_index( ((CamelAddress *)a)->addresses, index);
+
+	return TRUE;
+}
Index: camel/camel-nntp-address.h
===================================================================
RCS file: camel/camel-nntp-address.h
diff -N camel/camel-nntp-address.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ camel/camel-nntp-address.h	24 Feb 2005 07:36:02 -0000
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2005 Novell Inc.
+ *
+ * Authors: Michael Zucchi <notzed ximian com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef _CAMEL_NNTP_ADDRESS_H
+#define _CAMEL_NNTP_ADDRESS_H
+
+#ifdef __cplusplus
+extern "C" {
+#pragma }
+#endif /* __cplusplus */
+
+#include <camel/camel-address.h>
+
+#define CAMEL_NNTP_ADDRESS(obj)         CAMEL_CHECK_CAST (obj, camel_nntp_address_get_type (), CamelNNTPAddress)
+#define CAMEL_NNTP_ADDRESS_CLASS(klass) CAMEL_CHECK_CLASS_CAST (klass, camel_nntp_address_get_type (), CamelNNTPAddressClass)
+#define CAMEL_IS_NNTP_ADDRESS(obj)      CAMEL_CHECK_TYPE (obj, camel_nntp_address_get_type ())
+
+typedef struct _CamelNNTPAddress CamelNNTPAddress;
+typedef struct _CamelNNTPAddressClass CamelNNTPAddressClass;
+
+struct _CamelNNTPAddress {
+	CamelAddress parent;
+
+	struct _CamelNNTPAddressPrivate *priv;
+};
+
+struct _CamelNNTPAddressClass {
+	CamelAddressClass parent_class;
+};
+
+CamelType		camel_nntp_address_get_type	(void);
+CamelNNTPAddress   *camel_nntp_address_new	(void);
+
+int			camel_nntp_address_add	(CamelNNTPAddress *, const char *);
+gboolean		camel_nntp_address_get	(const CamelNNTPAddress *, int, const char **);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* ! _CAMEL_NNTP_ADDRESS_H */
? mail/GNOME_Evolution_Mail.oaf
? mail/GNOME_Evolution_Mail.oafinfo
? mail/Mail-common.c
? mail/Mail-skels.c
? mail/Mail-stubs.c
? mail/Mail.h
? mail/Mailer-common.c
? mail/Mailer-skels.c
? mail/Mailer-stubs.c
? mail/Mailer.h
? mail/a
? mail/a.diff
? mail/a.out
? mail/a.txt
? mail/all.txt
? mail/b
? mail/blah.c
? mail/blah.ps
? mail/changes.diff
? mail/conf.keys
? mail/day.diff
? mail/diff
? mail/e-plugin.html
? mail/econf.h
? mail/em-message-view.h
? mail/em-security-info.c
? mail/em-store-view.c
? mail/evolution-mail
? mail/evolution-mail-ops.log
? mail/evolution-mbox-upgrade
? mail/f.diff
? mail/fix.ed
? mail/foo
? mail/hide-empty.diff
? mail/html.diff
? mail/lockdown.txt
? mail/m.diff
? mail/mail-config.c.save
? mail/mail-config.evolution
? mail/mail-search.gladep
? mail/mail-security.gladep
? mail/mail-send-recv.c.save
? mail/mail.diff
? mail/map.sed
? mail/message-list.c.save
? mail/ml.diff
? mail/old
? mail/out
? mail/output.ps
? mail/plugins
? mail/search-types.xml
? mail/store_change.diff
? mail/subscribe-dialog-new.c
? mail/subscribe-dialog.c.new
? mail/subscribe-dialog.glade.backup
? mail/subscribe-dialog.glade.save
? mail/subscribe-dialog.gladep
? mail/test-mt
? mail/today-1.diff
? mail/today-2.diff
? mail/today-3.diff
? mail/today-4.diff
? mail/today-5.diff
? mail/today.diff
? mail/typescript
? mail/week.diff
? mail/default/zh_CN/Makefile
? mail/default/zh_CN/Makefile.in
? mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.oaf
? mail/importers/GNOME_Evolution_Mail_Elm_Intelligent_Importer.oaf.in
? mail/importers/GNOME_Evolution_Mail_Mbox_Importer.oaf
? mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.oaf
? mail/importers/GNOME_Evolution_Mail_Netscape_Intelligent_Importer.oaf.in
? mail/importers/GNOME_Evolution_Mail_Outlook_Importer.oaf
? mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.oaf
? mail/importers/GNOME_Evolution_Mail_Pine_Intelligent_Importer.oaf.in
? mail/importers/am.diff
? mail/importers/b
? mail/importers/elm-importer.c.new
? mail/importers/elm.ps
? mail/importers/im.diff
Index: mail/ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/mail/ChangeLog,v
retrieving revision 1.3589
diff -u -p -r1.3589 ChangeLog
--- mail/ChangeLog	24 Feb 2005 02:20:32 -0000	1.3589
+++ mail/ChangeLog	24 Feb 2005 07:36:16 -0000
@@ -1,3 +1,12 @@
+2005-02-24  Not Zed  <NotZed Ximian com>
+
+	** See bug #68459
+
+	* em-composer-utils.c (get_reply_sender): check the followup-to
+	header before the newsgroups header.
+	(reply_get_composer, get_reply_sender, get_reply_all): change
+	post-to to be a CamelNNTPAddress not a string pointer.
+
 2005-02-21  Not Zed  <NotZed Ximian com>
 
 	** See bug #71528.
Index: mail/em-composer-utils.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-composer-utils.c,v
retrieving revision 1.32
diff -u -p -r1.32 em-composer-utils.c
--- mail/em-composer-utils.c	19 Jan 2005 08:38:55 -0000	1.32
+++ mail/em-composer-utils.c	24 Feb 2005 07:36:17 -0000
@@ -50,6 +50,7 @@
 #include "e-util/e-account-list.h"
 
 #include <camel/camel-string-utils.h>
+#include <camel/camel-nntp-address.h>
 
 static EAccount *guess_account (CamelMimeMessage *message, CamelFolder *folder);
 
@@ -1215,7 +1216,7 @@ em_utils_camel_address_to_destination (C
 static EMsgComposer *
 reply_get_composer (CamelMimeMessage *message, EAccount *account,
 		    CamelInternetAddress *to, CamelInternetAddress *cc,
-		    CamelFolder *folder, const char *postto)
+		    CamelFolder *folder, CamelNNTPAddress *postto)
 {
 	const char *message_id, *references;
 	EDestination **tov, **ccv;
@@ -1231,7 +1232,7 @@ reply_get_composer (CamelMimeMessage *me
 	ccv = em_utils_camel_address_to_destination (cc);
 
 	if (tov || ccv) {
-		if (postto)
+		if (postto && camel_address_length((CamelAddress *)postto))
 			composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL_POST);
 		else
 			composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL);
@@ -1253,16 +1254,19 @@ reply_get_composer (CamelMimeMessage *me
 	g_free (subject);
 	
 	/* add post-to, if nessecary */
-	if (postto) {
+	if (postto && camel_address_length((CamelAddress *)postto)) {
 		char *store_url = NULL;
-		
+		char *post;
+
 		if (folder) {
 			store_url = camel_url_to_string (CAMEL_SERVICE (folder->parent_store)->url, CAMEL_URL_HIDE_ALL);
 			if (store_url[strlen (store_url) - 1] == '/')
 				store_url[strlen (store_url)-1] = '\0';
 		}
-		
-		e_msg_composer_hdrs_set_post_to_base (E_MSG_COMPOSER_HDRS (composer->hdrs), store_url ? store_url : "", postto);
+
+		post = camel_address_encode((CamelAddress *)postto);
+		e_msg_composer_hdrs_set_post_to_base (E_MSG_COMPOSER_HDRS (composer->hdrs), store_url ? store_url : "", post);
+		g_free(post);
 		g_free (store_url);
 	}
 	
@@ -1348,18 +1352,17 @@ guess_account (CamelMimeMessage *message
 }
 
 static void
-get_reply_sender (CamelMimeMessage *message, CamelInternetAddress **to, const char **postto)
+get_reply_sender (CamelMimeMessage *message, CamelInternetAddress *to, CamelNNTPAddress *postto)
 {
 	const CamelInternetAddress *reply_to;
 	const char *name, *addr, *posthdr;
 	int i;
 	
 	/* check whether there is a 'Newsgroups: ' header in there */
-	posthdr = camel_medium_get_header (CAMEL_MEDIUM (message), "Newsgroups");
-	if (posthdr && postto) {
-		*postto = posthdr;
-		while (**postto == ' ')
-			(*postto)++;
+	if (postto
+	    && ((posthdr = camel_medium_get_header((CamelMedium *)message, "Followup-To"))
+		 || (posthdr = camel_medium_get_header((CamelMedium *)message, "Newsgroups")))) {
+		camel_address_decode((CamelAddress *)postto, posthdr);
 		return;
 	}
 	
@@ -1368,15 +1371,13 @@ get_reply_sender (CamelMimeMessage *mess
 		reply_to = camel_mime_message_get_from (message);
 	
 	if (reply_to) {
-		*to = camel_internet_address_new ();
-		
 		for (i = 0; camel_internet_address_get (reply_to, i, &name, &addr); i++)
-			camel_internet_address_add (*to, name, addr);
+			camel_internet_address_add (to, name, addr);
 	}
 }
 
 static gboolean
-get_reply_list (CamelMimeMessage *message, CamelInternetAddress **to)
+get_reply_list (CamelMimeMessage *message, CamelInternetAddress *to)
 {
 	const char *header, *p;
 	char *addr;
@@ -1408,11 +1409,8 @@ get_reply_list (CamelMimeMessage *messag
 	while (*p && !strchr ("?>", *p))
 		p++;
 	
-	addr = g_strndup (header, p - header);
-	
-	*to = camel_internet_address_new ();
-	camel_internet_address_add (*to, NULL, addr);
-	
+	addr = g_strndup (header, p - header);	
+	camel_internet_address_add(to, NULL, addr);
 	g_free (addr);
 	
 	return TRUE;
@@ -1433,7 +1431,7 @@ concat_unique_addrs (CamelInternetAddres
 }
 
 static void
-get_reply_all (CamelMimeMessage *message, CamelInternetAddress **to, CamelInternetAddress **cc, const char **postto)
+get_reply_all (CamelMimeMessage *message, CamelInternetAddress *to, CamelInternetAddress *cc, CamelNNTPAddress *postto)
 {
 	const CamelInternetAddress *reply_to, *to_addrs, *cc_addrs;
 	const char *name, *addr, *posthdr;
@@ -1441,11 +1439,11 @@ get_reply_all (CamelMimeMessage *message
 	int i;
 	
 	/* check whether there is a 'Newsgroups: ' header in there */
-	posthdr = camel_medium_get_header (CAMEL_MEDIUM(message), "Newsgroups");
-	if (posthdr && postto) {
-		*postto = posthdr;
-		while (**postto == ' ')
-			(*postto)++;
+	if (postto) {
+		if ((posthdr = camel_medium_get_header((CamelMedium *)message, "Followup-To")))
+			camel_address_decode((CamelAddress *)postto, posthdr);
+		if ((posthdr = camel_medium_get_header((CamelMedium *)message, "Newsgroups")))
+			camel_address_decode((CamelAddress *)postto, posthdr);
 	}
 	
 	rcpt_hash = generate_account_hash ();
@@ -1457,9 +1455,6 @@ get_reply_all (CamelMimeMessage *message
 	to_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_TO);
 	cc_addrs = camel_mime_message_get_recipients (message, CAMEL_RECIPIENT_TYPE_CC);
 	
-	*to = camel_internet_address_new ();
-	*cc = camel_internet_address_new ();
-	
 	if (reply_to) {
 		for (i = 0; camel_internet_address_get (reply_to, i, &name, &addr); i++) {
 			/* ignore references to the Reply-To address in the To and Cc lists */
@@ -1468,27 +1463,27 @@ get_reply_all (CamelMimeMessage *message
 				   to include the user's email address because replying to oneself
 				   is kinda silly. */
 				
-				camel_internet_address_add (*to, name, addr);
+				camel_internet_address_add (to, name, addr);
 				g_hash_table_insert (rcpt_hash, (char *) addr, GINT_TO_POINTER (1));
 			}
 		}
 	}
 	
-	concat_unique_addrs (*cc, to_addrs, rcpt_hash);
-	concat_unique_addrs (*cc, cc_addrs, rcpt_hash);
+	concat_unique_addrs (cc, to_addrs, rcpt_hash);
+	concat_unique_addrs (cc, cc_addrs, rcpt_hash);
 	
 	/* promote the first Cc: address to To: if To: is empty */
-	if (camel_address_length ((CamelAddress *) *to) == 0 && camel_address_length ((CamelAddress *) *cc) > 0) {
-		camel_internet_address_get (*cc, 0, &name, &addr);
-		camel_internet_address_add (*to, name, addr);
-		camel_address_remove ((CamelAddress *) *cc, 0);
+	if (camel_address_length ((CamelAddress *) to) == 0 && camel_address_length ((CamelAddress *)cc) > 0) {
+		camel_internet_address_get (cc, 0, &name, &addr);
+		camel_internet_address_add (to, name, addr);
+		camel_address_remove ((CamelAddress *)cc, 0);
 	}
 
 	/* if To: is still empty, may we removed duplicates (i.e. ourself), so add the original To if it was set */
-	if (camel_address_length((CamelAddress *)*to) == 0
+	if (camel_address_length((CamelAddress *)to) == 0
 	    && (camel_internet_address_get(to_addrs, 0, &name, &addr)
 		|| camel_internet_address_get(cc_addrs, 0, &name, &addr))) {
-		camel_internet_address_add(*to, name, addr);
+		camel_internet_address_add(to, name, addr);
 	}
 	
 	g_hash_table_destroy (rcpt_hash);
@@ -1755,10 +1750,10 @@ reply_to_message(CamelFolder *folder, co
 void
 em_utils_reply_to_message(CamelFolder *folder, const char *uid, CamelMimeMessage *message, int mode, EMFormat *source)
 {
-	CamelInternetAddress *to = NULL, *cc = NULL;
+	CamelInternetAddress *to, *cc;
+	CamelNNTPAddress *postto = NULL;
 	EMsgComposer *composer;
 	EAccount *account;
-	const char *postto = NULL;
 	guint32 flags;
 	EMEvent *eme;
 	EMEventTargetMessage *target;
@@ -1788,6 +1783,9 @@ em_utils_reply_to_message(CamelFolder *f
 	target = em_event_target_new_message(eme, folder, message, uid,
 					     mode == REPLY_MODE_ALL ? EM_EVENT_MESSAGE_REPLY_ALL : 0);
 	e_event_emit((EEvent *)eme, "message.replying", (EEventTarget *)target);
+
+	to = camel_internet_address_new();
+	cc = camel_internet_address_new();
 	
 	account = guess_account (message, folder);
 	flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_SEEN;
@@ -1795,31 +1793,30 @@ em_utils_reply_to_message(CamelFolder *f
 	switch (mode) {
 	case REPLY_MODE_SENDER:
 		if (folder)
-			get_reply_sender (message, &to, &postto);
-		else
-			get_reply_sender (message, &to, NULL);
+			postto = camel_nntp_address_new();
+
+		get_reply_sender (message, to, postto);
 		break;
 	case REPLY_MODE_LIST:
 		flags |= CAMEL_MESSAGE_ANSWERED_ALL;
-		if (get_reply_list (message, &to))
+		if (get_reply_list (message, to))
 			break;
+		/* falls through */
 	case REPLY_MODE_ALL:
 		flags |= CAMEL_MESSAGE_ANSWERED_ALL;
 		if (folder)
-			get_reply_all (message, &to, &cc, &postto);
-		else
-			get_reply_all (message, &to, &cc, NULL);
+			postto = camel_nntp_address_new();
+
+		get_reply_all(message, to, cc, postto);
 		break;
 	}
 	
 	composer = reply_get_composer (message, account, to, cc, folder, postto);
 	e_msg_composer_add_message_attachments (composer, message, TRUE);
 	
-	if (to != NULL)
-		camel_object_unref (to);
-	
-	if (cc != NULL)
-		camel_object_unref (cc);
+	camel_object_unref(postto);
+	camel_object_unref(to);
+	camel_object_unref(cc);
 	
 	composer_set_body (composer, message, source);
 	
@@ -1836,7 +1833,7 @@ post_reply_to_message (CamelFolder *fold
 {
 	/* FIXME: would be nice if this shared more code with reply_get_composer() */
 	const char *message_id, *references;
-	CamelInternetAddress *to = NULL;
+	CamelInternetAddress *to;
 	EDestination **tov = NULL;
 	EMsgComposer *composer;
 	char *subject, *url;
@@ -1849,7 +1846,8 @@ post_reply_to_message (CamelFolder *fold
 	account = guess_account (message, folder);
 	flags = CAMEL_MESSAGE_ANSWERED | CAMEL_MESSAGE_SEEN;
 	
-	get_reply_sender (message, &to, NULL);
+	to = camel_internet_address_new();
+	get_reply_sender (message, to, NULL);
 	
 	composer = e_msg_composer_new_with_type (E_MSG_COMPOSER_MAIL_POST);
 	
@@ -1897,15 +1895,14 @@ post_reply_to_message (CamelFolder *fold
 	
 	e_msg_composer_add_message_attachments (composer, message, TRUE);
 	
-	if (to != NULL)
-		camel_object_unref (to);
-	
 	composer_set_body (composer, message, NULL);
 	
 	em_composer_utils_setup_callbacks (composer, folder, uid, flags, flags, NULL, NULL);
 	
 	gtk_widget_show (GTK_WIDGET (composer));	
 	e_msg_composer_unset_changed (composer);
+
+	camel_object_unref(to);
 }
 
 /**


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