use of ca.weblite.objc.Proxy in project buck by facebook.
the class MacWifiSsidFinder method getDefaultWifiInterface.
/**
* Finds the SSID of the default Wi-Fi interface using Mac OS X 10.10 and later APIs.
*/
private static Optional<Proxy> getDefaultWifiInterface(Client objcClient, Pointer wifiClientClass) {
// CWWiFiClient *sharedWiFiClient = [CWWiFiClient sharedWiFiClient];
Proxy sharedWiFiClient = objcClient.sendProxy(wifiClientClass, "sharedWiFiClient");
if (sharedWiFiClient == null) {
LOG.warn("+[CWWiFiClient sharedWiFiClient] returned null, could not find SSID.");
return Optional.empty();
}
// CWInterface *defaultInterface = [sharedWiFiClient interface];
Proxy defaultInterface = sharedWiFiClient.sendProxy("interface");
if (defaultInterface == null) {
LOG.warn("-[sharedWiFiClient interface] returned null, could not find SSID.");
return Optional.empty();
}
return Optional.of(defaultInterface);
}
use of ca.weblite.objc.Proxy in project buck by facebook.
the class MacWifiSsidFinder method findCurrentSsid.
/**
* Finds the SSID of the default Wi-Fi interface using Mac OS X APIs.
*/
public static Optional<String> findCurrentSsid() {
LOG.debug("Getting current SSID..");
// Grab a handle to the Objective-C runtime.
Client objcClient = Client.getInstance();
// Try the OS X 10.10 and later supported API, then fall
// back to the OS X 10.6 API.
Pointer wifiClientClass = RuntimeUtils.cls("CWWiFiClient");
Optional<Proxy> defaultInterface;
if (wifiClientClass != null) {
LOG.verbose("Getting default interface using +[CWWiFiClient sharedWiFiClient]");
defaultInterface = getDefaultWifiInterface(objcClient, wifiClientClass);
} else {
LOG.verbose("Getting default interface using +[CWInterface defaultInterface]");
// CWInterface *defaultInterface = [CWInterface interface];
defaultInterface = Optional.ofNullable(objcClient.sendProxy("CWInterface", "interface"));
}
return getSsidFromInterface(defaultInterface);
}