enhanced account selection on replies
This commit is contained in:
parent
9792804a7e
commit
63359dab79
10 changed files with 127 additions and 15 deletions
1
AUTHORS
1
AUTHORS
|
@ -79,3 +79,4 @@ contributors (beside the above; based on Changelog)
|
|||
Don Quijote
|
||||
David Looney
|
||||
Eric Limpens
|
||||
Melvin Hadasht
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
2001-08-30 [paul]
|
||||
|
||||
* src/account.c, src/compose.c, src/prefs_common.[ch]
|
||||
* src/procheader.[ch] src/utils.[ch]
|
||||
Enhanced automatic account selection on replies
|
||||
Submitted by Melvin Hadasht <melvin.hadasht@free.fr>
|
||||
|
||||
2001-08-29 [christoph]
|
||||
|
||||
* src/summeryview.c
|
||||
|
|
|
@ -195,7 +195,7 @@ PrefsAccount *account_find_from_address(const gchar *address)
|
|||
|
||||
for (cur = account_list; cur != NULL; cur = cur->next) {
|
||||
ac = (PrefsAccount *)cur->data;
|
||||
if (ac->protocol != A_NNTP && !strcmp2(address, ac->address))
|
||||
if (ac->protocol != A_NNTP && !strstr2(address, ac->address))
|
||||
return ac;
|
||||
}
|
||||
|
||||
|
|
|
@ -589,6 +589,14 @@ static void compose_generic_reply(MsgInfo *msginfo, gboolean quote,
|
|||
extract_address(to);
|
||||
account = account_find_from_address(to);
|
||||
}
|
||||
if(!account&& prefs_common.reply_account_autosel) {
|
||||
gchar cc[BUFFSIZE];
|
||||
if(!get_header_from_msginfo(msginfo,cc,sizeof(cc),"CC:")){ /* Found a CC header */
|
||||
extract_address(cc);
|
||||
account = account_find_from_address(cc);
|
||||
}
|
||||
}
|
||||
|
||||
if (!account) account = cur_account;
|
||||
g_return_if_fail(account != NULL);
|
||||
|
||||
|
@ -909,7 +917,23 @@ Compose * compose_forward(PrefsAccount * account, MsgInfo *msginfo,
|
|||
g_return_val_if_fail(msginfo != NULL, NULL);
|
||||
g_return_val_if_fail(msginfo->folder != NULL, NULL);
|
||||
|
||||
if (account == NULL) {
|
||||
account = msginfo->folder->folder->account;
|
||||
if (!account && msginfo->to && prefs_common.forward_account_autosel) {
|
||||
gchar *to;
|
||||
Xstrdup_a(to, msginfo->to, return);
|
||||
extract_address(to);
|
||||
account = account_find_from_address(to);
|
||||
}
|
||||
|
||||
if(!account&& prefs_common.forward_account_autosel) {
|
||||
gchar cc[BUFFSIZE];
|
||||
if(!get_header_from_msginfo(msginfo,cc,sizeof(cc),"CC:")){ /* Found a CC header */
|
||||
extract_address(cc);
|
||||
account = account_find_from_address(cc);
|
||||
}
|
||||
}
|
||||
|
||||
if (account == NULL) {
|
||||
account = cur_account;
|
||||
/*
|
||||
account = msginfo->folder->folder->account;
|
||||
|
@ -1004,7 +1028,7 @@ Compose * compose_forward_multiple(PrefsAccount * account,
|
|||
if ( ((MsgInfo *)msginfo->data)->folder == NULL )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (account == NULL) {
|
||||
account = cur_account;
|
||||
/*
|
||||
|
@ -1055,8 +1079,14 @@ void compose_reedit(MsgInfo *msginfo)
|
|||
g_return_if_fail(msginfo != NULL);
|
||||
g_return_if_fail(msginfo->folder != NULL);
|
||||
|
||||
account = msginfo->folder->folder->account;
|
||||
if (!account) account = cur_account;
|
||||
if(!account&& prefs_common.reedit_account_autosel) {
|
||||
gchar from[BUFFSIZE];
|
||||
if(!get_header_from_msginfo(msginfo,from,sizeof(from),"FROM:")){ /* Found a FROM header */
|
||||
extract_address(from);
|
||||
account = account_find_from_address(from);
|
||||
}
|
||||
}
|
||||
if (!account) account = cur_account;
|
||||
g_return_if_fail(account != NULL);
|
||||
|
||||
compose = compose_create(account);
|
||||
|
|
|
@ -99,10 +99,13 @@ static struct Compose {
|
|||
GtkWidget *checkbtn_autosig;
|
||||
GtkWidget *entry_sigsep;
|
||||
|
||||
GtkWidget *checkbtn_reply_account_autosel;
|
||||
GtkWidget *entry_fw_quotemark;
|
||||
GtkWidget *text_fw_quotefmt;
|
||||
|
||||
GtkWidget *checkbtn_reply_account_autosel;
|
||||
GtkWidget *checkbtn_forward_account_autosel;
|
||||
GtkWidget *checkbtn_reedit_account_autosel;
|
||||
|
||||
GtkWidget *spinbtn_linewrap;
|
||||
GtkObject *spinbtn_linewrap_adj;
|
||||
GtkWidget *checkbtn_wrapquote;
|
||||
|
@ -301,10 +304,18 @@ static PrefParam param[] = {
|
|||
{"signature_separator", "-- ", &prefs_common.sig_sep, P_STRING,
|
||||
&compose.entry_sigsep, prefs_set_data_from_entry, prefs_set_entry},
|
||||
|
||||
{"reply_account_autoselect", "TRUE",
|
||||
{"reply_account_autoselect", "TRUE",
|
||||
&prefs_common.reply_account_autosel, P_BOOL,
|
||||
&compose.checkbtn_reply_account_autosel,
|
||||
prefs_set_data_from_toggle, prefs_set_toggle},
|
||||
{"forward_account_autoselect", "TRUE",
|
||||
&prefs_common.forward_account_autosel, P_BOOL,
|
||||
&compose.checkbtn_forward_account_autosel,
|
||||
prefs_set_data_from_toggle, prefs_set_toggle},
|
||||
{"reedit_account_autoselect", "TRUE",
|
||||
&prefs_common.reedit_account_autosel, P_BOOL,
|
||||
&compose.checkbtn_reedit_account_autosel,
|
||||
prefs_set_data_from_toggle, prefs_set_toggle},
|
||||
|
||||
{"linewrap_length", "74", &prefs_common.linewrap_len, P_INT,
|
||||
&compose.spinbtn_linewrap,
|
||||
|
@ -1222,11 +1233,18 @@ static void prefs_compose_create(void)
|
|||
GtkWidget *label_sigsep;
|
||||
GtkWidget *entry_sigsep;
|
||||
|
||||
GtkWidget *frame_autosel;
|
||||
GtkWidget *hbox_autosel;
|
||||
GtkWidget *vbox_autosel;
|
||||
GtkWidget *checkbtn_reply_account_autosel;
|
||||
GtkWidget *vbox_linewrap;
|
||||
GtkWidget *checkbtn_forward_account_autosel;
|
||||
GtkWidget *checkbtn_reedit_account_autosel;
|
||||
|
||||
GtkWidget *hbox3;
|
||||
GtkWidget *vbox_linewrap;
|
||||
|
||||
GtkWidget *hbox3;
|
||||
GtkWidget *hbox4;
|
||||
GtkWidget *hbox5;
|
||||
GtkWidget *label_linewrap;
|
||||
GtkObject *spinbtn_linewrap_adj;
|
||||
GtkWidget *spinbtn_linewrap;
|
||||
|
@ -1341,6 +1359,21 @@ static void prefs_compose_create(void)
|
|||
|
||||
gtk_widget_set_usize (entry_sigsep, 64, -1);
|
||||
|
||||
/* Automatic (Smart) Account Selection */
|
||||
PACK_FRAME(vbox1, frame_autosel, _("Automatic Account Selection"));
|
||||
|
||||
hbox_autosel = gtk_hbox_new (FALSE, VSPACING_NARROW);
|
||||
gtk_widget_show (hbox_autosel);
|
||||
gtk_container_add (GTK_CONTAINER (frame_autosel), hbox_autosel);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (hbox_autosel), 8);
|
||||
|
||||
PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reply_account_autosel,
|
||||
_("when replying"));
|
||||
PACK_CHECK_BUTTON (hbox_autosel, checkbtn_forward_account_autosel,
|
||||
_("when forwarding"));
|
||||
PACK_CHECK_BUTTON (hbox_autosel, checkbtn_reedit_account_autosel,
|
||||
_("when re-editing"));
|
||||
|
||||
/* line-wrapping */
|
||||
vbox_linewrap = gtk_vbox_new (FALSE, VSPACING_NARROW);
|
||||
gtk_widget_show (vbox_linewrap);
|
||||
|
@ -1378,9 +1411,6 @@ static void prefs_compose_create(void)
|
|||
PACK_CHECK_BUTTON (vbox1, checkbtn_forward_as_attachment,
|
||||
_("Forward as attachment"));
|
||||
|
||||
PACK_CHECK_BUTTON (vbox1, checkbtn_reply_account_autosel,
|
||||
_("Automatically select account for mail replies"));
|
||||
|
||||
PACK_CHECK_BUTTON (vbox1, checkbtn_smart_wrapping,
|
||||
_("Smart wrapping (EXPERIMENTAL)"));
|
||||
|
||||
|
@ -1436,7 +1466,7 @@ static void prefs_compose_create(void)
|
|||
gtk_box_pack_start(GTK_BOX(hbox_dictionary_path), optmenu_dictionary_path, FALSE, FALSE, 0);
|
||||
gtk_widget_set_sensitive(optmenu_dictionary_path, prefs_common.enable_ispell);
|
||||
|
||||
/*
|
||||
/*
|
||||
compose.checkbtn_quote = checkbtn_quote;
|
||||
compose.entry_quotemark = entry_quotemark;
|
||||
compose.text_quotefmt = text_quotefmt;
|
||||
|
@ -1444,7 +1474,9 @@ static void prefs_compose_create(void)
|
|||
compose.checkbtn_autosig = checkbtn_autosig;
|
||||
compose.entry_sigsep = entry_sigsep;
|
||||
|
||||
compose.checkbtn_reply_account_autosel = checkbtn_reply_account_autosel;
|
||||
compose.checkbtn_reply_account_autosel = checkbtn_reply_account_autosel;
|
||||
compose.checkbtn_forward_account_autosel = checkbtn_forward_account_autosel;
|
||||
compose.checkbtn_reedit_account_autosel = checkbtn_reedit_account_autosel;
|
||||
|
||||
compose.spinbtn_linewrap = spinbtn_linewrap;
|
||||
compose.spinbtn_linewrap_adj = spinbtn_linewrap_adj;
|
||||
|
|
|
@ -70,6 +70,8 @@ struct _PrefsCommon
|
|||
gboolean linewrap_quote;
|
||||
gboolean linewrap_at_send;
|
||||
gboolean reply_account_autosel;
|
||||
gboolean forward_account_autosel;
|
||||
gboolean reedit_account_autosel;
|
||||
gboolean show_ruler;
|
||||
gchar *fw_quotemark;
|
||||
gchar *fw_quotefmt;
|
||||
|
|
|
@ -779,3 +779,28 @@ void procheader_date_get_localtime(gchar *dest, gint len, const time_t timer)
|
|||
else
|
||||
strftime(dest, len, default_format, lt);
|
||||
}
|
||||
|
||||
gint get_header_from_msginfo(MsgInfo *msginfo, gchar *buf, gint len,gchar *header)
|
||||
{
|
||||
gchar *file;
|
||||
FILE *fp;
|
||||
HeaderEntry hentry[]={{header,NULL,TRUE},
|
||||
{NULL,NULL,FALSE}};
|
||||
gint val;
|
||||
g_return_if_fail(msginfo != NULL);
|
||||
file = procmsg_get_message_file_path(msginfo);
|
||||
if ((fp = fopen(file, "r")) == NULL) {
|
||||
FILE_OP_ERROR(file, "fopen");
|
||||
g_free(file);
|
||||
return;
|
||||
}
|
||||
val=procheader_get_one_field(buf,len, fp, hentry);
|
||||
if (fclose(fp) == EOF) {
|
||||
FILE_OP_ERROR(file, "fclose");
|
||||
unlink(file);
|
||||
return -1;
|
||||
}
|
||||
if (val == -1)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -79,4 +79,7 @@ Header * procheader_parse_header (gchar * buf);
|
|||
gboolean procheader_headername_equal (char * hdr1, char * hdr2);
|
||||
void procheader_header_free (Header * header);
|
||||
|
||||
/* Added by Mel Hadasht on 27 Aug 2001 */
|
||||
/* Get a header from msginfo */
|
||||
gint get_header_from_msginfo(MsgInfo *msginfo, gchar *buf, gint len,gchar *header);
|
||||
#endif /* __PROCHEADER_H__ */
|
||||
|
|
12
src/utils.c
12
src/utils.c
|
@ -168,7 +168,17 @@ gint strcmp2(const gchar *s1, const gchar *s2)
|
|||
else
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
|
||||
/* strstr with NULL-checking */
|
||||
gint strstr2(const gchar *s1, const gchar *s2)
|
||||
{
|
||||
if (s1 == NULL || s2 == NULL)
|
||||
return -1;
|
||||
else
|
||||
if( strstr(s1, s2) !=NULL)
|
||||
return 0;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
/* compare paths */
|
||||
gint path_cmp(const gchar *s1, const gchar *s2)
|
||||
{
|
||||
|
|
|
@ -139,6 +139,8 @@ gchar *to_human_readable (off_t size);
|
|||
/* alternative string functions */
|
||||
gint strcmp2 (const gchar *s1,
|
||||
const gchar *s2);
|
||||
gint strstr2 (const gchar *s1,
|
||||
const gchar *s2);
|
||||
gint path_cmp (const gchar *s1,
|
||||
const gchar *s2);
|
||||
gchar *strretchomp (gchar *str);
|
||||
|
|
Loading…
Reference in a new issue