return compose_generic_new(account, NULL, NULL);
}
+Compose * compose_bounce(PrefsAccount *account, MsgInfo *msginfo)
+{
+ Compose * c;
+ gchar * filename;
+ GtkItemFactory *ifactory;
+
+ c = compose_generic_new(account, NULL, NULL);
+
+ filename = procmsg_get_message_file(msginfo);
+ if (filename == NULL)
+ return NULL;
+
+ c->bounce_filename = filename;
+
+ if (msginfo->subject)
+ gtk_entry_set_text(GTK_ENTRY(c->subject_entry),
+ msginfo->subject);
+ gtk_editable_set_editable(GTK_EDITABLE(c->subject_entry), FALSE);
+
+ compose_quote_fmt(c, msginfo, "%M", NULL);
+ gtk_editable_set_editable(GTK_EDITABLE(c->text), FALSE);
+
+ ifactory = gtk_item_factory_from_widget(c->popupmenu);
+ menu_set_sensitive(ifactory, "/Add...", FALSE);
+ menu_set_sensitive(ifactory, "/Remove", FALSE);
+ menu_set_sensitive(ifactory, "/Property...", FALSE);
+
+ ifactory = gtk_item_factory_from_widget(c->menubar);
+ menu_set_sensitive(ifactory, "/File/Insert file", FALSE);
+ menu_set_sensitive(ifactory, "/File/Attach file", FALSE);
+ menu_set_sensitive(ifactory, "/File/Insert signature", FALSE);
+ menu_set_sensitive(ifactory, "/Edit/Paste", FALSE);
+ menu_set_sensitive(ifactory, "/Edit/Wrap current paragraph", FALSE);
+ menu_set_sensitive(ifactory, "/Edit/Wrap all long lines", FALSE);
+ menu_set_sensitive(ifactory, "/Edit/Edit with external editor", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Attach", FALSE);
+#if USE_GPGME
+ menu_set_sensitive(ifactory, "/Message/Sign", FALSE);
+ menu_set_sensitive(ifactory, "/Message/Encrypt", FALSE);
+#endif
+ menu_set_sensitive(ifactory, "/Message/Request Return Receipt", FALSE);
+ menu_set_sensitive(ifactory, "/Tool/Template", FALSE);
+
+ gtk_widget_set_sensitive(c->insert_btn, FALSE);
+ gtk_widget_set_sensitive(c->attach_btn, FALSE);
+ gtk_widget_set_sensitive(c->sig_btn, FALSE);
+ gtk_widget_set_sensitive(c->exteditor_btn, FALSE);
+ gtk_widget_set_sensitive(c->linewrap_btn, FALSE);
+
+ return c;
+}
+
Compose * compose_new_with_recipient(PrefsAccount *account, const gchar *to)
{
return compose_generic_new(account, to, NULL);
return(gtk_clist_get_row_data(GTK_CLIST(compose->attach_clist), 0) != NULL);
}
+
+
+
+
+static gint compose_bounce_write_headers_from_headerlist(Compose *compose,
+ FILE *fp)
+{
+ gchar buf[BUFFSIZE];
+ gchar *str;
+ gboolean first_address;
+ GSList *list;
+ compose_headerentry *headerentry;
+ gchar * headerentryname;
+ gchar * header_w_colon;
+ gchar * cc_hdr;
+ gchar * to_hdr;
+
+ debug_print(_("Writing bounce header\n"));
+
+ header_w_colon = g_strconcat("To:", NULL);
+ to_hdr = (prefs_common.trans_hdr ? gettext(header_w_colon) : header_w_colon);
+ header_w_colon = g_strconcat("Cc:", NULL);
+ cc_hdr = (prefs_common.trans_hdr ? gettext(header_w_colon) : header_w_colon);
+
+ first_address = TRUE;
+ for(list = compose->header_list; list; list = list->next) {
+ headerentry = ((compose_headerentry *)list->data);
+ headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
+
+ if(g_strcasecmp(headerentryname, cc_hdr) == 0
+ || g_strcasecmp(headerentryname, to_hdr) == 0) {
+ str = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
+ if(str[0] != '\0') {
+ compose_convert_header
+ (buf, sizeof(buf), str,
+ strlen("Resent-To") + 2);
+ if(first_address) {
+ fprintf(fp, "Resent-To: ");
+ first_address = FALSE;
+ } else {
+ fprintf(fp, ",");
+ }
+ fprintf(fp, "%s", buf);
+ }
+ }
+ }
+ // if(!first_address) {
+ fprintf(fp, "\n");
+ // }
+
+ return(0);
+}
+
+
+static gint compose_bounce_write_headers(Compose *compose, FILE *fp)
+{
+ gchar buf[BUFFSIZE];
+ gchar *str;
+ /* struct utsname utsbuf; */
+
+ g_return_val_if_fail(fp != NULL, -1);
+ g_return_val_if_fail(compose->account != NULL, -1);
+ g_return_val_if_fail(compose->account->address != NULL, -1);
+
+ /* Date */
+ get_rfc822_date(buf, sizeof(buf));
+ fprintf(fp, "Resent-Date: %s\n", buf);
+
+ /* From */
+ if (compose->account->name && *compose->account->name) {
+ compose_convert_header
+ (buf, sizeof(buf), compose->account->name,
+ strlen("From: "));
+ fprintf(fp, "Resent-From: %s <%s>\n",
+ buf, compose->account->address);
+ } else
+ fprintf(fp, "Resent-From: %s\n", compose->account->address);
+
+ /* To */
+ compose_bounce_write_headers_from_headerlist(compose, fp);
+
+ /* separator between header and body */
+ fputs("\n", fp);
+
+ return 0;
+}
+
+static gint compose_bounce_write_to_file(Compose *compose, const gchar *file)
+{
+ FILE *fp;
+ FILE *fdest;
+ size_t len;
+ gchar buf[BUFFSIZE];
+
+ if ((fp = fopen(compose->bounce_filename, "r")) == NULL) {
+ FILE_OP_ERROR(file, "fopen");
+ return -1;
+ }
+
+ if ((fdest = fopen(file, "a+")) == NULL) {
+ FILE_OP_ERROR(file, "fopen");
+ fclose(fp);
+ return -1;
+ }
+
+ /* chmod for security */
+ if (change_file_mode_rw(fdest, file) < 0) {
+ FILE_OP_ERROR(file, "chmod");
+ g_warning(_("can't change file mode\n"));
+ }
+
+ while (procheader_get_unfolded_line(buf, sizeof(buf), fp)) {
+ if (fputs(buf, fdest) == -1)
+ goto error;
+ if (fputs("\n", fdest) == -1)
+ goto error;
+ }
+
+ compose_bounce_write_headers(compose, fdest);
+
+ while ((len = fread(buf, sizeof(gchar), BUFFSIZE, fp)) > 0) {
+ if (fwrite(buf, sizeof(gchar), len, fdest) == -1)
+ goto error;
+ }
+
+ fclose(fdest);
+ fclose(fp);
+
+ return 0;
+ error:
+ fclose(fdest);
+ fclose(fp);
+
+ return -1;
+}
+
static gint compose_write_to_file(Compose *compose, const gchar *file,
gboolean is_draft)
{
return 0;
}
+
static gint compose_queue(Compose *compose, gint *msgnum, FolderItem **item)
{
FolderItem *queue;
fprintf(fp, "\n");
fclose(fp);
- if (compose_write_to_file(compose, tmpfilename, FALSE) < 0) {
- unlink(tmpfilename);
- lock = FALSE;
- return -1;
+ if (compose->bounce_filename != NULL) {
+ if (compose_bounce_write_to_file(compose, tmpfilename) < 0) {
+ unlink(tmpfilename);
+ lock = FALSE;
+ return -1;
+ }
+ }
+ else {
+ if (compose_write_to_file(compose, tmpfilename, FALSE) < 0) {
+ unlink(tmpfilename);
+ lock = FALSE;
+ return -1;
+ }
}
/* queue message */
headerentry = ((compose_headerentry *)list->data);
headerentryname = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(headerentry->combo)->entry));
- if(!strcmp(trans_hdr, headerentryname)) {
+ if(!g_strcasecmp(trans_hdr, headerentryname)) {
str = gtk_entry_get_text(GTK_ENTRY(headerentry->entry));
Xstrdup_a(str, str, return -1);
g_strstrip(str);
compose->exteditor_readdes = -1;
compose->exteditor_tag = -1;
+ compose->bounce_filename = NULL;
+
compose_set_title(compose);
#if 0 /* NEW COMPOSE GUI */
g_free(compose->msgid);
g_free(compose->boundary);
+ if (compose->bounce_filename)
+ g_free(compose->bounce_filename);
+
g_free(compose->exteditor_file);
for (row = 0; (ainfo = gtk_clist_get_row_data(clist, row)) != NULL;
Compose *compose = (Compose *)data;
GList *file_list;
+ if (compose->bounce_filename != NULL)
+ return;
+
file_list = filesel_select_multiple_files(_("Select file"), NULL);
if (file_list) {