Commit 6410a0df authored by Jose Blaya's avatar Jose Blaya
Browse files

Merge branch '294-allow-hotspot-helper-notice-to-be-hidden' into 'release/3.0.0'

Resolve "Allow Hotspot Helper notice to be hidden"

See merge request ios/vpn-ios!403
parents 52803e24 abae2b05
...@@ -48,46 +48,55 @@ class PIAHotspotHelper { ...@@ -48,46 +48,55 @@ class PIAHotspotHelper {
*/ */
public func configureHotspotHelper() -> Bool { public func configureHotspotHelper() -> Bool {
let hotspotDisplayName = (Client.preferences.nmtRulesEnabled && Client.preferences.useWiFiProtection) ? let options: [String: NSObject] = [kNEHotspotHelperOptionDisplayName : self.hotspotHelperMessage() as NSObject]
L10n.Hotspothelper.Display.Protected.name :
L10n.Hotspothelper.Display.name
let options: [String: NSObject] = [kNEHotspotHelperOptionDisplayName : hotspotDisplayName as NSObject]
let queue: DispatchQueue = DispatchQueue(label: "com.privateinternetaccess.hotspot", attributes: DispatchQueue.Attributes.concurrent) let queue: DispatchQueue = DispatchQueue(label: "com.privateinternetaccess.hotspot", attributes: DispatchQueue.Attributes.concurrent)
NEHotspotHelper.supportedNetworkInterfaces() NEHotspotHelper.supportedNetworkInterfaces()
return NEHotspotHelper.register(options: options, if Client.preferences.nmtRulesEnabled {
queue: queue) { [weak self] (cmd: NEHotspotHelperCommand) in return NEHotspotHelper.register(options: options,
queue: queue) { [weak self] (cmd: NEHotspotHelperCommand) in
if let weakSelf = self {
if cmd.commandType == .filterScanList { if let weakSelf = self {
log.info("filtering ssid list") if cmd.commandType == .filterScanList {
var availableList: [String] = [] log.info("filtering ssid list")
var unsecuredList: [NEHotspotNetwork] = [] var availableList: [String] = []
for element in cmd.networkList! { var unsecuredList: [NEHotspotNetwork] = []
if !element.ssid.isEmpty, for element in cmd.networkList! {
!availableList.contains(element.ssid) { if !element.ssid.isEmpty,
availableList.append(element.ssid) !availableList.contains(element.ssid) {
availableList.append(element.ssid)
}
if !element.isSecure {
element.setConfidence(.high)
unsecuredList.append(element)
}
} }
if !element.isSecure { weakSelf.saveCurrentNetworkList(availableNetworks: availableList)
element.setConfidence(.high) let response = cmd.createResponse(NEHotspotHelperResult.success)
unsecuredList.append(element) if !Client.providers.vpnProvider.isVPNConnected {
response.setNetworkList(unsecuredList)
log.info("present PIA message for unprotected networks")
} }
response.deliver()
} }
weakSelf.saveCurrentNetworkList(availableNetworks: availableList)
let response = cmd.createResponse(NEHotspotHelperResult.success)
if !Client.providers.vpnProvider.isVPNConnected {
response.setNetworkList(unsecuredList)
log.info("present PIA message for unprotected networks")
}
response.deliver()
} }
} }
} else {
return false
} }
} }
private func hotspotHelperMessage() -> String {
if Client.preferences.nmtRulesEnabled,
Client.preferences.useWiFiProtection {
return L10n.Hotspothelper.Display.Protected.name
} else {
return L10n.Hotspothelper.Display.name
}
}
private func saveCurrentNetworkList(availableNetworks: [String]) { private func saveCurrentNetworkList(availableNetworks: [String]) {
let preferences = Client.preferences.editable() let preferences = Client.preferences.editable()
preferences.availableNetworks = availableNetworks preferences.availableNetworks = availableNetworks
......
...@@ -599,7 +599,7 @@ internal enum L10n { ...@@ -599,7 +599,7 @@ internal enum L10n {
} }
internal enum Quicksetting { internal enum Quicksetting {
internal enum Nmt { internal enum Nmt {
/// Network tool /// Network Management
internal static let title = L10n.tr("Localizable", "tiles.quicksetting.nmt.title") internal static let title = L10n.tr("Localizable", "tiles.quicksetting.nmt.title")
} }
} }
......
...@@ -219,7 +219,7 @@ ...@@ -219,7 +219,7 @@
"settings.hotspothelper.rules.title" = "Rules"; "settings.hotspothelper.rules.title" = "Rules";
"settings.trusted.networks.sections.trusted.rule.description"= "Perform actions when joining trusted networks."; "settings.trusted.networks.sections.trusted.rule.description"= "Perform actions when joining trusted networks.";
"settings.trusted.networks.sections.trusted.rule.action"= "Disconnect from PIA VPN"; "settings.trusted.networks.sections.trusted.rule.action"= "Disconnect from PIA VPN";
"tiles.quicksetting.nmt.title" = "Network tool"; "tiles.quicksetting.nmt.title" = "Network Management";
// REGION // REGION
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment