Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 86 lines (72 sloc) 2.363 kb
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
1 //
2 // SUAppcast.m
3 // Sparkle
4 //
5 // Created by Andy Matuschak on 3/12/06.
6 // Copyright 2006 Andy Matuschak. All rights reserved.
7 //
8
5aa1e18 Improved headers from Charles D. H. Williams.
andym authored
9 #import "Sparkle.h"
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
10 #import "SUAppcast.h"
11
d06b2f5 @andymatuschak Fixes bug #228449: now the appcast doesn't run the RSS feed fetching …
andymatuschak authored
12 @interface SUAppcast (Private)
13 - (void)reportError:(NSError *)error;
14 @end
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
15
d06b2f5 @andymatuschak Fixes bug #228449: now the appcast doesn't run the RSS feed fetching …
andymatuschak authored
16 @implementation SUAppcast
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
17
18 - (void)dealloc
19 {
20 [items release];
21 [super dealloc];
22 }
23
24 - (NSArray *)items
25 {
26 return items;
27 }
28
d06b2f5 @andymatuschak Fixes bug #228449: now the appcast doesn't run the RSS feed fetching …
andymatuschak authored
29 - (void)fetchAppcastFromURL:(NSURL *)url
30 {
31 RSS *feed = [[RSS alloc] initWithURL:url userAgent:userAgentString delegate:self];
32 CFRetain(feed); // Manage the RSS feed's memory manually.
33 }
34
35 - (void)feedDidFinishLoading:(RSS *)feed
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
36 {
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
37 // Set up all the appcast items:
4a26774 @andymatuschak Fixes 240274
andymatuschak authored
38 NSArray *tempItems = [NSMutableArray array];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
39 id enumerator = [[feed newsItems] objectEnumerator], current;
40 @try
41 {
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
42 while ((current = [enumerator nextObject]))
43 {
4a26774 @andymatuschak Fixes 240274
andymatuschak authored
44 [(NSMutableArray *)tempItems addObject:[[[SUAppcastItem alloc] initWithDictionary:current] autorelease]];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
45 }
4a26774 @andymatuschak Fixes 240274
andymatuschak authored
46 items = [[NSArray arrayWithArray:tempItems] retain]; // Make the items list immutable.
47
48 if ([delegate respondsToSelector:@selector(appcastDidFinishLoading:)])
49 [delegate performSelectorOnMainThread:@selector(appcastDidFinishLoading:) withObject:self waitUntilDone:NO];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
50 }
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
51 @catch (NSException *parseException)
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
52 {
d06b2f5 @andymatuschak Fixes bug #228449: now the appcast doesn't run the RSS feed fetching …
andymatuschak authored
53 [self reportError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred while parsing the update feed.", nil), NSLocalizedDescriptionKey, [parseException reason], SUTechnicalErrorInformationKey, nil]]];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
54 }
d06b2f5 @andymatuschak Fixes bug #228449: now the appcast doesn't run the RSS feed fetching …
andymatuschak authored
55 CFRelease(feed);
56 }
57
58 - (void)feed:(RSS *)feed didFailWithError:(NSError *)error
59 {
60 [self reportError:error];
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
61 }
62
63 - (void)reportError:(NSError *)error
64 {
65 if ([delegate respondsToSelector:@selector(appcast:failedToLoadWithError:)])
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
66 {
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
67 [delegate appcast:self failedToLoadWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastError userInfo:[NSDictionary dictionaryWithObjectsAndKeys:SULocalizedString(@"An error occurred in retrieving update information. Please try again later.", nil), NSLocalizedDescriptionKey, [error localizedDescription], NSLocalizedFailureReasonErrorKey, nil]]];
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
68 }
69 }
70
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
71 - (void)setUserAgentString:(NSString *)uas
72 {
a5dcf94 @andymatuschak Fixed all setters to eliminate the possibility of accidentally releas…
andymatuschak authored
73 if (uas != userAgentString)
74 {
75 [userAgentString release];
76 userAgentString = [uas copy];
77 }
bc3be9a Touched practically every line of code in a super-monster-awesome ref…
andym authored
78 }
79
80 - (void)setDelegate:del
81 {
82 delegate = del;
83 }
84
9fa3da5 Holy restructuring, batman! Watch out for falling folders.
andym authored
85 @end
Something went wrong with that request. Please try again.