Skip to content
This repository was archived by the owner on Jun 23, 2019. It is now read-only.

Commit fc06ef4

Browse files
committed
2.3.17 - Add support for new donation key formats.
1 parent b226a8c commit fc06ef4

File tree

4 files changed

+57
-30
lines changed

4 files changed

+57
-30
lines changed

MAL Updater OS X.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,9 @@
203203
91A8DD5E1E736814006E3566 /* NSNumberFormatterNumberOnly.m in Sources */ = {isa = PBXBuildFile; fileRef = 91A8DD5C1E736814006E3566 /* NSNumberFormatterNumberOnly.m */; };
204204
91A9B6691EA918FB00645690 /* MAL_Updater_OS_XTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 91A9B6681EA918FB00645690 /* MAL_Updater_OS_XTests.m */; };
205205
91A9B6701EA9192D00645690 /* testdata.json in Resources */ = {isa = PBXBuildFile; fileRef = 9115DA401EA911A300CAEF4E /* testdata.json */; };
206+
F84F3D3920AB248A00B9250F /* DonationCheck_KeyOnly.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */; };
207+
F84F3D3A20AB249900B9250F /* DonationCheck_KeyOnly.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */; };
208+
F84F3D3B20AB249900B9250F /* DonationCheck_KeyOnly.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
206209
/* End PBXBuildFile section */
207210

208211
/* Begin PBXContainerItemProxy section */
@@ -251,6 +254,7 @@
251254
91206C1F1E75F5AD0050E9C5 /* MASPreferences.framework in CopyFiles */,
252255
2D3CBE4A1F1532950085888D /* XMLReader.framework in CopyFiles */,
253256
2D63136F1EDA287200C3CB6B /* DetectionKit.framework in CopyFiles */,
257+
F84F3D3B20AB249900B9250F /* DonationCheck_KeyOnly.framework in CopyFiles */,
254258
91A609F51EA3E77C00EF40AB /* CocoaOniguruma.framework in CopyFiles */,
255259
2D6522711F7B50CD00A65BF8 /* GBPing.framework in CopyFiles */,
256260
2D6313731EDA293B00C3CB6B /* Reachability.framework in CopyFiles */,
@@ -497,6 +501,7 @@
497501
91A9B6661EA918FB00645690 /* MAL Updater OS XTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "MAL Updater OS XTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
498502
91A9B6681EA918FB00645690 /* MAL_Updater_OS_XTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MAL_Updater_OS_XTests.m; sourceTree = "<group>"; };
499503
91A9B66A1EA918FB00645690 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
504+
F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = DonationCheck_KeyOnly.framework; path = Frameworks/DonationCheck_KeyOnly.framework; sourceTree = "<group>"; };
500505
/* End PBXFileReference section */
501506

