Skip to content

Commit

Permalink
Merge pull request #116 from geteduroam/feature/115-support-opening-e…
Browse files Browse the repository at this point in the history
…ap-config-files-from-filesapp

Support opening EAP config files from Files.app
  • Loading branch information
johankool authored Jun 6, 2024
2 parents df84325 + 9e9c8df commit 29b5c2b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 10 deletions.
16 changes: 12 additions & 4 deletions geteduroam/GeteduroamPackage/Sources/Connect/ConnectFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,19 @@ public struct Connect: Reducer {
let eapConfigData: Data
if eapConfigURL.isFileURL {
let gotAccess = eapConfigURL.startAccessingSecurityScopedResource()
guard gotAccess else {
throw OrganizationSetupError.missingEAPConfigEndpoint
defer {
eapConfigURL.stopAccessingSecurityScopedResource()
}
if gotAccess {
eapConfigData = try Data(contentsOf: eapConfigURL)
} else {
// We didn't got access, but we may not even need it, so try anyway
do {
eapConfigData = try Data(contentsOf: eapConfigURL)
} catch {
throw OrganizationSetupError.missingEAPConfigEndpoint
}
}
eapConfigData = try Data(contentsOf: eapConfigURL)
eapConfigURL.stopAccessingSecurityScopedResource()

} else {
var urlRequest = URLRequest(url: eapConfigURL)
Expand Down
4 changes: 4 additions & 0 deletions geteduroam/GeteduroamPackage/Sources/Main/MainFeature.swift
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public struct Main: Reducer {
return .none

case let .useLocalFile(url):
#if os(iOS)
let displayName = FileManager().displayName(atPath: url.path)
let organization = Organization(
id: "local",
Expand All @@ -226,6 +227,9 @@ public struct Main: Reducer {
geo: []
)
state.destination = .connect(.init(organization: organization))
#else
NSLog("Opening EAP Config files not supported on macOS/this OS.")
#endif
return .none
}
}
Expand Down
3 changes: 3 additions & 0 deletions geteduroam/GeteduroamPackage/Sources/Main/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ struct MainContentView: View {
break
}
}
.onOpenURL { url in
store.send(.useLocalFile(url))
}
.onTapGesture(count: 10) {
#if canImport(UIKit)
let content = UIPasteboard.general.string
Expand Down
24 changes: 22 additions & 2 deletions geteduroam/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>EAP Config</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>app.geteduroam.eapconfig</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -20,18 +33,20 @@
<string>1</string>
<key>DiscoveryURL</key>
<string>https://discovery.eduroam.app/v2/</string>
<key>RemoteConfigurationURL</key>
<string>https://discovery.eduroam.app/v2/appconfig.json</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>NSUserNotificationsUsageDescription</key>
<string>Reminding you when you need to renew your network access.</string>
<key>OAuthRedirectURL</key>
<string>app.eduroam.geteduroam:/</string>
<key>RemoteConfigurationURL</key>
<string>https://discovery.eduroam.app/v2/appconfig.json</string>
<key>UIAppFonts</key>
<array>
<string>OpenSans-Regular.ttf</string>
Expand Down Expand Up @@ -86,6 +101,11 @@
<string>eap-config</string>
<string>xml</string>
</array>
<key>public.mime-type</key>
<array>
<string>text/xml</string>
<string>application/xml</string>
</array>
</dict>
</dict>
</array>
Expand Down
28 changes: 24 additions & 4 deletions getgovroam/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>EAP Config</string>
<key>LSHandlerRank</key>
<string>Alternate</string>
<key>LSItemContentTypes</key>
<array>
<string>app.geteduroam.eapconfig</string>
</array>
</dict>
</array>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -20,18 +33,20 @@
<string>1</string>
<key>DiscoveryURL</key>
<string>https://getgovroam.nl/v2/</string>
<key>RemoteConfigurationURL</key>
<string>https://getgovroam.nl/v2/appconfig.json</string>
<key>OAuthRedirectURL</key>
<string>app.govroam.getgovroam:/</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationCategoryType</key>
<string>public.app-category.utilities</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>NSUserNotificationsUsageDescription</key>
<string>Reminding you when you need to renew your network access.</string>
<key>OAuthRedirectURL</key>
<string>app.govroam.getgovroam:/</string>
<key>RemoteConfigurationURL</key>
<string>https://getgovroam.nl/v2/appconfig.json</string>
<key>UIAppFonts</key>
<array>
<string>Muli.ttf</string>
Expand Down Expand Up @@ -86,6 +101,11 @@
<string>eap-config</string>
<string>xml</string>
</array>
<key>public.mime-type</key>
<array>
<string>text/xml</string>
<string>application/xml</string>
</array>
</dict>
</dict>
</array>
Expand Down

0 comments on commit 29b5c2b

Please sign in to comment.