Changed two string with the same german translation
authorChristoph Hohmann <reboot@gmx.ch>
Tue, 13 Nov 2001 14:47:23 +0000 (14:47 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Tue, 13 Nov 2001 14:47:23 +0000 (14:47 +0000)
New mailsending process
Applied wwp <subscript@free.fr>'s patch that fixes marks for multiple forwarded messages

ChangeLog.claws
configure.in
po/de.po
src/compose.c
src/procmsg.c
src/procmsg.h
src/send.c
src/send.h
src/summaryview.c

index 257a946f13a4a91a15dfd9465c6370e68d120235..1af9af7634c6082b09244696f693bd42c71017d1 100644 (file)
@@ -1,3 +1,21 @@
+2001-11-13 [christoph] 0.6.5claws9
+
+       * po/de.po
+               Changed two string with the same translation
+       * src/compose.c
+       * src/procmsg.[ch]
+       * src/send.[ch]
+               New mailsending process:
+                 - Always queue message before sending
+                   (message will be saved if sylpheed crashed or
+                    freezes while sending)
+                 - Allow queuing of newspostings
+                 - No copy in outbox before sending
+                 - No more redundant code for send and send_later
+       * src/summaryview.c
+               Applied wwp <subscript@free.fr>'s patch that fixes
+               marks for multiple forwarded messages (+compose.c)
+
 2001-11-12 [alfons]
 
        * README.claws
 2001-11-12 [alfons]
 
        * README.claws
index 2c79b112384ad7b60652f9ade193f0d9db6717f7..68575f14f983c1042712c03fa968181c6ffbf690 100644 (file)
@@ -8,7 +8,7 @@ MINOR_VERSION=6
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
 MICRO_VERSION=5
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=claws8
+EXTRA_VERSION=claws9
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
 VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
 
 dnl
index b3bb50c7eadc7d793836573f82ee2f690a5d06f6..29288974ced48ded13fb8e7579d79f61076e6452 100644 (file)
--- a/po/de.po
+++ b/po/de.po
@@ -1477,7 +1477,7 @@ msgstr "/_Benotung..."
 
 #: src/folderview.c:240 src/folderview.c:255
 msgid "/_Update folder tree"
 
 #: src/folderview.c:240 src/folderview.c:255
 msgid "/_Update folder tree"
-msgstr "/_Ablagebaum erneuern"
+msgstr "/_Ablagenordner auffrischen"
 
 #: src/folderview.c:241 src/folderview.c:256
 msgid "/Re_scan folder tree"
 
 #: src/folderview.c:241 src/folderview.c:256
 msgid "/Re_scan folder tree"
index 57a11c53acd5c557f51ed9fdba6f390ed583c6b3..116a7d0cc2a0eb00ee9077d45b73268049a93f5e 100644 (file)
@@ -175,7 +175,8 @@ static gint compose_save_to_outbox          (Compose        *compose,
                                                 const gchar    *file);
 static gint compose_remove_reedit_target       (Compose        *compose);
 static gint compose_queue                      (Compose        *compose,
                                                 const gchar    *file);
 static gint compose_remove_reedit_target       (Compose        *compose);
 static gint compose_queue                      (Compose        *compose,
-                                                const gchar    *file);
+                                                gint           *msgnum,
+                                                FolderItem     **item);
 static void compose_write_attach               (Compose        *compose,
                                                 FILE           *fp);
 static gint compose_write_headers              (Compose        *compose,
 static void compose_write_attach               (Compose        *compose,
                                                 FILE           *fp);
 static gint compose_write_headers              (Compose        *compose,
@@ -1117,6 +1118,12 @@ Compose * compose_forward_multiple(PrefsAccount * account,
        }
        g_return_val_if_fail(account != NULL, NULL);
 
        }
        g_return_val_if_fail(account != NULL, NULL);
 
+       for (msginfo = msginfo_list; msginfo != NULL; msginfo = msginfo->next) {
+               MSG_UNSET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_REPLIED);
+               MSG_SET_PERM_FLAGS(((MsgInfo *)msginfo->data)->flags, MSG_FORWARDED);
+               CHANGE_FLAGS(((MsgInfo *)msginfo->data));
+       }
+
        compose = compose_create(account, COMPOSE_FORWARD);
 
        text = GTK_STEXT(compose->text);
        compose = compose_create(account, COMPOSE_FORWARD);
 
        text = GTK_STEXT(compose->text);
