Changeset 9902
- Timestamp:
- Jan 10, 2010, 2:34:00 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/announcer.c
r9868 r9902 296 296 int downloadCount; 297 297 int downloaderCount; 298 299 uint32_t identifier; 298 300 299 301 /* sent as the "key" argument in tracker requests … … 320 322 trackerNew( tr_announcer * announcer, 321 323 const char * announce, 322 const char * scrape ) 324 const char * scrape, 325 uint32_t identifier ) 323 326 { 324 327 tr_tracker_item * tracker = tr_new0( tr_tracker_item, 1 ); … … 326 329 tracker->announce = tr_strdup( announce ); 327 330 tracker->scrape = tr_strdup( scrape ); 331 tracker->identifier = identifier; 328 332 generateKeyParam( tracker->key_param, KEYLEN ); 329 333 tracker->seederCount = -1; … … 449 453 tr_tier * tier, 450 454 const char * announce, 451 const char * scrape ) 452 { 453 tr_tracker_item * tracker = trackerNew( announcer, announce, scrape ); 455 const char * scrape, 456 uint32_t identifier ) 457 { 458 tr_tracker_item * tracker = trackerNew( announcer, announce, scrape, identifier ); 454 459 455 460 tr_ptrArrayAppend( &tier->trackers, tracker ); … … 772 777 } 773 778 774 tierAddTracker( announcer, tier, info->announce, info->scrape );779 tierAddTracker( announcer, tier, info->announce, info->scrape, info->identifier ); 775 780 } 776 781 } … … 1750 1755 tr_tracker_stat * st = ret + out++; 1751 1756 1757 st->identifier = tracker->identifier; 1752 1758 tr_strlcpy( st->host, tracker->host->name, sizeof( st->host ) ); 1753 1759 tr_strlcpy( st->announce, tracker->announce, sizeof( st->announce ) ); -
trunk/libtransmission/metainfo.c
r9868 r9902 272 272 int i, j, validTiers; 273 273 const int numTiers = tr_bencListSize( tiers ); 274 uint32_t trackerId = 0; 274 275 275 276 n = 0; … … 278 279 279 280 trackers = tr_new0( tr_tracker_info, n ); 280 trackerCount = 0;281 281 282 282 for( i = 0, validTiers = 0; i < numTiers; ++i ) … … 292 292 if( tr_httpIsValidURL( url ) ) 293 293 { 294 tr_tracker_info * t = trackers + trackerCount ++;294 tr_tracker_info * t = trackers + trackerCount; 295 295 t->tier = validTiers; 296 296 t->announce = tr_strdup( url ); 297 297 t->scrape = tr_convertAnnounceToScrape( url ); 298 t->identifier = trackerCount; 298 299 299 300 anyAdded = TRUE; 301 ++trackerCount; 300 302 } 301 303 tr_free( url ); … … 325 327 trackers[trackerCount].tier = 0; 326 328 trackers[trackerCount].announce = tr_strdup( url ); 327 trackers[trackerCount++].scrape = tr_convertAnnounceToScrape( url ); 329 trackers[trackerCount].scrape = tr_convertAnnounceToScrape( url ); 330 trackers[trackerCount].identifier = 0; 331 trackerCount++; 328 332 /*fprintf( stderr, "single announce: [%s]\n", url );*/ 329 333 } … … 597 601 inf->trackers[i].announce = tr_strdup( url ); 598 602 inf->trackers[i].scrape = tr_convertAnnounceToScrape( url ); 603 inf->trackers[i].identifier = i; 599 604 } 600 605 } -
trunk/libtransmission/rpcimpl.c
r9868 r9902 364 364 tr_bencDictAddStr( d, "scrape", t->scrape ); 365 365 tr_bencDictAddInt( d, "tier", t->tier ); 366 tr_bencDictAddInt( d, "id", t->identifier ); 366 367 } 367 368 } -
trunk/libtransmission/transmission.h
r9891 r9902 1201 1201 **/ 1202 1202 1203 1203 1204 /** @brief a part of tr_info that represents a single tracker */ 1204 1205 typedef struct tr_tracker_info 1205 1206 { 1206 int tier; 1207 char * announce; 1208 char * scrape; 1207 int tier; 1208 char * announce; 1209 char * scrape; 1210 uint32_t identifier; /* used to match to a tr_tracker_stat */ 1209 1211 } 1210 1212 tr_tracker_info; 1211 1212 1213 1213 1214 /** … … 1459 1460 /* which tier this tracker is in */ 1460 1461 int tier; 1462 1463 /* used to match to a tr_tracker_info */ 1464 uint32_t identifier; 1461 1465 } 1462 1466 tr_tracker_stat; -
trunk/macosx/InfoWindowController.m
r9896 r9902 1742 1742 - (void) removeTrackers 1743 1743 { 1744 NSMutableIndexSet * removeI ndexes = [NSMutableIndexSet indexSet];1744 NSMutableIndexSet * removeIdentifiers = [NSMutableIndexSet indexSet]; 1745 1745 1746 1746 NSIndexSet * selectedIndexes = [fTrackerTable selectedRowIndexes]; 1747 NSLog(@"%@", fTrackers);1748 NSLog(@"selected: %@", selectedIndexes);1749 1747 BOOL groupSelected = NO; 1750 1748 for (NSUInteger i = 0, trackerIndex = 0; i < [fTrackers count]; ++i) … … 1759 1757 { 1760 1758 if (groupSelected || [selectedIndexes containsIndex: i]) 1761 { 1762 [removeIndexes addIndex: trackerIndex]; 1763 NSLog(@"adding for remove %d (%d): %@", trackerIndex, i, [fTrackers objectAtIndex: i]); 1764 } 1759 [removeIdentifiers addIndex: [(TrackerNode *)[fTrackers objectAtIndex: i] identifier]]; 1765 1760 ++trackerIndex; 1766 1761 } 1767 1762 } 1768 1763 1769 NSLog(@"%@", removeI ndexes);1770 1771 NSAssert([removeI ndexes count] > 0, @"Trying to remove no trackers.");1764 NSLog(@"%@", removeIdentifiers); 1765 1766 NSAssert([removeIdentifiers count] > 0, @"Trying to remove no trackers."); 1772 1767 1773 1768 if ([[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveTrackers"]) … … 1775 1770 NSAlert * alert = [[NSAlert alloc] init]; 1776 1771 1777 if ([removeI ndexes count] > 1)1772 if ([removeIdentifiers count] > 1) 1778 1773 { 1779 1774 [alert setMessageText: [NSString stringWithFormat: NSLocalizedString(@"Are you sure you want to remove %d trackers?", 1780 "Remove trackers alert -> title"), [removeI ndexes count]]];1775 "Remove trackers alert -> title"), [removeIdentifiers count]]]; 1781 1776 [alert setInformativeText: NSLocalizedString(@"Once removed, Transmission will no longer attempt to contact them." 1782 1777 " This cannot be undone.", "Remove trackers alert -> message")]; … … 1804 1799 1805 1800 Torrent * torrent = [fTorrents objectAtIndex: 0]; 1806 [torrent removeTrackers AtIndexes: removeIndexes];1801 [torrent removeTrackersWithIdentifiers: removeIdentifiers]; 1807 1802 1808 1803 //reset table with either new or old value -
trunk/macosx/Torrent.h
r9852 r9902 132 132 - (NSArray *) allTrackersFlat; //used by GroupRules 133 133 - (BOOL) addTrackerToNewTier: (NSString *) tracker; 134 - (void) removeTrackers AtIndexes: (NSIndexSet *) removeIndexes;134 - (void) removeTrackersWithIdentifiers: (NSIndexSet *) removeIdentifiers; 135 135 136 136 - (NSString *) comment; -
trunk/macosx/Torrent.m
r9897 r9902 588 588 int count; 589 589 tr_tracker_stat * stats = tr_torrentTrackers(fHandle, &count); 590 NSLog(@"count from tr_torrentTrackers: %d", count);591 590 592 591 NSMutableArray * trackers = [NSMutableArray arrayWithCapacity: (count > 0 ? count + stats[count-1].tier : 0)]; … … 630 629 const int oldTrackerCount = fInfo->trackerCount; 631 630 tr_tracker_info * trackerStructs = tr_new(tr_tracker_info, oldTrackerCount+1); 632 for (NSInteger i=0; i < oldTrackerCount; ++i) 631 for (NSUInteger i=0; i < oldTrackerCount; ++i) 632 { 633 633 trackerStructs[i] = fInfo->trackers[i]; 634 trackerStructs[i].identifier = i; 635 } 634 636 635 637 trackerStructs[oldTrackerCount].announce = (char *)[tracker UTF8String]; 636 638 trackerStructs[oldTrackerCount].tier = trackerStructs[oldTrackerCount-1].tier + 1; 639 trackerStructs[oldTrackerCount].identifier = trackerStructs[oldTrackerCount-1].identifier + 1; 637 640 638 641 const BOOL success = tr_torrentSetAnnounceList(fHandle, trackerStructs, oldTrackerCount+1); … … 642 645 } 643 646 644 - (void) removeTrackersAtIndexes: (NSIndexSet *) removeIndexes 645 { 646 NSAssert([removeIndexes lastIndex] < fInfo->trackerCount, @"Trying to remove trackers outside the tracker count."); 647 648 NSMutableIndexSet * indexes = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, fInfo->trackerCount)]; 649 [indexes removeIndexes: removeIndexes]; 650 647 - (void) removeTrackersWithIdentifiers: (NSIndexSet *) removeIdentifiers 648 { 651 649 //recreate the tracker structure 652 tr_tracker_info * trackerStructs = tr_new(tr_tracker_info, [indexes count]); 653 NSLog(@"count from fInfo: %d", fInfo->trackerCount); 654 655 int newCount = 0; 656 for (NSUInteger oldIndex = [indexes firstIndex]; oldIndex != NSNotFound; oldIndex = [indexes indexGreaterThanIndex: oldIndex]) 657 { 658 NSLog(@"oldIndex: %d %s", oldIndex, fInfo->trackers[oldIndex].announce); 659 trackerStructs[newCount++] = fInfo->trackers[oldIndex]; 650 tr_tracker_info * trackerStructs = tr_new(tr_tracker_info, fInfo->trackerCount); 651 652 NSUInteger newCount = 0; 653 for (NSUInteger i = 0; i < fInfo->trackerCount; i++) 654 { 655 if (![removeIdentifiers containsIndex: fInfo->trackers[i].identifier]) 656 { 657 trackerStructs[newCount] = fInfo->trackers[i]; 658 trackerStructs[newCount].identifier = newCount++; 659 } 660 660 } 661 661 -
trunk/macosx/TrackerNode.h
r9844 r9902 38 38 - (NSInteger) tier; 39 39 40 - (NSUInteger) identifier; 41 40 42 - (NSInteger) totalSeeders; 41 43 - (NSInteger) totalLeechers; -
trunk/macosx/TrackerNode.m
r9896 r9902 63 63 { 64 64 return fStat.tier; 65 } 66 67 - (NSUInteger) identifier 68 { 69 return fStat.identifier; 65 70 } 66 71
Note: See TracChangeset
for help on using the changeset viewer.