0.9.6claws14
authorChristoph Hohmann <reboot@gmx.ch>
Fri, 10 Oct 2003 21:57:06 +0000 (21:57 +0000)
committerChristoph Hohmann <reboot@gmx.ch>
Fri, 10 Oct 2003 21:57:06 +0000 (21:57 +0000)
* src/main.c
* src/privacy.[ch]
* src/rfc2015.[ch]
        implement detection of signed message parts for rfc2015

ChangeLog.claws
configure.ac
src/main.c
src/privacy.c
src/privacy.h
src/rfc2015.c
src/rfc2015.h

index 1d89e7d..d89e8ef 100644 (file)
@@ -1,3 +1,10 @@
+2003-10-10 [thorsten]  0.9.6claws14
+
+       * src/main.c
+       * src/privacy.[ch]
+       * src/rfc2015.[ch]
+               implement detection of signed message parts for rfc2015
+
 2003-10-10 [thorsten]  0.9.6claws13
 
        * src/mimeview.c
index e80cc6b..a226c96 100644 (file)
@@ -11,7 +11,7 @@ MINOR_VERSION=9
 MICRO_VERSION=6
 INTERFACE_AGE=0
 BINARY_AGE=0
-EXTRA_VERSION=13
+EXTRA_VERSION=14
 if test $EXTRA_VERSION -eq 0; then
     VERSION=${MAJOR_VERSION}.${MINOR_VERSION}.${MICRO_VERSION}claws
 else
index 93b58ef..1d43ed3 100644 (file)
@@ -117,10 +117,6 @@ static struct RemoteCmd {
 
 static void parse_cmd_opt(int argc, char *argv[]);
 
-#if USE_GPGME
-static void idle_function_for_gpgme(void);
-#endif /* USE_GPGME */
-
 static gint prohibit_duplicate_launch  (void);
 static gchar * get_crashfile_name      (void);
 static gint lock_socket_remove         (void);
@@ -250,27 +246,7 @@ int main(int argc, char *argv[])
        prefs_common_read_config();
 
 #if USE_GPGME
-       gpg_started = FALSE;
-       if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) != 
-                       GPGME_No_Error) {  /* Also does some gpgme init */
-               rfc2015_disable_all();
-               debug_print("gpgme_engine_version:\n%s\n",
-                           gpgme_get_engine_info());
-
-               if (prefs_common.gpg_warning) {
-                       AlertValue val;
-
-                       val = alertpanel_message_with_disable
-                               (_("Warning"),
-                                _("GnuPG is not installed properly, or needs to be upgraded.\n"
-                                  "OpenPGP support disabled."));
-                       if (val & G_ALERTDISABLE)
-                               prefs_common.gpg_warning = FALSE;
-               }
-       } else
-               gpg_started = TRUE;
-
-       gpgme_register_idle(idle_function_for_gpgme);
+       rfc2015_init();
 #endif
 
        prefs_fonts_init();
@@ -382,6 +358,10 @@ int main(int argc, char *argv[])
 
        addressbook_destroy();
 
+#ifdef USE_GPGME
+       rfc2015_done();
+#endif
+
        prefs_fonts_done();
 #ifdef USE_ASPELL       
        prefs_spelling_done();
@@ -620,10 +600,6 @@ void app_will_exit(GtkWidget *widget, gpointer data)
 
        inc_autocheck_timer_remove();
 
-#if USE_GPGME
-        gpgmegtk_free_passphrase();
-#endif
-
        if (prefs_common.clean_on_exit)
                main_window_empty_trash(mainwin, prefs_common.ask_on_clean);
 
@@ -669,14 +645,6 @@ void app_will_exit(GtkWidget *widget, gpointer data)
        gtk_main_quit();
 }
 
-#if USE_GPGME
-static void idle_function_for_gpgme(void)
-{
-       while (gtk_events_pending())
-               gtk_main_iteration();
-}
-#endif /* USE_GPGME */
-
 /*
  * CLAWS: want this public so crash dialog can delete the
  * lock file too
index 918c296..dbd6bed 100644 (file)
 #include "privacy.h"
 #include "procmime.h"
 
+static GSList *systems = NULL;
+
+void privacy_register_system(PrivacySystem *system)
+{
+       systems = g_slist_append(systems, system);
+}
+
+void privacy_unregister_system(PrivacySystem *system)
+{
+       systems = g_slist_remove(systems, system);
+}
+
 void privacy_free_privacydata(PrivacyData *privacydata)
 {
        g_return_if_fail(privacydata != NULL);
@@ -31,10 +43,26 @@ void privacy_free_privacydata(PrivacyData *privacydata)
 
 gboolean privacy_mimeinfo_is_signed(MimeInfo *mimeinfo)
 {
-       g_return_val_if_fail(mimeinfo != NULL, NULL);
+       GSList *cur;
+       g_return_val_if_fail(mimeinfo != NULL, FALSE);
+
+       if (mimeinfo->privacy != NULL) {
+               PrivacySystem *system = mimeinfo->privacy->system;
+
+               if (system->is_signed != NULL)
+                       return system->is_signed(mimeinfo);
+               else
+                       return FALSE;
+       }
+
+       for(cur = systems; cur != NULL; cur = g_slist_next(cur)) {
+               PrivacySystem *system = (PrivacySystem *) cur->data;
+
+               if(system->is_signed != NULL && system->is_signed(mimeinfo))
+                       return TRUE;                    
+       }
 
        return FALSE;
-       /* return mimeinfo->type == MIMETYPE_TEXT ? TRUE : FALSE; */
 }
 
 const gchar *privacy_get_signer(MimeInfo *mimeinfo)
