set missing properties

This commit is contained in:
Mitchell Livingston 2008-12-24 17:41:45 +00:00
parent e766168fc6
commit 111ce452d7
8 changed files with 1312 additions and 488 deletions

5
NEWS
View File

@ -14,6 +14,11 @@ NEWS file for Transmission <http://www.transmissionbt.com/>
- GTK+
+ Minor display improvements and HIG compliance
1.42 (2008/12/24)
<http://trac.transmissionbt.com/query?milestone=1.42&group=component&groupdesc=1&order=severity>
- All Platforms
+ Fix 1.41 lockup issue
1.41 (2008/12/23)
<http://trac.transmissionbt.com/query?milestone=1.41&group=component&groupdesc=1&order=severity>
- All Platforms

File diff suppressed because it is too large Load Diff

View File

@ -54,11 +54,8 @@
- (BOOL) usesAutoAssignRulesForIndex: (NSInteger) index;
- (void) setUsesAutoAssignRules: (BOOL) useAutoAssignRules forIndex: (NSInteger) index;
- (NSArray *) autoAssignRulesForIndex: (NSInteger) index;
- (void) setAutoAssignRules: (NSArray *) rules forIndex: (NSInteger) index;
- (BOOL) rulesNeedAllForIndex: (NSInteger) index;
- (void) setRulesNeedAllForIndex: (BOOL) all forIndex: (NSInteger) index;
- (NSPredicate *) autoAssignRulesForIndex: (NSInteger) index;
- (void) setAutoAssignRules: (NSPredicate *) predicate forIndex: (NSInteger) index;
- (void) addNewGroup;
- (void) removeGroupWithRowIndex: (NSInteger) row;

View File

