From e6cd4deed95b7b1a4b945e073a590f108a2809ba Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 2 Nov 2009 08:09:58 +0000 Subject: [PATCH 1/1] Commiting initial revision of cydget. --- Tweak.mm | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Tweak.plist | 1 + control | 13 +++++ make.sh | 2 + makefile | 4 ++ 5 files changed, 171 insertions(+) create mode 100644 Tweak.mm create mode 100644 Tweak.plist create mode 100644 control create mode 100755 make.sh create mode 100644 makefile diff --git a/Tweak.mm b/Tweak.mm new file mode 100644 index 0000000..c1edf62 --- /dev/null +++ b/Tweak.mm @@ -0,0 +1,151 @@ +/* Cydget - open-source IntelliScreen replacement + * Copyright (C) 2009 Jay Freeman (saurik) +*/ + +/* + * Redistribution and use in source and binary + * forms, with or without modification, are permitted + * provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the + * above copyright notice, this list of conditions + * and the following disclaimer. + * 2. Redistributions in binary form must reproduce the + * above copyright notice, this list of conditions + * and the following disclaimer in the documentation + * and/or other materials provided with the + * distribution. + * 3. The name of the author may not be used to endorse + * or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, + * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +#include + +#include +#include + +#import +#import + +MSClassHook(SpringBoard) +MSClassHook(SBAwayController) +MSClassHook(SBAwayView) + +#define _trace() \ + NSLog(@"_trace(%s:%u)@%s %d", __FILE__, __LINE__, __FUNCTION__, active_) +#define _not(type) \ + static_cast(~type()) + +static bool menu_; +static unsigned lock_; + +static _H cydgets_; +static size_t active_ = _not(size_t); + +@interface NSDictionary (Cydgets) +- (void) enableCydget:(SBAwayController *)away; +- (void) disableCydget:(SBAwayController *)away; +@end + +@implementation NSDictionary (Cydgets) + +- (void) enableCydget:(SBAwayController *)away { + [away enableLockScreenBundleWithName:[self objectForKey:@"Plugin"]]; +} + +- (void) disableCydget:(SBAwayController *)away { + [away disableLockScreenBundleWithName:[self objectForKey:@"Plugin"]]; +} + +@end + +MSHook(BOOL, SBAwayController$handleMenuButtonTap, SBAwayController *self, SEL sel) { + unsigned lock(lock_); + + if (!_SBAwayController$handleMenuButtonTap(self, sel) && lock != 2) { + if (active_ != _not(size_t)) + [[cydgets_ objectAtIndex:active_] disableCydget:self]; + + size_t count([cydgets_ count]); + if ((++active_ %= count + 1) == count) + active_ = _not(size_t); + else + [[cydgets_ objectAtIndex:active_] enableCydget:self]; + } + + return YES; +} + +MSHook(void, SBAwayController$_undimScreen, SBAwayController *self, SEL sel) { + if (lock_ == 1) + lock_ = 2; + _SBAwayController$_undimScreen(self, sel); +} + +MSHook(void, SBAwayController$undimScreen, SBAwayController *self, SEL sel) { + lock_ = menu_ ? 1 : 0; + _SBAwayController$undimScreen(self, sel); +} + +static void Deactivate_(SBAwayController *self) { + if (active_ != _not(size_t)) { + [[cydgets_ objectAtIndex:active_] disableCydget:self]; + active_ = _not(size_t); + } +} + +MSHook(void, SBAwayController$finishedDimmingScreen, SBAwayController *self, SEL sel) { + Deactivate_(self); + _SBAwayController$finishedDimmingScreen(self, sel); +} + +MSHook(void, SpringBoard$menuButtonUp$, UIView *self, SEL sel, GSEventRef event) { + menu_ = true; + _SpringBoard$menuButtonUp$(self, sel, event); + menu_ = false; +} + +MSHook(void, SBAwayView$addGestureRecognizer$, UIView *self, SEL sel, id gr) { + //_SBAwayView$addGestureRecognizer$(self, sel, gr); +} + +MSInstanceMessageHook1(void, SBAwayController, _finishedUnlockAttemptWithStatus, BOOL, status) { + if (status) + Deactivate_(self); + MSOldCall(status); +} + +#define Cydgets_ @"/System/Library/LockCydgets" + +MSInitialize { _pooled + cydgets_ = [NSMutableArray arrayWithCapacity:4]; + + for (NSString *plist in [[NSFileManager defaultManager] directoryContentsAtPath:Cydgets_]) + if ([plist hasSuffix:@".plist"]) + [cydgets_ addObject:[NSDictionary dictionaryWithContentsOfFile:[Cydgets_ stringByAppendingPathComponent:plist]]]; + + MSHookMessage1(SpringBoard, menuButtonUp); + + MSHookMessage0(SBAwayController, handleMenuButtonTap); + MSHookMessage0(SBAwayController, _undimScreen); + MSHookMessage0(SBAwayController, undimScreen); + MSHookMessage0(SBAwayController, finishedDimmingScreen); + + MSHookMessage1(SBAwayView, addGestureRecognizer); +} diff --git a/Tweak.plist b/Tweak.plist new file mode 100644 index 0000000..f94fd41 --- /dev/null +++ b/Tweak.plist @@ -0,0 +1 @@ +Filter = {Bundles = ("com.apple.springboard");}; diff --git a/control b/control new file mode 100644 index 0000000..f5dd29a --- /dev/null +++ b/control @@ -0,0 +1,13 @@ +Package: cydget +Priority: optional +Section: Tweaks +Maintainer: Jay Freeman (saurik) +Architecture: iphoneos-arm +Version: 0.9.3064-1 +Description: framework for managing lock screen plugins +Name: Cydget +Depends: mobilesubstrate (>= 0.9.2587-1) +Replaces: cydialer (<< 0.9.17) +Author: Jay Freeman (saurik) +Depiction: http://cydia.saurik.com/info/cydget/ +Tag: purpose::extension, role::enduser diff --git a/make.sh b/make.sh new file mode 100755 index 0000000..6d212b3 --- /dev/null +++ b/make.sh @@ -0,0 +1,2 @@ +#!/bin/bash +PKG_ARCH=iphoneos-arm /apl/tel/exec.sh - make package "$@" diff --git a/makefile b/makefile new file mode 100644 index 0000000..1d7f33c --- /dev/null +++ b/makefile @@ -0,0 +1,4 @@ +name := CydgetLoader +flags := -framework UIKit -framework AddressBook +base := $(shell cd ~; pwd)/menes/tweaks +include $(base)/tweak.mk -- 2.45.2