Bug 470447 - Auto-Sync improvement: Default folder strategy should give higher priority to the folders opened by the user; r+sr=bienvenu

This commit is contained in:
Emre Birol 2008-12-27 18:07:00 +01:00
Родитель 03a30bcba7
Коммит c58bfe5c33
1 изменённых файлов: 32 добавлений и 5 удалений

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

@ -43,6 +43,7 @@
#include "nsIMsgMailNewsUrl.h"
#include "nsIMsgAccountManager.h"
#include "nsIMsgIncomingServer.h"
#include "nsIMsgMailSession.h"
#include "nsMsgFolderFlags.h"
#include "nsImapIncomingServer.h"
#include "nsMsgUtils.h"
@ -148,12 +149,38 @@ NS_IMETHODIMP nsDefaultAutoSyncFolderStrategy::Sort(nsIMsgFolder *aFolderA,
//Follow this order;
// INBOX > DRAFTS > SUBFOLDERS > TRASH
if (isInbox2 || (isDrafts2 && !isInbox1) || isTrash1)
*aDecision = nsAutoSyncStrategyDecisions::Higher;
else if (isInbox1 || (isDrafts1 && !isDrafts2) || isTrash2)
*aDecision = nsAutoSyncStrategyDecisions::Lower;
// test whether the folder is opened by the user.
// we give high priority to the folders explicitly opened by
// the user.
nsresult rv;
PRBool folderAOpen = PR_FALSE;
PRBool folderBOpen = PR_FALSE;
nsCOMPtr<nsIMsgMailSession> session =
do_GetService(NS_MSGMAILSESSION_CONTRACTID, &rv);
if (NS_SUCCEEDED(rv) && session)
{
session->IsFolderOpenInWindow(aFolderA, &folderAOpen);
session->IsFolderOpenInWindow(aFolderB, &folderBOpen);
}
//
if (folderAOpen == folderBOpen)
{
// if both of them or none of them are opened by the user
// make your decision based on the folder type
if (isInbox2 || (isDrafts2 && !isInbox1) || isTrash1)
*aDecision = nsAutoSyncStrategyDecisions::Higher;
else if (isInbox1 || (isDrafts1 && !isDrafts2) || isTrash2)
*aDecision = nsAutoSyncStrategyDecisions::Lower;
else
*aDecision = nsAutoSyncStrategyDecisions::Same;
}
else
*aDecision = nsAutoSyncStrategyDecisions::Same;
{
// otherwise give higher priority to opened one
*aDecision = folderBOpen ? nsAutoSyncStrategyDecisions::Higher :
nsAutoSyncStrategyDecisions::Lower;
}
return NS_OK;
}