-
Notifications
You must be signed in to change notification settings - Fork 72
/
AppDelegate.m
655 lines (453 loc) · 25.3 KB
/
AppDelegate.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
//
// AppDelegate.m
// MacMiner
//
// Created by Administrator on 02/04/2013.
// Copyright (c) 2013 fabulouspanda. All rights reserved.
//
#import "AppDelegate.h"
#import "bfgminerViewController.h"
@implementation AppDelegate
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize managedObjectContext = _managedObjectContext;
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate:self];
BOOL notificationCenterIsAvailable = (NSClassFromString(@"NSUserNotificationCenter")!=nil);
if (notificationCenterIsAvailable) {
NSString *stringVersion = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://downloads.fabulouspanda.co.uk/version.html"]encoding:NSUTF8StringEncoding error:nil];
NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
// NSString *appVersion = [infoDict objectForKey:@"CFBundleShortVersionString"]; // example: 1.0.0
NSNumber *buildNumber = [infoDict objectForKey:@"CFBundleVersion"];
NSString *checkString = [NSString stringWithFormat:@"%@", buildNumber];
if ([checkString rangeOfString:stringVersion].location == NSNotFound) {
NSUserNotification *notification = [[NSUserNotification alloc] init];
[notification setTitle:@"Update Available"];
NSString *messageText = [NSString stringWithFormat:@"You have version %@, %@ is available", checkString, stringVersion];
[notification setInformativeText:messageText];
[notification setSoundName:NSUserNotificationDefaultSoundName];
NSUserNotificationCenter *center = [NSUserNotificationCenter defaultUserNotificationCenter];
[center scheduleNotification: notification];
}
}
[[NSApp dockTile] setContentView:self.dockView];
[[NSApp dockTile] display];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs synchronize];
NSString *hideVersion = [prefs objectForKey:@"hideVersion"];
if ([hideVersion isEqualToString:@"1513"]) {
[self.releaseNotes orderOut:nil];
}
prefs = nil;
}
- (void) userNotificationCenter: (NSUserNotificationCenter *) center didActivateNotification: (NSUserNotification *) notification
{
if ([notification activationType] == NSUserNotificationActivationTypeContentsClicked)
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://fabulouspanda.co.uk/macminer/"]];
}
}
- (BOOL)userNotificationCenter:(NSUserNotificationCenter *)center shouldPresentNotification:(NSUserNotification *)notification{
return YES;
}
// Returns the directory the application uses to store the Core Data store file. This code uses a directory named "fabulouspanda.MacMiner" in the user's Application Support directory.
- (NSURL *)applicationFilesDirectory
{
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *appSupportURL = [[fileManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask] lastObject];
return [appSupportURL URLByAppendingPathComponent:@"fabulouspanda.MacMiner"];
}
// Creates if necessary and returns the managed object model for the application.
- (NSManagedObjectModel *)managedObjectModel
{
if (_managedObjectModel) {
return _managedObjectModel;
}
NSURL *modelURL = [[NSBundle mainBundle] URLForResource:@"MacMiner" withExtension:@"momd"];
_managedObjectModel = [[NSManagedObjectModel alloc] initWithContentsOfURL:modelURL];
return _managedObjectModel;
}
// Returns the persistent store coordinator for the application. This implementation creates and return a coordinator, having added the store for the application to it. (The directory for the store is created, if necessary.)
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator
{
if (_persistentStoreCoordinator) {
return _persistentStoreCoordinator;
}
NSManagedObjectModel *mom = [self managedObjectModel];
if (!mom) {
NSLog(@"%@:%@ No model to generate a store from", [self class], NSStringFromSelector(_cmd));
return nil;
}
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *applicationFilesDirectory = [self applicationFilesDirectory];
NSError *error = nil;
NSDictionary *properties = [applicationFilesDirectory resourceValuesForKeys:@[NSURLIsDirectoryKey] error:&error];
if (!properties) {
BOOL ok = NO;
if ([error code] == NSFileReadNoSuchFileError) {
ok = [fileManager createDirectoryAtPath:[applicationFilesDirectory path] withIntermediateDirectories:YES attributes:nil error:&error];
}
if (!ok) {
[[NSApplication sharedApplication] presentError:error];
return nil;
}
}/* else {
if (![properties[NSURLIsDirectoryKey] boolValue]) {
// Customize and localize this error.
NSString *failureDescription = [NSString stringWithFormat:@"Expected a folder to store application data, found a file (%@).", [applicationFilesDirectory path]];
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setValue:failureDescription forKey:NSLocalizedDescriptionKey];
error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:101 userInfo:dict];
[[NSApplication sharedApplication] presentError:error];
return nil;
}
}*/
NSURL *url = [applicationFilesDirectory URLByAppendingPathComponent:@"MacMiner.storedata"];
NSPersistentStoreCoordinator *coordinator = [[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:mom];
if (![coordinator addPersistentStoreWithType:NSXMLStoreType configuration:nil URL:url options:nil error:&error]) {
[[NSApplication sharedApplication] presentError:error];
return nil;
}
_persistentStoreCoordinator = coordinator;
return _persistentStoreCoordinator;
}
// Returns the managed object context for the application (which is already bound to the persistent store coordinator for the application.)
- (NSManagedObjectContext *)managedObjectContext
{
if (_managedObjectContext) {
return _managedObjectContext;
}
NSPersistentStoreCoordinator *coordinator = [self persistentStoreCoordinator];
if (!coordinator) {
NSMutableDictionary *dict = [NSMutableDictionary dictionary];
[dict setValue:@"Failed to initialize the store" forKey:NSLocalizedDescriptionKey];
[dict setValue:@"There was an error building up the data file." forKey:NSLocalizedFailureReasonErrorKey];
NSError *error = [NSError errorWithDomain:@"YOUR_ERROR_DOMAIN" code:9999 userInfo:dict];
[[NSApplication sharedApplication] presentError:error];
return nil;
}
_managedObjectContext = [[NSManagedObjectContext alloc] init];
[_managedObjectContext setPersistentStoreCoordinator:coordinator];
return _managedObjectContext;
}
// Returns the NSUndoManager for the application. In this case, the manager returned is that of the managed object context for the application.
- (NSUndoManager *)windowWillReturnUndoManager:(NSWindow *)window
{
return [[self managedObjectContext] undoManager];
}
// Performs the save action for the application, which is to send the save: message to the application's managed object context. Any encountered errors are presented to the user.
- (IBAction)saveAction:(id)sender
{
NSError *error = nil;
if (![[self managedObjectContext] commitEditing]) {
NSLog(@"%@:%@ unable to commit editing before saving", [self class], NSStringFromSelector(_cmd));
}
if (![[self managedObjectContext] save:&error]) {
[[NSApplication sharedApplication] presentError:error];
}
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
// Save changes in the application's managed object context before the application terminates.
if ([self.bfgReading isHidden] == NO || [self.cgReading isHidden] == NO || [self.cpuReading isHidden] == NO || [self.asicReading isHidden] == NO) {
NSString *question = NSLocalizedString(@"Could not quit", @"Quit without stop error question message");
NSString *info = NSLocalizedString(@"Please stop your miners before quitting", @"Quit without saves error question info");
NSString *cancelButton = NSLocalizedString(@"Okie Dokie", @"Cancel button title");
NSAlert *alert = [[NSAlert alloc] init];
[alert setMessageText:question];
[alert setInformativeText:info];
[alert addButtonWithTitle:cancelButton];
NSInteger answer = [alert runModal];
if (answer == NSAlertFirstButtonReturn) {
return NSTerminateCancel;
}
}
else {
NSLog(@"I'm sploding!");
//
//
// if (!_managedObjectContext) {
// [bfgMiner stopBFG];
// return NSTerminateNow;
// }
//
// if (![[self managedObjectContext] commitEditing]) {
// [bfgMiner stopBFG];
// NSLog(@"%@:%@ unable to commit editing to terminate", [self class], NSStringFromSelector(_cmd));
// return NSTerminateCancel;
// }
//
// if (![[self managedObjectContext] hasChanges]) {
// [bfgMiner stopBFG];
// return NSTerminateNow;
// }
//
// NSError *error = nil;
// if (![[self managedObjectContext] save:&error]) {
// [bfgMiner stopBFG];
//
// // Customize this code block to include application-specific recovery steps.
// BOOL result = [sender presentError:error];
// if (result) {
// return NSTerminateCancel;
// }
//
// NSString *question = NSLocalizedString(@"Could not save changes while quitting. Quit anyway?", @"Quit without saves error question message");
// NSString *info = NSLocalizedString(@"Quitting now will lose any changes you have made since the last successful save", @"Quit without saves error question info");
// NSString *quitButton = NSLocalizedString(@"Quit anyway", @"Quit anyway button title");
// NSString *cancelButton = NSLocalizedString(@"Cancel", @"Cancel button title");
// NSAlert *alert = [[NSAlert alloc] init];
// [alert setMessageText:question];
// [alert setInformativeText:info];
// [alert addButtonWithTitle:quitButton];
// [alert addButtonWithTitle:cancelButton];
//
// NSInteger answer = [alert runModal];
//
// if (answer == NSAlertAlternateReturn) {
// return NSTerminateCancel;
// }
// }
// [searchTask stopProcess];
return NSTerminateNow;
}
return NSTerminateNow;
}
- (IBAction)displaySite:(id)sender
{
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://fabulouspanda.co.uk/macminer/"]];
}
- (void)mobileCommands {
[self performSelectorInBackground:@selector(mobileCommandsThread) withObject:nil];
}
-(void)mobileCommandsThread {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs synchronize];
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:@" trying to send data to MoMi "];
NSString *email = [prefs objectForKey:@"emailAddress"];
NSString *appID = [prefs objectForKey:@"appID"];
NSString *machineName = [[NSHost currentHost] localizedName];
machineName = [machineName stringByReplacingOccurrencesOfString:@" " withString:@"_"];
machineName = [machineName stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] invertedSet];
machineName = [[machineName componentsSeparatedByCharactersInSet:notAllowedChars] componentsJoinedByString:@""];
if (machineName.length <= 1) {
machineName = @"Mac";
}
if (self.allowMobileMinerControl.state == NSOnState) {
//GET Request
NSString *getString = [NSString stringWithFormat:@"http://mobileminer.azurewebsites.net/api/RemoteCommands?emailAddress=%@&applicationKey=%@&machineName=%@&apiKey=26efrOXrizmEF3", email, appID, machineName];
NSMutableURLRequest *request2 = [[NSMutableURLRequest alloc] init];
[request2 setHTTPMethod:@"GET"];
[request2 setURL:[NSURL URLWithString:getString]];
NSError *error = [[NSError alloc] init];
NSHTTPURLResponse *responseCode = nil;
NSData *oResponseData = [NSURLConnection sendSynchronousRequest:request2 returningResponse:&responseCode error:&error];
if([responseCode statusCode] != 200){
if([responseCode statusCode] != 0){
if([responseCode statusCode] != 503){
NSLog(@"Error getting %@, HTTP status code %li", getString, (long)[responseCode statusCode]);
// return nil;
}
}
}
NSString *responseString = [[NSString alloc] initWithData:oResponseData encoding:NSUTF8StringEncoding];
if ([responseString rangeOfString:@"STOP"].location != NSNotFound) {
self.mobileMinerStatus = @"STOP";
}
if ([responseString rangeOfString:@"START"].location != NSNotFound) {
self.mobileMinerStatus = @"START";
}
if ([responseString rangeOfString:@"RESTART"].location != NSNotFound) {
self.mobileMinerStatus = @"RESTART";
}
if ([responseString rangeOfString:@"Id"].location != NSNotFound) {
NSString *idString = [self getDataBetweenFromString:responseString
leftString:@"Id" rightString:@"," leftOffset:4];
NSString *deleteString = [NSString stringWithFormat:@"http://mobileminer.azurewebsites.net/api/RemoteCommands?emailAddress=%@&applicationKey=%@&machineName=%@&commandId=%@&apiKey=26efrOXrizmEF3", email, appID, machineName, idString];
NSMutableURLRequest *request3 = [[NSMutableURLRequest alloc] init];
[request3 setHTTPMethod:@"DELETE"];
[request3 setURL:[NSURL URLWithString:deleteString]];
NSError *error3 = [[NSError alloc] init];
NSHTTPURLResponse *responseCode3 = nil;
NSData *oResponseData3 = [NSURLConnection sendSynchronousRequest:request3 returningResponse:&responseCode3 error:&error3];
if([responseCode3 statusCode] != 200){
if([responseCode3 statusCode] != 0){
if([responseCode statusCode] != 503){
NSLog(@"Error getting %@, HTTP status code %li", getString, (long)[responseCode statusCode]);
// return nil;
}
}
}
else {
// NSLog(@"DELETE SUCCESS");
//NSString *responseString3 = [[NSString alloc] initWithData:oResponseData3 encoding:NSUTF8StringEncoding];
// NSLog(responseString3);
}
}
//end control code
}
email = nil;
appID = nil;
prefs = nil;
machineName = nil;
}
- (void)mobilePost
{
// [self performSelectorInBackground:@selector(mobilePostThread) withObject:nil];
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs synchronize];
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:@" trying to send data to MoMi "];
NSString *email = [prefs objectForKey:@"emailAddress"];
NSString *appID = [prefs objectForKey:@"appID"];
NSString *machineName = [[NSHost currentHost] localizedName];
machineName = [machineName stringByReplacingOccurrencesOfString:@" " withString:@"_"];
machineName = [machineName stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] invertedSet];
machineName = [[machineName componentsSeparatedByCharactersInSet:notAllowedChars] componentsJoinedByString:@""];
if (machineName.length <= 1) {
machineName = @"Mac";
}
if (email.length >= 5) {
NSString *prepost = @"";
prepost = [NSString stringWithFormat:[self.mobileMinerDataArray componentsJoinedByString:@","]];
if (prepost.length >= 30) {
NSString *post1 = [prepost stringByAppendingString:@"]"];
NSString *post = [@"[" stringByAppendingString:post1];
// NSLog(post);
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:@" POST formed: "];
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:post];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *urlString = @"";
if (self.disableHttpsButton.state == NSOffState) {
urlString = nil;
urlString = [NSString stringWithFormat:@"https://mobileminer.azurewebsites.net/api/MiningStatisticsInput?emailAddress=%@&applicationKey=%@&machineName=%@&apiKey=26efrOXrizmEF3", email, appID, machineName];
}
if (self.disableHttpsButton.state == NSOnState) {
urlString = nil;
urlString = [NSString stringWithFormat:@"http://mobileminer.azurewebsites.net/api/MiningStatisticsInput?emailAddress=%@&applicationKey=%@&machineName=%@&apiKey=26efrOXrizmEF3", email, appID, machineName];
}
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:@" DATA SENT "];
post1 = nil;
post = nil;
postData = nil;
postLength = nil;
request = nil;
urlString = nil;
theConnection = nil;
}
prepost = nil;
}
email = nil;
appID = nil;
prefs = nil;
machineName = nil;
}
- (void)mobilePostThread {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs synchronize];
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:@" trying to send data to MoMi "];
NSString *email = [prefs objectForKey:@"emailAddress"];
NSString *appID = [prefs objectForKey:@"appID"];
NSString *machineName = [[NSHost currentHost] localizedName];
machineName = [machineName stringByReplacingOccurrencesOfString:@" " withString:@"_"];
machineName = [machineName stringByReplacingOccurrencesOfString:@"-" withString:@"_"];
machineName = [machineName stringByReplacingOccurrencesOfString:@"'" withString:@"_"];
machineName = [machineName stringByReplacingOccurrencesOfString:@"\"" withString:@"_"];
machineName = [machineName stringByReplacingOccurrencesOfString:@"’" withString:@"_"];
NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:@"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"] invertedSet];
machineName = [[machineName componentsSeparatedByCharactersInSet:notAllowedChars] componentsJoinedByString:@""];
if (machineName.length <= 1) {
machineName = @"Mac";
}
if (email.length >= 5) {
NSString *prepost = @"";
prepost = [NSString stringWithFormat:[self.mobileMinerDataArray componentsJoinedByString:@","]];
if (prepost.length >= 30) {
NSString *post1 = [prepost stringByAppendingString:@"]"];
NSString *post = [@"[" stringByAppendingString:post1];
// NSLog(post);
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:@" POST formed: "];
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:post];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%lu", (unsigned long)[postData length]];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *urlString = @"";
if (self.disableHttpsButton.state == NSOffState) {
urlString = nil;
urlString = [NSString stringWithFormat:@"https://mobileminer.azurewebsites.net/api/MiningStatisticsInput?emailAddress=%@&applicationKey=%@&machineName=%@&apiKey=26efrOXrizmEF3", email, appID, machineName];
}
if (self.disableHttpsButton.state == NSOnState) {
urlString = nil;
urlString = [NSString stringWithFormat:@"http://mobileminer.azurewebsites.net/api/MiningStatisticsInput?emailAddress=%@&applicationKey=%@&machineName=%@&apiKey=26efrOXrizmEF3", email, appID, machineName];
}
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
// self.asicAPIStorage2.string = [self.asicAPIStorage2.string stringByAppendingString:@" DATA SENT "];
post1 = nil;
post = nil;
postData = nil;
postLength = nil;
request = nil;
urlString = nil;
theConnection = nil;
}
prepost = nil;
}
email = nil;
appID = nil;
prefs = nil;
machineName = nil;
}
- (BOOL)theConnection:(NSURLConnection *)theConnection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace {
return [protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust];
}
- (void)theConnection:(NSURLConnection *)theConnection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge {
// if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
// if (... user allows connection despite bad certificate ...)
// [challenge.sender useCredential:[NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust] forAuthenticationChallenge:challenge];
[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
}
- (IBAction)hideVersionStuff:(id)sender
{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
[prefs setObject:@"1513" forKey:@"hideVersion"];
[prefs synchronize];
[self.releaseNotes orderOut:sender];
prefs = nil;
}
- (NSString *)getDataBetweenFromString:(NSString *)data leftString:(NSString *)leftData rightString:(NSString *)rightData leftOffset:(NSInteger)leftPos;
{
if ([leftData isNotEqualTo:nil]) {
NSInteger left, right;
NSScanner *scanner=[NSScanner scannerWithString:data];
[scanner scanUpToString:leftData intoString: nil];
left = [scanner scanLocation];
[scanner setScanLocation:left + leftPos];
[scanner scanUpToString:rightData intoString: nil];
right = [scanner scanLocation] + 1;
left += leftPos;
self.foundData = [data substringWithRange: NSMakeRange(left, (right - left) - 1)];
return self.foundData;
self.foundData = nil;
scanner = nil;
leftData = nil;
rightData = nil;
}
else return nil;
}
@end