1515@interface WCServerBookmarkController (Private)
1616
1717- (void )_savePasswordForBookmark : (NSArray *)arguments ;
18- - (void )_reloadThemes ;
18+ - (void )_reloadCiphers ;
1919
2020@end
2121
@@ -41,24 +41,22 @@ - (void)_savePasswordForBookmark:(NSArray *)arguments {
4141
4242#pragma mark -
4343
44- - (void )_reloadThemes {
45- // NSEnumerator *enumerator;
46- // NSDictionary *theme;
47- // NSMenuItem *item;
48- // NSInteger index;
49- //
50- // while((index = [_bookmarksThemePopUpButton indexOfItemWithTag:0]) != -1)
51- // [_bookmarksThemePopUpButton removeItemAtIndex:index];
52- //
53- // enumerator = [[[WCSettings settings] objectForKey:WCThemes] objectEnumerator];
54- //
55- // while((theme = [enumerator nextObject])) {
56- // item = [NSMenuItem itemWithTitle:[theme objectForKey:WCThemesName]];
57- // [item setRepresentedObject:[theme objectForKey:WCThemesIdentifier]];
58- // [item setImage:[[WCPreferences preferences] imageForTheme:theme size:NSMakeSize(16.0, 12.0)]];
59- //
60- // [[_bookmarksThemePopUpButton menu] addItem:item];
61- // }
44+ - (void )_reloadCiphers {
45+ NSMenuItem *item;
46+ NSDictionary *schemes;
47+ NSArray *schemeKeys;
48+
49+ [[_bookmarksCipherPopUpButton menu ] removeAllItems ];
50+
51+ schemes = [WCP7Spec encryptionSchemes ];
52+ schemeKeys = [[schemes allKeys ] sortedArrayUsingSelector: @selector (compare: )];
53+
54+ for (NSNumber *key in schemeKeys) {
55+ NSString *name = [WCP7Spec nameForEncryptionSchemeID: [key stringValue ]];
56+ item = [NSMenuItem itemWithTitle: name tag: [key intValue ]];
57+
58+ [[_bookmarksCipherPopUpButton menu ] addItem: item];
59+ }
6260}
6361
6462
@@ -69,10 +67,9 @@ @implementation WCServerBookmarkController
6967#pragma mark -
7068
7169- (void )load {
72- NSDictionary *theme;
73- NSInteger index;
70+ NSNumber *encryptionCipher;
7471
75- [self _reloadThemes ];
72+ [self _reloadCiphers ];
7673
7774 if (_bookmark) {
7875 [_bookmarksNameTextField setStringValue: [_bookmark objectForKey: WCBookmarksName]];
@@ -87,12 +84,12 @@ - (void)load {
8784 else
8885 [_bookmarksPasswordTextField setStringValue: @" " ];
8986
90- // theme = [_bookmark objectForKey:WCBookmarksTheme ];
91- //
92- // if(theme && (index = [_bookmarksThemePopUpButton indexOfItemWithRepresentedObject:theme]) != -1 )
93- // [_bookmarksThemePopUpButton selectItemAtIndex:index ];
94- // else
95- // [_bookmarksThemePopUpButton selectItemAtIndex:0 ];
87+ encryptionCipher = [_bookmark objectForKey: WCBookmarksEncryptionCipher ];
88+
89+ if (encryptionCipher )
90+ [_bookmarksCipherPopUpButton selectItemWithTag: [encryptionCipher intValue ] ];
91+ else
92+ [_bookmarksCipherPopUpButton selectItemWithTag: [[WCSettings settings ] intForKey: WCNetworkEncryptionCipher] ];
9693
9794 [_bookmarksAutoConnectButton setState: [_bookmark boolForKey: WCBookmarksAutoConnect]];
9895 [_bookmarksAutoReconnectButton setState: [_bookmark boolForKey: WCBookmarksAutoReconnect]];
@@ -123,11 +120,6 @@ - (void)save {
123120 [_bookmark setObject: [_bookmarksAddressTextField stringValue ] forKey: WCBookmarksAddress];
124121 [_bookmark setObject: [_bookmarksLoginTextField stringValue ] forKey: WCBookmarksLogin];
125122
126- // if([_bookmarksThemePopUpButton representedObjectOfSelectedItem])
127- // [_bookmark setObject:[_bookmarksThemePopUpButton representedObjectOfSelectedItem] forKey:WCBookmarksTheme];
128- // else
129- // [_bookmark removeObjectForKey:WCBookmarksTheme];
130-
131123 [_bookmark setBool: [_bookmarksAutoConnectButton state ] forKey: WCBookmarksAutoConnect];
132124 [_bookmark setBool: [_bookmarksAutoReconnectButton state ] forKey: WCBookmarksAutoReconnect];
133125 [_bookmark setObject: [_bookmarksNickTextField stringValue ] forKey: WCBookmarksNick];
@@ -149,6 +141,10 @@ - (void)save {
149141 passwordChanged = YES ;
150142 }
151143
144+ if (([_bookmarksCipherPopUpButton selectedTag ] != [[WCSettings settings ] intForKey: WCNetworkEncryptionCipher]) ||
145+ ([_bookmark integerForKey: WCBookmarksEncryptionCipher] != [_bookmarksCipherPopUpButton selectedTag ]))
146+ [_bookmark setObject: [NSNumber numberWithInt: [_bookmarksCipherPopUpButton selectedTag ]] forKey: WCBookmarksEncryptionCipher];
147+
152148 if (![_oldBookmark isEqualToDictionary: _bookmark] || passwordChanged) {
153149 [[WCSettings settings ] replaceObjectAtIndex: row withObject: _bookmark inArrayForKey: WCBookmarks];
154150
@@ -167,16 +163,14 @@ - (void)save {
167163 [_bookmark setObject: [_bookmarksAddressTextField stringValue ] forKey: WCBookmarksAddress];
168164 [_bookmark setObject: [_bookmarksLoginTextField stringValue ] forKey: WCBookmarksLogin];
169165
170- // if([_bookmarksThemePopUpButton representedObjectOfSelectedItem])
171- // [_bookmark setObject:[_bookmarksThemePopUpButton representedObjectOfSelectedItem] forKey:WCBookmarksTheme];
172- // else
173- // [_bookmark removeObjectForKey:WCBookmarksTheme];
174-
175166 [_bookmark setBool: [_bookmarksAutoConnectButton state ] forKey: WCBookmarksAutoConnect];
176167 [_bookmark setBool: [_bookmarksAutoReconnectButton state ] forKey: WCBookmarksAutoReconnect];
177168 [_bookmark setObject: [_bookmarksNickTextField stringValue ] forKey: WCBookmarksNick];
178169 [_bookmark setObject: [_bookmarksStatusTextField stringValue ] forKey: WCBookmarksStatus];
179170
171+ if ([[WCSettings settings ] intForKey: WCNetworkEncryptionCipher] != [_bookmarksCipherPopUpButton selectedTag ])
172+ [_bookmark setObject: [NSNumber numberWithInt: [_bookmarksCipherPopUpButton selectedTag ]] forKey: WCBookmarksEncryptionCipher];
173+
180174 [[WCKeychain keychain ] setPassword: password forBookmark: _bookmark];
181175
182176 [_bookmarksPassword release ];
0 commit comments