зеркало из https://github.com/mozilla/gecko-dev.git
98391 98470 r=bienvenu sr=sspitzer. Make rename folder work again for folders having
subfolders. Also make filters work for a local folder whose parent is renamed.
This commit is contained in:
Родитель
39dc1fd90e
Коммит
0c703bc57c
|
@ -159,7 +159,7 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
|||
* @param name the new name of the folder
|
||||
*/
|
||||
void rename(in wstring name, in nsIMsgWindow msgWindow);
|
||||
|
||||
void renameSubFolders( in nsIMsgFolder oldFolder);
|
||||
/**
|
||||
* looks in immediate children of this folder for the given name
|
||||
*
|
||||
|
|
|
@ -1224,6 +1224,11 @@ NS_IMETHODIMP nsMsgFolder::Rename(const PRUnichar *name, nsIMsgWindow *msgWindow
|
|||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::RenameSubFolders(nsIMsgFolder *oldFolder)
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::ContainsChildNamed(const char *name, PRBool* containsChild)
|
||||
{
|
||||
nsCOMPtr<nsISupports> child;
|
||||
|
|
|
@ -101,6 +101,7 @@ public:
|
|||
NS_IMETHOD CompactAll(nsIUrlListener *aListener, nsIMsgWindow *msgWindow, nsISupportsArray *aFolderArray, PRBool aCompactOfflineAlso, nsISupportsArray *aOfflineFolderArray);
|
||||
NS_IMETHOD EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener);
|
||||
NS_IMETHOD Rename(const PRUnichar *name, nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD RenameSubFolders(nsIMsgFolder *msgFolder);
|
||||
NS_IMETHOD ContainsChildNamed(const char *name, PRBool *_retval);
|
||||
NS_IMETHOD IsAncestorOf(nsIMsgFolder *folder, PRBool *_retval);
|
||||
NS_IMETHOD GenerateUniqueSubfolderName(const char *prefix, nsIMsgFolder *otherFolder, char **_retval);
|
||||
|
|
|
@ -36,7 +36,6 @@ interface nsIMsgImapMailFolder : nsISupports {
|
|||
void performExpand(in nsIMsgWindow aMsgWindow);
|
||||
void recursiveCloseActiveConnections(in nsIImapIncomingServer aImapServer);
|
||||
void renameClient(in nsIMsgFolder msgFolder, in string oldName, in string newName);
|
||||
void renameSubfolders( in nsIMsgFolder oldFolder);
|
||||
|
||||
// these are used for offline synchronization
|
||||
void storeImapFlags(in long flags, in boolean addFlags, out nsMsgKey keysToFlag, in long numKeys);
|
||||
|
|
|
@ -5739,18 +5739,7 @@ NS_IMETHODIMP nsImapMailFolder::RenameClient( nsIMsgFolder *msgFolder, const cha
|
|||
unusedDB->SetSummaryValid(PR_TRUE);
|
||||
unusedDB->Commit(nsMsgDBCommitType::kLargeCommit);
|
||||
unusedDB->Close(PR_TRUE);
|
||||
imapFolder->RenameSubfolders(msgFolder);
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIFolder> parent;
|
||||
msgFolder->GetParent(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIMsgFolder> msgParent = do_QueryInterface(parent);
|
||||
msgFolder->SetParent(nsnull);
|
||||
msgParent->PropagateDelete(msgFolder,PR_FALSE, nsnull);
|
||||
|
||||
if(NS_SUCCEEDED(rv) && child)
|
||||
{
|
||||
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
|
||||
nsCOMPtr<nsISupports> folderSupports;
|
||||
rv = QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(folderSupports));
|
||||
|
@ -5758,13 +5747,21 @@ NS_IMETHODIMP nsImapMailFolder::RenameClient( nsIMsgFolder *msgFolder, const cha
|
|||
{
|
||||
NotifyItemAdded(folderSupports, childSupports, "folderView");
|
||||
}
|
||||
|
||||
child->RenameSubFolders(msgFolder);
|
||||
}
|
||||
}
|
||||
|
||||
return rv;
|
||||
nsCOMPtr<nsIFolder> parent;
|
||||
msgFolder->GetParent(getter_AddRefs(parent));
|
||||
nsCOMPtr<nsIMsgFolder> msgParent = do_QueryInterface(parent);
|
||||
msgFolder->SetParent(nsnull);
|
||||
msgParent->PropagateDelete(msgFolder,PR_FALSE, nsnull);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsImapMailFolder::RenameSubfolders(nsIMsgFolder *oldFolder)
|
||||
NS_IMETHODIMP nsImapMailFolder::RenameSubFolders(nsIMsgFolder *oldFolder)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
|
@ -5840,17 +5837,25 @@ NS_IMETHODIMP nsImapMailFolder::RenameSubfolders(nsIMsgFolder *oldFolder)
|
|||
nsCAutoString onlineCName(onlineName);
|
||||
onlineCName.AppendWithConversion(hierarchyDelimiter);
|
||||
onlineCName.Append(leafName);
|
||||
if (imapFolder)
|
||||
{
|
||||
imapFolder->SetVerifiedAsOnlineFolder(verified);
|
||||
imapFolder->SetOnlineName(onlineCName.get());
|
||||
imapFolder->SetHierarchyDelimiter(hierarchyDelimiter);
|
||||
imapFolder->SetBoxFlags(boxflags);
|
||||
|
||||
PRBool changed = PR_FALSE;
|
||||
msgFolder->ChangeFilterDestination(child, PR_FALSE /*caseInsensitive*/, &changed);
|
||||
|
||||
rv = aEnumerator->Next();
|
||||
nsCOMPtr <nsISupports> parentSupport = do_QueryInterface(NS_STATIC_CAST(nsIMsgImapMailFolder*, this));
|
||||
nsCOMPtr <nsISupports> childSupport = do_QueryInterface(child);
|
||||
if (parentSupport && childSupport)
|
||||
NotifyItemAdded(parentSupport, childSupport, "folderView");
|
||||
|
||||
imapFolder->RenameSubfolders(msgFolder);
|
||||
child->RenameSubFolders(msgFolder);
|
||||
m_initialized = PR_TRUE;
|
||||
}
|
||||
rv = aEnumerator->Next();
|
||||
PL_strfree(leafName);
|
||||
|
||||
}
|
||||
|
|
|
@ -128,6 +128,7 @@ public:
|
|||
NS_IMETHOD EmptyTrash(nsIMsgWindow *msgWindow, nsIUrlListener *aListener);
|
||||
NS_IMETHOD Delete ();
|
||||
NS_IMETHOD Rename (const PRUnichar *newName, nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD RenameSubFolders(nsIMsgFolder *oldFolder);
|
||||
NS_IMETHOD GetNoSelect(PRBool *aResult);
|
||||
|
||||
NS_IMETHOD GetPrettyName(PRUnichar ** prettyName); // Override of the base, for top-level mail folder
|
||||
|
|
|
@ -1225,15 +1225,15 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
|||
// function in nsIFileSpec
|
||||
|
||||
const nsString fileCharset(nsMsgI18NFileSystemCharset());
|
||||
char *convertedNewName;
|
||||
if (NS_FAILED(ConvertFromUnicode(fileCharset, nsAutoString(aNewName), &convertedNewName)))
|
||||
nsXPIDLCString convertedNewName;
|
||||
if (NS_FAILED(ConvertFromUnicode(fileCharset, nsAutoString(aNewName), getter_Copies(convertedNewName))))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCAutoString newNameStr(convertedNewName);
|
||||
nsCAutoString newNameStr(convertedNewName.get());
|
||||
|
||||
nsXPIDLCString oldLeafName;
|
||||
oldPathSpec->GetLeafName(getter_Copies(oldLeafName));
|
||||
|
||||
if (PL_strcasecmp(oldLeafName.get(), convertedNewName) == 0) {
|
||||
if (PL_strcasecmp(oldLeafName, convertedNewName) == 0) {
|
||||
if(msgWindow)
|
||||
rv=AlertFolderExists(msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
|
@ -1259,12 +1259,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
|||
NotifyStoreClosedAllHeaders();
|
||||
ForceDBClosed();
|
||||
|
||||
if (parentFolder)
|
||||
{
|
||||
SetParent(nsnull);
|
||||
parentFolder->PropagateDelete(this, PR_FALSE, msgWindow);
|
||||
}
|
||||
|
||||
oldPathSpec->Rename(newNameStr.get());
|
||||
|
||||
newNameStr += ".msf";
|
||||
|
@ -1273,33 +1267,79 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
|||
|
||||
if (NS_SUCCEEDED(rv) && cnt > 0) {
|
||||
// rename "*.sbd" directory
|
||||
nsCAutoString newNameDirStr(convertedNewName);
|
||||
nsCAutoString newNameDirStr(convertedNewName.get());
|
||||
newNameDirStr += ".sbd";
|
||||
dirSpec.Rename(newNameDirStr.get());
|
||||
}
|
||||
|
||||
PR_Free((void*) convertedNewName);
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> newFolder;
|
||||
if (parentSupport)
|
||||
{
|
||||
nsCOMPtr<nsIMsgFolder> newFolder;
|
||||
nsAutoString newFolderName(aNewName);
|
||||
rv = parentFolder->AddSubfolder(&newFolderName, getter_AddRefs(newFolder));
|
||||
if (newFolder) {
|
||||
if (newFolder)
|
||||
{
|
||||
newFolder->SetName(newFolderName.get());
|
||||
nsCOMPtr<nsISupports> newFolderSupport = do_QueryInterface(newFolder);
|
||||
NotifyItemAdded(parentSupport, newFolderSupport, "folderView");
|
||||
PRBool changed = PR_FALSE;
|
||||
ChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
|
||||
}
|
||||
nsCOMPtr<nsISupports> newFolderSupport = do_QueryInterface(newFolder);
|
||||
NotifyItemAdded(parentSupport, newFolderSupport, "folderView");
|
||||
/***** jefft -
|
||||
* Needs to find a way to reselect the new renamed folder and the
|
||||
* message being selected.
|
||||
*/
|
||||
if (cnt > 0)
|
||||
newFolder->RenameSubFolders(this);
|
||||
if (parentFolder)
|
||||
{
|
||||
SetParent(nsnull);
|
||||
parentFolder->PropagateDelete(this, PR_FALSE, msgWindow);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::RenameSubFolders(nsIMsgFolder *oldFolder)
|
||||
{
|
||||
nsresult rv =NS_OK;
|
||||
mInitialized = PR_TRUE;
|
||||
|
||||
PRUint32 flags;
|
||||
oldFolder->GetFlags(&flags);
|
||||
SetFlags(flags);
|
||||
|
||||
nsCOMPtr<nsIEnumerator> aEnumerator;
|
||||
oldFolder->GetSubFolders(getter_AddRefs(aEnumerator));
|
||||
nsCOMPtr<nsISupports> aSupport;
|
||||
rv = aEnumerator->First();
|
||||
while (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = aEnumerator->CurrentItem(getter_AddRefs(aSupport));
|
||||
nsCOMPtr<nsIMsgFolder>msgFolder = do_QueryInterface(aSupport);
|
||||
nsXPIDLString folderName;
|
||||
rv = msgFolder->GetName(getter_Copies(folderName));
|
||||
nsAutoString folderNameStr(folderName.get());
|
||||
nsCOMPtr <nsIMsgFolder> newFolder;
|
||||
AddSubfolder(&folderNameStr, getter_AddRefs(newFolder));
|
||||
if (newFolder)
|
||||
{
|
||||
newFolder->SetName(folderName);
|
||||
PRBool changed = PR_FALSE;
|
||||
msgFolder->ChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
|
||||
|
||||
nsCOMPtr <nsISupports> parentSupport = do_QueryInterface(NS_STATIC_CAST(nsIMsgLocalMailFolder*, this));
|
||||
nsCOMPtr <nsISupports> newFolderSupport = do_QueryInterface(newFolder);
|
||||
if (parentSupport && newFolderSupport)
|
||||
NotifyItemAdded(parentSupport, newFolderSupport, "folderView");
|
||||
|
||||
newFolder->RenameSubFolders(msgFolder);
|
||||
}
|
||||
rv = aEnumerator->Next();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::GetPrettyName(PRUnichar ** prettyName)
|
||||
{
|
||||
return nsMsgFolder::GetPrettyName(prettyName);
|
||||
|
|
|
@ -118,6 +118,7 @@ public:
|
|||
NS_IMETHOD DeleteSubFolders(nsISupportsArray *folders, nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD CreateStorageIfMissing(nsIUrlListener* urlListener);
|
||||
NS_IMETHOD Rename (const PRUnichar *aNewName, nsIMsgWindow *msgWindow);
|
||||
NS_IMETHOD RenameSubFolders (nsIMsgFolder *oldFolder);
|
||||
|
||||
NS_IMETHOD GetPrettyName(PRUnichar** prettyName); // Override of the base, for top-level mail folder
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче