Changeset 6167


Ignore:
Timestamp:
Jun 13, 2008, 3:44:56 AM (14 years ago)
Author:
livings124
Message:

only have a single proxy password, regardless of account name, address, etc; only attempt to grab it from the keychain when both the "enable proxy" and "enable proxy authorization" checks are enabled

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/PrefsController.h

    r6157 r6167  
    6161    IBOutlet NSPopUpButton * fProxyTypePopUp;
    6262    NSString * fProxyPassword;
     63    BOOL fProxyPasswordSet;
    6364   
    6465    IBOutlet NSTextField * fRPCPortField;
  • trunk/macosx/PrefsController.m

    r6159 r6167  
    109109        //set proxy type
    110110        [self updateProxyType];
    111         [self updateProxyPassword];
     111       
     112        fProxyPasswordSet = NO;
     113        if ([fProxyPasswordField isEnabled])
     114            [self updateProxyPassword];
    112115       
    113116        //update rpc access list
     
    210213    }
    211214    [fProxyTypePopUp selectItemAtIndex: proxyType];
    212     [fProxyPasswordField setStringValue: fProxyPassword];
     215    [fProxyPasswordField setStringValue: fProxyPassword ? fProxyPassword : @""];
    213216   
    214217    //set blocklist
     
    676679{
    677680    tr_sessionSetProxyEnabled(fHandle, [fDefaults boolForKey: @"Proxy"]);
     681   
     682    //if proxy password hasn't be retrieved, get it now
     683    if (!fProxyPasswordSet && [fProxyPasswordField isEnabled])
     684    {
     685        [self updateProxyPassword];
     686        [fProxyPasswordField setStringValue: fProxyPassword];
     687    }
    678688}
    679689
     
    743753{
    744754    tr_sessionSetProxyAuthEnabled(fHandle, [fDefaults boolForKey: @"ProxyAuthorize"]);
     755   
     756    //if proxy password hasn't be retrieved, get it now
     757    if (!fProxyPasswordSet && [fProxyPasswordField isEnabled])
     758    {
     759        [self updateProxyPassword];
     760        [fProxyPasswordField setStringValue: fProxyPassword];
     761    }
    745762}
    746763
     
    748765{
    749766    tr_sessionSetProxyUsername(fHandle, [[fDefaults stringForKey: @"ProxyUsername"] UTF8String]);
    750    
    751     //new username means new password
    752     [self updateProxyPassword];
    753     [fProxyPasswordField setStringValue: fProxyPassword];
    754767}
    755768
    756769- (void) setProxyPassword: (id) sender
    757770{
    758     NSString * username = [fDefaults stringForKey: @"ProxyUsername"];
    759    
    760     //don't allow passwords to be set if no user name
    761     if ([username isEqualToString: @""])
    762     {
    763         [sender setStringValue: @""];
    764        
    765         [fProxyPassword release];
    766         fProxyPassword = [@"" retain];
    767         return;
    768     }
    769    
    770771    [fProxyPassword release];
    771772    fProxyPassword = [[sender stringValue] retain];
    772773   
    773774    EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
    774                                             withUsername: username];
     775                                            withUsername: @"Proxy"];
    775776    if (keychainItem)
    776777        [keychainItem setPassword: fProxyPassword];
    777778    else
    778         [[EMKeychainProxy sharedProxy] addGenericKeychainItemForService: @"Transmission:Proxy" withUsername: username
     779        [[EMKeychainProxy sharedProxy] addGenericKeychainItemForService: @"Transmission:Proxy" withUsername: @"Proxy"
    779780            password: fProxyPassword];
    780781   
     
    784785- (void) updateProxyPassword
    785786{
     787    fProxyPasswordSet = YES;
     788   
    786789    [fProxyPassword release];
    787790   
    788     NSString * username = [fDefaults stringForKey: @"ProxyUsername"];
    789    
    790     if (![username isEqualToString: @""])
    791     {
    792         EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
    793                                                 withUsername: [fDefaults stringForKey: @"ProxyUsername"]];
    794         if (!(fProxyPassword = [keychainItem password]))
    795             fProxyPassword = @"";
    796     }
    797     else
     791    EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
     792                                            withUsername: @"Proxy"];
     793    if (!(fProxyPassword = [keychainItem password]))
    798794        fProxyPassword = @"";
    799    
    800795    [fProxyPassword retain];
    801796   
Note: See TracChangeset for help on using the changeset viewer.