Permalink
Browse files

Initial import

  • Loading branch information...
0 parents commit 40d6df4f26d0672352421aee0e284f1b88577ae5 @st3fan committed Apr 25, 2010
0 README
No changes.
Binary file not shown.
@@ -0,0 +1,14 @@
+// AtomContent.h
+
+#import <Foundation/Foundation.h>
+#import <CoreData/CoreData.h>
+
+@interface AtomContent : NSObject {
+ NSString* text_;
+ NSString* type_;
+}
+
+@property (nonatomic,retain) NSString* text;
+@property (nonatomic,retain) NSString* type;
+
+@end
@@ -0,0 +1,17 @@
+// AtomContent.m
+
+#import "AtomContent.h"
+
+@implementation AtomContent
+
+@synthesize text = text_;
+@synthesize type = type_;
+
+- (void) dealloc
+{
+ [text_ release];
+ [type_ release];
+ [super dealloc];
+}
+
+@end
@@ -0,0 +1,20 @@
+// AtomEngine.h
+
+@class AtomSubscription;
+
+@interface AtomEngine : NSObject {
+ @private
+ NSMutableArray* subscriptions_;
+ NSOperationQueue* operationQueue_;
+}
+
++ (id) sharedEngine;
+
+- (NSArray*) subscriptions;
+- (AtomSubscription*) subscriptionWithURL: (NSURL*) url;
+- (void) addSubscription: (AtomSubscription*) subscription;
+
+- (void) refreshAllSubscriptions;
+- (void) refreshSubscription: (AtomSubscription*) subscription;
+
+@end
@@ -0,0 +1,86 @@
+// AtomEngine.m
+
+#import "AtomRefreshSubscriptionOperation.h"
+#import "AtomSubscription.h"
+#import "AtomEngine.h"
+
+@implementation AtomEngine
+
++ (id) sharedEngine
+{
+ static AtomEngine* atomEngineSingleton = nil;
+
+ @synchronized (self) {
+ if (atomEngineSingleton == nil) {
+ atomEngineSingleton = [self new];
+ }
+ }
+
+ return atomEngineSingleton;
+}
+
+#pragma mark -
+
+- (id) init
+{
+ if ((self = [super init]) != nil) {
+ subscriptions_ = [NSMutableArray new];
+ operationQueue_ = [NSOperationQueue new];
+ [operationQueue_ setMaxConcurrentOperationCount: 2];
+ }
+
+ return self;
+}
+
+- (void) dealloc
+{
+ [subscriptions_ release];
+ [operationQueue_ release];
+ [super dealloc];
+}
+
+#pragma mark -
+
+- (NSArray*) subscriptions
+{
+ return [subscriptions_ copy];
+}
+
+- (AtomSubscription*) subscriptionWithURL: (NSURL*) url
+{
+ for (AtomSubscription* subscription in subscriptions_) {
+ if ([subscription.url isEqual: url]) {
+ return subscription;
+ }
+ }
+ return nil;
+}
+
+- (void) addSubscription: (AtomSubscription*) subscription
+{
+ if ([self subscriptionWithURL: subscription.url]) {
+ return;
+ }
+
+ [subscriptions_ addObject: subscription];
+}
+
+#pragma mark -
+
+- (void) refreshAllSubscriptions
+{
+ for (AtomSubscription* subscription in subscriptions_) {
+ [self refreshSubscription: subscription];
+ }
+}
+
+- (void) refreshSubscription: (AtomSubscription*) subscription
+{
+ AtomRefreshSubscriptionOperation* operation = [[AtomRefreshSubscriptionOperation alloc] initWithSubscription: subscription];
+ if (operation != nil) {
+ [operationQueue_ addOperation: operation];
+ [operation release];
+ }
+}
+
+@end
@@ -0,0 +1,28 @@
+// AtomEntry.h
+
+#import <Foundation/Foundation.h>
+#import <CoreData/CoreData.h>
+
+@class AtomContent;
+
+@interface AtomEntry : NSObject {
+ @private
+ NSString* title_;
+ NSString* summary_;
+ NSString* identifier_;
+ NSDate* published_;
+ NSDate* updated_;
+ AtomContent* content_;
+}
+
+@property (nonatomic,retain) NSString* title;
+@property (nonatomic,retain) NSString* summary;
+@property (nonatomic,retain) NSString* identifier;
+@property (nonatomic,retain) NSDate* published;
+@property (nonatomic,retain) NSDate* updated;
+@property (nonatomic,retain) AtomContent* content;
+
+- (void) setPublishedFromString: (NSString*) string;
+- (void) setUpdatedFromString: (NSString*) string;
+
+@end
@@ -0,0 +1,40 @@
+// AtomEntry.m
+
+#import "AtomEntry.h"
+#import "AtomContent.h"
+
+@implementation AtomEntry
+
+@synthesize title = title_;
+@synthesize summary = summary_;
+@synthesize identifier = identifier_;
+@synthesize published = published_;
+@synthesize updated = updated_;
+@synthesize content = content_;
+
+- (void) dealloc
+{
+ [title_ release];
+ [summary_ release];
+ [identifier_ release];
+ [published_ release];
+ [updated_ release];
+ [content_ release];
+ [super dealloc];
+}
+
+- (void) setPublishedFromString: (NSString*) string
+{
+ NSDateFormatter* dateFormatter = [[NSDateFormatter new] autorelease];
+ [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
+ self.published = [dateFormatter dateFromString: string];
+}
+
+- (void) setUpdatedFromString: (NSString*) string
+{
+ NSDateFormatter* dateFormatter = [[NSDateFormatter new] autorelease];
+ [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
+ self.updated = [dateFormatter dateFromString: string];
+}
+
+@end
@@ -0,0 +1,27 @@
+// AtomFeed.h
+
+#import <Foundation/Foundation.h>
+#import <CoreData/CoreData.h>
+
+@class AtomEntry;
+
+@interface AtomFeed : NSObject {
+ @private
+ NSString* identifier_;
+ NSString* title_;
+ NSString* subtitle_;
+ NSDate* updated_;
+ NSMutableArray* entries_;
+}
+
+@property (nonatomic,retain) NSString* identifier;
+@property (nonatomic,retain) NSString* title;
+@property (nonatomic,retain) NSString* subtitle;
+@property (nonatomic,retain) NSDate* updated;
+@property (nonatomic,readonly) NSMutableArray* entries;
+
+- (void) setUpdatedFromString: (NSString*) string;
+
+- (AtomEntry*) entryWithIdentifier: (NSString*) identifier;
+
+@end
@@ -0,0 +1,49 @@
+// AtomFeed.m
+
+#import "AtomEntry.h"
+#import "AtomFeed.h"
+
+@implementation AtomFeed
+
+@synthesize identifier = identifier_;
+@synthesize entries = entries_;
+@synthesize title = title_;
+@synthesize subtitle = subtitle_;
+@synthesize updated = updated_;
+
+- (id) init
+{
+ if ((self = [super init]) != nil) {
+ entries_ = [NSMutableArray new];
+ }
+ return self;
+}
+
+- (void) dealloc
+{
+ [identifier_ release];
+ [title_ release];
+ [subtitle_ release];
+ [entries_ release];
+ [updated_ release];
+ [super dealloc];
+}
+
+- (void) setUpdatedFromString: (NSString*) string
+{
+ NSDateFormatter* dateFormatter = [[NSDateFormatter new] autorelease];
+ [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss'Z'"];
+ self.updated = [dateFormatter dateFromString: string];
+}
+
+- (AtomEntry*) entryWithIdentifier: (NSString*) identifier
+{
+ for (AtomEntry* entry in entries_) {
+ if ([entry.identifier isEqualToString: identifier]) {
+ return entry;
+ }
+ }
+ return nil;
+}
+
+@end
@@ -0,0 +1,15 @@
+// AtomFeedParser.h
+
+#import <Foundation/Foundation.h>
+
+@class AtomFeed;
+
+@interface AtomFeedParser : NSObject {
+
+}
+
++ (AtomFeed*) parseAtomFeedFromData: (NSData*) data;
++ (AtomFeed*) parseAtomFeedFromURL: (NSURL*) url;
++ (AtomFeed*) parseAtomFeedFromFile: (NSString*) path;
+
+@end
Oops, something went wrong.

0 comments on commit 40d6df4

Please sign in to comment.