diff --git a/OwnTracks/OwnTracks/Base.lproj/Launch Screen.xib b/OwnTracks/OwnTracks/Base.lproj/Launch Screen.xib index 3dfb94c8..1f61e102 100644 --- a/OwnTracks/OwnTracks/Base.lproj/Launch Screen.xib +++ b/OwnTracks/OwnTracks/Base.lproj/Launch Screen.xib @@ -1,7 +1,7 @@ - + - + @@ -30,8 +30,8 @@ - - + @@ -385,7 +385,7 @@ @@ -419,9 +419,39 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -451,36 +481,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -494,19 +494,31 @@ - + + + + + + + + + + + - + + + @@ -1387,8 +1399,9 @@ - + + @@ -1437,7 +1450,7 @@ - + @@ -1459,7 +1472,7 @@ - + @@ -1477,20 +1490,6 @@ - - @@ -1566,7 +1565,7 @@ xyz - + @@ -1625,14 +1624,14 @@ xyz - + - + @@ -1664,14 +1663,14 @@ xyz - + - + @@ -1897,7 +1896,7 @@ xyz - + @@ -1920,7 +1919,7 @@ xyz - + @@ -2190,7 +2189,7 @@ xyz - + @@ -2473,7 +2472,7 @@ xyz - + @@ -2509,7 +2508,7 @@ xyz - + @@ -2617,7 +2616,7 @@ Cg - + @@ -2708,7 +2707,7 @@ libsodium (libsodium.org) - + @@ -2727,7 +2726,7 @@ libsodium (libsodium.org) - + @@ -3000,7 +2999,7 @@ libsodium (libsodium.org) - + @@ -3019,7 +3018,7 @@ libsodium (libsodium.org) - + @@ -3080,7 +3079,7 @@ libsodium (libsodium.org) - + @@ -3099,7 +3098,7 @@ libsodium (libsodium.org) - + @@ -3180,22 +3179,22 @@ Detailed info on http://owntracks.org/booklet - + - - + + - + - + diff --git a/OwnTracks/OwnTracks/Connection.h b/OwnTracks/OwnTracks/Connection.h index 0d7fddf3..b70f08d5 100644 --- a/OwnTracks/OwnTracks/Connection.h +++ b/OwnTracks/OwnTracks/Connection.h @@ -58,7 +58,11 @@ enum state { securityPolicy:(MQTTSSLSecurityPolicy *)securityPolicy certificates:(NSArray *)certificates; -- (void)connectHTTP:(NSString *)url auth:(BOOL)auth user:(NSString *)user pass:(NSString *)pass; +- (void)connectHTTP:(NSString *)url + auth:(BOOL)auth + user:(NSString *)user + pass:(NSString *)pass + device:(NSString *)device; - (void)connectToLast; diff --git a/OwnTracks/OwnTracks/Connection.m b/OwnTracks/OwnTracks/Connection.m index 6936ceb8..82929850 100644 --- a/OwnTracks/OwnTracks/Connection.m +++ b/OwnTracks/OwnTracks/Connection.m @@ -49,6 +49,7 @@ @interface Connection() @property (nonatomic) NSInteger willQos; @property (nonatomic) BOOL willRetainFlag; @property (strong, nonatomic) NSString *clientId; +@property (strong, nonatomic) NSString *device; @property (strong, nonatomic) MQTTSSLSecurityPolicy *securityPolicy; @property (strong, nonatomic) NSArray *certificates; @@ -336,11 +337,16 @@ - (void)URLSession:(NSURLSession *)session } -- (void)connectHTTP:(NSString *)url auth:(BOOL)auth user:(NSString *)user pass:(NSString *)pass { +- (void)connectHTTP:(NSString *)url + auth:(BOOL)auth + user:(NSString *)user + pass:(NSString *)pass + device:(NSString *)device { self.url = url; self.auth = auth; - self.user = auth ? user : nil; - self.pass = auth ? pass : nil; + self.user = user; + self.pass = pass; + self.device = device; self.reconnectTime = RECONNECT_TIMER; self.reconnectFlag = FALSE; self.state = state_starting; @@ -430,6 +436,17 @@ - (void)sendHTTP:(NSString *)topic data:(NSData *)data { NSString *authValue = [authData base64EncodedStringWithOptions:0]; [request setValue:[NSString stringWithFormat:@"Basic %@", authValue] forHTTPHeaderField:@"Authorization"]; } + NSString *user = @"user"; + if (self.user && self.user.length > 0) { + user = self.user; + } + [request setValue:user forHTTPHeaderField:@"X-Limit-U"]; + + NSString *device = @"device"; + if (self.device && self.device.length > 0) { + device = self.device; + } + [request setValue:device forHTTPHeaderField:@"X-Limit-D"]; request.URL = [NSURL URLWithString:self.url]; request.HTTPMethod = @"POST"; diff --git a/OwnTracks/OwnTracks/HTTP.plist b/OwnTracks/OwnTracks/HTTP.plist index a62b9727..5792d0c2 100644 --- a/OwnTracks/OwnTracks/HTTP.plist +++ b/OwnTracks/OwnTracks/HTTP.plist @@ -18,6 +18,8 @@ user pass_preference pass + usepassword_preference + monitoring_preference 1 ranging_preference diff --git a/OwnTracks/OwnTracks/MQTT.plist b/OwnTracks/OwnTracks/MQTT.plist index 6d07b964..4db02462 100644 --- a/OwnTracks/OwnTracks/MQTT.plist +++ b/OwnTracks/OwnTracks/MQTT.plist @@ -34,6 +34,8 @@ user pass_preference pass + usepassword_preference + keepalive_preference 60 clean_preference diff --git a/OwnTracks/OwnTracks/OwnTracks-Info.plist b/OwnTracks/OwnTracks/OwnTracks-Info.plist index d53f1537..51a961af 100644 --- a/OwnTracks/OwnTracks/OwnTracks-Info.plist +++ b/OwnTracks/OwnTracks/OwnTracks-Info.plist @@ -96,7 +96,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 12.0.1 + 12.0.2 CFBundleSignature ???? CFBundleURLTypes @@ -115,7 +115,7 @@ CFBundleVersion - 12.0.1 + 12.0.2 ITSAppUsesNonExemptEncryption LSRequiresIPhoneOS diff --git a/OwnTracks/OwnTracks/OwnTracksAppDelegate.m b/OwnTracks/OwnTracks/OwnTracksAppDelegate.m index a7577095..2d268104 100644 --- a/OwnTracks/OwnTracks/OwnTracksAppDelegate.m +++ b/OwnTracks/OwnTracks/OwnTracksAppDelegate.m @@ -1134,6 +1134,11 @@ - (void)sendRegion:(Region *)region { #pragma internal helpers - (void)connect { + BOOL usePassword = [Settings theMqttUsePasswordInMOC:CoreData.sharedInstance.mainMOC]; + NSString *password = nil; + if (usePassword) { + password = [Settings theMqttPassInMOC:CoreData.sharedInstance.mainMOC]; + } if ([Settings intForKey:@"mode" inMOC:CoreData.sharedInstance.mainMOC] == CONNECTION_MODE_HTTP) { self.connection.key = [Settings stringForKey:@"secret_preference" inMOC:CoreData.sharedInstance.mainMOC]; @@ -1141,7 +1146,8 @@ - (void)connect { inMOC:CoreData.sharedInstance.mainMOC] auth:[Settings theMqttAuthInMOC:CoreData.sharedInstance.mainMOC] user:[Settings theMqttUserInMOC:CoreData.sharedInstance.mainMOC] - pass:[Settings theMqttPassInMOC:CoreData.sharedInstance.mainMOC]]; + pass:password + device:[Settings theDeviceIdInMOC:CoreData.sharedInstance.mainMOC]]; } else { NSURL *directoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory @@ -1233,7 +1239,7 @@ - (void)connect { clean:[Settings intForKey:@"clean_preference" inMOC:CoreData.sharedInstance.mainMOC] auth:[Settings theMqttAuthInMOC:CoreData.sharedInstance.mainMOC] user:[Settings theMqttUserInMOC:CoreData.sharedInstance.mainMOC] - pass:[Settings theMqttPassInMOC:CoreData.sharedInstance.mainMOC] + pass:password willTopic:[Settings theWillTopicInMOC:CoreData.sharedInstance.mainMOC] will:[self jsonToData:json] willQos:[Settings intForKey:@"willqos_preference" inMOC:CoreData.sharedInstance.mainMOC] diff --git a/OwnTracks/OwnTracks/Settings.h b/OwnTracks/OwnTracks/Settings.h index f9cb8e7b..6566e731 100644 --- a/OwnTracks/OwnTracks/Settings.h +++ b/OwnTracks/OwnTracks/Settings.h @@ -52,6 +52,7 @@ typedef NS_ENUM(int, ConnectionMode) { + (NSString *)theMqttUserInMOC:(NSManagedObjectContext *)context; + (NSString *)theMqttPassInMOC:(NSManagedObjectContext *)context; ++ (BOOL)theMqttUsePasswordInMOC:(NSManagedObjectContext *)context; + (BOOL)theMqttAuthInMOC:(NSManagedObjectContext *)context; + (BOOL)validKey:(NSString *)key inMode:(ConnectionMode)mode; diff --git a/OwnTracks/OwnTracks/Settings.m b/OwnTracks/OwnTracks/Settings.m index 20bed309..41ac587d 100644 --- a/OwnTracks/OwnTracks/Settings.m +++ b/OwnTracks/OwnTracks/Settings.m @@ -210,7 +210,10 @@ + (NSError *)fromDictionary:(NSDictionary *)dictionary inMOC:(NSManagedObjectCon object = dictionary[@"auth"]; if (object) [self setString:object forKey:@"auth_preference" inMOC:context]; - + + object = dictionary[@"usePassword"]; + if (object) [self setString:object forKey:@"usepassword_preference" inMOC:context]; + object = dictionary[@"cleanSession"]; if (object) [self setString:[NSString stringWithFormat:@"%@", object] forKey:@"clean_preference" @@ -426,6 +429,7 @@ + (NSDictionary *)toDictionaryInMOC:(NSManagedObjectContext *)context { dict[@"tls"] = @([Settings boolForKey:@"tls_preference" inMOC:context]); dict[@"ws"] = @([Settings boolForKey:@"ws_preference" inMOC:context]); dict[@"auth"] = @([Settings boolForKey:@"auth_preference" inMOC:context]); + dict[@"usePassword"] = @([Settings boolForKey:@"usepassword_preference" inMOC:context]); dict[@"cleanSession"] = @([Settings boolForKey:@"clean_preference" inMOC:context]); dict[@"willRetain"] = @([Settings boolForKey:@"willretain_preference" inMOC:context]); dict[@"allowRemoteLocation"] = @([Settings boolForKey:@"allowremotelocation_preference" inMOC:context]); @@ -744,6 +748,10 @@ + (NSString *)theMqttPassInMOC:(NSManagedObjectContext *)context { return [self stringForKey:@"pass_preference" inMOC:context]; } ++ (BOOL)theMqttUsePasswordInMOC:(NSManagedObjectContext *)context { + return [self boolForKey:@"usepassword_preference" inMOC:context]; +} + + (BOOL)theMqttAuthInMOC:(NSManagedObjectContext *)context { return [self boolForKey:@"auth_preference" inMOC:context]; } diff --git a/OwnTracks/OwnTracks/SettingsTVC.m b/OwnTracks/OwnTracks/SettingsTVC.m index fb0b7dfb..29dcf19d 100644 --- a/OwnTracks/OwnTracks/SettingsTVC.m +++ b/OwnTracks/OwnTracks/SettingsTVC.m @@ -37,6 +37,7 @@ @interface SettingsTVC () @property (weak, nonatomic) IBOutlet UITextField *UIHost; @property (weak, nonatomic) IBOutlet UITextField *UIUserID; @property (weak, nonatomic) IBOutlet UITextField *UIPassword; +@property (weak, nonatomic) IBOutlet UISwitch *UIUsePassword; @property (weak, nonatomic) IBOutlet UITextField *UIPort; @property (weak, nonatomic) IBOutlet UISwitch *UITLS; @property (weak, nonatomic) IBOutlet UITextField *UIproto; @@ -184,6 +185,9 @@ - (void)updateValues { if (self.UIPassword) [Settings setString:self.UIPassword.text forKey:@"pass_preference" inMOC:CoreData.sharedInstance.mainMOC]; + if (self.UIUsePassword) [Settings setBool:self.UIUsePassword.on + forKey:@"usepassword_preference" + inMOC:CoreData.sharedInstance.mainMOC]; if (self.UIsecret) [Settings setString:self.UIsecret.text forKey:@"secret_preference" inMOC:CoreData.sharedInstance.mainMOC]; @@ -439,6 +443,11 @@ - (void)updated inMOC:CoreData.sharedInstance.mainMOC]; self.UIPassword.enabled = !locked; } + if (self.UIUsePassword) { + self.UIUsePassword.on = [Settings boolForKey:@"usepassword_preference" + inMOC:CoreData.sharedInstance.mainMOC]; + self.UIUsePassword.enabled = !locked; + } if (self.UIsecret) { self.UIsecret.text = [Settings stringForKey:@"secret_preference" inMOC:CoreData.sharedInstance.mainMOC]; @@ -591,8 +600,7 @@ - (void)updated } } - NSArray *privatePaths = @[[NSIndexPath indexPathForRow:4 inSection:0], - [NSIndexPath indexPathForRow:5 inSection:0], + NSArray *privatePaths = @[[NSIndexPath indexPathForRow:5 inSection:0], [NSIndexPath indexPathForRow:6 inSection:0], [NSIndexPath indexPathForRow:7 inSection:0] ]; @@ -606,14 +614,18 @@ - (void)updated if (self.UIUserID) { if (self.UIAuth) { - self.UIUserID.enabled = !locked && self.UIAuth.on; - self.UIUserID.textColor = self.UIAuth.on ? [UIColor blackColor] : [UIColor lightGrayColor]; + self.UIUserID.enabled = !locked; + } + } + if (self.UIUsePassword) { + if (self.UIAuth) { + self.UIUsePassword.enabled = !locked && self.UIAuth.on; } } if (self.UIPassword) { if (self.UIAuth) { - self.UIPassword.enabled = !locked && self.UIAuth.on; - self.UIPassword.textColor = self.UIAuth.on ? [UIColor blackColor] : [UIColor lightGrayColor]; + self.UIPassword.enabled = !locked && self.UIAuth.on && self.UIUsePassword.on; + self.UIPassword.textColor = (self.UIAuth.on && self.UIUsePassword.on) ? [UIColor blackColor] : [UIColor lightGrayColor]; } } diff --git a/OwnTracks/OwnTracks/ViewController.m b/OwnTracks/OwnTracks/ViewController.m index 293766de..7a8c2f2a 100644 --- a/OwnTracks/OwnTracks/ViewController.m +++ b/OwnTracks/OwnTracks/ViewController.m @@ -580,13 +580,23 @@ - (IBAction)longDoublePress:(UILongPressGestureRecognizer *)sender { - (void)sendNow { OwnTracksAppDelegate *delegate = (OwnTracksAppDelegate *)[UIApplication sharedApplication].delegate; - [delegate sendNow]; - [delegate.navigationController alert:NSLocalizedString(@"Location", - @"Header of an alert message regarding a location") - message:NSLocalizedString(@"publish queued on user request", - @"content of an alert message regarding user publish") - dismissAfter:1 - ]; + + if (![Settings validIdsInMOC:CoreData.sharedInstance.mainMOC]) { + NSString *message = NSLocalizedString(@"To publish your location userID and deviceID must be set", + @"Warning displayed if necessary settings are missing"); + + [delegate.navigationController alert:@"Settings" message:message]; + } else { + [delegate sendNow]; + [delegate.navigationController alert: + NSLocalizedString(@"Location", + @"Header of an alert message regarding a location") + message: + NSLocalizedString(@"publish queued on user request", + @"content of an alert message regarding user publish") + dismissAfter:1 + ]; + } } - (IBAction)longPress:(UILongPressGestureRecognizer *)sender { diff --git a/OwnTracks/OwnTracksToday/Info.plist b/OwnTracks/OwnTracksToday/Info.plist index ca70e034..c77561a0 100644 --- a/OwnTracks/OwnTracksToday/Info.plist +++ b/OwnTracks/OwnTracksToday/Info.plist @@ -21,11 +21,11 @@ CFBundlePackageType XPC! CFBundleShortVersionString - 12.0.1 + 12.0.2 CFBundleSignature ???? CFBundleVersion - 12.0.1 + 12.0.2 NSExtension NSExtensionMainStoryboard