+2001-05-13
+
+ * merged the custom header stuff from claws branch:
+ * src/customheader.[ch]
+ src/prefs_customheader.[ch]: new.
+ * src/customheader.c: custom_header_read_str(): use strtol() instead
+ of atoi() and check errors.
+ custom_header_find(): new function.
+ * src/compose.c: IS_IN_CUSTOM_HEADER(): new macro.
+ compose_write_headers(): made it replace headers with user-defined
+ headers except for some automatically generated headers.
+
2001-05-11
* src/inc.c: connection_check_cb(): fixed a bug that caused
+2001-03-13 [alfons]
+
+ 0.4.67claws3
+
+ * sync with sylpheed 0.4.67cvs5
+
2001-05-13 [paul]
* added Alfons' font selection patch
+2001-05-13
+
+ * claws ¥Ö¥é¥ó¥Á¤«¤é¥«¥¹¥¿¥à¥Ø¥Ã¥À´ØÏ¢¤ò¥Þ¡¼¥¸:
+ * src/customheader.[ch]
+ src/prefs_customheader.[ch]: ¿·µ¬¡£
+ * src/customheader.c: custom_header_read_str(): atoi() ¤ÎÂå¤ï¤ê¤Ë
+ strtol() ¤ò»ÈÍѤ·¡¢¥¨¥é¡¼¤ò¥Á¥§¥Ã¥¯¤¹¤ë¤è¤¦¤Ë¤·¤¿¡£
+ * src/compose.c: IS_IN_CUSTOM_HEADER(): ¿·µ¬¥Þ¥¯¥í¡£
+ compose_write_headers(): ¥Ø¥Ã¥À¤ò¥æ¡¼¥¶ÄêµÁ¤Î¥Ø¥Ã¥À¤ÇÃÖ´¹¤¹¤ë
+ ¤è¤¦¤Ë¤·¤¿(¤¤¤¯¤Ä¤«¤Î¼«Æ°Åª¤ËÀ¸À®¤µ¤ì¤ë¥Ø¥Ã¥À¤ò½ü¤¯)¡£
+
2001-05-11
* src/inc.c: connection_check_cb(): Àܳ¤¬³ÎΩ¤·¤Ê¤«¤Ã¤¿¤È¤¤Ë
o list view of newsgroups and subscription of groups from there
o full-text search of messages (plain, or hooking up with Namazu)
o original icons and logos
-o designate the displayed headers
-o user-defined headers
o template function
o speed-up of filtering
o regular expression support at filtering
* completion of mail address
* prohibition of multiple execution (with Unix domain socket)
* periodical check of newly arrived mails
+* designate the displayed headers
+* user-defined headers
o ¥Ë¥å¡¼¥¹¥°¥ë¡¼¥×¤Î¥ê¥¹¥Èɽ¼¨¤È¤½¤³¤«¤é¤Î¹ØÆÉ¥°¥ë¡¼¥×ÄɲÃ
o ¥á¥Ã¥»¡¼¥¸¤ÎÁ´Ê¸¸¡º÷ (¥Ù¥¿¡¢ Namazu ¤È¤ÎÏ¢·È)
o ¥ª¥ê¥¸¥Ê¥ë¤Î¥¢¥¤¥³¥ó¤È¥í¥´
-o ɽ¼¨¤µ¤ì¤ë¥Ø¥Ã¥À¤Î»ØÄê
-o ¥æ¡¼¥¶ÄêµÁ¤Î¥Ø¥Ã¥À
o ¥Æ¥ó¥×¥ì¡¼¥Èµ¡Ç½
o ¿¶¤êʬ¤±½èÍý¤Î¹â®²½
o ¿¶¤êʬ¤±¤ÇÀµµ¬É½¸½¤ËÂбþ¤¹¤ë
* ¥á¡¼¥ë¥¢¥É¥ì¥¹¤ÎÊä´°
* Æó½Åµ¯Æ°ËÉ»ß (with Unix domain socket)
* ¿·Ãå¥á¡¼¥ë¤ÎÄê´üŪ¥Á¥§¥Ã¥¯
+* ɽ¼¨¤µ¤ì¤ë¥Ø¥Ã¥À¤Î»ØÄê
+* ¥æ¡¼¥¶ÄêµÁ¤Î¥Ø¥Ã¥À
MICRO_VERSION=67
INTERFACE_AGE=67
BINARY_AGE=67
-EXTRA_VERSION=claws2
+EXTRA_VERSION=claws3
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$EXTRA_VERSION
dnl
prefs_filter.c prefs_filter.h \
prefs_account.c prefs_account.h \
prefs_display_header.c prefs_display_header.h \
+ prefs_customheader.c prefs_customheader.h \
account.c account.h \
displayheader.c displayheader.h \
+ customheader.c customheader.h \
addressbook.c addressbook.h \
filesel.c filesel.h \
foldersel.c foldersel.h \
addr_compl.c addr_compl.h \
gtkstext.c gtkstext.h \
grouplist_dialog.c grouplist_dialog.h \
- customheader.c customheader.h \
- prefs_headers.c prefs_headers.h \
scoring.c scoring.h \
prefs_folder_item.c prefs_folder_item.h \
matcher.c matcher.h \
GdkColormap *cmap;
GdkColor uri_color[2] = {{0, 0, 0, 0xffff}, {0, 0xffff, 0, 0}};
gboolean success[2];
-
+
#if HAVE_SYS_UTSNAME_H
struct utsname utsbuf;
-#endif
+#endif
gchar buf[1024];
gint i;
gtk_container_set_border_width(GTK_CONTAINER(window), 8);
gtk_widget_set_usize(window, 518, 358);
gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
- /* gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE); */
gtk_signal_connect(GTK_OBJECT(window), "delete_event",
GTK_SIGNAL_FUNC(gtk_widget_hide_on_delete), NULL);
gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
label = gtk_label_new("version "VERSION);
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
-
+
#if HAVE_SYS_UTSNAME_H
uname(&utsbuf);
g_snprintf(buf, sizeof(buf),
#include "menu.h"
#include "send.h"
#include "news.h"
+#include "customheader.h"
#include "prefs_common.h"
#include "prefs_account.h"
#include "account.h"
#include "gtkshruler.h"
#include "folder.h"
#include "addr_compl.h"
-#include "customheader.h"
#if USE_GPGME
# include "rfc2015.h"
gtk_widget_grab_focus(compose->newsgroups_entry);
}
+#undef INSERT_FW_HEADER
+
void compose_reedit(MsgInfo *msginfo)
{
Compose *compose;
}
}
+#undef SET_ENTRY
+
static void compose_insert_sig(Compose *compose)
{
gchar *sigfile;
fprintf(fp, "\n--%s--\n", compose->boundary);
}
-static gint is_in_custom_headers(Compose *compose, gchar * header)
-{
- GSList * cur;
-
- if (compose->account->add_customhdr) {
- for (cur = compose->account->customhdr_list;
- cur != NULL; cur = cur->next) {
- CustomHeader * ch = (CustomHeader *) cur->data;
- if (strcasecmp(ch->name, header) == 0)
- return 1;
- }
- }
- return 0;
-}
+#define IS_IN_CUSTOM_HEADER(header) \
+ (compose->account->add_customhdr && \
+ custom_header_find(compose->account->customhdr_list, header) != NULL)
static gint compose_write_headers(Compose *compose, FILE *fp,
const gchar *charset, EncodingType encoding,
gchar buf[BUFFSIZE];
gchar *str;
/* struct utsname utsbuf; */
- GSList * cur;
g_return_val_if_fail(fp != NULL, -1);
g_return_val_if_fail(charset != NULL, -1);
g_return_val_if_fail(compose->account->address != NULL, -1);
/* Date */
- if (!is_in_custom_headers(compose, "Date")) {
- if (compose->account->add_date) {
- get_rfc822_date(buf, sizeof(buf));
- fprintf(fp, "Date: %s\n", buf);
- }
+ if (compose->account->add_date) {
+ get_rfc822_date(buf, sizeof(buf));
+ fprintf(fp, "Date: %s\n", buf);
}
-
+
/* From */
- if (!is_in_custom_headers(compose, "From")) {
+ if (!IS_IN_CUSTOM_HEADER("From")) {
if (compose->account->name && *compose->account->name) {
compose_convert_header
(buf, sizeof(buf), compose->account->name,
strlen("From: "));
- fprintf(fp, "From: %s <%s>\n", buf, compose->account->address);
+ fprintf(fp, "From: %s <%s>\n",
+ buf, compose->account->address);
} else
fprintf(fp, "From: %s\n", compose->account->address);
}
-
+
slist_free_strings(compose->to_list);
g_slist_free(compose->to_list);
compose->to_list = NULL;
if (*str != '\0') {
compose->to_list = address_list_append
(compose->to_list, str);
- compose_convert_header(buf, sizeof(buf), str,
- strlen("To: "));
- if (!is_in_custom_headers(compose, "To")) {
+ if (!IS_IN_CUSTOM_HEADER("To")) {
+ compose_convert_header
+ (buf, sizeof(buf), str,
+ strlen("To: "));
fprintf(fp, "To: %s\n", buf);
}
}
}
}
-
+
slist_free_strings(compose->newsgroup_list);
g_slist_free(compose->newsgroup_list);
compose->newsgroup_list = NULL;
compose->newsgroup_list =
newsgroup_list_append(compose->newsgroup_list,
str);
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Newsgroups: "));
- if (!is_in_custom_headers(compose, "Newsgroups")) {
+ if (!IS_IN_CUSTOM_HEADER("Newsgroups")) {
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Newsgroups: "));
fprintf(fp, "Newsgroups: %s\n", buf);
}
}
if (*str != '\0') {
compose->to_list = address_list_append
(compose->to_list, str);
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Cc: "));
- if (!is_in_custom_headers(compose, "Cc")) {
+ if (!IS_IN_CUSTOM_HEADER("Cc")) {
+ compose_convert_header
+ (buf, sizeof(buf), str,
+ strlen("Cc: "));
fprintf(fp, "Cc: %s\n", buf);
}
}
}
}
-
+
/* Bcc */
if (compose->use_bcc) {
str = gtk_entry_get_text(GTK_ENTRY(compose->bcc_entry));
compose_convert_header
(buf, sizeof(buf), str,
strlen("Bcc: "));
- if (!is_in_custom_headers(compose,
- "Bcc")) {
- fprintf(fp, "Bcc: %s\n", buf);
- }
+ fprintf(fp, "Bcc: %s\n", buf);
}
}
}
}
/* Subject */
- if (!is_in_custom_headers(compose, "Subject")) {
- str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
+ str = gtk_entry_get_text(GTK_ENTRY(compose->subject_entry));
+ if (*str != '\0' && !IS_IN_CUSTOM_HEADER("Subject")) {
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Subject: "));
- fprintf(fp, "Subject: %s\n", buf);
- }
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Subject: "));
+ fprintf(fp, "Subject: %s\n", buf);
}
}
/* Message-ID */
- if (!is_in_custom_headers(compose, "Message-Id")) {
- if (compose->account->gen_msgid) {
- compose_generate_msgid(compose, buf, sizeof(buf));
- fprintf(fp, "Message-Id: <%s>\n", buf);
- compose->msgid = g_strdup(buf);
- }
+ if (compose->account->gen_msgid) {
+ compose_generate_msgid(compose, buf, sizeof(buf));
+ fprintf(fp, "Message-Id: <%s>\n", buf);
+ compose->msgid = g_strdup(buf);
}
/* In-Reply-To */
- if (!is_in_custom_headers(compose, "In-Reply-To")) {
- if (compose->inreplyto && compose->to_list)
- fprintf(fp, "In-Reply-To: <%s>\n", compose->inreplyto);
- }
+ if (compose->inreplyto && compose->to_list)
+ fprintf(fp, "In-Reply-To: <%s>\n", compose->inreplyto);
/* References */
- if (!is_in_custom_headers(compose, "References")) {
- if (compose->references)
- fprintf(fp, "References: %s\n", compose->references);
- }
+ if (compose->references)
+ fprintf(fp, "References: %s\n", compose->references);
/* Followup-To */
- if (!is_in_custom_headers(compose, "Followup-To")) {
- if (compose->use_followupto) {
- str = gtk_entry_get_text(GTK_ENTRY(compose->followup_entry));
+ if (compose->use_followupto && !IS_IN_CUSTOM_HEADER("Followup-To")) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->followup_entry));
+ if (*str != '\0') {
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
+ remove_space(str);
if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- remove_space(str);
- if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Followup-To: "));
- fprintf(fp, "Followup-To: %s\n", buf);
- }
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Followup-To: "));
+ fprintf(fp, "Followup-To: %s\n", buf);
}
}
}
/* Reply-To */
- if (!is_in_custom_headers(compose, "Reply-To")) {
- if (compose->use_replyto) {
- str = gtk_entry_get_text(GTK_ENTRY(compose->reply_entry));
+ if (compose->use_replyto && !IS_IN_CUSTOM_HEADER("Reply-To")) {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->reply_entry));
+ if (*str != '\0') {
+ Xstrdup_a(str, str, return -1);
+ g_strstrip(str);
if (*str != '\0') {
- Xstrdup_a(str, str, return -1);
- g_strstrip(str);
- if (*str != '\0') {
- compose_convert_header(buf, sizeof(buf), str,
- strlen("Reply-To: "));
- fprintf(fp, "Reply-To: %s\n", buf);
- }
+ compose_convert_header(buf, sizeof(buf), str,
+ strlen("Reply-To: "));
+ fprintf(fp, "Reply-To: %s\n", buf);
}
}
}
/* Program version and system info */
/* uname(&utsbuf); */
- if (!is_in_custom_headers(compose, "X-Mailer")) {
- str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
- if (*str != '\0') {
- fprintf(fp, "X-Mailer: %s (GTK+ %d.%d.%d; %s)\n",
- prog_version,
- gtk_major_version, gtk_minor_version, gtk_micro_version,
- HOST_ALIAS);
+ str = gtk_entry_get_text(GTK_ENTRY(compose->to_entry));
+ if (*str != '\0' && !IS_IN_CUSTOM_HEADER("X-Mailer")) {
+ fprintf(fp, "X-Mailer: %s (GTK+ %d.%d.%d; %s)\n",
+ prog_version,
+ gtk_major_version, gtk_minor_version, gtk_micro_version,
+ HOST_ALIAS);
/* utsbuf.sysname, utsbuf.release, utsbuf.machine); */
- }
}
-
- if (!is_in_custom_headers(compose, "X-Newsreader")) {
- str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
- if (*str != '\0') {
+ str = gtk_entry_get_text(GTK_ENTRY(compose->newsgroups_entry));
+ if (*str != '\0' && !IS_IN_CUSTOM_HEADER("X-Newsreader")) {
fprintf(fp, "X-Newsreader: %s (GTK+ %d.%d.%d; %s)\n",
prog_version,
gtk_major_version, gtk_minor_version, gtk_micro_version,
HOST_ALIAS);
/* utsbuf.sysname, utsbuf.release, utsbuf.machine); */
- }
}
/* Organization */
- if (!is_in_custom_headers(compose, "Organization")) {
- if (compose->account->organization) {
- compose_convert_header(buf, sizeof(buf),
- compose->account->organization,
- strlen("Organization: "));
- fprintf(fp, "Organization: %s\n", buf);
- }
+ if (compose->account->organization &&
+ !IS_IN_CUSTOM_HEADER("Organization")) {
+ compose_convert_header(buf, sizeof(buf),
+ compose->account->organization,
+ strlen("Organization: "));
+ fprintf(fp, "Organization: %s\n", buf);
}
/* MIME */
- if (!is_in_custom_headers(compose, "Mime-Version")) {
- fprintf(fp, "Mime-Version: 1.0\n");
- }
-
- /* Request Return Receipt */
- if (!is_in_custom_headers(compose, "Disposition-Notification-To")) {
- if (compose->return_receipt) {
- if (compose->account->name
- && *compose->account->name) {
- compose_convert_header(buf, sizeof(buf), compose->account->name, strlen("Disposition-Notification-To: "));
- fprintf(fp, "Disposition-Notification-To: %s <%s>\n", buf, compose->account->address);
- } else
- fprintf(fp, "Disposition-Notification-To: %s\n", compose->account->address);
- }
- }
-
+ fprintf(fp, "Mime-Version: 1.0\n");
if (compose->use_attach) {
get_rfc822_date(buf, sizeof(buf));
subst_char(buf, ' ', '_');
subst_char(buf, ',', '_');
compose->boundary = g_strdup_printf("Multipart_%s_%08x",
buf, (guint)compose);
- if (!is_in_custom_headers(compose, "Content-Type")) {
- fprintf(fp,
- "Content-Type: multipart/mixed;\n"
- " boundary=\"%s\"\n", compose->boundary);
- }
+ fprintf(fp,
+ "Content-Type: multipart/mixed;\n"
+ " boundary=\"%s\"\n", compose->boundary);
} else {
- if (!is_in_custom_headers(compose, "Content-Type")) {
- fprintf(fp, "Content-Type: text/plain; charset=%s\n", charset);
- }
- if (!is_in_custom_headers(compose,
- "Content-Transfer-Encoding")) {
- fprintf(fp, "Content-Transfer-Encoding: %s\n",
- procmime_get_encoding_str(encoding));
- }
+ fprintf(fp, "Content-Type: text/plain; charset=%s\n", charset);
+ fprintf(fp, "Content-Transfer-Encoding: %s\n",
+ procmime_get_encoding_str(encoding));
}
- /* Custom Headers */
+ /* custom headers */
if (compose->account->add_customhdr) {
+ GSList *cur;
+
for (cur = compose->account->customhdr_list; cur != NULL;
cur = cur->next) {
- CustomHeader * ch = (CustomHeader *) cur->data;
- fprintf(fp, "%s: %s\n", ch->name, ch->value);
+ CustomHeader *chdr = (CustomHeader *)cur->data;
+
+ if (strcasecmp(chdr->name, "Date") != 0 &&
+ strcasecmp(chdr->name, "Message-Id") != 0 &&
+ strcasecmp(chdr->name, "In-Reply-To") != 0 &&
+ strcasecmp(chdr->name, "References") != 0 &&
+ strcasecmp(chdr->name, "Mime-Version") != 0 &&
+ strcasecmp(chdr->name, "Content-Type") != 0 &&
+ strcasecmp(chdr->name, "Content-Transfer-Encoding") != 0)
+ fprintf(fp, "%s: %s\n",
+ chdr->name, chdr->value);
+ }
+ }
+
+ /* Request Return Receipt */
+ if (!IS_IN_CUSTOM_HEADER("Disposition-Notification-To")) {
+ if (compose->return_receipt) {
+ if (compose->account->name
+ && *compose->account->name) {
+ compose_convert_header(buf, sizeof(buf), compose->account->name, strlen("Disposition-Notification-To: "));
+ fprintf(fp, "Disposition-Notification-To: %s <%s>\n", buf, compose->account->address);
+ } else
+ fprintf(fp, "Disposition-Notification-To: %s\n", compose->account->address);
}
}
return 0;
}
+#undef IS_IN_CUSTOM_HEADER
+
static void compose_convert_header(gchar *dest, gint len, gchar *src,
gint header_len)
{
(GTK_CHECK_MENU_ITEM(menuitem), TRUE);
gtk_widget_set_sensitive(menuitem, FALSE);
}
+ if (account->set_autocc && account->auto_cc) {
+ gtk_entry_set_text(GTK_ENTRY(cc_entry), account->auto_cc);
+ menuitem = gtk_item_factory_get_item(ifactory, "/Message/Cc");
+ gtk_check_menu_item_set_active
+ (GTK_CHECK_MENU_ITEM(menuitem), TRUE);
+ }
if (account->set_autobcc) {
menuitem = gtk_item_factory_get_item(ifactory, "/Message/Bcc");
gtk_check_menu_item_set_active
gtk_widget_show_all(toolbar);
}
+#undef CREATE_TOOLBAR_ICON
+
static GtkWidget *compose_account_option_menu_create(Compose *compose)
{
GList *accounts;
attach_prop.cancel_btn = cancel_btn;
}
+#undef SET_LABEL_AND_ENTRY
+
static void attach_property_ok(GtkWidget *widget, gboolean *cancelled)
{
*cancelled = FALSE;
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#include <glib.h>
#include <string.h>
-#include <strings.h>
#include <stdlib.h>
#include "intl.h"
#include "utils.h"
-gchar * custom_header_get_str(CustomHeader *ch)
+gchar *custom_header_get_str(CustomHeader *ch)
{
- return g_strdup_printf
- ("%i:%s: %s", ch->account_id, ch->name, ch->value);
+ return g_strdup_printf("%i:%s: %s",
+ ch->account_id, ch->name, ch->value);
}
-
-CustomHeader * custom_header_read_str(gchar * buf)
+
+CustomHeader *custom_header_read_str(const gchar *buf)
{
- CustomHeader * ch;
- gchar * account_id_str;
- gchar * name;
- gchar * value;
- gchar * tmp;
-
- Xalloca(tmp, strlen(buf) + 1, return NULL);
- strcpy(tmp, buf);
+ CustomHeader *ch;
+ gchar *account_id_str;
+ gint id;
+ gchar *name;
+ gchar *value;
+ gchar *tmp;
+
+ Xstrdup_a(tmp, buf, return NULL);
+ g_strstrip(tmp);
account_id_str = tmp;
- name = strchr(account_id_str, ':');
- if (!name)
- return NULL;
- else
- *name++ = '\0';
+ name = strchr(account_id_str, ':');
+ if (!name)
+ return NULL;
+ else {
+ gchar *endp;
+
+ *name++ = '\0';
+ id = strtol(account_id_str, &endp, 10);
+ if (*endp != '\0') return NULL;
+ }
+
+ while (*name == ' ') name++;
- while (*name == ' ')
- name ++;
-
- ch = g_new0(CustomHeader, 1);
+ ch = g_new0(CustomHeader, 1);
+ ch->account_id = id;
- ch->account_id = atoi(account_id_str);
- if (ch->account_id == 0) {
+ value = strchr(name, ':');
+ if (!value) {
g_free(ch);
return NULL;
+ } else
+ *value++ = '\0';
+
+ ch->name = *name ? g_strdup(name) : NULL;
+ while (*value == ' ') value++;
+ ch->value = *value ? g_strdup(value) : NULL;
+
+ return ch;
+}
+
+CustomHeader *custom_header_find(GSList *header_list, const gchar *header)
+{
+ GSList *cur;
+ CustomHeader *chdr;
+
+ for (cur = header_list; cur != NULL; cur = cur->next) {
+ chdr = (CustomHeader *)cur->data;
+ if (!strcasecmp(chdr->name, header))
+ return chdr;
}
- value = strchr(name, ':');
- if (!value)
- {
- g_free(ch);
- return NULL;
- }
- else
- *value++ = '\0';
-
- ch->name = *name ? g_strdup(name) : NULL;
-
- while (*value == ' ')
- value ++;
-
- ch->value = *value ? g_strdup(value) : NULL;
-
- return ch;
+ return NULL;
}
-
+
void custom_header_free(CustomHeader *ch)
{
- if (!ch) return;
-
+ if (!ch) return;
+
if (ch->name)
g_free(ch->name);
if (ch->value)
g_free(ch->value);
-
- g_free(ch);
+
+ g_free(ch);
}
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#ifndef __CUSTOMHEADER_H__
#define __CUSTOMHEADER_H__
+#include <glib.h>
+
struct _CustomHeader
{
- int account_id;
+ gint account_id;
gchar *name;
gchar *value;
};
-typedef struct _CustomHeader CustomHeader;
+typedef struct _CustomHeader CustomHeader;
-gchar * custom_header_get_str(CustomHeader *ch);
-CustomHeader * custom_header_read_str(gchar * buf);
-void custom_header_free(CustomHeader *ch);
+gchar *custom_header_get_str (CustomHeader *ch);
+CustomHeader *custom_header_read_str (const gchar *buf);
+CustomHeader *custom_header_find (GSList *header_list,
+ const gchar *header);
+void custom_header_free (CustomHeader *ch);
#endif /* __CUSTOMHEADER_H__ */
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999,2000 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2001 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
#define COMMON_RC "sylpheedrc"
#define ACCOUNT_RC "accountrc"
#define FILTER_RC "filterrc"
-#define HEADERS_RC "headersrc"
+#define CUSTOM_HEADER_RC "customheaderrc"
#define DISPLAY_HEADER_RC "dispheaderrc"
#define FOLDERITEM_RC "folderitemrc"
#define SCORING_RC "scoringrc"
#define FOLDER_SPACING 4
#define COLOR_DIM 35000
-#if 0
-#define NORMAL_FONT "-*-helvetica-medium-r-normal--12-*," \
- "-*-*-medium-r-normal--12-*-*-*-*-*-*-*,*"
-#define BOLD_FONT "-*-helvetica-bold-r-normal--12-*," \
- "-*-*-bold-r-normal--12-*-*-*-*-*-*-*,*"
-#define SMALL_FONT "-*-helvetica-medium-r-normal--10-*," \
- "-*-*-medium-r-normal--10-*-*-*-*-*-*-*,*"
-#else
#define NORMAL_FONT prefs_common.normalfont
#define BOLD_FONT prefs_common.boldfont
#define SMALL_FONT prefs_common.smallfont
-#endif
#endif /* __DEFS_H__ */
"clicked", GTK_SIGNAL_FUNC(filesel_cancel_cb),
NULL);
gtk_signal_connect(GTK_OBJECT(filesel), "delete_event",
- GTK_SIGNAL_FUNC(delete_event),
- NULL);
+ GTK_SIGNAL_FUNC(delete_event), NULL);
gtk_signal_connect(GTK_OBJECT(filesel), "key_press_event",
GTK_SIGNAL_FUNC(key_pressed), NULL);
gtk_signal_connect(GTK_OBJECT(filesel), "focus_in_event",
#include "main.h"
#include "prefs.h"
#include "prefs_account.h"
+#include "prefs_customheader.h"
#include "account.h"
#include "mainwindow.h"
#include "manage_window.h"
#include "gtkutils.h"
#include "utils.h"
#include "alertpanel.h"
-#include "prefs_headers.h"
static gboolean cancelled;
#endif /* USE_GPGME */
static void prefs_account_advanced_create (void);
+static void prefs_account_edit_custom_header (void);
+
static gint prefs_account_deleted (GtkWidget *widget,
GdkEventAny *event,
gpointer data);
static gint prefs_account_apply (void);
static void prefs_account_cancel (void);
-static void prefs_account_customhdr_edit (void);
#define VSPACING 12
#define VSPACING_NARROW 4
gtk_widget_show (hbox);
gtk_box_pack_start (GTK_BOX (vbox2), hbox, FALSE, FALSE, 0);
- /* gtk_widget_set_sensitive(hbox, FALSE); */
-
PACK_CHECK_BUTTON (hbox, customhdr_chkbtn,
_("Add user-defined header"));
gtk_widget_show (customhdr_edit_btn);
gtk_box_pack_start (GTK_BOX (hbox), customhdr_edit_btn,
FALSE, FALSE, 0);
+ gtk_signal_connect (GTK_OBJECT (customhdr_edit_btn), "clicked",
+ GTK_SIGNAL_FUNC (prefs_account_edit_custom_header),
+ NULL);
SET_TOGGLE_SENSITIVITY (customhdr_chkbtn, customhdr_edit_btn);
_("Authenticate with POP3 before sending"));
gtk_widget_set_sensitive(pop_bfr_smtp_chkbtn, FALSE);
- gtk_signal_connect(GTK_OBJECT(customhdr_edit_btn), "clicked",
- GTK_SIGNAL_FUNC(prefs_account_customhdr_edit),
- NULL);
-
send.date_chkbtn = date_chkbtn;
send.msgid_chkbtn = msgid_chkbtn;
send.customhdr_chkbtn = customhdr_chkbtn;
gtk_main_quit();
}
-static void prefs_account_customhdr_edit(void)
+static void prefs_account_edit_custom_header(void)
{
prefs_headers_open(&tmp_ac_prefs);
}
A_IMAP4,
A_NNTP,
A_LOCAL,
- // A_LOCAL_CMD
} RecvProtocol;
#if USE_GPGME
#include "intl.h"
#include "main.h"
#include "prefs.h"
-#include "prefs_headers.h"
+#include "prefs_customheader.h"
#include "prefs_common.h"
#include "prefs_account.h"
#include "mainwindow.h"
#include "foldersel.h"
#include "manage_window.h"
#include "customheader.h"
+#include "folder.h"
#include "utils.h"
#include "gtkutils.h"
#include "alertpanel.h"
-#include "folder.h"
static struct Headers {
GtkWidget *window;
- /*
- GtkWidget *close_btn;
- */
GtkWidget *ok_btn;
GtkWidget *cancel_btn;
GtkWidget *headers_clist;
} headers;
-/*
- parameter name, default value, pointer to the prefs variable, data type,
- pointer to the widget pointer,
- pointer to the function for data setting,
- pointer to the function for widget setting
- */
-
#define VSPACING 12
#define VSPACING_NARROW 4
#define DEFAULT_ENTRY_WIDTH 80
#define PREFSBUFSIZE 1024
/* widget creating functions */
-static void prefs_headers_create (void);
+static void prefs_headers_create (void);
-static void prefs_headers_set_dialog (PrefsAccount * ac);
-static void prefs_headers_set_list (PrefsAccount * ac);
-static gint prefs_headers_clist_set_row (PrefsAccount * ac,
- gint row);
+static void prefs_headers_set_dialog (PrefsAccount *ac);
+static void prefs_headers_set_list (PrefsAccount *ac);
+static gint prefs_headers_clist_set_row (PrefsAccount *ac,
+ gint row);
/* callback functions */
-static void prefs_headers_select_dest_cb (void);
static void prefs_headers_register_cb (void);
static void prefs_headers_substitute_cb (void);
static void prefs_headers_delete_cb (void);
static void prefs_headers_up (void);
static void prefs_headers_down (void);
-static void prefs_headers_select (GtkCList *clist,
+static void prefs_headers_select (GtkCList *clist,
gint row,
gint column,
GdkEvent *event);
static void prefs_headers_key_pressed (GtkWidget *widget,
GdkEventKey *event,
gpointer data);
-/*
-static void prefs_headers_close (GtkButton *button);
-*/
static void prefs_headers_ok (GtkButton *button);
static void prefs_headers_cancel (GtkButton *button);
-static gint prefs_headers_deleted(GtkWidget *widget, GdkEventAny *event,
- gpointer data);
+static gint prefs_headers_deleted (GtkWidget *widget,
+ GdkEventAny *event,
+ gpointer data);
-static PrefsAccount * cur_ac = NULL;
+static PrefsAccount *cur_ac = NULL;
-void prefs_headers_open(PrefsAccount * ac)
+void prefs_headers_open(PrefsAccount *ac)
{
if (!headers.window) {
prefs_headers_create();
}
manage_window_set_transient(GTK_WINDOW(headers.window));
- /*
- gtk_widget_grab_focus(headers.close_btn);
- */
gtk_widget_grab_focus(headers.ok_btn);
prefs_headers_set_dialog(ac);
GtkWidget *window;
GtkWidget *vbox;
- /* GtkWidget *close_btn; */
GtkWidget *ok_btn;
GtkWidget *cancel_btn;
gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
&cancel_btn, _("Cancel"), NULL, NULL);
- /*
- gtkut_button_set_create (&confirm_area, &close_btn, _("Close"),
- NULL, NULL, NULL, NULL);
- */
gtk_widget_show (confirm_area);
gtk_box_pack_end (GTK_BOX(vbox), confirm_area, FALSE, FALSE, 0);
- /*
- gtk_widget_grab_default (close_btn);
- */
gtk_widget_grab_default (ok_btn);
gtk_window_set_title (GTK_WINDOW(window),
gtk_signal_connect (GTK_OBJECT (down_btn), "clicked",
GTK_SIGNAL_FUNC (prefs_headers_down), NULL);
-
gtk_widget_show_all(window);
- headers.window = window;
- /* headers.close_btn = close_btn; */
- headers.ok_btn = ok_btn;
+ headers.window = window;
+ headers.ok_btn = ok_btn;
headers.cancel_btn = cancel_btn;
headers.hdr_combo = hdr_combo;
headers.hdr_entry = GTK_COMBO (hdr_combo)->entry;
headers.key_entry = key_entry;
+
headers.headers_clist = headers_clist;
}
-void prefs_headers_read_config(PrefsAccount * ac)
+void prefs_headers_read_config(PrefsAccount *ac)
{
gchar *rcpath;
FILE *fp;
debug_print(_("Reading headers configuration...\n"));
- rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, HEADERS_RC, NULL);
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ CUSTOM_HEADER_RC, NULL);
if ((fp = fopen(rcpath, "r")) == NULL) {
if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
g_free(rcpath);
}
g_free(rcpath);
- /* remove all previous headers list */
- while (ac->customhdr_list != NULL) {
- ch = (CustomHeader *)ac->customhdr_list->data;
- custom_header_free(ch);
- ac->customhdr_list = g_slist_remove(ac->customhdr_list, ch);
- }
-
- while (fgets(buf, sizeof(buf), fp) != NULL) {
- g_strchomp(buf);
- ch = custom_header_read_str(buf);
- if (ch) {
- if (ch->account_id == ac->account_id)
+ /* remove all previous headers list */
+ while (ac->customhdr_list != NULL) {
+ ch = (CustomHeader *)ac->customhdr_list->data;
+ custom_header_free(ch);
+ ac->customhdr_list = g_slist_remove(ac->customhdr_list, ch);
+ }
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ g_strchomp(buf);
+ ch = custom_header_read_str(buf);
+ if (ch) {
+ if (ch->account_id == ac->account_id) {
ac->customhdr_list =
g_slist_append(ac->customhdr_list, ch);
- else
+ } else
custom_header_free(ch);
- }
- }
-
- fclose(fp);
+ }
+ }
+
+ fclose(fp);
}
-void prefs_headers_write_config(PrefsAccount * ac)
+void prefs_headers_write_config(PrefsAccount *ac)
{
gchar *rcpath;
PrefFile *pfile;
debug_print(_("Writing headers configuration...\n"));
- rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, HEADERS_RC, NULL);
+ rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
+ CUSTOM_HEADER_RC, NULL);
if ((fp = fopen(rcpath, "r")) == NULL) {
if (ENOENT != errno) FILE_OP_ERROR(rcpath, "fopen");
- }
- else {
+ } else {
all_hdrs = NULL;
while (fgets(buf, sizeof(buf), fp) != NULL) {
}
}
-static void prefs_headers_set_dialog(PrefsAccount * ac)
+static void prefs_headers_set_dialog(PrefsAccount *ac)
{
GtkCList *clist = GTK_CLIST(headers.headers_clist);
GSList *cur;
gtk_clist_thaw(clist);
}
-static void prefs_headers_set_list(PrefsAccount * ac)
+static void prefs_headers_set_list(PrefsAccount *ac)
{
gint row = 1;
CustomHeader *ch;
}
}
-#define GET_ENTRY(entry) \
- entry_text = gtk_entry_get_text(GTK_ENTRY(entry))
-
-static gint prefs_headers_clist_set_row(PrefsAccount * ac, gint row)
+static gint prefs_headers_clist_set_row(PrefsAccount *ac, gint row)
{
GtkCList *clist = GTK_CLIST(headers.headers_clist);
CustomHeader *ch;
g_return_val_if_fail(row != 0, -1);
- GET_ENTRY(headers.hdr_entry);
+ entry_text = gtk_entry_get_text(GTK_ENTRY(headers.hdr_entry));
if (entry_text[0] == '\0') {
alertpanel_error(_("Header name is not set."));
return -1;
ch->name = g_strdup(entry_text);
- GET_ENTRY(headers.key_entry);
+ entry_text = gtk_entry_get_text(GTK_ENTRY(headers.key_entry));
if (entry_text[0] != '\0')
ch->value = g_strdup(entry_text);
ENTRY_SET_TEXT(headers.key_entry, ch->value);
}
+#undef ENTRY_SET_TEXT
+
static void prefs_headers_key_pressed(GtkWidget *widget, GdkEventKey *event,
gpointer data)
{
static void prefs_headers_cancel(GtkButton *button)
{
- /*
- prefs_headers_write_config(cur_ac);
- */
prefs_headers_read_config(cur_ac);
gtk_widget_hide(headers.window);
}
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
-#ifndef __PREFS_HEADERS_H__
-#define __PREFS_HEADERS_H__
+#ifndef __PREFS_CUSTOMHEADER_H__
+#define __PREFS_CUSTOMHEADER_H__
-void prefs_headers_read_config (PrefsAccount * ac);
-void prefs_headers_write_config (PrefsAccount * ac);
-void prefs_headers_open (PrefsAccount * ac);
+void prefs_headers_read_config (PrefsAccount *ac);
+void prefs_headers_write_config (PrefsAccount *ac);
+void prefs_headers_open (PrefsAccount *ac);
-#endif /* __PREFS_HEADERS_H__ */
+#endif /* __PREFS_CUSTOMHEADER_H__ */