502507
/* Begin PBXFrameworksBuildPhase section */
@@ -545,6 +550,7 @@
545550
91206C1E1E75F5AD0050E9C5 /* MASPreferences.framework in Frameworks */,
546551
9149EBE21E75F8A700B1AA22 /* MASShortcut.framework in Frameworks */,
547552
2D6313721EDA293B00C3CB6B /* Reachability.framework in Frameworks */,
553+
F84F3D3920AB248A00B9250F /* DonationCheck_KeyOnly.framework in Frameworks */,
548554
2D6522751F7B50FC00A65BF8 /* MSWeakTimer_macOS.framework in Frameworks */,
549555
91A609F31EA3E77400EF40AB /* CocoaOniguruma.framework in Frameworks */,
550556
2D9C3AE11E6A0BC7007D8F68 /* EasyNSURLConnection.framework in Frameworks */,
@@ -565,6 +571,7 @@
565571
2D63136E1EDA287200C3CB6B /* DetectionKit.framework in Frameworks */,
566572
9161B2011E90246200FBF52F /* Fabric.framework in Frameworks */,
567573
5C2B9DFC1221EB25006DEF0D /* CoreData.framework in Frameworks */,
574+
F84F3D3A20AB249900B9250F /* DonationCheck_KeyOnly.framework in Frameworks */,
568575
);
569576
runOnlyForDeploymentPostprocessing = 0;
570577
};
@@ -629,6 +636,7 @@
629636
1058C7A2FEA54F0111CA2CBB /* Other Frameworks */ = {
630637
isa = PBXGroup;
631638
children = (
639+
F84F3D3820AB248A00B9250F /* DonationCheck_KeyOnly.framework */,
632640
2D6522741F7B50F700A65BF8 /* MSWeakTimer_macOS.framework */,
633641
2D65226F1F7B50C700A65BF8 /* GBPing.framework */,
634642
2D65226E1F7B50C600A65BF8 /* PingNotifier.framework */,

MAL_Updater_OS_X-Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>2.3.16</string>
18+
<string>2.3.17</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>
22-
<string>2.3.16</string>
22+
<string>2.3.17</string>
2323
<key>Fabric</key>
2424
<dict>
2525
<key>APIKey</key>

MAL_Updater_OS_XAppDelegate.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,8 @@ - (IBAction)showaboutwindow:(id)sender{
697697
[copyrightstr appendFormat:@"This copy is registered to: MAL Library User"];
698698
}
699699
else {
700-
[copyrightstr appendFormat:@"This copy is registered to: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
700+
[copyrightstr appendFormat:@"This copy is registered to: %@\r", [[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
701+
[copyrightstr appendFormat:@"Donation Key: %@", [[NSUserDefaults standardUserDefaults] objectForKey:@"donatekey"]];
701702
}
702703
}
703704
else {

Utility.m

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#import <EasyNSURLConnection/EasyNSURLConnection.h>
1111
#import <CocoaOniguruma/OnigRegexp.h>
1212
#import <CocoaOniguruma/OnigRegexpUtility.h>
13+
#ifdef oss
14+
#else
15+
#import <DonationCheck_KeyOnly/DonationKeyVerify.h>
16+
#endif
1317

1418
@implementation Utility
1519
+ (int)checkMatch:(NSString *)title
@@ -85,32 +89,35 @@ + (NSString *)urlEncodeString:(NSString *)string{
8589
}
8690
+ (void)donateCheck:(MAL_Updater_OS_XAppDelegate*)delegate{
8791
if ([NSUserDefaults.standardUserDefaults boolForKey:@"MacAppStoreMigrated"]) {
92+
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"donated"];
93+
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"MacAppStoreMigrated"];
8894
return;
8995
}
9096
if (![[NSUserDefaults standardUserDefaults] objectForKey:@"donatereminderdate"]) {
9197
[Utility setReminderDate];
9298
}
93-
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"donatereminderdate"] timeIntervalSinceNow] < 0) {
94-
if (((NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"donated"]).boolValue) {
95-
int validkey = [Utility checkDonationKey:[[NSUserDefaults standardUserDefaults] objectForKey:@"donatekey"] name:[[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
96-
if (validkey == 1) {
97-
//Reset check
98-
[Utility setReminderDate];
99-
}
100-
else if (validkey == 2) {
101-
//Try again when there is internet access
102-
}
103-
else {
104-
//Invalid Key
105-
[Utility showsheetmessage:@"Donation Key Error" explaination:@"This key has been revoked. Please contact the author of this program or enter a valid key." window:nil];
106-
[Utility showDonateReminder:delegate];
107-
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"donated"];
108-
}
99+
if (((NSNumber *)[[NSUserDefaults standardUserDefaults] objectForKey:@"donated"]).boolValue) {
100+
int validkey = [Utility checkDonationKey:[[NSUserDefaults standardUserDefaults] objectForKey:@"donatekey"] name:[[NSUserDefaults standardUserDefaults] objectForKey:@"donor"]];
101+
if (validkey == 1) {
102+
//Reset check
103+
[Utility setReminderDate];
104+
return;
105+
}
106+
else if (validkey == 2) {
107+
//Try again when there is internet access
108+
return;
109109
}
110110
else {
111+
//Invalid Key
112+
[Utility showsheetmessage:@"Donation Key Error" explaination:@"This key has been revoked. Please contact the author of this program or enter a valid key." window:nil];
111113
[Utility showDonateReminder:delegate];
114+
[[NSUserDefaults standardUserDefaults] setObject:@NO forKey:@"donated"];
115+
return;
112116
}
113117
}
118+
if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"donatereminderdate"] timeIntervalSinceNow] < 0) {
119+
[Utility showDonateReminder:delegate];
120+
}
114121
}
115122
+ (void)showDonateReminder:(MAL_Updater_OS_XAppDelegate*)delegate{
116123
// Shows Donation Reminder
@@ -147,23 +154,34 @@ + (void)setReminderDate{
147154
[[NSUserDefaults standardUserDefaults] setObject:reminderdate forKey:@"donatereminderdate"];
148155
}
149156
+ (int)checkDonationKey:(NSString *)key name:(NSString *)name{
150-
//Set Search API
151-
NSURL *url = [NSURL URLWithString:@"https://licensing.malupdaterosx.moe/keycheck.php"];
152-
EasyNSURLConnection *request = [[EasyNSURLConnection alloc] initWithURL:url];
153-
[request addFormData:name forKey:@"name"];
154-
[request addFormData:key forKey:@"key"];
155-
//Ignore Cookies
156-
[request setUseCookies:NO];
157-
//Perform Search
158-
[request startJSONFormRequest:EasyNSURLConnectionJsonType];
159-
// Get Status Code
160-
long statusCode = [request getStatusCode];
157+
// Check Cocoafob Keys
158+
bool valid = [DonationKeyVerify checkMALULicense:name withDonationKey:key];
159+
if (valid) {
160+
return 1;
161+
}
162+
// Checks Donation Key validatity
163+
NSURL *url = [NSURL URLWithString:@"https://licensing.malupdaterosx.moe/keycheck.php"];
164+
EasyNSURLConnection *request = [[EasyNSURLConnection alloc] initWithURL:url];
165+
[request addFormData:name forKey:@"name"];
166+
[request addFormData:key forKey:@"key"];
167+
//Ignore Cookies
168+
[request setUseCookies:NO];
169+
//Perform Search
170+
[request startJSONFormRequest:EasyNSURLConnectionJsonType];
171+
// Get Status Code
172+
long statusCode = [request getStatusCode];
161173
if (statusCode == 200) {
162174
NSError* jerror;
163175
NSDictionary *d = [NSJSONSerialization JSONObjectWithData:request.response.responsedata options:nil error:&jerror];
164176
int valid = ((NSNumber *)d[@"valid"]).intValue;
165177
if (valid == 1) {
166178
// Valid Key
179+
if (d[@"newlicense"]) {
180+
[[NSUserDefaults standardUserDefaults] setObject:d[@"newlicense"] forKey:@"donatekey"];
181+
}
182+
else {
183+
[[NSUserDefaults standardUserDefaults] setObject:key forKey:@"donatekey"];
184+
}
167185
return 1;
168186
}
169187
else {

0 commit comments

Comments
 (0)