Re: [evolution-patches] patch to fix a file being attached anytimes in a message



hi,

sorry for my last mail, i sent it with character set "UTF-7".

I believe it is a bug that a file could be attached for anytimes because
I think it is often caused by carelessness and few user would like to
choose to do this.

But certainly the evolution should not cross out the same attachment
file without any message to the user. It should ask the user whether to
add the same file into the list.
The file attached is just the patch for that.

regards
Jimmy  

On Thu, 2004-07-22 at 16:33, Not Zed wrote:
> hi,
> 
> there's something wrong with this patch.  it should be in unified
> format (-u) but it also appears to be messed up in other ways too
> (character set?).
> 
> also, why is this actually a bug?  if a user chooses to do this, why
> not let them?
> 
> Michael

> -- 
> 
> Michael Zucchi <notzed ximian com>
> "born to die, live to work, it's
> all downhill from here"
> Novell's Evolution and Free
> Software Developer
Index: composer/e-msg-composer-attachment-bar.c
===================================================================
RCS file: /export/src/cvs/evolution/composer/e-msg-composer-attachment-bar.c,v
retrieving revision 1.5
diff -u -r1.5 e-msg-composer-attachment-bar.c
--- composer/e-msg-composer-attachment-bar.c	2004/03/19 01:50:22	1.5
+++ composer/e-msg-composer-attachment-bar.c	2004/07/22 09:35:07
@@ -137,16 +137,80 @@
 	update (E_MSG_COMPOSER_ATTACHMENT_BAR (data));
 }
 
+static gboolean
+e_question (GtkWindow *parent, int def, const char *fmt, ...)
+{
+        GtkWidget *mbox;
+        va_list ap;
+        int button;
+        char *str;
+                                                                                                                              
+        va_start (ap, fmt);
+        str = g_strdup_vprintf (fmt, ap);
+        va_end (ap);
+        mbox = gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT,
+                                       GTK_MESSAGE_QUESTION, GTK_BUTTONS_YES_NO,
+                                       "%s", str);
+        g_free (str);
+        gtk_dialog_set_default_response ((GtkDialog *) mbox, def);
+                                                                                                                              
+        button = gtk_dialog_run ((GtkDialog *) mbox);
+        
+	gtk_widget_destroy (mbox);
+                                                                                                                              
+        return button == GTK_RESPONSE_YES;
+}
+
+
 static void
 add_common (EMsgComposerAttachmentBar *bar,
 	    EMsgComposerAttachment *attachment)
 {
+	GList * p;
+	CamelMimePart *part;
+	CamelMimePart *new_part;
+	char *file_name, * new_file_name;
+        char *disposition, * new_disposition;	
+	EMsgComposerAttachment *old_attachment;
+	int length,i;
+	gboolean res;
+	EMsgComposer *composer;
+	
 	g_return_if_fail (attachment != NULL);
 	
 	g_signal_connect (attachment, "changed",
 			  G_CALLBACK (attachment_changed_cb),
 			  bar);
 	
+	new_part=attachment->body;
+	new_file_name=camel_mime_part_get_filename(new_part);
+	new_disposition=camel_mime_part_get_disposition(new_part);
+
+	p=g_list_first(bar->priv->attachments);
+	length=g_list_length(bar->priv->attachments);
+	i=0;
+	while(i<length){
+		old_attachment=(EMsgComposerAttachment *)(p->data);
+		part=old_attachment->body;
+		file_name=camel_mime_part_get_filename(part);
+		disposition=camel_mime_part_get_disposition(part);
+		if((!strcmp(file_name,new_file_name))&&
+			(!strcmp(disposition,new_disposition))&&
+			(old_attachment->size==attachment->size))
+		{
+			composer = E_MSG_COMPOSER (gtk_widget_get_toplevel (GTK_WIDGET (bar)));
+			res=e_question ((GtkWindow *) composer, GTK_RESPONSE_YES,
+                          _("This file has already been attached.\nDo you want attach it again?"));
+			if(res)
+				break;
+			else{
+				g_object_unref(attachment);
+				return;
+			}
+		}
+		p=p->next;
+		i++;
+	}
 	bar->priv->attachments = g_list_append (bar->priv->attachments,
 						attachment);
 	bar->priv->num_attachments++;


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