more fixes for double byte folder names, including create and rename, r=putterman,jefft

This commit is contained in:
bienvenu%netscape.com 2000-02-08 01:20:00 +00:00
Родитель 7a7da3f6d2
Коммит a728827338
16 изменённых файлов: 75 добавлений и 64 удалений

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

@ -80,10 +80,10 @@ interface nsIMessenger : nsISupports {
void NewFolder(in nsIRDFCompositeDataSource database,
in nsIRDFResource parentFolder,
in string name);
in wstring name);
void RenameFolder(in nsIRDFCompositeDataSource db,
in nsIRDFResource folder, in string name);
in nsIRDFResource folder, in wstring name);
void CompactFolder(in nsIRDFCompositeDataSource db,
in nsIRDFResource folder);
void EmptyTrash(in nsIRDFCompositeDataSource db,

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

@ -132,7 +132,7 @@ interface nsIMsgFolder : nsIFolder {
*
* @param name the new name of the folder
*/
void rename(in string name);
void rename(in wstring name);
void adopt(in nsIMsgFolder srcFolder, out unsigned long outPos);
/**

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

@ -848,7 +848,7 @@ nsMessenger::MarkMessagesFlagged(nsIRDFCompositeDataSource *database,
NS_IMETHODIMP
nsMessenger::NewFolder(nsIRDFCompositeDataSource *database, nsIRDFResource *parentFolderResource,
const char *name)
const PRUnichar *name)
{
nsresult rv;
nsCOMPtr<nsISupportsArray> nameArray, folderArray;
@ -884,23 +884,25 @@ nsMessenger::NewFolder(nsIRDFCompositeDataSource *database, nsIRDFResource *pare
NS_IMETHODIMP
nsMessenger::RenameFolder(nsIRDFCompositeDataSource* db,
nsIRDFResource* folderResource,
const char* name)
const PRUnichar* name)
{
nsresult rv = NS_ERROR_NULL_POINTER;
if (!db || !folderResource || !name || !*name) return rv;
nsCOMPtr<nsISupports> streamSupport;
rv = NS_NewCharInputStream(getter_AddRefs(streamSupport), name);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsISupportsArray> folderArray;
nsCOMPtr<nsISupportsArray> argsArray;
rv = NS_NewISupportsArray(getter_AddRefs(folderArray));
if (NS_FAILED(rv)) return rv;
folderArray->AppendElement(folderResource);
rv = NS_NewISupportsArray(getter_AddRefs(argsArray));
if (NS_FAILED(rv)) return rv;
argsArray->AppendElement(streamSupport);
rv = NS_NewISupportsArray(getter_AddRefs(folderArray));
if (NS_FAILED(rv)) return rv;
folderArray->AppendElement(folderResource);
rv = NS_NewISupportsArray(getter_AddRefs(argsArray));
if (NS_FAILED(rv)) return rv;
NS_WITH_SERVICE(nsIRDFService, rdfService, kRDFServiceCID, &rv);
if(NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIRDFLiteral> nameLiteral;
rdfService->GetLiteral(name, getter_AddRefs(nameLiteral));
argsArray->AppendElement(nameLiteral);
rv = DoCommand(db, NC_RDF_RENAME, folderArray, argsArray);
}
return rv;

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

@ -678,28 +678,16 @@ nsMsgFolderDataSource::DoCommand(nsISupportsArray/*<nsIRDFResource>*/* aSources,
}
else if ((aCommand == kNC_Rename))
{
nsCOMPtr<nsISupports> streamSupport = getter_AddRefs(aArguments->ElementAt(0));
if (streamSupport)
{
nsCOMPtr<nsIInputStream> charInputStream = do_QueryInterface(streamSupport);
if (charInputStream)
{
PRUint32 length = 0;
rv = charInputStream->Available(&length);
if (NS_SUCCEEDED(rv) && length > 0)
{
char *newName = (char*) PR_MALLOC(length+1);
PRUint32 readCount = 0;
rv = charInputStream->Read(newName, length, &readCount);
if(NS_SUCCEEDED(rv) && readCount > 0)
{
newName[readCount] = 0;
rv = folder->Rename(newName);
}
PR_FREEIF(newName);
}
}
}
nsCOMPtr<nsISupports> elem = getter_AddRefs(aArguments->ElementAt(0));
nsCOMPtr<nsIRDFLiteral> literal = do_QueryInterface(elem, &rv);
if(NS_SUCCEEDED(rv))
{
PRUnichar *name;
literal->GetValue(&name);
rv = folder->Rename(name);
PR_FREEIF(name);
}
}
}
}

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

