HandleLine() should be defined as virtual, as we are overriding it.

some more stuff for real subscribe, only for windows right now.
general clean up.
This commit is contained in:
sspitzer%netscape.com 2000-03-28 07:44:24 +00:00
Родитель 70be3f48e8
Коммит d6f856b55b
6 изменённых файлов: 97 добавлений и 25 удалений

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

@ -168,6 +168,8 @@ public:
virtual void DoneParsingFolder(nsresult status);
virtual void AbortNewHeader();
// for nsMsgLineBuffer
virtual PRInt32 HandleLine(char *line, PRUint32 line_length);
void UpdateDBFolderInfo();

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

@ -260,6 +260,9 @@ public:
NS_IMETHOD OnStopRequest(nsIChannel * aChannel, nsISupports * aContext, nsresult aStatus, const PRUnichar* aMsg);
NS_IMETHOD Cancel(); // handle stop button
// for nsMsgLineBuffer
virtual PRInt32 HandleLine(char *line, PRUint32 line_length);
private:
nsCOMPtr<nsIMsgStringService> mStringService;
@ -328,7 +331,6 @@ private:
PRInt32 SendXsender();
PRInt32 XsenderResponse();
PRInt32 SendRetr();
PRInt32 HandleLine(char *line, PRUint32 line_length);
PRInt32 RetrResponse(nsIInputStream* inputStream, PRUint32 length);
PRInt32 TopResponse(nsIInputStream* inputStream, PRUint32 length);

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