@@ -2412,11 +2419,22 @@ compose_current_mail_account(void)
 }
 
 gboolean compose_check_for_valid_recipient(Compose *compose) {
 }
 
 gboolean compose_check_for_valid_recipient(Compose *compose) {
-       gchar *recipient_headers[] = {"To:", "Newsgroups:", "Cc:", "Bcc:", NULL};
+       gchar *recipient_headers_mail[] = {"To:", "Cc:", "Bcc:", NULL};
+       gchar *recipient_headers_news[] = {"Newsgroups:", NULL};
        gboolean recipient_found = FALSE;
        GSList *list;
        gchar **strptr;
 
        gboolean recipient_found = FALSE;
        GSList *list;
        gchar **strptr;
 
+       /* free to and newsgroup list */
+        slist_free_strings(compose->to_list);
+       g_slist_free(compose->to_list);
+       compose->to_list = NULL;
+                       
+       slist_free_strings(compose->newsgroup_list);
+        g_slist_free(compose->newsgroup_list);
+        compose->newsgroup_list = NULL;
+
+       /* search header entries for to and newsgroup entries */
        for(list = compose->header_list; list; list = list->next) {
                gchar *header;
                gchar *entry;
        for(list = compose->header_list; list; list = list->next) {
                gchar *header;
                gchar *entry;
@@ -2424,8 +2442,15 @@ gboolean compose_check_for_valid_recipient(Compose *compose) {
                entry = gtk_editable_get_chars(GTK_EDITABLE(((compose_headerentry *)list->data)->entry), 0, -1);
                g_strstrip(entry);
                if(entry[0] != '\0') {
                entry = gtk_editable_get_chars(GTK_EDITABLE(((compose_headerentry *)list->data)->entry), 0, -1);
                g_strstrip(entry);
                if(entry[0] != '\0') {
-                       for(strptr = recipient_headers; *strptr != NULL; strptr++) {
+                       for(strptr = recipient_headers_mail; *strptr != NULL; strptr++) {
+                               if(!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
+                                       compose->to_list = address_list_append(compose->to_list, entry);
+                                       recipient_found = TRUE;
+                               }
+                       }
+                       for(strptr = recipient_headers_news; *strptr != NULL; strptr++) {
                                if(!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
                                if(!strcmp(header, (prefs_common.trans_hdr ? gettext(*strptr) : *strptr))) {
+                                       compose->newsgroup_list = newsgroup_list_append(compose->newsgroup_list, entry);
                                        recipient_found = TRUE;
                                }
                        }
                                        recipient_found = TRUE;
                                }
                        }
@@ -2435,6 +2460,28 @@ gboolean compose_check_for_valid_recipient(Compose *compose) {
        return recipient_found;
 }
 
        return recipient_found;
 }
 
+gint compose_send(Compose *compose)
+{
+       gint msgnum;
+       FolderItem *folder;
+       gint val;
+
+       val = compose_queue(compose, &msgnum, &folder);
+       if (val) {
+               alertpanel_error(_("Could not queue message for sending"));
+               return;
+       }
+       
+       val = procmsg_send_message_queue(folder_item_fetch_msg(folder, msgnum));
+       if(!val) {
+               folder_item_remove_msg(folder, msgnum);
+               folderview_update_item(folder, TRUE);
+       }
+
+       return val;
+}
+
+#if 0 /* compose restructure */
 gint compose_send(Compose *compose)
 {
        gchar tmp[MAXPATHLEN + 1];
 gint compose_send(Compose *compose)
 {
        gchar tmp[MAXPATHLEN + 1];
@@ -2553,6 +2600,7 @@ gint compose_send(Compose *compose)
        lock = FALSE;
        return ok;
 }
        lock = FALSE;
        return ok;
 }
+#endif
 
 static gboolean compose_use_attach(Compose *compose) {
     return(gtk_clist_get_row_data(GTK_CLIST(compose->attach_clist), 0) != NULL);
 
 static gboolean compose_use_attach(Compose *compose) {
     return(gtk_clist_get_row_data(GTK_CLIST(compose->attach_clist), 0) != NULL);
@@ -2568,7 +2616,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file,
        const gchar *out_codeset;
        EncodingType encoding;
 
        const gchar *out_codeset;
        EncodingType encoding;
 
-       if ((fp = fopen(file, "w")) == NULL) {
+       if ((fp = fopen(file, "a+")) == NULL) {
                FILE_OP_ERROR(file, "fopen");
                return -1;
        }
                FILE_OP_ERROR(file, "fopen");
                return -1;
        }
@@ -2788,38 +2836,78 @@ static gint compose_remove_reedit_target(Compose *compose)
        return 0;
 }
 
        return 0;
 }
 
-static gint compose_queue(Compose *compose, const gchar *file)
+static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
 {
        FolderItem *queue;
 {
        FolderItem *queue;
-       gchar *tmp, *queue_path;
+       gchar *tmpfilename, *queue_path;
        FILE *fp, *src_fp;
        GSList *cur;
        gchar buf[BUFFSIZE];
        gint num;
        FILE *fp, *src_fp;
        GSList *cur;
        gchar buf[BUFFSIZE];
        gint num;
-
+        static gboolean lock = FALSE;
+       PrefsAccount *mailac = NULL, *newsac = NULL;
+       
        debug_print(_("queueing message...\n"));
        debug_print(_("queueing message...\n"));
-       g_return_val_if_fail(compose->to_list != NULL, -1);
        g_return_val_if_fail(compose->account != NULL, -1);
        g_return_val_if_fail(compose->account != NULL, -1);
+        g_return_val_if_fail(compose->orig_account != NULL, -1);
+
+        lock = TRUE;
+       
+        if(!compose_check_for_valid_recipient(compose)) {
+                alertpanel_error(_("Recipient is not specified."));
+                lock = FALSE;
+                return -1;
+        }
+                                                                       
+       if (!compose->to_list && !compose->newsgroup_list) {
+               g_warning(_("can't get recipient list."));
+               unlink(tmpfilename);
+               lock = FALSE;
+                return -1;
+        }
 
 
-       tmp = g_strdup_printf("%s%cqueue.%d", g_get_tmp_dir(),
+        if (prefs_common.linewrap_at_send)
+               compose_wrap_line_all(compose);
+                       
+       /* write to temporary file */
+       tmpfilename = g_strdup_printf("%s%cqueue.%d", g_get_tmp_dir(),
                              G_DIR_SEPARATOR, (gint)compose);
                              G_DIR_SEPARATOR, (gint)compose);
-       if ((fp = fopen(tmp, "w")) == NULL) {
-               FILE_OP_ERROR(tmp, "fopen");
-               g_free(tmp);
+       if ((fp = fopen(tmpfilename, "w")) == NULL) {
+               FILE_OP_ERROR(tmpfilename, "fopen");
+               g_free(tmpfilename);
                return -1;
        }
                return -1;
        }
-       if ((src_fp = fopen(file, "r")) == NULL) {
-               FILE_OP_ERROR(file, "fopen");
-               fclose(fp);
-               unlink(tmp);
-               g_free(tmp);
-               return -1;
-       }
-       if (change_file_mode_rw(fp, tmp) < 0) {
-               FILE_OP_ERROR(tmp, "chmod");
+       if (change_file_mode_rw(fp, tmpfilename) < 0) {
+               FILE_OP_ERROR(tmpfilename, "chmod");
                g_warning(_("can't change file mode\n"));
        }
 
                g_warning(_("can't change file mode\n"));
        }
 
+       if(compose->to_list) {
+               if (compose->account->protocol != A_NNTP)
+                       mailac = compose->account;
+               else if (compose->orig_account->protocol != A_NNTP)
+                       mailac = compose->orig_account;
+               else if (cur_account && cur_account->protocol != A_NNTP)
+                       mailac = cur_account;
+               else if (!(mailac = compose_current_mail_account())) {
+                       unlink(tmpfilename);
+                       lock = FALSE;
+                       alertpanel_error(_("No account for sending mails available!"));
+                       return -1;
+               }
+       }
+
+       if(compose->newsgroup_list) {
+                if (compose->account->protocol == A_NNTP)
+                        newsac = compose->account;
+                else if(!(newsac = compose->orig_account) || (newsac->protocol != A_NNTP)) {
+                       unlink(tmpfilename);
+                       lock = FALSE;
+                       alertpanel_error(_("No account for posting news available!"));
+                       return -1;
+               }                       
+       }
+
        /* queueing variables */
        fprintf(fp, "AF:\n");
        fprintf(fp, "NF:0\n");
        /* queueing variables */
        fprintf(fp, "AF:\n");
        fprintf(fp, "NF:0\n");
@@ -2835,56 +2923,62 @@ static gint compose_queue(Compose *compose, const gchar *file)
        fprintf(fp, "PT:0\n");
        fprintf(fp, "S:%s\n", compose->account->address);
        fprintf(fp, "RQ:\n");
        fprintf(fp, "PT:0\n");
        fprintf(fp, "S:%s\n", compose->account->address);
        fprintf(fp, "RQ:\n");
-       if (compose->account->smtp_server)
-               fprintf(fp, "SSV:%s\n", compose->account->smtp_server);
+       if (mailac)
+               fprintf(fp, "SSV:%s\n", mailac->smtp_server);
        else
                fprintf(fp, "SSV:\n");
        else
                fprintf(fp, "SSV:\n");
-       if (compose->account->nntp_server)
-               fprintf(fp, "NSV:%s\n", compose->account->nntp_server);
+       if (newsac)
+               fprintf(fp, "NSV:%s\n", newsac->nntp_server);
        else
                fprintf(fp, "NSV:\n");
        fprintf(fp, "SSH:\n");
        else
                fprintf(fp, "NSV:\n");
        fprintf(fp, "SSH:\n");
-       fprintf(fp, "R:<%s>", (gchar *)compose->to_list->data);
-       for (cur = compose->to_list->next; cur != NULL; cur = cur->next)
-               fprintf(fp, ",<%s>", (gchar *)cur->data);
+       /* write recepient list */
+       fprintf(fp, "R:");
+       if(compose->to_list) {
+               fprintf(fp, "<%s>", (gchar *)compose->to_list->data);
+               for (cur = compose->to_list->next; cur != NULL; cur = cur->next)
+                       fprintf(fp, ",<%s>", (gchar *)cur->data);
+       }
        fprintf(fp, "\n");
        fprintf(fp, "\n");
-       /* Sylpheed account ID */
-       fprintf(fp, "AID:%d\n", compose->account->account_id);
+       /* write newsgroup list */
+       fprintf(fp, "NG:");
+       if(compose->newsgroup_list) {
+               fprintf(fp, "%s", (gchar *)compose->newsgroup_list->data);
+               for (cur = compose->newsgroup_list->next; cur != NULL; cur = cur->next)
+                       fprintf(fp, ",%s", (gchar *)cur->data);
+       }
        fprintf(fp, "\n");
        fprintf(fp, "\n");
-
-       while (fgets(buf, sizeof(buf), src_fp) != NULL) {
-               if (fputs(buf, fp) == EOF) {
-                       FILE_OP_ERROR(tmp, "fputs");
-                       fclose(fp);
-                       fclose(src_fp);
-                       unlink(tmp);
-                       g_free(tmp);
-                       return -1;
-               }
+       /* Sylpheed account IDs */
+       if(mailac) {
+               fprintf(fp, "MAID:%d\n", mailac->account_id);
+       }
+       if(newsac) {
+               fprintf(fp, "NAID:%d\n", newsac->account_id);
        }
        }
+       fprintf(fp, "\n");
+       fclose(fp);
 
 
-       fclose(src_fp);
-       if (fclose(fp) == EOF) {
-               FILE_OP_ERROR(tmp, "fclose");
-               unlink(tmp);
-               g_free(tmp);
+        if (compose_write_to_file(compose, tmpfilename, FALSE) < 0) {
+               unlink(tmpfilename);
+               lock = FALSE;
                return -1;
        }
                return -1;
        }
-
+                                               
+       /* queue message */
        queue = folder_get_default_queue();
 
        folder_item_scan(queue);
        queue_path = folder_item_get_path(queue);
        if (!is_dir_exist(queue_path))
                make_dir_hier(queue_path);
        queue = folder_get_default_queue();
 
        folder_item_scan(queue);
        queue_path = folder_item_get_path(queue);
        if (!is_dir_exist(queue_path))
                make_dir_hier(queue_path);
-       if ((num = folder_item_add_msg(queue, tmp, TRUE)) < 0) {
+       if ((num = folder_item_add_msg(queue, tmpfilename, TRUE)) < 0) {
                g_warning(_("can't queue the message\n"));
                g_warning(_("can't queue the message\n"));
-               unlink(tmp);
-               g_free(tmp);
+               unlink(tmpfilename);
+               g_free(tmpfilename);
                g_free(queue_path);
                return -1;
        }
                g_free(queue_path);
                return -1;
        }
-       g_free(tmp);
+       g_free(tmpfilename);
 
        if (compose->mode == COMPOSE_REEDIT) {
                compose_remove_reedit_target(compose);
 
        if (compose->mode == COMPOSE_REEDIT) {
                compose_remove_reedit_target(compose);
@@ -2910,6 +3004,11 @@ static gint compose_queue(Compose *compose, const gchar *file)
        folder_item_scan(queue);
        folderview_update_item(queue, TRUE);
 
        folder_item_scan(queue);
        folderview_update_item(queue, TRUE);
 
+       if((msgnum != NULL) && (item != NULL)) {
+               *msgnum = num;
+               *item = queue;
+       }
+
        return 0;
 }
 
        return 0;
 }
 
@@ -2983,9 +3082,7 @@ static void compose_write_attach(Compose *compose, FILE *fp)
 
 static gint compose_write_headers_from_headerlist(Compose *compose, 
                                                  FILE *fp, 
 
 static gint compose_write_headers_from_headerlist(Compose *compose, 
                                                  FILE *fp, 
-                                                 gchar *header,
-                                                 GSList *(*list_append_func) (GSList *list, const gchar *str),
-                                                 GSList **dest_list)
+                                                 gchar *header)
 {
        gchar buf[BUFFSIZE];
        gchar *str, *header_w_colon, *trans_hdr;
 {
        gchar buf[BUFFSIZE];
        gchar *str, *header_w_colon, *trans_hdr;
@@ -3010,8 +3107,6 @@ static gint compose_write_headers_from_headerlist(Compose *compose,
                        Xstrdup_a(str, str, return -1);
                        g_strstrip(str);
                        if(str[0] != '\0') {
                        Xstrdup_a(str, str, return -1);
                        g_strstrip(str);
                        if(str[0] != '\0') {
-                               if(list_append_func)
-                                       *dest_list = list_append_func(*dest_list, str);
                                compose_convert_header
                                        (buf, sizeof(buf), str,
                                        strlen(header) + 2);
                                compose_convert_header
                                        (buf, sizeof(buf), str,
                                        strlen(header) + 2);
@@ -3070,7 +3165,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        compose->to_list = NULL;
 
        /* To */
        compose->to_list = NULL;
 
        /* To */
-       compose_write_headers_from_headerlist(compose, fp, "To", address_list_append, &compose->to_list);
+       compose_write_headers_from_headerlist(compose, fp, "To");
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_to) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_to) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
@@ -3095,7 +3190,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        compose->newsgroup_list = NULL;
 
        /* Newsgroups */
        compose->newsgroup_list = NULL;
 
        /* Newsgroups */
-       compose_write_headers_from_headerlist(compose, fp, "Newsgroups", newsgroup_list_append, &compose->newsgroup_list);
+       compose_write_headers_from_headerlist(compose, fp, "Newsgroups");
 #if 0 /* NEW COMPOSE GUI */
        str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
        if (*str != '\0') {
 #if 0 /* NEW COMPOSE GUI */
        str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
        if (*str != '\0') {
@@ -3115,7 +3210,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        }
 #endif
        /* Cc */
        }
 #endif
        /* Cc */
-       compose_write_headers_from_headerlist(compose, fp, "Cc", address_list_append, &compose->to_list);
+       compose_write_headers_from_headerlist(compose, fp, "Cc");
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_cc) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->cc_entry));
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_cc) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->cc_entry));
@@ -3136,7 +3231,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        }
 #endif
        /* Bcc */
        }
 #endif
        /* Bcc */
-       compose_write_headers_from_headerlist(compose, fp, "Bcc", address_list_append, &compose->to_list);
+       compose_write_headers_from_headerlist(compose, fp, "Bcc");
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_bcc) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->bcc_entry));
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_bcc) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->bcc_entry));
@@ -3184,7 +3279,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
                fprintf(fp, "References: %s\n", compose->references);
 
        /* Followup-To */
                fprintf(fp, "References: %s\n", compose->references);
 
        /* Followup-To */
