don't leave the user in limbo when privacy system is 'none' and auto signing/encrypti...
authorPaul <paul@claws-mail.org>
Thu, 25 Oct 2018 09:36:54 +0000 (10:36 +0100)
committerPaul <paul@claws-mail.org>
Thu, 25 Oct 2018 09:36:54 +0000 (10:36 +0100)
src/compose.c

index 11e0b6e..7a0b68e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2016 Hiroyuki Yamamoto and the Claws Mail team
+ * Copyright (C) 1999-2018 the Claws Mail team and 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
@@ -1010,6 +1010,13 @@ Compose *compose_generic_new(PrefsAccount *account, const gchar *mailto, FolderI
        compose = compose_create(account, item, COMPOSE_NEW, FALSE);
        compose_apply_folder_privacy_settings(compose, item);
 
+       if (privacy_system_can_sign(compose->privacy_system) == FALSE &&
+           (account->default_encrypt || account->default_sign))
+               alertpanel_error(_("You have opted to sign and/or encrypt this "
+                                  "message but have not selected a privacy system.\n\n"
+                                  "Signing and encrypting have been disabled for this "
+                                  "message."));
+
        /* override from name if mailto asked for it */
        if (mailto_from) {
                gtk_entry_set_text(GTK_ENTRY(compose->from_name), mailto_from);
@@ -1273,7 +1280,8 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
        cm_return_if_fail(compose != NULL);
        cm_return_if_fail(account != NULL);
 
-       if (override_pref == FALSE && account->default_encrypt_reply == FALSE)
+       if (privacy_system_can_encrypt(compose->privacy_system) == FALSE ||
+           (override_pref == FALSE && account->default_encrypt_reply == FALSE))
                return;
 
        if (account->default_privacy_system && strlen(account->default_privacy_system))
@@ -1310,6 +1318,8 @@ static void compose_force_encryption(Compose *compose, PrefsAccount *account,
 static void compose_force_signing(Compose *compose, PrefsAccount *account, const gchar *system)
 {
        const gchar *privacy = NULL;
+       if (privacy_system_can_sign(compose->privacy_system) == FALSE)
+               return;
 
        if (account->default_privacy_system && strlen(account->default_privacy_system))
                privacy = account->default_privacy_system;
@@ -1679,6 +1689,13 @@ static Compose *compose_generic_reply(MsgInfo *msginfo,
        }
        g_free(s_system);
 
+       if (privacy_system_can_sign(compose->privacy_system) == FALSE &&
+           (account->default_encrypt_reply || account->default_sign_reply))
+               alertpanel_error(_("You have opted to sign and/or encrypt this "
+                                  "message but have not selected a privacy system.\n\n"
+                                  "Signing and encrypting have been disabled for this "
+                                  "message."));
+
        SIGNAL_BLOCK(textbuf);
        
        if (account->auto_sig)
@@ -4951,16 +4968,18 @@ static void compose_select_account(Compose *compose, PrefsAccount *account,
 
        compose_set_title(compose);
 
-       if (account->default_sign && compose->mode != COMPOSE_REDIRECT)
+       compose_activate_privacy_system(compose, account, FALSE);
+
+       if (account->default_sign && privacy_system_can_sign(compose->privacy_system) &&
+           compose->mode != COMPOSE_REDIRECT)
                cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Sign", TRUE);
        else
                cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Sign", FALSE);
-       if (account->default_encrypt && compose->mode != COMPOSE_REDIRECT)
+       if (account->default_encrypt && privacy_system_can_encrypt(compose->privacy_system) &&
+           compose->mode != COMPOSE_REDIRECT)
                cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Encrypt", TRUE);
        else
                cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Options/Encrypt", FALSE);
-                                      
-       compose_activate_privacy_system(compose, account, FALSE);
 
        if (!init && compose->mode != COMPOSE_REDIRECT) {
                undo_block(compose->undostruct);
@@ -8271,6 +8290,14 @@ static Compose *compose_create(PrefsAccount *account,
 #endif
 
        compose_select_account(compose, account, TRUE);
+       if (folder->prefs && folder->prefs->save_copy_to_folder) {
+               gchar *folderidentifier;
+
+               gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(compose->savemsg_checkbtn), TRUE);
+               folderidentifier = folder_item_get_identifier(folder);
+               compose_set_save_to(compose, folderidentifier);
+               g_free(folderidentifier);
+       }
 
        cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Edit/AutoWrap", prefs_common.autowrap);
        cm_toggle_menu_set_active_full(compose->ui_manager, "Menu/Edit/AutoIndent", prefs_common.auto_indent);
@@ -11540,11 +11567,13 @@ static void compose_activate_privacy_system(Compose *compose, PrefsAccount *acco
 static void compose_apply_folder_privacy_settings(Compose *compose, FolderItem *folder_item)
 {
        if (folder_item != NULL) {
-               if (folder_item->prefs->always_sign != SIGN_OR_ENCRYPT_DEFAULT) {
+               if (folder_item->prefs->always_sign != SIGN_OR_ENCRYPT_DEFAULT &&
+                   privacy_system_can_sign(compose->privacy_system)) {
                        compose_use_signing(compose,
                                (folder_item->prefs->always_sign == SIGN_OR_ENCRYPT_ALWAYS) ? TRUE : FALSE);
                }
-               if (folder_item->prefs->always_encrypt != SIGN_OR_ENCRYPT_DEFAULT) {
+               if (folder_item->prefs->always_encrypt != SIGN_OR_ENCRYPT_DEFAULT &&
+                   privacy_system_can_encrypt(compose->privacy_system)) {
                        compose_use_encryption(compose,
                                (folder_item->prefs->always_encrypt == SIGN_OR_ENCRYPT_ALWAYS) ? TRUE : FALSE);
                }