more work on shared imap folders and acl, sharing tab of folder properties r=sspitzer, sr=mscott 112096

This commit is contained in:
bienvenu%netscape.com 2002-01-27 02:06:46 +00:00
Родитель ca7a498512
Коммит 4675bc64d0
17 изменённых файлов: 1800 добавлений и 719 удалений

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

@ -62,8 +62,6 @@ public:
NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights) = 0;
NS_IMETHOD AddFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights) = 0;
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights) = 0;
NS_IMETHOD FolderNeedsACLInitialized(nsIImapProtocol* aProtocol,

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

@ -43,7 +43,10 @@ interface nsIMsgMailNewsUrl;
[scriptable, uuid(8ec49a08-5cb0-11d3-a52c-0060b0fc04b7)]
interface nsIImapServerSink : nsISupports {
void possibleImapMailbox(in string folderPath, in wchar hierarchyDelim, in long boxFlags);
/* returns true if it's a new mailbox */
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 discoveryDone();
void onlineFolderDelete(in string aFolderName);
void onlineFolderCreateFailed(in string aFolderName);

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

@ -41,6 +41,18 @@
interface nsIMsgWindow;
interface nsIImapIncomingServer;
// this is a simple interface which allows the imap folder to update some values
// that the folder props js code will use to update the sharing tab in the folder props.
[scriptable, uuid(239472a2-6e8f-46f0-9507-887998da49e5)]
interface nsIMsgImapFolderProps : nsISupports {
void setFolderType(in wstring folderType);
void setFolderTypeDescription(in wstring folderTypeDescription);
void setFolderPermissions(in wstring permissions);
};
[scriptable, uuid(FBFEBE79-C1DD-11d2-8A40-0060B0FC04D2)]
interface nsIMsgImapMailFolder : nsISupports {
void removeSubFolder(in nsIMsgFolder folder);
@ -59,12 +71,18 @@ interface nsIMsgImapMailFolder : nsISupports {
in nsIUrlListener aUrlListener, in nsIMsgWindow aWindow);
void playbackOfflineFolderCreate(in wstring folderName, in nsIMsgWindow aWindow, out nsIURI url);
void liteSelect(in nsIUrlListener aUrlListener);
void fillInFolderProps(in nsIMsgImapFolderProps aFolderProps);
void resetNamespaceReferences();
void folderPrivileges(in nsIMsgWindow aWindow);
nsIMsgImapMailFolder findOnlineSubFolder(in string onlineName);
void addFolderRights(in string userName, in string rights);
attribute boolean verifiedAsOnlineFolder;
attribute boolean explicitlyVerify;
attribute wchar hierarchyDelimiter;
attribute long boxFlags;
attribute string onlineName;
attribute unsigned long aclFlags;
readonly attribute boolean canIOpenThisFolder;
readonly attribute boolean hasAdminUrl;
};

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

@ -339,7 +339,7 @@
## @name IMAP_OTHER_USERS_FOLDER_TYPE_DESCRIPTION
## @loc None
5072=This is a mail folder shared by the user '%S'."
5072=This is a mail folder shared by the user '%S'.
## @name IMAP_ACL_FULL_RIGHTS
## @loc None
@ -367,7 +367,7 @@
## @name IMAP_ACL_POST_RIGHT
## @loc None
5079=Post"
5079=Post
## @name IMAP_ACL_CREATE_RIGHT
## @loc None

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

@ -760,11 +760,11 @@ NS_IMETHODIMP nsIMAPHostSessionList::SetNamespaceHierarchyDelimiterFromMailboxFo
nsIMAPNamespace *ns = host->fNamespaceList->GetNamespaceForMailbox(boxName);
if (ns && !ns->GetIsDelimiterFilledIn())
{
ns->SetDelimiter(delimiter);
ns->SetDelimiter(delimiter, PR_TRUE);
}
}
PR_ExitMonitor(gCachedHostInfoMonitor);
return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK;
return (host) ? NS_OK : NS_ERROR_ILLEGAL_VALUE ;
}
NS_IMETHODIMP nsIMAPHostSessionList::AddShellToCacheForHost(const char *serverKey, nsIMAPBodyShell *shell)

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

@ -41,11 +41,13 @@
#include "nsIMAPNamespace.h"
#include "nsImapProtocol.h"
#include "nsIMAPGenericParser.h"
#include "nsMsgImapCID.h"
#include "nsImapUrl.h"
#include "nsString.h"
//////////////////// nsIMAPNamespace /////////////////////////////////////////////////////////////
static NS_DEFINE_CID(kCImapHostSessionListCID, NS_IIMAPHOSTSESSIONLIST_CID);
nsIMAPNamespace::nsIMAPNamespace(EIMAPNamespaceType type, const char *prefix, char delimiter, PRBool from_prefs)
{
@ -62,10 +64,10 @@ nsIMAPNamespace::~nsIMAPNamespace()
PR_FREEIF(m_prefix);
}
void nsIMAPNamespace::SetDelimiter(char delimiter)
void nsIMAPNamespace::SetDelimiter(char delimiter, PRBool delimiterFilledIn)
{
m_delimiter = delimiter;
m_delimiterFilledIn = PR_TRUE;
m_delimiterFilledIn = delimiterFilledIn;
}
// returns -1 if this box is not part of this namespace,
@ -404,3 +406,211 @@ int nsIMAPNamespaceList::UnserializeNamespaces(const char *str, char **prefixes,
}
}
char *nsIMAPNamespaceList::AllocateCanonicalFolderName(const char *onlineFolderName, char delimiter)
{
char *canonicalPath = nsnull;
if (delimiter)
canonicalPath = nsImapUrl::ReplaceCharsInCopiedString(onlineFolderName, delimiter , '/');
else
canonicalPath = strdup(onlineFolderName);
// eat any escape characters for escaped dir separators
if (canonicalPath)
{
char *currentEscapeSequence = strstr(canonicalPath, "\\/");
while (currentEscapeSequence)
{
strcpy(currentEscapeSequence, currentEscapeSequence+1);
currentEscapeSequence = strstr(currentEscapeSequence+1, "\\/");
}
}
return canonicalPath;
}
/*
GetFolderNameWithoutNamespace takes as input a folder name
in canonical form, and the namespace for the given folder. It returns an allocated
string of the folder's path with the namespace string stripped out. For instance,
when passed the folder Folders/a/b where the namespace is "Folders/", it will return
"a/b". Similarly, if the folder name is "#news/comp/mail/imap" in canonical form,
with a real delimiter of "." and a namespace of "#news.", it will return "comp/mail/imap".
The return value is always in canonical form.
*/
char* nsIMAPNamespaceList::GetFolderNameWithoutNamespace(nsIMAPNamespace *namespaceForFolder, const char *canonicalFolderName)
{
NS_ASSERTION(canonicalFolderName, "null folder name");
#ifdef DEBUG
NS_ASSERTION(namespaceForFolder || !PL_strcasecmp(canonicalFolderName, "INBOX"), "need namespace or INBOX");
#endif
char *retFolderName = nsnull;
if (!PL_strcasecmp(canonicalFolderName, "INBOX"))
return strdup(canonicalFolderName);
// convert the canonical path to the online path
char *convertedFolderName = nsIMAPNamespaceList::AllocateServerFolderName(canonicalFolderName, namespaceForFolder->GetDelimiter());
if (convertedFolderName)
{
char *beginFolderPath = nsnull;
if (strlen(convertedFolderName) <= strlen(namespaceForFolder->GetPrefix()))
beginFolderPath = convertedFolderName;
else
beginFolderPath = convertedFolderName + strlen(namespaceForFolder->GetPrefix());
NS_ASSERTION(beginFolderPath, "empty folder path");
retFolderName = nsIMAPNamespaceList::AllocateCanonicalFolderName(beginFolderPath, namespaceForFolder->GetDelimiter());
PR_Free(convertedFolderName);
}
NS_ASSERTION(retFolderName, "returning null folder name");
return retFolderName;
}
nsIMAPNamespace* nsIMAPNamespaceList::GetNamespaceForFolder(const char *hostName,
const char *canonicalFolderName,
char delimiter)
{
if (!hostName || !canonicalFolderName)
return nsnull;
nsIMAPNamespace *resultNamespace = nsnull;
nsresult rv;
char *convertedFolderName = nsIMAPNamespaceList::AllocateServerFolderName(canonicalFolderName, delimiter);
if (convertedFolderName)
{
nsCOMPtr<nsIImapHostSessionList> hostSessionList =
do_GetService(kCImapHostSessionListCID, &rv);
if (NS_FAILED(rv))
return nsnull;
hostSessionList->GetNamespaceForMailboxForHost(hostName, convertedFolderName, resultNamespace);
PR_Free(convertedFolderName);
}
else
{
NS_ASSERTION(PR_FALSE, "couldn't get converted folder name");
}
return resultNamespace;
}
/* static */
char *nsIMAPNamespaceList::AllocateServerFolderName(const char *canonicalFolderName, char delimiter)
{
if (delimiter)
return nsImapUrl::ReplaceCharsInCopiedString(canonicalFolderName, '/', delimiter);
else
return nsCRT::strdup(canonicalFolderName);
}
/*
GetFolderOwnerNameFromPath takes as inputs a folder name
in canonical form, and a namespace for that folder.
The namespace MUST be of type kOtherUsersNamespace, hence the folder MUST be
owned by another user. This function extracts the folder owner's name from the
canonical name of the folder, and returns an allocated copy of that owner's name
*/
/* static */
char *nsIMAPNamespaceList::GetFolderOwnerNameFromPath(nsIMAPNamespace *namespaceForFolder, const char *canonicalFolderName)
{
if (!namespaceForFolder || !canonicalFolderName)
{
NS_ASSERTION(PR_FALSE,"null namespace or canonical folder name");
return nsnull;
}
char *rv = nsnull;
// convert the canonical path to the online path
char *convertedFolderName = AllocateServerFolderName(canonicalFolderName, namespaceForFolder->GetDelimiter());
if (convertedFolderName)
{
#ifdef DEBUG
NS_ASSERTION(strlen(convertedFolderName) > strlen(namespaceForFolder->GetPrefix()), "server folder name invalid");
#endif
if (strlen(convertedFolderName) > strlen(namespaceForFolder->GetPrefix()))
{
char *owner = convertedFolderName + strlen(namespaceForFolder->GetPrefix());
NS_ASSERTION(owner, "couldn't find folder owner");
char *nextDelimiter = strchr(owner, namespaceForFolder->GetDelimiter());
// if !nextDelimiter, then the path is of the form Shared/Users/chrisf (no subfolder)
if (nextDelimiter)
{
*nextDelimiter = 0;
}
rv = strdup(owner);
}
PR_Free(convertedFolderName);
}
else
{
NS_ASSERTION(PR_FALSE, "couldn't allocate server folder name");
}
return rv;
}
/*
GetFolderIsNamespace returns TRUE if the given folder is the folder representing
a namespace.
*/
PRBool nsIMAPNamespaceList::GetFolderIsNamespace(const char *hostName,
const char *canonicalFolderName,
char delimiter,nsIMAPNamespace *namespaceForFolder)
{
NS_ASSERTION(namespaceForFolder, "null namespace");
PRBool rv = PR_FALSE;
const char *prefix = namespaceForFolder->GetPrefix();
NS_ASSERTION(prefix, "namespace has no prefix");
if (!prefix || !*prefix) // empty namespace prefix
return PR_FALSE;
char *convertedFolderName = AllocateServerFolderName(canonicalFolderName, delimiter);
if (convertedFolderName)
{
PRBool lastCharIsDelimiter = (prefix[strlen(prefix) - 1] == delimiter);
if (lastCharIsDelimiter)
{
rv = ((strncmp(convertedFolderName, prefix, strlen(convertedFolderName)) == 0) &&
(strlen(convertedFolderName) == strlen(prefix) - 1));
}
else
{
rv = (strcmp(convertedFolderName, prefix) == 0);
}
PR_FREEIF(convertedFolderName);
}
else
{
NS_ASSERTION(PR_FALSE, "couldn't allocate server folder name");
}
return rv;
}
/*
SuggestHierarchySeparatorForNamespace takes a namespace from libmsg
and a hierarchy delimiter. If the namespace has not been filled in from
online NAMESPACE command yet, it fills in the suggested delimiter to be
used from then on (until it is overridden by an online response).
*/
void nsIMAPNamespaceList::SuggestHierarchySeparatorForNamespace(nsIMAPNamespace *namespaceForFolder, char delimiterFromFolder)
{
NS_ASSERTION(namespaceForFolder, "need namespace");
if (namespaceForFolder && !namespaceForFolder->GetIsDelimiterFilledIn())
namespaceForFolder->SetDelimiter(delimiterFromFolder, PR_FALSE);
}

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