-       compose_write_headers_from_headerlist(compose, fp, "Followup-To", NULL, NULL);
+       compose_write_headers_from_headerlist(compose, fp, "Followup-To");
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_followupto && !IS_IN_CUSTOM_HEADER("Followup-To")) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->followup_entry));
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_followupto && !IS_IN_CUSTOM_HEADER("Followup-To")) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->followup_entry));
@@ -3201,7 +3296,7 @@ static gint compose_write_headers(Compose *compose, FILE *fp,
        }
 #endif
        /* Reply-To */
        }
 #endif
        /* Reply-To */
-       compose_write_headers_from_headerlist(compose, fp, "Reply-To", NULL, NULL);
+       compose_write_headers_from_headerlist(compose, fp, "Reply-To");
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_replyto && !IS_IN_CUSTOM_HEADER("Reply-To")) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->reply_entry));
 #if 0 /* NEW COMPOSE GUI */
        if (compose->use_replyto && !IS_IN_CUSTOM_HEADER("Reply-To")) {
                str = gtk_entry_get_text(GTK_ENTRY(compose->reply_entry));
@@ -5131,7 +5226,6 @@ static void compose_send_cb(gpointer data, guint action, GtkWidget *widget)
        gint val;
 
        val = compose_send(compose);
        gint val;
 
        val = compose_send(compose);
-
        if (val == 0) gtk_widget_destroy(compose->window);
 }
 
        if (val == 0) gtk_widget_destroy(compose->window);
 }
 
