mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-17 06:01:12 +00:00
Add applist and server info fetching error dialogs. Open the options menu when a user taps an offline PC.
This commit is contained in:
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
@protocol HostCallback <NSObject>
|
@protocol HostCallback <NSObject>
|
||||||
|
|
||||||
- (void) hostClicked:(Host*)host;
|
- (void) hostClicked:(Host*)host view:(UIView*)view;
|
||||||
- (void) hostLongClicked:(Host*)host view:(UIView*)view;
|
- (void) hostLongClicked:(Host*)host view:(UIView*)view;
|
||||||
- (void) addHostClicked;
|
- (void) addHostClicked;
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ static const int LABEL_DY = 20;
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (void) hostClicked {
|
- (void) hostClicked {
|
||||||
[_callback hostClicked:_host];
|
[_callback hostClicked:_host view:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) addClicked {
|
- (void) addClicked {
|
||||||
|
|||||||
@@ -73,30 +73,32 @@ static NSArray* appList;
|
|||||||
|
|
||||||
- (void)alreadyPaired {
|
- (void)alreadyPaired {
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
_computerNameButton.title = _selectedHost.name;
|
|
||||||
[self.navigationController.navigationBar setNeedsLayout];
|
|
||||||
});
|
|
||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:_selectedHost.address uniqueId:_uniqueId deviceName:deviceName cert:_cert];
|
||||||
|
|
||||||
AppListResponse* appListResp = [[AppListResponse alloc] init];
|
AppListResponse* appListResp = [[AppListResponse alloc] init];
|
||||||
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appListResp withUrlRequest:[hMan newAppListRequest]]];
|
[hMan executeRequestSynchronously:[HttpRequest requestForResponse:appListResp withUrlRequest:[hMan newAppListRequest]]];
|
||||||
if (appListResp == nil || ![appListResp isStatusOk]) {
|
if (appListResp == nil || ![appListResp isStatusOk] || (appList = [appListResp getAppList]) == nil) {
|
||||||
Log(LOG_W, @"Failed to get applist: %@", appListResp.statusMessage);
|
Log(LOG_W, @"Failed to get applist: %@", appListResp.statusMessage);
|
||||||
|
[self hideLoadingFrame];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
UIAlertController* applistAlert = [UIAlertController alertControllerWithTitle:@"Fetching App List Failed"
|
||||||
|
message:@"The connection to the PC was interrupted."
|
||||||
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
[applistAlert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:nil]];
|
||||||
|
[self presentViewController:applistAlert animated:YES completion:nil];
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
appList = [appListResp getAppList];
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (appList == nil) {
|
_computerNameButton.title = _selectedHost.name;
|
||||||
Log(LOG_W, @"Failed to parse applist");
|
[self.navigationController.navigationBar setNeedsLayout];
|
||||||
} else {
|
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
|
||||||
[self updateApps];
|
|
||||||
});
|
|
||||||
|
|
||||||
[_appManager stopRetrieving];
|
[self updateApps];
|
||||||
[_appManager retrieveAssets:appList fromHost:_selectedHost];
|
});
|
||||||
}
|
|
||||||
|
[_appManager stopRetrieving];
|
||||||
|
[_appManager retrieveAssets:appList fromHost:_selectedHost];
|
||||||
|
[self hideLoadingFrame];
|
||||||
}
|
}
|
||||||
[self hideLoadingFrame];
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,7 +122,16 @@ static NSArray* appList;
|
|||||||
[self presentViewController:alert animated:YES completion:nil];
|
[self presentViewController:alert animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) hostClicked:(Host *)host {
|
- (void) hostClicked:(Host *)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
|
||||||
|
// code path.
|
||||||
|
if (!host.online && view != nil) {
|
||||||
|
[self hostLongClicked:host view:view];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Log(LOG_D, @"Clicked host: %@", host.name);
|
Log(LOG_D, @"Clicked host: %@", host.name);
|
||||||
[self showLoadingFrame];
|
[self showLoadingFrame];
|
||||||
_selectedHost = host;
|
_selectedHost = host;
|
||||||
@@ -132,6 +143,13 @@ static NSArray* appList;
|
|||||||
if (serverInfoResp == nil || ![serverInfoResp isStatusOk]) {
|
if (serverInfoResp == nil || ![serverInfoResp isStatusOk]) {
|
||||||
Log(LOG_W, @"Failed to get server info: %@", serverInfoResp.statusMessage);
|
Log(LOG_W, @"Failed to get server info: %@", serverInfoResp.statusMessage);
|
||||||
[self hideLoadingFrame];
|
[self hideLoadingFrame];
|
||||||
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
|
UIAlertController* applistAlert = [UIAlertController alertControllerWithTitle:@"Fetching Server Info Failed"
|
||||||
|
message:@"The connection to the PC was interrupted."
|
||||||
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
[applistAlert addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDestructive handler:nil]];
|
||||||
|
[self presentViewController:applistAlert animated:YES completion:nil];
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Log(LOG_D, @"server info pair status: %@", [serverInfoResp getStringTag:@"PairStatus"]);
|
Log(LOG_D, @"server info pair status: %@", [serverInfoResp getStringTag:@"PairStatus"]);
|
||||||
if ([[serverInfoResp getStringTag:@"PairStatus"] isEqualToString:@"1"]) {
|
if ([[serverInfoResp getStringTag:@"PairStatus"] isEqualToString:@"1"]) {
|
||||||
@@ -401,7 +419,7 @@ static NSArray* appList;
|
|||||||
|
|
||||||
// This will refresh the applist
|
// This will refresh the applist
|
||||||
if (_selectedHost != nil) {
|
if (_selectedHost != nil) {
|
||||||
[self hostClicked:_selectedHost];
|
[self hostClicked:_selectedHost view:nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user