Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[NEW] Installer can update older versions.

  • Loading branch information...
commit 63f40ee2e16f742b3d6b576f02e59c43d44bdf1f 1 parent d2843b1
@rentzsch authored
View
4 ClickToFlash.xcodeproj/project.pbxproj
@@ -251,7 +251,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
- shellScript = "if [ $BUILD_STYLE != \"Release\" ]; then\n echo \"Could not generate .zip file.\"\n\techo \"Active Configuration needs to be set to 'Release'.\"\n\texit 1\nfi\n\ncd \"$BUILT_PRODUCTS_DIR\"\n\nDIR=\"ClickToFlash\"\n\nrm -rf \"$DIR\" > /dev/null\nmkdir \"$DIR\"\n/Developer/Tools/CpMac -r \"Install ClickToFlash.app\" $DIR\n\nmkdir \"$DIR/Source\"\ncp -r \"$SOURCE_ROOT\"/* \"$DIR/Source\"\n\nfind \"$DIR/Source/ClickToFlash.xcodeproj\" -not -name \"project.pbxproj\" -depth 1 | xargs rm -rf\n\nzip -r ClickToFlash.zip \"$DIR\"\nrm -rf \"$DIR\" > /dev/null\n\nopen .";
+ shellScript = "if [ $BUILD_STYLE != \"Release\" ]; then\n echo \"Could not generate .zip file.\"\n\techo \"Active Configuration needs to be set to 'Release'.\"\n\texit 1\nfi\n\ncd \"$BUILT_PRODUCTS_DIR\"\n\nDIR=\"ClickToFlash\"\n\nrm -rf \"$DIR\" > /dev/null\nmkdir \"$DIR\"\n/Developer/Tools/CpMac -r \"Install ClickToFlash $PRODUCT_VERSION.app\" $DIR\n\nmkdir \"$DIR/Source\"\ncp -r \"$SOURCE_ROOT\"/* \"$DIR/Source\"\n\nfind \"$DIR/Source/ClickToFlash.xcodeproj\" -not -name \"project.pbxproj\" -depth 1 | xargs rm -rf\n\nzip -r ClickToFlash-$PRODUCT_VERSION.zip \"$DIR\"\nrm -rf \"$DIR\" > /dev/null\n\nopen .";
};
/* End PBXShellScriptBuildPhase section */
@@ -410,6 +410,7 @@
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = NO;
+ PRODUCT_VERSION = 1.1;
};
name = Debug;
};
@@ -417,6 +418,7 @@
isa = XCBuildConfiguration;
buildSettings = {
COPY_PHASE_STRIP = YES;
+ PRODUCT_VERSION = 1.1;
};
name = Release;
};
View
91 Installer/CTFInstaller.m
@@ -24,6 +24,14 @@ of this software and associated documentation files (the "Software"), to deal
*/
+/*
+ - INSTALL missing ~/Library/Internet Plug-Ins
+ - INSTALL file where "Internet Plug-Ins" folder should be
+ - INSTALL no ClickToFlash
+ - UPDATE ClickToFlash 1.0 installed
+ - UPDATE ClickToFlash 1.0+rentzsch
+ - REMOVE ClickToFlash 1.1
+*/
#import "CTFInstaller.h"
@@ -34,6 +42,7 @@ @interface CTFInstaller (Internal)
- (NSString *) pathToClickToFlash;
- (id) installClickToFlash;
- (id) removeClickToFlash;
+- (id) updateClickToFlash;
@end
@@ -55,15 +64,31 @@ - (void)finishLaunching
}
} else {
- NSString *title = NSLocalizedString(@"Remove ClickToFlash", @"Remove ClickToFlash");
- NSString *message = NSLocalizedString(@"ClickToFlash is currently installed. Would you like to remove it?", @"ClickToFlash is currently installed. Would you like to remove it?");
+ NSString *thisVersion = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
+ NSString *installedVersion = [[[NSBundle bundleWithPath:pathToClickToFlash] infoDictionary] objectForKey:@"CFBundleShortVersionString"];
- NSInteger result = NSRunAlertPanel(title, message, NSLocalizedString(@"Remove", @"Remove"), NSLocalizedString(@"Cancel", @"Cancel"), nil);
-
- if (result == NSAlertDefaultReturn) {
- [self removeClickToFlash];
+ if([installedVersion isEqualToString:thisVersion]) {
+ NSString *title = NSLocalizedString(@"Remove ClickToFlash", @"Remove ClickToFlash");
+ NSString *message = NSLocalizedString(@"ClickToFlash is currently installed. Would you like to remove it?", @"ClickToFlash is currently installed. Would you like to remove it?");
+
+ NSInteger result = NSRunAlertPanel(title, message, NSLocalizedString(@"Remove", @"Remove"), NSLocalizedString(@"Cancel", @"Cancel"), nil);
+
+ if (result == NSAlertDefaultReturn) {
+ [self removeClickToFlash];
+ }
+ } else {
+ NSString *title = NSLocalizedString(@"Update ClickToFlash", @"Update ClickToFlash");
+ NSString *message = NSLocalizedString(@"An older version of ClickToFlash is currently installed. Would you like to update it?", @"An older version of ClickToFlash is currently installed. Would you like to update it?");
+
+ NSInteger result = NSRunAlertPanel(title, message, NSLocalizedString(@"Update", @"Update"), NSLocalizedString(@"Cancel", @"Cancel"), nil);
+
+ if (result == NSAlertDefaultReturn) {
+ [self updateClickToFlash];
+ }
}
}
+
+ [self terminate:nil];
}
@@ -71,8 +96,9 @@ - (NSString *) pathToClickToFlash
{
NSString *path = [kInternetPlugins @"/ClickToFlash.plugin" stringByStandardizingPath];
NSBundle *bundle = [NSBundle bundleWithPath:path];
-
- if ([[bundle bundleIdentifier] isEqualToString:@"com.google.code.p.clicktoflash"]) {
+ NSString *bundleID = [bundle bundleIdentifier];
+
+ if ([bundleID isEqualToString:@"com.google.code.p.clicktoflash"] || [bundleID isEqualToString:@"com.github.rentzsch.clicktoflash"]) {
return path;
}
@@ -88,30 +114,25 @@ - (id) installClickToFlash
BOOL isDirectory = NO;
BOOL doesPluginsExist = [[NSFileManager defaultManager] fileExistsAtPath:toPath isDirectory:&isDirectory];
-
- if (doesPluginsExist && !isDirectory) {
- [[NSFileManager defaultManager] removeFileAtPath:toPath handler:nil];
- }
if (!doesPluginsExist) {
[[NSFileManager defaultManager] createDirectoryAtPath:toPath attributes:nil];
+ } else if (doesPluginsExist && !isDirectory) {
+ [[NSFileManager defaultManager] removeFileAtPath:toPath handler:nil];
+ [[NSFileManager defaultManager] createDirectoryAtPath:toPath attributes:nil];
}
toPath = [toPath stringByAppendingPathComponent:@"ClickToFlash.plugin"];
- NSString *title = NSLocalizedString(@"Install ClickToFlash", @"Install ClickToFlash");
-
if ([[NSFileManager defaultManager] copyPath:fromPath toPath:toPath handler:nil]) {
- NSString *message = NSLocalizedString(@"ClickToFlash has been installed. Quit and relaunch Safari to activate ClickToFlash.", @"ClickToFlash has been installed. Quit and relaunch Safari to activate ClickToFlash.");
-
- NSRunAlertPanel(title, message, NSLocalizedString(@"OK", @"OK"), nil, nil);
+ NSString *message = NSLocalizedString(@"Quit and relaunch Safari to activate ClickToFlash.", nil);
+ NSRunAlertPanel(NSLocalizedString(@"ClickToFlash Installed", nil),
+ message, nil, nil, nil);
} else {
- NSString *message = NSLocalizedString(@"ClickToFlash could not be installed.", @"ClickToFlash could not be installed.");
-
- NSRunAlertPanel(title, message, NSLocalizedString(@"OK", @"OK"), nil, nil);
+ NSString *message = NSLocalizedString(@"ClickToFlash could not be installed.", nil);
+ NSRunAlertPanel(NSLocalizedString(@"Installed Failed", nil),
+ message, nil, nil, nil);
}
-
- [self terminate:self];
}
@@ -120,16 +141,30 @@ - (id) removeClickToFlash
NSString *path = [self pathToClickToFlash];
if ([[NSFileManager defaultManager] removeFileAtPath:path handler:nil]) {
- NSString *title = NSLocalizedString(@"Remove ClickToFlash", @"Remove ClickToFlash");
- NSString *message = NSLocalizedString(@"ClickToFlash has been removed.", @"ClickToFlash has been removed.");
-
- NSRunAlertPanel(title, message, NSLocalizedString(@"OK", @"OK"), nil, nil);
-
- [self terminate:self];
+ NSString *message = NSLocalizedString(@"ClickToFlash has been removed.", nil);
+ NSRunAlertPanel(NSLocalizedString(@"ClickToFlash Removed", nil), message, nil, nil, nil);
}
}
+- (id) updateClickToFlash
+{
+ NSString *installedPluginPath = [self pathToClickToFlash];
+
+ BOOL success = [[NSFileManager defaultManager] removeFileAtPath:installedPluginPath handler:nil];
+
+ if (success) {
+ NSString *fromPath = [[NSBundle mainBundle] pathForResource:@"ClickToFlash" ofType:@"plugin"];
+ success = [[NSFileManager defaultManager] copyPath:fromPath toPath:installedPluginPath handler:nil];
+ }
+
+ NSString *message = success
+ ? NSLocalizedString(@"ClickToFlash has been updated. Please quit and relaunch Safari.", nil)
+ : NSLocalizedString(@"ClickToFlash could not be updated.", nil);
+ NSRunAlertPanel(NSLocalizedString(@"Update ClickToFlash", nil), message, nil, nil, nil);
+}
+
+
@end
View
BIN  Installer/English.lproj/Localizable.strings
Binary file not shown
View
2  Installer/Info-Installer.plist
@@ -24,5 +24,7 @@
<string>Installer</string>
<key>NSPrincipalClass</key>
<string>CTFInstaller</string>
+ <key>CFBundleShortVersionString</key>
+ <string>${PRODUCT_VERSION}</string>
</dict>
</plist>
View
2  Plugin/Info-Plugin.plist
@@ -21,7 +21,7 @@
<key>CFBundleVersion</key>
<string>700</string>
<key>CFBundleShortVersionString</key>
- <string>1.1</string>
+ <string>${PRODUCT_VERSION}</string>
<key>NSPrincipalClass</key>
<string>CTFClickToFlashPlugin</string>
<key>WebPluginDescription</key>
View
2  README.markdown
@@ -4,6 +4,8 @@
ClickToFlash is a WebKit plug-in that prevents automatic loading of Adobe Flash content. If you want to see the content, you can opt-in by clicking on it or adding an entire site to its whitelist.
+Try control-clicking (or right-clicking) on a unloaded Flash box to access ClickToFlash's contextual menu which allow you to do advanced things like edit its whitelist.
+
Please [report bugs and request features](http://rentzsch.lighthouseapp.com/projects/24342-clicktoflash/tickets/new) on the [Lighthouse ClickToFlash project site](http://rentzsch.lighthouseapp.com/projects/24342-clicktoflash/tickets?q=all).
##Version History
Please sign in to comment.
Something went wrong with that request. Please try again.