get copy of news message to work. take off my belt and give the news code the beating it deserves.

remove some of the 4.x bloat.


git-svn-id: svn://10.0.0.236/branches/MailNews_Performance_20010208_BRANCH@89189 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sspitzer%netscape.com
2001-03-10 01:49:01 +00:00
parent 6ba8571302
commit 3e9a5b629d
42 changed files with 812 additions and 5055 deletions

View File

@@ -63,7 +63,6 @@ CPP_OBJS= .\$(OBJDIR)\nsMsgCompFields.obj \
.\$(OBJDIR)\nsSmtpService.obj \
.\$(OBJDIR)\nsMsgComposeService.obj \
.\$(OBJDIR)\nsMsgComposeParams.obj \
.\$(OBJDIR)\nsMsgComposeService.obj \
.\$(OBJDIR)\nsMsgComposeContentHandler.obj \
.\$(OBJDIR)\nsMsgCompose.obj \
.\$(OBJDIR)\nsMsgCreate.obj \

View File

@@ -133,7 +133,8 @@ static nsresult openWindow( const char *chrome, nsIMsgComposeParams *params )
return rv;
}
nsresult nsMsgComposeService::OpenComposeWindow(const char *msgComposeWindowURL, const char *originalMsgURI,
NS_IMETHODIMP
nsMsgComposeService::OpenComposeWindow(const char *msgComposeWindowURL, const char *originalMsgURI,
MSG_ComposeType type, MSG_ComposeFormat format, nsIMsgIdentity * identity)
{
nsresult rv;
@@ -201,9 +202,12 @@ nsresult nsMsgComposeService::OpenComposeWindow(const char *msgComposeWindowURL,
pMsgComposeParams->SetComposeFields(pMsgCompFields);
#ifdef MSGCOMP_TRACE_PERFORMANCE
char buff[256];
sprintf(buff, "Start opening the window, message size = %d", GetMessageSizeFromURI(originalMsgURI));
TimeStamp(buff, PR_TRUE);
// ducarroz, properly fix this in the case of new message (not a reply)
if (type != nsIMsgCompType::NewsPost) {
char buff[256];
sprintf(buff, "Start opening the window, message size = %d", GetMessageSizeFromURI(originalMsgURI));
TimeStamp(buff, PR_TRUE);
}
#endif
rv = openWindow(msgComposeWindowURL, pMsgComposeParams);
}

View File

@@ -53,12 +53,17 @@
//
// nsNntpService
//
// not needed? who does nntp:/ ?
#define NS_NNTPPROTOCOLINFO_CONTRACTID \
NS_MSGPROTOCOLINFO_CONTRACTID_PREFIX "nntp"
#define NS_NEWSPROTOCOLHANDLER_CONTRACTID \
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "news"
#define NS_SNEWSPROTOCOLHANDLER_CONTRACTID \
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "snews"
#define NS_NEWSMESSAGEPROTOCOLHANDLER_CONTRACTID \
NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX "news_message"
#define NS_NEWSMESSAGESERVICE_CONTRACTID \
"@mozilla.org/messenger/messageservice;1?type=news_message"
#define NS_NNTPMESSAGESERVICE_CONTRACTID \
@@ -74,17 +79,6 @@
{0x80, 0x6e, 0x0, 0x60, 0x8, 0x12, 0x8c, 0x4e} \
}
//
// nsNNTPNewsgroup
//
#define NS_NNTPNEWSGROUP_CONTRACTID \
"@mozilla.org/messenger/nntpnewsgroup;1"
#define NS_NNTPNEWSGROUP_CID \
{ /* 2c070e8a-187e-11d3-8e02-004005263078 */ \
0x2c070e8a, 0x187e, 0x11d3, \
{0x8e, 0x02, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78} \
}
//
// nsNNTPNewsgroupPost
//
@@ -118,17 +112,6 @@
{0x97, 0x3e, 0x00, 0x80, 0x5f, 0x91, 0x6f, 0xd3} \
}
//
// nsNNTPHost
//
#define NS_NNTPHOST_CONTRACTID \
"@mozilla.org/messenger/nntphost;1"
#define NS_NNTPHOST_CID \
{ /* 339e5576-196a-11d3-929a-004005263078 */ \
0x339e5576, 0x196a, 0x11d3, \
{0x92, 0x9a, 0x00, 0x40, 0x05, 0x26, 0x30, 0x78} \
}
//
// nsNntpUrl
//

View File

