-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSteamSettingsViewController.m
87 lines (69 loc) · 2.66 KB
/
SteamSettingsViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//
// SteamSettingsViewController.m
// Steam IM
//
// Created by Tobias Tangemann on 21.09.14.
// Copyright (c) 2014 Hermi. All rights reserved.
//
#import "SteamSettingsViewController.h"
#import <AdiumLibpurple/CBPurpleAccount.h>
#import "MXMatrixAccount.h"
enum identifyAsTag {
IDENTIFY_AS_MOBILE = 0,
IDENTIFY_AS_WEB = 1
};
@interface SteamSettingsViewController()
@end
@implementation SteamSettingsViewController
@synthesize optionsView;
- (NSView*) optionsView {
return optionsView;
}
- (NSString *)nibName {
return @"SteamOptions";
}
- (void)configureForAccount:(AIAccount *) inAccount
{
[super configureForAccount:inAccount];
// We need to get this from "purple_account_get_string" as it cant be updated by opensteamworks
PurpleAccount *pAccount = [((MXMatrixAccount*)inAccount) getPurpleAccount];
[steamGuardCode setStringValue: [NSString stringWithUTF8String: purple_account_get_string(pAccount, "steam_guard_code", "")]];
[alwaysHTTPS setState:[[account preferenceForKey:@"always_use_https" group:GROUP_ACCOUNT_STATUS] boolValue]];
[changeIngameStatus setState:[[account preferenceForKey:@"change_status_to_game" group:GROUP_ACCOUNT_STATUS] boolValue]];
[downloadOfflineHistory setState:[[account preferenceForKey:@"download_offline_history" group:GROUP_ACCOUNT_STATUS] boolValue]];
enum identifyAsTag identifyTag = IDENTIFY_AS_WEB;
if ([[account preferenceForKey:@"ui_mode" group:GROUP_ACCOUNT_STATUS] isEqualToString:@"mobile"])
identifyTag = IDENTIFY_AS_MOBILE;
[identifyAs selectCellWithTag:identifyTag];
}
//Save controls
- (void)saveConfiguration
{
[super saveConfiguration];
if (steamGuardCode.stringValue.length > 0) {
[account setPreference:steamGuardCode.stringValue
forKey:@"steam_guard_code" group:GROUP_ACCOUNT_STATUS];
}
[account setPreference:[NSNumber numberWithBool:[alwaysHTTPS state]]
forKey:@"always_use_https" group:GROUP_ACCOUNT_STATUS];
[account setPreference:[NSNumber numberWithBool:[changeIngameStatus state]]
forKey:@"change_status_to_game" group:GROUP_ACCOUNT_STATUS];
[account setPreference:[NSNumber numberWithBool:[downloadOfflineHistory state]]
forKey:@"download_offline_history" group:GROUP_ACCOUNT_STATUS];
NSInteger identifyTag = [identifyAs selectedTag];
NSString* identifyStr = nil;
switch (identifyTag) {
case IDENTIFY_AS_MOBILE:
identifyStr = @"mobile";
break;
case IDENTIFY_AS_WEB:
identifyStr = @"web";
break;
default:
identifyStr = @"web";
}
if (identifyStr) {
[account setPreference:identifyStr forKey:@"ui_mode" group:GROUP_ACCOUNT_STATUS];
}
}
@end