117835 r=cavin sr=bienvenu fixing invalid folder name containing japanese characters when you restart after creating new local folders. Also cleaning up local folders code that deals with checking for duplicate
folder names, renaming/deleting local folders git-svn-id: svn://10.0.0.236/trunk@133057 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
42a06500ad
commit
684c365224
@ -101,11 +101,6 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
||||
* URL for this folder
|
||||
*/
|
||||
readonly attribute string folderURL;
|
||||
|
||||
/**
|
||||
* should probably move to the server
|
||||
*/
|
||||
attribute boolean deleteIsMoveToTrash;
|
||||
|
||||
/**
|
||||
* should probably move to the server
|
||||
@ -292,8 +287,6 @@ const nsMsgBiffState nsMsgBiffState_Unknown = 2; // We dunno whether there is ne
|
||||
|
||||
attribute unsigned long flags;
|
||||
|
||||
void RecursiveSetDeleteIsMoveToTrash(in boolean bVal);
|
||||
|
||||
nsIMsgFolder getFoldersWithFlag(in unsigned long flags,
|
||||
in unsigned long resultsize, out unsigned long numFolders);
|
||||
|
||||
|
||||
@ -450,6 +450,11 @@ nsresult nsMsgDBFolder::ReadDBFolderInfo(PRBool force)
|
||||
folderInfo->GetNumNewMessages(&mNumUnreadMessages);
|
||||
folderInfo->GetExpungedBytes((PRInt32 *)&mExpungedBytes);
|
||||
|
||||
nsXPIDLCString utf8Name;
|
||||
folderInfo->GetFolderName(getter_Copies(utf8Name));
|
||||
if (!utf8Name.IsEmpty())
|
||||
mName = NS_ConvertUTF8toUCS2(utf8Name.get());
|
||||
|
||||
//These should be put in IMAP folder only.
|
||||
//folderInfo->GetImapTotalPendingMessages(&mNumPendingTotalMessages);
|
||||
//folderInfo->GetImapUnreadPendingMessages(&mNumPendingUnreadMessages);
|
||||
@ -948,7 +953,7 @@ NS_IMETHODIMP nsMsgDBFolder::GetFlags(PRUint32 *_retval)
|
||||
NS_IMETHODIMP nsMsgDBFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *element)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
char *charset;
|
||||
nsXPIDLCString charset;
|
||||
|
||||
element->GetInt32Property("flags", (PRInt32 *) &mFlags);
|
||||
|
||||
@ -968,7 +973,7 @@ NS_IMETHODIMP nsMsgDBFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *e
|
||||
element->GetInt32Property("expungedBytes", (PRInt32 *) &mExpungedBytes);
|
||||
element->GetInt32Property("folderSize", (PRInt32 *) &mFolderSize);
|
||||
|
||||
element->GetStringProperty("charset", &charset);
|
||||
element->GetStringProperty("charset", getter_Copies(charset));
|
||||
|
||||
#ifdef DEBUG_bienvenu1
|
||||
char *uri;
|
||||
@ -977,8 +982,7 @@ NS_IMETHODIMP nsMsgDBFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *e
|
||||
printf("read total %ld for %s\n", mNumTotalMessages, uri);
|
||||
PR_Free(uri);
|
||||
#endif
|
||||
mCharset.AssignWithConversion(charset);
|
||||
PR_FREEIF(charset);
|
||||
mCharset.AssignWithConversion(charset.get());
|
||||
|
||||
mInitializedFromCache = PR_TRUE;
|
||||
return rv;
|
||||
|
||||
@ -126,7 +126,6 @@ nsMsgFolder::nsMsgFolder(void)
|
||||
mHaveParsedURI(PR_FALSE),
|
||||
mIsServerIsValid(PR_FALSE),
|
||||
mIsServer(PR_FALSE),
|
||||
mDeleteIsMoveToTrash(PR_TRUE),
|
||||
mBaseMessageURI(nsnull)
|
||||
{
|
||||
// NS_INIT_ISUPPORTS(); done by superclass
|
||||
@ -1087,15 +1086,6 @@ NS_IMETHODIMP nsMsgFolder::HaveAdminUrl(MSG_AdminURLType type, PRBool *haveAdmin
|
||||
}
|
||||
#endif
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::GetDeleteIsMoveToTrash(PRBool *deleteIsMoveToTrash)
|
||||
{
|
||||
if (!deleteIsMoveToTrash)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*deleteIsMoveToTrash = mDeleteIsMoveToTrash;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgFolder::GetShowDeletedMessages(PRBool *showDeletedMessages)
|
||||
{
|
||||
if (!showDeletedMessages)
|
||||
@ -2307,13 +2297,6 @@ NS_IMETHODIMP nsMsgFolder::MatchName(nsString *name, PRBool *matches)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolder::SetDeleteIsMoveToTrash(PRBool bVal)
|
||||
{
|
||||
mDeleteIsMoveToTrash = bVal;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgFolder::NotifyPropertyChanged(nsIAtom *property,
|
||||
const char *oldValue, const char* newValue)
|
||||
@ -2525,31 +2508,6 @@ nsGetMailFolderSeparator(nsString& result)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolder::RecursiveSetDeleteIsMoveToTrash(PRBool bVal)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
if (mSubFolders)
|
||||
{
|
||||
PRUint32 cnt = 0, i;
|
||||
rv = mSubFolders->Count(&cnt);
|
||||
for (i=0; i < cnt; i++)
|
||||
{
|
||||
nsCOMPtr<nsISupports> aSupport;
|
||||
rv = GetElementAt(i, getter_AddRefs(aSupport));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
folder = do_QueryInterface(aSupport);
|
||||
if (folder)
|
||||
folder->RecursiveSetDeleteIsMoveToTrash(bVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
return SetDeleteIsMoveToTrash(bVal);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgFolder::GetFilterList(nsIMsgWindow *aMsgWindow, nsIMsgFilterList **aResult)
|
||||
{
|
||||
|
||||
@ -96,7 +96,6 @@ public:
|
||||
NS_IMETHOD GetVisibleSubFolders(nsIEnumerator **_retval);
|
||||
NS_IMETHOD GetPrettiestName(PRUnichar * *aPrettiestName);
|
||||
NS_IMETHOD GetFolderURL(char * *aFolderURL);
|
||||
NS_IMETHOD GetDeleteIsMoveToTrash(PRBool *aDeleteIsMoveToTrash);
|
||||
NS_IMETHOD GetShowDeletedMessages(PRBool *aShowDeletedMessages);
|
||||
NS_IMETHOD GetServer(nsIMsgIncomingServer * *aServer);
|
||||
NS_IMETHOD GetIsServer(PRBool *aIsServer);
|
||||
@ -149,8 +148,6 @@ public:
|
||||
NS_IMETHOD UserNeedsToAuthenticateForFolder(PRBool displayOnly, PRBool *_retval);
|
||||
NS_IMETHOD GetUsername(char * *aUsername);
|
||||
NS_IMETHOD GetHostname(char * *aHostname);
|
||||
NS_IMETHOD SetDeleteIsMoveToTrash(PRBool bVal);
|
||||
NS_IMETHOD RecursiveSetDeleteIsMoveToTrash(PRBool bVal);
|
||||
NS_IMETHOD SetFlag(PRUint32 flag);
|
||||
NS_IMETHOD SetPrefFlag();
|
||||
NS_IMETHOD ClearFlag(PRUint32 flag);
|
||||
@ -307,7 +304,6 @@ protected:
|
||||
PRBool mIsServer;
|
||||
nsString mName;
|
||||
nsCOMPtr<nsIFileSpec> mPath;
|
||||
PRBool mDeleteIsMoveToTrash;
|
||||
char * mBaseMessageURI; //The uri with the message scheme
|
||||
|
||||
// static stuff for cross-instance objects like atoms
|
||||
|
||||
@ -100,11 +100,11 @@ interface nsIDBFolderInfo : nsISupports {
|
||||
[noscript] void setMailboxName(in nsString newBoxName);
|
||||
[noscript] void getMailboxName(in nsString boxName);
|
||||
|
||||
|
||||
[noscript] void getProperty(in string propertyName, in nsString resultProperty);
|
||||
[noscript] void setProperty(in string propertyName, in nsString propertyStr);
|
||||
|
||||
attribute string knownArtsSet;
|
||||
attribute string folderName;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -978,6 +978,15 @@ NS_IMETHODIMP nsDBFolderInfo::SetBooleanProperty(const char *propertyName, PRBoo
|
||||
return m_mdb->SetUint32Property(m_mdbRow, propertyName, propertyValue ? 1 : 0);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDBFolderInfo::GetFolderName(char **folderName)
|
||||
{
|
||||
return GetCharPtrProperty("folderName", folderName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDBFolderInfo::SetFolderName(const char *folderName)
|
||||
{
|
||||
return SetCharPtrProperty("folderName", folderName);
|
||||
}
|
||||
|
||||
class nsTransferDBFolderInfo : public nsDBFolderInfo
|
||||
{
|
||||
@ -993,8 +1002,11 @@ public:
|
||||
NS_IMETHOD GetSortType(nsMsgViewSortTypeValue *aSortType);
|
||||
NS_IMETHOD SetSortType(nsMsgViewSortTypeValue aSortType);
|
||||
NS_IMETHOD GetSortOrder(nsMsgViewSortOrderValue *aSortOrder);
|
||||
NS_IMETHOD SetSortOrder(nsMsgViewSortOrderValue aSortOrder);
|
||||
NS_IMETHOD SetSortOrder(nsMsgViewSortOrderValue aSortOrder);
|
||||
NS_IMETHOD GetFolderName(char **folderName);
|
||||
NS_IMETHOD SetFolderName(const char *folderName);
|
||||
nsString m_boxName;
|
||||
nsCString m_folderName;
|
||||
nsMsgViewTypeValue m_viewType;
|
||||
nsMsgViewFlagsTypeValue m_viewFlags;
|
||||
nsMsgViewSortTypeValue m_sortType;
|
||||
@ -1036,6 +1048,25 @@ NS_IMETHODIMP nsDBFolderInfo::GetTransferInfo(nsIDBFolderInfo **transferInfo)
|
||||
newInfo->SetViewFlags(viewFlags);
|
||||
newInfo->SetSortType(sortType);
|
||||
newInfo->SetSortOrder(sortOrder);
|
||||
|
||||
nsXPIDLCString utf8Name;
|
||||
GetFolderName(getter_Copies(utf8Name));
|
||||
newInfo->SetFolderName(utf8Name.get());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransferDBFolderInfo::SetFolderName(const char *folderName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(folderName);
|
||||
m_folderName = folderName;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsTransferDBFolderInfo::GetFolderName(char **folderName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(folderName);
|
||||
*folderName = ToNewCString(m_folderName);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1067,6 +1098,11 @@ NS_IMETHODIMP nsDBFolderInfo::InitFromTransferInfo(nsIDBFolderInfo *transferInfo
|
||||
SetFlags(flags);
|
||||
transferInfo->GetMailboxName(&folderNameStr);
|
||||
SetMailboxName(&folderNameStr);
|
||||
|
||||
nsXPIDLCString utf8Name;
|
||||
transferInfo->GetFolderName(getter_Copies(utf8Name));
|
||||
SetFolderName(utf8Name.get());
|
||||
|
||||
// ### add whatever other fields we want to copy here.
|
||||
|
||||
nsMsgViewTypeValue viewType;
|
||||
|
||||
@ -73,6 +73,7 @@
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsMsgLocalCID.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIMsgFolderCacheElement.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsUnicharUtils.h"
|
||||
#include "nsLocalFolderSummarySpec.h"
|
||||
@ -191,7 +192,8 @@ nsShouldIgnoreFile(nsString& name)
|
||||
if (firstChar == '.' || firstChar == '#' || name.CharAt(name.Length() - 1) == '~')
|
||||
return PR_TRUE;
|
||||
|
||||
if (name.EqualsIgnoreCase("rules.dat") ||
|
||||
if (name.EqualsIgnoreCase("msgFilterRules.dat") ||
|
||||
name.EqualsIgnoreCase("rules.dat") ||
|
||||
name.EqualsIgnoreCase("filterlog.html") ||
|
||||
name.EqualsIgnoreCase("junklog.html") ||
|
||||
name.EqualsIgnoreCase("rulesbackup.dat"))
|
||||
@ -243,9 +245,16 @@ nsMsgLocalMailFolder::CreateSubFolders(nsFileSpec &path)
|
||||
if (nsShouldIgnoreFile(currentFolderNameStr))
|
||||
continue;
|
||||
|
||||
rv = AddSubfolder(¤tFolderNameStr, getter_AddRefs(child));
|
||||
rv = AddSubfolder(¤tFolderNameStr, getter_AddRefs(child));
|
||||
if (child)
|
||||
child->SetPrettyName(currentFolderNameStr.get());
|
||||
{
|
||||
nsXPIDLString folderName;
|
||||
child->GetName(getter_Copies(folderName)); //try to get it from cache/db
|
||||
if (folderName.IsEmpty())
|
||||
child->SetPrettyName(currentFolderNameStr.get());
|
||||
else
|
||||
child->SetPrettyName(folderName.get());
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -785,35 +794,42 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CreateStorageIfMissing(nsIUrlListener* urlLi
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgLocalMailFolder::CheckIfFolderExists(const PRUnichar *folderName, nsFileSpec &path, nsIMsgWindow *msgWindow)
|
||||
nsMsgLocalMailFolder::CheckIfFolderExists(const PRUnichar *newFolderName, nsIMsgFolder *parentFolder, nsIMsgWindow *msgWindow)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsAutoString leafName;
|
||||
for (nsDirectoryIterator dir(path, PR_FALSE); dir.Exists(); dir++)
|
||||
{
|
||||
nsFileSpec currentFolderPath = dir.Spec();
|
||||
|
||||
char *leaf = currentFolderPath.GetLeafName();
|
||||
nsMsgGetNativePathString(leaf,leafName);
|
||||
PR_FREEIF(leaf);
|
||||
|
||||
if (!leafName.IsEmpty() &&
|
||||
leafName.Equals(nsDependentString(folderName),
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (msgWindow)
|
||||
ThrowAlertMsg("folderExists", msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
NS_ENSURE_ARG_POINTER(newFolderName);
|
||||
NS_ENSURE_ARG_POINTER(parentFolder);
|
||||
nsCOMPtr<nsIEnumerator> subfolders;
|
||||
nsresult rv = parentFolder->GetSubFolders(getter_AddRefs(subfolders));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = subfolders->First(); //will fail if no subfolders
|
||||
while (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports;
|
||||
subfolders->CurrentItem(getter_AddRefs(supports));
|
||||
nsCOMPtr<nsIMsgFolder> msgFolder = do_QueryInterface(supports);
|
||||
nsAutoString folderNameString;
|
||||
PRUnichar *folderName;
|
||||
if (msgFolder)
|
||||
msgFolder->GetName(&folderName);
|
||||
folderNameString.Adopt(folderName);
|
||||
if (folderNameString.Equals(newFolderName, nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (msgWindow)
|
||||
ThrowAlertMsg("folderExists", msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
}
|
||||
rv = subfolders->Next();
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgLocalMailFolder::CreateSubfolder(const PRUnichar *folderName, nsIMsgWindow *msgWindow )
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
nsresult rv = CheckIfFolderExists(folderName, this, msgWindow);
|
||||
if(NS_FAILED(rv)) //we already throw an alert - no need for an assertion
|
||||
return rv;
|
||||
|
||||
nsFileSpec path;
|
||||
nsCOMPtr<nsIMsgFolder> child;
|
||||
//Get a directory based on our current path.
|
||||
@ -823,10 +839,6 @@ nsMsgLocalMailFolder::CreateSubfolder(const PRUnichar *folderName, nsIMsgWindow
|
||||
|
||||
//Now we have a valid directory or we have returned.
|
||||
//Make sure the new folder name is valid
|
||||
rv = CheckIfFolderExists(folderName, path, msgWindow);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsXPIDLCString nativeFolderName;
|
||||
rv = ConvertFromUnicode(nsMsgI18NFileSystemCharset(), nsAutoString(folderName),
|
||||
getter_Copies(nativeFolderName));
|
||||
@ -839,8 +851,14 @@ nsMsgLocalMailFolder::CreateSubfolder(const PRUnichar *folderName, nsIMsgWindow
|
||||
nsCAutoString safeFolderName;
|
||||
safeFolderName.Assign(nativeFolderName.get());
|
||||
NS_MsgHashIfNecessary(safeFolderName);
|
||||
path += safeFolderName.get();
|
||||
|
||||
|
||||
path += safeFolderName.get();
|
||||
if (path.Exists()) //check this because localized names are different from disk names
|
||||
{
|
||||
ThrowAlertMsg("folderExists", msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
}
|
||||
|
||||
nsOutputFileStream outputStream(path, PR_WRONLY | PR_CREATE_FILE, 00600);
|
||||
if (outputStream.is_open())
|
||||
{
|
||||
@ -894,7 +912,6 @@ nsMsgLocalMailFolder::CreateSubfolder(const PRUnichar *folderName, nsIMsgWindow
|
||||
nsCOMPtr<nsISupports> folderSupports(do_QueryInterface(NS_STATIC_CAST(nsIMsgLocalMailFolder*, this), &rv));
|
||||
if(childSupports && NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
||||
NotifyItemAdded(folderSupports, childSupports, "folderView");
|
||||
}
|
||||
}
|
||||
@ -982,7 +999,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EmptyTrash(nsIMsgWindow *msgWindow,
|
||||
nsXPIDLCString trashUri;
|
||||
trashFolder->GetURI(getter_Copies(trashUri));
|
||||
trashFolder->GetFlags(&flags);
|
||||
trashFolder->RecursiveSetDeleteIsMoveToTrash(PR_FALSE);
|
||||
PRInt32 totalMessages = 0;
|
||||
rv = trashFolder->GetTotalMessages(PR_TRUE, &totalMessages);
|
||||
|
||||
@ -1073,73 +1089,21 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Delete()
|
||||
|
||||
nsLocalFolderSummarySpec summarySpec(path);
|
||||
|
||||
if (!mDeleteIsMoveToTrash)
|
||||
//Clean up .sbd folder if it exists.
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
//Clean up .sbd folder if it exists.
|
||||
if(NS_SUCCEEDED(rv))
|
||||
{
|
||||
// Remove summary file.
|
||||
summarySpec.Delete(PR_FALSE);
|
||||
// Remove summary file.
|
||||
summarySpec.Delete(PR_FALSE);
|
||||
|
||||
//Delete mailbox
|
||||
path.Delete(PR_FALSE);
|
||||
//Delete mailbox
|
||||
path.Delete(PR_FALSE);
|
||||
|
||||
if (!path.IsDirectory())
|
||||
AddDirectorySeparator(path);
|
||||
if (!path.IsDirectory())
|
||||
AddDirectorySeparator(path);
|
||||
|
||||
//If this is a directory, then remove it.
|
||||
if (path.IsDirectory())
|
||||
{
|
||||
path.Delete(PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // move to trash folder
|
||||
nsXPIDLString idlName;
|
||||
nsCOMPtr<nsIMsgFolder> child;
|
||||
nsAutoString folderName;
|
||||
nsCOMPtr<nsIMsgFolder> trashFolder;
|
||||
nsCOMPtr<nsIFileSpec> trashSpec;
|
||||
nsFileSpec trashPath;
|
||||
|
||||
GetName(getter_Copies(idlName));
|
||||
folderName.Assign(idlName);
|
||||
|
||||
rv = GetTrashFolder(getter_AddRefs(trashFolder));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = trashFolder->GetPath(getter_AddRefs(trashSpec));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = trashSpec->GetFileSpec(&trashPath);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
AddDirectorySeparator(trashPath);
|
||||
if (!trashPath.IsDirectory())
|
||||
trashPath.CreateDirectory();
|
||||
|
||||
nsFileSpec oldPath = path;
|
||||
|
||||
rv = path.MoveToDir(trashPath);
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
summarySpec.MoveToDir(trashPath);
|
||||
|
||||
AddDirectorySeparator(oldPath);
|
||||
if (oldPath.IsDirectory())
|
||||
oldPath.Delete(PR_TRUE);
|
||||
|
||||
trashFolder->AddSubfolder(&folderName, getter_AddRefs(child));
|
||||
if (child)
|
||||
{
|
||||
child->SetName(folderName.get());
|
||||
nsCOMPtr<nsISupports> childSupports = do_QueryInterface(child);
|
||||
nsCOMPtr<nsISupports> trashSupports = do_QueryInterface(trashFolder);
|
||||
if (childSupports && trashSupports)
|
||||
{
|
||||
NotifyItemAdded(trashSupports, childSupports, "folderView");
|
||||
}
|
||||
}
|
||||
}
|
||||
//If this is a directory, then remove it.
|
||||
if (path.IsDirectory())
|
||||
path.Delete(PR_TRUE);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
@ -1152,19 +1116,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::DeleteSubFolders(
|
||||
rv = IsChildOfTrash(&isChildOfTrash);
|
||||
|
||||
if (isChildOfTrash)
|
||||
{
|
||||
PRUint32 count;
|
||||
rv = folders->Count(&count);
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
for(PRUint32 i = 0; i < count; i++)
|
||||
{
|
||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(folders->ElementAt(i));
|
||||
folder = do_QueryInterface(supports);
|
||||
if(folder)
|
||||
folder->RecursiveSetDeleteIsMoveToTrash(PR_FALSE);
|
||||
}
|
||||
return nsMsgFolder::DeleteSubFolders(folders, msgWindow);
|
||||
}
|
||||
|
||||
if (!msgWindow)
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
@ -1174,8 +1126,8 @@ NS_IMETHODIMP nsMsgLocalMailFolder::DeleteSubFolders(
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
// we don't allow multiple folder selection so this is ok.
|
||||
nsCOMPtr<nsISupports> supports = getter_AddRefs(folders->ElementAt(0));
|
||||
nsCOMPtr<nsIMsgFolder> folder = do_QueryInterface(supports);
|
||||
nsCOMPtr<nsIMsgFolder> folder;
|
||||
folders->QueryElementAt(0, NS_GET_IID(nsIMsgFolder), (void **) getter_AddRefs(folder));
|
||||
if (folder)
|
||||
trashFolder->CopyFolder(folder, PR_TRUE, msgWindow, nsnull);
|
||||
}
|
||||
@ -1244,12 +1196,15 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
||||
nsXPIDLCString convertedNewName;
|
||||
if (NS_FAILED(ConvertFromUnicode(nsMsgI18NFileSystemCharset(), nsAutoString(aNewName), getter_Copies(convertedNewName))))
|
||||
return NS_ERROR_FAILURE;
|
||||
nsCAutoString newNameStr(convertedNewName.get());
|
||||
|
||||
nsCAutoString newDiskName;
|
||||
newDiskName.Assign(convertedNewName.get());
|
||||
NS_MsgHashIfNecessary(newDiskName);
|
||||
|
||||
nsXPIDLCString oldLeafName;
|
||||
oldPathSpec->GetLeafName(getter_Copies(oldLeafName));
|
||||
|
||||
if (PL_strcasecmp(oldLeafName, convertedNewName) == 0)
|
||||
if (mName.Equals(aNewName, nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if(msgWindow)
|
||||
rv=ThrowAlertMsg("folderExists", msgWindow);
|
||||
@ -1268,20 +1223,21 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
||||
if (!parentPath.IsDirectory())
|
||||
AddDirectorySeparator(parentPath);
|
||||
|
||||
rv = CheckIfFolderExists(aNewName, parentPath, msgWindow);
|
||||
rv = CheckIfFolderExists(aNewName, parentFolder, msgWindow);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
}
|
||||
|
||||
NotifyStoreClosedAllHeaders();
|
||||
ForceDBClosed();
|
||||
|
||||
nsCAutoString newNameDirStr(newDiskName.get()); //save of dir name before appending .msf
|
||||
|
||||
rv = oldPathSpec->Rename(newNameStr.get());
|
||||
rv = oldPathSpec->Rename(newDiskName.get());
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
newNameStr += ".msf";
|
||||
oldSummarySpec.Rename(newNameStr.get());
|
||||
newDiskName += ".msf";
|
||||
oldSummarySpec.Rename(newDiskName.get());
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1292,7 +1248,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
||||
if (NS_SUCCEEDED(rv) && cnt > 0)
|
||||
{
|
||||
// rename "*.sbd" directory
|
||||
nsCAutoString newNameDirStr(convertedNewName.get());
|
||||
newNameDirStr += ".sbd";
|
||||
dirSpec.Rename(newNameDirStr.get());
|
||||
}
|
||||
@ -1304,7 +1259,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
||||
rv = parentFolder->AddSubfolder(&newFolderName, getter_AddRefs(newFolder));
|
||||
if (newFolder)
|
||||
{
|
||||
newFolder->SetName(newFolderName.get());
|
||||
newFolder->SetPrettyName(newFolderName.get());
|
||||
PRBool changed = PR_FALSE;
|
||||
MatchOrChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
|
||||
if (changed)
|
||||
@ -1356,7 +1311,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::RenameSubFolders(nsIMsgWindow *msgWindow, ns
|
||||
AddSubfolder(&folderNameStr, getter_AddRefs(newFolder));
|
||||
if (newFolder)
|
||||
{
|
||||
newFolder->SetName(folderName);
|
||||
newFolder->SetPrettyName(folderName.get());
|
||||
PRBool changed = PR_FALSE;
|
||||
msgFolder->MatchOrChangeFilterDestination(newFolder, PR_TRUE /*caseInsenstive*/, &changed);
|
||||
if (changed)
|
||||
@ -1374,6 +1329,20 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetPrettyName(PRUnichar ** prettyName)
|
||||
return nsMsgFolder::GetPrettyName(prettyName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::SetPrettyName(const PRUnichar *aName)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aName);
|
||||
nsresult rv = nsMsgFolder::SetPrettyName(aName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
return SetStringProperty("folderName", NS_ConvertUCS2toUTF8(mName).get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::GetName(PRUnichar **aName)
|
||||
{
|
||||
ReadDBFolderInfo(PR_FALSE);
|
||||
return nsMsgFolder::GetName(aName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMsgLocalMailFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgDatabase **db)
|
||||
{
|
||||
@ -1402,6 +1371,25 @@ nsMsgLocalMailFolder::GetDBFolderInfoAndDB(nsIDBFolderInfo **folderInfo, nsIMsgD
|
||||
return openErr;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::ReadFromFolderCacheElem(nsIMsgFolderCacheElement *element)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(element);
|
||||
nsresult rv = nsMsgDBFolder::ReadFromFolderCacheElem(element);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsXPIDLCString utf8Name;
|
||||
rv = element->GetStringProperty("folderName", getter_Copies(utf8Name));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mName = NS_ConvertUTF8toUCS2(utf8Name.get());
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::WriteToFolderCacheElem(nsIMsgFolderCacheElement *element)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(element);
|
||||
nsMsgDBFolder::WriteToFolderCacheElem(element);
|
||||
return element->SetStringProperty("folderName", NS_ConvertUCS2toUTF8(mName).get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMsgLocalMailFolder::UpdateSummaryTotals(PRBool force)
|
||||
{
|
||||
if (!mNotifyCountChanges)
|
||||
@ -1433,15 +1421,8 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetDeletable(PRBool *deletable)
|
||||
|
||||
PRBool isServer;
|
||||
GetIsServer(&isServer);
|
||||
// These are specified in the "Mail/News Windows" UI spec
|
||||
if (mFlags & MSG_FOLDER_FLAG_TRASH)
|
||||
{
|
||||
PRBool moveToTrash;
|
||||
GetDeleteIsMoveToTrash(&moveToTrash);
|
||||
if(moveToTrash)
|
||||
*deletable = PR_TRUE; // allow delete of trash if we don't use trash
|
||||
}
|
||||
else if (isServer)
|
||||
// These are specified in the "Mail/News Windows" UI spe
|
||||
if (isServer)
|
||||
*deletable = PR_FALSE;
|
||||
else if (mFlags & MSG_FOLDER_FLAG_INBOX ||
|
||||
mFlags & MSG_FOLDER_FLAG_DRAFTS ||
|
||||
@ -2078,18 +2059,22 @@ nsMsgLocalMailFolder::CopyFolderLocal(nsIMsgFolder *srcFolder, PRBool isMoveFold
|
||||
newPath.CreateDirectory();
|
||||
}
|
||||
|
||||
rv = CheckIfFolderExists(idlName.get(), newPath, msgWindow);
|
||||
if(NS_FAILED(rv)) return rv;
|
||||
rv = CheckIfFolderExists(folderName.get(), this, msgWindow);
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsFileSpec path = oldPath;
|
||||
|
||||
rv = path.CopyToDir(newPath); //copying necessary for aborting.... if failure return
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv); //would fail if a file by that name exists
|
||||
|
||||
rv = summarySpec.CopyToDir(newPath);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
AddSubfolder(&folderName, getter_AddRefs(newMsgFolder));
|
||||
rv = AddSubfolder(&folderName, getter_AddRefs(newMsgFolder));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
newMsgFolder->SetPrettyName(folderName.get());
|
||||
|
||||
PRUint32 flags;
|
||||
srcFolder->GetFlags(&flags);
|
||||
@ -2120,16 +2105,14 @@ nsMsgLocalMailFolder::CopyFolderLocal(nsIMsgFolder *srcFolder, PRBool isMoveFold
|
||||
|
||||
if (isMoveFolder && NS_SUCCEEDED(copyStatus))
|
||||
{
|
||||
if (newMsgFolder) //notifying the "folder" that was dragged and dropped has been created.
|
||||
{ //no need to do this for its subfolders - isMoveFolder will be true for "folder"
|
||||
newMsgFolder->SetName(folderName.get());
|
||||
nsCOMPtr<nsISupports> supports = do_QueryInterface(newMsgFolder);
|
||||
nsCOMPtr <nsISupports> parentSupports = do_QueryInterface((nsIMsgLocalMailFolder*)this);
|
||||
//notifying the "folder" that was dragged and dropped has been created.
|
||||
//no need to do this for its subfolders - isMoveFolder will be true for "folder"
|
||||
nsCOMPtr<nsISupports> supports = do_QueryInterface(newMsgFolder);
|
||||
nsCOMPtr <nsISupports> parentSupports = do_QueryInterface((nsIMsgLocalMailFolder*)this);
|
||||
|
||||
if (supports && parentSupports)
|
||||
NotifyItemAdded(parentSupports, supports, "folderView");
|
||||
|
||||
if (supports && parentSupports)
|
||||
NotifyItemAdded(parentSupports, supports, "folderView");
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIMsgFolder> msgParent;
|
||||
srcFolder->GetParentMsgFolder(getter_AddRefs(msgParent));
|
||||
srcFolder->SetParent(nsnull);
|
||||
@ -2146,7 +2129,6 @@ nsMsgLocalMailFolder::CopyFolderLocal(nsIMsgFolder *srcFolder, PRBool isMoveFold
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -2660,7 +2642,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
|
||||
srcFolder->NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);
|
||||
|
||||
(void) OnCopyCompleted(mCopyState->m_srcSupport, PR_TRUE);
|
||||
// enable the dest folder
|
||||
// enable the dest folder
|
||||
EnableNotifications(allMessageCountNotifications, PR_TRUE, PR_FALSE /*dbBatching*/); //dest folder doesn't need db batching
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,6 +141,7 @@ public:
|
||||
NS_IMETHOD RenameSubFolders (nsIMsgWindow *msgWindow, nsIMsgFolder *oldFolder);
|
||||
|
||||
NS_IMETHOD GetPrettyName(PRUnichar** prettyName); // Override of the base, for top-level mail folder
|
||||
NS_IMETHOD SetPrettyName(const PRUnichar *aName);
|
||||
|
||||
NS_IMETHOD GetFolderURL(char **url);
|
||||
|
||||
@ -173,6 +174,11 @@ public:
|
||||
NS_IMETHOD NotifyCompactCompleted();
|
||||
NS_IMETHOD Shutdown(PRBool shutdownChildren);
|
||||
|
||||
NS_IMETHOD WriteToFolderCacheElem(nsIMsgFolderCacheElement *element);
|
||||
NS_IMETHOD ReadFromFolderCacheElem(nsIMsgFolderCacheElement *element);
|
||||
|
||||
NS_IMETHOD GetName(PRUnichar **aName);
|
||||
|
||||
protected:
|
||||
nsresult CopyFolderAcrossServer(nsIMsgFolder *srcFolder, nsIMsgWindow *msgWindow,nsIMsgCopyServiceListener* listener);
|
||||
|
||||
@ -185,7 +191,7 @@ protected:
|
||||
nsresult RecursiveSetDeleteIsMoveTrash(PRBool bVal);
|
||||
nsresult ConfirmFolderDeletion(nsIMsgWindow *aMsgWindow, PRBool *aResult);
|
||||
|
||||
nsresult CheckIfFolderExists(const PRUnichar *folderName, nsFileSpec &path, nsIMsgWindow *msgWindow);
|
||||
nsresult CheckIfFolderExists(const PRUnichar *newFolderName, nsIMsgFolder *parentFolder, nsIMsgWindow *msgWindow);
|
||||
|
||||
/* Finds the directory associated with this folder. That is if the path is
|
||||
c:\Inbox, it will return c:\Inbox.sbd if it succeeds. If that path doesn't
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user