Make signature auto-check not blocking.
authorColin Leroy <colin@colino.net>
Thu, 25 Jul 2013 11:26:24 +0000 (13:26 +0200)
committerColin Leroy <colin@colino.net>
Thu, 25 Jul 2013 11:26:24 +0000 (13:26 +0200)
src/mimeview.c
src/plugins/pgpcore/prefs_gpg.c
src/plugins/pgpcore/prefs_gpg.h
src/plugins/pgpinline/pgpinline.c
src/plugins/pgpmime/pgpmime.c
src/plugins/smime/smime.c
src/privacy.c
src/privacy.h

index c9c1fbc..64bbdd9 100644 (file)
@@ -1094,6 +1094,9 @@ static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo,
                (gpointer) mimeview);
        noticeview_set_icon(mimeview->siginfoview, icon);
        noticeview_set_tooltip(mimeview->siginfoview, button_text);
+
+       icon_list_clear(mimeview);
+       icon_list_create(mimeview, mimeview->mimeinfo);
 }
 
 #ifdef USE_PTHREAD
@@ -1172,9 +1175,7 @@ static gboolean mimeview_check_sig_thread_cb(void *data)
        else
                update_signature_noticeview(mimeview, mimeview->siginfo, 
                        FALSE, 0);
-       icon_list_clear(mimeview);
-       icon_list_create(mimeview, mimeview->mimeinfo);
-       
+
 end:
        mimeview_check_data_reset(mimeview);
        return FALSE;
@@ -1329,8 +1330,6 @@ static void check_signature_cb(GtkWidget *widget, gpointer user_data)
                debug_print("checking without thread\n");
                privacy_mimeinfo_check_signature(mimeinfo);
                update_signature_noticeview(mimeview, mimeview->siginfo, FALSE, 0);
-               icon_list_clear(mimeview);
-               icon_list_create(mimeview, mimeview->mimeinfo);
        }
 }
 
@@ -1462,6 +1461,10 @@ static void mimeview_selected(GtkTreeSelection *selection, MimeView *mimeview)
                        break;
                }
        }
+
+       if (mimeview->siginfo && privacy_auto_check_signatures(mimeview->siginfo)) {
+               mimeview_check_signature(mimeview);
+       }
 }
 
 static gint mimeview_button_pressed(GtkWidget *widget, GdkEventButton *event,
index 5a95799..acdd714 100644 (file)
@@ -650,3 +650,8 @@ void prefs_gpg_remove_skip_encryption_warning(const gchar *systemid)
        }
        prefs_gpg_save_config();
 }
+
+gboolean prefs_gpg_auto_check_signatures(void)
+{
+       return prefs_gpg_get_config()->auto_check_signatures;
+}
index c9344e7..422b7d6 100644 (file)
@@ -57,3 +57,4 @@ void prefs_gpg_enable_agent(gboolean enable);
 void prefs_gpg_add_skip_encryption_warning(const gchar *systemid);
 void prefs_gpg_remove_skip_encryption_warning(const gchar *systemid);
 gboolean prefs_gpg_should_skip_encryption_warning(const gchar *systemid);
+gboolean prefs_gpg_auto_check_signatures(void);
index cbd3bb0..2a60946 100644 (file)
@@ -217,12 +217,8 @@ static gint pgpinline_check_signature(MimeInfo *mimeinfo)
 static SignatureStatus pgpinline_get_sig_status(MimeInfo *mimeinfo)
 {
        PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
-       
-       cm_return_val_if_fail(data != NULL, SIGNATURE_INVALID);
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               pgpinline_check_signature(mimeinfo);
+       cm_return_val_if_fail(data != NULL, SIGNATURE_INVALID);
 
        return sgpgme_sigstat_gpgme_to_privacy(data->ctx, data->sigstatus);
 }
@@ -230,13 +226,9 @@ static SignatureStatus pgpinline_get_sig_status(MimeInfo *mimeinfo)
 static gchar *pgpinline_get_sig_info_short(MimeInfo *mimeinfo)
 {
        PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
-       
+
        cm_return_val_if_fail(data != NULL, g_strdup("Error"));
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               pgpinline_check_signature(mimeinfo);
-       
        return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
 }
 
@@ -782,6 +774,7 @@ static PrivacySystem pgpinline_system = {
        pgpinline_encrypt,
        pgpinline_get_encrypt_warning,
        pgpinline_inhibit_encrypt_warning,
+       prefs_gpg_auto_check_signatures,
 };
 
 void pgpinline_init()
