mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 10:00:54 +00:00
Changes for compose reorg
This commit is contained in:
parent
e85123ef14
commit
1c192ecb11
@ -71,7 +71,7 @@
|
||||
|
||||
#include "nsIMsgSendLater.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
|
||||
#include "nsIMsgSendLaterListener.h"
|
||||
|
||||
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
|
||||
static NS_DEFINE_CID(kCPop3ServiceCID, NS_POP3SERVICE_CID);
|
||||
@ -910,14 +910,79 @@ nsMessenger::GetTransactionManager(nsITransactionManager* *aTxnMgr)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
SendUnsentMessagesCallback(nsresult aExitCode, PRUint32 totalSentCount,
|
||||
PRUint32 totalSentSuccessfully, void *tagData)
|
||||
NS_IMETHODIMP nsMessenger::SetDocumentCharset(const PRUnichar *characterSet)
|
||||
{
|
||||
// Set a default charset of the webshell.
|
||||
if (nsnull != mWebShell) {
|
||||
mWebShell->SetDefaultCharacterSet(characterSet);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// This is the listener class for the send operation.
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
class SendLaterListener: public nsIMsgSendLaterListener
|
||||
{
|
||||
public:
|
||||
SendLaterListener(void);
|
||||
virtual ~SendLaterListener(void);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* void OnStartSending (in PRUint32 aTotalMessageCount); */
|
||||
NS_IMETHOD OnStartSending(PRUint32 aTotalMessageCount);
|
||||
|
||||
/* void OnProgress (in PRUint32 aCurrentMessage, in PRUint32 aTotalMessage); */
|
||||
NS_IMETHOD OnProgress(PRUint32 aCurrentMessage, PRUint32 aTotalMessage);
|
||||
|
||||
/* void OnStatus (in wstring aMsg); */
|
||||
NS_IMETHOD OnStatus(const PRUnichar *aMsg);
|
||||
|
||||
/* void OnStopSending (in nsresult aStatus, in wstring aMsg, in PRUint32 aTotalTried, in PRUint32 aSuccessful); */
|
||||
NS_IMETHOD OnStopSending(nsresult aStatus, const PRUnichar *aMsg, PRUint32 aTotalTried, PRUint32 aSuccessful);
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(SendLaterListener, nsIMsgSendLaterListener::GetIID());
|
||||
|
||||
SendLaterListener::SendLaterListener()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
}
|
||||
|
||||
SendLaterListener::~SendLaterListener()
|
||||
{
|
||||
}
|
||||
|
||||
nsresult
|
||||
SendLaterListener::OnStartSending(PRUint32 aTotalMessageCount)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SendLaterListener::OnProgress(PRUint32 aCurrentMessage, PRUint32 aTotalMessage)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SendLaterListener::OnStatus(const PRUnichar *aMsg)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SendLaterListener::OnStopSending(nsresult aStatus, const PRUnichar *aMsg, PRUint32 aTotalTried,
|
||||
PRUint32 aSuccessful)
|
||||
{
|
||||
#ifdef NS_DEBUG
|
||||
printf("SendUnsentMessagesCallback: Tried to send %d messages. %d successful.\n",
|
||||
totalSentCount, totalSentSuccessfully);
|
||||
if (NS_SUCCEEDED(aStatus))
|
||||
printf("SendLaterListener::OnStopSending: Tried to send %d messages. %d successful.\n",
|
||||
aTotalTried, aSuccessful);
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -931,16 +996,13 @@ nsMessenger::SendUnsentMessages()
|
||||
if (NS_SUCCEEDED(rv) && pMsgSendLater)
|
||||
{
|
||||
printf("We succesfully obtained a nsIMsgSendLater interface....\n");
|
||||
pMsgSendLater->SendUnsentMessages(nsnull, SendUnsentMessagesCallback, nsnull);
|
||||
|
||||
SendLaterListener *sendLaterListener = new SendLaterListener();
|
||||
if (!sendLaterListener)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
pMsgSendLater->AddListener(sendLaterListener);
|
||||
pMsgSendLater->SendUnsentMessages(nsnull, nsnull, nsnull);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMessenger::SetDocumentCharset(const PRUnichar *characterSet)
|
||||
{
|
||||
// Set a default charset of the webshell.
|
||||
if (nsnull != mWebShell) {
|
||||
mWebShell->SetDefaultCharacterSet(characterSet);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -28,6 +28,8 @@ XPIDLSRCS = \
|
||||
nsIMsgCompose.idl \
|
||||
nsIMsgCompFields.idl \
|
||||
nsIMsgQuote.idl \
|
||||
nsIMsgSendListener.idl \
|
||||
nsIMsgSendLaterListener.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
|
@ -23,6 +23,8 @@ XPIDLSRCS = \
|
||||
.\nsIMsgCompose.idl \
|
||||
.\nsIMsgCompFields.idl \
|
||||
.\nsIMsgQuote.idl \
|
||||
.\nsIMsgSendListener.idl \
|
||||
.\nsIMsgSendLaterListener.idl \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
|
@ -108,5 +108,11 @@ interface nsIMsgCompFields : nsISupports {
|
||||
|
||||
long SetBody(in string value);
|
||||
string GetBody();
|
||||
|
||||
long SetUUEncodeAttachments(in boolean value);
|
||||
boolean GetUUEncodeAttachments();
|
||||
|
||||
long SetTheForcePlainText(in boolean value);
|
||||
boolean GetTheForcePlainText();
|
||||
};
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsIMsgCompFields.h" /* interface nsIMsgCompFields */
|
||||
#include "nsIMsgSendListener.h"
|
||||
#include "nsMsgComposeBE.h"
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
@ -36,9 +37,7 @@ class nsIMsgSend : public nsISupports {
|
||||
const struct nsMsgAttachmentData *attachments,
|
||||
const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
void *relatedPart /* nsMsgSendPart */,
|
||||
nsMsgSendCompletionCallback completionCallback,
|
||||
void *tagData) = 0;
|
||||
|
||||
nsIMsgSendListener **aListenerArray) = 0;
|
||||
|
||||
NS_IMETHOD SendMessageFile(
|
||||
nsIMsgCompFields *fields,
|
||||
@ -46,8 +45,16 @@ class nsIMsgSend : public nsISupports {
|
||||
PRBool deleteSendFileOnCompletion,
|
||||
PRBool digest_p,
|
||||
nsMsgDeliverMode mode,
|
||||
nsMsgSendCompletionCallback completionCallback,
|
||||
void *tagData) = 0;
|
||||
nsIMsgSendListener **aListenerArray) = 0;
|
||||
|
||||
NS_IMETHOD SendWebPage(
|
||||
nsIMsgCompFields *fields,
|
||||
nsIURI *url,
|
||||
nsMsgDeliverMode mode,
|
||||
nsIMsgSendListener **aListenerArray) = 0;
|
||||
|
||||
NS_IMETHOD AddListener(nsIMsgSendListener *aListener) = 0;
|
||||
NS_IMETHOD RemoveListener(nsIMsgSendListener *aListener) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
|
@ -20,6 +20,8 @@
|
||||
|
||||
#include "nsISupports.h" /* interface nsISupports */
|
||||
#include "nsIMsgIdentity.h" /* interface nsIMsgCompFields */
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIMsgSendLaterListener.h"
|
||||
#include "nsMsgComposeBE.h"
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
@ -34,12 +36,16 @@
|
||||
{ 0xe15c83e8, 0x1cf4, 0x11d3, \
|
||||
{ 0x8e, 0xf0, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } };
|
||||
|
||||
class nsIMsgSendLater : public nsISupports {
|
||||
class nsIMsgSendLater : public nsIOutputStream {
|
||||
public:
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMSGSENDLATER_IID)
|
||||
|
||||
NS_IMETHOD SendUnsentMessages(nsIMsgIdentity *identity, nsMsgSendUnsentMessagesCallback msgCallback,
|
||||
void *tagData) = 0;
|
||||
NS_IMETHOD SendUnsentMessages(nsIMsgIdentity *identity,
|
||||
nsIMsgSendLaterListener **listenerArray,
|
||||
void *tagData) = 0;
|
||||
|
||||
NS_IMETHOD RemoveListener(nsIMsgSendLaterListener *aListener) = 0;
|
||||
NS_IMETHOD AddListener(nsIMsgSendLaterListener *aListener) = 0;
|
||||
|
||||
#ifdef XPIDL_JS_STUBS
|
||||
static NS_EXPORT_(JSObject *) InitJSClass(JSContext *cx);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#define _nsMsgComposeBE_H_
|
||||
|
||||
#include "rosetta.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsFileSpec.h"
|
||||
|
||||
//
|
||||
@ -50,7 +51,7 @@ typedef enum
|
||||
// Attachment file/URL structures
|
||||
struct nsMsgAttachmentData
|
||||
{
|
||||
char *url; // The URL to attach. This should be 0 to signify "end of list".
|
||||
nsIURI *url; // The URL to attach. This should be 0 to signify "end of list".
|
||||
|
||||
char *desired_type; // The type to which this document should be
|
||||
// converted. Legal values are NULL, TEXT_PLAIN
|
||||
@ -83,32 +84,32 @@ struct nsMsgAttachmentData
|
||||
//
|
||||
typedef struct nsMsgAttachedFile
|
||||
{
|
||||
char *orig_url; // Where it came from on the network (or even elsewhere on the local disk.)
|
||||
nsIURI *orig_url; // Where it came from on the network (or even elsewhere on the local disk.)
|
||||
|
||||
char *file_name; // The tmp file in which the (possibly converted) data now resides.
|
||||
nsFileSpec *file_spec; // The tmp file in which the (possibly converted) data now resides.
|
||||
|
||||
char *type; // The type of the data in file_name (not necessarily the same as the type of orig_url.)
|
||||
char *type; // The type of the data in file_name (not necessarily the same as the type of orig_url.)
|
||||
|
||||
char *encoding; // Likewise, the encoding of the tmp file. This will be set only if the original
|
||||
// document had an encoding already; we don't do base64 encoding and so forth until
|
||||
// it's time to assemble a full MIME message of all parts.
|
||||
char *encoding; // Likewise, the encoding of the tmp file. This will be set only if the original
|
||||
// document had an encoding already; we don't do base64 encoding and so forth until
|
||||
// it's time to assemble a full MIME message of all parts.
|
||||
|
||||
|
||||
char *description; // For Content-Description header
|
||||
char *x_mac_type; // mac-specific info
|
||||
char *x_mac_creator;// mac-specific info
|
||||
char *real_name; // The real name of the file.
|
||||
char *description; // For Content-Description header
|
||||
char *x_mac_type; // mac-specific info
|
||||
char *x_mac_creator; // mac-specific info
|
||||
char *real_name; // The real name of the file.
|
||||
|
||||
// Some statistics about the data that was written to the file, so that when
|
||||
// it comes time to compose a MIME message, we can make an informed decision
|
||||
// about what Content-Transfer-Encoding would be best for this attachment.
|
||||
// (If it's encoded already, we ignore this information and ship it as-is.)
|
||||
PRUint32 size;
|
||||
PRUint32 unprintable_count;
|
||||
PRUint32 highbit_count;
|
||||
PRUint32 ctl_count;
|
||||
PRUint32 null_count;
|
||||
PRUint32 max_line_length;
|
||||
PRUint32 size;
|
||||
PRUint32 unprintable_count;
|
||||
PRUint32 highbit_count;
|
||||
PRUint32 ctl_count;
|
||||
PRUint32 null_count;
|
||||
PRUint32 max_line_length;
|
||||
|
||||
HG68452
|
||||
|
||||
|
@ -45,6 +45,7 @@ EXPORTS = \
|
||||
nsMsgPrompts.h \
|
||||
nsMsgTransition.h \
|
||||
nsMsgQuote.h \
|
||||
nsURLFetcher.h \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = \
|
||||
@ -70,6 +71,7 @@ CPPSRCS = \
|
||||
nsMsgComposeService.cpp \
|
||||
nsMsgCompose.cpp \
|
||||
nsMsgQuote.cpp \
|
||||
nsURLFetcher.cpp \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
@ -35,6 +35,7 @@ EXPORTS= nsSmtpUrl.h \
|
||||
nsMsgCompose.h \
|
||||
nsMsgCompFields.h \
|
||||
nsMsgQuote.h \
|
||||
nsURLFetcher.h \
|
||||
$(NULL)
|
||||
|
||||
################################################################################
|
||||
@ -64,6 +65,7 @@ CPP_OBJS= .\$(OBJDIR)\nsMsgCompFields.obj \
|
||||
.\$(OBJDIR)\nsMsgAttachmentHandler.obj \
|
||||
.\$(OBJDIR)\nsMsgPrompts.obj \
|
||||
.\$(OBJDIR)\nsMsgQuote.obj \
|
||||
.\$(OBJDIR)\nsURLFetcher.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
@ -46,8 +46,6 @@ void MSG_MailCompositionAllConnectionsComplete (MSG_Pane* /*pane*/) {return;}
|
||||
char *MimeGuessURLContentName(MWContext *context, const char *url) {return NULL;}
|
||||
void MIME_GetMessageCryptoState(MWContext *,PRBool *,PRBool *,PRBool *,PRBool *) {return;}
|
||||
|
||||
XP_Bool isMacFile(char* filename) {return PR_FALSE;}
|
||||
|
||||
HJ10196
|
||||
History_entry * SHIST_GetCurrent(History *) {return NULL;}
|
||||
int MISC_ValidateReturnAddress (MWContext *,const char *) {return nsnull;}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -19,81 +19,94 @@
|
||||
#ifndef _nsMsgAttachment_H_
|
||||
#define _nsMsgAttachment_H_
|
||||
|
||||
#include "net.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsURLFetcher.h"
|
||||
#include "nsIMimeConverter.h"
|
||||
#include "nsMsgCompFields.h"
|
||||
|
||||
// Forward declarations...
|
||||
class nsMsgComposeAndSend;
|
||||
|
||||
class nsMsgComposeAndSend;
|
||||
|
||||
//
|
||||
// This is a class that deals with processing remote attachments. It implements
|
||||
// an nsIStreamListener interface to deal with incoming data
|
||||
//
|
||||
class nsMsgAttachmentHandler
|
||||
{
|
||||
public:
|
||||
|
||||
nsMsgAttachmentHandler();
|
||||
~nsMsgAttachmentHandler();
|
||||
|
||||
void UrlExit(URL_Struct *url, int status, MWContext *context);
|
||||
PRInt32 SnarfAttachment ();
|
||||
void AnalyzeDataChunk (const char *chunk, PRInt32 chunkSize);
|
||||
void AnalyzeSnarfedFile (); /* Analyze a previously-snarfed file.
|
||||
(Currently only used for plaintext
|
||||
converted from HTML.) */
|
||||
int PickEncoding (const char *charset);
|
||||
|
||||
PRBool UseUUEncode_p(void);
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Object methods...
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
nsresult SnarfAttachment(nsMsgCompFields *compFields);
|
||||
nsresult UrlExit(nsresult status, const PRUnichar* aMsg);
|
||||
|
||||
char *m_url_string;
|
||||
URL_Struct *m_url;
|
||||
PRBool m_done;
|
||||
PRBool UseUUEncode_p(void);
|
||||
int PickEncoding (const char *charset);
|
||||
void AnalyzeDataChunk (const char *chunk, PRInt32 chunkSize);
|
||||
void AnalyzeSnarfedFile (); // Analyze a previously-snarfed file.
|
||||
// (Currently only used for plaintext
|
||||
// converted from HTML.)
|
||||
|
||||
nsMsgComposeAndSend *m_mime_delivery_state;
|
||||
|
||||
char *m_charset; /* charset name */
|
||||
char *m_type; /* The real type, once we know it. */
|
||||
char *m_override_type; /* The type we should assume it to be
|
||||
or 0, if we should get it from the
|
||||
URL_Struct (from the server) */
|
||||
char *m_override_encoding; /* Goes along with override_type */
|
||||
|
||||
char *m_desired_type; /* The type it should be converted to. */
|
||||
char *m_description; /* For Content-Description header */
|
||||
char *m_x_mac_type, *m_x_mac_creator; /* Mac file type/creator. */
|
||||
char *m_real_name; /* The name for the headers, if different
|
||||
from the URL. */
|
||||
char *m_encoding; /* The encoding, once we've decided. */
|
||||
PRBool m_already_encoded_p; /* If we attach a document that is already
|
||||
encoded, we just pass it through. */
|
||||
|
||||
char *m_file_name; /* The temp file to which we save it */
|
||||
PRFileDesc *m_file;
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Member vars...
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
nsIURI *mURL;
|
||||
nsFileSpec *mFileSpec; // The temp file to which we save it
|
||||
nsOutputFileStream *mOutFile; // The temp file stream pointer
|
||||
nsURLFetcher *mFetcher; // The URL Fetcher
|
||||
nsMsgCompFields *mCompFields; // Message composition fields for the sender
|
||||
|
||||
#ifdef XP_MAC
|
||||
char *m_ap_filename; /* The temp file holds the appledouble
|
||||
encoding of the file we want to post. */
|
||||
nsFileSpec *mAppleFileSpec; // The temp file holds the appledouble
|
||||
// encoding of the file we want to send.
|
||||
#endif
|
||||
char *m_x_mac_type; // Mac file type
|
||||
char *m_x_mac_creator; // Mac file creator
|
||||
|
||||
PRBool m_done;
|
||||
nsMsgComposeAndSend *m_mime_delivery_state;
|
||||
char *m_charset; // charset name
|
||||
char *m_type; // The real type, once we know it.
|
||||
char *m_override_type; // The type we should assume it to be
|
||||
// or 0, if we should get it from the
|
||||
// server)
|
||||
char *m_override_encoding; // Goes along with override_type
|
||||
|
||||
PRBool m_decrypted_p; /* S/MIME -- when attaching a message that was
|
||||
encrypted, it's necessary to decrypt it first
|
||||
(since nobody but the original recipient can
|
||||
read it -- if you forward it to someone in the
|
||||
raw, it will be useless to them.) This flag
|
||||
indicates whether decryption occurred, so that
|
||||
libmsg can issue appropriate warnings about
|
||||
doing a cleartext forward of a message that was
|
||||
originally encrypted.
|
||||
*/
|
||||
PRUint32 m_size; /* Some state used while filtering it */
|
||||
PRUint32 m_unprintable_count;
|
||||
PRUint32 m_highbit_count;
|
||||
PRUint32 m_ctl_count;
|
||||
PRUint32 m_null_count;
|
||||
PRUint32 m_current_column;
|
||||
PRUint32 m_max_column;
|
||||
PRUint32 m_lines;
|
||||
char *m_desired_type; // The type it should be converted to.
|
||||
char *m_description; // For Content-Description header
|
||||
char *m_real_name; // The name for the headers, if different
|
||||
// from the URL.
|
||||
char *m_encoding; // The encoding, once we've decided. */
|
||||
PRBool m_already_encoded_p; // If we attach a document that is already
|
||||
// encoded, we just pass it through.
|
||||
|
||||
PRBool m_decrypted_p; /* S/MIME -- when attaching a message that was
|
||||
encrypted, it's necessary to decrypt it first
|
||||
(since nobody but the original recipient can
|
||||
read it -- if you forward it to someone in the
|
||||
raw, it will be useless to them.) This flag
|
||||
indicates whether decryption occurred, so that
|
||||
libmsg can issue appropriate warnings about
|
||||
doing a cleartext forward of a message that was
|
||||
originally encrypted. */
|
||||
//
|
||||
// Vars for analyzing file data...
|
||||
//
|
||||
PRUint32 m_size; /* Some state used while filtering it */
|
||||
PRUint32 m_unprintable_count;
|
||||
PRUint32 m_highbit_count;
|
||||
PRUint32 m_ctl_count;
|
||||
PRUint32 m_null_count;
|
||||
PRUint32 m_current_column;
|
||||
PRUint32 m_max_column;
|
||||
PRUint32 m_lines;
|
||||
|
||||
MimeEncoderData *m_encoder_data; /* Opaque state for base64/qp encoder. */
|
||||
|
||||
PRBool m_graph_progress_started;
|
||||
};
|
||||
|
||||
|
||||
|
@ -468,6 +468,33 @@ nsresult nsMsgCompFields::GetAttachVCard(PRBool *_retval)
|
||||
return GetBoolHeader(MSG_ATTACH_VCARD_BOOL_HEADER_MASK, _retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgCompFields::SetUUEncodeAttachments(PRBool value, PRInt32 *_retval)
|
||||
{
|
||||
return GetBoolHeader(MSG_UUENCODE_BINARY_BOOL_HEADER_MASK, _retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgCompFields::GetUUEncodeAttachments(PRBool *_retval)
|
||||
{
|
||||
return GetBoolHeader(MSG_UUENCODE_BINARY_BOOL_HEADER_MASK, _retval);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgCompFields::SetTheForcePlainText(PRBool value, PRInt32 *_retval)
|
||||
{
|
||||
m_force_plain_text = value;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgCompFields::GetTheForcePlainText(PRBool *_retval)
|
||||
{
|
||||
*_retval = m_force_plain_text;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
HJ36954
|
||||
{
|
||||
/* Here's where we allow URLs in the newsgroups: header */
|
||||
|
@ -154,6 +154,11 @@ public:
|
||||
NS_IMETHOD GetAttachVCard(PRBool *_retval);
|
||||
PRBool GetAttachVCard() {return GetBoolHeader(MSG_RETURN_RECEIPT_BOOL_HEADER_MASK);}
|
||||
|
||||
NS_IMETHOD SetUUEncodeAttachments(PRBool value, PRInt32 *_retval);
|
||||
NS_IMETHOD GetUUEncodeAttachments(PRBool *_retval);
|
||||
PRBool GetUUEncodeAttachments() {return GetBoolHeader(MSG_UUENCODE_BINARY_BOOL_HEADER_MASK);}
|
||||
|
||||
|
||||
NS_IMETHOD SetBody(const char *value, PRInt32 *_retval);
|
||||
NS_IMETHOD GetBody(char **_retval);
|
||||
const char* GetBody();
|
||||
@ -177,9 +182,11 @@ public:
|
||||
|
||||
MSG_Pane * GetOwner() { return m_owner; }
|
||||
|
||||
NS_IMETHOD SetTheForcePlainText(PRBool value, PRInt32 *_retval);
|
||||
NS_IMETHOD GetTheForcePlainText(PRBool *_retval);
|
||||
void SetForcePlainText(PRBool value) {m_force_plain_text = value;}
|
||||
PRBool GetForcePlainText() {return m_force_plain_text;}
|
||||
|
||||
void SetForcePlainText(PRBool value) {m_force_plain_text = value;}
|
||||
PRBool GetForcePlainText() {return m_force_plain_text;}
|
||||
void SetUseMultipartAlternative(PRBool value) {m_multipart_alt = value;}
|
||||
PRBool GetUseMultipartAlternative() {return m_multipart_alt;}
|
||||
|
||||
|
@ -1755,12 +1755,12 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset)
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
const char *s, *s2;
|
||||
char *s3;
|
||||
char *url;
|
||||
const char *url;
|
||||
|
||||
if (attachment->m_real_name)
|
||||
return;
|
||||
|
||||
url = attachment->m_url_string;
|
||||
attachment->mURL->GetSpec(&url);
|
||||
|
||||
/* Perhaps the MIME parser knows a better name than the URL itself?
|
||||
This can happen when one attaches a MIME part from one message
|
||||
@ -1771,7 +1771,9 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset)
|
||||
MWContext *x = NULL;
|
||||
attachment->m_real_name = MimeGuessURLContentName(x, url);
|
||||
if (attachment->m_real_name)
|
||||
return;
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Otherwise, extract a name from the URL. */
|
||||
|
||||
@ -1784,7 +1786,9 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset)
|
||||
!PL_strncasecmp (url, "snews:", 6) ||
|
||||
!PL_strncasecmp (url, "IMAP:", 5) ||
|
||||
!PL_strncasecmp (url, "mailbox:", 8))
|
||||
return;
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Take the part of the file name after the last / or \ */
|
||||
s2 = PL_strrchr (s, '/');
|
||||
@ -1908,3 +1912,63 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Utility to create a nsIURI object...
|
||||
nsresult
|
||||
nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec)
|
||||
{
|
||||
if (nsnull == aInstancePtrResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsINetService *inet = nsnull;
|
||||
nsresult rv = nsServiceManager::GetService(kNetServiceCID, nsINetService::GetIID(),
|
||||
(nsISupports **)&inet);
|
||||
if (rv != NS_OK)
|
||||
return rv;
|
||||
|
||||
rv = inet->CreateURL(aInstancePtrResult, aSpec, nsnull, nsnull, nsnull);
|
||||
nsServiceManager::ReleaseService(kNetServiceCID, inet);
|
||||
return rv;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMsgIsLocalFile(const char *url)
|
||||
{
|
||||
if (PL_strncasecmp(url, "file:", 5) == 0)
|
||||
return PR_TRUE;
|
||||
else
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
char
|
||||
*nsMsgGetLocalFileFromURL(char *url)
|
||||
{
|
||||
char * finalPath;
|
||||
NS_ASSERTION(PL_strncasecmp(url, "file://", 7) == 0, "invalid url");
|
||||
finalPath = (char*)PR_Malloc(strlen(url));
|
||||
if (finalPath == NULL)
|
||||
return NULL;
|
||||
strcpy(finalPath, url+6+1);
|
||||
return finalPath;
|
||||
}
|
||||
|
||||
char *
|
||||
nsMsgPlatformFileToURL (const char *name)
|
||||
{
|
||||
char *prefix = "file://";
|
||||
char *retVal = (char *)PR_Malloc(PL_strlen(name) + PL_strlen(prefix) + 1);
|
||||
if (retVal)
|
||||
{
|
||||
PL_strcpy(retVal, "file://");
|
||||
PL_strcat(retVal, name);
|
||||
}
|
||||
|
||||
char *ptr = retVal;
|
||||
while (*ptr)
|
||||
{
|
||||
if (*ptr == '\\') *ptr = '/';
|
||||
++ptr;
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
|
@ -101,6 +101,14 @@ void msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *
|
||||
void nsMsgMIMESetConformToStandard (PRBool conform_p);
|
||||
PRBool nsMsgMIMEGetConformToStandard (void);
|
||||
|
||||
//
|
||||
// network service type calls...
|
||||
//
|
||||
nsresult nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec);
|
||||
PRBool nsMsgIsLocalFile(const char *url);
|
||||
char *nsMsgGetLocalFileFromURL(char *url);
|
||||
char *nsMsgPlatformFileToURL (const char *name);
|
||||
|
||||
|
||||
NS_END_EXTERN_C
|
||||
|
||||
|
@ -394,8 +394,7 @@ nsresult nsMsgCompose::SendMsgEx(MSG_DeliverMode deliverMode, const PRUnichar *a
|
||||
nsnull, // const struct nsMsgAttachmentData *attachments,
|
||||
nsnull, // const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
nsnull, // nsMsgSendPart *relatedPart,
|
||||
nsnull, // callback function defined in nsMsgComposeBE.h
|
||||
nsnull); // tagged FE data that will be passed to the FE
|
||||
nsnull); // listener array
|
||||
}
|
||||
}
|
||||
/*TODO, don't close the window but just hide it, we will close it later when we receive a call back from the BE
|
||||
|
@ -38,10 +38,8 @@ msg_delete_attached_files(struct nsMsgAttachedFile *attachments)
|
||||
PR_FREEIF(tmp->description);
|
||||
PR_FREEIF(tmp->x_mac_type);
|
||||
PR_FREEIF(tmp->x_mac_creator);
|
||||
if (tmp->file_name) {
|
||||
PR_Delete(tmp->file_name);
|
||||
PR_Free(tmp->file_name);
|
||||
}
|
||||
if (tmp->file_spec)
|
||||
delete tmp->file_spec;
|
||||
}
|
||||
PR_FREEIF(attachments);
|
||||
}
|
||||
|
@ -29,6 +29,12 @@ nsMsgDeliveryListener::OnStartRunningUrl(nsIURI * aUrl)
|
||||
#ifdef NS_DEBUG
|
||||
printf("Starting to run the delivery operation\n");
|
||||
#endif
|
||||
|
||||
if (mMsgSendObj)
|
||||
mMsgSendObj->NotifyListenersOnStartSending(nsnull, nsnull);
|
||||
|
||||
if (mMsgSendLaterObj)
|
||||
mMsgSendLaterObj->NotifyListenersOnStartSending(nsnull);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -50,6 +56,19 @@ nsMsgDeliveryListener::OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode)
|
||||
mailUrl->UnRegisterListener(this);
|
||||
}
|
||||
|
||||
if (mMsgSendObj)
|
||||
mMsgSendObj->NotifyListenersOnStopSending(
|
||||
nsnull, // const char *aMsgID,
|
||||
aExitCode, // nsresult aStatus,
|
||||
nsnull, // const PRUnichar *aMsg,
|
||||
nsnull); // nsIFileSpec *returnFileSpec);
|
||||
|
||||
if (mMsgSendLaterObj)
|
||||
mMsgSendLaterObj->NotifyListenersOnStopSending(aExitCode,
|
||||
nsnull, // const PRUnichar *aMsg,
|
||||
nsnull, // PRUint32 aTotalTried,
|
||||
nsnull); // PRUint32 aSuccessful);
|
||||
|
||||
//
|
||||
// Now, important, if there was a callback registered, call the
|
||||
// creators exit routine.
|
||||
@ -67,6 +86,8 @@ nsMsgDeliveryListener::nsMsgDeliveryListener(nsMsgDeliveryCompletionCallback cal
|
||||
mDeliveryType = delivType;
|
||||
mTagData = tagData;
|
||||
mCompletionCallback = callback;
|
||||
mMsgSendObj = nsnull;
|
||||
mMsgSendLaterObj = nsnull;
|
||||
}
|
||||
|
||||
nsMsgDeliveryListener::~nsMsgDeliveryListener()
|
||||
@ -74,3 +95,16 @@ nsMsgDeliveryListener::~nsMsgDeliveryListener()
|
||||
delete mTempFileSpec;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDeliveryListener::SetMsgComposeAndSendObject(nsMsgComposeAndSend *obj)
|
||||
{
|
||||
mMsgSendObj = obj;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgDeliveryListener::SetMsgSendLaterObject(nsMsgSendLater *obj)
|
||||
{
|
||||
mMsgSendLaterObj = obj;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include "nsIUrlListener.h"
|
||||
#include "nsFileSpec.h"
|
||||
#include "nsMsgSend.h"
|
||||
#include "nsMsgSendLater.h"
|
||||
|
||||
// For various delivery types
|
||||
enum nsMsgDeliveryType
|
||||
@ -52,12 +54,16 @@ public:
|
||||
// nsIUrlListener support
|
||||
NS_IMETHOD OnStartRunningUrl(nsIURI * aUrl);
|
||||
NS_IMETHOD OnStopRunningUrl(nsIURI * aUrl, nsresult aExitCode);
|
||||
NS_IMETHOD SetMsgComposeAndSendObject(nsMsgComposeAndSend *obj);
|
||||
NS_IMETHOD SetMsgSendLaterObject(nsMsgSendLater *obj);
|
||||
|
||||
private:
|
||||
// Private Information
|
||||
void *mTagData;
|
||||
nsFileSpec *mTempFileSpec;
|
||||
nsMsgDeliveryType mDeliveryType;
|
||||
nsMsgComposeAndSend *mMsgSendObj;
|
||||
nsMsgSendLater *mMsgSendLaterObj;
|
||||
nsMsgDeliveryCompletionCallback mCompletionCallback;
|
||||
};
|
||||
|
||||
|
@ -175,24 +175,6 @@ NS_IMPL_ISUPPORTS(FileInputStreamImpl, nsIInputStream::GetIID());
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Utility to create a nsIURI object...
|
||||
nsresult
|
||||
NewURL(nsIURI** aInstancePtrResult, const nsString& aSpec)
|
||||
{
|
||||
if (nsnull == aInstancePtrResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsINetService *inet = nsnull;
|
||||
nsresult rv = nsServiceManager::GetService(kNetServiceCID, nsINetService::GetIID(),
|
||||
(nsISupports **)&inet);
|
||||
if (rv != NS_OK)
|
||||
return rv;
|
||||
|
||||
rv = inet->CreateURL(aInstancePtrResult, aSpec, nsnull, nsnull, nsnull);
|
||||
nsServiceManager::ReleaseService(kNetServiceCID, inet);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
SaveQuoteMessageCompleteCallback(nsIURI *aURL, nsresult aExitCode, void *tagData)
|
||||
{
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -130,6 +130,7 @@
|
||||
#include "nsMsgAttachmentHandler.h"
|
||||
#include "nsMsgCompFields.h"
|
||||
#include "nsMsgComposeBE.h"
|
||||
#include "nsIMsgSendListener.h"
|
||||
|
||||
#include "net.h" /* should be defined into msgCore.h? */
|
||||
// RICHIE #include "intl_csi.h"
|
||||
@ -261,8 +262,6 @@ public:
|
||||
// The multipart/related save object for HTML text.
|
||||
nsMsgSendPart *m_related_part;
|
||||
|
||||
// File where we stored our HTML so that we could make the plaintext form.
|
||||
char* m_html_filename;
|
||||
|
||||
/* Subsequent attachments, if any.
|
||||
*/
|
||||
@ -271,10 +270,15 @@ public:
|
||||
nsMsgAttachmentHandler *m_attachments;
|
||||
PRInt32 m_status; /* in case some attachments fail but not all */
|
||||
|
||||
/* The exit method used when downloading attachments only. */
|
||||
//
|
||||
// The exit method used when downloading attachments only.
|
||||
// This still may be useful because of the fact that it is an
|
||||
// internal callback only. This way, no thread boundry issues and
|
||||
// we can get away without all of the listener array code.
|
||||
//
|
||||
void (*m_attachments_done_callback) (
|
||||
void * fe_data, int status,
|
||||
const char * error_msg,
|
||||
nsresult status,
|
||||
const char *error_msg,
|
||||
struct nsMsgAttachedFile *attachments);
|
||||
|
||||
|
||||
@ -326,8 +330,7 @@ public:
|
||||
PRUint32 attachment1_body_length,
|
||||
const struct nsMsgAttachmentData *attachments,
|
||||
const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
nsMsgSendPart *relatedPart,
|
||||
void *fe_data);
|
||||
nsMsgSendPart *relatedPart);
|
||||
|
||||
//
|
||||
// Setup the composition fields
|
||||
@ -362,8 +365,9 @@ public:
|
||||
const struct nsMsgAttachmentData *attachments,
|
||||
const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
void *relatedPart,
|
||||
nsMsgSendCompletionCallback completionCallback,
|
||||
void *tagData);
|
||||
// This is an array of nsIMsgSendListener objects...there must
|
||||
// be N+1 entries in the array with the final entry set to nsnull
|
||||
nsIMsgSendListener **aListenerArray);
|
||||
|
||||
NS_IMETHOD SendMessageFile(
|
||||
nsIMsgCompFields *fields,
|
||||
@ -371,9 +375,24 @@ public:
|
||||
PRBool deleteSendFileOnCompletion,
|
||||
PRBool digest_p,
|
||||
nsMsgDeliverMode mode,
|
||||
nsMsgSendCompletionCallback completionCallback,
|
||||
void *tagData);
|
||||
nsIMsgSendListener **aListenerArray);
|
||||
|
||||
NS_IMETHOD SendWebPage(
|
||||
nsIMsgCompFields *fields,
|
||||
nsIURI *url,
|
||||
nsMsgDeliverMode mode,
|
||||
nsIMsgSendListener **aListenerArray);
|
||||
|
||||
// methods for listener array processing...
|
||||
NS_IMETHOD SetListenerArray(nsIMsgSendListener **aListener);
|
||||
NS_IMETHOD AddListener(nsIMsgSendListener *aListener);
|
||||
NS_IMETHOD RemoveListener(nsIMsgSendListener *aListener);
|
||||
NS_IMETHOD DeleteListeners();
|
||||
NS_IMETHOD NotifyListenersOnStartSending(const char *aMsgID, PRUint32 aMsgSize);
|
||||
NS_IMETHOD NotifyListenersOnProgress(const char *aMsgID, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
NS_IMETHOD NotifyListenersOnStatus(const char *aMsgID, const PRUnichar *aMsg);
|
||||
NS_IMETHOD NotifyListenersOnStopSending(const char *aMsgID, nsresult aStatus, const PRUnichar *aMsg,
|
||||
nsIFileSpec *returnFileSpec);
|
||||
//
|
||||
// All vars necessary for this implementation
|
||||
//
|
||||
@ -388,9 +407,14 @@ public:
|
||||
// nsMsgSaveAsTemplate
|
||||
|
||||
// These are needed for callbacks to the FE...
|
||||
nsMsgSendCompletionCallback mSendCompleteCallback; // Used for completion of actual send operations
|
||||
void *m_fe_data; // passed in and passed to callback
|
||||
nsFileSpec *mReturnFileSpec; // a holder for file spec's to be returned to caller
|
||||
nsIMsgSendListener **mListenerArray;
|
||||
PRInt32 mListenerArrayCount;
|
||||
|
||||
nsIFileSpec *mReturnFileSpec; // a holder for file spec's to be returned to caller
|
||||
|
||||
// File where we stored our HTML so that we could make the plaintext form.
|
||||
nsFileSpec *mHTMLFileSpec;
|
||||
|
||||
};
|
||||
|
||||
//
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,6 +25,42 @@
|
||||
#include "nsIMsgFolder.h"
|
||||
#include "nsIMessage.h"
|
||||
#include "nsIFileSpec.h"
|
||||
#include "nsFileStream.h"
|
||||
#include "nsIMsgSendListener.h"
|
||||
#include "nsIMsgSendLaterListener.h"
|
||||
#include "nsIMsgSendLater.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// This is the listener class for the send operation. We have to create this class
|
||||
// to listen for message send completion and eventually notify the caller
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
class nsMsgSendLater;
|
||||
class SendOperationListener : public nsIMsgSendListener
|
||||
{
|
||||
public:
|
||||
SendOperationListener(void);
|
||||
virtual ~SendOperationListener(void);
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* void OnStartSending (in string aMsgID, in PRUint32 aMsgSize); */
|
||||
NS_IMETHOD OnStartSending(const char *aMsgID, PRUint32 aMsgSize);
|
||||
|
||||
/* void OnProgress (in string aMsgID, in PRUint32 aProgress, in PRUint32 aProgressMax); */
|
||||
NS_IMETHOD OnProgress(const char *aMsgID, PRUint32 aProgress, PRUint32 aProgressMax);
|
||||
|
||||
/* void OnStatus (in string aMsgID, in wstring aMsg); */
|
||||
NS_IMETHOD OnStatus(const char *aMsgID, const PRUnichar *aMsg);
|
||||
|
||||
/* void OnStopSending (in string aMsgID, in nsresult aStatus, in wstring aMsg, in nsIFileSpec returnFileSpec); */
|
||||
NS_IMETHOD OnStopSending(const char *aMsgID, nsresult aStatus, const PRUnichar *aMsg,
|
||||
nsIFileSpec *returnFileSpec);
|
||||
|
||||
NS_IMETHOD SetSendLaterObject(nsMsgSendLater *obj);
|
||||
private:
|
||||
nsMsgSendLater *mSendLater;
|
||||
};
|
||||
|
||||
class nsMsgSendLater: public nsIMsgSendLater
|
||||
{
|
||||
@ -34,9 +70,16 @@ public:
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
// nsIMsgSendLater support
|
||||
// nsIBaseStream interface
|
||||
NS_IMETHOD Close(void);
|
||||
|
||||
// nsIOutputStream interface
|
||||
NS_IMETHOD Write(const char* aBuf, PRUint32 aCount, PRUint32 *aWriteCount);
|
||||
NS_IMETHOD Flush(void);
|
||||
|
||||
// nsIMsgSendLater support
|
||||
NS_IMETHOD SendUnsentMessages(nsIMsgIdentity *identity,
|
||||
nsMsgSendUnsentMessagesCallback msgCallback,
|
||||
nsIMsgSendLaterListener **listenerArray, // SHERRY nsMsgSendUnsentMessagesCallback msgCallback,
|
||||
void *tagData);
|
||||
|
||||
// Methods needed for implementing interface...
|
||||
@ -46,21 +89,78 @@ public:
|
||||
|
||||
nsresult DeleteCurrentMessage();
|
||||
|
||||
// Necessary for creating a valid list of recipients
|
||||
nsresult BuildHeaders();
|
||||
nsresult DeliverQueuedLine(char *line, PRInt32 length);
|
||||
nsresult RebufferLeftovers(char *startBuf, PRUint32 aLen);
|
||||
nsresult BuildNewBuffer(const char* aBuf, PRUint32 aCount, PRUint32 *totalBufSize);
|
||||
|
||||
// RICHIE
|
||||
// This will go away when we get a stream from netlib...
|
||||
//
|
||||
nsresult DriveFakeStream(nsIOutputStream *stream);
|
||||
|
||||
// counters
|
||||
PRUint32 mTotalSentSuccessfully;
|
||||
PRUint32 mTotalSendCount;
|
||||
|
||||
// methods for listener array processing...
|
||||
NS_IMETHOD SetListenerArray(nsIMsgSendLaterListener **aListener);
|
||||
NS_IMETHOD AddListener(nsIMsgSendLaterListener *aListener);
|
||||
NS_IMETHOD RemoveListener(nsIMsgSendLaterListener *aListener);
|
||||
NS_IMETHOD DeleteListeners();
|
||||
NS_IMETHOD NotifyListenersOnStartSending(PRUint32 aTotalMessageCount);
|
||||
NS_IMETHOD NotifyListenersOnProgress(PRUint32 aCurrentMessage, PRUint32 aTotalMessage);
|
||||
NS_IMETHOD NotifyListenersOnStatus(const PRUnichar *aMsg);
|
||||
NS_IMETHOD NotifyListenersOnStopSending(nsresult aStatus, const PRUnichar *aMsg,
|
||||
PRUint32 aTotalTried, PRUint32 aSuccessful);
|
||||
|
||||
// Private Information
|
||||
private:
|
||||
nsIMsgSendLaterListener **mListenerArray;
|
||||
PRInt32 mListenerArrayCount;
|
||||
|
||||
nsMsgSendUnsentMessagesCallback mCompleteCallback;
|
||||
SendOperationListener *mSendListener;
|
||||
|
||||
nsIMsgIdentity *mIdentity;
|
||||
nsCOMPtr<nsIMsgFolder> mMessageFolder;
|
||||
nsCOMPtr<nsIMessage> mMessage;
|
||||
|
||||
// RICHIE
|
||||
// Theses are here for the hack temp file we need
|
||||
// to do...this will go away!!!
|
||||
nsFileSpec *mHackTempFileSpec;
|
||||
nsIFileSpec *mHackTempIFileSpec;
|
||||
|
||||
//
|
||||
// File output stuff...
|
||||
//
|
||||
nsFileSpec *mTempFileSpec;
|
||||
nsIFileSpec *mTempIFileSpec;
|
||||
nsOutputFileStream *mOutFile;
|
||||
|
||||
nsIEnumerator *mEnumerator;
|
||||
PRBool mFirstTime;
|
||||
nsMsgSendUnsentMessagesCallback mCompleteCallback;
|
||||
|
||||
void *mTagData;
|
||||
|
||||
// For building headers and stream parsing...
|
||||
char *m_to;
|
||||
char *m_bcc;
|
||||
char *m_fcc;
|
||||
char *m_newsgroups;
|
||||
char *m_newshost;
|
||||
char *m_headers;
|
||||
PRInt32 m_flags;
|
||||
PRInt32 m_headersFP;
|
||||
PRBool m_inhead;
|
||||
PRInt32 m_headersPosition;
|
||||
PRInt32 m_bytesRead;
|
||||
PRInt32 m_position;
|
||||
PRInt32 m_flagsPosition;
|
||||
PRInt32 m_headersSize;
|
||||
char *mLeftoverBuffer;
|
||||
};
|
||||
|
||||
|
||||
|
@ -60,7 +60,7 @@ nsMsgSendPart::nsMsgSendPart(nsMsgComposeAndSend* state, const char *part_charse
|
||||
SetMimeDeliveryState(state);
|
||||
|
||||
m_parent = NULL;
|
||||
m_filename = NULL;
|
||||
m_filespec = NULL;
|
||||
m_filetype = (XP_FileType)0;
|
||||
m_buffer = NULL;
|
||||
m_type = NULL;
|
||||
@ -89,7 +89,8 @@ nsMsgSendPart::~nsMsgSendPart()
|
||||
delete [] m_children;
|
||||
PR_FREEIF(m_buffer);
|
||||
PR_FREEIF(m_other);
|
||||
PR_FREEIF(m_filename);
|
||||
if (m_filespec)
|
||||
delete m_filespec;
|
||||
PR_FREEIF(m_type);
|
||||
}
|
||||
|
||||
@ -107,14 +108,12 @@ int nsMsgSendPart::CopyString(char** dest, const char* src)
|
||||
}
|
||||
|
||||
|
||||
int nsMsgSendPart::SetFile(const char* filename, XP_FileType type)
|
||||
int nsMsgSendPart::SetFile(nsFileSpec *filename)
|
||||
{
|
||||
NS_ASSERTION(m_filename == NULL, "not-null m_filename");
|
||||
int status = CopyString(&m_filename, filename);
|
||||
if (status < 0)
|
||||
return status;
|
||||
m_filetype = type;
|
||||
return status;
|
||||
m_filespec = new nsFileSpec(*filename);
|
||||
if (!m_filespec)
|
||||
return NS_ERROR_FAILURE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -515,42 +514,41 @@ int nsMsgSendPart::Write()
|
||||
#define PUSH(str) PUSHLEN(str, PL_strlen(str))
|
||||
|
||||
if (m_mainpart && m_type && PL_strcmp(m_type, TEXT_HTML) == 0) {
|
||||
if (m_filename) {
|
||||
if (m_filespec)
|
||||
{
|
||||
// The "insert HTML links" code requires a memory buffer,
|
||||
// so read the file into memory.
|
||||
NS_ASSERTION(m_buffer == NULL, "not-null buffer");
|
||||
PRInt32 length = 0;
|
||||
nsFileSpec mySpec(m_filename);
|
||||
|
||||
if (mySpec.Valid())
|
||||
length = mySpec.GetFileSize();
|
||||
|
||||
|
||||
if (m_filespec->Valid())
|
||||
length = m_filespec->GetFileSize();
|
||||
|
||||
m_buffer = (char *) PR_Malloc(sizeof(char) * (length + 1));
|
||||
if (m_buffer)
|
||||
{
|
||||
nsInputFileStream file(mySpec);
|
||||
{
|
||||
nsInputFileStream file(*m_filespec);
|
||||
if (file.is_open())
|
||||
{
|
||||
length = file.read(m_buffer, length);
|
||||
file.close();
|
||||
m_buffer[length] = '\0';
|
||||
PR_FREEIF(m_filename);
|
||||
{
|
||||
length = file.read(m_buffer, length);
|
||||
file.close();
|
||||
m_buffer[length] = '\0';
|
||||
}
|
||||
else
|
||||
PR_Free(m_buffer);
|
||||
PR_Free(m_buffer);
|
||||
}
|
||||
}
|
||||
if (m_buffer)
|
||||
{
|
||||
nsCOMPtr<nsIMimeURLUtils> myURLUtil;
|
||||
char *tmp = NULL;
|
||||
|
||||
|
||||
int res = nsComponentManager::CreateInstance(kCMimeURLUtilsCID,
|
||||
NULL, nsIMimeURLUtils::GetIID(),
|
||||
(void **) getter_AddRefs(myURLUtil));
|
||||
NULL, nsIMimeURLUtils::GetIID(),
|
||||
(void **) getter_AddRefs(myURLUtil));
|
||||
if (!NS_SUCCEEDED(res))
|
||||
goto FAIL;
|
||||
|
||||
|
||||
myURLUtil->ScanHTMLForURLs(m_buffer, &tmp);
|
||||
if (tmp) {
|
||||
SetBuffer(tmp);
|
||||
@ -679,15 +677,14 @@ int nsMsgSendPart::Write()
|
||||
m_intlDocToMailConverter = NULL;
|
||||
|
||||
|
||||
if (m_buffer) {
|
||||
NS_ASSERTION(!m_filename, "not-null m_filename");
|
||||
if (m_buffer)
|
||||
{
|
||||
status = PushBody(m_buffer, PL_strlen(m_buffer));
|
||||
if (status < 0)
|
||||
goto FAIL;
|
||||
}
|
||||
else if (m_filename) {
|
||||
nsFileSpec mySpec(m_filename);
|
||||
nsIOFileStream myStream(mySpec);
|
||||
else if (m_filespec) {
|
||||
nsIOFileStream myStream(*m_filespec);
|
||||
|
||||
if (!myStream.is_open())
|
||||
{
|
||||
|
@ -40,8 +40,8 @@ public:
|
||||
|
||||
virtual int Write();
|
||||
|
||||
virtual int SetFile(const char* filename, XP_FileType filetype);
|
||||
const char* GetFilename() {return m_filename;}
|
||||
virtual int SetFile(nsFileSpec *filename);
|
||||
const nsFileSpec * GetFileSpec() {return m_filespec;}
|
||||
XP_FileType GetFiletype() {return m_filetype;}
|
||||
|
||||
virtual int SetBuffer(const char* buffer);
|
||||
@ -87,7 +87,7 @@ protected:
|
||||
|
||||
nsMsgComposeAndSend* m_state;
|
||||
nsMsgSendPart* m_parent;
|
||||
char* m_filename;
|
||||
nsFileSpec *m_filespec;
|
||||
XP_FileType m_filetype;
|
||||
char* m_buffer;
|
||||
char* m_type;
|
||||
|
@ -19,7 +19,6 @@
|
||||
#ifndef _MsgCompose_H_
|
||||
#define _MsgCompose_H_
|
||||
|
||||
|
||||
#include "msgCore.h"
|
||||
#include "prprf.h" /* should be defined into msgCore.h? */
|
||||
#include "net.h" /* should be defined into msgCore.h? */
|
||||
@ -28,22 +27,12 @@
|
||||
#include "msgcom.h"
|
||||
|
||||
#include "MsgCompGlue.h"
|
||||
|
||||
//#include "nsMsgPtrArray.h"
|
||||
#include "nsMsgHeaderMasks.h"
|
||||
#include "nsMsgFolderFlags.h"
|
||||
|
||||
#include "nsMsgCompFields.h"
|
||||
#include "nsIMsgCompose.h"
|
||||
#include "nsMsgSend.h"
|
||||
|
||||
/*JFD
|
||||
#include "msg.h"
|
||||
#include "msgpane.h"
|
||||
#include "xlate.h"
|
||||
*/
|
||||
|
||||
|
||||
/* The MSG_REPLY_TYPE shares the same space as MSG_CommandType, to avoid
|
||||
possible weird errors, but is restricted to the `composition' commands
|
||||
(MSG_ReplyToSender through MSG_ForwardMessage.)
|
||||
@ -59,262 +48,5 @@ HJ08142
|
||||
class MSG_NewsHost;
|
||||
class MSG_HTMLRecipients;
|
||||
|
||||
#if 0
|
||||
class nsMsgCompose : public nsIMsgCompose, public MSG_Pane {
|
||||
public:
|
||||
|
||||
nsMsgCompose();
|
||||
virtual ~nsMsgCompose();
|
||||
|
||||
/* this macro defines QueryInterface, AddRef and Release for this class */
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CreateAndInitialize(/*MWContext* */PRInt32 a_context, /* MWContext* */PRInt32 old_context,
|
||||
/* MSG_Prefs* */PRInt32 prefs, nsIMsgCompFields* initfields,
|
||||
/* MSG_Master* */PRInt32 master);
|
||||
|
||||
// Or, if you prefer, construct using below constructor and be sure to
|
||||
// soon call the Initialize() method:
|
||||
|
||||
NS_IMETHOD Create(/* MWContext* */PRInt32 a_context, /* MSG_Prefs* */PRInt32 prefs,
|
||||
/* MSG_Master* */PRInt32 master);
|
||||
NS_IMETHOD Initialize(/* MWContext* */PRInt32 old_context, nsIMsgCompFields* initfields);
|
||||
|
||||
NS_IMETHOD Dispose();
|
||||
|
||||
virtual MSG_PaneType GetPaneType();
|
||||
|
||||
virtual void NotifyPrefsChange(NotifyCode code);
|
||||
|
||||
MSG_CommandType PreviousSaveCommand();
|
||||
|
||||
virtual nsresult GetCommandStatus(MSG_CommandType command,
|
||||
const nsMsgViewIndex* indices,
|
||||
PRInt32 numindices,
|
||||
PRBool *selectable_p,
|
||||
MSG_COMMAND_CHECK_STATE *selected_p,
|
||||
const char **display_string,
|
||||
PRBool * plural_p);
|
||||
virtual nsresult DoCommand(MSG_CommandType command,
|
||||
nsMsgViewIndex* indices, PRInt32 numindices);
|
||||
|
||||
const char* GetDefaultURL();
|
||||
virtual void SetDefaultURL(const char *defaultUrl = NULL,
|
||||
const char *htmlPart = NULL);
|
||||
|
||||
|
||||
int SetCallbacks(MSG_CompositionPaneCallbacks* callbacks, void* closure);
|
||||
|
||||
nsIMsgCompFields* GetInitialFields();
|
||||
|
||||
|
||||
MSG_HEADER_SET GetInterestingHeaders();
|
||||
int SetAttachmentList(struct nsMsgAttachmentData*);
|
||||
PRBool NoPendingAttachments() const;
|
||||
char* GetAttachmentString();
|
||||
PRBool ShouldAutoQuote();
|
||||
const char* GetCompHeader(MSG_HEADER_SET);
|
||||
PRInt32 SetCompHeader(MSG_HEADER_SET, const char*);
|
||||
PRBool GetCompBoolHeader(MSG_BOOL_HEADER_SET);
|
||||
PRInt32 SetCompBoolHeader(MSG_BOOL_HEADER_SET, PRBool);
|
||||
const char* GetCompBody();
|
||||
int SetCompBody(const char*);
|
||||
void ToggleCompositionHeader(PRUint32 header);
|
||||
PRBool ShowingAllCompositionHeaders();
|
||||
PRBool ShowingCompositionHeader(PRUint32 mask);
|
||||
PRBool GetHTMLMarkup(void);
|
||||
void SetHTMLMarkup(PRBool flag);
|
||||
nsresult QuoteMessage(int (*func)(void* closure, const char* data),
|
||||
void* closure);
|
||||
int PastePlaintextQuotation(const char* str);
|
||||
const struct nsMsgAttachmentData *GetAttachmentList();
|
||||
int DownloadAttachments();
|
||||
char* UpdateHeaderContents(MSG_HEADER_SET which_header, const char* value);
|
||||
const char* GetWindowTitle();
|
||||
void SetBodyEdited(PRBool value);
|
||||
void MailCompositionAllConnectionsComplete();
|
||||
void CheckExpansion(MSG_HEADER_SET header);
|
||||
PRBool DeliveryInProgress();
|
||||
|
||||
int SendMessageNow();
|
||||
int QueueMessageForLater();
|
||||
int SaveMessage();
|
||||
int SaveMessageAsDraft();
|
||||
int SaveMessageAsTemplate();
|
||||
|
||||
PRBool IsDuplicatePost();
|
||||
const char* GetCompositionMessageID();
|
||||
void ClearCompositionMessageID();
|
||||
HJ13591
|
||||
HJ86782
|
||||
HJ02278
|
||||
HJ95534
|
||||
|
||||
int RemoveNoCertRecipients();
|
||||
|
||||
PRBool SanityCheckNewsgroups (const char *newsgroups);
|
||||
int SanityCheck(int skippast);
|
||||
|
||||
HJ42055
|
||||
|
||||
/* draft */
|
||||
int SetPreloadedAttachments ( MWContext *context,
|
||||
struct nsMsgAttachmentData *attachmentData,
|
||||
struct nsMsgAttachedFile *attachments,
|
||||
int attachments_count );
|
||||
|
||||
virtual void SetIMAPMessageUID (nsMsgKey key);
|
||||
|
||||
int RetrieveStandardHeaders(MSG_HeaderEntry ** return_list);
|
||||
int SetHeaderEntries(MSG_HeaderEntry * in_list,int count);
|
||||
void ClearComposeHeaders();
|
||||
|
||||
HJ37212
|
||||
HJ42256
|
||||
|
||||
int SetHTMLAction(MSG_HTMLComposeAction action) {
|
||||
m_htmlaction = action;
|
||||
return 0;
|
||||
}
|
||||
MSG_HTMLComposeAction GetHTMLAction() {return m_htmlaction;}
|
||||
|
||||
int PutUpRecipientsDialog(void *pWnd = NULL);
|
||||
|
||||
int ResultsRecipients(PRBool cancelled, PRInt32* nohtml, PRInt32* htmlok);
|
||||
|
||||
PRBool m_confirmed_uuencode_p; // Have we confirmed sending uuencoded data?
|
||||
|
||||
// For qutoing plain text to html then convert back to plain text
|
||||
void SetLineWidth(int width) { m_lineWidth = width; }
|
||||
int GetLineWidth() { return m_lineWidth; }
|
||||
// #$@%&*
|
||||
|
||||
protected:
|
||||
static void QuoteHTMLDone_S(URL_Struct* url,
|
||||
int status, MWContext* context);
|
||||
|
||||
void InitializeHeaders(MWContext* old_context, const nsIMsgCompFields* fields);
|
||||
|
||||
char* FigureBcc(PRBool newsBcc);
|
||||
const char* CheckForLosingFcc(const char* fcc);
|
||||
|
||||
static void GetUrlDone_S(PrintSetup*);
|
||||
void GetUrlDone(PrintSetup*);
|
||||
|
||||
static void DownloadAttachmentsDone_S(MWContext *context,
|
||||
void *fe_data,
|
||||
int status,
|
||||
const char *error_message,
|
||||
struct nsMsgAttachedFile *attachmnts);
|
||||
|
||||
void DownloadAttachmentsDone(MWContext* context, int status,
|
||||
const char* error_message,
|
||||
struct nsMsgAttachedFile *attachments);
|
||||
|
||||
int DoneComposeMessage(nsMsgDeliverMode deliver_mode);
|
||||
|
||||
static void DeliveryDoneCB_s(MWContext *context, void *fe_data, int status,
|
||||
const char *error_message);
|
||||
void DeliveryDoneCB(MWContext* context, int status,
|
||||
const char* error_message);
|
||||
|
||||
int RemoveNoCertRecipientsFromList(MSG_HEADER_SET header);
|
||||
|
||||
PRBool HasNoMarkup();
|
||||
MSG_HTMLComposeAction DetermineHTMLAction();
|
||||
int MungeThroughRecipients(PRBool* someNonHTML, PRBool* groupNonHTML);
|
||||
|
||||
static PRBool AskDialogDone_s(XPDialogState *state, char **argv, int argc,
|
||||
unsigned int button);
|
||||
PRBool AskDialogDone(XPDialogState *state, char **argv, int argc,
|
||||
unsigned int button);
|
||||
static PRBool RecipientDialogDone_s(XPDialogState *state, char **argv,
|
||||
int argc, unsigned int button);
|
||||
PRBool RecipientDialogDone(XPDialogState *state, char **argv, int argc,
|
||||
unsigned int button);
|
||||
|
||||
int CreateVcardAttachment ();
|
||||
|
||||
MSG_NewsHost *InferNewsHost (const char *groups);
|
||||
|
||||
MSG_REPLY_TYPE m_replyType; /* The kind of message composition in
|
||||
progress (reply, forward, etc.) */
|
||||
|
||||
PRBool m_markup; /* Whether we should generate messages
|
||||
whose first part is text/html rather
|
||||
than text/plain. */
|
||||
|
||||
nsMsgAttachmentData *m_attachData; /* null-terminated list of the URLs and
|
||||
desired types currently scheduled
|
||||
for attachment. */
|
||||
nsMsgAttachedFile *m_attachedFiles; /* The attachments which have already
|
||||
been downloaded, and some info about
|
||||
them. */
|
||||
|
||||
char *m_defaultUrl; /* Default URL for attaching, etc. */
|
||||
|
||||
nsMsgCompFields* m_initfields; // What all the fields were,
|
||||
// initially.
|
||||
nsMsgCompFields* m_fields; // Current value of all the fields.
|
||||
|
||||
char* m_messageId; // Message-Id to use for composition.
|
||||
|
||||
char* m_attachmentString; // Storage for string to display in UI for
|
||||
// the list of attachments.
|
||||
char* m_quotedText; // The results of quoting the original text.
|
||||
|
||||
/* Stuff used while quoting a message. */
|
||||
PrintSetup* m_print;
|
||||
MWContext *m_textContext;
|
||||
MWContext *m_oldContext;
|
||||
char* m_quoteUrl;
|
||||
URL_Struct *m_dummyUrl;
|
||||
Net_GetUrlExitFunc *m_exitQuoting;
|
||||
int (*m_quotefunc)(void* closure, const char* data);
|
||||
void* m_quoteclosure;
|
||||
PRBool m_deliveryInProgress; /* True while mail is being sent. */
|
||||
PRBool m_attachmentInProgress; /* True while attachments being
|
||||
saved. */
|
||||
int m_pendingAttachmentsCount;
|
||||
|
||||
nsMsgDeliverMode m_deliver_mode; /* nsMsgDelverNow, nsMsgQueueForLater,
|
||||
* nsMsgSaveAs,
|
||||
* nsMsgSaveAsDraft, nsMsgSaveAsTemplate
|
||||
*/
|
||||
|
||||
HJ21695
|
||||
|
||||
PRBool m_cited;
|
||||
|
||||
PRBool m_duplicatePost; /* Whether we seem to be trying for a
|
||||
second time to post the same message.
|
||||
(If this is true, then we know to ignore
|
||||
435 errors from the newsserver.) */
|
||||
|
||||
HJ92535
|
||||
|
||||
MSG_HTMLComposeAction m_htmlaction;
|
||||
MSG_HTMLRecipients* m_htmlrecip;
|
||||
|
||||
int m_status;
|
||||
// I'm sure this isn't what Terry had in mind... // ### dmb
|
||||
MSG_HEADER_SET m_visible_headers;
|
||||
|
||||
MSG_NewsHost* m_host; // Which newshost we're posting to. This is
|
||||
// lazily evaluated, so a NULL does necessarily
|
||||
// mean we have no news host specified.
|
||||
|
||||
PRBool m_closeAfterSave;
|
||||
|
||||
PRBool m_haveQuoted;
|
||||
PRBool m_haveAttachedVcard;
|
||||
|
||||
MSG_CompositionPaneCallbacks m_callbacks;
|
||||
void* m_callbackclosure;
|
||||
int m_lineWidth; // for quoting plain text to html then convert back
|
||||
// to plain text
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _MsgCompose_H_ */
|
||||
|
@ -1,3 +1,4 @@
|
||||
#include "nsCOMPtr.h"
|
||||
#include "msgCore.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
@ -22,7 +23,8 @@
|
||||
#include "nsINetSupportDialogService.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIWebShellWindow.h"
|
||||
#include "nsIAllocator.h"
|
||||
#include "nsIGenericFactory.h"
|
||||
|
||||
#include "nsINetService.h"
|
||||
#include "nsIComponentManager.h"
|
||||
@ -40,6 +42,7 @@
|
||||
#include "prmem.h"
|
||||
|
||||
#include "nsIMimeURLUtils.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
|
||||
#ifdef XP_PC
|
||||
#define NETLIB_DLL "netlib.dll"
|
||||
@ -47,6 +50,7 @@
|
||||
#define PREF_DLL "xppref32.dll"
|
||||
#define APPSHELL_DLL "nsappshell.dll"
|
||||
#define MIME_DLL "mime.dll"
|
||||
#define UNICHAR_DLL "uconv.dll"
|
||||
#else
|
||||
#ifdef XP_MAC
|
||||
#include "nsMacRepository.h"
|
||||
@ -60,6 +64,9 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// {588595CB-2012-11d3-8EF0-00A024A7D144}
|
||||
#define CONV_CID { 0x1e3f79f1, 0x6b6b, 0x11d2, { 0x8a, 0x86, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36 } };
|
||||
#define CONV_IID { 0x1e3f79f0, 0x6b6b, 0x11d2, { 0x8a, 0x86, 0x0, 0x60, 0x8, 0x11, 0xa8, 0x36 } }
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Define keys for all of the interfaces we are going to require for this test
|
||||
@ -82,6 +89,13 @@ static NS_DEFINE_CID(kMimeURLUtilsCID, NS_IMIME_URLUTILS_CID);
|
||||
static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
static NS_DEFINE_IID(kIAppShellServiceIID, NS_IAPPSHELL_SERVICE_IID);
|
||||
static NS_DEFINE_CID(kGenericFactoryCID, NS_GENERICFACTORY_CID);
|
||||
|
||||
// I18N
|
||||
static NS_DEFINE_CID(charsetCID, CONV_CID);
|
||||
NS_DEFINE_IID(kConvMeIID, CONV_IID);
|
||||
|
||||
nsICharsetConverterManager *ccMan = nsnull;
|
||||
|
||||
nsresult OnIdentityCheck()
|
||||
{
|
||||
@ -116,28 +130,89 @@ nsresult OnIdentityCheck()
|
||||
return result;
|
||||
}
|
||||
|
||||
// Utility to create a nsIURL object...
|
||||
nsresult
|
||||
nsMsgNewURL(nsIURI** aInstancePtrResult, const nsString& aSpec)
|
||||
{
|
||||
if (nsnull == aInstancePtrResult)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
nsINetService *inet = nsnull;
|
||||
nsresult rv = nsServiceManager::GetService(kNetServiceCID, nsINetService::GetIID(),
|
||||
(nsISupports **)&inet);
|
||||
if (rv != NS_OK)
|
||||
return rv;
|
||||
|
||||
rv = inet->CreateURL(aInstancePtrResult, aSpec, nsnull, nsnull, nsnull);
|
||||
nsServiceManager::ReleaseService(kNetServiceCID, inet);
|
||||
return rv;
|
||||
}
|
||||
|
||||
//nsMsgAttachmentData *
|
||||
nsMsgAttachedFile *
|
||||
GetAttachments(void)
|
||||
{
|
||||
int attachCount = 3;
|
||||
int attachCount = 2;
|
||||
nsIURI *url;
|
||||
nsMsgAttachedFile *attachments = (nsMsgAttachedFile *) PR_Malloc(sizeof(nsMsgAttachedFile) * attachCount);
|
||||
|
||||
if (!attachments)
|
||||
return NULL;
|
||||
|
||||
nsCRT::memset(attachments, 0, sizeof(MSG_AttachedFile) * attachCount);
|
||||
attachments[0].orig_url = PL_strdup("file://C:/boxster.jpg");
|
||||
attachments[0].file_name = PL_strdup("C:\\boxster.jpg");
|
||||
nsMsgNewURL(&url, nsString("file://C:/boxster.jpg"));
|
||||
|
||||
nsCRT::memset(attachments, 0, sizeof(nsMsgAttachedFile) * attachCount);
|
||||
attachments[0].orig_url = url;
|
||||
attachments[0].file_spec = new nsFileSpec("C:\\boxster.jpg");
|
||||
attachments[0].type = PL_strdup("image/jpeg");
|
||||
attachments[0].encoding = PL_strdup(ENCODING_BINARY);
|
||||
attachments[0].description = PL_strdup("Boxster Image");
|
||||
return attachments;
|
||||
}
|
||||
|
||||
nsMsgAttachmentData *
|
||||
GetRemoteAttachments()
|
||||
{
|
||||
int attachCount = 4;
|
||||
nsMsgAttachmentData *attachments = (nsMsgAttachmentData *) PR_Malloc(sizeof(nsMsgAttachmentData) * attachCount);
|
||||
nsIURI *url;
|
||||
|
||||
if (!attachments)
|
||||
return NULL;
|
||||
|
||||
nsCRT::memset(attachments, 0, sizeof(nsMsgAttachmentData) * attachCount);
|
||||
|
||||
nsMsgNewURL(&url, nsString("http://www.netscape.com"));
|
||||
NS_ADDREF(url);
|
||||
attachments[0].url = url; // The URL to attach. This should be 0 to signify "end of list".
|
||||
|
||||
attachments[0].desired_type; // The type to which this document should be
|
||||
// converted. Legal values are NULL, TEXT_PLAIN
|
||||
// and APPLICATION_POSTSCRIPT (which are macros
|
||||
// defined in net.h); other values are ignored.
|
||||
|
||||
attachments[0].real_type; // The type of the URL if known, otherwise NULL. For example, if
|
||||
// you were attaching a temp file which was known to contain HTML data,
|
||||
// you would pass in TEXT_HTML as the real_type, to override whatever type
|
||||
// the name of the tmp file might otherwise indicate.
|
||||
|
||||
attachments[0].real_encoding; // Goes along with real_type
|
||||
|
||||
attachments[0].real_name; // The original name of this document, which will eventually show up in the
|
||||
// Content-Disposition header. For example, if you had copied a document to a
|
||||
// tmp file, this would be the original, human-readable name of the document.
|
||||
|
||||
attachments[0].description; // If you put a string here, it will show up as the Content-Description header.
|
||||
// This can be any explanatory text; it's not a file name.
|
||||
|
||||
nsMsgNewURL(&url, nsString("http://www.pennatech.com"));
|
||||
NS_ADDREF(url);
|
||||
attachments[1].url = url; // The URL to attach. This should be 0 to signify "end of list".
|
||||
|
||||
nsMsgNewURL(&url, nsString("file:///C|/boxster.jpg"));
|
||||
NS_ADDREF(url);
|
||||
attachments[2].url = url; // The URL to attach. This should be 0 to signify "end of list".
|
||||
|
||||
attachments[1].orig_url = PL_strdup("file://C:/boxster.jpg");
|
||||
attachments[1].file_name = PL_strdup("C:\\boxster.jpg");
|
||||
attachments[1].type = PL_strdup("image/jpeg");
|
||||
attachments[1].encoding = PL_strdup(ENCODING_BINARY);
|
||||
attachments[1].description = PL_strdup("Boxster Image");
|
||||
return attachments;
|
||||
}
|
||||
|
||||
@ -173,27 +248,89 @@ CallMe(nsresult aExitCode, void *tagData, nsFileSpec *fs)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
SetupRegistry(void)
|
||||
{
|
||||
// i18n
|
||||
nsComponentManager::RegisterComponent(charsetCID, NULL, NULL, UNICHAR_DLL, PR_FALSE, PR_FALSE);
|
||||
nsresult res = nsServiceManager::GetService(charsetCID, kConvMeIID, (nsISupports **)&ccMan);
|
||||
if (NS_FAILED(res))
|
||||
{
|
||||
printf("ERROR at GetService() code=0x%x.\n",res);
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// netlib
|
||||
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
// xpcom
|
||||
static NS_DEFINE_CID(kAllocatorCID, NS_ALLOCATOR_CID);
|
||||
static NS_DEFINE_CID(kEventQueueCID, NS_EVENTQUEUE_CID);
|
||||
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kGenericFactoryCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kAllocatorCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
// prefs
|
||||
nsComponentManager::RegisterComponent(kPrefCID, NULL, NULL, PREF_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIMsgIdentity *
|
||||
GetHackIdentity()
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
printf("Failure on Mail Session Init!\n");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMsgIdentity> identity = nsnull;
|
||||
nsCOMPtr<nsIMsgAccountManager> accountManager;
|
||||
|
||||
rv = mailSession->GetAccountManager(getter_AddRefs(accountManager));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
printf("Failure getting account Manager!\n");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
rv = mailSession->GetCurrentIdentity(getter_AddRefs(identity));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
printf("Failure getting Identity!\n");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
return identity;
|
||||
}
|
||||
|
||||
/*
|
||||
* This is a test stub for mail composition. This will be enhanced as the
|
||||
* development continues for message send functions.
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
nsIMsgCompose *pMsgCompose;
|
||||
nsIMsgCompFields *pMsgCompFields;
|
||||
nsIMsgSend *pMsgSend;
|
||||
nsresult rv = NS_OK;
|
||||
nsIAppShellService* appShell = nsnull;
|
||||
|
||||
|
||||
nsComponentManager::RegisterComponent(kNetServiceCID, NULL, NULL, NETLIB_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kEventQueueCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kPrefCID, nsnull, nsnull, PREF_DLL, PR_TRUE, PR_TRUE);
|
||||
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kFileLocatorCID, NULL, NS_FILELOCATOR_PROGID, APPSHELL_DLL, PR_TRUE, PR_TRUE);
|
||||
nsComponentManager::RegisterComponent(kMimeURLUtilsCID, NULL, NULL, MIME_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kNetSupportDialogCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kAppShellServiceCID, NULL, NULL, APPSHELL_DLL, PR_FALSE, PR_FALSE);
|
||||
|
||||
SetupRegistry();
|
||||
/*
|
||||
* Create the Application Shell instance...
|
||||
*/
|
||||
@ -221,16 +358,25 @@ int main(int argc, char *argv[])
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// make sure prefs get initialized and loaded..
|
||||
// mscott - this is just a bad bad bad hack right now until prefs
|
||||
// has the ability to take nsnull as a parameter. Once that happens,
|
||||
// prefs will do the work of figuring out which prefs file to load...
|
||||
NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &rv);
|
||||
if (NS_FAILED(rv) || (prefs == nsnull)) {
|
||||
exit(rv);
|
||||
}
|
||||
if (NS_FAILED(rv) || (prefs == nsnull)) {
|
||||
exit(rv);
|
||||
}
|
||||
|
||||
if (NS_FAILED(prefs->StartUp()))
|
||||
{
|
||||
printf("Failed to start up prefs!\n");
|
||||
exit(rv);
|
||||
}
|
||||
if (NS_FAILED(prefs->ReadUserPrefs()))
|
||||
{
|
||||
printf("Failed on reading user prefs!\n");
|
||||
exit(rv);
|
||||
}
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kCMsgMailSessionCID, &rv);
|
||||
if (NS_FAILED(rv))
|
||||
@ -239,6 +385,7 @@ int main(int argc, char *argv[])
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsIMsgIdentity *identity = GetHackIdentity();
|
||||
OnIdentityCheck();
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kMsgCompFieldsCID, NULL,
|
||||
@ -249,15 +396,6 @@ int main(int argc, char *argv[])
|
||||
pMsgCompFields->Release();
|
||||
}
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kMsgComposeCID, NULL,
|
||||
nsIMsgCompose::GetIID(), (void **) &pMsgCompose);
|
||||
if (rv == NS_OK && pMsgCompose)
|
||||
{
|
||||
printf("We succesfully obtained a nsIMsgCompose interface....\n");
|
||||
printf("Releasing the interface now...\n");
|
||||
pMsgCompose->Release();
|
||||
}
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kMsgSendCID, NULL, kIMsgSendIID, (void **) &pMsgSend);
|
||||
if (rv == NS_OK && pMsgSend)
|
||||
{
|
||||
@ -266,12 +404,13 @@ int main(int argc, char *argv[])
|
||||
(void **) &pMsgCompFields);
|
||||
if (rv == NS_OK && pMsgCompFields)
|
||||
{
|
||||
PRInt32 rv;
|
||||
pMsgCompFields->SetFrom(", rhp@netscape.com, ", NULL);
|
||||
pMsgCompFields->SetTo("rhp@netscape.com", NULL);
|
||||
pMsgCompFields->SetSubject("[spam] test", NULL);
|
||||
//pMsgCompFields->SetBody("Sample message sent with Mozilla\n\nPlease do not reply, thanks\n\nRich Pizzarro\n", NULL);
|
||||
// pMsgCompFields->SetTheForcePlainText(PR_TRUE, &rv);
|
||||
pMsgCompFields->SetBody(email, NULL);
|
||||
// pMsgCompFields->SetAttachments("c:\\boxster.jpg", NULL);
|
||||
pMsgCompFields->SetCharacterSet("us-ascii", NULL);
|
||||
|
||||
PRInt32 nBodyLength;
|
||||
char *pBody;
|
||||
@ -283,7 +422,11 @@ int main(int argc, char *argv[])
|
||||
nBodyLength = 0;
|
||||
|
||||
nsMsgAttachedFile *ptr = NULL;
|
||||
//nsMsgAttachedFile *ptr = GetAttachments();
|
||||
nsMsgAttachmentData *newPtr = NULL;
|
||||
|
||||
|
||||
newPtr = GetRemoteAttachments();
|
||||
//ptr = GetAttachments();
|
||||
|
||||
char *tagBuf = (char *)PR_Malloc(256);
|
||||
if (tagBuf)
|
||||
@ -296,11 +439,10 @@ int main(int argc, char *argv[])
|
||||
TEXT_HTML, //TEXT_PLAIN, // const char *attachment1_type,
|
||||
pBody, // const char *attachment1_body,
|
||||
nBodyLength, // PRUint32 attachment1_body_length,
|
||||
NULL, // const struct nsMsgAttachmentData *attachments,
|
||||
newPtr, // const struct nsMsgAttachmentData *attachments,
|
||||
ptr, // const struct nsMsgAttachedFile *preloaded_attachments,
|
||||
NULL, // nsMsgSendPart *relatedPart,
|
||||
CallMe,
|
||||
tagBuf);
|
||||
nsnull); // listener array
|
||||
|
||||
PR_FREEIF(ptr);
|
||||
}
|
||||
|
@ -17,6 +17,6 @@
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=compose smtp
|
||||
DIRS=compose smtp sendpage
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
@ -447,6 +447,12 @@ int main()
|
||||
if (NS_FAILED(result) || (prefs == nsnull)) {
|
||||
exit(result);
|
||||
}
|
||||
|
||||
if (NS_FAILED(prefs->ReadUserPrefs()))
|
||||
{
|
||||
printf("Failed on reading user prefs!\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
// Create the Event Queue for this thread...
|
||||
NS_WITH_SERVICE(nsIEventQueueService, pEventQService, kEventQueueServiceCID, &result);
|
||||
|
Loading…
Reference in New Issue
Block a user