From 03dd781fc8d29032ea38bf28160d034897d25cc5 Mon Sep 17 00:00:00 2001 From: "spider%netscape.com" Date: Fri, 30 Oct 1998 19:09:57 +0000 Subject: [PATCH] Adding nsIMIMEMessage interface git-svn-id: svn://10.0.0.236/trunk@13731 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpfc/core/inc/nsxpfcCIID.h | 6 +++ mozilla/xpfc/core/inc/nsxpfcFactory.h | 2 + mozilla/xpfc/core/src/nsxpfcFactory.cpp | 2 + mozilla/xpfc/msg/inc/manifest.mn | 1 + mozilla/xpfc/msg/inc/nsMIMEMessage.h | 40 +++++++++++++++ mozilla/xpfc/msg/public/manifest.mn | 1 + mozilla/xpfc/msg/public/nsIMimeMessage.h | 39 +++++++++++++++ mozilla/xpfc/msg/src/manifest.mn | 1 + mozilla/xpfc/msg/src/nsMIMEMessage.cpp | 63 ++++++++++++++++++++++++ mozilla/xpfc/msg/src/nsSMTPService.cpp | 13 ++++- 10 files changed, 167 insertions(+), 1 deletion(-) create mode 100644 mozilla/xpfc/msg/inc/nsMIMEMessage.h create mode 100644 mozilla/xpfc/msg/public/nsIMimeMessage.h create mode 100644 mozilla/xpfc/msg/src/nsMIMEMessage.cpp diff --git a/mozilla/xpfc/core/inc/nsxpfcCIID.h b/mozilla/xpfc/core/inc/nsxpfcCIID.h index 4a976f9d298..1ade160f76f 100644 --- a/mozilla/xpfc/core/inc/nsxpfcCIID.h +++ b/mozilla/xpfc/core/inc/nsxpfcCIID.h @@ -226,5 +226,11 @@ { 0x1887e710, 0x6f9a, 0x11d2, \ {0x8d, 0xbc, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } +//8afb9c70-7029-11d2-8dbc-00805f8a7ab6 +#define NS_MIME_MESSAGE_CID \ + { 0x8afb9c70, 0x7029, 0x11d2, \ + {0x8d, 0xbc, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6} } + + #endif diff --git a/mozilla/xpfc/core/inc/nsxpfcFactory.h b/mozilla/xpfc/core/inc/nsxpfcFactory.h index 13f2c61f8a9..06e1f65402a 100644 --- a/mozilla/xpfc/core/inc/nsxpfcFactory.h +++ b/mozilla/xpfc/core/inc/nsxpfcFactory.h @@ -54,6 +54,7 @@ #include "nsSMTPService.h" #include "nsMIMEService.h" #include "nsMessage.h" +#include "nsMIMEMessage.h" #include "nsXPFCSubject.h" #include "nsXPFCCommand.h" #include "nsXPFCCanvas.h" @@ -112,6 +113,7 @@ static NS_DEFINE_IID(kCXPFCActionCommand, NS_XPFC_ACTION_COMMAND_CID); static NS_DEFINE_IID(kCUserCID, NS_USER_CID); static NS_DEFINE_IID(kCSMTPServiceCID, NS_SMTP_SERVICE_CID); static NS_DEFINE_IID(kCMessageCID, NS_MESSAGE_CID); +static NS_DEFINE_IID(kCMIMEMessageCID, NS_MIME_MESSAGE_CID); static NS_DEFINE_IID(kCMIMEServiceCID, NS_MIME_SERVICE_CID); class nsxpfcFactory : public nsIFactory diff --git a/mozilla/xpfc/core/src/nsxpfcFactory.cpp b/mozilla/xpfc/core/src/nsxpfcFactory.cpp index 61f90ef6769..318ab3229a5 100644 --- a/mozilla/xpfc/core/src/nsxpfcFactory.cpp +++ b/mozilla/xpfc/core/src/nsxpfcFactory.cpp @@ -162,6 +162,8 @@ nsresult nsxpfcFactory::CreateInstance(nsISupports *aOuter, inst = (nsISupports *)new nsMIMEService(); } else if (mClassID.Equals(kCMessageCID)) { inst = (nsISupports *)new nsMessage(); + } else if (mClassID.Equals(kCMIMEMessageCID)) { + inst = (nsISupports *)(nsIMIMEMessage*) new nsMIMEMessage(); } if (inst == NULL) { diff --git a/mozilla/xpfc/msg/inc/manifest.mn b/mozilla/xpfc/msg/inc/manifest.mn index 6c0b7afc470..36e765e8044 100644 --- a/mozilla/xpfc/msg/inc/manifest.mn +++ b/mozilla/xpfc/msg/inc/manifest.mn @@ -16,6 +16,7 @@ PRIVATE_EXPORTS = \ nsSMTPService.h \ nsMIMEService.h \ nsMessage.h \ + nsMIMEMessage.h \ nsSMTPServerCallback.h \ $(NULL) diff --git a/mozilla/xpfc/msg/inc/nsMIMEMessage.h b/mozilla/xpfc/msg/inc/nsMIMEMessage.h new file mode 100644 index 00000000000..0bbc652213c --- /dev/null +++ b/mozilla/xpfc/msg/inc/nsMIMEMessage.h @@ -0,0 +1,40 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsMIMEMessage_h___ +#define nsMIMEMessage_h___ + +#include "nsMessage.h" +#include "nsIMIMEMessage.h" + +class nsMIMEMessage : public nsMessage, + public nsIMIMEMessage +{ +public: + nsMIMEMessage(); + + NS_DECL_ISUPPORTS + + NS_IMETHOD Init() ; + +protected: + ~nsMIMEMessage(); + +}; + +#endif /* nsMIMEMessage_h___ */ diff --git a/mozilla/xpfc/msg/public/manifest.mn b/mozilla/xpfc/msg/public/manifest.mn index 35d551f40f8..0c88fa3de65 100644 --- a/mozilla/xpfc/msg/public/manifest.mn +++ b/mozilla/xpfc/msg/public/manifest.mn @@ -15,6 +15,7 @@ EXPORTS = \ nsIMIMEService.h \ nsISMTPObserver.h \ nsIMessage.h \ + nsIMIMEMessage.h \ $(NULL) PRIVATE_EXPORTS = \ diff --git a/mozilla/xpfc/msg/public/nsIMimeMessage.h b/mozilla/xpfc/msg/public/nsIMimeMessage.h new file mode 100644 index 00000000000..422a611793f --- /dev/null +++ b/mozilla/xpfc/msg/public/nsIMimeMessage.h @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#ifndef nsIMIMEMessage_h___ +#define nsIMIMEMessage_h___ + +#include "nsISupports.h" +#include "nsString.h" + +//d69d9a40-7027-11d2-8dbc-00805f8a7ab6 +#define NS_IMIME_MESSAGE_IID \ +{ 0xd69d9a40, 0x7027, 0x11d2, \ +{ 0x8d, 0xbc, 0x00, 0x80, 0x5f, 0x8a, 0x7a, 0xb6 } } + +class nsIMIMEMessage : public nsISupports +{ + +public: + + NS_IMETHOD Init() = 0; + +}; + +#endif /* nsIMIMEMessage_h___ */ diff --git a/mozilla/xpfc/msg/src/manifest.mn b/mozilla/xpfc/msg/src/manifest.mn index af9272d7851..23c57c93b3f 100644 --- a/mozilla/xpfc/msg/src/manifest.mn +++ b/mozilla/xpfc/msg/src/manifest.mn @@ -21,6 +21,7 @@ CPPSRCS = \ nsSMTPService.cpp \ nsMIMEService.cpp \ nsMessage.cpp \ + nsMIMEMessage.cpp \ nsSMTPServerCallback.cpp \ $(NULL) diff --git a/mozilla/xpfc/msg/src/nsMIMEMessage.cpp b/mozilla/xpfc/msg/src/nsMIMEMessage.cpp new file mode 100644 index 00000000000..3a2686da3e1 --- /dev/null +++ b/mozilla/xpfc/msg/src/nsMIMEMessage.cpp @@ -0,0 +1,63 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ + +#include "nsMIMEMessage.h" +#include "nsxpfcCIID.h" + +static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); +static NS_DEFINE_IID(kIMessageIID, NS_IMESSAGE_IID); +static NS_DEFINE_IID(kIMIMEMessageIID, NS_IMIME_MESSAGE_IID); + +nsMIMEMessage :: nsMIMEMessage() : nsMessage() +{ + NS_INIT_REFCNT(); +} + +nsMIMEMessage :: ~nsMIMEMessage() +{ +} + +NS_IMPL_ADDREF(nsMIMEMessage) +NS_IMPL_RELEASE(nsMIMEMessage) + +nsresult nsMIMEMessage::QueryInterface(REFNSIID aIID, void** aInstancePtr) +{ + if (NULL == aInstancePtr) { + return NS_ERROR_NULL_POINTER; + } + static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); + static NS_DEFINE_IID(kClassIID, kIMIMEMessageIID); + if (aIID.Equals(kClassIID)) { + *aInstancePtr = (void*) this; + AddRef(); + return NS_OK; + } + if (aIID.Equals(kISupportsIID)) { + *aInstancePtr = (void*) (this); + AddRef(); + return NS_OK; + } + return (nsMessage::QueryInterface(aIID,aInstancePtr)); +} + + +nsresult nsMIMEMessage::Init() +{ + return (nsMessage::Init()); +} + diff --git a/mozilla/xpfc/msg/src/nsSMTPService.cpp b/mozilla/xpfc/msg/src/nsSMTPService.cpp index fb5faef987d..d72067c9f93 100644 --- a/mozilla/xpfc/msg/src/nsSMTPService.cpp +++ b/mozilla/xpfc/msg/src/nsSMTPService.cpp @@ -52,6 +52,14 @@ nsresult nsSMTPService::SendMail(nsString& aServer, nsIMessage& aMessage, nsISMTPObserver * aObserver) { + /* + * Check to see if nsIMessage supports the MIME interface, + * and if so , send this message as MIME as do regular + * plain/text mail + */ + + + return NS_OK; } @@ -62,6 +70,10 @@ nsresult nsSMTPService::SendMail(nsString& aServer, nsString& aBody, nsISMTPObserver * aObserver) { + /* + * Get a bunch of character strings for passing to SMTP directly + */ + char * from = aFrom.ToNewCString(); char * to = aTo.ToNewCString(); char * header = aSubject.ToNewCString(); @@ -71,7 +83,6 @@ nsresult nsSMTPService::SendMail(nsString& aServer, data += header; data += "\r\n"; data += aBody.ToNewCString(); - message = data.ToNewCString(); nsString strdomain ;