From 3215ed85f3cf21e6bcb4979a522c0b6e41c20b3d Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 24 Jan 2014 05:37:16 -0800 Subject: [PATCH] Allow relative URLs to be used in CYConfiguration. --- CydgetLoader.mm | 14 ++++++++++++-- LockScreen.mm | 7 +++++-- PhotoExample.cydget/Info.plist | 2 +- Welcome.cydget/Info.plist | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/CydgetLoader.mm b/CydgetLoader.mm index 3ea3c7b..a06d860 100644 --- a/CydgetLoader.mm +++ b/CydgetLoader.mm @@ -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; diff --git a/LockScreen.mm b/LockScreen.mm index c039c09..4c8f190 100644 --- a/LockScreen.mm +++ b/LockScreen.mm @@ -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; diff --git a/PhotoExample.cydget/Info.plist b/PhotoExample.cydget/Info.plist index e6ff261..31e62c7 100644 --- a/PhotoExample.cydget/Info.plist +++ b/PhotoExample.cydget/Info.plist @@ -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"; }; diff --git a/Welcome.cydget/Info.plist b/Welcome.cydget/Info.plist index f0fbfd0..436e790 100644 --- a/Welcome.cydget/Info.plist +++ b/Welcome.cydget/Info.plist @@ -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"; }; -- 2.50.0