Permalink
Browse files

Prevent formatting of integers in text fields

  • Loading branch information...
1 parent c281fdc commit 9e8707914a70d506719756d6f4c008c30221f9db @eofster eofster committed Nov 16, 2013
Showing with 27 additions and 19 deletions.
  1. +3 −3 Classes/AccountPreferencesViewController.m
  2. +24 −16 Classes/NetworkPreferencesViewController.m
@@ -292,8 +292,8 @@ - (void)populateFieldsForAccountAtIndex:(NSInteger)index {
// Reregister every...
if ([[accountDict objectForKey:kReregistrationTime] integerValue] > 0) {
- [[self reregistrationTimeField] setIntegerValue:
- [[accountDict objectForKey:kReregistrationTime] integerValue]];
+ [[self reregistrationTimeField] setStringValue:
+ [[accountDict objectForKey:kReregistrationTime] stringValue]];
} else {
[[self reregistrationTimeField] setStringValue:@""];
}
@@ -315,7 +315,7 @@ - (void)populateFieldsForAccountAtIndex:(NSInteger)index {
// Proxy Port.
if ([[accountDict objectForKey:kProxyPort] integerValue] > 0) {
- [[self proxyPortField] setIntegerValue:[[accountDict objectForKey:kProxyPort] integerValue]];
+ [[self proxyPortField] setStringValue:[[accountDict objectForKey:kProxyPort] stringValue]];
} else {
[[self proxyPortField] setStringValue:@""];
}
@@ -61,21 +61,24 @@ - (void)awakeFromNib {
object:nil];
// Show user agent's current transport port as a placeholder string.
- if ([[[NSApp delegate] userAgent] isStarted]) {
+ AKSIPUserAgent *userAgent = [AKSIPUserAgent sharedUserAgent];
+ if (userAgent.isStarted) {
[[[self transportPortField] cell] setPlaceholderString:
- [[NSNumber numberWithUnsignedInteger:[[[NSApp delegate] userAgent] transportPort]] stringValue]];
+ [NSString stringWithFormat:@"%lu", (unsigned long)userAgent.transportPort]];
}
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- if ([defaults integerForKey:kTransportPort] > 0) {
- [[self transportPortField] setIntegerValue:[defaults integerForKey:kTransportPort]];
+ NSInteger transportPort = [defaults integerForKey:kTransportPort];
+ if (transportPort > 0) {
+ [[self transportPortField] setStringValue:[NSString stringWithFormat:@"%ld", (long)transportPort]];
}
[[self STUNServerHostField] setStringValue:[defaults stringForKey:kSTUNServerHost]];
- if ([defaults integerForKey:kSTUNServerPort] > 0) {
- [[self STUNServerPortField] setIntegerValue:[defaults integerForKey:kSTUNServerPort]];
+ NSInteger STUNServerPort = [defaults integerForKey:kSTUNServerPort];
+ if (STUNServerPort > 0) {
+ [[self STUNServerPortField] setStringValue:[NSString stringWithFormat:@"%ld", (long)STUNServerPort]];
}
[[self useICECheckBox] setState:[defaults integerForKey:kUseICE]];
@@ -84,8 +87,9 @@ - (void)awakeFromNib {
[[self outboundProxyHostField] setStringValue:[defaults stringForKey:kOutboundProxyHost]];
- if ([defaults integerForKey:kOutboundProxyPort] > 0) {
- [[self outboundProxyPortField] setIntegerValue:[defaults integerForKey:kOutboundProxyPort]];
+ NSInteger outboundProxyPort = [defaults integerForKey:kOutboundProxyPort];
+ if (outboundProxyPort > 0) {
+ [[self outboundProxyPortField] setStringValue:[NSString stringWithFormat:@"%ld", (long)outboundProxyPort]];
}
}
@@ -177,18 +181,20 @@ - (void)networkSettingsChangeAlertDidEnd:(NSAlert *)alert returnCode:(int)return
object:[self preferencesController]];
} else if (returnCode == NSAlertThirdButtonReturn) {
- if ([defaults integerForKey:kTransportPort] == 0) {
+ NSInteger transportPort = [defaults integerForKey:kTransportPort];
+ if (transportPort == 0) {
[[self transportPortField] setStringValue:@""];
} else {
- [[self transportPortField] setIntegerValue:[defaults integerForKey:kTransportPort]];
+ [[self transportPortField] setStringValue:[NSString stringWithFormat:@"%ld", (long)transportPort]];
}
[[self STUNServerHostField] setStringValue:[defaults stringForKey:kSTUNServerHost]];
- if ([defaults integerForKey:kSTUNServerPort] == 0) {
+ NSInteger STUNServerPort = [defaults integerForKey:kSTUNServerPort];
+ if (STUNServerPort == 0) {
[[self STUNServerPortField] setStringValue:@""];
} else {
- [[self STUNServerPortField] setIntegerValue:[defaults integerForKey:kSTUNServerPort]];
+ [[self STUNServerPortField] setStringValue:[NSString stringWithFormat:@"%ld", (long)STUNServerPort]];
}
[[self useICECheckBox] setState:[defaults integerForKey:kUseICE]];
@@ -197,10 +203,11 @@ - (void)networkSettingsChangeAlertDidEnd:(NSAlert *)alert returnCode:(int)return
[[self outboundProxyHostField] setStringValue:[defaults stringForKey:kOutboundProxyHost]];
- if ([defaults integerForKey:kOutboundProxyPort] == 0) {
+ NSInteger outboundProxyPort = [defaults integerForKey:kOutboundProxyPort];
+ if (outboundProxyPort == 0) {
[[self outboundProxyPortField] setStringValue:@""];
} else {
- [[self outboundProxyPortField] setIntegerValue:[defaults integerForKey:kOutboundProxyPort]];
+ [[self outboundProxyPortField] setStringValue:[NSString stringWithFormat:@"%ld", (long)outboundProxyPort]];
}
}
@@ -217,13 +224,14 @@ - (void)networkSettingsChangeAlertDidEnd:(NSAlert *)alert returnCode:(int)return
#pragma mark AKSIPUserAgent notifications
- (void)SIPUserAgentDidFinishStarting:(NSNotification *)notification {
- if (![[[NSApp delegate] userAgent] isStarted]) {
+ AKSIPUserAgent *userAgent = [AKSIPUserAgent sharedUserAgent];
+ if (!userAgent.isStarted) {
return;
}
// Show transport port in the network preferences as a placeholder string.
[[[self transportPortField] cell] setPlaceholderString:
- [[NSNumber numberWithUnsignedInteger:[[[NSApp delegate] userAgent] transportPort]] stringValue]];
+ [NSString stringWithFormat:@"%lu", (unsigned long)userAgent.transportPort]];
}
@end

0 comments on commit 9e87079

Please sign in to comment.