@@ -46,7 +74,7 @@ const gchar *privacy_get_signer(MimeInfo *mimeinfo)
 
 gboolean privacy_mimeinfo_is_encrypted(MimeInfo *mimeinfo)
 {
-       g_return_val_if_fail(mimeinfo != NULL, NULL);
+       g_return_val_if_fail(mimeinfo != NULL, FALSE);
 
        return FALSE;
 }
index cb18220..0885b51 100644 (file)
@@ -33,6 +33,9 @@ typedef enum {
 
 #include "procmime.h"
 
+void privacy_register_system           (PrivacySystem *system);
+void privacy_unregister_system         (PrivacySystem *system);
+
 void privacy_free_privacydata          (PrivacyData *);
 
 gboolean privacy_mimeinfo_is_signed    (MimeInfo *);
@@ -45,16 +48,17 @@ gint privacy_decrypt                        (MimeInfo *);
 #endif
 
 struct _PrivacySystem {
+       gchar            *name;
+
        void             (*free_privacydata)    (PrivacyData *);
 
        gboolean         (*is_signed)           (MimeInfo *);
        const gchar     *(*get_signer)          (MimeInfo *);
        SignatureStatus  (*check_signature)     (MimeInfo *);
 
-#if 0 /* NOT YET */
+       /* NOT YET */
        gboolean         (*is_encrypted)        (MimeInfo *);
        MimeInfo        *(*decrypt)             (MimeInfo *);
-#endif
 };
 
 struct _PrivacyData {
index 0f3b082..a0cc91e 100644 (file)
@@ -46,6 +46,7 @@
 #include "select-keys.h"
 #include "sigstatus.h"
 #include "rfc2015.h"
+#include "alertpanel.h"
 
 #define DIM(v)     (sizeof(v)/sizeof((v)[0]))
 
@@ -1462,4 +1463,88 @@ failure:
     return -1;
 }
 
+static gboolean rfc2015_is_signed(MimeInfo *mimeinfo)
+{
+       MimeInfo *parent;
+       MimeInfo *signature;
+       gchar *protocol;
+
+       g_return_val_if_fail(mimeinfo != NULL, FALSE);
+       
+       /* check parent */
+       parent = mimeinfo->parent;
+       if (parent == NULL)
+               return FALSE;
+       if ((parent->type != MIMETYPE_MULTIPART) ||
+           g_strcasecmp(parent->subtype, "signed"))
+               return FALSE;
+       protocol = g_hash_table_lookup(parent->parameters, "protocol");
+       if ((protocol == NULL) || g_strcasecmp(protocol, "application/pgp-signature"))
+               return FALSE;
+
+       /* check if mimeinfo is the first child */
+       if (parent->children != mimeinfo)
+               return FALSE;
+
+       /* check signature */
+       signature = parent->children->next;
+       if (signature == NULL)
+               return FALSE;
+       if ((signature->type != MIMETYPE_APPLICATION) ||
+           g_strcasecmp(signature->subtype, "pgp-signature"))
+               return FALSE;
+
+       return TRUE;
+}
+
+static void idle_function_for_gpgme(void)
+{
+       while (gtk_events_pending())
+               gtk_main_iteration();
+}
+
+static PrivacySystem rfc2015_system = {
+       "PGP/Mime",             /* name */
+
+       g_free,                 /* free_privacydata */
+
+       rfc2015_is_signed,      /* is_signed(MimeInfo *) */
+       NULL,                   /* get_signer(MimeInfo *) */
+       NULL,                   /* check_signature(MimeInfo *) */
+
+       /* NOT YET */
+       NULL,                   /* is_encrypted(MimeInfo *) */
+       NULL,                   /* decrypt(MimeInfo *) */
+};
+
+void rfc2015_init()
+{
+       if (gpgme_engine_check_version(GPGME_PROTOCOL_OpenPGP) != 
+                       GPGME_No_Error) {  /* Also does some gpgme init */
+               rfc2015_disable_all();
+               debug_print("gpgme_engine_version:\n%s\n",
+                           gpgme_get_engine_info());
+
+               if (prefs_common.gpg_warning) {
+                       AlertValue val;
+
+                       val = alertpanel_message_with_disable
+                               (_("Warning"),
+                                _("GnuPG is not installed properly, or needs to be upgraded.\n"
+                                  "OpenPGP support disabled."));
+                       if (val & G_ALERTDISABLE)
+                               prefs_common.gpg_warning = FALSE;
+               }
+       } else
+               privacy_register_system(&rfc2015_system);
+
+       gpgme_register_idle(idle_function_for_gpgme);
+}
+
+void rfc2015_done()
+{
+       privacy_unregister_system(&rfc2015_system);
+        gpgmegtk_free_passphrase();
+}
+
 #endif /* USE_GPGME */
index cf6ca4f..0452319 100644 (file)
@@ -25,6 +25,9 @@
 
 #include "procmime.h"
 
+void rfc2015_init                      (void);
+void rfc2015_done                      (void);
+
 void rfc2015_disable_all               (void);
 void rfc2015_secure_remove             (const gchar    *fname);
 MimeInfo *rfc2015_find_signature       (MimeInfo       *mimeinfo);
@@ -44,6 +47,4 @@ gint rfc2015_sign                     (const gchar    *file,
                                         GSList         *key_list);
 gint rfc2015_clearsign                 (const gchar    *file,
                                         GSList         *key_list);
-
-gboolean gpg_started;
 #endif /* __RFC2015_H__ */