From 9962db3236df651281bccf06c8adc3133d864f5d Mon Sep 17 00:00:00 2001 From: "scott%scott-macgregor.org" Date: Thu, 22 Jul 2004 23:27:32 +0000 Subject: [PATCH] Bug #2522688 --> Add rss incoming server attributes for fetching the location of the feed and feed item data sources for thunderbird. sr=bienvenu --- .../local/public/nsIRssIncomingServer.idl | 8 +++- mailnews/local/src/nsLocalMailFolder.cpp | 5 +++ mailnews/local/src/nsRssIncomingServer.cpp | 38 +++++++++++++++++-- mailnews/local/src/nsRssIncomingServer.h | 3 +- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/mailnews/local/public/nsIRssIncomingServer.idl b/mailnews/local/public/nsIRssIncomingServer.idl index a70c55feebfc..e3f0003aaa86 100644 --- a/mailnews/local/public/nsIRssIncomingServer.idl +++ b/mailnews/local/public/nsIRssIncomingServer.idl @@ -36,7 +36,13 @@ #include "nsISupports.idl" +interface nsILocalFile; + [scriptable, uuid(6d744e7f-2218-45c6-8734-998a56cb3c6d)] interface nsIRssIncomingServer : nsISupports { -}; + // Path to the subscriptions data source for this RSS server + readonly attribute nsILocalFile subscriptionsDataSourcePath; + // Path to the feed items data source for this RSS server + readonly attribute nsILocalFile feedItemsDataSourcePath; +}; diff --git a/mailnews/local/src/nsLocalMailFolder.cpp b/mailnews/local/src/nsLocalMailFolder.cpp index 648e31ceaf60..d24d432bbab8 100644 --- a/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mailnews/local/src/nsLocalMailFolder.cpp @@ -211,6 +211,11 @@ nsShouldIgnoreFile(nsString& name) nsStringEndsWith(name, ".toc")) return PR_TRUE; + // ignore RSS data source files + if (name.LowerCaseEqualsLiteral("feeds.rdf") || + name.LowerCaseEqualsLiteral("feeditems.rdf")) + return PR_TRUE; + return (nsStringEndsWith(name,".sbd") || nsStringEndsWith(name,".msf")); } diff --git a/mailnews/local/src/nsRssIncomingServer.cpp b/mailnews/local/src/nsRssIncomingServer.cpp index 8719dc8ca328..b1424478f331 100755 --- a/mailnews/local/src/nsRssIncomingServer.cpp +++ b/mailnews/local/src/nsRssIncomingServer.cpp @@ -57,6 +57,38 @@ nsRssIncomingServer::~nsRssIncomingServer() { } +nsresult nsRssIncomingServer::FillInDataSourcePath(const nsAString& aDataSourceName, nsILocalFile ** aLocation) +{ + nsresult rv; + // start by gettting the local path for this server + nsCOMPtr localPathForServer; + rv = GetLocalPath(getter_AddRefs(localPathForServer)); + NS_ENSURE_SUCCESS(rv, rv); + + // convert to a nsIFile + nsCOMPtr localFile; + nsFileSpec pathSpec; + localPathForServer->GetFileSpec(&pathSpec); + rv = NS_FileSpecToIFile(&pathSpec, getter_AddRefs(localFile)); + NS_ENSURE_SUCCESS(rv, rv); + + // now append the name of the subscriptions data source + rv = localFile->Append(aDataSourceName); + NS_IF_ADDREF(*aLocation = localFile); + return rv; +} + +// nsIRSSIncomingServer methods +NS_IMETHODIMP nsRssIncomingServer::GetSubscriptionsDataSourcePath(nsILocalFile ** aLocation) +{ + return FillInDataSourcePath(NS_LITERAL_STRING("feeds.rdf"), aLocation); +} + +NS_IMETHODIMP nsRssIncomingServer::GetFeedItemsDataSourcePath(nsILocalFile ** aLocation) +{ + return FillInDataSourcePath(NS_LITERAL_STRING("feeditems.rdf"), aLocation); +} + NS_IMETHODIMP nsRssIncomingServer::CreateDefaultMailboxes(nsIFileSpec *path) { NS_ENSURE_ARG_POINTER(path); @@ -133,9 +165,9 @@ NS_IMETHODIMP nsRssIncomingServer::GetNewMail(nsIMsgWindow *aMsgWindow, nsIUrlLi // before we even try to get New Mail, check to see if the passed in folder was the root folder. // If it was, then call PerformBiff which will properly walk through each RSS folder, asking it to check for new Mail. - nsCOMPtr rootRSSFolder; - GetRootMsgFolder(getter_AddRefs(rootRSSFolder)); - if (rootRSSFolder == aFolder) // pointing to the same folder? + PRBool rootFolder = PR_FALSE; + aFolder->GetIsServer(&rootFolder); + if (rootFolder) return PerformBiff(aMsgWindow); PRBool valid = PR_FALSE; diff --git a/mailnews/local/src/nsRssIncomingServer.h b/mailnews/local/src/nsRssIncomingServer.h index 1377fd31dd83..1f1381c5d77b 100755 --- a/mailnews/local/src/nsRssIncomingServer.h +++ b/mailnews/local/src/nsRssIncomingServer.h @@ -60,7 +60,8 @@ public: nsRssIncomingServer(); virtual ~nsRssIncomingServer(); - +protected: + nsresult FillInDataSourcePath(const nsAString& aDataSourceName, nsILocalFile ** aLocation); }; #endif /* __nsRssIncomingServer_h */