Part of the intregration of preferences into compose
git-svn-id: svn://10.0.0.236/trunk@23812 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -9,9 +9,6 @@ class MSG_Pane;
|
||||
|
||||
void FE_DestroyMailCompositionContext(MWContext*) {return;}
|
||||
const char * FE_UsersSignature() {return NULL;}
|
||||
const char * FE_UsersOrganization() {return NULL;}
|
||||
const char * FE_UsersFullName() {return NULL;}
|
||||
const char * FE_UsersMailAddress() {return PL_strdup("qatest02@netscape.com");}
|
||||
void FE_UpdateCompToolbar(MSG_Pane*) {return;}
|
||||
void FE_SetWindowLoading(MWContext *, URL_Struct *,Net_GetUrlExitFunc **) {return;}
|
||||
|
||||
@@ -77,7 +74,6 @@ int strncasecomp (const char *, const char *, int ) {return NULL;}
|
||||
char * strcasestr (const char * str, const char * substr) {return NULL;}
|
||||
|
||||
XP_FILE_NATIVE_PATH WH_FileName (const char *, XP_FileType ) {return NULL;}
|
||||
char * WH_TempName(XP_FileType type, const char * prefix) {return PL_strdup("c:\\temp\\nsmail01.txt");}
|
||||
|
||||
HJ10196
|
||||
History_entry * SHIST_GetCurrent(History *) {return NULL;}
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include "nsIScriptContextOwner.h"
|
||||
|
||||
/* rhp - for access to webshell */
|
||||
#include "prmem.h"
|
||||
#include "plstr.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
@@ -36,6 +38,7 @@
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIURL.h"
|
||||
#include "nsMsgCompPrefs.h"
|
||||
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsIMsgCompose.h"
|
||||
@@ -51,7 +54,10 @@ static NS_DEFINE_IID(kIMsgCompFieldsIID, NS_IMSGCOMPFIELDS_IID);
|
||||
static NS_DEFINE_CID(kMsgCompFieldsCID, NS_MSGCOMPFIELDS_CID);
|
||||
|
||||
static NS_DEFINE_IID(kIMsgSendIID, NS_IMSGSEND_IID);
|
||||
static NS_DEFINE_CID(kMsgSendCID, NS_MSGSEND_CID);
|
||||
static NS_DEFINE_CID(kMsgSendCID, NS_MSGSEND_CID);
|
||||
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
|
||||
NS_BEGIN_EXTERN_C
|
||||
|
||||
@@ -276,14 +282,13 @@ nsComposeAppCore::SetWindow(nsIDOMWindow* aWin)
|
||||
NS_IMETHODIMP
|
||||
nsComposeAppCore::CompleteCallback(nsAutoString& aScript)
|
||||
{
|
||||
mScript = *aScript;
|
||||
mScript = aScript;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComposeAppCore::NewMessage(nsAutoString& aUrl)
|
||||
{
|
||||
static NS_DEFINE_CID(kAppShellServiceCID, NS_APPSHELL_SERVICE_CID);
|
||||
|
||||
char * urlstr=nsnull;
|
||||
nsresult rv;
|
||||
@@ -321,6 +326,9 @@ done:
|
||||
NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, nsAutoString& aAddrCc,
|
||||
nsAutoString& aAddrBcc, nsAutoString& aSubject, nsAutoString& aMsg)
|
||||
{
|
||||
nsMsgCompPrefs pCompPrefs;
|
||||
char* pUserEmail = nsnull;
|
||||
|
||||
if (nsnull == mScriptContext)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
@@ -337,43 +345,22 @@ NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, nsAutoString&
|
||||
nsIMsgCompFields *pMsgCompFields;
|
||||
nsIMsgSend *pMsgSend;
|
||||
nsresult res;
|
||||
|
||||
// register our dll
|
||||
/*
|
||||
const char* compose_dll = "msgcompose.dll";
|
||||
nsComponentManager::RegisterComponent(kMsgComposeCID,
|
||||
"Netscape Mail Composer AppCore",
|
||||
NULL,
|
||||
compose_dll,
|
||||
PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kMsgCompFieldsCID,
|
||||
"Netscape Mail Composer Fields",
|
||||
NULL,
|
||||
compose_dll,
|
||||
PR_FALSE, PR_FALSE);
|
||||
nsComponentManager::RegisterComponent(kMsgSendCID,
|
||||
"Netscape Mail Sender",
|
||||
NULL,
|
||||
compose_dll,
|
||||
PR_FALSE, PR_FALSE);
|
||||
*/
|
||||
|
||||
|
||||
res = nsComponentManager::CreateInstance(kMsgSendCID,
|
||||
NULL,
|
||||
kIMsgSendIID,
|
||||
(void **) &pMsgSend);
|
||||
|
||||
if (res == NS_OK && pMsgSend) {
|
||||
if (NS_SUCCEEDED(res) && pMsgSend) {
|
||||
printf("We succesfully obtained a nsIMsgSend interface....\n");
|
||||
/* pMsgSend->Test(); */
|
||||
|
||||
res = nsComponentManager::CreateInstance(kMsgCompFieldsCID,
|
||||
NULL,
|
||||
kIMsgCompFieldsIID,
|
||||
(void **) &pMsgCompFields);
|
||||
if (res == NS_OK && pMsgCompFields) {
|
||||
|
||||
pMsgCompFields->SetFrom("qatest02@netscape.com", NULL); //JFD Need to use the prefs
|
||||
if (NS_SUCCEEDED(NS_OK) && pMsgCompFields) {
|
||||
pMsgCompFields->SetFrom((char *)pCompPrefs.GetUserEmail(), NULL);
|
||||
pMsgCompFields->SetOrganization((char *)pCompPrefs.GetOrganization(), NULL);
|
||||
pMsgCompFields->SetTo(aAddrTo.ToNewCString(), NULL);
|
||||
pMsgCompFields->SetCc(aAddrCc.ToNewCString(), NULL);
|
||||
pMsgCompFields->SetBcc(aAddrBcc.ToNewCString(), NULL);
|
||||
@@ -393,7 +380,15 @@ NS_IMETHODIMP nsComposeAppCore::SendMessage(nsAutoString& aAddrTo, nsAutoString&
|
||||
PRBool isUndefined = PR_FALSE;
|
||||
nsString rVal;
|
||||
mScriptContext->EvaluateString(mScript, url, 0, rVal, &isUndefined);
|
||||
}
|
||||
}
|
||||
|
||||
if (mWindow) {
|
||||
mWindow->Close(); //JFD Doesn't work yet because mopener wasn't set!
|
||||
NS_RELEASE(mWindow);
|
||||
}
|
||||
|
||||
PR_FREEIF(pUserEmail);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "rosetta_mailnews.h"
|
||||
#include "nsMsgSend.h"
|
||||
#include "nsMsgComposeFact.h"
|
||||
#include "nsMsgCompPrefs.h"
|
||||
#include "nsMsgCompose.h"
|
||||
|
||||
/*JFD
|
||||
@@ -567,6 +568,7 @@ void nsMsgCompose::NotifyPrefsChange(NotifyCode) {
|
||||
|
||||
int nsMsgCompose::CreateVcardAttachment ()
|
||||
{
|
||||
nsMsgCompPrefs pCompPrefs;
|
||||
char* name;
|
||||
int status = 0;
|
||||
|
||||
@@ -582,8 +584,8 @@ int nsMsgCompose::CreateVcardAttachment ()
|
||||
if (vCard)
|
||||
PR_Free(vCard); // free our allocated VCardString...
|
||||
char buf [ 2 * kMaxFullNameLength ];
|
||||
if (FE_UsersFullName())
|
||||
name = PL_strdup (FE_UsersFullName());
|
||||
if (pCompPrefs.GetUserFullName())
|
||||
name = PL_strdup (pCompPrefs.GetUserFullName());
|
||||
// write out a content description string
|
||||
XP_SPRINTF (buf, XP_GetString (MK_ADDR_BOOK_CARD), name);
|
||||
PR_FREEIF(name);
|
||||
@@ -678,6 +680,7 @@ int nsMsgCompose::CreateVcardAttachment ()
|
||||
char*
|
||||
nsMsgCompose::FigureBcc(PRBool newsBcc)
|
||||
{
|
||||
nsMsgCompPrefs pCompPrefs;
|
||||
char* result = NULL;
|
||||
PRBool useBcc = PR_FALSE;
|
||||
|
||||
@@ -694,9 +697,9 @@ nsMsgCompose::FigureBcc(PRBool newsBcc)
|
||||
if (!GetPrefs()->GetDefaultBccSelf(newsBcc)) {
|
||||
result = PL_strdup(tmp ? tmp : "");
|
||||
} else if (!tmp || !*tmp) {
|
||||
result = PL_strdup(FE_UsersMailAddress());
|
||||
result = PL_strdup(pCompPrefs.GetUserEmail());
|
||||
} else {
|
||||
result = PR_smprintf("%s, %s", FE_UsersMailAddress(), tmp);
|
||||
result = PR_smprintf("%s, %s", pCompPrefs.GetUserEmail(), tmp);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -971,10 +974,12 @@ HJ73123
|
||||
void
|
||||
nsMsgCompose::InitializeHeaders(MWContext* old_context, const nsIMsgCompFields* fields)
|
||||
{
|
||||
nsMsgCompPrefs pCompPrefs;
|
||||
|
||||
PR_ASSERT(m_fields == NULL);
|
||||
PR_ASSERT(m_initfields == NULL);
|
||||
|
||||
const char *real_addr = FE_UsersMailAddress ();
|
||||
const char *real_addr = pCompPrefs.GetUserEmail();
|
||||
char *real_return_address;
|
||||
const char* sig;
|
||||
PRBool forward_quoted;
|
||||
@@ -1014,7 +1019,7 @@ nsMsgCompose::InitializeHeaders(MWContext* old_context, const nsIMsgCompFields*
|
||||
|
||||
/*JFD
|
||||
real_return_address = MIME_MakeFromField(old_context->win_csid);
|
||||
*/ real_return_address = (char *)FE_UsersMailAddress();/*JFD*/
|
||||
*/ real_return_address = (char *)pCompPrefs.GetUserEmail();/*JFD*/
|
||||
|
||||
/*JFD
|
||||
PR_ASSERT (m_context->type == MWContextMessageComposition);
|
||||
@@ -1117,7 +1122,7 @@ nsMsgCompose::InitializeHeaders(MWContext* old_context, const nsIMsgCompFields*
|
||||
HJ77855
|
||||
|
||||
if (!*m_fields->GetOrganization()) {
|
||||
m_fields->SetOrganization((char *)FE_UsersOrganization(), NULL);
|
||||
m_fields->SetOrganization((char *)pCompPrefs.GetOrganization(), NULL);
|
||||
}
|
||||
|
||||
if (!*m_fields->GetReplyTo()) {
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
#include "nsIMsgRFC822Parser.h"
|
||||
#include "nsINetService.h"
|
||||
#include "nsISmtpService.h" // for actually sending the message...
|
||||
#include "nsMsgCompPrefs.h"
|
||||
#include "nsIMsgMailSession.h"
|
||||
#include "nsIMsgIdentity.h"
|
||||
#include "nsMsgSend.h"
|
||||
|
||||
/* use these macros to define a class IID for our component. Our object currently supports two interfaces
|
||||
@@ -232,6 +235,7 @@ extern OSErr my_FSSpecFromPathname(char* src_filename, FSSpec* fspec);
|
||||
extern void MSG_MimeNotifyCryptoAttachmentKludge(NET_StreamClass *stream);
|
||||
XP_END_PROTOS
|
||||
|
||||
|
||||
static char* NET_GetLocalFileFromURL(char *url)
|
||||
{
|
||||
char * finalPath;
|
||||
@@ -257,6 +261,40 @@ static char* NET_GetURLFromLocalFile(char *filename)
|
||||
|
||||
#endif /* XP_MAC */
|
||||
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_IID(kIPrefIID, NS_IPREF_IID);
|
||||
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
|
||||
|
||||
static char * WH_TempName(XP_FileType /*type*/, const char * prefix)
|
||||
{
|
||||
nsresult res;
|
||||
nsString tempPath = "c:\\temp\\";
|
||||
|
||||
#define PREF_LENGTH 128
|
||||
char prefValue[PREF_LENGTH];
|
||||
PRInt32 prefLength = PREF_LENGTH;
|
||||
nsIPref* prefs;
|
||||
res = nsServiceManager::GetService(kPrefCID, kIPrefIID, (nsISupports**)&prefs);
|
||||
if (prefs && NS_SUCCEEDED(res))
|
||||
{
|
||||
prefs->Startup("prefs.js");
|
||||
res = prefs->GetCharPref("browser.download_directory", prefValue, &prefLength);
|
||||
if (NS_SUCCEEDED(res) && prefLength > 0)
|
||||
tempPath = PL_strdup(prefValue);
|
||||
|
||||
nsServiceManager::ReleaseService(kPrefCID, prefs);
|
||||
}
|
||||
|
||||
if (tempPath.Last() != '\\')
|
||||
tempPath += '\\';
|
||||
|
||||
tempPath += prefix;
|
||||
tempPath += "01.txt"; //JFD, need to be smarter than that!
|
||||
|
||||
return tempPath.ToNewCString();
|
||||
}
|
||||
|
||||
/* this function will be used by the factory to generate an Message Send Object....*/
|
||||
nsresult NS_NewMsgSend(nsIMsgSend** aInstancePtrResult)
|
||||
{
|
||||
@@ -2828,8 +2866,9 @@ char * msg_generate_message_id (void)
|
||||
{
|
||||
time_t now = XP_TIME();
|
||||
PRUint32 salt = 0;
|
||||
nsMsgCompPrefs pCompPrefs;
|
||||
const char *host = 0;
|
||||
const char *from = FE_UsersMailAddress ();
|
||||
const char *from = pCompPrefs.GetUserEmail();
|
||||
|
||||
RNG_GenerateGlobalRandomBytes((void *) &salt, sizeof(salt));
|
||||
|
||||
@@ -3590,8 +3629,9 @@ int MIME_GenerateMailtoFormPostHeaders (const char *old_post_url,
|
||||
*new_post_url_return = 0;
|
||||
|
||||
/*JFD
|
||||
fields = MSG_CreateCompositionFields(from, 0, to, cc, 0, 0, 0, 0,
|
||||
FE_UsersOrganization(), 0, 0,
|
||||
nsMsgCompPrefs pCompPrefs;
|
||||
fields = MSG_CreateCompositionFields(from, 0, to, cc, 0, 0, 0, 0,
|
||||
(char *)pCompPrefs.GetOrganization(), 0, 0,
|
||||
extra_headers, 0, 0, 0,
|
||||
encrypt_p, sign_p);
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user