X-Git-Url: https://git.saurik.com/cydia.git/blobdiff_plain/474d96bb73506523b1e47444575d92432c482c1c..3e5a9f5d3097f16c99b57d476c986e13325762c5:/MobileCydia.mm
diff --git a/MobileCydia.mm b/MobileCydia.mm
index 22ed6cb2..79163ba9 100644
--- a/MobileCydia.mm
+++ b/MobileCydia.mm
@@ -1,40 +1,22 @@
/* Cydia - iPhone UIKit Front-End for Debian APT
- * Copyright (C) 2008-2012 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?
@@ -56,7 +38,6 @@
#include
#endif
-#include
#include
#include
@@ -69,9 +50,11 @@
#include
#include
+#include
#include
#include
+#include
#include
#include
@@ -129,6 +112,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,8 +237,6 @@ union SplitHash {
};
// }}}
-static bool ShowPromoted_;
-
static NSString *Colon_;
NSString *Elision_;
static NSString *Error_;
@@ -262,10 +244,17 @@ static NSString *Warning_;
static NSString *Cache_;
-static bool AprilFools_;
-
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; {
SCNetworkReachabilityRef reachability(SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, name));
@@ -697,6 +686,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_;
@@ -715,6 +705,7 @@ static BOOL Ignored_;
static _H Font12_;
static _H Font12Bold_;
static _H Font14_;
+static _H Font18_;
static _H Font18Bold_;
static _H Font22Bold_;
@@ -724,7 +715,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_;
@@ -736,7 +727,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_;
@@ -873,6 +863,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;
@@ -884,6 +884,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;
@@ -891,7 +892,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;
@@ -899,29 +899,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;
}
@@ -930,6 +920,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]);
@@ -957,9 +980,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)
@@ -973,16 +994,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() {
@@ -1023,7 +1035,7 @@ typedef std::map< unsigned long, _H