diff --git a/Sources/Earthquake Network/AppDelegate.m b/Sources/Earthquake Network/AppDelegate.m index 0e609c2..1339bcf 100644 --- a/Sources/Earthquake Network/AppDelegate.m +++ b/Sources/Earthquake Network/AppDelegate.m @@ -137,7 +137,7 @@ - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { NSURL *url = [EQNGeneratoreURLServer urlPosizione]; - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:posizione success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:EQNTipoChiamataPosizione success:^(id result) { completionHandler(UIBackgroundFetchResultNewData); } failure:^(NSError *error) { completionHandler(UIBackgroundFetchResultFailed); diff --git a/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m b/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m index 15542f8..9677c46 100644 --- a/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m +++ b/Sources/Earthquake Network/Controllers/Alerts/AllerteViewController.m @@ -222,7 +222,7 @@ typedef NS_ENUM(NSInteger, AllerteTableRow) { } NSURL *url = [EQNGeneratoreURLServer urlAlertPushTest]; - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:alertPushTest success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:EQNTipoChiamataAlertPushTest success:^(id result) { // nope } failure:^(NSError *error) { dispatch_async(dispatch_get_main_queue(), ^{ diff --git a/Sources/Earthquake Network/Controllers/Reports/SegnalazioniViewController.m b/Sources/Earthquake Network/Controllers/Reports/SegnalazioniViewController.m index 701ee87..e199bb8 100644 --- a/Sources/Earthquake Network/Controllers/Reports/SegnalazioniViewController.m +++ b/Sources/Earthquake Network/Controllers/Reports/SegnalazioniViewController.m @@ -178,7 +178,7 @@ static NSString * const SegueIdentifierMap = @"ShowMap"; NSURL *url = [EQNGeneratoreURLServer urlInvioMessagioTerremoto:magnitude withAdress:address]; - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:segnalazzioneTerremoto success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:EQNTipoChiamataSegnalazioneTerremoto success:^(id result) { [self.userDefoult setObject:result forKey:CODE_MESSAGE_EQN]; [self.userDefoult setObject:[NSDate date] forKey:DATA_MESSAGE_EQN]; @@ -212,7 +212,7 @@ static NSString * const SegueIdentifierMap = @"ShowMap"; UITextField * messaggio = alertController.textFields.firstObject; NSURL *url = [EQNGeneratoreURLServer urlInvioCommentoTerremoto:messaggio.text codeMessage:[self.userDefoult objectForKey:CODE_MESSAGE_EQN]]; - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:commentoTerremoto success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:EQNTipoChiamataCommentoTerremoto success:^(id result) { dispatch_async(dispatch_get_main_queue(), ^{ UIAlertController *alert = [UIAlertController alertControllerWithTitle:NSLocalizedString(@"Messaggio" , @"") diff --git a/Sources/Earthquake Network/Controllers/Settings/SettingsBaseViewController.m b/Sources/Earthquake Network/Controllers/Settings/SettingsBaseViewController.m index 097a4bc..d3d16e3 100644 --- a/Sources/Earthquake Network/Controllers/Settings/SettingsBaseViewController.m +++ b/Sources/Earthquake Network/Controllers/Settings/SettingsBaseViewController.m @@ -32,7 +32,7 @@ + (void)saveSettings { - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlInvioImpostazioniNotifiche] richiesta:impostazioniNotifiche success:^(id result){ + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlInvioImpostazioniNotifiche] richiesta:EQNTipoChiamataImpostazioniNotifiche success:^(id result){ NSLog(@"Settings saved successfully"); } failure:^(NSError *error){ NSLog(@"Settings saved failed. Error: %@", error.localizedDescription); diff --git a/Sources/Earthquake Network/Costanti.h b/Sources/Earthquake Network/Costanti.h index f47bc8a..b111c4d 100644 --- a/Sources/Earthquake Network/Costanti.h +++ b/Sources/Earthquake Network/Costanti.h @@ -125,24 +125,25 @@ typedef enum : NSInteger { #define MESSAGGIO @"MESSAGGIO_ERRORE" -typedef enum : NSInteger { - registrazione = 0, - posizione, - calibrazione, - rilevamento, - downloadDati, - areaCheck, - pastquakes, - utentiDisponibili, - tempoDisponibile, - segnalazioneManuale, - tsunami, - segnalazzioneTerremoto, - commentoTerremoto, - impostazioniNotifiche, - offerTimeRemaining, - alertPushTest -} EQNTipoChiamata; +/// Sections inside the app +typedef NS_ENUM(NSInteger, EQNTipoChiamata) { + EQNTipoChiamataRegistrazione = 0, + EQNTipoChiamataPosizione, + EQNTipoChiamataCalibrazione, + EQNTipoChiamataRilevamento, + EQNTipoChiamataDownloadDati, + EQNTipoChiamataAreaCheck, + EQNTipoChiamataPastquakes, + EQNTipoChiamataUtentiDisponibili, + EQNTipoChiamataTempoDisponibile, + EQNTipoChiamataSegnalazioneManuale, + EQNTipoChiamataTsunami, + EQNTipoChiamataSegnalazioneTerremoto, + EQNTipoChiamataCommentoTerremoto, + EQNTipoChiamataImpostazioniNotifiche, + EQNTipoChiamataOfferTimeRemaining, + EQNTipoChiamataAlertPushTest +}; // chiavi rMax e rMin diff --git a/Sources/Earthquake Network/ServerRequest.m b/Sources/Earthquake Network/ServerRequest.m index e627468..4022fce 100644 --- a/Sources/Earthquake Network/ServerRequest.m +++ b/Sources/Earthquake Network/ServerRequest.m @@ -109,7 +109,7 @@ switch (httpResp.statusCode) { case 200: switch (chiamata) { - case posizione: + case EQNTipoChiamataPosizione: onSuccess(@"success"); break; default: @@ -128,16 +128,16 @@ } switch (chiamata) { - case segnalazzioneTerremoto: + case EQNTipoChiamataSegnalazioneTerremoto: onSuccess([EQNUtility clearStringMessaggi:newStr]); break; - case rilevamento: + case EQNTipoChiamataRilevamento: onSuccess([EQNUtility clearStringMessaggi:newStr]); break; - case calibrazione: + case EQNTipoChiamataCalibrazione: onSuccess(newStr); break; - case impostazioniNotifiche: + case EQNTipoChiamataImpostazioniNotifiche: onSuccess(newStr); default: // don't call the callback diff --git a/Sources/Earthquake Network/model/EQNManager.m b/Sources/Earthquake Network/model/EQNManager.m index e7051be..8d21bc7 100644 --- a/Sources/Earthquake Network/model/EQNManager.m +++ b/Sources/Earthquake Network/model/EQNManager.m @@ -62,7 +62,7 @@ - (void)scaricaDatiReteSmartphone { - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadSmartphoneNetwork] richiesta:downloadDati success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadSmartphoneNetwork] richiesta:EQNTipoChiamataDownloadDati success:^(id result) { self.rete_smartphone = [[EQNReteSmartphone alloc] initWithInfo:result]; @@ -74,7 +74,7 @@ - (void)scaricaAreaCheck { - [[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) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?lat=%f&lon=%f", EQNServerUrlDownloadAreaCheck, [EQNUser defaultUser].lastPosition.coordinate.latitude, [EQNUser defaultUser].lastPosition.coordinate.longitude]] richiesta:EQNTipoChiamataAreaCheck success:^(id result) { self.area_check = [[EQNAreaCheck alloc] initWithInfo:result]; @@ -87,7 +87,7 @@ - (void)scaricaPastquakes { - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadPastQuakes] richiesta:pastquakes success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadPastQuakes] richiesta:EQNTipoChiamataPastquakes success:^(id result) { NSMutableArray *arryTemp = [NSMutableArray array]; for (NSDictionary *dic in result) { @@ -103,7 +103,7 @@ - (void)scaricaSegnalazioniManuali { - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadUserReports] richiesta:segnalazioneManuale success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[NSURL URLWithString:EQNServerUrlDownloadUserReports] richiesta:EQNTipoChiamataSegnalazioneManuale success:^(id result) { NSMutableArray *array = [NSMutableArray array]; NSArray *tempArray = (NSArray *)result; @@ -147,7 +147,7 @@ NSURL *url = [NSURL URLWithString:urlString]; NSLog(@"[EQNManager] Url utilizzato per download reti sismiche: %@", url.absoluteURL); - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:downloadDati success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:EQNTipoChiamataDownloadDati success:^(id result) { NSMutableArray *array = [NSMutableArray array]; for (NSDictionary *dic in result) { @@ -345,10 +345,10 @@ - (void)iniviaMessaggioAlServer:(EQNRilevamento *)anRilevamento { - EQNTipoChiamata tipo = calibrazione; + EQNTipoChiamata tipo = EQNTipoChiamataCalibrazione; EQNCalibrazione *anCalibrazione = [self.calibrazione copy]; if (anRilevamento.rilievo == positivo){ - tipo = rilevamento; + tipo = EQNTipoChiamataRilevamento; [self annullaCalibrazione]; } diff --git a/Sources/Earthquake Network/model/EQNUser.m b/Sources/Earthquake Network/model/EQNUser.m index 9529266..750ec72 100644 --- a/Sources/Earthquake Network/model/EQNUser.m +++ b/Sources/Earthquake Network/model/EQNUser.m @@ -105,7 +105,7 @@ - (void)inviaregistrazioneServer:(NSString *)token withPosition:(CLLocation *)location { - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlRegistrazione] richiesta:registrazione success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlRegistrazione] richiesta:EQNTipoChiamataRegistrazione success:^(id result) { self.user_ID = [self convertUserIdIntoString:result]; [self saveUserInfo]; @@ -119,7 +119,7 @@ { NSLog(@"URLPosizione %@", [EQNGeneratoreURLServer urlPosizione]); - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlPosizione] richiesta:posizione success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:[EQNGeneratoreURLServer urlPosizione] richiesta:EQNTipoChiamataPosizione success:^(id result) { NSLog(@"inviato"); @@ -131,7 +131,7 @@ - (void)downloadOfferTimeRemainingWithCompletion:(_Nonnull timeRemainingCompletion)completionHandler { NSURL *url = [EQNGeneratoreURLServer urlDownloadOfferTimeRemaining]; - [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:offerTimeRemaining success:^(id result) { + [[ServerRequest defaultServerConnectionSingleton] inviaInformazioniAlServerWithURL:url richiesta:EQNTipoChiamataOfferTimeRemaining success:^(id result) { NSInteger timeRemaining = 0; if ([result isKindOfClass:[NSNumber class]]) { NSNumber *timeRemainingNumber = (NSNumber *)result;