Showing
2 changed files
with
486 additions
and
35 deletions
... | @@ -329,6 +329,10 @@ WL_VERSION_INTERFACE() | ... | @@ -329,6 +329,10 @@ WL_VERSION_INTERFACE() |
329 | 329 | ||
330 | - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 330 | - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
331 | 331 | ||
332 | +- (void)refreshToken2ndTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
333 | + | ||
334 | +- (void)refreshToken3rdTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ||
335 | + | ||
332 | - (void)changePasswordWithSuccessBlock:(NSString*)oldPassword andNewPassword:(NSString*)newPassword :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 336 | - (void)changePasswordWithSuccessBlock:(NSString*)oldPassword andNewPassword:(NSString*)newPassword :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; |
333 | 337 | ||
334 | - (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | 338 | - (void)getProfileWithSuccessBlock :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure; | ... | ... |
... | @@ -574,7 +574,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -574,7 +574,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
574 | }]; | 574 | }]; |
575 | } failureBlock:^(NSError *error) { | 575 | } failureBlock:^(NSError *error) { |
576 | if (failure) { | 576 | if (failure) { |
577 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 577 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
578 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
579 | + | ||
580 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
581 | + WL_FMDBLogError | ||
582 | + | ||
583 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
584 | + | ||
585 | + } else { | ||
586 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
587 | + } | ||
578 | failure(error); | 588 | failure(error); |
579 | } | 589 | } |
580 | NSLog(@"Error at token %@", error ); | 590 | NSLog(@"Error at token %@", error ); |
... | @@ -820,7 +830,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -820,7 +830,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
820 | - (NSDictionary*)logout | 830 | - (NSDictionary*)logout |
821 | { | 831 | { |
822 | 832 | ||
823 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 833 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
834 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
835 | + | ||
836 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
837 | + WL_FMDBLogError | ||
838 | + | ||
839 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
840 | + | ||
841 | + } else { | ||
842 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
843 | + } | ||
824 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 844 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
825 | NSLog(@"**************** WARPLY Logout *****************" ); | 845 | NSLog(@"**************** WARPLY Logout *****************" ); |
826 | return successResponse; | 846 | return successResponse; |
... | @@ -903,6 +923,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -903,6 +923,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
903 | }]; | 923 | }]; |
904 | } | 924 | } |
905 | 925 | ||
926 | +// TODO: ADD NEW SDK | ||
906 | - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 927 | - (void)refreshToken:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
907 | { | 928 | { |
908 | FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"]; | 929 | FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"]; |
... | @@ -935,13 +956,82 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -935,13 +956,82 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
935 | dict = [error userInfo]; | 956 | dict = [error userInfo]; |
936 | NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | 957 | NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; |
937 | if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | 958 | if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { |
938 | - [self refreshToken:^(NSDictionary *response) { | 959 | + [self refreshToken2ndTry:^(NSDictionary *response) { |
939 | // [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]]; | 960 | // [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]]; |
940 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 961 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
941 | success(successResponse); | 962 | success(successResponse); |
942 | } failureBlock:^(NSError *error) { | 963 | } failureBlock:^(NSError *error) { |
943 | if (failure) { | 964 | if (failure) { |
944 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 965 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
966 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
967 | + | ||
968 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
969 | + WL_FMDBLogError | ||
970 | + | ||
971 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
972 | + | ||
973 | + } else { | ||
974 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
975 | + } | ||
976 | + failure(error); | ||
977 | + } | ||
978 | + NSLog(@"Error at token %@", error ); | ||
979 | + }]; | ||
980 | + } | ||
981 | + NSLog(@"Error at token %@", error ); | ||
982 | + } | ||
983 | + }]; | ||
984 | +} | ||
985 | + | ||
986 | +- (void)refreshToken2ndTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
987 | +{ | ||
988 | + FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"]; | ||
989 | + NSString *refreshToken = [NSString alloc]; | ||
990 | + while ([refreshTokenSet next]) { | ||
991 | + refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue]; | ||
992 | + } | ||
993 | + FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"]; | ||
994 | + NSString *clientId = [NSString alloc]; | ||
995 | + while ([clientIdSet next]) { | ||
996 | + clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue]; | ||
997 | + } | ||
998 | + FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"]; | ||
999 | + NSString *clientSecret = [NSString alloc]; | ||
1000 | + while ([clientSecretSet next]) { | ||
1001 | + clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue]; | ||
1002 | + } | ||
1003 | + | ||
1004 | + NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; | ||
1005 | + NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; | ||
1006 | + [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { | ||
1007 | + if (success) { | ||
1008 | + [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | ||
1009 | + NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1010 | + success(successResponse); | ||
1011 | + } | ||
1012 | + } failureBlock:^(NSError *error) { | ||
1013 | + if (failure) { | ||
1014 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1015 | + dict = [error userInfo]; | ||
1016 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1017 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1018 | + [self refreshToken3rdTry:^(NSDictionary *response) { | ||
1019 | +// [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [response objectForKey:@"access_token"], [response objectForKey:@"refresh_token"]]; | ||
1020 | + NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1021 | + success(successResponse); | ||
1022 | + } failureBlock:^(NSError *error) { | ||
1023 | + if (failure) { | ||
1024 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1025 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1026 | + | ||
1027 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1028 | + WL_FMDBLogError | ||
1029 | + | ||
1030 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1031 | + | ||
1032 | + } else { | ||
1033 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1034 | + } | ||
945 | failure(error); | 1035 | failure(error); |
946 | } | 1036 | } |
947 | NSLog(@"Error at token %@", error ); | 1037 | NSLog(@"Error at token %@", error ); |
... | @@ -952,6 +1042,59 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -952,6 +1042,59 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
952 | }]; | 1042 | }]; |
953 | } | 1043 | } |
954 | 1044 | ||
1045 | +- (void)refreshToken3rdTry:(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | ||
1046 | +{ | ||
1047 | + FMResultSet *refreshTokenSet = [_db executeQuery:@"SELECT refresh_token FROM requestVariables WHERE id = 1;"]; | ||
1048 | + NSString *refreshToken = [NSString alloc]; | ||
1049 | + while ([refreshTokenSet next]) { | ||
1050 | + refreshToken = [[refreshTokenSet resultDictionary][@"refresh_token"] stringValue]; | ||
1051 | + } | ||
1052 | + FMResultSet *clientIdSet = [_db executeQuery:@"SELECT client_id FROM requestVariables WHERE id = 1;"]; | ||
1053 | + NSString *clientId = [NSString alloc]; | ||
1054 | + while ([clientIdSet next]) { | ||
1055 | + clientId = [[clientIdSet resultDictionary][@"client_id"] stringValue]; | ||
1056 | + } | ||
1057 | + FMResultSet *clientSecretSet = [_db executeQuery:@"SELECT client_secret FROM requestVariables WHERE id = 1;"]; | ||
1058 | + NSString *clientSecret = [NSString alloc]; | ||
1059 | + while ([clientSecretSet next]) { | ||
1060 | + clientSecret = [[clientSecretSet resultDictionary][@"client_secret"] stringValue]; | ||
1061 | + } | ||
1062 | + | ||
1063 | + NSDictionary *postDictionary3 = @{@"client_id": clientId, @"client_secret": clientSecret, @"refresh_token": refreshToken, @"grant_type":@"refresh_token", }; | ||
1064 | + NSData *jsonData3 = [NSJSONSerialization dataWithJSONObject:postDictionary3 options:0 error:NULL]; | ||
1065 | + [self sendContext5:jsonData3 successBlock:^(NSDictionary *contextResponse) { | ||
1066 | + if (success) { | ||
1067 | + [_db executeUpdate:@"UPDATE requestVariables SET access_token = ?, refresh_token = ? WHERE id = 1", [contextResponse objectForKey:@"access_token"], [contextResponse objectForKey:@"refresh_token"]]; | ||
1068 | + NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | ||
1069 | + success(successResponse); | ||
1070 | + } | ||
1071 | + } failureBlock:^(NSError *error) { | ||
1072 | + if (failure) { | ||
1073 | + NSDictionary* dict = [NSDictionary alloc]; | ||
1074 | + dict = [error userInfo]; | ||
1075 | + NSString* errorCode = [dict objectForKey:@"NSLocalizedDescription"]; | ||
1076 | + if ([errorCode isEqual:@"Request failed: unauthorized (401)"]) { | ||
1077 | + if (failure) { | ||
1078 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1079 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1080 | + | ||
1081 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1082 | + WL_FMDBLogError | ||
1083 | + | ||
1084 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1085 | + | ||
1086 | + } else { | ||
1087 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1088 | + } | ||
1089 | + failure(error); | ||
1090 | + } | ||
1091 | + NSLog(@"Error at token %@", error ); | ||
1092 | + } | ||
1093 | + NSLog(@"Error at token %@", error ); | ||
1094 | + } | ||
1095 | + }]; | ||
1096 | +} | ||
1097 | + | ||
955 | - (void)changePasswordWithSuccessBlock:(NSString*)oldPassword andNewPassword:(NSString*)newPassword :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 1098 | - (void)changePasswordWithSuccessBlock:(NSString*)oldPassword andNewPassword:(NSString*)newPassword :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
956 | { | 1099 | { |
957 | NSDictionary *postDictionary = @{@"old_password": oldPassword, @"new_password": newPassword, @"channel": @"mobile" }; | 1100 | NSDictionary *postDictionary = @{@"old_password": oldPassword, @"new_password": newPassword, @"channel": @"mobile" }; |
... | @@ -978,7 +1121,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -978,7 +1121,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
978 | }]; | 1121 | }]; |
979 | } failureBlock:^(NSError *error) { | 1122 | } failureBlock:^(NSError *error) { |
980 | if (failure) { | 1123 | if (failure) { |
981 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1124 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1125 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1126 | + | ||
1127 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1128 | + WL_FMDBLogError | ||
1129 | + | ||
1130 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1131 | + | ||
1132 | + } else { | ||
1133 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1134 | + } | ||
982 | failure(error); | 1135 | failure(error); |
983 | } | 1136 | } |
984 | NSLog(@"Error at token %@", error ); | 1137 | NSLog(@"Error at token %@", error ); |
... | @@ -1021,7 +1174,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1021,7 +1174,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1021 | }]; | 1174 | }]; |
1022 | } failureBlock:^(NSError *error) { | 1175 | } failureBlock:^(NSError *error) { |
1023 | if (failure) { | 1176 | if (failure) { |
1024 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1177 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1178 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1179 | + | ||
1180 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1181 | + WL_FMDBLogError | ||
1182 | + | ||
1183 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1184 | + | ||
1185 | + } else { | ||
1186 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1187 | + } | ||
1025 | failure(error); | 1188 | failure(error); |
1026 | } | 1189 | } |
1027 | NSLog(@"Error at token %@", error ); | 1190 | NSLog(@"Error at token %@", error ); |
... | @@ -1082,7 +1245,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1082,7 +1245,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1082 | }]; | 1245 | }]; |
1083 | } failureBlock:^(NSError *error) { | 1246 | } failureBlock:^(NSError *error) { |
1084 | if (failure) { | 1247 | if (failure) { |
1085 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1248 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1249 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1250 | + | ||
1251 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1252 | + WL_FMDBLogError | ||
1253 | + | ||
1254 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1255 | + | ||
1256 | + } else { | ||
1257 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1258 | + } | ||
1086 | failure(error); | 1259 | failure(error); |
1087 | } | 1260 | } |
1088 | NSLog(@"Error at token %@", error ); | 1261 | NSLog(@"Error at token %@", error ); |
... | @@ -1188,7 +1361,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1188,7 +1361,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1188 | }]; | 1361 | }]; |
1189 | } failureBlock:^(NSError *error) { | 1362 | } failureBlock:^(NSError *error) { |
1190 | if (failure) { | 1363 | if (failure) { |
1191 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1364 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1365 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1366 | + | ||
1367 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1368 | + WL_FMDBLogError | ||
1369 | + | ||
1370 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1371 | + | ||
1372 | + } else { | ||
1373 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1374 | + } | ||
1192 | failure(error); | 1375 | failure(error); |
1193 | } | 1376 | } |
1194 | NSLog(@"Error at token %@", error ); | 1377 | NSLog(@"Error at token %@", error ); |
... | @@ -1229,7 +1412,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1229,7 +1412,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1229 | }]; | 1412 | }]; |
1230 | } failureBlock:^(NSError *error) { | 1413 | } failureBlock:^(NSError *error) { |
1231 | if (failure) { | 1414 | if (failure) { |
1232 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1415 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1416 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1417 | + | ||
1418 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1419 | + WL_FMDBLogError | ||
1420 | + | ||
1421 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1422 | + | ||
1423 | + } else { | ||
1424 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1425 | + } | ||
1233 | failure(error); | 1426 | failure(error); |
1234 | } | 1427 | } |
1235 | NSLog(@"Error at token %@", error ); | 1428 | NSLog(@"Error at token %@", error ); |
... | @@ -1270,7 +1463,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1270,7 +1463,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1270 | }]; | 1463 | }]; |
1271 | } failureBlock:^(NSError *error) { | 1464 | } failureBlock:^(NSError *error) { |
1272 | if (failure) { | 1465 | if (failure) { |
1273 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1466 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1467 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1468 | + | ||
1469 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1470 | + WL_FMDBLogError | ||
1471 | + | ||
1472 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1473 | + | ||
1474 | + } else { | ||
1475 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1476 | + } | ||
1274 | failure(error); | 1477 | failure(error); |
1275 | } | 1478 | } |
1276 | NSLog(@"Error at token %@", error ); | 1479 | NSLog(@"Error at token %@", error ); |
... | @@ -1348,7 +1551,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1348,7 +1551,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1348 | }]; | 1551 | }]; |
1349 | } failureBlock:^(NSError *error) { | 1552 | } failureBlock:^(NSError *error) { |
1350 | if (failure) { | 1553 | if (failure) { |
1351 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1554 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1555 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1556 | + | ||
1557 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1558 | + WL_FMDBLogError | ||
1559 | + | ||
1560 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1561 | + | ||
1562 | + } else { | ||
1563 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1564 | + } | ||
1352 | failure(error); | 1565 | failure(error); |
1353 | } | 1566 | } |
1354 | NSLog(@"Error at token %@", error ); | 1567 | NSLog(@"Error at token %@", error ); |
... | @@ -1385,7 +1598,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1385,7 +1598,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1385 | }]; | 1598 | }]; |
1386 | } failureBlock:^(NSError *error) { | 1599 | } failureBlock:^(NSError *error) { |
1387 | if (failure) { | 1600 | if (failure) { |
1388 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1601 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1602 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1603 | + | ||
1604 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1605 | + WL_FMDBLogError | ||
1606 | + | ||
1607 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1608 | + | ||
1609 | + } else { | ||
1610 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1611 | + } | ||
1389 | failure(error); | 1612 | failure(error); |
1390 | } | 1613 | } |
1391 | NSLog(@"Error at token %@", error ); | 1614 | NSLog(@"Error at token %@", error ); |
... | @@ -1422,7 +1645,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1422,7 +1645,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1422 | }]; | 1645 | }]; |
1423 | } failureBlock:^(NSError *error) { | 1646 | } failureBlock:^(NSError *error) { |
1424 | if (failure) { | 1647 | if (failure) { |
1425 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1648 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1649 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1650 | + | ||
1651 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1652 | + WL_FMDBLogError | ||
1653 | + | ||
1654 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1655 | + | ||
1656 | + } else { | ||
1657 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1658 | + } | ||
1426 | failure(error); | 1659 | failure(error); |
1427 | } | 1660 | } |
1428 | NSLog(@"Error at token %@", error ); | 1661 | NSLog(@"Error at token %@", error ); |
... | @@ -1459,7 +1692,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1459,7 +1692,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1459 | }]; | 1692 | }]; |
1460 | } failureBlock:^(NSError *error) { | 1693 | } failureBlock:^(NSError *error) { |
1461 | if (failure) { | 1694 | if (failure) { |
1462 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1695 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1696 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1697 | + | ||
1698 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1699 | + WL_FMDBLogError | ||
1700 | + | ||
1701 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1702 | + | ||
1703 | + } else { | ||
1704 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1705 | + } | ||
1463 | failure(error); | 1706 | failure(error); |
1464 | } | 1707 | } |
1465 | NSLog(@"Error at token %@", error ); | 1708 | NSLog(@"Error at token %@", error ); |
... | @@ -1496,7 +1739,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1496,7 +1739,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1496 | }]; | 1739 | }]; |
1497 | } failureBlock:^(NSError *error) { | 1740 | } failureBlock:^(NSError *error) { |
1498 | if (failure) { | 1741 | if (failure) { |
1499 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1742 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1743 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1744 | + | ||
1745 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1746 | + WL_FMDBLogError | ||
1747 | + | ||
1748 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1749 | + | ||
1750 | + } else { | ||
1751 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1752 | + } | ||
1500 | failure(error); | 1753 | failure(error); |
1501 | } | 1754 | } |
1502 | NSLog(@"Error at token %@", error ); | 1755 | NSLog(@"Error at token %@", error ); |
... | @@ -1507,6 +1760,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1507,6 +1760,7 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1507 | }]; | 1760 | }]; |
1508 | } | 1761 | } |
1509 | 1762 | ||
1763 | +// TODO: ADD NEW SDK | ||
1510 | - (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure | 1764 | - (void)verifyTicketWithSuccessBlock:(NSString*)guid :(NSString*)ticket :(void(^)(NSDictionary *response))success failureBlock:(void(^)(NSError *error))failure |
1511 | { | 1765 | { |
1512 | NSString* appUuid = [NSString alloc]; | 1766 | NSString* appUuid = [NSString alloc]; |
... | @@ -1524,11 +1778,21 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1524,11 +1778,21 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1524 | accessToken = [tokens objectForKey:@"access_token"]; | 1778 | accessToken = [tokens objectForKey:@"access_token"]; |
1525 | NSString* clientSecret = [NSString alloc]; | 1779 | NSString* clientSecret = [NSString alloc]; |
1526 | clientSecret = [tokens objectForKey:@"client_secret"]; | 1780 | clientSecret = [tokens objectForKey:@"client_secret"]; |
1527 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1781 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1782 | +// [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1783 | +// WL_FMDBLogError | ||
1784 | +// | ||
1785 | +// [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken]; | ||
1786 | + | ||
1787 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1788 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1528 | [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | 1789 | [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; |
1529 | WL_FMDBLogError | 1790 | WL_FMDBLogError |
1530 | 1791 | ||
1531 | - [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken]; | 1792 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, refreshToken, accessToken]; |
1793 | + } else { | ||
1794 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", clientId, clientSecret, refreshToken, accessToken]; | ||
1795 | + } | ||
1532 | 1796 | ||
1533 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 1797 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
1534 | if (success) { | 1798 | if (success) { |
... | @@ -1561,11 +1825,22 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1561,11 +1825,22 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1561 | accessToken = [tokens objectForKey:@"access_token"]; | 1825 | accessToken = [tokens objectForKey:@"access_token"]; |
1562 | NSString* clientSecret = [NSString alloc]; | 1826 | NSString* clientSecret = [NSString alloc]; |
1563 | clientSecret = [tokens objectForKey:@"client_secret"]; | 1827 | clientSecret = [tokens objectForKey:@"client_secret"]; |
1564 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1828 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1829 | +// [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1830 | +// WL_FMDBLogError | ||
1831 | +// | ||
1832 | +// [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken]; | ||
1833 | + | ||
1834 | + // TODO: ADD NEW SDK | ||
1835 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
1836 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1565 | [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | 1837 | [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; |
1566 | WL_FMDBLogError | 1838 | WL_FMDBLogError |
1567 | 1839 | ||
1568 | - [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, access_token, refresh_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, accessToken, refreshToken]; | 1840 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", clientId, clientSecret, refreshToken, accessToken]; |
1841 | + } else { | ||
1842 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", clientId, clientSecret, refreshToken, accessToken]; | ||
1843 | + } | ||
1569 | 1844 | ||
1570 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; | 1845 | NSDictionary *successResponse = @{@"result": @"success", @"status":@1}; |
1571 | if (success) { | 1846 | if (success) { |
... | @@ -1611,7 +1886,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1611,7 +1886,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1611 | }]; | 1886 | }]; |
1612 | } failureBlock:^(NSError *error) { | 1887 | } failureBlock:^(NSError *error) { |
1613 | if (failure) { | 1888 | if (failure) { |
1614 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1889 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1890 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1891 | + | ||
1892 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1893 | + WL_FMDBLogError | ||
1894 | + | ||
1895 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1896 | + | ||
1897 | + } else { | ||
1898 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1899 | + } | ||
1615 | failure(error); | 1900 | failure(error); |
1616 | } | 1901 | } |
1617 | NSLog(@"Error at token %@", error ); | 1902 | NSLog(@"Error at token %@", error ); |
... | @@ -1648,7 +1933,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1648,7 +1933,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1648 | }]; | 1933 | }]; |
1649 | } failureBlock:^(NSError *error) { | 1934 | } failureBlock:^(NSError *error) { |
1650 | if (failure) { | 1935 | if (failure) { |
1651 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1936 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1937 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1938 | + | ||
1939 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1940 | + WL_FMDBLogError | ||
1941 | + | ||
1942 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1943 | + | ||
1944 | + } else { | ||
1945 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1946 | + } | ||
1652 | failure(error); | 1947 | failure(error); |
1653 | } | 1948 | } |
1654 | NSLog(@"Error at token %@", error ); | 1949 | NSLog(@"Error at token %@", error ); |
... | @@ -1685,7 +1980,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1685,7 +1980,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1685 | }]; | 1980 | }]; |
1686 | } failureBlock:^(NSError *error) { | 1981 | } failureBlock:^(NSError *error) { |
1687 | if (failure) { | 1982 | if (failure) { |
1688 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 1983 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
1984 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
1985 | + | ||
1986 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
1987 | + WL_FMDBLogError | ||
1988 | + | ||
1989 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
1990 | + | ||
1991 | + } else { | ||
1992 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
1993 | + } | ||
1689 | failure(error); | 1994 | failure(error); |
1690 | } | 1995 | } |
1691 | NSLog(@"Error at token %@", error ); | 1996 | NSLog(@"Error at token %@", error ); |
... | @@ -1726,7 +2031,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1726,7 +2031,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1726 | }]; | 2031 | }]; |
1727 | } failureBlock:^(NSError *error) { | 2032 | } failureBlock:^(NSError *error) { |
1728 | if (failure) { | 2033 | if (failure) { |
1729 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2034 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2035 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2036 | + | ||
2037 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2038 | + WL_FMDBLogError | ||
2039 | + | ||
2040 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2041 | + | ||
2042 | + } else { | ||
2043 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2044 | + } | ||
1730 | failure(error); | 2045 | failure(error); |
1731 | } | 2046 | } |
1732 | NSLog(@"Error at token %@", error ); | 2047 | NSLog(@"Error at token %@", error ); |
... | @@ -1763,7 +2078,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1763,7 +2078,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1763 | }]; | 2078 | }]; |
1764 | } failureBlock:^(NSError *error) { | 2079 | } failureBlock:^(NSError *error) { |
1765 | if (failure) { | 2080 | if (failure) { |
1766 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2081 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2082 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2083 | + | ||
2084 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2085 | + WL_FMDBLogError | ||
2086 | + | ||
2087 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2088 | + | ||
2089 | + } else { | ||
2090 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2091 | + } | ||
1767 | failure(error); | 2092 | failure(error); |
1768 | } | 2093 | } |
1769 | NSLog(@"Error at token %@", error ); | 2094 | NSLog(@"Error at token %@", error ); |
... | @@ -1800,7 +2125,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1800,7 +2125,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1800 | }]; | 2125 | }]; |
1801 | } failureBlock:^(NSError *error) { | 2126 | } failureBlock:^(NSError *error) { |
1802 | if (failure) { | 2127 | if (failure) { |
1803 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2128 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2129 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2130 | + | ||
2131 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2132 | + WL_FMDBLogError | ||
2133 | + | ||
2134 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2135 | + | ||
2136 | + } else { | ||
2137 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2138 | + } | ||
1804 | failure(error); | 2139 | failure(error); |
1805 | } | 2140 | } |
1806 | NSLog(@"Error at token %@", error ); | 2141 | NSLog(@"Error at token %@", error ); |
... | @@ -1882,7 +2217,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1882,7 +2217,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1882 | }]; | 2217 | }]; |
1883 | } failureBlock:^(NSError *error) { | 2218 | } failureBlock:^(NSError *error) { |
1884 | if (failure) { | 2219 | if (failure) { |
1885 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2220 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2221 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2222 | + | ||
2223 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2224 | + WL_FMDBLogError | ||
2225 | + | ||
2226 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2227 | + | ||
2228 | + } else { | ||
2229 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2230 | + } | ||
1886 | failure(error); | 2231 | failure(error); |
1887 | } | 2232 | } |
1888 | NSLog(@"Error at token %@", error ); | 2233 | NSLog(@"Error at token %@", error ); |
... | @@ -1919,7 +2264,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1919,7 +2264,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1919 | }]; | 2264 | }]; |
1920 | } failureBlock:^(NSError *error) { | 2265 | } failureBlock:^(NSError *error) { |
1921 | if (failure) { | 2266 | if (failure) { |
1922 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2267 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2268 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2269 | + | ||
2270 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2271 | + WL_FMDBLogError | ||
2272 | + | ||
2273 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2274 | + | ||
2275 | + } else { | ||
2276 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2277 | + } | ||
1923 | failure(error); | 2278 | failure(error); |
1924 | } | 2279 | } |
1925 | NSLog(@"Error at token %@", error ); | 2280 | NSLog(@"Error at token %@", error ); |
... | @@ -1956,7 +2311,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -1956,7 +2311,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
1956 | }]; | 2311 | }]; |
1957 | } failureBlock:^(NSError *error) { | 2312 | } failureBlock:^(NSError *error) { |
1958 | if (failure) { | 2313 | if (failure) { |
1959 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2314 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2315 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2316 | + | ||
2317 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2318 | + WL_FMDBLogError | ||
2319 | + | ||
2320 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2321 | + | ||
2322 | + } else { | ||
2323 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2324 | + } | ||
1960 | failure(error); | 2325 | failure(error); |
1961 | } | 2326 | } |
1962 | NSLog(@"Error at token %@", error ); | 2327 | NSLog(@"Error at token %@", error ); |
... | @@ -2168,7 +2533,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2168,7 +2533,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2168 | }]; | 2533 | }]; |
2169 | } failureBlock:^(NSError *error) { | 2534 | } failureBlock:^(NSError *error) { |
2170 | if (failure) { | 2535 | if (failure) { |
2171 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2536 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2537 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2538 | + | ||
2539 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2540 | + WL_FMDBLogError | ||
2541 | + | ||
2542 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2543 | + | ||
2544 | + } else { | ||
2545 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2546 | + } | ||
2172 | failure(error); | 2547 | failure(error); |
2173 | } | 2548 | } |
2174 | NSLog(@"Error at token %@", error ); | 2549 | NSLog(@"Error at token %@", error ); |
... | @@ -2228,7 +2603,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2228,7 +2603,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2228 | }]; | 2603 | }]; |
2229 | } failureBlock:^(NSError *error) { | 2604 | } failureBlock:^(NSError *error) { |
2230 | if (failure) { | 2605 | if (failure) { |
2231 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2606 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2607 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2608 | + | ||
2609 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2610 | + WL_FMDBLogError | ||
2611 | + | ||
2612 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2613 | + | ||
2614 | + } else { | ||
2615 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2616 | + } | ||
2232 | failure(error); | 2617 | failure(error); |
2233 | } | 2618 | } |
2234 | NSLog(@"Error at token %@", error ); | 2619 | NSLog(@"Error at token %@", error ); |
... | @@ -2269,7 +2654,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2269,7 +2654,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2269 | }]; | 2654 | }]; |
2270 | } failureBlock:^(NSError *error) { | 2655 | } failureBlock:^(NSError *error) { |
2271 | if (failure) { | 2656 | if (failure) { |
2272 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2657 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2658 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2659 | + | ||
2660 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2661 | + WL_FMDBLogError | ||
2662 | + | ||
2663 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2664 | + | ||
2665 | + } else { | ||
2666 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2667 | + } | ||
2273 | failure(error); | 2668 | failure(error); |
2274 | } | 2669 | } |
2275 | NSLog(@"Error at token %@", error ); | 2670 | NSLog(@"Error at token %@", error ); |
... | @@ -2310,7 +2705,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2310,7 +2705,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2310 | }]; | 2705 | }]; |
2311 | } failureBlock:^(NSError *error) { | 2706 | } failureBlock:^(NSError *error) { |
2312 | if (failure) { | 2707 | if (failure) { |
2313 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2708 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2709 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2710 | + | ||
2711 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2712 | + WL_FMDBLogError | ||
2713 | + | ||
2714 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2715 | + | ||
2716 | + } else { | ||
2717 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2718 | + } | ||
2314 | failure(error); | 2719 | failure(error); |
2315 | } | 2720 | } |
2316 | NSLog(@"Error at token %@", error ); | 2721 | NSLog(@"Error at token %@", error ); |
... | @@ -2351,7 +2756,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2351,7 +2756,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2351 | }]; | 2756 | }]; |
2352 | } failureBlock:^(NSError *error) { | 2757 | } failureBlock:^(NSError *error) { |
2353 | if (failure) { | 2758 | if (failure) { |
2354 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2759 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2760 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2761 | + | ||
2762 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2763 | + WL_FMDBLogError | ||
2764 | + | ||
2765 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2766 | + | ||
2767 | + } else { | ||
2768 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2769 | + } | ||
2355 | failure(error); | 2770 | failure(error); |
2356 | } | 2771 | } |
2357 | NSLog(@"Error at token %@", error ); | 2772 | NSLog(@"Error at token %@", error ); |
... | @@ -2411,7 +2826,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2411,7 +2826,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2411 | }]; | 2826 | }]; |
2412 | } failureBlock:^(NSError *error) { | 2827 | } failureBlock:^(NSError *error) { |
2413 | if (failure) { | 2828 | if (failure) { |
2414 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2829 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2830 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2831 | + | ||
2832 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2833 | + WL_FMDBLogError | ||
2834 | + | ||
2835 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2836 | + | ||
2837 | + } else { | ||
2838 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2839 | + } | ||
2415 | failure(error); | 2840 | failure(error); |
2416 | } | 2841 | } |
2417 | NSLog(@"Error at token %@", error ); | 2842 | NSLog(@"Error at token %@", error ); |
... | @@ -2448,7 +2873,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) | ... | @@ -2448,7 +2873,17 @@ WL_VERSION_IMPLEMENTATION(WL_VERSION) |
2448 | }]; | 2873 | }]; |
2449 | } failureBlock:^(NSError *error) { | 2874 | } failureBlock:^(NSError *error) { |
2450 | if (failure) { | 2875 | if (failure) { |
2451 | - [_db executeUpdate:@"DROP TABLE requestVariables"]; | 2876 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; |
2877 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
2878 | + | ||
2879 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
2880 | + WL_FMDBLogError | ||
2881 | + | ||
2882 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
2883 | + | ||
2884 | + } else { | ||
2885 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
2886 | + } | ||
2452 | failure(error); | 2887 | failure(error); |
2453 | } | 2888 | } |
2454 | NSLog(@"Error at token %@", error ); | 2889 | NSLog(@"Error at token %@", error ); |
... | @@ -5698,6 +6133,18 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) | ... | @@ -5698,6 +6133,18 @@ CGFloat DistanceBetweenTwoPoints(CGPoint point1,CGPoint point2) |
5698 | [_db executeUpdate:@"CREATE TABLE pois (id INTEGER PRIMARY KEY NOT NULL UNIQUE, lat NUMERIC, lon NUMERIC, radius NUMERIC)"]; | 6133 | [_db executeUpdate:@"CREATE TABLE pois (id INTEGER PRIMARY KEY NOT NULL UNIQUE, lat NUMERIC, lon NUMERIC, radius NUMERIC)"]; |
5699 | } | 6134 | } |
5700 | 6135 | ||
6136 | + // TODO: ADD NEW SDK | ||
6137 | +// [_db executeUpdate:@"DROP TABLE requestVariables"]; | ||
6138 | + if ([_db tableExists:@"requestVariables"] == NO) { | ||
6139 | + [_db executeUpdate:@"CREATE TABLE requestVariables (id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL UNIQUE, client_id INTEGER, client_secret VARCHAR(255), access_token VARCHAR(255), refresh_token VARCHAR(255))"]; | ||
6140 | + WL_FMDBLogError | ||
6141 | + | ||
6142 | + [_db executeUpdate:@"INSERT INTO requestVariables (id, client_id, client_secret, refresh_token, access_token) VALUES (1, ?, ?, ?, ?)", @0, @"", @"", @""]; | ||
6143 | + | ||
6144 | + } else { | ||
6145 | + [_db executeUpdate:@"UPDATE requestVariables SET client_id = ? , client_secret = ?, refresh_token = ?, access_token = ? WHERE id = 1", @0, @"", @"", @""]; | ||
6146 | + } | ||
6147 | + | ||
5701 | [_db makeFunctionNamed:@"DISTANCE" maximumArguments:4 withBlock:^(sqlite3_context *context, int argc, sqlite3_value **argv) { | 6148 | [_db makeFunctionNamed:@"DISTANCE" maximumArguments:4 withBlock:^(sqlite3_context *context, int argc, sqlite3_value **argv) { |
5702 | distanceFunc(context, argc, argv); | 6149 | distanceFunc(context, argc, argv); |
5703 | }]; | 6150 | }]; | ... | ... |
-
Please register or login to post a comment