@ -65,6 +65,7 @@
#include "nsIWalletService.h"
#include "nsIURL.h"
#include "nsINntpUrl.h"
#include "nsNewsSummarySpec.h"
// we need this because of an egcs 1.0 (and possibly gcc) compiler bug
// that doesn't allow you to call ::nsISupports::GetIID() inside of a class
@ -78,8 +79,11 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID);
static NS_DEFINE_CID(kStandardUrlCID, NS_STANDARDURL_CID);
#define PREF_NEWS_MAX_HEADERS_TO_SHOW "news.max_headers_to_show"
#define PREF_NEWS_ABBREVIATE_PRETTY_NAMES "news.abbreviate_pretty_name"
// ###tw This really ought to be the most
// efficient file reading size for the current
// operating system.
#define NEWSRC_FILE_BUFFER_SIZE 1024
#define NEWS_SCHEME "news:"
@ -161,6 +165,7 @@ nsMsgNewsFolder::CreateSubFolders(nsFileSpec &path)
if (NS_FAILED(rv)) return rv;
rv = LoadNewsrcFileAndCreateNewsgroups();
if (NS_FAILED(rv)) return rv;
}
else {
#ifdef DEBUG_NEWS
@ -550,8 +555,26 @@ NS_IMETHODIMP nsMsgNewsFolder::CreateSubfolder(const PRUnichar *uninewsgroupname
NS_IMETHODIMP nsMsgNewsFolder::Delete()
{
NS_ASSERTION(0,"Delete not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
nsresult rv = GetDatabase(nsnull);
if(NS_SUCCEEDED(rv)) {
mDatabase->ForceClosed();
mDatabase = null_nsCOMPtr();
}
nsCOMPtr<nsIFileSpec> pathSpec;
rv = GetPath(getter_AddRefs(pathSpec));
if (NS_FAILED(rv)) return rv;
nsFileSpec path;
rv = pathSpec->GetFileSpec(&path);
if (NS_FAILED(rv)) return rv;
// Remove summary file.
nsNewsSummarySpec summarySpec(path);
summarySpec.Delete(PR_FALSE);
return NS_OK;
}
NS_IMETHODIMP nsMsgNewsFolder::Rename(const PRUnichar *newName)
@ -910,34 +933,29 @@ nsMsgNewsFolder::LoadNewsrcFileAndCreateNewsgroups()
rv = mNewsrcFilePath->Exists(&exists);
if (NS_FAILED(rv)) return rv;
// it is ok for the newsrc file to not exist yet
if (!exists) return NS_OK;
if (!exists) {
#ifdef DEBUG_NEWS
printf("it is ok for the newsrc file to not exist yet\n");
#endif
return NS_OK;
}
nsInputFileStream newsrcStream(mNewsrcFilePath);
PRInt32 numread = 0;
if (NS_FAILED(m_inputStream.GrowBuffer(NEWSRC_FILE_BUFFER_SIZE))) {
#ifdef DEBUG_NEWS
printf("GrowBuffer failed\n");
#endif
if (NS_FAILED(m_newsrcInputStream.GrowBuffer(NEWSRC_FILE_BUFFER_SIZE))) {
return NS_ERROR_FAILURE;
}
while (1) {
numread = newsrcStream.read(m_inputStream.GetBuffer(), NEWSRC_FILE_BUFFER_SIZE);
#ifdef DEBUG_NEWS
printf("numread == %d\n", numread);
#endif
numread = newsrcStream.read(m_newsrcInputStream.GetBuffer(), NEWSRC_FILE_BUFFER_SIZE);
if (numread == 0) {
break;
}
else {
rv = BufferInput(m_inputStream.GetBuffer(), numread);
rv = BufferInput(m_newsrcInputStream.GetBuffer(), numread);
if (NS_FAILED(rv)) {
#ifdef DEBUG_NEWS
printf("bufferInput did not return NS_OK\n");
#endif
break;
}
}
@ -951,16 +969,24 @@ nsMsgNewsFolder::LoadNewsrcFileAndCreateNewsgroups()
PRInt32
nsMsgNewsFolder::HandleLine(char* line, PRUint32 line_size)
{
return HandleNewsrcLine(line, line_size);
}
PRInt32
nsMsgNewsFolder::HandleNewsrcLine(char* line, PRUint32 line_size)
{
nsresult rv;
#ifdef DEBUG_NEWS
printf("nsMsgNewsFolder::HandleLine(%s,%d)\n",line,line_size);
#endif
/* guard against blank line lossage */
if (line[0] == '#' || line[0] == CR || line[0] == LF) return 0;
line[line_size] = 0;
#ifdef DEBUG_NEWS_
printf("nsMsgNewsFolder::HandleNewsrcLine(%s,%d)\n",line,line_size);
#endif
if ((line[0] == 'o' || line[0] == 'O') &&
!PL_strncasecmp (line, "options", 7)) {
return RememberLine(line);
@ -1057,7 +1083,7 @@ nsMsgNewsFolder::HandleLine(char* line, PRUint32 line_size)
if (!info) { // autosubscribe, if we haven't seen this one.
char* groupLine = PR_smprintf("%s:", fullname);
if (groupLine) {
HandleLine(groupLine, PL_strlen(groupLine));
HandleNewsrcLine(groupLine, PL_strlen(groupLine));
PR_FREEIF(groupLine);
groupLine = nsnull;
}

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

@ -94,6 +94,9 @@ public:
NS_IMETHOD GetCanRename(PRBool *aResult);
NS_IMETHOD OnReadChanged(nsIDBChangeListener * aInstigator);
// for nsMsgLineBuffer
virtual PRInt32 HandleLine(char *line, PRUint32 line_size);
protected:
nsresult AbbreviatePrettyName(PRUnichar ** prettyName, PRInt32 fullwords);
nsresult ParseFolder(nsFileSpec& path);
@ -106,11 +109,11 @@ protected:
nsresult RememberUnsubscribedGroup(const char *newsgroup, const char *setStr);
nsresult ForgetLine(void);
PRInt32 HandleLine(char *line, PRUint32 line_size);
PRInt32 HandleNewsrcLine(char *line, PRUint32 line_size);
virtual const char *GetIncomingServerType() {return "nntp";}
virtual nsresult CreateBaseMessageURI(const char *aURI);
nsByteArray m_inputStream;
nsByteArray m_newsrcInputStream;
protected:
PRUint32 mExpungedBytes;

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

@ -31,6 +31,14 @@
#include "nsIFileSpec.h"
#include "nsFileStream.h"
// sorry, unix & mac will have to wait for tomorrow. camelot is down.
#if defined(XP_WIN)
#define HAVE_REAL_SUBSCRIBE 1
#endif
#ifdef HAVE_REAL_SUBSCRIBE
#include "nsISubscribeDialogListener.h"
#endif
#ifdef DEBUG_seth
#define DO_HASHING_OF_HOSTNAME 1
#endif /* DEBUG_seth */
@ -52,9 +60,16 @@ static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_IID(kIFileLocatorIID, NS_IFILELOCATOR_IID);
static NS_DEFINE_CID(kFileLocatorCID, NS_FILELOCATOR_CID);
#ifdef HAVE_REAL_SUBSCRIBE
NS_IMPL_ISUPPORTS_INHERITED2(nsNntpIncomingServer,
nsMsgIncomingServer,
nsINntpIncomingServer,
nsISubscribeDialogMaster);
#else
NS_IMPL_ISUPPORTS_INHERITED(nsNntpIncomingServer,
nsMsgIncomingServer,
nsINntpIncomingServer);
#endif
nsNntpIncomingServer::nsNntpIncomingServer()
@ -295,3 +310,24 @@ nsNntpIncomingServer::CloseCachedConnections()
{
return WriteNewsrcFile();
}
#ifdef HAVE_REAL_SUBSCRIBE
NS_IMETHODIMP
nsNntpIncomingServer::PopulateSubscribeDialog(nsISubscribeDialogListener *listener)
{
nsresult rv;
PRInt32 i;
if (!listener) return NS_ERROR_FAILURE;
nsAutoString name;
// simple test code for now.
for (i=0;i<1000;i++) {
name = "";
name.Append(i);
rv = listener->AddItem(name.GetUnicode(),PR_FALSE,i+2);
if (NS_FAILED(rv)) return rv;
}
return NS_OK;
}
#endif

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

@ -27,6 +27,7 @@
#include "nscore.h"
#include "nsMsgIncomingServer.h"
#include "nsISubscribeDialogMaster.h"
#include "nsIPref.h"
@ -36,12 +37,14 @@
/* get some implementation from nsMsgIncomingServer */
class nsNntpIncomingServer : public nsMsgIncomingServer,
public nsINntpIncomingServer
public nsINntpIncomingServer,
public nsISubscribeDialogMaster
{
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSINNTPINCOMINGSERVER
NS_DECL_NSISUBSCRIBEDIALOGMASTER
nsNntpIncomingServer();
virtual ~nsNntpIncomingServer();