-
Notifications
You must be signed in to change notification settings - Fork 424
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b798fb0
commit 348021b
Showing
22 changed files
with
595 additions
and
450 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// swift-tools-version: 6.0 | ||
// The swift-tools-version declares the minimum version of Swift required to build this package. | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "VPNiOS", | ||
platforms: [ | ||
.iOS(.v15) | ||
], | ||
products: [ | ||
// Products define the executables and libraries a package produces, making them visible to other packages. | ||
.library( | ||
name: "VPNWidgetSupport", | ||
targets: ["VPNWidgetSupport"]), | ||
// Products define the executables and libraries a package produces, making them visible to other packages. | ||
.library( | ||
name: "VPNAppIntents", | ||
targets: ["VPNAppIntents"]), | ||
], | ||
targets: [ | ||
// Targets are the basic building blocks of a package, defining a module or a test suite. | ||
// Targets can depend on other targets in this package and products from dependencies. | ||
.target( | ||
name: "VPNWidgetSupport" | ||
), | ||
.target( | ||
name: "VPNAppIntents", | ||
dependencies: ["VPNWidgetSupport"] | ||
), | ||
] | ||
) |
92 changes: 92 additions & 0 deletions
92
LocalPackages/VPNiOS/Sources/VPNAppIntents/VPNAppIntents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
// | ||
// VPNAppIntents.swift | ||
// VPNiOS | ||
// | ||
// Created by ddg on 12/17/24. | ||
// | ||
|
||
// MARK: - Toggle | ||
|
||
/// `ForegroundContinuableIntent` isn't available for extensions, which makes it impossible to call | ||
/// from extensions. This is the recommended workaround from: | ||
/// https://mastodon.social/@mgorbach/110812347476671807 | ||
/// | ||
|
||
import AppIntents | ||
import VPNWidgetSupport | ||
import WidgetKit | ||
|
||
public struct VPNAppIntents: AppIntentsPackage { } | ||
/* | ||
@available(iOS 17.0, *) | ||
public struct ControlWidgetToggleVPNIntent: SetValueIntent { | ||
public static let title: LocalizedStringResource = "Toggle DuckDuckGo VPN from the Control Center Widget" | ||
public static let description: LocalizedStringResource = "Toggles the DuckDuckGo VPN from the Control Center widget" | ||
public static let isDiscoverable = false | ||
public static let openAppWhenRun = false | ||
|
||
@Parameter(title: "Enabled") | ||
public var value: Bool | ||
|
||
public init() {} | ||
|
||
public func perform() async throws -> some IntentResult { | ||
if value { | ||
try await startVPN() | ||
} else { | ||
try await stopVPN() | ||
} | ||
|
||
return .result() | ||
} | ||
|
||
private func startVPN() async throws { | ||
do { | ||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterConnectAttempt) | ||
|
||
let controller = VPNWidgetTunnelController() | ||
try await controller.start() | ||
|
||
WidgetCenter.shared.reloadAllTimelines() | ||
|
||
//await VPNSnoozeLiveActivityManager().endSnoozeActivity() | ||
//VPNReloadStatusWidgets() | ||
|
||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterConnectSuccess) | ||
} catch { | ||
switch error { | ||
case VPNWidgetTunnelController.StartFailure.vpnNotConfigured: | ||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterConnectCancelled) | ||
throw error | ||
default: | ||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterConnectFailure, error: error) | ||
throw error | ||
} | ||
} | ||
} | ||
|
||
private func stopVPN() async throws { | ||
do { | ||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterDisconnectAttempt) | ||
|
||
let controller = VPNWidgetTunnelController() | ||
try await controller.stop() | ||
|
||
WidgetCenter.shared.reloadAllTimelines() | ||
//await VPNSnoozeLiveActivityManager().endSnoozeActivity() | ||
//VPNReloadStatusWidgets() | ||
|
||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterDisconnectSuccess) | ||
} catch { | ||
switch error { | ||
case VPNWidgetTunnelController.StopFailure.vpnNotConfigured: | ||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterDisconnectCancelled) | ||
throw error | ||
default: | ||
//DailyPixel.fireDailyAndCount(pixel: .vpnControlCenterDisconnectFailure, error: error) | ||
throw error | ||
} | ||
} | ||
} | ||
} | ||
*/ |
Oops, something went wrong.