2006-09-27 [wwp] 2.5.2cvs9
[claws.git] / src / send_message.c
index 29cfc80eef9f4eee341031b830d87b64fca8bbec..393515410eaa2b08127405c98dee877ae4099005 100644 (file)
@@ -202,6 +202,10 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
        gchar buf[BUFFSIZE];
        gint ret = 0;
        gboolean was_inited = FALSE;
+       MsgInfo *tmp_msginfo = NULL;
+       MsgFlags flags = {0, 0};
+       long fp_pos = 0;
+       gchar spec_from[BUFFSIZE];
 
        g_return_val_if_fail(ac_prefs != NULL, -1);
        g_return_val_if_fail(ac_prefs->address != NULL, -1);
@@ -209,6 +213,23 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
        g_return_val_if_fail(to_list != NULL, -1);
        g_return_val_if_fail(fp != NULL, -1);
 
+       /* get the From address used, not necessarily the ac_prefs',
+        * because it's editable. */
+
+       fp_pos = ftell(fp);
+       tmp_msginfo = procheader_parse_stream(fp, flags, FALSE, FALSE);
+       fseek(fp, fp_pos, SEEK_SET);
+       
+       if (tmp_msginfo && tmp_msginfo->from) {
+               strncpy2(spec_from, tmp_msginfo->from, BUFFSIZE-1);
+               extract_address(spec_from);
+       } else {
+               strncpy2(spec_from, ac_prefs->address, BUFFSIZE-1);
+       }
+       if (tmp_msginfo) {
+               procmsg_msginfo_free(tmp_msginfo);
+       }
+
        if (!ac_prefs->session) {
                /* we can't reuse a previously initialised session */
                session = smtp_session_new();
@@ -334,11 +355,11 @@ gint send_message_smtp_full(PrefsAccount *ac_prefs, GSList *to_list, FILE *fp, g
        }
 
        /* This has to be initialised for every mail sent */
-       smtp_session->from = g_strdup(ac_prefs->address);
+       smtp_session->from = g_strdup(spec_from);
        smtp_session->to_list = to_list;
        smtp_session->cur_to = to_list;
-       smtp_session->send_data = get_outgoing_rfc2822_str(fp);
-       smtp_session->send_data_len = strlen(smtp_session->send_data);
+       smtp_session->send_data = (guchar *)get_outgoing_rfc2822_str(fp);
+       smtp_session->send_data_len = strlen((gchar *)smtp_session->send_data);
 
        session_set_timeout(session,
                            prefs_common.io_timeout_secs * 1000);
@@ -512,10 +533,20 @@ static gint send_send_data_finished(Session *session, guint len, gpointer data)
        return 0;
 }
 
+static void send_progress_dialog_size_allocate_cb(GtkWidget *widget,
+                                        GtkAllocation *allocation)
+{
+       g_return_if_fail(allocation != NULL);
+
+       prefs_common.sendwin_width = allocation->width;
+       prefs_common.sendwin_height = allocation->height;
+}
+
 static SendProgressDialog *send_progress_dialog_create(void)
 {
        SendProgressDialog *dialog;
        ProgressDialog *progress;
+       static GdkGeometry geometry;
 
        dialog = g_new0(SendProgressDialog, 1);
 
@@ -527,10 +558,22 @@ static SendProgressDialog *send_progress_dialog_create(void)
        g_signal_connect(G_OBJECT(progress->window), "delete_event",
                         G_CALLBACK(gtk_true), NULL);
        gtk_window_set_modal(GTK_WINDOW(progress->window), TRUE);
+       g_signal_connect(G_OBJECT(progress->window), "size_allocate",
+                        G_CALLBACK(send_progress_dialog_size_allocate_cb), NULL);
        manage_window_set_transient(GTK_WINDOW(progress->window));
 
        progress_dialog_get_fraction(progress);
 
+       if (!geometry.min_height) {
+               geometry.min_width = 460;
+               geometry.min_height = 250;
+       }
+
+       gtk_window_set_geometry_hints(GTK_WINDOW(progress->window), NULL, &geometry,
+                                     GDK_HINT_MIN_SIZE);
+       gtk_widget_set_size_request(progress->window, prefs_common.sendwin_width,
+                                   prefs_common.sendwin_height);
+
        if (prefs_common.send_dialog_mode == SEND_DIALOG_ALWAYS) {
                gtk_widget_show_now(progress->window);
        }