2006-04-18 [colin] 2.1.1cvs12

* src/imap.c
		Factorize get/set_xml code
	* src/compose.c
	* src/prefs_account.c
	* src/prefs_account.h
	* src/procmsg.c
		Add Encrypt to self option
This commit is contained in:
Colin Leroy 2006-04-18 16:21:10 +00:00
parent 1a7c947e25
commit 49220d751b
8 changed files with 44 additions and 135 deletions

View file

@ -1,3 +1,13 @@
2006-04-18 [colin] 2.1.1cvs12
* src/imap.c
Factorize get/set_xml code
* src/compose.c
* src/prefs_account.c
* src/prefs_account.h
* src/procmsg.c
Add Encrypt to self option
2006-04-17 [colin] 2.1.1cvs11
* configure.ac

View file

@ -1433,3 +1433,4 @@
( cvs diff -u -r 1.1.4.33 -r 1.1.4.34 src/etpan/imap-thread.c; ) > 2.1.1cvs9.patchset
( cvs diff -u -r 1.105.2.51 -r 1.105.2.52 src/prefs_account.c; ) > 2.1.1cvs10.patchset
( cvs diff -u -r 1.654.2.1477 -r 1.654.2.1478 configure.ac; ) > 2.1.1cvs11.patchset
( cvs diff -u -r 1.382.2.264 -r 1.382.2.265 src/compose.c; cvs diff -u -r 1.179.2.105 -r 1.179.2.106 src/imap.c; cvs diff -u -r 1.105.2.52 -r 1.105.2.53 src/prefs_account.c; cvs diff -u -r 1.49.2.18 -r 1.49.2.19 src/prefs_account.h; cvs diff -u -r 1.150.2.60 -r 1.150.2.61 src/procmsg.c; ) > 2.1.1cvs12.patchset

View file

@ -11,7 +11,7 @@ MINOR_VERSION=1
MICRO_VERSION=1
INTERFACE_AGE=0
BINARY_AGE=0
EXTRA_VERSION=11
EXTRA_VERSION=12
EXTRA_RELEASE=
EXTRA_GTK2_VERSION=

View file

