X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/1dc38e9c3a4bacab79baf18a418e19bee6d4026c..299aeacd7d337a1e57ca14660a151f5a9fd453e2:/MobileCydia.mm
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 1870b772..e0539fa0 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -1,40 +1,22 @@
/* Cydia - iPhone UIKit Front-End for Debian APT
- * Copyright (C) 2008-2011 Jay Freeman (saurik)
+ * Copyright (C) 2008-2013 Jay Freeman (saurik)
*/
-/* Modified BSD License {{{ */
+/* GNU General Public License, Version 3 {{{ */
/*
- * Redistribution and use in source and binary
- * forms, with or without modification, are permitted
- * provided that the following conditions are met:
+ * Cydia is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
*
- * 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.
+ * Cydia is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
*
- * 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.
-*/
+ * You should have received a copy of the GNU General Public License
+ * along with Cydia. If not, see .
+**/
/* }}} */
// XXX: wtf/FastMalloc.h... wtf?
@@ -69,9 +51,11 @@
#include
#include
+#include
#include
#include
+#include
#include
#include
@@ -129,6 +113,7 @@ extern "C" {
#include "CyteKit/IndirectDelegate.h"
#include "CyteKit/PerlCompatibleRegEx.hpp"
#include "CyteKit/TableViewCell.h"
+#include "CyteKit/TabBarController.h"
#include "CyteKit/WebScriptObject-Cyte.h"
#include "CyteKit/WebViewController.h"
#include "CyteKit/WebViewTableViewCell.h"
@@ -253,14 +238,23 @@ union SplitHash {
};
// }}}
-static bool ShowPromoted_;
-
static NSString *Colon_;
NSString *Elision_;
static NSString *Error_;
static NSString *Warning_;
-static bool AprilFools_;
+static NSString *Cache_;
+
+static void (*$SBSSetInterceptsMenuButtonForever)(bool);
+
+static CFStringRef (*$MGCopyAnswer)(CFStringRef);
+
+static NSString *UniqueIdentifier(UIDevice *device = nil) {
+ if (kCFCoreFoundationVersionNumber < 800) // iOS 7.x
+ return [device ?: [UIDevice currentDevice] uniqueIdentifier];
+ else
+ return [(id)$MGCopyAnswer(CFSTR("UniqueDeviceID")) autorelease];
+}
static bool IsReachable(const char *name) {
SCNetworkReachabilityFlags flags; {
@@ -693,6 +687,7 @@ static bool Queuing_;
static CYColor Blue_;
static CYColor Blueish_;
static CYColor Black_;
+static CYColor Folder_;
static CYColor Off_;
static CYColor White_;
static CYColor Gray_;
@@ -711,6 +706,7 @@ static BOOL Ignored_;
static _H Font12_;
static _H Font12Bold_;
static _H Font14_;
+static _H Font18_;
static _H Font18Bold_;
static _H Font22Bold_;
@@ -720,7 +716,7 @@ static NSString *SerialNumber_ = nil;
static NSString *ChipID_ = nil;
static NSString *BBSNum_ = nil;
static _H Token_;
-static NSString *UniqueID_ = nil;
+static _H UniqueID_;
static _H UserAgent_;
static _H Product_;
static _H Safari_;
@@ -732,7 +728,6 @@ static CGColorSpaceRef space_;
static NSDictionary *SectionMap_;
static NSMutableDictionary *Metadata_;
static _transient NSMutableDictionary *Settings_;
-static _transient NSString *Role_;
static _transient NSMutableDictionary *Packages_;
static _transient NSMutableDictionary *Values_;
static _transient NSMutableDictionary *Sections_;
@@ -869,6 +864,16 @@ static NSString *CYHex(NSData *data, bool reverse = false) {
@class CYPackageController;
+@protocol SourceDelegate
+- (void) setFetch:(NSNumber *)fetch;
+@end
+
+@protocol FetchDelegate
+- (bool) isSourceCancelled;
+- (void) startSourceFetch:(NSString *)uri;
+- (void) stopSourceFetch:(NSString *)uri;
+@end
+
@protocol CydiaDelegate
- (void) returnToCydia;
- (void) saveState;
@@ -880,6 +885,7 @@ static NSString *CYHex(NSData *data, bool reverse = false) {
- (void) removePackage:(Package *)package;
- (void) beginUpdate;
- (BOOL) updating;
+- (bool) requestUpdate;
- (void) distUpgrade;
- (void) loadData;
- (void) updateData;
@@ -887,7 +893,6 @@ static NSString *CYHex(NSData *data, bool reverse = false) {
- (void) syncData;
- (void) addSource:(NSDictionary *)source;
- (void) addTrivialSource:(NSString *)href;
-- (void) showSettings;
- (UIProgressHUD *) addProgressHUD;
- (void) removeProgressHUD:(UIProgressHUD *)hud;
- (void) showActionSheet:(UIActionSheet *)sheet fromItem:(UIBarButtonItem *)item;
@@ -895,29 +900,19 @@ static NSString *CYHex(NSData *data, bool reverse = false) {
@end
/* }}} */
-/* Status Delegation {{{ */
-class Status :
+/* CancelStatus {{{ */
+class CancelStatus :
public pkgAcquireStatus
{
private:
- _transient NSObject *delegate_;
bool cancelled_;
public:
- Status() :
- delegate_(nil),
+ CancelStatus() :
cancelled_(false)
{
}
- void setDelegate(NSObject *delegate) {
- delegate_ = delegate;
- }
-
- NSObject *getDelegate() const {
- return delegate_;
- }
-
virtual bool MediaChange(std::string media, std::string drive) {
return false;
}
@@ -926,6 +921,39 @@ class Status :
Done(item);
}
+ virtual bool Pulse_(pkgAcquire *Owner) = 0;
+
+ virtual bool Pulse(pkgAcquire *Owner) {
+ if (pkgAcquireStatus::Pulse(Owner) && Pulse_(Owner))
+ return true;
+ else {
+ cancelled_ = true;
+ return false;
+ }
+ }
+
+ _finline bool WasCancelled() const {
+ return cancelled_;
+ }
+};
+/* }}} */
+/* DelegateStatus {{{ */
+class CydiaStatus :
+ public CancelStatus
+{
+ private:
+ _transient NSObject *delegate_;
+
+ public:
+ CydiaStatus() :
+ delegate_(nil)
+ {
+ }
+
+ void setDelegate(NSObject *delegate) {
+ delegate_ = delegate;
+ }
+
virtual void Fetch(pkgAcquire::ItemDesc &item) {
NSString *name([NSString stringWithUTF8String:item.ShortDesc.c_str()]);
CydiaProgressEvent *event([CydiaProgressEvent eventWithMessage:[NSString stringWithFormat:UCLocalize("DOWNLOADING_"), name] ofType:kCydiaProgressEventTypeStatus forItem:item]);
@@ -953,9 +981,7 @@ class Status :
[delegate_ performSelectorOnMainThread:@selector(addProgressEvent:) withObject:event waitUntilDone:YES];
}
- virtual bool Pulse(pkgAcquire *Owner) {
- bool value = pkgAcquireStatus::Pulse(Owner);
-
+ virtual bool Pulse_(pkgAcquire *Owner) {
double percent(
double(CurrentBytes + CurrentItems) /
double(TotalBytes + TotalItems)
@@ -969,16 +995,7 @@ class Status :
[NSNumber numberWithDouble:CurrentCPS], @"Speed",
nil] waitUntilDone:YES];
- if (value && ![delegate_ isProgressCancelled])
- return true;
- else {
- cancelled_ = true;
- return false;
- }
- }
-
- _finline bool WasCancelled() const {
- return cancelled_;
+ return ![delegate_ isProgressCancelled];
}
virtual void Start() {
@@ -1019,7 +1036,7 @@ typedef std::map< unsigned long, _H