mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-17 06:01:13 +00:00
Improve description messages of error message dialogs
This commit is contained in:
@@ -18,11 +18,11 @@
|
|||||||
HttpManager* hMan = [[HttpManager alloc] initWithHost:hostIP uniqueId:uniqueId serverCert:cert];
|
HttpManager* hMan = [[HttpManager alloc] initWithHost:hostIP uniqueId:uniqueId serverCert:cert];
|
||||||
|
|
||||||
// Try up to 5 times to get the app list
|
// Try up to 5 times to get the app list
|
||||||
AppListResponse* appListResp;
|
AppListResponse* appListResp = nil;
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
appListResp = [[AppListResponse alloc] init];
|
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] || [appListResp getAppList] == nil) {
|
if (![appListResp isStatusOk] || [appListResp getAppList] == nil) {
|
||||||
Log(LOG_W, @"Failed to get applist on try %d: %@", i, appListResp.statusMessage);
|
Log(LOG_W, @"Failed to get applist on try %d: %@", i, appListResp.statusMessage);
|
||||||
|
|
||||||
// Wait for one second then retry
|
// Wait for one second then retry
|
||||||
@@ -30,10 +30,11 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Log(LOG_I, @"App list successfully retreived - took %d tries", i);
|
Log(LOG_I, @"App list successfully retreived - took %d tries", i);
|
||||||
return appListResp;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil;
|
|
||||||
|
return appListResp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -33,10 +33,6 @@
|
|||||||
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
|
ServerInfoResponse* serverInfoResp = [[ServerInfoResponse alloc] init];
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResp withUrlRequest:[_httpManager newServerInfoRequest:false]
|
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:serverInfoResp withUrlRequest:[_httpManager newServerInfoRequest:false]
|
||||||
fallbackError:401 fallbackRequest:[_httpManager newHttpServerInfoRequest]]];
|
fallbackError:401 fallbackRequest:[_httpManager newHttpServerInfoRequest]]];
|
||||||
if (serverInfoResp == nil) {
|
|
||||||
[_callback pairFailed:@"Unable to connect to PC"];
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if ([serverInfoResp isStatusOk]) {
|
if ([serverInfoResp isStatusOk]) {
|
||||||
if ([[serverInfoResp getStringTag:@"state"] hasSuffix:@"_SERVER_BUSY"]) {
|
if ([[serverInfoResp getStringTag:@"state"] hasSuffix:@"_SERVER_BUSY"]) {
|
||||||
[_callback pairFailed:@"You cannot pair while a previous session is still running on the host PC. Quit any running games or reboot the host PC, then try pairing again."];
|
[_callback pairFailed:@"You cannot pair while a previous session is still running on the host PC. Quit any running games or reboot the host PC, then try pairing again."];
|
||||||
@@ -51,13 +47,25 @@
|
|||||||
[_callback alreadyPaired];
|
[_callback alreadyPaired];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
[_callback pairFailed:serverInfoResp.statusMessage];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) finishPairing:(UIBackgroundTaskIdentifier)bgId withError:(NSString*)errorMsg {
|
- (void) finishPairing:(UIBackgroundTaskIdentifier)bgId
|
||||||
|
forResponse:(HttpResponse*)resp
|
||||||
|
withFallbackError:(NSString*)errorMsg {
|
||||||
|
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
||||||
|
|
||||||
if (bgId != UIBackgroundTaskInvalid) {
|
if (bgId != UIBackgroundTaskInvalid) {
|
||||||
[[UIApplication sharedApplication] endBackgroundTask:bgId];
|
[[UIApplication sharedApplication] endBackgroundTask:bgId];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (![resp isStatusOk]) {
|
||||||
|
// Use the response error if the request failed
|
||||||
|
errorMsg = resp.statusMessage;
|
||||||
|
}
|
||||||
|
|
||||||
[_callback pairFailed:errorMsg];
|
[_callback pairFailed:errorMsg];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,18 +95,13 @@
|
|||||||
HttpResponse* pairResp = [[HttpResponse alloc] init];
|
HttpResponse* pairResp = [[HttpResponse alloc] init];
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:pairResp withUrlRequest:[_httpManager newPairRequest:salt clientCert:_clientCert]]];
|
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:pairResp withUrlRequest:[_httpManager newPairRequest:salt clientCert:_clientCert]]];
|
||||||
if (![self verifyResponseStatus:pairResp]) {
|
if (![self verifyResponseStatus:pairResp]) {
|
||||||
[self finishPairing:bgId withError:@"Pairing stage #1 failed"];
|
[self finishPairing:bgId forResponse:pairResp withFallbackError:@"Pairing was declined by the target."];
|
||||||
return;
|
|
||||||
}
|
|
||||||
NSInteger pairedStatus;
|
|
||||||
if (![pairResp getIntTag:@"paired" value:&pairedStatus] || !pairedStatus) {
|
|
||||||
[self finishPairing:bgId withError:@"Pairing was declined by the target."];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* plainCert = [pairResp getStringTag:@"plaincert"];
|
NSString* plainCert = [pairResp getStringTag:@"plaincert"];
|
||||||
if ([plainCert length] == 0) {
|
if ([plainCert length] == 0) {
|
||||||
[self finishPairing:bgId withError:@"Another pairing attempt is already in progress."];
|
[self finishPairing:bgId forResponse:pairResp withFallbackError:@"Another pairing attempt is already in progress."];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,11 +128,8 @@
|
|||||||
|
|
||||||
HttpResponse* challengeResp = [[HttpResponse alloc] init];
|
HttpResponse* challengeResp = [[HttpResponse alloc] init];
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:challengeResp withUrlRequest:[_httpManager newChallengeRequest:encryptedChallenge]]];
|
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:challengeResp withUrlRequest:[_httpManager newChallengeRequest:encryptedChallenge]]];
|
||||||
if (![self verifyResponseStatus:challengeResp] ||
|
if (![self verifyResponseStatus:challengeResp]) {
|
||||||
![challengeResp getIntTag:@"paired" value:&pairedStatus] ||
|
[self finishPairing:bgId forResponse:challengeResp withFallbackError:@"Pairing stage #2 failed"];
|
||||||
pairedStatus != 1) {
|
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
|
||||||
[self finishPairing:bgId withError:@"Pairing stage #2 failed"];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,11 +152,8 @@
|
|||||||
|
|
||||||
HttpResponse* secretResp = [[HttpResponse alloc] init];
|
HttpResponse* secretResp = [[HttpResponse alloc] init];
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:secretResp withUrlRequest:[_httpManager newChallengeRespRequest:challengeRespEncrypted]]];
|
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:secretResp withUrlRequest:[_httpManager newChallengeRespRequest:challengeRespEncrypted]]];
|
||||||
if (![self verifyResponseStatus:secretResp] ||
|
if (![self verifyResponseStatus:secretResp]) {
|
||||||
![secretResp getIntTag:@"paired" value:&pairedStatus] ||
|
[self finishPairing:bgId forResponse:secretResp withFallbackError:@"Pairing stage #3 failed"];
|
||||||
pairedStatus != 1) {
|
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
|
||||||
[self finishPairing:bgId withError:@"Pairing stage #3 failed"];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,8 +162,7 @@
|
|||||||
NSData* serverSignature = [serverSecretResp subdataWithRange:NSMakeRange(16, 256)];
|
NSData* serverSignature = [serverSecretResp subdataWithRange:NSMakeRange(16, 256)];
|
||||||
|
|
||||||
if (![cryptoMan verifySignature:serverSecret withSignature:serverSignature andCert:[Utils hexToBytes:plainCert]]) {
|
if (![cryptoMan verifySignature:serverSecret withSignature:serverSignature andCert:[Utils hexToBytes:plainCert]]) {
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
[self finishPairing:bgId forResponse:secretResp withFallbackError:@"Server certificate invalid"];
|
||||||
[self finishPairing:bgId withError:@"Server certificate invalid"];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,29 +175,22 @@
|
|||||||
serverChallengeRespHash = [cryptoMan SHA1HashData: serverChallengeRespHashInput];
|
serverChallengeRespHash = [cryptoMan SHA1HashData: serverChallengeRespHashInput];
|
||||||
}
|
}
|
||||||
if (![serverChallengeRespHash isEqual:serverResponse]) {
|
if (![serverChallengeRespHash isEqual:serverResponse]) {
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
[self finishPairing:bgId forResponse:secretResp withFallbackError:@"Incorrect PIN"];
|
||||||
[self finishPairing:bgId withError:@"Incorrect PIN"];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSData* clientPairingSecret = [self concatData:clientSecret with:[cryptoMan signData:clientSecret withKey:[CryptoManager readKeyFromFile]]];
|
NSData* clientPairingSecret = [self concatData:clientSecret with:[cryptoMan signData:clientSecret withKey:[CryptoManager readKeyFromFile]]];
|
||||||
HttpResponse* clientSecretResp = [[HttpResponse alloc] init];
|
HttpResponse* clientSecretResp = [[HttpResponse alloc] init];
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:clientSecretResp withUrlRequest:[_httpManager newClientSecretRespRequest:[Utils bytesToHex:clientPairingSecret]]]];
|
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:clientSecretResp withUrlRequest:[_httpManager newClientSecretRespRequest:[Utils bytesToHex:clientPairingSecret]]]];
|
||||||
if (![self verifyResponseStatus:clientSecretResp] ||
|
if (![self verifyResponseStatus:clientSecretResp]) {
|
||||||
![clientSecretResp getIntTag:@"paired" value:&pairedStatus] ||
|
[self finishPairing:bgId forResponse:clientSecretResp withFallbackError:@"Pairing stage #4 failed"];
|
||||||
pairedStatus != 1) {
|
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
|
||||||
[self finishPairing:bgId withError:@"Pairing stage #4 failed"];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
HttpResponse* clientPairChallengeResp = [[HttpResponse alloc] init];
|
HttpResponse* clientPairChallengeResp = [[HttpResponse alloc] init];
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:clientPairChallengeResp withUrlRequest:[_httpManager newPairChallenge]]];
|
[_httpManager executeRequestSynchronously:[HttpRequest requestForResponse:clientPairChallengeResp withUrlRequest:[_httpManager newPairChallenge]]];
|
||||||
if (![self verifyResponseStatus:clientPairChallengeResp] ||
|
if (![self verifyResponseStatus:clientPairChallengeResp]) {
|
||||||
![clientPairChallengeResp getIntTag:@"paired" value:&pairedStatus] ||
|
[self finishPairing:bgId forResponse:clientPairChallengeResp withFallbackError:@"Pairing stage #5 failed"];
|
||||||
pairedStatus != 1) {
|
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
|
||||||
[self finishPairing:bgId withError:@"Pairing stage #5 failed"];
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -210,14 +199,16 @@
|
|||||||
|
|
||||||
// Caller calls finishPairing for us on failure
|
// Caller calls finishPairing for us on failure
|
||||||
- (BOOL) verifyResponseStatus:(HttpResponse*)resp {
|
- (BOOL) verifyResponseStatus:(HttpResponse*)resp {
|
||||||
if (resp == nil) {
|
if (![resp isStatusOk]) {
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
|
||||||
return false;
|
|
||||||
} else if (![resp isStatusOk]) {
|
|
||||||
[_httpManager executeRequestSynchronously:[HttpRequest requestWithUrlRequest:[_httpManager newUnpairRequest]]];
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return true;
|
long pairedStatus;
|
||||||
|
|
||||||
|
if (![resp getIntTag:@"paired" value:&pairedStatus]) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pairedStatus == 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,11 @@
|
|||||||
NSString* appversion = [serverInfoResp getStringTag:@"appversion"];
|
NSString* appversion = [serverInfoResp getStringTag:@"appversion"];
|
||||||
NSString* gfeVersion = [serverInfoResp getStringTag:@"GfeVersion"];
|
NSString* gfeVersion = [serverInfoResp getStringTag:@"GfeVersion"];
|
||||||
NSString* serverState = [serverInfoResp getStringTag:@"state"];
|
NSString* serverState = [serverInfoResp getStringTag:@"state"];
|
||||||
if (![serverInfoResp isStatusOk] || pairStatus == NULL || appversion == NULL || serverState == NULL) {
|
if (![serverInfoResp isStatusOk]) {
|
||||||
|
[_callbacks launchFailed:serverInfoResp.statusMessage];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else if (pairStatus == NULL || appversion == NULL || serverState == NULL) {
|
||||||
[_callbacks launchFailed:@"Failed to connect to PC"];
|
[_callbacks launchFailed:@"Failed to connect to PC"];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ static NSMutableSet* hostList;
|
|||||||
|
|
||||||
[self->_discMan addHostToDiscovery:host];
|
[self->_discMan addHostToDiscovery:host];
|
||||||
|
|
||||||
if (appListResp == nil || ![appListResp isStatusOk] || [appListResp getAppList] == nil) {
|
if (![appListResp isStatusOk] || [appListResp getAppList] == nil) {
|
||||||
Log(LOG_W, @"Failed to get applist: %@", appListResp.statusMessage);
|
Log(LOG_W, @"Failed to get applist: %@", appListResp.statusMessage);
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (host != self->_selectedHost) {
|
if (host != self->_selectedHost) {
|
||||||
@@ -160,8 +160,8 @@ static NSMutableSet* hostList;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIAlertController* applistAlert = [UIAlertController alertControllerWithTitle:@"Fetching App List Failed"
|
UIAlertController* applistAlert = [UIAlertController alertControllerWithTitle:@"Connection Interrupted"
|
||||||
message:@"The connection to the PC was interrupted."
|
message:appListResp.statusMessage
|
||||||
preferredStyle:UIAlertControllerStyleAlert];
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
[Utils addHelpOptionToDialog:applistAlert];
|
[Utils addHelpOptionToDialog:applistAlert];
|
||||||
[applistAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
[applistAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
||||||
@@ -320,7 +320,7 @@ static NSMutableSet* hostList;
|
|||||||
fallbackError:401 fallbackRequest:[hMan newHttpServerInfoRequest]]];
|
fallbackError:401 fallbackRequest:[hMan newHttpServerInfoRequest]]];
|
||||||
[self->_discMan addHostToDiscovery:host];
|
[self->_discMan addHostToDiscovery:host];
|
||||||
|
|
||||||
if (serverInfoResp == nil || ![serverInfoResp isStatusOk]) {
|
if (![serverInfoResp isStatusOk]) {
|
||||||
Log(LOG_W, @"Failed to get server info: %@", serverInfoResp.statusMessage);
|
Log(LOG_W, @"Failed to get server info: %@", serverInfoResp.statusMessage);
|
||||||
dispatch_async(dispatch_get_main_queue(), ^{
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (host != self->_selectedHost) {
|
if (host != self->_selectedHost) {
|
||||||
@@ -328,8 +328,8 @@ static NSMutableSet* hostList;
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UIAlertController* applistAlert = [UIAlertController alertControllerWithTitle:@"Fetching Server Info Failed"
|
UIAlertController* applistAlert = [UIAlertController alertControllerWithTitle:@"Connection Failed"
|
||||||
message:@"The connection to the PC was interrupted."
|
message:serverInfoResp.statusMessage
|
||||||
preferredStyle:UIAlertControllerStyleAlert];
|
preferredStyle:UIAlertControllerStyleAlert];
|
||||||
[Utils addHelpOptionToDialog:applistAlert];
|
[Utils addHelpOptionToDialog:applistAlert];
|
||||||
[applistAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
[applistAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]];
|
||||||
|
|||||||
Reference in New Issue
Block a user