]> git.saurik.com Git - cydia.git/blobdiff - Cydia.mm
Forgot the Sponsor field.
[cydia.git] / Cydia.mm
index 1805a59871076c7b781eac0bdaf1e9094f891e94..2e1b5b814afe19c3cba479e9ec028d810d672f87 100644 (file)
--- a/Cydia.mm
+++ b/Cydia.mm
@@ -272,11 +272,11 @@ class Pcre {
 /* Mime Addresses {{{ */
 @interface Address : NSObject {
     NSString *name_;
-    NSString *email_;
+    NSString *address_;
 }
 
 - (NSString *) name;
-- (NSString *) email;
+- (NSString *) address;
 
 + (Address *) addressWithString:(NSString *)string;
 - (Address *) initWithString:(NSString *)string;
@@ -286,8 +286,8 @@ class Pcre {
 
 - (void) dealloc {
     [name_ release];
-    if (email_ != nil)
-        [email_ release];
+    if (address_ != nil)
+        [address_ release];
     [super dealloc];
 }
 
@@ -295,24 +295,36 @@ class Pcre {
     return name_;
 }
 
-- (NSString *) email {
-    return email_;
+- (NSString *) address {
+    return address_;
 }
 
 + (Address *) addressWithString:(NSString *)string {
     return [[[Address alloc] initWithString:string] autorelease];
 }
 
++ (NSArray *) _attributeKeys {
+    return [NSArray arrayWithObjects:@"address", @"name", nil];
+}
+
+- (NSArray *) attributeKeys {
+    return [[self class] _attributeKeys];
+}
+
++ (BOOL) isKeyExcludedFromWebScript:(const char *)name {
+    return ![[self _attributeKeys] containsObject:[NSString stringWithUTF8String:name]] && [super isKeyExcludedFromWebScript:name];
+}
+
 - (Address *) initWithString:(NSString *)string {
     if ((self = [super init]) != nil) {
         const char *data = [string UTF8String];
         size_t size = [string length];
 
-        static Pcre email_r("^\"?(.*)\"? <([^>]*)>$");
+        static Pcre address_r("^\"?(.*)\"? <([^>]*)>$");
 
-        if (email_r(data, size)) {
-            name_ = [email_r[1] retain];
-            email_ = [email_r[2] retain];
+        if (address_r(data, size)) {
+            name_ = [address_r[1] retain];
+            address_ = [address_r[2] retain];
         } else {
             name_ = [[NSString alloc]
                 initWithBytes:data
@@ -320,7 +332,7 @@ class Pcre {
                 encoding:kCFStringEncodingUTF8
             ];
 
-            email_ = nil;
+            address_ = nil;
         }
     } return self;
 }
@@ -425,10 +437,6 @@ static const int ButtonBarHeight_ = 48;
 static const float KeyboardTime_ = 0.3f;
 static const char * const SpringBoard_ = "/System/Library/LaunchDaemons/com.apple.SpringBoard.plist";
 
-#ifndef Cydia_
-#define Cydia_ ""
-#endif
-
 static CGColor Blue_;
 static CGColor Blueish_;
 static CGColor Black_;
@@ -441,7 +449,7 @@ static NSString *Home_;
 static BOOL Sounds_Keyboard_;
 
 static BOOL Advanced_;
-//static BOOL Loaded_;
+static BOOL Loaded_;
 static BOOL Ignored_;
 
 static UIFont *Font12_;
@@ -817,6 +825,18 @@ class Progress :
     [super dealloc];
 }
 
++ (NSArray *) _attributeKeys {
+    return [NSArray arrayWithObjects:@"description", @"distribution", @"host", @"key", @"label", @"name", @"origin", @"trusted", @"type", @"uri", @"version", nil];
+}
+
+- (NSArray *) attributeKeys {
+    return [[self class] _attributeKeys];
+}
+
++ (BOOL) isKeyExcludedFromWebScript:(const char *)name {
+    return ![[self _attributeKeys] containsObject:[NSString stringWithUTF8String:name]] && [super isKeyExcludedFromWebScript:name];
+}
+
 - (Source *) initWithMetaIndex:(metaIndex *)index {
     if ((self = [super init]) != nil) {
         trusted_ = index->IsTrusted();
@@ -1022,7 +1042,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     NSString *name_;
     NSString *tagline_;
     NSString *icon_;
-    NSString *website_;
+    NSString *homepage_;
     Address *sponsor_;
     Address *author_;
     NSArray *tags_;
@@ -1063,7 +1083,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 - (NSString *) name;
 - (NSString *) tagline;
 - (NSString *) icon;
-- (NSString *) website;
+- (NSString *) homepage;
 - (Address *) author;
 
 - (NSArray *) relationships;
@@ -1107,8 +1127,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     [tagline_ release];
     if (icon_ != nil)
         [icon_ release];
-    if (website_ != nil)
-        [website_ release];
+    if (homepage_ != nil)
+        [homepage_ release];
     if (sponsor_ != nil)
         [sponsor_ release];
     if (author_ != nil)
@@ -1124,6 +1144,18 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     [super dealloc];
 }
 
++ (NSArray *) _attributeKeys {
+    return [NSArray arrayWithObjects:@"author", @"description", @"essential", @"homepage", @"icon", @"id", @"installed", @"latest", @"maintainer", @"name", @"section", @"size", @"source", @"sponsor", @"tagline", nil];
+}
+
+- (NSArray *) attributeKeys {
+    return [[self class] _attributeKeys];
+}
+
++ (BOOL) isKeyExcludedFromWebScript:(const char *)name {
+    return ![[self _attributeKeys] containsObject:[NSString stringWithUTF8String:name]] && [super isKeyExcludedFromWebScript:name];
+}
+
 - (Package *) initWithIterator:(pkgCache::PkgIterator)iterator database:(Database *)database {
     if ((self = [super init]) != nil) {
         iterator_ = iterator;
@@ -1157,11 +1189,11 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
             icon_ = Scour("Icon", begin, end);
             if (icon_ != nil)
                 icon_ = [icon_ retain];
-            website_ = Scour("Homepage", begin, end);
-            if (website_ == nil)
-                website_ = Scour("Website", begin, end);
-            if (website_ != nil)
-                website_ = [website_ retain];
+            homepage_ = Scour("Homepage", begin, end);
+            if (homepage_ == nil)
+                homepage_ = Scour("Website", begin, end);
+            if (homepage_ != nil)
+                homepage_ = [homepage_ retain];
             NSString *sponsor = Scour("Sponsor", begin, end);
             if (sponsor != nil)
                 sponsor_ = [[Address addressWithString:sponsor] retain];
@@ -1368,8 +1400,8 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     return icon_;
 }
 
-- (NSString *) website {
-    return website_;
+- (NSString *) homepage {
+    return homepage_;
 }
 
 - (Address *) sponsor {
@@ -1634,6 +1666,9 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
 @end
 /* }}} */
 
+int Finish_;
+NSArray *Finishes_;
+
 /* Database Implementation {{{ */
 @implementation Database
 
@@ -1649,10 +1684,19 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
     std::istream is(&ib);
     std::string line;
 
+    static Pcre finish_r("^finish:([^:]*)$");
+
     while (std::getline(is, line)) {
         const char *data(line.c_str());
-        //size_t size = line.size();
+        size_t size = line.size();
         fprintf(stderr, "C:%s\n", data);
+
+        if (finish_r(data, size)) {
+            NSString *finish = finish_r[1];
+            int index = [Finishes_ indexOfObject:finish];
+            if (index != INT_MAX && index > Finish_)
+                Finish_ = index;
+        }
     }
 
     [pool release];
@@ -1749,7 +1793,7 @@ NSString *Scour(const char *field, const char *begin, const char *end) {
         cydiafd_ = fds[1];
 
         _config->Set("APT::Keep-Fds::", cydiafd_);
-        setenv("CYDIA", [[[[NSNumber numberWithInt:cydiafd_] stringValue] stringByAppendingString:@" 0"] UTF8String], _not(int));
+        setenv("CYDIA", [[[[NSNumber numberWithInt:cydiafd_] stringValue] stringByAppendingString:@" 1"] UTF8String], _not(int));
 
         [NSThread
             detachNewThreadSelector:@selector(_readCydia:)
@@ -2523,7 +2567,6 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
         [close_ setAutosizesToFit:NO];
         [close_ setDrawsShadow:YES];
         [close_ setStretchBackground:YES];
-        [close_ setTitle:@"Return to Cydia"];
         [close_ setEnabled:YES];
 
         GSFontRef bold = GSFontCreateWithName("Helvetica", kGSFontTraitBold, 22);
@@ -2567,8 +2610,28 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 }
 
 - (void) closeButtonPushed {
-    [delegate_ progressViewIsComplete:self];
-    [self resetView];
+    switch (Finish_) {
+        case 0:
+            [delegate_ progressViewIsComplete:self];
+           [self resetView];
+        break;
+
+        case 1:
+            [delegate_ suspendWithAnimation:YES];
+        break;
+
+        case 2:
+            system("killall SpringBoard");
+        break;
+
+        case 3:
+            system("launchctl unload /System/Library/LaunchDaemons/com.apple.SpringBoard.plist; launchctl load /System/Library/LaunchDaemons/com.apple.SpringBoard.plist");
+        break;
+
+        case 4:
+            system("reboot");
+        break;
+    }
 }
 
 - (void) _retachThread {
@@ -2579,6 +2642,14 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     [progress_ removeFromSuperview];
     [status_ removeFromSuperview];
 
+    switch (Finish_) {
+        case 0: [close_ setTitle:@"Return to Cydia"]; break;
+        case 1: [close_ setTitle:@"Close Cydia (Restart)"]; break;
+        case 2: [close_ setTitle:@"Restart SpringBoard"]; break;
+        case 3: [close_ setTitle:@"Reload SpringBoard"]; break;
+        case 4: [close_ setTitle:@"Reboot Device"]; break;
+    }
+
 #ifdef __OBJC2__
     notify_post("com.apple.mobile.application_installed");
 #endif
@@ -3148,16 +3219,9 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 @end
 /* }}} */
 /* Package View {{{ */
-@protocol PackageViewDelegate
-- (void) performPackage:(Package *)package;
-@end
-
-@interface PackageView : RVPage {
-    _transient Database *database_;
-    UIPreferencesTable *table_;
+@interface PackageView : BrowserView {
     Package *package_;
     NSString *name_;
-    UITextView *description_;
     NSMutableArray *buttons_;
 }
 
@@ -3169,238 +3233,14 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 @implementation PackageView
 
 - (void) dealloc {
-    [table_ setDataSource:nil];
-    [table_ setDelegate:nil];
-
     if (package_ != nil)
         [package_ release];
     if (name_ != nil)
         [name_ release];
-    if (description_ != nil)
-        [description_ release];
-    [table_ release];
     [buttons_ release];
     [super dealloc];
 }
 
-- (int) numberOfGroupsInPreferencesTable:(UIPreferencesTable *)table {
-    int number = 2;
-    if ([package_ installed] != nil)
-        ++number;
-    if ([package_ source] != nil)
-        ++number;
-    return number;
-}
-
-- (NSString *) preferencesTable:(UIPreferencesTable *)table titleForGroup:(int)group {
-    if (group-- == 0)
-        return nil;
-    else if ([package_ installed] != nil && group-- == 0)
-        return @"Installed Package";
-    else if (group-- == 0)
-        return @"Package Details";
-    else if ([package_ source] != nil && group-- == 0)
-        return @"Source Information";
-    else _assert(false);
-}
-
-- (float) preferencesTable:(UIPreferencesTable *)table heightForRow:(int)row inGroup:(int)group withProposedHeight:(float)proposed {
-    if (description_ == nil || group != 0 || row != ([package_ author] == nil ? 1 : 2))
-        return proposed;
-    else
-        return [description_ visibleTextRect].size.height + TextViewOffset_;
-}
-
-- (int) preferencesTable:(UIPreferencesTable *)table numberOfRowsInGroup:(int)group {
-    if (group-- == 0) {
-        int number = 1;
-        if ([package_ author] != nil)
-            ++number;
-        if (description_ != nil)
-            ++number;
-        if ([package_ website] != nil)
-            ++number;
-        return number;
-    } else if ([package_ installed] != nil && group-- == 0)
-        return 2;
-    else if (group-- == 0) {
-        int number = 2;
-        if ([package_ size] != 0)
-            ++number;
-        if ([package_ maintainer] != nil)
-            ++number;
-        if ([package_ sponsor] != nil)
-            ++number;
-        if ([package_ relationships] != nil)
-            ++number;
-        if ([[package_ source] trusted])
-            ++number;
-        return number;
-    } else if ([package_ source] != nil && group-- == 0) {
-        Source *source = [package_ source];
-        NSString *description = [source description];
-        int number = 1;
-        if (description != nil && ![description isEqualToString:[source label]])
-            ++number;
-        if ([source origin] != nil)
-            ++number;
-        return number;
-    } else _assert(false);
-}
-
-- (UIPreferencesTableCell *) preferencesTable:(UIPreferencesTable *)table cellForRow:(int)row inGroup:(int)group {
-    UIPreferencesTableCell *cell = [[[UIPreferencesTableCell alloc] init] autorelease];
-    [cell setShowSelection:NO];
-
-    if (group-- == 0) {
-        if (false) {
-        } else if (row-- == 0) {
-            [cell setTitle:[package_ name]];
-            [cell setValue:[package_ latest]];
-        } else if ([package_ author] != nil && row-- == 0) {
-            [cell setTitle:@"Author"];
-            [cell setValue:[[package_ author] name]];
-            [cell setShowDisclosure:YES];
-            [cell setShowSelection:YES];
-        } else if (description_ != nil && row-- == 0) {
-            [cell addSubview:description_];
-        } else if ([package_ website] != nil && row-- == 0) {
-            [cell setTitle:@"More Information"];
-            [cell setShowDisclosure:YES];
-            [cell setShowSelection:YES];
-        } else _assert(false);
-    } else if ([package_ installed] != nil && group-- == 0) {
-        if (false) {
-        } else if (row-- == 0) {
-            [cell setTitle:@"Version"];
-            NSString *installed([package_ installed]);
-            [cell setValue:(installed == nil ? @"n/a" : installed)];
-        } else if (row-- == 0) {
-            [cell setTitle:@"Filesystem Content"];
-            [cell setShowDisclosure:YES];
-            [cell setShowSelection:YES];
-        } else _assert(false);
-    } else if (group-- == 0) {
-        if (false) {
-        } else if (row-- == 0) {
-            [cell setTitle:@"Identifier"];
-            [cell setValue:[package_ id]];
-        } else if (row-- == 0) {
-            [cell setTitle:@"Section"];
-            NSString *section([package_ section]);
-            [cell setValue:(section == nil ? @"n/a" : section)];
-        } else if ([package_ size] != 0 && row-- == 0) {
-            [cell setTitle:@"Expanded Size"];
-            [cell setValue:SizeString([package_ size])];
-        } else if ([package_ maintainer] != nil && row-- == 0) {
-            [cell setTitle:@"Maintainer"];
-            [cell setValue:[[package_ maintainer] name]];
-            [cell setShowDisclosure:YES];
-            [cell setShowSelection:YES];
-        } else if ([package_ sponsor] != nil && row-- == 0) {
-            [cell setTitle:@"Sponsor"];
-            [cell setValue:[[package_ sponsor] name]];
-            [cell setShowDisclosure:YES];
-            [cell setShowSelection:YES];
-        } else if ([package_ relationships] != nil && row-- == 0) {
-            [cell setTitle:@"Package Relationships"];
-            [cell setShowDisclosure:YES];
-            [cell setShowSelection:YES];
-        } else if ([[package_ source] trusted] && row-- == 0) {
-            [cell setIcon:[UIImage applicationImageNamed:@"trusted.png"]];
-            [cell setValue:@"This package has been signed."];
-        } else _assert(false);
-    } else if ([package_ source] != nil && group-- == 0) {
-        Source *source = [package_ source];
-        NSString *description = [source description];
-
-        if (false) {
-        } else if (row-- == 0) {
-            NSString *label = [source label];
-            if (label == nil)
-                label = [source uri];
-            [cell setTitle:label];
-            [cell setValue:[source version]];
-        } else if (description != nil && ![description isEqualToString:[source label]] && row-- == 0) {
-            [cell setValue:description];
-        } else if ([source origin] != nil && row-- == 0) {
-            [cell setTitle:@"Origin"];
-            [cell setValue:[source origin]];
-        } else _assert(false);
-    } else _assert(false);
-
-    return cell;
-}
-
-- (BOOL) canSelectRow:(int)row {
-    return YES;
-}
-
-- (void) tableRowSelected:(NSNotification *)notification {
-    int row = [table_ selectedRow];
-    if (row == INT_MAX)
-        return;
-
-    #define _else else goto _label; return; } _label:
-
-    if (true) {
-        if (row-- == 0) {
-        } else if (row-- == 0) {
-        } else if ([package_ author] != nil && row-- == 0) {
-            [delegate_ openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@",
-                [[package_ author] email],
-                [[NSString stringWithFormat:@"regarding apt package \"%@\"",
-                    [package_ name]
-                ] stringByAddingPercentEscapes]
-            ]]];
-        } else if (description_ != nil && row-- == 0) {
-        } else if ([package_ website] != nil && row-- == 0) {
-            NSURL *url = [NSURL URLWithString:[package_ website]];
-            BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
-            [browser setDelegate:delegate_];
-            [book_ pushPage:browser];
-            [browser loadURL:url];
-    } _else if ([package_ installed] != nil) {
-        if (row-- == 0) {
-        } else if (row-- == 0) {
-        } else if (row-- == 0) {
-            FileTable *files = [[[FileTable alloc] initWithBook:book_ database:database_] autorelease];
-            [files setDelegate:delegate_];
-            [files setPackage:package_];
-            [book_ pushPage:files];
-    } _else if (true) {
-        if (row-- == 0) {
-        } else if (row-- == 0) {
-        } else if (row-- == 0) {
-        } else if ([package_ size] != 0 && row-- == 0) {
-        } else if ([package_ maintainer] != nil && row-- == 0) {
-            [delegate_ openURL:[NSURL URLWithString:[NSString stringWithFormat:@"mailto:%@?subject=%@",
-                [[package_ maintainer] email],
-                [[NSString stringWithFormat:@"regarding apt package \"%@\"",
-                    [package_ name]
-                ] stringByAddingPercentEscapes]
-            ]]];
-        } else if ([package_ sponsor] != nil && row-- == 0) {
-            NSURL *url = [NSURL URLWithString:[[package_ sponsor] email]];
-            BrowserView *browser = [[[BrowserView alloc] initWithBook:book_ database:database_] autorelease];
-            [browser setDelegate:delegate_];
-            [book_ pushPage:browser];
-            [browser loadURL:url];
-        } else if ([package_ relationships] != nil && row-- == 0) {
-        } else if ([[package_ source] trusted] && row-- == 0) {
-    } _else if ([package_ source] != nil) {
-        Source *source = [package_ source];
-        NSString *description = [source description];
-
-        if (row-- == 0) {
-        } else if (row-- == 0) {
-        } else if (description != nil && ![description isEqualToString:[source label]] && row-- == 0) {
-        } else if ([source origin] != nil && row-- == 0) {
-    } _else _assert(false);
-
-    #undef _else
-}
-
 - (void) _clickButtonWithName:(NSString *)name {
     if ([name isEqualToString:@"Install"])
         [delegate_ installPackage:package_];
@@ -3424,7 +3264,14 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     [sheet dismiss];
 }
 
+- (void) webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame {
+    [window setValue:package_ forKey:@"package"];
+}
+
 - (void) _rightButtonClicked {
+    /*[super _rightButtonClicked];
+    return;*/
+
     int count = [buttons_ count];
     _assert(count != 0);
 
@@ -3445,7 +3292,7 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     }
 }
 
-- (NSString *) rightButtonTitle {
+- (NSString *) _rightButtonTitle {
     int count = [buttons_ count];
     return count == 0 ? nil : count != 1 ? @"Modify" : [buttons_ objectAtIndex:0];
 }
@@ -3455,15 +3302,8 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 }
 
 - (id) initWithBook:(RVBook *)book database:(Database *)database {
-    if ((self = [super initWithBook:book]) != nil) {
+    if ((self = [super initWithBook:book database:database]) != nil) {
         database_ = database;
-
-        table_ = [[UIPreferencesTable alloc] initWithFrame:[self bounds]];
-        [self addSubview:table_];
-
-        [table_ setDataSource:self];
-        [table_ setDelegate:self];
-
         buttons_ = [[NSMutableArray alloc] initWithCapacity:4];
     } return self;
 }
@@ -3479,26 +3319,13 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
         name_ = nil;
     }
 
-    if (description_ != nil) {
-        [description_ release];
-        description_ = nil;
-    }
-
     [buttons_ removeAllObjects];
 
     if (package != nil) {
         package_ = [package retain];
         name_ = [[package id] retain];
 
-        NSString *description([package description]);
-        if (description == nil)
-            description = [package tagline];
-        if (description != nil) {
-            description_ = [GetTextView(description, 12, true) retain];
-            [description_ setTextColor:Black_];
-        }
-
-        [table_ reloadData];
+        [self loadURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"package" ofType:@"html"]]];
 
         if ([package_ source] == nil);
         else if ([package_ upgradableAndEssential:NO])
@@ -3512,10 +3339,6 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     }
 }
 
-- (void) resetViewAnimated:(BOOL)animated {
-    [table_ resetViewAnimated:animated];
-}
-
 - (void) reloadData {
     [self setPackage:[database_ packageWithName:name_]];
     [self reloadButtons];
@@ -4225,6 +4048,7 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 @end
 /* }}} */
 
+/* Home View {{{ */
 @interface HomeView : BrowserView {
 }
 
@@ -4268,7 +4092,8 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 }
 
 @end
-
+/* }}} */
+/* Manage View {{{ */
 @interface ManageView : BrowserView {
 }
 
@@ -4288,11 +4113,12 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     return @"Settings";
 }
 
-- (NSString *) rightButtonTitle {
+- (NSString *) _rightButtonTitle {
     return nil;
 }
 
 @end
+/* }}} */
 
 /* Browser Implementation {{{ */
 @implementation BrowserView
@@ -4380,7 +4206,15 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
         page = [[[SourceTable alloc] initWithBook:book_ database:database_] autorelease];
     else if ([href isEqualToString:@"cydia://packages"])
         page = [[[InstalledView alloc] initWithBook:book_ database:database_] autorelease];
-    else if ([href hasPrefix:@"apptapp://package/"]) {
+    else if ([href hasPrefix:@"cydia://files/"]) {
+        NSString *name = [href substringFromIndex:14];
+
+        if (Package *package = [database_ packageWithName:name]) {
+            FileTable *files = [[[FileTable alloc] initWithBook:book_ database:database_] autorelease];
+            [files setPackage:package];
+            page = files;
+        }
+    } else if ([href hasPrefix:@"apptapp://package/"]) {
         NSString *name = [href substringFromIndex:18];
 
         if (Package *package = [database_ packageWithName:name]) {
@@ -4576,8 +4410,12 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
     [self reloadURL];
 }
 
+- (NSString *) _rightButtonTitle {
+    return @"Reload";
+}
+
 - (NSString *) rightButtonTitle {
-    return loading_ ? @"" : @"Reload";
+    return loading_ ? @"" : [self _rightButtonTitle];
 }
 
 - (NSString *) title {
@@ -5562,13 +5400,13 @@ void AddTextView(NSMutableDictionary *fields, NSMutableArray *packages, NSString
 
     [self updateData];
 
-    /*if ([packages count] == 0);
-    else if (Loaded_)*/
+    if ([packages count] == 0);
+    else if (Loaded_)
         [self _loaded];
-    /*else {
+    else {
         Loaded_ = YES;
         [book_ update];
-    }*/
+    }
 
     /*[hud show:NO];
     [hud removeFromSuperview];*/
@@ -6327,6 +6165,8 @@ int main(int argc, char *argv[]) {
     White_.Set(space_, 1.0, 1.0, 1.0, 1.0);
     Gray_.Set(space_, 0.4, 0.4, 0.4, 1.0);
 
+    Finishes_ = [NSArray arrayWithObjects:@"return", @"reopen", @"restart", @"reload", @"reboot", nil];
+
     SectionMap_ = [[[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Sections" ofType:@"plist"]] autorelease];
 
     int value = UIApplicationMain(argc, argv, [Cydia class]);