store labels on the imap server r=naving, sr=sspitzer 114379 show shared imap folders with special icon 28756 r=naving, sr=sspitzer fix subscribe/unsubscribe to utf7 imap folders r=naving, sr=sspitzer

This commit is contained in:
bienvenu%netscape.com 2002-02-14 01:05:37 +00:00
Родитель fe45ee7e7d
Коммит 6969f40fbd
12 изменённых файлов: 239 добавлений и 237 удалений

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

@ -62,8 +62,6 @@ public:
NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol, NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights) = 0; nsIMAPACLRightsInfo* aclRights) = 0;
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights) = 0;
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol, NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* keyArray, nsMsgKeyArray* keyArray,
const char *msgIdString, const char *msgIdString,

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

@ -47,6 +47,7 @@ interface nsIImapServerSink : nsISupports {
boolean possibleImapMailbox(in string folderPath, in wchar hierarchyDelim, in long boxFlags); boolean possibleImapMailbox(in string folderPath, in wchar hierarchyDelim, in long boxFlags);
boolean folderNeedsACLInitialized(in string folderPath); boolean folderNeedsACLInitialized(in string folderPath);
void addFolderRights(in string folderPath, in string userName, in string rights); void addFolderRights(in string folderPath, in string userName, in string rights);
void refreshFolderRights(in string folderPath);
void discoveryDone(); void discoveryDone();
void onlineFolderDelete(in string aFolderName); void onlineFolderDelete(in string aFolderName);
void onlineFolderCreateFailed(in string aFolderName); void onlineFolderCreateFailed(in string aFolderName);

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

@ -76,6 +76,7 @@ interface nsIMsgImapMailFolder : nsISupports {
void folderPrivileges(in nsIMsgWindow aWindow); void folderPrivileges(in nsIMsgWindow aWindow);
nsIMsgImapMailFolder findOnlineSubFolder(in string onlineName); nsIMsgImapMailFolder findOnlineSubFolder(in string onlineName);
void addFolderRights(in string userName, in string rights); void addFolderRights(in string userName, in string rights);
void refreshFolderRights();
attribute boolean verifiedAsOnlineFolder; attribute boolean verifiedAsOnlineFolder;
attribute boolean explicitlyVerify; attribute boolean explicitlyVerify;
attribute wchar hierarchyDelimiter; attribute wchar hierarchyDelimiter;

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

@ -66,22 +66,22 @@ typedef PRUint16 imapMessageFlagsType;
/* flags for individual messages */ /* flags for individual messages */
/* currently the ui only offers \Seen and \Flagged */ /* currently the ui only offers \Seen and \Flagged */
#define kNoImapMsgFlag 0x0000 #define kNoImapMsgFlag 0x0000
#define kImapMsgSeenFlag 0x0001 #define kImapMsgSeenFlag 0x0001
#define kImapMsgAnsweredFlag 0x0002 #define kImapMsgAnsweredFlag 0x0002
#define kImapMsgFlaggedFlag 0x0004 #define kImapMsgFlaggedFlag 0x0004
#define kImapMsgDeletedFlag 0x0008 #define kImapMsgDeletedFlag 0x0008
#define kImapMsgDraftFlag 0x0010 #define kImapMsgDraftFlag 0x0010
#define kImapMsgRecentFlag 0x0020 #define kImapMsgRecentFlag 0x0020
#define kImapMsgForwardedFlag 0x0040 /* Not always supported, check mailbox folder */ #define kImapMsgForwardedFlag 0x0040 /* Not always supported, check mailbox folder */
#define kImapMsgMDNSentFlag 0x0080 /* Not always supported. check mailbox folder */ #define kImapMsgMDNSentFlag 0x0080 /* Not always supported. check mailbox folder */
#define kImapMsgLabelFlags 0x0E00 /* supports 5 labels only supported if the folder supports keywords */
#define kImapMsgSupportMDNSentFlag 0x2000 #define kImapMsgSupportMDNSentFlag 0x2000
#define kImapMsgSupportForwardedFlag 0x4000 #define kImapMsgSupportForwardedFlag 0x4000
#define kImapMsgSupportUserFlag 0x8000 /* This seems to be the most cost effective way of #define kImapMsgSupportUserFlag 0x8000
* piggying back the server support user flag /* This seems to be the most cost effective way of
* info. * piggying back the server support user flag info.
*/ */
/* if a url creator does not know the hierarchySeparator, use this */ /* if a url creator does not know the hierarchySeparator, use this */
#define kOnlineHierarchySeparatorUnknown '^' #define kOnlineHierarchySeparatorUnknown '^'

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

@ -1330,6 +1330,24 @@ NS_IMETHODIMP nsImapIncomingServer::FolderNeedsACLInitialized(const char *folder
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP nsImapIncomingServer::RefreshFolderRights(const char *folderPath)
{
nsCOMPtr <nsIFolder> rootFolder;
nsresult rv = GetRootFolder(getter_AddRefs(rootFolder));
if(NS_SUCCEEDED(rv) && rootFolder)
{
nsCOMPtr <nsIMsgImapMailFolder> imapRoot = do_QueryInterface(rootFolder);
if (imapRoot)
{
nsCOMPtr <nsIMsgImapMailFolder> foundFolder;
rv = imapRoot->FindOnlineSubFolder(folderPath, getter_AddRefs(foundFolder));
if (NS_SUCCEEDED(rv) && foundFolder)
return foundFolder->RefreshFolderRights();
}
}
return rv;
}
NS_IMETHODIMP nsImapIncomingServer::GetRedirectorType(char **redirectorType) NS_IMETHODIMP nsImapIncomingServer::GetRedirectorType(char **redirectorType)
{ {
nsresult rv; nsresult rv;
@ -2879,29 +2897,29 @@ nsImapIncomingServer::GetSubscribeListener(nsISubscribeListener **aListener)
NS_IMETHODIMP NS_IMETHODIMP
nsImapIncomingServer::Subscribe(const PRUnichar *aName) nsImapIncomingServer::Subscribe(const PRUnichar *aName)
{ {
return SubscribeToFolder(aName, PR_TRUE); return SubscribeToFolder(aName, PR_TRUE);
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapIncomingServer::Unsubscribe(const PRUnichar *aName) nsImapIncomingServer::Unsubscribe(const PRUnichar *aName)
{ {
return SubscribeToFolder(aName, PR_FALSE); return SubscribeToFolder(aName, PR_FALSE);
} }
nsresult nsresult
nsImapIncomingServer::SubscribeToFolder(const PRUnichar *aName, PRBool subscribe) nsImapIncomingServer::SubscribeToFolder(const PRUnichar *aName, PRBool subscribe)
{ {
nsresult rv; nsresult rv;
nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv); nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!imapService) return NS_ERROR_FAILURE; if (!imapService) return NS_ERROR_FAILURE;
nsCOMPtr<nsIFolder> rootFolder; nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder)); rv = GetRootFolder(getter_AddRefs(rootFolder));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder, &rv); nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (!rootMsgFolder) return NS_ERROR_FAILURE; if (!rootMsgFolder) return NS_ERROR_FAILURE;
// Locate the folder so that the correct hierarchical delimiter is used in the // Locate the folder so that the correct hierarchical delimiter is used in the
// folder pathnames, otherwise root's (ie, '^') is used and this is wrong. // folder pathnames, otherwise root's (ie, '^') is used and this is wrong.
@ -2916,46 +2934,44 @@ nsImapIncomingServer::SubscribeToFolder(const PRUnichar *aName, PRBool subscribe
msgFolder = do_QueryInterface(subFolder); msgFolder = do_QueryInterface(subFolder);
} }
nsCOMPtr<nsIEventQueue> queue; nsCOMPtr<nsIEventQueue> queue;
// get the Event Queue for this thread... // get the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> pEventQService = nsCOMPtr<nsIEventQueueService> pEventQService =
do_GetService(kEventQueueServiceCID, &rv); do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue)); rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
if (subscribe) { // ok, aName is really a fake unicode name,
rv = imapService->SubscribeFolder(queue, // just a utf-7 encoded ascii string 0 byte extended to unicode. So convert it
msgFolder, // to real unicode, and pass that into the subscribe routines.
aName, nsXPIDLString unicodeName;
nsnull, nsnull); CreateUnicodeStringFromUtf7(folderCName.get(), getter_Copies(unicodeName));
} // we need to convert aName, which is utf-7 encoded, to unicode
else { if (subscribe)
rv = imapService->UnsubscribeFolder(queue, rv = imapService->SubscribeFolder(queue, msgFolder, unicodeName.get(), nsnull, nsnull);
msgFolder, else
aName, rv = imapService->UnsubscribeFolder(queue, msgFolder, unicodeName.get(), nsnull, nsnull);
nsnull, nsnull);
}
if (NS_FAILED(rv)) return rv; if (NS_FAILED(rv)) return rv;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapIncomingServer::SetDoingLsub(PRBool doingLsub) nsImapIncomingServer::SetDoingLsub(PRBool doingLsub)
{ {
mDoingLsub = doingLsub; mDoingLsub = doingLsub;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapIncomingServer::GetDoingLsub(PRBool *doingLsub) nsImapIncomingServer::GetDoingLsub(PRBool *doingLsub)
{ {
if (!doingLsub) return NS_ERROR_NULL_POINTER; if (!doingLsub) return NS_ERROR_NULL_POINTER;
*doingLsub = mDoingLsub; *doingLsub = mDoingLsub;
return NS_OK; return NS_OK;
} }
NS_IMETHODIMP NS_IMETHODIMP

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

@ -96,6 +96,7 @@
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsIMAPNamespace.h" #include "nsIMAPNamespace.h"
#include "nsHashtable.h" #include "nsHashtable.h"
#include "nsMsgMessageFlags.h"
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID); static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID); static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -1054,6 +1055,7 @@ NS_IMETHODIMP nsImapMailFolder::GetNoSelect(PRBool *aResult)
NS_ENSURE_ARG_POINTER(aResult); NS_ENSURE_ARG_POINTER(aResult);
return GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, aResult); return GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, aResult);
} }
NS_IMETHODIMP nsImapMailFolder::Compact(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow) NS_IMETHODIMP nsImapMailFolder::Compact(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow)
{ {
nsresult rv; nsresult rv;
@ -2899,6 +2901,10 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindo
nsMsgLabelValue filterLabel; nsMsgLabelValue filterLabel;
filter->GetActionLabel(&filterLabel); filter->GetActionLabel(&filterLabel);
msgHdr->SetLabel(filterLabel); msgHdr->SetLabel(filterLabel);
nsMsgKeyArray keysToFlag;
keysToFlag.Add(msgKey);
StoreImapFlags((filterLabel << 9), PR_TRUE, keysToFlag.GetArray(), keysToFlag.GetSize());
} }
default: default:
break; break;
@ -3424,7 +3430,7 @@ void nsImapMailFolder::TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr
if (NS_SUCCEEDED(res) && foundIt) if (NS_SUCCEEDED(res) && foundIt)
{ {
// make a mask and clear these message flags // make a mask and clear these message flags
PRUint32 mask = MSG_FLAG_READ | MSG_FLAG_REPLIED | MSG_FLAG_MARKED | MSG_FLAG_IMAP_DELETED; PRUint32 mask = MSG_FLAG_READ | MSG_FLAG_REPLIED | MSG_FLAG_MARKED | MSG_FLAG_IMAP_DELETED | MSG_FLAG_LABELS;
PRUint32 dbHdrFlags; PRUint32 dbHdrFlags;
tweakMe->GetFlags(&dbHdrFlags); tweakMe->GetFlags(&dbHdrFlags);
@ -3473,6 +3479,11 @@ void nsImapMailFolder::TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr
if (imap_flags & kImapMsgForwardedFlag) if (imap_flags & kImapMsgForwardedFlag)
newFlags |= MSG_FLAG_FORWARDED; newFlags |= MSG_FLAG_FORWARDED;
// db label flags are 0x0E000000 and imap label flags are 0x0E00
// so we need to shift 16 bits to the left to convert them.
if (imap_flags & kImapMsgLabelFlags)
newFlags |= (imap_flags & kImapMsgLabelFlags) << 16;
if (newFlags) if (newFlags)
tweakMe->OrFlags(newFlags, &dbHdrFlags); tweakMe->OrFlags(newFlags, &dbHdrFlags);
} }
@ -3792,25 +3803,32 @@ nsImapMailFolder::NotifyMessageFlags(PRUint32 flags, nsMsgKey msgKey)
{ {
if (NS_SUCCEEDED(GetDatabase(nsnull)) && mDatabase) if (NS_SUCCEEDED(GetDatabase(nsnull)) && mDatabase)
{ {
nsCOMPtr<nsIMsgDBHdr> dbHdr; nsCOMPtr<nsIMsgDBHdr> dbHdr;
nsresult rv; nsresult rv;
PRBool containsKey; PRBool containsKey;
rv = mDatabase->ContainsKey(msgKey , &containsKey); rv = mDatabase->ContainsKey(msgKey , &containsKey);
// if we don't have the header, don't diddle the flags. // if we don't have the header, don't diddle the flags.
// GetMsgHdrForKey will create the header if it doesn't exist. // GetMsgHdrForKey will create the header if it doesn't exist.
if (NS_FAILED(rv) || !containsKey) if (NS_FAILED(rv) || !containsKey)
return rv; return rv;
rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(dbHdr)); rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(dbHdr));
if(NS_SUCCEEDED(rv) && dbHdr) if(NS_SUCCEEDED(rv) && dbHdr)
{ {
mDatabase->MarkHdrRead(dbHdr, (flags & kImapMsgSeenFlag) != 0, nsnull); mDatabase->MarkHdrRead(dbHdr, (flags & kImapMsgSeenFlag) != 0, nsnull);
mDatabase->MarkHdrReplied(dbHdr, (flags & kImapMsgAnsweredFlag) != 0, nsnull); mDatabase->MarkHdrReplied(dbHdr, (flags & kImapMsgAnsweredFlag) != 0, nsnull);
mDatabase->MarkHdrMarked(dbHdr, (flags & kImapMsgFlaggedFlag) != 0, nsnull); mDatabase->MarkHdrMarked(dbHdr, (flags & kImapMsgFlaggedFlag) != 0, nsnull);
mDatabase->MarkImapDeleted(msgKey, (flags & kImapMsgDeletedFlag) != 0, nsnull); mDatabase->MarkImapDeleted(msgKey, (flags & kImapMsgDeletedFlag) != 0, nsnull);
} // this turns on labels, but it doesn't handle the case where the user
// unlabels a message on one machine, and expects it to be unlabeled
// on their other machines. If I turn that on, I'll be removing all the labels
// that were assigned before we started storing them on the server, which will
// make some people very unhappy.
if (flags & kImapMsgLabelFlags)
mDatabase->SetLabel(msgKey, (flags & kImapMsgLabelFlags) >> 9);
}
} }
return NS_OK; return NS_OK;
@ -4418,8 +4436,7 @@ nsImapMailFolder::AddFolderRights(const char *userName, const char *rights)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsImapMailFolder::RefreshFolderRights(nsIImapProtocol* aProtocol, nsImapMailFolder::RefreshFolderRights()
nsIMAPACLRightsInfo* aclRights)
{ {
if (GetFolderACL()->GetIsFolderShared()) if (GetFolderACL()->GetIsFolderShared())
{ {

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

@ -308,8 +308,6 @@ public:
NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol, NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights); nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol, NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* keyArray, nsMsgKeyArray* keyArray,
const char* msgIdString, const char* msgIdString,

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

@ -3659,28 +3659,27 @@ PRBool nsImapProtocol::GetIOTunnellingEnabled()
// if userName is NULL, it means "me," or MYRIGHTS. // if userName is NULL, it means "me," or MYRIGHTS.
void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char *userName, const char *rights) void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char *userName, const char *rights)
{ {
nsIMAPACLRightsInfo *aclRightsInfo = new nsIMAPACLRightsInfo(); nsIMAPACLRightsInfo *aclRightsInfo = new nsIMAPACLRightsInfo();
if (aclRightsInfo) if (aclRightsInfo)
{ {
nsIMAPNamespace *namespaceForFolder = nsnull; nsIMAPNamespace *namespaceForFolder = nsnull;
const char *userName = GetImapUserName(); NS_ASSERTION (m_hostSessionList, "fatal ... null host session list");
NS_ASSERTION (m_hostSessionList, "fatal ... null host session list"); if (m_hostSessionList)
if (m_hostSessionList) m_hostSessionList->GetNamespaceForMailboxForHost(
m_hostSessionList->GetNamespaceForMailboxForHost( GetImapServerKey(), mailboxName,
GetImapServerKey(), mailboxName, namespaceForFolder);
namespaceForFolder);
aclRightsInfo->hostName = PL_strdup(GetImapHostName()); aclRightsInfo->hostName = PL_strdup(GetImapHostName());
if (namespaceForFolder) if (namespaceForFolder)
m_runningUrl->AllocateCanonicalPath( m_runningUrl->AllocateCanonicalPath(
mailboxName, mailboxName,
namespaceForFolder->GetDelimiter(), namespaceForFolder->GetDelimiter(),
&aclRightsInfo->mailboxName); &aclRightsInfo->mailboxName);
else else
m_runningUrl->AllocateCanonicalPath(mailboxName, m_runningUrl->AllocateCanonicalPath(mailboxName,
kOnlineHierarchySeparatorUnknown, kOnlineHierarchySeparatorUnknown,
&aclRightsInfo->mailboxName); &aclRightsInfo->mailboxName);
if (userName) if (userName)
aclRightsInfo->userName = PL_strdup(userName); aclRightsInfo->userName = PL_strdup(userName);
@ -3690,18 +3689,18 @@ void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char
if (aclRightsInfo->hostName && if (aclRightsInfo->hostName &&
aclRightsInfo->mailboxName && aclRightsInfo->rights && aclRightsInfo->mailboxName && aclRightsInfo->rights &&
userName ? (aclRightsInfo->userName != NULL) : PR_TRUE) userName ? (aclRightsInfo->userName != NULL) : PR_TRUE)
{ {
if (m_imapServerSink) if (m_imapServerSink)
{ {
m_imapServerSink->AddFolderRights(mailboxName, userName, rights); m_imapServerSink->AddFolderRights(mailboxName, userName, rights);
} }
} }
PR_FREEIF(aclRightsInfo->hostName); PR_FREEIF(aclRightsInfo->hostName);
PR_FREEIF(aclRightsInfo->mailboxName); PR_FREEIF(aclRightsInfo->mailboxName);
PR_FREEIF(aclRightsInfo->rights); PR_FREEIF(aclRightsInfo->rights);
PR_FREEIF(aclRightsInfo->userName); PR_FREEIF(aclRightsInfo->userName);
delete aclRightsInfo; delete aclRightsInfo;
} }
@ -5000,9 +4999,7 @@ void nsImapProtocol::RefreshACLForFolder(const char *mailboxName)
// Now, get the new one. // Now, get the new one.
GetACLForFolder(mailboxName); GetACLForFolder(mailboxName);
// We're all done, refresh the icon/flags for this folder // We're all done, refresh the icon/flags for this folder
#ifdef REFRESHING_VIEW
RefreshFolderACLView(mailboxName, ns); RefreshFolderACLView(mailboxName, ns);
#endif
break; break;
default: default:
// We know it's a public folder or other user's folder. // We know it's a public folder or other user's folder.
@ -5013,9 +5010,7 @@ void nsImapProtocol::RefreshACLForFolder(const char *mailboxName)
// Now, get the new one. // Now, get the new one.
GetMyRightsForFolder(mailboxName); GetMyRightsForFolder(mailboxName);
// We're all done, refresh the icon/flags for this folder // We're all done, refresh the icon/flags for this folder
#ifdef REFRESHING_VIEW
RefreshFolderACLView(mailboxName, ns); RefreshFolderACLView(mailboxName, ns);
#endif
break; break;
} }
} }
@ -5026,6 +5021,24 @@ void nsImapProtocol::RefreshACLForFolder(const char *mailboxName)
} }
} }
void nsImapProtocol::RefreshFolderACLView(const char *mailboxName, nsIMAPNamespace *nsForMailbox)
{
char *nonUTF7ConvertedName = CreateUtf7ConvertedString(mailboxName, FALSE);
nsXPIDLCString canonicalMailboxName;
if (nonUTF7ConvertedName)
mailboxName = nonUTF7ConvertedName;
if (nsForMailbox)
m_runningUrl->AllocateCanonicalPath(mailboxName, nsForMailbox->GetDelimiter(), getter_Copies(canonicalMailboxName));
else
m_runningUrl->AllocateCanonicalPath(mailboxName, kOnlineHierarchySeparatorUnknown, getter_Copies(canonicalMailboxName));
PR_Free(nonUTF7ConvertedName);
if (m_imapServerSink)
m_imapServerSink->RefreshFolderRights(canonicalMailboxName);
}
void nsImapProtocol::GetACLForFolder(const char *mailboxName) void nsImapProtocol::GetACLForFolder(const char *mailboxName)
{ {
IncrementCommandTagNumber(); IncrementCommandTagNumber();
@ -5045,37 +5058,37 @@ void nsImapProtocol::GetACLForFolder(const char *mailboxName)
void nsImapProtocol::OnRefreshAllACLs() void nsImapProtocol::OnRefreshAllACLs()
{ {
m_hierarchyNameState = kListingForInfoOnly; m_hierarchyNameState = kListingForInfoOnly;
nsIMAPMailboxInfo *mb = NULL; nsIMAPMailboxInfo *mb = NULL;
// This will fill in the list // This will fill in the list
List("*", PR_TRUE); List("*", PR_TRUE);
PRInt32 total = m_listedMailboxList.Count(), count = 0; PRInt32 total = m_listedMailboxList.Count(), count = 0;
GetServerStateParser().SetReportingErrors(PR_FALSE); GetServerStateParser().SetReportingErrors(PR_FALSE);
for (PRInt32 i = 0; i < total; i++) for (PRInt32 i = 0; i < total; i++)
{ {
mb = (nsIMAPMailboxInfo *) m_listedMailboxList.ElementAt(i); mb = (nsIMAPMailboxInfo *) m_listedMailboxList.ElementAt(i);
if (mb) // paranoia if (mb) // paranoia
{ {
char *onlineName = nsnull; char *onlineName = nsnull;
m_runningUrl->AllocateServerPath(mb->GetMailboxName(), m_runningUrl->AllocateServerPath(mb->GetMailboxName(),
mb->GetDelimiter(), &onlineName); mb->GetDelimiter(), &onlineName);
if (onlineName) if (onlineName)
{ {
RefreshACLForFolder(onlineName); RefreshACLForFolder(onlineName);
nsCRT::free(onlineName); nsCRT::free(onlineName);
} }
PercentProgressUpdateEvent(NULL, count, total); PercentProgressUpdateEvent(NULL, count, total);
delete mb; delete mb;
count++; count++;
} }
} }
m_listedMailboxList.Clear(); m_listedMailboxList.Clear();
PercentProgressUpdateEvent(NULL, 100, 100); PercentProgressUpdateEvent(NULL, 100, 100);
GetServerStateParser().SetReportingErrors(PR_TRUE); GetServerStateParser().SetReportingErrors(PR_TRUE);
m_hierarchyNameState = kNoOperationInProgress; m_hierarchyNameState = kNoOperationInProgress;
} }
// any state commands // any state commands
@ -6524,6 +6537,14 @@ void nsImapProtocol::SetupMessageFlagsString(nsCString& flagString,
userFlags & kImapMsgSupportMDNSentFlag)) userFlags & kImapMsgSupportMDNSentFlag))
flagString.Append("$MDNSent "); // Not always available flagString.Append("$MDNSent "); // Not always available
if ((flags & kImapMsgLabelFlags) && (userFlags & kImapMsgSupportUserFlag))
{
// turn into a number from 1-5
PRUint32 labelValue = (flags & kImapMsgLabelFlags) >> 9;
flagString.Append("$Label");
flagString.AppendInt(labelValue);
flagString.Append(" ");
}
// eat the last space // eat the last space
if (flagString.Length() > 0) if (flagString.Length() > 0)
flagString.SetLength(flagString.Length()-1); flagString.SetLength(flagString.Length()-1);
@ -6534,15 +6555,12 @@ void nsImapProtocol::ProcessStoreFlags(const char * messageIdsString,
imapMessageFlagsType flags, imapMessageFlagsType flags,
PRBool addFlags) PRBool addFlags)
{ {
if (!flags)
return;
nsCString flagString; nsCString flagString;
uint16 userFlags = GetServerStateParser().SupportsUserFlags(); uint16 userFlags = GetServerStateParser().SupportsUserFlags();
uint16 settableFlags = GetServerStateParser().SettablePermanentFlags(); uint16 settableFlags = GetServerStateParser().SettablePermanentFlags();
if (!(flags & userFlags) && !(flags & settableFlags)) if (!addFlags && (flags & userFlags) && !(flags & settableFlags))
return; // if cannot set any of the flags bail out return; // if cannot set any of the flags bail out
if (addFlags) if (addFlags)
@ -6565,10 +6583,26 @@ void nsImapProtocol::ProcessStoreFlags(const char * messageIdsString,
if (flags & kImapMsgMDNSentFlag && kImapMsgSupportMDNSentFlag & userFlags) if (flags & kImapMsgMDNSentFlag && kImapMsgSupportMDNSentFlag & userFlags)
flagString .Append("$MDNSent "); // if supported flagString .Append("$MDNSent "); // if supported
// replace the final space with ')' if (userFlags & kImapMsgSupportUserFlag)
flagString.SetCharAt(')',flagString.Length() - 1); {
if ((flags & kImapMsgLabelFlags))
{
// turn into a number from 1-5
PRUint32 labelValue = (flags & kImapMsgLabelFlags) >> 9;
flagString.Append("$Label");
flagString.AppendInt(labelValue);
flagString.Append(" ");
}
// only turn off all labels if the caller has said to turn off flags
// and passed in 0 as the flag value. There is at least one situation
// where client code attempts to add flags of 0
else if (!flags && !addFlags)// we must be turning off labels, so subtract them all
flagString.Append("$Label1 $Label2 $Label3 $Label4 $Label5 ");
}
// replace the final space with ')'
flagString.SetCharAt(')',flagString.Length() - 1);
Store(messageIdsString, flagString.get(), idsAreUids); Store(messageIdsString, flagString.get(), idsAreUids);
} }

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

@ -304,6 +304,7 @@ public:
void AddFolderRightsForUser(const char *mailboxName, const char *userName, const char *rights); void AddFolderRightsForUser(const char *mailboxName, const char *userName, const char *rights);
// Clears all rights for a given folder, for all users. // Clears all rights for a given folder, for all users.
void ClearAllFolderRights(const char *mailboxName, nsIMAPNamespace *nsForMailbox); void ClearAllFolderRights(const char *mailboxName, nsIMAPNamespace *nsForMailbox);
void RefreshFolderACLView(const char *mailboxName, nsIMAPNamespace *nsForMailbox);
nsresult SetFolderAdminUrl(const char *mailboxName); nsresult SetFolderAdminUrl(const char *mailboxName);
void WaitForFEEventCompletion(); void WaitForFEEventCompletion();

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

@ -169,31 +169,6 @@ nsImapExtensionSinkProxy::ClearFolderRights(nsIImapProtocol* aProtocol,
return res; return res;
} }
NS_IMETHODIMP
nsImapExtensionSinkProxy::RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
{
nsresult res = NS_OK;
NS_PRECONDITION (aclRights, "Oops... null aclRights");
if(!aclRights)
return NS_ERROR_NULL_POINTER;
NS_ASSERTION (m_protocol == aProtocol, "Ooh ooh, wrong protocol");
if (PR_GetCurrentThread() == m_thread)
{
RefreshFolderRightsProxyEvent *ev =
new RefreshFolderRightsProxyEvent(this, aclRights);
if(nsnull == ev)
res = NS_ERROR_OUT_OF_MEMORY;
else
ev->PostEvent(m_eventQueue);
}
else
{
res = m_realImapExtensionSink->RefreshFolderRights(aProtocol, aclRights);
}
return res;
}
NS_IMETHODIMP NS_IMETHODIMP
nsImapExtensionSinkProxy::SetCopyResponseUid(nsIImapProtocol* aProtocol, nsImapExtensionSinkProxy::SetCopyResponseUid(nsIImapProtocol* aProtocol,
@ -632,49 +607,6 @@ ClearFolderRightsProxyEvent::HandleEvent()
return res; return res;
} }
RefreshFolderRightsProxyEvent::RefreshFolderRightsProxyEvent(
nsImapExtensionSinkProxy* aProxy, nsIMAPACLRightsInfo* aclRights) :
nsImapExtensionSinkProxyEvent(aProxy)
{
NS_ASSERTION (aclRights, "Oops... a null acl rights info");
if (aclRights)
{
m_aclRightsInfo.hostName = PL_strdup(aclRights->hostName);
m_aclRightsInfo.mailboxName = PL_strdup(aclRights->mailboxName);
m_aclRightsInfo.userName = PL_strdup(aclRights->userName);
m_aclRightsInfo.rights = PL_strdup(aclRights->rights);
}
else
{
m_aclRightsInfo.hostName = nsnull;
m_aclRightsInfo.mailboxName = nsnull;
m_aclRightsInfo.userName = nsnull;
m_aclRightsInfo.rights = nsnull;
}
}
RefreshFolderRightsProxyEvent::~RefreshFolderRightsProxyEvent()
{
if (m_aclRightsInfo.hostName)
PL_strfree(m_aclRightsInfo.hostName);
if (m_aclRightsInfo.mailboxName)
PL_strfree(m_aclRightsInfo.mailboxName);
if (m_aclRightsInfo.userName)
PL_strfree(m_aclRightsInfo.userName);
if (m_aclRightsInfo.rights)
PL_strfree(m_aclRightsInfo.rights);
}
NS_IMETHODIMP
RefreshFolderRightsProxyEvent::HandleEvent()
{
nsresult res = m_proxy->m_realImapExtensionSink->RefreshFolderRights(
m_proxy->m_protocol, &m_aclRightsInfo);
if (m_notifyCompletion)
m_proxy->m_protocol->NotifyFEEventCompletion();
return res;
}
SetCopyResponseUidProxyEvent::SetCopyResponseUidProxyEvent( SetCopyResponseUidProxyEvent::SetCopyResponseUidProxyEvent(
nsImapExtensionSinkProxy* aProxy, nsMsgKeyArray* aKeyArray, nsImapExtensionSinkProxy* aProxy, nsMsgKeyArray* aKeyArray,
const char* msgIdString, nsIImapUrl * aUrl) : const char* msgIdString, nsIImapUrl * aUrl) :

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

