diff --git a/Hack.xm b/Hack.xm new file mode 100644 index 0000000..fe8f1fa --- /dev/null +++ b/Hack.xm @@ -0,0 +1,129 @@ +/* Imports */ +#import +#import +#include + + +/* Definitions (Macros) */ +#define Bundle_Path @"/Library/MobileSubstrate/DynamicLibraries/MovieBoxBundle.bundle" +#define Queued_Update @"Update has been queued and will commence soon." +#define AlertTitle @"Movie Box Updater" +#define AlertDownload @"Download Working" +#define AlertDismiss @"Dismiss" +#define AlertOK @"OK" + +#define UpdateCheck_URL @"http://gh0stbyte.ga/iOS/moviebox.json" +#define UpdateCheck_Local @"3.6.4" +#define UpdateCheck_Alert @"There is an update available for this tweak." + + +/* Fake interface to allow calling of the update function, along with new sharedInstance */ +@interface UpdatesManager : NSObject +/* Fool the compiler into thinking that we have the method */ +- (void)requestUpdatedDataBaseWithFileURL:(NSString*)url; +/* Create sharedInstance method */ ++ (id)sharedInstance; +@end + +/* Variables */ +static UIView *header; +static UpdatesManager *sharedInstance = nil; +NSString *updateURL; + + +%hook MenuViewController + +/* When it sets up the headerView */ +-(UIView*)headerView { + /* set the headerview to itself */ + header = %orig; + /* Give it a second to create the header before adding to it */ + [NSTimer scheduledTimerWithTimeInterval:1.0 + target:self + selector:@selector(setupButton) + userInfo:nil + repeats:NO]; + /* return the header variable which is itself */ + return header; +} + +%new +/* New function called 1 second after headerView called allowing time for it to be created */ +-(void)setupButton { + + // Update Available Check + NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:UpdateCheck_URL]]; + [NSURLConnection sendAsynchronousRequest:request + queue:[NSOperationQueue mainQueue] + completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) { + NSDictionary *myjson = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL]; + updateURL = @"http://sbfunapi.cc/data/data_en.zip"; + NSString *current_version = [myjson objectForKey:@"current_version"]; + + if(![current_version isEqualToString:UpdateCheck_Local]) { + UIAlertView *a = [[UIAlertView alloc] initWithTitle:AlertTitle message:UpdateCheck_Alert delegate:self cancelButtonTitle:AlertOK otherButtonTitles:@"Update", nil]; + [a show]; + [a release]; + } + + }]; + + + CGFloat height = CGRectGetHeight(header.bounds); + CGFloat width = CGRectGetWidth(header.bounds); + + // Create a new button that will trigger database updates. + UIButton *updateButton = [[UIButton alloc] initWithFrame:CGRectMake((width - 63), ((height/2) +3.333333), 20.0, 20.0)]; + // When button pressed, updateDB function will be called + [updateButton addTarget:self + action:@selector(updateDB) + forControlEvents:UIControlEventTouchUpInside]; + // Set the image of the button + [updateButton setImage:[UIImage imageWithContentsOfFile:[[[NSBundle alloc] initWithPath:Bundle_Path] pathForResource:@"refresh" ofType:@"png"]] forState:UIControlStateNormal]; + // Add button to the header UIView (header) + [header addSubview:updateButton]; +} + +%new +/* Function to update the Database */ +-(void)updateDB { + /* Let the user know that the update has been queued. Good for older phones that take a while to actually show the update process, and prevent the user + from spamming the update button. */ + UIAlertView *a = [[UIAlertView alloc] initWithTitle:AlertTitle message:Queued_Update delegate:nil cancelButtonTitle:AlertOK otherButtonTitles:nil]; + [a show]; + [a release]; + /* Use the sharedInstance function (returns the current instance) to call the requestUpdateBlah function with our updateURL grabbed from the server */ + [[%c(UpdatesManager) sharedInstance] requestUpdatedDataBaseWithFileURL:updateURL]; +} + +%new +// When the user presses a button +- (void)alertView :(UIAlertView*)alertView clickedButtonAtIndex: (NSInteger)buttonIndex { + + if([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString: @"Update"]) { + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://cydia.dtathemes.com/"]]; + } + +} + +%end + +%hook UpdatesManager +/* When an UpdatesManager instance is created */ +- (id)init +{ + /* we set our sharedInstance to be the current instance of the UpdatesManager */ + sharedInstance = %orig; + /* Then we return the sharedInstance which is itself */ + return sharedInstance; +} + +/* Create new sharedInstance */ +%new ++ (id)sharedInstance +{ + /* It returns the current instance of the UpdatesManger */ + return sharedInstance; +} + +%end diff --git a/Layout/DEBIAN/control b/Layout/DEBIAN/control new file mode 100644 index 0000000..23906f4 --- /dev/null +++ b/Layout/DEBIAN/control @@ -0,0 +1,23 @@ +Package: com.gh0stbyte.movieboxupdater +Name: Movie Box Updater +Depends: mobilesubstrate +Architecture: iphoneos-arm +Description: Update your Movie Box database whenever you wish with this nifty tweak made by Gh0stByte, of iOSCheaters.com + With this tweak, you can update your Movie Box database whenever you want, no need to wait 24 hours. + Complete re-work of the tweak! You can now update via a button in the menu's header. + Changelog: + v.3.6.4 + - Fully compatible with latest Movie Box (3.6.4) + - Tweaked code for optimum speed + - Minor UI changes + - Version check on startup + v.3.6.2 + - Updated to work for the latest Movie Box (3.6.2) + - Changed the way you preform updates. + - Added custom button to update the Database. + v.1.0.0 + - Initial Release +Maintainer: Gh0stByte +Author: Gh0stByte +Section: Tweaks +Version: 3.6.4 diff --git a/Layout/DEBIAN/postinst b/Layout/DEBIAN/postinst new file mode 100644 index 0000000..24607ee --- /dev/null +++ b/Layout/DEBIAN/postinst @@ -0,0 +1,10 @@ +#!/bin/sh +echo +echo '#####################################################' +echo ' Movie Box 3 Updater --- Version 3.6.4 ' +echo '#####################################################' +echo 'Made by Gh0stByte! Enjoy! See more at iOSCheaters.com' +echo '#####################################################' +echo +echo +exit 0 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..39f8c3c --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +ARCHS = arm64 armv7 armv7s +include $(THEOS)/makefiles/common.mk + +TWEAK_NAME = MovieBoxUpdate +MovieBoxUpdate_FILES = Hack.xm +MovieBoxUpdate_FRAMEWORKS = UIKit CoreGraphics +MovieBoxUpdate_LDFLAGS += -Wl,-segalign,4000 +TARGET_IPHONEOS_DEPLOYMENT_VERSION = 6.0 + +BUNDLE_NAME = MovieBoxBundle +MovieBoxBundle_INSTALL_PATH = /Library/MobileSubstrate/DynamicLibraries/ +include $(THEOS)/makefiles/bundle.mk + +include $(THEOS_MAKE_PATH)/tweak.mk + +after-install:: + install.exec "killall -9 MovieBox3; killall -9 Preferences" +include $(THEOS_MAKE_PATH)/aggregate.mk diff --git a/MovieBoxUpdate.plist b/MovieBoxUpdate.plist new file mode 100644 index 0000000..136f33c --- /dev/null +++ b/MovieBoxUpdate.plist @@ -0,0 +1,17 @@ + + + + + Filter + + Executables + + MovieBox3 + + Bundles + + com.trendico.moviebox3 + + + + diff --git a/Resources/refresh.png b/Resources/refresh.png new file mode 100644 index 0000000..f06a305 Binary files /dev/null and b/Resources/refresh.png differ