@@ -39,11 +39,9 @@
#include "nsNntpUrl.h"
#include "nsNntpService.h"
#include "nsNntpIncomingServer.h"
#include "nsNNTPNewsgroup.h"
#include "nsNNTPNewsgroupPost.h"
#include "nsNNTPNewsgroupList.h"
#include "nsNNTPArticleList.h"
#include "nsNNTPHost.h"
#include "nsNewsDownloadDialogArgs.h"
#include "nsIContentHandler.h"
#include "nsCURILoader.h"
@@ -52,8 +50,6 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsNntpUrl)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNntpService)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNntpIncomingServer)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPArticleList)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPHost)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPNewsgroup)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPNewsgroupPost)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsNNTPNewsgroupList)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMsgNewsFolder)
@@ -91,6 +87,10 @@ static nsModuleComponentInfo components[] =
NS_NNTPSERVICE_CID,
NS_NEWSPROTOCOLHANDLER_CONTRACTID,
nsNntpServiceConstructor },
{ "News Message Protocol Handler",
NS_NNTPSERVICE_CID,
NS_NEWSMESSAGEPROTOCOLHANDLER_CONTRACTID,
nsNntpServiceConstructor },
{ "Secure News Protocol Handler",
NS_NNTPSERVICE_CID,
NS_SNEWSPROTOCOLHANDLER_CONTRACTID,
@@ -107,13 +107,9 @@ static nsModuleComponentInfo components[] =
NS_NNTPINCOMINGSERVER_CID,
NS_NNTPINCOMINGSERVER_CONTRACTID,
nsNntpIncomingServerConstructor },
{ "NNTP Newsgroup",
NS_NNTPNEWSGROUP_CID,
NS_NNTPNEWSGROUP_CONTRACTID,
nsNNTPNewsgroupConstructor },
{ "NNTP Newsgroup Post",
NS_NNTPNEWSGROUPPOST_CID,
NS_NNTPNEWSGROUP_CONTRACTID,
NS_NNTPNEWSGROUPPOST_CONTRACTID,
nsNNTPNewsgroupPostConstructor },
{ "NNTP Newsgroup List",
NS_NNTPNEWSGROUPLIST_CID,
@@ -123,10 +119,6 @@ static nsModuleComponentInfo components[] =
NS_NNTPARTICLELIST_CID,
NS_NNTPARTICLELIST_CONTRACTID,
nsNNTPArticleListConstructor },
{ "NNTP Host",
NS_NNTPHOST_CID,
NS_NNTPHOST_CONTRACTID,
nsNNTPHostConstructor },
{ "News download dialog args",
NS_NEWSDOWNLOADDIALOGARGS_CID,
NS_NEWSDOWNLOADDIALOGARGS_CONTRACTID,

View File

@@ -31,10 +31,6 @@ MODULE = msgnews
XPIDLSRCS = \
nsIMsgOfflineNewsState.idl \
nsINNTPArticleList.idl \
nsINNTPCategory.idl \
nsINNTPCategoryContainer.idl \
nsINNTPHost.idl \
nsINNTPNewsgroup.idl \
nsINNTPNewsgroupList.idl \
nsINNTPProtocol.idl \
nsINntpIncomingServer.idl \

View File

@@ -25,10 +25,6 @@ MODULE=msgnews
XPIDLSRCS= \
.\nsIMsgOfflineNewsState.idl \
.\nsINNTPArticleList.idl \
.\nsINNTPCategory.idl \
.\nsINNTPCategoryContainer.idl \
.\nsINNTPHost.idl \
.\nsINNTPNewsgroup.idl \
.\nsINNTPNewsgroupList.idl \
.\nsINNTPNewsgroupPost.idl \
.\nsINNTPProtocol.idl \

View File

@@ -31,6 +31,11 @@ interface nsIMsgNewsFolder : nsISupports {
attribute string groupUsername;
attribute string groupPassword;
/** the ascii name for the newsgroup.
* newsgroup names are always ascii, and this can help simply
* the code, to prevent use from having to get the name (as a wstring)
* and then converting it back to ascii.
*/
readonly attribute string asciiName;
readonly attribute nsINntpIncomingServer nntpServer;
attribute boolean saveArticleOffline;

View File

@@ -25,18 +25,15 @@
*/
#include "nsISupports.idl"
#include "nsINNTPNewsgroup.idl"
[scriptable, uuid(921AC210-96B5-11d2-B7EB-00805F05FFA5)]
interface nsIMsgOfflineNewsState : nsISupports {
attribute nsINNTPNewsgroup newsgroup;
/* outputBuffer is actually
* a buffer to dump data into, but we normally pass it NET_Socket_Buffer,
* which is constant. The implementation should only allocate a new
* buffer if *outputBuffer is NULL.
*/
long Process(out string outputBuffer, in long bufferSize);
long Interrupt();
};

View File

@@ -21,15 +21,13 @@
*/
#include "nsISupports.idl"
#include "nsINNTPNewsgroup.idl"
#include "nsINNTPHost.idl"
interface nsIMsgNewsFolder;
[scriptable, uuid(921AC214-96B5-11d2-B7EB-00805F05FFA5)]
interface nsINNTPArticleList : nsISupports {
void Initialize(in nsINNTPHost newsHost, in nsINNTPNewsgroup newsgroup);
void AddArticleKey(in long key);
void FinishAddingArticleKeys();
void initialize(in nsIMsgNewsFolder newsFolder);
void addArticleKey(in long key);
void finishAddingArticleKeys();
};

View File

@@ -1,41 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsIMsgGroupRecord.idl"
#include "nsINNTPNewsgroup.idl"
[scriptable, uuid(203b2120-b256-11d2-b7f0-00805f05ffa5)]
interface nsINNTPCategory : nsISupports {
nsINNTPNewsgroup BuildCategoryTree(in nsINNTPNewsgroup parent,
in string catName,
in nsIMsgGroupRecord group,
in short depth);
nsINNTPNewsgroup AddToCategoryTree(in nsINNTPNewsgroup parent,
in string groupName,
in nsIMsgGroupRecord group);
nsINNTPNewsgroup CloneIntoNewsFolder();
nsINNTPNewsgroup GetRootCategory();
};

View File

@@ -1,34 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
#include "nsINNTPNewsgroup.idl"
interface nsINNTPNewsgroup;
[scriptable, uuid(cb36d510-b249-11d2-b7ef-00805f05ffa5)]
interface nsINNTPCategoryContainer : nsISupports {
attribute nsINNTPNewsgroup rootCategory;
void Initialize(in nsINNTPNewsgroup rootCategory);
};

View File

@@ -1,153 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#include "nsISupports.idl"
interface nsINNTPNewsgroup;
interface nsINNTPNewsgroupList;
interface nsINntpUrl;
[scriptable, uuid(6b128da0-d74f-11d2-b7f9-00805f05ffa5)]
interface nsINNTPHost : nsISupports {
void Initialize(in nsINntpUrl runningURL, in string username, in string hostname);
attribute boolean supportsExtensions;
void AddExtension(in string extension);
boolean QueryExtension(in string extension);
attribute boolean postingAllowed;
attribute boolean pushAuth;
attribute unsigned long lastUpdatedTime;
/* look up the newsgroup list for the given name */
nsINNTPNewsgroupList GetNewsgroupList(in string name);
/* given a newsgroup name, find or create the given name */
nsINNTPNewsgroup FindNewsgroup(in string name, in boolean create);
/* libnet callbacks for Dredd NNTP extensions
* please document if you know how these work
*/
void AddPropertyForGet(in string name, in string value);
string QueryPropertyForGet(in string name);
void AddSearchableGroup(in string name);
boolean QuerySearchableGroup(in string name);
void AddVirtualGroup(in string responseText);
void SetIsVirtualGroup(in string name, in boolean isVirtual);
boolean GetIsVirtualGroup(in string name
/*, nsIMsgGroupRecord inGroupRecord */);
void AddSearchableHeader(in string headerName);
boolean QuerySearchableHeader(in string headerName);
/* this used to just call pane->GetMaster()->AddNewsGroup(url) */
/* void AddSubscribedNewsgroup(in string url); */
/* In response to an NNTP GROUP command, the server said
* the group doesn't exist
*/
void GroupNotFound(in string group, in boolean opening);
/* Tell the subscribe pane about a new newsgroup we noticed. */
/* XXX should xactive flags be a long? */
void AddNewNewsgroup(in string name,
in long first, in long last,
in string flags, in boolean xactiveFlags);
/* formerly GetNewsRCCount() */
/* After displaying a list of newsgroups, we need the NNTP module to go and
run "GROUP" commands for the ones for which we don't know the unread
article count. This function returns a count of how many groups we think
we're going to need this for (so we can display progress in a reasonable
way).
*/
long GetNumGroupsNeedingCounts();
/* formerly GetNewsRCGroup() */
/* Gets the name of the next group that we want to get article counts for.
MSG_DisplaySubscribedGroup() should get called with this group before
this call happens again. */
string GetFirstGroupNeedingCounts();
/* In response to a "news://host/" URL; this is called once for each group
that was returned by MSG_GetNewsRCGroup(), after the NNTP GROUP
command has been run. It's also called whenever we actually visit the
group (the user clicks on the newsgroup line), in case the data has
changed since the initial passthrough. The "nowvisiting" parameter
is TRUE in the latter case, FALSE otherwise. */
void DisplaySubscribedGroup(in nsINNTPNewsgroup newsgroup,
in long first_message, in long last_message,
in long total_messages,
in boolean visit_now);
string GetFirstGroupNeedingExtraInfo();
void SetGroupNeedsExtraInfo(in string name, in boolean needsExtraInfo);
/* News servers work better if you ask for message numbers instead of IDs.
So, the NNTP module asks us what the group and number of an ID is with
this. If we don't know, we return 0 for both. If the pane is not a
thead or message pane, this routine will fail.
*/
void GetNewsgroupAndNumberOfID(in string message_id,
out nsINNTPNewsgroup group,
out unsigned long message_number);
void SetPrettyName(in string name, in string prettyName);
/* Write out the newsrc for this host right now. In general, either
MarkDirty() or WriteIfDirty() should be called instead. */
void WriteNewsrc();
/* Write out the newsrc for this host right now, if anything has changed
in it. */
void WriteIfDirty();
/* Note that something has changed, and we need to rewrite the newsrc file
for this host at some point. */
void MarkDirty();
attribute string newsRCFilename;
nsINNTPNewsgroup FindGroup(in string name);
nsINNTPNewsgroup AddGroup(in string name
/* , msg_GroupRecord *inGroupRecord */ );
void RemoveGroupByName(in string name);
void RemoveGroup(in nsINNTPNewsgroup group);
/* Name of directory to store newsgroup
databases in. This needs to have
"/name" appended to it, and the
whole thing can be passed to the XP_File
stuff with a type of xpXoverCache.
*/
readonly attribute string dbDirName;
/* this should actually return a list of strings..how to do in XPIDL? */
string GetGroupList();
};

View File

@@ -1,65 +0,0 @@
/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
/*
* network-oriented interface to newsgroups.
* This is similar to the old MSG_NewsFolderInfo but is an interface
* only NNTP uses for talking to the news server and maintaining state.
*
*/
#include "nsISupports.idl"
%{ C++
#include "nsMsgKeySet.h"
%}
interface nsMsgKeySet;
interface nsINNTPNewsgroupList;
[scriptable, uuid(1A39CD90-ACAF-11d2-B7EE-00805F05FFA5)]
interface nsINNTPNewsgroup : nsISupports {
attribute string name;
attribute string prettyName;
attribute boolean needsExtraInfo;
boolean IsOfflineArticle(in long num);
attribute boolean category;
attribute boolean subscribed;
attribute boolean wantNewTotals;
attribute nsINNTPNewsgroupList newsgroupList;
void UpdateSummaryFromNNTPInfo(in long oldest,
in long youngest,
in long total_messages);
void Initialize(in string name,
in nsMsgKeySet set,
in boolean subscribed);
};

View File

@@ -26,28 +26,23 @@
* to destroy the DBView)
*/
#include "nsISupports.idl"
#include "nsINNTPHost.idl"
#include "nsINNTPNewsgroup.idl"
interface nsINNTPHost;
interface nsINNTPNewsgroup;
interface nsIMsgNewsFolder;
interface nsINntpUrl;
interface nsIMsgWindow;
[scriptable, uuid(E628ED19-9452-11d2-B7EA-00805F05FFA5)]
interface nsINNTPNewsgroupList : nsISupports {
/* These calls are used by libnet to determine which articles it ought to
get in a big newsgroup. */
long GetRangeOfArtsToDownload(in nsIMsgWindow aMsgWindow, in long first_message,
void initialize(in nsINntpUrl runningURL, in nsIMsgNewsFolder newsFolder);
long getRangeOfArtsToDownload(in nsIMsgWindow aMsgWindow, in long first_message,
in long last_message,
in long maxextra,
out long real_first_message,
out long real_last_message);
void AddToKnownArticles(in long first_message, in long last_message);
void addToKnownArticles(in long first_message, in long last_message);
/* The NNTP module of netlib calls these to feed XOVER data to the message
@@ -61,15 +56,12 @@ interface nsINNTPNewsgroupList : nsISupports {
line to, followed by a "\n". This is used by the XOVER-caching code.
*/
/* the XOVER Sink should maintain the ListNewsGroupState */
void InitXOVER(in long first_message, in long last_message);
void ProcessXOVERLINE(in string line, out unsigned long status);
void ProcessNonXOVER(in string line);
void ResetXOVER();
void FinishXOVERLINE(in long status, out long newstatus);
void ClearXOVERState();
string GetGroupName();
void Initialize(in nsINNTPHost host, in nsINntpUrl runningURL, in nsINNTPNewsgroup newsgroup, in string username, in string hostname, in string groupname);
void initXOVER(in long first_message, in long last_message);
void processXOVERLINE(in string line, out unsigned long status);
void processNonXOVER(in string line);
void resetXOVER();
void finishXOVERLINE(in long status, out long newstatus);
void clearXOVERState();
attribute boolean getOldMessages;
};

View File

@@ -64,9 +64,9 @@ interface nsINntpIncomingServer : nsISupports {
void displaySubscribedGroup(in nsIMsgNewsFolder msgFolder, in long firstMessage, in long lastMessage, in long totalMessages);
void GetNntpConnection(in nsIURI url, in nsIMsgWindow window,
void getNntpConnection(in nsIURI url, in nsIMsgWindow window,
out nsINNTPProtocol aNntpConnection);
void RemoveConnection(in nsINNTPProtocol aNntpConnection);
void removeConnection(in nsINNTPProtocol aNntpConnection);
/* used for auto subscribing */
boolean containsNewsgroup(in string name);
@@ -75,4 +75,29 @@ interface nsINntpIncomingServer : nsISupports {
/* used for the subscribe dialog */
void addNewsgroupToList(in string name);
attribute boolean supportsExtensions;
void addExtension(in string extension);
boolean queryExtension(in string extension);
attribute boolean postingAllowed;
attribute boolean pushAuth;
attribute unsigned long lastUpdatedTime;
void addPropertyForGet(in string name, in string value);
string queryPropertyForGet(in string name);
void addSearchableGroup(in string name);
boolean querySearchableGroup(in string name);
void addSearchableHeader(in string headerName);
boolean querySearchableHeader(in string headerName);
nsIMsgNewsFolder findGroup(in string name);
readonly attribute string firstGroupNeedingExtraInfo;
void setGroupNeedsExtraInfo(in string name, in boolean needsExtraInfo);
void groupNotFound(in string group, in boolean opening);
void setPrettyName(in string name, in string prettyName);
};

View File

@@ -42,7 +42,7 @@ interface nsINntpService : nsISupports {
nsIURI getNewNews (in nsINntpIncomingServer nntpServer, in string uri, in boolean getOld, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
nsIURI cancelMessages (in string hostname, in string newsgroupname, in nsISupportsArray messages, in nsISupports aConsumer, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
nsIURI cancelMessage(in string uri, in nsISupports aConsumer, in nsIUrlListener aUrlListener, in nsIMsgWindow aMsgWindow);
void getListOfGroupsOnServer(in nsINntpIncomingServer nntpServer, in nsIMsgWindow aMsgWindow);
@@ -50,5 +50,10 @@ interface nsINntpService : nsISupports {
nsIURI fetchMessage(in nsIMsgFolder newsFolder, in nsMsgKey key, in nsIMsgWindow aMsgWindow, in nsISupports aConsumer, in nsIUrlListener aUrlListener);
/**
* can handle news_message:// and news://
*/
void decomposeNewsURI(in string uri, out nsIMsgFolder folder, out nsMsgKey key);
};

View File

@@ -24,11 +24,7 @@
#include "MailNewsTypes2.idl"
%{ C++
#include "nsINNTPHost.h"
#include "nsINNTPArticleList.h"
#include "nsINNTPNewsgroup.h"
#include "nsIMsgOfflineNewsState.h"
#include "nsINNTPNewsgroupList.h"
#include "nsINNTPNewsgroupPost.h"
#include "nsIMsgMailNewsUrl.h"
@@ -37,26 +33,16 @@
%}
interface nsIMsgDBHdr;
interface nsINNTPHost;
interface nsINNTPArticleList;
interface nsINNTPNewsgroup;
interface nsIMsgOfflineNewsState;
interface nsINNTPNewsgroupList;
interface nsINNTPNewsgroupPost;
typedef long nsNewsAction;
[scriptable, uuid(BDD12930-A682-11d2-804C-006008128C4E)]
interface nsINntpUrl : nsISupports {
attribute nsINNTPHost nntpHost;
attribute nsINNTPArticleList nntpArticleList;
attribute nsINNTPNewsgroup newsgroup;
attribute nsIMsgOfflineNewsState offlineNewsState;
attribute nsINNTPNewsgroupList newsgroupList;
attribute nsINNTPNewsgroupPost messageToPost;
readonly attribute nsIMsgDBHdr messageHeader;
attribute nsMsgKey messageKey;
attribute string newsgroupName;
attribute nsNewsAction newsAction;
attribute boolean getOldMessages;

View File

@@ -46,6 +46,8 @@ bytesReceived=Downloading newsgroups: %S received (%SK read at %SK/sec)
checkingForNewNews=Checking newsgroup %S of %S for new messages
downloadingArticlesForOffline=%Downloading articles %S-%S in %S
onlyCancelOneMessage=You can only cancel one article at a time.
# LOCALIZATION NOTE (Error -304): In the following item, don't translate "NNTP"
# Error - server error
## @name NNTP_ERROR_MESSAGE

View File

@@ -23,12 +23,9 @@
nsNNTPProtocol.h
nsNntpUrl.h
nsNNTPNewsgroupList.h
nsNNTPNewsgroup.h
nntpCore.h
nsNNTPNewsgroupPost.h
nsNewsFolder.h
nsNntpIncomingServer.h
nsNewsUtils.h
nsNNTPArticleList.h
nsNNTPHost.h
nsNNTPCategoryContainer.h

View File

@@ -32,12 +32,10 @@ REQUIRES = xpcom mailnews msgbase msgbaseutil necko msgdb locale mork dom js rdf
CPPSRCS = \
nsNNTPArticleList.cpp \
nsNNTPNewsgroup.cpp \
nsNNTPNewsgroupList.cpp \
nsNNTPNewsgroupPost.cpp \
nsNNTPProtocol.cpp \
nsNntpUrl.cpp \
nsNNTPHost.cpp \
nsNntpService.cpp \
nsNewsFolder.cpp \
nsNntpIncomingServer.cpp \
@@ -51,15 +49,12 @@ EXPORTS = \
nsNntpUrl.h \
nsNNTPArticleList.h \
nsNNTPNewsgroupList.h \
nsNNTPNewsgroup.h \
nsNNTPNewsgroupPost.h \
nntpCore.h \
nsNntpService.h \
nsNewsFolder.h \
nsNntpIncomingServer.h \
nsNewsUtils.h \
nsNNTPHost.h \
nsNNTPCategoryContainer.h \
nsNewsDownloadDialogArgs.h \
$(NULL)

View File

@@ -31,15 +31,12 @@ EXPORTS= nsNNTPProtocol.h \
nsNntpUrl.h \
nsNNTPNewsgroupList.h \
nsNNTPArticleList.h \
nsNNTPNewsgroup.h \
nntpCore.h \
nsNNTPNewsgroupPost.h \
nsNntpService.h \
nsNewsFolder.h \
nsNntpIncomingServer.h \
nsNewsUtils.h \
nsNNTPHost.h \
nsNNTPCategoryContainer.h \
nsNewsDownloadDialogArgs.h \
$(NULL)
@@ -53,9 +50,6 @@ CPP_OBJS= .\$(OBJDIR)\nsNNTPProtocol.obj \
.\$(OBJDIR)\nsNNTPArticleList.obj \
.\$(OBJDIR)\nsNNTPNewsgroupList.obj \
.\$(OBJDIR)\nsNNTPNewsgroupPost.obj \
.\$(OBJDIR)\nsNNTPHost.obj \
.\$(OBJDIR)\nsNNTPNewsgroup.obj \
.\$(OBJDIR)\nsNNTPCategoryContainer.obj \
.\$(OBJDIR)\nsNntpService.obj \
.\$(OBJDIR)\nsNewsFolder.obj \
.\$(OBJDIR)\nsNntpIncomingServer.obj \

View File

@@ -22,11 +22,12 @@
#include "msgCore.h" // precompiled header...
#include "nsCOMPtr.h"
#include "nsNNTPNewsgroupList.h"
#include "nsINNTPHost.h"
#include "nsINNTPArticleList.h"
#include "nsMsgKeySet.h"
#include "nsNNTPArticleList.h"
#include "nsIMsgFolder.h"
NS_IMPL_ISUPPORTS1(nsNNTPArticleList, nsINNTPArticleList)
@@ -36,53 +37,37 @@ nsNNTPArticleList::nsNNTPArticleList()
}
nsresult
nsNNTPArticleList::Initialize(nsINNTPHost * newsHost,
nsINNTPNewsgroup* newsgroup)
nsNNTPArticleList::Initialize(nsIMsgNewsFolder *newsFolder)
{
m_host = newsHost;
m_newsgroup = newsgroup;
#ifdef HAVE_PANES
m_pane = pane;
#endif
#ifdef HAVE_NEWSDB
m_newsDB = NULL;
#endif
m_idsOnServer.set = nsMsgKeySet::Create();
#ifdef HAVE_PANES
nsINNTPNewsgroup *newsFolder = m_pane->GetMaster()->FindNewsFolder(host, groupName, PR_FALSE);
if (newsFolder)
{
char *url = newsFolder->BuildUrl(NULL, nsMsgKey_None);
#ifdef HAVE_NEWSDB
if (url)
NewsGroupDB::Open(url, m_pane->GetMaster(), &m_newsDB);
if (m_newsDB)
m_newsDB->ListAllIds(m_idsInDB);
#endif
m_dbIndex = 0;
nsresult rv;
m_newsFolder = newsFolder;
PR_FREEIF(url);
}
#endif
return NS_MSG_SUCCESS;
nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = folder->GetMsgDatabase(nsnull /* msgWindow */, getter_AddRefs(m_newsDB));
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
}
nsNNTPArticleList::~nsNNTPArticleList()
{
#ifdef HAVE_NEWSDB
if (m_newsDB)
m_newsDB->Close();
#endif
if (m_newsDB) {
m_newsDB->Commit(nsMsgDBCommitType::kSessionCommit);
m_newsDB->Close(PR_TRUE);
m_newsDB = nsnull;
}
}
nsresult
nsNNTPArticleList::AddArticleKey(PRInt32 key)
{
#ifdef DEBUG_NEWS
char * groupname = nsnull;
if (m_newsgroup)
m_newsgroup->GetName(&groupname);
printf("Adding article key %d for group %s.\n", key, groupname ? groupname : "unspecified");
nsXPIDLCString groupname
if (m_newsFolder)
m_newsFolder->GetAsciiName(getter_Copies(groupname));
printf("Adding article key %d for group %s.\n", key, (const char *)groupname);
PR_FREEIF(groupname);
#endif
m_idsOnServer.set->Add(key);

View File

@@ -23,10 +23,10 @@
#ifndef nsNNTPArticleList_h___
#define nsNNTPArticleList_h___
#include "nsCOMPtr.h"
#include "nsINNTPArticleList.h"
/* XXX - temporary hack so this will compile */
typedef PRUint32 nsMsgKey;
#include "nsIMsgNewsFolder.h"
#include "nsIMsgDatabase.h"
class nsNNTPArticleList : public nsINNTPArticleList
#ifdef HAVE_CHANGELISTENER
@@ -43,15 +43,11 @@ public:
// other stuff
protected:
struct MSG_NewsKnown m_idsOnServer;
#ifdef HAVE_PANES
MSG_Pane *m_pane;
#endif
/* formerly m_groupName */
nsINNTPNewsgroup *m_newsgroup;
const nsINNTPHost *m_host;
#ifdef HAVE_NEWSDB
NewsGroupDB *m_newsDB;
#endif
/* formerly m_groupName */
nsCOMPtr <nsIMsgNewsFolder> m_newsFolder;
nsCOMPtr <nsIMsgDatabase> m_newsDB;
#ifdef HAVE_IDARRAY
IDArray m_idsInDB;
#ifdef DEBUG_bienvenu

View File

@@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*/
/* This is a stub event sink for a NNTP Newsgroup introduced by mscott to test
the NNTP protocol */
#include "nsNNTPCategoryContainer.h"
NS_IMPL_ISUPPORTS1(nsNNTPCategoryContainer, nsINNTPCategoryContainer)
nsNNTPCategoryContainer::nsNNTPCategoryContainer()
{
NS_INIT_REFCNT();
m_newsgroup = nsnull;
}
nsNNTPCategoryContainer::~nsNNTPCategoryContainer()
{
printf("Destroying category container. \n");
NS_IF_RELEASE(m_newsgroup);
}
nsresult nsNNTPCategoryContainer::GetRootCategory(nsINNTPNewsgroup * *aRootCategory)
{
if (aRootCategory)
{
*aRootCategory = m_newsgroup;
NS_IF_ADDREF(m_newsgroup);
}
return NS_OK;
}
nsresult nsNNTPCategoryContainer::Initialize(nsINNTPNewsgroup * aRootCategory)
{
// for now, just set the root category.
return SetRootCategory(aRootCategory);
}
nsresult nsNNTPCategoryContainer::SetRootCategory(nsINNTPNewsgroup * aRootCategory)
{
if (aRootCategory)
{
char * name = nsnull;
aRootCategory->GetName(&name);
#ifdef DEBUG_NEWS
printf("Setting root category for container to %s", name ? name : "unspecified");
#endif
m_newsgroup = aRootCategory;
NS_IF_ADDREF(m_newsgroup);
}
return NS_OK;
}

View File

@@ -1,48 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __nsNNTPCategoryContainer_h
#define __nsNNTPCategoryContainer_h
#include "nsINNTPCategoryContainer.h"
#include "nsINNTPNewsgroup.h"
#include "nsISupports.h" /* interface nsISupports */
#include "nscore.h"
#include "plstr.h"
#include "prmem.h"
//#include <stdio.h>
class nsNNTPCategoryContainer : public nsINNTPCategoryContainer {
public:
nsNNTPCategoryContainer();
virtual ~nsNNTPCategoryContainer();
NS_DECL_ISUPPORTS
NS_DECL_NSINNTPCATEGORYCONTAINER
protected:
nsINNTPNewsgroup * m_newsgroup;
};
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,425 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __msg_NewsHost__
#define __msg_NewsHost__ 1
#include "nsINNTPHost.h"
#include "msgCore.h" // precompiled header...
#include "nsMsgFolderFlags.h"
#include "nntpCore.h"
#include "nsINNTPHost.h"
#include "nsINNTPCategory.h"
#include "nsINNTPCategoryContainer.h"
#include "nsNNTPCategoryContainer.h"
#include "nsNNTPHost.h"
#include "nsMsgKeySet.h"
#include "nsMsgGroupRecord.h"
#include "nsINNTPNewsgroup.h"
#include "nsNNTPNewsgroup.h"
#include "nsINNTPNewsgroupList.h"
#include "nsNNTPNewsgroupList.h"
#include "nsIMsgFolder.h"
#include "nsISupportsArray.h"
#include "nsIEnumerator.h"
#include "nsFileStream.h"
#include "nsNewsUtils.h"
#include "prprf.h"
#include "prmem.h"
#include "plstr.h"
#include "plhash.h"
#include "prio.h"
#include "nsCOMPtr.h"
#include "nsINntpUrl.h"
/* temporary hacks to test if this compiles */
typedef void MSG_GroupName;
class nsNNTPHost : public nsINNTPHost {
public:
nsNNTPHost();
virtual ~nsNNTPHost();
NS_DECL_ISUPPORTS
// nsINNTPHost
NS_IMETHOD Initialize(nsINntpUrl *runningURL, const char *username, const char *hostname);
NS_IMPL_CLASS_GETSET(SupportsExtensions, PRBool,
m_supportsExtensions);
NS_IMETHOD AddExtension (const char *ext);
NS_IMETHOD QueryExtension (const char *ext, PRBool *_retval);
NS_IMPL_CLASS_GETSET(PostingAllowed, PRBool, m_postingAllowed);
NS_IMPL_CLASS_GETTER(GetPushAuth, PRBool, m_pushAuth);
NS_IMETHOD SetPushAuth(PRBool value);
NS_IMPL_CLASS_GETSET(LastUpdatedTime, PRUint32, m_lastGroupUpdate);
NS_IMETHOD GetNewsgroupList(const char *name,nsINNTPNewsgroupList **_retval);
NS_IMETHOD GetNewsgroupAndNumberOfID(const char *message_id,
nsINNTPNewsgroup **group,
PRUint32 *messageNumber);
/* get this from MSG_Master::FindNewsFolder */
NS_IMETHOD FindNewsgroup(const char *name, PRBool create,
nsINNTPNewsgroup **_retval) { NS_ASSERTION(0, "unimplemented!"); return NS_OK;}
NS_IMETHOD AddPropertyForGet (const char *property, const char *value);
NS_IMETHOD QueryPropertyForGet (const char *property, char **_retval);
NS_IMETHOD AddSearchableGroup(const char *name);
// should these go into interfaces?
NS_IMETHOD QuerySearchableGroup (const char *group, PRBool *);
NS_IMETHOD QuerySearchableGroupCharsets(const char *group, char **);
// Virtual groups
NS_IMETHOD AddVirtualGroup(const char *responseText) { return NS_OK;}
NS_IMETHOD SetIsVirtualGroup(const char *name, PRBool isVirtual);
NS_IMETHOD SetIsVirtualGroup(const char *name, PRBool isVirtual,
nsMsgGroupRecord *inGroupRecord);
NS_IMETHOD GetIsVirtualGroup(const char *name, PRBool *_retval);
// custom/searchable headers
NS_IMETHOD AddSearchableHeader(const char *headerName);
NS_IMETHOD QuerySearchableHeader(const char *headerName, PRBool *_retval);
// Write out the newsrc for this host right now. In general, either
// MarkDirty() or WriteIfDirty() should be called instead.
NS_IMETHOD WriteNewsrc();
// Write out the newsrc for this host right now, if anything has changed
// in it.
NS_IMETHOD WriteIfDirty();
// Note that something has changed, and we need to rewrite the newsrc file
// for this host at some point.
NS_IMETHOD MarkDirty();
/* the Setter implementation is a little more complex */
NS_IMPL_CLASS_GETTER(GetNewsRCFilename, char *, m_filename);
NS_IMETHOD SetNewsRCFilename(const char *);
// helper for accessing the above accessors from within this class
// (this is what the pre-mozilla API looked like)
char *GetNewsrcFileName() { return m_filename; };
NS_IMETHOD FindGroup(const char* name, nsINNTPNewsgroup* *_retval);
NS_IMETHOD AddGroup(const char *name,
nsINNTPNewsgroup **_retval);
NS_IMETHOD AddGroup(const char *name,
nsMsgGroupRecord *groupRecord,
nsINNTPNewsgroup **_retval);
NS_IMETHOD RemoveGroupByName(const char *name);
NS_IMETHOD RemoveGroup(nsINNTPNewsgroup*);
NS_IMETHOD AddNewNewsgroup(const char *name,
PRInt32 first,
PRInt32 last,
const char *flags,
PRBool xactiveFlags);
/* Name of directory to store newsgroup
databases in. This needs to have
"/name" appended to it, and the
whole thing can be passed to the XP_File
stuff with a type of xpXoverCache. */
NS_IMETHOD GetDbDirName(char * *aDbDirName) {NS_ASSERTION(0, "unimplemented"); return NS_OK;};
/* helper for internal accesses - part of the Pre-Mozilla API) */
const char *GetDBDirName();
/* Returns a list of newsgroups. The result
must be free'd using PR_Free(); the
individual strings must not be free'd. */
NS_IMETHOD GetGroupList(char **_retval) { return NS_OK;}
NS_IMETHOD DisplaySubscribedGroup(nsINNTPNewsgroup *newsgroup,
PRInt32 first_message,
PRInt32 last_message,
PRInt32 total_messages,
PRBool visit_now);
// end of nsINNTPHost
private:
// simplify the QueryInterface calls
static nsIMsgFolder *getFolderFor(nsINNTPNewsgroup *group);
static nsIMsgFolder *getFolderFor(nsINNTPCategoryContainer *catContainer);
NS_METHOD CleanUp();
virtual PRBool IsNews () { return PR_TRUE; }
virtual nsINNTPHost *GetNewsHost() { return this; }
//
void addNew(MSG_GroupName* group);
void ClearNew();
// Get the nsIMsgFolder which represents this host; the children
// of this nsIMsgFolder are the groups in this host.
nsIMsgFolder* GetHostInfo() {return m_hostinfo;}
// GetNumGroupsNeedingCounts() returns how many newsgroups we have
// that we don't have an accurate count of unread/total articles.
NS_IMETHOD GetNumGroupsNeedingCounts(PRInt32 *);
// GetFirstGroupNeedingCounts() returns the name of the first newsgroup
// that does not have an accurate count of unread/total articles. The
// string must be free'd by the caller using PR_Free().
NS_IMETHOD GetFirstGroupNeedingCounts(char **);
// GetFirstGroupNeedingExtraInfo() returns the name of the first newsgroup
// that does not have extra info (xactive flags and prettyname). The
// string must be free'd by the caller using PR_Free().
NS_IMETHOD GetFirstGroupNeedingExtraInfo(char **);
void SetWantNewTotals(PRBool value); // Sets this bit on every newsgroup
// in this host.
PRBool NeedsExtension (const char *ext);
// Returns the base part of the URL for this newshost, in the
// form "news://hostname:port" or "snews://hostname:port".
// Note that no trailing slash is appended, and that the
// ":port" part will be omitted if this host uses the default
// port.
const char* GetURLBase();
PRBool GetEverExpanded() {return m_everexpanded;}
void SetEverExpanded(PRBool value) {m_everexpanded = value;}
PRBool GetCheckedForNew() {return m_checkedForNew;}
void SetCheckedForNew(PRBool value) {m_checkedForNew = value;}
void SetGroupSucceeded(PRBool value) {m_groupSucceeded = value;}
// Completely obliterate this news host. Remove all traces of it from
// disk and memory.
PRInt32 RemoveHost();
PRInt32 DeleteFiles();
// Returns the pretty name for the given group. The resulting string
// must be free'd using delete[].
char* GetPrettyName(char* name);
NS_IMETHOD SetPrettyName(const char* name, const char* prettyname);
PRTime GetAddTime(char* name);
// Returns a unique integer associated with this newsgroup. This is
// mostly used by Win16 to generate a 8.3 filename.
PRInt32 GetUniqueID(char* name);
PRBool IsCategory(char* name);
PRBool IsCategoryContainer(char* name);
PRInt32 SetIsCategoryContainer(const char* name, PRBool value, nsMsgGroupRecord *inGroupRecord = nsnull);
NS_IMETHOD SetGroupNeedsExtraInfo(const char *name, PRBool value);
// Finds the container newsgroup for this category (or nsnull if this isn't
// a category). The resulting string must be free'd using delete[].
char* GetCategoryContainer(const char* name, nsMsgGroupRecord *inGroupRecord = nsnull);
nsINNTPNewsgroup * GetCategoryContainerFolderInfo(const char *name);
// Get/Set whether this is a real group (as opposed to a container of
// other groups, like "mcom".)
PRBool IsGroup(char* name);
PRInt32 SetIsGroup(char* name, PRBool value);
// Returns PR_TRUE if it's OK to post HTML in this group (either because the
// bit is on for this group, or one of this group's ancestor's has marked
// all of its descendents as being OK for HTML.)
PRBool IsHTMLOk(char* name);
// Get/Set if it's OK to post HTML in just this group.
PRBool IsHTMLOKGroup(char* name);
PRInt32 SetIsHTMLOKGroup(char* name, PRBool value);
// Get/Set if it's OK to post HTML in this group and all of its subgroups.
PRBool IsHTMLOKTree(char* name);
PRInt32 SetIsHTMLOKTree(char* name, PRBool value);
// Create the given group (if not already present). Returns 0 if the
// group is already present, 1 if we had to create it, negative on error.
// The given group will have the "isgroup" bit set on it (in other words,
// it is not to be just a container of other groups, like "mcom" is.)
PRInt32 NoticeNewGroup(const char* name, nsMsgGroupRecord **outGroupRecord = nsnull);
// Makes sure that we have records in memory for all known descendants
// of the given newsgroup.
PRInt32 AssureAllDescendentsLoaded(nsMsgGroupRecord* group);
PRInt32 SaveHostInfo();
// Suck the entire hostinfo file into memory. If force is PR_TRUE, then throw
// away whatever we had in memory first.
PRInt32 Inhale(PRBool force = PR_FALSE);
// If we inhale'd, then write thing out to the file and free up the
// memory.
PRInt32 Exhale();
// Inhale, but make believe the file is empty. In other words, set the
// inhaled bit, but empty out the memory.
PRInt32 EmptyInhale();
nsMsgGroupRecord* GetGroupTree() {return m_groupTree;}
PRTime GetFirstNewDate() {return m_firstnewdate;}
NS_IMETHOD GroupNotFound(const char *name, PRBool opening);
PRInt32 ReorderGroup (nsINNTPNewsgroup *groupToMove, nsINNTPNewsgroup *groupToMoveBefore, PRInt32 *newIdx);
protected:
void OpenGroupFile(const PRIntn = PR_WRONLY);
static void WriteTimer(void* closure);
PRInt32 CreateFileHeader();
PRInt32 ReadInitialPart();
nsMsgGroupRecord* FindGroupInBlock(nsMsgGroupRecord* parent,
char* name,
PRInt32* comp);
nsMsgGroupRecord* LoadSingleEntry(nsMsgGroupRecord* parent,
char* name,
PRInt32 min, PRInt32 max);
static PRInt32 InhaleLine(char* line, PRUint32 length, void* closure);
nsMsgGroupRecord* FindOrCreateGroup(const char* name,
PRInt32 * statusOfMakingGroup = nsnull);
nsINNTPCategoryContainer *SwitchNewsToCategoryContainer(nsINNTPNewsgroup *newsInfo);
nsINNTPNewsgroup * SwitchCategoryContainerToNews(nsINNTPCategoryContainer *catContainerInfo);
char* m_hostname;
char* m_username;
nsISupportsArray* m_groups; // List of nsINNTPNewsgroup* objects.
nsISupportsArray* m_newsgrouplists; // List of nsINNTPNewsgroupList* objects.
nsIMsgFolder* m_hostinfo; // Object representing entire newshost in
// tree.
char* m_optionLines;
char* m_filename; /* The name of the newsrc file associated with
this host. This will be of the form:
"" meaning .newsrc or .snewsrc
HOST meaning .newsrc-HOST
HOST:PORT meaning .newsrc-HOST:PORT
Whether it begins with .newsrc or .snewsrc
depends on a special property slot
(we pass one of
the types xpNewsRC or xpSNewsRC to xp_file.)
The reason this is not simply derived from
the host_name and port slots is that it's
not a 1:1 mapping; if the user has a file
called "newsrc", we will use that for the
default host (the "" name.) Likewise,
".newsrc-H" and ".newsrc-H:119" are
ambiguous.
*/
char* m_dbfilename;
PRBool m_dirty;
PRBool m_supportsExtensions;
void* m_writetimer;
char* m_urlbase;
PRBool m_everexpanded; // Whether the user ever opened up this
// newshost this session.
PRBool m_checkedForNew; // Whether we've checked for new newgroups
// in this newshost this session.
PRBool m_groupSucceeded; // Whether a group command has succeeded this
// session, protect against server bustage
// where it says no group exists.
nsVoidArray m_supportedExtensions;
nsVoidArray m_searchableGroups;
nsVoidArray m_searchableHeaders;
// ### mwelch Added to determine what charsets can be used
// for each table.
PLHashTable * m_searchableGroupCharsets;
nsVoidArray m_propertiesForGet;
nsVoidArray m_valuesForGet;
PRBool m_postingAllowed;
PRBool m_pushAuth; // PR_TRUE if we should volunteer authentication without a
// challenge
PRUint32 m_lastGroupUpdate;
PRTime m_firstnewdate;
nsMsgGroupRecord* m_groupTree; // Tree of groups we're remembering.
PRBool m_inhaled; // Whether we inhaled the entire list of
// groups, or just some.
PRInt32 m_groupTreeDirty; // Whether the group tree is dirty. If 0, then
// we don't need to write anything. If 1, then
// we can write things in place. If >1, then
// we need to rewrite the whole tree file.
char* m_hostinfofilename; // Filename of the hostinfo file.
static nsNNTPHost* M_FileOwner; // In an effort to save file descriptors,
// only one newshost ever has its
// hostinfo file opened. This is the
// one.
PRFileDesc * m_groupFile; // File handle to the hostinfo file.
char* m_groupFilePermissions; // Permissions used to create the above
// file handle.
char* m_block; // A block of text read from the hostinfo file.
PRInt32 m_blockSize; // How many bytes allocated in m_block.
PRInt32 m_blockStart; // Where in the file we read the data that is
// currently sitting in m_block.
PRInt32 m_fileStart; // Where in the file the actual newsgroup data
// starts.
PRInt32 m_fileSize; // Total number of bytes in the hostinfo file.
PRInt32 m_uniqueId; // Unique number assigned to each newsgroup.
nsINntpUrl *m_runningURL;
};
#endif /* __msg_NewsHost__ */

View File

@@ -1,255 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
* Seth Spitzer <sspitzer@netscape.com>
* Pierre Phaneuf <pp@ludusdesign.com>
*/
#include "nscore.h"
#include "plstr.h"
#include "prmem.h"
#include <stdio.h>
#include "nsISupports.h" /* interface nsISupports */
#include "nsNNTPNewsgroup.h"
#include "nsCOMPtr.h"
nsNNTPNewsgroup::nsNNTPNewsgroup()
{
NS_INIT_REFCNT();
m_groupName = nsnull;
m_prettyName = nsnull;
m_needsExtraInfo = PR_FALSE;
m_category = PR_FALSE;
}
nsNNTPNewsgroup::~nsNNTPNewsgroup()
{
#ifdef DEBUG_NEWS
printf("destroying newsgroup: %s", m_groupName ? m_groupName : "");
#endif
PR_FREEIF(m_groupName);
PR_FREEIF(m_prettyName);
}
NS_IMPL_ISUPPORTS1(nsNNTPNewsgroup, nsINNTPNewsgroup)
nsresult nsNNTPNewsgroup::GetName(char ** aName)
{
if (aName)
{
*aName = PL_strdup(m_groupName);
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::SetName(const char *aName)
{
if (aName)
{
#ifdef DEBUG_NEWS
printf("Setting newsgroup name to %s. \n", aName);
#endif
m_groupName = PL_strdup(aName);
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::GetPrettyName(char ** aName)
{
if (aName)
{
*aName = PL_strdup(m_prettyName);
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::SetPrettyName(const char *aName)
{
if (aName)
{
#ifdef DEBUG_NEWS
printf("Setting pretty newsgroup name to %s. \n", aName);
#endif
m_prettyName = PL_strdup(aName);
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::GetNeedsExtraInfo(PRBool *aNeedsExtraInfo)
{
if (aNeedsExtraInfo)
{
*aNeedsExtraInfo = m_needsExtraInfo;
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::SetNeedsExtraInfo(PRBool aNeedsExtraInfo)
{
if (aNeedsExtraInfo)
{
#ifdef DEBUG_NEWS
printf("Setting needs extra info for newsgroup %s to %s. \n", m_groupName, aNeedsExtraInfo ? "TRUE" : "FALSE" );
#endif
m_needsExtraInfo = aNeedsExtraInfo;
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::IsOfflineArticle(PRInt32 num, PRBool *_retval)
{
#ifdef DEBUG_NEWS
printf("Testing for offline article %d in %s. \n", num, m_groupName);
#endif
if (_retval)
*_retval = PR_FALSE;
return NS_OK;
}
nsresult nsNNTPNewsgroup::GetCategory(PRBool *aCategory)
{
if (aCategory)
{
*aCategory = m_category;
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::SetCategory(PRBool aCategory)
{
if (aCategory)
{
#ifdef DEBUG_NEWS
printf("Setting is category for newsgroup %s to %s. \n", m_groupName, aCategory ? "TRUE" : "FALSE" );
#endif
m_category = aCategory;
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::GetSubscribed(PRBool *aSubscribed)
{
if (aSubscribed)
{
*aSubscribed = m_isSubscribed;
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::SetSubscribed(PRBool aSubscribed)
{
m_isSubscribed = aSubscribed;
return NS_OK;
}
nsresult nsNNTPNewsgroup::GetWantNewTotals(PRBool *aWantNewTotals)
{
if (aWantNewTotals)
{
*aWantNewTotals = m_wantsNewTotals;
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::SetWantNewTotals(PRBool aWantNewTotals)
{
if (aWantNewTotals)
{
#ifdef DEBUG_NEWS
printf("Setting wants new totals for newsgroup %s to %s. \n", m_groupName, aWantNewTotals ? "TRUE" : "FALSE" );
#endif
m_wantsNewTotals = aWantNewTotals;
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::GetNewsgroupList(nsINNTPNewsgroupList * *aNewsgroupList)
{
if (aNewsgroupList)
{
*aNewsgroupList = m_newsgroupList;
NS_IF_ADDREF(*aNewsgroupList);
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::SetNewsgroupList(nsINNTPNewsgroupList * aNewsgroupList)
{
if (aNewsgroupList)
{
#ifdef DEBUG_NEWS
printf("Setting newsgroup list for newsgroup %s. \n", m_groupName);
#endif
m_newsgroupList = aNewsgroupList;
NS_IF_ADDREF(aNewsgroupList);
}
return NS_OK;
}
nsresult nsNNTPNewsgroup::UpdateSummaryFromNNTPInfo(PRInt32 oldest, PRInt32 youngest, PRInt32 total_messages)
{
#ifdef DEBUG_NEWS
printf("Updating summary with oldest= %d, youngest= %d, and total messages = %d. \n", oldest, youngest, total_messages);
#endif
return NS_OK;
}
nsresult nsNNTPNewsgroup::Initialize(const char *name,
nsMsgKeySet *set,
PRBool subscribed)
{
#ifdef DEBUG_NEWS
printf("nsNNTPNewsgroup::Intialize(name = %s, subscribed = %s)\n",name?name:"(null)", subscribed?"TRUE":"FALSE");
#endif
nsresult rv = NS_OK;
rv = SetSubscribed(subscribed);
if (NS_FAILED(rv)) return rv;
if (name) {
rv = SetName((char *)name);
if (NS_FAILED(rv)) return rv;
}
if (set) {
NS_ASSERTION(0, "not doing anything with set in nsNNTPNewsgroup::Initialize() yet...");
}
return rv;
}

View File

@@ -1,52 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* The contents of this file are subject to the Netscape Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/NPL/
*
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
*/
#ifndef __nsNNTPNewsgroup_h
#define __nsNNTPNewsgroup_h
#include "nsMsgKeySet.h"
#include "nsINNTPHost.h"
#include "nsINNTPNewsgroup.h"
#include "nsINNTPNewsgroupList.h"
#include "nsCOMPtr.h"
class nsNNTPNewsgroup : public nsINNTPNewsgroup
{
public:
nsNNTPNewsgroup();
virtual ~nsNNTPNewsgroup();
NS_DECL_ISUPPORTS
NS_DECL_NSINNTPNEWSGROUP
protected:
char * m_groupName;
char * m_prettyName;
PRBool m_isSubscribed;
PRBool m_wantsNewTotals;
PRBool m_needsExtraInfo;
PRBool m_category;
nsCOMPtr<nsINNTPNewsgroupList> m_newsgroupList;
};
#endif /* __nsNNTPNewsgroup_h */

View File

@@ -51,12 +51,6 @@
#include "nsINNTPArticleList.h"
#include "nsMsgKeySet.h"
#include "nsINNTPNewsgroup.h"
#include "nsNNTPNewsgroup.h"
#include "nsINNTPHost.h"
#include "nsNNTPHost.h"
#include "nntpCore.h"
#include "nsIStringBundle.h"
@@ -91,11 +85,6 @@ extern PRInt32 net_NewsChunkSize;
nsNNTPNewsgroupList::nsNNTPNewsgroupList()
{
NS_INIT_REFCNT();
m_username = nsnull;
m_hostname = nsnull;
m_uri = nsnull;
m_groupName = nsnull;
}
@@ -108,36 +97,17 @@ NS_IMPL_ISUPPORTS1(nsNNTPNewsgroupList, nsINNTPNewsgroupList)
nsresult
nsNNTPNewsgroupList::Initialize(nsINNTPHost *host, nsINntpUrl *runningURL, nsINNTPNewsgroup *newsgroup, const char *username, const char *hostname, const char *groupname)
nsNNTPNewsgroupList::Initialize(nsINntpUrl *runningURL, nsIMsgNewsFolder *newsFolder)
{
m_newsDB = nsnull;
if (groupname) {
m_groupName = PL_strdup(groupname);
}
if (hostname) {
m_hostname = PL_strdup(hostname);
}
if (username) {
m_username = PL_strdup(username);
m_uri = PR_smprintf("%s/%s@%s/%s",kNewsRootURI,username,hostname,groupname);
}
else {
m_uri = PR_smprintf("%s/%s/%s",kNewsRootURI,hostname,groupname);
}
m_lastProcessedNumber = 0;
m_newsDB = nsnull;
m_lastProcessedNumber = 0;
m_lastMsgNumber = 0;
m_set = nsnull;
m_finishingXover = PR_FALSE;
memset(&m_knownArts, 0, sizeof(m_knownArts));
m_knownArts.group_name = m_groupName;
m_host = host;
m_newsgroup = newsgroup;
m_knownArts.host = m_host;
m_newsFolder = newsFolder;
m_knownArts.set = nsMsgKeySet::Create();
m_getOldMessages = PR_FALSE;
m_promptedAlready = PR_FALSE;
@@ -150,22 +120,21 @@ nsNNTPNewsgroupList::Initialize(nsINNTPHost *host, nsINntpUrl *runningURL, nsINN
}
nsresult
nsNNTPNewsgroupList::CleanUp() {
PR_FREEIF(m_username);
PR_FREEIF(m_hostname);
PR_FREEIF(m_uri);
PR_FREEIF(m_groupName);
nsNNTPNewsgroupList::CleanUp()
{
if (m_newsDB) {
m_newsDB->Commit(nsMsgDBCommitType::kSessionCommit);
m_newsDB->Close(PR_TRUE);
NS_RELEASE(m_newsDB);
}
m_newsDB = nsnull;
}
if (m_knownArts.set) {
delete m_knownArts.set;
m_knownArts.set = nsnull;
}
m_newsFolder = nsnull;
m_runningURL = nsnull;
return NS_OK;
}
@@ -176,42 +145,6 @@ void nsNNTPNewsgroupList::OnAnnouncerGoingAway (ChangeAnnouncer *instigator)
}
#endif
nsresult
nsNNTPNewsgroupList::GetDatabase(const char *uri, nsIMsgDatabase **db)
{
if (*db == nsnull) {
nsFileSpec path;
nsresult rv = nsNewsURI2Path(kNewsRootURI, uri, path);
if (NS_FAILED(rv)) return rv;
nsresult newsDBOpen = NS_OK;
nsCOMPtr <nsIMsgDatabase> newsDBFactory;
rv = nsComponentManager::CreateInstance(kCNewsDB, nsnull, NS_GET_IID(nsIMsgDatabase), getter_AddRefs(newsDBFactory));
if (NS_SUCCEEDED(rv) && newsDBFactory) {
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(path, getter_AddRefs(dbFileSpec));
newsDBOpen = newsDBFactory->Open(dbFileSpec, PR_TRUE, PR_FALSE, (nsIMsgDatabase **) db);
#ifdef DEBUG_NEWS
if (NS_SUCCEEDED(newsDBOpen)) {
printf ("newsDBFactory->Open() succeeded\n");
}
else {
printf ("newsDBFactory->Open() failed\n");
}
#endif /* DEBUG_NEWS */
return rv;
}
#ifdef DEBUG_NEWS
else {
printf("nsComponentManager::CreateInstance(kCNewsDB,...) failed\n");
}
#endif
}
return NS_OK;
}
static nsresult
openWindow(nsIMsgWindow *aMsgWindow, const char *chromeURL, nsINewsDownloadDialogArgs *param)
{
@@ -264,8 +197,6 @@ openWindow(nsIMsgWindow *aMsgWindow, const char *chromeURL, nsINewsDownloadDialo
nsresult
nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
/*nsINNTPHost* host,
const char* group_name,*/
PRInt32 first_possible,
PRInt32 last_possible,
PRInt32 maxextra,
@@ -273,7 +204,7 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
PRInt32* last,
PRInt32 *status)
{
PRBool emptyGroup_p = PR_FALSE;
nsresult rv = NS_OK;
NS_ASSERTION(first && last, "no first or no last");
if (!first || !last) return NS_MSG_FAILURE;
@@ -281,126 +212,87 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
*first = 0;
*last = 0;
nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(m_newsFolder, &rv);
NS_ENSURE_SUCCESS(rv,rv);
if (!m_newsDB) {
nsresult err;
if ((err = GetDatabase(GetURI(), &m_newsDB)) != NS_OK) {
return err;
}
else {
nsresult rv = NS_OK;
nsCOMPtr<nsINewsDatabase> db(do_QueryInterface(m_newsDB, &rv));
if (NS_FAILED(rv)) return rv;
rv = db->GetReadSet(&m_set);
if (NS_FAILED(rv) || !m_set) {
return rv;
}
m_set->SetLastMember(last_possible); // make sure highwater mark is valid.
nsCOMPtr <nsIDBFolderInfo> newsGroupInfo;
rv = m_newsDB->GetDBFolderInfo(getter_AddRefs(newsGroupInfo));
if (NS_SUCCEEDED(rv) && newsGroupInfo)
{
nsAutoString knownArtsString;
nsMsgKey mark;
newsGroupInfo->GetKnownArtsSet(&knownArtsString);
rv = newsGroupInfo->GetHighWater(&mark);
if (NS_FAILED(rv)) {
return rv;
}
if (last_possible < ((PRInt32)mark))
newsGroupInfo->SetHighWater(last_possible, PR_TRUE);
if (m_knownArts.set) {
delete m_knownArts.set;
}
nsCAutoString knownartstringC;
knownartstringC.AssignWithConversion(knownArtsString);
m_knownArts.set = nsMsgKeySet::Create(knownartstringC);
}
else
{
if (m_knownArts.set) {
delete m_knownArts.set;
}
m_knownArts.set = nsMsgKeySet::Create();
nsMsgKey low, high;
rv = m_newsDB->GetLowWaterArticleNum(&low);
if (NS_FAILED(rv)) return rv;
rv = m_newsDB->GetHighWaterArticleNum(&high);
if (NS_FAILED(rv)) return rv;
m_knownArts.set->AddRange(low,high);
}
#ifdef HAVE_PANES
m_pane->StartingUpdate(MSG_NotifyNone, 0, 0);
m_newsDB->ExpireUpTo(first_possible, m_pane->GetContext());
m_pane->EndingUpdate(MSG_NotifyNone, 0, 0);
#endif /* HAVE_PANES */
if (m_knownArts.set->IsMember(last_possible)) {
nsXPIDLString statusString;
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle(NEWS_MSGS_URL, nsnull, getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
rv = bundle->GetStringFromName(NS_LITERAL_STRING("noNewMessages"), getter_Copies(statusString));
NS_ENSURE_SUCCESS(rv, rv);
SetProgressStatus(statusString);
}
}
rv = folder->GetMsgDatabase(nsnull /* msgWindow */, getter_AddRefs(m_newsDB));
}
nsCOMPtr<nsINewsDatabase> db(do_QueryInterface(m_newsDB, &rv));
NS_ENSURE_SUCCESS(rv,rv);
rv = db->GetReadSet(&m_set);
if (NS_FAILED(rv) || !m_set) {
return rv;
}
m_set->SetLastMember(last_possible); // make sure highwater mark is valid.
nsCOMPtr <nsIDBFolderInfo> newsGroupInfo;
rv = m_newsDB->GetDBFolderInfo(getter_AddRefs(newsGroupInfo));
if (NS_SUCCEEDED(rv) && newsGroupInfo) {
nsAutoString knownArtsString;
nsMsgKey mark;
newsGroupInfo->GetKnownArtsSet(&knownArtsString);
rv = newsGroupInfo->GetHighWater(&mark);
NS_ENSURE_SUCCESS(rv,rv);
if (last_possible < ((PRInt32)mark))
newsGroupInfo->SetHighWater(last_possible, PR_TRUE);
if (m_knownArts.set) {
delete m_knownArts.set;
}
nsCAutoString knownartstringC;
knownartstringC.AssignWithConversion(knownArtsString);
m_knownArts.set = nsMsgKeySet::Create(knownartstringC);
}
else
{
if (m_knownArts.set) {
delete m_knownArts.set;
}
m_knownArts.set = nsMsgKeySet::Create();
nsMsgKey low, high;
rv = m_newsDB->GetLowWaterArticleNum(&low);
NS_ENSURE_SUCCESS(rv,rv);
rv = m_newsDB->GetHighWaterArticleNum(&high);
NS_ENSURE_SUCCESS(rv,rv);
m_knownArts.set->AddRange(low,high);
}
if (m_knownArts.set->IsMember(last_possible)) {
nsXPIDLString statusString;
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle(NEWS_MSGS_URL, nsnull, getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
rv = bundle->GetStringFromName(NS_LITERAL_STRING("noNewMessages"), getter_Copies(statusString));
NS_ENSURE_SUCCESS(rv, rv);
SetProgressStatus(statusString);
}
if (maxextra <= 0 || last_possible < first_possible || last_possible < 1)
{
emptyGroup_p = PR_TRUE;
}
// this is just a temporary hack. these used to be parameters
// to this function, but then we were mutually dependant between this
// class and nsNNTPHost
nsINNTPHost *host=m_knownArts.host;
const char* group_name = m_knownArts.group_name;
if (m_knownArts.host != host ||
m_knownArts.group_name == NULL ||
PL_strcmp(m_knownArts.group_name, group_name) != 0 ||
!m_knownArts.set)
{
/* We're displaying some other group. Clear out that display, and set up
everything to return the proper first chunk. */
NS_ASSERTION(0, "todo - need new way of doing");
if (emptyGroup_p) {
if (status) *status=0;
return NS_OK;
}
}
else
{
if (emptyGroup_p) {
if (status) *status=0;
return NS_OK;
}
if (status) *status=0;
return NS_OK;
}
m_knownArts.first_possible = first_possible;
m_knownArts.last_possible = last_possible;
nsresult rv = NS_OK;
// get the incoming msg server
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, NS_MSGACCOUNTMANAGER_CONTRACTID, &rv)
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIMsgIncomingServer> server;
rv = accountManager->FindServer(m_username,m_hostname,"nntp", getter_AddRefs(server));
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsIMsgIncomingServer> server;
rv = folder->GetServer(getter_AddRefs(server));
NS_ENSURE_SUCCESS(rv,rv);
// QI to get the nntp incoming msg server
nsCOMPtr<nsINntpIncomingServer> nntpServer;
rv = server->QueryInterface(NS_GET_IID(nsINntpIncomingServer), getter_AddRefs(nntpServer));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINntpIncomingServer> nntpServer = do_QueryInterface(server, &rv);
NS_ENSURE_SUCCESS(rv,rv);
/* Determine if we only want to get just new articles or more messages.
If there are new articles at the end we haven't seen, we always want to get those first.
@@ -441,7 +333,11 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow,
rv = args->SetArticleCount(*last - *first + 1);
NS_ENSURE_SUCCESS(rv,rv);
rv = args->SetGroupName((const char *)m_groupName);
nsXPIDLCString groupName;
rv = m_newsFolder->GetAsciiName(getter_Copies(groupName));
NS_ENSURE_SUCCESS(rv,rv);
rv = args->SetGroupName((const char *)groupName);
NS_ENSURE_SUCCESS(rv,rv);
// get the server key
@@ -503,24 +399,12 @@ nsresult
nsNNTPNewsgroupList::AddToKnownArticles(PRInt32 first, PRInt32 last)
{
int status;
// another temporary hack
nsINNTPHost *host = m_knownArts.host;
const char* group_name = m_knownArts.group_name;
if (m_knownArts.host != host ||
m_knownArts.group_name == NULL ||
PL_strcmp(m_knownArts.group_name, group_name) != 0 ||
!m_knownArts.set)
if (!m_knownArts.set)
{
m_knownArts.host = host;
PR_FREEIF(m_knownArts.group_name);
m_knownArts.group_name = PL_strdup(group_name);
if (m_knownArts.set) {
delete m_knownArts.set;
}
m_knownArts.set = nsMsgKeySet::Create();
if (!m_knownArts.group_name || !m_knownArts.set) {
if (!m_knownArts.set) {
return NS_ERROR_OUT_OF_MEMORY;
}
@@ -536,7 +420,7 @@ nsNNTPNewsgroupList::AddToKnownArticles(PRInt32 first, PRInt32 last)
char *output;
status = m_knownArts.set->Output(&output);
if (output) {
nsString str; str.AssignWithConversion(output);
nsAutoString str; str.AssignWithConversion(output);
newsGroupInfo->SetKnownArtsSet(&str);
nsMemory::Free(output);
}
@@ -919,50 +803,18 @@ nsNNTPNewsgroupList::FinishXOVERLINE(int status, int *newstatus)
SetProgressStatus(statusString);
}
#ifdef HAVE_PANES
nsINNTPNewsgroup *newsFolder =
(m_pane) ?
savePane->GetMaster()->FindNewsFolder(m_host, m_groupName, PR_FALSE) :
0;
FE_PaneChanged(m_pane, PR_FALSE, MSG_PaneNotifyFolderLoaded, (PRUint32)newsFolder);
#endif
}
if (newstatus) *newstatus=0;
return NS_OK;
// nsNNTPNewsgroupList object gets deleted by the master when a new one is created.
}
// this used to be in the master:
// void MSG_Master::ClearListNewsGroupState(MSG_NewsHost* host,
// const char *newsGroupName)
// {
// MSG_FolderInfoNews *newsFolder = FindNewsFolder(host, newsGroupName);
// ListNewsGroupState *state = (newsFolder) ? newsFolder->GetListNewsGroupState
// if (state != NULL)
// {
// delete state;
// newsFolder->SetListNewsGroupState(NULL);
// }
// }
nsresult
nsNNTPNewsgroupList::ClearXOVERState()
{
return NS_OK;
}
nsresult
nsNNTPNewsgroupList::GetGroupName(char **_retval)
{
if (_retval) {
*_retval = m_groupName;
return NS_OK;
}
else {
return NS_ERROR_NULL_POINTER;
}
}
void
nsNNTPNewsgroupList::SetProgressBarPercent(PRInt32 percent)
{

View File

@@ -29,9 +29,8 @@
#ifndef nsNNTPNewsgroupListState_h___
#define nsNNTPNewsgroupListState_h___
#include "nsINNTPHost.h"
#include "nsINNTPNewsgroupList.h"
#include "nsINNTPNewsgroup.h"
#include "nsIMsgNewsFolder.h"
#include "nsIMsgDatabase.h"
#include "nsMsgKeySet.h"
#include "nsINntpUrl.h"
@@ -41,8 +40,6 @@
articles we've already seen in the current newsgroup. */
typedef struct MSG_NewsKnown {
nsINNTPHost* host;
char* group_name;
nsMsgKeySet* set; /* Set of articles we've already gotten
from the newsserver (if it's marked
"read", then we've already gotten it).
@@ -77,9 +74,7 @@ private:
NS_METHOD CleanUp();
PRBool m_finishingXover;
nsINNTPHost* GetHost() {return m_host;}
const char * GetURI() {return m_uri;}
#ifdef HAVE_CHANGELISTENER
virtual void OnAnnouncerGoingAway (ChangeAnnouncer *instigator);
#endif
@@ -89,17 +84,13 @@ private:
void SetProgressStatus(const PRUnichar *message);
protected:
nsIMsgDatabase *m_newsDB;
PRBool m_getOldMessages;
PRBool m_promptedAlready;
PRBool m_downloadAll;
PRInt32 m_maxArticles;
char *m_groupName;
nsINNTPHost *m_host;
nsINNTPNewsgroup *m_newsgroup;
char *m_username;
char *m_hostname;
char *m_uri;
nsCOMPtr <nsIMsgNewsFolder> m_newsFolder;
nsCOMPtr <nsIMsgDatabase> m_newsDB;
nsMsgKey m_lastProcessedNumber;
nsMsgKey m_firstMsgNumber;
@@ -109,7 +100,7 @@ protected:
struct MSG_NewsKnown m_knownArts;
nsMsgKeySet *m_set;
nsINntpUrl *m_runningURL;
nsINntpUrl *m_runningURL;
};
#endif /* nsNNTPNewsgroupListState_h___ */

View File

@@ -83,6 +83,7 @@
#include "nsIMsgWindow.h"
#include "nsIPrompt.h"
#include "nsINntpService.h"
#include "nntpCore.h"
#undef GetPort // XXX Windows!
@@ -152,7 +153,6 @@ char * NET_SACat (char **destination, const char *source);
static NS_DEFINE_CID(kCHeaderParserCID, NS_MSGHEADERPARSER_CID);
static NS_DEFINE_CID(kNNTPArticleListCID, NS_NNTPARTICLELIST_CID);
static NS_DEFINE_CID(kNNTPHostCID, NS_NNTPHOST_CID);
static NS_DEFINE_CID(kCMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kCMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
static NS_DEFINE_CID(kPrefServiceCID,NS_PREF_CID);
@@ -457,6 +457,7 @@ nsNNTPProtocol::nsNNTPProtocol(nsIURI * aURL, nsIMsgWindow *aMsgWindow)
m_cancelID = nsnull;
m_messageID = nsnull;
m_key = nsMsgKey_None;
m_commandSpecificData = nsnull;
m_searchData = nsnull;
@@ -573,10 +574,6 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI * aURL, nsIMsgWindow *aMsgWindow
}
// okay, now fill in our event sinks...Note that each getter ref counts before
// it returns the interface to us...we'll release when we are done
m_runningURL->GetNewsgroupList(getter_AddRefs(m_newsgroupList));
m_runningURL->GetNntpArticleList(getter_AddRefs(m_articleList));
m_runningURL->GetNntpHost(getter_AddRefs(m_newsHost));
m_runningURL->GetNewsgroup(getter_AddRefs(m_newsgroup));
m_runningURL->GetOfflineNewsState(getter_AddRefs(m_offlineNewsState));
if (msgIsInLocalCache)
return NS_OK; // probably don't need to do anything else - definitely don't want
@@ -626,6 +623,7 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI * aURL, nsIMsgWindow *aMsgWindow
PR_FREEIF(m_messageID);
m_messageID = nsnull;
m_key = nsMsgKey_None;
m_articleNumber = 0;
m_originalContentLength = 0;
@@ -636,13 +634,6 @@ NS_IMETHODIMP nsNNTPProtocol::Initialize(nsIURI * aURL, nsIMsgWindow *aMsgWindow
return NS_OK;
}
nsresult
nsNNTPProtocol::InitializeNewsFolderFromUri(const char *uri)
{
PR_LOG(NNTP,PR_LOG_ALWAYS,("InitializeNewsFolderFromUri(%s)",uri));
return nsGetNewsGroupFromUri(uri, getter_AddRefs(m_newsFolder));
}
/* void IsBusy (out boolean aIsConnectionBusy); */
NS_IMETHODIMP nsNNTPProtocol::IsBusy(PRBool *aIsConnectionBusy)
{
@@ -771,7 +762,7 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL, &rv);
if (NS_FAILED(rv)) return rv;
SetNewsFolder(); // make sure m_newsFolder is set.
SetNewsFolderAndMsgKey(); // make sure m_newsFolder is set.
m_channelContext = ctxt;
m_channelListener = listener;
m_runningURL->GetNewsAction(&m_newsAction);
@@ -791,10 +782,8 @@ NS_IMETHODIMP nsNNTPProtocol::AsyncRead(nsIStreamListener *listener, nsISupports
if (folder && NS_SUCCEEDED(rv))
{
// we want to create a file channel and read the msg from there.
nsMsgKey key = nsMsgKey_None;
rv = m_runningURL->GetMessageKey(&key);
nsCOMPtr<nsIFileChannel> fileChannel;
rv = folder->GetOfflineFileChannel(key, getter_AddRefs(fileChannel));
rv = folder->GetOfflineFileChannel(m_key, getter_AddRefs(fileChannel));
// get the file channel from the folder, somehow (through the message or
// folder sink?) We also need to set the transfer offset to the message offset
if (fileChannel && NS_SUCCEEDED(rv))
@@ -895,7 +884,9 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
m_runningURL->GetNewsAction(&m_newsAction);
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsUrl = do_QueryInterface(m_runningURL);
SetNewsFolder(); // make sure m_newsFolder is set.
if (m_newsAction != nsINntpUrl::ActionPostArticle) {
SetNewsFolderAndMsgKey(); // set m_newsFolder and m_key, if we can
}
m_articleNumber = -1;
rv = aURL->GetHost(getter_Copies(m_hostName));
@@ -907,10 +898,6 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
// okay, now fill in our event sinks...Note that each getter ref counts before
// it returns the interface to us...we'll release when we are done
m_runningURL->GetNewsgroupList(getter_AddRefs(m_newsgroupList));
m_runningURL->GetNntpArticleList(getter_AddRefs(m_articleList));
m_runningURL->GetNntpHost(getter_AddRefs(m_newsHost));
m_runningURL->GetNewsgroup(getter_AddRefs(m_newsgroup));
m_runningURL->GetOfflineNewsState(getter_AddRefs(m_offlineNewsState));
@@ -918,45 +905,16 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
PR_FREEIF(m_messageID);
m_messageID = nsnull;
rv = ParseURL(aURL,&bVal, getter_Copies(group), &m_messageID, &commandSpecificData);
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to parse news url");
//if (NS_FAILED(rv)) return rv;
// if we don't have a news host already, go get one...
if (!m_newsHost)
{
m_newsHost = do_CreateInstance(kNNTPHostCID, &rv);
if (NS_FAILED(rv) || (!m_newsHost)) goto FAIL;
if (!m_newsFolder) goto FAIL;
// m_newsHost holds m_runningURL (make this a weak reference)
// m_runningURL holds m_newsHost
// need to make sure there is no cycle.
// retrieve the AccountManager
NS_WITH_SERVICE(nsIMsgAccountManager, accountManager, NS_MSGACCOUNTMANAGER_CONTRACTID, &rv);
if (NS_FAILED(rv)) goto FAIL;
// find the incoming server
nsCOMPtr<nsIMsgIncomingServer> server;
rv = accountManager->FindServer(m_userName,
m_hostName,
"nntp",
getter_AddRefs(server));
if (NS_FAILED(rv) || !server) goto FAIL;
m_nntpServer = do_QueryInterface(server, &rv);
if (NS_FAILED(rv) || !m_nntpServer) goto FAIL;
m_newsHost->Initialize(m_runningURL, m_userName, m_hostName);
// save it on our url for future use....
m_runningURL->SetNntpHost(m_newsHost);
if (NS_FAILED(rv)) goto FAIL;
}
if (NS_FAILED(rv))
goto FAIL;
rv = m_newsFolder->GetNntpServer(getter_AddRefs(m_nntpServer));
if (NS_FAILED(rv) || !m_nntpServer) goto FAIL;
if (m_messageID && commandSpecificData && !PL_strcmp (commandSpecificData, "?cancel"))
cancel = PR_TRUE;
@@ -996,11 +954,16 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
NET_SACopy(&m_path, "");
}
else
if (m_messageID)
if (m_messageID || (m_key != nsMsgKey_None))
{
/* news:MESSAGE_ID
news:/GROUP/MESSAGE_ID (useless)
/*
news_message://HOST/GROUP#key
news://HOST/MESSAGE_ID
not sure about these:
news:MESSAGE_ID
news:/GROUP/MESSAGE_ID (useless)
news://HOST/GROUP/MESSAGE_ID (useless)
*/
if (cancel)
@@ -1079,8 +1042,8 @@ nsresult nsNNTPProtocol::LoadUrl(nsIURI * aURL, nsISupports * aConsumer)
if (NS_FAILED(rv)) return rv;
}
}
rv = InitializeNewsFolderFromUri((const char *)newsgroupURI);
rv = nsGetNewsGroupFromUri((const char *)newsgroupURI, getter_AddRefs(m_newsFolder));
if (NS_FAILED(rv)) return rv;
m_typeWanted = GROUP_WANTED;
@@ -1517,10 +1480,7 @@ PRInt32 nsNNTPProtocol::LoginResponse()
return MK_BAD_NNTP_CONNECTION;
}
// ###mscott: I'm commenting this out right now since phil has a comment saying it is dead code...
// cd->control_con->posting_allowed = postingAllowed; /* ###phil dead code */
m_newsHost->SetPostingAllowed(postingAllowed);
m_nntpServer->SetPostingAllowed(postingAllowed);
m_nextState = NNTP_SEND_MODE_READER;
return(0); /* good */
}
@@ -1546,7 +1506,7 @@ PRInt32 nsNNTPProtocol::SendModeReaderResponse()
/* ignore the response code and continue
*/
PRBool pushAuth;
nsresult rv = m_newsHost->GetPushAuth(&pushAuth);
nsresult rv = m_nntpServer->GetPushAuth(&pushAuth);
if (NS_SUCCEEDED(rv) && pushAuth)
/* if the news host is set up to require volunteered (pushed) authentication,
* do that before we do anything else
@@ -1593,12 +1553,13 @@ PRInt32 nsNNTPProtocol::SendListExtensionsResponse(nsIInputStream * inputStream,
if (!line)
return status; /* no line yet */
if ('.' != line[0])
m_newsHost->AddExtension(line);
if ('.' != line[0]) {
m_nntpServer->AddExtension(line);
}
else
{
/* tell libmsg that it's ok to ask this news host for extensions */
m_newsHost->SetSupportsExtensions(PR_TRUE);
m_nntpServer->SetSupportsExtensions(PR_TRUE);
/* all extensions received */
m_nextState = SEND_LIST_SEARCHES;
ClearFlag(NNTP_PAUSE_FOR_READ);
@@ -1610,7 +1571,7 @@ PRInt32 nsNNTPProtocol::SendListExtensionsResponse(nsIInputStream * inputStream,
* tell libmsg not to ask for any more extensions and move on to
* the real NNTP command we were trying to do. */
m_newsHost->SetSupportsExtensions(PR_FALSE);
m_nntpServer->SetSupportsExtensions(PR_FALSE);
m_nextState = SEND_FIRST_NNTP_COMMAND;
}
@@ -1623,7 +1584,7 @@ PRInt32 nsNNTPProtocol::SendListSearches()
PRBool searchable=PR_FALSE;
PRInt32 status = 0;
rv = m_newsHost->QueryExtension("SEARCH",&searchable);
rv = m_nntpServer->QueryExtension("SEARCH",&searchable);
if (NS_SUCCEEDED(rv) && searchable)
{
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
@@ -1666,7 +1627,7 @@ PRInt32 nsNNTPProtocol::SendListSearchesResponse(nsIInputStream * inputStream, P
if ('.' != line[0])
{
m_newsHost->AddSearchableGroup(line);
m_nntpServer->AddSearchableGroup(line);
}
else
{
@@ -1712,7 +1673,7 @@ PRInt32 nsNNTPProtocol::SendListSearchHeadersResponse(nsIInputStream * inputStre
return status; /* no line yet */
if ('.' != line[0])
m_newsHost->AddSearchableHeader(line);
m_nntpServer->AddSearchableHeader(line);
else
{
m_nextState = NNTP_GET_PROPERTIES;
@@ -1729,7 +1690,7 @@ PRInt32 nsNNTPProtocol::GetProperties()
PRBool setget=PR_FALSE;
PRInt32 status = 0;
rv = m_newsHost->QueryExtension("SETGET",&setget);
rv = m_nntpServer->QueryExtension("SETGET",&setget);
if (NS_SUCCEEDED(rv) && setget)
{
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
@@ -1774,7 +1735,7 @@ PRInt32 nsNNTPProtocol::GetPropertiesResponse(nsIInputStream * inputStream, PRUi
{
char *propertyValue = space + 1;
*space = '\0';
m_newsHost->AddPropertyForGet(propertyName, propertyValue);
m_nntpServer->AddPropertyForGet(propertyName, propertyValue);
}
PR_Free(propertyName);
}
@@ -1796,7 +1757,7 @@ PRInt32 nsNNTPProtocol::SendListSubscriptions()
#if 0
nsresult rv;
PRBool searchable=PR_FALSE;
rv = m_newsHost->QueryExtension("LISTSUBSCR",&listsubscr);
rv = m_nntpServer->QueryExtension("LISTSUBSCR",&listsubscr);
if (NS_SUCCEEDED(rv) && listsubscr)
#else
if (0)
@@ -1865,17 +1826,21 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
if (m_typeWanted == ARTICLE_WANTED)
{
nsresult rv1,rv2;
nsresult rv;
nsMsgKey key = nsMsgKey_None;
rv1 = m_runningURL->GetMessageKey(&key);
nsXPIDLCString newsgroupName;
rv2 = m_runningURL->GetNewsgroupName(getter_Copies(newsgroupName));
if (m_newsFolder) {
rv = m_newsFolder->GetAsciiName(getter_Copies(newsgroupName));
NS_ENSURE_SUCCESS(rv,rv);
}
else {
printf("no news folder!\n");
rv = NS_ERROR_UNEXPECTED;
}
if (NS_SUCCEEDED(rv1) && NS_SUCCEEDED(rv2) && ((const char *)newsgroupName) && (key != nsMsgKey_None))
if (NS_SUCCEEDED(rv) && ((const char *)newsgroupName) && (m_key != nsMsgKey_None))
{
m_articleNumber = key;
m_articleNumber = m_key;
if (((const char *)m_currentGroup) && !PL_strcmp ((const char *)m_currentGroup, (const char *)newsgroupName))
m_nextState = NNTP_SEND_ARTICLE_NUMBER;
@@ -1908,11 +1873,11 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
PRUint32 last_update;
nsresult rv;
if (!m_newsHost) {
NNTP_LOG_NOTE("m_newsHost is null, panic!");
if (!m_nntpServer) {
NNTP_LOG_NOTE("m_nntpServer is null, panic!");
return -1;
}
rv = m_newsHost->GetLastUpdatedTime(&last_update);
rv = m_nntpServer->GetLastUpdatedTime(&last_update);
char small_buf[64];
PRExplodedTime expandedTime;
@@ -1945,11 +1910,11 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
ClearFlag(NNTP_USE_FANCY_NEWSGROUP);
PRUint32 last_update;
if (!m_newsHost) {
NNTP_LOG_NOTE("m_newsHost is null, panic!");
if (!m_nntpServer) {
NNTP_LOG_NOTE("m_nntpServer is null, panic!");
return -1;
}
nsresult rv = m_newsHost->GetLastUpdatedTime(&last_update);
nsresult rv = m_nntpServer->GetLastUpdatedTime(&last_update);
if (NS_SUCCEEDED(rv) && last_update!=0)
{
@@ -1968,7 +1933,7 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
#endif /* BUG_21013 */
#endif
PRBool xactive=PR_FALSE;
rv = m_newsHost->QueryExtension("XACTIVE",&xactive);
rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
if (NS_SUCCEEDED(rv) && xactive)
{
NET_SACopy(&command, "LIST XACTIVE");
@@ -1982,44 +1947,37 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
}
else if(m_typeWanted == GROUP_WANTED)
{
/* Don't use MKParse because the news: access URL doesn't follow traditional
* rules. For instance, if the article reference contains a '#',
* the rest of it is lost.
*/
char * slash;
char * group_name;
nsresult rv=NS_ERROR_NULL_POINTER;
NET_SACopy(&command, "GROUP ");
if (!m_newsgroup) {
NNTP_LOG_NOTE("m_newsHost is null, panic!");
nsXPIDLCString group_name;
nsresult rv = NS_ERROR_NULL_POINTER;
NS_ASSERTION(m_newsFolder, "m_newsFolder is null, panic!");
if (!m_newsFolder) {
return -1;
}
rv = m_newsgroup->GetName(&group_name);
slash = PL_strchr(group_name, '/');
rv = m_newsFolder->GetAsciiName(getter_Copies(group_name));
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to get newsgroup name");
if (NS_FAILED(rv)) {
return -1;
}
m_firstArticle = 0;
m_lastArticle = 0;
if (slash)
{
*slash = '\0';
(void) PR_sscanf(slash+1, "%d-%d", &m_firstArticle, &m_lastArticle);
}
NET_SACopy(&command, "GROUP ");
m_currentGroup = group_name;
m_currentGroup = (const char *)group_name;
NET_SACat(&command, (const char *)m_currentGroup);
PR_FREEIF(group_name);
}
else if (m_typeWanted == SEARCH_WANTED)
{
nsresult rv;
PRBool searchable=PR_FALSE;
if (!m_newsHost) {
NNTP_LOG_NOTE("m_newsHost is null, panic!");
if (!m_nntpServer) {
NNTP_LOG_NOTE("m_nntpServer is null, panic!");
return -1;
}
rv = m_newsHost->QueryExtension("SEARCH", &searchable);
rv = m_nntpServer->QueryExtension("SEARCH", &searchable);
if (NS_SUCCEEDED(rv) && searchable)
{
/* use the SEARCH extension */
@@ -2042,11 +2000,12 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
/* for XPAT, we have to GROUP into the group before searching */
NET_SACopy(&command, "GROUP ");
if (!m_newsgroup) {
NNTP_LOG_NOTE("m_newsHost is null, panic!");
if (!m_newsFolder) {
NNTP_LOG_NOTE("m_newsFolder is null, panic!");
return -1;
}
rv = m_newsgroup->GetName(getter_Copies(group_name));
rv = m_newsFolder->GetAsciiName(getter_Copies(group_name));
if (NS_FAILED(rv)) return -1;
NET_SACat (&command, group_name);
m_nextState = NNTP_RESPONSE;
m_nextStateAfterResponse = NNTP_XPAT_SEND;
@@ -2056,7 +2015,7 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommand(nsIURI * url)
{
nsresult rv;
PRBool listpretty=PR_FALSE;
rv = m_newsHost->QueryExtension("LISTPRETTY",&listpretty);
rv = m_nntpServer->QueryExtension("LISTPRETTY",&listpretty);
if (NS_SUCCEEDED(rv) && listpretty)
{
m_nextState = NNTP_LIST_PRETTY_NAMES;
@@ -2146,12 +2105,8 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
if (m_responseCode == MK_NNTP_RESPONSE_GROUP_NO_GROUP &&
m_typeWanted == GROUP_WANTED) {
NNTP_LOG_NOTE("group not found!");
#ifdef UNREADY_CODE
MSG_GroupNotFound(cd->pane, cd->host, cd->control_con->current_group, PR_TRUE /* opening group */);
#else
m_newsHost->GroupNotFound((const char *)m_currentGroup,
m_nntpServer->GroupNotFound((const char *)m_currentGroup,
PR_TRUE /* opening */);
#endif
}
/* if the server returned a 400 error then it is an expected
@@ -2165,8 +2120,8 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
nsresult rv = NS_OK;
nsXPIDLCString group_name;
if (m_newsgroup) {
rv = m_newsgroup->GetName(getter_Copies(group_name));
if (m_newsFolder) {
rv = m_newsFolder->GetAsciiName(getter_Copies(group_name));
}
if (NS_SUCCEEDED(rv) && group_name) {
@@ -2188,15 +2143,11 @@ PRInt32 nsNNTPProtocol::SendFirstNNTPCommandResponse()
NS_ENSURE_SUCCESS(rv,rv);
errorHtml.Append(newsErrorStr);
nsMsgKey key = nsMsgKey_None;
rv = m_runningURL->GetMessageKey(&key);
NS_ENSURE_SUCCESS(rv,rv);
char outputBuffer[OUTPUT_BUFFER_SIZE];
NS_ASSERTION(m_messageID && (key != nsMsgKey_None), "unexpected");
if (m_messageID && (key != nsMsgKey_None)) {
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P>&lt;%.512s&gt; (%lu)", m_messageID, key);
NS_ASSERTION(m_messageID && (m_key != nsMsgKey_None), "unexpected");
if (m_messageID && (m_key != nsMsgKey_None)) {
PR_snprintf(outputBuffer,OUTPUT_BUFFER_SIZE,"<P>&lt;%.512s&gt; (%lu)", m_messageID, m_key);
errorHtml.AppendWithConversion(outputBuffer);
}
@@ -2249,7 +2200,7 @@ PRInt32 nsNNTPProtocol::SendGroupForArticle()
PRInt32 status = 0;
nsXPIDLCString groupname;
rv = m_newsgroup->GetName(getter_Copies(groupname));
rv = m_newsFolder->GetAsciiName(getter_Copies(groupname));
NS_ASSERTION(NS_SUCCEEDED(rv) && (const char *)groupname && nsCRT::strlen((const char *)groupname), "no group name");
char outputBuffer[OUTPUT_BUFFER_SIZE];
@@ -2278,7 +2229,7 @@ PRInt32 nsNNTPProtocol::SendGroupForArticleResponse()
m_nextState = NNTP_SEND_ARTICLE_NUMBER;
nsXPIDLCString groupname;
rv = m_newsgroup->GetName(getter_Copies(groupname));
rv = m_newsFolder->GetAsciiName(getter_Copies(groupname));
NS_ASSERTION(NS_SUCCEEDED(rv) && (const char *)groupname && nsCRT::strlen((const char *)groupname), "no group name");
m_currentGroup = (const char *)groupname;
@@ -2642,23 +2593,32 @@ void nsNNTPProtocol::ParseHeaderForCancel(char *buf)
}
nsresult
nsNNTPProtocol::SetNewsFolder()
nsNNTPProtocol::SetNewsFolderAndMsgKey()
{
nsresult rv;
// xxx todo: I need to fix this so this is passed in when I create the nsNNTPProtocol
if (!m_newsFolder) {
nsXPIDLCString folderURI;
nsXPIDLCString newsgroupName;
rv = m_runningURL->GetNewsgroupName(getter_Copies(newsgroupName));
if (NS_FAILED(rv)) return rv;
if (!m_newsFolder || (m_key == nsMsgKey_None)) {
nsXPIDLCString uri;
nsCOMPtr <nsIMsgMessageUrl> msgUrl = do_QueryInterface(m_runningURL, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = CreateNewsFolderURI((const char *)m_userName,(const char *)m_hostName, (const char *)newsgroupName, getter_Copies(folderURI));
if (NS_FAILED(rv)) return rv;
rv = msgUrl->GetUri(getter_Copies(uri));
NS_ENSURE_SUCCESS(rv,rv);
rv = InitializeNewsFolderFromUri((const char *)folderURI);
if (NS_FAILED(rv)) return rv;
#ifdef DEBUG_seth
printf("SetNewsFolderAndMsgKey in nsNNTPProtocol with %s\n",(const char *)uri);
#endif
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIMsgFolder> folder;
rv = nntpService->DecomposeNewsURI((const char *)uri, getter_AddRefs(folder), &m_key);
NS_ENSURE_SUCCESS(rv,rv);
m_newsFolder = do_QueryInterface(folder, &rv);
NS_ENSURE_SUCCESS(rv,rv);
}
return NS_OK;
}
@@ -2697,7 +2657,7 @@ PRInt32 nsNNTPProtocol::BeginAuthorization()
PRInt32 status = 0;
nsXPIDLCString cachedUsername;
SetNewsFolder();
SetNewsFolderAndMsgKey();
if (m_newsFolder) {
rv = m_newsFolder->GetGroupUsername(getter_Copies(cachedUsername));
@@ -2777,7 +2737,7 @@ PRInt32 nsNNTPProtocol::AuthorizationResponse()
/* If we're here because the host demanded authentication before we
* even sent a single command, then jump back to the beginning of everything
*/
rv = m_newsHost->GetPushAuth(&pushAuth);
rv = m_nntpServer->GetPushAuth(&pushAuth);
if (!TestFlag(NNTP_READER_PERFORMED))
m_nextState = NNTP_SEND_MODE_READER;
@@ -2806,7 +2766,8 @@ PRInt32 nsNNTPProtocol::AuthorizationResponse()
nsXPIDLCString password;
nsXPIDLCString cachedPassword;
SetNewsFolder();
SetNewsFolderAndMsgKey();
if (m_newsFolder) {
rv = m_newsFolder->GetGroupPassword(getter_Copies(cachedPassword));
}
@@ -2899,7 +2860,7 @@ PRInt32 nsNNTPProtocol::PasswordResponse()
/* If we're here because the host demanded authentication before we
* even sent a single command, then jump back to the beginning of everything
*/
rv = m_newsHost->GetPushAuth(&pushAuth);
rv = m_nntpServer->GetPushAuth(&pushAuth);
if (!TestFlag(NNTP_READER_PERFORMED))
m_nextState = NNTP_SEND_MODE_READER;
@@ -2918,16 +2879,16 @@ PRInt32 nsNNTPProtocol::PasswordResponse()
m_nextState = SEND_FIRST_NNTP_COMMAND;
#endif /* HAVE_PUSH_AUTH_AND_EXTENSIONS */
// if we are posting, m_newsgroup will be null
if (!m_newsgroupList && m_newsgroup) {
nsXPIDLCString groupName;
rv = m_newsgroup->GetName(getter_Copies(groupName));
if (NS_SUCCEEDED(rv)) {
rv = m_newsHost->GetNewsgroupList(groupName, getter_AddRefs(m_newsgroupList));
}
// if we are posting, m_newsFolder will be null
if (!m_newsgroupList && m_newsFolder) {
m_newsgroupList = do_CreateInstance(NS_NNTPNEWSGROUPLIST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return -1;
rv = m_newsgroupList->Initialize(m_runningURL, m_newsFolder);
if (NS_FAILED(rv)) return -1;
}
if (m_newsgroupList) {
rv = m_newsgroupList->ResetXOVER();
rv = m_newsgroupList->ResetXOVER();
}
return(0);
}
@@ -3009,14 +2970,13 @@ PRInt32 nsNNTPProtocol::ProcessNewsgroups(nsIInputStream * inputStream, PRUint32
{
ClearFlag(NNTP_PAUSE_FOR_READ);
PRBool xactive=PR_FALSE;
rv = m_newsHost->QueryExtension("XACTIVE",&xactive);
rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
if (NS_SUCCEEDED(rv) && xactive)
{
char *groupName;
rv = m_newsHost->GetFirstGroupNeedingExtraInfo(&groupName);
if (NS_SUCCEEDED(rv) && m_newsgroup)
{
rv = m_newsHost->FindGroup(groupName, getter_AddRefs(m_newsgroup));
nsXPIDLCString groupName;
rv = m_nntpServer->GetFirstGroupNeedingExtraInfo(getter_Copies(groupName));
if (NS_SUCCEEDED(rv)) {
rv = m_nntpServer->FindGroup((const char *)groupName, getter_AddRefs(m_newsFolder));
NS_ASSERTION(NS_SUCCEEDED(rv), "FindGroup failed");
m_nextState = NNTP_LIST_XACTIVE;
PR_LOG(NNTP,PR_LOG_ALWAYS,("listing xactive for %s", groupName));
@@ -3085,20 +3045,18 @@ PRInt32 nsNNTPProtocol::ProcessNewsgroups(nsIInputStream * inputStream, PRUint32
mBytesReceived += status;
mBytesReceivedSinceLastStatusUpdate += status;
#endif
#if 0
m_newsHost->AddNewNewsgroup(line, oldest, youngest, flag, PR_FALSE);
#else
NS_ASSERTION(m_nntpServer, "no nntp incoming server");
if (m_nntpServer) {
rv = m_nntpServer->AddNewsgroupToList(line);
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
}
#endif /* 0 */
PRBool xactive=PR_FALSE;
rv = m_newsHost->QueryExtension("XACTIVE",&xactive);
rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
if (NS_SUCCEEDED(rv) && xactive)
{
m_newsHost->SetGroupNeedsExtraInfo(line, PR_TRUE);
m_nntpServer->SetGroupNeedsExtraInfo(line, PR_TRUE);
}
PR_FREEIF(line);
@@ -3145,7 +3103,7 @@ static void ComputeRate(PRInt32 bytes, PRTime startTime, float *rate)
// compute rate
if (delta > 0) {
*rate = (bytes * RATE_CONSTANT) / delta;
*rate = (float) ((bytes * RATE_CONSTANT) / delta);
}
else {
*rate = 0.0;
@@ -3179,7 +3137,7 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng
if (line[0]=='.' && line[1]=='\0')
{
PRBool listpnames=PR_FALSE;
rv = m_newsHost->QueryExtension("LISTPNAMES",&listpnames);
rv = m_nntpServer->QueryExtension("LISTPNAMES",&listpnames);
if (NS_SUCCEEDED(rv) && listpnames)
m_nextState = NNTP_LIST_PRETTY_NAMES;
else
@@ -3260,9 +3218,6 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng
line[i] = 0; /* terminate group name */
/* store all the group names */
#if 0
m_newsHost->AddNewNewsgroup(line, 0, 0, "", PR_FALSE);
#else
NS_ASSERTION(m_nntpServer, "no nntp incoming server");
if (m_nntpServer) {
m_readNewsListCount++;
@@ -3273,7 +3228,6 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng
else {
rv = NS_ERROR_FAILURE;
}
#endif /* 0 */
if (m_readNewsListCount == READ_NEWS_LIST_COUNT_MAX) {
m_readNewsListCount = 0;
@@ -3341,13 +3295,13 @@ PRInt32 nsNNTPProtocol::BeginReadXover()
&m_firstPossibleArticle,
&m_lastPossibleArticle);
/* We now know there is a summary line there; make sure it has the
right numbers in it. */
rv = m_newsHost->DisplaySubscribedGroup(m_newsgroup,
m_firstPossibleArticle,
m_lastPossibleArticle,
count, PR_TRUE);
m_newsgroupList = do_CreateInstance(NS_NNTPNEWSGROUPLIST_CONTRACTID, &rv);
if (NS_FAILED(rv)) return -1;
rv = m_newsgroupList->Initialize(m_runningURL, m_newsFolder);
if (NS_FAILED(rv)) return -1;
rv = m_newsFolder->UpdateSummaryFromNNTPInfo(m_firstPossibleArticle, m_lastPossibleArticle, count);
if (NS_FAILED(rv)) return -1;
m_numArticlesLoaded = 0;
@@ -3366,14 +3320,6 @@ PRInt32 nsNNTPProtocol::FigureNextChunk()
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
if (m_firstArticle > 0)
{
nsXPIDLCString groupName;
rv = m_newsgroup->GetName(getter_Copies(groupName));
/* XXX - parse state stored in MSG_Pane cd->pane */
if (NS_SUCCEEDED(rv))
rv = m_newsHost->GetNewsgroupList(groupName, getter_AddRefs(m_newsgroupList));
PR_LOG(NNTP,PR_LOG_ALWAYS,("add to known articles: %d - %d", m_firstArticle, m_lastArticle));
if (NS_SUCCEEDED(rv) && m_newsgroupList) {
@@ -3392,32 +3338,26 @@ PRInt32 nsNNTPProtocol::FigureNextChunk()
return 0;
}
if (!m_newsgroupList) {
nsXPIDLCString groupName;
rv = m_newsgroup->GetName(getter_Copies(groupName));
if (NS_SUCCEEDED(rv))
rv = m_newsHost->GetNewsgroupList(groupName, getter_AddRefs(m_newsgroupList));
}
NS_ASSERTION(m_newsgroupList, "yikes");
if (!m_newsgroupList) return -1;
if (NS_SUCCEEDED(rv) && m_newsgroupList) {
PRBool getOldMessages = PR_FALSE;
if (m_runningURL) {
rv = m_runningURL->GetGetOldMessages(&getOldMessages);
if (NS_FAILED(rv)) return status;
}
rv = m_newsgroupList->SetGetOldMessages(getOldMessages);
if (NS_FAILED(rv)) return status;
rv = m_newsgroupList->GetRangeOfArtsToDownload(m_msgWindow,
m_firstPossibleArticle,
m_lastPossibleArticle,
m_numArticlesWanted -
m_numArticlesLoaded,
&(m_firstArticle),
&(m_lastArticle),
&status);
PRBool getOldMessages = PR_FALSE;
if (m_runningURL) {
rv = m_runningURL->GetGetOldMessages(&getOldMessages);
if (NS_FAILED(rv)) return status;
}
rv = m_newsgroupList->SetGetOldMessages(getOldMessages);
if (NS_FAILED(rv)) return status;
rv = m_newsgroupList->GetRangeOfArtsToDownload(m_msgWindow,
m_firstPossibleArticle,
m_lastPossibleArticle,
m_numArticlesWanted -
m_numArticlesLoaded,
&(m_firstArticle),
&(m_lastArticle),
&status);
}
if (NS_FAILED(rv)) return status;
@@ -3580,14 +3520,14 @@ PRInt32 nsNNTPProtocol::ProcessXover()
PRInt32 status = 0;
/* xover_parse_state stored in MSG_Pane cd->pane */
if (!m_newsgroupList) {
return NS_ERROR_NULL_POINTER;
}
NS_ASSERTION(m_newsgroupList, "yikes");
if (!m_newsgroupList) return -1;
rv = m_newsgroupList->FinishXOVERLINE(0,&status);
if (NS_SUCCEEDED(rv) && status < 0) return status;
m_newsgroupList = nsnull;
m_nextState = NEWS_DONE;
return(MK_DATA_LOADED);
@@ -3635,6 +3575,8 @@ PRInt32 nsNNTPProtocol::ReadNewsgroupResponse()
if(m_messageID)
*m_messageID = '\0';
m_key = nsMsgKey_None;
/* Give the message number to the header parser. */
rv = m_newsgroupList->ProcessNonXOVER(m_responseText);
/* convert nsresult->status */
@@ -4094,7 +4036,7 @@ PRInt32 nsNNTPProtocol::DisplayNewsRCResponse()
}
else if (m_responseCode == MK_NNTP_RESPONSE_GROUP_NO_GROUP)
{
m_newsHost->GroupNotFound(m_currentGroup, PR_FALSE);
m_nntpServer->GroupNotFound(m_currentGroup, PR_FALSE);
}
/* it turns out subscribe ui depends on getting this displaysubscribedgroup call,
even if there was an error.
@@ -4212,7 +4154,7 @@ PRInt32 nsNNTPProtocol::DoCancel()
MSG_CompositionFields *fields = NULL;
#endif
SetNewsFolder();
SetNewsFolderAndMsgKey();
/* #### Should we do a more real check than this? If the POST command
didn't respond with "MK_NNTP_RESPONSE_POST_SEND_NOW Ok", then it's not ready for us to throw a
@@ -4272,7 +4214,7 @@ PRInt32 nsNNTPProtocol::DoCancel()
Don't do this if server tells us it will validate user. DMB 3/19/97
*/
PRBool cancelchk=PR_FALSE;
rv = m_newsHost->QueryExtension("CANCELCHK",&cancelchk);
rv = m_nntpServer->QueryExtension("CANCELCHK",&cancelchk);
if (NS_SUCCEEDED(rv) && !cancelchk) {
NNTP_LOG_NOTE("CANCELCHK not supported");
@@ -4397,13 +4339,11 @@ PRInt32 nsNNTPProtocol::DoCancel()
if (!m_runningURL) return -1;
// delete the message from the db here.
nsMsgKey key = nsMsgKey_None;
rv = m_runningURL->GetMessageKey(&key);
NS_ASSERTION(NS_SUCCEEDED(rv) && m_newsFolder && (key != nsMsgKey_None), "need more to remove this message from the db");
if ((key != nsMsgKey_None) && (m_newsFolder)) {
rv = m_newsFolder->RemoveMessage(key);
// delete the message from the db here.
NS_ASSERTION(NS_SUCCEEDED(rv) && m_newsFolder && (m_key != nsMsgKey_None), "need more to remove this message from the db");
if ((m_key != nsMsgKey_None) && (m_newsFolder)) {
rv = m_newsFolder->RemoveMessage(m_key);
}
}
@@ -4544,7 +4484,7 @@ PRInt32 nsNNTPProtocol::ListPrettyNames()
char outputBuffer[OUTPUT_BUFFER_SIZE];
PRInt32 status = 0;
nsresult rv = m_newsgroup->GetName(getter_Copies(group_name));
nsresult rv = m_newsFolder->GetAsciiName(getter_Copies(group_name));
PR_snprintf(outputBuffer,
OUTPUT_BUFFER_SIZE,
"LIST PRETTYNAMES %.512s" CRLF,
@@ -4601,7 +4541,7 @@ PRInt32 nsNNTPProtocol::ListPrettyNamesResponse(nsIInputStream * inputStream, PR
line[i] = 0; /* terminate group name */
if (i > 0)
m_newsHost->SetPrettyName(line,prettyName);
m_nntpServer->SetPrettyName(line, prettyName);
PR_LOG(NNTP,PR_LOG_ALWAYS,("adding pretty name %s", prettyName));
}
@@ -4621,9 +4561,10 @@ PRInt32 nsNNTPProtocol::ListPrettyNamesResponse(nsIInputStream * inputStream, PR
PRInt32 nsNNTPProtocol::ListXActive()
{
nsXPIDLCString group_name;
nsresult rv;
rv = m_newsgroup->GetName(getter_Copies(group_name));
// XXX: check rv?
nsresult rv;
rv = m_newsFolder->GetAsciiName(getter_Copies(group_name));
if (NS_FAILED(rv)) return -1;
PRInt32 status = 0;
char outputBuffer[OUTPUT_BUFFER_SIZE];
@@ -4699,17 +4640,12 @@ PRInt32 nsNNTPProtocol::ListXActiveResponse(nsIInputStream * inputStream, PRUint
&m_lastPossibleArticle,
flags);
#if 0
m_newsHost->AddNewNewsgroup(line,
m_firstPossibleArticle,
m_lastPossibleArticle, flags, PR_TRUE);
#else
NS_ASSERTION(m_nntpServer, "no nntp incoming server");
if (m_nntpServer) {
rv = m_nntpServer->AddNewsgroupToList(line);
NS_ASSERTION(NS_SUCCEEDED(rv),"failed to add to subscribe ds");
}
#endif /* 0 */
/* we're either going to list prettynames first, or list
all prettynames every time, so we won't care so much
@@ -4725,19 +4661,22 @@ PRInt32 nsNNTPProtocol::ListXActiveResponse(nsIInputStream * inputStream, PRUint
else
{
PRBool xactive=PR_FALSE;
rv = m_newsHost->QueryExtension("XACTIVE",&xactive);
rv = m_nntpServer->QueryExtension("XACTIVE",&xactive);
if (m_typeWanted == NEW_GROUPS &&
NS_SUCCEEDED(rv) && xactive)
{
nsCOMPtr <nsINNTPNewsgroup> old_newsgroup;
old_newsgroup = m_newsgroup;
char *groupName;
nsCOMPtr <nsIMsgNewsFolder> old_newsFolder;
old_newsFolder = m_newsFolder;
nsXPIDLCString groupName;
m_newsHost->GetFirstGroupNeedingExtraInfo(&groupName);
m_newsHost->FindGroup(groupName, getter_AddRefs(m_newsgroup));
rv = m_nntpServer->GetFirstGroupNeedingExtraInfo(getter_Copies(groupName));
if (NS_FAILED(rv)) return -1;
rv = m_nntpServer->FindGroup(groupName, getter_AddRefs(m_newsFolder));
if (NS_FAILED(rv)) return -1;
// see if we got a different group
if (old_newsgroup && m_newsgroup &&
(old_newsgroup != m_newsgroup))
if (old_newsFolder && m_newsFolder &&
(old_newsFolder.get() != m_newsFolder.get()))
/* make sure we're not stuck on the same group */
{
PR_LOG(NNTP,PR_LOG_ALWAYS,("listing xactive for %s", groupName));
@@ -4748,11 +4687,11 @@ PRInt32 nsNNTPProtocol::ListXActiveResponse(nsIInputStream * inputStream, PRUint
}
else
{
m_newsgroup = null_nsCOMPtr();
m_newsFolder = nsnull;
}
}
PRBool listpname;
rv = m_newsHost->QueryExtension("LISTPNAME",&listpname);
rv = m_nntpServer->QueryExtension("LISTPNAME",&listpname);
if (NS_SUCCEEDED(rv) && listpname)
m_nextState = NNTP_LIST_PRETTY_NAMES;
else
@@ -4784,7 +4723,7 @@ PRInt32 nsNNTPProtocol::ListGroup()
getter_AddRefs(m_articleList));
NS_ENSURE_SUCCESS(rv,rv);
rv = m_articleList->Initialize(m_newsHost, m_newsgroup);
rv = m_articleList->Initialize(m_newsFolder);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIMsgMailNewsUrl> mailnewsurl = do_QueryInterface(m_runningURL);
@@ -4832,6 +4771,8 @@ PRInt32 nsNNTPProtocol::ListGroupResponse(nsIInputStream * inputStream, PRUint32
}
else
{
m_articleList->FinishAddingArticleKeys();
m_articleList = nsnull;
m_nextState = NEWS_DONE; /* ### dmb - don't really know */
ClearFlag(NNTP_PAUSE_FOR_READ);
PR_FREEIF(line);
@@ -5377,10 +5318,19 @@ nsresult nsNNTPProtocol::ProcessProtocolState(nsIURI * url, nsIInputStream * inp
NS_IMETHODIMP nsNNTPProtocol::CloseConnection()
{
SendData(nsnull, NNTP_CMD_QUIT); // this will cause OnStopRequest get called, which will call CloseSocket()
SendData(nsnull, NNTP_CMD_QUIT); // this will cause OnStopRequest get called, which will call CloseSocket()
// break some cycles
m_newsHost = nsnull;
m_newsgroupList = nsnull;
m_nntpServer = nsnull;
m_newsFolder = nsnull;
if (m_articleList) {
m_articleList->FinishAddingArticleKeys();
m_articleList = nsnull;
}
m_key = nsMsgKey_None;
return NS_OK;
}
@@ -5408,15 +5358,9 @@ nsresult nsNNTPProtocol::CleanupAfterRunningUrl()
if (m_newsgroupList)
{
int status;
/* XXX - how/when to Release() this? */
rv = m_newsgroupList->FinishXOVERLINE(0,&status);
NS_ASSERTION(NS_SUCCEEDED(rv), "FinishXOVERLINE failed");
}
else
{
/* XXX - state is stored in the newshost - should
we be releasing it here? */
/* NS_RELEASE(m_newsgroup->GetNewsgroupList()); */
m_newsgroupList = nsnull;
}
// clear out mem cache entry so we're not holding onto it.
@@ -5492,7 +5436,7 @@ NS_IMETHODIMP nsNNTPProtocol::GetContentType(char * *aContentType)
// otherwise do what we did before...
if (m_typeWanted != ARTICLE_WANTED && !m_currentGroup.IsEmpty() &&
if (m_key == nsMsgKey_None && m_typeWanted != ARTICLE_WANTED && !m_currentGroup.IsEmpty() &&
// if it is an article url, it has a @ or %40 in it.
m_currentGroup.FindChar('@') == kNotFound && m_currentGroup.Find("%40") == kNotFound) {
*aContentType = nsCRT::strdup("x-application-newsgroup");

View File

@@ -36,8 +36,6 @@
#include "nsINNTPNewsgroupList.h"
#include "nsINNTPArticleList.h"
#include "nsINNTPHost.h"
#include "nsINNTPNewsgroup.h"
#include "nsIMsgOfflineNewsState.h"
#include "nsIMsgNewsFolder.h"
#include "nsIMsgWindow.h"
@@ -192,8 +190,6 @@ private:
// News Event Sinks
nsCOMPtr <nsINNTPNewsgroupList> m_newsgroupList;
nsCOMPtr <nsINNTPArticleList> m_articleList;
nsCOMPtr <nsINNTPHost> m_newsHost;
nsCOMPtr <nsINNTPNewsgroup> m_newsgroup;
nsCOMPtr <nsIMsgOfflineNewsState> m_offlineNewsState;
nsCOMPtr <nsIMsgNewsFolder> m_newsFolder;
@@ -397,7 +393,7 @@ private:
nsresult SetProgressStatus(const PRUnichar *aMessage);
nsresult SetCheckingForNewNewsStatus(PRInt32 current, PRInt32 total);
nsresult MarkCurrentMsgRead(); // marks the message corresponding to the currently running url read.
nsresult SetNewsFolder(); /* sets m_newsFolder, if not already set */
nsresult SetNewsFolderAndMsgKey(); /* sets m_newsFolder (if not already set) and m_key from the running url */
nsresult CreateNewsFolderURI (const char *username, const char *hostname, const char *newsgroupname, char **uri);
nsresult InitializeNewsFolderFromUri(const char *uri);
void TimerCallback();
@@ -408,6 +404,8 @@ private:
PRInt32 mBytesReceivedSinceLastStatusUpdate;
PRTime m_startTime;
PRInt32 mNumGroupsListed;
nsMsgKey m_key;
};
NS_BEGIN_EXTERN_C

View File

@@ -33,8 +33,6 @@
// This file contains the news article download state machine.
static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID);
// if pIds is not null, download the articles whose id's are passed in. Otherwise,
// which articles to download is determined by nsNewsDownloader object,
@@ -108,7 +106,7 @@ nsresult nsNewsDownloader::DownloadNext(PRBool firstTimeP)
StartDownload();
m_wroteAnyP = PR_FALSE;
NS_WITH_SERVICE(nsINntpService, nntpService, kNntpServiceCID, &rv);
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID,&rv);
NS_ENSURE_SUCCESS(rv, rv);
return nntpService->FetchMessage(m_folder, m_keyToDownload, m_window, nsnull, this, nsnull);

View File

@@ -27,6 +27,7 @@
#include "prlog.h"
#include "msgCore.h" // precompiled header...
#include "nntpCore.h"
#include "nsNewsFolder.h"
#include "nsMsgFolderFlags.h"
@@ -71,12 +72,13 @@
#include "nsReadableUtils.h"
#include "nsNewsDownloader.h"
#include "nsIStringBundle.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
// that multiply inherits from nsISupports
static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
static NS_DEFINE_CID(kRDFServiceCID, NS_RDFSERVICE_CID);
static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID);
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
static NS_DEFINE_CID(kMsgMailSessionCID, NS_MSGMAILSESSION_CID);
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
@@ -100,7 +102,7 @@ static NS_DEFINE_CID(kNetSupportDialogCID, NS_NETSUPPORTDIALOG_CID);
nsMsgNewsFolder::nsMsgNewsFolder(void) : nsMsgLineBuffer(nsnull, PR_FALSE),
mExpungedBytes(0), mGettingNews(PR_FALSE),
mInitialized(PR_FALSE), mOptionLines(""), mUnsubscribedNewsgroupLines(""),
m_downloadMessageForOfflineUse(PR_FALSE), mCachedNewsrcLine(nsnull), mGroupUsername(nsnull), mGroupPassword(nsnull)
m_downloadMessageForOfflineUse(PR_FALSE), mCachedNewsrcLine(nsnull), mGroupUsername(nsnull), mGroupPassword(nsnull), mAsciiName(nsnull)
{
MOZ_COUNT_CTOR(nsNewsFolder); // double count these for now.
/* we're parsing the newsrc file, and the line breaks are platform specific.
@@ -120,6 +122,7 @@ nsMsgNewsFolder::~nsMsgNewsFolder(void)
PR_FREEIF(mCachedNewsrcLine);
PR_FREEIF(mGroupUsername);
PR_FREEIF(mGroupPassword);
PR_FREEIF(mAsciiName);
}
NS_IMPL_ADDREF_INHERITED(nsMsgNewsFolder, nsMsgDBFolder)
@@ -902,30 +905,58 @@ NS_IMETHODIMP nsMsgNewsFolder::GetSizeOnDisk(PRUint32 *size)
}
/* this is news, so remember that DeleteMessage is really CANCEL */
NS_IMETHODIMP nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages,
nsIMsgWindow *aMsgWindow, PRBool deleteStorage,
PRBool isMove)
NS_IMETHODIMP
nsMsgNewsFolder::DeleteMessages(nsISupportsArray *messages, nsIMsgWindow *aMsgWindow,
PRBool deleteStorage, PRBool isMove)
{
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(messages);
NS_ENSURE_ARG_POINTER(aMsgWindow);
PRUint32 count = 0;
rv = messages->Count(&count);
NS_ENSURE_SUCCESS(rv,rv);
if (!messages) {
// nothing to CANCEL
return NS_ERROR_NULL_POINTER;
}
if (count != 1) {
nsCOMPtr<nsIStringBundleService> bundleService = do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
NS_WITH_SERVICE(nsINntpService, nntpService, kNntpServiceCID, &rv);
nsCOMPtr<nsIStringBundle> bundle;
rv = bundleService->CreateBundle(NEWS_MSGS_URL, nsnull, getter_AddRefs(bundle));
NS_ENSURE_SUCCESS(rv, rv);
nsXPIDLString alertText;
rv = bundle->GetStringFromName(NS_LITERAL_STRING("onlyCancelOneMessage"), getter_Copies(alertText));
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrompt> dialog;
rv = aMsgWindow->GetPromptDialog(getter_AddRefs(dialog));
NS_ENSURE_SUCCESS(rv,rv);
if (dialog) {
rv = dialog->Alert(nsnull, (const PRUnichar *) alertText);
NS_ENSURE_SUCCESS(rv,rv);
}
// return failure, since the cancel failed
return NS_ERROR_FAILURE;
}
if (NS_SUCCEEDED(rv) && nntpService) {
nsXPIDLCString hostname;
rv = GetHostname(getter_Copies(hostname));
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsXPIDLCString newsgroupname;
rv = GetAsciiName(getter_Copies(newsgroupname));
if (NS_FAILED(rv)) return rv;
rv = nntpService->CancelMessages((const char *)hostname, (const char *)newsgroupname, messages, nsnull /* consumer */, nsnull, aMsgWindow, nsnull);
}
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(0));
nsCOMPtr<nsIMsgDBHdr> msgHdr(do_QueryInterface(msgSupports));
nsXPIDLCString messageUri;
rv = GetUriForMsg(msgHdr, getter_Copies(messageUri));
NS_ENSURE_SUCCESS(rv,rv);
nsCAutoString cancelUrl((const char *)messageUri);
cancelUrl += "?cancel";
rv = nntpService->CancelMessage(cancelUrl.get(), nsnull /* consumer */, nsnull, aMsgWindow, nsnull);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
}
@@ -957,8 +988,8 @@ nsresult nsMsgNewsFolder::GetNewsMessages(nsIMsgWindow *aMsgWindow, PRBool aGetO
return NS_OK;
}
NS_WITH_SERVICE(nsINntpService, nntpService, kNntpServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsINntpIncomingServer> nntpServer;
rv = GetNntpServer(getter_AddRefs(nntpServer));
@@ -1595,15 +1626,21 @@ nsMsgNewsFolder::GetAsciiName(char **asciiName)
{
nsresult rv;
if (!asciiName) return NS_ERROR_NULL_POINTER;
NS_ENSURE_ARG_POINTER(asciiName);
if (!mAsciiName) {
nsXPIDLString name;
rv = GetName(getter_Copies(name));
NS_ENSURE_SUCCESS(rv,rv);
nsXPIDLString name;
rv = GetName(getter_Copies(name));
if (NS_FAILED(rv)) return rv;
// convert to ASCII
nsCAutoString tmpStr;
tmpStr.AssignWithConversion(name);
nsCAutoString tmpStr;
tmpStr.AssignWithConversion(name);
*asciiName = nsCRT::strdup((const char *)tmpStr);
mAsciiName = nsCRT::strdup(tmpStr.get());
if (!mAsciiName) return NS_ERROR_OUT_OF_MEMORY;
}
*asciiName = nsCRT::strdup(mAsciiName);
if (!*asciiName) return NS_ERROR_OUT_OF_MEMORY;
return NS_OK;
@@ -1753,4 +1790,3 @@ NS_IMETHODIMP nsMsgNewsFolder::Compact(nsIUrlListener *aListener)
}
return rv;
}

View File

@@ -134,6 +134,9 @@ protected:
char *mGroupUsername;
char *mGroupPassword;
// the name of the newsgroup.
char *mAsciiName;
private:
nsresult CreateNewsgroupUsernameUrlForSignon(const char *inUriStr, char **result);
nsresult CreateNewsgroupPasswordUrlForSignon(const char *inUriStr, char **result);

View File

@@ -61,7 +61,6 @@
#define HOSTINFO_FILE_BUFFER_SIZE 1024
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kNntpServiceCID, NS_NNTPSERVICE_CID);
static NS_DEFINE_CID(kSubscribableServerCID, NS_SUBSCRIBABLESERVER_CID);
NS_IMPL_ADDREF_INHERITED(nsNntpIncomingServer, nsMsgIncomingServer)
@@ -92,6 +91,9 @@ nsNntpIncomingServer::nsNntpIncomingServer() : nsMsgLineBuffer(nsnull, PR_FALSE)
mUniqueId = 0;
mPushAuth = PR_FALSE;
mHasSeenBeginGroups = PR_FALSE;
mPostingAllowed = PR_FALSE;
mLastUpdatedTime = 0;
SetupNewsrcSaveTimer();
}
@@ -566,16 +568,12 @@ NS_IMETHODIMP
nsNntpIncomingServer::PerformExpand(nsIMsgWindow *aMsgWindow)
{
nsresult rv;
#ifdef DEBUG_NEWS
printf("PerformExpand for nntp\n");
#endif
nsCOMPtr<nsINntpService> nntpService = do_GetService(kNntpServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (!nntpService) return NS_ERROR_FAILURE;
nsCOMPtr<nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = nntpService->UpdateCounts(this, aMsgWindow);
if (NS_FAILED(rv)) return rv;
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
}
@@ -965,9 +963,8 @@ nsNntpIncomingServer::StartPopulating(nsIMsgWindow *aMsgWindow, PRBool aForceToS
rv = SetShowFullName(PR_TRUE);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINntpService> nntpService = do_GetService(kNntpServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
if (!nntpService) return NS_ERROR_FAILURE;
nsCOMPtr<nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
mHostInfoLoaded = PR_FALSE;
mVersion = INVALID_VERSION;
@@ -1387,3 +1384,153 @@ nsNntpIncomingServer::ForgetPassword()
return return_rv;
}
NS_IMETHODIMP
nsNntpIncomingServer::GetSupportsExtensions(PRBool *aSupportsExtensions)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::SetSupportsExtensions(PRBool aSupportsExtensions)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::AddExtension(const char *extension)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::QueryExtension(const char *extension, PRBool *result)
{
#ifdef DEBUG_seth
printf("no extension support yet\n");
#endif
*result = PR_FALSE;
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::GetPostingAllowed(PRBool *aPostingAllowed)
{
*aPostingAllowed = mPostingAllowed;
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::SetPostingAllowed(PRBool aPostingAllowed)
{
mPostingAllowed = aPostingAllowed;
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::GetPushAuth(PRBool *aPushAuth)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::SetPushAuth(PRBool aPushAuth)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::GetLastUpdatedTime(PRUint32 *aLastUpdatedTime)
{
*aLastUpdatedTime = mLastUpdatedTime;
return NS_OK;
}
NS_IMETHODIMP
nsNntpIncomingServer::SetLastUpdatedTime(PRUint32 aLastUpdatedTime)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::AddPropertyForGet(const char *name, const char *value)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::QueryPropertyForGet(const char *name, char **value)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::AddSearchableGroup(const char *name)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::QuerySearchableGroup(const char *name, PRBool *result)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::AddSearchableHeader(const char *name)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::QuerySearchableHeader(const char *name, PRBool *result)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::FindGroup(const char *name, nsIMsgNewsFolder **result)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::GetFirstGroupNeedingExtraInfo(char **result)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::SetGroupNeedsExtraInfo(const char *name, PRBool needsExtraInfo)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::GroupNotFound(const char *name, PRBool opening)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsNntpIncomingServer::SetPrettyName(const char *name, const char *prettyName)
{
NS_ASSERTION(0,"not implemented");
return NS_ERROR_NOT_IMPLEMENTED;
}

View File

@@ -102,7 +102,9 @@ private:
PRTime mFirstNewDate;
PRInt32 mUniqueId;
PRBool mPushAuth;
PRUint32 mLastUpdatedTime;
PRInt32 mVersion;
PRBool mPostingAllowed;
nsCOMPtr<nsITimer> mNewsrcSaveTimer;
nsCOMPtr <nsIMsgWindow> mMsgWindow;

View File

@@ -35,7 +35,6 @@
#include "nsNewsUtils.h"
#include "nsNewsDatabase.h"
#include "nsMsgDBCID.h"
#include "nsNNTPNewsgroup.h"
#include "nsMsgBaseCID.h"
#include "nsMsgNewsCID.h"
#include "nsIPref.h"
@@ -68,7 +67,6 @@
static NS_DEFINE_CID(kCNntpUrlCID, NS_NNTPURL_CID);
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
static NS_DEFINE_CID(kCNNTPNewsgroupCID, NS_NNTPNEWSGROUP_CID);
static NS_DEFINE_CID(kCNNTPNewsgroupPostCID, NS_NNTPNEWSGROUPPOST_CID);
static NS_DEFINE_CID(kCPrefServiceCID, NS_PREF_CID);
static NS_DEFINE_CID(kMsgAccountManagerCID, NS_MSGACCOUNTMANAGER_CID);
@@ -112,48 +110,34 @@ nsNntpService::SaveMessageToDisk(const char *aMessageURI,
nsIMsgWindow *aMsgWindow)
{
nsresult rv = NS_OK;
if (!aMessageURI)
return NS_ERROR_NULL_POINTER;
#ifdef DEBUG_NEWS
printf("nsNntpService::SaveMessageToDisk(%s,...)\n",aMessageURI);
#endif
nsCAutoString uri;
nsCAutoString newsgroupName;
nsMsgKey key = nsMsgKey_None;
if (PL_strncmp(aMessageURI, kNewsMessageRootURI, kNewsMessageRootURILen) == 0) {
rv = ConvertNewsMessageURI2NewsURI(aMessageURI, uri, newsgroupName, nsnull, &key);
NS_ENSURE_SUCCESS(rv,rv);
}
else {
NS_ENSURE_ARG_POINTER(aMessageURI);
// double check it is a news_message:/ uri
if (PL_strncmp(aMessageURI, kNewsMessageRootURI, kNewsMessageRootURILen)) {
rv = NS_ERROR_UNEXPECTED;
NS_ENSURE_SUCCESS(rv,rv);
}
// now create a url with this uri spec
nsCOMPtr<nsIURI> myuri;
nsCOMPtr<nsIURI> url;
rv = ConstructNntpUrl(uri, newsgroupName, key, aUrlListener, aMsgWindow, getter_AddRefs(myuri));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsINntpUrl> nntpUrl = do_QueryInterface(myuri);
nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(myuri);
nntpUrl->SetNewsAction(nsINntpUrl::ActionSaveMessageToDisk);
if (msgUrl)
{
rv = ConstructNntpUrl(aMessageURI, aUrlListener, aMsgWindow, getter_AddRefs(url));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsINntpUrl> nntpUrl = do_QueryInterface(url);
nsCOMPtr<nsIMsgMessageUrl> msgUrl = do_QueryInterface(url);
nntpUrl->SetNewsAction(nsINntpUrl::ActionSaveMessageToDisk);
if (msgUrl) {
msgUrl->SetMessageFile(aFile);
msgUrl->SetAddDummyEnvelope(aAddDummyEnvelope);
msgUrl->SetCanonicalLineEnding(canonicalLineEnding);
}
msgUrl->SetAddDummyEnvelope(aAddDummyEnvelope);
msgUrl->SetCanonicalLineEnding(canonicalLineEnding);
}
rv = RunNewsUrl(myuri, nsnull, nsnull);
}
rv = RunNewsUrl(url, nsnull, nsnull);
NS_ENSURE_SUCCESS(rv,rv);
if (aURL)
{
*aURL = myuri;
*aURL = url;
NS_IF_ADDREF(*aURL);
}
@@ -167,34 +151,25 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(aMessageURI);
nsCAutoString uri;
nsCAutoString newsgroupName;
nsMsgKey key = nsMsgKey_None;
nsCOMPtr <nsIMsgNewsFolder> newsFolder;
if (PL_strncmp(aMessageURI, kNewsMessageRootURI, kNewsMessageRootURILen) == 0) {
rv = ConvertNewsMessageURI2NewsURI(aMessageURI, uri, newsgroupName, getter_AddRefs(newsFolder), &key);
NS_ENSURE_SUCCESS(rv,rv);
}
else {
#ifdef DEBUG_seth
printf("todo: if we get here, make sure uri really a news article url (example: news://host/aa@bb\n");
#endif
uri = aMessageURI;
}
// now create a url with this uri spec
nsCOMPtr<nsIURI> myuri;
nsCAutoString uri(aMessageURI);
// rhp: If we are displaying this message for the purposes of printing, append
// the magic operand.
if (mPrintingOperation)
uri.Append("?header=print");
rv = ConstructNntpUrl(uri, newsgroupName, key, aUrlListener, aMsgWindow, getter_AddRefs(myuri));
nsCOMPtr<nsIURI> url;
rv = ConstructNntpUrl(uri.get(), aUrlListener, aMsgWindow, getter_AddRefs(url));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIMsgFolder> folder;
nsMsgKey key = nsMsgKey_None;
rv = DecomposeNewsMessageURI(uri.get(), getter_AddRefs(folder), &key);
NS_ENSURE_SUCCESS(rv,rv);
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsINntpUrl> nntpUrl (do_QueryInterface(myuri));
nsCOMPtr<nsINntpUrl> nntpUrl (do_QueryInterface(url));
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl (do_QueryInterface(nntpUrl));
msgUrl->SetMsgWindow(aMsgWindow);
nntpUrl->SetNewsAction(nsINntpUrl::ActionDisplayArticle);
@@ -205,10 +180,10 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
PRBool shouldStoreMsgOffline = PR_FALSE;
PRBool hasMsgOffline = PR_FALSE;
if (newsFolder)
if (folder)
{
nsCOMPtr <nsIMsgFolder> folder = do_QueryInterface(newsFolder);
if (folder)
nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(folder);
if (newsFolder)
{
folder->ShouldStoreMsgOffline(key, &shouldStoreMsgOffline);
folder->HasMsgOffline(key, &hasMsgOffline);
@@ -226,7 +201,6 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
}
}
newsFolder->SetSaveArticleOffline(shouldStoreMsgOffline);
}
// now is where our behavior differs....if the consumer is the docshell then we want to
@@ -242,15 +216,15 @@ nsNntpService::DisplayMessage(const char* aMessageURI, nsISupports * aDisplayCon
docShell->CreateLoadInfo(getter_AddRefs(loadInfo));
loadInfo->SetLoadType(nsIDocShellLoadInfo::loadLink);
}
rv = docShell->LoadURI(myuri, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE);
rv = docShell->LoadURI(url, loadInfo, nsIWebNavigation::LOAD_FLAGS_NONE);
}
else {
rv = RunNewsUrl(myuri, aMsgWindow, aDisplayConsumer);
rv = RunNewsUrl(url, aMsgWindow, aDisplayConsumer);
}
}
if (aURL) {
*aURL = myuri;
*aURL = url;
NS_IF_ADDREF(*aURL);
}
@@ -263,15 +237,11 @@ nsNntpService::FetchMessage(nsIMsgFolder *newsFolder, nsMsgKey key, nsIMsgWindow
nsresult rv = NS_OK;
NS_ENSURE_ARG_POINTER(newsFolder);
nsCString uri;
nsCString newsgroupName;
nsXPIDLCString msgUri;
// now create a url for the message
nsCOMPtr<nsIMsgNewsFolder> msgNewsFolder = do_QueryInterface(newsFolder);
if (!msgNewsFolder)
return NS_ERROR_INVALID_ARG;
// msgNewsFolder->GetAsciiName(getter_Copies(newsgroupName));
nsCOMPtr<nsIMsgDatabase> db;
nsCOMPtr<nsIMsgDBHdr> msgHdr;
@@ -281,24 +251,23 @@ nsNntpService::FetchMessage(nsIMsgFolder *newsFolder, nsMsgKey key, nsIMsgWindow
if (!NS_SUCCEEDED(rv) || !msgHdr)
return NS_ERROR_INVALID_ARG;
newsFolder->GetUriForMsg(msgHdr, getter_Copies(msgUri));
nsCOMPtr<nsIURI> myuri;
nsXPIDLCString uri;
newsFolder->GetUriForMsg(msgHdr, getter_Copies(uri));
nsCOMPtr<nsIURI> url;
rv = ConvertNewsMessageURI2NewsURI(msgUri, uri, newsgroupName, nsnull, &key);
rv = ConstructNntpUrl(uri, newsgroupName, key, aUrlListener, aMsgWindow, getter_AddRefs(myuri));
rv = ConstructNntpUrl((const char *)uri, aUrlListener, aMsgWindow, getter_AddRefs(url));
if (NS_SUCCEEDED(rv))
{
nsCOMPtr<nsINntpUrl> nntpUrl (do_QueryInterface(myuri));
nsCOMPtr<nsINntpUrl> nntpUrl (do_QueryInterface(url));
nsCOMPtr<nsIMsgMailNewsUrl> msgUrl (do_QueryInterface(nntpUrl));
msgUrl->SetMsgWindow(aMsgWindow);
nntpUrl->SetNewsAction(nsINntpUrl::ActionDisplayArticle);
rv = RunNewsUrl(myuri, aMsgWindow, aConsumer);
rv = RunNewsUrl(url, aMsgWindow, aConsumer);
}
if (aURL)
{
*aURL = myuri;
*aURL = url;
NS_IF_ADDREF(*aURL);
}
@@ -331,16 +300,13 @@ NS_IMETHODIMP nsNntpService::OpenAttachment(const char *aContentType,
NS_IMETHODIMP nsNntpService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL, nsIMsgWindow *aMsgWindow)
{
nsresult rv = NS_OK;
nsCAutoString uri;
nsCAutoString newsgroupName;
nsMsgKey key = nsMsgKey_None;
NS_ENSURE_ARG_POINTER(aMessageURI);
// double check that it is a news_message:/ uri
if (PL_strncmp(aMessageURI, kNewsMessageRootURI, kNewsMessageRootURILen) == 0)
{
rv = ConvertNewsMessageURI2NewsURI(aMessageURI, uri, newsgroupName, nsnull, &key);
NS_ENSURE_SUCCESS(rv,rv);
rv = ConstructNntpUrl(uri, newsgroupName, key, nsnull, aMsgWindow, aURL);
rv = ConstructNntpUrl(aMessageURI, nsnull, aMsgWindow, aURL);
NS_ENSURE_SUCCESS(rv,rv);
}
else {
@@ -352,6 +318,23 @@ NS_IMETHODIMP nsNntpService::GetUrlForUri(const char *aMessageURI, nsIURI **aURL
}
NS_IMETHODIMP
nsNntpService::DecomposeNewsURI(const char *uri, nsIMsgFolder **folder, nsMsgKey *aMsgKey)
{
nsresult rv;
if (nsCRT::strncmp(uri, kNewsMessageRootURI, kNewsMessageRootURILen) == 0) {
rv = DecomposeNewsMessageURI(uri, folder, aMsgKey);
NS_ENSURE_SUCCESS(rv,rv);
}
else {
rv = GetFolderFromUri(uri, folder);
NS_ENSURE_SUCCESS(rv,rv);
*aMsgKey = nsMsgKey_None;
}
return rv;
}
nsresult
nsNntpService::DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder ** aFolder, nsMsgKey *aMsgKey)
{
@@ -361,19 +344,32 @@ nsNntpService::DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder **
nsresult rv = NS_OK;
nsCAutoString folderURI;
rv = nsParseNewsMessageURI(aMessageURI, folderURI, aMsgKey);
NS_ENSURE_SUCCESS(rv,rv);
rv = GetFolderFromUri(folderURI, aFolder);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
}
nsresult
nsNntpService::GetFolderFromUri(const char *uri, nsIMsgFolder **folder)
{
nsresult rv;
nsCOMPtr <nsIRDFService> rdf = do_GetService("@mozilla.org/rdf/rdf-service;1",&rv);
NS_ENSURE_SUCCESS(rv,rv);
// if this is a message uri, we need
// m_currentGroup.FindChar('@') == kNotFound && m_currentGroup.Find("%40") == kNotFound) {
nsCOMPtr<nsIRDFResource> res;
rv = rdf->GetResource(folderURI, getter_AddRefs(res));
rv = rdf->GetResource(uri, getter_AddRefs(res));
NS_ENSURE_SUCCESS(rv,rv);
rv = res->QueryInterface(NS_GET_IID(nsIMsgFolder), (void **) aFolder);
rv = res->QueryInterface(NS_GET_IID(nsIMsgFolder), (void **)folder);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
}
@@ -632,14 +628,6 @@ nsNntpService::SetUpNntpUrlForPosting(nsINntpUrl *nntpUrl, const char *newsgroup
host = "news";
}
// if the user tried to post to one newsgroup, set that information in the
// nntp url. this can save them an authentication, if they've already logged in
// and we have that information in the single signon database
if ((numGroups == 1) && ((const char *)currentGroup)) {
rv = nntpUrl->SetNewsgroupName((const char *)currentGroup);
if (NS_FAILED(rv)) return rv;
}
*newsUrlSpec = PR_smprintf("%s/%s",kNewsRootURI,(const char *)host);
if (!*newsUrlSpec) return NS_ERROR_FAILURE;
@@ -826,8 +814,8 @@ nsNntpService::PostMessage(nsIFileSpec *fileToPost, const char *newsgroupsNames,
return rv;
}
nsresult nsNntpService::ConstructNntpUrl(const char * urlString, const char * newsgroupName, nsMsgKey key, nsIUrlListener *aUrlListener,
nsIMsgWindow * aMsgWindow, nsIURI ** aUrl)
nsresult
nsNntpService::ConstructNntpUrl(const char * urlString, nsIUrlListener *aUrlListener, nsIMsgWindow * aMsgWindow, nsIURI ** aUrl)
{
nsCOMPtr <nsINntpUrl> nntpUrl;
nsresult rv = NS_OK;
@@ -841,26 +829,6 @@ nsresult nsNntpService::ConstructNntpUrl(const char * urlString, const char * ne
msgUrl->SetUri(urlString);
mailnewsurl->SetSpec(urlString);
if (newsgroupName != "") {
nsCOMPtr <nsINNTPNewsgroup> newsgroup;
rv = nsComponentManager::CreateInstance(kCNNTPNewsgroupCID, nsnull, NS_GET_IID(nsINNTPNewsgroup), getter_AddRefs(newsgroup));
if (NS_FAILED(rv) || !newsgroup) return rv;
rv = newsgroup->Initialize(newsgroupName, nsnull /* set */, PR_TRUE);
if (NS_FAILED(rv)) return rv;
rv = nntpUrl->SetNewsgroup(newsgroup);
if (NS_FAILED(rv)) return rv;
// if we are running a news url to display a message, these
// will be used later, to mark the message as read after we finish loading
rv = nntpUrl->SetMessageKey(key);
if (NS_FAILED(rv)) return rv;
rv = nntpUrl->SetNewsgroupName((char *) newsgroupName);
if (NS_FAILED(rv)) return rv;
}
if (aUrlListener) // register listener if there is one...
mailnewsurl->RegisterListener(aUrlListener);
@@ -1066,168 +1034,74 @@ NS_IMETHODIMP nsNntpService::GetNewNews(nsINntpIncomingServer *nntpServer, const
{
if (!uri) return NS_ERROR_NULL_POINTER;
#ifdef DEBUG_NEWS
printf("nsNntpService::GetNewNews(%s)\n", uri);
#endif
NS_LOCK_INSTANCE();
nsresult rv = NS_OK;
nsXPIDLCString nntpHostName;
nsCOMPtr<nsIMsgIncomingServer> server;
server = do_QueryInterface(nntpServer);
// convert normal host to nntp host.
// XXX - this doesn't handle QI failing very well
if (server) {
// load up required server information
server->GetHostName(getter_Copies(nntpHostName));
}
#ifdef DEBUG_NEWS
else {
printf("server == nsnull\n");
}
#endif
#ifdef DEBUG_NEWS
if (nntpHostName) {
printf("get news from news://%s\n", (const char *) nntpHostName);
}
else {
printf("nntpHostName is null\n");
}
#endif
/* double check that it is a "news:/" url */
if (nsCRT::strncmp(uri, kNewsRootURI, kNewsRootURILen) == 0) {
nsCOMPtr<nsIURI> aUrl;
rv = ConstructNntpUrl(uri, aUrlListener, aMsgWindow, getter_AddRefs(aUrl));
if (NS_FAILED(rv)) return rv;
nsCAutoString uriStr(uri);
nsCAutoString newsgroupName;
NS_ASSERTION((uriStr.Find(kNewsRootURI) == 0), "uriStr didn't start with news:/");
if (uriStr.Find(kNewsRootURI) == 0) {
// uriStr looks like this:
// "news://news.mcom.com/mcom.linux"
// or this:
// "news://sspitzer@news.mcom.com/mcom.linux"
PRInt32 atPos = uriStr.FindChar('@');
if (atPos == -1) {
uriStr.Right(newsgroupName, uriStr.Length() - kNewsRootURILen /* for news:/ */ - 1 /* for the slash */ - PL_strlen(nntpHostName) /* for the hostname */ -1 /* for the next slash */);
}
else {
uriStr.Right(newsgroupName, uriStr.Length() - atPos /* for "news://<username>" */ -1 /* for the @ */ - PL_strlen(nntpHostName) /* for the hostname */ -1 /* for the next slash */);
}
nsCOMPtr<nsIURI> aUrl;
rv = ConstructNntpUrl(uriStr, newsgroupName, nsMsgKey_None, aUrlListener, aMsgWindow, getter_AddRefs(aUrl));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINntpUrl> nntpUrl = do_QueryInterface(aUrl);
if (nntpUrl) {
rv = nntpUrl->SetNewsAction(nsINntpUrl::ActionGetNewNews);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINntpUrl> nntpUrl = do_QueryInterface(aUrl);
if (nntpUrl) {
rv = nntpUrl->SetNewsAction(nsINntpUrl::ActionGetNewNews);
if (NS_FAILED(rv)) return rv;
rv = nntpUrl->SetGetOldMessages(aGetOld);
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(aUrl);
if (mailNewsUrl)
{
mailNewsUrl->SetUpdatingFolder(PR_TRUE);
mailNewsUrl->SetMsgWindow(aMsgWindow);
}
rv = nntpUrl->SetGetOldMessages(aGetOld);
if (NS_FAILED(rv)) return rv;
}
nsCOMPtr<nsIMsgMailNewsUrl> mailNewsUrl = do_QueryInterface(aUrl);
if (mailNewsUrl) {
mailNewsUrl->SetUpdatingFolder(PR_TRUE);
mailNewsUrl->SetMsgWindow(aMsgWindow);
}
rv = RunNewsUrl(aUrl, aMsgWindow, nsnull);
if (_retval)
{
*_retval = aUrl;
NS_IF_ADDREF(*_retval);
}
if (_retval) {
*_retval = aUrl;
NS_IF_ADDREF(*_retval);
}
}
else
else {
NS_ASSERTION(0,"not a news:/ url");
rv = NS_ERROR_FAILURE;
}
NS_UNLOCK_INSTANCE();
return rv;
}
NS_IMETHODIMP nsNntpService::CancelMessages(const char *hostname, const char *newsgroupname, nsISupportsArray *messages, nsISupports * aConsumer, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI ** aURL)
NS_IMETHODIMP
nsNntpService::CancelMessage(const char *uri, nsISupports * aConsumer, nsIUrlListener * aUrlListener, nsIMsgWindow *aMsgWindow, nsIURI ** aURL)
{
nsresult rv = NS_OK;
PRUint32 count = 0;
nsresult rv;
NS_ENSURE_ARG_POINTER(uri);
NS_ENSURE_ARG(aMsgWindow);
if (!hostname) return NS_ERROR_NULL_POINTER;
if (PL_strlen(hostname) == 0) return NS_ERROR_FAILURE;
nsCOMPtr<nsIPrompt> dialog;
aMsgWindow->GetPromptDialog(getter_AddRefs(dialog));
NS_ENSURE_TRUE(dialog, NS_ERROR_FAILURE);
if (!messages) {
nsAutoString alertText; alertText.AssignWithConversion("No articles are selected.");
if (dialog)
rv = dialog->Alert(nsnull, alertText.GetUnicode());
return NS_ERROR_NULL_POINTER;
}
rv = messages->Count(&count);
if (NS_FAILED(rv)) {
#ifdef DEBUG_NEWS
printf("Count failed\n");
#endif
return rv;
}
if (count != 1) {
nsAutoString alertText; alertText.AssignWithConversion("You can only cancel one article at a time.");
if (dialog)
rv = dialog->Alert(nsnull, alertText.GetUnicode());
return NS_ERROR_FAILURE;
}
nsMsgKey key;
nsXPIDLCString messageId;
nsCOMPtr<nsISupports> msgSupports = getter_AddRefs(messages->ElementAt(0));
nsCOMPtr<nsIMsgDBHdr> message(do_QueryInterface(msgSupports));
if (message) {
rv = message->GetMessageKey(&key);
if (NS_FAILED(rv)) return rv;
rv = message->GetMessageId(getter_Copies(messageId));
if (NS_FAILED(rv)) return rv;
}
else {
return NS_ERROR_FAILURE;
}
nsCAutoString urlStr;
urlStr += kNewsRootURI;
urlStr += "/";
urlStr += hostname;
urlStr += "/";
urlStr += (const char*)messageId;
urlStr += "?cancel";
#ifdef DEBUG_NEWS
printf("attempt to cancel the message (key,ID,cancel url): (%d,%s,%s)\n", key, (const char *)messageId, (const char *)urlStr);
#endif /* DEBUG_NEWS */
nsCAutoString newsgroupNameStr(newsgroupname);
nsCOMPtr<nsIURI> url;
rv = ConstructNntpUrl((const char *)urlStr, newsgroupNameStr, key, aUrlListener, aMsgWindow, getter_AddRefs(url));
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsINntpUrl> nntpUrl = do_QueryInterface(url);
if (nntpUrl)
nntpUrl->SetNewsAction(nsINntpUrl::ActionCancelArticle);
rv = RunNewsUrl(url, aMsgWindow, aConsumer);
// the url should have "?cancel" already on it
rv = ConstructNntpUrl(uri, aUrlListener, aMsgWindow, getter_AddRefs(url));
NS_ENSURE_SUCCESS(rv,rv);
if (aURL)
{
*aURL = url;
NS_IF_ADDREF(*aURL);
nsCOMPtr<nsINntpUrl> nntpUrl = do_QueryInterface(url);
if (nntpUrl) {
nntpUrl->SetNewsAction(nsINntpUrl::ActionCancelArticle);
}
rv = RunNewsUrl(url, aMsgWindow, aConsumer);
NS_ENSURE_SUCCESS(rv,rv);
if (aURL) {
*aURL = url;
NS_IF_ADDREF(*aURL);
}
return rv;
}
@@ -1447,28 +1321,31 @@ NS_IMETHODIMP nsNntpService::Search(nsIMsgSearchSession *aSearchSession, nsIMsgW
{
nsCOMPtr<nsIURI> uri;
nsXPIDLCString serverUri;
nsXPIDLString newsgroupName;
rv = server->GetServerURI(getter_Copies(serverUri));
if (NS_FAILED(rv)) return rv;
aMsgFolder->GetName(getter_Copies(newsgroupName));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString newsgroupName;
nsCString searchUrl(NS_STATIC_CAST(const char *, serverUri));
nsCString asciiNewsgroupName;
asciiNewsgroupName.AssignWithConversion(newsgroupName);
searchUrl.Append(aSearchUri);
rv = server->GetServerURI(getter_Copies(serverUri));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr <nsIMsgNewsFolder> newsFolder = do_QueryInterface(aMsgFolder, &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = newsFolder->GetAsciiName(getter_Copies(newsgroupName));
NS_ENSURE_SUCCESS(rv,rv);
nsCAutoString searchUrl((const char *)serverUri);
searchUrl += aSearchUri;
nsCOMPtr <nsIUrlListener> urlListener = do_QueryInterface(aSearchSession);
rv = ConstructNntpUrl(searchUrl.GetBuffer(), asciiNewsgroupName.GetBuffer(), nsMsgKey_None, urlListener, aMsgWindow, getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
rv = ConstructNntpUrl(searchUrl.get(), urlListener, aMsgWindow, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIMsgMailNewsUrl> msgurl (do_QueryInterface(uri));
if (msgurl)
msgurl->SetSearchSession(aSearchSession);
// run the url to update the counts
rv = RunNewsUrl(uri, nsnull, nsnull);
if (NS_FAILED(rv)) return rv;
// run the url to update the counts
rv = RunNewsUrl(uri, nsnull, nsnull);
NS_ENSURE_SUCCESS(rv,rv);
}
return rv;
}
@@ -1492,7 +1369,7 @@ nsNntpService::UpdateCounts(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aM
rv = server->GetServerURI(getter_Copies(serverUri));
if (NS_FAILED(rv)) return rv;
rv = ConstructNntpUrl((const char *)serverUri, "", nsMsgKey_None, nsnull, aMsgWindow, getter_AddRefs(uri));
rv = ConstructNntpUrl((const char *)serverUri, nsnull, aMsgWindow, getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
// run the url to update the counts
@@ -1506,10 +1383,8 @@ NS_IMETHODIMP
nsNntpService::GetListOfGroupsOnServer(nsINntpIncomingServer *aNntpServer, nsIMsgWindow *aMsgWindow)
{
nsresult rv;
#ifdef DEBUG_NEWS
printf("in GetListOfGroupsOnServer()\n");
#endif
if (!aNntpServer) return NS_ERROR_NULL_POINTER;
NS_ENSURE_ARG_POINTER(aNntpServer);
nsCOMPtr<nsIURI> uri;
nsCOMPtr<nsIMsgIncomingServer> server = do_QueryInterface(aNntpServer, &rv);
@@ -1526,7 +1401,7 @@ nsNntpService::GetListOfGroupsOnServer(nsINntpIncomingServer *aNntpServer, nsIMs
nsCOMPtr <nsIUrlListener> listener = do_QueryInterface(aNntpServer, &rv);
if (NS_FAILED(rv)) return rv;
if (!listener) return NS_ERROR_FAILURE;
rv = ConstructNntpUrl((const char *)uriStr, "", nsMsgKey_None, listener, aMsgWindow, getter_AddRefs(uri));
rv = ConstructNntpUrl((const char *)uriStr, listener, aMsgWindow, getter_AddRefs(uri));
if (NS_FAILED(rv)) return rv;
// now run the url to add the rest of the groups

View File

@@ -76,11 +76,13 @@ protected:
nsresult FindServerWithNewsgroup(nsCString &host, nsCString &groupName);
// a convience routine used to put together news urls.
nsresult ConstructNntpUrl(const char * urlString, const char * newsgroupName, nsMsgKey key, nsIUrlListener *aUrlListener, nsIMsgWindow * aMsgWindow, nsIURI ** aUrl);
nsresult ConstructNntpUrl(const char * urlString, nsIUrlListener *aUrlListener, nsIMsgWindow * aMsgWindow, nsIURI ** aUrl);
nsresult CreateNewsAccount(const char *username, const char *hostname, PRBool isSecure, PRInt32 port, nsIMsgIncomingServer **server);
nsresult GetProtocolForUri(nsIURI *aUri, nsIMsgWindow *aMsgWindow, nsINNTPProtocol **aProtocol);
// a convience routine to run news urls
nsresult RunNewsUrl (nsIURI * aUrl, nsIMsgWindow *aMsgWindow, nsISupports * aConsumer);
// a convience routine to go from folder uri to msg folder
nsresult GetFolderFromUri(const char *uri, nsIMsgFolder **folder);
static PRBool findNewsServerWithGroup(nsISupports *aElement, void *data);
nsresult DecomposeNewsMessageURI(const char * aMessageURI, nsIMsgFolder ** aFolder, nsMsgKey *aMsgKey);

View File

@@ -40,23 +40,20 @@
#include "nsXPIDLString.h"
#include "nsIMsgDatabase.h"
#include "nsMsgDBCID.h"
#include "nsMsgNewsCID.h"
#include "nsIRDFService.h"
#include "rdf.h"
#include "nsIMsgFolder.h"
#include "nsINntpService.h"
#include "nsIMsgMessageService.h"
static NS_DEFINE_CID(kCNewsDB, NS_NEWSDB_CID);
nsNntpUrl::nsNntpUrl()
{
// nsINntpUrl specific code...
m_newsHost = nsnull;
m_articleList = nsnull;
m_newsgroup = nsnull;
m_offlineNews = nsnull;
m_newsgroupList = nsnull;
m_newsgroupPost = nsnull;
m_messageKey = nsMsgKey_None;
m_newsAction = nsINntpUrl::ActionGetNewNews;
m_addDummyEnvelope = PR_FALSE;
m_canonicalLineEnding = PR_FALSE;
@@ -66,11 +63,7 @@ nsNntpUrl::nsNntpUrl()
nsNntpUrl::~nsNntpUrl()
{
NS_IF_RELEASE(m_newsHost);
NS_IF_RELEASE(m_articleList);
NS_IF_RELEASE(m_newsgroup);
NS_IF_RELEASE(m_offlineNews);
NS_IF_RELEASE(m_newsgroupList);
NS_IF_RELEASE(m_newsgroupPost);
}
@@ -115,81 +108,6 @@ NS_IMETHODIMP nsNntpUrl::SetNewsAction(nsNewsAction aNewsAction)
return NS_OK;
}
nsresult nsNntpUrl::SetNntpHost (nsINNTPHost * newsHost)
{
NS_LOCK_INSTANCE();
if (newsHost)
{
NS_IF_RELEASE(m_newsHost);
m_newsHost = newsHost;
NS_ADDREF(m_newsHost);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::GetNntpHost (nsINNTPHost ** newsHost)
{
NS_LOCK_INSTANCE();
if (newsHost)
{
*newsHost = m_newsHost;
NS_IF_ADDREF(m_newsHost);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::SetNntpArticleList (nsINNTPArticleList * articleList)
{
NS_LOCK_INSTANCE();
if (articleList)
{
NS_IF_RELEASE(m_articleList);
m_articleList = articleList;
NS_ADDREF(m_articleList);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::GetNntpArticleList (nsINNTPArticleList ** articleList)
{
NS_LOCK_INSTANCE();
if (articleList)
{
*articleList = m_articleList;
NS_IF_ADDREF(m_articleList);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::SetNewsgroup (nsINNTPNewsgroup * newsgroup)
{
NS_LOCK_INSTANCE();
if (newsgroup)
{
NS_IF_RELEASE(m_newsgroup);
m_newsgroup = newsgroup;
NS_ADDREF(m_newsgroup);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::GetNewsgroup (nsINNTPNewsgroup ** newsgroup)
{
NS_LOCK_INSTANCE();
if (newsgroup)
{
*newsgroup = m_newsgroup;
NS_IF_ADDREF(m_newsgroup);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::SetOfflineNewsState (nsIMsgOfflineNewsState * offlineNews)
{
NS_LOCK_INSTANCE();
@@ -215,61 +133,20 @@ nsresult nsNntpUrl::GetOfflineNewsState (nsIMsgOfflineNewsState ** offlineNews)
return NS_OK;
}
nsresult nsNntpUrl::SetNewsgroupList (nsINNTPNewsgroupList * newsgroupList)
{
NS_LOCK_INSTANCE();
if (newsgroupList)
{
NS_IF_RELEASE(m_newsgroupList);
m_newsgroupList = newsgroupList;
NS_IF_ADDREF(m_newsgroupList);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
nsresult nsNntpUrl::GetNewsgroupList (nsINNTPNewsgroupList ** newsgroupList)
{
NS_LOCK_INSTANCE();
if (newsgroupList)
{
*newsgroupList = m_newsgroupList;
NS_IF_ADDREF(m_newsgroupList);
}
NS_UNLOCK_INSTANCE();
return NS_OK;
}
NS_IMETHODIMP nsNntpUrl::SetUri(const char * aURI)
{
mURI= aURI;
mURI = aURI;
return NS_OK;
}
// from nsIMsgMessageUrl
NS_IMETHODIMP nsNntpUrl::GetUri(char ** aURI)
{
nsresult rv = NS_OK;
// if we have been given a uri to associate with this url, then use it
// otherwise try to reconstruct a URI on the fly....
if (!mURI.IsEmpty())
*aURI = mURI.ToNewCString();
else
{
nsXPIDLCString spec;
GetSpec(getter_Copies(spec));
char * baseMessageURI;
nsCreateNewsBaseMessageURI(spec, &baseMessageURI);
nsCAutoString uriStr;
rv = nsBuildNewsMessageURI(baseMessageURI, m_messageKey, uriStr);
nsCRT::free(baseMessageURI);
if (NS_FAILED(rv)) return rv;
*aURI = uriStr.ToNewCString();
return NS_OK;
}
{
NS_ENSURE_ARG_POINTER(aURI);
nsresult rv = NS_OK;
*aURI = mURI.ToNewCString();
if (!*aURI) return NS_ERROR_OUT_OF_MEMORY;
return rv;
}
@@ -318,88 +195,21 @@ nsresult nsNntpUrl::GetMessageToPost(nsINNTPNewsgroupPost **aPost)
NS_IMETHODIMP nsNntpUrl::GetMessageHeader(nsIMsgDBHdr ** aMsgHdr)
{
nsresult rv = NS_OK;
nsFileSpec pathResult;
if (!aMsgHdr) return NS_ERROR_NULL_POINTER;
if (!((const char *)m_newsgroupName)) return NS_ERROR_FAILURE;
nsXPIDLCString hostName;
rv = GetHost(getter_Copies(hostName));
if (NS_FAILED(rv)) return rv;
nsXPIDLCString userName;
rv = GetPreHost(getter_Copies(userName));
if (NS_FAILED(rv)) return rv;
nsCString newsgroupURI(kNewsMessageRootURI);
newsgroupURI.Append("/");
if (userName && (userName != (const char *)"")) {
newsgroupURI.Append(userName);
newsgroupURI.Append("@");
}
newsgroupURI.Append(hostName);
newsgroupURI.Append("/");
newsgroupURI.Append((const char *)m_newsgroupName);
rv = nsNewsURI2Path(kNewsMessageRootURI, newsgroupURI.GetBuffer(), pathResult);
if (NS_FAILED(rv)) {
return rv;
}
nsCOMPtr<nsIMsgDatabase> newsDBFactory;
nsCOMPtr<nsIMsgDatabase> newsDB;
rv = nsComponentManager::CreateInstance(kCNewsDB, nsnull, NS_GET_IID(nsIMsgDatabase), getter_AddRefs(newsDBFactory));
if (NS_FAILED(rv) || (!newsDBFactory)) {
return rv;
}
nsCOMPtr <nsIFileSpec> dbFileSpec;
NS_NewFileSpecWithSpec(pathResult, getter_AddRefs(dbFileSpec));
rv = newsDBFactory->Open(dbFileSpec, PR_TRUE, PR_FALSE, getter_AddRefs(newsDB));
if (NS_FAILED(rv) || (!newsDB)) {
return rv;
}
rv = newsDB->GetMsgHdrForKey(m_messageKey, aMsgHdr);
if (NS_FAILED(rv) || (!aMsgHdr)) {
return rv;
}
nsresult rv;
return NS_OK;
}
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
NS_IMETHODIMP nsNntpUrl::SetNewsgroupName(const char * aNewsgroupName)
{
m_newsgroupName = aNewsgroupName;
return NS_OK;
}
#ifdef DEBUG_seth
printf("GetMessageHeader for %s\n",mURI.get());
#endif
nsCOMPtr <nsIMsgMessageService> msgService = do_QueryInterface(nntpService, &rv);
NS_ENSURE_SUCCESS(rv,rv);
NS_IMETHODIMP nsNntpUrl::GetNewsgroupName(char ** aNewsgroupName)
{
NS_ENSURE_ARG_POINTER(aNewsgroupName);
*aNewsgroupName = nsCRT::strdup((const char *)m_newsgroupName);
if (!aNewsgroupName) {
return NS_ERROR_OUT_OF_MEMORY;
}
return NS_OK;
}
NS_IMETHODIMP nsNntpUrl::SetMessageKey(nsMsgKey aKey)
{
m_messageKey = aKey;
return NS_OK;
}
NS_IMETHODIMP nsNntpUrl::GetMessageKey(nsMsgKey * aKey)
{
*aKey = m_messageKey;
return NS_OK;
rv = msgService->MessageURIToMsgHdr(mURI.get(), aMsgHdr);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
}
NS_IMETHODIMP nsNntpUrl::IsUrlType(PRUint32 type, PRBool *isType)
@@ -433,64 +243,14 @@ nsNntpUrl::SetOriginalSpec(const char *aSpec)
nsresult nsNntpUrl::GetMsgFolder(nsIMsgFolder **msgFolder)
{
/*
well, not proud of this. but it will all get fixed when
the news code gets the beating it deserves.
nsresult rv;
nsCOMPtr <nsINntpService> nntpService = do_GetService(NS_NNTPSERVICE_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv,rv);
ideally, we'd keep a weak reference to the current news folder
and just use that to determine the char set, but for now
we'll just get the folder from the url we are running.
this code takes the current uri, which is for a news message
and turns it into a news folder uri,
and then get the folder for that URI, and the ask the folder
for it's charset....
*/
nsresult rv;
nsXPIDLCString uriStr;
rv = GetUri(getter_Copies(uriStr));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIURI> uri = do_CreateInstance("@mozilla.org/network/standard-url;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
rv = uri->SetSpec((const char *)uriStr);
NS_ENSURE_SUCCESS(rv,rv);
// XXX todo?
// could the url already be a folder url?
//
// get the path, check for @ or %40. if has them,
// this is an article url, and we need to replace
// the path with the newsgroup name.
// for now, assume it is always an article url
if (!((const char *)m_newsgroupName)) {
NS_ASSERTION(NS_ERROR_FAILURE,"no group name");
return NS_ERROR_FAILURE;
}
nsCAutoString groupPath("/");
groupPath += m_newsgroupName;
rv = uri->SetPath((const char *)groupPath);
NS_ENSURE_SUCCESS(rv,rv);
rv = uri->GetSpec(getter_Copies(uriStr));
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIRDFService> rdfService = do_GetService(NS_RDF_CONTRACTID "/rdf-service;1", &rv);
NS_ENSURE_SUCCESS(rv,rv);
nsCOMPtr<nsIRDFResource> resource;
rv = rdfService->GetResource((const char *)uriStr, getter_AddRefs(resource));
NS_ENSURE_SUCCESS(rv,rv);
rv = resource->QueryInterface(NS_GET_IID(nsIMsgFolder), (void**) msgFolder);
NS_ENSURE_SUCCESS(rv,rv);
return rv;
nsMsgKey msgKey;
rv = nntpService->DecomposeNewsURI(mURI.get(), msgFolder, &msgKey);
NS_ENSURE_SUCCESS(rv,rv);
return NS_OK;
}
NS_IMETHODIMP

View File

@@ -59,13 +59,7 @@ protected:
nsresult GetMsgFolder(nsIMsgFolder **msgFolder);
/* NNTP specific event sinks */
nsINNTPHost * m_newsHost;
nsINNTPArticleList * m_articleList;
nsINNTPNewsgroup * m_newsgroup;
nsIMsgOfflineNewsState* m_offlineNews;
nsINNTPNewsgroupList * m_newsgroupList;
nsMsgKey m_messageKey;
nsCString m_newsgroupName;
nsCString mURI; // the RDF URI associated with this url.
nsString mCharsetOverride; // used by nsIMsgI18NUrl...
PRBool m_getOldMessages;