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 <Adium/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,
44 checkbox_allowWebPhoto, KEY_SIPE_ALLOW_WEB_PHOTO,
54 [sipe_key_to_gui release];
58 - (NSString *)nibName{
59 return @"ESSIPEAccountView";
62 #pragma mark Configuration methods
63 - (void)configureForAccount:(AIAccount *)inAccount
65 [super configureForAccount:inAccount];
67 // BEAST mitigation for Mavericks and 10.8.5 users (with Security Update 2014-001)
68 if (NSAppKitVersionNumber < NSAppKitVersionNumber10_8_5) {
69 // We are not running on an OS with BEAST mitigations - Don't display this as a configuration option
70 [checkbox_beastDisable setHidden:YES];
73 // Only need 1 hash for both connection & auth since there are no overlapping keys
74 NSDictionary *conn_auth_dict =
75 [NSDictionary dictionaryWithObjectsAndKeys:
78 @"TLS-DSK",@"tls-dsk",
84 for (NSString* key in sipe_key_to_gui) {
85 id value = [sipe_key_to_gui objectForKey:key];
87 if ([value isKindOfClass:[NSTextField class]]) {
88 NSString *tmp = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
89 [value setStringValue:(tmp ? tmp : @"")];
90 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
91 // NSPopUpButton *MUST* appear before NSButton in the if/else
92 // because NSPopUpButton is a NSButton...
93 NSString *tmp_key = [account preferenceForKey:key group:GROUP_ACCOUNT_STATUS];
94 NSString *tmp = @"auto";
96 if ([conn_auth_dict objectForKey:tmp_key])
97 tmp = [conn_auth_dict objectForKey:tmp_key];
99 [value selectItemWithTitle:tmp];
100 } else if ([value isKindOfClass:[NSButton class]]) {
101 [value setState:[[account preferenceForKey:key group:GROUP_ACCOUNT_STATUS] boolValue]];
103 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);
108 - (void)saveConfiguration
110 [super saveConfiguration];
112 // Only need 1 hash for both connection & auth since there are no overlapping keys
113 NSDictionary *conn_auth_dict =
114 [NSDictionary dictionaryWithObjectsAndKeys:
117 @"tls-dsk",@"TLS-DSK",
123 for (NSString* key in sipe_key_to_gui) {
124 id value = [sipe_key_to_gui objectForKey:key];
126 if ([value isKindOfClass:[NSTextField class]]) {
128 setPreference:[[value stringValue] length] ? [value stringValue] : @""
130 group:GROUP_ACCOUNT_STATUS];
131 } else if ([value isKindOfClass:[NSPopUpButton class]]) {
132 // NSPopUpButton *MUST* appear before NSButton in the if/else
133 // because NSPopUpButton is a NSButton...
134 NSString *tmp = [conn_auth_dict objectForKey:[[value selectedItem] title]];
138 group:GROUP_ACCOUNT_STATUS];
139 } else if ([value isKindOfClass:[NSButton class]]) {
141 setPreference:[NSNumber numberWithBool:[value state]]
143 group:GROUP_ACCOUNT_STATUS];
145 AILog(@"(ESSIPEAccountViewController) Unknown class %@ for key %@", [value class], key);