more changes for the new subscribe dialog.

This commit is contained in:
sspitzer%netscape.com 2000-04-14 06:54:19 +00:00
parent 8f96fd3223
commit 09743b17ac
7 changed files with 98 additions and 38 deletions

View File

@ -126,10 +126,9 @@ interface nsIMsgIncomingServer : nsISupports {
/* do a biff */
void PerformBiff();
/* this checks if a Server need's a password, implemented because of biffing Nntp, Tobias A (TAJT) */
boolean GetServerRequiresPasswordForBiff();
/* this checks if a server needs a password to do biff */
readonly attribute boolean serverRequiresPasswordForBiff;
/* this gets called when the server is expanded in the folder pane */
void PerformExpand();

View File

@ -1469,6 +1469,8 @@ NS_IMETHODIMP nsMsgFolder::OnFlagChange(PRUint32 flag)
rv = GetDBFolderInfoAndDB(getter_AddRefs(folderInfo), getter_AddRefs(db));
if (NS_SUCCEEDED(rv) && folderInfo)
{
nsXPIDLString name;
rv = GetName(getter_Copies(name));
folderInfo->SetFlags((PRInt32) mFlags);
if (db)
db->Commit(nsMsgDBCommitType::kLargeCommit);

View File

@ -53,8 +53,9 @@ interface nsINntpIncomingServer : nsISupports {
attribute boolean newsrcHasChanged;
attribute long maximumConnectionsNumber;
/* used when populating the subscribe dialog */
void addNewNewsgroup(in string name, in string state, in string count);
void addNewNewsgroup(in string name);
void addSubscribedNewsgroups();
readonly attribute long numGroupsNeedingCounts;

View File

@ -2954,7 +2954,7 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng
#else
NS_ASSERTION(m_nntpServer, "no nntp incoming server");
if (m_nntpServer) {
rv = m_nntpServer->AddNewNewsgroup(line, "false", "0");
rv = m_nntpServer->AddNewNewsgroup(line);
}
else {
rv = NS_ERROR_FAILURE;

View File

@ -56,9 +56,10 @@ static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID);
NS_IMPL_ISUPPORTS_INHERITED(nsNntpIncomingServer,
NS_IMPL_ISUPPORTS_INHERITED2(nsNntpIncomingServer,
nsMsgIncomingServer,
nsINntpIncomingServer);
nsINntpIncomingServer,
nsIUrlListener);
nsNntpIncomingServer::nsNntpIncomingServer()
{
@ -492,7 +493,7 @@ nsNntpIncomingServer::AddSubscribedNewsgroups()
rv = currFolder->GetName(getter_Copies(name));
if (NS_SUCCEEDED(rv) && name) {
nsCAutoString asciiName(name);
rv = AddNewNewsgroup((const char *)asciiName,"true","0");
rv = SetNewsgroupAsSubscribed((const char *)asciiName);
}
}
}
@ -502,8 +503,70 @@ nsNntpIncomingServer::AddSubscribedNewsgroups()
return NS_OK;
}
nsresult
nsNntpIncomingServer::SetNewsgroupAsSubscribed(const char *aName)
{
nsresult rv;
NS_ASSERTION(aName,"newsgroup with no name");
if (!aName) return NS_ERROR_FAILURE;
#ifdef DEBUG_NEWS
printf("SetNewsgroupAsSubscribed(%s)\n",aName);
#endif
nsXPIDLCString serverUri;
rv = GetServerURI(getter_Copies(serverUri));
if (NS_FAILED(rv)) return rv;
nsCAutoString groupUri;
groupUri = (const char *)serverUri;
groupUri += "/";
groupUri += aName;
nsCOMPtr <nsIRDFService> rdfService = do_GetService(kRDFServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (!rdfService) return NS_ERROR_FAILURE;
nsCOMPtr<nsIRDFResource> newsgroupResource;
rv = rdfService->GetResource((const char *) groupUri, getter_AddRefs(newsgroupResource));
#if 0
nsCOMPtr<nsIRDFLiteral> totalMessagesLiteral;
nsAutoString totalMessagesString(aTotalMessages);
rv = rdfService->GetLiteral(totalMessagesString.GetUnicode(), getter_AddRefs(totalMessagesLiteral));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_TotalMessages;
rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#TotalMessages", getter_AddRefs(kNC_TotalMessages));
if(NS_FAILED(rv)) return rv;
#endif
nsCOMPtr<nsIRDFLiteral> subscribedLiteral;
nsAutoString subscribedString("true");
rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_Subscribed;
rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Subscribed", getter_AddRefs(kNC_Subscribed));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFDataSource> ds;
rv = rdfService->GetDataSource("rdf:subscribe",getter_AddRefs(ds));
if(NS_FAILED(rv)) return rv;
if (!ds) return NS_ERROR_FAILURE;
#if 0
rv = ds->Assert(newsgroupResource, kNC_TotalMessages, totalMessagesLiteral, PR_TRUE);
if(NS_FAILED(rv)) return rv;
#endif
rv = ds->Assert(newsgroupResource, kNC_Subscribed, subscribedLiteral, PR_TRUE);
if(NS_FAILED(rv)) return rv;
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, const char *aCount)
nsNntpIncomingServer::AddNewNewsgroup(const char *aName)
{
nsresult rv;
@ -538,22 +601,6 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, con
rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Name", getter_AddRefs(kNC_Name));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFLiteral> subscribedLiteral;
nsAutoString subscribedString(aState);
rv = rdfService->GetLiteral(subscribedString.GetUnicode(), getter_AddRefs(subscribedLiteral));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_Subscribed;
rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Subscribed", getter_AddRefs(kNC_Subscribed));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFLiteral> countLiteral;
nsAutoString countString(aCount);
rv = rdfService->GetLiteral(countString.GetUnicode(), getter_AddRefs(countLiteral));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_Count;
rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#Count", getter_AddRefs(kNC_Count));
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFDataSource> ds;
rv = rdfService->GetDataSource("rdf:subscribe",getter_AddRefs(ds));
if(NS_FAILED(rv)) return rv;
@ -561,10 +608,6 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, con
rv = ds->Assert(newsgroupResource, kNC_Name, nameLiteral, PR_TRUE);
if(NS_FAILED(rv)) return rv;
rv = ds->Assert(newsgroupResource, kNC_Subscribed, subscribedLiteral, PR_TRUE);
if(NS_FAILED(rv)) return rv;
rv = ds->Assert(newsgroupResource, kNC_Count, countLiteral, PR_TRUE);
if(NS_FAILED(rv)) return rv;
nsCOMPtr<nsIRDFResource> kNC_Child;
rv = rdfService->GetResource("http://home.netscape.com/NC-rdf#child", getter_AddRefs(kNC_Child));
@ -585,7 +628,6 @@ nsNntpIncomingServer::AddNewNewsgroup(const char *aName, const char *aState, con
if(NS_FAILED(rv)) return rv;
}
// if HasAssertion
rv = ds->Assert(parent, kNC_Child, newsgroupResource, PR_TRUE);
if(NS_FAILED(rv)) return rv;
@ -706,3 +748,17 @@ nsNntpIncomingServer::GetServerRequiresPasswordForBiff(PRBool *_retval)
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::OnStartRunningUrl(nsIURI *url)
{
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::OnStopRunningUrl(nsIURI *url, nsresult exitCode)
{
nsresult rv;
rv = AddSubscribedNewsgroups();
return rv;
}

View File

@ -24,6 +24,7 @@
#define __nsNntpIncomingServer_h
#include "nsINntpIncomingServer.h"
#include "nsIUrlListener.h"
#include "nscore.h"
#include "nsMsgIncomingServer.h"
@ -41,12 +42,14 @@ class nsIMsgMailNewsUrl;
/* get some implementation from nsMsgIncomingServer */
class nsNntpIncomingServer : public nsMsgIncomingServer,
public nsINntpIncomingServer
public nsINntpIncomingServer,
public nsIUrlListener
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSINNTPINCOMINGSERVER
NS_DECL_NSIURLLISTENER
nsNntpIncomingServer();
virtual ~nsNntpIncomingServer();
@ -63,6 +66,7 @@ protected:
NS_IMETHOD GetServerRequiresPasswordForBiff(PRBool *_retval);
private:
nsresult SetNewsgroupAsSubscribed(const char *aName);
PRBool mNewsrcHasChanged;
nsAdapterEnumerator *mGroupsEnumerator;
};

View File

@ -1247,17 +1247,15 @@ nsNntpService::BuildSubscribeDatasource(nsINntpIncomingServer *aNntpServer)
uriStr += (const char *)serverUri;
uriStr += "/*";
rv = ConstructNntpUrl((const char *)uriStr, "", nsMsgKey_None, nsnull, getter_AddRefs(uri));
nsCOMPtr <nsIUrlListener> listener = do_QueryInterface(aNntpServer, &rv);
if (NS_FAILED(rv)) return rv;
#if 0
// first add the newsgroups we are subscribed to.
rv = aNntpServer->AddSubscribedNewsgroups();
if (!listener) return NS_ERROR_FAILURE;
rv = ConstructNntpUrl((const char *)uriStr, "", nsMsgKey_None, listener, getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
#endif
// now run the url to add the rest of the groups
rv = RunNewsUrl(uri, nsnull, nsnull);
// TODO: pass in the nsIMsgWindow for progress.
rv = RunNewsUrl(uri, nsnull /* nsIMsgWindow */, nsnull);
if (NS_FAILED(rv)) return rv;
return NS_OK;