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
28 [[NSDictionary alloc] initWithObjectsAndKeys:
29 textField_windowsLogin, KEY_SIPE_WINDOWS_LOGIN,
30 textField_password, KEY_SIPE_PASSWORD,
31 textField_server, KEY_SIPE_CONNECT_HOST,
32 popup_connectionType, KEY_SIPE_CONNECTION_TYPE,
33 popup_authenticationScheme, KEY_SIPE_AUTH_SCHEME,
34 textField_userAgent, KEY_SIPE_USER_AGENT,
35 checkBox_singleSignOn, KEY_SIPE_SINGLE_SIGN_ON,
36 checkbox_beastDisable, KEY_SIPE_BEAST_DISABLE,
37 textField_groupchatUser, KEY_SIPE_GROUP_CHAT_PROXY,
38 textField_emailURL, KEY_SIPE_EMAIL_URL,
39 textField_email, KEY_SIPE_EMAIL,
40 textField_emailLogin, KEY_SIPE_EMAIL_LOGIN,
41 textField_emailPassword, KEY_SIPE_EMAIL_PASSWORD,
42 checkbox_dontPublish, KEY_SIPE_DONT_PUBLISH,
51 [sipe_key_to_gui release];
55 - (NSString *)nibName{
56 return @"ESSIPEAccountView";
59 #pragma mark Configuration methods
60 - (void)configureForAccount:(AIAccount *)inAccount
62 [super configureForAccount:inAccount];
64 // BEAST mitigation for Mavericks and 10.8.5 users (with Security Update 2014-001)
65 if (NSAppKitVersionNumber < NSAppKitVersionNumber10_8_5) {
66 // We are not running on an OS with BEAST mitigations - Don't display this as a configuration option
67 [checkbox_beastDisable setHidden:YES];
70 // Only need 1 hash for both connection & auth since there are no overlapping keys
71 NSDictionary *conn_auth_dict =
72 [NSDictionary dictionaryWithObjectsAndKeys:
75 @"TLS-DSK",@"tls-dsk",
81 for (NSString* key in sipe_key_to_gui) {
82 id value = [sipe_key_to_gui objectForKey:key];
84 if ([value isKindOfClass:[NSTextField class]]) {
85 NSString *tmp = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
86 [value setStringValue:(tmp ? tmp : @"")];
87 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
88 // NSPopUpButton *MUST* appear before NSButton in the if/else
89 // because NSPopUpButton is a NSButton...
90 NSString *tmp_key = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
91 NSString *tmp = [key isEqualToString:KEY_SIPE_CONNECTION_TYPE] ? @"auto" : @"ntlm";
93 if (conn_auth_dict[tmp_key])
94 tmp = conn_auth_dict[tmp_key];
96 [value selectItemWithTitle:tmp];
97 } else if ([value isKindOfClass:[NSButton class]]) {
98 [value setState:[[account preferenceForKey:key group:GROUP_ACCOUNT_STATUS] boolValue]];
100 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);
105 - (void)saveConfiguration
107 [super saveConfiguration];
109 // Only need 1 hash for both connection & auth since there are no overlapping keys
110 NSDictionary *conn_auth_dict =
111 [NSDictionary dictionaryWithObjectsAndKeys:
114 @"tls-dsk",@"TLS-DSK",
120 for (NSString* key in sipe_key_to_gui) {
121 id value = [sipe_key_to_gui objectForKey:key];
123 if ([value isKindOfClass:[NSTextField class]]) {
125 setPreference:[[value stringValue] length] ? [value stringValue] : @""
127 group:GROUP_ACCOUNT_STATUS];
128 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
129 // NSPopUpButton *MUST* appear before NSButton in the if/else
130 // because NSPopUpButton is a NSButton...
131 NSString *tmp = conn_auth_dict[[[value selectedItem] title]];
135 group:GROUP_ACCOUNT_STATUS];
136 } else if ([value isKindOfClass:[NSButton class]]) {
138 setPreference:[NSNumber numberWithBool:[value state]]
140 group:GROUP_ACCOUNT_STATUS];
142 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);