Update of /cvsroot/mahogany/M/src/modules/viewflt
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23263/src/modules/viewflt

Modified Files:
        UUDecode.cpp 
Log Message:
a lot of changes to make it possible to fully support PGP-MIME messages
(although not quite yet):

1. added MimePartVirtual class which can be created from raw text
2. use it instead of (not existing any longer) MimePartRaw in UUDecode.cpp
3. added MessageView::AddVirtualMimePart() which allows to attach a virtual
   MIME part to the viewer, this replaces ugly hack used by UUDecode.cpp
4. added MimePartCCBase: common base for MimePartCC and MimePartVirtual
5. MimePartCC implementation is now in MimePartCC.cpp, not MessageCC.cpp
6. added CclientParseMessage() function, fixed CR LF confusion in MessageCC
   ctor from text


Index: UUDecode.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/modules/viewflt/UUDecode.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -b -u -2 -r1.12 -r1.13
--- UUDecode.cpp        11 Jul 2004 21:33:00 -0000      1.12
+++ UUDecode.cpp        13 Jul 2004 21:58:41 -0000      1.13
@@ -26,101 +26,16 @@
 #endif //USE_PCH
 
-#include "MessageViewer.h"
-#include "ViewFilter.h"
-#include "ClickAtt.h"
-
 #include <wx/bitmap.h>
-
-#include "MimePart.h"
 #include <wx/mimetype.h>
 
-// MimePartRaw
-//
-// A MIME part built from raw data. This class does not know about sub-parts,
-// or other MIME stuff.
-//
-// It should be possible to re-use this class to handle the result of decrypting
-// (part of) a message.
-
-class MimePartRaw : public MimePart
-{
-public:
-  MimePartRaw(const String& fileName,
-              const String& mimeType,
-              const String& content,
-              const String& disposition)
-    : m_fileName(fileName)
-    , m_mimeType(mimeType)
-    , m_content(content)
-    , m_disposition(disposition)
-  {}
-public:
-   virtual MimePart *GetParent() const {return 0;}
-   virtual MimePart *GetNext() const {return 0;}
-   virtual MimePart *GetNested() const {return 0;}
-
-   virtual MimeType GetType() const {
-      return MimeType(m_mimeType);
-   }
-   virtual String GetDescription() const {return String();}
-   virtual String GetFilename() const {return m_fileName;}
-   virtual String GetDisposition() const {return m_disposition;}
-   virtual String GetPartSpec() const {return String();}
-   virtual String GetParam(const String& name) const {return String();}
-   virtual String GetDispositionParam(const String& name) const {return String();}
-   virtual const MimeParameterList& GetParameters() const {return m_parameters;}
-   virtual const MimeParameterList& GetDispositionParameters() const {return 
m_dispositionParameters;}
-
-   /// get the raw (un-decoded) contents of this part
-   virtual const void *GetRawContent(unsigned long *len = NULL) const
-   {
-      // We actually return the only thing we have: the decoded file.
-      return GetContent(len);
-   }
-   virtual const void *GetContent(unsigned long *len) const
-   {
-     if (len)
-        *len = m_content.Length();
-     return m_content.c_str();
-   }
-   virtual String GetTextContent() const
-   {
-      // Same as for MimePartCC
-      unsigned long len;
-      const char *p = reinterpret_cast<const char *>(GetContent(&len));
-      if ( !p )
-         return wxGetEmptyString();
-
-#if wxUSE_UNICODE
-#warning "We need the original encoding here, TODO"
-      return wxConvertMB2WX(p);
-#else // ANSI
-      return wxString(p, len);
-#endif // Unicode/ANSI
-   }
-
+#include "MessageViewer.h"
+#include "ViewFilter.h"
+#include "ClickAtt.h"
 
-   virtual String GetHeaders() const {return String();}
-   virtual MimeXferEncoding GetTransferEncoding() const {return MIME_ENC_BINARY;}
-   virtual size_t GetSize() const {return m_content.length();}
-
-   virtual wxFontEncoding GetTextEncoding() const {return wxFONTENCODING_DEFAULT;}
-   virtual size_t GetNumberOfLines() const {return 0;}
-
-private:
-  MimeParameterList m_parameters;
-  MimeParameterList m_dispositionParameters;
-
-  String m_fileName;
-  String m_mimeType;
-  String m_content;
-  String m_disposition;
-};
+#include "MimePartVirtual.h"
 
 // strlen("\r\n")
 static const size_t lenEOL = 2;
 
-
-
 // ----------------------------------------------------------------------------
 // UUDecodeFilter itself
@@ -131,5 +46,4 @@
 public:
    UUDecodeFilter(MessageView *msgView, ViewFilter *next, bool enable);
-   virtual ~UUDecodeFilter();
 
 protected:
@@ -137,13 +51,4 @@
                           MessageViewer *viewer,
                           MTextStyle& style);
-
-   // all MimePartRaw we create: we add them to this array to free them later
-   //
-   // unfortunately this is totally bogus as we're normally destroyed only when
-   // the program terminates so even if it doesn't appear as the memory leak in
-   // the end, it still is one: the MimePartRaws should have been destroyed
-   // much earlier... unfortunately it's not clear when, probably they should
-   // be attached to the Message and destroyed with it but this is so ugly...
-   wxArrayPtrVoid m_mimeParts;
 };
 
@@ -180,13 +85,4 @@
 }
 
-UUDecodeFilter::~UUDecodeFilter()
-{
-   const size_t count = m_mimeParts.GetCount();
-   for ( size_t n = 0; n < count; n++ )
-   {
-      delete static_cast<MimePartRaw *>(m_mimeParts[n]);
-   }
-}
-
 // ----------------------------------------------------------------------------
 // UUDecodeFilter work function
@@ -379,16 +275,27 @@
          }
 
-         // Let's get a mimeType from the extention
-         wxFileType *fileType = 
mApplication->GetMimeManager().GetFileTypeFromExtension(fileName.AfterLast('.'));
+         // now create the header for the uuencoded part
+         String header(_T("Mime-Version: 1.0\nContent-Disposition: uuencoded\n"));
+
+         // get a mimeType from the extention
          String mimeType;
-         if ( !fileType || !fileType->GetMimeType(&mimeType) )
-         {
-            mimeType = _T("APPLICATION/OCTET-STREAM");
+         String ext;
+         wxSplitPath(fileName, NULL, NULL, &ext);
+         if ( !ext.empty() )
+         {
+            wxFileType *
+               ft = mApplication->GetMimeManager().GetFileTypeFromExtension(ext);
+            if ( ft )
+               ft->GetMimeType(&mimeType);
+            delete ft;
          }
-         delete fileType;
 
-         MimePartRaw *mimepart =
-            new MimePartRaw(fileName, mimeType, decodedFile, _T("uuencoded"));
-         m_mimeParts.Add(mimepart);
+         if ( mimeType.empty() )
+            mimeType = _T("APPLICATION/OCTET-STREAM");
+         header += _T("Content-Type: ") + mimeType + _T("\n");
+
+         MimePartVirtual *
+            mimepart = new MimePartVirtual(header + _T('\n') + decodedFile);
+         m_msgView->AddVirtualMimePart(mimepart);
          m_msgView->ShowPart(mimepart);
 



-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 - 
digital self defense, top technical experts, no vendor pitches, 
unmatched networking opportunities. Visit www.blackhat.com
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates

Reply via email to