Changeset 6812
- Timestamp:
- Sep 30, 2008, 2:08:21 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/macosx/PrefsController.m
r6803 r6812 956 956 957 957 //create better-formatted ip string 958 BOOL valid = false; 958 959 if ([components count] == 4) 959 960 { 961 valid = true; 960 962 NSEnumerator * enumerator = [components objectEnumerator]; 961 963 NSString * component; … … 965 967 [newComponents addObject: component]; 966 968 else 967 [newComponents addObject: [[NSNumber numberWithInt: [component intValue]] stringValue]]; 969 { 970 int num = [component intValue]; 971 if (num >= 0 && num < 256) 972 [newComponents addObject: [[NSNumber numberWithInt: num] stringValue]]; 973 else 974 { 975 valid = false; 976 break; 977 } 978 } 968 979 } 969 980 } 970 981 971 NSString * newIP = [newComponents componentsJoinedByString: @"."]; 972 973 NSDictionary * newDict = [NSDictionary dictionaryWithObjectsAndKeys: newIP, @"IP", 974 [oldDict objectForKey: @"Allow"], @"Allow", nil]; 975 [fRPCAccessArray replaceObjectAtIndex: row withObject: newDict]; 976 977 NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"IP" ascending: YES 978 selector: @selector(compareNumeric:)] autorelease]; 979 [fRPCAccessArray sortUsingDescriptors: [NSArray arrayWithObject: descriptor]]; 982 if (valid) 983 { 984 NSString * newIP = [newComponents componentsJoinedByString: @"."]; 985 986 NSDictionary * newDict = [NSDictionary dictionaryWithObjectsAndKeys: newIP, @"IP", 987 [oldDict objectForKey: @"Allow"], @"Allow", nil]; 988 [fRPCAccessArray replaceObjectAtIndex: row withObject: newDict]; 989 990 NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"IP" ascending: YES 991 selector: @selector(compareNumeric:)] autorelease]; 992 [fRPCAccessArray sortUsingDescriptors: [NSArray arrayWithObject: descriptor]]; 993 } 994 else 995 { 996 NSBeep(); 997 if ([[oldDict objectForKey: @"IP"] isEqualToString: @""]) 998 [fRPCAccessArray removeObjectAtIndex: row]; 999 } 980 1000 981 1001 [fRPCAccessTable deselectAll: self];
Note: See TracChangeset
for help on using the changeset viewer.