0.9.6claws47
authorPaul Mangan <paul@claws-mail.org>
Thu, 23 Oct 2003 18:57:49 +0000 (18:57 +0000)
committerPaul Mangan <paul@claws-mail.org>
Thu, 23 Oct 2003 18:57:49 +0000 (18:57 +0000)
* src/noticeview.c
        don't always display button when noticeview is made visible

* src/mimeview.c
* src/pgpmime.c
* src/privacy.[ch]
* src/sgpgme.[ch]
        get signature information from crypto system

ChangeLog.claws
configure.ac
src/mimeview.c
src/noticeview.c
src/pgpmime.c
src/privacy.c
src/privacy.h
src/sgpgme.c
src/sgpgme.h

index 30cc340..41342e3 100644 (file)
@@ -1,3 +1,14 @@
+2003-10-23 [christoph] 0.9.6claws47
+
+       * src/noticeview.c
+               don't always display button when noticeview is made visible
+
+       * src/mimeview.c
+       * src/pgpmime.c
+       * src/privacy.[ch]
+       * src/sgpgme.[ch]
+               get signature information from crypto system
+
 2003-10-22 [paul]      0.9.6claws46
 
        * po/es.po
index d17cd28..19569bf 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=46
+EXTRA_VERSION=47
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 3dd92ba..cee0b88 100644 (file)
@@ -627,32 +627,29 @@ static void update_signature_noticeview(MimeView *mimeview, MimeInfo *mimeinfo)
                
                switch (privacy_mimeinfo_get_sig_status(mimeinfo)) {
                case SIGNATURE_UNCHECKED:
-                       text = _("This part of the message has been signed");
                        button_text = _("Check");
                        func = check_signature_cb;
                        icon = STOCK_PIXMAP_PRIVACY_SIGNED;
                        break;
                case SIGNATURE_OK:
-                       text = _("Signature is valid");
                        icon = STOCK_PIXMAP_PRIVACY_PASSED;
                        break;
                case SIGNATURE_WARN:
-                       text = _("Signature is ok");
                        icon = STOCK_PIXMAP_PRIVACY_WARN;
                        break;
                case SIGNATURE_INVALID:
-                       text = _("The signature of this part is invalid");
                        icon = STOCK_PIXMAP_PRIVACY_FAILED;
                        break;
                case SIGNATURE_CHECK_FAILED:
-                       text = _("Signature check failed");
                        button_text = _("Check again");
                        func = check_signature_cb;
                        icon = STOCK_PIXMAP_PRIVACY_UNKNOWN;
                default:
                        break;
                }
+               text = privacy_mimeinfo_sig_info_short(mimeinfo);
                noticeview_set_text(mimeview->siginfoview, text);
+               g_free(text);
                noticeview_set_button_text(mimeview->siginfoview, button_text);
                noticeview_set_button_press_callback(
                        mimeview->siginfoview,
index f564865..69cb87a 100644 (file)
@@ -115,7 +115,7 @@ gboolean noticeview_is_visible(NoticeView *noticeview)
 void noticeview_show(NoticeView *noticeview)
 {
        if (!noticeview->visible) {
-               gtk_widget_show_all(GTK_WIDGET_PTR(noticeview));
+               gtk_widget_show(GTK_WIDGET_PTR(noticeview));
                noticeview->visible = TRUE;
        }       
 }
index 8431ace..b1c76d0 100644 (file)
@@ -186,6 +186,15 @@ static SignatureStatus pgpmime_get_sig_status(MimeInfo *mimeinfo)
        return sgpgme_sigstat_gpgme_to_privacy(data->sigstatus);
 }
 