@ -55,8 +55,13 @@ GroupsController * fGroupsInstance = nil;
if ((self = [super init]))
{
NSData * data;
if ((data = [[NSUserDefaults standardUserDefaults] dataForKey: @"Groups"]))
if ((data = [[NSUserDefaults standardUserDefaults] dataForKey: @"GroupDicts"]))
fGroups = [[NSKeyedUnarchiver unarchiveObjectWithData: data] retain];
else if ((data = [[NSUserDefaults standardUserDefaults] dataForKey: @"Groups"])) //handle old groups
{
fGroups = [[NSUnarchiver unarchiveObjectWithData: data] retain];
[[NSUserDefaults standardUserDefaults] removeObjectForKey: @"Groups"];
}
else
{
//default groups
@ -210,7 +215,7 @@ GroupsController * fGroupsInstance = nil;
if (orderIndex == -1)
return NO;
NSNumber * assignRules = [[fGroups objectAtIndex: orderIndex] objectForKey: @"UsesAutoAssignRules"];
NSNumber * assignRules = [[fGroups objectAtIndex: orderIndex] objectForKey: @"UsesAutoGroupRules"];
return assignRules && [assignRules boolValue];
}
@ -218,53 +223,36 @@ GroupsController * fGroupsInstance = nil;
{
NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]];
[dict setObject: [NSNumber numberWithBool: useAutoAssignRules] forKey: @"UsesAutoAssignRules"];
[dict setObject: [NSNumber numberWithBool: useAutoAssignRules] forKey: @"UsesAutoGroupRules"];
[[GroupsController groups] saveGroups];
}
- (NSArray *) autoAssignRulesForIndex: (NSInteger) index
- (NSPredicate *) autoAssignRulesForIndex: (NSInteger) index
{
NSInteger orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [[fGroups objectAtIndex: orderIndex] objectForKey: @"AutoAssignRules"] : nil;
if (orderIndex == -1)
return nil;
return [[fGroups objectAtIndex: orderIndex] objectForKey: @"AutoGroupRules"];
}
- (void) setAutoAssignRules: (NSArray *) rules forIndex: (NSInteger) index
- (void) setAutoAssignRules: (NSPredicate *) predicate forIndex: (NSInteger) index
{
NSMutableDictionary * dict = [fGroups objectAtIndex: [self rowValueForIndex: index]];
if (rules && [rules count] > 0)
if (predicate)
{
[dict setObject: rules forKey: @"AutoAssignRules"];
[dict setObject: predicate forKey: @"AutoGroupRules"];
[[GroupsController groups] saveGroups];
}
else
{
[dict removeObjectForKey: @"AutoAssignRules"];
[dict removeObjectForKey: @"AutoGroupRules"];
[self setUsesAutoAssignRules: NO forIndex: index];
}
}
- (BOOL) rulesNeedAllForIndex: (NSInteger) index
{
NSInteger orderIndex = [self rowValueForIndex: index];
if (orderIndex == -1)
return YES;
NSNumber * enforceAll = [[fGroups objectAtIndex: orderIndex] objectForKey: @"AssignRulesNeedAll"];
return !enforceAll || [enforceAll boolValue];
}
- (void) setRulesNeedAllForIndex: (BOOL) all forIndex: (NSInteger) index
{
NSMutableDictionary * group = [fGroups objectAtIndex: [self rowValueForIndex: index]];
[group setObject: [NSNumber numberWithBool: all] forKey: @"AssignRulesNeedAll"];
[[GroupsController groups] saveGroups];
}
- (void) addNewGroup
{
//find the lowest index
@ -410,7 +398,7 @@ GroupsController * fGroupsInstance = nil;
[tempDict release];
}
[[NSUserDefaults standardUserDefaults] setObject: [NSArchiver archivedDataWithRootObject: groups] forKey: @"Groups"];
[[NSUserDefaults standardUserDefaults] setObject: [NSKeyedArchiver archivedDataWithRootObject: groups] forKey: @"GroupDicts"];
}
- (NSImage *) imageForGroup: (NSMutableDictionary *) dict
@ -451,56 +439,9 @@ GroupsController * fGroupsInstance = nil;
{
if (![self usesAutoAssignRulesForIndex: index])
return NO;
const BOOL needAll = [self rulesNeedAllForIndex: index];
BOOL anyPassed = NO;
NSEnumerator * iterator = [[self autoAssignRulesForIndex: index] objectEnumerator];
NSArray * rule;
while ((rule = [iterator nextObject]))
{
NSString * type = [rule objectAtIndex: 0], * place = [rule objectAtIndex: 1], * givenValue = [rule objectAtIndex: 2];
NSArray * values;
if ([type isEqualToString: @"title"])
values = [NSArray arrayWithObject: [torrent name]];
else if ([type isEqualToString: @"tracker"])
values = [torrent allTrackers: NO];
else
continue;
NSStringCompareOptions options;
if ([place isEqualToString: @"begins"])
options = NSCaseInsensitiveSearch | NSAnchoredSearch;
else if ([place isEqualToString: @"ends"])
options = NSCaseInsensitiveSearch | NSBackwardsSearch | NSAnchoredSearch;
else if ([place isEqualToString: @"contains"])
options = NSCaseInsensitiveSearch;
else
continue;
BOOL match = NO;
NSEnumerator * enumerator = [values objectEnumerator];
NSString * value;
while ((value = [enumerator nextObject]))
{
NSRange result = [value rangeOfString: givenValue options: options];
if (result.location != NSNotFound)
{
match = YES;
anyPassed = YES;
break;
}
}
if (match && !needAll)
return YES;
else if (!match && needAll)
return NO;
else;
}
return anyPassed && needAll;
NSPredicate * predicate = [self autoAssignRulesForIndex: index];
return [predicate evaluateWithObject: torrent];
}
@end

View File