@@ -5139,37 +5233,10 @@ static void compose_send_later_cb(gpointer data, guint action,
                                  GtkWidget *widget)
 {
        Compose *compose = (Compose *)data;
                                  GtkWidget *widget)
 {
        Compose *compose = (Compose *)data;
-       gchar tmp[22];
-       gboolean recipient_found;
-       GSList *list;
-
-       if(!compose_check_for_valid_recipient(compose)) {
-               alertpanel_error(_("Recipient is not specified."));
-               return;
-       }
-
-       g_snprintf(tmp, 22, "%s%ctmpmsg%d",
-                  g_get_tmp_dir(), G_DIR_SEPARATOR, (gint)compose);
-
-       if (prefs_common.linewrap_at_send)
-               compose_wrap_line_all(compose);
-
-       if (compose_write_to_file(compose, tmp, FALSE) < 0 ||
-           compose_queue(compose, tmp) < 0) {
-               alertpanel_error(_("Can't queue the message."));
-               return;
-       }
-
-       if (prefs_common.savemsg) {
-               if (compose_save_to_outbox(compose, tmp) < 0)
-                       alertpanel_error
-                               (_("Can't save the message to outbox."));
-       }
-
-       if (unlink(tmp) < 0)
-               FILE_OP_ERROR(tmp, "unlink");
+       gint val;
 
 
-       gtk_widget_destroy(compose->window);
+       val = compose_queue(compose, NULL, NULL);
+       if (!val) gtk_widget_destroy(compose->window);
 }
 
 static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
 }
 
 static void compose_draft_cb(gpointer data, guint action, GtkWidget *widget)