@ -4639,8 +4639,14 @@ static gint compose_queue_sub(Compose *compose, gint *msgnum, FolderItem **item,
fprintf(fp, "X-Sylpheed-Sign:%d\n", compose->use_signing);
if (compose->use_encryption) {
gchar *encdata;
encdata = privacy_get_encrypt_data(compose->privacy_system, compose->to_list);
if (mailac && mailac->encrypt_to_self) {
GSList *tmp_list = g_slist_copy(compose->to_list);
tmp_list = g_slist_append(tmp_list, compose->account->address);
encdata = privacy_get_encrypt_data(compose->privacy_system, tmp_list);
g_slist_free(tmp_list);
} else {
encdata = privacy_get_encrypt_data(compose->privacy_system, compose->to_list);
}
if (encdata != NULL) {
if (strcmp(encdata, "_DONT_ENCRYPT_")) {
fprintf(fp, "X-Sylpheed-Encrypt:%d\n", compose->use_encryption);

View file

@ -4280,151 +4280,25 @@ static void imap_item_set_xml(Folder *folder, FolderItem *item, XMLTag *tag)
{
GList *cur;
folder_item_set_xml(folder, item, tag);
for (cur = tag->attr; cur != NULL; cur = g_list_next(cur)) {
XMLAttr *attr = (XMLAttr *) cur->data;
if (!attr || !attr->name || !attr->value) continue;
if (!strcmp(attr->name, "type")) {
if (!g_ascii_strcasecmp(attr->value, "normal"))
item->stype = F_NORMAL;
else if (!g_ascii_strcasecmp(attr->value, "inbox"))
item->stype = F_INBOX;
else if (!g_ascii_strcasecmp(attr->value, "outbox"))
item->stype = F_OUTBOX;
else if (!g_ascii_strcasecmp(attr->value, "draft"))
item->stype = F_DRAFT;
else if (!g_ascii_strcasecmp(attr->value, "queue"))
item->stype = F_QUEUE;
else if (!g_ascii_strcasecmp(attr->value, "trash"))
item->stype = F_TRASH;
} else if (!strcmp(attr->name, "name")) {
g_free(item->name);
item->name = g_strdup(attr->value);
} else if (!strcmp(attr->name, "path")) {
g_free(item->path);
item->path = g_strdup(attr->value);
} else if (!strcmp(attr->name, "mtime"))
item->mtime = strtoul(attr->value, NULL, 10);
else if (!strcmp(attr->name, "new"))
item->new_msgs = atoi(attr->value);
else if (!strcmp(attr->name, "unread"))
item->unread_msgs = atoi(attr->value);
else if (!strcmp(attr->name, "unreadmarked"))
item->unreadmarked_msgs = atoi(attr->value);
else if (!strcmp(attr->name, "marked"))
item->marked_msgs = atoi(attr->value);
else if (!strcmp(attr->name, "total"))
item->total_msgs = atoi(attr->value);
else if (!strcmp(attr->name, "no_sub"))
item->no_sub = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "no_select"))
item->no_select = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "collapsed"))
item->collapsed = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "thread_collapsed"))
item->thread_collapsed = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "threaded"))
item->threaded = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "hidereadmsgs"))
item->hide_read_msgs = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "reqretrcpt"))
item->ret_rcpt = *attr->value == '1' ? TRUE : FALSE;
else if (!strcmp(attr->name, "uidnext"))
if (!strcmp(attr->name, "uidnext"))
IMAP_FOLDER_ITEM(item)->uid_next = atoi(attr->value);
else if (!strcmp(attr->name, "sort_key")) {
if (!strcmp(attr->value, "none"))
item->sort_key = SORT_BY_NONE;
else if (!strcmp(attr->value, "number"))
item->sort_key = SORT_BY_NUMBER;
else if (!strcmp(attr->value, "size"))
item->sort_key = SORT_BY_SIZE;
else if (!strcmp(attr->value, "date"))
item->sort_key = SORT_BY_DATE;
else if (!strcmp(attr->value, "from"))
item->sort_key = SORT_BY_FROM;
else if (!strcmp(attr->value, "subject"))
item->sort_key = SORT_BY_SUBJECT;
else if (!strcmp(attr->value, "score"))
item->sort_key = SORT_BY_SCORE;
else if (!strcmp(attr->value, "label"))
item->sort_key = SORT_BY_LABEL;
else if (!strcmp(attr->value, "mark"))
item->sort_key = SORT_BY_MARK;
else if (!strcmp(attr->value, "unread"))
item->sort_key = SORT_BY_STATUS;
else if (!strcmp(attr->value, "mime"))
item->sort_key = SORT_BY_MIME;
else if (!strcmp(attr->value, "to"))
item->sort_key = SORT_BY_TO;
else if (!strcmp(attr->value, "locked"))
item->sort_key = SORT_BY_LOCKED;
} else if (!strcmp(attr->name, "sort_type")) {
if (!strcmp(attr->value, "ascending"))
item->sort_type = SORT_ASCENDING;
else
item->sort_type = SORT_DESCENDING;
} else if (!strcmp(attr->name, "account_id")) {
PrefsAccount *account;
account = account_find_from_id(atoi(attr->value));
if (!account)
g_warning("account_id: %s not found\n", attr->value);
else
item->account = account;
} else if (!strcmp(attr->name, "apply_sub"))
item->apply_sub = *attr->value == '1' ? TRUE : FALSE;
}
}
static XMLTag *imap_item_get_xml(Folder *folder, FolderItem *item)
{
static gchar *folder_item_stype_str[] = {"normal", "inbox", "outbox",
"draft", "queue", "trash"};
static gchar *sort_key_str[] = {"none", "number", "size", "date",
"from", "subject", "score", "label",
"mark", "unread", "mime", "to",
"locked"};
XMLTag *tag;
gchar *value;
tag = xml_tag_new("folderitem");
xml_tag_add_attr(tag, xml_attr_new("type", folder_item_stype_str[item->stype]));
if (item->name)
xml_tag_add_attr(tag, xml_attr_new("name", item->name));
if (item->path)
xml_tag_add_attr(tag, xml_attr_new("path", item->path));
if (item->no_sub)
xml_tag_add_attr(tag, xml_attr_new("no_sub", "1"));
if (item->no_select)
xml_tag_add_attr(tag, xml_attr_new("no_select", "1"));
xml_tag_add_attr(tag, xml_attr_new("collapsed", item->collapsed && item->node->children ? "1" : "0"));
xml_tag_add_attr(tag, xml_attr_new("thread_collapsed", item->thread_collapsed ? "1" : "0"));
xml_tag_add_attr(tag, xml_attr_new("threaded", item->threaded ? "1" : "0"));
xml_tag_add_attr(tag, xml_attr_new("hidereadmsgs", item->hide_read_msgs ? "1" : "0"));
if (item->ret_rcpt)
xml_tag_add_attr(tag, xml_attr_new("reqretrcpt", "1"));
if (item->sort_key != SORT_BY_NONE) {
xml_tag_add_attr(tag, xml_attr_new("sort_key", sort_key_str[item->sort_key]));
xml_tag_add_attr(tag, xml_attr_new("sort_type", item->sort_type == SORT_ASCENDING ? "ascending" : "descending"));
}
value = g_strdup_printf("%ld", (unsigned long int) item->mtime);
xml_tag_add_attr(tag, xml_attr_new("mtime", value));
g_free(value);
xml_tag_add_attr(tag, xml_attr_new_int("new", item->new_msgs));
xml_tag_add_attr(tag, xml_attr_new_int("unread", item->unread_msgs));
xml_tag_add_attr(tag, xml_attr_new_int("unreadmarked", item->unreadmarked_msgs));
xml_tag_add_attr(tag, xml_attr_new_int("marked", item->marked_msgs));
xml_tag_add_attr(tag, xml_attr_new_int("total", item->total_msgs));
tag = folder_item_get_xml(folder, item);
xml_tag_add_attr(tag, xml_attr_new_int("uidnext",
IMAP_FOLDER_ITEM(item)->uid_next));
if (item->account)
xml_tag_add_attr(tag, xml_attr_new_int("account_id", item->account->account_id));
if (item->apply_sub)
xml_tag_add_attr(tag, xml_attr_new("apply_sub", "1"));
return tag;
}

