add folder listing, support for imap extensions, fix prob deleting from trash,r=mscott

This commit is contained in:
bienvenu%netscape.com 2000-01-08 01:38:34 +00:00
Родитель 0d8d377efa
Коммит 37f6448763
6 изменённых файлов: 120 добавлений и 20 удалений

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

@ -110,7 +110,8 @@ typedef enum {
kHasAuthPlainCapability = 0x00001000, /* new form of auth plain base64
login */
kUidplusCapability = 0x00002000, /* RFC 2359 UIDPLUS extension */
kLiteralPlusCapability = 0x00004000 /* RFC 2088 LITERAL+ extension */
kLiteralPlusCapability = 0x00004000, /* RFC 2088 LITERAL+ extension */
kAOLImapCapability = 0x00008000 /* aol imap extensions */
} eIMAPCapabilityFlag;
// this used to be part of the connection object class - maybe we should move it into

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

@ -200,6 +200,26 @@ NS_IMPL_SERVERPREF_BOOL(nsImapIncomingServer, FetchByChunks,
NS_IMPL_SERVERPREF_BOOL(nsImapIncomingServer, MimePartsOnDemand,
"mime_parts_on_demand");
NS_IMETHODIMP
nsImapIncomingServer::GetIsAOLServer(PRBool *aBool)
{
if (!aBool)
return NS_ERROR_NULL_POINTER;
*aBool = ((m_capability & kAOLImapCapability) != 0);
return NS_OK;
}
NS_IMETHODIMP
nsImapIncomingServer::SetIsAOLServer(PRBool aBool)
{
if (aBool)
m_capability |= kAOLImapCapability;
else
m_capability &= ~kAOLImapCapability;
return NS_OK;
}
NS_IMETHODIMP
nsImapIncomingServer::GetImapConnectionAndLoadUrl(nsIEventQueue * aClientEventQueue,
nsIImapUrl* aImapUrl,
@ -537,6 +557,7 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
{
nsresult rv;
PRBool found = PR_FALSE;
PRBool haveParent = PR_FALSE;
nsCOMPtr<nsIMsgImapMailFolder> hostFolder;
nsCOMPtr<nsIMsgFolder> aFolder;
@ -554,16 +575,20 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
GetHostName(getter_Copies(hostName));
uri.Append(hostName);
#if 0
PRInt32 leafPos = folderName.RFindChar('/');
nsCAutoString parentName(folderName);
nsCAutoString parentUri(uri);
if (leafPos > 0)
{
uri.Append('/');
nsAutoString parentName(folderName);
{
// If there is a hierarchy, there is a parent.
// Don't strip off slash if it's the first character
parentName.Truncate(leafPos);
uri.Append(parentName);
}
#endif
haveParent = PR_TRUE;
parentUri.Append('/');
parentUri.Append(parentName);
}
nsCOMPtr<nsIFolder> rootFolder;
rv = GetRootFolder(getter_AddRefs(rootFolder));
@ -585,12 +610,26 @@ NS_IMETHODIMP nsImapIncomingServer::PossibleImapMailbox(const char *folderPath,
uri.Append('/');
uri.Append(folderPath);
a_nsIFolder->GetChildWithURI(uri, PR_TRUE, getter_AddRefs(child));
if (child)
found = PR_TRUE;
if (!found)
{
// trying to find/discover the parent
if (haveParent)
{
nsCOMPtr <nsIMsgFolder> parent;
a_nsIFolder->GetChildWithURI(parentUri, PR_TRUE, getter_AddRefs(parent));
if (!parent /* || parentFolder->GetFolderNeedsAdded()*/)
{
PossibleImapMailbox(parentName, hierarchyDelimiter,kNoselect | // be defensive
((boxFlags & // only inherit certain flags from the child
(kPublicMailbox | kOtherUsersMailbox | kPersonalMailbox))));
}
}
hostFolder->CreateClientSubfolderInfo(folderPath);
a_nsIFolder->GetChildWithURI(uri, PR_TRUE, getter_AddRefs(child));
}
@ -748,14 +787,7 @@ NS_IMETHODIMP nsImapIncomingServer::DiscoveryDone()
// Only if there are subfolders and at least one of them is verified do we want
// to refresh that folder's flags, because it won't be going away.
currentImapFolder->SetExplicitlyVerify(PR_FALSE);
#if 0
char *url = CreateIMAPListFolderURL(hostName, currentFolder->GetOnlineName(), currentFolder->GetOnlineHierarchySeparator());
if (url)
{
MSG_UrlQueue::AddUrlToPane(url, NULL, currentContext->imapURLPane);
XP_FREE(url);
}
#endif
currentImapFolder->List();
}
else
{

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

@ -603,6 +603,17 @@ NS_IMETHODIMP nsImapMailFolder::CreateClientSubfolderInfo(const char *folderName
return rv;
}
NS_IMETHODIMP nsImapMailFolder::List()
{
nsresult rv;
NS_WITH_SERVICE(nsIImapService, imapService, kCImapService, &rv);
if (NS_FAILED(rv))
return rv;
rv = imapService->ListFolder(m_eventQueue, this, nsnull, nsnull);
return rv;
}
NS_IMETHODIMP nsImapMailFolder::RemoveSubFolder (nsIMsgFolder *which)
{
nsCOMPtr<nsISupportsArray> folders;
@ -1138,7 +1149,13 @@ NS_IMETHODIMP nsImapMailFolder::DeleteMessages(nsISupportsArray *messages,
rv = GetFlag(MSG_FOLDER_FLAG_TRASH, &isTrashFolder);
if (NS_SUCCEEDED(rv) && isTrashFolder)
{
return StoreImapFlags(kImapMsgDeletedFlag, PR_TRUE, srcKeyArray);
rv = StoreImapFlags(kImapMsgDeletedFlag, PR_TRUE, srcKeyArray);
if (NS_SUCCEEDED(rv))
{
if (mDatabase)
mDatabase->DeleteMessages(&srcKeyArray,NULL);
return rv;
}
}
else
{
@ -1965,7 +1982,7 @@ nsresult nsImapMailFolder::StoreImapFlags(imapMessageFlagsType flags, PRBool add
nsCString msgIds;
AllocateUidStringFromKeyArray(keysToFlag, msgIds);
imapService->AddMessageFlags(m_eventQueue, this, nsnull,
imapService->AddMessageFlags(m_eventQueue, this, this,
nsnull, msgIds, flags, PR_TRUE);
}
else
@ -1973,7 +1990,7 @@ nsresult nsImapMailFolder::StoreImapFlags(imapMessageFlagsType flags, PRBool add
nsCString msgIds;
AllocateUidStringFromKeyArray(keysToFlag, msgIds);
imapService->SubtractMessageFlags(m_eventQueue, this, nsnull,
imapService->SubtractMessageFlags(m_eventQueue, this, this,
nsnull, msgIds, flags,
PR_TRUE);
}

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

@ -1104,7 +1104,7 @@ void nsImapServerResponseParser::msg_fetch()
}
}
}
else if (!PL_strcasecmp(fNextToken, "RFC822.SIZE"))
else if (!PL_strcasecmp(fNextToken, "RFC822.SIZE") || !PL_strcasecmp(fNextToken, "XAOL-SIZE"))
{
fNextToken = GetNextToken();
if (ContinueParse())
@ -1707,6 +1707,8 @@ void nsImapServerResponseParser::capability_data()
fCapabilityFlag |= kUidplusCapability;
else if (! PL_strcasecmp(fNextToken, "LITERAL+"))
fCapabilityFlag |= kLiteralPlusCapability;
else if (! PL_strcasecmp(fNextToken, "XAOL-OPTION"))
fCapabilityFlag |= kAOLImapCapability;
}
} while (fNextToken &&
!at_end_of_line() &&

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

@ -1585,6 +1585,49 @@ nsImapService::CreateFolder(nsIEventQueue* eventQueue, nsIMsgFolder* parent,
return rv;
}
NS_IMETHODIMP
nsImapService::ListFolder(nsIEventQueue* aClientEventQueue,
nsIMsgFolder* aImapMailFolder,
nsIUrlListener* aUrlListener,
nsIURI** aURL)
{
NS_ASSERTION(aClientEventQueue && aImapMailFolder ,
"Oops ... [RenameLeaf] null pointers");
if (!aClientEventQueue || !aImapMailFolder)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIImapUrl> imapUrl;
nsCAutoString urlSpec;
nsresult rv;
PRUnichar hierarchySeparator = '/';
rv = CreateStartOfImapUrl(getter_AddRefs(imapUrl), aImapMailFolder, aUrlListener, urlSpec, hierarchySeparator);
if (NS_SUCCEEDED(rv) && imapUrl)
{
rv = SetImapUrlSink(aImapMailFolder, imapUrl);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsIURI> uri = do_QueryInterface(imapUrl);
nsXPIDLCString folderName;
GetFolderName(aImapMailFolder, getter_Copies(folderName));
urlSpec.Append("/listfolder>");
urlSpec.Append(hierarchySeparator);
if ((const char *) folderName && nsCRT::strlen(folderName) > 0)
{
urlSpec.Append((const char *) folderName);
rv = uri->SetSpec((char*) urlSpec.GetBuffer());
if (NS_SUCCEEDED(rv))
rv = GetImapConnectionAndLoadUrl(aClientEventQueue, imapUrl,
nsnull,
aURL);
}
} // if (NS_SUCCEEDED(rv))
} // if (NS_SUCCEEDED(rv) && imapUrl)
return rv;
}
#ifdef HAVE_PORT
/* fetching the headers of RFC822 messages */

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

@ -178,6 +178,11 @@ public:
const char* leafName,
nsIUrlListener* urlListener,
nsIURI** url);
NS_IMETHOD ListFolder(nsIEventQueue* aClientEventQueue,
nsIMsgFolder* aImapMailFolder,
nsIUrlListener* aUrlListener,
nsIURI** aURL);
////////////////////////////////////////////////////////////////////////////////////////
// End support of nsIImapService interface
////////////////////////////////////////////////////////////////////////////////////////