diff --git a/Classes/InAppProductsManager.m b/Classes/InAppProductsManager.m index 8665bc9d5..052c8acd4 100644 --- a/Classes/InAppProductsManager.m +++ b/Classes/InAppProductsManager.m @@ -27,6 +27,9 @@ #import "Utils.h" #import "LinphoneManager.h" +#import "PhoneMainView.h" +#import "InAppProductsViewController.h" + NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotification"; @@ -254,22 +257,25 @@ NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotificati // [waitView setHidden:true]; if ([response isFault]) { LOGE(@"Communication issue (%@)", [response faultString]); - // NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [response faultString]]; - // UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue",nil) - // message:errorString - // delegate:nil - // cancelButtonTitle:NSLocalizedString(@"Continue",nil) - // otherButtonTitles:nil,nil]; - // [errorView show]; - // [errorView release]; + NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [response faultString]]; + UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue",nil) + message:errorString + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue",nil) + otherButtonTitles:nil,nil]; + [errorView show]; + [errorView release]; } else if([response object] != nil) { //Don't handle if not object: HTTP/Communication Error if([[request method] isEqualToString:@"get_expiration_date"]) { - if([response object] == [NSNumber numberWithInt:1]) { + if(false && [response object] == [NSNumber numberWithInt:1]) { LOGE(@"Todo: parse the response"); // [_productsIDPurchased addObject:@"test.auto_renew_7days"]; [self postNotificationforStatus:IAPReceiptSucceeded]; return; + } else { + LOGI(@"Account has expired"); + [[PhoneMainView instance] changeCurrentView:[InAppProductsViewController compositeViewDescription]]; } } } @@ -279,15 +285,15 @@ NSString *const kLinphoneIAPurchaseNotification = @"LinphoneIAProductsNotificati - (void)XMLRPCRequest:(XMLRPCRequest *)request didFailWithError:(NSError *)error { LOGE(@"Communication issue (%@)", [error localizedDescription]); - // NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [error localizedDescription]]; - // UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue", nil) - // message:errorString - // delegate:nil - // cancelButtonTitle:NSLocalizedString(@"Continue", nil) - // otherButtonTitles:nil,nil]; - // [errorView show]; - // [errorView release]; - // [waitView setHidden:true]; + NSString *errorString = [NSString stringWithFormat:NSLocalizedString(@"Communication issue (%@)", nil), [error localizedDescription]]; + UIAlertView* errorView = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Communication issue", nil) + message:errorString + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue", nil) + otherButtonTitles:nil,nil]; + [errorView show]; + [errorView release]; + [waitView setHidden:true]; latestReceiptMD5 = nil; [self postNotificationforStatus:IAPReceiptFailed]; } diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index 00ed9c506..a096f2df0 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -240,7 +240,7 @@ - (NSString *)md5 { const char *ptr = [self UTF8String]; unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH]; - CC_MD5(ptr, strlen(ptr), md5Buffer); + CC_MD5(ptr, (unsigned int)strlen(ptr), md5Buffer); NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2]; for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++) { [output appendFormat:@"%02x",md5Buffer[i]];