diff --git a/Limelight/Database/App.m b/Limelight/Database/App.m index d1e28d40..2ada9a82 100644 --- a/Limelight/Database/App.m +++ b/Limelight/Database/App.m @@ -7,7 +7,6 @@ // #import "App.h" -#import "Host.h" @implementation App diff --git a/Limelight/Database/TemporaryApp.h b/Limelight/Database/TemporaryApp.h index 8a3e223e..b49b3cc9 100644 --- a/Limelight/Database/TemporaryApp.h +++ b/Limelight/Database/TemporaryApp.h @@ -7,7 +7,7 @@ // #import -#import "Host.h" +#import "TemporaryHost.h" @interface TemporaryApp : NSObject @@ -15,6 +15,6 @@ @property (nullable, nonatomic, retain) NSData *image; @property (nullable, nonatomic, retain) NSString *name; @property (nonatomic) BOOL isRunning; -@property (nullable, nonatomic, retain) Host *host; +@property (nullable, nonatomic, retain) TemporaryHost *host; @end diff --git a/Limelight/Database/TemporaryHost.h b/Limelight/Database/TemporaryHost.h new file mode 100644 index 00000000..7707edd5 --- /dev/null +++ b/Limelight/Database/TemporaryHost.h @@ -0,0 +1,26 @@ +// +// TemporaryHost.h +// Moonlight +// +// Created by Cameron Gutman on 12/1/15. +// Copyright © 2015 Moonlight Stream. All rights reserved. +// + +#import +#import "Utils.h" + +@interface TemporaryHost : NSObject + +@property (nonatomic) BOOL online; +@property (nonatomic) PairState pairState; +@property (nonatomic, nullable) NSString * activeAddress; + +@property (nullable, nonatomic, retain) NSString *address; +@property (nullable, nonatomic, retain) NSString *externalAddress; +@property (nullable, nonatomic, retain) NSString *localAddress; +@property (nullable, nonatomic, retain) NSString *mac; +@property (nullable, nonatomic, retain) NSString *name; +@property (nullable, nonatomic, retain) NSString *uuid; +@property (nullable, nonatomic, retain) NSSet *appList; + +@end diff --git a/Limelight/Database/TemporaryHost.m b/Limelight/Database/TemporaryHost.m new file mode 100644 index 00000000..4f66b52b --- /dev/null +++ b/Limelight/Database/TemporaryHost.m @@ -0,0 +1,13 @@ +// +// TemporaryHost.m +// Moonlight +// +// Created by Cameron Gutman on 12/1/15. +// Copyright © 2015 Moonlight Stream. All rights reserved. +// + +#import "TemporaryHost.h" + +@implementation TemporaryHost + +@end diff --git a/Limelight/Network/AppAssetManager.h b/Limelight/Network/AppAssetManager.h index 95f3a4be..42f7720c 100644 --- a/Limelight/Network/AppAssetManager.h +++ b/Limelight/Network/AppAssetManager.h @@ -7,20 +7,20 @@ // #import -#import "App.h" +#import "TemporaryApp.h" #import "HttpManager.h" -#import "Host.h" +#import "TemporaryHost.h" @protocol AppAssetCallback -- (void) receivedAssetForApp:(App*)app; +- (void) receivedAssetForApp:(TemporaryApp*)app; @end @interface AppAssetManager : NSObject - (id) initWithCallback:(id)callback; -- (void) retrieveAssetsFromHost:(Host*)host; +- (void) retrieveAssetsFromHost:(TemporaryHost*)host; - (void) stopRetrieving; @end diff --git a/Limelight/Network/AppAssetManager.m b/Limelight/Network/AppAssetManager.m index 6aaad796..f8a8f5df 100644 --- a/Limelight/Network/AppAssetManager.m +++ b/Limelight/Network/AppAssetManager.m @@ -28,8 +28,8 @@ static const int MAX_REQUEST_COUNT = 4; return self; } -- (void) retrieveAssetsFromHost:(Host*)host { - for (App* app in host.appList) { +- (void) retrieveAssetsFromHost:(TemporaryHost*)host { + for (TemporaryApp* app in host.appList) { if (app.image == nil) { AppAssetRetriever* retriever = [[AppAssetRetriever alloc] init]; retriever.app = app; @@ -45,7 +45,7 @@ static const int MAX_REQUEST_COUNT = 4; [_opQueue cancelAllOperations]; } -- (void) sendCallBackForApp:(App*)app { +- (void) sendCallBackForApp:(TemporaryApp*)app { [_callback receivedAssetForApp:app]; } diff --git a/Limelight/Network/AppAssetRetriever.h b/Limelight/Network/AppAssetRetriever.h index 9588f6de..b897a0f8 100644 --- a/Limelight/Network/AppAssetRetriever.h +++ b/Limelight/Network/AppAssetRetriever.h @@ -7,14 +7,14 @@ // #import -#import "Host.h" -#import "App.h" +#import "TemporaryHost.h" +#import "TemporaryApp.h" #import "AppAssetManager.h" @interface AppAssetRetriever : NSOperation -@property (nonatomic) Host* host; -@property (nonatomic) App* app; +@property (nonatomic) TemporaryHost* host; +@property (nonatomic) TemporaryApp* app; @property (nonatomic) id callback; @end diff --git a/Limelight/Network/AppAssetRetriever.m b/Limelight/Network/AppAssetRetriever.m index 07cd1a09..824b423e 100644 --- a/Limelight/Network/AppAssetRetriever.m +++ b/Limelight/Network/AppAssetRetriever.m @@ -36,7 +36,7 @@ static const int MAX_ATTEMPTS = 5; [self performSelectorOnMainThread:@selector(sendCallbackForApp:) withObject:self.app waitUntilDone:NO]; } -- (void) sendCallbackForApp:(App*)app { +- (void) sendCallbackForApp:(TemporaryApp*)app { [self.callback receivedAssetForApp:app]; } diff --git a/Limelight/Network/DiscoveryManager.h b/Limelight/Network/DiscoveryManager.h index 354b3bfe..7d5dfcc6 100644 --- a/Limelight/Network/DiscoveryManager.h +++ b/Limelight/Network/DiscoveryManager.h @@ -8,7 +8,7 @@ #import #import "MDNSManager.h" -#import "Host.h" +#import "TemporaryHost.h" @protocol DiscoveryCallback @@ -22,8 +22,8 @@ - (void) startDiscovery; - (void) stopDiscovery; - (void) stopDiscoveryBlocking; -- (BOOL) addHostToDiscovery:(Host*)host; -- (void) removeHostFromDiscovery:(Host*)host; -- (void) discoverHost:(NSString*)hostAddress withCallback:(void (^)(Host*, NSString*))callback; +- (BOOL) addHostToDiscovery:(TemporaryHost*)host; +- (void) removeHostFromDiscovery:(TemporaryHost*)host; +- (void) discoverHost:(NSString*)hostAddress withCallback:(void (^)(TemporaryHost*, NSString*))callback; @end diff --git a/Limelight/Network/DiscoveryManager.m b/Limelight/Network/DiscoveryManager.m index 0e756a67..45041d5d 100644 --- a/Limelight/Network/DiscoveryManager.m +++ b/Limelight/Network/DiscoveryManager.m @@ -17,7 +17,6 @@ @implementation DiscoveryManager { NSMutableArray* _hostQueue; - NSMutableArray* _discoveredHosts; id _callback; MDNSManager* _mdnsMan; NSOperationQueue* _opQueue; @@ -35,7 +34,7 @@ shouldDiscover = NO; _hostQueue = [NSMutableArray array]; DataManager* dataMan = [[DataManager alloc] init]; - for (Host* host in hosts) + for (TemporaryHost* host in hosts) { if (![self addHostToDiscovery:host]) { @@ -54,12 +53,12 @@ return self; } -- (void) discoverHost:(NSString *)hostAddress withCallback:(void (^)(Host *, NSString*))callback { +- (void) discoverHost:(NSString *)hostAddress withCallback:(void (^)(TemporaryHost *, NSString*))callback { HttpManager* hMan = [[HttpManager alloc] initWithHost:hostAddress uniqueId:_uniqueId deviceName:deviceName cert:_cert]; ServerInfoResponse* serverInfoResponse = [[ServerInfoResponse alloc] init]; [hMan executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResponse withUrlRequest:[hMan newServerInfoRequest] fallbackError:401 fallbackRequest:[hMan newHttpServerInfoRequest]]]; - Host* host = nil; + TemporaryHost* host = nil; if ([serverInfoResponse isStatusOk]) { DataManager* dataMan = [[DataManager alloc] init]; host = [dataMan createHost]; @@ -82,7 +81,7 @@ Log(LOG_I, @"Starting discovery"); shouldDiscover = YES; [_mdnsMan searchForHosts]; - for (Host* host in _hostQueue) { + for (TemporaryHost* host in _hostQueue) { [_opQueue addOperation:[self createWorkerForHost:host]]; } } @@ -103,7 +102,7 @@ Log(LOG_I, @"All discovery workers stopped"); } -- (BOOL) addHostToDiscovery:(Host *)host { +- (BOOL) addHostToDiscovery:(TemporaryHost *)host { if (host.uuid.length > 0 && ![self isHostInDiscovery:host]) { [_hostQueue addObject:host]; if (shouldDiscover) { @@ -114,7 +113,7 @@ return NO; } -- (void) removeHostFromDiscovery:(Host *)host { +- (void) removeHostFromDiscovery:(TemporaryHost *)host { for (DiscoveryWorker* worker in [_opQueue operations]) { if ([worker getHost] == host) { [worker cancel]; @@ -128,7 +127,7 @@ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ DataManager* dataMan = [[DataManager alloc] init]; // Discover the hosts before adding to eliminate duplicates - for (Host* host in hosts) { + for (TemporaryHost* host in hosts) { 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]; @@ -145,9 +144,9 @@ }); } -- (BOOL) isHostInDiscovery:(Host*)host { +- (BOOL) isHostInDiscovery:(TemporaryHost*)host { for (int i = 0; i < _hostQueue.count; i++) { - Host* discoveredHost = [_hostQueue objectAtIndex:i]; + TemporaryHost* discoveredHost = [_hostQueue objectAtIndex:i]; if (discoveredHost.uuid.length > 0 && [discoveredHost.uuid isEqualToString:host.uuid]) { return YES; } @@ -155,7 +154,7 @@ return NO; } -- (NSOperation*) createWorkerForHost:(Host*)host { +- (NSOperation*) createWorkerForHost:(TemporaryHost*)host { DiscoveryWorker* worker = [[DiscoveryWorker alloc] initWithHost:host uniqueId:_uniqueId cert:_cert]; return worker; } diff --git a/Limelight/Network/DiscoveryWorker.h b/Limelight/Network/DiscoveryWorker.h index 41928d69..c8d2a6cf 100644 --- a/Limelight/Network/DiscoveryWorker.h +++ b/Limelight/Network/DiscoveryWorker.h @@ -7,12 +7,12 @@ // #import -#import "Host.h" +#import "TemporaryHost.h" @interface DiscoveryWorker : NSOperation -- (id) initWithHost:(Host*)host uniqueId:(NSString*)uniqueId cert:(NSData*)cert; +- (id) initWithHost:(TemporaryHost*)host uniqueId:(NSString*)uniqueId cert:(NSData*)cert; - (void) discoverHost; -- (Host*) getHost; +- (TemporaryHost*) getHost; @end diff --git a/Limelight/Network/DiscoveryWorker.m b/Limelight/Network/DiscoveryWorker.m index d86d58af..9f487617 100644 --- a/Limelight/Network/DiscoveryWorker.m +++ b/Limelight/Network/DiscoveryWorker.m @@ -13,14 +13,14 @@ #import "HttpRequest.h" @implementation DiscoveryWorker { - Host* _host; + TemporaryHost* _host; NSString* _uniqueId; NSData* _cert; } static const float POLL_RATE = 2.0f; // Poll every 2 seconds -- (id) initWithHost:(Host*)host uniqueId:(NSString*)uniqueId cert:(NSData*)cert { +- (id) initWithHost:(TemporaryHost*)host uniqueId:(NSString*)uniqueId cert:(NSData*)cert { self = [super init]; _host = host; _uniqueId = uniqueId; @@ -28,7 +28,7 @@ static const float POLL_RATE = 2.0f; // Poll every 2 seconds return self; } -- (Host*) getHost { +- (TemporaryHost*) getHost { return _host; } diff --git a/Limelight/Network/HttpManager.h b/Limelight/Network/HttpManager.h index d72a6182..97caaaaa 100644 --- a/Limelight/Network/HttpManager.h +++ b/Limelight/Network/HttpManager.h @@ -7,7 +7,6 @@ // #import -#import "Host.h" #import "HttpResponse.h" #import "HttpRequest.h" diff --git a/Limelight/Network/HttpManager.m b/Limelight/Network/HttpManager.m index c957e36a..6bef638b 100644 --- a/Limelight/Network/HttpManager.m +++ b/Limelight/Network/HttpManager.m @@ -9,7 +9,7 @@ #import "HttpManager.h" #import "HttpRequest.h" #import "CryptoManager.h" -#import "App.h" +#import "TemporaryApp.h" #include #include diff --git a/Limelight/Network/HttpResponse.h b/Limelight/Network/HttpResponse.h index d4bbf7dd..28d2636a 100644 --- a/Limelight/Network/HttpResponse.h +++ b/Limelight/Network/HttpResponse.h @@ -7,7 +7,6 @@ // #import -#import "Host.h" static NSString* TAG_STATUS_CODE = @"status_code"; static NSString* TAG_STATUS_MESSAGE = @"status_message"; diff --git a/Limelight/Network/HttpResponse.m b/Limelight/Network/HttpResponse.m index ad5c7d4d..312825b8 100644 --- a/Limelight/Network/HttpResponse.m +++ b/Limelight/Network/HttpResponse.m @@ -7,7 +7,7 @@ // #import "HttpResponse.h" -#import "App.h" +#import "TemporaryApp.h" #import @implementation HttpResponse { diff --git a/Limelight/Network/MDNSManager.m b/Limelight/Network/MDNSManager.m index 3f6681ec..dfd521a6 100644 --- a/Limelight/Network/MDNSManager.m +++ b/Limelight/Network/MDNSManager.m @@ -7,7 +7,7 @@ // #import "MDNSManager.h" -#import "Host.h" +#import "TemporaryHost.h" #import "DataManager.h" @implementation MDNSManager { @@ -50,7 +50,7 @@ static NSString* NV_SERVICE_TYPE = @"_nvstream._tcp"; DataManager* dataMan = [[DataManager alloc] init]; for (NSNetService* service in services) { if (service.hostName != nil) { - Host* host = [dataMan createHost]; + TemporaryHost* host = [dataMan createHost]; host.activeAddress = host.address = service.hostName; host.name = host.address; [hosts addObject:host]; diff --git a/Limelight/Network/ServerInfoResponse.h b/Limelight/Network/ServerInfoResponse.h index 39e212af..445addbf 100644 --- a/Limelight/Network/ServerInfoResponse.h +++ b/Limelight/Network/ServerInfoResponse.h @@ -7,6 +7,7 @@ // #import "HttpResponse.h" +#import "TemporaryHost.h" #define TAG_HOSTNAME @"hostname" #define TAG_EXTERNAL_IP @"ExternalIP" @@ -18,7 +19,7 @@ @interface ServerInfoResponse : HttpResponse - (void) populateWithData:(NSData *)data; -- (void) populateHost:(Host*)host; +- (void) populateHost:(TemporaryHost*)host; @end diff --git a/Limelight/Network/ServerInfoResponse.m b/Limelight/Network/ServerInfoResponse.m index 2ba8249c..a69e3317 100644 --- a/Limelight/Network/ServerInfoResponse.m +++ b/Limelight/Network/ServerInfoResponse.m @@ -17,7 +17,7 @@ [super parseData]; } -- (void) populateHost:(Host*)host { +- (void) populateHost:(TemporaryHost*)host { host.name = [[self getStringTag:TAG_HOSTNAME] trim]; host.externalAddress = [[self getStringTag:TAG_EXTERNAL_IP] trim]; host.localAddress = [[self getStringTag:TAG_LOCAL_IP] trim]; diff --git a/Limelight/Network/WakeOnLanManager.h b/Limelight/Network/WakeOnLanManager.h index 232431ea..a3da81ec 100644 --- a/Limelight/Network/WakeOnLanManager.h +++ b/Limelight/Network/WakeOnLanManager.h @@ -7,10 +7,10 @@ // #import -#import "Host.h" +#import "TemporaryHost.h" @interface WakeOnLanManager : NSObject -+ (void) wakeHost:(Host*)host; ++ (void) wakeHost:(TemporaryHost*)host; @end diff --git a/Limelight/Network/WakeOnLanManager.m b/Limelight/Network/WakeOnLanManager.m index 8c445615..bf86722a 100644 --- a/Limelight/Network/WakeOnLanManager.m +++ b/Limelight/Network/WakeOnLanManager.m @@ -18,7 +18,7 @@ static const int numPorts = 5; static const int ports[numPorts] = {7, 9, 47998, 47999, 48000}; -+ (void) wakeHost:(Host*)host { ++ (void) wakeHost:(TemporaryHost*)host { NSData* wolPayload = [WakeOnLanManager createPayload:host]; CFDataRef dataPayload = CFDataCreate(kCFAllocatorDefault, [wolPayload bytes], [wolPayload length]); CFSocketRef wolSocket = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM, IPPROTO_UDP, 0, NULL, NULL); @@ -56,7 +56,7 @@ static const int ports[numPorts] = {7, 9, 47998, 47999, 48000}; CFRelease(dataPayload); } -+ (NSData*) createPayload:(Host*)host { ++ (NSData*) createPayload:(TemporaryHost*)host { NSMutableData* payload = [[NSMutableData alloc] initWithCapacity:102]; // 6 bytes of FF diff --git a/Limelight/UIAppView.h b/Limelight/UIAppView.h index ca6c5657..31108c3d 100644 --- a/Limelight/UIAppView.h +++ b/Limelight/UIAppView.h @@ -7,17 +7,17 @@ // #import -#import "App.h" +#import "TemporaryApp.h" @protocol AppCallback -- (void) appClicked:(App*) app; +- (void) appClicked:(TemporaryApp*) app; @end @interface UIAppView : UIView -- (id) initWithApp:(App*)app cache:(NSCache*)cache andCallback:(id)callback; +- (id) initWithApp:(TemporaryApp*)app cache:(NSCache*)cache andCallback:(id)callback; - (void) updateAppImage; @end diff --git a/Limelight/UIAppView.m b/Limelight/UIAppView.m index 89bcc7aa..aefb7c50 100644 --- a/Limelight/UIAppView.m +++ b/Limelight/UIAppView.m @@ -9,7 +9,7 @@ #import "UIAppView.h" @implementation UIAppView { - App* _app; + TemporaryApp* _app; UIButton* _appButton; UILabel* _appLabel; UIImageView* _appOverlay; @@ -19,7 +19,7 @@ static UIImage* noImage; -- (id) initWithApp:(App*)app cache:(NSCache*)cache andCallback:(id)callback { +- (id) initWithApp:(TemporaryApp*)app cache:(NSCache*)cache andCallback:(id)callback { self = [super init]; _app = app; _callback = callback; diff --git a/Limelight/UIComputerView.h b/Limelight/UIComputerView.h index 8fe81a25..7bbf698d 100644 --- a/Limelight/UIComputerView.h +++ b/Limelight/UIComputerView.h @@ -7,19 +7,19 @@ // #import -#import "Host.h" +#import "TemporaryHost.h" @protocol HostCallback -- (void) hostClicked:(Host*)host view:(UIView*)view; -- (void) hostLongClicked:(Host*)host view:(UIView*)view; +- (void) hostClicked:(TemporaryHost*)host view:(UIView*)view; +- (void) hostLongClicked:(TemporaryHost*)host view:(UIView*)view; - (void) addHostClicked; @end @interface UIComputerView : UIView -- (id) initWithComputer:(Host*)host andCallback:(id)callback; +- (id) initWithComputer:(TemporaryHost*)host andCallback:(id)callback; - (id) initForAddWithCallback:(id)callback; @end diff --git a/Limelight/UIComputerView.m b/Limelight/UIComputerView.m index 0c7384ef..364610cf 100644 --- a/Limelight/UIComputerView.m +++ b/Limelight/UIComputerView.m @@ -9,7 +9,7 @@ #import "UIComputerView.h" @implementation UIComputerView { - Host* _host; + TemporaryHost* _host; UIButton* _hostButton; UILabel* _hostLabel; UILabel* _hostStatus; @@ -72,7 +72,7 @@ static const int LABEL_DY = 20; return self; } -- (id) initWithComputer:(Host*)host andCallback:(id)callback { +- (id) initWithComputer:(TemporaryHost*)host andCallback:(id)callback { self = [self init]; _host = host; _callback = callback; @@ -123,7 +123,7 @@ static const int LABEL_DY = 20; self.frame = CGRectMake(x, y, width, height); } -- (void) updateContentsForHost:(Host*)host { +- (void) updateContentsForHost:(TemporaryHost*)host { _hostLabel.text = _host.name; _hostLabel.textColor = [UIColor whiteColor]; [_hostLabel sizeToFit]; diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index 3eb2cdcb..303a1be3 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -15,7 +15,6 @@ #import "Utils.h" #import "UIComputerView.h" #import "UIAppView.h" -#import "App.h" #import "SettingsViewController.h" #import "DataManager.h" #import "Settings.h" @@ -30,7 +29,7 @@ @implementation MainFrameViewController { NSOperationQueue* _opQueue; - Host* _selectedHost; + TemporaryHost* _selectedHost; NSString* _uniqueId; NSData* _cert; DiscoveryManager* _discMan; @@ -80,7 +79,7 @@ static NSMutableSet* hostList; // Capture the host here because it can change once we // leave the main thread - Host* host = _selectedHost; + TemporaryHost* host = _selectedHost; if ([host.appList count] > 0) { usingCachedAppList = true; @@ -159,11 +158,11 @@ static NSMutableSet* hostList; }); } -- (void) mergeAppLists:(NSArray*) newList forHost:(Host*)host { +- (void) mergeAppLists:(NSArray*) newList forHost:(TemporaryHost*)host { DataManager* database = [[DataManager alloc] init]; for (TemporaryApp* app in newList) { BOOL appAlreadyInList = NO; - for (App* savedApp in host.appList) { + for (TemporaryApp* savedApp in host.appList) { if ([app.id isEqualToString:savedApp.id]) { savedApp.name = app.name; savedApp.isRunning = app.isRunning; @@ -181,9 +180,9 @@ static NSMutableSet* hostList; do { appWasRemoved = NO; - for (App* app in host.appList) { + for (TemporaryApp* app in host.appList) { appWasRemoved = YES; - for (App* mergedApp in newList) { + for (TemporaryApp* mergedApp in newList) { if ([mergedApp.id isEqualToString:app.id]) { appWasRemoved = NO; break; @@ -212,7 +211,7 @@ static NSMutableSet* hostList; [self.view addSubview:hostScrollView]; } -- (void) receivedAssetForApp:(App*)app { +- (void) receivedAssetForApp:(TemporaryApp*)app { // Update the box art cache now so we don't have to do it // on the main thread [self updateBoxArtCacheForApp:app]; @@ -230,7 +229,7 @@ static NSMutableSet* hostList; [self presentViewController:alert animated:YES completion:nil]; } -- (void) hostClicked:(Host *)host view:(UIView *)view { +- (void) hostClicked:(TemporaryHost *)host view:(UIView *)view { // Treat clicks on offline hosts to be long clicks // This shows the context menu with wake, delete, etc. rather // than just hanging for a while and failing as we would in this @@ -296,7 +295,7 @@ static NSMutableSet* hostList; }); } -- (void)hostLongClicked:(Host *)host view:(UIView *)view { +- (void)hostLongClicked:(TemporaryHost *)host view:(UIView *)view { Log(LOG_D, @"Long clicked host: %@", host.name); UIAlertController* longClickAlert = [UIAlertController alertControllerWithTitle:host.name message:@"" preferredStyle:UIAlertControllerStyleActionSheet]; if (!host.online) { @@ -322,8 +321,8 @@ static NSMutableSet* hostList; [dataMan removeHost:host]; @synchronized(hostList) { [hostList removeObject:host]; + [self updateAllHosts:[hostList allObjects]]; } - [self updateAllHosts:[hostList allObjects]]; }]]; [longClickAlert addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]]; @@ -345,7 +344,7 @@ static NSMutableSet* hostList; [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){ NSString* hostAddress = ((UITextField*)[[alertController textFields] objectAtIndex:0]).text; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{ - [_discMan discoverHost:hostAddress withCallback:^(Host* host, NSString* error){ + [_discMan discoverHost:hostAddress withCallback:^(TemporaryHost* host, NSString* error){ if (host != nil) { DataManager* dataMan = [[DataManager alloc] init]; [dataMan saveData]; @@ -369,7 +368,7 @@ static NSMutableSet* hostList; [self presentViewController:alertController animated:YES completion:nil]; } -- (void) appClicked:(App *)app { +- (void) appClicked:(TemporaryApp *)app { Log(LOG_D, @"Clicked app: %@", app.name); _streamConfig = [[StreamConfiguration alloc] init]; _streamConfig.host = app.host.activeAddress; @@ -389,7 +388,7 @@ static NSMutableSet* hostList; [[self revealViewController] revealToggle:self]; } - App* currentApp = [self findRunningApp:app.host]; + TemporaryApp* currentApp = [self findRunningApp:app.host]; if (currentApp != nil) { UIAlertController* alertController = [UIAlertController alertControllerWithTitle: app.name @@ -455,8 +454,8 @@ static NSMutableSet* hostList; } } -- (App*) findRunningApp:(Host*)host { - for (App* app in host.appList) { +- (TemporaryApp*) findRunningApp:(TemporaryHost*)host { + for (TemporaryApp* app in host.appList) { if (app.isRunning) { return app; } @@ -605,7 +604,7 @@ static NSMutableSet* hostList; [hostList addObjectsFromArray:hosts]; // Initialize the non-persistent host state - for (Host* host in hostList) { + for (TemporaryHost* host in hostList) { if (host.activeAddress == nil) { host.activeAddress = host.localAddress; } @@ -622,7 +621,7 @@ static NSMutableSet* hostList; - (void) updateAllHosts:(NSArray *)hosts { dispatch_async(dispatch_get_main_queue(), ^{ Log(LOG_D, @"New host list:"); - for (Host* host in hosts) { + for (TemporaryHost* host in hosts) { 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\t activeAddress:%@ \n}", host.name, host.address, host.localAddress, host.externalAddress, host.uuid, host.mac, host.pairState, host.online, host.activeAddress); } @synchronized(hostList) { @@ -642,7 +641,7 @@ static NSMutableSet* hostList; @synchronized (hostList) { // Sort the host list in alphabetical order NSArray* sortedHostList = [[hostList allObjects] sortedArrayUsingSelector:@selector(compareName:)]; - for (Host* comp in sortedHostList) { + for (TemporaryHost* comp in sortedHostList) { compView = [[UIComputerView alloc] initWithComputer:comp andCallback:self]; compView.center = CGPointMake([self getCompViewX:compView addComp:addComp prevEdge:prevEdge], hostScrollView.frame.size.height / 2); prevEdge = compView.frame.origin.x + compView.frame.size.width; @@ -667,7 +666,7 @@ static NSMutableSet* hostList; // This function forces immediate decoding of the UIImage, rather // than the default lazy decoding that results in janky scrolling. -+ (UIImage*) loadBoxArtForCaching:(App*)app { ++ (UIImage*) loadBoxArtForCaching:(TemporaryApp*)app { CGImageSourceRef source = CGImageSourceCreateWithData((__bridge CFDataRef)app.image, NULL); CGImageRef cgImage = CGImageSourceCreateImageAtIndex(source, 0, (__bridge CFDictionaryRef)@{(id)kCGImageSourceShouldCacheImmediately: (id)kCFBooleanTrue}); @@ -680,7 +679,7 @@ static NSMutableSet* hostList; return boxArt; } -- (void) updateBoxArtCacheForApp:(App*)app { +- (void) updateBoxArtCacheForApp:(TemporaryApp*)app { if (app.image == nil) { [_boxArtCache removeObjectForKey:app]; } @@ -689,7 +688,7 @@ static NSMutableSet* hostList; } } -- (void) updateAppsForHost:(Host*)host { +- (void) updateAppsForHost:(TemporaryHost*)host { if (host != _selectedHost) { Log(LOG_W, @"Mismatched host during app update"); return; @@ -715,12 +714,12 @@ static NSMutableSet* hostList; // Start 2 jobs dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - for (App* app in firstHalf) { + for (TemporaryApp* app in firstHalf) { [self updateBoxArtCacheForApp:app]; } }); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - for (App* app in secondHalf) { + for (TemporaryApp* app in secondHalf) { [self updateBoxArtCacheForApp:app]; } }); @@ -732,7 +731,7 @@ static NSMutableSet* hostList; - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath { UICollectionViewCell* cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"AppCell" forIndexPath:indexPath]; - App* app = _sortedAppList[indexPath.row]; + TemporaryApp* app = _sortedAppList[indexPath.row]; UIAppView* appView = [[UIAppView alloc] initWithApp:app cache:_boxArtCache andCallback:self]; [appView updateAppImage]; diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index 360ba77c..11e40199 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -9,6 +9,7 @@ /* Begin PBXBuildFile section */ 9832D1361BBCD5C50036EF48 /* TemporaryApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 9832D1351BBCD5C50036EF48 /* TemporaryApp.m */; }; 987140041B04542F00AB57D5 /* libmoonlight-common.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FB1E43101AE8B0F200AFF679 /* libmoonlight-common.a */; }; + 98D5856D1C0EA79600F6CC00 /* TemporaryHost.m in Sources */ = {isa = PBXBuildFile; fileRef = 98D5856C1C0EA79600F6CC00 /* TemporaryHost.m */; }; 9E5D600B1A5A5A3900689918 /* Apache License.txt in Resources */ = {isa = PBXBuildFile; fileRef = 9E5D5FF81A5A5A3900689918 /* Apache License.txt */; }; 9E5D600C1A5A5A3900689918 /* Roboto-Black.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9E5D5FF91A5A5A3900689918 /* Roboto-Black.ttf */; }; 9E5D600E1A5A5A3900689918 /* Roboto-Bold.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9E5D5FFB1A5A5A3900689918 /* Roboto-Bold.ttf */; }; @@ -98,6 +99,8 @@ 9832D1341BBCD5C50036EF48 /* TemporaryApp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TemporaryApp.h; path = Database/TemporaryApp.h; sourceTree = ""; }; 9832D1351BBCD5C50036EF48 /* TemporaryApp.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TemporaryApp.m; path = Database/TemporaryApp.m; sourceTree = ""; }; 98A03B4519F3514B00861ACA /* moonlight-common.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = "moonlight-common.xcodeproj"; path = "limelight-common-c/moonlight-common.xcodeproj"; sourceTree = ""; }; + 98D5856B1C0EA79600F6CC00 /* TemporaryHost.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TemporaryHost.h; path = Database/TemporaryHost.h; sourceTree = ""; }; + 98D5856C1C0EA79600F6CC00 /* TemporaryHost.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TemporaryHost.m; path = Database/TemporaryHost.m; sourceTree = ""; }; 9E5D5FF81A5A5A3900689918 /* Apache License.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "Apache License.txt"; sourceTree = ""; }; 9E5D5FF91A5A5A3900689918 /* Roboto-Black.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Black.ttf"; sourceTree = ""; }; 9E5D5FFB1A5A5A3900689918 /* Roboto-Bold.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Roboto-Bold.ttf"; sourceTree = ""; }; @@ -733,6 +736,8 @@ FBD349611A0089F6002D2A60 /* DataManager.m */, 9832D1341BBCD5C50036EF48 /* TemporaryApp.h */, 9832D1351BBCD5C50036EF48 /* TemporaryApp.m */, + 98D5856B1C0EA79600F6CC00 /* TemporaryHost.h */, + 98D5856C1C0EA79600F6CC00 /* TemporaryHost.m */, ); name = Database; sourceTree = ""; @@ -855,6 +860,7 @@ FB89462D19F646E200339C8A /* MDNSManager.m in Sources */, FB89462B19F646E200339C8A /* StreamView.m in Sources */, FB4678FA1A55FFAD00377732 /* DiscoveryManager.m in Sources */, + 98D5856D1C0EA79600F6CC00 /* TemporaryHost.m in Sources */, FB89463519F646E200339C8A /* MainFrameViewController.m in Sources */, FBD1C8E21A8AD71400C6703C /* Logger.m in Sources */, FB1D599A1BBCCD7E00F482CA /* AppCollectionView.m in Sources */,