diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-09 03:20:01 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-09 03:20:01 +0000 |
| commit | c912deb4e76adb823b1bb5355b1171eb1241b42b (patch) | |
| tree | a914f42122662759aa8bd13a2bf2447ad3c22e81 /macosx/plugins/DFNet/macsrc | |
| parent | 2062efdfedb6fd9bef719a1b8ad000602ddf0e69 (diff) | |
| download | pcsxr-c912deb4e76adb823b1bb5355b1171eb1241b42b.tar.gz | |
Updating OS X plug-in code.
Now the net plug-in will warn you if you have a too large or non-ASCII characters.
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85926 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/DFNet/macsrc')
| -rwxr-xr-x | macosx/plugins/DFNet/macsrc/PluginConfigController.m | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/macosx/plugins/DFNet/macsrc/PluginConfigController.m b/macosx/plugins/DFNet/macsrc/PluginConfigController.m index 53f1567a..c25bd8bf 100755 --- a/macosx/plugins/DFNet/macsrc/PluginConfigController.m +++ b/macosx/plugins/DFNet/macsrc/PluginConfigController.m @@ -23,9 +23,9 @@ #include "dfnet.h" #import "ARCBridge.h" -NSString * const kIPADDRKEY = @"IP Address"; -NSString * const kIPPORT = @"IP Port"; -NSString * const kPLAYERNUM = @"Player Number"; +#define kIPADDRKEY @"IP Address" +#define kIPPORT @"IP Port" +#define kPLAYERNUM @"Player Number" #define APP_ID @"net.codeplex.pcsxr.DFNet" #define PrefsKey APP_ID @" Settings" @@ -90,9 +90,9 @@ void ReadConfig() [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: [NSDictionary dictionaryWithObjectsAndKeys: - @"127.0.0.1",kIPADDRKEY, - [NSNumber numberWithInt:33306], kIPPORT, - [NSNumber numberWithInt:1], kPLAYERNUM, + @"127.0.0.1", kIPADDRKEY, + @((unsigned short)33306), kIPPORT, + @1, kPLAYERNUM, nil], PrefsKey, nil]]; keyValues = [defaults dictionaryForKey:PrefsKey]; @@ -113,10 +113,21 @@ void ReadConfig() { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; + NSString *theAddress = [ipAddress stringValue]; + NSInteger asciiLen = [theAddress lengthOfBytesUsingEncoding:NSASCIIStringEncoding]; + if (asciiLen > (sizeof(conf.ipAddress) - 1)) { + NSBeginAlertSheet(@"Address too long", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The address is too long.\n\nTry to use only the IP address and not a host name."); + return; + } else if (asciiLen == 0) { + NSBeginAlertSheet(@"Blank address", nil, nil, nil, [self window], nil, NULL, NULL, NULL, @"The address specified is either blank, or can't be converted to ASCII.\n\nTry connecting directly using the IP address using latin numerals."); + return; + } + + NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:[defaults dictionaryForKey:PrefsKey]]; - [writeDic setObject:[NSNumber numberWithInt:[portNum intValue]] forKey:kIPPORT]; - [writeDic setObject:[NSNumber numberWithInt:[playerNum intValue]] forKey:kPLAYERNUM]; - [writeDic setObject:[ipAddress stringValue] forKey:kIPADDRKEY]; + [writeDic setObject:@((unsigned short)[portNum intValue]) forKey:kIPPORT]; + [writeDic setObject:@([playerNum intValue]) forKey:kPLAYERNUM]; + [writeDic setObject:theAddress forKey:kIPADDRKEY]; // write to defaults [defaults setObject:writeDic forKey:PrefsKey]; @@ -135,18 +146,11 @@ void ReadConfig() NSDictionary *keyValues = [defaults dictionaryForKey:PrefsKey]; [ipAddress setStringValue:[keyValues objectForKey:kIPADDRKEY]]; - [portNum setStringValue:[[keyValues objectForKey:kIPPORT] stringValue]]; - [playerNum setStringValue:[[keyValues objectForKey:kPLAYERNUM] stringValue]]; + [portNum setIntValue:[[keyValues objectForKey:kIPPORT] unsignedShortValue]]; + [playerNum setIntValue:[[keyValues objectForKey:kPLAYERNUM] intValue]]; } @end -char* PLUGLOC(char *toloc) -{ - NSBundle *mainBundle = [NSBundle bundleForClass:[PluginConfigController class]]; - NSString *origString = nil, *transString = nil; - origString = @(toloc); - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString UTF8String]; -} - +#import "OSXPlugLocalization.h" +PLUGLOCIMP([PluginConfigController class]); |
