Update of /cvsroot/mahogany/M/src/mail
In directory usw-pr-cvs1:/tmp/cvs-serv14708/src/mail
Modified Files:
MessageCC.cpp SendMessageCC.cpp
Log Message:
implemented "Bounce" command
Index: MessageCC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/MessageCC.cpp,v
retrieving revision 1.128
retrieving revision 1.129
diff -b -u -2 -r1.128 -r1.129
--- MessageCC.cpp 11 Apr 2002 19:26:12 -0000 1.128
+++ MessageCC.cpp 11 Jun 2002 20:22:28 -0000 1.129
@@ -476,5 +476,5 @@
else
{
- ERRORMESSAGE(("Cannot fetch message header"));
+ ERRORMESSAGE((_("Cannot fetch message header")));
}
}
@@ -766,5 +766,5 @@
String
-MessageCC::FetchText(void)
+MessageCC::FetchText(void) const
{
if ( m_folder )
@@ -786,7 +786,13 @@
// having FT_PEEK here for now is a lesser evil, in the
// future we really must have PeekText() and GetText()!
- m_mailFullText = mail_fetchtext_full(m_folder->Stream(), m_uid,
- &m_MailTextLen,
- FT_UID | FT_PEEK);
+ MessageCC *self = (MessageCC *)this;
+ self->m_mailFullText = mail_fetchtext_full
+ (
+ m_folder->Stream(),
+ m_uid,
+ &self->m_MailTextLen,
+ FT_UID | FT_PEEK
+ );
+
m_folder->UnLock();
@@ -802,5 +808,5 @@
else
{
- ERRORMESSAGE(("Cannot get lock for obtaining message text."));
+ ERRORMESSAGE((_("Cannot get lock for obtaining message text.")));
}
}
Index: SendMessageCC.cpp
===================================================================
RCS file: /cvsroot/mahogany/M/src/mail/SendMessageCC.cpp,v
retrieving revision 1.188
retrieving revision 1.189
diff -b -u -2 -r1.188 -r1.189
--- SendMessageCC.cpp 3 May 2002 13:10:59 -0000 1.188
+++ SendMessageCC.cpp 11 Jun 2002 20:22:28 -0000 1.189
@@ -11,27 +11,4 @@
///////////////////////////////////////////////////////////////////////////////
-/*
- This is just a quick note I put here to remind me how to do the
- application/remote-printing support for sending faxes via
- [EMAIL PROTECTED]
-
- puts $f "Content-Type: application/remote-printing"
- puts $f ""
- puts $f "Recipient: $recipient(name)"
- puts $f "Title: "
- puts $f "Organization: $recipient(organisation)"
- puts $f "Address: "
- puts $f "Telephone: "
- puts $f "Facsimile: +$recipient(country) $recipient(local) $recipient(number)"
- puts $f "Email: $recipient(email)"
- puts $f ""
- puts $f "Originator: $user(name)"
- puts $f "Organization: $user(organisation)"
- puts $f "Telephone: $user(tel)"
- puts $f "Facsimile: $user(fax)"
- puts $f "Email: $user(email)"
-
- */
-
// ============================================================================
// declarations
@@ -196,7 +173,16 @@
/* static */
SendMessage *
-SendMessage::Create(Profile *prof, Protocol protocol, wxFrame *frame)
+SendMessage::Create(Profile *profile, Protocol protocol, wxFrame *frame)
{
- return new SendMessageCC(prof, protocol, frame);
+ return new SendMessageCC(profile, protocol, frame);
+}
+
+/* static */
+SendMessage *
+SendMessage::CreateResent(Profile *profile,
+ const Message *message,
+ wxFrame *frame)
+{
+ return new SendMessageCC(profile, Prot_Default, frame, message);
}
@@ -209,15 +195,8 @@
// ----------------------------------------------------------------------------
-SendMessageCC::SendMessageCC(Profile *prof,
+SendMessageCC::SendMessageCC(Profile *profile,
Protocol protocol,
- wxFrame *frame)
-{
- Create(protocol, prof, frame);
-}
-
-void
-SendMessageCC::Create(Protocol protocol,
- Profile *prof,
- wxFrame *frame)
+ wxFrame *frame,
+ const Message *message)
{
m_frame = frame;
@@ -227,30 +206,110 @@
m_headerValues = NULL;
- m_Protocol = protocol;
+ m_wasBuilt = false;
m_Envelope = mail_newenvelope();
m_Body = mail_newbody();
- m_Body->type = TYPEMULTIPART;
- m_Body->nested.part = mail_newbody_part();
- m_Body->nested.part->next = NULL;
- m_NextPart = m_Body->nested.part;
- m_LastPart = m_NextPart;
+ m_NextPart =
+ m_LastPart = NULL;
- if ( !prof )
+ if ( !profile )
{
FAIL_MSG( "SendMessageCC::Create() requires profile" );
- prof = mApplication->GetProfile();
+ profile = mApplication->GetProfile();
}
- m_profile = prof;
+ m_profile = profile;
m_profile->IncRef();
+ // choose the protocol: mail (SMTP, Sendmail) or NNTP
+ if ( protocol == Prot_Default )
+ {
+#ifdef OS_UNIX
+ if ( READ_CONFIG_BOOL(profile, MP_USE_SENDMAIL) )
+ protocol = Prot_Sendmail;
+ else
+#endif // OS_UNIX
+ protocol = Prot_SMTP;
+ }
+
+ m_Protocol = protocol;
+
+ switch ( m_Protocol )
+ {
+ default:
+ FAIL_MSG( "unknown SendMessage protocol" );
+ // fall through
+
+ case Prot_SMTP:
+ m_ServerHost = READ_CONFIG_TEXT(profile, MP_SMTPHOST);
+ m_UserName = READ_CONFIG_TEXT(profile, MP_SMTPHOST_LOGIN);
+ m_Password = READ_CONFIG_TEXT(profile, MP_SMTPHOST_PASSWORD);
+#ifdef USE_SSL
+ m_UseSSLforSMTP = READ_CONFIG_BOOL(profile, MP_SMTPHOST_USE_SSL);
+ m_UseSSLUnsignedforSMTP = READ_CONFIG_BOOL(profile,
+MP_SMTPHOST_USE_SSL_UNSIGNED);
+#endif // USE_SSL
+ break;
+
+#ifdef OS_UNIX
+ case Prot_Sendmail:
+ m_SendmailCmd = READ_CONFIG_TEXT(profile, MP_SENDMAILCMD);
+ break;
+#endif // OS_UNIX
+
+ case Prot_NNTP:
+ m_ServerHost = READ_CONFIG_TEXT(profile, MP_NNTPHOST);
+ m_UserName = READ_CONFIG_TEXT(profile,MP_NNTPHOST_LOGIN);
+ m_Password = READ_CONFIG_TEXT(profile,MP_NNTPHOST_PASSWORD);
+#ifdef USE_SSL
+ m_UseSSLforNNTP = READ_CONFIG_BOOL(profile, MP_NNTPHOST_USE_SSL);
+ m_UseSSLUnsignedforNNTP = READ_CONFIG_BOOL(profile,
+MP_NNTPHOST_USE_SSL_UNSIGNED);
+#endif // USE_SSL
+ }
+
+ // other initializations common to all messages
+ // --------------------------------------------
+
// remember the default hostname to use for addresses without host part
- m_DefaultHost = READ_CONFIG_TEXT(prof, MP_HOSTNAME);
+ m_DefaultHost = READ_CONFIG_TEXT(profile, MP_HOSTNAME);
+
+ if ( READ_CONFIG_BOOL(profile, MP_USE_OUTBOX) )
+ m_OutboxName = READ_CONFIG_TEXT(profile,MP_OUTBOX_NAME);
+ if ( READ_CONFIG(profile,MP_USEOUTGOINGFOLDER) )
+ m_SentMailName = READ_CONFIG_TEXT(profile,MP_OUTGOINGFOLDER);
+
+ // check that we have password if we use it
+ //
+ // FIXME: why do we do it here and not when sending??
+ if ( !m_UserName.empty() && m_Password.empty() )
+ {
+ MDialog_GetPassword(protocol, m_ServerHost,
+ &m_Password, &m_UserName, m_frame);
+ }
+ else // we do have it stored
+ {
+ m_Password = strutil_decrypt(m_Password);
+ }
+
+ // finally, special init for resent messages
+ // -----------------------------------------
+
+ if ( message )
+ InitResent(message);
+ else
+ InitNew();
+}
+
+void SendMessageCC::InitNew()
+{
+ m_Body->type = TYPEMULTIPART;
+ m_Body->nested.part = mail_newbody_part();
+ m_Body->nested.part->next = NULL;
+ m_NextPart = m_Body->nested.part;
+ m_LastPart = m_NextPart;
// set up default values for From/Reply-To headers
- AddressList_obj addrList(AddressList::CreateFromAddress(prof));
+ AddressList_obj addrList(AddressList::CreateFromAddress(m_profile));
Address *addrFrom = addrList->GetFirst();
if ( addrFrom )
@@ -259,5 +318,5 @@
}
- m_ReplyTo = READ_CONFIG_TEXT(prof, MP_REPLY_ADDRESS);
+ m_ReplyTo = READ_CONFIG_TEXT(m_profile, MP_REPLY_ADDRESS);
/*
@@ -267,7 +326,7 @@
instead.
*/
- if ( READ_CONFIG(prof, MP_GUESS_SENDER) )
+ if ( READ_CONFIG(m_profile, MP_GUESS_SENDER) )
{
- m_Sender = READ_CONFIG_TEXT(prof, MP_SMTPHOST_LOGIN);
+ m_Sender = READ_CONFIG_TEXT(m_profile, MP_SMTPHOST_LOGIN);
m_Sender.Trim().Trim(FALSE); // remove all spaces on begin/end
@@ -280,54 +339,75 @@
else // don't guess, use provided value
{
- m_Sender = READ_CONFIG_TEXT(prof, MP_SENDER);
+ m_Sender = READ_CONFIG_TEXT(m_profile, MP_SENDER);
}
- if ( READ_CONFIG_BOOL(prof, MP_COMPOSE_USE_XFACE) )
- m_XFaceFile = prof->readEntry(MP_COMPOSE_XFACE_FILE, "");
- if ( READ_CONFIG_BOOL(prof, MP_USE_OUTBOX) )
- m_OutboxName = READ_CONFIG_TEXT(prof,MP_OUTBOX_NAME);
- if ( READ_CONFIG(prof,MP_USEOUTGOINGFOLDER) )
- m_SentMailName = READ_CONFIG_TEXT(prof,MP_OUTGOINGFOLDER);
- m_CharSet = READ_CONFIG_TEXT(prof,MP_CHARSET);
+ if ( READ_CONFIG_BOOL(m_profile, MP_COMPOSE_USE_XFACE) )
+ m_XFaceFile = m_profile->readEntry(MP_COMPOSE_XFACE_FILE, "");
-#ifdef OS_UNIX
- if ( READ_CONFIG(prof, MP_USE_SENDMAIL) )
- {
- m_SendmailCmd = READ_CONFIG_TEXT(prof, MP_SENDMAILCMD);
- }
-#endif // OS_UNIX
+ m_CharSet = READ_CONFIG_TEXT(m_profile,MP_CHARSET);
+}
+
+void SendMessageCC::InitResent(const Message *message)
+{
+ CHECK_RET( message, "message being resent can't be NULL" );
+
+ CHECK_RET( m_Envelope, "envelope must be created in InitResent" );
+
+ // get the original message header and copy it to remail envelope field
+ // almost without any changes except that we have to mask the transport
+ // layer headers as otherwise the SMTP software might get confused: e.g. if
+ // we don't quote Delivered-To line some systems think that the message is
+ // looping endlessly and we quote "Received:" and "Resent-xxx:" because Pine
+ // does it (although I don't know why)
+ String hdrOrig = message->GetHeader();
+
+ String hdr;
+ hdr.reserve(hdrOrig.length() + 100); // slightly more for "X-"s
- if ( protocol == Prot_SMTP )
+ bool firstHeader = true;
+ for ( const char *p = hdrOrig; *p; p++ )
{
- m_ServerHost = READ_CONFIG_TEXT(prof, MP_SMTPHOST);
- m_UserName = READ_CONFIG_TEXT(prof, MP_SMTPHOST_LOGIN);
- m_Password = READ_CONFIG_TEXT(prof, MP_SMTPHOST_PASSWORD);
-#ifdef USE_SSL
- m_UseSSLforSMTP = READ_CONFIG_BOOL(prof, MP_SMTPHOST_USE_SSL);
- m_UseSSLUnsignedforSMTP = READ_CONFIG_BOOL(prof, MP_SMTPHOST_USE_SSL_UNSIGNED);
-#endif
+ // start of line?
+ if ( firstHeader || (p[0] == '\r' && p[1] == '\n') )
+ {
+ if ( firstHeader )
+ {
+ // no longer
+ firstHeader = false;
}
- else // protocol == NNTP
+ else // end of previous line
{
- m_ServerHost = READ_CONFIG_TEXT(prof, MP_NNTPHOST);
- m_UserName = READ_CONFIG_TEXT(prof,MP_NNTPHOST_LOGIN);
- m_Password = READ_CONFIG_TEXT(prof,MP_NNTPHOST_PASSWORD);
-#ifdef USE_SSL
- m_UseSSLforNNTP = READ_CONFIG_BOOL(prof, MP_NNTPHOST_USE_SSL);
- m_UseSSLUnsignedforNNTP = READ_CONFIG_BOOL(prof, MP_NNTPHOST_USE_SSL_UNSIGNED);
-#endif
+ // copy CR LF as is
+ hdr += *p++;
+ hdr += *p++;
}
- // check that we have password if we use it
- if ( !m_UserName.empty() && m_Password.empty() )
+#define STARTS_WITH(p, what) (!(wxStrnicmp((p), (what), strlen(what))))
+
+ if ( STARTS_WITH(p, "Delivered-To:") ||
+ STARTS_WITH(p, "Received:") ||
+ STARTS_WITH(p, "Resent-") )
{
- MDialog_GetPassword(protocol, m_ServerHost,
- &m_Password, &m_UserName, m_frame);
+ hdr += "X-";
}
- else // we do have it stored
- {
- m_Password = strutil_decrypt(m_Password);
+
+#undef STARTS_WITH
+ }
+
+ hdr += *p;
}
+ m_Envelope->remail = cpystr(hdr.c_str());
+
+ // now copy the body: note that we have to use ENCOTHER here to prevent
+ // c-client from (re)encoding the body
+ m_Body->type = TYPETEXT;
+ m_Body->encoding = ENCOTHER;
+ m_Body->subtype = cpystr("PLAIN");
+
+ // FIXME: we potentially copy a lot of data here!
+ String text = message->FetchText();
+ m_Body->contents.text.data = (unsigned char *)cpystr(text.c_str());
+ m_Body->contents.text.size = text.length();
}
@@ -668,4 +748,6 @@
}
+ if ( adr )
+ {
// Return-Path (it is used as SMTP "MAIL FROM: <>" argument)
ASSERT_MSG( m_Envelope->return_path == NIL, "Return-Path already set?" );
@@ -674,4 +756,5 @@
m_Envelope->return_path->mailbox = cpystr(adr->mailbox);
m_Envelope->return_path->host = cpystr(adr->host);
+ }
}
@@ -895,7 +978,15 @@
SendMessageCC::Build(bool forStorage)
{
- if(m_headerNames != NULL) // message was already build
+ if ( m_wasBuilt )
+ {
+ // message was already build
return;
+ }
+ m_wasBuilt = true;
+
+ // don't add any more headers to the message being resent
+ if ( !m_Envelope->remail )
+ {
SetupFromAddresses();
@@ -1027,4 +1118,5 @@
mail_free_body(&oldbody);
}
+ }
// finally, set the date
@@ -1077,6 +1169,5 @@
bdy->type = type;
- bdy->subtype = (char *) fs_get( subtype.length()+1);
- strcpy(bdy->subtype,(char *)subtype.c_str());
+ bdy->subtype = cpystr((char *)subtype.c_str());
bdy->contents.text.data = data;
@@ -1341,5 +1432,5 @@
SendMessageCC::Send(int flags)
{
- ASSERT_MSG(m_headerNames != NULL, "Build() must have been called!");
+ ASSERT_MSG( m_wasBuilt, "Build() must have been called!" );
if ( !MailFolder::Init() )
_______________________________________________________________
Multimillion Dollar Computer Inventory
Live Webcast Auctions Thru Aug. 2002 - http://www.cowanalexander.com/calendar
_______________________________________________
Mahogany-cvsupdates mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/mahogany-cvsupdates