I have a Mac software client who sets a Mac for a new Internet connection via DSL modem. Some devices have WiFi access points and therefore the software sets the user's Mac, so that he can connect it wirelessly too.
All this works fine from Mac OS X 10.4.x to 10.6.x. Later through the core WLAN framework) once.
The problem is that the airport will not save the software connection, e.g. A keychain airport password entry has been created.
Clients (ISP and Telecom companies) want to be disconnected / rebooted Airport connections, obviously.
Is there any kind of savings to complete an established airport connection? System Configuration Framework, Core WLAN?
With Core WLAN API you can do the following code:
< Previous>
NSArray * airportInterfaces = [CW interfaces supported interface]; If ([count of airport interface] <1) {NSRunCriticalAlertPanel (@ "error", @ "airport card does not exist", @ "OK", zero, zero); } // Choose the desired interface The first example for this example is NSSTING * interface = [airport interface objectattyx index: 0]; CW interfaces * airport = [CW interfaces interface: interface]; If (! Airport) {NSR Critical AlertPanel (@ "Error", @ "airport card is not present", @ "OK", zero, zero); } // We want to add a sample WPA2 Personal Network CWWirelessProfile * newProfile = [CWWirelessProfile Profile]; [New Profile Set SSID: @ "SSID"]; [New Profile Set Security Mode: [NSNumber Number with Init: KCWSAquiryMODAWAP2PPSK]]; [Newprofile set password: @ "very secret password"]; CWConfiguration * conf = [airport configuration]; // We first add a profile while remembering the profile, when necessary, BOOL configChanged = NO; NSSet * Remembered Network = [Command Network Remaining]; If (missions included in the network: newprofile) {{conf setRememberedNetworks: [missed network setbeaving object: newprofile]]; ConfigChanged = Yes; } // We add the system to the preferred network to allow it to connect automatically to NSArray * preferredNetworks = [conf preferencesNetworks]; If (! [Preferred Networks Include: NewProfile]) {[conf setPreferredNetworks: [Favorite Network ArrayBaid Heading Object: NewProfile]]; ConfigChanged = Yes; } If (! ConfigChanged) {return; } / Authorized Authorization Authority * Authority = [SFA Authorization Authority]; BOOL authResult = [AuthorizationwithWithRight: "system.preferences" Flags: (kAuthorizationFlagExtendRights | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagPreAuthorize) Error: Zero]; If (! AuthResult) {NSRunCriticalAlertPanel (@ "Error", @ "Aith Fail", @ "OK", zero, zero); Return; } [Airport set authorization: authorization]; NSError * err = nil ;; BOOL Saved = [Airport Committed Configuration: Confusion Error: & amp; Err]; If (! Saved & amp; amp; and;); [[NSAPP presentError: err]; Return; } If ((saved!) {NSRunCriticalAlertPanel (@ "error", @ "save error", @ "OK", zero, zero);
Comments
Post a Comment