2 // ESSIPEAccountViewController.m
5 // Created by Matt Meissner on 10/30/09.
6 // Modified by Michael Lamb on 2/27/13
7 // Copyright 2013 Michael Lamb/Harris Kauffman. All rights reserved.
10 #import <AdiumLibpurple/CBPurpleAccount.h>
11 #import <ESDebugAILog.h>
12 #import "ESSIPEAccountViewController.h"
15 #include "ESPurpleSIPEAccount.h"
17 // Gotta define these here, because they're not yet in the 10.9 SDK. :(
18 #define NSAppKitVersionNumber10_8 1187
19 #define NSAppKitVersionNumber10_8_5 1187.4
20 #define NSAppKitVersionNumber10_9 1265
22 @implementation ESSIPEAccountViewController
29 [[NSDictionary alloc] initWithObjectsAndKeys:
30 textField_windowsLogin, KEY_SIPE_WINDOWS_LOGIN,
31 textField_password, KEY_SIPE_PASSWORD,
32 textField_server, KEY_SIPE_CONNECT_HOST,
33 popup_connectionType, KEY_SIPE_CONNECTION_TYPE,
34 popup_authenticationScheme, KEY_SIPE_AUTH_SCHEME,
35 textField_userAgent, KEY_SIPE_USER_AGENT,
36 checkBox_singleSignOn, KEY_SIPE_SINGLE_SIGN_ON,
37 checkbox_beastDisable, KEY_SIPE_BEAST_DISABLE,
38 textField_groupchatUser, KEY_SIPE_GROUP_CHAT_PROXY,
39 textField_emailURL, KEY_SIPE_EMAIL_URL,
40 textField_email, KEY_SIPE_EMAIL,
41 textField_emailLogin, KEY_SIPE_EMAIL_LOGIN,
42 textField_emailPassword, KEY_SIPE_EMAIL_PASSWORD,
43 checkbox_dontPublish, KEY_SIPE_DONT_PUBLISH,
53 [sipe_key_to_gui release];
57 - (NSString *)nibName{
58 return @"ESSIPEAccountView";
61 #pragma mark Configuration methods
62 - (void)configureForAccount:(AIAccount *)inAccount
64 [super configureForAccount:inAccount];
66 // BEAST mitigation for Mavericks and 10.8.5 users (with Security Update 2014-001)
67 if (NSAppKitVersionNumber < NSAppKitVersionNumber10_8_5) {
68 // We are not running on an OS with BEAST mitigations - Don't display this as a configuration option
69 [checkbox_beastDisable setHidden:YES];
72 // Only need 1 hash for both connection & auth since there are no overlapping keys
73 NSDictionary *conn_auth_dict =
74 [NSDictionary dictionaryWithObjectsAndKeys:
77 @"TLS-DSK",@"tls-dsk",
83 for (NSString* key in sipe_key_to_gui) {
84 id value = [sipe_key_to_gui objectForKey:key];
86 if ([value isKindOfClass:[NSTextField class]]) {
87 NSString *tmp = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
88 [value setStringValue:(tmp ? tmp : @"")];
89 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
90 // NSPopUpButton *MUST* appear before NSButton in the if/else
91 // because NSPopUpButton is a NSButton...
92 NSString *tmp_key = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
93 NSString *tmp = @"auto";
95 if ([conn_auth_dict objectForKey:tmp_key])
96 tmp = [conn_auth_dict objectForKey:tmp_key];
98 [value selectItemWithTitle:tmp];
99 } else if ([value isKindOfClass:[NSButton class]]) {
100 [value setState:[[account preferenceForKey:key group:GROUP_ACCOUNT_STATUS] boolValue]];
102 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);
107 - (void)saveConfiguration
109 [super saveConfiguration];
111 // Only need 1 hash for both connection & auth since there are no overlapping keys
112 NSDictionary *conn_auth_dict =
113 [NSDictionary dictionaryWithObjectsAndKeys:
116 @"tls-dsk",@"TLS-DSK",
122 for (NSString* key in sipe_key_to_gui) {
123 id value = [sipe_key_to_gui objectForKey:key];
125 if ([value isKindOfClass:[NSTextField class]]) {
127 setPreference:[[value stringValue] length] ? [value stringValue] : @""
129 group:GROUP_ACCOUNT_STATUS];
130 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
131 // NSPopUpButton *MUST* appear before NSButton in the if/else
132 // because NSPopUpButton is a NSButton...
133 NSString *tmp = [conn_auth_dict objectForKey:[[value selectedItem] title]];
137 group:GROUP_ACCOUNT_STATUS];
138 } else if ([value isKindOfClass:[NSButton class]]) {
140 setPreference:[NSNumber numberWithBool:[value state]]
142 group:GROUP_ACCOUNT_STATUS];
144 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);