index 30cf043..2a0bb7a 100644 (file)
@@ -241,10 +241,6 @@ static SignatureStatus pgpmime_get_sig_status(MimeInfo *mimeinfo)
        
        cm_return_val_if_fail(data != NULL, SIGNATURE_INVALID);
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               pgpmime_check_signature(mimeinfo);
-       
        return sgpgme_sigstat_gpgme_to_privacy(data->ctx, data->sigstatus);
 }
 
@@ -254,23 +250,15 @@ static gchar *pgpmime_get_sig_info_short(MimeInfo *mimeinfo)
        
        cm_return_val_if_fail(data != NULL, g_strdup("Error"));
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               pgpmime_check_signature(mimeinfo);
-       
        return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
 }
 
 static gchar *pgpmime_get_sig_info_full(MimeInfo *mimeinfo)
 {
        PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
-       
+
        cm_return_val_if_fail(data != NULL, g_strdup("Error"));
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               pgpmime_check_signature(mimeinfo);
-       
        return sgpgme_sigstat_info_full(data->ctx, data->sigstatus);
 }
 
@@ -781,6 +769,7 @@ static PrivacySystem pgpmime_system = {
        pgpmime_encrypt,
        pgpmime_get_encrypt_warning,
        pgpmime_inhibit_encrypt_warning,
+       prefs_gpg_auto_check_signatures,
 };
 
 void pgpmime_init()
index 07e2345..f439796 100644 (file)
@@ -330,10 +330,6 @@ static SignatureStatus smime_get_sig_status(MimeInfo *mimeinfo)
        
        cm_return_val_if_fail(data != NULL, SIGNATURE_INVALID);
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               smime_check_signature(mimeinfo);
-       
        return sgpgme_sigstat_gpgme_to_privacy(data->ctx, data->sigstatus);
 }
 
@@ -343,10 +339,6 @@ static gchar *smime_get_sig_info_short(MimeInfo *mimeinfo)
        
        cm_return_val_if_fail(data != NULL, g_strdup("Error"));
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               smime_check_signature(mimeinfo);
-       
        return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
 }
 
@@ -356,10 +348,6 @@ static gchar *smime_get_sig_info_full(MimeInfo *mimeinfo)
        
        cm_return_val_if_fail(data != NULL, g_strdup("Error"));
 
-       if (data->sigstatus == NULL && 
-           prefs_gpg_get_config()->auto_check_signatures)
-               smime_check_signature(mimeinfo);
-       
        return sgpgme_sigstat_info_full(data->ctx, data->sigstatus);
 }
 
@@ -906,6 +894,7 @@ static PrivacySystem smime_system = {
        smime_encrypt,
        smime_get_encrypt_warning,
        smime_inhibit_encrypt_warning,
+       prefs_gpg_auto_check_signatures,
 };
 
 void smime_init()
index cdf2316..ffc61ae 100644 (file)
@@ -501,3 +501,24 @@ gboolean privacy_encrypt(const gchar *id, MimeInfo *mimeinfo, const gchar *encda
 
        return system->encrypt(mimeinfo, encdata);
 }
+
+gboolean privacy_auto_check_signatures(MimeInfo *mimeinfo)
+{
+       PrivacySystem *system;
+
+       cm_return_val_if_fail(mimeinfo != NULL, FALSE);
+
+       if (mimeinfo->privacy == NULL)
+               privacy_mimeinfo_is_signed(mimeinfo);
+
+       if (mimeinfo->privacy == NULL)
+               return FALSE;
+
+       system = privacy_data_get_system(mimeinfo->privacy);
+       if (system == NULL)
+               return FALSE;
+       if (system->auto_check_signatures == NULL)
+               return FALSE;
+
+       return system->auto_check_signatures();
+}
index a0333bd..ebc1919 100644 (file)
@@ -102,6 +102,7 @@ struct _PrivacySystem {
                                                 const gchar *encrypt_data);
        const gchar     *(*get_encrypt_warning) (void);
        void             (*inhibit_encrypt_warning)     (gboolean inhibit);
+       gboolean         (*auto_check_signatures)(void);
 };
 
 struct _PrivacyData {
@@ -110,5 +111,6 @@ struct _PrivacyData {
 
 void privacy_inhibit_encrypt_warning           (const gchar *id,
                                                 gboolean inhibit);
+gboolean privacy_auto_check_signatures(MimeInfo *mimeinfo);
 
 #endif /* PRIVACY_H */