]> git.saurik.com Git - cydia.git/commitdiff
Merge branch 'master' of git.saurik.com:cydia
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 6 Jun 2011 08:37:47 +0000 (01:37 -0700)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 6 Jun 2011 08:37:47 +0000 (01:37 -0700)
1  2 
MobileCydia.mm

diff --combined MobileCydia.mm
index ea858e997e1f959d17a58eb2dc5615322fe963e2,a6b61fed7aed7b410b7e923bff0bd0fe57ee3b0a..1acb5eac3e8c8928b4cb50d3f9a550bb7317b527
@@@ -1338,7 -1338,6 +1338,7 @@@ static void PackageImport(const void *k
  - (NSString *) depictionForPackage:(NSString *)package;
  - (NSString *) supportForPackage:(NSString *)package;
  
 +- (metaIndex *) metaIndex;
  - (NSDictionary *) record;
  - (BOOL) trusted;
  
      return ![[self _attributeKeys] containsObject:[NSString stringWithUTF8String:name]] && [super isKeyExcludedFromWebScript:name];
  }
  
 +- (metaIndex *) metaIndex {
 +    return index_;
 +}
 +
  - (void) setMetaIndex:(metaIndex *)index inPool:(apr_pool_t *)pool {
      [self _clear];
  
@@@ -2378,7 -2373,7 +2378,7 @@@ struct PackageNameOrdering 
          _end
  
          _profile(Package$initWithVersion$Section)
 -            section_ = iterator.Section();
 +            section_ = version_.Section();
          _end
  
          _profile(Package$initWithVersion$Flags)
@@@ -3544,47 -3539,29 +3544,47 @@@ class CydiaLogCleaner 
  
      NSString *title(UCLocalize("DATABASE"));
  
 +    list_ = new pkgSourceList();
 +    if ([self popErrorWithTitle:title forOperation:list_->ReadMainList()])
 +        return;
 +
 +    for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) {
 +        Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:pool_] autorelease]);
 +        [sourceList_ addObject:object];
 +    }
 +
      _trace();
      OpProgress progress;
 -    while (!cache_.Open(progress, true)) { pop:
 -        std::string error;
 -        bool warning(!_error->PopMessage(error));
 -        lprintf("cache_.Open():[%s]\n", error.c_str());
 -
 -        if (error == "dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. ")
 -            [delegate_ repairWithSelector:@selector(configure)];
 -        else if (error == "The package lists or status file could not be parsed or opened.")
 -            [delegate_ repairWithSelector:@selector(update)];
 -        // else if (error == "Could not get lock /var/lib/dpkg/lock - open (35 Resource temporarily unavailable)")
 -        // else if (error == "Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)")
 -        // else if (error == "Malformed Status line")
 -        // else if (error == "The list of sources could not be read.")
 -        else {
 +  open:
 +    if (!cache_.Open(progress, true)) {
 +        // XXX: what if there are errors, but Open() == true? this should be merged with popError:
 +        while (!_error->empty()) {
 +            std::string error;
 +            bool warning(!_error->PopMessage(error));
 +
 +            lprintf("cache_.Open():[%s]\n", error.c_str());
 +
              [delegate_ addProgressEventOnMainThread:[CydiaProgressEvent eventWithMessage:[NSString stringWithUTF8String:error.c_str()] ofType:(warning ? kCydiaProgressEventTypeWarning : kCydiaProgressEventTypeError)] forTask:title];
 -            return;
 +
 +            SEL repair(NULL);
 +            if (false);
 +            else if (error == "dpkg was interrupted, you must manually run 'dpkg --configure -a' to correct the problem. ")
 +                repair = @selector(configure);
 +            //else if (error == "The package lists or status file could not be parsed or opened.")
 +            //    repair = @selector(update);
 +            // else if (error == "Could not get lock /var/lib/dpkg/lock - open (35 Resource temporarily unavailable)")
 +            // else if (error == "Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)")
 +            // else if (error == "Malformed Status line")
 +            // else if (error == "The list of sources could not be read.")
 +
 +            if (repair != NULL) {
 +                _error->Discard();
 +                [delegate_ repairWithSelector:repair];
 +                goto open;
 +            }
          }
  
 -        if (warning)
 -            goto pop;
 -        _error->Discard();
 +        return;
      }
      _trace();
  
      fetcher_ = new pkgAcquire(&status_);
      lock_ = NULL;
  
 -    list_ = new pkgSourceList();
 -    if ([self popErrorWithTitle:title forOperation:list_->ReadMainList()])
 -        return;
 -
      if (cache_->DelCount() != 0 || cache_->InstCount() != 0) {
          [delegate_ addProgressEventOnMainThread:[CydiaProgressEvent eventWithMessage:UCLocalize("COUNTS_NONZERO_EX") ofType:kCydiaProgressEventTypeError] forTask:title];
          return;
              return;
      }
  
 -    for (pkgSourceList::const_iterator source = list_->begin(); source != list_->end(); ++source) {
 -        Source *object([[[Source alloc] initWithMetaIndex:*source forDatabase:self inPool:pool_] autorelease]);
 -        [sourceList_ addObject:object];
 -
 -        std::vector<pkgIndexFile *> *indices = (*source)->GetIndexFiles();
 +    for (Source *object in (id) sourceList_) {
 +        metaIndex *source([object metaIndex]);
 +        std::vector<pkgIndexFile *> *indices = source->GetIndexFiles();
          for (std::vector<pkgIndexFile *>::const_iterator index = indices->begin(); index != indices->end(); ++index)
              // XXX: this could be more intelligent
              if (dynamic_cast<debPackagesIndex *>(*index) != NULL) {
@@@ -4470,7 -4453,7 +4470,7 @@@ static _H<NSMutableSet> Diversions_
  }
  
  - (NSString *) substitutePackageNames:(NSString *)message {
-     NSMutableArray *words([[message componentsSeparatedByString:@" "] mutableCopy]);
+     NSMutableArray *words([[[message componentsSeparatedByString:@" "] mutableCopy] autorelease]);
      for (size_t i(0), e([words count]); i != e; ++i) {
          NSString *word([words objectAtIndex:i]);
          if (Package *package = [[Database sharedInstance] packageWithName:word])
  }
  
  + (NSURLRequest *) requestWithHeaders:(NSURLRequest *)request {
-     NSMutableURLRequest *copy([request mutableCopy]);
+     NSMutableURLRequest *copy([[request mutableCopy] autorelease]);
  
      NSURL *url([copy URL]);
      NSString *href([url absoluteString]);
@@@ -5341,6 -5324,12 +5341,6 @@@ bool DepSubstrate(const pkgCache::VerIt
      ] autorelease];
  }
  
 -- (void) uicache {
 -    _trace();
 -    system("su -c /usr/bin/uicache mobile");
 -    _trace();
 -}
 -
  - (void) invoke:(NSInvocation *)invocation withTitle:(NSString *)title {
      UpdateExternalStatus(1);
  
          case 4: [progress_ setFinish:UCLocalize("REBOOT_DEVICE")]; break;
      }
  
 -    UIProgressHUD *hud([delegate_ addProgressHUD]);
 -    [hud setText:UCLocalize("LOADING")];
 -    [self yieldToSelector:@selector(uicache)];
 -    [delegate_ removeProgressHUD:hud];
 -
      UpdateExternalStatus(Finish_ == 0 ? 0 : 2);
  
      [progress_ setRunning:false];
@@@ -6902,7 -6896,7 +6902,7 @@@ static void HomeControllerReachabilityC
          } return;
      }
  
-     NSMutableArray *controllers = [[self viewControllers] mutableCopy];
+     NSMutableArray *controllers = [[[self viewControllers] mutableCopy] autorelease];
      if (transient != nil) {
          UINavigationController *navigation([[[UINavigationController alloc] init] autorelease]);
          [navigation setViewControllers:[NSArray arrayWithObject:transient]];
  @synchronized (database_) {
      era_ = [database_ era];
  
 -    pkgSourceList list;
 -    if ([database_ popErrorWithTitle:UCLocalize("SOURCES") forOperation:list.ReadMainList()])
 -        return;
 -
      sources_ = [NSMutableArray arrayWithCapacity:16];
      [sources_ addObjectsFromArray:[database_ sources]];
      _trace();
      }
  }
  
 +- (void) _uicache {
 +    _trace();
 +    system("su -c /usr/bin/uicache mobile");
 +    _trace();
 +}
 +
 +- (void) uicache {
 +    UIProgressHUD *hud([self addProgressHUD]);
 +    [hud setText:UCLocalize("LOADING")];
 +    [self yieldToSelector:@selector(_uicache)];
 +    [self removeProgressHUD:hud];
 +}
 +
  - (void) perform_ {
      [database_ perform];
      [self performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:YES];
 +    [self performSelectorOnMainThread:@selector(uicache) withObject:nil waitUntilDone:YES];
  }
  
  - (void) confirmWithNavigationController:(UINavigationController *)navigation {
@@@ -10254,7 -10238,7 +10254,7 @@@ _trace()
      [self disemulate];
  
      int savedIndex = [[Metadata_ objectForKey:@"InterfaceIndex"] intValue];
-     NSArray *saved = [[Metadata_ objectForKey:@"InterfaceState"] mutableCopy];
+     NSArray *saved = [[[Metadata_ objectForKey:@"InterfaceState"] mutableCopy] autorelease];
      int standardIndex = 0;
      NSArray *standard = [self defaultStartPages];
  
@@@ -10407,7 -10391,7 +10407,7 @@@ MSHook(void *, CFXPreferencesPropertyLi
  Class $NSURLConnection;
  
  MSHook(id, NSURLConnection$init$, NSURLConnection *self, SEL _cmd, NSURLRequest *request, id delegate, BOOL usesCache, int64_t maxContentLength, BOOL startImmediately, NSDictionary *connectionProperties) {
-     NSMutableURLRequest *copy([request mutableCopy]);
+     NSMutableURLRequest *copy([[request mutableCopy] autorelease]);
  
      NSURL *url([copy URL]);