View file

@ -163,6 +163,7 @@ static struct Privacy {
GtkWidget *default_encrypt_reply_chkbtn;
GtkWidget *default_sign_chkbtn;
GtkWidget *save_clear_text_chkbtn;
GtkWidget *encrypt_to_self_chkbtn;
} privacy;
#if USE_OPENSSL
@ -443,6 +444,9 @@ static PrefParam param[] = {
{"save_clear_text", "FALSE", &tmp_ac_prefs.save_encrypted_as_clear_text, P_BOOL,
&privacy.save_clear_text_chkbtn,
prefs_set_data_from_toggle, prefs_set_toggle},
{"encrypt_to_self", "FALSE", &tmp_ac_prefs.encrypt_to_self, P_BOOL,
&privacy.encrypt_to_self_chkbtn,
prefs_set_data_from_toggle, prefs_set_toggle},
{"privacy_prefs", "", &privacy_prefs, P_STRING,
NULL, NULL, NULL},
#if USE_OPENSSL
@ -630,7 +634,10 @@ static void privacy_system_activated(GtkMenuItem *menuitem)
gtk_widget_set_sensitive (privacy.default_encrypt_chkbtn, privacy_enabled);
gtk_widget_set_sensitive (privacy.default_encrypt_reply_chkbtn, privacy_enabled);
gtk_widget_set_sensitive (privacy.default_sign_chkbtn, privacy_enabled);
gtk_widget_set_sensitive (privacy.save_clear_text_chkbtn, privacy_enabled);
gtk_widget_set_sensitive (privacy.encrypt_to_self_chkbtn, privacy_enabled);
gtk_widget_set_sensitive (privacy.save_clear_text_chkbtn,
privacy_enabled && !gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(privacy.encrypt_to_self_chkbtn)));
}
void update_privacy_system_menu() {
@ -2015,6 +2022,7 @@ static void prefs_account_privacy_create(void)
GtkWidget *default_encrypt_reply_chkbtn;
GtkWidget *default_sign_chkbtn;
GtkWidget *save_clear_text_chkbtn;
GtkWidget *encrypt_to_self_chkbtn;
vbox1 = gtk_vbox_new (FALSE, VSPACING);
gtk_widget_show (vbox1);
@ -2044,14 +2052,19 @@ static void prefs_account_privacy_create(void)
"encrypted message"));
PACK_CHECK_BUTTON (vbox2, default_sign_chkbtn,
_("Sign message by default"));
PACK_CHECK_BUTTON (vbox2, encrypt_to_self_chkbtn,
_("Encrypt sent messages to myself too"));
PACK_CHECK_BUTTON (vbox2, save_clear_text_chkbtn,
_("Save sent encrypted messages as clear text"));
SET_TOGGLE_SENSITIVITY_REVERSE(encrypt_to_self_chkbtn, save_clear_text_chkbtn);
privacy.default_privacy_system = default_privacy_system;
privacy.default_encrypt_chkbtn = default_encrypt_chkbtn;
privacy.default_encrypt_reply_chkbtn = default_encrypt_reply_chkbtn;
privacy.default_sign_chkbtn = default_sign_chkbtn;
privacy.save_clear_text_chkbtn = save_clear_text_chkbtn;
privacy.encrypt_to_self_chkbtn = encrypt_to_self_chkbtn;
}
#if USE_OPENSSL

View file

@ -133,6 +133,7 @@ struct _PrefsAccount
gboolean default_encrypt_reply;
gboolean default_sign;
gboolean save_encrypted_as_clear_text;
gboolean encrypt_to_self;
/* Advanced */
gboolean set_smtpport;

View file

@ -1432,7 +1432,11 @@ static gint procmsg_send_message_queue_full(const gchar *file, gboolean keep_ses
if (encrypt) {
MimeInfo *mimeinfo;
save_clear_text = (mailac != NULL && mailac->save_encrypted_as_clear_text);
if (mailac && mailac->save_encrypted_as_clear_text
&& !mailac->encrypt_to_self)
save_clear_text = TRUE;
else
save_clear_text = FALSE;
fclose(fp);
fp = NULL;