@ -49,7 +49,7 @@ public:
EIMAPNamespaceType GetType() { return m_namespaceType; }
const char * GetPrefix() { return m_prefix; }
char GetDelimiter() { return m_delimiter; }
void SetDelimiter(char delimiter);
void SetDelimiter(char delimiter, PRBool delimiterFilledIn);
PRBool GetIsDelimiterFilledIn() { return m_delimiterFilledIn; }
PRBool GetIsNamespaceFromPrefs() { return m_fromPrefs; }
@ -89,6 +89,17 @@ public:
nsIMAPNamespace *GetDefaultNamespaceOfType(EIMAPNamespaceType type);
int AddNewNamespace(nsIMAPNamespace *ns);
nsIMAPNamespace *GetNamespaceForMailbox(const char *boxname);
static nsIMAPNamespace* GetNamespaceForFolder(const char *hostName,
const char *canonicalFolderName,
char delimiter);
static PRBool GetFolderIsNamespace(const char *hostName,
const char *canonicalFolderName,
char delimiter,nsIMAPNamespace *namespaceForFolder);
static char* GetFolderNameWithoutNamespace(nsIMAPNamespace *namespaceForFolder, const char *canonicalFolderName);
static char *AllocateServerFolderName(const char *canonicalFolderName, char delimiter);
static char *GetFolderOwnerNameFromPath(nsIMAPNamespace *namespaceForFolder, const char *canonicalFolderName);
static char *AllocateCanonicalFolderName(const char *onlineFolderName, char delimiter);
static void SuggestHierarchySeparatorForNamespace(nsIMAPNamespace *namespaceForFolder, char delimiterFromFolder);
protected:
nsIMAPNamespaceList(); // use CreatensIMAPNamespaceList to create one

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

