Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4604a5a51 |
No files matched your search
|
Before Width: | Height: | Size: 5.1 KiB |
|
Before Width: | Height: | Size: 51 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 488 KiB |
|
Before Width: | Height: | Size: 492 KiB |
|
Before Width: | Height: | Size: 527 KiB |
|
Before Width: | Height: | Size: 3.2 MiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 4.9 KiB |
|
Before Width: | Height: | Size: 48 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 488 KiB |
|
Before Width: | Height: | Size: 492 KiB |
|
Before Width: | Height: | Size: 527 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 5.9 KiB |
|
Before Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 752 KiB |
|
Before Width: | Height: | Size: 527 KiB |
|
Before Width: | Height: | Size: 3.2 MiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 6.2 KiB |
|
Before Width: | Height: | Size: 105 KiB |
|
Before Width: | Height: | Size: 1.1 MiB |
|
Before Width: | Height: | Size: 752 KiB |
|
Before Width: | Height: | Size: 527 KiB |
|
Before Width: | Height: | Size: 3.2 MiB |
|
Before Width: | Height: | Size: 73 KiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
@@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"pins" : [
|
||||||
|
{
|
||||||
|
"identity" : "asn1",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/leif-ibsen/ASN1",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "555922e06f1835863d4c0143eb00d0097bcfc707",
|
||||||
|
"version" : "2.0.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "bigint",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/leif-ibsen/BigInt",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "47903c6b2dd2cb3b4484d4524676a2ca8723a871",
|
||||||
|
"version" : "1.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swift-protobuf",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/apple/swift-protobuf.git",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "0af9125c4eae12a4973fb66574c53a54962a9e1e",
|
||||||
|
"version" : "1.21.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "swiftecc",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/leif-ibsen/SwiftECC",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "55493f0609f07b24bf6cd52b90898ed1cefb268e",
|
||||||
|
"version" : "3.5.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 2
|
||||||
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1640"
|
LastUpgradeVersion = "1430"
|
||||||
version = "1.7">
|
version = "1.7">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
parallelizeBuildables = "YES"
|
parallelizeBuildables = "YES"
|
||||||
buildImplicitDependencies = "YES"
|
buildImplicitDependencies = "YES">
|
||||||
buildArchitectures = "Automatic">
|
|
||||||
<BuildActionEntries>
|
<BuildActionEntries>
|
||||||
<BuildActionEntry
|
<BuildActionEntry
|
||||||
buildForTesting = "YES"
|
buildForTesting = "YES"
|
||||||
@@ -16,9 +15,9 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
||||||
BuildableName = "QuickDrop.app"
|
BuildableName = "NearDrop.app"
|
||||||
BlueprintName = "QuickDrop"
|
BlueprintName = "NearDrop"
|
||||||
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
ReferencedContainer = "container:NearDrop.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildActionEntry>
|
</BuildActionEntry>
|
||||||
</BuildActionEntries>
|
</BuildActionEntries>
|
||||||
@@ -45,9 +44,9 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
||||||
BuildableName = "QuickDrop.app"
|
BuildableName = "NearDrop.app"
|
||||||
BlueprintName = "QuickDrop"
|
BlueprintName = "NearDrop"
|
||||||
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
ReferencedContainer = "container:NearDrop.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
@@ -62,9 +61,9 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
||||||
BuildableName = "QuickDrop.app"
|
BuildableName = "NearDrop.app"
|
||||||
BlueprintName = "QuickDrop"
|
BlueprintName = "NearDrop"
|
||||||
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
ReferencedContainer = "container:NearDrop.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
</ProfileAction>
|
</ProfileAction>
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<Scheme
|
<Scheme
|
||||||
LastUpgradeVersion = "1640"
|
LastUpgradeVersion = "1430"
|
||||||
wasCreatedForAppExtension = "YES"
|
wasCreatedForAppExtension = "YES"
|
||||||
version = "2.0">
|
version = "2.0">
|
||||||
<BuildAction
|
<BuildAction
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "699DEBA02AB0573200115D22"
|
BlueprintIdentifier = "699DEBA02AB0573200115D22"
|
||||||
BuildableName = "QuickDropShareExtension.appex"
|
BuildableName = "ShareExtension.appex"
|
||||||
BlueprintName = "QuickDropShareExtension"
|
BlueprintName = "ShareExtension"
|
||||||
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
ReferencedContainer = "container:NearDrop.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildActionEntry>
|
</BuildActionEntry>
|
||||||
<BuildActionEntry
|
<BuildActionEntry
|
||||||
@@ -30,9 +30,9 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
||||||
BuildableName = "QuickDrop.app"
|
BuildableName = "NearDrop.app"
|
||||||
BlueprintName = "QuickDrop"
|
BlueprintName = "NearDrop"
|
||||||
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
ReferencedContainer = "container:NearDrop.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildActionEntry>
|
</BuildActionEntry>
|
||||||
</BuildActionEntries>
|
</BuildActionEntries>
|
||||||
@@ -60,9 +60,9 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
||||||
BuildableName = "QuickDrop.app"
|
BuildableName = "NearDrop.app"
|
||||||
BlueprintName = "QuickDrop"
|
BlueprintName = "NearDrop"
|
||||||
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
ReferencedContainer = "container:NearDrop.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</MacroExpansion>
|
</MacroExpansion>
|
||||||
</LaunchAction>
|
</LaunchAction>
|
||||||
@@ -79,9 +79,9 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
BlueprintIdentifier = "69DA9A0D29E0BF5100A442DA"
|
||||||
BuildableName = "QuickDrop.app"
|
BuildableName = "NearDrop.app"
|
||||||
BlueprintName = "QuickDrop"
|
BlueprintName = "NearDrop"
|
||||||
ReferencedContainer = "container:QuickDrop.xcodeproj">
|
ReferencedContainer = "container:NearDrop.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
</BuildableProductRunnable>
|
</BuildableProductRunnable>
|
||||||
</ProfileAction>
|
</ProfileAction>
|
||||||
@@ -0,0 +1,140 @@
|
|||||||
|
//
|
||||||
|
// AppDelegate.swift
|
||||||
|
// NearDrop
|
||||||
|
//
|
||||||
|
// Created by Grishka on 08.04.2023.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cocoa
|
||||||
|
import UserNotifications
|
||||||
|
import NearbyShare
|
||||||
|
|
||||||
|
@main
|
||||||
|
class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate, MainAppDelegate{
|
||||||
|
private var statusItem:NSStatusItem?
|
||||||
|
private var activeIncomingTransfers:[String:TransferInfo]=[:]
|
||||||
|
|
||||||
|
func applicationDidFinishLaunching(_ aNotification: Notification) {
|
||||||
|
let menu=NSMenu()
|
||||||
|
menu.addItem(withTitle: NSLocalizedString("VisibleToEveryone", value: "Visible to everyone", comment: ""), action: nil, keyEquivalent: "")
|
||||||
|
menu.addItem(withTitle: String(format: NSLocalizedString("DeviceName", value: "Device name: %@", comment: ""), arguments: [Host.current().localizedName!]), action: nil, keyEquivalent: "")
|
||||||
|
menu.addItem(NSMenuItem.separator())
|
||||||
|
menu.addItem(withTitle: NSLocalizedString("Quit", value: "Quit NearDrop", comment: ""), action: #selector(NSApplication.terminate(_:)), keyEquivalent: "")
|
||||||
|
statusItem=NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||||
|
statusItem?.button?.image=NSImage(named: "MenuBarIcon")
|
||||||
|
statusItem?.menu=menu
|
||||||
|
statusItem?.behavior = .removalAllowed
|
||||||
|
|
||||||
|
let nc=UNUserNotificationCenter.current()
|
||||||
|
nc.requestAuthorization(options: [.alert, .sound]) { granted, err in
|
||||||
|
if !granted{
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
self.showNotificationsDeniedAlert()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
nc.delegate=self
|
||||||
|
let incomingTransfersCategory=UNNotificationCategory(identifier: "INCOMING_TRANSFERS", actions: [
|
||||||
|
UNNotificationAction(identifier: "ACCEPT", title: NSLocalizedString("Accept", comment: ""), options: UNNotificationActionOptions.authenticationRequired),
|
||||||
|
UNNotificationAction(identifier: "DECLINE", title: NSLocalizedString("Decline", comment: ""))
|
||||||
|
], intentIdentifiers: [])
|
||||||
|
let errorsCategory=UNNotificationCategory(identifier: "ERRORS", actions: [], intentIdentifiers: [])
|
||||||
|
nc.setNotificationCategories([incomingTransfersCategory, errorsCategory])
|
||||||
|
NearbyConnectionManager.shared.mainAppDelegate=self
|
||||||
|
NearbyConnectionManager.shared.becomeVisible()
|
||||||
|
}
|
||||||
|
|
||||||
|
func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
|
||||||
|
statusItem?.isVisible=true
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func applicationWillTerminate(_ aNotification: Notification) {
|
||||||
|
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
|
||||||
|
}
|
||||||
|
|
||||||
|
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func showNotificationsDeniedAlert(){
|
||||||
|
let alert=NSAlert()
|
||||||
|
alert.alertStyle = .critical
|
||||||
|
alert.messageText=NSLocalizedString("NotificationsDenied.Title", value: "Notification Permission Required", comment: "")
|
||||||
|
alert.informativeText=NSLocalizedString("NotificationsDenied.Message", value: "NearDrop needs to be able to display notifications for incoming file transfers. Please allow notifications in System Settings.", comment: "")
|
||||||
|
alert.addButton(withTitle: NSLocalizedString("NotificationsDenied.OpenSettings", value: "Open settings", comment: ""))
|
||||||
|
alert.addButton(withTitle: NSLocalizedString("Quit", value: "Quit NearDrop", comment: ""))
|
||||||
|
let result=alert.runModal()
|
||||||
|
if result==NSApplication.ModalResponse.alertFirstButtonReturn{
|
||||||
|
NSWorkspace.shared.open(URL(string: "x-apple.systempreferences:com.apple.preference.notifications")!)
|
||||||
|
}else if result==NSApplication.ModalResponse.alertSecondButtonReturn{
|
||||||
|
NSApplication.shared.terminate(nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||||
|
let transferID=response.notification.request.content.userInfo["transferID"]! as! String
|
||||||
|
NearbyConnectionManager.shared.submitUserConsent(transferID: transferID, accept: response.actionIdentifier=="ACCEPT")
|
||||||
|
if response.actionIdentifier != "ACCEPT"{
|
||||||
|
activeIncomingTransfers.removeValue(forKey: transferID)
|
||||||
|
}
|
||||||
|
completionHandler()
|
||||||
|
}
|
||||||
|
|
||||||
|
func obtainUserConsent(for transfer: TransferMetadata, from device: RemoteDeviceInfo) {
|
||||||
|
let fileStr:String
|
||||||
|
if let textTitle=transfer.textDescription{
|
||||||
|
fileStr=textTitle
|
||||||
|
}else if transfer.files.count==1{
|
||||||
|
fileStr=transfer.files[0].name
|
||||||
|
}else{
|
||||||
|
fileStr=String.localizedStringWithFormat(NSLocalizedString("NFiles", value: "%d files", comment: ""), transfer.files.count)
|
||||||
|
}
|
||||||
|
let notificationContent=UNMutableNotificationContent()
|
||||||
|
notificationContent.title="NearDrop"
|
||||||
|
notificationContent.subtitle=String(format:NSLocalizedString("PinCode", value: "PIN: %@", comment: ""), arguments: [transfer.pinCode!])
|
||||||
|
notificationContent.body=String(format: NSLocalizedString("DeviceSendingFiles", value: "%1$@ is sending you %2$@", comment: ""), arguments: [device.name, fileStr])
|
||||||
|
notificationContent.sound = .default
|
||||||
|
notificationContent.categoryIdentifier="INCOMING_TRANSFERS"
|
||||||
|
notificationContent.userInfo=["transferID": transfer.id]
|
||||||
|
if #available(macOS 11.0, *){
|
||||||
|
NDNotificationCenterHackery.removeDefaultAction(notificationContent)
|
||||||
|
}
|
||||||
|
let notificationReq=UNNotificationRequest(identifier: "transfer_"+transfer.id, content: notificationContent, trigger: nil)
|
||||||
|
UNUserNotificationCenter.current().add(notificationReq)
|
||||||
|
self.activeIncomingTransfers[transfer.id]=TransferInfo(device: device, transfer: transfer)
|
||||||
|
}
|
||||||
|
|
||||||
|
func incomingTransfer(id: String, didFinishWith error: Error?) {
|
||||||
|
guard let transfer=self.activeIncomingTransfers[id] else {return}
|
||||||
|
if let error=error{
|
||||||
|
let notificationContent=UNMutableNotificationContent()
|
||||||
|
notificationContent.title=String(format: NSLocalizedString("TransferError", value: "Failed to receive files from %@", comment: ""), arguments: [transfer.device.name])
|
||||||
|
if let ne=(error as? NearbyError){
|
||||||
|
switch ne{
|
||||||
|
case .inputOutput:
|
||||||
|
notificationContent.body="I/O Error";
|
||||||
|
case .protocolError(_):
|
||||||
|
notificationContent.body=NSLocalizedString("Error.Protocol", value: "Communication error", comment: "")
|
||||||
|
case .requiredFieldMissing:
|
||||||
|
notificationContent.body=NSLocalizedString("Error.Protocol", value: "Communication error", comment: "")
|
||||||
|
case .ukey2:
|
||||||
|
notificationContent.body=NSLocalizedString("Error.Crypto", value: "Encryption error", comment: "")
|
||||||
|
case .canceled(reason: _):
|
||||||
|
break; // can't happen for incoming transfers
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
notificationContent.body=error.localizedDescription
|
||||||
|
}
|
||||||
|
notificationContent.categoryIdentifier="ERRORS"
|
||||||
|
UNUserNotificationCenter.current().add(UNNotificationRequest(identifier: "transferError_"+id, content: notificationContent, trigger: nil))
|
||||||
|
}
|
||||||
|
UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: ["transfer_"+id])
|
||||||
|
self.activeIncomingTransfers.removeValue(forKey: id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct TransferInfo{
|
||||||
|
let device:RemoteDeviceInfo
|
||||||
|
let transfer:TransferMetadata
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 364 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 1005 B |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 37 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 111 KiB |