1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
/* -*-objc-*-
*
* GNUstep RSS Kit
* Copyright (C) 2006 Guenther Noack
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, in version 2.1
* of the License
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#import <objc/objc.h>
#import <Foundation/Foundation.h>
#import "RSSFeedProtocol.h"
#import "RSSArticle.h"
/**
* The states that the RSS feed can have.
*/
enum RSSFeedStatus
{
RSSFeedIsFetching,
RSSFeedIsIdle
};
/**
* Objects of this class represent a RSS/ATOM feed, which is basically
* just a source for new articles. When creating a RSSFeed object, you'll
* just have to provide it with the URL, where the feed can be downloaded
* from.
*
* This is the generic way to read feeds:
*
* <ul>
* <li>Create a URL object with the location of the feed.<br>
* <code>
* NSURL* url =
* [NSURL URLWithString:@"http://www.example.com/feed.xml"];
* </code>
* </li>
* <li>Create a RSSFeed object with the URL:<br>
* <code>
* RSSFeed* feed = [RSSFeed initWithURL: url];
* </code>
* </li>
* <li>Fetch the contents of the feed:<br>
* <code>
* [feed fetch]; // alternatively [feed fetchInBackground];
* </code>
* </li>
* <li>Optionally tell the RSSFeed to keep old articles.<br>
* <code>
* [feed setAutoClear: NO];
* </code>
* </li>
* <li>Retrieve the set of articles.
* <code>
* NSSet* articles = [feed articleSet];
* </code>
* </li>
* </ul>
*
*
* @see initWithURL:
* @see fetch
* @see setAutoClear:
*
* @see RSSArticle
* @see NSURL
*/
@interface RSSFeed : NSObject <RSSMutableFeed>
{
@protected
NSDate* lastRetrieval;
BOOL clearFeedBeforeFetching;
NSMutableArray* articles;
enum RSSFeedError lastError;
NSString* feedName;
NSURL* feedURL;
Class articleClass;
enum RSSFeedStatus status;
NSMutableData *cacheData; // Used only when load in background.
}
+ (RSSFeed *) feed;
+ (RSSFeed *) feedWithURL: (NSURL*) aURL;
- (id) init;
/**
* Designated initializer.
*
* @param aURL The URL where the feed can be downloaded from.
*/
- (id) initWithURL: (NSURL*) aURL;
/**
* @return Description of the Feed (the feed name)
*/
-(NSString*) description;
// ----------------------------------------------------------------------
// Status access
// ----------------------------------------------------------------------
/**
* Accessor for the status of the feed.
* This can be used by a multithreaded GUI to indicate if a feed
* is currently fetching...
*
* @deprecated in favor of -isFetching
* @see isFetching
*
* @return either RSSFeedIsFetching or RSSFeedIsIdle
*/
- (enum RSSFeedStatus) status;
/**
* Returns YES if and only if this feed is currently being fetched.
*/
- (BOOL)isFetching;
// ----------------------------------------------------------------------
// Access to the articles
// ----------------------------------------------------------------------
// Note: please refer to RSSFeed protocol instead.
/**
* @return an enumerator for the articles in this feed
*/
- (NSEnumerator*) articleEnumerator;
/**
* Deletes an article from the feed.
*
* @param article The index of the article to delete.
*/
- (void) removeArticle: (RSSArticle*) article;
// ----------------------------------------------------------------------
// Access to the preferences
// ----------------------------------------------------------------------
/**
* Sets the feed name
*/
- (void) setFeedName: (NSString*) aFeedName;
/**
* @return The name of the feed
*/
- (NSString*) feedName;
/**
* @return the URL where the feed can be downloaded from (as NSURL object)
* @see NSURL
*/
- (NSURL*) feedURL;
// --------------------------------------------------------------------
// Equality and hash codes
// --------------------------------------------------------------------
- (BOOL) isEqual: (id)anObject;
// --------------------------------------------------------------------
// Accessor and Mutator for the automatic clearing
// --------------------------------------------------------------------
/**
* Lets you decide if the feed should be cleared before new
* articles are downloaded.
*
* @param autoClear YES, if the feed should clear its article list
* before fetching new articles. NO otherwise
*/
- (void) setAutoClear: (BOOL) autoClear;
/**
* @return YES, if the automatic clearing of the article list is
* enabled for this feed. NO otherwise.
*/
- (BOOL) autoClear;
/**
* Clears the list of articles.
*/
- (void) clearArticles;
// ------------------------------------------------------------------
// Extensions that make subclassing RSSFeed and RSSArticle easier.
// ------------------------------------------------------------------
/**
* Sets the class of the article objects. This needs to be a subtype
* of RSSArticle.
*
* @param aClass The class newly created article objects should have.
*/
-(void) setArticleClass:(Class)aClass;
/**
* Returns the class of the article objects. This will be a subtype
* of RSSArticle.
*
* @return the article class
*/
-(Class) articleClass;
// ------------------------------------------------------------------
// Dirtyness, now implemented via the date of last retrieval
// ------------------------------------------------------------------
/**
* Returns the date of last retrieval of this feed.
* If the feed hasn't been retrieved yet, this method returns nil.
*
* @return The date of last retrieval as a NSDate pointer.
*/
-(NSDate*) lastRetrieval;
/**
* RSSFeed also implements the NewRSSArticleListener informal protocol.
*/
-(void) newArticleFound: (id) anArticle;
@end
|