]> git.saurik.com Git - cydia.git/commitdiff
Merge branch 'master' of git.saurik.com:cydia
authorJay Freeman (saurik) <saurik@saurik.com>
Fri, 26 Nov 2010 22:18:35 +0000 (14:18 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Fri, 26 Nov 2010 22:18:35 +0000 (14:18 -0800)
1  2 
MobileCydia.mm

diff --combined MobileCydia.mm
index dae7d615cda96e6b0a1391d907c53b2c5f901a60,c4abc53d4ae767641439abbe0a65b3a65e8f2937..ee5e006d25fb9eb13ad462ea66eac3c54beeff33
@@@ -1735,6 -1735,7 +1735,7 @@@ typedef std::map< unsigned long, _H<Sou
      _transient NSDate *firstSeen_;
      _transient NSDate *lastSeen_;
      bool subscribed_;
+     bool ignored_;
  }
  
  - (Package *) initWithVersion:(pkgCache::VerIterator)version withZone:(NSZone *)zone inPool:(apr_pool_t *)pool database:(Database *)database;
  
  - (uint32_t) compareBySection:(NSArray *)sections;
  
 -- (uint32_t) compareForChanges;
 -
  - (void) install;
  - (void) remove;
  
@@@ -2178,6 -2181,8 +2179,8 @@@ struct PackageNameOrdering 
              obsolete_ = [self hasTag:@"cydia::obsolete"];
              essential_ = ((iterator_->Flags & pkgCache::Flag::Essential) == 0 ? NO : YES) || [self hasTag:@"cydia::essential"];
          _end
+         ignored_ = iterator_->SelectedState == pkgCache::State::Hold;
      _end } return self;
  }
  
  }
  
  - (Address *) maintainer {
 -    if (file_.end())
 +@synchronized (database_) {
 +    if ([database_ era] != era_ || file_.end())
          return nil;
 +
      pkgRecords::Parser *parser = &[database_ records]->Lookup(file_);
      const std::string &maintainer(parser->Maintainer());
      return maintainer.empty() ? nil : [Address addressWithString:[NSString stringWithUTF8String:maintainer.c_str()]];
 -}
 +} }
  
  - (size_t) size {
 -    return version_.end() ? 0 : version_->InstalledSize;
 -}
 +@synchronized (database_) {
 +    if ([database_ era] != era_ || version_.end())
 +        return 0;
 +
 +    return version_->InstalledSize;
 +} }
  
  - (NSString *) longDescription {
  @synchronized (database_) {
  }
  
  - (BOOL) ignored {
-     NSDictionary *metadata([self metadata]);
-     if (NSNumber *ignored = [metadata objectForKey:@"IsIgnored"])
-         return [ignored boolValue];
-     else
-         return false;
+     return ignored_;
  }
  
  - (NSString *) latest {
              icon = [UIImage imageAtPath:[static_cast<id>(icon_) substringFromIndex:7]];
      if (icon == nil) if (section != nil)
          icon = [UIImage imageAtPath:[NSString stringWithFormat:@"%@/Sections/%@.png", App_, section]];
 -    if (icon == nil) if (source_ != nil) if (NSString *dicon = [source_ defaultIcon])
 +    if (icon == nil) if (Source *source = [self source]) if (NSString *dicon = [source defaultIcon])
          if ([dicon hasPrefix:@"file:///"])
              // XXX: correct escaping
              icon = [UIImage imageAtPath:[dicon substringFromIndex:7]];
      return _not(uint32_t);
  }
  
 -- (uint32_t) compareForChanges {
 -    union {
 -        uint32_t key;
 -
 -        struct {
 -            uint32_t timestamp : 30;
 -            uint32_t ignored : 1;
 -            uint32_t upgradable : 1;
 -        } bits;
 -    } value;
 -
 -    bool upgradable([self upgradableAndEssential:YES]);
 -    value.bits.upgradable = upgradable ? 1 : 0;
 -
 -    if (upgradable) {
 -        value.bits.timestamp = 0;
 -        value.bits.ignored = [self ignored] ? 0 : 1;
 -        value.bits.upgradable = 1;
 -    } else {
 -        value.bits.timestamp = static_cast<uint32_t>([[self seen] timeIntervalSince1970]) >> 2;
 -        value.bits.ignored = 0;
 -        value.bits.upgradable = 0;
 -    }
 -
 -    return _not(uint32_t) - value.key;
 -}
 -
  - (void) clear {
  @synchronized (database_) {
      pkgProblemResolver *resolver = [database_ resolver];
@@@ -2914,17 -2936,12 +2913,17 @@@ static NSString *Warning_
      return era_;
  }
  
 +- (void) releasePackages {
 +    CFArrayApplyFunction(packages_, CFRangeMake(0, CFArrayGetCount(packages_)), reinterpret_cast<CFArrayApplierFunction>(&CFRelease), NULL);
 +    CFArrayRemoveAllValues(packages_);
 +}
 +
  - (void) dealloc {
      // XXX: actually implement this thing
      _assert(false);
 -    NSRecycleZone(zone_);
 -    // XXX: malloc_destroy_zone(zone_);
 +    [self releasePackages];
      apr_pool_destroy(pool_);
 +    NSRecycleZone(zone_);
      [super dealloc];
  }
  
  @synchronized (self) {
      ++era_;
  
 -    CFArrayApplyFunction(packages_, CFRangeMake(0, CFArrayGetCount(packages_)), reinterpret_cast<CFArrayApplierFunction>(&CFRelease), NULL);
 -    CFArrayRemoveAllValues(packages_);
 -
 +    [self releasePackages];
      sources_.clear();
  
      _error->Discard();
@@@ -3678,7 -3697,7 +3677,7 @@@ bool DepSubstrate(const pkgCache::VerIt
  
  - (NSArray *) getInstalledPackages {
      NSArray *packages([[Database sharedInstance] packages]);
 -    NSMutableArray *installed([NSMutableArray arrayWithCapacity:[packages count]]);
 +    NSMutableArray *installed([NSMutableArray arrayWithCapacity:1024]);
      for (Package *package in packages)
          if ([package installed] != nil)
              [installed addObject:package];
@@@ -7020,7 -7039,7 +7019,7 @@@ freeing the view controllers on tab cha
  #endif
  
      Section *upgradable = [[[Section alloc] initWithName:UCLocalize("AVAILABLE_UPGRADES") localize:NO] autorelease];
-     Section *ignored = [[[Section alloc] initWithName:UCLocalize("IGNORED_UPGRADES") localize:NO] autorelease];
+     Section *ignored = nil;
      Section *section = nil;
      NSDate *last = nil;
  
              }
  
              [section addToCount];
-         } else if ([package ignored])
+         } else if ([package ignored]) {
+             if (ignored == nil) {
+                 ignored = [[[Section alloc] initWithName:UCLocalize("IGNORED_UPGRADES") row:offset localize:NO] autorelease];
+             }
              [ignored addToCount];
-         else {
+         else {
              ++upgrades_;
              [upgradable addToCount];
          }
  }
  
  - (void) onIgnored:(id)control {
-     [self onSomething:(int) [control isOn] withKey:@"IsIgnored"];
+     // TODO: set Held state - possibly call out to dpkg, etc.
  }
  
  - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {