зеркало из https://github.com/mozilla/gecko-dev.git
use imap utf7 internally, fixes unicode folder names, r=jefft
This commit is contained in:
Родитель
b8c3a871df
Коммит
3606781335
|
@ -1449,14 +1449,6 @@ NS_IMETHODIMP nsImapProtocol::CanHandleUrl(nsIImapUrl * aImapUrl,
|
|||
&srcFolderName);
|
||||
if (NS_SUCCEEDED(rv) && srcFolderName)
|
||||
{
|
||||
char* convertedName =
|
||||
CreateUtf7ConvertedString(srcFolderName,
|
||||
PR_TRUE);
|
||||
if (convertedName)
|
||||
{
|
||||
PR_Free(srcFolderName);
|
||||
srcFolderName = convertedName;
|
||||
}
|
||||
PRBool isInbox =
|
||||
PL_strcasecmp("Inbox", srcFolderName) == 0;
|
||||
if (curUrlFolderName.Length() > 0)
|
||||
|
@ -1795,20 +1787,19 @@ void nsImapProtocol::ProcessSelectedStateURL()
|
|||
|
||||
// convert name back from utf7
|
||||
utf_name_struct *nameStruct = (utf_name_struct *) PR_Malloc(sizeof(utf_name_struct));
|
||||
char *convertedCanonicalName = NULL;
|
||||
char *canonicalName = NULL;
|
||||
if (nameStruct)
|
||||
{
|
||||
char *convertedName = CreateUtf7ConvertedString(GetServerStateParser().GetSelectedMailboxName(), PR_FALSE);
|
||||
if (convertedName)
|
||||
const char *selectedMailboxName = GetServerStateParser().GetSelectedMailboxName();
|
||||
if (selectedMailboxName)
|
||||
{
|
||||
m_runningUrl->AllocateCanonicalPath(convertedName,
|
||||
kOnlineHierarchySeparatorUnknown, &convertedCanonicalName);
|
||||
PR_Free(convertedName);
|
||||
m_runningUrl->AllocateCanonicalPath(selectedMailboxName,
|
||||
kOnlineHierarchySeparatorUnknown, &canonicalName);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_imapMessageSink)
|
||||
m_imapMessageSink->NotifyMessageDeleted(convertedCanonicalName, PR_FALSE, messageIdString);
|
||||
m_imapMessageSink->NotifyMessageDeleted(canonicalName, PR_FALSE, messageIdString);
|
||||
// notice we don't wait for this to finish...
|
||||
}
|
||||
else
|
||||
|
@ -1831,20 +1822,19 @@ void nsImapProtocol::ProcessSelectedStateURL()
|
|||
{
|
||||
// convert name back from utf7
|
||||
utf_name_struct *nameStruct = (utf_name_struct *) PR_Malloc(sizeof(utf_name_struct));
|
||||
char *convertedCanonicalName = NULL;
|
||||
char *canonicalName = NULL;
|
||||
if (nameStruct)
|
||||
{
|
||||
char *convertedName = CreateUtf7ConvertedString(GetServerStateParser().GetSelectedMailboxName(), PR_FALSE);
|
||||
if (convertedName )
|
||||
const char *mailboxName = GetServerStateParser().GetSelectedMailboxName();
|
||||
if (mailboxName )
|
||||
{
|
||||
m_runningUrl->AllocateCanonicalPath(convertedName,
|
||||
kOnlineHierarchySeparatorUnknown, &convertedCanonicalName);
|
||||
PR_Free(convertedName);
|
||||
m_runningUrl->AllocateCanonicalPath(mailboxName,
|
||||
kOnlineHierarchySeparatorUnknown, &canonicalName);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_imapMessageSink)
|
||||
m_imapMessageSink->NotifyMessageDeleted(convertedCanonicalName, PR_TRUE, nsnull);
|
||||
m_imapMessageSink->NotifyMessageDeleted(canonicalName, PR_TRUE, nsnull);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3302,9 +3292,6 @@ PRUint32 nsImapProtocol::GetMessageSize(nsCString &messageId,
|
|||
m_hostSessionList->GetNamespaceForMailboxForHost(GetImapServerKey(), folderFromParser,
|
||||
nsForMailbox);
|
||||
|
||||
char *nonUTF7ConvertedName = CreateUtf7ConvertedString(folderFromParser, PR_FALSE);
|
||||
if (nonUTF7ConvertedName)
|
||||
folderFromParser = nonUTF7ConvertedName;
|
||||
|
||||
if (nsForMailbox)
|
||||
m_runningUrl->AllocateCanonicalPath(
|
||||
|
@ -3314,7 +3301,6 @@ PRUint32 nsImapProtocol::GetMessageSize(nsCString &messageId,
|
|||
m_runningUrl->AllocateCanonicalPath(
|
||||
folderFromParser,kOnlineHierarchySeparatorUnknown,
|
||||
&folderName);
|
||||
PR_FREEIF(nonUTF7ConvertedName);
|
||||
|
||||
if (id && folderName)
|
||||
{
|
||||
|
@ -3518,10 +3504,6 @@ void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char
|
|||
|
||||
aclRightsInfo->hostName = PL_strdup(GetImapHostName());
|
||||
|
||||
char *nonUTF7ConvertedName = CreateUtf7ConvertedString(mailboxName, PR_FALSE);
|
||||
if (nonUTF7ConvertedName)
|
||||
mailboxName = nonUTF7ConvertedName;
|
||||
|
||||
if (namespaceForFolder)
|
||||
m_runningUrl->AllocateCanonicalPath(
|
||||
mailboxName,
|
||||
|
@ -3532,7 +3514,6 @@ void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char
|
|||
kOnlineHierarchySeparatorUnknown,
|
||||
&aclRightsInfo->mailboxName);
|
||||
|
||||
PR_FREEIF(nonUTF7ConvertedName);
|
||||
if (userName)
|
||||
aclRightsInfo->userName = PL_strdup(userName);
|
||||
else
|
||||
|
@ -3599,10 +3580,6 @@ void nsImapProtocol::ClearAllFolderRights(const char *mailboxName,
|
|||
nsIMAPACLRightsInfo *aclRightsInfo = new nsIMAPACLRightsInfo();
|
||||
if (aclRightsInfo)
|
||||
{
|
||||
char *nonUTF7ConvertedName = CreateUtf7ConvertedString(mailboxName, PR_FALSE);
|
||||
if (nonUTF7ConvertedName)
|
||||
mailboxName = nonUTF7ConvertedName;
|
||||
|
||||
const char *hostName = GetImapHostName();
|
||||
|
||||
aclRightsInfo->hostName = PL_strdup(hostName);
|
||||
|
@ -3615,7 +3592,6 @@ void nsImapProtocol::ClearAllFolderRights(const char *mailboxName,
|
|||
mailboxName, kOnlineHierarchySeparatorUnknown,
|
||||
&aclRightsInfo->mailboxName);
|
||||
|
||||
PR_FREEIF(nonUTF7ConvertedName);
|
||||
|
||||
aclRightsInfo->rights = NULL;
|
||||
aclRightsInfo->userName = NULL;
|
||||
|
@ -4558,12 +4534,6 @@ char * nsImapProtocol::OnCreateServerSourceFolderPathString()
|
|||
nsCRT::free(onlineDelimiter);
|
||||
|
||||
m_runningUrl->CreateServerSourceFolderPathString(&sourceMailbox);
|
||||
if (sourceMailbox)
|
||||
{
|
||||
char *convertedName = CreateUtf7ConvertedString(sourceMailbox, PR_TRUE);
|
||||
PR_Free(sourceMailbox);
|
||||
sourceMailbox = convertedName;
|
||||
}
|
||||
|
||||
return sourceMailbox;
|
||||
}
|
||||
|
@ -4583,12 +4553,6 @@ char * nsImapProtocol::OnCreateServerDestinationFolderPathString()
|
|||
nsCRT::free(onlineDelimiter);
|
||||
|
||||
m_runningUrl->CreateServerDestinationFolderPathString(&destinationMailbox);
|
||||
if (destinationMailbox)
|
||||
{
|
||||
char *convertedName = CreateUtf7ConvertedString(destinationMailbox, PR_TRUE);
|
||||
PR_Free(destinationMailbox);
|
||||
destinationMailbox = convertedName;
|
||||
}
|
||||
|
||||
return destinationMailbox;
|
||||
}
|
||||
|
@ -4858,12 +4822,8 @@ PRBool nsImapProtocol::MailboxIsNoSelectMailbox(const char *mailboxName)
|
|||
mailboxName, nsForMailbox);
|
||||
// NS_ASSERTION (nsForMailbox, "Oops .. null nsForMailbox\n");
|
||||
|
||||
char *nonUTF7ConvertedName = CreateUtf7ConvertedString(mailboxName, PR_FALSE);
|
||||
char *name;
|
||||
|
||||
if (nonUTF7ConvertedName)
|
||||
mailboxName = nonUTF7ConvertedName;
|
||||
|
||||
if (nsForMailbox)
|
||||
m_runningUrl->AllocateCanonicalPath(mailboxName,
|
||||
nsForMailbox->GetDelimiter(),
|
||||
|
@ -4872,7 +4832,6 @@ PRBool nsImapProtocol::MailboxIsNoSelectMailbox(const char *mailboxName)
|
|||
m_runningUrl->AllocateCanonicalPath(mailboxName,
|
||||
kOnlineHierarchySeparatorUnknown,
|
||||
&name);
|
||||
PR_FREEIF(nonUTF7ConvertedName);
|
||||
|
||||
if (!name)
|
||||
return PR_FALSE;
|
||||
|
@ -5117,19 +5076,17 @@ PRBool nsImapProtocol::DeleteSubFolders(const char* selectedMailbox)
|
|||
|
||||
void nsImapProtocol::FolderDeleted(const char *mailboxName)
|
||||
{
|
||||
char *convertedName = CreateUtf7ConvertedString(mailboxName,PR_FALSE);
|
||||
char onlineDelimiter = kOnlineHierarchySeparatorUnknown;
|
||||
char *orphanedMailboxName = nsnull;
|
||||
|
||||
if (convertedName)
|
||||
if (mailboxName)
|
||||
{
|
||||
m_runningUrl->AllocateCanonicalPath(convertedName, onlineDelimiter,
|
||||
m_runningUrl->AllocateCanonicalPath(mailboxName, onlineDelimiter,
|
||||
&orphanedMailboxName);
|
||||
if (m_imapServerSink)
|
||||
m_imapServerSink->OnlineFolderDelete(orphanedMailboxName);
|
||||
}
|
||||
|
||||
PR_FREEIF(convertedName);
|
||||
PR_FREEIF(orphanedMailboxName);
|
||||
}
|
||||
|
||||
|
@ -5148,25 +5105,17 @@ void nsImapProtocol::FolderRenamed(const char *oldName,
|
|||
(m_hierarchyNameState == kListingForInfoAndDiscovery))
|
||||
|
||||
{
|
||||
char *oldConvertedName = CreateUtf7ConvertedString(oldName,PR_FALSE);
|
||||
char *newConvertedName = CreateUtf7ConvertedString(newName,PR_FALSE);
|
||||
|
||||
if (oldConvertedName && newConvertedName)
|
||||
{
|
||||
char *oldName, *newName;
|
||||
m_runningUrl->AllocateCanonicalPath(oldConvertedName,
|
||||
m_runningUrl->AllocateCanonicalPath(oldName,
|
||||
onlineDelimiter,
|
||||
&oldName);
|
||||
m_runningUrl->AllocateCanonicalPath(newConvertedName,
|
||||
m_runningUrl->AllocateCanonicalPath(newName,
|
||||
onlineDelimiter,
|
||||
&newName);
|
||||
|
||||
m_imapServerSink->OnlineFolderRename(oldName, newName);
|
||||
PR_FREEIF (oldName);
|
||||
PR_FREEIF(newName);
|
||||
}
|
||||
PR_FREEIF(oldConvertedName);
|
||||
PR_FREEIF(newConvertedName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2268,7 +2268,6 @@ nsImapMailboxSpec *nsImapServerResponseParser::CreateCurrentMailboxSpec(const ch
|
|||
NS_ADDREF(returnSpec);
|
||||
if (returnSpec)
|
||||
{
|
||||
char *convertedMailboxName = nsnull;
|
||||
const char *mailboxNameToConvert = (mailboxName) ? mailboxName : fSelectedMailboxName;
|
||||
if (mailboxNameToConvert)
|
||||
{
|
||||
|
@ -2286,12 +2285,6 @@ nsImapMailboxSpec *nsImapServerResponseParser::CreateCurrentMailboxSpec(const ch
|
|||
else
|
||||
returnSpec->hierarchySeparator = '/'; // a guess?
|
||||
|
||||
char *convertedName = CreateUtf7ConvertedString(mailboxNameToConvert, PR_FALSE);
|
||||
if (convertedName)
|
||||
{
|
||||
fServerConnection.GetCurrentUrl()->AllocateCanonicalPath(convertedName, returnSpec->hierarchySeparator, &convertedMailboxName);
|
||||
PR_Free(convertedName);
|
||||
}
|
||||
}
|
||||
|
||||
returnSpec->folderSelected = PR_TRUE;
|
||||
|
@ -2302,7 +2295,7 @@ nsImapMailboxSpec *nsImapServerResponseParser::CreateCurrentMailboxSpec(const ch
|
|||
|
||||
returnSpec->box_flags = kNoFlags; // stub
|
||||
returnSpec->onlineVerified = PR_FALSE; // we're fabricating this. The flags aren't verified.
|
||||
returnSpec->allocatedPathName = convertedMailboxName;
|
||||
returnSpec->allocatedPathName = nsCRT::strdup(mailboxNameToConvert);
|
||||
returnSpec->connection = &fServerConnection;
|
||||
if (returnSpec->connection)
|
||||
{
|
||||
|
|
|
@ -102,11 +102,9 @@ nsImapService::GetFolderName(nsIMsgFolder* aImapFolder,
|
|||
nsCOMPtr<nsIMsgImapMailFolder> aFolder(do_QueryInterface(aImapFolder, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsXPIDLCString onlineName;
|
||||
// online name is in imap utf-7 - leave it that way
|
||||
rv = aFolder->GetOnlineName(getter_Copies(onlineName));
|
||||
|
||||
char *convertedName = CreateUtf7ConvertedString(onlineName, PR_FALSE);
|
||||
onlineName = convertedName;
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
if ((const char *)onlineName == nsnull || nsCRT::strlen((const char *) onlineName) == 0)
|
||||
{
|
||||
|
@ -585,17 +583,21 @@ nsImapService::CreateStartOfImapUrl(nsIImapUrl ** imapUrl,
|
|||
{
|
||||
nsresult rv = NS_OK;
|
||||
char *hostname = nsnull;
|
||||
char *username = nsnull;
|
||||
nsXPIDLCString username;
|
||||
nsXPIDLCString escapedUsername;
|
||||
|
||||
rv = aImapMailFolder->GetHostname(&hostname);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aImapMailFolder->GetUsername(&username);
|
||||
rv = aImapMailFolder->GetUsername(getter_Copies(username));
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
PR_FREEIF(hostname);
|
||||
return rv;
|
||||
}
|
||||
|
||||
if (((const char*)username) && username[0])
|
||||
*((char **)getter_Copies(escapedUsername)) = nsEscape(username, url_XAlphas);
|
||||
|
||||
PRInt32 port = IMAP_PORT;
|
||||
nsCOMPtr<nsIMsgIncomingServer> server;
|
||||
rv = aImapMailFolder->GetServer(getter_AddRefs(server));
|
||||
|
@ -616,7 +618,7 @@ nsImapService::CreateStartOfImapUrl(nsIImapUrl ** imapUrl,
|
|||
mailnewsUrl->RegisterListener(aUrlListener);
|
||||
|
||||
urlSpec = "imap://";
|
||||
urlSpec.Append(username);
|
||||
urlSpec.Append((const char *) escapedUsername);
|
||||
urlSpec.Append('@');
|
||||
urlSpec.Append(hostname);
|
||||
urlSpec.Append(':');
|
||||
|
@ -637,7 +639,6 @@ nsImapService::CreateStartOfImapUrl(nsIImapUrl ** imapUrl,
|
|||
}
|
||||
|
||||
PR_FREEIF(hostname);
|
||||
PR_FREEIF(username);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@ -1629,9 +1630,11 @@ nsImapService::CreateFolder(nsIEventQueue* eventQueue, nsIMsgFolder* parent,
|
|||
urlSpec.Append((const char *) folderName);
|
||||
urlSpec.Append(hierarchySeparator);
|
||||
}
|
||||
char *escapedFolderName = nsEscape(newFolderName, url_Path);
|
||||
char *utfNewName = CreateUtf7ConvertedString( newFolderName, PR_TRUE);
|
||||
char *escapedFolderName = nsEscape(utfNewName, url_Path);
|
||||
urlSpec.Append(escapedFolderName);
|
||||
nsCRT::free(escapedFolderName);
|
||||
nsCRT::free(utfNewName);
|
||||
|
||||
rv = uri->SetSpec((char*) urlSpec.GetBuffer());
|
||||
if (NS_SUCCEEDED(rv))
|
||||
|
|
|
@ -100,10 +100,19 @@ nsImapURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult)
|
|||
NS_MSGACCOUNTMANAGER_PROGID, &rv);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = accountManager->FindServer(username,
|
||||
hostname,
|
||||
"imap",
|
||||
getter_AddRefs(server));
|
||||
char *unescapedUserName = username.ToNewCString();
|
||||
if (unescapedUserName)
|
||||
{
|
||||
nsUnescape(unescapedUserName);
|
||||
rv = accountManager->FindServer(unescapedUserName,
|
||||
hostname,
|
||||
"imap",
|
||||
getter_AddRefs(server));
|
||||
PR_FREEIF(unescapedUserName);
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (server) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче