/
AutoDownloads.xm
85 lines (70 loc) · 4.4 KB
/
AutoDownloads.xm
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
#import <Preferences/Preferences.h>
#import "PowerSaver.h"
#import "PSToggleProtocol.h"
#import "PSPersistence.h"
@interface PSADToggle : NSObject <PSToggleProtocol>
@end
@interface StoreSettingsController
+(id) alloc;
-(id) init;
-(void)_setAutomaticUpdatesEnabled:(id)arg1 specifier:(id)arg2;
-(void)_setAutomaticDownloadsEnabled:(id)arg1 specifier:(id)arg2;
-(id)_automaticDownloadsEnabled:(id)arg1;
-(id)_automaticUpdatesEnabled:(id)arg1;
@end
static StoreSettingsController *storeSettingsController;
@implementation PSADToggle
-(void) disable
{
if (!storeSettingsController)
storeSettingsController = [[%c(StoreSettingsController) alloc] init];
PSSpecifier *spec = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[spec setProperty:[NSSet setWithArray:@[@"software", @"ebook", @"song", @"music-video"]] forKey:@"SSDownloadKinds"];
PSSpecifier *software = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[software setProperty:[NSSet setWithArray:@[@"software"]] forKey:@"SSDownloadKinds"];
PSSpecifier *ebook = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[ebook setProperty:[NSSet setWithArray:@[@"ebook"]] forKey:@"SSDownloadKinds"];
PSSpecifier *song = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[song setProperty:[NSSet setWithArray:@[@"song"]] forKey:@"SSDownloadKinds"];
PSSpecifier *music_video = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[music_video setProperty:[NSSet setWithArray:@[@"music-video"]] forKey:@"SSDownloadKinds"];
NSDictionary *previousValues = @{
@"software": [storeSettingsController _automaticDownloadsEnabled:software],
@"ebook": [storeSettingsController _automaticDownloadsEnabled:ebook],
@"song": [storeSettingsController _automaticDownloadsEnabled:song],
@"music_video": [storeSettingsController _automaticDownloadsEnabled:music_video],
};
SET_VAL(previousValues, @"previousValues");
[storeSettingsController _setAutomaticDownloadsEnabled:@NO specifier:spec];
SET_STATE([[storeSettingsController _automaticUpdatesEnabled:nil] boolValue]);
[storeSettingsController _setAutomaticUpdatesEnabled:@NO specifier:nil];
}
-(void) enable
{
if (!storeSettingsController)
storeSettingsController = [[%c(StoreSettingsController) alloc] init];
PSSpecifier *software = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[software setProperty:[NSSet setWithArray:@[@"software"]] forKey:@"SSDownloadKinds"];
PSSpecifier *ebook = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[ebook setProperty:[NSSet setWithArray:@[@"ebook"]] forKey:@"SSDownloadKinds"];
PSSpecifier *song = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[song setProperty:[NSSet setWithArray:@[@"song"]] forKey:@"SSDownloadKinds"];
PSSpecifier *music_video = [PSSpecifier preferenceSpecifierNamed:@"test555" target:nil set:NULL get:NULL detail:NULL cell:PSSwitchCell edit:NULL];
[music_video setProperty:[NSSet setWithArray:@[@"music-video"]] forKey:@"SSDownloadKinds"];
NSDictionary *previousValues = GET_VAL(@"previousValues");
[storeSettingsController _setAutomaticDownloadsEnabled:previousValues[@"software"] specifier:software];
[storeSettingsController _setAutomaticDownloadsEnabled:previousValues[@"ebook"] specifier:ebook];
[storeSettingsController _setAutomaticDownloadsEnabled:previousValues[@"song"] specifier:song];
[storeSettingsController _setAutomaticDownloadsEnabled:previousValues[@"music_video"] specifier:music_video];
[storeSettingsController _setAutomaticUpdatesEnabled:@(GET_STATE) specifier:nil];
}
-(NSString*) identifier { return @"com.efrederickson.powersaver.toggles.autodownloads"; }
-(NSString*) displayName { return @"Disable Auto Downloads"; }
@end
%ctor
{
static PSADToggle *toggle = [[PSADToggle alloc] init];
[[PowerSaver sharedInstance] addToggle:toggle];
if ([NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.springboard"])
[[NSBundle bundleWithPath:@"/System/Library/PreferenceBundles/MobileStoreSettings.bundle"] load];
}