+static gchar *pgpmime_get_sig_info_short(MimeInfo *mimeinfo)
+{
+       PrivacyDataPGP *data = (PrivacyDataPGP *) mimeinfo->privacy;
+       
+       g_return_val_if_fail(data != NULL, g_strdup("Error"));
+
+       return sgpgme_sigstat_info_short(data->ctx, data->sigstatus);
+}
+
 static PrivacySystem pgpmime_system = {
        "PGP/Mime",                     /* name */
 
@@ -194,7 +203,7 @@ static PrivacySystem pgpmime_system = {
        pgpmime_is_signed,              /* is_signed(MimeInfo *) */
        pgpmime_check_signature,        /* check_signature(MimeInfo *) */
        pgpmime_get_sig_status,         /* get_sig_status(MimeInfo *) */
-       NULL,                           /* get_sig_info_short(MimeInfo *) */
+       pgpmime_get_sig_info_short,     /* get_sig_info_short(MimeInfo *) */
        NULL,                           /* get_sig_info_full(MimeInfo *) */
 
        /* NOT YET */
index 13fbaf8..13059c7 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <glib.h>
 
+#include "intl.h"
 #include "privacy.h"
 #include "procmime.h"
 
@@ -103,6 +104,25 @@ SignatureStatus privacy_mimeinfo_get_sig_status(MimeInfo *mimeinfo)
        return system->get_sig_status(mimeinfo);
 }
 
+gchar *privacy_mimeinfo_sig_info_short(MimeInfo *mimeinfo)
+{
+       PrivacySystem *system;
+
+       g_return_val_if_fail(mimeinfo != NULL, NULL);
+
+       if (mimeinfo->privacy == NULL)
+               privacy_mimeinfo_is_signed(mimeinfo);
+       
+       if (mimeinfo->privacy == NULL)
+               return g_strdup(_("No signature found"));
+       
+       system = mimeinfo->privacy->system;
+       if (system->get_sig_info_short == NULL)
+               return g_strdup(_("No information available"));
+       
+       return system->get_sig_info_short(mimeinfo);
+}
+
 gboolean privacy_mimeinfo_is_encrypted(MimeInfo *mimeinfo)
 {
        g_return_val_if_fail(mimeinfo != NULL, FALSE);
index f339f60..583665c 100644 (file)
@@ -43,6 +43,7 @@ void privacy_free_privacydata                 (PrivacyData *);
 gboolean privacy_mimeinfo_is_signed            (MimeInfo *);
 gint privacy_mimeinfo_check_signature          (MimeInfo *);
 SignatureStatus privacy_mimeinfo_get_sig_status        (MimeInfo *);
+gchar *privacy_mimeinfo_sig_info_short         (MimeInfo *);
 
 #if 0 /* NOT YET */
 gboolean privacy_mimeinfo_is_encrypted         (MimeInfo *);
@@ -57,8 +58,8 @@ struct _PrivacySystem {
        gboolean         (*is_signed)           (MimeInfo *);
        gint             (*check_signature)     (MimeInfo *);
        SignatureStatus  (*get_sig_status)      (MimeInfo *);
-       const gchar     *(*get_sig_info_short)  (MimeInfo *);
-       const gchar     *(*get_sig_info_full)   (MimeInfo *);
+       gchar           *(*get_sig_info_short)  (MimeInfo *);
+       gchar           *(*get_sig_info_full)   (MimeInfo *);
 
        /* NOT YET */
        gboolean         (*is_encrypted)        (MimeInfo *);
index 1863c4c..391f088 100644 (file)
@@ -78,6 +78,67 @@ SignatureStatus sgpgme_sigstat_gpgme_to_privacy(GpgmeSigStat status)
        return SIGNATURE_CHECK_FAILED;
 }
 
+static const gchar *get_validity_str(unsigned long validity)
+{
+       switch (validity) {
+       case GPGME_VALIDITY_UNKNOWN:
+               return _("Unknown");
+       case GPGME_VALIDITY_UNDEFINED:
+               return _("Undefined");
+       case GPGME_VALIDITY_NEVER:
+               return _("Never");
+       case GPGME_VALIDITY_MARGINAL:
+               return _("Marginal");
+       case GPGME_VALIDITY_FULL:
+               return _("Full");
+       case GPGME_VALIDITY_ULTIMATE:
+               return _("Ultimate");
+       default:
+               return _("Error");
+       }
+}
+
+gchar *sgpgme_sigstat_info_short(GpgmeCtx ctx, GpgmeSigStat status)
+{
+       GpgmeKey key;
+
+       switch (status) {
+       case GPGME_SIG_STAT_GOOD:
+       {
+               unsigned long validity = 0, val, i;     
+       
+               if (gpgme_get_sig_key(ctx, 0, &key) != GPGME_No_Error)
+                       return g_strdup(_("Error"));
+               
+               i = 0;
+               while ((val = gpgme_key_get_ulong_attr(key, GPGME_ATTR_VALIDITY, NULL, i++)) > 0)
+                       if (val > validity)
+                               validity = val;
+               
+               return g_strdup_printf(_("Valid signature by %s (Trust: %s)"),
+                       gpgme_key_get_string_attr(key, GPGME_ATTR_USERID, NULL, 0),
+                       get_validity_str(validity));
+       }
+       case GPGME_SIG_STAT_GOOD_EXP:
+               return g_strdup(_("The signature of this part has expired"));
+       case GPGME_SIG_STAT_GOOD_EXPKEY:
+               return g_strdup(_("The key that was used to sign this part has expired"));
+       case GPGME_SIG_STAT_DIFF:
+               return g_strdup(_("Not all signatures are valid"));
+       case GPGME_SIG_STAT_BAD:
+               return g_strdup(_("This signature is invalid"));
+       case GPGME_SIG_STAT_NOKEY:
+               return g_strdup(_("You have no key to verify this signature"));
+       case GPGME_SIG_STAT_NOSIG:
+               return g_strdup(_("Bo signature found"));
+       case GPGME_SIG_STAT_ERROR:
+               return g_strdup(_("An error occured"));
+       case GPGME_SIG_STAT_NONE:
+               return g_strdup(_("The signature of this part has not been checked"));
+       }
+       return g_strdup(_("Error"));
+}
+
 void sgpgme_init()
 {
        if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) != 
index 3be85cd..37d3dd6 100644 (file)
 void sgpgme_init(void);
 void sgpgme_done(void);
 
-GpgmeSigStat sgpgme_verify_signature(GpgmeCtx ctx,
-                                    GpgmeData sig,
-                                    GpgmeData plain);
-SignatureStatus sgpgme_sigstat_gpgme_to_privacy(GpgmeSigStat status);
+GpgmeSigStat sgpgme_verify_signature   (GpgmeCtx ctx,
+                                        GpgmeData sig,
+                                        GpgmeData plain);
+SignatureStatus sgpgme_sigstat_gpgme_to_privacy
+                                       (GpgmeSigStat status);
+gchar *sgpgme_sigstat_info_short       (GpgmeCtx ctx,
+                                        GpgmeSigStat status);
 
 #endif /* SGPGME_H */