diff --git a/Classes/Dialogs/TDCServerSheet.m b/Classes/Dialogs/TDCServerSheet.m index f9c8c7c9fc..626d443324 100755 --- a/Classes/Dialogs/TDCServerSheet.m +++ b/Classes/Dialogs/TDCServerSheet.m @@ -314,7 +314,11 @@ - (void)load self.autoReconnectCheck.state = self.config.autoReconnect; self.connectionUsesSSLCheck.state = self.config.connectionUsesSSL; self.serverNameField.stringValue = self.config.clientName; - self.serverPasswordField.stringValue = self.config.serverPassword; + + if (self.config.serverPasswordIsSet) { + self.serverPasswordField.stringValue = self.config.serverPassword; + } + self.serverPortField.stringValue = [NSString stringWithInteger:self.config.serverPort]; #ifdef TEXTUAL_BUILT_WITH_ICLOUD_SUPPORT @@ -358,9 +362,11 @@ - (void)load } else { self.alternateNicknamesField.stringValue = NSStringEmptyPlaceholder; } - - self.nicknamePasswordField.stringValue = self.config.nicknamePassword; - + + if (self.config.nicknamePasswordIsSet) { + self.nicknamePasswordField.stringValue = self.config.nicknamePassword; + } + /* Messages */ self.sleepModeQuitMessageField.stringValue = self.config.sleepModeLeavingComment; self.normalLeavingCommentField.stringValue = self.config.normalLeavingComment; @@ -377,7 +383,11 @@ - (void)load self.proxyAddressField.stringValue = self.config.proxyAddress; self.proxyUsernameField.stringValue = self.config.proxyUsername; - self.proxyPasswordField.stringValue = self.config.proxyPassword; + + if (self.config.proxyPasswordIsSet) { + self.proxyPasswordField.stringValue = self.config.proxyPassword; + } + self.proxyPortField.stringValue = [NSString stringWithInteger:self.config.proxyPort]; /* Connect Commands */ @@ -1035,7 +1045,11 @@ - (id)tableView:(NSTableView *)sender objectValueForTableColumn:(NSTableColumn * if ([columnId isEqualToString:@"name"]) { return c.channelName; } else if ([columnId isEqualToString:@"pass"]) { - return c.secretKey; + if (c.secretKeyIsSet) { + return c.secretKey; + } else { + return NSStringEmptyPlaceholder; + } } else if ([columnId isEqualToString:@"join"]) { return @(c.autoJoin); } diff --git a/Classes/Dialogs/TDChannelSheet.m b/Classes/Dialogs/TDChannelSheet.m index ff1319ff47..0d9881f582 100755 --- a/Classes/Dialogs/TDChannelSheet.m +++ b/Classes/Dialogs/TDChannelSheet.m @@ -122,9 +122,15 @@ - (void)load self.channelNameField.stringValue = self.config.channelName; self.defaultModesField.stringValue = self.config.defaultModes; self.defaultTopicField.stringValue = self.config.defaultTopic; - self.encryptionKeyField.stringValue = self.config.encryptionKey; - self.secretKeyField.stringValue = self.config.secretKey; - + + if (self.config.encryptionKeyIsSet) { + self.encryptionKeyField.stringValue = self.config.encryptionKey; + } + + if (self.config.secretKeyIsSet) { + self.secretKeyField.stringValue = self.config.secretKey; + } + self.autoJoinCheck.state = self.config.autoJoin; self.ignoreHighlightsCheck.state = self.config.ignoreHighlights; self.pushNotificationsCheck.state = self.config.pushNotifications; diff --git a/Classes/Headers/IRCChannelConfig.h b/Classes/Headers/IRCChannelConfig.h index 102513d43c..78dedadf54 100755 --- a/Classes/Headers/IRCChannelConfig.h +++ b/Classes/Headers/IRCChannelConfig.h @@ -58,6 +58,9 @@ typedef enum IRCChannelType : NSInteger { @property (nonatomic, assign) BOOL ignoreHighlights; @property (nonatomic, assign) BOOL ignoreJPQActivity; +@property (nonatomic, assign) BOOL encryptionKeyIsSet; +@property (nonatomic, assign) BOOL secretKeyIsSet; + - (void)destroyKeychains; - (id)initWithDictionary:(NSDictionary *)dic; diff --git a/Classes/Headers/IRCClientConfig.h b/Classes/Headers/IRCClientConfig.h index d2f762a415..fbe04e1516 100755 --- a/Classes/Headers/IRCClientConfig.h +++ b/Classes/Headers/IRCClientConfig.h @@ -100,6 +100,10 @@ NSComparisonResult IRCChannelDataSort(IRCChannel *s1, IRCChannel *s2, void *cont @property (nonatomic, strong) NSString *normalLeavingComment; @property (nonatomic, strong) NSString *sleepModeLeavingComment; +@property (nonatomic, assign) BOOL serverPasswordIsSet; +@property (nonatomic, assign) BOOL nicknamePasswordIsSet; +@property (nonatomic, assign) BOOL proxyPasswordIsSet; + - (id)initWithDictionary:(NSDictionary *)dic; - (NSMutableDictionary *)dictionaryValue; diff --git a/Classes/IRC/IRCChannelConfig.m b/Classes/IRC/IRCChannelConfig.m index 7983fb8bf2..3804967b46 100755 --- a/Classes/IRC/IRCChannelConfig.m +++ b/Classes/IRC/IRCChannelConfig.m @@ -40,9 +40,6 @@ @implementation IRCChannelConfig -@synthesize secretKey = _secretKey; -@synthesize encryptionKey = _encryptionKey; - - (id)init { if ((self = [super init])) { @@ -77,87 +74,57 @@ - (void)dealloc - (NSString *)encryptionKey { - NSString *kcPassword = NSStringEmptyPlaceholder; - - /* Only read from keychain if our value is nil. Let the set command - handle any changes to the actual property after that. */ - if (_encryptionKey == nil) { - kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Blowfish Encryption)" - withItemKind:@"application password" - forUsername:nil - serviceName:[NSString stringWithFormat:@"textual.cblowfish.%@", self.itemUUID]]; - - if (kcPassword) { - if ([kcPassword isEqualToString:_encryptionKey] == NO) { - _encryptionKey = nil; - _encryptionKey = kcPassword; - } - } - } + NSString *kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Blowfish Encryption)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.cblowfish.%@", self.itemUUID]]; - return _encryptionKey; + return kcPassword; } - (NSString *)secretKey { - NSString *kcPassword = NSStringEmptyPlaceholder; - - if (_secretKey == nil) { - kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Channel JOIN Key)" - withItemKind:@"application password" - forUsername:nil - serviceName:[NSString stringWithFormat:@"textual.cjoinkey.%@", self.itemUUID]]; - - if (kcPassword) { - if ([kcPassword isEqualToString:_secretKey] == NO) { - _secretKey = nil; - _secretKey = kcPassword; - } - } - } + NSString *kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Channel JOIN Key)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.cjoinkey.%@", self.itemUUID]]; - return _secretKey; + return kcPassword; } - (void)setEncryptionKey:(NSString *)pass { - if ([_encryptionKey isEqualToString:pass] == NO) { - if (NSObjectIsEmpty(pass)) { - [AGKeychain deleteKeychainItem:@"Textual (Blowfish Encryption)" - withItemKind:@"application password" - forUsername:nil - serviceName:[NSString stringWithFormat:@"textual.cblowfish.%@", self.itemUUID]]; - } else { - [AGKeychain modifyOrAddKeychainItem:@"Textual (Blowfish Encryption)" - withItemKind:@"application password" - forUsername:nil - withNewPassword:pass - serviceName:[NSString stringWithFormat:@"textual.cblowfish.%@", self.itemUUID]]; - } - - _encryptionKey = nil; - _encryptionKey = pass; + self.encryptionKeyIsSet = NSObjectIsNotEmpty(pass); + + if (self.encryptionKeyIsSet == NO) { + [AGKeychain deleteKeychainItem:@"Textual (Blowfish Encryption)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.cblowfish.%@", self.itemUUID]]; + } else { + [AGKeychain modifyOrAddKeychainItem:@"Textual (Blowfish Encryption)" + withItemKind:@"application password" + forUsername:nil + withNewPassword:pass + serviceName:[NSString stringWithFormat:@"textual.cblowfish.%@", self.itemUUID]]; } } - (void)setSecretKey:(NSString *)pass { - if ([_secretKey isEqualToString:pass] == NO) { - if (NSObjectIsEmpty(pass)) { - [AGKeychain deleteKeychainItem:@"Textual (Channel JOIN Key)" - withItemKind:@"application password" - forUsername:nil - serviceName:[NSString stringWithFormat:@"textual.cjoinkey.%@", self.itemUUID]]; - } else { - [AGKeychain modifyOrAddKeychainItem:@"Textual (Channel JOIN Key)" - withItemKind:@"application password" - forUsername:nil - withNewPassword:pass - serviceName:[NSString stringWithFormat:@"textual.cjoinkey.%@", self.itemUUID]]; - } - - _secretKey = nil; - _secretKey = pass; + self.secretKeyIsSet = NSObjectIsNotEmpty(pass); + + if (self.secretKeyIsSet == NO) { + [AGKeychain deleteKeychainItem:@"Textual (Channel JOIN Key)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.cjoinkey.%@", self.itemUUID]]; + } else { + [AGKeychain modifyOrAddKeychainItem:@"Textual (Channel JOIN Key)" + withItemKind:@"application password" + forUsername:nil + withNewPassword:pass + serviceName:[NSString stringWithFormat:@"textual.cjoinkey.%@", self.itemUUID]]; } } @@ -172,6 +139,9 @@ - (void)destroyKeychains withItemKind:@"application password" forUsername:nil serviceName:[NSString stringWithFormat:@"textual.cjoinkey.%@", self.itemUUID]]; + + self.secretKeyIsSet = NO; + self.encryptionKeyIsSet = NO; } #pragma mark - @@ -191,6 +161,7 @@ + (NSDictionary *)seedDictionary:(NSString *)channelName - (id)initWithDictionary:(NSDictionary *)dic { if ((self = [self init])) { + /* General preferences. */ self.type = (IRCChannelType)NSDictionaryIntegerKeyValueCompare(dic, @"channelType", self.type); self.itemUUID = NSDictionaryObjectKeyValueCompare(dic, @"uniqueIdentifier", self.itemUUID); @@ -206,8 +177,7 @@ - (id)initWithDictionary:(NSDictionary *)dic self.defaultModes = NSDictionaryObjectKeyValueCompare(dic, @"defaultMode", self.defaultModes); self.defaultTopic = NSDictionaryObjectKeyValueCompare(dic, @"defaultTopic", self.defaultTopic); - // ---- // Migrate to keychain. - + /* Migrate to keychain.*/ NSString *oldEncKey = [dic stringForKey:@"encryptionKey"]; NSString *oldJoinKey = [dic stringForKey:@"secretJoinKey"]; @@ -218,7 +188,11 @@ - (id)initWithDictionary:(NSDictionary *)dic if (NSObjectIsNotEmpty(oldJoinKey)) { [self setSecretKey:oldJoinKey]; } - + + /* Establish state. */ + self.secretKeyIsSet = NSObjectIsNotEmpty(self.secretKey); + self.encryptionKeyIsSet = NSObjectIsNotEmpty(self.encryptionKey); + return self; } diff --git a/Classes/IRC/IRCClient.m b/Classes/IRC/IRCClient.m index 6878a6dc21..8cc04106d4 100755 --- a/Classes/IRC/IRCClient.m +++ b/Classes/IRC/IRCClient.m @@ -580,7 +580,7 @@ - (BOOL)isSupportedMessageEncryptionFormat:(NSString *)message channel:(IRCChann NSObjectIsEmptyAssertReturn(message, NO); if (channel && (channel.isChannel || channel.isPrivateMessage)) { - return NSObjectIsNotEmpty(channel.config.encryptionKey); + return channel.config.encryptionKeyIsSet; } return NO; @@ -3066,7 +3066,7 @@ - (void)ircConnectionDidConnect:(IRCConnection *)sender [self send:IRCPrivateCommandIndex("cap"), @"LS", nil]; - if (NSObjectIsNotEmpty(self.config.serverPassword)) { + if (self.config.serverPasswordIsSet) { [self send:IRCPrivateCommandIndex("pass"), self.config.serverPassword, nil]; } @@ -3590,7 +3590,7 @@ - (void)receiveText:(IRCMessage *)m command:(NSString *)command text:(NSString * if ([cleanedText containsIgnoringCase:token]) { continueNickServScan = NO; - NSObjectIsEmptyAssertLoopBreak(self.config.nicknamePassword); + NSAssertReturnLoopContinue(self.config.nicknamePasswordIsSet); NSString *IDMessage = [NSString stringWithFormat:@"IDENTIFY %@", self.config.nicknamePassword]; @@ -3879,7 +3879,7 @@ - (void)receiveJoin:(IRCMessage *)m } } - if (NSObjectIsNotEmpty(c.config.encryptionKey)) { + if (c.config.encryptionKeyIsSet) { [c.client printDebugInformation:TXTLS(@"BlowfishEncryptionStarted") channel:c]; } } @@ -4337,7 +4337,7 @@ - (void)receiveMode:(IRCMessage *)m if (saveKey) { [c.config setSecretKey:newSecretKeyActual]; } - } else if (oldSecretKey.modeIsSet == YES && newSecretKey.modeIsSet == NO && NSObjectIsNotEmpty(c.secretKey)) { + } else if (oldSecretKey.modeIsSet == YES && newSecretKey.modeIsSet == NO && c.config.secretKeyIsSet) { BOOL saveKey = [TLOPopupPrompts dialogWindowWithQuestion:TXTFLS(@"ChannelKeyRemovalDetectedDialogMessage", c.name) title:TXTLS(@"ChannelKeyRemovalDetectedDialogTitle") defaultButton:TXTLS(@"YesButton") @@ -4504,7 +4504,7 @@ - (BOOL)isCapAvailable:(NSString *)cap [cap isEqualIgnoringCase:@"server-time"] || [cap isEqualIgnoringCase:@"znc.in/server-time"] || [cap isEqualIgnoringCase:@"znc.in/server-time-iso"] || - ([cap isEqualIgnoringCase:@"sasl"] && NSObjectIsNotEmpty(self.config.nicknamePassword))); + ([cap isEqualIgnoringCase:@"sasl"] && self.config.nicknamePasswordIsSet)); } - (void)cap:(NSString *)cap result:(BOOL)supported @@ -5072,7 +5072,7 @@ - (void)receiveNumericReply:(IRCMessage *)m NSString *secretKey = [c.modeInfo modeInfoFor:@"k"].modeParamater; - if (NSObjectIsEmpty(c.secretKey) && NSObjectIsNotEmpty(secretKey)) { + if (c.config.secretKeyIsSet == NO && NSObjectIsNotEmpty(secretKey)) { /* We offer to remember the key when we found one and our configuration does not already have one. */ @@ -5086,7 +5086,7 @@ - (void)receiveNumericReply:(IRCMessage *)m if (saveKey) { [c.config setSecretKey:secretKey]; } - } else if (NSObjectIsEmpty(secretKey) && NSObjectIsNotEmpty(c.secretKey)) { + } else if (NSObjectIsEmpty(secretKey) && c.config.secretKeyIsSet) { /* We have a key set on a channel that no longer has one. */ BOOL saveKey = [TLOPopupPrompts dialogWindowWithQuestion:TXTFLS(@"ChannelKeyRemovalDetectedDialogMessage", c.name) title:TXTLS(@"ChannelKeyRemovalDetectedDialogTitle") @@ -6595,11 +6595,11 @@ - (void)joinChannel:(IRCChannel *)channel password:(NSString *)password channel.status = IRCChannelJoining; if (NSObjectIsEmpty(password)) { - password = channel.secretKey; - } - - if (NSObjectIsEmpty(password)) { - password = nil; + if (channel.config.secretKey) { + password = channel.secretKey; + } else { + password = nil; + } } [self forceJoinChannel:channel.name password:password]; @@ -6708,7 +6708,7 @@ - (void)quickJoin:(NSArray *)chans withKeys:(BOOL)passKeys c.status = IRCChannelJoining; - if (NSObjectIsNotEmpty(c.secretKey)) { + if (c.config.secretKeyIsSet) { if (passKeys == NO) { continue; } @@ -6738,7 +6738,10 @@ - (void)quickJoin:(NSArray *)chans withKeys:(BOOL)passKeys } [channelList setString:c.name]; - [passwordList setString:c.secretKey]; + + if (c.config.secretKeyIsSet) { + [passwordList setString:c.secretKey]; + } channelCount = 1; // To match setString: statements up above. } else { diff --git a/Classes/IRC/IRCClientConfig.m b/Classes/IRC/IRCClientConfig.m index 2197ffa876..39134b8751 100755 --- a/Classes/IRC/IRCClientConfig.m +++ b/Classes/IRC/IRCClientConfig.m @@ -44,9 +44,6 @@ NSComparisonResult IRCChannelDataSort(IRCChannel *s1, IRCChannel *s2, void *cont @implementation IRCClientConfig -@synthesize serverPassword = _serverPassword; -@synthesize nicknamePassword = _nicknamePassword; - - (id)init { if ((self = [super init])) { @@ -113,100 +110,100 @@ - (id)init - (NSString *)nicknamePassword { - NSString *kcPassword = nil; - - if (NSObjectIsEmpty(_nicknamePassword)) { + NSString *kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (NickServ)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; + + if (kcPassword == nil) { kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (NickServ)" withItemKind:@"application password" - forUsername:nil + forUsername:[TPCPreferences applicationName] // Compatible with 2.1.1 serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; - - if (kcPassword == nil) { - kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (NickServ)" - withItemKind:@"application password" - forUsername:[TPCPreferences applicationName] // Compatible with 2.1.1 - serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; - - } - } - - if (kcPassword) { - if ([kcPassword isEqualToString:_nicknamePassword] == NO) { - _nicknamePassword = nil; - _nicknamePassword = kcPassword; - } + } - - return _nicknamePassword; + + return kcPassword; } - (void)setNicknamePassword:(NSString *)pass { - if ([_nicknamePassword isEqualToString:pass] == NO) { - if (NSObjectIsEmpty(pass)) { - [AGKeychain deleteKeychainItem:@"Textual (NickServ)" - withItemKind:@"application password" - forUsername:nil - serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; - } else { - [AGKeychain modifyOrAddKeychainItem:@"Textual (NickServ)" - withItemKind:@"application password" - forUsername:nil - withNewPassword:pass - serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; - } - - _nicknamePassword = nil; - _nicknamePassword = pass; + self.nicknamePasswordIsSet = NSObjectIsNotEmpty(pass); + + if (self.nicknamePasswordIsSet == NO) { + [AGKeychain deleteKeychainItem:@"Textual (NickServ)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; + } else { + [AGKeychain modifyOrAddKeychainItem:@"Textual (NickServ)" + withItemKind:@"application password" + forUsername:nil + withNewPassword:pass + serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; } } - (NSString *)serverPassword { - NSString *kcPassword = nil; - - if (NSObjectIsEmpty(_serverPassword)) { + NSString *kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Server Password)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; + + if (kcPassword == nil) { kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Server Password)" withItemKind:@"application password" - forUsername:nil + forUsername:[TPCPreferences applicationName] // Compatible with 2.1.1 serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; - - if (kcPassword == nil) { - kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Server Password)" - withItemKind:@"application password" - forUsername:[TPCPreferences applicationName] // Compatible with 2.1.1 - serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; - } - } - - if (kcPassword) { - if ([kcPassword isEqualToString:_serverPassword] == NO) { - _serverPassword = nil; - _serverPassword = kcPassword; - } } - - return _serverPassword; + + return kcPassword; } - (void)setServerPassword:(NSString *)pass { - if ([_serverPassword isEqualToString:pass] == NO) { - if (NSObjectIsEmpty(pass)) { - [AGKeychain deleteKeychainItem:@"Textual (Server Password)" - withItemKind:@"application password" - forUsername:nil - serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; - } else { - [AGKeychain modifyOrAddKeychainItem:@"Textual (Server Password)" - withItemKind:@"application password" - forUsername:nil - withNewPassword:pass - serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; - } - - _serverPassword = nil; - _serverPassword = pass; + self.serverPasswordIsSet = NSObjectIsNotEmpty(pass); + + if (self.serverPasswordIsSet == NO) { + [AGKeychain deleteKeychainItem:@"Textual (Server Password)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; + } else { + [AGKeychain modifyOrAddKeychainItem:@"Textual (Server Password)" + withItemKind:@"application password" + forUsername:nil + withNewPassword:pass + serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; + } +} + +- (NSString *)proxyPassword +{ + NSString *kcPassword = [AGKeychain getPasswordFromKeychainItem:@"Textual (Proxy Server Password)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.proxy-server.%@", self.itemUUID]]; + + return kcPassword; +} + +- (void)setProxyPassword:(NSString *)pass +{ + self.proxyPasswordIsSet = NSObjectIsNotEmpty(pass); + + if (self.proxyPasswordIsSet == NO) { + [AGKeychain deleteKeychainItem:@"Textual (Proxy Server Password)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.proxy-server.%@", self.itemUUID]]; + } else { + [AGKeychain modifyOrAddKeychainItem:@"Textual (Proxy Server Password)" + withItemKind:@"application password" + forUsername:nil + withNewPassword:pass + serviceName:[NSString stringWithFormat:@"textual.proxy-server.%@", self.itemUUID]]; } } @@ -216,11 +213,20 @@ - (void)destroyKeychains withItemKind:@"application password" forUsername:nil serviceName:[NSString stringWithFormat:@"textual.server.%@", self.itemUUID]]; - + + [AGKeychain deleteKeychainItem:@"Textual (Proxy Server Password)" + withItemKind:@"application password" + forUsername:nil + serviceName:[NSString stringWithFormat:@"textual.proxy-server.%@", self.itemUUID]]; + [AGKeychain deleteKeychainItem:@"Textual (NickServ)" withItemKind:@"application password" forUsername:nil serviceName:[NSString stringWithFormat:@"textual.nickserv.%@", self.itemUUID]]; + + self.serverPasswordIsSet = NO; + self.nicknamePasswordIsSet = NO; + self.proxyPasswordIsSet = NO; } #pragma mark - @@ -229,6 +235,7 @@ - (void)destroyKeychains - (id)initWithDictionary:(NSDictionary *)dic { if ((self = [self init])) { + /* General preferences. */ self.sidebarItemExpanded = NSDictionaryBOOLKeyValueCompare(dic, @"serverListItemIsExpanded", YES); self.itemUUID = NSDictionaryObjectKeyValueCompare(dic, @"uniqueIdentifier", self.itemUUID); @@ -251,7 +258,6 @@ - (id)initWithDictionary:(NSDictionary *)dic self.proxyType = (TXConnectionProxyType)NSDictionaryIntegerKeyValueCompare(dic, @"proxyServerType", self.proxyType); self.proxyAddress = NSDictionaryObjectKeyValueCompare(dic, @"proxyServerAddress", self.proxyAddress); - self.proxyPassword = NSDictionaryObjectKeyValueCompare(dic, @"proxyServerPassword", self.proxyPassword); self.proxyPort = NSDictionaryIntegerKeyValueCompare(dic, @"proxyServerPort", self.proxyPort); self.proxyUsername = NSDictionaryObjectKeyValueCompare(dic, @"proxyServerUsername", self.proxyUsername); @@ -273,25 +279,29 @@ - (id)initWithDictionary:(NSDictionary *)dic self.isTrustedConnection = NSDictionaryBOOLKeyValueCompare(dic, @"trustedSSLConnection", self.isTrustedConnection); [self.loginCommands addObjectsFromArray:[dic arrayForKey:@"onConnectCommands"]]; - + + /* Channel list. */ for (NSDictionary *e in [dic arrayForKey:@"channelList"]) { IRCChannelConfig *c = [[IRCChannelConfig alloc] initWithDictionary:e]; [self.channelList safeAddObject:c]; } - + + /* Ignore list. */ for (NSDictionary *e in [dic arrayForKey:@"ignoreList"]) { IRCAddressBook *ignore = [[IRCAddressBook alloc] initWithDictionary:e]; [self.ignoreList safeAddObject:ignore]; } + /* Server specific highlight list. */ for (NSDictionary *e in [dic arrayForKey:@"highlightList"]) { TDCHighlightEntryMatchCondition *c = [[TDCHighlightEntryMatchCondition alloc] initWithDictionary:e]; [self.highlightList safeAddObject:c]; } - + + /* Flood control. */ if ([dic containsKey:@"floodControl"]) { NSDictionary *e = [dic dictionaryForKey:@"floodControl"]; @@ -303,6 +313,19 @@ - (id)initWithDictionary:(NSDictionary *)dic } } + /* Migrate to keychain. */ + NSString *proxyPassword = [dic stringForKey:@"proxyServerPassword"]; + + if (NSObjectIsNotEmpty(proxyPassword)) { + [self setProxyPassword:proxyPassword]; + } + + /* Get a base reading. */ + self.serverPasswordIsSet = NSObjectIsNotEmpty(self.serverPassword); + self.nicknamePasswordIsSet = NSObjectIsNotEmpty(self.nicknamePassword); + self.proxyPasswordIsSet = NSObjectIsNotEmpty(self.proxyPassword); + + /* We're done. */ return self; } @@ -344,7 +367,6 @@ - (NSMutableDictionary *)dictionaryValue [dic safeSetObject:self.awayNickname forKey:@"identityAwayNickname"]; [dic safeSetObject:self.normalLeavingComment forKey:@"connectionDisconnectDefaultMessage"]; [dic safeSetObject:self.proxyAddress forKey:@"proxyServerAddress"]; - [dic safeSetObject:self.proxyPassword forKey:@"proxyServerPassword"]; [dic safeSetObject:self.proxyUsername forKey:@"proxyServerUsername"]; [dic safeSetObject:self.realname forKey:@"identityRealname"]; [dic safeSetObject:self.serverAddress forKey:@"serverAddress"]; diff --git a/Classes/Library/External Libraries/Keychain Control/AGKeychain.m b/Classes/Library/External Libraries/Keychain Control/AGKeychain.m index ac1f19b792..9b1fab5905 100755 --- a/Classes/Library/External Libraries/Keychain Control/AGKeychain.m +++ b/Classes/Library/External Libraries/Keychain Control/AGKeychain.m @@ -133,7 +133,7 @@ + (NSString *)getPasswordFromKeychainItem:(NSString *)keychainItemName forUsername:username serviceName:service]; - NSObjectIsEmptyAssertReturn(passwordData, NSStringEmptyPlaceholder); + NSObjectIsEmptyAssertReturn(passwordData, nil); return [NSString stringWithData:passwordData encoding:NSUTF8StringEncoding]; } diff --git a/Resources/Plugins/Blowfish Key Control/TPI_BlowfishCommands.m b/Resources/Plugins/Blowfish Key Control/TPI_BlowfishCommands.m index 1f0205aead..6c5c0b6727 100755 --- a/Resources/Plugins/Blowfish Key Control/TPI_BlowfishCommands.m +++ b/Resources/Plugins/Blowfish Key Control/TPI_BlowfishCommands.m @@ -139,7 +139,7 @@ - (void)messageSentByUser:(IRCClient *)client [client printDebugInformation:TXTLS(@"BlowfishEncryptionStopped") channel:c]; } else { - if (NSObjectIsNotEmpty(c.config.encryptionKey)) { + if (c.config.encryptionKeyIsSet) { if ([c.config.encryptionKey isEqualToString:messageString] == NO) { [client printDebugInformation:TXTLS(@"BlowfishEncryptionKeyChanged") channel:c]; } @@ -158,7 +158,7 @@ - (void)messageSentByUser:(IRCClient *)client [client printDebugInformation:TXTLS(@"BlowfishEncryptionStopped") channel:c]; } else if ([commandString isEqualToString:@"KEY"]) { - if (NSObjectIsNotEmpty(c.config.encryptionKey)) { + if (c.config.encryptionKeyIsSet) { [client printDebugInformation:TPIFLS(@"BlowfishCurrentEncryptionKey", c.config.encryptionKey) channel:c]; } else { [client printDebugInformation:TPILS(@"BlowfishNoEncryptionKeySet") channel:c]; @@ -175,7 +175,7 @@ - (void)messageSentByUser:(IRCClient *)client } else { if ([self keyExchangeRequestExists:c]) { [client printDebugInformation:TPIFLS(@"BlowfishKeyExchangeRequestAlreadyExists", c.name) channel:c]; - } else if (NSObjectIsNotEmpty(c.config.encryptionKey)) { + } else if (c.config.encryptionKeyIsSet) { [client printDebugInformation:TPIFLS(@"BlowfishKeyExchangeCannotHandleEncryptedRequest_2", c.name) channel:c]; } else { CFDH1080 *keyRequest = [CFDH1080 new]; @@ -245,7 +245,7 @@ - (void)keyExchangeRequestReceived:(NSString *)requestDataRaw on:(IRCClient *)cl { IRCChannel *channel = [client findChannelOrCreate:requestSender isPrivateMessage:YES]; - if (NSObjectIsNotEmpty(channel.config.encryptionKey)) { + if (channel.config.encryptionKeyIsSet) { [client printDebugInformation:TPIFLS(@"BlowfishKeyExchangeCannotHandleEncryptedRequest_1", channel.name) channel:channel]; return; @@ -318,7 +318,7 @@ - (void)keyExchangeResponseReceived:(NSString *)responseData on:(IRCClient *)cli CFDH1080 *request = exchangeData[0]; IRCChannel *channel = exchangeData[1]; - if (NSObjectIsNotEmpty(channel.config.encryptionKey)) { + if (channel.config.encryptionKeyIsSet) { [client printDebugInformation:TPIFLS(@"BlowfishKeyExchangeCannotHandleEncryptedRequest_1", channel.name) channel:channel]; return;