@ -735,10 +735,13 @@ NS_IMETHODIMP nsMsgFolder::GetName(PRUnichar **name)
NS_IMETHODIMP nsMsgFolder::SetName(const PRUnichar * name)
{
// override the URI-generated name
mName = name;
if (!mName.Equals(name))
{
mName = name;
// old/new value doesn't matter here
NotifyUnicharPropertyChanged(kNameAtom, name, name);
NotifyUnicharPropertyChanged(kNameAtom, name, name);
}
return NS_OK;
}
@ -1034,7 +1037,7 @@ NS_IMETHODIMP nsMsgFolder::EmptyTrash()
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP nsMsgFolder::Rename(const char *name)
NS_IMETHODIMP nsMsgFolder::Rename(const PRUnichar *name)
{
nsresult status = NS_OK;
nsAutoString2 unicharString(name);

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

@ -92,7 +92,7 @@ public:
NS_IMETHOD AddSubfolder(nsAutoString *folderName, nsIMsgFolder **newFolder);
NS_IMETHOD Compact(void);
NS_IMETHOD EmptyTrash(void);
NS_IMETHOD Rename(const char *name);
NS_IMETHOD Rename(const PRUnichar *name);
NS_IMETHOD Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos);
NS_IMETHOD ContainsChildNamed(const char *name, PRBool *_retval);
NS_IMETHOD IsAncestorOf(nsIMsgFolder *folder, PRBool *_retval);

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

@ -61,4 +61,5 @@ interface nsIImapIncomingServer : nsISupports {
void ResetNamespaceReferences();
void PseudoInterruptMsgLoad(in nsIImapUrl aImapUrl, out boolean interrupted);
void ResetConnection(in string folderName);
void CreatePRUnicharStringFromUTF7(in string aSourceString, out wstring aUnicodeStr);
};

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

@ -166,7 +166,7 @@ public:
nsIURI** aUrl) = 0;
NS_IMETHOD RenameLeaf(nsIEventQueue* aClientEventQ,
nsIMsgFolder* srcFolder,
const char* leafName,
const PRUnichar* leafName,
nsIUrlListener* urlListener,
nsIURI** url) = 0;
NS_IMETHOD DeleteFolder(nsIEventQueue* aClientEventQ,

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

@ -1507,7 +1507,7 @@ NS_IMETHODIMP nsImapIncomingServer::RemoveChannelFromUrl(nsIMsgMailNewsUrl *aUrl
return rv;
}
nsresult nsImapIncomingServer::CreatePRUnicharStringFromUTF7(const char * aSourceString, PRUnichar **aUnicodeStr)
NS_IMETHODIMP nsImapIncomingServer::CreatePRUnicharStringFromUTF7(const char * aSourceString, PRUnichar **aUnicodeStr)
{
PRUnichar *convertedString = NULL;
nsresult res;

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

@ -61,8 +61,6 @@ protected:
PRBool NoDescendentsAreVerified(nsIFolder *parentFolder);
PRBool AllDescendentsAreNoSelect(nsIFolder *parentFolder);
nsresult CreatePRUnicharStringFromUTF7(const char * aSourceString, PRUnichar **aUnicodeStr);
private:
nsresult CreateImapConnection (nsIEventQueue* aEventQueue,
nsIImapUrl* aImapUrl,

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

@ -287,6 +287,12 @@ nsresult nsImapMailFolder::CreateSubFolders(nsFileSpec &path)
nsAutoString currentFolderNameStr; // online name
nsAutoString currentFolderDBNameStr; // possibly munged name
nsCOMPtr<nsIMsgFolder> child;
nsCOMPtr<nsIMsgIncomingServer> server;
nsCOMPtr<nsIImapIncomingServer> imapServer;
if (NS_SUCCEEDED(GetServer(getter_AddRefs(server))) && server)
imapServer = do_QueryInterface(server);
char *folderName;
for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++)
{
@ -321,11 +327,19 @@ nsresult nsImapMailFolder::CreateSubFolders(nsFileSpec &path)
rv = cacheElement->GetStringProperty("onlineName", getter_Copies(onlineName));
if (NS_SUCCEEDED(rv) && (const char *) onlineName && nsCRT::strlen((const char *) onlineName))
{
currentFolderNameStr = onlineName;
if (imapServer)
{
nsXPIDLString nonUtf7Name;
imapServer->CreatePRUnicharStringFromUTF7(onlineName, getter_Copies(nonUtf7Name));
currentFolderNameStr = nonUtf7Name;
}
else
currentFolderNameStr = onlineName;
PRInt32 leafPos = currentFolderNameStr.RFindChar('/');
if (leafPos > 0)
currentFolderNameStr.Cut(0, leafPos + 1);
}
}
}
@ -856,11 +870,12 @@ NS_IMETHODIMP nsImapMailFolder::Delete ()
return rv;
}
NS_IMETHODIMP nsImapMailFolder::Rename (const char *newName)
NS_IMETHODIMP nsImapMailFolder::Rename (const PRUnichar *newName)
{
nsresult rv = NS_ERROR_FAILURE;
rv = RenameLocal(newName);
char *utf7Name = CreateUtf7ConvertedStringFromUnicode(newName);
rv = RenameLocal(utf7Name);
nsCRT::free(utf7Name);
NS_WITH_SERVICE (nsIImapService, imapService, kCImapService, &rv);
if (NS_SUCCEEDED(rv))

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

@ -122,7 +122,7 @@ public:
NS_IMETHOD Compact();
NS_IMETHOD EmptyTrash();
NS_IMETHOD Delete ();
NS_IMETHOD Rename (const char *newName);
NS_IMETHOD Rename (const PRUnichar *newName);
NS_IMETHOD Adopt(nsIMsgFolder *srcFolder, PRUint32 *outPos);
NS_IMETHOD GetPrettyName(PRUnichar ** prettyName); // Override of the base, for top-level mail folder

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

@ -1825,10 +1825,10 @@ void nsImapProtocol::ProcessSelectedStateURL()
char *canonicalName = NULL;
if (nameStruct)
{
const char *mailboxName = GetServerStateParser().GetSelectedMailboxName();
if (mailboxName )
const char *selectedMailboxName = GetServerStateParser().GetSelectedMailboxName();
if (selectedMailboxName )
{
m_runningUrl->AllocateCanonicalPath(mailboxName,
m_runningUrl->AllocateCanonicalPath(selectedMailboxName,
kOnlineHierarchySeparatorUnknown, &canonicalName);
}
}
@ -5105,17 +5105,15 @@ void nsImapProtocol::FolderRenamed(const char *oldName,
(m_hierarchyNameState == kListingForInfoAndDiscovery))
{
char *oldName, *newName;
nsXPIDLCString canonicalOldName, canonicalNewName;
m_runningUrl->AllocateCanonicalPath(oldName,
onlineDelimiter,
&oldName);
getter_Copies(canonicalOldName));
m_runningUrl->AllocateCanonicalPath(newName,
onlineDelimiter,
&newName);
getter_Copies(canonicalNewName));
m_imapServerSink->OnlineFolderRename(oldName, newName);
PR_FREEIF (oldName);
PR_FREEIF(newName);
m_imapServerSink->OnlineFolderRename(canonicalOldName, canonicalNewName);
}
}

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

