mirror of
https://github.com/transmission/transmission.git
synced 2025-12-20 10:28:32 +00:00
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
This commit is contained in:
@@ -60,6 +60,7 @@
|
|||||||
IBOutlet NSTextField * fProxyAddressField, * fProxyPasswordField;
|
IBOutlet NSTextField * fProxyAddressField, * fProxyPasswordField;
|
||||||
IBOutlet NSPopUpButton * fProxyTypePopUp;
|
IBOutlet NSPopUpButton * fProxyTypePopUp;
|
||||||
NSString * fProxyPassword;
|
NSString * fProxyPassword;
|
||||||
|
BOOL fProxyPasswordSet;
|
||||||
|
|
||||||
IBOutlet NSTextField * fRPCPortField;
|
IBOutlet NSTextField * fRPCPortField;
|
||||||
IBOutlet NSTableView * fRPCAccessTable;
|
IBOutlet NSTableView * fRPCAccessTable;
|
||||||
|
|||||||
@@ -108,6 +108,9 @@
|
|||||||
|
|
||||||
//set proxy type
|
//set proxy type
|
||||||
[self updateProxyType];
|
[self updateProxyType];
|
||||||
|
|
||||||
|
fProxyPasswordSet = NO;
|
||||||
|
if ([fProxyPasswordField isEnabled])
|
||||||
[self updateProxyPassword];
|
[self updateProxyPassword];
|
||||||
|
|
||||||
//update rpc access list
|
//update rpc access list
|
||||||
@@ -209,7 +212,7 @@
|
|||||||
proxyType = PROXY_HTTP;
|
proxyType = PROXY_HTTP;
|
||||||
}
|
}
|
||||||
[fProxyTypePopUp selectItemAtIndex: proxyType];
|
[fProxyTypePopUp selectItemAtIndex: proxyType];
|
||||||
[fProxyPasswordField setStringValue: fProxyPassword];
|
[fProxyPasswordField setStringValue: fProxyPassword ? fProxyPassword : @""];
|
||||||
|
|
||||||
//set blocklist
|
//set blocklist
|
||||||
[self updateBlocklistFields];
|
[self updateBlocklistFields];
|
||||||
@@ -675,6 +678,13 @@
|
|||||||
- (void) setProxyEnabled: (id) sender
|
- (void) setProxyEnabled: (id) sender
|
||||||
{
|
{
|
||||||
tr_sessionSetProxyEnabled(fHandle, [fDefaults boolForKey: @"Proxy"]);
|
tr_sessionSetProxyEnabled(fHandle, [fDefaults boolForKey: @"Proxy"]);
|
||||||
|
|
||||||
|
//if proxy password hasn't be retrieved, get it now
|
||||||
|
if (!fProxyPasswordSet && [fProxyPasswordField isEnabled])
|
||||||
|
{
|
||||||
|
[self updateProxyPassword];
|
||||||
|
[fProxyPasswordField setStringValue: fProxyPassword];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setProxyAddress: (id) sender
|
- (void) setProxyAddress: (id) sender
|
||||||
@@ -742,40 +752,31 @@
|
|||||||
- (void) setProxyAuthorize: (id) sender
|
- (void) setProxyAuthorize: (id) sender
|
||||||
{
|
{
|
||||||
tr_sessionSetProxyAuthEnabled(fHandle, [fDefaults boolForKey: @"ProxyAuthorize"]);
|
tr_sessionSetProxyAuthEnabled(fHandle, [fDefaults boolForKey: @"ProxyAuthorize"]);
|
||||||
|
|
||||||
|
//if proxy password hasn't be retrieved, get it now
|
||||||
|
if (!fProxyPasswordSet && [fProxyPasswordField isEnabled])
|
||||||
|
{
|
||||||
|
[self updateProxyPassword];
|
||||||
|
[fProxyPasswordField setStringValue: fProxyPassword];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setProxyUsername: (id) sender
|
- (void) setProxyUsername: (id) sender
|
||||||
{
|
{
|
||||||
tr_sessionSetProxyUsername(fHandle, [[fDefaults stringForKey: @"ProxyUsername"] UTF8String]);
|
tr_sessionSetProxyUsername(fHandle, [[fDefaults stringForKey: @"ProxyUsername"] UTF8String]);
|
||||||
|
|
||||||
//new username means new password
|
|
||||||
[self updateProxyPassword];
|
|
||||||
[fProxyPasswordField setStringValue: fProxyPassword];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setProxyPassword: (id) sender
|
- (void) setProxyPassword: (id) sender
|
||||||
{
|
{
|
||||||
NSString * username = [fDefaults stringForKey: @"ProxyUsername"];
|
|
||||||
|
|
||||||
//don't allow passwords to be set if no user name
|
|
||||||
if ([username isEqualToString: @""])
|
|
||||||
{
|
|
||||||
[sender setStringValue: @""];
|
|
||||||
|
|
||||||
[fProxyPassword release];
|
|
||||||
fProxyPassword = [@"" retain];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
[fProxyPassword release];
|
[fProxyPassword release];
|
||||||
fProxyPassword = [[sender stringValue] retain];
|
fProxyPassword = [[sender stringValue] retain];
|
||||||
|
|
||||||
EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
|
EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
|
||||||
withUsername: username];
|
withUsername: @"Proxy"];
|
||||||
if (keychainItem)
|
if (keychainItem)
|
||||||
[keychainItem setPassword: fProxyPassword];
|
[keychainItem setPassword: fProxyPassword];
|
||||||
else
|
else
|
||||||
[[EMKeychainProxy sharedProxy] addGenericKeychainItemForService: @"Transmission:Proxy" withUsername: username
|
[[EMKeychainProxy sharedProxy] addGenericKeychainItemForService: @"Transmission:Proxy" withUsername: @"Proxy"
|
||||||
password: fProxyPassword];
|
password: fProxyPassword];
|
||||||
|
|
||||||
tr_sessionSetProxyPassword(fHandle, [fProxyPassword UTF8String]);
|
tr_sessionSetProxyPassword(fHandle, [fProxyPassword UTF8String]);
|
||||||
@@ -783,20 +784,14 @@
|
|||||||
|
|
||||||
- (void) updateProxyPassword
|
- (void) updateProxyPassword
|
||||||
{
|
{
|
||||||
|
fProxyPasswordSet = YES;
|
||||||
|
|
||||||
[fProxyPassword release];
|
[fProxyPassword release];
|
||||||
|
|
||||||
NSString * username = [fDefaults stringForKey: @"ProxyUsername"];
|
|
||||||
|
|
||||||
if (![username isEqualToString: @""])
|
|
||||||
{
|
|
||||||
EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
|
EMGenericKeychainItem * keychainItem = [[EMKeychainProxy sharedProxy] genericKeychainItemForService: @"Transmission:Proxy"
|
||||||
withUsername: [fDefaults stringForKey: @"ProxyUsername"]];
|
withUsername: @"Proxy"];
|
||||||
if (!(fProxyPassword = [keychainItem password]))
|
if (!(fProxyPassword = [keychainItem password]))
|
||||||
fProxyPassword = @"";
|
fProxyPassword = @"";
|
||||||
}
|
|
||||||
else
|
|
||||||
fProxyPassword = @"";
|
|
||||||
|
|
||||||
[fProxyPassword retain];
|
[fProxyPassword retain];
|
||||||
|
|
||||||
tr_sessionSetProxyPassword(fHandle, [fProxyPassword UTF8String]);
|
tr_sessionSetProxyPassword(fHandle, [fProxyPassword UTF8String]);
|
||||||
|
|||||||
Reference in New Issue
Block a user