Manos Chorianopoulos

logout db drop table issue fixed

......@@ -719,6 +719,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([accessTokenSet next]) {
accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
}
[accessTokenSet close];
}
}
@catch (NSException *exception) {
......@@ -739,27 +740,28 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
};
- (NSString*)getAccessToken2 {
BOOL tableExist = NO;
@try {
@synchronized (_DatabaseLock) {
tableExist = [_db tableExists:@"requestVariables"];
}
}
@catch (NSException *exception) {
NSLog(@"tableExists error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
// BOOL tableExist = NO;
// @try {
// @synchronized (_DatabaseLock) {
// tableExist = [_db tableExists:@"requestVariables"];
// }
// }
// @catch (NSException *exception) {
// NSLog(@"tableExists error: %@", exception.reason);
// }
// @finally {
// // NSLog(@"Finally condition");
// }
// NSString *accessToken = [NSString alloc];
NSString *accessToken = @"";
if (tableExist == YES) {
// if (tableExist == YES) {
@try {
@synchronized (_DatabaseLock) {
FMResultSet *accessTokenSet = [_db executeQuery:@"SELECT access_token FROM requestVariables WHERE id = 1;"];
while ([accessTokenSet next]) {
accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
}
[accessTokenSet close];
}
}
@catch (NSException *exception) {
......@@ -775,33 +777,34 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
// accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
// }
return accessToken;
}
return @"";
// }
// return @"";
};
- (NSString*)getRefreshToken {
BOOL tableExist = NO;
@try {
@synchronized (_DatabaseLock) {
tableExist = [_db tableExists:@"requestVariables"];
}
}
@catch (NSException *exception) {
NSLog(@"tableExists error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
// BOOL tableExist = NO;
// @try {
// @synchronized (_DatabaseLock) {
// tableExist = [_db tableExists:@"requestVariables"];
// }
// }
// @catch (NSException *exception) {
// NSLog(@"tableExists error: %@", exception.reason);
// }
// @finally {
// // NSLog(@"Finally condition");
// }
// NSString *refreshToken = [NSString alloc];
NSString *refreshToken = @"";
if (tableExist == YES) {
// if (tableExist == YES) {
@try {
@synchronized (_DatabaseLock) {
FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"];
while ([refreshTokenSet next]) {
refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
}
[refreshTokenSet close];
}
}
@catch (NSException *exception) {
......@@ -817,33 +820,34 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
// refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
// }
return refreshToken;
}
return @"";
// }
// return @"";
}
- (NSString*)getClientId {
BOOL tableExist = NO;
@try {
@synchronized (_DatabaseLock) {
tableExist = [_db tableExists:@"requestVariables"];
}
}
@catch (NSException *exception) {
NSLog(@"tableExists error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
// BOOL tableExist = NO;
// @try {
// @synchronized (_DatabaseLock) {
// tableExist = [_db tableExists:@"requestVariables"];
// }
// }
// @catch (NSException *exception) {
// NSLog(@"tableExists error: %@", exception.reason);
// }
// @finally {
// // NSLog(@"Finally condition");
// }
// NSString *clientId = [NSString alloc];
NSString *clientId = @"";
if (tableExist == YES) {
// if (tableExist == YES) {
@try {
@synchronized (_DatabaseLock) {
FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"];
while ([clientIdSet next]) {
clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
}
[clientIdSet close];
}
}
@catch (NSException *exception) {
......@@ -859,34 +863,35 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
// clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
// }
return clientId;
}
return @"";
// }
// return @"";
}
- (NSString*)getClientSecret {
BOOL tableExist = NO;
@try {
@synchronized (_DatabaseLock) {
tableExist = [_db tableExists:@"requestVariables"];
}
}
@catch (NSException *exception) {
NSLog(@"tableExists error: %@", exception.reason);
}
@finally {
// NSLog(@"Finally condition");
}
// BOOL tableExist = NO;
// @try {
// @synchronized (_DatabaseLock) {
// tableExist = [_db tableExists:@"requestVariables"];
// }
// }
// @catch (NSException *exception) {
// NSLog(@"tableExists error: %@", exception.reason);
// }
// @finally {
// // NSLog(@"Finally condition");
// }
// NSString *clientSecret = [NSString alloc];
NSString *clientSecret = @"";
if (tableExist == YES) {
// if (tableExist == YES) {
@try {
@synchronized (_DatabaseLock) {
FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"];
while ([clientSecretSet next]) {
clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
}
[clientSecretSet close];
}
}
@catch (NSException *exception) {
......@@ -902,8 +907,8 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
// clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
// }
return clientSecret;
}
return @"";
// }
// return @"";
}
- (void)getProductsWithSuccessBlock:(NSString*)filter :(void(^)(NSMutableArray *params)) success failureBlock:(void(^)(NSError *error))failure
......@@ -1156,24 +1161,24 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
"refresh_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOjMyMjI4ODYsImlhdCI6MTcxMDE2ODIwMiwiZXhwIjoxNzEwMTcwMDAyLCJIT1NUIjoiaHR0cHM6Ly9lbmdhZ2Utc3RhZ2Uud2FycC5seSJ9.8W9x4uuEsZiL8NNtJmpA1I3JsMtx8j3jePAnGekNkAM"}
*/
BOOL tableExist = NO;
@try {
@synchronized (_DatabaseLock) {
tableExist = [_db tableExists:@"requestVariables"];
}
}
@catch (NSException *exception) {
NSLog(@"tableExists error: %@", exception.reason);
if (failure) {
NSError *error = nil;
failure(error);
}
}
@finally {
// NSLog(@"Finally condition");
}
// BOOL tableExist = NO;
// @try {
// @synchronized (_DatabaseLock) {
// tableExist = [_db tableExists:@"requestVariables"];
// }
// }
// @catch (NSException *exception) {
// NSLog(@"tableExists error: %@", exception.reason);
// if (failure) {
// NSError *error = nil;
// failure(error);
// }
// }
// @finally {
// // NSLog(@"Finally condition");
// }
if (tableExist == YES) {
// if (tableExist == YES) {
NSString *accessToken = @"";
NSString *refreshToken = @"";
NSString *clientId = @"";
......@@ -1205,11 +1210,16 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
if (success) {
// success(contextResponse);
// @synchronized (_DatabaseLock) {
// [_db executeUpdate:@"DROP TABLE requestVariables"];
// }
@synchronized (_DatabaseLock) {
[_db executeUpdate:@"DROP TABLE requestVariables"];
[_db closeOpenResultSets]; // Clean up any open result sets
[_db executeUpdate:@"DROP TABLE IF EXISTS requestVariables"];
}
NSDictionary *successResponse = @{@"result": @"success", @"status":@1};
NSLog(@"**************** WARPLY Logout *****************" );
success(successResponse);
}
NSLog(@"**************** WARPLY Response *****************" );
......@@ -1222,7 +1232,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
}
NSLog(@"Error at logout %@", error );
}];
}
// }
// @synchronized (_DatabaseLock) {
// [_db executeUpdate:@"DROP TABLE requestVariables"];
......@@ -1411,6 +1421,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([refreshTokenSet next]) {
refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
}
[refreshTokenSet close];
}
@synchronized (_DatabaseLock) {
FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"];
......@@ -1419,6 +1430,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([clientIdSet next]) {
clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
}
[clientIdSet close];
}
@synchronized (_DatabaseLock) {
FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"];
......@@ -1427,6 +1439,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([clientSecretSet next]) {
clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
}
[clientSecretSet close];
}
}
@catch (NSException *exception) {
......@@ -1543,6 +1556,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([refreshTokenSet next]) {
refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
}
[refreshTokenSet close];
}
@synchronized (_DatabaseLock) {
FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"];
......@@ -1551,6 +1565,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([clientIdSet next]) {
clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
}
[clientIdSet close];
}
@synchronized (_DatabaseLock) {
FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"];
......@@ -1559,6 +1574,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([clientSecretSet next]) {
clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
}
[clientSecretSet close];
}
}
@catch (NSException *exception) {
......@@ -1674,6 +1690,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([refreshTokenSet next]) {
refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue];
}
[refreshTokenSet close];
}
@synchronized (_DatabaseLock) {
FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"];
......@@ -1682,6 +1699,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([clientIdSet next]) {
clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue];
}
[clientIdSet close];
}
@synchronized (_DatabaseLock) {
FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"];
......@@ -1690,6 +1708,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION)
while ([clientSecretSet next]) {
clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue];
}
[clientSecretSet close];
}
}
@catch (NSException *exception) {
......@@ -3838,6 +3857,7 @@ return appIsRegisteredWithWarply;
return true;
}
}
[result close];
}
return false;
......@@ -4738,6 +4758,7 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
while ([accessTokenSet next]) {
accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
}
[accessTokenSet close];
}
}
@catch (NSException *exception) {
......@@ -4921,6 +4942,7 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2)
while ([accessTokenSet next]) {
accessToken = [[accessTokenSet resultDictionary][@"access_token"] stringValue];
}
[accessTokenSet close];
}
}
@catch (NSException *exception) {
......@@ -6935,6 +6957,7 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg
return YES;
}
}
[priorityEvents close];
}
@synchronized (_DatabaseLock) {
FMResultSet *rs = [_db executeQuery:@"SELECT COUNT(*) FROM events;"];
......@@ -6945,6 +6968,7 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg
return YES;
}
}
[rs close];
}
return NO;
}
......@@ -6962,6 +6986,7 @@ static void distanceFunc(sqlite3_context *context, int argc, sqlite3_value **arg
[mutableEventDict setObject:[rs objectForColumnName:@"_id"] forKey:@"_id"];
[events addObject:mutableEventDict];
}
[rs close];
}
return events;
}
......