Update of /cvsroot/mahogany/M/src/modules/crypt
In directory sc8-pr-cvs1:/tmp/cvs-serv22568/src/modules/crypt

Modified Files:
        PGPEngine.cpp 
Log Message:
1. added InsertClickable() in addition to InsertAttachment() to MessageViewer
2. use it in PGP view filter to insert icons showing the PGP status
3. added MCryptoEngineOutputLog


Index: PGPEngine.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/crypt/PGPEngine.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -b -u -2 -r1.7 -r1.8
--- PGPEngine.cpp       5 Dec 2002 00:18:49 -0000       1.7
+++ PGPEngine.cpp       5 Dec 2002 23:14:59 -0000       1.8
@@ -50,55 +50,4 @@
 
 // ----------------------------------------------------------------------------
-// MPassphrase: not used currently
-// ----------------------------------------------------------------------------
-
-#if 0
-
-/**
-  MPassphrase represents a passphrase needed to unlock a private key.
-
-  MPassphrase is basicly just a string which is either stored in memory
-  (insecure) or which the user is asked about every time it is needed. Each
-  pass phrase is associated with a given user id.
- */
-class MPassphrase
-{
-public:
-   MPassphrase() { m_store = false; }
-
-   /**
-     Returns the passphrase -- called by MCryptoEngine when needed.
-
-     This can either return the stored string or ask the user. In either case,
-     Unget() must be called later if the passphrase was correct or Get() should
-     be called again if it was not.
-
-     @param user the user id of the user whose passphrase is requested
-     @param passphrase is filled with the pass phrase if true is returned
-     @return true if ok, false if user cancelled entering the passphrase
-    */
-   bool Get(const String& user, String& passphrase);
-
-   /**
-     Forget or store the passphrase previously returned by Get().
-
-     @param passphrase the pass phrase previously returned by Get()
-    */
-   void Unget(const String& passphrase);
-
-private:
-   /// the user the passphrase was last requested for
-   String m_user;
-
-   /// the stored passphrase if m_store is true
-   String m_passphrase;
-
-   /// if true, we have a valid stored pass phrase
-   bool m_store;
-};
-
-#endif // 0
-
-// ----------------------------------------------------------------------------
 // PassphraseManager: this class can be used to remember the passphrases
 //                    instead of asking the user to reenter them again and
@@ -148,18 +97,26 @@
 public:
    // implement the base class pure virtuals
-   virtual int Decrypt(const String& messageIn,
-                       String& messageOut);
+   virtual Status Decrypt(const String& messageIn,
+                          String& messageOut,
+                          MCryptoEngineOutputLog *log);
 
-   virtual int Encrypt(const String& recipient,
+   virtual Status Encrypt(const String& recipient,
                        const String& messageIn,
                        String &messageOut,
-                       const String& user);
+                          const String& user,
+                          MCryptoEngineOutputLog *log);
 
-   virtual int Sign(const String& user,
+   virtual Status Sign(const String& user,
                     const String& messageIn,
-                    String& messageOut);
+                       String& messageOut,
+                       MCryptoEngineOutputLog *log);
 
-   virtual int VerifySignature(const String& messageIn,
-                               String& messageOut);
+   virtual Status VerifySignature(const String& messageIn,
+                                  String& messageOut,
+                                  MCryptoEngineOutputLog *log);
+
+   virtual Status VerifyDetachedSignature(const String& message,
+                                          const String& signature,
+                                          MCryptoEngineOutputLog *log);
 
 protected:
@@ -167,7 +124,8 @@
       Executes the tool with messageIn on stdin and puts stdout into messageOut
     */
-   int ExecCommand(const String& options,
+   Status ExecCommand(const String& options,
                    const String& messageIn,
-                   String& messageOut);
+                      String& messageOut,
+                      MCryptoEngineOutputLog *log);
 
 private:
