1/* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#import "WALTAppDelegate.h" 18 19#include <sys/utsname.h> 20 21#import "UIAlertView+Extensions.h" 22#import "WALTClient.h" 23#import "WALTLogger.h" 24 25@interface WALTAppDelegate () 26@property (readwrite, nonatomic) WALTClient *client; 27@end 28 29@implementation WALTAppDelegate 30- (BOOL)application:(UIApplication *)application 31 willFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 32 struct utsname systemInfo; 33 if (uname(&systemInfo) != 0) { 34 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"System Error" 35 message:@"Cannot identify system." 36 delegate:nil 37 cancelButtonTitle:@"Dismiss" 38 otherButtonTitles:nil]; 39 [alert show]; 40 } else { 41 [[WALTLogger sessionLogger] appendFormat:@"DEVICE\t%s\t%s\t%s\t%s\t%s\n", 42 systemInfo.machine, 43 systemInfo.sysname, 44 systemInfo.release, 45 systemInfo.nodename, 46 systemInfo.version]; 47 } 48 49 NSError *error = nil; 50 self.client = [[WALTClient alloc] initWithError:&error]; 51 if (!self.client) { 52 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"WALT Connection Error" error:error]; 53 [alert show]; 54 } 55 56 return YES; 57} 58@end 59