@ -89,7 +89,6 @@
#include "nsITimer.h"
#include "nsMsgUtils.h"
static NS_DEFINE_CID(kCImapHostSessionList, NS_IIMAPHOSTSESSIONLIST_CID);
static NS_DEFINE_CID(kImapProtocolCID, NS_IMAPPROTOCOL_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -1061,7 +1060,9 @@ NS_IMETHODIMP nsImapIncomingServer::GetSentMailPFC(PRBool createIfMissing, nsIMs
}
// nsIImapServerSink impl
NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath, PRUnichar hierarchyDelimiter, PRInt32 boxFlags)
// aNewFolder will not be set if we're listing for the subscribe UI, since that's the way 4.x worked.
NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath, PRUnichar hierarchyDelimiter,
PRInt32 boxFlags, PRBool *aNewFolder)
{
// folderPath is in canonical format, i.e., hierarchy separator has been replaced with '/'
nsresult rv;
@ -1071,8 +1072,9 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
nsCOMPtr<nsIMsgFolder> aFolder;
PRBool explicitlyVerify = PR_FALSE;
if (!folderPath || !*folderPath) return NS_ERROR_NULL_POINTER;
if (!folderPath || !*folderPath || !aNewFolder) return NS_ERROR_NULL_POINTER;
*aNewFolder = PR_FALSE;
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
@ -1175,7 +1177,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
nsCOMPtr <nsIMsgFolder> child;
// nsCString possibleName(aSpec->allocatedPathName);
// nsCString possibleName(aSpec->allocatedPathName);
uri.Append('/');
@ -1184,6 +1186,8 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
PRBool caseInsensitive = (nsCRT::strcasecmp("INBOX", dupFolderPath.get()) == 0);
a_nsIFolder->GetChildWithURI(uri.get(), PR_TRUE, caseInsensitive, getter_AddRefs(child));
// if we couldn't find this folder by URI, tell the imap code it's a new folder to us
*aNewFolder = !child;
if (child)
found = PR_TRUE;
if (!found)
@ -1192,13 +1196,14 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
if (haveParent)
{
nsCOMPtr <nsIMsgFolder> parent;
PRBool parentIsNew;
caseInsensitive = (nsCRT::strcasecmp("INBOX", parentName.get()) == 0);
a_nsIFolder->GetChildWithURI(parentUri.get(), PR_TRUE, caseInsensitive, getter_AddRefs(parent));
if (!parent /* || parentFolder->GetFolderNeedsAdded()*/)
{
PossibleImapMailbox(parentName.get(), hierarchyDelimiter, kNoselect | // be defensive
((boxFlags & //only inherit certain flags from the child
(kPublicMailbox | kOtherUsersMailbox | kPersonalMailbox))));
(kPublicMailbox | kOtherUsersMailbox | kPersonalMailbox))), &parentIsNew);
}
}
@ -1272,6 +1277,48 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
return NS_OK;
}
NS_IMETHODIMP nsImapIncomingServer::AddFolderRights(const char *mailboxName, const char *userName, const char *rights)
{
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(mailboxName, getter_AddRefs(foundFolder));
if (NS_SUCCEEDED(rv) && foundFolder)
return foundFolder->AddFolderRights(userName, rights);
}
}
return rv;
}
NS_IMETHODIMP nsImapIncomingServer::FolderNeedsACLInitialized(const char *folderPath, PRBool *aNeedsACLInitialized)
{
NS_ENSURE_ARG_POINTER(aNeedsACLInitialized);
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)
{
nsCOMPtr <nsIImapMailFolderSink> folderSink = do_QueryInterface(foundFolder);
if (folderSink)
return folderSink->GetFolderNeedsACLListed(aNeedsACLInitialized);
}
}
}
*aNeedsACLInitialized = PR_FALSE; // maybe we want to say TRUE here...
return NS_OK;
}
NS_IMETHODIMP nsImapIncomingServer::GetRedirectorType(char **redirectorType)
{
nsresult rv;
@ -2050,6 +2097,7 @@ NS_IMETHODIMP nsImapIncomingServer::GetImapStringByID(PRInt32 aMsgId, PRUnichar
{
nsresult res = NS_OK;
GetStringBundle();
if (m_stringBundle)
{
@ -2061,10 +2109,10 @@ NS_IMETHODIMP nsImapIncomingServer::GetImapStringByID(PRInt32 aMsgId, PRUnichar
resultString.AppendInt(aMsgId);
*aString = ToNewUnicode(resultString);
return NS_OK;
}
}
NS_IMETHODIMP nsImapIncomingServer::FormatStringWithHostNameByID(PRInt32 aMsgId, PRUnichar **aString)
{
{
nsresult res = NS_OK;
GetStringBundle();
@ -2281,75 +2329,24 @@ NS_IMETHODIMP nsImapIncomingServer::PseudoInterruptMsgLoad(nsIImapUrl *aImapUrl,
NS_IMETHODIMP nsImapIncomingServer::ResetNamespaceReferences()
{
return NS_ERROR_NOT_IMPLEMENTED;
}
#if FINISHED_PORTED_NAMESPACE_STUFF
int numberOfChildren = GetNumSubFolders();
for (int childIndex = 0; childIndex < numberOfChildren; childIndex++)
nsCOMPtr <nsIFolder> rootFolder;
nsresult rv = GetRootFolder(getter_AddRefs(rootFolder));
if (NS_SUCCEEDED(rv) && rootFolder)
{
MSG_IMAPFolderInfoMail *currentChild = (MSG_IMAPFolderInfoMail *) GetSubFolder(childIndex);
currentChild->ResetNamespaceReferences();
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(rootFolder);
if (imapFolder)
rv = imapFolder->ResetNamespaceReferences();
}
void MSG_IMAPFolderInfoMail::SetFolderIsNamespace(XP_Bool isNamespace)
{
m_folderIsNamespace = isNamespace;
return rv;
}
void MSG_IMAPFolderInfoMail::InitializeFolderCreatedOffline()
{
TIMAPNamespace *ns = IMAPNS_GetNamespaceForFolder(m_host->GetHostName(), GetOnlineName(), '/');
SetOnlineHierarchySeparator(IMAPNS_GetDelimiterForNamespace(ns));
}
//void MSG_IMAPFolderInfoMail::InitializeFolderCreatedOffline()
//{
// TIMAPNamespace *ns = IMAPNS_GetNamespaceForFolder(m_host->GetHostName(), GetOnlineName(), '/');
// SetOnlineHierarchySeparator(IMAPNS_GetDelimiterForNamespace(ns));
//}
TIMAPNamespace *MSG_IMAPFolderInfoMail::GetNamespaceForFolder()
{
if (!m_namespace)
{
#ifdef DEBUG_bienvenu
// Make sure this isn't causing us to open the database
PR_ASSERT(m_OnlineHierSeparator != kOnlineHierarchySeparatorUnknown);
#endif
m_namespace = IMAPNS_GetNamespaceForFolder(m_host->GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator());
PR_ASSERT(m_namespace);
if (m_namespace)
{
IMAPNS_SuggestHierarchySeparatorForNamespace(m_namespace, GetOnlineHierarchySeparator());
m_folderIsNamespace = IMAPNS_GetFolderIsNamespace(m_host->GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator(), m_namespace);
}
}
return m_namespace;
}
void MSG_IMAPFolderInfoMail::SetNamespaceForFolder(TIMAPNamespace *ns)
{
#ifdef DEBUG_bienvenu
NS_ASSERTION(ns, "null namespace");
#endif
m_namespace = ns;
}
void MSG_IMAPFolderInfoMail::ResetNamespaceReferences()
{
// this
m_namespace = IMAPNS_GetNamespaceForFolder(GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator());
NS_ASSERTION(m_namespace, "resetting null namespace");
if (m_namespace)
m_folderIsNamespace = IMAPNS_GetFolderIsNamespace(GetHostName(), GetOnlineName(), GetOnlineHierarchySeparator(), m_namespace);
else
m_folderIsNamespace = PR_FALSE;
// children
int numberOfChildren = GetNumSubFolders();
for (int childIndex = 0; childIndex < numberOfChildren; childIndex++)
{
MSG_IMAPFolderInfoMail *currentChild = (MSG_IMAPFolderInfoMail *) GetSubFolder(childIndex);
currentChild->ResetNamespaceReferences();
}
}
#endif //FINISHED_PORTED_NAMESPACE_STUFF
NS_IMPL_GETSET(nsImapIncomingServer, UserAuthenticated, PRBool, m_userAuthenticated);

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

@ -94,6 +94,8 @@
#include "nsIImapMockChannel.h"
#include "nsIWebNavigation.h"
#include "nsNetUtil.h"
#include "nsIMAPNamespace.h"
#include "nsHashtable.h"
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
@ -212,6 +214,8 @@ nsImapMailFolder::nsImapMailFolder() :
m_uidValidity = 0;
m_hierarchyDelimiter = kOnlineHierarchySeparatorUnknown;
m_pathName = nsnull;
m_folderACL = nsnull;
m_namespace = nsnull;
}
nsImapMailFolder::~nsImapMailFolder()
@ -223,6 +227,7 @@ nsImapMailFolder::~nsImapMailFolder()
if (m_moveCoalescer)
delete m_moveCoalescer;
delete m_pathName;
delete m_folderACL;
}
NS_IMPL_ADDREF_INHERITED(nsImapMailFolder, nsMsgDBFolder)
@ -1949,7 +1954,7 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
else
{
EnableNotifications(allMessageCountNotifications, PR_FALSE); //"remove it immediately" model
mDatabase->DeleteMessages(&srcKeyArray,NULL);
mDatabase->DeleteMessages(&srcKeyArray,nsnull);
EnableNotifications(allMessageCountNotifications, PR_TRUE);
NotifyFolderEvent(mDeleteOrMoveMsgCompletedAtom);
}
@ -2358,7 +2363,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
// It would be nice to notify RDF or whoever of a mass delete here.
if (mDatabase) {
mDatabase->DeleteMessages(&keysToDelete,NULL);
mDatabase->DeleteMessages(&keysToDelete,nsnull);
total = keysToDelete.GetSize();
}
}
@ -2382,7 +2387,7 @@ NS_IMETHODIMP nsImapMailFolder::UpdateImapMailboxInfo(
{
// let the imap libnet module know that we don't need headers
if (aProtocol)
aProtocol->NotifyHdrsToDownload(NULL, 0);
aProtocol->NotifyHdrsToDownload(nsnull, 0);
PRBool gettingNewMessages;
GetGettingNewMessages(&gettingNewMessages);
if (gettingNewMessages)
@ -3013,15 +3018,132 @@ NS_IMETHODIMP nsImapMailFolder::LiteSelect(nsIUrlListener *aUrlListener)
return rv;
}
NS_IMETHODIMP nsImapMailFolder::FolderPrivileges(nsIMsgWindow *window)
nsresult nsImapMailFolder::GetFolderOwnerUserName(char **userName)
{
if ((mFlags & MSG_FOLDER_FLAG_IMAP_PERSONAL) ||
!(mFlags & (MSG_FOLDER_FLAG_IMAP_PUBLIC | MSG_FOLDER_FLAG_IMAP_OTHER_USER)))
{
// this is one of our personal mail folders
// return our username on this host
nsCOMPtr<nsIMsgIncomingServer> server;
nsresult rv = GetServer(getter_AddRefs(server));
if (NS_SUCCEEDED(rv) && server)
return server->GetUsername(userName);
else
return rv;
}
// the only other type of owner is if it's in the other users' namespace
if (!(mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER))
return NS_OK;
if (!m_ownerUserName.Length())
{
nsXPIDLCString onlineName;
GetOnlineName(getter_Copies(onlineName));
m_ownerUserName = nsIMAPNamespaceList::GetFolderOwnerNameFromPath(GetNamespaceForFolder(), onlineName.get());
}
*userName = (m_ownerUserName.Length()) ? ToNewCString(m_ownerUserName) : nsnull;
return NS_OK;
}
// returns the online folder name, with the other users' namespace and his username
// stripped out
nsresult nsImapMailFolder::GetOwnersOnlineFolderName(char **retName)
{
nsXPIDLCString onlineName;
GetOnlineName(getter_Copies(onlineName));
if (mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER)
{
nsXPIDLCString user;
GetFolderOwnerUserName(getter_Copies(user));
if (onlineName.Length() && user.Length())
{
const char *where = PL_strstr(onlineName.get(), user.get());
NS_ASSERTION(where, "user name not in online name");
if (where)
{
const char *relativeFolder = where + strlen(user) + 1;
if (!relativeFolder) // root of this user's personal namespace
{
*retName = strdup("");
return NS_OK;
}
else
{
*retName = strdup(relativeFolder);
return NS_OK;
}
}
}
*retName = strdup(onlineName.get());
return NS_OK;
}
else if (!(mFlags & MSG_FOLDER_FLAG_IMAP_PUBLIC))
{
// We own this folder.
*retName = nsIMAPNamespaceList::GetFolderNameWithoutNamespace(GetNamespaceForFolder(), onlineName);
}
else
*retName = strdup(onlineName.get());
return NS_OK;
}
nsIMAPNamespace *nsImapMailFolder::GetNamespaceForFolder()
{
if (!m_namespace)
{
#ifdef DEBUG_bienvenu
// Make sure this isn't causing us to open the database
NS_ASSERTION(m_hierarchyDelimiter != kOnlineHierarchySeparatorUnknown, "haven't set hierarchy delimiter");
#endif
nsXPIDLCString serverKey;
nsXPIDLCString onlineName;
GetServerKey(getter_Copies(serverKey));
GetOnlineName(getter_Copies(onlineName));
PRUnichar hierarchyDelimiter;
GetHierarchyDelimiter(&hierarchyDelimiter);
m_namespace = nsIMAPNamespaceList::GetNamespaceForFolder(serverKey.get(), onlineName.get(), (char) hierarchyDelimiter);
NS_ASSERTION(m_namespace, "didn't get namespace for folder");
if (m_namespace)
{
nsIMAPNamespaceList::SuggestHierarchySeparatorForNamespace(m_namespace, (char) hierarchyDelimiter);
m_folderIsNamespace = nsIMAPNamespaceList::GetFolderIsNamespace(serverKey.get(), onlineName.get(), (char) hierarchyDelimiter, m_namespace);
}
}
return m_namespace;
}
void nsImapMailFolder::SetNamespaceForFolder(nsIMAPNamespace *ns)
{
#ifdef DEBUG_bienvenu
NS_ASSERTION(ns, "null namespace");
#endif
m_namespace = ns;
}
nsresult nsImapMailFolder::GetServerAdminUrl(char **aAdminUrl)
{
nsCOMPtr<nsIImapIncomingServer> imapServer;
nsresult rv = GetImapIncomingServer(getter_AddRefs(imapServer));
if (window && NS_SUCCEEDED(rv) && imapServer)
if (NS_SUCCEEDED(rv) && imapServer)
rv = imapServer->GetManageMailAccountUrl(aAdminUrl);
return rv;
}
NS_IMETHODIMP nsImapMailFolder::FolderPrivileges(nsIMsgWindow *window)
{
nsresult rv = NS_ERROR_NULL_POINTER; // if no window...
if (window)
{
nsXPIDLCString manageMailAccountUrl;
rv = imapServer->GetManageMailAccountUrl(getter_Copies(manageMailAccountUrl));
rv = GetServerAdminUrl(getter_Copies(manageMailAccountUrl));
if (NS_SUCCEEDED(rv) && manageMailAccountUrl.Length())
{
nsCOMPtr <nsIDocShell> docShell;
@ -3039,6 +3161,15 @@ NS_IMETHODIMP nsImapMailFolder::FolderPrivileges(nsIMsgWindow *window)
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetHasAdminUrl(PRBool *aBool)
{
NS_ENSURE_ARG_POINTER(aBool);
nsXPIDLCString manageMailAccountUrl;
nsresult rv = GetServerAdminUrl(getter_Copies(manageMailAccountUrl));
*aBool = (NS_SUCCEEDED(rv) && manageMailAccountUrl.Length());
return rv;
}
nsresult nsImapMailFolder::MoveIncorporatedMessage(nsIMsgDBHdr *mailHdr,
nsIMsgDatabase *sourceDB,
const char *destFolderUri,
@ -3225,7 +3356,7 @@ void nsImapMailFolder::PrepareToAddHeadersToMailDB(nsIImapProtocol* aProtocol, c
SetParseMailboxState(new ParseIMAPMailboxState(m_master, m_host, this,
urlQueue,
boxSpec->flagState));
boxSpec->flagState = NULL; // adopted by ParseIMAPMailboxState
boxSpec->flagState = nsnull; // adopted by ParseIMAPMailboxState
GetParseMailboxState()->SetPane(url_pane);
GetParseMailboxState()->SetDB(mailDB);
@ -3241,12 +3372,12 @@ void nsImapMailFolder::PrepareToAddHeadersToMailDB(nsIImapProtocol* aProtocol, c
aProtocol->NotifyHdrsToDownload(theKeys, total /*keysToFetch.GetSize() */);
// now, tell it we don't need any bodies.
if (aProtocol)
aProtocol->NotifyBodysToDownload(NULL, 0);
aProtocol->NotifyBodysToDownload(nsnull, 0);
}
else
{
if (aProtocol)
aProtocol->NotifyHdrsToDownload(NULL, 0);
aProtocol->NotifyHdrsToDownload(nsnull, 0);
}
}
}
@ -3546,7 +3677,7 @@ nsImapMailFolder::OnlineCopyCompleted(nsIImapProtocol *aProtocol, ImapOnlineCopy
char *keyTokenString = nsCRT::strdup(messageIds);
ParseUidString(keyTokenString, affectedMessages);
if (mDatabase)
mDatabase->DeleteMessages(&affectedMessages,NULL);
mDatabase->DeleteMessages(&affectedMessages,nsnull);
nsCRT::free(keyTokenString);
return rv;
}
@ -3667,7 +3798,7 @@ nsImapMailFolder::NotifyMessageDeleted(const char *onlineFolderName,PRBool delet
if (deleteAllMsgs)
{
#ifdef HAVE_PORT
TNeoFolderInfoTransfer *originalInfo = NULL;
TNeoFolderInfoTransfer *originalInfo = nsnull;
nsIMsgDatabase *folderDB;
if (ImapMailDB::Open(GetPathname(), PR_FALSE, &folderDB, GetMaster(), &wasCreated) == eSUCCESS)
{
@ -4195,28 +4326,45 @@ NS_IMETHODIMP
nsImapMailFolder::ClearFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
{
return NS_ERROR_FAILURE;
SetFolderNeedsACLListed(PR_FALSE);
delete m_folderACL;
m_folderACL = new nsMsgIMAPFolderACL(this);
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::AddFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
nsImapMailFolder::AddFolderRights(const char *userName, const char *rights)
{
return NS_ERROR_FAILURE;
SetFolderNeedsACLListed(PR_FALSE);
GetFolderACL()->SetFolderRightsForUser(userName, rights);
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
{
return NS_ERROR_FAILURE;
if (GetFolderACL()->GetIsFolderShared())
{
SetFlag(MSG_FOLDER_FLAG_PERSONAL_SHARED);
}
else
{
ClearFlag(MSG_FOLDER_FLAG_PERSONAL_SHARED);
}
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::FolderNeedsACLInitialized(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
{
return NS_ERROR_FAILURE;
PRBool noSelect;
GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, &noSelect);
return (m_folderNeedsACLListed &&
!GetFolderIsNamespace() &&
!noSelect);
}
NS_IMETHODIMP
@ -4459,7 +4607,7 @@ nsImapMailFolder::HeaderFetchCompleted(nsIImapProtocol* aProtocol)
aProtocol->NotifyBodysToDownload(keysToDownload.GetArray(), keysToDownload.GetSize());
}
else
aProtocol->NotifyBodysToDownload(NULL, 0/*keysToFetch.GetSize() */);
aProtocol->NotifyBodysToDownload(nsnull, 0/*keysToFetch.GetSize() */);
}
return NS_OK;
}
@ -4495,6 +4643,502 @@ nsImapMailFolder::LiteSelectUIDValidity(nsIImapProtocol* aProtocol,
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::FillInFolderProps(nsIMsgImapFolderProps *aFolderProps)
{
NS_ENSURE_ARG(aFolderProps);
PRUint32 folderTypeStringID;
PRUint32 folderTypeDescStringID = 0;
nsXPIDLString folderType;
nsXPIDLString folderTypeDesc;
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = IMAPGetStringBundle(getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
if (mFlags & MSG_FOLDER_FLAG_IMAP_PUBLIC)
{
folderTypeStringID = IMAP_PUBLIC_FOLDER_TYPE_NAME;
folderTypeDescStringID = IMAP_PUBLIC_FOLDER_TYPE_DESCRIPTION;
}
else if (mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER)
{
folderTypeStringID = IMAP_OTHER_USERS_FOLDER_TYPE_NAME;
nsXPIDLCString owner;
nsXPIDLString uniOwner;
GetFolderOwnerUserName(getter_Copies(owner));
if (!owner.Length())
{
rv = IMAPGetStringByID(folderTypeStringID, getter_Copies(uniOwner));
// Another user's folder, for which we couldn't find an owner name
NS_ASSERTION(PR_FALSE, "couldn't get owner name for other user's folder");
}
else
{
// is this right? It doesn't leak, does it?
uniOwner.Assign(NS_ConvertASCIItoUCS2(owner.get()));
}
const PRUnichar *params[] = { uniOwner.get() };
rv = bundle->FormatStringFromID(IMAP_OTHER_USERS_FOLDER_TYPE_DESCRIPTION, params, 1, getter_Copies(folderTypeDesc));
}
// personal folder - 4.x distinguished between shared and not personal folders,
// but put up the same folder type, so we don't need to distinguish here, I guess.
// else if (GetFolderACL()->GetIsFolderShared())
// folderTypeStringID = IMAP_PERSONAL_SHARED_FOLDER_TYPE_NAME;
else
{
folderTypeStringID = IMAP_PERSONAL_SHARED_FOLDER_TYPE_NAME;
folderTypeDescStringID = IMAP_PERSONAL_SHARED_FOLDER_TYPE_DESCRIPTION;
}
rv = IMAPGetStringByID(folderTypeStringID, getter_Copies(folderType));
if (NS_SUCCEEDED(rv))
aFolderProps->SetFolderType(folderType);
if (!folderTypeDesc.Length() && folderTypeDescStringID != 0)
rv = IMAPGetStringByID(folderTypeDescStringID, getter_Copies(folderTypeDesc));
if (folderTypeDesc.Length())
aFolderProps->SetFolderTypeDescription(folderTypeDesc.get());
nsXPIDLString rightsString;
rv = CreateACLRightsStringForFolder(getter_Copies(rightsString));
if (NS_SUCCEEDED(rv))
aFolderProps->SetFolderPermissions(rightsString.get());
return NS_OK;
}
NS_IMETHODIMP nsImapMailFolder::SetAclFlags(PRUint32 aclFlags)
{
nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
nsresult rv = GetDatabase(nsnull);
if (mDatabase)
{
rv = mDatabase->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
if (NS_SUCCEEDED(rv) && dbFolderInfo)
dbFolderInfo->SetUint32Property("aclFlags", aclFlags);
}
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetAclFlags(PRUint32 *aclFlags)
{
NS_ENSURE_ARG_POINTER(aclFlags);
nsCOMPtr<nsIDBFolderInfo> dbFolderInfo;
nsresult rv = GetDatabase(nsnull);
if (mDatabase)
{
rv = mDatabase->GetDBFolderInfo(getter_AddRefs(dbFolderInfo));
if (NS_SUCCEEDED(rv) && dbFolderInfo)
rv = dbFolderInfo->GetUint32Property("aclFlags", aclFlags, 0);
}
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetCanIOpenThisFolder(PRBool *aBool)
{
NS_ENSURE_ARG_POINTER(aBool);
PRBool noSelect;
GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, &noSelect);
*aBool = (noSelect) ? PR_FALSE : GetFolderACL()->GetCanIReadFolder();
return NS_OK;
}
///////// nsMsgIMAPFolderACL class ///////////////////////////////
// This string is defined in the ACL RFC to be "anyone"
#define IMAP_ACL_ANYONE_STRING "anyone"
static int
imap_hash_strcmp (const void *a, const void *b)
{
return strcmp ((const char *) a, (const char *) b);
}
/* static */PRBool nsMsgIMAPFolderACL::FreeHashRights(nsHashKey *aKey, void *aData,
void *closure)
{
PR_FREEIF(aData);
return PR_TRUE;
}
nsMsgIMAPFolderACL::nsMsgIMAPFolderACL(nsImapMailFolder *folder)
{
NS_ASSERTION(folder, "need folder");
m_folder = folder;
m_rightsHash = new nsHashtable(24);
m_aclCount = 0;
BuildInitialACLFromCache();
}
nsMsgIMAPFolderACL::~nsMsgIMAPFolderACL()
{
m_rightsHash->Reset(FreeHashRights, nsnull);
delete m_rightsHash;
}
// We cache most of our own rights in the MSG_FOLDER_PREF_* flags
void nsMsgIMAPFolderACL::BuildInitialACLFromCache()
{
nsCAutoString myrights;
PRUint32 startingFlags;
m_folder->GetAclFlags(&startingFlags);
if (startingFlags & IMAP_ACL_READ_FLAG)
myrights += "r";
if (startingFlags & IMAP_ACL_STORE_SEEN_FLAG)
myrights += "s";
if (startingFlags & IMAP_ACL_WRITE_FLAG)
myrights += "w";
if (startingFlags & IMAP_ACL_INSERT_FLAG)
myrights += "i";
if (startingFlags & IMAP_ACL_POST_FLAG)
myrights += "p";
if (startingFlags & IMAP_ACL_CREATE_SUBFOLDER_FLAG)
myrights +="c";
if (startingFlags & IMAP_ACL_DELETE_FLAG)
myrights += "d";
if (startingFlags & IMAP_ACL_ADMINISTER_FLAG)
myrights += "a";
if (myrights.Length())
SetFolderRightsForUser(nsnull, myrights.get());
}
void nsMsgIMAPFolderACL::UpdateACLCache()
{
PRUint32 startingFlags = 0;
m_folder->GetAclFlags(&startingFlags);
if (GetCanIReadFolder())
startingFlags |= IMAP_ACL_READ_FLAG;
else
startingFlags &= ~IMAP_ACL_READ_FLAG;
if (GetCanIStoreSeenInFolder())
startingFlags |= IMAP_ACL_STORE_SEEN_FLAG;
else
startingFlags &= ~IMAP_ACL_STORE_SEEN_FLAG;
if (GetCanIWriteFolder())
startingFlags |= IMAP_ACL_WRITE_FLAG;
else
startingFlags &= ~IMAP_ACL_WRITE_FLAG;
if (GetCanIInsertInFolder())
startingFlags |= IMAP_ACL_INSERT_FLAG;
else
startingFlags &= ~IMAP_ACL_INSERT_FLAG;
if (GetCanIPostToFolder())
startingFlags |= IMAP_ACL_POST_FLAG;
else
startingFlags &= ~IMAP_ACL_POST_FLAG;
if (GetCanICreateSubfolder())
startingFlags |= IMAP_ACL_CREATE_SUBFOLDER_FLAG;
else
startingFlags &= ~IMAP_ACL_CREATE_SUBFOLDER_FLAG;
if (GetCanIDeleteInFolder())
startingFlags |= IMAP_ACL_DELETE_FLAG;
else
startingFlags &= ~IMAP_ACL_DELETE_FLAG;
if (GetCanIAdministerFolder())
startingFlags |= IMAP_ACL_ADMINISTER_FLAG;
else
startingFlags &= ~IMAP_ACL_ADMINISTER_FLAG;
m_folder->SetAclFlags(startingFlags);
}
PRBool nsMsgIMAPFolderACL::SetFolderRightsForUser(const char *userName, const char *rights)
{
PRBool rv = PR_FALSE;
nsXPIDLCString myUserName;
m_folder->GetUsername(getter_Copies(myUserName));
char *ourUserName = nsnull;
if (!userName)
ourUserName = strdup(myUserName.get());
else
ourUserName = strdup(userName);
char *rightsWeOwn = strdup(rights);
nsCStringKey hashKey(ourUserName);
if (rightsWeOwn && ourUserName)
{
char *oldValue = (char *) m_rightsHash->Get(&hashKey);
if (oldValue)
{
PR_FREEIF(oldValue);
m_rightsHash->Remove(&hashKey);
m_aclCount--;
NS_ASSERTION(m_aclCount >= 0, "acl count can't go negative");
}
m_aclCount++;
rv = (m_rightsHash->Put(&hashKey, rightsWeOwn) == 0);
}
if (ourUserName &&
(!strcmp(ourUserName, myUserName) || !strcmp(ourUserName, IMAP_ACL_ANYONE_STRING)))
{
// if this is setting an ACL for me, cache it in the folder pref flags
UpdateACLCache();
}
return rv;
}
const char *nsMsgIMAPFolderACL::GetRightsStringForUser(const char *inUserName)
{
nsXPIDLCString userName;
userName.Assign(inUserName);
if (!userName.Length())
m_folder->GetUsername(getter_Copies(userName));
nsCStringKey userKey(userName.get());
return (const char *)m_rightsHash->Get(&userKey);
}
// First looks for individual user; then looks for 'anyone' if the user isn't found.
// Returns defaultIfNotFound, if neither are found.
PRBool nsMsgIMAPFolderACL::GetFlagSetInRightsForUser(const char *userName, char flag, PRBool defaultIfNotFound)
{
const char *flags = GetRightsStringForUser(userName);
if (!flags)
{
const char *anyoneFlags = GetRightsStringForUser(IMAP_ACL_ANYONE_STRING);
if (!anyoneFlags)
return defaultIfNotFound;
else
return (strchr(anyoneFlags, flag) != nsnull);
}
else
return (strchr(flags, flag) != nsnull);
}
PRBool nsMsgIMAPFolderACL::GetCanUserLookupFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'l', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserReadFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'r', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserStoreSeenInFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 's', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserWriteFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'w', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserInsertInFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'i', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserPostToFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'p', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserCreateSubfolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'c', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserDeleteInFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'd', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanUserAdministerFolder(const char *userName)
{
return GetFlagSetInRightsForUser(userName, 'a', PR_FALSE);
}
PRBool nsMsgIMAPFolderACL::GetCanILookupFolder()
{
return GetFlagSetInRightsForUser(nsnull, 'l', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanIReadFolder()
{
return GetFlagSetInRightsForUser(nsnull, 'r', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanIStoreSeenInFolder()
{
return GetFlagSetInRightsForUser(nsnull, 's', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanIWriteFolder()
{
return GetFlagSetInRightsForUser(nsnull, 'w', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanIInsertInFolder()
{
return GetFlagSetInRightsForUser(nsnull, 'i', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanIPostToFolder()
{
return GetFlagSetInRightsForUser(nsnull, 'p', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanICreateSubfolder()
{
return GetFlagSetInRightsForUser(nsnull, 'c', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanIDeleteInFolder()
{
return GetFlagSetInRightsForUser(nsnull, 'd', PR_TRUE);
}
PRBool nsMsgIMAPFolderACL::GetCanIAdministerFolder()
{
return GetFlagSetInRightsForUser(nsnull, 'a', PR_TRUE);
}
// We use this to see if the ACLs think a folder is shared or not.
// We will define "Shared" in 5.0 to mean:
// At least one user other than the currently authenticated user has at least one
// explicitly-listed ACL right on that folder.
PRBool nsMsgIMAPFolderACL::GetIsFolderShared()
{
// If we have more than one ACL count for this folder, which means that someone
// other than ourself has rights on it, then it is "shared."
if (m_aclCount > 1)
return PR_TRUE;
// Or, if "anyone" has rights to it, it is shared.
nsCStringKey hashKey(IMAP_ACL_ANYONE_STRING);
const char *anyonesRights = (const char *)m_rightsHash->Get(&hashKey);
return (anyonesRights != nsnull);
}
PRBool nsMsgIMAPFolderACL::GetDoIHaveFullRightsForFolder()
{
return (GetCanIReadFolder() &&
GetCanIWriteFolder() &&
GetCanIInsertInFolder() &&
GetCanIAdministerFolder() &&
GetCanICreateSubfolder() &&
GetCanIDeleteInFolder() &&
GetCanILookupFolder() &&
GetCanIStoreSeenInFolder() &&
GetCanIPostToFolder());
}
// Returns a newly allocated string describing these rights
nsresult nsMsgIMAPFolderACL::CreateACLRightsString(PRUnichar **rightsString)
{
nsAutoString rights;
nsXPIDLString curRight;
nsCOMPtr<nsIStringBundle> bundle;
nsresult rv = IMAPGetStringBundle(getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
if (GetDoIHaveFullRightsForFolder())
{
return bundle->GetStringFromID(IMAP_ACL_FULL_RIGHTS, rightsString);
}
else
{
if (GetCanIReadFolder())
{
bundle->GetStringFromID(IMAP_ACL_READ_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanIWriteFolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_WRITE_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanIInsertInFolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_INSERT_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanILookupFolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_LOOKUP_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanIStoreSeenInFolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_SEEN_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanIDeleteInFolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_DELETE_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanICreateSubfolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_CREATE_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanIPostToFolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_POST_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
if (GetCanIAdministerFolder())
{
if (rights.Length()) rights += NS_LITERAL_STRING(", ");
bundle->GetStringFromID(IMAP_ACL_ADMINISTER_RIGHT, getter_Copies(curRight));
rights.Append(curRight);
}
}
*rightsString = ToNewUnicode(rights);
return rv;
}
#ifdef WE_HAVE_NS_YET
PRBool MSG_IsFolderACLInitialized(const char *folderName, const char *hostName)
{
MSG_IMAPFolderInfoMail *fi = master->FindImapMailFolder(hostName, folderName, nsnull, PR_FALSE);
if (fi)
return ((fi->GetFolderPrefFlags() & MSG_FOLDER_PREF_IMAP_ACL_RETRIEVED) ||
fi->GetFolderIsNamespace() ||
fi->GetFolderIsNoSelect()); // If a namespace or \Noselect, treat it as if initialized
else
{
NS_ASSERTION(PR_FALSE, "no folder");
return PR_TRUE; // If we can't find the folder, we don't want to get ACLs for it
}
}
#endif
NS_IMETHODIMP nsImapMailFolder::GetPath(nsIFileSpec ** aPathName)
{
nsresult rv;
@ -5456,7 +6100,7 @@ nsImapMailFolder::CopyStreamMessage(nsIMsgDBHdr* message,
nsCOMPtr<nsICopyMessageStreamListener> copyStreamListener;
rv = nsComponentManager::CreateInstance(kCopyMessageStreamListenerCID,
NULL, NS_GET_IID(nsICopyMessageStreamListener),
nsnull, NS_GET_IID(nsICopyMessageStreamListener),
getter_AddRefs(copyStreamListener));
if(NS_FAILED(rv))
return rv;
@ -5616,10 +6260,28 @@ NS_IMETHODIMP nsImapMailFolder::SetFolderNeedsSubscribing(PRBool bVal)
return NS_OK;
}
nsMsgIMAPFolderACL * nsImapMailFolder::GetFolderACL()
{
if (!m_folderACL)
m_folderACL = new nsMsgIMAPFolderACL(this);
return m_folderACL;
}
nsresult nsImapMailFolder::CreateACLRightsStringForFolder(PRUnichar **rightsString)
{
NS_ENSURE_ARG_POINTER(rightsString);
GetFolderACL(); // lazy create
if (m_folderACL)
{
return m_folderACL->CreateACLRightsString(rightsString);
}
return NS_ERROR_NULL_POINTER;
}
NS_IMETHODIMP nsImapMailFolder::GetFolderNeedsACLListed(PRBool *bVal)
{
if (!bVal)
return NS_ERROR_NULL_POINTER;
NS_ENSURE_ARG_POINTER(bVal);
// *** jt -- come back later; still need to worry about if the folder
// itself is a namespace
*bVal = (m_folderNeedsACLListed && !(mFlags &
@ -5634,6 +6296,125 @@ NS_IMETHODIMP nsImapMailFolder::SetFolderNeedsACLListed(PRBool bVal)
return NS_OK;
}
PRBool nsImapMailFolder::GetFolderIsNamespace()
{
if (!m_namespace)
{
#ifdef DEBUG_bienvenu
// Make sure this isn't causing us to open the database
NS_ASSERTION(m_hierarchyDelimiter != kOnlineHierarchySeparatorUnknown, "hierarchy delimiter not set");
#endif
nsXPIDLCString hostName;
nsXPIDLCString onlineName;
GetHostname(getter_Copies(hostName));
GetOnlineName(getter_Copies(onlineName));
PRUnichar hierarchyDelimiter;
GetHierarchyDelimiter(&hierarchyDelimiter);
nsresult rv;
nsCOMPtr<nsIImapHostSessionList> hostSession =
do_GetService(kCImapHostSessionList, &rv);
if (NS_SUCCEEDED(rv) && hostSession)
{
m_namespace = nsIMAPNamespaceList::GetNamespaceForFolder(hostName.get(), onlineName.get(), (char) hierarchyDelimiter);
if (m_namespace == nsnull)
{
if (mFlags & MSG_FOLDER_FLAG_IMAP_OTHER_USER)
{
rv = hostSession->GetDefaultNamespaceOfTypeForHost(hostName.get(), kOtherUsersNamespace, m_namespace);
}
else if (mFlags & MSG_FOLDER_FLAG_IMAP_PUBLIC)
{
rv = hostSession->GetDefaultNamespaceOfTypeForHost(hostName.get(), kPublicNamespace, m_namespace);
}
else
{
rv = hostSession->GetDefaultNamespaceOfTypeForHost(hostName.get(), kPersonalNamespace, m_namespace);
}
}
NS_ASSERTION(m_namespace, "failed to get namespace");
if (m_namespace)
{
nsIMAPNamespaceList::SuggestHierarchySeparatorForNamespace(m_namespace, (char) hierarchyDelimiter);
m_folderIsNamespace = nsIMAPNamespaceList::GetFolderIsNamespace(hostName.get(), onlineName.get(), (char) hierarchyDelimiter, m_namespace);
}
}
}
return m_folderIsNamespace;
}
NS_IMETHODIMP nsImapMailFolder::SetFolderIsNamespace(PRBool isNamespace)
{
m_folderIsNamespace = isNamespace;
return NS_OK;
}
NS_IMETHODIMP nsImapMailFolder::ResetNamespaceReferences()
{
nsXPIDLCString serverKey;
nsXPIDLCString onlineName;
GetServerKey(getter_Copies(serverKey));
GetOnlineName(getter_Copies(onlineName));
PRUnichar hierarchyDelimiter;
GetHierarchyDelimiter(&hierarchyDelimiter);
m_namespace = nsIMAPNamespaceList::GetNamespaceForFolder(serverKey.get(), onlineName.get(), (char) hierarchyDelimiter);
NS_ASSERTION(m_namespace, "resetting null namespace");
if (m_namespace)
m_folderIsNamespace = nsIMAPNamespaceList::GetFolderIsNamespace(serverKey.get(), onlineName.get(), (char) hierarchyDelimiter, m_namespace);
else
m_folderIsNamespace = PR_FALSE;
nsCOMPtr<nsIEnumerator> aEnumerator;
GetSubFolders(getter_AddRefs(aEnumerator));
if (!aEnumerator)
return NS_OK;
nsCOMPtr<nsISupports> aSupport;
nsresult rv = aEnumerator->First();
while (NS_SUCCEEDED(rv))
{
rv = aEnumerator->CurrentItem(getter_AddRefs(aSupport));
nsCOMPtr<nsIMsgImapMailFolder> folder = do_QueryInterface(aSupport, &rv);
if (NS_FAILED(rv)) return rv;
folder->ResetNamespaceReferences();
rv = aEnumerator->Next();
}
return rv;
}
NS_IMETHODIMP nsImapMailFolder::FindOnlineSubFolder(const char *targetOnlineName, nsIMsgImapMailFolder **aResultFolder)
{
nsresult rv = NS_OK;
nsXPIDLCString onlineName;
GetOnlineName(getter_Copies(onlineName));
if (onlineName.Equals(targetOnlineName))
{
return QueryInterface(NS_GET_IID(nsIMsgImapMailFolder), (void **) aResultFolder);
}
nsCOMPtr<nsIEnumerator> aEnumerator;
GetSubFolders(getter_AddRefs(aEnumerator));
if (!aEnumerator)
return NS_OK;
nsCOMPtr<nsISupports> aSupport;
rv = aEnumerator->First();
while (NS_SUCCEEDED(rv))
{
rv = aEnumerator->CurrentItem(getter_AddRefs(aSupport));
nsCOMPtr<nsIMsgImapMailFolder> folder = do_QueryInterface(aSupport, &rv);
if (NS_FAILED(rv)) return rv;
rv = folder->FindOnlineSubFolder(targetOnlineName, aResultFolder);
if (*aResultFolder)
return rv;
rv = aEnumerator->Next();
}
return rv;
}
NS_IMETHODIMP nsImapMailFolder::GetFolderNeedsAdded(PRBool *bVal)
{
if (!bVal)

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

@ -60,8 +60,8 @@
#include "nsIImapMailFolderSink.h"
#include "nsIImapServerSink.h"
class nsImapMoveCoalescer;
class nsHashtable;
class nsHashKey;
#define COPY_BUFFER_SIZE 16384
/* b64534f0-3d53-11d3-ac2a-00805f8ac968 */
@ -107,6 +107,86 @@ public:
PRBool m_allowUndo;
};
// ACLs for this folder.
// Generally, we will try to always query this class when performing
// an operation on the folder.
// If the server doesn't support ACLs, none of this data will be filled in.
// Therefore, we can assume that if we look up ourselves and don't find
// any info (and also look up "anyone") then we have full rights, that is, ACLs don't exist.
class nsImapMailFolder;
#define IMAP_ACL_READ_FLAG 0x0000001 /* SELECT, CHECK, FETCH, PARTIAL, SEARCH, COPY from folder */
#define IMAP_ACL_STORE_SEEN_FLAG 0x0000002 /* STORE SEEN flag */
#define IMAP_ACL_WRITE_FLAG 0x0000004 /* STORE flags other than SEEN and DELETED */
#define IMAP_ACL_INSERT_FLAG 0x0000008 /* APPEND, COPY into folder */
#define IMAP_ACL_POST_FLAG 0x0000010 /* Can I send mail to the submission address for folder? */
#define IMAP_ACL_CREATE_SUBFOLDER_FLAG 0x0000020 /* Can I CREATE a subfolder of this folder? */
#define IMAP_ACL_DELETE_FLAG 0x0000040 /* STORE DELETED flag, perform EXPUNGE */
#define IMAP_ACL_ADMINISTER_FLAG 0x0000080 /* perform SETACL */
#define IMAP_ACL_RETRIEVED_FLAG 0x0000100 /* ACL info for this folder has been initialized */
class nsMsgIMAPFolderACL
{
public:
nsMsgIMAPFolderACL(nsImapMailFolder *folder);
~nsMsgIMAPFolderACL();
PRBool SetFolderRightsForUser(const char *userName, const char *rights);
public:
// generic for any user, although we might not use them in
// DO NOT use these for looking up information about the currently authenticated user.
// (There are some different checks and defaults we do).
// Instead, use the functions below, GetICan....()
PRBool GetCanUserLookupFolder(const char *userName); // Is folder visible to LIST/LSUB?
PRBool GetCanUserReadFolder(const char *userName); // SELECT, CHECK, FETCH, PARTIAL, SEARCH, COPY from folder?
PRBool GetCanUserStoreSeenInFolder(const char *userName); // STORE SEEN flag?
PRBool GetCanUserWriteFolder(const char *userName); // STORE flags other than SEEN and DELETED?
PRBool GetCanUserInsertInFolder(const char *userName); // APPEND, COPY into folder?
PRBool GetCanUserPostToFolder(const char *userName); // Can I send mail to the submission address for folder?
PRBool GetCanUserCreateSubfolder(const char *userName); // Can I CREATE a subfolder of this folder?
PRBool GetCanUserDeleteInFolder(const char *userName); // STORE DELETED flag, perform EXPUNGE?
PRBool GetCanUserAdministerFolder(const char *userName); // perform SETACL?
// Functions to find out rights for the currently authenticated user.
PRBool GetCanILookupFolder(); // Is folder visible to LIST/LSUB?
PRBool GetCanIReadFolder(); // SELECT, CHECK, FETCH, PARTIAL, SEARCH, COPY from folder?
PRBool GetCanIStoreSeenInFolder(); // STORE SEEN flag?
PRBool GetCanIWriteFolder(); // STORE flags other than SEEN and DELETED?
PRBool GetCanIInsertInFolder(); // APPEND, COPY into folder?
PRBool GetCanIPostToFolder(); // Can I send mail to the submission address for folder?
PRBool GetCanICreateSubfolder(); // Can I CREATE a subfolder of this folder?
PRBool GetCanIDeleteInFolder(); // STORE DELETED flag, perform EXPUNGE?
PRBool GetCanIAdministerFolder(); // perform SETACL?
PRBool GetDoIHaveFullRightsForFolder(); // Returns TRUE if I have full rights on this folder (all of the above return TRUE)
PRBool GetIsFolderShared(); // We use this to see if the ACLs think a folder is shared or not.
// We will define "Shared" in 5.0 to mean:
// At least one user other than the currently authenticated user has at least one
// explicitly-listed ACL right on that folder.
// Returns a newly allocated string describing these rights
nsresult CreateACLRightsString(PRUnichar **rightsString);
protected:
const char *GetRightsStringForUser(const char *userName);
PRBool GetFlagSetInRightsForUser(const char *userName, char flag, PRBool defaultIfNotFound);
void BuildInitialACLFromCache();
void UpdateACLCache();
static PRBool FreeHashRights(nsHashKey *aKey, void *aData, void *closure);
protected:
nsHashtable *m_rightsHash; // Hash table, mapping username strings to rights strings.
nsImapMailFolder *m_folder;
PRInt32 m_aclCount;
};
class nsImapMailFolder : public nsMsgDBFolder,
public nsIMsgImapMailFolder,
public nsIImapMailFolderSink,
@ -227,8 +307,6 @@ public:
NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD AddFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD FolderNeedsACLInitialized(nsIImapProtocol* aProtocol,
@ -317,6 +395,17 @@ protected:
nsresult GetDatabase(nsIMsgWindow *aMsgWindow);
virtual const char *GetIncomingServerType() {return "imap";}
nsresult GetFolderOwnerUserName(char **userName);
nsresult GetOwnersOnlineFolderName(char **onlineName);
nsIMAPNamespace *GetNamespaceForFolder();
void SetNamespaceForFolder(nsIMAPNamespace *ns);
PRBool GetFolderIsNamespace();
// ### TODO if this is supposed to be a method of an interface, which interface, and who will call it?
NS_IMETHODIMP SetFolderIsNamespace(PRBool isNamespace);
nsresult GetServerAdminUrl(char **aAdminUrl);
nsMsgIMAPFolderACL * GetFolderACL();
nsresult CreateACLRightsStringForFolder(PRUnichar **rightsString);
nsresult GetBodysToDownload(nsMsgKeyArray *keysOfMessagesToDownload);
// Uber message copy service
@ -371,16 +460,23 @@ protected:
nsCOMPtr<nsMsgTxn> m_pendingUndoTxn;
nsCOMPtr<nsImapMailCopyState> m_copyState;
PRMonitor *m_appendMsgMonitor;
PRBool m_verifiedAsOnlineFolder;
PRBool m_explicitlyVerify; // whether or not we need to explicitly verify this through LIST
PRUnichar m_hierarchyDelimiter;
PRInt32 m_boxFlags;
nsCString m_onlineFolderName;
nsFileSpec *m_pathName;
nsCString m_ownerUserName; // username of the "other user," as in
// "Other Users' Mailboxes"
PRBool m_folderNeedsSubscribing;
PRBool m_folderNeedsAdded;
PRBool m_folderNeedsACLListed;
nsIMAPNamespace *m_namespace; // Opaque pointer to the IMAP namespace for this folder
// Use libnet accessors for various namespace functionality
PRPackedBool m_verifiedAsOnlineFolder;
PRPackedBool m_explicitlyVerify; // whether or not we need to explicitly verify this through LIST
PRPackedBool m_folderIsNamespace;
PRPackedBool m_folderNeedsSubscribing;
PRPackedBool m_folderNeedsAdded;
PRPackedBool m_folderNeedsACLListed;
nsMsgIMAPFolderACL *m_folderACL;
nsCOMPtr<nsIMsgMailNewsUrl> mUrlToRelease;
@ -389,4 +485,6 @@ protected:
PRBool m_downloadingFolderForOfflineUse;
};
#endif

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

@ -3682,10 +3682,9 @@ void nsImapProtocol::AddFolderRightsForUser(const char *mailboxName, const char
aclRightsInfo->mailboxName && aclRightsInfo->rights &&
userName ? (aclRightsInfo->userName != NULL) : PR_TRUE)
{
if (m_imapExtensionSink)
if (m_imapServerSink)
{
m_imapExtensionSink->AddFolderRights(this, aclRightsInfo);
WaitForFEEventCompletion();
m_imapServerSink->AddFolderRights(mailboxName, userName, rights);
}
}
PR_FREEIF(aclRightsInfo->hostName);
@ -3965,9 +3964,14 @@ nsImapProtocol::DiscoverMailboxSpec(nsImapMailboxSpec * adoptedBoxSpec)
if (m_imapServerSink)
{
PRBool newFolder;
m_imapServerSink->PossibleImapMailbox(boxNameCopy.get(),
adoptedBoxSpec->hierarchySeparator,
adoptedBoxSpec->box_flags);
adoptedBoxSpec->box_flags, &newFolder);
// if it's a new folder to the server sink, setting discovery status to
// eContinueNew will cause us to get the ACL for the new folder.
if (newFolder)
SetMailboxDiscoveryStatus(eContinueNew);
PRBool useSubscription = PR_FALSE;
@ -4974,13 +4978,58 @@ void nsImapProtocol::RefreshACLForFolderIfNecessary(const char *mailboxName)
m_imapMailFolderSink->GetFolderNeedsACLListed(&m_folderNeedsACLRefreshed);
if (m_folderNeedsACLRefreshed)
{
OnRefreshACLForFolder(mailboxName);
RefreshACLForFolder(mailboxName);
m_folderNeedsACLRefreshed = PR_FALSE;
}
}
}
void nsImapProtocol::OnRefreshACLForFolder(const char *mailboxName)
void nsImapProtocol::RefreshACLForFolder(const char *mailboxName)
{
nsIMAPNamespace *ns = nsnull;
m_hostSessionList->GetNamespaceForMailboxForHost(GetImapServerKey(), mailboxName, ns);
if (ns)
{
switch (ns->GetType())
{
case kPersonalNamespace:
// It's a personal folder, most likely.
// I find it hard to imagine a server that supports ACL that doesn't support NAMESPACE,
// so most likely we KNOW that this is a personal, rather than the default, namespace.
// First, clear what we have.
ClearAllFolderRights(mailboxName, ns);
// 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.
// We only want our own rights
// First, clear what we have
ClearAllFolderRights(mailboxName, ns);
// 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;
}
}
else
{
// no namespace, not even default... can this happen?
NS_ASSERTION(PR_FALSE, "couldn't get namespace");
}
}
void nsImapProtocol::GetACLForFolder(const char *mailboxName)
{
IncrementCommandTagNumber();
@ -5017,7 +5066,7 @@ void nsImapProtocol::OnRefreshAllACLs()
mb->GetDelimiter(), &onlineName);
if (onlineName)
{
OnRefreshACLForFolder(onlineName);
RefreshACLForFolder(onlineName);
nsCRT::free(onlineName);
}
PercentProgressUpdateEvent(NULL, count, total);
@ -5859,7 +5908,7 @@ void nsImapProtocol::DiscoverMailboxList()
m_runningUrl->AllocateServerPath(mb->GetMailboxName(), mb->GetDelimiter(), &onlineName);
if (onlineName)
{
OnRefreshACLForFolder(onlineName);
RefreshACLForFolder(onlineName);
PR_Free(onlineName);
}
}
@ -5879,8 +5928,7 @@ PRBool nsImapProtocol::FolderNeedsACLInitialized(const char *folderName)
char *name = PL_strdup(folderName);
if (!name)
return PR_FALSE;
// mscott - big hack...where do we get a IMAPACLRights object from??????
// m_imapServerSink->FolderNeedsACLInitialized(name, nsnull);
m_imapServerSink->FolderNeedsACLInitialized(name, &rv);
PR_Free(name);
return rv;
@ -6341,7 +6389,7 @@ void nsImapProtocol::ProcessAuthenticatedStateURL()
break;
case nsIImapUrl::nsImapRefreshACL:
sourceMailbox = OnCreateServerSourceFolderPathString();
OnRefreshACLForFolder(sourceMailbox);
RefreshACLForFolder(sourceMailbox);
break;
case nsIImapUrl::nsImapRefreshAllACLs:
OnRefreshAllACLs();

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

@ -483,7 +483,8 @@ private:
void OnSubscribe(const char * aSourceMailbox);
void OnUnsubscribe(const char * aSourceMailbox);
void RefreshACLForFolderIfNecessary(const char * mailboxName);
void OnRefreshACLForFolder(const char * aSourceMailbox);
void RefreshACLForFolder(const char * aSourceMailbox);
void GetACLForFolder(const char *aMailboxName);
void OnRefreshAllACLs();
void OnListFolder(const char * aSourceMailbox, PRBool aBool);
void OnStatusForFolder(const char * sourceMailbox);

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

@ -169,36 +169,6 @@ nsImapExtensionSinkProxy::ClearFolderRights(nsIImapProtocol* aProtocol,
return res;
}
NS_IMETHODIMP
nsImapExtensionSinkProxy::AddFolderRights(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)
{
AddFolderRightsProxyEvent *ev =
new AddFolderRightsProxyEvent(this, aclRights);
if(nsnull == ev)
res = NS_ERROR_OUT_OF_MEMORY;
else
{
ev->SetNotifyCompletion(PR_TRUE);
ev->PostEvent(m_eventQueue);
}
}
else
{
res = m_realImapExtensionSink->AddFolderRights(aProtocol, aclRights);
aProtocol->NotifyFEEventCompletion();
}
return res;
}
NS_IMETHODIMP
nsImapExtensionSinkProxy::RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
@ -693,49 +663,6 @@ ClearFolderRightsProxyEvent::HandleEvent()
return res;
}
AddFolderRightsProxyEvent::AddFolderRightsProxyEvent(
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;
}
}
AddFolderRightsProxyEvent::~AddFolderRightsProxyEvent()
{
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
AddFolderRightsProxyEvent::HandleEvent()
{
nsresult res = m_proxy->m_realImapExtensionSink->AddFolderRights(
m_proxy->m_protocol, &m_aclRightsInfo);
if (m_notifyCompletion)
m_proxy->m_protocol->NotifyFEEventCompletion();
return res;
}
RefreshFolderRightsProxyEvent::RefreshFolderRightsProxyEvent(
nsImapExtensionSinkProxy* aProxy, nsIMAPACLRightsInfo* aclRights) :
nsImapExtensionSinkProxyEvent(aProxy)

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

@ -81,8 +81,6 @@ public:
NS_IMETHOD ClearFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD AddFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD FolderNeedsACLInitialized(nsIImapProtocol* aProtocol,
@ -169,15 +167,6 @@ struct ClearFolderRightsProxyEvent : nsImapExtensionSinkProxyEvent
nsIMAPACLRightsInfo m_aclRightsInfo;
};
struct AddFolderRightsProxyEvent : nsImapExtensionSinkProxyEvent
{
AddFolderRightsProxyEvent(nsImapExtensionSinkProxy* aProxy,
nsIMAPACLRightsInfo* aclRights);
virtual ~AddFolderRightsProxyEvent();
NS_IMETHOD HandleEvent();
nsIMAPACLRightsInfo m_aclRightsInfo;
};
struct RefreshFolderRightsProxyEvent : nsImapExtensionSinkProxyEvent
{
RefreshFolderRightsProxyEvent(nsImapExtensionSinkProxy* aProxy,

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

@ -373,8 +373,6 @@ nsImapService::SelectFolder(nsIEventQueue * aClientEventQueue,
nsIMsgWindow *aMsgWindow,
nsIURI ** aURL)
{
// create a protocol instance to handle the request.
// NOTE: once we start working with multiple connections, this step will be much more complicated...but for now
// just create a connection and process the request.
@ -386,10 +384,12 @@ nsImapService::SelectFolder(nsIEventQueue * aClientEventQueue,
if (WeAreOffline())
return NS_MSG_ERROR_OFFLINE;
PRBool noSelect = PR_FALSE;
aImapMailFolder->GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, &noSelect);
PRBool canOpenThisFolder = PR_TRUE;
nsCOMPtr <nsIMsgImapMailFolder> imapFolder = do_QueryInterface(aImapMailFolder);
if (imapFolder)
imapFolder->GetCanIOpenThisFolder(&canOpenThisFolder);
if (noSelect) return NS_OK;
if (!canOpenThisFolder) return NS_OK;
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString urlSpec;

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

@ -83,6 +83,7 @@ public:
static nsresult ConvertToCanonicalFormat(const char *folderName, char onlineDelimiter, char **resultingCanonicalPath);
static nsresult EscapeSlashes(const char *sourcePath, char **resultPath);
static nsresult UnescapeSlashes(char *path);
static char * ReplaceCharsInCopiedString(const char *stringToCopy, char oldChar, char newChar);
protected:
virtual nsresult ParseUrl();
@ -93,7 +94,6 @@ protected:
// handle the imap specific parsing
void ParseImapPart(char *imapPartOfUrl);
static char * ReplaceCharsInCopiedString(const char *stringToCopy, char oldChar, char newChar);
void ParseFolderPath(char **resultingCanonicalPath);
void ParseSearchCriteriaString();
void ParseChildDiscoveryDepth();