index 3ab3bed9e6f9bba2862a7d52308e38ba2ac9625f..17b80c00c0f96ba4ef46113736b91b90472296aa 100644 (file)
@@ -32,6 +32,8 @@
 #include "procmime.h"
 #include "statusbar.h"
 #include "folder.h"
 #include "procmime.h"
 #include "statusbar.h"
 #include "folder.h"
+#include "prefs_common.h"
+#include "account.h"
 
 typedef struct _FlagInfo       FlagInfo;
 
 
 typedef struct _FlagInfo       FlagInfo;
 
@@ -765,7 +767,7 @@ gint procmsg_send_queue(void)
 
                file = folder_item_fetch_msg(queue, i);
                if (file) {
 
                file = folder_item_fetch_msg(queue, i);
                if (file) {
-                       if (send_message_queue(file) < 0) {
+                       if (procmsg_send_message_queue(file) < 0) {
                                g_warning(_("Sending queued message %d failed.\n"), i);
                                ret = -1;
                        } else
                                g_warning(_("Sending queued message %d failed.\n"), i);
                                ret = -1;
                        } else
@@ -936,3 +938,194 @@ static gint procmsg_cmp_flag_msgnum(gconstpointer a, gconstpointer b)
 
        return finfo->msgnum - msgnum;
 }
 
        return finfo->msgnum - msgnum;
 }
