зеркало из https://github.com/mozilla/gecko-dev.git
fix 228597 news article article always gets sent to the first account's server when sharing identities between accounts, patch by ch.ey@gmx.net, r=me, sr=mscott
This commit is contained in:
Родитель
7bf3df9f49
Коммит
9fe00adc1f
|
@ -1736,7 +1736,7 @@ function GenericSendMessage( msgType )
|
|||
}
|
||||
msgWindow.SetDOMWindow(window);
|
||||
|
||||
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), msgWindow, progress);
|
||||
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), getCurrentAccountKey(), msgWindow, progress);
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to SendMsg: " + ex + "\n");
|
||||
|
@ -2031,6 +2031,7 @@ function FillIdentityListPopup(popup)
|
|||
item.className = "identity-popup-item";
|
||||
item.setAttribute("label", identity.identityName);
|
||||
item.setAttribute("value", identity.key);
|
||||
item.setAttribute("accountkey", accounts[i].key);
|
||||
item.setAttribute("accountname", " - " + server.prettyName);
|
||||
popup.appendChild(item);
|
||||
}
|
||||
|
@ -2050,6 +2051,13 @@ function getCurrentIdentity()
|
|||
return identity;
|
||||
}
|
||||
|
||||
function getCurrentAccountKey()
|
||||
{
|
||||
// get the accounts key
|
||||
var identityList = document.getElementById("msgIdentity");
|
||||
return identityList.selectedItem.getAttribute("accountkey");
|
||||
}
|
||||
|
||||
function getIdentityForKey(key)
|
||||
{
|
||||
return gAccountManager.getIdentity(key);
|
||||
|
|
|
@ -141,7 +141,7 @@ interface nsIMsgCompose : nsISupports {
|
|||
void UnregisterStateListener(in nsIMsgComposeStateListener stateListener);
|
||||
|
||||
/* ... */
|
||||
void SendMsg(in MSG_DeliverMode deliverMode, in nsIMsgIdentity identity, in nsIMsgWindow aMsgWindow, in nsIMsgProgress progress);
|
||||
void SendMsg(in MSG_DeliverMode deliverMode, in nsIMsgIdentity identity, in string accountKey, in nsIMsgWindow aMsgWindow, in nsIMsgProgress progress);
|
||||
|
||||
/* ... */
|
||||
void CloseWindow(in boolean reclycleIt);
|
||||
|
|
|
@ -186,8 +186,9 @@ interface nsIMsgSend : nsISupports
|
|||
const nsMsgDeliverMode nsMsgSendUnsent = 6;
|
||||
|
||||
[noscript]
|
||||
void createAndSendMessage(in nsIEditor aEditor,
|
||||
void createAndSendMessage(in nsIEditor aEditor,
|
||||
in nsIMsgIdentity aUserIdentity,
|
||||
in string aAccountKey,
|
||||
in nsIMsgCompFields fields,
|
||||
in PRBool digest_p,
|
||||
in PRBool dont_deliver_p,
|
||||
|
@ -207,6 +208,7 @@ interface nsIMsgSend : nsISupports
|
|||
|
||||
|
||||
void sendMessageFile(in nsIMsgIdentity aUserIdentity,
|
||||
in string aAccountKey,
|
||||
in nsIMsgCompFields fields,
|
||||
in nsIFileSpec sendIFileSpec,
|
||||
in PRBool deleteSendFileOnCompletion,
|
||||
|
|
|
@ -1673,7 +1673,7 @@ function GenericSendMessage( msgType )
|
|||
}
|
||||
msgWindow.SetDOMWindow(window);
|
||||
|
||||
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), msgWindow, progress);
|
||||
gMsgCompose.SendMsg(msgType, getCurrentIdentity(), getCurrentAccountKey(), msgWindow, progress);
|
||||
}
|
||||
catch (ex) {
|
||||
dump("failed to SendMsg: " + ex + "\n");
|
||||
|
@ -1949,6 +1949,7 @@ function FillIdentityListPopup(popup)
|
|||
item.className = "identity-popup-item";
|
||||
item.setAttribute("label", identity.identityName);
|
||||
item.setAttribute("value", identity.key);
|
||||
item.setAttribute("accountkey", accounts[i].key);
|
||||
item.setAttribute("accountname", " - " + server.prettyName);
|
||||
popup.appendChild(item);
|
||||
}
|
||||
|
@ -1968,6 +1969,13 @@ function getCurrentIdentity()
|
|||
return identity;
|
||||
}
|
||||
|
||||
function getCurrentAccountKey()
|
||||
{
|
||||
// get the accounts key
|
||||
var identityList = document.getElementById("msgIdentity");
|
||||
return identityList.selectedItem.getAttribute("accountkey");
|
||||
}
|
||||
|
||||
function getIdentityForKey(key)
|
||||
{
|
||||
return gAccountManager.getIdentity(key);
|
||||
|
|
|
@ -823,7 +823,7 @@ nsresult nsMsgCompose::UnregisterStateListener(nsIMsgComposeStateListener *state
|
|||
return mStateListeners->RemoveElement(iSupports);
|
||||
}
|
||||
|
||||
nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, PRBool entityConversionDone)
|
||||
nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const char *accountKey, PRBool entityConversionDone)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -941,6 +941,7 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide
|
|||
rv = mMsgSend->CreateAndSendMessage(
|
||||
m_composeHTML ? m_editor.get() : nsnull,
|
||||
identity,
|
||||
accountKey,
|
||||
m_compFields,
|
||||
PR_FALSE, // PRBool digest_p,
|
||||
PR_FALSE, // PRBool dont_deliver_p,
|
||||
|
@ -973,7 +974,7 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, nsIMsgWindow *aMsgWindow, nsIMsgProgress *progress)
|
||||
NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const char *accountKey, nsIMsgWindow *aMsgWindow, nsIMsgProgress *progress)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
PRBool entityConversionDone = PR_FALSE;
|
||||
|
@ -1117,7 +1118,7 @@ NS_IMETHODIMP nsMsgCompose::SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity
|
|||
}
|
||||
}
|
||||
|
||||
rv = _SendMsg(deliverMode, identity, entityConversionDone);
|
||||
rv = _SendMsg(deliverMode, identity, accountKey, entityConversionDone);
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIMsgSendReport> sendReport;
|
||||
|
|
|
@ -115,7 +115,7 @@ private:
|
|||
nsCString m_folderName;
|
||||
|
||||
private:
|
||||
nsresult _SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, PRBool entityConversionDone);
|
||||
nsresult _SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *identity, const char *accountKey, PRBool entityConversionDone);
|
||||
nsresult CreateMessage(const char * originalMsgURI, MSG_ComposeType type, nsIMsgCompFields* compFields);
|
||||
void CleanUpRecipients(nsString& recipients);
|
||||
nsresult GetABDirectories(const nsACString& dirUri, nsISupportsArray* directoriesArray, PRBool searchSubDirectory);
|
||||
|
|
|
@ -3092,6 +3092,7 @@ nsMsgComposeAndSend::SnarfAndCopyBody(const char *attachment1_body,
|
|||
nsresult
|
||||
nsMsgComposeAndSend::Init(
|
||||
nsIMsgIdentity *aUserIdentity,
|
||||
const char *aAccountKey,
|
||||
nsMsgCompFields *fields,
|
||||
nsFileSpec *sendFileSpec,
|
||||
PRBool digest_p,
|
||||
|
@ -3135,6 +3136,7 @@ nsMsgComposeAndSend::Init(
|
|||
mMsgToReplace = msgToReplace;
|
||||
|
||||
mUserIdentity = aUserIdentity;
|
||||
mAccountKey = aAccountKey;
|
||||
NS_ASSERTION(mUserIdentity, "Got null identity!\n");
|
||||
if (!mUserIdentity) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
|
@ -3528,8 +3530,8 @@ nsMsgComposeAndSend::DeliverFileAsNews()
|
|||
if(NS_FAILED(rv))
|
||||
msgWindow = nsnull;
|
||||
|
||||
rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mUserIdentity,
|
||||
uriListener, msgWindow, nsnull);
|
||||
rv = nntpService->PostMessage(fileToPost, mCompFields->GetNewsgroups(), mAccountKey.get(),
|
||||
uriListener, msgWindow, nsnull);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
|
@ -3968,6 +3970,7 @@ NS_IMETHODIMP
|
|||
nsMsgComposeAndSend::CreateAndSendMessage(
|
||||
nsIEditor *aEditor,
|
||||
nsIMsgIdentity *aUserIdentity,
|
||||
const char *aAccountKey,
|
||||
nsIMsgCompFields *fields,
|
||||
PRBool digest_p,
|
||||
PRBool dont_deliver_p,
|
||||
|
@ -4006,7 +4009,7 @@ nsMsgComposeAndSend::CreateAndSendMessage(
|
|||
if (aEditor)
|
||||
mEditor = aEditor;
|
||||
|
||||
rv = Init(aUserIdentity, (nsMsgCompFields *)fields, nsnull,
|
||||
rv = Init(aUserIdentity, aAccountKey, (nsMsgCompFields *)fields, nsnull,
|
||||
digest_p, dont_deliver_p, mode, msgToReplace,
|
||||
attachment1_type, attachment1_body,
|
||||
attachment1_body_length,
|
||||
|
@ -4022,6 +4025,7 @@ nsMsgComposeAndSend::CreateAndSendMessage(
|
|||
nsresult
|
||||
nsMsgComposeAndSend::SendMessageFile(
|
||||
nsIMsgIdentity *aUserIndentity,
|
||||
const char *aAccountKey,
|
||||
nsIMsgCompFields *fields,
|
||||
nsIFileSpec *sendIFileSpec,
|
||||
PRBool deleteSendFileOnCompletion,
|
||||
|
@ -4077,11 +4081,11 @@ nsMsgComposeAndSend::SendMessageFile(
|
|||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
rv = Init(aUserIndentity, (nsMsgCompFields *)fields, sendFileSpec,
|
||||
digest_p, PR_FALSE, mode, msgToReplace,
|
||||
nsnull, nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
password);
|
||||
rv = Init(aUserIndentity, aAccountKey, (nsMsgCompFields *)fields, sendFileSpec,
|
||||
digest_p, PR_FALSE, mode, msgToReplace,
|
||||
nsnull, nsnull, nsnull,
|
||||
nsnull, nsnull,
|
||||
password);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = DeliverMessage();
|
||||
|
@ -4484,15 +4488,32 @@ nsMsgComposeAndSend::MimeDoFCC(nsFileSpec *input_file,
|
|||
&& ( mUserIdentity )
|
||||
)
|
||||
{
|
||||
char *key = nsnull;
|
||||
char *buf = nsnull, *key = nsnull;
|
||||
|
||||
if (NS_SUCCEEDED(mUserIdentity->GetKey(&key)) && (key))
|
||||
{
|
||||
char *tmpLine = PR_smprintf(HEADER_X_MOZILLA_IDENTITY_KEY ": %s" CRLF, key);
|
||||
if (tmpLine)
|
||||
buf = PR_smprintf(HEADER_X_MOZILLA_IDENTITY_KEY ": %s" CRLF, key);
|
||||
if (buf)
|
||||
{
|
||||
PRInt32 len = strlen(tmpLine);
|
||||
n = tempOutfile.write(tmpLine, len);
|
||||
PRInt32 len = strlen(buf);
|
||||
n = tempOutfile.write(buf, len);
|
||||
PR_Free(buf);
|
||||
if (n != len)
|
||||
{
|
||||
status = NS_ERROR_FAILURE;
|
||||
goto FAIL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!mAccountKey.IsEmpty())
|
||||
{
|
||||
buf = PR_smprintf(HEADER_X_MOZILLA_ACCOUNT_KEY ": %s" CRLF, mAccountKey.get());
|
||||
if (buf)
|
||||
{
|
||||
PRInt32 len = strlen(buf);
|
||||
n = tempOutfile.write(buf, len);
|
||||
PR_Free(buf);
|
||||
if (n != len)
|
||||
{
|
||||
status = NS_ERROR_FAILURE;
|
||||
|
|
|
@ -243,18 +243,19 @@ public:
|
|||
// message creation and send operations
|
||||
//
|
||||
nsresult Init(
|
||||
nsIMsgIdentity *aUserIdentity,
|
||||
nsMsgCompFields *fields,
|
||||
nsIMsgIdentity *aUserIdentity,
|
||||
const char *aAccountKey,
|
||||
nsMsgCompFields *fields,
|
||||
nsFileSpec *sendFileSpec,
|
||||
PRBool digest_p,
|
||||
PRBool dont_deliver_p,
|
||||
nsMsgDeliverMode mode,
|
||||
PRBool digest_p,
|
||||
PRBool dont_deliver_p,
|
||||
nsMsgDeliverMode mode,
|
||||
nsIMsgDBHdr *msgToReplace,
|
||||
const char *attachment1_type,
|
||||
const char *attachment1_body,
|
||||
PRUint32 attachment1_body_length,
|
||||
const nsMsgAttachmentData *attachments,
|
||||
const nsMsgAttachedFile *preloaded_attachments,
|
||||
const char *attachment1_type,
|
||||
const char *attachment1_body,
|
||||
PRUint32 attachment1_body_length,
|
||||
const nsMsgAttachmentData *attachments,
|
||||
const nsMsgAttachedFile *preloaded_attachments,
|
||||
const char *password);
|
||||
|
||||
//
|
||||
|
@ -297,6 +298,7 @@ public:
|
|||
//
|
||||
nsMsgKey m_messageKey; // jt -- Draft/Template support; newly created key
|
||||
nsCOMPtr<nsIMsgIdentity> mUserIdentity;
|
||||
nsCString mAccountKey;
|
||||
nsCOMPtr<nsMsgCompFields> mCompFields; // All needed composition fields (header, etc...)
|
||||
nsFileSpec *mTempFileSpec; // our temporary file
|
||||
|
||||
|
|
|
@ -107,6 +107,7 @@ nsMsgSendLater::nsMsgSendLater()
|
|||
m_headersSize = 0;
|
||||
|
||||
mIdentityKey = nsnull;
|
||||
mAccountKey = nsnull;
|
||||
|
||||
mRequestReturnReceipt = PR_FALSE;
|
||||
|
||||
|
@ -124,6 +125,7 @@ nsMsgSendLater::~nsMsgSendLater()
|
|||
PR_Free(m_headers);
|
||||
PR_Free(mLeftoverBuffer);
|
||||
PR_Free(mIdentityKey);
|
||||
PR_Free(mAccountKey);
|
||||
}
|
||||
|
||||
// Stream is done...drive on!
|
||||
|
@ -551,6 +553,7 @@ nsMsgSendLater::CompleteMailFileSend()
|
|||
m_window->GetStatusFeedback(getter_AddRefs(statusFeedback));
|
||||
NS_ADDREF(this); //TODO: We should remove this!!!
|
||||
rv = pMsgSend->SendMessageFile(identity,
|
||||
mAccountKey,
|
||||
compFields, // nsIMsgCompFields *fields,
|
||||
mTempIFileSpec, // nsIFileSpec *sendFileSpec,
|
||||
PR_TRUE, // PRBool deleteSendFileOnCompletion,
|
||||
|
@ -810,6 +813,7 @@ nsMsgSendLater::BuildHeaders()
|
|||
PR_FREEIF(m_newshost);
|
||||
PR_FREEIF(m_fcc);
|
||||
PR_FREEIF(mIdentityKey);
|
||||
PR_FREEIF(mAccountKey);
|
||||
m_flags = 0;
|
||||
|
||||
while (buf < buf_end)
|
||||
|
@ -889,6 +893,11 @@ nsMsgSendLater::BuildHeaders()
|
|||
prune_p = PR_TRUE;
|
||||
header = &mIdentityKey;
|
||||
}
|
||||
else if (!PL_strncasecmp(HEADER_X_MOZILLA_ACCOUNT_KEY, buf, end - buf))
|
||||
{
|
||||
prune_p = PR_TRUE;
|
||||
header = &mAccountKey;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -160,6 +160,7 @@ private:
|
|||
char *mLeftoverBuffer;
|
||||
PRBool mRequestReturnReceipt;
|
||||
char *mIdentityKey;
|
||||
char *mAccountKey;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -696,6 +696,7 @@ nsresult nsEudoraCompose::SendTheMessage( nsIFileSpec *pMsg)
|
|||
rv = m_pSendProxy->CreateAndSendMessage(
|
||||
nsnull, // no editor shell
|
||||
m_pIdentity, // dummy identity
|
||||
nsnull, // account key
|
||||
m_pMsgFields, // message fields
|
||||
PR_FALSE, // digest = NO
|
||||
PR_TRUE, // dont_deliver = YES, make a file
|
||||
|
@ -717,6 +718,7 @@ nsresult nsEudoraCompose::SendTheMessage( nsIFileSpec *pMsg)
|
|||
rv = m_pSendProxy->CreateAndSendMessage(
|
||||
nsnull, // no editor shell
|
||||
m_pIdentity, // dummy identity
|
||||
nsnull, // account key
|
||||
m_pMsgFields, // message fields
|
||||
PR_FALSE, // digest = NO
|
||||
PR_TRUE, // dont_deliver = YES, make a file
|
||||
|
|
|
@ -662,6 +662,7 @@ nsresult nsOutlookCompose::SendTheMessage( nsIFileSpec *pMsg, nsMsgDeliverMode m
|
|||
rv = m_pSendProxy->CreateAndSendMessage(
|
||||
nsnull, // no editor shell
|
||||
m_pIdentity, // dummy identity
|
||||
nsnull, // account key
|
||||
m_pMsgFields, // message fields
|
||||
PR_FALSE, // digest = NO
|
||||
PR_TRUE, // dont_deliver = YES, make a file
|
||||
|
|
|
@ -398,7 +398,7 @@ nsresult nsMapiHook::BlindSendMail (unsigned long aSession, nsIMsgCompFields * a
|
|||
rv = pMsgCompose->Initialize(hiddenWindow, pMsgComposeParams) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, pMsgId, nsnull, nsnull) ;
|
||||
pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, pMsgId, nsnull, nsnull, nsnull) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
// assign to interface pointer from nsCOMPtr to facilitate typecast below
|
||||
|
|
|
@ -110,5 +110,6 @@
|
|||
|
||||
#define HEADER_X_MOZILLA_PART_URL "X-Mozilla-PartURL"
|
||||
#define HEADER_X_MOZILLA_IDENTITY_KEY "X-Identity-Key"
|
||||
#define HEADER_X_MOZILLA_ACCOUNT_KEY "X-Account-Key"
|
||||
|
||||
#endif /* nsMailHeaders_h_ */
|
||||
|
|
|
@ -65,7 +65,7 @@ interface nsINntpService : nsISupports {
|
|||
*/
|
||||
void generateNewsHeaderValsForPosting(in string newsgroupsList, out string newsgroupsHeaderVal, out string newshostHeaderVal);
|
||||
|
||||
nsIURI postMessage(in nsIFileSpec fileToPost, in string newsgroupNames, in nsIMsgIdentity aSenderIdentity, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
|
||||
nsIURI postMessage(in nsIFileSpec fileToPost, in string newsgroupNames, in string aAccountKey, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
|
||||
|
||||
nsIURI getNewNews(in nsINntpIncomingServer nntpServer, in string uri, in boolean getOld, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
|
||||
|
||||
|
|
|
@ -775,31 +775,22 @@ nsresult nsNntpService::FindHostFromGroup(nsCString &host, nsCString &groupName)
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsNntpService::SetUpNntpUrlForPosting(nsINntpUrl *nntpUrl, const char *newsgroupsNames, nsIMsgIdentity *aSenderIdentity, char **newsUrlSpec)
|
||||
nsNntpService::SetUpNntpUrlForPosting(const char *aAccountKey, char **newsUrlSpec)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
NS_ENSURE_ARG_POINTER(nntpUrl);
|
||||
NS_ENSURE_ARG_POINTER(newsgroupsNames);
|
||||
if (*newsgroupsNames == '\0') return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString host;
|
||||
nsXPIDLCString temphost;
|
||||
nsXPIDLCString host;
|
||||
PRInt32 port;
|
||||
|
||||
nsCOMPtr<nsIMsgIncomingServer> nntpServer;
|
||||
rv = GetNntpServerByIdentity(aSenderIdentity, getter_AddRefs(nntpServer));
|
||||
rv = GetNntpServerByAccount(aAccountKey, getter_AddRefs(nntpServer));
|
||||
if (NS_SUCCEEDED(rv) && nntpServer)
|
||||
{
|
||||
nntpServer->GetRealHostName(getter_Copies(temphost));
|
||||
host = temphost;
|
||||
nntpServer->GetRealHostName(getter_Copies(host));
|
||||
nntpServer->GetPort(&port);
|
||||
}
|
||||
|
||||
// if we *still* don't have a hostname, use "news"
|
||||
if (host.IsEmpty())
|
||||
host = "news";
|
||||
|
||||
*newsUrlSpec = PR_smprintf("%s/%s:%d",kNewsRootURI, host.get(), port);
|
||||
*newsUrlSpec = PR_smprintf("%s/%s:%d",kNewsRootURI, host.IsEmpty() ? "news" : host.get(), port);
|
||||
if (!*newsUrlSpec) return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
|
@ -936,50 +927,30 @@ nsNntpService::GenerateNewsHeaderValsForPosting(const char *newsgroupsList, char
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsNntpService::GetNntpServerByIdentity(nsIMsgIdentity *aSenderIdentity, nsIMsgIncomingServer **aNntpServer)
|
||||
nsNntpService::GetNntpServerByAccount(const char *aAccountKey, nsIMsgIncomingServer **aNntpServer)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aNntpServer);
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
|
||||
if (aSenderIdentity)
|
||||
nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
if (aAccountKey)
|
||||
{
|
||||
nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr <nsISupportsArray> servers;
|
||||
accountManager->GetServersForIdentity(aSenderIdentity, getter_AddRefs(servers));
|
||||
if (!servers) return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 cnt = 0, i;
|
||||
servers->Count(&cnt);
|
||||
for (i=0; i<cnt; i++)
|
||||
{
|
||||
nsCOMPtr<nsIMsgIncomingServer> inServer;
|
||||
inServer = do_QueryElementAt(servers, i, &rv);
|
||||
if(NS_FAILED(rv) || (!inServer))
|
||||
continue;
|
||||
|
||||
nsXPIDLCString serverType;
|
||||
rv = inServer->GetType(getter_Copies(serverType));
|
||||
if(serverType.Equals("nntp"))
|
||||
{
|
||||
*aNntpServer = inServer;
|
||||
|
||||
NS_IF_ADDREF(*aNntpServer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// if we don't have a news host, find the first news server and use it
|
||||
if (!*aNntpServer)
|
||||
rv = accountManager->FindServer("","","nntp", aNntpServer);
|
||||
nsCOMPtr <nsIMsgAccount> account;
|
||||
rv = accountManager->GetAccount(aAccountKey, getter_AddRefs(account));
|
||||
if (NS_SUCCEEDED(rv) && account)
|
||||
rv = account->GetIncomingServer(aNntpServer);
|
||||
}
|
||||
|
||||
// if we don't have a news host, find the first news server and use it
|
||||
if (NS_FAILED(rv) || !*aNntpServer)
|
||||
rv = accountManager->FindServer("","","nntp", aNntpServer);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, nsIMsgIdentity *aSenderIdentity, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **_retval)
|
||||
nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames, const char *aAccountKey, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI **_retval)
|
||||
{
|
||||
// aMsgWindow might be null
|
||||
NS_ENSURE_ARG_POINTER(newsgroupsNames);
|
||||
|
@ -997,7 +968,7 @@ nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames,
|
|||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsXPIDLCString newsUrlSpec;
|
||||
rv = SetUpNntpUrlForPosting(nntpUrl, newsgroupsNames, aSenderIdentity, getter_Copies(newsUrlSpec));
|
||||
rv = SetUpNntpUrlForPosting(aAccountKey, getter_Copies(newsUrlSpec));
|
||||
NS_ENSURE_SUCCESS(rv,rv);
|
||||
|
||||
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(nntpUrl, &rv);
|
||||
|
|
|
@ -84,8 +84,8 @@ public:
|
|||
protected:
|
||||
PRBool WeAreOffline();
|
||||
|
||||
nsresult GetNntpServerByIdentity(nsIMsgIdentity *aSenderIdentity, nsIMsgIncomingServer **aNntpServer);
|
||||
nsresult SetUpNntpUrlForPosting(nsINntpUrl * nntpUrl, const char *newsgroupNames, nsIMsgIdentity *aSenderIdentity, char **newsUrlSpec);
|
||||
nsresult GetNntpServerByAccount(const char *aAccountKey, nsIMsgIncomingServer **aNntpServer);
|
||||
nsresult SetUpNntpUrlForPosting(const char *aAccountKey, char **newsUrlSpec);
|
||||
nsresult FindHostFromGroup(nsCString &host, nsCString &groupName);
|
||||
nsresult FindServerWithNewsgroup(nsCString &host, nsCString &groupName);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче