]> git.saurik.com Git - cydget.git/commitdiff
Allow relative URLs to be used in CYConfiguration.
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 24 Jan 2014 13:37:16 +0000 (05:37 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 24 Jan 2014 13:49:04 +0000 (05:49 -0800)
CydgetLoader.mm
LockScreen.mm
PhotoExample.cydget/Info.plist
Welcome.cydget/Info.plist

index 3ea3c7b8b55ca12d80fd589130a4cf013f06976b..a06d860d9ed950c79f0aad160068481f11685028 100644 (file)
@@ -71,6 +71,7 @@ static unsigned online_;
 }
 
 + (NSDictionary *) currentConfiguration;
++ (NSString *) currentPath;
 
 @end
 
@@ -81,6 +82,11 @@ static unsigned online_;
     return [cydget objectForKey:@"CYConfiguration"] ?: [cydget objectForKey:@"Configuration"];
 }
 
++ (NSDictionary *) currentPath {
+    NSDictionary *cydget([cydgets_ objectAtIndex:active_]);
+    return [cydget objectForKey:@"CYPath"];
+}
+
 @end
 
 @interface SBUserAgent : NSObject
@@ -250,9 +256,13 @@ static void CydgetSetup() {
 
     cydgets_ = [NSMutableArray arrayWithCapacity:4];
     for (NSDictionary *cydget in cydgets)
-        if ([[cydget objectForKey:@"Active"] boolValue])
-            if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.cydget/Info.plist", Cydgets_, [cydget objectForKey:@"Name"]]])
+        if ([[cydget objectForKey:@"Active"] boolValue]) {
+            NSString *path([NSString stringWithFormat:@"%@/%@.cydget/Info.plist", Cydgets_, [cydget objectForKey:@"Name"]]);
+            if (NSMutableDictionary *info = [NSMutableDictionary dictionaryWithContentsOfFile:path]) {
+                [info setObject:path forKey:@"CYPath"];
                 [cydgets_ addObject:info];
+            }
+        }
 
     if ([cydgets_ count] == 0)
         cydgets_ = nil;
index c039c095f91ebe22d063575c9fb05bb3d4a9d290..4c8f190a66fdb89ddf11aea0a544e3eb48daaea6 100644 (file)
@@ -129,6 +129,7 @@ typedef uint16_t UChar;
 
 @protocol CydgetController
 - (NSDictionary *) currentConfiguration;
+- (NSString *) currentPath;
 @end
 
 static Class $CydgetController(objc_getClass("CydgetController"));
@@ -1135,11 +1136,13 @@ static void $UIWebViewWebViewDelegate$webView$didClearWindowObject$forFrame$(UIW
 }
 
 - (void) loadView {
+    NSURL *base([NSURL fileURLWithPath:[$CydgetController currentPath]]);
+
     if (NSString *background = [configuration_ objectForKey:@"Background"])
-        background_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:background]];
+        background_ = [[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:background relativeToURL:base]];
 
     if (NSString *homepage = [configuration_ objectForKey:@"Homepage"])
-        [self setView:[[[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:homepage]] autorelease]];
+        [self setView:[[[WebCydgetLockScreenView alloc] initWithURL:[NSURL URLWithString:homepage relativeToURL:base]] autorelease]];
     else if (kCFCoreFoundationVersionNumber < 800 && background_ != nil) {
         [self setView:[background_ autorelease]];
         background_ = nil;
index e6ff261917bca8d3b6d8b404b3b294ca34dbfc2f..31e62c722da2f7fae8967c15cf0b34e9c9a6127b 100644 (file)
@@ -2,7 +2,7 @@ CYTagline = "a lame example Cydget that renders Camera photos";
 CYPlugin = "WebCycriptLockScreen";
 
 CYConfiguration = {
-    Homepage = "file:///System/Library/LockCydgets/PhotoExample.cydget/index.html";
+    Background = "index.html";
     CycriptURLs = "^file:///System/Library/LockCydgets/PhotoExample\\.cydget/index\\.html$";
     Scrollable = "NO";
 };
index f0fbfd0215d883f915fe29c8b791ca32d9f1d352..436e7901fcbc95afce293f643be44107eca10102 100644 (file)
@@ -2,7 +2,7 @@ CYTagline = "a warm welcome to the new cydget experience";
 CYPlugin = "WebCycriptLockScreen";
 
 CYConfiguration = {
-    Homepage = "file:///System/Library/LockCydgets/Welcome.cydget/Welcome.html";
+    Homepage = "Welcome.html";
     CycriptURLs = "^file:///System/Library/LockCydgets/Welcome\\.cydget/Welcome\\.html$";
     Scrollable = "NO";
 };