Made application URLs configurable through the info.plist file.
authorMiltiadis Vasilakis <mvasilak@gmail.com>
Tue, 11 Oct 2011 09:38:09 +0000 (12:38 +0300)
committerMiltiadis Vasilakis <mvasilak@gmail.com>
Tue, 11 Oct 2011 09:38:09 +0000 (12:38 +0300)
pithos-apple-common
pithos-macos/PithosPreferencesController.m
pithos-macos/pithos-macos-Info.plist
pithos-macos/pithos_macosAppDelegate.h
pithos-macos/pithos_macosAppDelegate.m

index 78355da..20e74a1 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 78355da33ddaffcb7bc9bd460cb38f184962f3bf
+Subproject commit 20e74a13c1a904064b0544b398b677cc30f28ae8
index b3807a9..43f6d2b 100644 (file)
 - (IBAction)authenticationLogin:(id)sender {
     // XXX hardcoded for now
     NSProcessInfo *processInfo = [NSProcessInfo processInfo];
-    NSString *loginURL = [NSString stringWithFormat:@"https://pithos.dev.grnet.gr/login?next=pithos://%@_%d",
-                          [processInfo processName], [processInfo processIdentifier]];
+    NSString *loginURL = [NSString stringWithFormat:@"%@?next=pithos://%@_%d",
+                          ((pithos_macosAppDelegate *)[[NSApplication sharedApplication] delegate]).loginURLPrefix, 
+                          [processInfo processName], 
+                          [processInfo processIdentifier]];
     if ([authenticationRenewCheckBox state] == NSOnState)
         loginURL = [loginURL stringByAppendingString:@"&renew="];
     NSLog(@"loginURL: %@", loginURL);
index 4752f1e..2796712 100644 (file)
        <string>1.0</string>
        <key>CFBundleSignature</key>
        <string>????</string>
-       <key>CFBundleVersion</key>
-       <string>1</string>
-       <key>LSMinimumSystemVersion</key>
-       <string>${MACOSX_DEPLOYMENT_TARGET}</string>
-       <key>NSMainNibFile</key>
-       <string>MainMenu</string>
-       <key>NSPrincipalClass</key>
-       <string>NSApplication</string>
        <key>CFBundleURLTypes</key>
        <array>
                <dict>
                        </array>
                </dict>
        </array>
+       <key>CFBundleVersion</key>
+       <string>1</string>
+       <key>LSMinimumSystemVersion</key>
+       <string>${MACOSX_DEPLOYMENT_TARGET}</string>
+       <key>NSMainNibFile</key>
+       <string>MainMenu</string>
+       <key>NSPrincipalClass</key>
+       <string>NSApplication</string>
+       <key>PithosStorageURLPrefix</key>
+       <string>https://pithos.dev.grnet.gr/v1</string>
+       <key>PithosPublicURLPrefix</key>
+       <string>https://pithos.dev.grnet.gr</string>
+       <key>PithosLoginURLPrefix</key>
+       <string>https://pithos.dev.grnet.gr/login</string>
+       <key>PithosAboutURL</key>
+       <string>https://pithos.dev.grnet.gr/docs</string>
 </dict>
 </plist>
index cfeb2e2..7d999ef 100644 (file)
@@ -50,6 +50,8 @@
     
     NSString *storageURLPrefix;
     NSString *publicURLPrefix;
+    NSString *loginURLPrefix;
+    NSString *aboutURL;
 }
 
 - (void)handleAppleEvent:(NSAppleEventDescriptor *)event withReplyEvent: (NSAppleEventDescriptor *)replyEvent;
@@ -61,5 +63,7 @@
 
 @property (nonatomic, readonly) NSString *storageURLPrefix;
 @property (nonatomic, readonly) NSString *publicURLPrefix;
+@property (nonatomic, readonly) NSString *loginURLPrefix;
+@property (nonatomic, readonly) NSString *aboutURL;
 
 @end
index 2dd9d48..76944c3 100644 (file)
 #import "ASIDownloadCache.h"
 
 @implementation pithos_macosAppDelegate
-@synthesize storageURLPrefix, publicURLPrefix;
+@synthesize storageURLPrefix, publicURLPrefix, loginURLPrefix, aboutURL;
 
 - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
-    // XXX hardcoded for now
-    storageURLPrefix = @"https://pithos.dev.grnet.gr/v1";
-    publicURLPrefix = @"https://pithos.dev.grnet.gr";
+    NSURL *testURL;
+    storageURLPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"PithosStorageURLPrefix"];
+    if (!storageURLPrefix) {
+        storageURLPrefix = [NSString stringWithString:@"https://pithos.dev.grnet.gr/v1"];
+    } else {
+        testURL = [NSURL URLWithString:storageURLPrefix];
+        if (!testURL || !testURL.scheme || !testURL.host)
+            storageURLPrefix = [NSString stringWithString:@"https://pithos.dev.grnet.gr/v1"];
+    }
+    [storageURLPrefix retain];
+    
+    publicURLPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"PithosPublicURLPrefix"];
+    if (!publicURLPrefix) {
+        publicURLPrefix = [NSString stringWithString:@"https://pithos.dev.grnet.gr"];
+    } else {
+        testURL = [NSURL URLWithString:publicURLPrefix];
+        if (!testURL || !testURL.scheme || !testURL.host)
+            publicURLPrefix = [NSString stringWithString:@"https://pithos.dev.grnet.gr"];
+    }
+    [publicURLPrefix retain];
+    
+    loginURLPrefix = [[NSUserDefaults standardUserDefaults] stringForKey:@"PithosLoginURLPrefix"];
+    if (!loginURLPrefix) {
+        loginURLPrefix = [NSString stringWithString:@"https://pithos.dev.grnet.gr/login"];
+    } else {
+        testURL = [NSURL URLWithString:loginURLPrefix];
+        if (!testURL || !testURL.scheme || !testURL.host)
+            loginURLPrefix = [NSString stringWithString:@"https://pithos.dev.grnet.gr/login"];
+    }
+    [loginURLPrefix retain];
+
+    aboutURL = [[NSUserDefaults standardUserDefaults] stringForKey:@"PithosAboutURL"];
+    if (!aboutURL) {
+        aboutURL = [NSString stringWithString:@"https://pithos.dev.grnet.gr/docs"];
+    } else {
+        testURL = [NSURL URLWithString:aboutURL];
+        if (!testURL || !testURL.scheme || !testURL.host)
+            aboutURL = [NSString stringWithString:@"https://pithos.dev.grnet.gr/docs"];
+    }
+    [aboutURL retain];
     
     [[NSAppleEventManager sharedAppleEventManager] setEventHandler:self 
                                                        andSelector:@selector(handleAppleEvent:withReplyEvent:) 
 }
 
 - (IBAction)aboutPithos:(id)sender {
-    [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://pithos.dev.grnet.gr/docs"]];
+    [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:self.aboutURL]];
 }
 
 #pragma mark -