@ -39,12 +39,10 @@
IBOutlet NSView * fGroupRulesPrefsContainer;
IBOutlet NSButton * fAutoAssignRulesEnableCheck;
IBOutlet NSButton * fAutoAssignRulesEditButton;
IBOutlet NSWindow * fGroupRulesSheetWindow;
IBOutlet NSRuleEditor * fRuleEditor;
IBOutlet NSWindow * fGroupRulesSheetWindow;
IBOutlet NSPredicateEditor * fRuleEditor;
IBOutlet NSButton * fRulesSheetOKButton, * fRulesSheetCancelButton;
IBOutlet NSTextField * fRulesSheetDescriptionField;
IBOutlet NSPopUpButton * fRulesAllAnyButton;
}
- (void) addRemoveGroup: (id) sender;

View File

@ -33,9 +33,6 @@
#define ADD_TAG 0
#define REMOVE_TAG 1
#define RULES_ALL_TAG 0
#define RULES_ANY_TAG 1
@interface GroupsPrefsController (Private)
- (void) updateSelectedGroup;
@ -58,13 +55,6 @@
[fRulesSheetOKButton setStringValue: NSLocalizedString(@"OK", "Groups -> rule editor -> button")];
[fRulesSheetCancelButton setStringValue: NSLocalizedString(@"Cancel", "Groups -> rule editor -> button")];
[fRulesSheetDescriptionField setStringValue: NSLocalizedString(@"criteria must be met to assign a transfer on add.",
"Groups -> rule editor -> button (All/Any criteria must....)")];
[[fRulesAllAnyButton itemAtIndex: [fRulesAllAnyButton indexOfItemWithTag: RULES_ALL_TAG]] setTitle:
NSLocalizedString(@"All", "Groups -> rule editor -> all/any")];
[[fRulesAllAnyButton itemAtIndex: [fRulesAllAnyButton indexOfItemWithTag: RULES_ANY_TAG]] setTitle:
NSLocalizedString(@"Any", "Groups -> rule editor -> all/any")];
[fSelectedColorView addObserver: self forKeyPath: @"color" options: 0 context: NULL];
@ -277,25 +267,12 @@
if (!fGroupRulesSheetWindow)
[NSBundle loadNibNamed: @"GroupRules" owner: self];
[fRuleEditor removeRowsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fRuleEditor numberOfRows])]
includeSubrows: YES];
const NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
NSArray * rules = [[GroupsController groups] autoAssignRulesForIndex: index];
if (rules)
{
for (NSInteger i = 0; i < [rules count]; i++)
{
[fRuleEditor addRow: nil];
[fRuleEditor setCriteria: [rules objectAtIndex: i] andDisplayValues: [NSArray array] forRowAtIndex: i];
}
}
NSPredicate *predicate = [[GroupsController groups] autoAssignRulesForIndex: [fTableView selectedRow]];
[fRuleEditor setObjectValue: predicate];
if ([fRuleEditor numberOfRows] == 0)
[fRuleEditor addRow: nil];
[fRulesAllAnyButton selectItemWithTag: [[GroupsController groups] rulesNeedAllForIndex: index] ? RULES_ALL_TAG : RULES_ANY_TAG];
[NSApp beginSheet: fGroupRulesSheetWindow modalForWindow: [fTableView window] modalDelegate: nil didEndSelector: NULL
contextInfo: NULL];
}
@ -320,76 +297,15 @@
[NSApp endSheet: fGroupRulesSheetWindow];
NSInteger index = [[GroupsController groups] indexForRow: [fTableView selectedRow]];
[[GroupsController groups] setRulesNeedAllForIndex: [[fRulesAllAnyButton selectedItem] tag] == RULES_ALL_TAG forIndex: index];
[[GroupsController groups] setUsesAutoAssignRules: YES forIndex: index];
NSMutableArray * rules = [NSMutableArray arrayWithCapacity: [fRuleEditor numberOfRows]];
for (NSInteger index = 0; index < [fRuleEditor numberOfRows]; ++index)
{
NSString * string = [[[fRuleEditor displayValuesForRow: index] objectAtIndex: 2] stringValue];
if (string && [string length] > 0)
{
NSMutableArray * rule = [[[fRuleEditor criteriaForRow: index] mutableCopy] autorelease];
[rule replaceObjectAtIndex: 2 withObject: string];
[rules addObject: rule];
}
}
[[GroupsController groups] setAutoAssignRules: rules forIndex: index];
NSPredicate * predicate = [fRuleEditor objectValue];
[[GroupsController groups] setAutoAssignRules: predicate forIndex: index];
[fAutoAssignRulesEnableCheck setState: [[GroupsController groups] usesAutoAssignRulesForIndex: index]];
[fAutoAssignRulesEditButton setEnabled: [fAutoAssignRulesEnableCheck state] == NSOnState];
}
static NSString * torrentTitleCriteria = @"title";
static NSString * trackerURLCriteria = @"tracker";
static NSString * startsWithCriteria = @"begins";
static NSString * containsCriteria = @"contains";
static NSString * endsWithCriteria = @"ends";
- (NSInteger) ruleEditor: (NSRuleEditor *) editor numberOfChildrenForCriterion: (id) criterion withRowType: (NSRuleEditorRowType) rowType
{
if (!criterion)
return 2;
else if ([criterion isEqualToString: torrentTitleCriteria] || [criterion isEqualToString: trackerURLCriteria])
return 3;
else if ([criterion isEqualToString: startsWithCriteria] || [criterion isEqualToString: containsCriteria]
|| [criterion isEqualToString: endsWithCriteria])
return 1;
else
return 0;
}
- (id) ruleEditor: (NSRuleEditor *) editor child: (NSInteger) index forCriterion: (id) criterion
withRowType: (NSRuleEditorRowType) rowType
{
if (criterion == nil)
return [[NSArray arrayWithObjects: torrentTitleCriteria, trackerURLCriteria, nil] objectAtIndex: index];
else if ([criterion isEqualToString: torrentTitleCriteria] || [criterion isEqualToString: trackerURLCriteria])
return [[NSArray arrayWithObjects: startsWithCriteria, containsCriteria, endsWithCriteria, nil] objectAtIndex: index];
else
return @"";
}
- (id) ruleEditor: (NSRuleEditor *) editor displayValueForCriterion: (id) criterion inRow: (NSInteger) row
{
if ([criterion isEqualToString: torrentTitleCriteria])
return NSLocalizedString(@"Torrent Title", "Groups -> rule editor");
else if ([criterion isEqualToString: trackerURLCriteria])
return NSLocalizedString(@"Tracker URL", "Groups -> rule editor");
else if ([criterion isEqualToString: startsWithCriteria])
return NSLocalizedString(@"Starts With", "Groups -> rule editor");
else if ([criterion isEqualToString: containsCriteria])
return NSLocalizedString(@"Contains", "Groups -> rule editor");
else if ([criterion isEqualToString: endsWithCriteria])
return NSLocalizedString(@"Ends With", "Groups -> rule editor");
else
{
NSTextField * field = [[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, 130, 22)];
[field setStringValue: criterion];
return [field autorelease];
}
}
- (void) ruleEditorRowsDidChange: (NSNotification *) notification
{
CGFloat rowHeight = [fRuleEditor rowHeight];

View File

@ -154,6 +154,7 @@ typedef enum
- (NSString *) scrapeResponse;
- (NSMutableArray *) allTrackers: (BOOL) separators;
- (NSString *) trackerList;
- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers;
- (void) updateAllTrackersForRemove: (NSMutableArray *) trackers;
- (BOOL) hasAddedTrackers;

View File

@ -787,6 +787,11 @@ int trashDataFile(const char * filename)
return allTrackers;
}
- (NSString *) trackerList
{
return [[self allTrackers: NO] componentsJoinedByString: @"\n"];
}
- (BOOL) updateAllTrackersForAdd: (NSMutableArray *) trackers
{
//find added tracker at end of first tier