github.com/c-darwin/mobile@v0.0.0-20160313183840-ff625c46f7c9/app/armx.m_02.12.15 (about) 1 // Copyright 2015 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // +build darwin 6 // +build arm arm64 7 8 #include "_cgo_export.h" 9 #include <pthread.h> 10 #include <stdio.h> 11 #include <sys/utsname.h> 12 13 #import <UIKit/UIKit.h> 14 #import <GLKit/GLKit.h> 15 16 struct utsname sysInfo; 17 18 @interface ViewController : UIViewController<UIWebViewDelegate,UIScrollViewDelegate,UITextFieldDelegate> 19 { 20 IBOutlet UIWebView *webView; 21 IBOutlet UISlider *slider; 22 IBOutlet UILabel *lbl; 23 IBOutlet UITextField *txtField; 24 IBOutlet UIButton *btn; 25 IBOutlet UISwitch *swich; 26 IBOutlet UIScrollView *scView; 27 } 28 //property (strong, nonatomic) IBOutlet UIWebView *viewWeb; 29 //property (nonatomic, retain) UIWebView *page; 30 @property(nonatomic,retain)UIWindow *window; 31 @property(nonatomic,retain)UIWebView *webView; 32 @property(nonatomic,retain)UISlider *slider; 33 @property(nonatomic,retain)UILabel *lbl; 34 @property(nonatomic,retain)UITextField *txtField; 35 @property(nonatomic,retain)UIButton *btn; 36 @property(nonatomic,retain)UIScrollView *scView; 37 @property(nonatomic,retain)UISwitch *swich; 38 39 -(IBAction)sliderChanged:(UISlider *)slider; 40 41 @end 42 43 44 @interface GoAppAppDelegate : UIResponder <UIApplicationDelegate> 45 @property (nonatomic, strong) ViewController *vc; 46 @property (strong, nonatomic) UIWindow *window; 47 @end 48 49 @implementation GoAppAppDelegate 50 51 - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo 52 { 53 if (error != NULL) 54 { 55 NSLog(@"Loading KEY ERROR:%@", error); 56 } 57 else 58 { 59 NSLog(@"OK DCOIN KEY"); 60 } 61 } 62 63 64 65 66 /* 67 -(void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler 68 { 69 NSLog(@"golog2 performFetchWithCompletionHandler"); 70 for (int i=0;i<15;i++) 71 { 72 int tRem = [[UIApplication sharedApplication] backgroundTimeRemaining]; 73 NSLog(@"golog2 b20.3>: Background +++++++++++ time Remaining: %d",tRem); 74 if (i == 15) { 75 NSLog(@"golog2 b20.3>: DCOIN STOP"); 76 dcoinStopHTTPServer(); 77 dcoinStop(); 78 } 79 [NSThread sleepForTimeInterval:1]; //wait for 1 sec 80 } 81 completionHandler(UIBackgroundFetchResultNewData); 82 } 83 */ 84 85 86 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 87 { 88 [[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum]; 89 90 NSLog(@"golog2 didFinishLaunchingWithOptions"); 91 92 93 94 95 NSString *searchedString = @"http://127.0.0.1:8089/ajax?controllerName=dcoinKey&password=2fh4h3Fdd"; 96 NSRange searchedRange = NSMakeRange(0, [searchedString length]); 97 NSString *pattern = @"dcoinKey&password=(.*)$"; 98 NSError *error = nil; 99 NSRegularExpression* regex = [NSRegularExpression regularExpressionWithPattern: pattern options:0 error:&error]; 100 NSArray* matches = [regex matchesInString:searchedString options:0 range: searchedRange]; 101 for (NSTextCheckingResult* match in matches) { 102 NSString* matchText = [searchedString substringWithRange:[match range]]; 103 NSLog(@"*********************match: %@", matchText); 104 NSRange group1 = [match rangeAtIndex:1]; 105 //NSRange group2 = [match rangeAtIndex:2]; 106 NSLog(@"group1: %@", [searchedString substringWithRange:group1]); 107 //NSLog(@"group2: %@", [searchedString substringWithRange:group2]); 108 } 109 110 NSTextCheckingResult *match = [regex firstMatchInString:searchedString options:0 range: searchedRange]; 111 NSLog(@">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>.group1: %@", [searchedString substringWithRange:[match rangeAtIndex:1]]); 112 //NSLog(@">>>>group2: %@", [searchedString substringWithRange:[match rangeAtIndex:2]]); 113 114 115 // NSError* error = nil; 116 // UIImage *imageWithData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.fnordware.com/superpng/pngtest8rgba.png"] options:NSDataReadingUncached error:&error]; 117 /* UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.fnordware.com/superpng/pngtest8rgba.png"]]]; 118 NSLog(@"img ok"); 119 if (error) { 120 NSLog(@"ERRR IMG%@", [error localizedDescription]); 121 [error release]; 122 } else { 123 NSLog(@">>>>>>>>Data has loaded successfully."); 124 } 125 // Create path. 126 NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 127 NSString *filePath = [[paths objectAtIndex:0] stringByAppendingPathComponent:@"Image.png"]; 128 NSLog(@">>>>>>>PATH%@", filePath); 129 */ 130 /* // Save image. 131 [UIImagePNGRepresentation(image) writeToFile:filePath atomically:YES]; 132 */ 133 134 // UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 135 136 137 138 if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]) { 139 [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeSound|UIUserNotificationTypeBadge 140 categories:nil]]; 141 } 142 //-- Set Notification 143 if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 144 { 145 // iOS 8 Notifications 146 [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 147 148 [application registerForRemoteNotifications]; 149 } 150 else 151 { 152 // iOS < 8 Notifications 153 [application registerForRemoteNotificationTypes: 154 (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)]; 155 } 156 157 158 159 160 // dcoinStart(); 161 // self.vc = [[ViewController alloc] initWithNibName:nil bundle:nil]; 162 // self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 163 // self.window.rootViewController = self.vc; 164 // self.window.backgroundColor = [UIColor greenColor]; 165 // [self.window makeKeyAndVisible]; 166 167 168 if([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)]) 169 { 170 NSLog(@"golog2: Multitasking Supported"); 171 172 __block UIBackgroundTaskIdentifier background_task; 173 background_task = [application beginBackgroundTaskWithExpirationHandler:^ { 174 175 //Clean up code. Tell the system that we are done. 176 [application endBackgroundTask: background_task]; 177 background_task = UIBackgroundTaskInvalid; 178 }]; 179 180 //To make the code block asynchronous 181 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 182 183 //### background task starts 184 NSLog(@"golog2>: Running in the background\n"); 185 //goserv(); 186 dcoinStart(); 187 while(TRUE) 188 { 189 int tRem = [[UIApplication sharedApplication] backgroundTimeRemaining]; 190 NSLog(@"golog2 b20.3>: Background time Remaining: %d",tRem); 191 if (tRem < 10 && tRem > 0) { 192 NSLog(@"golog2 b20.3>: DCOIN STOP"); 193 dcoinStopHTTPServer(); 194 dcoinStop(); 195 } 196 [NSThread sleepForTimeInterval:1]; //wait for 1 sec 197 } 198 //#### background task ends 199 200 //Clean up code. Tell the system that we are done. 201 [application endBackgroundTask: background_task]; 202 background_task = UIBackgroundTaskInvalid; 203 }); 204 } 205 else 206 { 207 NSLog(@"golog2: Multitasking Not Supported"); 208 } 209 210 211 self.vc = [[ViewController alloc] initWithNibName:nil bundle:nil]; 212 self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 213 self.window.rootViewController = self.vc; 214 // self.window.backgroundColor = [UIColor [colorFromHexString: @"#0E70AD"]] 215 // self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"assets/LaunchImage.png"]]; 216 UIGraphicsBeginImageContext(self.window.frame.size); 217 [[UIImage imageNamed:@"assets/LaunchImage.png"] drawInRect:self.window.bounds]; 218 UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); 219 UIGraphicsEndImageContext(); 220 self.window.backgroundColor = [UIColor colorWithPatternImage:image]; 221 222 223 [self.window makeKeyAndVisible]; 224 225 226 return YES; 227 } 228 /* 229 // Assumes input like "#00FF00" (#RRGGBB). 230 + (UIColor *)colorFromHexString:(NSString *)hexString { 231 unsigned rgbValue = 0; 232 NSScanner *scanner = [NSScanner scannerWithString:hexString]; 233 [scanner setScanLocation:1]; // bypass '#' character 234 [scanner scanHexInt:&rgbValue]; 235 return [UIColor colorWithRed:((rgbValue & 0xFF0000) >> 16)/255.0 green:((rgbValue & 0xFF00) >> 8)/255.0 blue:(rgbValue & 0xFF)/255.0 alpha:1.0]; 236 } 237 */ 238 -(void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification 239 { 240 241 UIApplicationState state = [[UIApplication sharedApplication] applicationState]; 242 // checking the state of the application 243 if (state == UIApplicationStateActive) 244 { 245 // Application is running in the foreground 246 UIAlertView* alert = [[UIAlertView alloc] initWithTitle:notification.alertTitle message:notification.alertBody delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 247 248 [alert show]; 249 [alert release]; 250 251 //Playing sound 252 // NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] resourcePath],notification.soundName]]; 253 254 //AVAudioPlayer *newAudioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:NULL]; 255 // self.audioPlayer = newAudioPlayer; 256 // self.audioPlayer.numberOfLoops = -1; 257 // [self.audioPlayer play]; 258 // [newAudioPlayer release]; 259 } 260 } 261 262 /* 263 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 264 { 265 [self.audioPlayer stop]; 266 } 267 */ 268 269 - (void)applicationWillResignActive:(UIApplication *)application 270 { 271 NSLog(@"golog2 applicationWillResignActive"); 272 273 // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 274 // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 275 } 276 277 - (void) sleep1:(NSTimer*)t { 278 NSLog(@"SLEEP ok"); 279 } 280 281 - (void)applicationDidEnterBackground:(UIApplication *)application 282 { 283 NSLog(@"golog2 applicationDidEnterBackground"); 284 // dcoinStopHTTPServer(); 285 // dcoinTestSleep(); 286 NSLog(@"golog2 toback ok"); 287 // [NSTimer scheduledTimerWithTimeInterval:3.0 288 // target:self 289 // selector:@selector(sleep1:) 290 // userInfo:nil 291 // repeats:NO]; 292 // NSLog(@"golog2 toback 2"); 293 294 } 295 296 - (void)applicationWillEnterForeground:(UIApplication *)application 297 { 298 // dcoinStartHTTPServer(); 299 NSLog(@"golog2 applicationWillEnterForeground"); 300 301 // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 302 } 303 304 - (void)applicationDidBecomeActive:(UIApplication *)application 305 { 306 NSLog(@"golog2 applicationDidBecomeActive"); 307 //dcoinStartHTTPServer(); 308 [UIApplication sharedApplication].applicationIconBadgeNumber=0; 309 310 // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 311 } 312 313 314 - (void) terminate1:(NSTimer*)t { 315 NSLog(@"TERM ok"); 316 } 317 318 319 320 - (void)applicationWillTerminate:(UIApplication *)application 321 { 322 NSLog(@"golog2 applicationWillTerminate!!!"); 323 dcoinStopHTTPServer(); 324 NSLog(@"golog2 dcoinStop ++++++++++++++++++++++++++++++++++"); 325 dcoinStop(); 326 //dcoinTestSleep(); 327 NSLog(@"golog2 applicationWillTerminate ok"); 328 //[NSTimer scheduledTimerWithTimeInterval:5.0 329 // target:self 330 // selector:@selector(terminate1:) 331 // userInfo:nil 332 // repeats:NO]; 333 // NSLog(@"golog2 applicationWillTerminate 2"); 334 335 // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 336 } 337 338 339 @end 340 341 342 @interface ViewController () 343 344 @end 345 346 @implementation ViewController 347 348 //- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 349 //{ 350 // NSLog(@"golog2 initWithNibName"); 351 // self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 352 // return self; 353 //} 354 355 //- (void)viewDidLayoutSubviews { 356 // webView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 357 // NSLog(@"golog2 viewDidLayoutSubviews"); 358 359 //} 360 /* 361 - (void) openWV:(NSTimer*)t { 362 363 self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 364 NSMutableURLRequest * request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1:8089"]]; 365 self.view = self.webView; 366 [self.webView loadRequest:request]; 367 } 368 */ 369 - (void)viewDidLoad 370 { 371 /// [super viewDidLoad]; 372 373 374 375 376 /* dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 377 //Here your non-main thread. 378 [NSThread sleepForTimeInterval:5.0f]; 379 dispatch_async(dispatch_get_main_queue(), ^{ 380 381 self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 382 NSString * string = @"<html><body><h1>Hayageek</h1>How to <a href=\"http://vk.com/\" target=\"_blank\">111</a> <br><br><br><br><br><a href=\"?jjj=1\">222222222222222</a>"; 383 self.view = self.webView; 384 self.webView.delegate = self; 385 [self.webView loadHTMLString:string baseURL:nil]; 386 }); 387 }); 388 */ 389 390 391 // [NSTimer scheduledTimerWithTimeInterval:5.0 392 // target:self 393 // selector:@selector(openWV:) 394 // userInfo:nil 395 // repeats:NO]; 396 397 398 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 399 //Here your non-main thread. 400 [NSThread sleepForTimeInterval:3.0f]; 401 dispatch_async(dispatch_get_main_queue(), ^{ 402 403 self.webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)]; 404 NSMutableURLRequest * request =[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://127.0.0.1:8089"]]; 405 self.webView.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight; 406 self.webView.scrollView.bounces = NO; 407 self.webView.scalesPageToFit = NO; 408 self.view = self.webView; 409 self.webView.delegate = self; 410 [self.webView loadRequest:request]; 411 }); 412 }); 413 414 NSLog(@"golog2 viewDidLoad ok"); 415 [super viewDidLoad]; 416 417 } 418 419 420 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 421 NSLog(@"golog2 111111111111111111111111111"); 422 return (UIInterfaceOrientationIsPortrait(interfaceOrientation) || UIInterfaceOrientationIsLandscape(interfaceOrientation)); 423 } 424 425 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------- 426 427 - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{ 428 NSLog(@"golog2 111111111111111111111111111222"); 429 430 } 431 432 //-------------------------------------------------------------------------------------------------------------------------------------------------------------------- 433 434 - (void) changeTheViewToPortrait:(BOOL)portrait andDuration:(NSTimeInterval)duration{ 435 436 NSLog(@"golog2 11111111111111111111111111122233333"); 437 438 } 439 440 - (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error 441 { 442 NSLog(@"golog2 Failed to load with error :%@",[error debugDescription]); 443 } 444 445 //- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { 446 // NSLog(@"golog2 +++++++++++++++++++++++++++++++++111111+"); 447 // return YES; 448 //} 449 450 -(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType { 451 NSLog(@"golog2 ++++++++++++SAFARI++++++++++++++++++++++"); 452 // NSLog(@"%@", inRequest); 453 NSLog(@"%@", [inRequest URL]); 454 // NSLog(@"%@", inWeb); 455 // NSLog(@"%@", inType); 456 457 // self.webView.scalesPageToFit = NO; 458 459 NSError *error = nil; 460 NSString* string = [[inRequest URL] absoluteString]; 461 462 // NSString* string = @"http://127.0.0.1/dcoin1Key/"; 463 NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"^((?!127\.0\.0\.1).)*$" options:NSRegularExpressionCaseInsensitive error:&error]; 464 NSTextCheckingResult *match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])]; 465 NSLog(@"external: %@", match); 466 BOOL isExternal = match != nil; 467 468 /*regex = [NSRegularExpression regularExpressionWithPattern:@"FormExPs=mobile" options:NSRegularExpressionCaseInsensitive error:&error]; 469 match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])]; 470 NSLog(@"isMobileGate: %@", match); 471 BOOL isMobileGate = match != nil;*/ 472 473 regex = [NSRegularExpression regularExpressionWithPattern:@"dcoinKey&password=(.*)$" options:NSRegularExpressionCaseInsensitive error:&error]; 474 match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])]; 475 NSLog(@"isKey: %@", match); 476 BOOL isKey = match != nil; 477 478 regex = [NSRegularExpression regularExpressionWithPattern:@"upgrade3" options:NSRegularExpressionCaseInsensitive error:&error]; 479 match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])]; 480 NSLog(@"isUpgrade3: %@", match); 481 BOOL isUpgrade3 = match != nil; 482 483 regex = [NSRegularExpression regularExpressionWithPattern:@"upgrade4" options:NSRegularExpressionCaseInsensitive error:&error]; 484 match = [regex firstMatchInString:string options:0 range:NSMakeRange(0, [string length])]; 485 NSLog(@"isUpgrade4: %@", match); 486 BOOL isUpgrade4 = match != nil; 487 488 489 if (isUpgrade3) { 490 NSLog(@"isUpgrade3 ok"); 491 self.webView.scalesPageToFit = YES; 492 return YES; 493 } else if (isUpgrade4) { 494 NSLog(@"isUpgrade4 ok"); 495 self.webView.scalesPageToFit = NO; 496 return YES; 497 /*} else if (isMobileGate) { 498 NSLog(@"isMobileGate ok"); 499 // [[UIApplication sharedApplication] openURL:[inRequest URL]]; 500 return YES;*/ 501 } else if (isExternal) { 502 NSLog(@"isExternal %@", [inRequest URL]); 503 //NSString* URL = @"http://tmp-e.dcoin.club/go.php?FormExPs=mobile&FormExAmount=1&FormDC=72&FormToken=ZyCIpKnpEoUXrl6nNzDo3r5XJaDLsC"; 504 [[UIApplication sharedApplication] openURL:[inRequest URL]]; 505 return NO; 506 } else if (isKey) { 507 NSLog(@"group1: %@", [string substringWithRange:[match rangeAtIndex:1]]); 508 NSLog(@"SAFARI"); 509 //[[UIApplication sharedApplication] openURL:[inRequest URL]]; 510 //return NO; 511 /* UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://127.0.0.1:8089/ajax?controllerName=dcoinKey&ios=1&password="+[string substringWithRange:[match rangeAtIndex:1]]]]]; 512 NSLog(@"img ok"); 513 if (error) { 514 NSLog(@"ERRR IMG%@", [error localizedDescription]); 515 [error release]; 516 } else { 517 NSLog(@">>>>>>>>Data has loaded successfully."); 518 } 519 UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 520 */ 521 522 [NSThread detachNewThreadSelector:@selector(downloadImage) toTarget:self withObject:nil]; 523 return NO; 524 } 525 return YES; 526 } 527 528 - (void)downloadImage 529 { 530 531 // network animation on 532 [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 533 534 // create autorelease pool 535 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 536 537 NSError *error = nil; 538 NSLog(@"001"); 539 // save image from the web 540 UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://127.0.0.1:8089/ajax?controllerName=dcoinKey&ios=1&first=1"]]]; 541 NSLog(@"img ok"); 542 if (error) { 543 NSLog(@"ERRR IMG%@", [error localizedDescription]); 544 [error release]; 545 } else { 546 NSLog(@">>>>>>>>Data has loaded successfully."); 547 } 548 UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 549 550 //UIImageWriteToSavedPhotosAlbum([UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://127.0.0.1:8089/ajax?controllerName=dcoinKey"]]], self, @selector(image:didFinishSavingWithError:contextInfo:), nil); 551 NSLog(@"002"); 552 [self performSelectorOnMainThread:@selector(imageDownloaded) withObject:nil waitUntilDone:NO ]; 553 NSLog(@"003"); 554 [pool drain]; 555 556 } 557 558 - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo 559 { 560 if (error != NULL) 561 { 562 NSLog(@"Loading KEY ERROR:%@", error); 563 } 564 else 565 { 566 NSLog(@"OK DCOIN KEY"); 567 } 568 } 569 570 - (void)imageDownloaded 571 { 572 NSLog(@"004"); 573 // network animation off 574 [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 575 NSLog(@"005"); 576 // do whatever you need to do after 577 } 578 579 /* 580 #pragma - mark UIWebView Delegate Methods 581 - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 582 { 583 NSLog(@"Loading URL :%@",request.URL.absoluteString); 584 585 //return FALSE; //to stop loading 586 return YES; 587 } 588 589 590 - (void)didReceiveMemoryWarning 591 { 592 [super didReceiveMemoryWarning]; 593 NSLog(@"golog2 didReceiveMemoryWarning"); 594 595 // Dispose of any resources that can be recreated. 596 } 597 */ 598 599 - (NSUInteger) supportedInterfaceOrientations { 600 // Return a bitmask of supported orientations. If you need more, 601 // use bitwise or (see the commented return). 602 return UIInterfaceOrientationMaskPortrait; 603 // return UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown; 604 } 605 606 - (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation { 607 // Return the orientation you'd prefer - this is what it launches to. The 608 // user can still rotate. You don't have to implement this method, in which 609 // case it launches in the current orientation 610 return UIInterfaceOrientationPortrait; 611 } 612 @end 613 614 615 void runApp(void) { 616 // back2(); 617 NSLog(@"golog2 runApp"); 618 @autoreleasepool { 619 UIApplicationMain(0, nil, nil, NSStringFromClass([GoAppAppDelegate class])); 620 } 621 } 622 623 void setContext(void* context) { 624 EAGLContext* ctx = (EAGLContext*)context; 625 if (![EAGLContext setCurrentContext:ctx]) { 626 // TODO(crawshaw): determine how terrible this is. Exit? 627 NSLog(@"failed to set current context"); 628 } 629 } 630 631 char* GetFilesDir(void) { 632 NSArray *paths = NSSearchPathForDirectoriesInDomains 633 (NSDocumentDirectory, NSUserDomainMask, YES); 634 NSString *documentsDirectory = [paths objectAtIndex:0]; 635 return (char*)[documentsDirectory UTF8String]; 636 } 637 638 uint64_t threadID() { 639 uint64_t id; 640 if (pthread_threadid_np(pthread_self(), &id)) { 641 abort(); 642 } 643 return id; 644 } 645 646 //void logNS(char* text) { 647 // NSLog(@"golog: %s", text); 648 //} 649 650 651 void ShowMess1() { 652 NSLog(@"golog2 UIAlertView ++++++++############"); 653 UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Простой alert" message:@"Это простой UIAlertView, он просто показывает сообщение" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil]; 654 [alert show]; 655 [alert release]; 656 }