+
+enum
+{
+       Q_SENDER          = 0,
+       Q_SMTPSERVER      = 1,
+       Q_RECIPIENTS      = 2,
+       Q_NEWSGROUPS      = 3,
+       Q_MAIL_ACCOUNT_ID = 4,
+       Q_NEWS_ACCOUNT_ID = 5
+};
+
+gint procmsg_send_message_queue(const gchar *file)
+{
+       static HeaderEntry qentry[] = {{"S:",    NULL, FALSE},
+                                      {"SSV:",  NULL, FALSE},
+                                      {"R:",    NULL, FALSE},
+                                      {"NG:",   NULL, FALSE},
+                                      {"MAID:", NULL, FALSE},
+                                      {"NAID:", NULL, FALSE},
+                                      {NULL,    NULL, FALSE}};
+       FILE *fp;
+       gint filepos;
+       gint mailval = 0, newsval = 0;
+       gchar *from = NULL;
+       gchar *smtpserver = NULL;
+       GSList *to_list = NULL;
+       GSList *newsgroup_list = NULL;
+       gchar buf[BUFFSIZE];
+       gint hnum;
+       PrefsAccount *mailac = NULL, *newsac = NULL;
+       gchar *tmp = NULL;
+
+       g_return_val_if_fail(file != NULL, -1);
+
+       if ((fp = fopen(file, "r")) == NULL) {
+               FILE_OP_ERROR(file, "fopen");
+               return -1;
+       }
+
+       while ((hnum = procheader_get_one_field(buf, sizeof(buf), fp, qentry))
+              != -1) {
+               gchar *p = buf + strlen(qentry[hnum].name);
+
+               switch (hnum) {
+               case Q_SENDER:
+                       if (!from) from = g_strdup(p);
+                       break;
+               case Q_SMTPSERVER:
+                       if (!smtpserver) smtpserver = g_strdup(p);
+                       break;
+               case Q_RECIPIENTS:
+                       to_list = address_list_append(to_list, p);
+                       break;
+               case Q_NEWSGROUPS:
+                       newsgroup_list = newsgroup_list_append(newsgroup_list, p);
+                       break;
+               case Q_MAIL_ACCOUNT_ID:
+                       mailac = account_find_from_id(atoi(p));
+                       break;
+               case Q_NEWS_ACCOUNT_ID:
+                       newsac = account_find_from_id(atoi(p));
+                       break;
+               default:
+               }
+       }
+       filepos = ftell(fp);
+
+       if(newsgroup_list || prefs_common.savemsg) {
+               FILE *tmpfp;
+
+               /* write to temporary file */
+               tmp = g_strdup_printf("%s%ctmp%d", g_get_tmp_dir(),
+                           G_DIR_SEPARATOR, (gint)file);
+               if ((tmpfp = fopen(tmp, "w")) == NULL) {
+                       FILE_OP_ERROR(tmp, "fopen");
+                       newsval = -1;
+               }
+               if (change_file_mode_rw(tmpfp, tmp) < 0) {
+                       FILE_OP_ERROR(tmp, "chmod");
+                       g_warning(_("can't change file mode\n"));
+               }
+
+               while ((newsval == 0) && fgets(buf, sizeof(buf), fp) != NULL) {
+                       if (fputs(buf, tmpfp) == EOF) {
+                               FILE_OP_ERROR(tmp, "fputs");
+                               newsval = -1;
+                       }
+               }
+               fclose(tmpfp);
+       }
+
+       fseek(fp, filepos, SEEK_SET);
+       if (to_list) {
+               debug_print(_("Sending message by mail\n"));
+               if(!from) {
+                       g_warning(_("Queued message header is broken.\n"));
+                       mailval = -1;
+               } else if (prefs_common.use_extsend && prefs_common.extsend_cmd) {
+                       mailval = send_message_local(prefs_common.extsend_cmd, fp);
+               } else {
+                       if (!mailac) {
+                               mailac = account_find_from_smtp_server(from, smtpserver);
+                               if (!mailac) {
+                                       g_warning(_("Account not found. "
+                                                   "Using current account...\n"));
+                                       mailac = cur_account;
+                               }
+                       }
+
+                       if (mailac)
+                               mailval = send_message_smtp(mailac, to_list, fp);
+                       else {
+                               PrefsAccount tmp_ac;
+
+                               g_warning(_("Account not found.\n"));
+
+                               memset(&tmp_ac, 0, sizeof(PrefsAccount));
+                               tmp_ac.address = from;
+                               tmp_ac.smtp_server = smtpserver;
+                               tmp_ac.smtpport = SMTP_PORT;
+                               mailval = send_message_smtp(&tmp_ac, to_list, fp);
+                       }
+               }
+       }
+
+       if(newsgroup_list) {
+               Folder *folder;
+
+               debug_print(_("Sending message by news\n"));
+
+               folder = FOLDER(newsac->folder);
+
+               if(newsval == 0) {
+                       newsval = news_post(folder, tmp);
+                       if (newsval < 0) {
+                               alertpanel_error(_("Error occurred while posting the message to %s ."),
+                                         newsac->nntp_server);
+                       }
+               }
+
+       }
+
+       /* save message to outbox */
+       if (mailval == 0 && newsval == 0 && prefs_common.savemsg) {
+               FolderItem *outbox;
+               gchar *path;
+               gint num;
+               FILE *fp;
+
+               debug_print(_("saving sent message...\n"));
+
+               outbox = folder_get_default_outbox();
+               path = folder_item_get_path(outbox);
+               if (!is_dir_exist(path))
+                       make_dir_hier(path);
+
+               folder_item_scan(outbox);
+               if ((num = folder_item_add_msg(outbox, tmp, FALSE)) < 0) {
+                       g_warning(_("can't save message\n"));
+               }
+
+               if(num) {
+                       if ((fp = procmsg_open_mark_file(path, TRUE)) == NULL)
+                               g_warning(_("can't open mark file\n"));
+                       else {
+                               MsgInfo newmsginfo;
+
+                               newmsginfo.msgnum = num;
+                               newmsginfo.flags.perm_flags = 0;
+                               newmsginfo.flags.tmp_flags = 0;
+                               procmsg_write_flags(&newmsginfo, fp);
+                               fclose(fp);
+                       }
+               }
+               g_free(path);
+       }
+
+       slist_free_strings(to_list);
+       g_slist_free(to_list);
+       slist_free_strings(newsgroup_list);
+       g_slist_free(newsgroup_list);
+       g_free(from);
+       g_free(smtpserver);
+       fclose(fp);
+       if(tmp) {
+               unlink(tmp);
+               g_free(tmp);
+       }
+
+       return (newsval != 0 ? newsval : mailval);
+}
index 8c729b0c7e02f2f8a1c376cfdfbd3ce5f22b6cf5..1df46484ed602f3eda48e9ce2efaa284e4eff8c5 100644 (file)
@@ -237,5 +237,6 @@ void         procmsg_msginfo_free           (MsgInfo        *msginfo);
 
 gint procmsg_cmp_msgnum_for_sort       (gconstpointer   a,
                                         gconstpointer   b);
 
 gint procmsg_cmp_msgnum_for_sort       (gconstpointer   a,
                                         gconstpointer   b);