@ -81,8 +81,6 @@ public:
NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol, NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights); nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol, NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* aKeyArray, nsMsgKeyArray* aKeyArray,
const char* msgIdString, const char* msgIdString,
@ -165,15 +163,6 @@ struct ClearFolderRightsProxyEvent : nsImapExtensionSinkProxyEvent
nsIMAPACLRightsInfo m_aclRightsInfo; nsIMAPACLRightsInfo m_aclRightsInfo;
}; };
struct RefreshFolderRightsProxyEvent : nsImapExtensionSinkProxyEvent
{
RefreshFolderRightsProxyEvent(nsImapExtensionSinkProxy* aProxy,
nsIMAPACLRightsInfo* aclRights);
virtual ~RefreshFolderRightsProxyEvent();
NS_IMETHOD HandleEvent();
nsIMAPACLRightsInfo m_aclRightsInfo;
};
struct SetCopyResponseUidProxyEvent : nsImapExtensionSinkProxyEvent struct SetCopyResponseUidProxyEvent : nsImapExtensionSinkProxyEvent
{ {
SetCopyResponseUidProxyEvent(nsImapExtensionSinkProxy* aProxy, SetCopyResponseUidProxyEvent(nsImapExtensionSinkProxy* aProxy,

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

@ -1498,6 +1498,20 @@ void nsImapServerResponseParser::flags()
&& !PL_strncasecmp(fNextToken, "$Forwarded",10)) && !PL_strncasecmp(fNextToken, "$Forwarded",10))
messageFlags |= kImapMsgForwardedFlag; messageFlags |= kImapMsgForwardedFlag;
break; break;
case 'L':
if (fSupportsUserDefinedFlags & kImapMsgSupportUserFlag
&& !PL_strncasecmp(fNextToken, "$Label", 6))
{
PRInt32 labelValue = fNextToken[6];
if (labelValue > '0')
{
// turn off any previous label flags
messageFlags &= ~kImapMsgLabelFlags;
// turn on this label flag
messageFlags |= (labelValue - '0') << 9;
}
}
break;
default: default:
break; break;
} }
@ -1673,6 +1687,7 @@ void nsImapServerResponseParser::resp_text_code()
fSupportsUserDefinedFlags |= kImapMsgSupportUserFlag; fSupportsUserDefinedFlags |= kImapMsgSupportUserFlag;
fSupportsUserDefinedFlags |= kImapMsgSupportForwardedFlag; fSupportsUserDefinedFlags |= kImapMsgSupportForwardedFlag;
fSupportsUserDefinedFlags |= kImapMsgSupportMDNSentFlag; fSupportsUserDefinedFlags |= kImapMsgSupportMDNSentFlag;
fSupportsUserDefinedFlags |= kImapMsgLabelFlags;
} }
} while (!at_end_of_line() && ContinueParse()); } while (!at_end_of_line() && ContinueParse());
if (fFlagState) if (fFlagState)