diff --git a/Classes/InAppProductsManager.m b/Classes/InAppProductsManager.m
index 3b105e0c4..94ab2c96d 100644
--- a/Classes/InAppProductsManager.m
+++ b/Classes/InAppProductsManager.m
@@ -54,6 +54,7 @@
warnBeforeExpiryPeriod = [LinphoneManager.instance lpConfigIntForKey:@"warn_before_expiry_period" inSection:@"in_app_purchase"];
lastCheck = 0;
+ [XMLRPCHelper.self initArray];
//========// for test only
// int testExpiry = [LinphoneManager.instance lpConfigIntForKey:@"expiry_time_test"
// inSection:@"in_app_purchase"];
diff --git a/Classes/Utils/XMLRPCHelper.h b/Classes/Utils/XMLRPCHelper.h
index f69f20718..4baecc43a 100644
--- a/Classes/Utils/XMLRPCHelper.h
+++ b/Classes/Utils/XMLRPCHelper.h
@@ -11,6 +11,8 @@
* All the rest is implemented to do nothing
*/
+@property(nonatomic, strong) NSMutableArray *personsArray;
+
+ (void)sendXMLRPCRequest:(NSString *)method;
+ (void)sendXMLRPCRequestWithParams:(NSString *)method withParams:(NSArray *)params;
+ (void)sendXMLRPCRequestWithParams:(NSString *)method
@@ -23,5 +25,6 @@
- (void)dealWithXmlRpcResponse:(LinphoneXmlRpcRequest *)request;
- (void)displayErrorPopup:(NSString *)error;
++ (void)initArray;
@end
diff --git a/Classes/Utils/XMLRPCHelper.m b/Classes/Utils/XMLRPCHelper.m
index c210ac695..85c8825d8 100644
--- a/Classes/Utils/XMLRPCHelper.m
+++ b/Classes/Utils/XMLRPCHelper.m
@@ -13,17 +13,31 @@
#import "Utils.h"
#import "PhoneMainView.h"
+/* This subclass allows use to store the block to execute on success */
+@interface XMLRPCRequestObject : NSObject
+@property(copy, nonatomic) void (^XMLRPCHelperBlockSuccess)(NSString *something);
+@property(copy, nonatomic) void (^XMLRPCHelperBlockError)(NSString *something);
+@property LinphoneXmlRpcRequest *xmlRpcRequest;
+@end
+
+@implementation XMLRPCRequestObject
+@end
@implementation XMLRPCHelper
#pragma mark - API
-typedef void (^XMLRPCHelperBlock)(NSString *something);
+// typedef void (^XMLRPCHelperBlock)(NSString *something);
-XMLRPCHelperBlock successBlock = nil;
-XMLRPCHelperBlock errorBlock = nil;
+// XMLRPCHelperBlock successBlock = nil;
+// XMLRPCHelperBlock errorBlock = nil;
+
+NSMutableArray *personsArray;
/*****************************************************************************************/
++ (void)initArray {
+ personsArray = [[NSMutableArray alloc] init];
+}
+ (void)sendXMLRPCRequest:(NSString *)method {
[self sendXMLRPCRequestWithParams:method withParams:nil onSuccess:nil onError:nil];
@@ -46,33 +60,36 @@ XMLRPCHelperBlock errorBlock = nil;
onSuccess:(void (^)(NSString *))successBk
onError:(void (^)(NSString *req))errorBk {
LOGI(@"XMLRPC %@ - %@", method, params);
+ XMLRPCRequestObject *requestObject = [XMLRPCRequestObject alloc];
const char *URL =
[LinphoneManager.instance lpConfigStringForKey:@"receipt_validation_url" inSection:@"in_app_purchase"]
.UTF8String;
- successBlock = successBk;
- errorBlock = errorBk;
+ requestObject.XMLRPCHelperBlockSuccess = successBk;
+ requestObject.XMLRPCHelperBlockError = errorBk;
// Create LinphoneXMLRPCRequest
LinphoneXmlRpcSession *requestSession = linphone_xml_rpc_session_new(LC, URL);
- LinphoneXmlRpcRequest *request = linphone_xml_rpc_request_new(method.UTF8String, LinphoneXmlRpcArgString);
+ // LinphoneXmlRpcRequest *request = linphone_xml_rpc_request_new(method.UTF8String, LinphoneXmlRpcArgString);
+ requestObject.xmlRpcRequest = linphone_xml_rpc_request_new(method.UTF8String, LinphoneXmlRpcArgString);
+ [personsArray addObject:requestObject];
// Set argument to this LinphoneXMLRPCRequest
for (NSString *item in params) {
NSLog(@"Linphone XMLRPC Request with argument: %@", item);
- linphone_xml_rpc_request_add_string_arg(request, item.UTF8String);
+ linphone_xml_rpc_request_add_string_arg(requestObject.xmlRpcRequest, item.UTF8String);
}
// Ref and send the LinphoneXMLRPCRequest
requestSession = linphone_xml_rpc_session_ref(requestSession);
- linphone_xml_rpc_session_send_request(requestSession, request);
+ linphone_xml_rpc_session_send_request(requestSession, requestObject.xmlRpcRequest);
// Set the callbacks to this LinphoneXMLRPCRequest
- LinphoneXmlRpcRequestCbs *cbs = linphone_xml_rpc_request_get_callbacks(request);
+ LinphoneXmlRpcRequestCbs *cbs = linphone_xml_rpc_request_get_callbacks(requestObject.xmlRpcRequest);
// Register XMLRPCHelper in user data to get it back on Callback rised
XMLRPCHelper *xMLRPCHelper = [[XMLRPCHelper alloc] init];
- linphone_xml_rpc_request_set_user_data(request, ((void *)CFBridgingRetain(xMLRPCHelper)));
+ linphone_xml_rpc_request_set_user_data(requestObject.xmlRpcRequest, ((void *)CFBridgingRetain(xMLRPCHelper)));
// Set the response Callback
linphone_xml_rpc_request_cbs_set_response(cbs, linphone_xmlrpc_call_back_received);
@@ -83,21 +100,31 @@ static void linphone_xmlrpc_call_back_received(LinphoneXmlRpcRequest *request) {
}
- (void)dealWithXmlRpcResponse:(LinphoneXmlRpcRequest *)request {
+ XMLRPCRequestObject *xmlrpcObject;
+ NSInteger index = 0;
+ for (int i = 0; i < [personsArray count]; i++) {
+ xmlrpcObject = [personsArray objectAtIndex:i];
+ if (xmlrpcObject.xmlRpcRequest == request)
+ break;
+ index++;
+ }
+
NSString *responseString =
[NSString stringWithFormat:@"%s", (linphone_xml_rpc_request_get_string_response(request))];
LOGI(@"XMLRPC query: %@", responseString);
if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusOk) {
// Call success block
- successBlock(responseString);
+ xmlrpcObject.XMLRPCHelperBlockSuccess(responseString);
} else if (linphone_xml_rpc_request_get_status(request) == LinphoneXmlRpcStatusFailed) {
- if (errorBlock != nil) {
+ if (xmlrpcObject.XMLRPCHelperBlockError != nil) {
LOGI(@"XMLRPC query ErrorBlock rised");
- errorBlock(responseString);
+ xmlrpcObject.XMLRPCHelperBlockError(responseString);
}
// Display Error alert
[self displayErrorPopup:@"LinphoneXMLRPC Request Failed"];
}
linphone_xml_rpc_request_unref(request);
+ [personsArray removeObjectAtIndex:index];
}
#pragma mark - Error alerts
diff --git a/Settings/InAppSettings.bundle/Network.plist b/Settings/InAppSettings.bundle/Network.plist
index 290ffd3bf..26784addf 100644
--- a/Settings/InAppSettings.bundle/Network.plist
+++ b/Settings/InAppSettings.bundle/Network.plist
@@ -36,7 +36,7 @@
AutocorrectionType
No
DefaultValue
-
+
IASKTextAlignment
IASKUITextAlignmentRight
@@ -48,7 +48,7 @@
Type
PSToggleSwitchSpecifier
DefaultValue
-
+
Title
@@ -58,7 +58,7 @@
Type
PSToggleSwitchSpecifier
DefaultValue
-
+
Key