mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
107598 r=racham sr=bienvenu. Imap folder creation is first done on server then on client so we need to
notify filterEditor window that we are done with folder creation and then we can set the folder picker to new folder. Added SetBusyCursor for this action. Also remove alert code from imap and local and use existing "ThrowAlertMsg" in base.
This commit is contained in:
parent
7716bf30c8
commit
9e2c1a9793
@ -65,6 +65,7 @@ downloadingNewsgroups=Downloading Newsgroups for Offline Use
|
||||
downloadingMail=Downloading Mail for Offline Use
|
||||
sendingUnsent=Sending Unsent Messages
|
||||
|
||||
folderExists=A folder with that name already exists. Please enter a different name.
|
||||
compactingFolder=Compacting folder %S...
|
||||
autoCompactAllFolders=Do you wish to compact all local and offline folders to save disk space?
|
||||
confirmFolderDeletionForFilter=Deleting the folder '%S' will disable its associated filter(s). Are you sure you want to delete the folder?
|
||||
|
@ -52,6 +52,7 @@ var gPreFillName;
|
||||
var nsMsgSearchScope = Components.interfaces.nsMsgSearchScope;
|
||||
var gPref;
|
||||
var gPrefBranch;
|
||||
var gMailSession = null;
|
||||
|
||||
var nsMsgFilterAction = Components.interfaces.nsMsgFilterAction;
|
||||
|
||||
@ -129,6 +130,12 @@ function filterEditorOnLoad()
|
||||
moveToAlertPosition();
|
||||
}
|
||||
|
||||
function filterEditorOnUnload()
|
||||
{
|
||||
if (gMailSession)
|
||||
gMailSession.RemoveFolderListener(gFolderListener);
|
||||
}
|
||||
|
||||
function onEnterInSearchTerm()
|
||||
{
|
||||
// do nothing. onOk() will get called since this is a dialog
|
||||
@ -169,6 +176,36 @@ function onCancel()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// the folderListener object
|
||||
var gFolderListener = {
|
||||
OnItemAdded: function(parentItem, item, view) {},
|
||||
|
||||
OnItemRemoved: function(parentItem, item, view){},
|
||||
|
||||
OnItemPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
|
||||
OnItemIntPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
|
||||
OnItemBoolPropertyChanged: function(item, property, oldValue, newValue) {},
|
||||
|
||||
OnItemUnicharPropertyChanged: function(item, property, oldValue, newValue){},
|
||||
OnItemPropertyFlagChanged: function(item, property, oldFlag, newFlag) {},
|
||||
|
||||
OnItemEvent: function(folder, event) {
|
||||
var eventType = event.GetUnicode();
|
||||
|
||||
if (eventType == "FolderCreateCompleted") {
|
||||
SetFolderPicker(folder.URI, gActionTargetElement.id);
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
else if (eventType == "FolderCreateFailed") {
|
||||
SetBusyCursor(window, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function duplicateFilterNameExists(filterName)
|
||||
{
|
||||
var args = window.arguments[0];
|
||||
@ -433,18 +470,49 @@ function GetFirstSelectedMsgFolder()
|
||||
|
||||
function SearchNewFolderOkCallback(name,uri)
|
||||
{
|
||||
var msgFolder = GetMsgFolderFromUri(uri, true);
|
||||
var msgWindow = GetFilterEditorMsgWindow();
|
||||
msgFolder.createSubfolder(name, msgWindow);
|
||||
var msgFolder = GetMsgFolderFromUri(uri, true);
|
||||
var imapFolder = null;
|
||||
try
|
||||
{
|
||||
imapFolder = msgFolder.QueryInterface(Components.interfaces.nsIMsgImapMailFolder);
|
||||
}
|
||||
catch(ex) {}
|
||||
var mailSessionContractID = "@mozilla.org/messenger/services/session;1";
|
||||
if (imapFolder) //imapFolder creation is asynchronous.
|
||||
{
|
||||
if (!gMailSession)
|
||||
gMailSession = Components.classes[mailSessionContractID].getService(Components.interfaces.nsIMsgMailSession);
|
||||
try
|
||||
{
|
||||
var nsIFolderListener = Components.interfaces.nsIFolderListener;
|
||||
var notifyFlags = nsIFolderListener.event;
|
||||
gMailSession.AddFolderListener(gFolderListener, notifyFlags);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
dump("Error adding to session: " +ex + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
var msgWindow = GetFilterEditorMsgWindow();
|
||||
|
||||
if (imapFolder)
|
||||
SetBusyCursor(window, true);
|
||||
|
||||
msgFolder.createSubfolder(name, msgWindow);
|
||||
|
||||
if (!imapFolder)
|
||||
{
|
||||
var curFolder = uri+"/"+name;
|
||||
SetFolderPicker(curFolder, gActionTargetElement.id);
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateAfterCustomHeaderChange()
|
||||
{
|
||||
updateSearchAttributes();
|
||||
}
|
||||
|
||||
//if you use msgWindow, please make sure that destructor gets called when you close the "window"
|
||||
function GetFilterEditorMsgWindow()
|
||||
{
|
||||
@ -457,3 +525,17 @@ function GetFilterEditorMsgWindow()
|
||||
}
|
||||
return gFilterEditorMsgWindow;
|
||||
}
|
||||
|
||||
function SetBusyCursor(window, enable)
|
||||
{
|
||||
// setCursor() is only available for chrome windows.
|
||||
// However one of our frames is the start page which
|
||||
// is a non-chrome window, so check if this window has a
|
||||
// setCursor method
|
||||
if ("setCursor" in window) {
|
||||
if (enable)
|
||||
window.setCursor("wait");
|
||||
else
|
||||
window.setCursor("auto");
|
||||
}
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ Contributor(s):
|
||||
width="510" height="360"
|
||||
persist="width height screenX screenY"
|
||||
onload="filterEditorOnLoad();"
|
||||
onunload="filterEditorOnUnload();"
|
||||
ondialogaccept="return onAccept();"
|
||||
ondialogcancel="return onCancel();">
|
||||
|
||||
|
@ -293,10 +293,6 @@
|
||||
## @loc None
|
||||
5058=Deleting this folder is not undoable and will delete all of the messages it contains. Are you sure you still want to delete this folder?
|
||||
|
||||
## @name IMAP_MAILBOX_ALREADY_EXISTS
|
||||
## @loc None
|
||||
5061=The mailbox already exists.
|
||||
|
||||
## @name IMAP_PERSONAL_FILING_CABINET
|
||||
## @loc None
|
||||
5062=Personal Filing Cabinet
|
||||
|
@ -708,44 +708,26 @@ NS_IMETHODIMP nsImapMailFolder::GetMessages(nsIMsgWindow *aMsgWindow, nsISimpleE
|
||||
NS_IMETHODIMP nsImapMailFolder::CreateSubfolder(const PRUnichar* folderName, nsIMsgWindow *msgWindow )
|
||||
{
|
||||
nsresult rv = NS_ERROR_NULL_POINTER;
|
||||
if (!folderName) return rv;
|
||||
if (!folderName)
|
||||
return rv;
|
||||
|
||||
if ( nsDependentString(folderName).Equals(NS_LITERAL_STRING("Trash"),nsCaseInsensitiveStringComparator()) ) // Trash , a special folder
|
||||
{
|
||||
AlertSpecialFolderExists(msgWindow);
|
||||
ThrowAlertMsg("folderExists", msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
}
|
||||
else if ( nsDependentString(folderName).Equals(NS_LITERAL_STRING("Inbox"),nsCaseInsensitiveStringComparator()) ) // Inbox, a special folder
|
||||
{
|
||||
AlertSpecialFolderExists(msgWindow);
|
||||
ThrowAlertMsg("folderExists", msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIImapService> imapService(do_GetService(kCImapService, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
rv = imapService->CreateFolder(m_eventQueue, this,
|
||||
folderName, this, nsnull);
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsImapMailFolder::AlertSpecialFolderExists(nsIMsgWindow *msgWindow)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
msgWindow->GetRootDocShell(getter_AddRefs(docShell));
|
||||
nsXPIDLString alertString;
|
||||
IMAPGetStringByID(IMAP_MAILBOX_ALREADY_EXISTS, getter_Copies(alertString));
|
||||
if (!alertString) return rv;
|
||||
if (docShell)
|
||||
{
|
||||
nsCOMPtr<nsIPrompt> dialog(do_GetInterface(docShell));
|
||||
if (dialog)
|
||||
{
|
||||
rv = dialog->Alert(nsnull, alertString);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -869,6 +851,7 @@ NS_IMETHODIMP nsImapMailFolder::CreateClientSubfolderInfo(const char *folderName
|
||||
unusedDB->Close(PR_TRUE);
|
||||
}
|
||||
}
|
||||
nsCOMPtr <nsIAtom> folderCreateAtom;
|
||||
if(NS_SUCCEEDED(rv) && child)
|
||||
{
|
||||
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
|
||||
@ -876,10 +859,16 @@ NS_IMETHODIMP nsImapMailFolder::CreateClientSubfolderInfo(const char *folderName
|
||||
rv = QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(folderSupports));
|
||||
if(childSupports && NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
||||
NotifyItemAdded(folderSupports, childSupports, "folderView");
|
||||
folderCreateAtom = getter_AddRefs(NS_NewAtom("FolderCreateCompleted"));
|
||||
child->NotifyFolderEvent(folderCreateAtom);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
folderCreateAtom = getter_AddRefs(NS_NewAtom("FolderCreateFailed"));
|
||||
NotifyFolderEvent(folderCreateAtom);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@ -4298,11 +4287,19 @@ nsImapMailFolder::OnStopRunningUrl(nsIURI *aUrl, nsresult aExitCode)
|
||||
|
||||
}
|
||||
break;
|
||||
case nsIImapUrl::nsImapRefreshFolderUrls:
|
||||
// we finished getting an admin url for the folder.
|
||||
case nsIImapUrl::nsImapRefreshFolderUrls:
|
||||
// we finished getting an admin url for the folder.
|
||||
if (!m_adminUrl.IsEmpty())
|
||||
FolderPrivileges(aWindow);
|
||||
break;
|
||||
case nsIImapUrl::nsImapCreateFolder:
|
||||
if (NS_FAILED(aExitCode)) //if success notification already done
|
||||
{
|
||||
nsCOMPtr <nsIAtom> folderCreateAtom;
|
||||
folderCreateAtom = getter_AddRefs(NS_NewAtom("FolderCreateFailed"));
|
||||
NotifyFolderEvent(folderCreateAtom);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -6703,6 +6700,7 @@ NS_IMETHODIMP nsImapMailFolder::RenameClient(nsIMsgWindow *msgWindow, nsIMsgFold
|
||||
nsCOMPtr<nsISupports> childSupports(do_QueryInterface(child));
|
||||
nsCOMPtr<nsISupports> parentSupports;
|
||||
rv = QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(parentSupports));
|
||||
|
||||
if(childSupports && NS_SUCCEEDED(rv))
|
||||
{
|
||||
NotifyItemAdded(parentSupports, childSupports, "folderView");
|
||||
|
@ -359,8 +359,6 @@ public:
|
||||
protected:
|
||||
// Helper methods
|
||||
|
||||
nsresult AlertSpecialFolderExists(nsIMsgWindow *msgWindow);
|
||||
|
||||
void FindKeysToAdd(const nsMsgKeyArray &existingKeys, nsMsgKeyArray
|
||||
&keysToFetch, nsIImapFlagAndUidState *flagState);
|
||||
void FindKeysToDelete(const nsMsgKeyArray &existingKeys, nsMsgKeyArray
|
||||
|
@ -102,7 +102,6 @@ NS_END_EXTERN_C
|
||||
#define IMAP_DELETE_NO_TRASH 5058
|
||||
#define IMAP_HTML_NO_CACHED_BODY_TITLE 5059
|
||||
#define IMAP_HTML_NO_CACHED_BODY_BODY 5060
|
||||
#define IMAP_MAILBOX_ALREADY_EXISTS 5061
|
||||
#define IMAP_PERSONAL_FILING_CABINET 5062
|
||||
#define IMAP_PFC_READ_MAIL 5063
|
||||
#define IMAP_PFC_SENT_MAIL 5064
|
||||
|
@ -167,10 +167,6 @@
|
||||
## @loc None
|
||||
4021=Are you sure you want to move the selected folder into the Trash?
|
||||
|
||||
## @name POP3_FOLDER_ALREADY_EXISTS
|
||||
## @loc None
|
||||
4022=A folder with that name already exists.
|
||||
|
||||
## @name POP3_FOLDER_FOR_TRASH
|
||||
## @loc None
|
||||
4023=The Trash already contained a folder named %s. The folder which you just deleted can be found in the Trash under the new name %s.
|
||||
|
@ -763,30 +763,6 @@ NS_IMETHODIMP nsMsgLocalMailFolder::CreateStorageIfMissing(nsIUrlListener* urlLi
|
||||
return status;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgLocalMailFolder::AlertFolderExists(nsIMsgWindow *msgWindow)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
nsCOMPtr<nsIDocShell> docShell;
|
||||
msgWindow->GetRootDocShell(getter_AddRefs(docShell));
|
||||
if (!mMsgStringService)
|
||||
mMsgStringService = do_GetService(NS_MSG_POPSTRINGSERVICE_CONTRACTID);
|
||||
if (!mMsgStringService) return NS_ERROR_FAILURE;
|
||||
PRUnichar *alertString = nsnull;
|
||||
mMsgStringService->GetStringByID(POP3_FOLDER_ALREADY_EXISTS, &alertString);
|
||||
if (!alertString) return rv;
|
||||
if (docShell)
|
||||
{
|
||||
nsCOMPtr<nsIPrompt> dialog(do_GetInterface(docShell));
|
||||
if (dialog)
|
||||
{
|
||||
rv = dialog->Alert(nsnull, alertString);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsMsgLocalMailFolder::CheckIfFolderExists(const PRUnichar *folderName, nsFileSpec &path, nsIMsgWindow *msgWindow)
|
||||
{
|
||||
@ -805,7 +781,7 @@ nsMsgLocalMailFolder::CheckIfFolderExists(const PRUnichar *folderName, nsFileSpe
|
||||
nsCaseInsensitiveStringComparator()))
|
||||
{
|
||||
if (msgWindow)
|
||||
AlertFolderExists(msgWindow);
|
||||
ThrowAlertMsg("folderExists", msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
}
|
||||
}
|
||||
@ -1265,7 +1241,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::Rename(const PRUnichar *aNewName, nsIMsgWind
|
||||
|
||||
if (PL_strcasecmp(oldLeafName, convertedNewName) == 0) {
|
||||
if(msgWindow)
|
||||
rv=AlertFolderExists(msgWindow);
|
||||
rv=ThrowAlertMsg("folderExists", msgWindow);
|
||||
return NS_MSG_FOLDER_EXISTS;
|
||||
}
|
||||
else
|
||||
|
@ -178,7 +178,6 @@ protected:
|
||||
nsresult WriteStartOfNewMessage();
|
||||
nsresult IsChildOfTrash(PRBool *result);
|
||||
nsresult RecursiveSetDeleteIsMoveTrash(PRBool bVal);
|
||||
nsresult AlertFolderExists(nsIMsgWindow *msgWindow);
|
||||
|
||||
nsresult CheckIfFolderExists(const PRUnichar *folderName, nsFileSpec &path, nsIMsgWindow *msgWindow);
|
||||
|
||||
|
@ -79,7 +79,6 @@ private:
|
||||
#define POP3_NO_ANSWER 4019
|
||||
#define POP3_ENTER_PASSWORD_PROMPT_TITLE 4020
|
||||
#define POP3_MOVE_FOLDER_TO_TRASH 4021
|
||||
#define POP3_FOLDER_ALREADY_EXISTS 4022
|
||||
#define POP3_FOLDER_FOR_TRASH 4023
|
||||
#define POP3_STAT_FAILURE 4024
|
||||
#define POP3_SERVER_SAID 4025
|
||||
|
Loading…
Reference in New Issue
Block a user