Update of /cvsroot/mahogany/M/src/classes
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19477/src/classes

Modified Files:
        MessageView.cpp 
Log Message:
still show PGP signature (as unverified) when PGP command is not configured 
instead of not handling PGP signed messages at all

Index: MessageView.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/classes/MessageView.cpp,v
retrieving revision 1.166
retrieving revision 1.167
diff -b -u -2 -r1.166 -r1.167
--- MessageView.cpp     25 Jun 2005 15:30:30 -0000      1.166
+++ MessageView.cpp     13 Jul 2005 16:20:00 -0000      1.167
@@ -2006,5 +2006,5 @@
 }
 
-void
+bool
 MessageView::ProcessAlternativeMultiPart(const MimePart *mimepart)
 {
@@ -2033,21 +2033,24 @@
 
    // show just the best one
-   CHECK_RET(partBest != 0, _T("No part can be displayed !"));
+   CHECK(partBest, false, _T("No part can be displayed !"));
 
    // the content of an alternative is not necessarily a single
    // part, so process it as well.
    ProcessPart(partBest);
+
+   return true;
 }
 
-void
+bool
 MessageView::ProcessSignedMultiPart(const MimePart *mimepart)
 {
-   // we use MP_PGP_COMMAND as a boolean switch telling us whether we should
-   // use pgp or not as well
-   if ( mimepart->GetParam(_T("protocol")) == _T("application/pgp-signature") 
&&
-            !READ_APPCONFIG_TEXT(MP_PGP_COMMAND).empty() )
+   if ( mimepart->GetParam(_T("protocol")) != _T("application/pgp-signature") )
    {
-      static const wxChar *sigIgnoredMsg =
-         gettext_noop("\n\nSignature will be ignored");
+      // unknown signature protocol, don't try to interpret it
+      return false;
+   }
+
+   static const wxChar *
+      sigIgnoredMsg = gettext_noop("\n\nSignature will be ignored");
 
       MimePart * const signedPart = mimepart->GetNested();
@@ -2059,8 +2062,5 @@
                       wxGetTranslation(sigIgnoredMsg));
 
-         // still show the message contents
-         ProcessAllNestedParts(mimepart);
-
-         return;
+      return false;
       }
 
@@ -2079,29 +2079,25 @@
                       wxGetTranslation(sigIgnoredMsg));
 
-         ProcessAllNestedParts(mimepart);
-
-         return;
+      return false;
       }
 
-
       // the signature is applied to both the headers and the body of the
-      // message and it is done after encoding the latter so we need to get it
-      // in the raw form
+   // message and it is done after encoding the latter so we need to get
+   // it in the raw form
       String signedText = signedPart->GetHeaders();
 
       unsigned long signedTextLength = 0;
-      const char* c = (const char 
*)signedPart->GetRawContent(&signedTextLength);
+   const char *c = static_cast<const char *>(
+                     signedPart->GetRawContent(&signedTextLength));
       signedText += String(wxConvertMB2WX(c), signedTextLength);
 
       MCryptoEngineFactory * const factory
          = (MCryptoEngineFactory *)MModule::LoadModule(_T("PGPEngine"));
-      if ( factory )
-      {
-         MCryptoEngine* pgpEngine = factory->Get();
+   CHECK( factory, false, _T("failed to create PGPEngineFactory") );
 
+   MCryptoEngine *pgpEngine = factory->Get();
          MCryptoEngineOutputLog *log = new MCryptoEngineOutputLog(GetWindow());
 
-         MCryptoEngine::Status
-             status = pgpEngine->VerifyDetachedSignature
+   MCryptoEngine::Status status = pgpEngine->VerifyDetachedSignature
                                  (
                                     signedText,
@@ -2109,5 +2105,4 @@
                                     log
                                  );
-
          ClickablePGPInfo *pgpInfo = ClickablePGPInfo::CreateFromSigStatusCode
                                      (
@@ -2119,6 +2114,4 @@
          ProcessPart(signedPart);
 
-         if ( pgpInfo )
-         {
             pgpInfo->SetLog(log);
 
@@ -2130,30 +2123,19 @@
 
             ShowText(_T("\r\n"));
-         }
-         else
-         {
-            delete log;
-         }
 
          factory->DecRef();
-      }
-      else
-      {
-         FAIL_MSG( _T("failed to create PGPEngineFactory") );
 
-         ProcessPart(signedPart);
-      }
-   }
-   else // unknown signature protocol, don't try to interpret it
-   {
-      ProcessAllNestedParts(mimepart);
-   }
+   return true;
 }
 
-void
+bool
 MessageView::ProcessEncryptedMultiPart(const MimePart *mimepart)
 {
-   if ( mimepart->GetParam(_T("protocol")) == _T("application/pgp-encrypted") )
+   if ( mimepart->GetParam(_T("protocol")) != _T("application/pgp-encrypted") )
    {
+      // unknown encryption protocol, don't try to interpret it
+      return false;
+   }
+
       MimePart * const controlPart = mimepart->GetNested();
       MimePart * const encryptedPart = controlPart->GetNext();
@@ -2163,5 +2145,5 @@
          wxLogError(_("This message pretends to be encrypted but "
                       "doesn't have the correct MIME structure."));
-         return;
+      return false;
       }
 
@@ -2175,5 +2157,5 @@
                       "\"application/octet-stream\" type, "
                       "ignoring it."));
-         return;
+      return false;
       }
 
@@ -2184,6 +2166,6 @@
       MCryptoEngineFactory * const factory
          = (MCryptoEngineFactory *)MModule::LoadModule(_T("PGPEngine"));
-      if ( factory )
-      {
+   CHECK( factory, false, _T("failed to create PGPEngineFactory") );
+
          MCryptoEngine* pgpEngine = factory->Get();
 
@@ -2218,6 +2200,4 @@
          }
 
-         if ( pgpInfo )
-         {
             pgpInfo->SetLog(log);
 
@@ -2229,23 +2209,8 @@
 
             ShowText(_T("\r\n"));
-         }
-         else
-         {
-            delete log;
-         }
 
          factory->DecRef();
-      }
-      else
-      {
-         FAIL_MSG( _T("failed to create PGPEngineFactory") );
 
-         ProcessPart(encryptedPart);
-      }
-   }
-   else // unknown encryption protocol, don't try to interpret it
-   {
-      ProcessAllNestedParts(mimepart);
-   }
+   return true;
 }
 
@@ -2255,20 +2220,24 @@
    // TODO: support for DIGEST and RELATED
 
+   bool processed;
    if ( subtype == _T("ALTERNATIVE") )
    {
-      ProcessAlternativeMultiPart(mimepart);
+      processed = ProcessAlternativeMultiPart(mimepart);
    }
    else if ( subtype == _T("SIGNED") )
    {
-      ProcessSignedMultiPart(mimepart);
+      processed = ProcessSignedMultiPart(mimepart);
    }
    else if ( subtype == _T("ENCRYPTED") )
    {
-      ProcessEncryptedMultiPart(mimepart);
+      processed = ProcessEncryptedMultiPart(mimepart);
    }
    else // process all unknown as MIXED (according to the RFC 2047)
    {
-      ProcessAllNestedParts(mimepart);
+      processed = false;
    }
+
+   if ( !processed )
+      ProcessAllNestedParts(mimepart);
 }
 



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Mahogany-cvsupdates mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to