100991 r=bienvenu sr=mscott a=roc+moz. Select the folder and the message (if any) after renaming a folder.

This commit is contained in:
naving%netscape.com 2002-02-21 00:16:57 +00:00
Родитель ea8e15ed01
Коммит af09a418bc
5 изменённых файлов: 194 добавлений и 157 удалений

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

@ -45,8 +45,7 @@ var gCurrentDisplayedMessage = null;
var gNextMessageAfterDelete = null;
var gNextMessageAfterLoad = null;
var gNextMessageViewIndexAfterDelete = -2;
var gCurrentlyDisplayedMessage=-1;
var gCurrentlyDisplayedMessage=nsMsgViewIndex_None;
var gStartFolderUri = null;
var gStartMsgKey = -1;
@ -133,6 +132,8 @@ var folderListener = {
var scrolled = false;
LoadCurrentlyDisplayedMessage(); //used for rename folder msg loading after folder is loaded.
if (gStartMsgKey != -1) {
// select the desired message
gDBView.selectMsgByKey(gStartMsgKey);
@ -179,6 +180,9 @@ var folderListener = {
else if (eventType == "CompactCompleted") {
HandleCompactCompleted(folder);
}
else if(eventType == "RenameCompleted") {
SelectFolder(folder.URI);
}
}
}
@ -331,22 +335,27 @@ function HandleCompactCompleted (folder)
dbFolderInfo = null;
}
RerootFolder(uri, msgFolder, viewType, viewFlags, sortType, sortOrder);
SetFocusThreadPane();
if (gCurrentlyDisplayedMessage != -1)
{
var outlinerView = gDBView.QueryInterface(Components.interfaces.nsIOutlinerView);
var outlinerSelection = outlinerView.selection;
outlinerSelection.select(gCurrentlyDisplayedMessage);
if (outlinerView)
outlinerView.selectionChanged();
EnsureRowInThreadOutlinerIsVisible(gCurrentlyDisplayedMessage);
}
gCurrentlyDisplayedMessage = -1; //reset
LoadCurrentlyDisplayedMessage();
}
}
}
}
function LoadCurrentlyDisplayedMessage()
{
if (gCurrentlyDisplayedMessage != nsMsgViewIndex_None)
{
var outlinerView = gDBView.QueryInterface(Components.interfaces.nsIOutlinerView);
var outlinerSelection = outlinerView.selection;
outlinerSelection.select(gCurrentlyDisplayedMessage);
if (outlinerView)
outlinerView.selectionChanged();
EnsureRowInThreadOutlinerIsVisible(gCurrentlyDisplayedMessage);
SetFocusThreadPane();
gCurrentlyDisplayedMessage = nsMsgViewIndex_None; //reset
}
}
function IsCurrentLoadedFolder(folder)
{
var msgfolder = folder.QueryInterface(Components.interfaces.nsIMsgFolder);

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

@ -78,33 +78,40 @@ function MsgRenameFolder()
function RenameFolder(name,uri)
{
dump("uri,name = " + uri + "," + name + "\n");
var folderOutliner = GetFolderOutliner();
if (folderOutliner)
dump("uri,name = " + uri + "," + name + "\n");
var folderOutliner = GetFolderOutliner();
if (folderOutliner)
{
if (uri && (uri != "") && name && (name != ""))
{
if (uri && (uri != "") && name && (name != "")) {
var selectedFolder = GetResourceFromUri(uri);
try
{
messenger.RenameFolder(GetFolderDatasource(), selectedFolder, name);
}
catch(e)
{
throw(e); // so that the dialog does not automatically close
dump ("Exception : RenameFolder \n");
}
var selectedFolder = GetResourceFromUri(uri);
if (gDBView)
gCurrentlyDisplayedMessage = gDBView.currentlyDisplayedMessage;
ClearThreadPane();
ClearMessagePane();
folderOutliner.outlinerBoxObject.selection.clearSelection();
}
else {
dump("no name or nothing selected\n");
}
}
else {
dump("no folder tree\n");
ClearThreadPane();
ClearMessagePane();
folderOutliner.outlinerBoxObject.selection.clearSelection();
try
{
messenger.RenameFolder(GetFolderDatasource(), selectedFolder, name);
}
catch(e)
{
SelectFolder(selectedFolder.URI); //restore selection
throw(e); // so that the dialog does not automatically close
dump ("Exception : RenameFolder \n");
}
}
else
{
dump("no name or nothing selected\n");
}
}
else
{
dump("no folder tree\n");
}
}
function MsgEmptyTrash()

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

@ -1580,42 +1580,53 @@ NS_IMETHODIMP nsImapIncomingServer::OnlineFolderCreateFailed(const char *aFolde
NS_IMETHODIMP nsImapIncomingServer::OnlineFolderRename(nsIMsgWindow *msgWindow, const char *oldName, const char *newName)
{
nsresult rv = NS_ERROR_FAILURE;
if (newName && *newName)
nsresult rv = NS_ERROR_FAILURE;
if (newName && *newName)
{
nsCOMPtr<nsIMsgFolder> me;
rv = GetFolder(oldName, getter_AddRefs(me));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIMsgFolder> parent;
nsCAutoString newNameString(newName);
nsCAutoString parentName;
PRInt32 folderStart = newNameString.RFindChar('/');
if (folderStart > 0)
{
nsCOMPtr<nsIMsgFolder> me;
rv = GetFolder(oldName, getter_AddRefs(me));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> parent ;
nsCAutoString newNameString(newName);
nsCAutoString parentName;
PRInt32 folderStart = newNameString.RFindChar('/');
if (folderStart > 0)
{
newNameString.Left(parentName, folderStart);
rv = GetFolder(parentName.get(),getter_AddRefs(parent));
}
else // root is the parent
{
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
parent = do_QueryInterface(rootFolder,&rv);
}
if (NS_SUCCEEDED(rv) && parent)
{
nsCOMPtr<nsIMsgImapMailFolder> folder;
folder = do_QueryInterface(me, &rv);
if (NS_SUCCEEDED(rv))
folder->RenameLocal(newName,parent);
nsCOMPtr<nsIMsgImapMailFolder> parentImapFolder = do_QueryInterface(parent);
if (parentImapFolder)
parentImapFolder->RenameClient(msgWindow, me,oldName, newName);
}
newNameString.Left(parentName, folderStart);
rv = GetFolder(parentName.get(),getter_AddRefs(parent));
}
return rv;
else // root is the parent
{
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
parent = do_QueryInterface(rootFolder,&rv);
}
if (NS_SUCCEEDED(rv) && parent)
{
nsCOMPtr<nsIMsgImapMailFolder> folder;
folder = do_QueryInterface(me, &rv);
if (NS_SUCCEEDED(rv))
{
folder->RenameLocal(newName,parent);
nsCOMPtr<nsIMsgImapMailFolder> parentImapFolder = do_QueryInterface(parent);
if (parentImapFolder)
parentImapFolder->RenameClient(msgWindow, me,oldName, newName);
nsCOMPtr <nsIMsgFolder> newFolder;
rv = GetFolder(newName, getter_AddRefs(newFolder));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr <nsIAtom> folderRenameAtom;
folderRenameAtom = getter_AddRefs(NS_NewAtom("RenameCompleted"));
newFolder->NotifyFolderEvent(folderRenameAtom);
}
}
}
}
return rv;
}
NS_IMETHODIMP nsImapIncomingServer::FolderIsNoSelect(const char *aFolderName, PRBool *result)

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

@ -852,11 +852,11 @@ NS_IMETHODIMP nsImapMailFolder::CreateClientSubfolderInfo(const char *folderName
unusedDB->Close(PR_TRUE);
}
}
nsCOMPtr <nsIAtom> folderCreateAtom;
if (!suppressNotification)
{
nsCOMPtr <nsIAtom> folderCreateAtom;
if(NS_SUCCEEDED(rv) && child)
{
{
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
nsCOMPtr<nsISupports> folderSupports;
rv = QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(folderSupports));
@ -4294,7 +4294,13 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
}
break;
case nsIImapUrl::nsImapRenameFolder:
break;
if (NS_FAILED(aExitCode))
{
nsCOMPtr <nsIAtom> folderRenameAtom;
folderRenameAtom = getter_AddRefs(NS_NewAtom("RenameCompleted"));
NotifyFolderEvent(folderRenameAtom);
}
break;
case nsIImapUrl::nsImapDeleteAllMsgs:
if (NS_SUCCEEDED(aExitCode))
{

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

@ -1206,27 +1206,29 @@ NS_IMETHODIMP nsMsgLocalMailFolder::DeleteSubFolders(
NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWindow *msgWindow)
{
nsCOMPtr<nsIFileSpec> oldPathSpec;
nsresult rv = GetPath(getter_AddRefs(oldPathSpec));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> parentFolder;
rv = GetParentMsgFolder(getter_AddRefs(parentFolder));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsISupports> parentSupport = do_QueryInterface(parentFolder);
nsCOMPtr<nsIFileSpec> oldPathSpec;
nsCOMPtr<nsIAtom> folderRenameAtom;
nsresult rv = GetPath(getter_AddRefs(oldPathSpec));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsIMsgFolder> parentFolder;
rv = GetParentMsgFolder(getter_AddRefs(parentFolder));
if (NS_FAILED(rv))
return rv;
nsCOMPtr<nsISupports> parentSupport = do_QueryInterface(parentFolder);
nsFileSpec fileSpec;
oldPathSpec->GetFileSpec(&fileSpec);
nsLocalFolderSummarySpec oldSummarySpec(fileSpec);
nsFileSpec dirSpec;
nsFileSpec fileSpec;
oldPathSpec->GetFileSpec(&fileSpec);
nsLocalFolderSummarySpec oldSummarySpec(fileSpec);
nsFileSpec dirSpec;
PRUint32 cnt = 0;
if (mSubFolders)
mSubFolders->Count(&cnt);
if (mSubFolders)
mSubFolders->Count(&cnt);
if (cnt > 0)
rv = CreateDirectoryForFolder(dirSpec);
if (cnt > 0)
rv = CreateDirectoryForFolder(dirSpec);
// convert from PRUnichar* to char* due to not having Rename(PRUnichar*)
// function in nsIFileSpec
@ -1235,88 +1237,90 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
return NS_ERROR_FAILURE;
nsCAutoString newNameStr(convertedNewName.get());
nsXPIDLCString oldLeafName;
oldPathSpec->GetLeafName(getter_Copies(oldLeafName));
nsXPIDLCString oldLeafName;
oldPathSpec->GetLeafName(getter_Copies(oldLeafName));
if (PL_strcasecmp(oldLeafName, convertedNewName) == 0) {
if(msgWindow)
rv=ThrowAlertMsg("folderExists", msgWindow);
return NS_MSG_FOLDER_EXISTS;
}
if (PL_strcasecmp(oldLeafName, convertedNewName) == 0)
{
if(msgWindow)
rv=ThrowAlertMsg("folderExists", msgWindow);
return NS_MSG_FOLDER_EXISTS;
}
else
{
nsCOMPtr <nsIFileSpec> parentPathSpec;
parentFolder->GetPath(getter_AddRefs(parentPathSpec));
NS_ENSURE_SUCCESS(rv,rv);
{
nsCOMPtr <nsIFileSpec> parentPathSpec;
parentFolder->GetPath(getter_AddRefs(parentPathSpec));
NS_ENSURE_SUCCESS(rv,rv);
nsFileSpec parentPath;
parentPathSpec->GetFileSpec(&parentPath);
NS_ENSURE_SUCCESS(rv,rv);
if (!parentPath.IsDirectory())
AddDirectorySeparator(parentPath);
nsFileSpec parentPath;
parentPathSpec->GetFileSpec(&parentPath);
NS_ENSURE_SUCCESS(rv,rv);
if (!parentPath.IsDirectory())
AddDirectorySeparator(parentPath);
rv = CheckIfFolderExists(aNewName, parentPath, msgWindow);
if (NS_FAILED(rv)) return rv;
}
rv = CheckIfFolderExists(aNewName, parentPath, msgWindow);
if (NS_FAILED(rv))
return rv;
}
NotifyStoreClosedAllHeaders();
ForceDBClosed();
rv = oldPathSpec->Rename(newNameStr.get());
if (NS_SUCCEEDED(rv))
{
newNameStr += ".msf";
oldSummarySpec.Rename(newNameStr.get());
}
else
{
ThrowAlertMsg("folderRenameFailed", msgWindow);
return rv;
}
rv = oldPathSpec->Rename(newNameStr.get());
if (NS_SUCCEEDED(rv))
{
newNameStr += ".msf";
oldSummarySpec.Rename(newNameStr.get());
}
else
{
ThrowAlertMsg("folderRenameFailed", msgWindow);
return rv;
}
if (NS_SUCCEEDED(rv) && cnt > 0) {
// rename "*.sbd" directory
nsCAutoString newNameDirStr(convertedNewName.get());
newNameDirStr += ".sbd";
dirSpec.Rename(newNameDirStr.get());
if (NS_SUCCEEDED(rv) && cnt > 0)
{
// rename "*.sbd" directory
nsCAutoString newNameDirStr(convertedNewName.get());
newNameDirStr += ".sbd";
dirSpec.Rename(newNameDirStr.get());
}
nsCOMPtr<nsIMsgFolder> newFolder;
if (parentSupport)
nsCOMPtr<nsIMsgFolder> newFolder;
if (parentSupport)
{
nsAutoString newFolderName(aNewName);
rv = parentFolder->AddSubfolder(&newFolderName, getter_AddRefs(newFolder));
if (newFolder)
{
nsAutoString newFolderName(aNewName);
rv = parentFolder->AddSubfolder(&newFolderName, getter_AddRefs(newFolder));
if (newFolder)
newFolder->SetName(newFolderName.get());
PRBool changed = PR_FALSE;
MatchOrChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
if (changed)
AlertFilterChanged(msgWindow);
if (cnt > 0)
newFolder->RenameSubFolders(msgWindow, this);
if (parentFolder)
{
SetParent(nsnull);
parentFolder->PropagateDelete(this, PR_FALSE, msgWindow);
nsCOMPtr<nsISupports> newFolderSupports = do_QueryInterface(newFolder);
nsCOMPtr<nsISupports> parentSupports = do_QueryInterface(parentFolder);
if(newFolderSupports && parentSupports)
{
newFolder->SetName(newFolderName.get());
PRBool changed = PR_FALSE;
MatchOrChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
if (changed)
AlertFilterChanged(msgWindow);
/***** jefft -
* Needs to find a way to reselect the new renamed folder and the
* message being selected.
*/
if (cnt > 0)
newFolder->RenameSubFolders(msgWindow, this);
if (parentFolder)
{
SetParent(nsnull);
parentFolder->PropagateDelete(this, PR_FALSE, msgWindow);
nsCOMPtr<nsISupports> newFolderSupports = do_QueryInterface(newFolder);
nsCOMPtr<nsISupports> parentSupports = do_QueryInterface(parentFolder);
if(newFolderSupports && parentSupports)
{
NotifyItemAdded(parentSupports, newFolderSupports, "folderView");
}
}
NotifyItemAdded(parentSupports, newFolderSupports, "folderView");
}
}
folderRenameAtom = getter_AddRefs(NS_NewAtom("RenameCompleted"));
newFolder->NotifyFolderEvent(folderRenameAtom);
}
return rv;
}
return rv;
}
NS_IMETHODIMP nsMsgLocalMailFolder::RenameSubFolders(nsIMsgWindow *msgWindow, nsIMsgFolder *oldFolder)