]> git.saurik.com Git - cydget.git/commitdiff
Commiting initial revision of cydget.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 2 Nov 2009 08:09:58 +0000 (08:09 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 2 Nov 2009 08:09:58 +0000 (08:09 +0000)
Tweak.mm [new file with mode: 0644]
Tweak.plist [new file with mode: 0644]
control [new file with mode: 0644]
make.sh [new file with mode: 0755]
makefile [new file with mode: 0644]

diff --git a/Tweak.mm b/Tweak.mm
new file mode 100644 (file)
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 <substrate.h>
+
+#include <Foundation/Foundation.h>
+#include <GraphicsServices/GraphicsServices.h>
+
+#import <SpringBoard/SBAwayController.h>
+#import <SpringBoard/SBAwayWindow.h>
+
+MSClassHook(SpringBoard)
+MSClassHook(SBAwayController)
+MSClassHook(SBAwayView)
+
+#define _trace() \
+    NSLog(@"_trace(%s:%u)@%s %d", __FILE__, __LINE__, __FUNCTION__, active_)
+#define _not(type) \
+    static_cast<type>(~type())
+
+static bool menu_;
+static unsigned lock_;
+
+static _H<NSArray> 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 (file)
index 0000000..f94fd41
--- /dev/null
@@ -0,0 +1 @@
+Filter = {Bundles = ("com.apple.springboard");};
diff --git a/control b/control
new file mode 100644 (file)
index 0000000..f5dd29a
--- /dev/null
+++ b/control
@@ -0,0 +1,13 @@
+Package: cydget
+Priority: optional
+Section: Tweaks
+Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
+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) <saurik@saurik.com>
+Depiction: http://cydia.saurik.com/info/cydget/
+Tag: purpose::extension, role::enduser
diff --git a/make.sh b/make.sh
new file mode 100755 (executable)
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 (file)
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