From 10b0586ff23283c1f3f8fee6832efcc21462df30 Mon Sep 17 00:00:00 2001 From: "spider%netscape.com" Date: Fri, 30 Oct 1998 19:29:56 +0000 Subject: [PATCH] Switch between MIME & plain based on interface in SMTP Service git-svn-id: svn://10.0.0.236/trunk@13736 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpfc/msg/inc/nsMessage.h | 2 +- mozilla/xpfc/msg/inc/nsSMTPService.h | 4 +++ mozilla/xpfc/msg/public/nsIMessage.h | 2 +- mozilla/xpfc/msg/public/nsISMTPService.h | 5 ++++ mozilla/xpfc/msg/src/nsMessage.cpp | 2 +- mozilla/xpfc/msg/src/nsSMTPService.cpp | 32 +++++++++++++++++++++++- 6 files changed, 43 insertions(+), 4 deletions(-) diff --git a/mozilla/xpfc/msg/inc/nsMessage.h b/mozilla/xpfc/msg/inc/nsMessage.h index 076aa68a56b..6272af16c28 100644 --- a/mozilla/xpfc/msg/inc/nsMessage.h +++ b/mozilla/xpfc/msg/inc/nsMessage.h @@ -36,7 +36,7 @@ public: NS_IMETHOD SetBody(nsString& aBody); NS_IMETHOD GetSender(nsString& aSender); - NS_IMETHOD GetReciepients(nsString& aRecipients); + NS_IMETHOD GetRecipients(nsString& aRecipients); NS_IMETHOD GetSubject(nsString& aSubject); NS_IMETHOD GetBody(nsString& aBody); diff --git a/mozilla/xpfc/msg/inc/nsSMTPService.h b/mozilla/xpfc/msg/inc/nsSMTPService.h index 4add71ef0a1..dfc1191b1ba 100644 --- a/mozilla/xpfc/msg/inc/nsSMTPService.h +++ b/mozilla/xpfc/msg/inc/nsSMTPService.h @@ -41,6 +41,10 @@ public: nsIMessage& aMessage, nsISMTPObserver * aObserver = nsnull); + NS_IMETHOD SendMail(nsString& aServer, + nsIMIMEMessage& aMIMEMessage, + nsISMTPObserver * aObserver = nsnull); + protected: ~nsSMTPService(); diff --git a/mozilla/xpfc/msg/public/nsIMessage.h b/mozilla/xpfc/msg/public/nsIMessage.h index 8fccc5ebe6b..29cf773edf5 100644 --- a/mozilla/xpfc/msg/public/nsIMessage.h +++ b/mozilla/xpfc/msg/public/nsIMessage.h @@ -41,7 +41,7 @@ public: NS_IMETHOD SetBody(nsString& aBody) = 0; NS_IMETHOD GetSender(nsString& aSender) = 0; - NS_IMETHOD GetReciepients(nsString& aRecipients) = 0; + NS_IMETHOD GetRecipients(nsString& aRecipients) = 0; NS_IMETHOD GetSubject(nsString& aSubject) = 0; NS_IMETHOD GetBody(nsString& aBody) = 0; diff --git a/mozilla/xpfc/msg/public/nsISMTPService.h b/mozilla/xpfc/msg/public/nsISMTPService.h index 39ddf36b00f..45941fa634b 100644 --- a/mozilla/xpfc/msg/public/nsISMTPService.h +++ b/mozilla/xpfc/msg/public/nsISMTPService.h @@ -22,6 +22,7 @@ #include "nsISupports.h" #include "nsString.h" #include "nsIMessage.h" +#include "nsIMIMEMessage.h" #include "nsISMTPObserver.h" //b64f8b50-6f77-11d2-8dbc-00805f8a7ab6 @@ -47,6 +48,10 @@ public: nsIMessage& aMessage, nsISMTPObserver * aObserver = nsnull) = 0; + NS_IMETHOD SendMail(nsString& aServer, + nsIMIMEMessage& aMIMEMessage, + nsISMTPObserver * aObserver = nsnull) = 0; + }; #endif /* nsISMTPService_h___ */ diff --git a/mozilla/xpfc/msg/src/nsMessage.cpp b/mozilla/xpfc/msg/src/nsMessage.cpp index 309e5d15e79..cf1a29141db 100644 --- a/mozilla/xpfc/msg/src/nsMessage.cpp +++ b/mozilla/xpfc/msg/src/nsMessage.cpp @@ -79,7 +79,7 @@ nsresult nsMessage::GetSender(nsString& aSender) return NS_OK; } -nsresult nsMessage::GetReciepients(nsString& aRecipients) +nsresult nsMessage::GetRecipients(nsString& aRecipients) { aRecipients = mRecipients; return NS_OK; diff --git a/mozilla/xpfc/msg/src/nsSMTPService.cpp b/mozilla/xpfc/msg/src/nsSMTPService.cpp index d72067c9f93..48a28ab1056 100644 --- a/mozilla/xpfc/msg/src/nsSMTPService.cpp +++ b/mozilla/xpfc/msg/src/nsSMTPService.cpp @@ -25,10 +25,11 @@ #include #include "nsCRT.h" #include "nsSMTPServerCallback.h" +#include "nsIMIMEMessage.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kSMTPServiceIID, NS_ISMTP_SERVICE_IID); - +static NS_DEFINE_IID(kIMIMEMessageIID, NS_IMIME_MESSAGE_IID); nsSMTPService :: nsSMTPService() { @@ -58,8 +59,37 @@ nsresult nsSMTPService::SendMail(nsString& aServer, * plain/text mail */ + nsIMIMEMessage * mime_message = nsnull; + nsresult res = NS_OK; + res = aMessage.QueryInterface(kIMIMEMessageIID, (void**)&mime_message); + + if (res == NS_OK) + return (SendMail(aServer, *mime_message, aObserver)); + + /* + * this is not a MIME message. Send as plain text + */ + + nsString str_from; + nsString str_to; + nsString str_subject; + nsString str_body; + + aMessage.GetSender(str_from); + aMessage.GetRecipients(str_to); + aMessage.GetSubject(str_subject); + aMessage.GetBody(str_body); + + return (SendMail(aServer, str_from,str_to, str_subject, str_body)); + +} + +nsresult nsSMTPService::SendMail(nsString& aServer, + nsIMIMEMessage& aMIMEMessage, + nsISMTPObserver * aObserver) +{ return NS_OK; }