@@ -192,5 +150,5 @@
 
 /*
-   The format og "gnupg --status-fd" output as taken from the DETAILS file of
+   The format of "gnupg --status-fd" output as taken from the DETAILS file of
    gnupg distribution:
 
@@ -478,11 +436,10 @@
 };
 
-int
+PGPEngine::Status
 PGPEngine::ExecCommand(const String& options,
                        const String& messageIn,
-                       String& messageOut)
+                       String& messageOut,
+                       MCryptoEngineOutputLog *log)
 {
-   Profile *profile = mApplication->GetProfile();
-
    PGPProcess process;
    long pid = wxExecute
@@ -491,10 +448,5 @@
                (
                 "%s --status-fd=2 --command-fd 0 --output - -a %s",
-//                String(READ_CONFIG_TEXT(profile, MP_PGP_COMMAND)), //FIXME
-#ifdef OS_WIN
-                "G:\\Internet\\PGP\\GPG-1.2.1\\gpg.exe", // TODO
-#else
-                "/usr/bin/gpg", // TODO
-#endif
+                READ_APPCONFIG_TEXT(MP_PGP_COMMAND).c_str(),
                 options.c_str()
                ),
@@ -579,6 +531,5 @@
             else if ( code == _T("EXPSIG") || code == _T("EXPKEYSIG") )
             {
-               // FIXME: at least give a warning
-               status = OK;
+               status = SIGNATURE_EXPIRED_ERROR;
                wxLogWarning(_("Expired signature for public key \"%s\""), pc);
             }
@@ -640,5 +591,5 @@
             else if ( code == _T("MISSING_PASSPHRASE") )
             {
-               wxLogWarning(_("Passphrase for the user \"%s\" unavailable."),
+               wxLogError(_("Passphrase for the user \"%s\" unavailable."),
                             user.c_str());
             }
@@ -693,5 +644,12 @@
             }
          }
-         //else: some babble, ignore
+         else // normal (free form) gpg output
+         {
+            // remember in the output log object if we have one
+            if ( log )
+            {
+               log->AddMessage(line);
+            }
+         }
       }
    }
@@ -712,7 +670,8 @@
 // ----------------------------------------------------------------------------
 
-int
+PGPEngine::Status
 PGPEngine::Decrypt(const String& messageIn,
-                   String& messageOut)
+                   String& messageOut,
+                   MCryptoEngineOutputLog *log)
 {
    // as wxExecute() doesn't allow redirecting anything but stdin/out/err we
@@ -734,13 +693,14 @@
    }
 
-   return ExecCommand(tmpfname.GetName(), _T(""), messageOut);
+   return ExecCommand(tmpfname.GetName(), _T(""), messageOut, log);
 }
 
 
-int
+PGPEngine::Status
 PGPEngine::Encrypt(const String& recipient,
                    const String& messageIn,
                    String &messageOut,
-                   const String& user)
+                   const String& user,
+                   MCryptoEngineOutputLog *log)
 {
    FAIL_MSG( _T("TODO") );
@@ -753,8 +713,9 @@
 // ----------------------------------------------------------------------------
 
-int
+PGPEngine::Status
 PGPEngine::Sign(const String& user,
                 const String& messageIn,
-                String& messageOut)
+                String& messageOut,
+                MCryptoEngineOutputLog *log)
 {
    FAIL_MSG( _T("TODO") );
@@ -764,14 +725,25 @@
 
 
-int
+PGPEngine::Status
 PGPEngine::VerifySignature(const String& messageIn,
-                           String& messageOut)
+                           String& messageOut,
+                           MCryptoEngineOutputLog *log)
 {
-   return ExecCommand(_T(""), messageIn, messageOut);
+   return ExecCommand(_T(""), messageIn, messageOut, log);
 }
 
-// ----------------------------------------------------------------------------
+PGPEngine::Status
+PGPEngine::VerifyDetachedSignature(const String& message,
+                                   const String& signature,
+                                   MCryptoEngineOutputLog *log)
+{
+   FAIL_MSG( _T("TODO") );
+
+   return NOT_IMPLEMENTED_ERROR;
+}
+
+// ============================================================================
 // PassphraseManager
-// ----------------------------------------------------------------------------
+// ============================================================================
 
 UserPassMap PassphraseManager::m_map;



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to