SCNetworkconnect
SCNetworkconnect
- Subject: SCNetworkconnect
- From: Stefan Lehrner <email@hidden>
- Date: Wed, 25 Nov 2009 02:50:41 -0800
Hi,
I run a dashboard for multiple 3G vendors. Normally the connection will be done without Username/Password - but some Providers have changed their policy, so I have to rebuild my Application and enter "Username/Password" to it.
This is the Code I am now using - but it will not pass the User/Password Data to my Dialing Options - which means, User/Pass will not accepted. When I am enterining the Data in my Network Options, everything is working fine.
May someone can check out, what I am doing wrong?
// Code - without User(Password
SDictionary *pppOptionsForDialModem = [NSDictionary dictionaryWithObjectsAndKeys:
[connect modemScript], (NSString*)kSCPropNetModemConnectionScript,
nil];
NSDictionary *pppOptionsForDialAdress = [NSDictionary dictionaryWithObjectsAndKeys:
[connect apn], (NSString*)kSCPropNetPPPCommRemoteAddress,
nil];
NSDictionary *optionsForDial = [NSDictionary dictionaryWithObjectsAndKeys:
pppOptionsForDialAdress, (NSString*)kSCEntNetPPP,
pppOptionsForDialModem, (NSString*)kSCEntNetModem,
nil];
BOOL startConnection = SCNetworkConnectionStart(connection,(CFDictionaryRef)optionsForDial,false);
//NSLog(@"der bool ist: %@", startConnection?@"YES":@"NO");
if ( ! startConnection ) {
NSString *errorstring = [NSString stringWithCString:SCErrorString(SCError()) encoding:NSUTF8StringEncoding];
[[NSAlert alertWithMessageText:@"Fehler beim Verbinden des Modems" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@",errorstring] runModal];
}
// End Code without User/Password
Now with the Adaptions:
// Code with User/Password
SDictionary *pppOptionsForDialModem = [NSDictionary dictionaryWithObjectsAndKeys:
[connect modemScript], (NSString*)kSCPropNetModemConnectionScript,
nil];
NSDictionary *pppOptionsForDialAdress = [NSDictionary dictionaryWithObjectsAndKeys:
[connect apn], (NSString*)kSCPropNetPPPCommRemoteAddress,
nil];
NSDictionary *pppOptionsForDialUserName = [NSDictionary dictionaryWithObjectsAndKeys:
[connect username], (NSString*)kSCPropNetPPPAuthName,
nil];
NSDictionary *pppOptionsForDialPassword = [NSDictionary dictionaryWithObjectsAndKeys:
[connect userPassword], (NSString*)kSCPropNetPPPAuthPassword,
nil];
NSDictionary *optionsForDial = [NSDictionary dictionaryWithObjectsAndKeys:
pppOptionsForDialAdress, (NSString*)kSCEntNetPPP,
pppOptionsForDialModem, (NSString*)kSCEntNetModem,
pppOptionsForDialUserName, (NSString*)kSCPropNetPPPAuthName,
pppOptionsForDialPassword, (NSString*)kSCPropNetPPPAuthPassword,
nil];
BOOL startConnection = SCNetworkConnectionStart(connection,(CFDictionaryRef)optionsForDial,false);
//NSLog(@"der bool ist: %@", startConnection?@"YES":@"NO");
if ( ! startConnection ) {
NSString *errorstring = [NSString stringWithCString:SCErrorString(SCError()) encoding:NSUTF8StringEncoding];
[[NSAlert alertWithMessageText:@"Fehler beim Verbinden des Modems" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@",errorstring] runModal];
}
//End Code with User/Password
You see - I have build a NSDictionary *pppOptionsForDialPassword and *pppOptionsForDialUsername - when NSLog the Dictionary *optionsForDial it will show the given Credentials but it will not use the credentials for dialing...
Thanks a lot for your feedback,
Stefan
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden