refactor: Convert from Macro to static constants and use HTTPS as default protocol

Resolves: https://gitlab.steamware.net/eqn/eqn.ios/-/issues/17
This commit is contained in:
Andrea Busi
2020-10-03 15:28:48 +02:00
parent ce387912f8
commit bad1ce5879
3 changed files with 31 additions and 33 deletions
+19 -21
View File
@@ -36,33 +36,31 @@ static NSString * const EQNServerUrlOfferTimeRemaining = @"https://srv.earthquak
static NSString * const EQNServerUrlAvailableSubscriptionsCounter = @"https://srv.earthquakenetwork.it/distquake_count_top_redis.php";
/// Carica le impostazioni delle notifiche definite dall'utente
static NSString * const EQNServerUrlUploadSettings = @"https://srv.earthquakenetwork.it/distquake_upload_settings_ios.php";
// URL registrazione server
static NSString * const EQNServerUrlRegistration = @"https://srv.earthquakenetwork.it/distquake_upload_gcm_regid2.php";
// URL posizione server
static NSString * const EQNServerUrlUserLocation = @"https://srv.earthquakenetwork.it/distquake_upload_gcm_latlon.php";
static NSString * const EQNServerUrlCalibration = @"https://srv.earthquakenetwork.it/distquake_upload4.php";
// download rete smartphone
static NSString * const EQNServerUrlDownloadSmartphoneNetwork = @"https://srv.earthquakenetwork.it/distquake_count_redis.php";
// download grafico smartphone
static NSString * const EQNServerUrlDownloadUserGraph = @"https://srv.earthquakenetwork.it/distquake_download_users.php";
// download area check
static NSString * const EQNServerUrlDownloadAreaCheck = @"https://srv.earthquakenetwork.it/distquake_download_areacheck.php";
// download pastquakes
static NSString * const EQNServerUrlDownloadPastQuakes = @"https://srv.earthquakenetwork.it/distquake_download_pastquakes.php";
// download segnalazioni
static NSString * const EQNServerUrlDownloadUserReports = @"https://srv.earthquakenetwork.it/distquake_download_manual.php";
// Invio segnalazione
static NSString * const EQNServerUrlSendUserReport = @"https://srv.earthquakenetwork.it/distquake_upload_manual3.php";
static NSString * const EQNServerUrlSendUserReportMessage = @"https://srv.earthquakenetwork.it/distquake_upload_manual_message.php";
#pragma mark - UserDefaults Keys
static NSString * const EQNUserDefaultKeySesmicInformations = @"EQNetwork.SeismicInformations";
static NSString * const EQNUserDefaultKeyOneShotShowCountry = @"EQNetwork.OneShot.CountrySelection";
// URL registrazione server
#define URL_SERVER_REGISTRAZIONE @"http://srv.earthquakenetwork.it/distquake_upload_gcm_regid2.php"
// URL posizione server
#define URL_SERVER_POSIZIONE @"http://srv.earthquakenetwork.it/distquake_upload_gcm_latlon.php"
#define URL_SERVER_CAL_RIL @"http://srv.earthquakenetwork.it/distquake_upload4.php"
// download rete smartphone
#define URL_SERVER_DOWNLOAD @"http://srv.earthquakenetwork.it/distquake_count_redis.php"
// download grafico smartphone
#define URL_SERVER_GEAFICO_UTENTI @"http://srv.earthquakenetwork.it/distquake_download_users.php"
// download area check
#define URL_SERVER_AREA_CHECK @"http://srv.earthquakenetwork.it/distquake_download_areacheck.php"
// download pastquakes
#define URL_SERVER_PAST_QUAKES @"http://srv.earthquakenetwork.it/distquake_download_pastquakes.php"
// download segnalazioni
#define URL_SERVER_DOWNLOAD_SEGNALAZIONI_UTENTE @"http://srv.earthquakenetwork.it/distquake_download_manual.php"
// Invio segnalazione
#define URL_SERVER_UPLOAD_SEGNALAZIONI_UTENTE @"http://srv.earthquakenetwork.it/distquake_upload_manual3.php"
#define URL_SERVER_UPLOAD_SEGNALAZIONI_COMMENTO_UTENTE @"http://srv.earthquakenetwork.it/distquake_upload_manual_message.php"
#define TEMPO_INVIO_MESSAGGIO 5
#define TEMPO_INVIO_COMMENTO 30
@@ -20,7 +20,7 @@
+(NSURL *)urlDownloadDati{
NSString *stringUrl = [NSString stringWithFormat:@"%@",URL_SERVER_DOWNLOAD];
NSString *stringUrl = [NSString stringWithFormat:@"%@",EQNServerUrlDownloadSmartphoneNetwork];
return [NSURL URLWithString:stringUrl];
}
@@ -32,14 +32,14 @@
NSLog(@"Utente registrato");
}
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&r_id=%@&lat=%f&lon=%f&ios=1",URL_SERVER_REGISTRAZIONE, primaRegistrazione, [EQNUser defaultUser].tokenUser, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude ];
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&r_id=%@&lat=%f&lon=%f&ios=1", EQNServerUrlRegistration, primaRegistrazione, [EQNUser defaultUser].tokenUser, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude ];
return [NSURL URLWithString:stringUrl];
}
+(NSURL *)urlPosizione{
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&lat=%f&lon=%f",URL_SERVER_POSIZIONE, [EQNUser defaultUser].user_ID, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude ];
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&lat=%f&lon=%f", EQNServerUrlUserLocation, [EQNUser defaultUser].user_ID, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude ];
return [NSURL URLWithString:stringUrl];
}
@@ -79,7 +79,7 @@
NSString *ver = [self ottieniVersioneComeIntero];
NSString *os = @"1";
NSString *stringUrl = [NSString stringWithFormat:@"%@?e_t=%@&u_id=%@&lat=%@&lon=%@&acc=%@&a_max=%@&d_not=%@&cal=%@&ch=%@&s_on=%@&tru=%@&upd=%@&ver=%@&os=%@", URL_SERVER_CAL_RIL,e_t,u_id,lat,lon,acc,a_max,d_not,calib,ch,s_on,tru,upd,ver,os];
NSString *stringUrl = [NSString stringWithFormat:@"%@?e_t=%@&u_id=%@&lat=%@&lon=%@&acc=%@&a_max=%@&d_not=%@&cal=%@&ch=%@&s_on=%@&tru=%@&upd=%@&ver=%@&os=%@", EQNServerUrlCalibration,e_t,u_id,lat,lon,acc,a_max,d_not,calib,ch,s_on,tru,upd,ver,os];
return [NSURL URLWithString:stringUrl];
}
@@ -101,7 +101,7 @@
NSDateFormatter *formatOre = [[NSDateFormatter alloc] init];
[formatOre setDateFormat:@"HH"];
NSString *ora = [formatOre stringFromDate:date];
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&lat=%@&lon=%@&mag=%ld&address=%@&hod=%@", URL_SERVER_UPLOAD_SEGNALAZIONI_UTENTE, [EQNUser defaultUser].user_ID, lat, lon, (long)magnitudo, address, ora];
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&lat=%@&lon=%@&mag=%ld&address=%@&hod=%@", EQNServerUrlSendUserReport, [EQNUser defaultUser].user_ID, lat, lon, (long)magnitudo, address, ora];
NSURL *url = [NSURL URLWithString:stringUrl];
if (url) {
@@ -109,7 +109,7 @@
}
else{
stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&lat=%@&lon=%@&mag=%ld&hod=%@", URL_SERVER_UPLOAD_SEGNALAZIONI_UTENTE, [EQNUser defaultUser].user_ID, lat, lon, (long)magnitudo, ora];
stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&lat=%@&lon=%@&mag=%ld&hod=%@", EQNServerUrlSendUserReport, [EQNUser defaultUser].user_ID, lat, lon, (long)magnitudo, ora];
return [NSURL URLWithString:stringUrl];
}
@@ -122,7 +122,7 @@
NSString* commentEscaped = [commento stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLHostAllowedCharacterSet ]];
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&e_code=%@&message=%@", URL_SERVER_UPLOAD_SEGNALAZIONI_COMMENTO_UTENTE, [EQNUser defaultUser].user_ID, codeEscaped, commentEscaped];
NSString *stringUrl = [NSString stringWithFormat:@"%@?u_id=%@&e_code=%@&message=%@", EQNServerUrlSendUserReportMessage, [EQNUser defaultUser].user_ID, codeEscaped, commentEscaped];
return [NSURL URLWithString: stringUrl];
@@ -46,7 +46,7 @@
- (void)scaricaDatiReteSmartphone
{
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:URL_SERVER_DOWNLOAD] richiesta:downloadDati success:^(id result) {
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadSmartphoneNetwork] richiesta:downloadDati success:^(id result) {
self.rete_smartphone = [[EQNReteSmartphone alloc] initWithInfo:result];
@@ -58,7 +58,7 @@
- (void)scaricaDatiGrafico
{
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:URL_SERVER_GEAFICO_UTENTI] richiesta:graficoSmartPhone success:^(id result) {
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadUserGraph] richiesta:graficoSmartPhone success:^(id result) {
NSMutableArray *arryTemp = [NSMutableArray array];
for (NSDictionary *dic in result) {
@@ -75,7 +75,7 @@
- (void)scaricaAreaCheck
{
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?lat=%f&lon=%f", URL_SERVER_AREA_CHECK, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude]] richiesta:areaCheck success:^(id result) {
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?lat=%f&lon=%f", EQNServerUrlDownloadAreaCheck, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude]] richiesta:areaCheck success:^(id result) {
self.area_check = [[EQNAreaCheck alloc] initWithInfo:result];
@@ -89,7 +89,7 @@
- (void)scaricaPastquakes
{
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:URL_SERVER_PAST_QUAKES] richiesta:pastquakes success:^(id result) {
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadPastQuakes] richiesta:pastquakes success:^(id result) {
NSMutableArray *arryTemp = [NSMutableArray array];
for (NSDictionary *dic in result) {
@@ -105,7 +105,7 @@
- (void)scaricaSegnalazioniManuali
{
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:URL_SERVER_DOWNLOAD_SEGNALAZIONI_UTENTE] richiesta:segnalazioneManuale success:^(id result) {
[[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadUserReports] richiesta:segnalazioneManuale success:^(id result) {
NSMutableArray *array = [NSMutableArray array];
NSArray *tempArray = (NSArray *)result;