Changeset 6168


Ignore:
Timestamp:
Jun 13, 2008, 4:05:54 AM (14 years ago)
Author:
livings124
Message:

eliminate an unnecessary variable and improve the behavior of the proxy keychain

Location:
trunk/macosx
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r6161 r6168  
    229229                                [fDefaults boolForKey: @"ProxyAuthorize"],
    230230                                [[fDefaults stringForKey: @"ProxyUsername"] UTF8String],
    231                                 NULL); /* reset in prefs - from Keychain */
     231                                ""); /* reset in prefs - from Keychain (leave blank instead of NULL) */
    232232       
    233233        [NSApp setDelegate: self];
  • trunk/macosx/PrefsController.h

    r6167 r6168  
    6060    IBOutlet NSTextField * fProxyAddressField, * fProxyPasswordField;
    6161    IBOutlet NSPopUpButton * fProxyTypePopUp;
    62     NSString * fProxyPassword;
    6362    BOOL fProxyPasswordSet;
    6463   
  • trunk/macosx/PrefsController.m

    r6167 r6168  
    111111       
    112112        fProxyPasswordSet = NO;
    113         if ([fProxyPasswordField isEnabled])
     113        if ([fDefaults boolForKey: @"Proxy"] && [fDefaults boolForKey: @"ProxyAuthorize"])
    114114            [self updateProxyPassword];
    115115       
     
    138138        [fPortChecker release];
    139139    }
    140    
    141     [fProxyPassword release];
    142140   
    143141    [fRPCAccessArray release];
     
    213211    }
    214212    [fProxyTypePopUp selectItemAtIndex: proxyType];
    215     [fProxyPasswordField setStringValue: fProxyPassword ? fProxyPassword : @""];
     213    [fProxyPasswordField setStringValue: [NSString stringWithUTF8String: tr_sessionGetProxyPassword(fHandle)]];
    216214   
    217215    //set blocklist
     
    678676- (void) setProxyEnabled: (id) sender
    679677{
     678    BOOL enable = [fDefaults boolForKey: @"Proxy"];
    680679    tr_sessionSetProxyEnabled(fHandle, [fDefaults boolForKey: @"Proxy"]);
    681680   
    682681    //if proxy password hasn't be retrieved, get it now
    683     if (!fProxyPasswordSet && [fProxyPasswordField isEnabled])
    684     {
     682    if (!fProxyPasswordSet && enable && [fDefaults boolForKey: @"ProxyAuthorize"])
    685683        [self updateProxyPassword];
    686         [fProxyPasswordField setStringValue: fProxyPassword];
    687     }
    688684}
    689685
     
    752748- (void) setProxyAuthorize: (id) sender
    753749{
    754     tr_sessionSetProxyAuthEnabled(fHandle, [fDefaults boolForKey: @"ProxyAuthorize"]);
     750    BOOL enable = [fDefaults boolForKey: @"ProxyAuthorize"];
     751    tr_sessionSetProxyAuthEnabled(fHandle, enable);
    755752   
    756753    //if proxy password hasn't be retrieved, get it now
    757     if (!fProxyPasswordSet && [fProxyPasswordField isEnabled])
    758     {
     754    if (!fProxyPasswordSet && enable)
    759755        [self updateProxyPassword];
    760         [fProxyPasswordField setStringValue: fProxyPassword];
    761     }
    762756}
    763757
     
    769763- (void) setProxyPassword: (id) sender
    770764{
    771     [fProxyPassword release];
    772     fProxyPassword = [[sender stringValue] retain];
     765    NSString * password = [[sender stringValue] retain];
    773766   
    774767    EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
    775768                                            withUsername: @"Proxy"];
    776769    if (keychainItem)
    777         [keychainItem setPassword: fProxyPassword];
     770        [keychainItem setPassword: password];
    778771    else
    779772        [[EMKeychainProxy sharedProxy] addGenericKeychainItemForService: @"Transmission:Proxy" withUsername: @"Proxy"
    780             password: fProxyPassword];
    781    
    782     tr_sessionSetProxyPassword(fHandle, [fProxyPassword UTF8String]);
     773            password: password];
     774   
     775    tr_sessionSetProxyPassword(fHandle, [password UTF8String]);
    783776}
    784777
     
    787780    fProxyPasswordSet = YES;
    788781   
    789     [fProxyPassword release];
    790    
     782    NSString * password;
    791783    EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
    792784                                            withUsername: @"Proxy"];
    793     if (!(fProxyPassword = [keychainItem password]))
    794         fProxyPassword = @"";
    795     [fProxyPassword retain];
    796    
    797     tr_sessionSetProxyPassword(fHandle, [fProxyPassword UTF8String]);
     785    if (!(password = [keychainItem password]))
     786        password = @"";
     787   
     788    tr_sessionSetProxyPassword(fHandle, [password UTF8String]);
     789   
     790    [fProxyPasswordField setStringValue: password];
    798791}
    799792
Note: See TracChangeset for help on using the changeset viewer.