mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-02-16 10:31:02 +00:00
Created logger with log levels
This commit is contained in:
@@ -65,6 +65,7 @@
|
||||
FB9AFD3D1A7E111600872C98 /* AppAssetResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD3C1A7E111600872C98 /* AppAssetResponse.m */; };
|
||||
FB9AFD401A7E127D00872C98 /* AppListResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD3F1A7E127D00872C98 /* AppListResponse.m */; };
|
||||
FB9AFD431A7F0C6900872C98 /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = FB9AFD421A7F0C6900872C98 /* Controller.m */; };
|
||||
FBD1C8E21A8AD71400C6703C /* Logger.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD1C8E11A8AD71400C6703C /* Logger.m */; };
|
||||
FBD3494319FC9C04002D2A60 /* AppAssetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3494219FC9C04002D2A60 /* AppAssetManager.m */; };
|
||||
FBD3495019FF2174002D2A60 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3494F19FF2174002D2A60 /* SettingsViewController.m */; };
|
||||
FBD3495319FF36FB002D2A60 /* SWRevealViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = FBD3495219FF36FB002D2A60 /* SWRevealViewController.m */; };
|
||||
@@ -268,6 +269,8 @@
|
||||
FB9AFD3F1A7E127D00872C98 /* AppListResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppListResponse.m; sourceTree = "<group>"; };
|
||||
FB9AFD411A7F0C6900872C98 /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = "<group>"; };
|
||||
FB9AFD421A7F0C6900872C98 /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = "<group>"; };
|
||||
FBD1C8E01A8AD69E00C6703C /* Logger.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Logger.h; sourceTree = "<group>"; };
|
||||
FBD1C8E11A8AD71400C6703C /* Logger.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Logger.m; sourceTree = "<group>"; };
|
||||
FBD3494119FC9C04002D2A60 /* AppAssetManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppAssetManager.h; sourceTree = "<group>"; };
|
||||
FBD3494219FC9C04002D2A60 /* AppAssetManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppAssetManager.m; sourceTree = "<group>"; };
|
||||
FBD3494E19FF2174002D2A60 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = "<group>"; };
|
||||
@@ -509,6 +512,8 @@
|
||||
FBDE86E819F82315001C18A8 /* App.m */,
|
||||
FB89462119F646E200339C8A /* Utils.h */,
|
||||
FB89462219F646E200339C8A /* Utils.m */,
|
||||
FBD1C8E01A8AD69E00C6703C /* Logger.h */,
|
||||
FBD1C8E11A8AD71400C6703C /* Logger.m */,
|
||||
);
|
||||
path = Utility;
|
||||
sourceTree = "<group>";
|
||||
@@ -893,6 +898,7 @@
|
||||
FB4678FA1A55FFAD00377732 /* DiscoveryManager.m in Sources */,
|
||||
FBD3495B1A004411002D2A60 /* Host.m in Sources */,
|
||||
FB89463519F646E200339C8A /* MainFrameViewController.m in Sources */,
|
||||
FBD1C8E21A8AD71400C6703C /* Logger.m in Sources */,
|
||||
FB89463619F646E200339C8A /* StreamFrameViewController.m in Sources */,
|
||||
FB89462819F646E200339C8A /* CryptoManager.m in Sources */,
|
||||
FB89462E19F646E200339C8A /* PairManager.m in Sources */,
|
||||
|
||||
@@ -85,7 +85,7 @@ static NSOperationQueue* mainQueue;
|
||||
if ([managedObjectContext hasChanges] && ![managedObjectContext save:&error]) {
|
||||
// Replace this implementation with code to handle the error appropriately.
|
||||
// abort() causes the application to generate a crash log and terminate. You should not use this function in a shipping application, although it may be useful during development.
|
||||
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
|
||||
Log(LOG_E, @"Unresolved error %@, %@", error, [error userInfo]);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ static NSOperationQueue* mainQueue;
|
||||
Lightweight migration will only work for a limited set of schema changes; consult "Core Data Model Versioning and Data Migration Programming Guide" for details.
|
||||
|
||||
*/
|
||||
NSLog(@"Unresolved error %@, %@", error, [error userInfo]);
|
||||
Log(LOG_E, @"Unresolved error %@, %@", error, [error userInfo]);
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@ static NSData* p12 = nil;
|
||||
BIO_free(bio);
|
||||
|
||||
if (!x509) {
|
||||
NSLog(@"ERROR: unable to parse certificate in memory");
|
||||
Log(LOG_E, @"Unable to parse certificate in memory");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ static NSData* p12 = nil;
|
||||
BIO_free(bio);
|
||||
|
||||
if (!pkey) {
|
||||
NSLog(@"ERROR: unable to parse private key in memory!");
|
||||
Log(LOG_E, @"Unable to parse private key in memory!");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ static NSData* p12 = nil;
|
||||
x509 = PEM_read_bio_X509(bio, NULL, NULL, NULL);
|
||||
|
||||
if (!x509) {
|
||||
NSLog(@"ERROR: unable to parse certificate in memory!");
|
||||
Log(LOG_E, @"Unable to parse certificate in memory!");
|
||||
return NULL;
|
||||
}
|
||||
return [NSData dataWithBytes:x509->signature->data length:x509->signature->length];
|
||||
@@ -206,7 +206,7 @@ static NSData* p12 = nil;
|
||||
dispatch_once(&pred, ^{
|
||||
if (![CryptoManager keyPairExists]) {
|
||||
|
||||
NSLog(@"Generating Certificate... ");
|
||||
Log(LOG_I, @"Generating Certificate... ");
|
||||
CertKeyPair certKeyPair = generateCertKeyPair();
|
||||
|
||||
NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
||||
@@ -215,10 +215,10 @@ static NSData* p12 = nil;
|
||||
NSString* keyPairFile = [documentsDirectory stringByAppendingPathComponent:@"client.key"];
|
||||
NSString* p12File = [documentsDirectory stringByAppendingPathComponent:@"client.p12"];
|
||||
|
||||
//NSLog(@"Writing cert and key to: \n%@\n%@", certFile, keyPairFile);
|
||||
//Log(LOG_D, @"Writing cert and key to: \n%@\n%@", certFile, keyPairFile);
|
||||
saveCertKeyPair([certFile UTF8String], [p12File UTF8String], [keyPairFile UTF8String], certKeyPair);
|
||||
freeCertKeyPair(certKeyPair);
|
||||
NSLog(@"Certificate created");
|
||||
Log(LOG_I, @"Certificate created");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -233,7 +233,7 @@ static NSData* p12 = nil;
|
||||
NSMutableString* uniqueId = [NSMutableString stringWithString:[idString substringFromIndex:19]];
|
||||
[uniqueId deleteCharactersInRange:NSMakeRange(4, 1)];
|
||||
|
||||
//NSLog(@"Unique ID: %@", uniqueId);
|
||||
//Log(LOG_D, @"Unique ID: %@", uniqueId);
|
||||
return [NSString stringWithString:uniqueId];
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
NSError* error;
|
||||
if (![[self.appDelegate managedObjectContext] save:&error]) {
|
||||
NSLog(@"ERROR: Unable to save settings to database");
|
||||
Log(LOG_E, @"Unable to save settings to database: %@", error);
|
||||
}
|
||||
[self.appDelegate saveContext];
|
||||
}
|
||||
@@ -59,7 +59,7 @@
|
||||
- (void) saveHosts {
|
||||
NSError* error;
|
||||
if (![[self.appDelegate managedObjectContext] save:&error]) {
|
||||
NSLog(@"ERROR: Unable to save hosts to database");
|
||||
Log(LOG_E, @"Unable to save hosts to database: %@", error);
|
||||
}
|
||||
[self.appDelegate saveContext];
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@
|
||||
};
|
||||
}
|
||||
} else {
|
||||
NSLog(@"ERROR: Tried to register controller callbacks on NULL controller");
|
||||
Log(LOG_W, @"Tried to register controller callbacks on NULL controller");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@
|
||||
limeController.playerIndex = i;
|
||||
[_controllers setObject:limeController forKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
||||
|
||||
NSLog(@"Assigning controller index: %d", i);
|
||||
Log(LOG_I, @"Assigning controller index: %d", i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@
|
||||
_controllers = [[NSMutableDictionary alloc] init];
|
||||
_controllerNumbers = 0;
|
||||
|
||||
NSLog(@"Number of controllers connected: %ld", (long)[[GCController controllers] count]);
|
||||
Log(LOG_I, @"Number of controllers connected: %ld", (long)[[GCController controllers] count]);
|
||||
for (GCController* controller in [GCController controllers]) {
|
||||
[self assignController:controller];
|
||||
[self registerControllerCallbacks:controller];
|
||||
@@ -299,7 +299,7 @@
|
||||
}
|
||||
|
||||
self.connectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidConnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
NSLog(@"Controller connected!");
|
||||
Log(LOG_I, @"Controller connected!");
|
||||
|
||||
GCController* controller = note.object;
|
||||
[self assignController:controller];
|
||||
@@ -311,13 +311,13 @@
|
||||
[self updateAutoOnScreenControlMode];
|
||||
}];
|
||||
self.disconnectObserver = [[NSNotificationCenter defaultCenter] addObserverForName:GCControllerDidDisconnectNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *note) {
|
||||
NSLog(@"Controller disconnected!");
|
||||
Log(LOG_I, @"Controller disconnected!");
|
||||
|
||||
GCController* controller = note.object;
|
||||
[self unregisterControllerCallbacks:controller];
|
||||
[_controllers removeObjectForKey:[NSNumber numberWithInteger:controller.playerIndex]];
|
||||
_controllerNumbers &= ~(1 << controller.playerIndex);
|
||||
NSLog(@"Unassigning controller index: %ld", (long)controller.playerIndex);
|
||||
Log(LOG_I, @"Unassigning controller index: %ld", (long)controller.playerIndex);
|
||||
|
||||
// Re-evaluate the on-screen control mode
|
||||
[self updateAutoOnScreenControlMode];
|
||||
|
||||
@@ -205,7 +205,7 @@ static float L3_Y;
|
||||
[self hideL3R3]; // Full controls don't need these they have the sticks
|
||||
break;
|
||||
default:
|
||||
NSLog(@"Unknown on-screen controls level: %d", (int)_level);
|
||||
Log(LOG_W, @"Unknown on-screen controls level: %d", (int)_level);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,13 +38,13 @@
|
||||
[controllerSupport initAutoOnScreenControlMode:onScreenControls];
|
||||
}
|
||||
else {
|
||||
NSLog(@"Setting manual on-screen controls level: %d", (int)level);
|
||||
Log(LOG_I, @"Setting manual on-screen controls level: %d", (int)level);
|
||||
[onScreenControls setLevel:level];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
NSLog(@"Touch down");
|
||||
Log(LOG_D, @"Touch down");
|
||||
if (![onScreenControls handleTouchDownEvent:touches]) {
|
||||
UITouch *touch = [[event allTouches] anyObject];
|
||||
touchLocation = [touch locationInView:self];
|
||||
@@ -88,11 +88,11 @@
|
||||
}
|
||||
|
||||
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
|
||||
NSLog(@"Touch up");
|
||||
Log(LOG_D, @"Touch up");
|
||||
if (![onScreenControls handleTouchUpEvent:touches]) {
|
||||
if (!touchMoved) {
|
||||
if ([[event allTouches] count] == 2) {
|
||||
NSLog(@"Sending right mouse button press");
|
||||
Log(LOG_D, @"Sending right mouse button press");
|
||||
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
|
||||
|
||||
} else {
|
||||
NSLog(@"Sending left mouse button press");
|
||||
Log(LOG_D, @"Sending left mouse button press");
|
||||
|
||||
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
|
||||
|
||||
|
||||
@@ -14,4 +14,5 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <CoreData/CoreData.h>
|
||||
#endif
|
||||
#import "Logger.h"
|
||||
#endif
|
||||
@@ -32,7 +32,7 @@
|
||||
Host* oldHost = _host;
|
||||
_host = host;
|
||||
BOOL useCache = [oldHost.uuid isEqualToString:_host.uuid];
|
||||
NSLog(@"Using cached app images: %d", useCache);
|
||||
Log(LOG_I, @"Using cached app images: %d", useCache);
|
||||
if (!useCache) {
|
||||
[_imageCache removeAllObjects];
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ static const char* TAG_APP_IS_RUNNING = "IsRunning";
|
||||
- (void) parseData {
|
||||
xmlDocPtr docPtr = xmlParseMemory([self.data bytes], (int)[self.data length]);
|
||||
if (docPtr == NULL) {
|
||||
NSLog(@"ERROR: An error occured trying to parse xml.");
|
||||
Log(LOG_W, @"An error occured trying to parse xml.");
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr node = xmlDocGetRootElement(docPtr);
|
||||
if (node == NULL) {
|
||||
NSLog(@"ERROR: No root XML element.");
|
||||
Log(LOG_W, @"No root XML element.");
|
||||
xmlFreeDoc(docPtr);
|
||||
return;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ static const char* TAG_APP_IS_RUNNING = "IsRunning";
|
||||
node = node->children;
|
||||
|
||||
while (node != NULL) {
|
||||
//NSLog(@"node: %s", node->name);
|
||||
//Log(LOG_D, @"node: %s", node->name);
|
||||
if (!xmlStrcmp(node->name, (xmlChar*)TAG_APP)) {
|
||||
xmlNodePtr appInfoNode = node->xmlChildrenNode;
|
||||
NSString* appName;
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
}
|
||||
|
||||
- (void) startDiscovery {
|
||||
NSLog(@"Starting discovery");
|
||||
Log(LOG_I, @"Starting discovery");
|
||||
shouldDiscover = YES;
|
||||
[_mdnsMan searchForHosts];
|
||||
for (Host* host in _hostQueue) {
|
||||
@@ -72,19 +72,19 @@
|
||||
}
|
||||
|
||||
- (void) stopDiscovery {
|
||||
NSLog(@"Stopping discovery");
|
||||
Log(LOG_I, @"Stopping discovery");
|
||||
shouldDiscover = NO;
|
||||
[_mdnsMan stopSearching];
|
||||
[_opQueue cancelAllOperations];
|
||||
}
|
||||
|
||||
- (void) stopDiscoveryBlocking {
|
||||
NSLog(@"Stopping discovery and waiting for workers to stop");
|
||||
Log(LOG_I, @"Stopping discovery and waiting for workers to stop");
|
||||
shouldDiscover = NO;
|
||||
[_mdnsMan stopSearching];
|
||||
[_opQueue cancelAllOperations];
|
||||
[_opQueue waitUntilAllOperationsAreFinished];
|
||||
NSLog(@"All discovery workers stopped");
|
||||
Log(LOG_I, @"All discovery workers stopped");
|
||||
}
|
||||
|
||||
- (BOOL) addHostToDiscovery:(Host *)host {
|
||||
@@ -113,15 +113,15 @@
|
||||
DataManager* dataMan = [[DataManager alloc] init];
|
||||
// Discover the hosts before adding to eliminate duplicates
|
||||
for (Host* host in hosts) {
|
||||
NSLog(@"Found host through MDNS: %@:", host.name);
|
||||
Log(LOG_I, @"Found host through MDNS: %@:", host.name);
|
||||
// Since this is on a background thread, we do not need to use the opQueue
|
||||
DiscoveryWorker* worker = (DiscoveryWorker*)[self createWorkerForHost:host];
|
||||
[worker discoverHost];
|
||||
if ([self addHostToDiscovery:host]) {
|
||||
NSLog(@"Adding host to discovery: %@", host.name);
|
||||
Log(LOG_I, @"Adding host to discovery: %@", host.name);
|
||||
[_callback updateAllHosts:_hostQueue];
|
||||
} else {
|
||||
NSLog(@"Not adding host to discovery: %@", host.name);
|
||||
Log(LOG_I, @"Not adding host to discovery: %@", host.name);
|
||||
[dataMan removeHost:host];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
||||
}
|
||||
_host.online = receivedResponse;
|
||||
if (receivedResponse) {
|
||||
NSLog(@"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online);
|
||||
Log(LOG_D, @"Received response from: %@\n{\n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", _host.name, _host.address, _host.localAddress, _host.externalAddress, _host.uuid, _host.mac, _host.pairState, _host.online);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds
|
||||
[response populateHost:_host];
|
||||
return YES;
|
||||
} else {
|
||||
NSLog(@"Received response from incorrect host: %@ expected: %@", [response getStringTag:TAG_UNIQUE_ID], _host.uuid);
|
||||
Log(LOG_I, @"Received response from incorrect host: %@ expected: %@", [response getStringTag:TAG_UNIQUE_ID], _host.uuid);
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
|
||||
@@ -48,7 +48,7 @@ static const NSString* PORT = @"47984";
|
||||
}
|
||||
|
||||
- (void) executeRequestSynchronously:(HttpRequest*)request {
|
||||
NSLog(@"Making Request: %@", request);
|
||||
Log(LOG_D, @"Making Request: %@", request);
|
||||
[_respData setLength:0];
|
||||
dispatch_sync(dispatch_get_main_queue(), ^{
|
||||
[NSURLConnection connectionWithRequest:request.request delegate:self];
|
||||
@@ -154,11 +154,11 @@ static const NSString* PORT = @"47984";
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
|
||||
NSLog(@"Received response: %@", response);
|
||||
Log(LOG_D, @"Received response: %@", response);
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
|
||||
NSLog(@"\n\nReceived data: %@\n\n", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
|
||||
Log(LOG_D, @"\n\nReceived data: %@\n\n", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
|
||||
[_respData appendData:data];
|
||||
}
|
||||
|
||||
@@ -202,11 +202,11 @@ static const NSString* PORT = @"47984";
|
||||
OSStatus securityError = SecPKCS12Import(p12Data, options, &items);
|
||||
|
||||
if (securityError == errSecSuccess) {
|
||||
//NSLog(@"Success opening p12 certificate. Items: %ld", CFArrayGetCount(items));
|
||||
//Log(LOG_D, @"Success opening p12 certificate. Items: %ld", CFArrayGetCount(items));
|
||||
CFDictionaryRef identityDict = CFArrayGetValueAtIndex(items, 0);
|
||||
identityApp = (SecIdentityRef)CFDictionaryGetValue(identityDict, kSecImportItemIdentity);
|
||||
} else {
|
||||
NSLog(@"Error opening Certificate.");
|
||||
Log(LOG_E, @"Error opening Certificate.");
|
||||
}
|
||||
|
||||
CFRelease(options);
|
||||
@@ -216,7 +216,7 @@ static const NSString* PORT = @"47984";
|
||||
}
|
||||
|
||||
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
|
||||
NSLog(@"connection error: %@", error);
|
||||
Log(LOG_W, @"connection error: %@", error);
|
||||
dispatch_semaphore_signal(_requestLock);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,13 +42,13 @@
|
||||
_elements = [[NSMutableDictionary alloc] init];
|
||||
xmlDocPtr docPtr = xmlParseMemory([self.data bytes], (int)[self.data length]);
|
||||
if (docPtr == NULL) {
|
||||
NSLog(@"ERROR: An error occured trying to parse xml.");
|
||||
Log(LOG_W, @"An error occured trying to parse xml.");
|
||||
return;
|
||||
}
|
||||
|
||||
xmlNodePtr node = xmlDocGetRootElement(docPtr);
|
||||
if (node == NULL) {
|
||||
NSLog(@"ERROR: No root XML element.");
|
||||
Log(LOG_W, @"No root XML element.");
|
||||
xmlFreeDoc(docPtr);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -34,13 +34,13 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
||||
}
|
||||
|
||||
- (void) searchForHosts {
|
||||
NSLog(@"Starting mDNS discovery");
|
||||
Log(LOG_I, @"Starting mDNS discovery");
|
||||
scanActive = TRUE;
|
||||
[mDNSBrowser searchForServicesOfType:NV_SERVICE_TYPE inDomain:@""];
|
||||
}
|
||||
|
||||
- (void) stopSearching {
|
||||
NSLog(@"Stopping mDNS discovery");
|
||||
Log(LOG_I, @"Stopping mDNS discovery");
|
||||
scanActive = FALSE;
|
||||
[mDNSBrowser stop];
|
||||
}
|
||||
@@ -60,12 +60,12 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
||||
}
|
||||
|
||||
- (void)netServiceDidResolveAddress:(NSNetService *)service {
|
||||
NSLog(@"Resolved address: %@ -> %@", service, service.hostName);
|
||||
Log(LOG_I, @"Resolved address: %@ -> %@", service, service.hostName);
|
||||
[self.callback updateHosts:[self getFoundHosts]];
|
||||
}
|
||||
|
||||
- (void)netService:(NSNetService *)sender didNotResolve:(NSDictionary *)errorDict {
|
||||
NSLog(@"Did not resolve address for: %@\n%@", sender, [errorDict description]);
|
||||
Log(LOG_W, @"Did not resolve address for: %@\n%@", sender, [errorDict description]);
|
||||
|
||||
// Schedule a retry in 2 seconds
|
||||
[NSTimer scheduledTimerWithTimeInterval:2.0
|
||||
@@ -76,7 +76,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
||||
}
|
||||
|
||||
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didFindService:(NSNetService *)aNetService moreComing:(BOOL)moreComing {
|
||||
NSLog(@"Found service: %@", aNetService);
|
||||
Log(LOG_I, @"Found service: %@", aNetService);
|
||||
[aNetService setDelegate:self];
|
||||
[aNetService resolveWithTimeout:5];
|
||||
|
||||
@@ -85,13 +85,12 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
||||
}
|
||||
|
||||
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didRemoveService:(NSNetService *)aNetService moreComing:(BOOL)moreComing {
|
||||
NSLog(@"Removing service: %@", aNetService);
|
||||
Log(LOG_I, @"Removing service: %@", aNetService);
|
||||
[services removeObject:aNetService];
|
||||
}
|
||||
|
||||
- (void)netServiceBrowser:(NSNetServiceBrowser *)aNetServiceBrowser didNotSearch:(NSDictionary *)errorDict {
|
||||
NSLog(@"Did not perform search");
|
||||
NSLog(@"%@", [errorDict description]);
|
||||
Log(LOG_W, @"Did not perform search: \n%@", [errorDict description]);
|
||||
|
||||
// Schedule a retry in 2 seconds
|
||||
[NSTimer scheduledTimerWithTimeInterval:2.0
|
||||
@@ -107,7 +106,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"Retrying mDNS search");
|
||||
Log(LOG_I, @"Retrying mDNS search");
|
||||
[mDNSBrowser stop];
|
||||
[mDNSBrowser searchForServicesOfType:NV_SERVICE_TYPE inDomain:@""];
|
||||
}
|
||||
@@ -118,7 +117,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp";
|
||||
return;
|
||||
}
|
||||
|
||||
NSLog(@"Retrying mDNS resolution");
|
||||
Log(LOG_I, @"Retrying mDNS resolution");
|
||||
for (NSNetService* service in services) {
|
||||
if (service.hostName == nil) {
|
||||
[service setDelegate:self];
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
- (void) initiatePair {
|
||||
NSString* PIN = [self generatePIN];
|
||||
NSData* salt = [self saltPIN:PIN];
|
||||
NSLog(@"PIN: %@, saltedPIN: %@", PIN, salt);
|
||||
Log(LOG_I, @"PIN: %@, saltedPIN: %@", PIN, salt);
|
||||
[_callback showPIN:PIN];
|
||||
|
||||
HttpResponse* pairResp = [[HttpResponse alloc] init];
|
||||
|
||||
@@ -24,10 +24,10 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
||||
CFSocketRef wolSocket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL);
|
||||
if (!wolSocket) {
|
||||
CFRelease(dataPayload);
|
||||
NSLog(@"Failed to create WOL socket");
|
||||
Log(LOG_E, @"Failed to create WOL socket");
|
||||
return;
|
||||
}
|
||||
NSLog(@"WOL socket created");
|
||||
Log(LOG_I, @"WOL socket created");
|
||||
|
||||
struct sockaddr_in addr;
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
@@ -48,7 +48,7 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
||||
// try all ports
|
||||
for (int j = 0; j < numPorts; j++) {
|
||||
addr.sin_port = htons(ports[j]);
|
||||
NSLog(@"Sending WOL packet");
|
||||
Log(LOG_I, @"Sending WOL packet");
|
||||
CFSocketSendData(wolSocket, dataAddress, dataPayload, 0);
|
||||
}
|
||||
CFRelease(dataAddress);
|
||||
@@ -76,7 +76,7 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000};
|
||||
|
||||
+ (NSData*) macStringToBytes:(NSString*)mac {
|
||||
NSString* macString = [mac stringByReplacingOccurrencesOfString:@":" withString:@""];
|
||||
NSLog(@"MAC: %@", macString);
|
||||
Log(LOG_D, @"MAC: %@", macString);
|
||||
return [Utils hexToBytes:macString];
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ void ArInit(void)
|
||||
status = AudioComponentInstanceNew(AudioComponentFindNext(NULL, &audioDesc), &audioUnit);
|
||||
|
||||
if (status) {
|
||||
NSLog(@"Unable to instantiate new AudioComponent: %d", (int32_t)status);
|
||||
Log(LOG_E, @"Unable to instantiate new AudioComponent: %d", (int32_t)status);
|
||||
}
|
||||
|
||||
AudioStreamBasicDescription audioFormat = {0};
|
||||
@@ -132,7 +132,7 @@ void ArInit(void)
|
||||
&audioFormat,
|
||||
sizeof(audioFormat));
|
||||
if (status) {
|
||||
NSLog(@"Unable to set audio unit to input: %d", (int32_t)status);
|
||||
Log(LOG_E, @"Unable to set audio unit to input: %d", (int32_t)status);
|
||||
}
|
||||
|
||||
AURenderCallbackStruct callbackStruct = {0};
|
||||
@@ -146,12 +146,12 @@ void ArInit(void)
|
||||
&callbackStruct,
|
||||
sizeof(callbackStruct));
|
||||
if (status) {
|
||||
NSLog(@"Unable to set audio unit callback: %d", (int32_t)status);
|
||||
Log(LOG_E, @"Unable to set audio unit callback: %d", (int32_t)status);
|
||||
}
|
||||
|
||||
status = AudioUnitInitialize(audioUnit);
|
||||
if (status) {
|
||||
NSLog(@"Unable to initialize audioUnit: %d", (int32_t)status);
|
||||
Log(LOG_E, @"Unable to initialize audioUnit: %d", (int32_t)status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ void ArRelease(void)
|
||||
|
||||
OSStatus status = AudioUnitUninitialize(audioUnit);
|
||||
if (status) {
|
||||
NSLog(@"Unable to uninitialize audioUnit: %d", (int32_t)status);
|
||||
Log(LOG_E, @"Unable to uninitialize audioUnit: %d", (int32_t)status);
|
||||
}
|
||||
|
||||
// Audio session is now inactive
|
||||
@@ -186,7 +186,7 @@ void ArStart(void)
|
||||
{
|
||||
OSStatus status = AudioOutputUnitStart(audioUnit);
|
||||
if (status) {
|
||||
NSLog(@"Unable to start audioUnit: %d", (int32_t)status);
|
||||
Log(LOG_E, @"Unable to start audioUnit: %d", (int32_t)status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ void ArStop(void)
|
||||
{
|
||||
OSStatus status = AudioOutputUnitStop(audioUnit);
|
||||
if (status) {
|
||||
NSLog(@"Unable to stop audioUnit: %d", (int32_t)status);
|
||||
Log(LOG_E, @"Unable to stop audioUnit: %d", (int32_t)status);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ void ArDecodeAndPlaySample(char* sampleData, int sampleLength)
|
||||
|
||||
[audioLock lock];
|
||||
if (audioBufferQueueLength > MAX_QUEUE_ENTRIES) {
|
||||
NSLog(@"Audio player too slow. Dropping all decoded samples!");
|
||||
Log(LOG_W, @"Audio player too slow. Dropping all decoded samples!");
|
||||
|
||||
// Clear all values from the buffer queue
|
||||
struct AUDIO_BUFFER_QUEUE_ENTRY *entry;
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
y:_config.height / screenSize.height];
|
||||
|
||||
int majorVersion = [[appversion substringToIndex:1] intValue];
|
||||
NSLog(@"Server is generation %d", majorVersion);
|
||||
Log(LOG_I, @"Server is generation %d", majorVersion);
|
||||
|
||||
VideoDecoderRenderer* renderer = [[VideoDecoderRenderer alloc]initWithView:_renderView];
|
||||
_connection = [[Connection alloc] initWithConfig:_config renderer:renderer connectionCallbacks:_callbacks serverMajorVersion:majorVersion];
|
||||
@@ -121,11 +121,11 @@
|
||||
NSString *gameSession = [launchResp getStringTag:@"gamesession"];
|
||||
if (launchResp == NULL || ![launchResp isStatusOk]) {
|
||||
[_callbacks launchFailed:@"Failed to launch app"];
|
||||
NSLog(@"Failed Launch Response: %@", launchResp.statusMessage);
|
||||
Log(LOG_E, @"Failed Launch Response: %@", launchResp.statusMessage);
|
||||
return FALSE;
|
||||
} else if (gameSession == NULL || [gameSession isEqualToString:@"0"]) {
|
||||
[_callbacks launchFailed:launchResp.statusMessage];
|
||||
NSLog(@"Failed to parse game session. Code: %ld Response: %@", (long)launchResp.statusCode, launchResp.statusMessage);
|
||||
Log(LOG_E, @"Failed to parse game session. Code: %ld Response: %@", (long)launchResp.statusCode, launchResp.statusMessage);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -140,11 +140,11 @@
|
||||
NSString* resume = [resumeResp getStringTag:@"resume"];
|
||||
if (resumeResp == NULL || ![resumeResp isStatusOk]) {
|
||||
[_callbacks launchFailed:@"Failed to resume app"];
|
||||
NSLog(@"Failed Resume Response: %@", resumeResp.statusMessage);
|
||||
Log(LOG_E, @"Failed Resume Response: %@", resumeResp.statusMessage);
|
||||
return FALSE;
|
||||
} else if (resume == NULL || [resume isEqualToString:@"0"]) {
|
||||
[_callbacks launchFailed:resumeResp.statusMessage];
|
||||
NSLog(@"Failed to parse resume response. Code: %ld Response: %@", (long)resumeResp.statusCode, resumeResp.statusMessage);
|
||||
Log(LOG_E, @"Failed to parse resume response. Code: %ld Response: %@", (long)resumeResp.statusCode, resumeResp.statusMessage);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
kCFAllocatorDefault,
|
||||
NULL, 0, nalLength + 1, 0);
|
||||
if (status != noErr) {
|
||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@
|
||||
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
||||
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
||||
if (status != noErr) {
|
||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -106,7 +106,7 @@
|
||||
kCFAllocatorDefault, NULL, 0,
|
||||
NAL_LENGTH_PREFIX_SIZE, 0);
|
||||
if (status != noErr) {
|
||||
NSLog(@"CMBlockBufferAppendMemoryBlock failed: %d", (int)status);
|
||||
Log(LOG_E, @"CMBlockBufferAppendMemoryBlock failed: %d", (int)status);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@
|
||||
status = CMBlockBufferReplaceDataBytes(lengthBytes, existingBuffer,
|
||||
oldOffset, NAL_LENGTH_PREFIX_SIZE);
|
||||
if (status != noErr) {
|
||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
kCFAllocatorNull, // Don't deallocate data on free
|
||||
NULL, 0, dataLength, 0);
|
||||
if (status != noErr) {
|
||||
NSLog(@"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
Log(LOG_E, @"CMBlockBufferReplaceDataBytes failed: %d", (int)status);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -141,7 +141,7 @@
|
||||
|
||||
// Check for previous decoder errors before doing anything
|
||||
if (displayLayer.status == AVQueuedSampleBufferRenderingStatusFailed) {
|
||||
NSLog(@"Display layer rendering failed: %@", displayLayer.error);
|
||||
Log(LOG_E, @"Display layer rendering failed: %@", displayLayer.error);
|
||||
|
||||
// Recreate the display layer
|
||||
[self reinitializeDisplayLayer];
|
||||
@@ -152,14 +152,14 @@
|
||||
|
||||
if (nalType == NAL_TYPE_SPS || nalType == NAL_TYPE_PPS) {
|
||||
if (nalType == NAL_TYPE_SPS) {
|
||||
NSLog(@"Got SPS");
|
||||
Log(LOG_I, @"Got SPS");
|
||||
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||
waitingForSps = false;
|
||||
|
||||
// We got a new SPS so wait for a new PPS to match it
|
||||
waitingForPps = true;
|
||||
} else if (nalType == NAL_TYPE_PPS) {
|
||||
NSLog(@"Got PPS");
|
||||
Log(LOG_I, @"Got PPS");
|
||||
ppsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||
waitingForPps = false;
|
||||
}
|
||||
@@ -169,7 +169,7 @@
|
||||
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsData bytes] };
|
||||
const size_t parameterSetSizes[] = { [spsData length], [ppsData length] };
|
||||
|
||||
NSLog(@"Constructing new format description");
|
||||
Log(LOG_I, @"Constructing new format description");
|
||||
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
|
||||
2, /* count of parameter sets */
|
||||
parameterSetPointers,
|
||||
@@ -177,7 +177,7 @@
|
||||
NAL_LENGTH_PREFIX_SIZE,
|
||||
&formatDesc);
|
||||
if (status != noErr) {
|
||||
NSLog(@"Failed to create format description: %d", (int)status);
|
||||
Log(LOG_E, @"Failed to create format description: %d", (int)status);
|
||||
formatDesc = NULL;
|
||||
}
|
||||
}
|
||||
@@ -206,7 +206,7 @@
|
||||
|
||||
status = CMBlockBufferCreateEmpty(NULL, 0, 0, &blockBuffer);
|
||||
if (status != noErr) {
|
||||
NSLog(@"CMBlockBufferCreateEmpty failed: %d", (int)status);
|
||||
Log(LOG_E, @"CMBlockBufferCreateEmpty failed: %d", (int)status);
|
||||
free(data);
|
||||
return DR_NEED_IDR;
|
||||
}
|
||||
@@ -241,7 +241,7 @@
|
||||
NULL, 0, NULL,
|
||||
&sampleBuffer);
|
||||
if (status != noErr) {
|
||||
NSLog(@"CMSampleBufferCreate failed: %d", (int)status);
|
||||
Log(LOG_E, @"CMSampleBufferCreate failed: %d", (int)status);
|
||||
CFRelease(blockBuffer);
|
||||
return DR_NEED_IDR;
|
||||
}
|
||||
|
||||
28
Limelight/Utility/Logger.h
Normal file
28
Limelight/Utility/Logger.h
Normal file
@@ -0,0 +1,28 @@
|
||||
//
|
||||
// Logger.h
|
||||
// Limelight
|
||||
//
|
||||
// Created by Diego Waxemberg on 2/10/15.
|
||||
// Copyright (c) 2015 Limelight Stream. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef Limelight_Logger_h
|
||||
#define Limelight_Logger_h
|
||||
|
||||
#import <stdarg.h>
|
||||
|
||||
typedef enum {
|
||||
LOG_D,
|
||||
LOG_I,
|
||||
LOG_W,
|
||||
LOG_E
|
||||
} LogLevel;
|
||||
|
||||
#define PRFX_DEBUG @"<DEBUG>"
|
||||
#define PRFX_INFO @"<INFO>"
|
||||
#define PRFX_WARN @"<WARN>"
|
||||
#define PRFX_ERROR @"<ERROR>"
|
||||
|
||||
void Log(LogLevel level, NSString* fmt, ...);
|
||||
|
||||
#endif
|
||||
35
Limelight/Utility/Logger.m
Normal file
35
Limelight/Utility/Logger.m
Normal file
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Logger.m
|
||||
// Limelight
|
||||
//
|
||||
// Created by Diego Waxemberg on 2/10/15.
|
||||
// Copyright (c) 2015 Limelight Stream. All rights reserved.
|
||||
//
|
||||
|
||||
#import "Logger.h"
|
||||
|
||||
void Log(LogLevel level, NSString* fmt, ...) {
|
||||
NSString* levelPrefix = @"";
|
||||
|
||||
switch(level) {
|
||||
case LOG_D:
|
||||
levelPrefix = PRFX_DEBUG;
|
||||
break;
|
||||
case LOG_I:
|
||||
levelPrefix = PRFX_INFO;
|
||||
break;
|
||||
case LOG_W:
|
||||
levelPrefix = PRFX_WARN;
|
||||
break;
|
||||
case LOG_E:
|
||||
levelPrefix = PRFX_ERROR;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
NSString* prefixedString = [NSString stringWithFormat:@"%@ %@", levelPrefix, fmt];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
NSLogv(prefixedString, args);
|
||||
va_end(args);
|
||||
}
|
||||
@@ -56,18 +56,18 @@ NSString *const deviceName = @"roth";
|
||||
if (inet_addr([host UTF8String]) != INADDR_NONE) {
|
||||
// Already an IP address
|
||||
int addr = inet_addr([host UTF8String]);
|
||||
NSLog(@"host address: %d", addr);
|
||||
Log(LOG_I, @"host address: %d", addr);
|
||||
return addr;
|
||||
} else {
|
||||
hostent = gethostbyname([host UTF8String]);
|
||||
if (hostent != NULL) {
|
||||
char* ipstr = inet_ntoa(*(struct in_addr*)hostent->h_addr_list[0]);
|
||||
NSLog(@"Resolved %@ -> %s", host, ipstr);
|
||||
Log(LOG_I, @"Resolved %@ -> %s", host, ipstr);
|
||||
int addr = inet_addr(ipstr);
|
||||
NSLog(@"host address: %d", addr);
|
||||
Log(LOG_I, @"host address: %d", addr);
|
||||
return addr;
|
||||
} else {
|
||||
NSLog(@"Failed to resolve host: %d", h_errno);
|
||||
Log(LOG_W, @"Failed to resolve host: %d", h_errno);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,11 +74,11 @@ static NSArray* appList;
|
||||
AppListResponse* appListResp = [[AppListResponse alloc] init];
|
||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appListResp withUrlRequest:[hMan newAppListRequest]]];
|
||||
if (appListResp == nil || ![appListResp isStatusOk]) {
|
||||
NSLog(@"Failed to get applist: %@", appListResp.statusMessage);
|
||||
Log(LOG_W, @"Failed to get applist: %@", appListResp.statusMessage);
|
||||
} else {
|
||||
appList = [appListResp getAppList];
|
||||
if (appList == nil) {
|
||||
NSLog(@"Failed to parse applist");
|
||||
Log(LOG_W, @"Failed to parse applist");
|
||||
} else {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self updateApps];
|
||||
@@ -112,21 +112,21 @@ static NSArray* appList;
|
||||
}
|
||||
|
||||
- (void) hostClicked:(Host *)host {
|
||||
NSLog(@"Clicked host: %@", host.name);
|
||||
Log(LOG_D, @"Clicked host: %@", host.name);
|
||||
_selectedHost = host;
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:host.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
|
||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResp withUrlRequest:[hMan newServerInfoRequest]]];
|
||||
if (serverInfoResp == nil || ![serverInfoResp isStatusOk]) {
|
||||
NSLog(@"Failed to get server info: %@", serverInfoResp.statusMessage);
|
||||
Log(LOG_W, @"Failed to get server info: %@", serverInfoResp.statusMessage);
|
||||
} else {
|
||||
NSLog(@"server info pair status: %@", [serverInfoResp getStringTag:@"PairStatus"]);
|
||||
Log(LOG_D, @"server info pair status: %@", [serverInfoResp getStringTag:@"PairStatus"]);
|
||||
if ([[serverInfoResp getStringTag:@"PairStatus"] isEqualToString:@"1"]) {
|
||||
NSLog(@"Already Paired");
|
||||
Log(LOG_I, @"Already Paired");
|
||||
[self alreadyPaired];
|
||||
} else {
|
||||
NSLog(@"Trying to pair");
|
||||
Log(LOG_I, @"Trying to pair");
|
||||
// Polling the server while pairing causes the server to screw up
|
||||
[_discMan stopDiscoveryBlocking];
|
||||
PairManager* pMan = [[PairManager alloc] initWithManager:hMan andCert:_cert callback:self];
|
||||
@@ -137,7 +137,7 @@ static NSArray* appList;
|
||||
}
|
||||
|
||||
- (void)hostLongClicked:(Host *)host view:(UIView *)view {
|
||||
NSLog(@"Long clicked host: %@", host.name);
|
||||
Log(LOG_D, @"Long clicked host: %@", host.name);
|
||||
UIAlertController* longClickAlert = [UIAlertController alertControllerWithTitle:host.name message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
|
||||
if (host.online) {
|
||||
[longClickAlert addAction:[UIAlertAction actionWithTitle:@"Unpair" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||
@@ -185,7 +185,7 @@ static NSArray* appList;
|
||||
}
|
||||
|
||||
- (void) addHostClicked {
|
||||
NSLog(@"Clicked add host");
|
||||
Log(LOG_D, @"Clicked add host");
|
||||
UIAlertController* alertController = [UIAlertController alertControllerWithTitle:@"Host Address" message:@"Please enter a hostname or IP address" preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]];
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||
@@ -215,7 +215,7 @@ static NSArray* appList;
|
||||
}
|
||||
|
||||
- (void) appClicked:(App *)app {
|
||||
NSLog(@"Clicked app: %@", app.appName);
|
||||
Log(LOG_D, @"Clicked app: %@", app.appName);
|
||||
_streamConfig = [[StreamConfiguration alloc] init];
|
||||
_streamConfig.host = _selectedHost.address;
|
||||
_streamConfig.hostAddr = [Utils resolveHost:_selectedHost.address];
|
||||
@@ -245,12 +245,12 @@ static NSArray* appList;
|
||||
message: [app.appId isEqualToString:currentApp.appId] ? @"" : [NSString stringWithFormat:@"%@ is currently running", currentApp.appName]preferredStyle:UIAlertControllerStyleAlert];
|
||||
[alertController addAction:[UIAlertAction
|
||||
actionWithTitle:[app.appId isEqualToString:currentApp.appId] ? @"Resume App" : @"Resume Running App" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){
|
||||
NSLog(@"Resuming application: %@", currentApp.appName);
|
||||
Log(LOG_I, @"Resuming application: %@", currentApp.appName);
|
||||
[self performSegueWithIdentifier:@"createStreamFrame" sender:nil];
|
||||
}]];
|
||||
[alertController addAction:[UIAlertAction actionWithTitle:
|
||||
[app.appId isEqualToString:currentApp.appId] ? @"Quit App" : @"Quit Running App and Start" style:UIAlertActionStyleDestructive handler:^(UIAlertAction* action){
|
||||
NSLog(@"Quitting application: %@", currentApp.appName);
|
||||
Log(LOG_I, @"Quitting application: %@", currentApp.appName);
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||
[hMan executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[hMan newQuitAppRequest]]];
|
||||
@@ -380,9 +380,9 @@ static NSArray* appList;
|
||||
|
||||
- (void) updateAllHosts:(NSArray *)hosts {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSLog(@"New host list:");
|
||||
Log(LOG_D, @"New host list:");
|
||||
for (Host* host in hosts) {
|
||||
NSLog(@"Host: \n{\n\t name:%@ \n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", host.name, host.address, host.localAddress, host.externalAddress, host.uuid, host.mac, host.pairState, host.online);
|
||||
Log(LOG_D, @"Host: \n{\n\t name:%@ \n\t address:%@ \n\t localAddress:%@ \n\t externalAddress:%@ \n\t uuid:%@ \n\t mac:%@ \n\t pairState:%d \n\t online:%d \n}", host.name, host.address, host.localAddress, host.externalAddress, host.uuid, host.mac, host.pairState, host.online);
|
||||
}
|
||||
@synchronized(hostList) {
|
||||
[hostList removeAllObjects];
|
||||
@@ -393,7 +393,7 @@ static NSArray* appList;
|
||||
}
|
||||
|
||||
- (void)updateHosts {
|
||||
NSLog(@"Updating hosts...");
|
||||
Log(LOG_I, @"Updating hosts...");
|
||||
[[hostScrollView subviews] makeObjectsPerformSelector:@selector(removeFromSuperview)];
|
||||
UIComputerView* addComp = [[UIComputerView alloc] initForAddWithCallback:self];
|
||||
UIComputerView* compView;
|
||||
|
||||
@@ -1140,7 +1140,7 @@ const int FrontViewPositionNone = 0xff;
|
||||
// forbid gesture if the initial translation is not horizontal
|
||||
UIView *recognizerView = _panGestureRecognizer.view;
|
||||
CGPoint translation = [_panGestureRecognizer translationInView:recognizerView];
|
||||
// NSLog( @"translation:%@", NSStringFromCGPoint(translation) );
|
||||
// Log(LOG_D, @"translation:%@", NSStringFromCGPoint(translation) );
|
||||
// if ( fabs(translation.y/translation.x) > 1 )
|
||||
// return NO;
|
||||
|
||||
@@ -1252,7 +1252,7 @@ const int FrontViewPositionNone = 0xff;
|
||||
|
||||
CGFloat xLocation = frontView.frame.origin.x;
|
||||
CGFloat velocity = [recognizer velocityInView:_contentView].x;
|
||||
//NSLog( @"Velocity:%1.4f", velocity);
|
||||
//Log(LOG_D, @"Velocity:%1.4f", velocity);
|
||||
|
||||
// depending on position we compute a simetric replacement of widths and positions
|
||||
int symetry = xLocation<0 ? -1 : 1;
|
||||
|
||||
@@ -59,13 +59,13 @@
|
||||
}
|
||||
|
||||
- (void)edgeSwiped {
|
||||
NSLog(@"User swiped to end stream");
|
||||
Log(LOG_D, @"User swiped to end stream");
|
||||
[_streamMan stopStream];
|
||||
[self returnToMainFrame];
|
||||
}
|
||||
|
||||
- (void) connectionStarted {
|
||||
NSLog(@"Connection started");
|
||||
Log(LOG_I, @"Connection started");
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[self.spinner stopAnimating];
|
||||
[self.stageLabel setText:@"Waiting for first frame..."];
|
||||
@@ -74,7 +74,7 @@
|
||||
UIScreenEdgePanGestureRecognizer* swipeGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(edgeSwiped)];
|
||||
swipeGesture.edges = UIRectEdgeLeft;
|
||||
if (swipeGesture == nil) {
|
||||
NSLog(@"An error occured trying to create UIScreenEdgePanGestureRecognizer");
|
||||
Log(LOG_E, @"An error occured trying to create UIScreenEdgePanGestureRecognizer");
|
||||
} else {
|
||||
[self.view addGestureRecognizer:swipeGesture];
|
||||
}
|
||||
@@ -82,7 +82,7 @@
|
||||
}
|
||||
|
||||
- (void)connectionTerminated:(long)errorCode {
|
||||
NSLog(@"Connection terminated: %ld", errorCode);
|
||||
Log(LOG_I, @"Connection terminated: %ld", errorCode);
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
UIAlertController* conTermAlert = [UIAlertController alertControllerWithTitle:@"Connection Terminated" message:@"The connection was terminated" preferredStyle:UIAlertControllerStyleAlert];
|
||||
@@ -96,7 +96,7 @@
|
||||
}
|
||||
|
||||
- (void) stageStarting:(char*)stageName {
|
||||
NSLog(@"Starting %s", stageName);
|
||||
Log(LOG_I, @"Starting %s", stageName);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSString* lowerCase = [NSString stringWithFormat:@"%s in progress...", stageName];
|
||||
NSString* titleCase = [[[lowerCase substringToIndex:1] uppercaseString] stringByAppendingString:[lowerCase substringFromIndex:1]];
|
||||
@@ -131,11 +131,11 @@
|
||||
}
|
||||
|
||||
- (void) displayMessage:(char*)message {
|
||||
NSLog(@"Display message: %s", message);
|
||||
Log(LOG_I, @"Display message: %s", message);
|
||||
}
|
||||
|
||||
- (void) displayTransientMessage:(char*)message {
|
||||
NSLog(@"Display transient message: %s", message);
|
||||
Log(LOG_I, @"Display transient message: %s", message);
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
||||
Reference in New Issue
Block a user