Skip to content

Commit

Permalink
SHA 256/512 + prefs cleaning + localize
Browse files Browse the repository at this point in the history
  • Loading branch information
nark committed Apr 21, 2020
1 parent dcb104e commit afb5fab
Show file tree
Hide file tree
Showing 42 changed files with 4,869 additions and 6,359 deletions.
5 changes: 2 additions & 3 deletions Sources/WCConnect.m
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,13 @@ - (id)_initConnectWithURL:(WIURL *)url bookmark:(NSDictionary *)bookmark {
_url = [url retain];

// check that bookmark password was loaded from keychain
if (_url.password == nil) {
if (_url.password == nil)
[_url setPassword:[[WCKeychain keychain] passwordForBookmark:bookmark]];
}

_connection = [[WCServerConnection connection] retain];
[_connection setURL:url];
[_connection setBookmark:bookmark];

theme = [[WCSettings settings] themeWithIdentifier:[bookmark objectForKey:WCBookmarksTheme]];

if(!theme)
Expand Down
3 changes: 3 additions & 0 deletions Sources/WCLinkConnection.m
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,9 @@ - (WIError *)linkDisconnectedError:(WIP7Link *)link {


- (NSUInteger)linkCipher:(WIP7Link *)link {
if(_bookmark && [_bookmark objectForKey:WCBookmarksEncryptionCipher])
return [[_bookmark objectForKey:WCBookmarksEncryptionCipher] integerValue];

if([[WCSettings settings] objectForKey:WCNetworkEncryptionCipher])
return [[[WCSettings settings] objectForKey:WCNetworkEncryptionCipher] integerValue];

Expand Down
53 changes: 25 additions & 28 deletions Sources/WCPreferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -118,34 +118,31 @@ - (void)_bookmarkDidChange:(NSDictionary *)bookmark {
#pragma mark -

- (void)_updateTheme:(NSMutableDictionary *)theme {
[theme setObject:WIStringFromColor([_themesChatTextColorWell color]) forKey:WCThemesChatTextColor];
[theme setObject:WIStringFromColor([_themesChatBackgroundColorWell color]) forKey:WCThemesChatBackgroundColor];
[theme setObject:WIStringFromColor([_themesChatEventsColorWell color]) forKey:WCThemesChatEventsColor];
[theme setObject:WIStringFromColor([_themesChatTimestampEveryLineColorWell color]) forKey:WCThemesChatTimestampEveryLineColor];
[theme setObject:WIStringFromColor([_themesChatURLsColorWell color]) forKey:WCThemesChatURLsColor];

[theme setObject:WIStringFromColor([_themesMessagesTextColorWell color]) forKey:WCThemesMessagesTextColor];
[theme setObject:WIStringFromColor([_themesMessagesBackgroundColorWell color]) forKey:WCThemesMessagesBackgroundColor];
[theme setObject:WIStringFromColor([_themesBoardsTextColorWell color]) forKey:WCThemesBoardsTextColor];
[theme setObject:WIStringFromColor([_themesBoardsBackgroundColorWell color]) forKey:WCThemesBoardsBackgroundColor];

[theme setBool:[_themesShowSmileysButton state] forKey:WCThemesShowSmileys];

[theme setBool:[_themesChatTimestampEveryLineButton state] forKey:WCThemesChatTimestampEveryLine];

[theme setInteger:[_themesUserListIconSizeMatrix selectedTag] forKey:WCThemesUserListIconSize];
[theme setBool:[_themesUserListAlternateRowsButton state] forKey:WCThemesUserListAlternateRows];

[theme setInteger:[_themesFileListIconSizeMatrix selectedTag] forKey:WCThemesFileListIconSize];
[theme setBool:[_themesFileListAlternateRowsButton state] forKey:WCThemesFileListAlternateRows];

[theme setBool:[_themesTransferListShowProgressBarButton state] forKey:WCThemesTransferListShowProgressBar];
[theme setBool:[_themesTransferListAlternateRowsButton state] forKey:WCThemesTransferListAlternateRows];

[theme setBool:[_themesTrackerListAlternateRowsButton state] forKey:WCThemesTrackerListAlternateRows];

[theme setInteger:[_themesMonitorIconSizeMatrix selectedTag] forKey:WCThemesMonitorIconSize];
[theme setBool:[_themesMonitorAlternateRowsButton state] forKey:WCThemesMonitorAlternateRows];
// [theme setObject:WIStringFromColor([_themesChatTextColorWell color]) forKey:WCThemesChatTextColor];
// [theme setObject:WIStringFromColor([_themesChatBackgroundColorWell color]) forKey:WCThemesChatBackgroundColor];
// [theme setObject:WIStringFromColor([_themesMessagesTextColorWell color]) forKey:WCThemesMessagesTextColor];
// [theme setObject:WIStringFromColor([_themesMessagesBackgroundColorWell color]) forKey:WCThemesMessagesBackgroundColor];
// [theme setObject:WIStringFromColor([_themesBoardsTextColorWell color]) forKey:WCThemesBoardsTextColor];
// [theme setObject:WIStringFromColor([_themesBoardsBackgroundColorWell color]) forKey:WCThemesBoardsBackgroundColor];

[theme setObject:WIStringFromColor([_themesChatEventsColorWell color]) forKey:WCThemesChatEventsColor];
[theme setObject:WIStringFromColor([_themesChatTimestampEveryLineColorWell color]) forKey:WCThemesChatTimestampEveryLineColor];
[theme setObject:WIStringFromColor([_themesChatURLsColorWell color]) forKey:WCThemesChatURLsColor];
[theme setBool:[_themesShowSmileysButton state] forKey:WCThemesShowSmileys];
[theme setBool:[_themesChatTimestampEveryLineButton state] forKey:WCThemesChatTimestampEveryLine];
[theme setInteger:[_themesUserListIconSizeMatrix selectedTag] forKey:WCThemesUserListIconSize];
[theme setBool:[_themesUserListAlternateRowsButton state] forKey:WCThemesUserListAlternateRows];

[theme setInteger:[_themesFileListIconSizeMatrix selectedTag] forKey:WCThemesFileListIconSize];
[theme setBool:[_themesFileListAlternateRowsButton state] forKey:WCThemesFileListAlternateRows];

[theme setBool:[_themesTransferListShowProgressBarButton state] forKey:WCThemesTransferListShowProgressBar];
[theme setBool:[_themesTransferListAlternateRowsButton state] forKey:WCThemesTransferListAlternateRows];

[theme setBool:[_themesTrackerListAlternateRowsButton state] forKey:WCThemesTrackerListAlternateRows];

[theme setInteger:[_themesMonitorIconSizeMatrix selectedTag] forKey:WCThemesMonitorIconSize];
[theme setBool:[_themesMonitorAlternateRowsButton state] forKey:WCThemesMonitorAlternateRows];
}

- (NSInteger)_selectedThemeRow {
Expand Down
2 changes: 1 addition & 1 deletion Sources/WCServerBookmarkController.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
#import "WCBookmarkController.h"

@interface WCServerBookmarkController : WCBookmarkController {
IBOutlet NSPopUpButton *_bookmarksThemePopUpButton;
IBOutlet NSButton *_bookmarksAutoConnectButton;
IBOutlet NSButton *_bookmarksAutoReconnectButton;
IBOutlet NSTextField *_bookmarksNickTextField;
IBOutlet NSTextField *_bookmarksStatusTextField;
IBOutlet NSPopUpButton *_bookmarksCipherPopUpButton;
}

@end
70 changes: 32 additions & 38 deletions Sources/WCServerBookmarkController.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@interface WCServerBookmarkController (Private)

- (void)_savePasswordForBookmark:(NSArray *)arguments;
- (void)_reloadThemes;
- (void)_reloadCiphers;

@end

Expand All @@ -41,24 +41,22 @@ - (void)_savePasswordForBookmark:(NSArray *)arguments {

#pragma mark -

- (void)_reloadThemes {
// NSEnumerator *enumerator;
// NSDictionary *theme;
// NSMenuItem *item;
// NSInteger index;
//
// while((index = [_bookmarksThemePopUpButton indexOfItemWithTag:0]) != -1)
// [_bookmarksThemePopUpButton removeItemAtIndex:index];
//
// enumerator = [[[WCSettings settings] objectForKey:WCThemes] objectEnumerator];
//
// while((theme = [enumerator nextObject])) {
// item = [NSMenuItem itemWithTitle:[theme objectForKey:WCThemesName]];
// [item setRepresentedObject:[theme objectForKey:WCThemesIdentifier]];
// [item setImage:[[WCPreferences preferences] imageForTheme:theme size:NSMakeSize(16.0, 12.0)]];
//
// [[_bookmarksThemePopUpButton menu] addItem:item];
// }
- (void)_reloadCiphers {
NSMenuItem *item;
NSDictionary *schemes;
NSArray *schemeKeys;

[[_bookmarksCipherPopUpButton menu] removeAllItems];

schemes = [WCP7Spec encryptionSchemes];
schemeKeys = [[schemes allKeys] sortedArrayUsingSelector:@selector(compare:)];

for(NSNumber *key in schemeKeys) {
NSString *name = [WCP7Spec nameForEncryptionSchemeID:[key stringValue]];
item = [NSMenuItem itemWithTitle:name tag:[key intValue]];

[[_bookmarksCipherPopUpButton menu] addItem:item];
}
}


Expand All @@ -69,10 +67,9 @@ @implementation WCServerBookmarkController
#pragma mark -

- (void)load {
NSDictionary *theme;
NSInteger index;
NSNumber *encryptionCipher;

[self _reloadThemes];
[self _reloadCiphers];

if(_bookmark) {
[_bookmarksNameTextField setStringValue:[_bookmark objectForKey:WCBookmarksName]];
Expand All @@ -87,12 +84,12 @@ - (void)load {
else
[_bookmarksPasswordTextField setStringValue:@""];

// theme = [_bookmark objectForKey:WCBookmarksTheme];
//
// if(theme && (index = [_bookmarksThemePopUpButton indexOfItemWithRepresentedObject:theme]) != -1)
// [_bookmarksThemePopUpButton selectItemAtIndex:index];
// else
// [_bookmarksThemePopUpButton selectItemAtIndex:0];
encryptionCipher = [_bookmark objectForKey:WCBookmarksEncryptionCipher];
if (encryptionCipher)
[_bookmarksCipherPopUpButton selectItemWithTag:[encryptionCipher intValue]];
else
[_bookmarksCipherPopUpButton selectItemWithTag:[[WCSettings settings] intForKey:WCNetworkEncryptionCipher]];

[_bookmarksAutoConnectButton setState:[_bookmark boolForKey:WCBookmarksAutoConnect]];
[_bookmarksAutoReconnectButton setState:[_bookmark boolForKey:WCBookmarksAutoReconnect]];
Expand Down Expand Up @@ -123,11 +120,6 @@ - (void)save {
[_bookmark setObject:[_bookmarksAddressTextField stringValue] forKey:WCBookmarksAddress];
[_bookmark setObject:[_bookmarksLoginTextField stringValue] forKey:WCBookmarksLogin];

// if([_bookmarksThemePopUpButton representedObjectOfSelectedItem])
// [_bookmark setObject:[_bookmarksThemePopUpButton representedObjectOfSelectedItem] forKey:WCBookmarksTheme];
// else
// [_bookmark removeObjectForKey:WCBookmarksTheme];

[_bookmark setBool:[_bookmarksAutoConnectButton state] forKey:WCBookmarksAutoConnect];
[_bookmark setBool:[_bookmarksAutoReconnectButton state] forKey:WCBookmarksAutoReconnect];
[_bookmark setObject:[_bookmarksNickTextField stringValue] forKey:WCBookmarksNick];
Expand All @@ -149,6 +141,10 @@ - (void)save {
passwordChanged = YES;
}

if(([_bookmarksCipherPopUpButton selectedTag] != [[WCSettings settings] intForKey:WCNetworkEncryptionCipher]) ||
([_bookmark integerForKey:WCBookmarksEncryptionCipher] != [_bookmarksCipherPopUpButton selectedTag]))
[_bookmark setObject:[NSNumber numberWithInt:[_bookmarksCipherPopUpButton selectedTag]] forKey:WCBookmarksEncryptionCipher];

if(![_oldBookmark isEqualToDictionary:_bookmark] || passwordChanged) {
[[WCSettings settings] replaceObjectAtIndex:row withObject:_bookmark inArrayForKey:WCBookmarks];

Expand All @@ -167,16 +163,14 @@ - (void)save {
[_bookmark setObject:[_bookmarksAddressTextField stringValue] forKey:WCBookmarksAddress];
[_bookmark setObject:[_bookmarksLoginTextField stringValue] forKey:WCBookmarksLogin];

// if([_bookmarksThemePopUpButton representedObjectOfSelectedItem])
// [_bookmark setObject:[_bookmarksThemePopUpButton representedObjectOfSelectedItem] forKey:WCBookmarksTheme];
// else
// [_bookmark removeObjectForKey:WCBookmarksTheme];

[_bookmark setBool:[_bookmarksAutoConnectButton state] forKey:WCBookmarksAutoConnect];
[_bookmark setBool:[_bookmarksAutoReconnectButton state] forKey:WCBookmarksAutoReconnect];
[_bookmark setObject:[_bookmarksNickTextField stringValue] forKey:WCBookmarksNick];
[_bookmark setObject:[_bookmarksStatusTextField stringValue] forKey:WCBookmarksStatus];

if([[WCSettings settings] intForKey:WCNetworkEncryptionCipher] != [_bookmarksCipherPopUpButton selectedTag])
[_bookmark setObject:[NSNumber numberWithInt:[_bookmarksCipherPopUpButton selectedTag]] forKey:WCBookmarksEncryptionCipher];

[[WCKeychain keychain] setPassword:password forBookmark:_bookmark];

[_bookmarksPassword release];
Expand Down
2 changes: 2 additions & 0 deletions Sources/WCServerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
IBOutlet NSTextField *_protocolTextField;
IBOutlet NSTextField *_cipherTitleTextField;
IBOutlet NSTextField *_cipherTextField;
IBOutlet NSTextField *_checksumTitleTextField;
IBOutlet NSTextField *_checksumTextField;
IBOutlet NSTextField *_serializationTitleTextField;
IBOutlet NSTextField *_serializationTextField;
IBOutlet NSTextField *_compressionTitleTextField;
Expand Down
23 changes: 23 additions & 0 deletions Sources/WCServerInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,28 @@ - (void)_updateServerInfo {
} else {
[_cipherTextField setStringValue:NSLS(@"None", @"Encryption disabled")];
}

wi_p7_options_t options = wi_p7_socket_options([socket P7Socket]);

if (options & WI_P7_ENCRYPTION_RSA_AES128_SHA1 ||
options & WI_P7_ENCRYPTION_RSA_AES192_SHA1 ||
options & WI_P7_ENCRYPTION_RSA_AES256_SHA1 ||
options & WI_P7_ENCRYPTION_RSA_BF128_SHA1 ||
options & WI_P7_ENCRYPTION_RSA_3DES192_SHA1) {
[_checksumTextField setStringValue:@"SHA1"];
} else if (options & WI_P7_ENCRYPTION_RSA_AES128_SHA256 ||
options & WI_P7_ENCRYPTION_RSA_AES192_SHA256 ||
options & WI_P7_ENCRYPTION_RSA_AES256_SHA256 ||
options & WI_P7_ENCRYPTION_RSA_BF128_SHA256 ||
options & WI_P7_ENCRYPTION_RSA_3DES192_SHA256) {
[_checksumTextField setStringValue:@"SHA256"];
} else if (options & WI_P7_ENCRYPTION_RSA_AES128_SHA512 ||
options & WI_P7_ENCRYPTION_RSA_AES192_SHA512 ||
options & WI_P7_ENCRYPTION_RSA_AES256_SHA512 ||
options & WI_P7_ENCRYPTION_RSA_BF128_SHA512 ||
options & WI_P7_ENCRYPTION_RSA_3DES192_SHA512) {
[_checksumTextField setStringValue:@"SHA512"];
}

if([socket usesCompression]) {
[_compressionTextField setStringValue:[NSSWF:NSLS(@"Yes, compression ratio %.2f", @"Compression enabled (ratio)"),
Expand All @@ -108,6 +130,7 @@ - (void)_updateServerInfo {

[self resizeTitleTextField:_compressionTitleTextField withTextField:_compressionTextField];
[self resizeTitleTextField:_serializationTitleTextField withTextField:_serializationTextField];
[self resizeTitleTextField:_checksumTitleTextField withTextField:_checksumTextField];
[self resizeTitleTextField:_cipherTitleTextField withTextField:_cipherTextField];
[self resizeTitleTextField:_protocolTitleTextField withTextField:_protocolTextField];
[self resizeTitleTextField:_versionTitleTextField withTextField:_versionTextField];
Expand Down
1 change: 1 addition & 0 deletions Sources/WCSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ extern NSString * const WCBookmarksStatus;
extern NSString * const WCBookmarksAutoConnect;
extern NSString * const WCBookmarksAutoReconnect;
extern NSString * const WCBookmarksTheme;
extern NSString * const WCBookmarksEncryptionCipher;

extern NSString * const WCChatHistoryScrollback;
extern NSString * const WCChatHistoryScrollbackModifier;
Expand Down
1 change: 1 addition & 0 deletions Sources/WCSettings.m
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
NSString * const WCBookmarksAutoConnect = @"AutoJoin";
NSString * const WCBookmarksAutoReconnect = @"AutoReconnect";
NSString * const WCBookmarksTheme = @"Theme";
NSString * const WCBookmarksEncryptionCipher = @"EncryptionCipher";

NSString * const WCChatHistoryScrollback = @"WCHistoryScrollback";
NSString * const WCChatHistoryScrollbackModifier = @"WCHistoryScrollbackModifier";
Expand Down
6 changes: 3 additions & 3 deletions WiredClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2344,7 +2344,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 49;
CURRENT_PROJECT_VERSION = 50;
DEVELOPMENT_TEAM = 7KTXA5Y36K;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2598,7 +2598,7 @@
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 49;
CURRENT_PROJECT_VERSION = 50;
DEVELOPMENT_TEAM = 7KTXA5Y36K;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
Expand Down Expand Up @@ -2700,7 +2700,7 @@
ALWAYS_SEARCH_USER_PATHS = NO;
CODE_SIGN_ENTITLEMENTS = "Wired Client.entitlements";
CODE_SIGN_IDENTITY = "-";
CURRENT_PROJECT_VERSION = 49;
CURRENT_PROJECT_VERSION = 50;
ENABLE_HARDENED_RUNTIME = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<key>Localize Strings.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>24</integer>
<integer>25</integer>
</dict>
<key>Neo.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>25</integer>
<integer>24</integer>
</dict>
<key>Wired Client (Distribute Debug).xcscheme_^#shared#^_</key>
<dict>
Expand Down
Loading

0 comments on commit afb5fab

Please sign in to comment.