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_password, KEY_SIPE_PASSWORD,
30 textField_windowsLogin, KEY_SIPE_WINDOWS_LOGIN,
31 checkBox_singleSignOn, KEY_SIPE_SINGLE_SIGN_ON,
32 checkbox_dontPublish, KEY_SIPE_DONT_PUBLISH,
33 textField_userAgent, KEY_SIPE_USER_AGENT,
34 textField_emailURL, KEY_SIPE_EMAIL_URL,
35 textField_email, KEY_SIPE_EMAIL,
36 textField_emailLogin, KEY_SIPE_EMAIL_LOGIN,
37 textField_emailPassword, KEY_SIPE_EMAIL_PASSWORD,
38 textField_groupchatUser, KEY_SIPE_GROUP_CHAT_PROXY,
39 popup_connectionType, KEY_SIPE_CONNECTION_TYPE,
40 popup_authenticationScheme, KEY_SIPE_AUTH_SCHEME,
41 checkbox_beastDisable, KEY_SIPE_BEAST_DISABLE,
50 [sipe_key_to_gui release];
54 - (NSString *)nibName{
55 return @"ESSIPEAccountView";
58 #pragma mark Configuration methods
59 - (void)configureForAccount:(AIAccount *)inAccount
61 [super configureForAccount:inAccount];
63 // BEAST mitigation for Mavericks users
64 if (floor(NSAppKitVersionNumber) <= NSAppKitVersionNumber10_8) {
65 // We are not running on Mavericks - Don't display BEAST mitigation configuration option
66 [checkbox_beastDisable setHidden:YES];
69 // Only need 1 hash for both connection & auth since there are no overlapping keys
70 NSDictionary *conn_auth_dict =
71 [NSDictionary dictionaryWithObjectsAndKeys:
74 @"TLS-DSK",@"tls-dsk",
80 for (NSString* key in sipe_key_to_gui) {
81 id value = [sipe_key_to_gui objectForKey:key];
83 if ([value isKindOfClass:[NSTextField class]]) {
84 NSString *tmp = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
85 [value setStringValue:(tmp ? tmp : @"")];
86 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
87 // NSPopUpButton *MUST* appear before NSButton in the if/else
88 // because NSPopUpButton is a NSButton...
89 NSString *tmp_key = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
90 NSString *tmp = [key isEqualToString:KEY_SIPE_CONNECTION_TYPE] ? @"auto" : @"ntlm";
92 if (conn_auth_dict[tmp_key])
93 tmp = conn_auth_dict[tmp_key];
95 [value selectItemWithTitle:tmp];
96 } else if ([value isKindOfClass:[NSButton class]]) {
97 [value setState:[[account preferenceForKey:key group:GROUP_ACCOUNT_STATUS] boolValue]];
99 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);
104 - (void)saveConfiguration
106 [super saveConfiguration];
108 // Only need 1 hash for both connection & auth since there are no overlapping keys
109 NSDictionary *conn_auth_dict =
110 [NSDictionary dictionaryWithObjectsAndKeys:
113 @"tls-dsk",@"TLS-DSK",
119 for (NSString* key in sipe_key_to_gui) {
120 id value = [sipe_key_to_gui objectForKey:key];
122 if ([value isKindOfClass:[NSTextField class]]) {
124 setPreference:[[value stringValue] length] ? [value stringValue] : @""
126 group:GROUP_ACCOUNT_STATUS];
127 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
128 // NSPopUpButton *MUST* appear before NSButton in the if/else
129 // because NSPopUpButton is a NSButton...
130 NSString *tmp = conn_auth_dict[[[value selectedItem] title]];
134 group:GROUP_ACCOUNT_STATUS];
135 } else if ([value isKindOfClass:[NSButton class]]) {
137 setPreference:[NSNumber numberWithBool:[value state]]
139 group:GROUP_ACCOUNT_STATUS];
141 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);