diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-11-10 09:49:06 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2005-11-10 09:49:06 +0000 |
commit | 0b73715dd9b3033f2ce4e8698a5a1968a9e87646 (patch) | |
tree | 08a9f0ee3b0c9521eff68062e8a4f38632e37710 /src | |
parent | 9273d06df99648652b98adf86d7562811eb323b8 (diff) |
hide PGP checkboxes if PGP is not available.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@734 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r-- | src/compose.c | 53 | ||||
-rw-r--r-- | src/logwindow.c | 17 | ||||
-rw-r--r-- | src/main.c | 4 | ||||
-rw-r--r-- | src/rfc2015.c | 10 | ||||
-rw-r--r-- | src/rfc2015.h | 3 |
5 files changed, 69 insertions, 18 deletions
diff --git a/src/compose.c b/src/compose.c index 0b886964..7989fdd1 100644 --- a/src/compose.c +++ b/src/compose.c @@ -793,7 +793,7 @@ void compose_reply(MsgInfo *msginfo, FolderItem *item, ComposeMode mode, compose_set_title(compose); #if USE_GPGME - if (account->encrypt_reply && + if (rfc2015_is_available() && account->encrypt_reply && MSG_IS_ENCRYPTED(compose->replyinfo->flags)) { GtkItemFactory *ifactory; @@ -2455,10 +2455,12 @@ static void compose_select_account(Compose *compose, PrefsAccount *account, } #if USE_GPGME - if (account->default_sign) - menu_set_active(ifactory, "/Tools/PGP Sign", TRUE); - if (account->default_encrypt) - menu_set_active(ifactory, "/Tools/PGP Encrypt", TRUE); + if (rfc2015_is_available()) { + if (account->default_sign) + menu_set_active(ifactory, "/Tools/PGP Sign", TRUE); + if (account->default_encrypt) + menu_set_active(ifactory, "/Tools/PGP Encrypt", TRUE); + } #endif /* USE_GPGME */ if (!init && compose->mode != COMPOSE_REDIRECT && prefs_common.auto_sig) @@ -2820,14 +2822,16 @@ static gint compose_write_to_file(Compose *compose, const gchar *file, #if USE_GPGME /* force encoding to protect trailing spaces */ - if (!is_draft && compose->use_signing && !compose->account->clearsign) { + if (rfc2015_is_available() && !is_draft && + compose->use_signing && !compose->account->clearsign) { if (encoding == ENC_7BIT) encoding = ENC_QUOTED_PRINTABLE; else if (encoding == ENC_8BIT) encoding = ENC_BASE64; } - if (!is_draft && compose->use_signing && compose->account->clearsign) { + if (rfc2015_is_available() && !is_draft && + compose->use_signing && compose->account->clearsign) { /* MIME encoding doesn't fit with cleartext signature */ if (encoding == ENC_QUOTED_PRINTABLE || encoding == ENC_BASE64) encoding = ENC_8BIT; @@ -2888,7 +2892,8 @@ static gint compose_write_to_file(Compose *compose, const gchar *file, /* This prolog message is ignored by mime software and * because it would make our signing/encryption task * tougher, we don't emit it in that case */ - if (!compose->use_signing && !compose->use_encryption) + if (!rfc2015_is_available() || + (!compose->use_signing && !compose->use_encryption)) #endif fputs("This is a multi-part message in MIME format.\n", fp); @@ -2896,7 +2901,8 @@ static gint compose_write_to_file(Compose *compose, const gchar *file, fprintf(fp, "Content-Type: text/plain; charset=%s\n", body_charset); #if USE_GPGME - if (compose->use_signing && !compose->account->clearsign) + if (rfc2015_is_available() && + compose->use_signing && !compose->account->clearsign) fprintf(fp, "Content-Disposition: inline\n"); #endif fprintf(fp, "Content-Transfer-Encoding: %s\n", @@ -2952,7 +2958,7 @@ static gint compose_write_to_file(Compose *compose, const gchar *file, } #if USE_GPGME - if (is_draft) { + if (!rfc2015_is_available() || is_draft) { uncanonicalize_file_replace(file); return 0; } @@ -3320,7 +3326,7 @@ static void compose_write_attach(Compose *compose, FILE *fp, #if USE_GPGME /* force encoding to protect trailing spaces */ - if (compose->use_signing && + if (rfc2015_is_available() && compose->use_signing && !compose->account->clearsign) { if (encoding == ENC_7BIT) encoding = ENC_QUOTED_PRINTABLE; @@ -3646,7 +3652,8 @@ static gint compose_write_headers(Compose *compose, FILE *fp, fprintf(fp, "Content-Type: text/plain; charset=%s\n", body_charset); #if USE_GPGME - if (compose->use_signing && !compose->account->clearsign) + if (rfc2015_is_available() && + compose->use_signing && !compose->account->clearsign) fprintf(fp, "Content-Disposition: inline\n"); #endif fprintf(fp, "Content-Transfer-Encoding: %s\n", @@ -4275,6 +4282,9 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode) gtk_table_set_row_spacing(GTK_TABLE(table), 2, 0); } + if (!rfc2015_is_available()) + gtk_widget_hide(misc_hbox); + switch (prefs_common.toolbar_style) { case TOOLBAR_NONE: gtk_widget_hide(toolbar); @@ -4431,6 +4441,13 @@ static Compose *compose_create(PrefsAccount *account, ComposeMode mode) FALSE); } +#if USE_GPGME + if (!rfc2015_is_available()) { + menu_set_sensitive(ifactory, "/Tools/PGP Sign", FALSE); + menu_set_sensitive(ifactory, "/Tools/PGP Encrypt", FALSE); + } +#endif /* USE_GPGME */ + compose_set_out_encoding(compose); addressbook_set_target_compose(compose); action_update_compose_menu(ifactory, compose); @@ -5996,6 +6013,9 @@ static void compose_signing_toggled(GtkWidget *widget, Compose *compose) { GtkItemFactory *ifactory; + if (!rfc2015_is_available()) + return; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) compose->use_signing = TRUE; else @@ -6009,6 +6029,9 @@ static void compose_encrypt_toggled(GtkWidget *widget, Compose *compose) { GtkItemFactory *ifactory; + if (!rfc2015_is_available()) + return; + if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) compose->use_encryption = TRUE; else @@ -6223,6 +6246,9 @@ static void compose_toggle_sign_cb(gpointer data, guint action, { Compose *compose = (Compose *)data; + if (!rfc2015_is_available()) + return; + if (GTK_CHECK_MENU_ITEM(widget)->active) compose->use_signing = TRUE; else @@ -6237,6 +6263,9 @@ static void compose_toggle_encrypt_cb(gpointer data, guint action, { Compose *compose = (Compose *)data; + if (!rfc2015_is_available()) + return; + if (GTK_CHECK_MENU_ITEM(widget)->active) compose->use_encryption = TRUE; else diff --git a/src/logwindow.c b/src/logwindow.c index ccd6b987..017bb37b 100644 --- a/src/logwindow.c +++ b/src/logwindow.c @@ -35,6 +35,7 @@ #include "prefs_common.h" #include "utils.h" #include "gtkutils.h" +#include "codeconv.h" #define TRIM_LINES 25 @@ -210,8 +211,20 @@ void log_window_append(const gchar *str, LogType type) if (head) gtk_text_buffer_insert_with_tags_by_name (buffer, &iter, head, -1, tag, NULL); - gtk_text_buffer_insert_with_tags_by_name - (buffer, &iter, str, -1, tag, NULL); + + if (!g_utf8_validate(str, -1, NULL)) { + gchar *str_; + + str_ = conv_utf8todisp(str, NULL); + if (str_) { + gtk_text_buffer_insert_with_tags_by_name + (buffer, &iter, str_, -1, tag, NULL); + g_free(str_); + } + } else { + gtk_text_buffer_insert_with_tags_by_name + (buffer, &iter, str, -1, tag, NULL); + } if (GTK_WIDGET_VISIBLE(text)) { GtkTextMark *mark; @@ -631,8 +631,6 @@ static void check_gpg(void) /* Also does some gpgme init */ gpgme_engine_info_t engineInfo; - rfc2015_disable_all(); - gpgme_set_locale(NULL, LC_CTYPE, setlocale(LC_CTYPE, NULL)); gpgme_set_locale(NULL, LC_MESSAGES, setlocale(LC_MESSAGES, NULL)); @@ -651,6 +649,8 @@ static void check_gpg(void) procmsg_set_decrypt_message_func (rfc2015_open_message_decrypted); } else { + rfc2015_disable_all(); + if (prefs_common.gpg_warning) { AlertValue val; diff --git a/src/rfc2015.c b/src/rfc2015.c index 21d48f9b..fc2ccfb7 100644 --- a/src/rfc2015.c +++ b/src/rfc2015.c @@ -51,6 +51,8 @@ #define DIM(v) (sizeof(v) / sizeof((v)[0])) +static gboolean gpg_available = TRUE; + static gchar *content_names[] = { "Content-Type", "Content-Disposition", @@ -106,8 +108,12 @@ static void dump_part(MimeInfo *mimeinfo, FILE *fp) void rfc2015_disable_all(void) { - /* FIXME: set a flag, so that we don't bother the user with failed - * gpgme messages */ + gpg_available = FALSE; +} + +gboolean rfc2015_is_available(void) +{ + return gpg_available; } void rfc2015_secure_remove(const gchar *fname) diff --git a/src/rfc2015.h b/src/rfc2015.h index 7c6a638a..e7c9f123 100644 --- a/src/rfc2015.h +++ b/src/rfc2015.h @@ -27,7 +27,10 @@ #include "procmime.h" void rfc2015_disable_all (void); +gboolean rfc2015_is_available (void); + void rfc2015_secure_remove (const gchar *fname); + MimeInfo **rfc2015_find_signature (MimeInfo *mimeinfo); gboolean rfc2015_has_signature (MimeInfo *mimeinfo); void rfc2015_check_signature (MimeInfo *mimeinfo, |