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,
nsIMAPACLRightsInfo* aclRights) = 0;
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights) = 0;
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* keyArray,
const char *msgIdString,

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

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

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

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

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

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

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

@ -1330,6 +1330,24 @@ NS_IMETHODIMP nsImapIncomingServer::FolderNeedsACLInitialized(const char *folder
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)
{
nsresult rv;
@ -2879,30 +2897,30 @@ nsImapIncomingServer::GetSubscribeListener(nsISubscribeListener **aListener)
NS_IMETHODIMP
nsImapIncomingServer::Subscribe(const PRUnichar *aName)
{
return SubscribeToFolder(aName, PR_TRUE);
return SubscribeToFolder(aName, PR_TRUE);
}
NS_IMETHODIMP
nsImapIncomingServer::Unsubscribe(const PRUnichar *aName)
{
return SubscribeToFolder(aName, PR_FALSE);
return SubscribeToFolder(aName, PR_FALSE);
}
nsresult
nsImapIncomingServer::SubscribeToFolder(const PRUnichar *aName, PRBool subscribe)
{
nsresult rv;
nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (!imapService) return NS_ERROR_FAILURE;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder, &rv);
if (NS_FAILED(rv)) return rv;
if (!rootMsgFolder) return NS_ERROR_FAILURE;
nsresult rv;
nsCOMPtr<nsIImapService> imapService = do_GetService(kImapServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (!imapService) return NS_ERROR_FAILURE;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgFolder> rootMsgFolder = do_QueryInterface(rootFolder, &rv);
if (NS_FAILED(rv)) return rv;
if (!rootMsgFolder) return NS_ERROR_FAILURE;
// 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.
nsCAutoString folderCName;
@ -2915,47 +2933,45 @@ nsImapIncomingServer::SubscribeToFolder(const PRUnichar *aName, PRBool subscribe
if (NS_SUCCEEDED(rv))
msgFolder = do_QueryInterface(subFolder);
}
nsCOMPtr<nsIEventQueue> queue;
// get the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> pEventQService =
do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIEventQueue> queue;
// get the Event Queue for this thread...
nsCOMPtr<nsIEventQueueService> pEventQService =
do_GetService(kEventQueueServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
rv = pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(queue));
if (NS_FAILED(rv)) return rv;
if (subscribe) {
rv = imapService->SubscribeFolder(queue,
msgFolder,
aName,
nsnull, nsnull);
}
else {
rv = imapService->UnsubscribeFolder(queue,
msgFolder,
aName,
nsnull, nsnull);
}
if (NS_FAILED(rv)) return rv;
return NS_OK;
// ok, aName is really a fake unicode name,
// just a utf-7 encoded ascii string 0 byte extended to unicode. So convert it
// to real unicode, and pass that into the subscribe routines.
nsXPIDLString unicodeName;
CreateUnicodeStringFromUtf7(folderCName.get(), getter_Copies(unicodeName));
// we need to convert aName, which is utf-7 encoded, to unicode
if (subscribe)
rv = imapService->SubscribeFolder(queue, msgFolder, unicodeName.get(), nsnull, nsnull);
else
rv = imapService->UnsubscribeFolder(queue, msgFolder, unicodeName.get(), nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
return NS_OK;
}
NS_IMETHODIMP
nsImapIncomingServer::SetDoingLsub(PRBool doingLsub)
{
mDoingLsub = doingLsub;
return NS_OK;
mDoingLsub = doingLsub;
return NS_OK;
}
NS_IMETHODIMP
nsImapIncomingServer::GetDoingLsub(PRBool *doingLsub)
{
if (!doingLsub) return NS_ERROR_NULL_POINTER;
*doingLsub = mDoingLsub;
return NS_OK;
if (!doingLsub) return NS_ERROR_NULL_POINTER;
*doingLsub = mDoingLsub;
return NS_OK;
}
NS_IMETHODIMP

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

@ -96,6 +96,7 @@
#include "nsNetUtil.h"
#include "nsIMAPNamespace.h"
#include "nsHashtable.h"
#include "nsMsgMessageFlags.h"
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -1054,6 +1055,7 @@ NS_IMETHODIMP nsImapMailFolder::GetNoSelect(PRBool *aResult)
NS_ENSURE_ARG_POINTER(aResult);
return GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, aResult);
}
NS_IMETHODIMP nsImapMailFolder::Compact(nsIUrlListener *aListener, nsIMsgWindow *aMsgWindow)
{
nsresult rv;
@ -2899,6 +2901,10 @@ NS_IMETHODIMP nsImapMailFolder::ApplyFilterHit(nsIMsgFilter *filter, nsIMsgWindo
nsMsgLabelValue filterLabel;
filter->GetActionLabel(&filterLabel);
msgHdr->SetLabel(filterLabel);
nsMsgKeyArray keysToFlag;
keysToFlag.Add(msgKey);
StoreImapFlags((filterLabel << 9), PR_TRUE, keysToFlag.GetArray(), keysToFlag.GetSize());
}
default:
break;
@ -3424,7 +3430,7 @@ void nsImapMailFolder::TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr
if (NS_SUCCEEDED(res) && foundIt)
{
// 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;
tweakMe->GetFlags(&dbHdrFlags);
@ -3473,6 +3479,11 @@ void nsImapMailFolder::TweakHeaderFlags(nsIImapProtocol* aProtocol, nsIMsgDBHdr
if (imap_flags & kImapMsgForwardedFlag)
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)
tweakMe->OrFlags(newFlags, &dbHdrFlags);
}
@ -3792,25 +3803,32 @@ nsImapMailFolder::NotifyMessageFlags(PRUint32 flags, nsMsgKey msgKey)
{
if (NS_SUCCEEDED(GetDatabase(nsnull)) && mDatabase)
{
nsCOMPtr<nsIMsgDBHdr> dbHdr;
nsresult rv;
PRBool containsKey;
rv = mDatabase->ContainsKey(msgKey , &containsKey);
// if we don't have the header, don't diddle the flags.
// GetMsgHdrForKey will create the header if it doesn't exist.
if (NS_FAILED(rv) || !containsKey)
return rv;
rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(dbHdr));
if(NS_SUCCEEDED(rv) && dbHdr)
{
mDatabase->MarkHdrRead(dbHdr, (flags & kImapMsgSeenFlag) != 0, nsnull);
mDatabase->MarkHdrReplied(dbHdr, (flags & kImapMsgAnsweredFlag) != 0, nsnull);
mDatabase->MarkHdrMarked(dbHdr, (flags & kImapMsgFlaggedFlag) != 0, nsnull);
mDatabase->MarkImapDeleted(msgKey, (flags & kImapMsgDeletedFlag) != 0, nsnull);
}
nsCOMPtr<nsIMsgDBHdr> dbHdr;
nsresult rv;
PRBool containsKey;
rv = mDatabase->ContainsKey(msgKey , &containsKey);
// if we don't have the header, don't diddle the flags.
// GetMsgHdrForKey will create the header if it doesn't exist.
if (NS_FAILED(rv) || !containsKey)
return rv;
rv = mDatabase->GetMsgHdrForKey(msgKey, getter_AddRefs(dbHdr));
if(NS_SUCCEEDED(rv) && dbHdr)
{
mDatabase->MarkHdrRead(dbHdr, (flags & kImapMsgSeenFlag) != 0, nsnull);
mDatabase->MarkHdrReplied(dbHdr, (flags & kImapMsgAnsweredFlag) != 0, nsnull);
mDatabase->MarkHdrMarked(dbHdr, (flags & kImapMsgFlaggedFlag) != 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;
@ -4418,8 +4436,7 @@ nsImapMailFolder::AddFolderRights(const char *userName, const char *rights)
}
NS_IMETHODIMP
nsImapMailFolder::RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
nsImapMailFolder::RefreshFolderRights()
{
if (GetFolderACL()->GetIsFolderShared())
{

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

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

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

@ -3659,50 +3659,49 @@ PRBool nsImapProtocol::GetIOTunnellingEnabled()
// if userName is NULL, it means "me," or MYRIGHTS.
void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char *userName, const char *rights)
{
nsIMAPACLRightsInfo *aclRightsInfo = new nsIMAPACLRightsInfo();
nsIMAPACLRightsInfo *aclRightsInfo = new nsIMAPACLRightsInfo();
if (aclRightsInfo)
{
nsIMAPNamespace *namespaceForFolder = nsnull;
const char *userName = GetImapUserName();
NS_ASSERTION (m_hostSessionList, "fatal ... null host session list");
if (m_hostSessionList)
m_hostSessionList->GetNamespaceForMailboxForHost(
GetImapServerKey(), mailboxName,
namespaceForFolder);
NS_ASSERTION (m_hostSessionList, "fatal ... null host session list");
if (m_hostSessionList)
m_hostSessionList->GetNamespaceForMailboxForHost(
GetImapServerKey(), mailboxName,
namespaceForFolder);
aclRightsInfo->hostName = PL_strdup(GetImapHostName());
if (namespaceForFolder)
m_runningUrl->AllocateCanonicalPath(
mailboxName,
namespaceForFolder->GetDelimiter(),
&aclRightsInfo->mailboxName);
m_runningUrl->AllocateCanonicalPath(
mailboxName,
namespaceForFolder->GetDelimiter(),
&aclRightsInfo->mailboxName);
else
m_runningUrl->AllocateCanonicalPath(mailboxName,
kOnlineHierarchySeparatorUnknown,
&aclRightsInfo->mailboxName);
m_runningUrl->AllocateCanonicalPath(mailboxName,
kOnlineHierarchySeparatorUnknown,
&aclRightsInfo->mailboxName);
if (userName)
aclRightsInfo->userName = PL_strdup(userName);
else
aclRightsInfo->userName = NULL;
aclRightsInfo->rights = PL_strdup(rights);
if (aclRightsInfo->hostName &&
aclRightsInfo->mailboxName && aclRightsInfo->rights &&
aclRightsInfo->mailboxName && aclRightsInfo->rights &&
userName ? (aclRightsInfo->userName != NULL) : PR_TRUE)
{
if (m_imapServerSink)
{
m_imapServerSink->AddFolderRights(mailboxName, userName, rights);
}
}
PR_FREEIF(aclRightsInfo->hostName);
PR_FREEIF(aclRightsInfo->mailboxName);
PR_FREEIF(aclRightsInfo->rights);
PR_FREEIF(aclRightsInfo->userName);
if (m_imapServerSink)
{
m_imapServerSink->AddFolderRights(mailboxName, userName, rights);
}
}
PR_FREEIF(aclRightsInfo->hostName);
PR_FREEIF(aclRightsInfo->mailboxName);
PR_FREEIF(aclRightsInfo->rights);
PR_FREEIF(aclRightsInfo->userName);
delete aclRightsInfo;
}
else
@ -5000,9 +4999,7 @@ void nsImapProtocol::RefreshACLForFolder(const char *mailboxName)
// Now, get the new one.
GetACLForFolder(mailboxName);
// We're all done, refresh the icon/flags for this folder
#ifdef REFRESHING_VIEW
RefreshFolderACLView(mailboxName, ns);
#endif
break;
default:
// 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.
GetMyRightsForFolder(mailboxName);
// We're all done, refresh the icon/flags for this folder
#ifdef REFRESHING_VIEW
RefreshFolderACLView(mailboxName, ns);
#endif
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)
{
IncrementCommandTagNumber();
@ -5045,37 +5058,37 @@ void nsImapProtocol::GetACLForFolder(const char *mailboxName)
void nsImapProtocol::OnRefreshAllACLs()
{
m_hierarchyNameState = kListingForInfoOnly;
nsIMAPMailboxInfo *mb = NULL;
// This will fill in the list
List("*", PR_TRUE);
PRInt32 total = m_listedMailboxList.Count(), count = 0;
GetServerStateParser().SetReportingErrors(PR_FALSE);
for (PRInt32 i = 0; i < total; i++)
{
mb = (nsIMAPMailboxInfo *) m_listedMailboxList.ElementAt(i);
if (mb) // paranoia
{
char *onlineName = nsnull;
m_runningUrl->AllocateServerPath(mb->GetMailboxName(),
mb->GetDelimiter(), &onlineName);
if (onlineName)
{
RefreshACLForFolder(onlineName);
nsCRT::free(onlineName);
}
PercentProgressUpdateEvent(NULL, count, total);
delete mb;
count++;
}
}
m_listedMailboxList.Clear();
PercentProgressUpdateEvent(NULL, 100, 100);
GetServerStateParser().SetReportingErrors(PR_TRUE);
m_hierarchyNameState = kNoOperationInProgress;
m_hierarchyNameState = kListingForInfoOnly;
nsIMAPMailboxInfo *mb = NULL;
// This will fill in the list
List("*", PR_TRUE);
PRInt32 total = m_listedMailboxList.Count(), count = 0;
GetServerStateParser().SetReportingErrors(PR_FALSE);
for (PRInt32 i = 0; i < total; i++)
{
mb = (nsIMAPMailboxInfo *) m_listedMailboxList.ElementAt(i);
if (mb) // paranoia
{
char *onlineName = nsnull;
m_runningUrl->AllocateServerPath(mb->GetMailboxName(),
mb->GetDelimiter(), &onlineName);
if (onlineName)
{
RefreshACLForFolder(onlineName);
nsCRT::free(onlineName);
}
PercentProgressUpdateEvent(NULL, count, total);
delete mb;
count++;
}
}
m_listedMailboxList.Clear();
PercentProgressUpdateEvent(NULL, 100, 100);
GetServerStateParser().SetReportingErrors(PR_TRUE);
m_hierarchyNameState = kNoOperationInProgress;
}
// any state commands
@ -6524,6 +6537,14 @@ void nsImapProtocol::SetupMessageFlagsString(nsCString& flagString,
userFlags & kImapMsgSupportMDNSentFlag))
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
if (flagString.Length() > 0)
flagString.SetLength(flagString.Length()-1);
@ -6534,15 +6555,12 @@ void nsImapProtocol::ProcessStoreFlags(const char * messageIdsString,
imapMessageFlagsType flags,
PRBool addFlags)
{
if (!flags)
return;
nsCString flagString;
uint16 userFlags = GetServerStateParser().SupportsUserFlags();
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
if (addFlags)
@ -6565,10 +6583,26 @@ void nsImapProtocol::ProcessStoreFlags(const char * messageIdsString,
if (flags & kImapMsgMDNSentFlag && kImapMsgSupportMDNSentFlag & userFlags)
flagString .Append("$MDNSent "); // if supported
// replace the final space with ')'
flagString.SetCharAt(')',flagString.Length() - 1);
Store(messageIdsString, flagString.get(), idsAreUids);
if (userFlags & kImapMsgSupportUserFlag)
{
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);
}

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

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

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

@ -169,31 +169,6 @@ nsImapExtensionSinkProxy::ClearFolderRights(nsIImapProtocol* aProtocol,
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
nsImapExtensionSinkProxy::SetCopyResponseUid(nsIImapProtocol* aProtocol,
@ -632,49 +607,6 @@ ClearFolderRightsProxyEvent::HandleEvent()
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(
nsImapExtensionSinkProxy* aProxy, nsMsgKeyArray* aKeyArray,
const char* msgIdString, nsIImapUrl * aUrl) :

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

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

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

@ -1498,6 +1498,20 @@ void nsImapServerResponseParser::flags()
&& !PL_strncasecmp(fNextToken, "$Forwarded",10))
messageFlags |= kImapMsgForwardedFlag;
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:
break;
}
@ -1673,6 +1687,7 @@ void nsImapServerResponseParser::resp_text_code()
fSupportsUserDefinedFlags |= kImapMsgSupportUserFlag;
fSupportsUserDefinedFlags |= kImapMsgSupportForwardedFlag;
fSupportsUserDefinedFlags |= kImapMsgSupportMDNSentFlag;
fSupportsUserDefinedFlags |= kImapMsgLabelFlags;
}
} while (!at_end_of_line() && ContinueParse());
if (fFlagState)