+gint procmsg_send_message_queue                (const gchar *file);
 
 #endif /* __PROCMSG_H__ */
 
 #endif /* __PROCMSG_H__ */
index 97df31be0fae41ca3017f7ea3f71d5119964d8b7..d332ab8f3414de9adf39f6f6e68449f7f0bdab6e 100644 (file)
 #include "utils.h"
 #include "gtkutils.h"
 
 #include "utils.h"
 #include "gtkutils.h"
 
-#define SMTP_PORT      25
-#if USE_SSL
-#define SSMTP_PORT     465
-#endif
-
 typedef struct _SendProgressDialog     SendProgressDialog;
 
 struct _SendProgressDialog
 typedef struct _SendProgressDialog     SendProgressDialog;
 
 struct _SendProgressDialog
@@ -65,11 +60,6 @@ struct _SendProgressDialog
        gboolean cancelled;
 };
 
        gboolean cancelled;
 };
 
-static gint send_message_local (const gchar *command, FILE *fp);
-
-static gint send_message_smtp  (PrefsAccount *ac_prefs, GSList *to_list,
-                                FILE *fp);
-
 #if USE_SSL
 static SockInfo *send_smtp_open        (const gchar *server, gushort port,
                                 const gchar *domain, gboolean use_smtp_auth,
 #if USE_SSL
 static SockInfo *send_smtp_open        (const gchar *server, gushort port,
                                 const gchar *domain, gboolean use_smtp_auth,
@@ -206,7 +196,7 @@ gint send_message_queue(const gchar *file)
        return val;
 }
 
        return val;
 }
 
