remove more xpidl strings, 379070, sr=mscott

This commit is contained in:
bienvenu%nventure.com 2007-05-10 15:12:39 +00:00
Родитель 8b851f9773
Коммит 3d0478f569
23 изменённых файлов: 2087 добавлений и 2161 удалений

Просмотреть файл

@ -183,7 +183,6 @@ nsMsgDBFolder::nsMsgDBFolder(void)
mHaveParsedURI(PR_FALSE),
mIsServerIsValid(PR_FALSE),
mIsServer(PR_FALSE),
mBaseMessageURI(nsnull),
mInVFEditSearchScope (PR_FALSE)
{
NS_NewISupportsArray(getter_AddRefs(mSubFolders));
@ -200,8 +199,6 @@ nsMsgDBFolder::nsMsgDBFolder(void)
nsMsgDBFolder::~nsMsgDBFolder(void)
{
CRTFREEIF(mBaseMessageURI);
if (--mInstanceCount == 0) {
NS_IF_RELEASE(gCollationKeyGenerator);
CRTFREEIF(kLocalizedInboxName);
@ -4845,10 +4842,10 @@ NS_IMETHODIMP nsMsgDBFolder::GetBaseMessageURI(char **baseMessageURI)
{
NS_ENSURE_ARG_POINTER(baseMessageURI);
if (!mBaseMessageURI)
if (mBaseMessageURI.IsEmpty())
return NS_ERROR_FAILURE;
*baseMessageURI = nsCRT::strdup(mBaseMessageURI);
*baseMessageURI = ToNewCString(mBaseMessageURI);
return NS_OK;
}

Просмотреть файл

@ -236,7 +236,7 @@ protected:
PRBool mIsServer;
nsString mName;
nsCOMPtr<nsILocalFile> mPath;
char * mBaseMessageURI; //The uri with the message scheme
nsCString mBaseMessageURI; //The uri with the message scheme
PRBool mInVFEditSearchScope ; // non persistant state used by the virtual folder UI

Просмотреть файл

@ -265,7 +265,7 @@ PRInt32 nsIMAPBodyShell::Generate(char *partNum)
PRUint32 messageSize = m_protocolConnection->GetMessageSize(GetUID().get(), PR_TRUE);
m_protocolConnection->SetContentModified(IMAP_CONTENT_NOT_MODIFIED); // So that when we cache it, we know we have the whole message
if (!DeathSignalReceived())
m_protocolConnection->FallbackToFetchWholeMsg(GetUID().get(), messageSize);
m_protocolConnection->FallbackToFetchWholeMsg(GetUID(), messageSize);
contentLength = (PRInt32) messageSize; // ugh
}
else
@ -502,7 +502,7 @@ PRInt32 nsIMAPBodypart::GeneratePart(nsIMAPBodyShell *aShell, PRBool stream, PRB
PRBool fetchingSpecificPart = (generatingPart && !PL_strcmp(generatingPart, m_partNumberString));
aShell->GetConnection()->Log("SHELL","GENERATE-Part-Inline",m_partNumberString);
aShell->GetConnection()->FetchTryChunking(aShell->GetUID().get(), kMIMEPart, PR_TRUE, m_partNumberString, m_partLength, !fetchingSpecificPart);
aShell->GetConnection()->FetchTryChunking(aShell->GetUID(), kMIMEPart, PR_TRUE, m_partNumberString, m_partLength, !fetchingSpecificPart);
}
return m_partLength; // the part length has been filled in from the BODYSTRUCTURE response
}

Просмотреть файл

@ -67,7 +67,6 @@
#include "nsMsgFolderFlags.h"
#include "prmem.h"
#include "plstr.h"
#include "nsXPIDLString.h"
#include "nsIMsgFolder.h"
#include "nsIMsgWindow.h"
#include "nsIMsgImapMailFolder.h"
@ -158,7 +157,7 @@ NS_IMETHODIMP nsImapIncomingServer::SetKey(const nsACString& aKey) // override
hostSession->SetDeleteIsMoveToTrashForHost(key.get(), deleteModel == nsMsgImapDeleteModels::MoveToTrash);
hostSession->SetShowDeletedMessagesForHost(key.get(), deleteModel == nsMsgImapDeleteModels::IMAPDelete);
nsCString onlineDir;
nsCAutoString onlineDir;
rv = GetServerDirectory(onlineDir);
NS_ENSURE_SUCCESS(rv, rv);
if (!onlineDir.IsEmpty())
@ -200,9 +199,8 @@ NS_IMETHODIMP nsImapIncomingServer::SetKey(const nsACString& aKey) // override
NS_IMETHODIMP
nsImapIncomingServer::GetConstructedPrettyName(nsAString& retval)
{
nsCString username;
nsCString hostName;
nsCAutoString username;
nsCAutoString hostName;
nsresult rv;
nsCOMPtr<nsIMsgAccountManager> accountManager =
@ -360,7 +358,7 @@ nsImapIncomingServer::GetDeleteModel(PRInt32 *retval)
{
NS_ENSURE_ARG(retval);
nsCString redirectorType;
nsCAutoString redirectorType;
GetRedirectorType(redirectorType);
if (redirectorType.Equals("aol"))
{
@ -696,7 +694,7 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
nsCOMPtr<nsIImapProtocol> freeConnection;
PRBool isBusy = PR_FALSE;
PRBool isInboxConnection = PR_FALSE;
nsCString redirectorType;
nsCAutoString redirectorType;
PR_CEnterMonitor(this);
@ -740,7 +738,7 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
{
rv = connection->CanHandleUrl(aImapUrl, &canRunUrlImmediately, &canRunButBusy);
#ifdef DEBUG_bienvenu
nsXPIDLCString curSelectedFolderName;
nsCAutoString curSelectedFolderName;
if (connection)
connection->GetSelectedMailboxName(getter_Copies(curSelectedFolderName));
// check that no other connection is in the same selected state.
@ -753,7 +751,7 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
nsCOMPtr<nsIImapProtocol> otherConnection = do_QueryElementAt(m_connectionCache, j);
if (otherConnection)
{
nsXPIDLCString otherSelectedFolderName;
nsCAutoString otherSelectedFolderName;
otherConnection->GetSelectedMailboxName(getter_Copies(otherSelectedFolderName));
NS_ASSERTION(!curSelectedFolderName.Equals(otherSelectedFolderName), "two connections selected on same folder");
}
@ -785,7 +783,7 @@ nsImapIncomingServer::GetImapConnection(nsIEventTarget *aEventTarget,
freeConnection = connection;
else // check which is the better free connection to use.
{ // We prefer one not in the selected state.
nsCString selectedFolderName;
nsCAutoString selectedFolderName;
connection->GetSelectedMailboxName(getter_Copies(selectedFolderName));
if (selectedFolderName.IsEmpty())
freeConnection = connection;
@ -1041,7 +1039,7 @@ void nsImapIncomingServer::GetPFCName(nsACString& aPfcname)
{
if(NS_SUCCEEDED(GetStringBundle()))
{
nsString pfcName;
nsAutoString pfcName;
nsresult res = m_stringBundle->GetStringFromID(IMAP_PERSONAL_FILING_CABINET, getter_Copies(pfcName));
if (NS_SUCCEEDED(res))
CopyUTF16toUTF8(pfcName, m_pfcName);
@ -1083,12 +1081,12 @@ nsresult nsImapIncomingServer::GetPFCForStringId(PRBool createIfMissing, PRInt32
nsresult rv = GetPFC(createIfMissing, getter_AddRefs(pfcParent));
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString pfcURI;
nsCString pfcURI;
pfcParent->GetURI(getter_Copies(pfcURI));
rv = GetStringBundle();
NS_ENSURE_SUCCESS(rv, rv);
nsString pfcName;
nsAutoString pfcName;
rv = m_stringBundle->GetStringFromID(stringId, getter_Copies(pfcName));
NS_ENSURE_SUCCESS(rv, rv);
nsCAutoString pfcMailUri(pfcURI);
@ -1228,7 +1226,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder
parentUri.Append('/');
parentUri.Append(parentName);
}
if (folderPath.LowerCaseEqualsLiteral("INBOX") &&
if (folderPath.LowerCaseEqualsLiteral("inbox") &&
hierarchyDelimiter == kOnlineHierarchySeparatorNil)
{
hierarchyDelimiter = '/'; // set to default in this case (as in 4.x)
@ -1246,7 +1244,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder
// nsCString possibleName(aSpec->allocatedPathName);
uri.Append('/');
uri.Append(dupFolderPath);
PRBool caseInsensitive = dupFolderPath.LowerCaseEqualsLiteral("INBOX");
PRBool caseInsensitive = dupFolderPath.LowerCaseEqualsLiteral("inbox");
a_nsIFolder->GetChildWithURI(uri.get(), PR_TRUE, caseInsensitive, getter_AddRefs(child));
// if we couldn't find this folder by URI, tell the imap code it's a new folder to us
*aNewFolder = !child;
@ -1259,7 +1257,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder
{
nsCOMPtr <nsIMsgFolder> parent;
PRBool parentIsNew;
caseInsensitive = parentName.LowerCaseEqualsLiteral("INBOX");
caseInsensitive = parentName.LowerCaseEqualsLiteral("inbox");
a_nsIFolder->GetChildWithURI(parentUri.get(), PR_TRUE, caseInsensitive, getter_AddRefs(parent));
if (!parent /* || parentFolder->GetFolderNeedsAdded()*/)
{
@ -1269,7 +1267,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder
}
}
hostFolder->CreateClientSubfolderInfo(dupFolderPath.get(), hierarchyDelimiter,boxFlags, PR_FALSE);
caseInsensitive = dupFolderPath.LowerCaseEqualsLiteral("INBOX");
caseInsensitive = dupFolderPath.LowerCaseEqualsLiteral("inbox");
a_nsIFolder->GetChildWithURI(uri.get(), PR_TRUE, caseInsensitive, getter_AddRefs(child));
}
if (child)
@ -1281,8 +1279,8 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder
GetIsAOLServer(&isAOLServer);
nsXPIDLCString onlineName;
nsXPIDLString unicodeName;
nsCAutoString onlineName;
nsAutoString unicodeName;
imapFolder->SetVerifiedAsOnlineFolder(PR_TRUE);
imapFolder->SetHierarchyDelimiter(hierarchyDelimiter);
if (boxFlags & kImapTrash)
@ -1314,12 +1312,12 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder
if (hierarchyDelimiter != '/')
nsImapUrl::UnescapeSlashes(folderName.BeginWriting());
if (NS_SUCCEEDED(CopyMUTF7toUTF16(folderName, unicodeName)))
child->SetPrettyName(unicodeName);
child->SetPrettyName(unicodeName.get());
// Call ConvertFolderName() and HideFolderName() to do special folder name
// mapping and hiding, if configured to do so. For example, need to hide AOL's
// 'RECYCLE_OUT' & convert a few AOL folder names. Regular imap accounts
// will do no-op in the calls.
nsString convertedName;
nsAutoString convertedName;
PRBool hideFolder;
rv = HideFolderName(onlineName, &hideFolder);
if (hideFolder)
@ -1331,7 +1329,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const nsACString& folder
{
rv = ConvertFolderName(onlineName, convertedName);
//make sure rv value is not crunched, it is used to SetPrettyName
nsCString redirectorType;
nsCAutoString redirectorType;
GetRedirectorType(redirectorType); //Sent mail folder as per aol/netscape webmail
if ((redirectorType.EqualsLiteral("aol") && onlineName.EqualsLiteral("Sent Items"))
|| (redirectorType.EqualsLiteral("netscape") && onlineName.EqualsLiteral("Sent")))
@ -1438,7 +1436,7 @@ NS_IMETHODIMP nsImapIncomingServer::GetRedirectorType(nsACString& redirectorType
// redirectory type
if (redirectorType.LowerCaseEqualsLiteral("aol"))
{
nsCString hostName;
nsCAutoString hostName;
GetHostName(hostName);
if (hostName.LowerCaseEqualsLiteral("imap.mail.netcenter.com"))
SetRedirectorType(NS_LITERAL_CSTRING("netscape"));
@ -1454,7 +1452,7 @@ NS_IMETHODIMP nsImapIncomingServer::GetRedirectorType(nsACString& redirectorType
rv = CreateHostSpecificPrefName("default_redirector_type", prefName);
NS_ENSURE_SUCCESS(rv,rv);
nsCString defaultRedirectorType;
nsCAutoString defaultRedirectorType;
nsCOMPtr <nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
@ -1537,7 +1535,7 @@ NS_IMETHODIMP nsImapIncomingServer::ConvertFolderName(const nsACString& original
// Get string bundle based on redirector type and convert folder name.
nsCOMPtr<nsIStringBundle> stringBundle;
nsCAutoString propertyURL;
nsCString redirectorType;
nsCAutoString redirectorType;
GetRedirectorType(redirectorType);
if (redirectorType.IsEmpty())
return NS_ERROR_FAILURE; // return if no redirector type
@ -1748,7 +1746,7 @@ NS_IMETHODIMP nsImapIncomingServer::DiscoveryDone()
if (NS_SUCCEEDED(rv) && numFolders > 1)
{
nsString trashName;
nsAutoString trashName;
if (NS_SUCCEEDED(GetTrashFolderName(trashName)))
{
nsIMsgFolder *trashFolders[2];
@ -1757,7 +1755,7 @@ NS_IMETHODIMP nsImapIncomingServer::DiscoveryDone()
{
for (PRUint32 i = 0; i < numFolders; i++)
{
nsString folderName;
nsAutoString folderName;
if (NS_SUCCEEDED(trashFolders[i]->GetName(getter_Copies(folderName))))
{
if (!folderName.Equals(trashName))
@ -2097,7 +2095,7 @@ NS_IMETHODIMP nsImapIncomingServer::FormatStringWithHostNameByID(PRInt32 aMsgId
GetStringBundle();
if (m_stringBundle)
{
nsCString hostName;
nsCAutoString hostName;
res = GetRealHostName(hostName);
if (NS_SUCCEEDED(res))
{
@ -2408,8 +2406,7 @@ nsresult nsImapIncomingServer::RequestOverrideInfo(nsIMsgWindow *aMsgWindow)
{
nsresult rv;
nsCAutoString contractID(NS_MSGLOGONREDIRECTORSERVICE_CONTRACTID);
nsCString redirectorType;
nsCAutoString redirectorType;
GetRedirectorType(redirectorType);
contractID.Append('/');
contractID.Append(redirectorType);
@ -2420,12 +2417,11 @@ nsresult nsImapIncomingServer::RequestOverrideInfo(nsIMsgWindow *aMsgWindow)
rv = QueryInterface(NS_GET_IID(nsIMsgLogonRedirectionRequester), getter_AddRefs(logonRedirectorRequester));
if (NS_SUCCEEDED(rv))
{
nsCString password;
nsCString userName;
nsCAutoString password;
nsCAutoString userName;
PRBool requiresPassword = PR_TRUE;
GetRealUsername(userName);
m_logonRedirector->RequiresPassword(userName.get(), redirectorType.get(), &requiresPassword);
if (requiresPassword)
{
GetPassword(password);
@ -2759,10 +2755,8 @@ nsImapIncomingServer::AddTo(const nsACString &aName, PRBool addAsSubscribed,
NS_IMETHODIMP
nsImapIncomingServer::StopPopulating(nsIMsgWindow *aMsgWindow)
{
nsresult rv;
nsCOMPtr<nsISubscribeListener> listener;
rv = GetSubscribeListener(getter_AddRefs(listener));
nsresult rv = GetSubscribeListener(getter_AddRefs(listener));
NS_ENSURE_SUCCESS(rv, rv);
rv = listener->OnDonePopulating();
@ -3025,7 +3019,7 @@ nsImapIncomingServer::CreateHostSpecificPrefName(const char *prefPrefix, nsCAuto
prefName = prefPrefix;
prefName.Append('.');
prefName.Append(hostName.get());
prefName.Append(hostName);
return NS_OK;
}
@ -3431,7 +3425,7 @@ nsImapIncomingServer::OnUserOrHostNameChanged(const nsACString& oldName, const n
// reloaded (ie, DiscoverMailboxList() will be invoked in nsImapProtocol).
nsCOMPtr<nsIImapHostSessionList> hostSessionList = do_GetService(kCImapHostSessionListCID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCString serverKey;
nsCAutoString serverKey;
rv = GetKey(serverKey);
NS_ENSURE_SUCCESS(rv, rv);
hostSessionList->SetHaveWeEverDiscoveredFoldersForHost(serverKey.get(), PR_FALSE);
@ -3448,10 +3442,9 @@ nsImapIncomingServer::GetUriWithNamespacePrefixIfNecessary(PRInt32 namespaceType
nsACString& convertedUri)
{
nsresult rv = NS_OK;
nsCString serverKey;
nsCAutoString serverKey;
rv = GetKey(serverKey);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIImapHostSessionList> hostSessionList = do_GetService(kCImapHostSessionListCID, &rv);
nsIMAPNamespace *ns = nsnull;
rv = hostSessionList->GetDefaultNamespaceOfTypeForHost(serverKey.get(), (EIMAPNamespaceType)namespaceType, ns);
@ -3461,7 +3454,7 @@ nsImapIncomingServer::GetUriWithNamespacePrefixIfNecessary(PRInt32 namespaceType
if (!namespacePrefix.IsEmpty())
{
// check if namespacePrefix is the same as the online directory; if so, ignore it.
nsCString onlineDir;
nsCAutoString onlineDir;
rv = GetServerDirectory(onlineDir);
NS_ENSURE_SUCCESS(rv, rv);
if (!onlineDir.IsEmpty())
@ -3501,7 +3494,7 @@ NS_IMETHODIMP nsImapIncomingServer::GetTrashFolderName(nsAString& retval)
NS_IMETHODIMP nsImapIncomingServer::SetTrashFolderName(const nsAString& chvalue)
{
// clear trash flag from the old pref
nsString oldTrashName;
nsAutoString oldTrashName;
nsresult rv = GetTrashFolderName(oldTrashName);
if (NS_SUCCEEDED(rv))
{

Просмотреть файл

@ -7602,7 +7602,7 @@ NS_IMETHODIMP nsImapMailFolder::MatchName(nsString *name, PRBool *matches)
nsresult nsImapMailFolder::CreateBaseMessageURI(const char *aURI)
{
return nsCreateImapBaseMessageURI(aURI, &mBaseMessageURI);
return nsCreateImapBaseMessageURI(aURI, mBaseMessageURI);
}
NS_IMETHODIMP nsImapMailFolder::GetFolderURL(char **aFolderURL)

Просмотреть файл

@ -41,7 +41,6 @@
#include "nsImapOfflineSync.h"
#include "nsImapMailFolder.h"
#include "nsMsgFolderFlags.h"
#include "nsXPIDLString.h"
#include "nsIRDFService.h"
#include "nsMsgBaseCID.h"
#include "nsRDFCID.h"
@ -302,7 +301,7 @@ void nsImapOfflineSync::ProcessKeywordOperation(nsIMsgOfflineImapOperation *op)
nsMsgKeyArray matchingKeywordKeys;
PRUint32 currentKeyIndex = m_KeyIndex;
nsXPIDLCString keywords;
nsCAutoString keywords;
if (mCurrentPlaybackOpType == nsIMsgOfflineImapOperation::kAddKeywords)
currentOp->GetKeywordsToAdd(getter_Copies(keywords));
else
@ -323,7 +322,7 @@ void nsImapOfflineSync::ProcessKeywordOperation(nsIMsgOfflineImapOperation *op)
getter_AddRefs(currentOp));
if (currentOp)
{
nsXPIDLCString curOpKeywords;
nsCAutoString curOpKeywords;
nsOfflineImapOperationType operation;
currentOp->GetOperation(&operation);
if (mCurrentPlaybackOpType == nsIMsgOfflineImapOperation::kAddKeywords)
@ -394,7 +393,7 @@ nsImapOfflineSync::ProcessAppendMsgOperation(nsIMsgOfflineImapOperation *current
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), tmpFile, PR_WRONLY | PR_CREATE_FILE, 00600);
if (NS_SUCCEEDED(rv) && outputStream)
{
nsXPIDLCString moveDestination;
nsCString moveDestination;
currentOp->GetDestinationFolderURI(getter_Copies(moveDestination));
nsCOMPtr<nsIRDFService> rdf(do_GetService(kRDFServiceCID, &rv));
nsCOMPtr<nsIRDFResource> res;
@ -477,7 +476,7 @@ void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *op)
{
nsMsgKeyArray matchingFlagKeys ;
PRUint32 currentKeyIndex = m_KeyIndex;
nsXPIDLCString moveDestination;
nsCString moveDestination;
op->GetDestinationFolderURI(getter_Copies(moveDestination));
PRBool moveMatches = PR_TRUE;
nsCOMPtr <nsIMsgOfflineImapOperation> currentOp = op;
@ -494,7 +493,7 @@ void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *op)
if (++currentKeyIndex < m_CurrentKeys.GetSize())
{
nsXPIDLCString nextDestination;
nsCString nextDestination;
nsresult rv = m_currentDB->GetOfflineOpForKey(m_CurrentKeys[currentKeyIndex], PR_FALSE, getter_AddRefs(currentOp));
moveMatches = PR_FALSE;
if (NS_SUCCEEDED(rv) && currentOp)
@ -504,7 +503,7 @@ void nsImapOfflineSync::ProcessMoveOperation(nsIMsgOfflineImapOperation *op)
if (opType & nsIMsgOfflineImapOperation::kMsgMoved)
{
currentOp->GetDestinationFolderURI(getter_Copies(nextDestination));
moveMatches = nsCRT::strcmp(moveDestination, nextDestination) == 0;
moveMatches = moveDestination.Equals(nextDestination);
}
}
}
@ -591,7 +590,7 @@ void nsImapOfflineSync::ProcessCopyOperation(nsIMsgOfflineImapOperation *current
{
nsMsgKeyArray matchingFlagKeys;
PRUint32 currentKeyIndex = m_KeyIndex;
nsXPIDLCString copyDestination;
nsCString copyDestination;
currentOp->GetCopyDestination(0, getter_Copies(copyDestination));
PRBool copyMatches = PR_TRUE;
@ -607,7 +606,7 @@ void nsImapOfflineSync::ProcessCopyOperation(nsIMsgOfflineImapOperation *current
if (++currentKeyIndex < m_CurrentKeys.GetSize())
{
nsXPIDLCString nextDestination;
nsCString nextDestination;
nsresult rv = m_currentDB->GetOfflineOpForKey(m_CurrentKeys[currentKeyIndex], PR_FALSE, &currentOp);
copyMatches = PR_FALSE;
if (NS_SUCCEEDED(rv) && currentOp)
@ -617,7 +616,7 @@ void nsImapOfflineSync::ProcessCopyOperation(nsIMsgOfflineImapOperation *current
if (opType & nsIMsgOfflineImapOperation::kMsgCopy)
{
currentOp->GetCopyDestination(0, getter_Copies(nextDestination));
copyMatches = nsCRT::strcmp(copyDestination, nextDestination) == 0;
copyMatches = copyDestination.Equals(nextDestination);
}
}
}
@ -702,7 +701,7 @@ PRBool nsImapOfflineSync::CreateOfflineFolder(nsIMsgFolder *folder)
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(parent);
nsCOMPtr <nsIURI> createFolderURI;
nsXPIDLCString onlineName;
nsCString onlineName;
imapFolder->GetOnlineName(getter_Copies(onlineName));
NS_ConvertASCIItoUTF16 folderName(onlineName);

Просмотреть файл

@ -70,7 +70,6 @@
#include "nsIStreamListenerTee.h"
#include "nsXPCOMCIDInternal.h"
#include "nsNetUtil.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsIPipe.h"
#include "nsIMsgFolder.h"
@ -343,9 +342,9 @@ nsresult nsImapProtocol::GlobalInitialization()
prefBranch->GetBoolPref("mail.imap.expunge_after_delete", &gExpungeAfterDelete);
prefBranch->GetBoolPref("mail.imap.check_deleted_before_expunge", &gCheckDeletedBeforeExpunge);
prefBranch->GetIntPref("mailnews.tcptimeout", &gResponseTimeout);
nsXPIDLCString customDBHeaders;
nsCString customDBHeaders;
prefBranch->GetCharPref("mailnews.customDBHeaders", getter_Copies(customDBHeaders));
gCustomDBHeaders.ParseString(customDBHeaders, " ");
gCustomDBHeaders.ParseString(customDBHeaders.get(), " ");
return NS_OK;
}
@ -726,8 +725,7 @@ nsresult nsImapProtocol::SetupWithUrl(nsIURI * aURL, nsISupports* aConsumer)
&& socketType == nsIMsgIncomingServer::useSSL)
? SECURE_IMAP_PORT :IMAP_PORT;
}
nsCString hostName;
nsCAutoString hostName;
nsCOMPtr<nsISocketTransportService> socketService =
do_GetService(NS_SOCKETTRANSPORTSERVICE_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && aURL)
@ -1949,7 +1947,7 @@ char *nsImapProtocol::GetServerCommandTag()
void nsImapProtocol::ProcessSelectedStateURL()
{
nsXPIDLCString mailboxName;
nsCString mailboxName;
PRBool bMessageIdsAreUids = PR_TRUE;
imapMessageFlagsType msgFlags = 0;
nsCString urlHost;
@ -1973,20 +1971,20 @@ void nsImapProtocol::ProcessSelectedStateURL()
{
if (GetServerStateParser().GetSelectedMailboxName() &&
PL_strcmp(GetServerStateParser().GetSelectedMailboxName(),
mailboxName))
mailboxName.get()))
{ // we are selected in another folder
if (m_closeNeededBeforeSelect)
Close();
if (GetServerStateParser().LastCommandSuccessful())
{
selectIssued = PR_TRUE;
AutoSubscribeToMailboxIfNecessary(mailboxName);
SelectMailbox(mailboxName);
AutoSubscribeToMailboxIfNecessary(mailboxName.get());
SelectMailbox(mailboxName.get());
}
}
else if (!GetServerStateParser().GetSelectedMailboxName())
{ // why are we in the selected state with no box name?
SelectMailbox(mailboxName);
SelectMailbox(mailboxName.get());
selectIssued = PR_TRUE;
}
else
@ -2007,13 +2005,13 @@ void nsImapProtocol::ProcessSelectedStateURL()
else
{
// go to selected state
AutoSubscribeToMailboxIfNecessary(mailboxName);
SelectMailbox(mailboxName);
AutoSubscribeToMailboxIfNecessary(mailboxName.get());
SelectMailbox(mailboxName.get());
selectIssued = GetServerStateParser().LastCommandSuccessful();
}
if (selectIssued)
RefreshACLForFolderIfNecessary(mailboxName);
RefreshACLForFolderIfNecessary(mailboxName.get());
PRBool uidValidityOk = PR_TRUE;
if (GetServerStateParser().LastCommandSuccessful() && selectIssued &&
@ -2083,7 +2081,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
case nsIImapUrl::nsImapMsgDownloadForOffline:
case nsIImapUrl::nsImapMsgPreview:
{
nsXPIDLCString messageIdString;
nsCString messageIdString;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
// we don't want to send the flags back in a group
// GetServerStateParser().ResetFlagInfo(0);
@ -2094,7 +2092,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
SetProgressString(IMAP_FOLDER_RECEIVING_MESSAGE_OF);
m_progressIndex = 0;
m_progressCount = CountMessagesInIdString(messageIdString);
m_progressCount = CountMessagesInIdString(messageIdString.get());
// we need to set this so we'll get the msg from the memory cache.
if (m_imapAction == nsIImapUrl::nsImapMsgFetchPeek)
@ -2130,7 +2128,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
nsIMAPBodyShell *foundShell = nsnull;
res = m_hostSessionList->FindShellInCacheForHost(GetImapServerKey(),
GetServerStateParser().GetSelectedMailboxName(), messageIdString, modType, &foundShell);
GetServerStateParser().GetSelectedMailboxName(), messageIdString.get(), modType, &foundShell);
if (!foundShell)
{
// The shell wasn't in the cache. Deal with this case later.
@ -2148,7 +2146,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
foundShell->SetConnection(this);
GetServerStateParser().UseCachedShell(foundShell);
//Set the current uid in server state parser (in case it was used for new mail msgs earlier).
GetServerStateParser().SetCurrentResponseUID((PRUint32)atoi(messageIdString));
GetServerStateParser().SetCurrentResponseUID((PRUint32)atoi(messageIdString.get()));
foundShell->Generate(imappart);
GetServerStateParser().UseCachedShell(NULL);
}
@ -2163,7 +2161,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
else
{
// downloading a single message: try to do it by bodystructure, and/or do it by chunks
PRUint32 messageSize = GetMessageSize(messageIdString, bMessageIdsAreUids);
PRUint32 messageSize = GetMessageSize(messageIdString.get(), bMessageIdsAreUids);
// We need to check the format_out bits to see if we are allowed to leave out parts,
// or if we are required to get the whole thing. Some instances where we are allowed
// to do it by parts: when viewing a message, replying to a message, or viewing its source
@ -2206,7 +2204,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
if (bMessageIdsAreUids)
{
res = m_hostSessionList->FindShellInCacheForHost(GetImapServerKey(),
GetServerStateParser().GetSelectedMailboxName(), messageIdString, modType, &foundShell);
GetServerStateParser().GetSelectedMailboxName(), messageIdString.get(), modType, &foundShell);
if (foundShell)
{
Log("SHELL",NULL,"Loading message, using cached shell.");
@ -2214,7 +2212,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
foundShell->SetConnection(this);
GetServerStateParser().UseCachedShell(foundShell);
//Set the current uid in server state parser (in case it was used for new mail msgs earlier).
GetServerStateParser().SetCurrentResponseUID((PRUint32)atoi(messageIdString));
GetServerStateParser().SetCurrentResponseUID((PRUint32)atoi(messageIdString.get()));
foundShell->Generate(NULL);
GetServerStateParser().UseCachedShell(NULL);
}
@ -2236,7 +2234,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
&& m_imapAction != nsIImapUrl::nsImapMsgPreview
&& m_imapAction != nsIImapUrl::nsImapMsgFetchPeek)
{
PRUint32 uid = atoi(messageIdString);
PRUint32 uid = atoi(messageIdString.get());
PRInt32 index;
PRBool foundIt;
imapMessageFlagsType flags = m_flagState->GetMessageFlagsFromUID(uid, &foundIt, &index);
@ -2259,7 +2257,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
break;
case nsIImapUrl::nsImapMsgHeader:
{
nsXPIDLCString messageIds;
nsCString messageIds;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIds));
// we don't want to send the flags back in a group
@ -2275,26 +2273,26 @@ void nsImapProtocol::ProcessSelectedStateURL()
break;
case nsIImapUrl::nsImapSearch:
{
nsXPIDLCString searchCriteriaString;
nsCAutoString searchCriteriaString;
m_runningUrl->CreateSearchCriteriaString(getter_Copies(searchCriteriaString));
Search(searchCriteriaString, bMessageIdsAreUids);
Search(searchCriteriaString.get(), bMessageIdsAreUids);
// drop the results on the floor for now
}
break;
case nsIImapUrl::nsImapUserDefinedMsgCommand:
{
nsXPIDLCString messageIdString;
nsXPIDLCString command;
nsCString messageIdString;
nsCString command;
m_runningUrl->GetCommand(getter_Copies(command));
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
IssueUserDefinedMsgCommand(command, messageIdString);
IssueUserDefinedMsgCommand(command.get(), messageIdString.get());
}
break;
case nsIImapUrl::nsImapUserDefinedFetchAttribute:
{
nsXPIDLCString messageIdString;
nsXPIDLCString attribute;
nsCString messageIdString;
nsCString attribute;
m_runningUrl->GetCustomAttributeToFetch(getter_Copies(attribute));
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
@ -2308,9 +2306,9 @@ void nsImapProtocol::ProcessSelectedStateURL()
GetSupportedUserFlags(&userFlags);
if (! (userFlags & kImapMsgSupportUserFlag))
break;
nsXPIDLCString messageIdString;
nsXPIDLCString addFlags;
nsXPIDLCString subtractFlags;
nsCString messageIdString;
nsCString addFlags;
nsCString subtractFlags;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
m_runningUrl->GetCustomAddFlags(getter_Copies(addFlags));
@ -2333,13 +2331,11 @@ void nsImapProtocol::ProcessSelectedStateURL()
break;
case nsIImapUrl::nsImapDeleteMsg:
{
nsXPIDLCString messageIdString;
nsCString messageIdString;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
if (HandlingMultipleMessages(messageIdString))
ProgressEventFunctionUsingId (IMAP_DELETING_MESSAGES);
else
ProgressEventFunctionUsingId(IMAP_DELETING_MESSAGE);
ProgressEventFunctionUsingId (HandlingMultipleMessages(messageIdString) ?
IMAP_DELETING_MESSAGES :IMAP_DELETING_MESSAGE);
Store(messageIdString, "+FLAGS (\\Deleted)", bMessageIdsAreUids);
@ -2360,7 +2356,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
}
if (m_imapMessageSink)
m_imapMessageSink->NotifyMessageDeleted(canonicalName, PR_FALSE, messageIdString);
m_imapMessageSink->NotifyMessageDeleted(canonicalName, PR_FALSE, messageIdString.get());
// notice we don't wait for this to finish...
}
else
@ -2368,15 +2364,14 @@ void nsImapProtocol::ProcessSelectedStateURL()
}
break;
case nsIImapUrl::nsImapDeleteFolderAndMsgs:
DeleteFolderAndMsgs(mailboxName);
DeleteFolderAndMsgs(mailboxName.get());
break;
case nsIImapUrl::nsImapDeleteAllMsgs:
{
uint32 numberOfMessages = GetServerStateParser().NumberOfMessages();
if (numberOfMessages)
{
Store("1:*", "+FLAGS.SILENT (\\Deleted)",
Store(NS_LITERAL_CSTRING("1:*"), "+FLAGS.SILENT (\\Deleted)",
PR_FALSE); // use sequence #'s
if (GetServerStateParser().LastCommandSuccessful())
@ -2402,7 +2397,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
}
PRBool deleteSelf = PR_FALSE;
DeleteSubFolders(mailboxName, deleteSelf); // don't delete self
DeleteSubFolders(mailboxName.get(), deleteSelf); // don't delete self
}
break;
case nsIImapUrl::nsImapAppendDraftFromFile:
@ -2412,7 +2407,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
break;
case nsIImapUrl::nsImapAddMsgFlags:
{
nsXPIDLCString messageIdString;
nsCString messageIdString;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
ProcessStoreFlags(messageIdString, bMessageIdsAreUids,
@ -2421,7 +2416,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
break;
case nsIImapUrl::nsImapSubtractMsgFlags:
{
nsXPIDLCString messageIdString;
nsCString messageIdString;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
ProcessStoreFlags(messageIdString, bMessageIdsAreUids,
@ -2430,7 +2425,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
break;
case nsIImapUrl::nsImapSetMsgFlags:
{
nsXPIDLCString messageIdString;
nsCString messageIdString;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
ProcessStoreFlags(messageIdString, bMessageIdsAreUids,
@ -2445,7 +2440,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
case nsIImapUrl::nsImapOnlineCopy:
case nsIImapUrl::nsImapOnlineMove:
{
nsXPIDLCString messageIdString;
nsCString messageIdString;
m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
char *destinationMailbox = OnCreateServerDestinationFolderPathString();
@ -2464,8 +2459,7 @@ void nsImapProtocol::ProcessSelectedStateURL()
else
ProgressEventFunctionUsingIdWithString (IMAP_COPYING_MESSAGE_TO, destinationMailbox);
}
Copy(messageIdString, destinationMailbox, bMessageIdsAreUids);
Copy(messageIdString.get(), destinationMailbox, bMessageIdsAreUids);
PR_FREEIF( destinationMailbox);
ImapOnlineCopyState copyState;
if (DeathSignalReceived())
@ -2504,26 +2498,23 @@ void nsImapProtocol::ProcessSelectedStateURL()
case nsIImapUrl::nsImapOnlineToOfflineCopy:
case nsIImapUrl::nsImapOnlineToOfflineMove:
{
nsXPIDLCString messageIdString;
nsCString messageIdString;
nsresult rv = m_runningUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
if (NS_SUCCEEDED(rv))
{
SetProgressString(IMAP_FOLDER_RECEIVING_MESSAGE_OF);
m_progressIndex = 0;
m_progressCount = CountMessagesInIdString(messageIdString);
m_progressCount = CountMessagesInIdString(messageIdString.get());
FetchMessage(messageIdString,
kEveryThingRFC822Peek,
bMessageIdsAreUids);
FetchMessage(messageIdString, kEveryThingRFC822Peek, bMessageIdsAreUids);
SetProgressString(0);
if (m_imapMailFolderSink)
{
ImapOnlineCopyState copyStatus;
if (GetServerStateParser().LastCommandSuccessful())
copyStatus = ImapOnlineCopyStateType::kSuccessfulCopy;
else
copyStatus = ImapOnlineCopyStateType::kFailedCopy;
copyStatus = GetServerStateParser().LastCommandSuccessful() ?
ImapOnlineCopyStateType::kSuccessfulCopy : ImapOnlineCopyStateType::kFailedCopy;
m_imapMailFolderSink->OnlineCopyCompleted(this, copyStatus);
if (GetServerStateParser().LastCommandSuccessful() &&
(m_imapAction == nsIImapUrl::nsImapOnlineToOfflineMove))
@ -2772,7 +2763,7 @@ void nsImapProtocol::SelectMailbox(const char *mailboxName)
}
// Please call only with a single message ID
void nsImapProtocol::Bodystructure(const char *messageId, PRBool idIsUid)
void nsImapProtocol::Bodystructure(const nsCString &messageId, PRBool idIsUid)
{
IncrementCommandTagNumber();
@ -2855,7 +2846,7 @@ void nsImapProtocol::PipelinedFetchMessageParts(const char *uid, nsIMAPMessagePa
}
void nsImapProtocol::FetchMsgAttribute(const char * messageIds, const char *attribute)
void nsImapProtocol::FetchMsgAttribute(const nsCString &messageIds, const nsCString &attribute)
{
IncrementCommandTagNumber();
@ -2876,7 +2867,7 @@ void nsImapProtocol::FetchMsgAttribute(const char * messageIds, const char *attr
// this routine is used to fetch a message or messages, or headers for a
// message...
void nsImapProtocol::FallbackToFetchWholeMsg(const char *messageId, PRUint32 messageSize)
void nsImapProtocol::FallbackToFetchWholeMsg(const nsCString &messageId, PRUint32 messageSize)
{
if (m_imapMessageSink && m_runningUrl)
{
@ -2889,7 +2880,7 @@ void nsImapProtocol::FallbackToFetchWholeMsg(const char *messageId, PRUint32 mes
}
void
nsImapProtocol::FetchMessage(const char * messageIds,
nsImapProtocol::FetchMessage(const nsCString &messageIds,
nsIMAPeFetchFields whatToFetch,
PRBool idIsUid,
PRUint32 startByte, PRUint32 endByte,
@ -2989,7 +2980,7 @@ nsImapProtocol::FetchMessage(const char * messageIds,
char *headersToDL = nsnull;
char *what = nsnull;
const char *dbHeaders = (gUseEnvelopeCmd) ? IMAP_DB_HEADERS : IMAP_ENV_AND_DB_HEADERS;
nsXPIDLCString arbitraryHeaders;
nsCString arbitraryHeaders;
GetArbitraryHeadersToDownload(getter_Copies(arbitraryHeaders));
for (PRInt32 i = 0; i < gCustomDBHeaders.Count(); i++)
{
@ -3001,7 +2992,7 @@ nsImapProtocol::FetchMessage(const char * messageIds,
}
}
if (arbitraryHeaders.IsEmpty())
headersToDL = nsCRT::strdup(dbHeaders);
headersToDL = strdup(dbHeaders);
else
headersToDL = PR_smprintf("%s %s",dbHeaders, arbitraryHeaders.get());
@ -3099,7 +3090,7 @@ nsImapProtocol::FetchMessage(const char * messageIds,
// since messageIds can be infinitely long, use a dynamic buffer rather than the fixed one
const char *commandTag = GetServerCommandTag();
int protocolStringSize = commandString.Length() + strlen(messageIds) + PL_strlen(commandTag) + 1 +
int protocolStringSize = commandString.Length() + messageIds.Length() + PL_strlen(commandTag) + 1 +
(part ? PL_strlen(part) : 0);
char *protocolString = (char *) PR_CALLOC( protocolStringSize );
@ -3113,7 +3104,7 @@ nsImapProtocol::FetchMessage(const char * messageIds,
protocolStringSize, // max size
cCommandStr, // format string
commandTag, // command tag
messageIds,
messageIds.get(),
part);
}
else
@ -3122,7 +3113,7 @@ nsImapProtocol::FetchMessage(const char * messageIds,
protocolStringSize, // max size
cCommandStr, // format string
commandTag, // command tag
messageIds);
messageIds.get());
}
nsresult rv = SendData(protocolString);
@ -3140,7 +3131,7 @@ nsImapProtocol::FetchMessage(const char * messageIds,
HandleMemoryFailure();
}
void nsImapProtocol::FetchTryChunking(const char * messageIds,
void nsImapProtocol::FetchTryChunking(const nsCString &messageIds,
nsIMAPeFetchFields whatToFetch,
PRBool idIsUid,
char *part,
@ -3602,7 +3593,7 @@ void nsImapProtocol::ProcessMailboxUpdate(PRBool handlePossibleUndo)
if (handlePossibleUndo)
{
// undo any delete flags we may have asked to
nsXPIDLCString undoIdsStr;
nsCString undoIdsStr;
nsCAutoString undoIds;
GetCurrentUrl()->CreateListOfMessageIdsString(getter_Copies(undoIdsStr));
@ -3614,9 +3605,9 @@ void nsImapProtocol::ProcessMailboxUpdate(PRBool handlePossibleUndo)
// if this string started with a '-', then this is an undo of a delete
// if its a '+' its a redo
if (firstChar == '-')
Store(undoIds.get(), "-FLAGS (\\Deleted)", PR_TRUE); // most servers will fail silently on a failure, deal with it?
Store(undoIds, "-FLAGS (\\Deleted)", PR_TRUE); // most servers will fail silently on a failure, deal with it?
else if (firstChar == '+')
Store(undoIds.get(), "+FLAGS (\\Deleted)", PR_TRUE); // most servers will fail silently on a failure, deal with it?
Store(undoIds, "+FLAGS (\\Deleted)", PR_TRUE); // most servers will fail silently on a failure, deal with it?
else
NS_ASSERTION(PR_FALSE, "bogus undo Id's");
}
@ -3632,7 +3623,7 @@ void nsImapProtocol::ProcessMailboxUpdate(PRBool handlePossibleUndo)
if (!added || (added == deleted))
{
nsCString idsToFetch("1:*");
FetchMessage(idsToFetch.get(), kFlags, PR_TRUE); // id string shows uids
FetchMessage(idsToFetch, kFlags, PR_TRUE); // id string shows uids
// lets see if we should expunge during a full sync of flags.
if (!DeathSignalReceived()) // only expunge if not reading messages manually and before fetching new
{
@ -3650,7 +3641,7 @@ void nsImapProtocol::ProcessMailboxUpdate(PRBool handlePossibleUndo)
fetchStr.Append(":*");
// sprintf(fetchStr, "%ld:*", GetServerStateParser().HighestRecordedUID() + 1);
FetchMessage(fetchStr.get(), kFlags, PR_TRUE); // only new messages please
FetchMessage(fetchStr, kFlags, PR_TRUE); // only new messages please
}
}
else if (!DeathSignalReceived())
@ -3849,7 +3840,7 @@ void nsImapProtocol::FolderMsgDumpLoop(PRUint32 *msgUids, PRUint32 msgCount, nsI
PRUint32 msgsToDownload = msgCountLeft;
AllocateImapUidString(msgUids + msgsDownloaded, msgsToDownload, m_flagState, idString); // 20 * 200
FetchMessage(idString.get(), fields, PR_TRUE); // msg ids are uids
FetchMessage(idString, fields, PR_TRUE); // msg ids are uids
msgsDownloaded += msgsToDownload;
msgCountLeft -= msgsToDownload;
@ -3900,8 +3891,7 @@ void nsImapProtocol::PeriodicBiff()
//sprintf(fetchStr, "%ld:%ld", id, id + GetServerStateParser().NumberOfMessages() - fFlagState->GetNumberOfMessages());
fetchStr.AppendInt(id);
fetchStr.Append(":*");
FetchMessage(fetchStr.get(), kFlags, PR_TRUE);
FetchMessage(fetchStr, kFlags, PR_TRUE);
if (((PRUint32) m_flagState->GetHighestNonDeletedUID() >= id) && m_flagState->IsLastMessageUnseen())
m_currentBiffState = nsIMsgFolder::nsMsgBiffState_NewMail;
else
@ -4009,9 +3999,9 @@ void nsImapProtocol::Log(const char *logSubName, const char *extraInfo, const ch
}
if (extraInfo)
PR_LOG(IMAP, PR_LOG_ALWAYS, ("%x:%s:%s:%s:%s: %.400s", this,hostName,stateName,logSubName,extraInfo,logDataToLog));
PR_LOG(IMAP, PR_LOG_ALWAYS, ("%x:%s:%s:%s:%s: %.400s", this,hostName.get(),stateName,logSubName,extraInfo,logDataToLog));
else
PR_LOG(IMAP, PR_LOG_ALWAYS, ("%x:%s:%s:%s: %.400s",this,hostName,stateName,logSubName,logDataToLog));
PR_LOG(IMAP, PR_LOG_ALWAYS, ("%x:%s:%s:%s: %.400s",this,hostName.get(),stateName,logSubName,logDataToLog));
// dump the rest of the string in < 400 byte chunks
while (logDataLen > kLogDataChunkSize)
@ -4075,10 +4065,9 @@ PRUint32 nsImapProtocol::GetMessageSize(const char * messageId,
}
// message id string utility functions
/* static */PRBool nsImapProtocol::HandlingMultipleMessages(const char *messageIdString)
/* static */PRBool nsImapProtocol::HandlingMultipleMessages(const nsCString & messageIdString)
{
return (PL_strchr(messageIdString,',') != nsnull ||
PL_strchr(messageIdString,':') != nsnull);
return (messageIdString.FindCharInSet(",:") != kNotFound);
}
PRUint32 nsImapProtocol::CountMessagesInIdString(const char *idString)
@ -4715,16 +4704,14 @@ nsImapProtocol::ShowProgress()
PRUnichar *progressString = NULL;
nsCAutoString cProgressString; cProgressString.AssignWithConversion(m_progressString);
const char *mailboxName = GetServerStateParser().GetSelectedMailboxName();
nsXPIDLString unicodeMailboxName;
nsString unicodeMailboxName;
nsresult rv = CopyMUTF7toUTF16(nsDependentCString(mailboxName),
unicodeMailboxName);
if (NS_SUCCEEDED(rv))
{
// ### should convert mailboxName to PRUnichar and change %s to %S in msg text
progressString = nsTextFormatter::smprintf(m_progressString.get(), (const PRUnichar *) unicodeMailboxName,
++m_progressIndex, m_progressCount);
progressString = nsTextFormatter::smprintf(m_progressString.get(),
unicodeMailboxName.get(), ++m_progressIndex, m_progressCount);
if (progressString)
{
PercentProgressUpdateEvent(progressString, m_progressIndex, m_progressCount);
@ -4751,10 +4738,10 @@ nsImapProtocol::ProgressEventFunctionUsingIdWithString(PRUint32 aMsgId, const
{
if (m_imapMailFolderSink)
{
nsXPIDLString unicodeStr;
nsString unicodeStr;
nsresult rv = CopyMUTF7toUTF16(nsDependentCString(aExtraInfo), unicodeStr);
if (NS_SUCCEEDED(rv))
m_imapMailFolderSink->ProgressStatus(this, aMsgId, unicodeStr);
m_imapMailFolderSink->ProgressStatus(this, aMsgId, unicodeStr.get());
}
}
@ -4794,7 +4781,7 @@ nsImapProtocol::PercentProgressUpdateEvent(PRUnichar *message, PRInt32 currentPr
// imap commands issued by the parser
void
nsImapProtocol::Store(const char * messageList, const char * messageData,
nsImapProtocol::Store(const nsCString &messageList, const char * messageData,
PRBool idsAreUid)
{
@ -4803,7 +4790,7 @@ nsImapProtocol::Store(const char * messageList, const char * messageData,
nsCString messageIdList;
nsMsgKeyArray msgKeys;
if (idsAreUid)
ParseUidString(messageList, msgKeys);
ParseUidString(messageList.get(), msgKeys);
PRInt32 msgCountLeft = msgKeys.GetSize();
PRUint32 msgsHandled = 0;
@ -4834,7 +4821,7 @@ nsImapProtocol::Store(const char * messageList, const char * messageData,
const char *commandTag = GetServerCommandTag();
int protocolStringSize = PL_strlen(formatString) +
PL_strlen(messageList) + PL_strlen(messageData) +
messageList.Length() + PL_strlen(messageData) +
PL_strlen(commandTag) + 1;
char *protocolString = (char *) PR_CALLOC( protocolStringSize );
@ -4897,7 +4884,7 @@ nsImapProtocol::IssueUserDefinedMsgCommand(const char *command, const char * mes
}
void
nsImapProtocol::UidExpunge(const char* messageSet)
nsImapProtocol::UidExpunge(const nsCString &messageSet)
{
IncrementCommandTagNumber();
nsCString command(GetServerCommandTag());
@ -5069,7 +5056,7 @@ void nsImapProtocol::EscapeUserNamePasswordString(const char *strToEscape, nsCSt
}
}
void nsImapProtocol::InsecureLogin(const char *userName, const char *password)
void nsImapProtocol::InsecureLogin(const char *userName, const nsCString &password)
{
ProgressEventFunctionUsingId (IMAP_STATUS_SENDING_LOGIN);
IncrementCommandTagNumber();
@ -5083,7 +5070,7 @@ void nsImapProtocol::InsecureLogin(const char *userName, const char *password)
// if the password contains a \, login will fail
// turn foo\bar into foo\\bar
nsCAutoString correctedPassword;
EscapeUserNamePasswordString(password, &correctedPassword);
EscapeUserNamePasswordString(password.get(), &correctedPassword);
command.Append(correctedPassword);
command.Append("\""CRLF);
@ -5093,7 +5080,7 @@ void nsImapProtocol::InsecureLogin(const char *userName, const char *password)
ParseIMAPandCheckForNewMail();
}
nsresult nsImapProtocol::AuthLogin(const char *userName, const char *password, eIMAPCapabilityFlag flag)
nsresult nsImapProtocol::AuthLogin(const char *userName, const nsCString &password, eIMAPCapabilityFlag flag)
{
ProgressEventFunctionUsingId (IMAP_STATUS_SENDING_AUTH_LOGIN);
IncrementCommandTagNumber();
@ -5115,7 +5102,7 @@ nsresult nsImapProtocol::AuthLogin(const char *userName, const char *password, e
char * decodedChallenge = PL_Base64Decode(cramDigest,
strlen(cramDigest), nsnull);
if (m_imapServerSink)
rv = m_imapServerSink->CramMD5Hash(decodedChallenge, password, &digest);
rv = m_imapServerSink->CramMD5Hash(decodedChallenge, password.get(), &digest);
PR_Free(decodedChallenge);
if (NS_SUCCEEDED(rv) && digest)
@ -5203,7 +5190,7 @@ nsresult nsImapProtocol::AuthLogin(const char *userName, const char *password, e
if (GetServerStateParser().LastCommandSuccessful())
{
nsCAutoString cmd;
rv = DoNtlmStep1(userName, password, cmd);
rv = DoNtlmStep1(userName, password.get(), cmd);
if (NS_SUCCEEDED(rv))
{
cmd += CRLF;
@ -5244,9 +5231,8 @@ nsresult nsImapProtocol::AuthLogin(const char *userName, const char *password, e
PR_snprintf(&plainstr[1], 510, "%s", userName);
len += PL_strlen(userName);
len++; // count for second <NUL> char
PR_snprintf(&plainstr[len], 511-len, "%s", password);
len += PL_strlen(password);
PR_snprintf(&plainstr[len], 511-len, "%s", password.get());
len += password.Length();
char *base64Str = PL_Base64Encode(plainstr, len, nsnull);
if (base64Str)
{
@ -5285,7 +5271,7 @@ nsresult nsImapProtocol::AuthLogin(const char *userName, const char *password, e
}
if (GetServerStateParser().LastCommandSuccessful())
{
base64Str = PL_Base64Encode((char*)password, PL_strlen(password), nsnull);
base64Str = PL_Base64Encode(password.get(), password.Length(), nsnull);
PR_snprintf(m_dataOutputBuf, OUTPUT_BUFFER_SIZE, "%s" CRLF, base64Str);
PR_Free(base64Str);
rv = SendData(m_dataOutputBuf, PR_TRUE /* suppress logging */);
@ -5346,7 +5332,7 @@ void nsImapProtocol::OnAppendMsgFromFile()
imapMessageFlagsType flagsToSet = 0;
PRUint32 msgFlags = 0;
PRTime date = 0;
nsXPIDLCString keywords;
nsCString keywords;
if (m_imapMessageSink)
m_imapMessageSink->GetCurMoveCopyMessageInfo(m_runningUrl, &date,
getter_Copies(keywords), &msgFlags);
@ -5510,7 +5496,7 @@ void nsImapProtocol::UploadMessageFromFile (nsIFile* file,
if (FolderIsSelected(mailboxName))
Noop();
nsXPIDLCString oldMsgId;
nsCString oldMsgId;
rv = m_runningUrl->CreateListOfMessageIdsString(getter_Copies(oldMsgId));
if (NS_SUCCEEDED(rv) && !oldMsgId.IsEmpty())
{
@ -5673,7 +5659,7 @@ void nsImapProtocol::OnEnsureExistsFolder(const char * aSourceMailbox)
aSourceMailbox, nsForMailbox);
// NS_ASSERTION (nsForMailbox, "Oops .. null nsForMailbox\n");
nsXPIDLCString name;
nsCString name;
if (nsForMailbox)
m_runningUrl->AllocateCanonicalPath(aSourceMailbox,
@ -5784,7 +5770,7 @@ void nsImapProtocol::RefreshACLForFolder(const char *mailboxName)
void nsImapProtocol::RefreshFolderACLView(const char *mailboxName, nsIMAPNamespace *nsForMailbox)
{
nsXPIDLCString canonicalMailboxName;
nsCString canonicalMailboxName;
if (nsForMailbox)
m_runningUrl->AllocateCanonicalPath(mailboxName, nsForMailbox->GetDelimiter(), getter_Copies(canonicalMailboxName));
@ -6443,7 +6429,7 @@ void nsImapProtocol::RemoveMsgsAndExpunge()
if (numberOfMessages)
{
// Remove all msgs and expunge the folder (ie, compact it).
Store("1:*", "+FLAGS.SILENT (\\Deleted)", PR_FALSE); // use sequence #'s
Store(NS_LITERAL_CSTRING("1:*"), "+FLAGS.SILENT (\\Deleted)", PR_FALSE); // use sequence #'s
if (GetServerStateParser().LastCommandSuccessful())
Expunge();
}
@ -7005,7 +6991,7 @@ const char * nsImapProtocol::GetTrashFolderName()
nsCOMPtr<nsIImapIncomingServer> server = do_QueryReferent(m_server);
if (server)
{
nsString trashFolderName;
nsAutoString trashFolderName;
if (NS_SUCCEEDED(server->GetTrashFolderName(trashFolderName)))
CopyUTF16toMUTF7(trashFolderName, m_trashFolderName);
}
@ -7456,7 +7442,7 @@ void nsImapProtocol::SetupMessageFlagsString(nsCString& flagString,
flagString.SetLength(flagString.Length()-1);
}
void nsImapProtocol::ProcessStoreFlags(const char * messageIdsString,
void nsImapProtocol::ProcessStoreFlags(const nsCString &messageIdsString,
PRBool idsAreUids,
imapMessageFlagsType flags,
PRBool addFlags)
@ -7608,8 +7594,8 @@ PRBool nsImapProtocol::TryToLogon()
PRInt32 logonTries = 0;
PRBool loginSucceeded = PR_FALSE;
PRBool clientSucceeded = PR_TRUE;
nsCString password;
nsCString userName;
nsCAutoString password;
nsCAutoString userName;
nsresult rv = NS_OK;
// get the password and user name for the current incoming server...
@ -7687,38 +7673,38 @@ PRBool nsImapProtocol::TryToLogon()
// all subsequent login attempts to fail (bug 231303, bug 227560)
if (m_useSecAuth && GetServerStateParser().GetCapabilityFlag() & kHasAuthGssApiCapability)
{
clientSucceeded = NS_SUCCEEDED(AuthLogin(userName.get(), password.get(), kHasAuthGssApiCapability));
clientSucceeded = NS_SUCCEEDED(AuthLogin(userName.get(), password, kHasAuthGssApiCapability));
}
else if (m_useSecAuth && GetServerStateParser().GetCapabilityFlag() & kHasCRAMCapability)
{
AuthLogin (userName.get(), password.get(), kHasCRAMCapability);
AuthLogin (userName.get(), password, kHasCRAMCapability);
logonTries++;
}
else if (m_useSecAuth && GetServerStateParser().GetCapabilityFlag() & kHasAuthNTLMCapability)
{
AuthLogin (userName.get(), password.get(), kHasAuthNTLMCapability);
AuthLogin (userName.get(), password, kHasAuthNTLMCapability);
logonTries++;
}
else if (m_useSecAuth && GetServerStateParser().GetCapabilityFlag() & kHasAuthMSNCapability)
{
AuthLogin (userName.get(), password.get(), kHasAuthMSNCapability);
AuthLogin (userName.get(), password, kHasAuthMSNCapability);
logonTries++;
}
else if (GetServerStateParser().GetCapabilityFlag() & kHasAuthPlainCapability)
{
AuthLogin (userName.get(), password.get(), kHasAuthPlainCapability);
AuthLogin (userName.get(), password, kHasAuthPlainCapability);
logonTries++;
}
else if (GetServerStateParser().GetCapabilityFlag() & kHasAuthLoginCapability)
{
AuthLogin (userName.get(), password.get(), kHasAuthLoginCapability);
AuthLogin (userName.get(), password, kHasAuthLoginCapability);
logonTries++; // This counts as a logon try for most servers
}
else if (! (GetServerStateParser().GetCapabilityFlag() & kLoginDisabled))
InsecureLogin(userName.get(), password.get());
InsecureLogin(userName.get(), password);
}
else if (! (GetServerStateParser().GetCapabilityFlag() & kLoginDisabled))
InsecureLogin(userName.get(), password.get());
InsecureLogin(userName.get(), password);
if (!clientSucceeded || !GetServerStateParser().LastCommandSuccessful())
{
@ -7815,7 +7801,7 @@ void nsImapProtocol::GetQuotaDataIfSupported(const char *aBoxName)
nsCOMPtr<nsIImapIncomingServer> imapServer = do_QueryReferent(m_server, &rv);
if (NS_FAILED(rv))
return;
nsCString redirectorType;
nsCAutoString redirectorType;
imapServer->GetRedirectorType(redirectorType);
if (redirectorType.EqualsLiteral("aol") && PL_strcasecmp("Inbox", aBoxName))
return;
@ -8312,9 +8298,9 @@ nsresult nsImapMockChannel::ReadFromMemCache(nsICacheEntryDescriptor *entry)
NS_ENSURE_ARG(entry);
PRUint32 annotationLength = 0;
nsXPIDLCString annotation;
nsCString annotation;
nsCAutoString entryKey;
nsXPIDLCString contentType;
nsCAutoString contentType;
nsresult rv = NS_OK;
PRBool shouldUseCacheEntry = PR_FALSE;
@ -8331,12 +8317,9 @@ nsresult nsImapMockChannel::ReadFromMemCache(nsICacheEntryDescriptor *entry)
{
// otherwise, we have the whole msg, and we should make sure the content isn't modified.
rv = entry->GetMetaDataElement("ContentModified", getter_Copies(annotation));
if (NS_SUCCEEDED(rv) && (annotation.get()))
{
annotationLength = strlen(annotation.get());
if (annotationLength == strlen("Not Modified") && !nsCRT::strncmp(annotation, "Not Modified", annotationLength))
shouldUseCacheEntry = PR_TRUE;
}
if (NS_SUCCEEDED(rv) && !annotation.IsEmpty())
shouldUseCacheEntry = annotation.EqualsLiteral("Not Modified");
}
if (shouldUseCacheEntry)
{
@ -8423,7 +8406,7 @@ PRBool nsImapMockChannel::ReadFromLocalCache()
mailnewsUrl->GetMsgIsInLocalCache(&useLocalCache);
if (useLocalCache)
{
nsXPIDLCString messageIdString;
nsCAutoString messageIdString;
SetupPartExtractorListener(imapUrl, m_channelListener);
@ -8434,7 +8417,7 @@ PRBool nsImapMockChannel::ReadFromLocalCache()
{
// we want to create a file channel and read the msg from there.
nsCOMPtr<nsIInputStream> fileStream;
nsMsgKey msgKey = atoi(messageIdString);
nsMsgKey msgKey = atoi(messageIdString.get());
PRUint32 size, offset;
rv = folder->GetOfflineFileStream(msgKey, &offset, &size, getter_AddRefs(fileStream));
// get the file channel from the folder, somehow (through the message or

Просмотреть файл

@ -78,7 +78,6 @@
#include "nsILoadGroup.h"
#include "nsCOMPtr.h"
#include "nsIImapIncomingServer.h"
#include "nsXPIDLString.h"
#include "nsIMsgWindow.h"
#include "nsIMsgLogonRedirector.h"
#include "nsICacheListener.h"
@ -175,8 +174,7 @@ public:
// message id string utilities.
PRUint32 CountMessagesInIdString(const char *idString);
static PRBool HandlingMultipleMessages(const char *messageIdString);
static PRBool HandlingMultipleMessages(const nsCString &messageIdString);
// escape slashes and double quotes in username/passwords for insecure login.
static void EscapeUserNamePasswordString(const char *strToEscape, nsCString *resultStr);
@ -184,20 +182,19 @@ public:
void GetShouldDownloadAllHeaders(PRBool *aResult);
void GetArbitraryHeadersToDownload(char **aResult);
virtual void AdjustChunkSize();
virtual void FetchMessage(const char * messageIds,
virtual void FetchMessage(const nsCString &messageIds,
nsIMAPeFetchFields whatToFetch,
PRBool idAreUid,
PRUint32 startByte = 0, PRUint32 endByte = 0,
char *part = 0);
void FetchTryChunking(const char * messageIds,
void FetchTryChunking(const nsCString &messageIds,
nsIMAPeFetchFields whatToFetch,
PRBool idIsUid,
char *part,
PRUint32 downloadSize,
PRBool tryChunking);
virtual void PipelinedFetchMessageParts(nsCString &uid, nsIMAPMessagePartIDArray *parts);
void FallbackToFetchWholeMsg(const char *messageId, PRUint32 messageSize);
void FallbackToFetchWholeMsg(const nsCString &messageId, PRUint32 messageSize);
// used when streaming a message fetch
virtual nsresult BeginMessageDownLoad(PRUint32 totalSize, // for user, headers and body
const char *contentType); // some downloads are header only
@ -266,16 +263,16 @@ public:
void Search(const char * searchCriteria, PRBool useUID,
PRBool notifyHit = PR_TRUE);
// imap commands issued by the parser
void Store(const char * aMessageList, const char * aMessageData, PRBool
void Store(const nsCString &aMessageList, const char * aMessageData, PRBool
aIdsAreUid);
void ProcessStoreFlags(const char * messageIds,
void ProcessStoreFlags(const nsCString &messageIds,
PRBool idsAreUids,
imapMessageFlagsType flags,
PRBool addFlags);
void IssueUserDefinedMsgCommand(const char *command, const char * messageList);
void FetchMsgAttribute(const char * messageIds, const char *attribute);
void FetchMsgAttribute(const nsCString &messageIds, const nsCString &attribute);
void Expunge();
void UidExpunge(const char* messageSet);
void UidExpunge(const nsCString &messageSet);
void Close(PRBool shuttingDown = PR_FALSE, PRBool waitForResponse = PR_TRUE);
void Check();
void SelectMailbox(const char *mailboxName);
@ -289,7 +286,7 @@ public:
void MailboxData();
void GetMyRightsForFolder(const char *mailboxName);
void AutoSubscribeToMailboxIfNecessary(const char *mailboxName);
void Bodystructure(const char *messageId, PRBool idIsUid);
void Bodystructure(const nsCString &messageId, PRBool idIsUid);
void PipelinedFetchMessageParts(const char *uid, nsIMAPMessagePartIDArray *parts);
@ -458,8 +455,8 @@ private:
void Capability(); // query host for capabilities.
void Language(); // set the language on the server if it supports it
void Namespace();
void InsecureLogin(const char *userName, const char *password);
nsresult AuthLogin(const char *userName, const char *password, eIMAPCapabilityFlag flag);
void InsecureLogin(const char *userName, const nsCString &password);
nsresult AuthLogin(const char *userName, const nsCString &password, eIMAPCapabilityFlag flag);
void ProcessAuthenticatedStateURL();
void ProcessAfterAuthenticated();
void ProcessSelectedStateURL();
@ -571,7 +568,7 @@ private:
nsCString m_logonCookie;
PRInt16 m_logonPort;
nsXPIDLString mAcceptLanguages;
nsString mAcceptLanguages;
// progress stuff
void SetProgressString(PRInt32 stringId);

Просмотреть файл

@ -444,7 +444,7 @@ void nsImapServerResponseParser::ProcessOkCommand(const char *commandToken)
if (!fZeroLengthMessageUidString.IsEmpty())
{
// "Deleting zero length message");
fServerConnection.Store(fZeroLengthMessageUidString.get(), "+Flags (\\Deleted)", PR_TRUE);
fServerConnection.Store(fZeroLengthMessageUidString, "+Flags (\\Deleted)", PR_TRUE);
if (LastCommandSuccessful())
fServerConnection.Expunge();
@ -722,7 +722,7 @@ void nsImapServerResponseParser::response_data()
else
{
// check if custom command
nsXPIDLCString customCommand;
nsCAutoString customCommand;
fServerConnection.GetCurrentUrl()->GetCommand(getter_Copies(customCommand));
if (customCommand.Equals(fNextToken))
{
@ -1298,7 +1298,7 @@ void nsImapServerResponseParser::msg_fetch()
if (!fServerConnection.GetCurrentUrl())
return;
fServerConnection.GetCurrentUrl()->GetImapAction(&imapAction);
nsXPIDLCString userDefinedFetchAttribute;
nsCAutoString userDefinedFetchAttribute;
fServerConnection.GetCurrentUrl()->GetCustomAttributeToFetch(getter_Copies(userDefinedFetchAttribute));
if (imapAction == nsIImapUrl::nsImapUserDefinedFetchAttribute && !strcmp(userDefinedFetchAttribute.get(), fNextToken))
{
@ -1407,12 +1407,10 @@ void nsImapServerResponseParser::envelope_data()
PRBool headerNonNil = PR_TRUE;
if (EnvelopeTable[tableIndex].type == envelopeString)
{
nsXPIDLCString strValue;
nsCAutoString strValue;
strValue.Adopt(CreateNilString());
if (strValue)
{
if (!strValue.IsEmpty())
headerLine.Append(strValue);
}
else
headerNonNil = PR_FALSE;
}
@ -1444,7 +1442,7 @@ void nsImapServerResponseParser::xaolenvelope_data()
{
AdvanceToNextToken();
fNextToken++; // eat '('
nsXPIDLCString subject;
nsCAutoString subject;
subject.Adopt(CreateNilString());
nsCAutoString subjectLine("Subject: ");
subjectLine += subject;

Просмотреть файл

@ -57,7 +57,6 @@
#include "nsIDocShell.h"
#include "nsIDocShellLoadInfo.h"
#include "nsIRDFService.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsRDFCID.h"
#include "nsEscape.h"
@ -166,7 +165,7 @@ nsImapService::GetFolderName(nsIMsgFolder* aImapFolder,
nsresult rv;
nsCOMPtr<nsIMsgImapMailFolder> aFolder(do_QueryInterface(aImapFolder, &rv));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString onlineName;
nsCString onlineName;
// online name is in imap utf-7 - leave it that way
rv = aFolder->GetOnlineName(getter_Copies(onlineName));
@ -187,15 +186,15 @@ nsImapService::GetFolderName(nsIMsgFolder* aImapFolder,
// otherwise, we do want to escape slashes.
// we want to escape slashes and '^' first, otherwise, nsEscape will lose them
PRBool escapeSlashes = (GetHierarchyDelimiter(aImapFolder) != (PRUnichar) '/');
if (escapeSlashes && (const char *) onlineName)
if (escapeSlashes && !onlineName.IsEmpty())
{
char* escapedOnlineName;
rv = nsImapUrl::EscapeSlashes((const char *) onlineName, &escapedOnlineName);
rv = nsImapUrl::EscapeSlashes(onlineName.get(), &escapedOnlineName);
if (NS_SUCCEEDED(rv))
onlineName.Adopt(escapedOnlineName);
}
// need to escape everything else
*folderName = nsEscape((const char *) onlineName, url_Path);
*folderName = nsEscape(onlineName.get(), url_Path);
return rv;
}
@ -244,11 +243,11 @@ nsImapService::SelectFolder(nsIEventTarget * aClientEventTarget,
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append("/select>");
urlSpec.Append(char(hierarchySeparator));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
rv = mailNewsUrl->SetSpec(urlSpec);
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventTarget,
@ -282,7 +281,7 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
nsCAutoString msgKey;
rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey));
if (NS_SUCCEEDED(rv))
{
@ -295,7 +294,7 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr <nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(imapUrl);
PRBool useLocalCache = PR_FALSE;
folder->HasMsgOffline(atoi(msgKey), &useLocalCache);
folder->HasMsgOffline(atoi(msgKey.get()), &useLocalCache);
mailnewsUrl->SetMsgIsInLocalCache(useLocalCache);
nsCOMPtr<nsIURI> url = do_QueryInterface(imapUrl);
@ -303,9 +302,9 @@ NS_IMETHODIMP nsImapService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL
urlSpec.Append("fetch>UID>");
urlSpec.Append(char(hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(folder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(msgKey);
rv = url->SetSpec(urlSpec);
@ -359,8 +358,8 @@ NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType,
}
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
nsXPIDLCString uriMimePart;
nsCAutoString msgKey;
nsCAutoString uriMimePart;
nsCAutoString folderURI;
nsMsgKey key;
@ -381,14 +380,14 @@ NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType,
urlSpec.Append("/fetch>UID>");
urlSpec.Append(char(hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(folder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(msgKey.get());
urlSpec.Append(uriMimePart.get());
if (uriMimePart)
if (!uriMimePart.IsEmpty())
{
nsCOMPtr<nsIMsgMailNewsUrl> mailUrl (do_QueryInterface(imapUrl));
if (mailUrl)
@ -397,7 +396,7 @@ NS_IMETHODIMP nsImapService::OpenAttachment(const char *aContentType,
mailUrl->SetFileName(nsDependentCString(aFileName));
}
rv = FetchMimePart(imapUrl, nsIImapUrl::nsImapOpenMimePart, folder, imapMessageSink,
nsnull, aDisplayConsumer, msgKey, uriMimePart);
nsnull, aDisplayConsumer, msgKey.get(), uriMimePart.get());
}
} // if we got a message sink
} // if we parsed the message uri
@ -409,8 +408,8 @@ NS_IMETHODIMP nsImapService::FetchMimePart(nsIURI *aURI, const char *aMessageURI
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
nsXPIDLCString mimePart;
nsCAutoString msgKey;
nsCAutoString mimePart;
nsCAutoString folderURI;
nsMsgKey key;
@ -427,10 +426,10 @@ NS_IMETHODIMP nsImapService::FetchMimePart(nsIURI *aURI, const char *aMessageURI
msgurl->SetMsgWindow(aMsgWindow);
msgurl->RegisterListener(aUrlListener);
if (mimePart)
if (!mimePart.IsEmpty())
{
return FetchMimePart(imapUrl, nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink,
aURL, aDisplayConsumer, msgKey, mimePart);
aURL, aDisplayConsumer, msgKey.get(), mimePart.get());
}
}
}
@ -446,8 +445,8 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI,
{
nsresult rv = NS_OK;
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
nsXPIDLCString mimePart;
nsCAutoString msgKey;
nsCAutoString mimePart;
nsCAutoString folderURI;
nsMsgKey key;
nsCAutoString messageURI(aMessageURI);
@ -496,10 +495,10 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI,
rv = CreateStartOfImapUrl(aMessageURI, getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
if (NS_FAILED(rv))
return rv;
if (mimePart)
if (!mimePart.IsEmpty())
{
return FetchMimePart(imapUrl, nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink,
aURL, aDisplayConsumer, msgKey, mimePart);
aURL, aDisplayConsumer, msgKey.get(), mimePart.get());
}
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(imapUrl));
@ -514,7 +513,7 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI,
nsCOMPtr<nsIMsgIncomingServer> aMsgIncomingServer;
if (imapMessageSink)
imapMessageSink->GetMessageSizeFromDB(msgKey, PR_TRUE, &messageSize);
imapMessageSink->GetMessageSizeFromDB(msgKey.get(), PR_TRUE, &messageSize);
msgurl->SetMsgWindow(aMsgWindow);
@ -577,7 +576,7 @@ NS_IMETHODIMP nsImapService::DisplayMessage(const char* aMessageURI,
prefBranch->GetBoolPref("mailnews.mark_message_read.delay", &forcePeek);
rv = FetchMessage(imapUrl, forcePeek ? nsIImapUrl::nsImapMsgFetchPeek : nsIImapUrl::nsImapMsgFetch, folder, imapMessageSink,
aMsgWindow, aDisplayConsumer, msgKey, PR_FALSE, (mPrintingOperation) ? "print" : nsnull, aURL);
aMsgWindow, aDisplayConsumer, msgKey.get(), PR_FALSE, (mPrintingOperation) ? "print" : nsnull, aURL);
}
}
return rv;
@ -627,9 +626,6 @@ nsresult nsImapService::FetchMimePart(nsIImapUrl * aImapUrl,
if (mPrintingOperation)
urlSpec.Append("?header=print");
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = url->SetSpec(urlSpec);
rv = aImapUrl->SetImapAction(actionToUse /* nsIImapUrl::nsImapMsgFetch */);
@ -727,7 +723,7 @@ nsImapService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener *
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
nsCAutoString msgKey;
rv = DecomposeImapURI(aSrcMailboxURI, getter_AddRefs(folder), getter_Copies(msgKey));
if (NS_SUCCEEDED(rv))
{
@ -738,7 +734,7 @@ nsImapService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener *
nsCAutoString urlSpec;
PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder);
PRBool hasMsgOffline = PR_FALSE;
nsMsgKey key = atoi(msgKey);
nsMsgKey key = atoi(msgKey.get());
rv = CreateStartOfImapUrl(aSrcMailboxURI, getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
@ -753,7 +749,7 @@ nsImapService::CopyMessage(const char * aSrcMailboxURI, nsIStreamListener *
nsImapAction imapAction = nsIImapUrl::nsImapOnlineToOfflineCopy;
if (moveMessage)
imapAction = nsIImapUrl::nsImapOnlineToOfflineMove;
rv = FetchMessage(imapUrl,imapAction, folder, imapMessageSink,aMsgWindow, streamSupport, msgKey, PR_FALSE, nsnull, aURL);
rv = FetchMessage(imapUrl,imapAction, folder, imapMessageSink,aMsgWindow, streamSupport, msgKey.get(), PR_FALSE, nsnull, aURL);
} // if we got an imap message sink
} // if we decomposed the imap message
return rv;
@ -771,7 +767,7 @@ nsImapService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStr
if (!streamSupport || NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> folder = srcFolder;
nsXPIDLCString msgKey;
nsCAutoString msgKey;
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIImapMessageSink> imapMessageSink(do_QueryInterface(folder, &rv));
@ -780,7 +776,7 @@ nsImapService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStr
// we generate the uri for the first message so that way on down the line,
// GetMessage in nsCopyMessageStreamListener will get an unescaped username
// and be able to find the msg hdr. See bug 259656 for details
nsXPIDLCString uri;
nsCString uri;
srcFolder->GenerateMessageURI(keys->GetAt(0), getter_Copies(uri));
nsCString messageIds;
@ -789,12 +785,9 @@ nsImapService::CopyMessages(nsMsgKeyArray *keys, nsIMsgFolder *srcFolder, nsIStr
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString urlSpec;
PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder);
rv = CreateStartOfImapUrl(uri, getter_AddRefs(imapUrl), folder, aUrlListener, urlSpec, hierarchySeparator);
rv = CreateStartOfImapUrl(uri.get(), getter_AddRefs(imapUrl), folder.get(), aUrlListener, urlSpec, hierarchySeparator);
nsImapAction action;
if (moveMessage)
action = nsIImapUrl::nsImapOnlineToOfflineMove;
else
action = nsIImapUrl::nsImapOnlineToOfflineCopy;
action = (moveMessage) ? nsIImapUrl::nsImapOnlineToOfflineMove : nsIImapUrl::nsImapOnlineToOfflineCopy;
imapUrl->SetCopyState(aMailboxCopy);
// now try to display the message
rv = FetchMessage(imapUrl, action, folder, imapMessageSink,
@ -828,7 +821,7 @@ NS_IMETHODIMP nsImapService::Search(nsIMsgSearchSession *aSearchSession, nsIMsgW
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aMsgFolder, getter_Copies(folderName));
nsCOMPtr <nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(imapUrl);
@ -837,7 +830,7 @@ NS_IMETHODIMP nsImapService::Search(nsIMsgSearchSession *aSearchSession, nsIMsgW
urlSpec.Append("/search>UID>");
urlSpec.Append(char(hierarchySeparator));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append('>');
// escape aSearchUri so that IMAP special characters (i.e. '\')
// won't be replaced with '/' in NECKO.
@ -908,7 +901,7 @@ NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI,
nsresult rv = NS_OK;
nsCOMPtr<nsIMsgFolder> folder;
nsCOMPtr<nsIImapUrl> imapUrl;
nsXPIDLCString msgKey;
nsCAutoString msgKey;
rv = DecomposeImapURI(aMessageURI, getter_AddRefs(folder), getter_Copies(msgKey));
if (NS_FAILED(rv)) return rv;
@ -916,7 +909,7 @@ NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI,
PRBool hasMsgOffline = PR_FALSE;
if (folder)
folder->HasMsgOffline(atoi(msgKey), &hasMsgOffline);
folder->HasMsgOffline(atoi(msgKey.get()), &hasMsgOffline);
nsCAutoString urlSpec;
PRUnichar hierarchySeparator = GetHierarchyDelimiter(folder);
@ -938,7 +931,7 @@ NS_IMETHODIMP nsImapService::SaveMessageToDisk(const char *aMessageURI,
nsCOMPtr <nsIStreamListener> saveAsListener;
mailnewsUrl->GetSaveAsListener(aAddDummyEnvelope, aFile, getter_AddRefs(saveAsListener));
return FetchMessage(imapUrl, nsIImapUrl::nsImapSaveMessageToDisk, folder, imapMessageSink, aMsgWindow, saveAsListener, msgKey, PR_FALSE, nsnull, aURL);
return FetchMessage(imapUrl, nsIImapUrl::nsImapSaveMessageToDisk, folder, imapMessageSink, aMsgWindow, saveAsListener, msgKey.get(), PR_FALSE, nsnull, aURL);
}
return rv;
@ -1003,9 +996,9 @@ nsImapService::FetchMessage(nsIImapUrl * aImapUrl,
urlSpec.Append("fetch>UID>");
urlSpec.Append(char(hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(messageIdentifierList);
@ -1101,8 +1094,8 @@ nsImapService::StreamMessage(const char *aMessageURI, nsISupports *aConsumer,
nsIURI **aURL)
{
nsCOMPtr<nsIMsgFolder> folder;
nsXPIDLCString msgKey;
nsXPIDLCString mimePart;
nsCAutoString msgKey;
nsCAutoString mimePart;
nsCAutoString folderURI;
nsMsgKey key;
@ -1147,7 +1140,7 @@ nsImapService::StreamMessage(const char *aMessageURI, nsISupports *aConsumer,
msgurl->SetMsgIsInLocalCache(PR_TRUE);
rv = FetchMessage(imapUrl, nsIImapUrl::nsImapMsgFetchPeek, folder, imapMessageSink,
aMsgWindow, aConsumer, msgKey, aConvertData, aAdditionalHeader, aURL);
aMsgWindow, aConsumer, msgKey.get(), aConvertData, aAdditionalHeader, aURL);
}
}
return rv;
@ -1162,8 +1155,8 @@ nsImapService::CreateStartOfImapUrl(const char * aImapURI, nsIImapUrl ** imapUrl
{
nsresult rv = NS_OK;
char *hostname = nsnull;
nsXPIDLCString username;
nsXPIDLCString escapedUsername;
nsCAutoString username;
nsCAutoString escapedUsername;
rv = aImapMailFolder->GetHostname(&hostname);
if (NS_FAILED(rv)) return rv;
@ -1174,8 +1167,8 @@ nsImapService::CreateStartOfImapUrl(const char * aImapURI, nsIImapUrl ** imapUrl
return rv;
}
if (((const char*)username) && username[0])
*((char **)getter_Copies(escapedUsername)) = nsEscape(username, url_XAlphas);
if (!username.IsEmpty())
*((char **)getter_Copies(escapedUsername)) = nsEscape(username.get(), url_XAlphas);
PRInt32 port = IMAP_PORT;
nsCOMPtr<nsIMsgIncomingServer> server;
@ -1199,7 +1192,7 @@ nsImapService::CreateStartOfImapUrl(const char * aImapURI, nsIImapUrl ** imapUrl
msgurl->SetUri(aImapURI);
urlSpec = "imap://";
urlSpec.Append((const char *) escapedUsername);
urlSpec.Append(escapedUsername);
urlSpec.Append('@');
urlSpec.Append(hostname);
urlSpec.Append(':');
@ -1208,9 +1201,6 @@ nsImapService::CreateStartOfImapUrl(const char * aImapURI, nsIImapUrl ** imapUrl
// *** jefft - force to parse the urlSpec in order to search for
// the correct incoming server
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = mailnewsUrl->SetSpec(urlSpec);
hierarchyDelimiter = kOnlineHierarchySeparatorUnknown;
@ -1263,10 +1253,10 @@ nsImapService::GetHeaders(nsIEventTarget * aClientEventTarget,
urlSpec.Append(">");
urlSpec.Append(char (hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(messageIdentifierList);
rv = uri->SetSpec(urlSpec);
@ -1321,10 +1311,10 @@ nsImapService::GetBodyStart(nsIEventTarget * aClientEventTarget,
urlSpec.Append(">");
urlSpec.Append(char (hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(messageIdentifierList);
urlSpec.Append(">");
@ -1369,10 +1359,10 @@ nsresult nsImapService::FolderCommand(nsIEventTarget * clientEventTarget,
urlSpec.Append(command);
urlSpec.Append(char (hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(imapMailFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
rv = uri->SetSpec(urlSpec);
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(clientEventTarget, imapUrl,
@ -1450,9 +1440,9 @@ nsImapService::Biff(nsIEventTarget * aClientEventTarget,
urlSpec.Append("/Biff>");
urlSpec.Append(char(hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.AppendInt(uidHighWater);
rv = uri->SetSpec(urlSpec);
@ -1526,10 +1516,10 @@ nsImapService::DeleteMessages(nsIEventTarget * aClientEventTarget,
urlSpec.Append(">");
urlSpec.Append(char (hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(messageIdentifierList);
rv = uri->SetSpec(urlSpec);
@ -1632,9 +1622,9 @@ nsresult nsImapService::DiddleFlags(nsIEventTarget * aClientEventTarget,
urlSpec.Append(messageIdsAreUID ? uidString : sequenceString);
urlSpec.Append(">");
urlSpec.Append(char(hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(messageIdentifierList);
urlSpec.Append('>');
@ -1797,9 +1787,6 @@ nsImapService::DiscoverChildren(nsIEventTarget* aClientEventTarget,
urlSpec.Append("/discoverchildren>");
urlSpec.Append(char(hierarchySeparator));
urlSpec.Append(folderPath);
// mscott - this cast to a char * is okay...there's a bug in the XPIDL
// compiler that is preventing in string parameters from showing up as
// const char *. hopefully they will fix it soon.
rv = uri->SetSpec(urlSpec);
// Make sure the uri has the same hierarchy separator as the one in msg folder
@ -1893,16 +1880,16 @@ nsImapService::OnlineMessageCopy(nsIEventTarget* aClientEventTarget,
urlSpec.Append('>');
urlSpec.Append(char(hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aSrcFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append('>');
urlSpec.Append(messageIds);
urlSpec.Append('>');
urlSpec.Append(char(hierarchySeparator));
folderName.Adopt(strdup(""));
GetFolderName(aDstFolder, getter_Copies(folderName));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
rv = uri->SetSpec(urlSpec);
if (NS_SUCCEEDED(rv))
@ -1934,11 +1921,11 @@ nsresult nsImapService::OfflineAppendFromFile(nsIFile* aFile,
rv = destDB->GetOfflineOpForKey(fakeKey, PR_TRUE, getter_AddRefs(op));
if (NS_SUCCEEDED(rv) && op)
{
nsXPIDLCString destFolderUri;
nsCString destFolderUri;
aDstFolder->GetURI(getter_Copies(destFolderUri));
op->SetOperation(nsIMsgOfflineImapOperation::kAppendDraft); // ### do we care if it's a template?
op->SetDestinationFolderURI(destFolderUri);
op->SetDestinationFolderURI(destFolderUri.get());
nsCOMPtr <nsIOutputStream> offlineStore;
rv = aDstFolder->GetOfflineStoreOutputStream(getter_AddRefs(offlineStore));
@ -2070,7 +2057,7 @@ nsImapService::AppendMessageFromFile(nsIEventTarget* aClientEventTarget,
urlSpec.Append(char(hierarchySeparator));
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(aDstFolder, getter_Copies(folderName));
urlSpec.Append(folderName);
@ -2162,20 +2149,19 @@ nsImapService::MoveFolder(nsIEventTarget* eventTarget, nsIMsgFolder* srcFolder,
if (mailNewsUrl)
mailNewsUrl->SetMsgWindow(msgWindow);
char hierarchySeparator = kOnlineHierarchySeparatorUnknown;
nsXPIDLCString folderName;
nsCString folderName;
nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
GetFolderName(srcFolder, getter_Copies(folderName));
urlSpec.Append("/movefolderhierarchy>");
urlSpec.Append(hierarchySeparator);
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append('>');
folderName.Adopt(strdup(""));
GetFolderName(dstFolder, getter_Copies(folderName));
if ( folderName && folderName[0])
if (!folderName.IsEmpty())
{
urlSpec.Append(hierarchySeparator);
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
}
rv = uri->SetSpec(urlSpec);
if (NS_SUCCEEDED(rv))
@ -2215,16 +2201,16 @@ nsImapService::RenameLeaf(nsIEventTarget* eventTarget, nsIMsgFolder* srcFolder,
nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(imapUrl);
if (mailNewsUrl)
mailNewsUrl->SetMsgWindow(msgWindow);
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(srcFolder, getter_Copies(folderName));
urlSpec.Append("/rename>");
urlSpec.Append(char(hierarchySeparator));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append('>');
urlSpec.Append(char(hierarchySeparator));
nsCAutoString cStrFolderName(NS_STATIC_CAST(const char *, folderName));
nsCAutoString cStrFolderName(folderName);
// Unescape the name before looking for parent path
nsUnescape(cStrFolderName.BeginWriting());
PRInt32 leafNameStart =
@ -2239,11 +2225,11 @@ nsImapService::RenameLeaf(nsIEventTarget* eventTarget, nsIMsgFolder* srcFolder,
CopyUTF16toMUTF7(nsDependentString(newLeafName), utfNewName);
char* escapedNewName = nsEscape(utfNewName.get(), url_Path);
if (!escapedNewName) return NS_ERROR_OUT_OF_MEMORY;
nsXPIDLCString escapedSlashName;
nsCString escapedSlashName;
rv = nsImapUrl::EscapeSlashes(escapedNewName, getter_Copies(escapedSlashName));
NS_ENSURE_SUCCESS(rv, rv);
nsCRT::free(escapedNewName);
urlSpec.Append(escapedSlashName.get());
urlSpec.Append(escapedSlashName);
rv = uri->SetSpec(urlSpec);
if (NS_SUCCEEDED(rv))
@ -2279,16 +2265,16 @@ nsImapService::CreateFolder(nsIEventTarget* eventTarget, nsIMsgFolder* parent,
{
nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(parent, getter_Copies(folderName));
urlSpec.Append("/create>");
urlSpec.Append(char(hierarchySeparator));
if (!folderName.IsEmpty())
{
nsXPIDLCString canonicalName;
nsCString canonicalName;
nsImapUrl::ConvertToCanonicalFormat(folderName, (char) hierarchySeparator, getter_Copies(canonicalName));
urlSpec.Append((const char *) canonicalName);
nsImapUrl::ConvertToCanonicalFormat(folderName.get(), (char) hierarchySeparator, getter_Copies(canonicalName));
urlSpec.Append(canonicalName);
urlSpec.Append(char(hierarchySeparator));
}
@ -2332,13 +2318,13 @@ nsImapService::EnsureFolderExists(nsIEventTarget* eventTarget, nsIMsgFolder* par
{
nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(parent, getter_Copies(folderName));
urlSpec.Append("/ensureExists>");
urlSpec.Append(char(hierarchySeparator));
if (!folderName.IsEmpty())
{
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(char(hierarchySeparator));
}
nsCAutoString utfNewName;
@ -2431,7 +2417,7 @@ nsresult nsImapService::GetServerFromUrl(nsIImapUrl *aImapUrl, nsIMsgIncomingSer
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(aImapUrl);
nsresult rv;
nsXPIDLCString folderName;
nsCString folderName;
// if we can't get a folder name out of the url then I think this is an error
aImapUrl->CreateCanonicalSourceFolderPathString(getter_Copies(folderName));
@ -2501,7 +2487,7 @@ NS_IMETHODIMP nsImapService::NewURI(const nsACString &aSpec,
mailnewsUrl->SetSpec(aSpec);
}
nsXPIDLCString folderName;
nsCString folderName;
// if we can't get a folder name out of the url then I think this is an error
aImapUrl->CreateCanonicalSourceFolderPathString(getter_Copies(folderName));
@ -2530,7 +2516,7 @@ NS_IMETHODIMP nsImapService::NewURI(const nsACString &aSpec,
nsCOMPtr <nsIMsgImapMailFolder> subFolder;
if (imapRoot)
{
imapRoot->FindOnlineSubFolder(folderName, getter_AddRefs(subFolder));
imapRoot->FindOnlineSubFolder(folderName.get(), getter_AddRefs(subFolder));
folder = do_QueryInterface(subFolder, &rv);
}
if (NS_SUCCEEDED(rv))
@ -2540,14 +2526,14 @@ NS_IMETHODIMP nsImapService::NewURI(const nsACString &aSpec,
nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(folder);
rv = SetImapUrlSink(msgFolder, aImapUrl);
nsXPIDLCString msgKey;
nsCAutoString msgKey;
nsXPIDLCString messageIdString;
nsCString messageIdString;
aImapUrl->CreateListOfMessageIdsString(getter_Copies(messageIdString));
if (messageIdString.get())
if (!messageIdString.IsEmpty())
{
PRBool useLocalCache = PR_FALSE;
msgFolder->HasMsgOffline(atoi(messageIdString), &useLocalCache);
msgFolder->HasMsgOffline(atoi(messageIdString.get()), &useLocalCache);
mailnewsUrl->SetMsgIsInLocalCache(useLocalCache);
}
}
@ -2602,7 +2588,7 @@ NS_IMETHODIMP nsImapService::NewChannel(nsIURI *aURI, nsIChannel **_retval)
nsCOMPtr <nsIMsgIncomingServer> server;
rv = GetServerFromUrl(imapUrl, getter_AddRefs(server));
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLCString folderName;
nsCString folderName;
imapUrl->CreateCanonicalSourceFolderPathString(getter_Copies(folderName));
if (folderName.IsEmpty())
{
@ -2620,7 +2606,7 @@ NS_IMETHODIMP nsImapService::NewChannel(nsIURI *aURI, nsIChannel **_retval)
nsCOMPtr <nsIMsgImapMailFolder> subFolder;
if (imapRoot)
{
imapRoot->FindOnlineSubFolder(folderName, getter_AddRefs(subFolder));
imapRoot->FindOnlineSubFolder(folderName.get(), getter_AddRefs(subFolder));
aFolder = do_QueryInterface(subFolder);
}
nsCOMPtr <nsIMsgFolder> parent;
@ -2656,7 +2642,7 @@ NS_IMETHODIMP nsImapService::NewChannel(nsIURI *aURI, nsIChannel **_retval)
NS_ENSURE_SUCCESS(rv, rv);
wwatch->GetNewPrompter(nsnull, getter_AddRefs(dialog));
nsXPIDLString statusString, confirmText;
nsString statusString, confirmText;
nsCOMPtr<nsIStringBundle> bundle;
rv = IMAPGetStringBundle(getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
@ -2672,7 +2658,7 @@ NS_IMETHODIMP nsImapService::NewChannel(nsIURI *aURI, nsIChannel **_retval)
NS_ENSURE_SUCCESS(rv,rv);
PRBool confirmResult = PR_FALSE;
rv = dialog->Confirm(nsnull, confirmText, &confirmResult);
rv = dialog->Confirm(nsnull, confirmText.get(), &confirmResult);
NS_ENSURE_SUCCESS(rv, rv);
if (confirmResult)
@ -2732,7 +2718,7 @@ NS_IMETHODIMP nsImapService::NewChannel(nsIURI *aURI, nsIChannel **_retval)
rv = mailSession->GetTopmostMsgWindow(getter_AddRefs(msgWindow));
if (NS_SUCCEEDED(rv) && msgWindow)
{
nsXPIDLCString uri;
nsCString uri;
rootFolder->GetURI(getter_Copies(uri));
uri.Append('/');
uri.Append(fullFolderName);
@ -3058,7 +3044,7 @@ nsImapService::IssueCommandOnMsgs(nsIEventTarget *aClientEventTarget,
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(anImapFolder, getter_Copies(folderName));
urlSpec.Append("/");
urlSpec.Append(aCommand);
@ -3066,7 +3052,7 @@ nsImapService::IssueCommandOnMsgs(nsIEventTarget *aClientEventTarget,
urlSpec.Append(uidString);
urlSpec.Append(">");
urlSpec.Append(char(hierarchySeparator));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(uids);
rv = mailNewsUrl->SetSpec(urlSpec);
@ -3111,11 +3097,11 @@ nsImapService::FetchCustomMsgAttribute(nsIEventTarget *aClientEventTarget,
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(anImapFolder, getter_Copies(folderName));
urlSpec.Append("/customFetch>UID>");
urlSpec.Append(char(hierarchySeparator));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(uids);
urlSpec.Append(">");
@ -3162,11 +3148,11 @@ nsImapService::StoreCustomKeywords(nsIEventTarget *aClientEventTarget,
if (NS_SUCCEEDED(rv))
{
nsXPIDLCString folderName;
nsCString folderName;
GetFolderName(anImapFolder, getter_Copies(folderName));
urlSpec.Append("/customKeywords>UID>");
urlSpec.Append(char(hierarchySeparator));
urlSpec.Append((const char *) folderName);
urlSpec.Append(folderName);
urlSpec.Append(">");
urlSpec.Append(uids);
urlSpec.Append(">");

Просмотреть файл

@ -40,7 +40,6 @@
#include "nsMsgImapCID.h"
#include "nsIMsgHdr.h"
#include "nsImapUndoTxn.h"
#include "nsXPIDLString.h"
#include "nsIIMAPHostSessionList.h"
#include "nsIMsgIncomingServer.h"
#include "nsIDBFolderInfo.h"
@ -69,7 +68,7 @@ nsImapMoveCopyMsgTxn::Init(
m_urlListener = do_QueryInterface(urlListener, &rv);
m_srcKeyArray.CopyArray(srcKeyArray);
m_dupKeyArray.CopyArray(srcKeyArray);
nsXPIDLCString uri;
nsCString uri;
rv = srcFolder->GetURI(getter_Copies(uri));
nsCString protocolType(uri);
protocolType.SetLength(protocolType.FindChar(':'));
@ -574,18 +573,18 @@ NS_IMETHODIMP nsImapOfflineTxn::RedoTransaction(void)
nsCOMPtr<nsIMsgFolder> dstFolder = do_QueryReferent(m_dstFolder, &rv);
if (dstFolder)
{
nsXPIDLCString folderURI;
nsCString folderURI;
dstFolder->GetURI(getter_Copies(folderURI));
if (m_opType == nsIMsgOfflineImapOperation::kMsgMoved)
{
op->SetDestinationFolderURI(folderURI); // offline move
op->SetDestinationFolderURI(folderURI.get()); // offline move
}
if (m_opType == nsIMsgOfflineImapOperation::kMsgCopy)
{
op->SetOperation(nsIMsgOfflineImapOperation::kMsgMoved);
op->AddMessageCopyOperation(folderURI); // offline copy
op->AddMessageCopyOperation(folderURI.get()); // offline copy
}
dstFolder->SummaryChanged();
}
@ -606,9 +605,9 @@ NS_IMETHODIMP nsImapOfflineTxn::RedoTransaction(void)
rv = destDB->GetOfflineOpForKey(hdrKey, PR_TRUE, getter_AddRefs(op));
if (NS_SUCCEEDED(rv) && op)
{
nsXPIDLCString folderURI;
nsCString folderURI;
srcFolder->GetURI(getter_Copies(folderURI));
op->SetSourceFolderURI(folderURI);
op->SetSourceFolderURI(folderURI.get());
}
dstFolder->SummaryChanged();
destDB->Close(PR_TRUE);

Просмотреть файл

@ -52,7 +52,6 @@
#include "nsIImapIncomingServer.h"
#include "nsMsgBaseCID.h"
#include "nsImapUtils.h"
#include "nsXPIDLString.h"
#include "nsReadableUtils.h"
#include "nsAutoLock.h"
#include "nsIMAPNamespace.h"
@ -975,10 +974,10 @@ NS_IMETHODIMP nsImapUrl::AllocateServerPath(const char * canonicalPath, char onl
char *canonicalPath;
if (onlineDelimiter != '/')
{
nsXPIDLCString escapedPath;
nsCString escapedPath;
EscapeSlashes(folderName, getter_Copies(escapedPath));
canonicalPath = ReplaceCharsInCopiedString(escapedPath, onlineDelimiter , '/');
canonicalPath = ReplaceCharsInCopiedString(escapedPath.get(), onlineDelimiter , '/');
}
else
{
@ -1283,7 +1282,7 @@ NS_IMETHODIMP nsImapUrl::GetUri(char** aURI)
{
*aURI = nsnull;
PRUint32 key = m_listOfMessageIds ? atoi(m_listOfMessageIds) : 0;
nsXPIDLCString canonicalPath;
nsCString canonicalPath;
AllocateCanonicalPath(m_sourceCanonicalFolderPathSubString, m_onlineSubDirSeparator, (getter_Copies(canonicalPath)));
nsCString fullFolderPath("/");
fullFolderPath.Append(m_userName);
@ -1294,14 +1293,12 @@ NS_IMETHODIMP nsImapUrl::GetUri(char** aURI)
fullFolderPath.Append('/');
fullFolderPath.Append(canonicalPath);
char * baseMessageURI;
nsCreateImapBaseMessageURI(fullFolderPath.get(), &baseMessageURI);
nsCString baseMessageURI;
nsCreateImapBaseMessageURI(fullFolderPath.get(), baseMessageURI);
nsCAutoString uriStr;
rv = nsBuildImapMessageURI(baseMessageURI, key, uriStr);
nsCRT::free(baseMessageURI);
rv = nsBuildImapMessageURI(baseMessageURI.get(), key, uriStr);
*aURI = ToNewCString(uriStr);
}
return rv;
}
@ -1527,12 +1524,12 @@ nsresult nsImapUrl::GetMsgFolder(nsIMsgFolder **msgFolder)
// if we have a RDF URI, then try to get the folder for that URI and then ask the folder
// for it's charset....
nsXPIDLCString uri;
nsCString uri;
GetUri(getter_Copies(uri));
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
NS_ENSURE_TRUE(!uri.IsEmpty(), NS_ERROR_FAILURE);
nsCOMPtr<nsIMsgDBHdr> msg;
GetMsgDBHdrFromURI(uri, getter_AddRefs(msg));
GetMsgDBHdrFromURI(uri.get(), getter_AddRefs(msg));
NS_ENSURE_TRUE(msg, NS_ERROR_FAILURE);
nsresult rv = msg->GetFolder(msgFolder);
NS_ENSURE_SUCCESS(rv,rv);
@ -1591,7 +1588,7 @@ NS_IMETHODIMP nsImapUrl::SetShouldStoreMsgOffline(PRBool aShouldStoreMsgOffline)
NS_IMETHODIMP nsImapUrl::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr)
{
nsXPIDLCString uri;
nsCString uri;
nsresult rv = GetUri(getter_Copies(uri));
NS_ENSURE_SUCCESS(rv, rv);
return GetMsgDBHdrFromURI(uri.get(), aMsgHdr);

Просмотреть файл

@ -48,7 +48,6 @@
#include "nsIImapMessageSink.h"
#include "nsWeakPtr.h"
#include "nsXPIDLString.h"
#include "nsIFile.h"
class nsImapUrl : public nsIImapUrl, public nsMsgMailNewsUrl, public nsIMsgMessageUrl, public nsIMsgI18NUrl

Просмотреть файл

@ -219,23 +219,16 @@ nsresult nsBuildImapMessageURI(const char *baseURI, PRUint32 key, nsCString& uri
return NS_OK;
}
nsresult nsCreateImapBaseMessageURI(const char *baseURI, char **baseMessageURI)
nsresult nsCreateImapBaseMessageURI(const char *baseURI, nsCString &baseMessageURI)
{
if(!baseMessageURI)
return NS_ERROR_NULL_POINTER;
nsCAutoString tailURI(baseURI);
// chop off mailbox:/
// chop off imap:/
if (tailURI.Find(kImapRootURI) == 0)
tailURI.Cut(0, PL_strlen(kImapRootURI));
nsCAutoString baseURIStr(kImapMessageRootURI);
baseURIStr += tailURI;
*baseMessageURI = ToNewCString(baseURIStr);
if(!*baseMessageURI)
return NS_ERROR_OUT_OF_MEMORY;
baseMessageURI = kImapMessageRootURI;
baseMessageURI += tailURI;
return NS_OK;
}

Просмотреть файл

@ -62,7 +62,7 @@ extern nsresult
nsBuildImapMessageURI(const char *baseURI, PRUint32 key, nsCString& uri);
extern nsresult
nsCreateImapBaseMessageURI(const char *baseURI, char **baseMessageURI);
nsCreateImapBaseMessageURI(const char *baseURI, nsCString &baseMessageURI);
void AllocateImapUidString(PRUint32 *msgUids, PRUint32 &msgCount, nsImapFlagAndUidState *flagState, nsCString &returnString);
void ParseUidString(const char *uidString, nsMsgKeyArray &keys);

Просмотреть файл

@ -3161,7 +3161,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::SelectDownloadMsg()
if (mDownloadState == DOWNLOAD_STATE_GOTMSG && mDownloadWindow)
{
nsCAutoString newuri;
nsBuildLocalMessageURI(mBaseMessageURI, mDownloadSelectKey, newuri);
nsBuildLocalMessageURI(mBaseMessageURI.get(), mDownloadSelectKey, newuri);
nsCOMPtr<nsIMsgWindowCommands> windowCommands;
mDownloadWindow->GetWindowCommands(getter_AddRefs(windowCommands));
if (windowCommands)
@ -3291,7 +3291,7 @@ nsMsgLocalMailFolder::GetIncomingServerType()
nsresult nsMsgLocalMailFolder::CreateBaseMessageURI(const char *aURI)
{
return nsCreateLocalBaseMessageURI(aURI, &mBaseMessageURI);
return nsCreateLocalBaseMessageURI(aURI, mBaseMessageURI);
}
NS_IMETHODIMP
@ -3308,7 +3308,7 @@ nsMsgLocalMailFolder::OnStartRunningUrl(nsIURI * aUrl)
nsCOMPtr<nsIPop3Sink> popsink;
rv = popurl->GetPop3Sink(getter_AddRefs(popsink));
if (NS_SUCCEEDED(rv))
popsink->SetBaseMessageUri(mBaseMessageURI);
popsink->SetBaseMessageUri(mBaseMessageURI.get());
}
}
return nsMsgDBFolder::OnStartRunningUrl(aUrl);

Просмотреть файл

@ -259,23 +259,16 @@ nsresult nsBuildLocalMessageURI(const char *baseURI, PRUint32 key, nsCString& ur
return NS_OK;
}
nsresult nsCreateLocalBaseMessageURI(const char *baseURI, char **baseMessageURI)
nsresult nsCreateLocalBaseMessageURI(const char *baseURI, nsCString &baseMessageURI)
{
if(!baseMessageURI)
return NS_ERROR_NULL_POINTER;
nsCAutoString tailURI(baseURI);
// chop off mailbox:/
if (tailURI.Find(kMailboxRootURI) == 0)
tailURI.Cut(0, PL_strlen(kMailboxRootURI));
nsCAutoString baseURIStr(kMailboxMessageRootURI);
baseURIStr += tailURI;
*baseMessageURI = ToNewCString(baseURIStr);
if(!*baseMessageURI)
return NS_ERROR_OUT_OF_MEMORY;
baseMessageURI = kMailboxMessageRootURI;
baseMessageURI += tailURI;
return NS_OK;
}

Просмотреть файл

@ -54,7 +54,7 @@ nsresult
nsBuildLocalMessageURI(const char* baseURI, PRUint32 key, nsCString& uri);
nsresult
nsCreateLocalBaseMessageURI(const char *baseURI, char **baseMessageURI);
nsCreateLocalBaseMessageURI(const char *baseURI, nsCString &baseMessageURI);
void
nsEscapeNativePath(nsCString& nativePath);

Просмотреть файл

@ -199,12 +199,11 @@ NS_IMETHODIMP nsMailboxUrl::GetUri(char ** aURI)
(void) MsgMailboxGetURI(m_file, baseUri);
if (baseUri.IsEmpty())
m_baseURL->GetSpec(baseUri);
char * baseMessageURI;
nsCreateLocalBaseMessageURI(baseUri.get(), &baseMessageURI);
nsCString baseMessageURI;
nsCreateLocalBaseMessageURI(baseUri.get(), baseMessageURI);
char * uri = nsnull;
nsCAutoString uriStr;
nsBuildLocalMessageURI(baseMessageURI, m_messageKey, uriStr);
nsCRT::free(baseMessageURI);
nsBuildLocalMessageURI(baseMessageURI.get(), m_messageKey, uriStr);
uri = ToNewCString(uriStr);
*aURI = uri;
}

Просмотреть файл

@ -1450,7 +1450,7 @@ nsresult nsMsgNewsFolder::CreateBaseMessageURI(const char *aURI)
{
nsresult rv;
rv = nsCreateNewsBaseMessageURI(aURI, &mBaseMessageURI);
rv = nsCreateNewsBaseMessageURI(aURI, mBaseMessageURI);
return rv;
}

Просмотреть файл

@ -73,23 +73,16 @@ nsParseNewsMessageURI(const char* uri, nsCString& folderURI, PRUint32 *key)
return NS_ERROR_FAILURE;
}
nsresult nsCreateNewsBaseMessageURI(const char *baseURI, char **baseMessageURI)
nsresult nsCreateNewsBaseMessageURI(const char *baseURI, nsCString &baseMessageURI)
{
if(!baseMessageURI)
return NS_ERROR_NULL_POINTER;
nsCAutoString tailURI(baseURI);
// chop off mailbox:/
// chop off news:/
if (tailURI.Find(kNewsRootURI) == 0)
tailURI.Cut(0, PL_strlen(kNewsRootURI));
nsCAutoString baseURIStr(kNewsMessageRootURI);
baseURIStr += tailURI;
*baseMessageURI = ToNewCString(baseURIStr);
if(!*baseMessageURI)
return NS_ERROR_OUT_OF_MEMORY;
baseMessageURI = kNewsMessageRootURI;
baseMessageURI += tailURI;
return NS_OK;
}

Просмотреть файл

@ -54,7 +54,7 @@ extern nsresult
nsParseNewsMessageURI(const char* uri, nsCString& messageUriWithoutKey, PRUint32 *key);
extern nsresult
nsCreateNewsBaseMessageURI(const char *baseURI, char **baseMessageURI);
nsCreateNewsBaseMessageURI(const char *baseURI, nsCString &baseMessageURI);
#endif //NS_NEWSUTILS_H