fix imap subscribe ui not to allow subscription to no select/namespace folders r=sspitzer, sr=mscott 9572

This commit is contained in:
bienvenu%netscape.com 2002-02-05 15:54:14 +00:00
Родитель 59b7198e85
Коммит 1deb92ac73
7 изменённых файлов: 30 добавлений и 139 удалений

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

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

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

@ -82,6 +82,7 @@ interface nsIMsgImapMailFolder : nsISupports {
attribute long boxFlags;
attribute string onlineName;
attribute unsigned long aclFlags;
attribute boolean isNamespace;
readonly attribute boolean canIOpenThisFolder;
readonly attribute boolean hasAdminUrl;
};

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

@ -1092,21 +1092,27 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
if (mDoingSubscribeDialog)
{
rv = AddTo(folderPath, mDoingLsub /* add as subscribed */, mDoingLsub /* change if exists */);
NS_ENSURE_SUCCESS(rv,rv);
// Make sure the imapmailfolder object has the right delimiter because the unsubscribed
// folders (those not in the 'lsub' list) have the delimiter set to the default ('^').
if (a_nsIFolder && folderPath && (*folderPath))
{
nsCOMPtr<nsIMsgFolder> msgFolder;
nsCOMPtr<nsIFolder> subFolder;
PRBool isNamespace = PR_FALSE;
PRBool noSelect = PR_FALSE;
rv = a_nsIFolder->FindSubFolder(folderPath, getter_AddRefs(subFolder));
NS_ENSURE_SUCCESS(rv,rv);
msgFolder = do_QueryInterface(subFolder, &rv);
NS_ENSURE_SUCCESS(rv,rv);
msgFolder->GetNoSelect(&noSelect);
nsCOMPtr<nsIMsgImapMailFolder> imapFolder = do_QueryInterface(msgFolder, &rv);
NS_ENSURE_SUCCESS(rv,rv);
imapFolder->SetHierarchyDelimiter(hierarchyDelimiter);
isNamespace = (boxFlags & kNameSpace) != 0;
if (!isNamespace && !noSelect)
rv = AddTo(folderPath, mDoingLsub /* add as subscribed */, mDoingLsub /* change if exists */);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
}
}

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