-static gint send_message_local(const gchar *command, FILE *fp)
+gint send_message_local(const gchar *command, FILE *fp)
 {
        FILE *pipefp;
        gchar buf[BUFFSIZE];
 {
        FILE *pipefp;
        gchar buf[BUFFSIZE];
@@ -276,7 +266,7 @@ static gint send_message_local(const gchar *command, FILE *fp)
        } \
 }
 
        } \
 }
 
-static gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list,
+gint send_message_smtp(PrefsAccount *ac_prefs, GSList *to_list,
                              FILE *fp)
 {
        SockInfo *smtp_sock = NULL;
                              FILE *fp)
 {
        SockInfo *smtp_sock = NULL;
index 72fa4fe0036a5340d09b608730c13e12d7faf4d4..31eba0aee2ea1f5d34e09f3276ef317862a7df87 100644 (file)
 
 #include "prefs_account.h"
 
 
 #include "prefs_account.h"
 
+#define SMTP_PORT      25
+#if USE_SSL
+#define SSMTP_PORT     465
+#endif
+
 gint send_message              (const gchar    *file,
                                 PrefsAccount   *ac_prefs,
                                 GSList         *to_list);
 gint send_message_queue                (const gchar    *file);
 gint send_message              (const gchar    *file,
                                 PrefsAccount   *ac_prefs,
                                 GSList         *to_list);
 gint send_message_queue                (const gchar    *file);
+gint send_message_local                (const gchar *command,
+                                FILE *fp);
+gint send_message_smtp         (PrefsAccount *ac_prefs,
+                                GSList *to_list,
+                                FILE *fp);
 
 #endif /* __SEND_H__ */
 
 #endif /* __SEND_H__ */
index d6ff5990b332da17b97eb4cfb45e03b1fc70b2dd..112edfce1b4e6291cfa3c5aa3dab15169adaa033 100644 (file)
@@ -2506,7 +2506,11 @@ static void summary_set_row_marks(SummaryView *summaryview, GtkCTreeNode *row)
 
 void summary_set_marks_selected(SummaryView *summaryview)
 {
 
 void summary_set_marks_selected(SummaryView *summaryview)
 {
-       summary_set_row_marks(summaryview, summaryview->selected);
+       GtkCTree *ctree = GTK_CTREE(summaryview->ctree);
+       GList *cur;
+
+       for (cur = GTK_CLIST(ctree)->selection; cur != NULL; cur = cur->next)
+               summary_set_row_marks(summaryview, GTK_CTREE_NODE(cur->data));
 }
 
 static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)
 }
 
 static void summary_mark_row(SummaryView *summaryview, GtkCTreeNode *row)