Permalink
Browse files

Check if the Passenger module is installed on start and when becoming…

… active.
  • Loading branch information...
1 parent 7c89e0c commit 8f9bda3b791d09ef5a95fca0a901306cf6dd33da @Manfred Manfred committed Mar 11, 2011
Showing with 17 additions and 4 deletions.
  1. +4 −1 app/controllers/PassengerPref.h
  2. +11 −1 app/controllers/PassengerPref.m
  3. +2 −2 app/utils/CLI.m
@@ -4,7 +4,8 @@
@interface PassengerPref : NSPreferencePane
{
- BOOL authorized, dirty;
+ BOOL authorized, dirty, passengerModuleInstalled;
+
NSMutableArray *applications;
IBOutlet NSColor *textStateColor;
@@ -19,6 +20,7 @@
@property (assign, getter=isAuthorized) BOOL authorized;
@property (assign, getter=isDirty) BOOL dirty;
+@property (assign, getter=isPassengerModuleInstalled) BOOL passengerModuleInstalled;
@property (assign) NSMutableArray *applications;
@property (assign) NSColor *textStateColor;
@@ -49,5 +51,6 @@
- (BOOL) requestAuthorization;
- (void) checkForDirtyApplications;
+- (void) checkIfPassengerModuleInstalled;
@end
@@ -2,7 +2,7 @@
@implementation PassengerPref
-@synthesize authorized, dirty;
+@synthesize authorized, dirty, passengerModuleInstalled;
@synthesize applications;
@synthesize textStateColor;
@@ -16,6 +16,8 @@ - (void) mainViewDidLoad {
[self setupAuthorizationView];
[self setupApplicationView];
+ [self checkIfPassengerModuleInstalled];
+
[[NSHelpManager sharedHelpManager] registerBooksInBundle:[self bundle]];
[[NSNotificationCenter defaultCenter] addObserver:self
@@ -136,6 +138,7 @@ - (void)didChangeValueForKey:(NSString *)key {
- (void) paneWillBecomeActive:(id)sender {
[self reloadApplications];
+ [self checkIfPassengerModuleInstalled];
}
#pragma Actions
@@ -291,4 +294,11 @@ - (void)checkForDirtyApplications {
[self setDirty:NO];
}
+- (void)checkIfPassengerModuleInstalled {
+ // If we don't know or when it's not yet the case, check.
+ if (!passengerModuleInstalled) {
+ [self setPassengerModuleInstalled:[[CLI sharedInstance] isPassengerModuleInstalled]];
+ }
+}
+
@end
View
@@ -75,7 +75,8 @@ - (void) restart {
}
- (BOOL) isPassengerModuleInstalled {
- NSDictionary *info = [self execute:[NSArray arrayWithObject:@"info"]];
+ NSLog(@"Checking if the Passenger module is installed");
+ NSDictionary *info = [self execute:[NSArray arrayWithObjects:@"info", @"-m", nil] elevated:NO];
if (info) {
NSNumber *isInstalled = [info objectForKey:@"passenger_module_installed"];
return [isInstalled boolValue];
@@ -118,7 +119,6 @@ - (id) execute:(NSArray *)arguments elevated:(BOOL)elevated {
data = [file readDataToEndOfFile];
[file closeFile];
if ([data length] > 0) {
- NSLog(@"ppane returned: %@", data);
result = [[CJSONDeserializer deserializer] deserialize:data error:&error];
if (error) {
NSLog(@"ppane returned invalid JSON: %@", [error description]);

0 comments on commit 8f9bda3

Please sign in to comment.