@ -4361,18 +4361,6 @@ nsImapMailFolder::RefreshFolderRights(nsIImapProtocol* aProtocol,
return NS_OK;
}
NS_IMETHODIMP
nsImapMailFolder::FolderNeedsACLInitialized(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights)
{
PRBool noSelect;
GetFlag(MSG_FOLDER_FLAG_IMAP_NOSELECT, &noSelect);
return (m_folderNeedsACLListed &&
!GetFolderIsNamespace() &&
!noSelect);
}
NS_IMETHODIMP
nsImapMailFolder::SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* aKeyArray,
@ -5127,22 +5115,6 @@ nsresult nsMsgIMAPFolderACL::CreateACLRightsString(PRUnichar **rightsString)
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;
@ -6286,12 +6258,14 @@ nsresult nsImapMailFolder::CreateACLRightsStringForFolder(PRUnichar **rightsStri
NS_IMETHODIMP nsImapMailFolder::GetFolderNeedsACLListed(PRBool *bVal)
{
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 &
MSG_FOLDER_FLAG_IMAP_NOSELECT)
/* && !GetFolderIsNamespace() */ );
return NS_OK;
PRBool dontNeedACLListed = PR_TRUE;
// if we haven't acl listed, and it's not a no select folder, then we'll
// list the acl if it's not a namespace.
if (m_folderNeedsACLListed && !(mFlags & MSG_FOLDER_FLAG_IMAP_NOSELECT))
GetIsNamespace(&dontNeedACLListed);
*bVal = !dontNeedACLListed;
return NS_OK;
}
NS_IMETHODIMP nsImapMailFolder::SetFolderNeedsACLListed(PRBool bVal)
@ -6300,8 +6274,10 @@ NS_IMETHODIMP nsImapMailFolder::SetFolderNeedsACLListed(PRBool bVal)
return NS_OK;
}
PRBool nsImapMailFolder::GetFolderIsNamespace()
NS_IMETHODIMP nsImapMailFolder::GetIsNamespace(PRBool *aResult)
{
NS_ENSURE_ARG_POINTER(aResult);
nsresult rv = NS_OK;
if (!m_namespace)
{
#ifdef DEBUG_bienvenu
@ -6309,47 +6285,47 @@ PRBool nsImapMailFolder::GetFolderIsNamespace()
NS_ASSERTION(m_hierarchyDelimiter != kOnlineHierarchySeparatorUnknown, "hierarchy delimiter not set");
#endif
nsXPIDLCString hostName;
nsXPIDLCString onlineName;
GetHostname(getter_Copies(hostName));
nsXPIDLCString serverKey;
GetServerKey(getter_Copies(serverKey));
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);
m_namespace = nsIMAPNamespaceList::GetNamespaceForFolder(serverKey.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);
rv = hostSession->GetDefaultNamespaceOfTypeForHost(serverKey.get(), kOtherUsersNamespace, m_namespace);
}
else if (mFlags & MSG_FOLDER_FLAG_IMAP_PUBLIC)
{
rv = hostSession->GetDefaultNamespaceOfTypeForHost(hostName.get(), kPublicNamespace, m_namespace);
rv = hostSession->GetDefaultNamespaceOfTypeForHost(serverKey.get(), kPublicNamespace, m_namespace);
}
else
{
rv = hostSession->GetDefaultNamespaceOfTypeForHost(hostName.get(), kPersonalNamespace, m_namespace);
rv = hostSession->GetDefaultNamespaceOfTypeForHost(serverKey.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);
m_folderIsNamespace = nsIMAPNamespaceList::GetFolderIsNamespace(serverKey.get(), onlineName.get(), (char) hierarchyDelimiter, m_namespace);
}
}
}
return m_folderIsNamespace;
*aResult = m_folderIsNamespace;
return rv;
}
NS_IMETHODIMP nsImapMailFolder::SetFolderIsNamespace(PRBool isNamespace)
NS_IMETHODIMP nsImapMailFolder::SetIsNamespace(PRBool isNamespace)
{
m_folderIsNamespace = isNamespace;
return NS_OK;

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

@ -309,8 +309,6 @@ public:
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD FolderNeedsACLInitialized(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* keyArray,
const char* msgIdString,
@ -399,9 +397,6 @@ protected:
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();

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

@ -195,37 +195,6 @@ nsImapExtensionSinkProxy::RefreshFolderRights(nsIImapProtocol* aProtocol,
return res;
}
NS_IMETHODIMP
nsImapExtensionSinkProxy::FolderNeedsACLInitialized(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)
{
FolderNeedsACLInitializedProxyEvent *ev =
new FolderNeedsACLInitializedProxyEvent(this, aclRights);
if(nsnull == ev)
res = NS_ERROR_OUT_OF_MEMORY;
else
{
ev->SetNotifyCompletion(PR_TRUE);
ev->PostEvent(m_eventQueue);
}
}
else
{
res = m_realImapExtensionSink->FolderNeedsACLInitialized(aProtocol,
aclRights);
aProtocol->NotifyFEEventCompletion();
}
return res;
}
NS_IMETHODIMP
nsImapExtensionSinkProxy::SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* aKeyArray,
@ -706,49 +675,6 @@ RefreshFolderRightsProxyEvent::HandleEvent()
return res;
}
FolderNeedsACLInitializedProxyEvent::FolderNeedsACLInitializedProxyEvent(
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;
}
}
FolderNeedsACLInitializedProxyEvent::~FolderNeedsACLInitializedProxyEvent()
{
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
FolderNeedsACLInitializedProxyEvent::HandleEvent()
{
nsresult res = m_proxy->m_realImapExtensionSink->FolderNeedsACLInitialized(
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) :

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

@ -83,8 +83,6 @@ public:
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD RefreshFolderRights(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD FolderNeedsACLInitialized(nsIImapProtocol* aProtocol,
nsIMAPACLRightsInfo* aclRights);
NS_IMETHOD SetCopyResponseUid(nsIImapProtocol* aProtocol,
nsMsgKeyArray* aKeyArray,
const char* msgIdString,
@ -176,15 +174,6 @@ struct RefreshFolderRightsProxyEvent : nsImapExtensionSinkProxyEvent
nsIMAPACLRightsInfo m_aclRightsInfo;
};
struct FolderNeedsACLInitializedProxyEvent : nsImapExtensionSinkProxyEvent
{
FolderNeedsACLInitializedProxyEvent(nsImapExtensionSinkProxy* aProxy,
nsIMAPACLRightsInfo* aclRights);
virtual ~FolderNeedsACLInitializedProxyEvent();
NS_IMETHOD HandleEvent();
nsIMAPACLRightsInfo m_aclRightsInfo;
};
struct SetCopyResponseUidProxyEvent : nsImapExtensionSinkProxyEvent
{
SetCopyResponseUidProxyEvent(nsImapExtensionSinkProxy* aProxy,