@ -1553,7 +1553,7 @@ nsImapService::MoveFolder(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder,
NS_IMETHODIMP
nsImapService::RenameLeaf(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder,
const char* newLeafName, nsIUrlListener* urlListener,
const PRUnichar* newLeafName, nsIUrlListener* urlListener,
nsIURI** url)
{
NS_ASSERTION(eventQueue && srcFolder && newLeafName && *newLeafName,
@ -1581,6 +1581,9 @@ nsImapService::RenameLeaf(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder,
urlSpec.Append((const char *) folderName);
urlSpec.Append('>');
urlSpec.Append(hierarchySeparator);
char *utfNewName = CreateUtf7ConvertedStringFromUnicode( newLeafName);
nsCAutoString cStrFolderName = (const char *) folderName;
PRInt32 leafNameStart =
cStrFolderName.RFindChar('/'); // ** troublesome hierarchyseparator
@ -1589,7 +1592,11 @@ nsImapService::RenameLeaf(nsIEventQueue* eventQueue, nsIMsgFolder* srcFolder,
cStrFolderName.SetLength(leafNameStart+1);
urlSpec.Append(cStrFolderName.GetBuffer());
}
urlSpec.Append(newLeafName);
urlSpec.Append(utfNewName);
nsCRT::free(utfNewName);
rv = uri->SetSpec((char*) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
{

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

@ -166,7 +166,7 @@ public:
nsIURI** url);
NS_IMETHOD RenameLeaf(nsIEventQueue* eventQueue,
nsIMsgFolder* srcFolder,
const char* leafName,
const PRUnichar* leafName,
nsIUrlListener* urlListener,
nsIURI** url);
NS_IMETHOD DeleteFolder(nsIEventQueue* eventQueue,

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

@ -467,7 +467,6 @@ CreateUtf7ConvertedStringFromUnicode(const PRUnichar * aSourceString)
if(NS_SUCCEEDED(res) && (nsnull != ccm))
{
nsString aCharset("x-imap4-modified-utf7");
PRUnichar *unichars = nsnull;
PRInt32 unicharLength;
// convert from 8 bit ascii string to modified utf7