Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv18437/src/mail
Modified Files:
MailFolder.cpp MailFolderCmn.cpp
Log Message:
1. added MailFolder::SaveMEssageAsMBOX()
2. made resuming interrupted messages work
Index: MailFolder.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolder.cpp,v
retrieving revision 1.273
retrieving revision 1.274
diff -b -u -2 -r1.273 -r1.274
--- MailFolder.cpp 5 Mar 2002 17:32:05 -0000 1.273
+++ MailFolder.cpp 19 Mar 2002 01:43:45 -0000 1.274
@@ -34,4 +34,5 @@
#include <wx/dynarray.h>
+#include <wx/file.h>
#include "MDialogs.h" // for MDialog_FolderChoose
@@ -1295,4 +1296,64 @@
return seq.GetString();
+}
+
+/* static */
+bool MailFolder::SaveMessageAsMBOX(const String& filename, const char *content)
+{
+ wxFile out(filename, wxFile::write);
+ bool ok = out.IsOpened();
+ if ( ok )
+ {
+ // when saving messages to a file we need to "From stuff" them to
+ // make them readable in a standard mail client (including this one)
+
+ // standard prefix
+ String fromLine = "From ";
+
+ // find the from address
+ static const char *FROM_HEADER = "From: ";
+ const char *p = strstr(content, FROM_HEADER);
+ if ( !p )
+ {
+ // this shouldn't normally happen, but if it does just make it up
+ wxLogDebug("Couldn't find from header in the message");
+
+ fromLine += "MAHOGANY-DUMMY-SENDER";
+ }
+ else // take everything until the end of line
+ {
+ // extract just the address in angle brackets
+ p += strlen(FROM_HEADER);
+ const char *q = strchr(p, '<');
+ if ( q )
+ p = q + 1;
+
+ while ( *p && *p != '\r' )
+ {
+ if ( q && *p == '>' )
+ break;
+
+ fromLine += *p++;
+ }
+ }
+
+ fromLine += ' ';
+
+ // time stamp
+ time_t t;
+ time(&t);
+ fromLine += ctime(&t);
+
+ ok = out.Write(fromLine);
+
+ if ( ok )
+ {
+ // write the body
+ size_t len = strlen(content);
+ ok = out.Write(content, len) == len;
+ }
+ }
+
+ return ok;
}
Index: MailFolderCmn.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MailFolderCmn.cpp,v
retrieving revision 1.85
retrieving revision 1.86
diff -b -u -2 -r1.85 -r1.86
--- MailFolderCmn.cpp 15 Feb 2002 18:49:14 -0000 1.85
+++ MailFolderCmn.cpp 19 Mar 2002 01:43:45 -0000 1.86
@@ -707,35 +707,12 @@
pd->Update( 2*i + 1 );
- // iterate over all parts
- int numParts = msg->CountParts();
- for ( int part = 0; part < numParts; part++ )
- {
- size_t size = msg->GetPartSize(part);
- if ( size == 0 )
- {
- // skip empty parts
- continue;
- }
-
- int partType = msg->GetPartType(part);
- if ( (partType == Message::MSG_TYPETEXT) ||
- (partType == Message::MSG_TYPEMESSAGE ))
- {
- // it is always "char *", not "void *" for these types
- const char *cptr = (const char *)msg->GetPartContent(part);
- if( !cptr )
- {
- FAIL_MSG( "failed to get the content of a text psrt?" );
-
- continue;
- }
-
- tmpstr = strutil_enforceNativeCRLF(cptr);
- size = tmpstr.length();
- if ( file.Write(tmpstr, size) != size )
+ if ( !msg->WriteToString(tmpstr, false /* no headers */) )
{
+ wxLogError(_("Failed to get the text of the mesage to save."));
rc = false;
}
- }
+ else
+ {
+ rc &= file.Write(tmpstr);
}
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates