Permalink
Browse files

Numerous minor changes courtesy Sean McBride. Mostly clarifications.

  • Loading branch information...
1 parent 2049194 commit a7148d97ff05f5d43ce12fb61d68a89763ef0650 andym committed Jan 14, 2008
@@ -57,7 +57,7 @@ - (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst
NSString *tmp = [[[dst stringByDeletingPathExtension] stringByAppendingString:@".old"] stringByAppendingPathExtension:[dst pathExtension]];
BOOL res = NO;
struct stat sb;
- if((stat([src UTF8String], &sb) != 0) || (stat([tmp UTF8String], &sb) == 0) || stat([dst UTF8String], &sb) != 0)
+ if((stat([src fileSystemRepresentation], &sb) != 0) || (stat([tmp fileSystemRepresentation], &sb) == 0) || stat([dst fileSystemRepresentation], &sb) != 0)
return false;
NSString *command = [NSString stringWithFormat:@"mv -f \"%@\" \"%@\" && cp -f -R \"%@\" \"%@\" && rm -rf \"%@\" && chown -R %d:%d \"%@\"",
@@ -73,7 +73,7 @@ - (BOOL)_copyPathWithForcedAuthentication:(NSString *)src toPath:(NSString *)dst
AuthorizationRef auth;
if(AuthorizationCreate(NULL, kAuthorizationEmptyEnvironment, kAuthorizationFlagDefaults, &auth) == errAuthorizationSuccess)
{
- char const* arguments[] = { "-c", [command UTF8String], NULL };
+ char const* arguments[] = { "-c", [command fileSystemRepresentation], NULL };
if(AuthorizationExecuteWithPrivileges(auth, "/bin/sh", kAuthorizationFlagDefaults, (char**)arguments, NULL) == errAuthorizationSuccess)
{
int status;
View
@@ -88,9 +88,9 @@ - (NSString *) ellipsizeAfterNWords: (NSInteger) n {
- (NSString *) stripHTML {
- NSInteger len = [self length];
+ NSUInteger len = [self length];
NSMutableString *s = [NSMutableString stringWithCapacity: len];
- NSInteger i = 0, level = 0;
+ NSUInteger i = 0, level = 0;
for (i = 0; i < len; i++) {
View
@@ -36,14 +36,16 @@ @implementation NTSynchronousTask
- (id)init;
{
self = [super init];
+ if (self)
+ {
+ [self setTask:[[[NSTask alloc] init] autorelease]];
+ [self setOutputPipe:[[[NSPipe alloc] init] autorelease]];
+ [self setInputPipe:[[[NSPipe alloc] init] autorelease]];
- [self setTask:[[[NSTask alloc] init] autorelease]];
- [self setOutputPipe:[[[NSPipe alloc] init] autorelease]];
- [self setInputPipe:[[[NSPipe alloc] init] autorelease]];
+ [[self task] setStandardInput:[self inputPipe]];
+ [[self task] setStandardOutput:[self outputPipe]];
+ }
- [[self task] setStandardInput:[self inputPipe]];
- [[self task] setStandardOutput:[self outputPipe]];
-
return self;
}
View
22 RSS.m
@@ -482,7 +482,7 @@ - (void) normalizeRSSItem: (NSMutableDictionary *) rssItem {
Also trim white space, remove HTML when appropriate.
*/
- NSString *description, *link, *title;
+ NSString *description, *normalizedLink, *title;
BOOL nilDescription = NO;
/*Description*/
@@ -505,9 +505,9 @@ - (void) normalizeRSSItem: (NSMutableDictionary *) rssItem {
/*Link*/
- link = [rssItem objectForKey: linkKey];
+ normalizedLink = [rssItem objectForKey: linkKey];
- if ([NSString stringIsEmpty: link]) {
+ if ([NSString stringIsEmpty: normalizedLink]) {
/*Try to get a URL from the description.*/
@@ -517,21 +517,21 @@ - (void) normalizeRSSItem: (NSMutableDictionary *) rssItem {
if ([stringComponents count] > 1) {
- link = [stringComponents objectAtIndex: 1];
+ normalizedLink = [stringComponents objectAtIndex: 1];
- stringComponents = [link componentsSeparatedByString: @"\""];
+ stringComponents = [normalizedLink componentsSeparatedByString: @"\""];
- link = [stringComponents objectAtIndex: 0];
+ normalizedLink = [stringComponents objectAtIndex: 0];
} /*if*/
} /*if*/
} /*if*/
- if (link == nil)
- link = @"";
+ if (normalizedLink == nil)
+ normalizedLink = @"";
- link = [link trimWhiteSpace];
+ normalizedLink = [normalizedLink trimWhiteSpace];
- [rssItem setObject: link forKey: linkKey];
+ [rssItem setObject: normalizedLink forKey: linkKey];
/*Title*/
@@ -703,7 +703,7 @@ - (NSString *) getelementvalue: (CFXMLTreeRef) tree {
} /*if*/
} /*for*/
- value = [valueMutable copy];
+ value = [[valueMutable trimWhiteSpace] retain];
[valueMutable autorelease];
View
@@ -13,65 +13,68 @@ @implementation SUAppcastItem
- initWithDictionary:(NSDictionary *)dict
{
- [super init];
- [self setTitle:[dict objectForKey:@"title"]];
- [self setDate:[dict objectForKey:@"pubDate"]];
- [self setDescription:[dict objectForKey:@"description"]];
-
- id enclosure = [dict objectForKey:@"enclosure"];
- [self setDSASignature:[enclosure objectForKey:@"sparkle:dsaSignature"]];
- [self setMD5Sum:[enclosure objectForKey:@"sparkle:md5Sum"]];
-
- [self setFileURL:[NSURL URLWithString:[[enclosure objectForKey:@"url"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
-
- // Find the appropriate release notes URL.
- if ([dict objectForKey:@"sparkle:releaseNotesLink"])
- {
- [self setReleaseNotesURL:[NSURL URLWithString:[dict objectForKey:@"sparkle:releaseNotesLink"]]];
- }
- else if ([[self description] hasPrefix:@"http://"]) // if the description starts with http://, use that.
- {
- [self setReleaseNotesURL:[NSURL URLWithString:[self description]]];
- }
- else
- {
- [self setReleaseNotesURL:nil];
- }
-
- NSString *minVersion = [dict objectForKey:@"sparkle:minimumSystemVersion"];
- if(minVersion)
- [self setMinimumSystemVersion:minVersion];
- else
- [self setMinimumSystemVersion:@"10.3.0"];//sparkle doesn't run on 10.2-, so we don't have to worry about it
-
- // Try to find a version string.
- // Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
- // 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
- // 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
- // that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
- // underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
- // The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
- // Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
- NSString *newVersion = [enclosure objectForKey:@"sparkle:version"];
- if (!newVersion) // no sparkle:version attribute
- {
- // Separate the url by underscores and take the last component, as that'll be closest to the end,
- // then we remove the extension. Hopefully, this will be the version.
- NSArray *fileComponents = [[enclosure objectForKey:@"url"] componentsSeparatedByString:@"_"];
- if ([fileComponents count] > 1)
- newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
- }
- [self setFileVersion:newVersion];
-
- NSString *shortVersionString = [enclosure objectForKey:@"sparkle:shortVersionString"];
- if (shortVersionString)
+ self = [super init];
+ if (self)
{
- if (![[self fileVersion] isEqualToString:shortVersionString])
- shortVersionString = [shortVersionString stringByAppendingFormat:@"/%@", [self fileVersion]];
- [self setVersionString:shortVersionString];
+ [self setTitle:[dict objectForKey:@"title"]];
+ [self setDate:[dict objectForKey:@"pubDate"]];
+ [self setDescription:[dict objectForKey:@"description"]];
+
+ id enclosure = [dict objectForKey:@"enclosure"];
+ [self setDSASignature:[enclosure objectForKey:@"sparkle:dsaSignature"]];
+ [self setMD5Sum:[enclosure objectForKey:@"sparkle:md5Sum"]];
+
+ [self setFileURL:[NSURL URLWithString:[[enclosure objectForKey:@"url"] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]];
+
+ // Find the appropriate release notes URL.
+ if ([dict objectForKey:@"sparkle:releaseNotesLink"])
+ {
+ [self setReleaseNotesURL:[NSURL URLWithString:[dict objectForKey:@"sparkle:releaseNotesLink"]]];
+ }
+ else if ([[self description] hasPrefix:@"http://"]) // if the description starts with http://, use that.
+ {
+ [self setReleaseNotesURL:[NSURL URLWithString:[self description]]];
+ }
+ else
+ {
+ [self setReleaseNotesURL:nil];
+ }
+
+ NSString *minVersion = [dict objectForKey:@"sparkle:minimumSystemVersion"];
+ if(minVersion)
+ [self setMinimumSystemVersion:minVersion];
+ else
+ [self setMinimumSystemVersion:@"10.3.0"];//sparkle doesn't run on 10.2-, so we don't have to worry about it
+
+ // Try to find a version string.
+ // Finding the new version number from the RSS feed is a little bit hacky. There are two ways:
+ // 1. A "sparkle:version" attribute on the enclosure tag, an extension from the RSS spec.
+ // 2. If there isn't a version attribute, Sparkle will parse the path in the enclosure, expecting
+ // that it will look like this: http://something.com/YourApp_0.5.zip. It'll read whatever's between the last
+ // underscore and the last period as the version number. So name your packages like this: APPNAME_VERSION.extension.
+ // The big caveat with this is that you can't have underscores in your version strings, as that'll confuse Sparkle.
+ // Feel free to change the separator string to a hyphen or something more suited to your needs if you like.
+ NSString *newVersion = [enclosure objectForKey:@"sparkle:version"];
+ if (!newVersion) // no sparkle:version attribute
+ {
+ // Separate the url by underscores and take the last component, as that'll be closest to the end,
+ // then we remove the extension. Hopefully, this will be the version.
+ NSArray *fileComponents = [[enclosure objectForKey:@"url"] componentsSeparatedByString:@"_"];
+ if ([fileComponents count] > 1)
+ newVersion = [[fileComponents lastObject] stringByDeletingPathExtension];
+ }
+ [self setFileVersion:newVersion];
+
+ NSString *shortVersionString = [enclosure objectForKey:@"sparkle:shortVersionString"];
+ if (shortVersionString)
+ {
+ if (![[self fileVersion] isEqualToString:shortVersionString])
+ shortVersionString = [shortVersionString stringByAppendingFormat:@"/%@", [self fileVersion]];
+ [self setVersionString:shortVersionString];
+ }
+ else
+ [self setVersionString:[self fileVersion]];
}
- else
- [self setVersionString:[self fileVersion]];
return self;
}
View
@@ -15,11 +15,11 @@
NSBundle *hostBundle;
}
-- initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hostBundle;
+- (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hostBundle;
- (IBAction)relaunchNow:sender;
- (IBAction)relaunchLater:sender;
@end
-#endif
+#endif
View
@@ -11,20 +11,20 @@
@implementation SUAutomaticUpdateAlert
-- initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb;
+- (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb;
{
updateItem = [item retain];
hostBundle = [hb retain];
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUAutomaticUpdateAlert" ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
- NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingString:@"/Sparkle.framework"];
+ NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:@"SUAutomaticUpdateAlert" ofType:@"nib"];
}
- [super initWithWindowNibPath:path owner:self];
+ self = [super initWithWindowNibPath:path owner:self];
[self setShouldCascadeWindows:NO];
return self;
@@ -3,7 +3,7 @@
// Sparkle
//
// Created by Andy Matuschak on 12/21/07.
-// Copyright 2007 __MyCompanyName__. All rights reserved.
+// Copyright 2007 Andy Matuschak. All rights reserved.
//
#ifndef SUSTANDARDVERSIONCOMPARATOR_H
View
@@ -18,7 +18,7 @@
NSBundle *hostBundle;
}
-- initWithHostBundle:(NSBundle *)hostBundle;
+- (id)initWithHostBundle:(NSBundle *)hostBundle;
// Pass 0 for the max progress value to get an indeterminate progress bar.
// Pass nil for the status text to not show it.
View
@@ -11,17 +11,17 @@
@implementation SUStatusController
-- initWithHostBundle:(NSBundle *)hb
+- (id)initWithHostBundle:(NSBundle *)hb
{
hostBundle = [hb retain];
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUStatus" ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
- NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingString:@"/Sparkle.framework"];
+ NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:@"SUStatus" ofType:@"nib"];
}
- [super initWithWindowNibPath:path owner:self];
+ self = [super initWithWindowNibPath:path owner:self];
[self setShouldCascadeWindows:NO];
return self;
}
@@ -119,5 +119,3 @@ - (void)setStatusText:(NSString *)aStatusText
}
@end
-
-
View
@@ -16,7 +16,7 @@ @implementation SUSystemProfiler
+ (NSDictionary *)modelTranslationTable
{
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUModelTranslation" ofType:@"plist"];
- return [[NSDictionary alloc] initWithContentsOfFile:path];
+ return [[[NSDictionary alloc] initWithContentsOfFile:path] autorelease];
}
+ (NSMutableArray *)systemProfileInformationArrayWithHostBundle:(NSBundle *)hostBundle
@@ -30,7 +30,7 @@ + (NSMutableArray *)systemProfileInformationArrayWithHostBundle:(NSBundle *)host
int value = 0 ;
unsigned long length = sizeof(value) ;
- // OS version (Apple recommends using SystemVersion.plist instead of Gestalt() here, don't ask me why).
+ // OS version
NSString *currentSystemVersion = SUSystemVersionString();
if (currentSystemVersion != nil)
[profileArray addObject:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects:@"osVersion",@"OS Version",currentSystemVersion,currentSystemVersion,nil] forKeys:profileDictKeys]];
View
@@ -28,7 +28,7 @@ typedef enum
BOOL webViewFinishedLoading;
}
-- initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hostBundle;
+- (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hostBundle;
- (void)setDelegate:delegate;
- (IBAction)installUpdate:sender;
View
@@ -13,20 +13,20 @@
@implementation SUUpdateAlert
-- initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb
+- (id)initWithAppcastItem:(SUAppcastItem *)item hostBundle:(NSBundle *)hb
{
hostBundle = [hb retain];
updateItem = [item retain];
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"SUUpdateAlert" ofType:@"nib"];
if (path == nil) // Slight hack to resolve issues with running Sparkle in debug configurations.
{
- NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingString:@"/Sparkle.framework"];
+ NSString *frameworkPath = [[hostBundle sharedFrameworksPath] stringByAppendingPathComponent:@"Sparkle.framework"];
NSBundle *framework = [NSBundle bundleWithPath:frameworkPath];
path = [framework pathForResource:@"SUUpdateAlert" ofType:@"nib"];
}
- [super initWithWindowNibPath:path owner:self];
+ self = [super initWithWindowNibPath:path owner:self];
[self setShouldCascadeWindows:NO];
return self;
}
@@ -158,7 +158,7 @@ - (NSString *)titleText
- (NSString *)descriptionText
{
- return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available%Cyou have %@. Would you like to download it now?", nil), [hostBundle name], [updateItem versionString], 0x2014, [hostBundle displayVersion]];
+ return [NSString stringWithFormat:SULocalizedString(@"%@ %@ is now available%Cyou have %@. Would you like to download it now?", nil), [hostBundle name], [updateItem versionString], 0x2014, [hostBundle displayVersion]];
}
- (void)webView:(WebView *)sender didFinishLoadForFrame:frame
View
@@ -45,7 +45,7 @@ + (SUUpdater *)sharedUpdater
return [SUUpdater alloc];
}
-- init
+- (id)init
{
self = [super init];
if (self)
Oops, something went wrong.

0 comments on commit a7148d9

Please sign in to comment.