Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8837d0e0aa | ||
|
|
2939990607 | ||
|
|
404e25d3bd | ||
|
|
23705c5e26 | ||
|
|
73e86ff65f | ||
|
|
7403e70893 | ||
|
|
34d677fb92 | ||
|
|
da10b8bbb8 | ||
|
|
ff08266e44 | ||
|
|
b6fdf61430 | ||
|
|
d743a5039a | ||
|
|
f416f8f098 | ||
|
|
90e3e23905 | ||
|
|
98da599302 | ||
|
|
c68ca3376b | ||
|
|
46997ab9fc | ||
|
|
e5ae0c250e | ||
|
|
20af028cc3 | ||
|
|
f3f6616280 | ||
|
|
04b5b4228b | ||
|
|
62f9abb5e5 | ||
|
|
df7cdecda5 | ||
|
|
d96cec2ab1 | ||
|
|
843bc56f69 | ||
|
|
82e401b87d | ||
|
|
711519ded5 | ||
|
|
3ccb41ae0f | ||
|
|
e710bcab47 | ||
|
|
815ea3396f | ||
|
|
bf6093e299 | ||
|
|
7c18c73c82 | ||
|
|
65515eb2ce | ||
|
|
62d285364f | ||
|
|
9a3d31ce3b | ||
|
|
a4ddb9d6be | ||
|
|
dd28d21134 | ||
|
|
6b883e9457 | ||
|
|
e7654313f3 | ||
|
|
ab4af784c4 | ||
|
|
dbca8d6434 | ||
|
|
3a2a8c70b9 | ||
|
|
f800975607 | ||
|
|
a76983df36 | ||
|
|
1cdcf0297d | ||
|
|
ca722b8894 | ||
|
|
6e33998fb6 | ||
|
|
cbcbb20077 | ||
|
|
0115a6453e | ||
|
|
3522a64955 | ||
|
|
d9f23f9b44 | ||
|
|
6f1c4f4cf9 | ||
|
|
6ea0782565 | ||
|
|
c18a240ab3 | ||
|
|
399fc8810b | ||
|
|
d82e02dffb | ||
|
|
bf9540a06b | ||
|
|
124d62594f | ||
|
|
4c6c7cbd6a | ||
|
|
11a66d0f8a | ||
|
|
73e273b790 | ||
|
|
c9140cf19f | ||
|
|
6c6c79cdad | ||
|
|
05fa6043fe | ||
|
|
b2180f9235 | ||
|
|
f6452de763 | ||
|
|
653fbeb096 | ||
|
|
e43e017803 | ||
|
|
d055140364 | ||
|
|
c40841fc9b | ||
|
|
58e488c0ad | ||
|
|
088a3b5389 | ||
|
|
199621acf3 | ||
|
|
8f8d46f7aa | ||
|
|
81a7ee06af | ||
|
|
99c57e9927 | ||
|
|
a810a59b20 | ||
|
|
fd524adca1 | ||
|
|
0614ab56cd | ||
|
|
a2e3bf1603 | ||
|
|
54bb6069d6 | ||
|
|
383560ad43 | ||
|
|
aee59f6f47 | ||
|
|
2ea08a8604 | ||
|
|
5a8f1561c9 | ||
|
|
4984311370 | ||
|
|
6986b6ce2b | ||
|
|
b81a453b69 | ||
|
|
ce77e73428 | ||
|
|
bb86ebc606 | ||
|
|
c0fb5dd303 | ||
|
|
63d838728f | ||
|
|
ba1f49a711 | ||
|
|
867bf3fff5 | ||
|
|
ca571096bc | ||
|
|
bd5a0ae061 | ||
|
|
a87387cd1d | ||
|
|
ea324ea7d8 | ||
|
|
164d351c4d | ||
|
|
955763c004 | ||
|
|
8e4989e163 | ||
|
|
8ebebbda15 | ||
|
|
b5d1233778 | ||
|
|
45b89cd391 | ||
|
|
c5d4197562 | ||
|
|
1f5901ed38 | ||
|
|
b0d4cc19c3 | ||
|
|
2b7782a44c | ||
|
|
2b0b7113c2 | ||
|
|
da4dd4cc79 | ||
|
|
5ee4689893 | ||
|
|
8d8d4036dd | ||
|
|
d399f5f99a | ||
|
|
4bea296541 | ||
|
|
eb71cf76a9 | ||
|
|
29f0d419a5 | ||
|
|
3e8accaade | ||
|
|
3fb926ce52 | ||
|
|
eeedb06027 | ||
|
|
4a13fd049f | ||
|
|
89d892eea9 | ||
|
|
af26ffc88f | ||
|
|
ff6bc4d780 | ||
|
|
5d07cf1ae5 | ||
|
|
f4ddb7b776 | ||
|
|
ff66234223 | ||
|
|
af2dbc8c2d | ||
|
|
4743424ac4 | ||
|
|
ed381c56a6 | ||
|
|
34583fbd05 | ||
|
|
1f959b5bb0 | ||
|
|
753827e6c3 | ||
|
|
d6658498ba | ||
|
|
46b45cd3f7 | ||
|
|
0c3ccc278a | ||
|
|
406f1ab78b | ||
|
|
4929a96134 | ||
|
|
79b359fb64 | ||
|
|
2ef0d0b058 | ||
|
|
fd3ca7872e | ||
|
|
61ca2648bb | ||
|
|
583a377655 | ||
|
|
83468e46f7 | ||
|
|
1713ef28d4 | ||
|
|
7bf12bd2f4 | ||
|
|
61e1fe38e6 | ||
|
|
1fb0d86545 | ||
|
|
037f1117e4 | ||
|
|
c28a69ff42 | ||
|
|
e6fc89d050 | ||
|
|
6da986a974 | ||
|
|
90bfcda2f8 |
No files matched your search
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 51 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 4.9 KiB |
|
After Width: | Height: | Size: 48 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 158 KiB |
|
After Width: | Height: | Size: 488 KiB |
|
After Width: | Height: | Size: 492 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 33 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 752 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 6.2 KiB |
|
After Width: | Height: | Size: 105 KiB |
|
After Width: | Height: | Size: 1.1 MiB |
|
After Width: | Height: | Size: 752 KiB |
|
After Width: | Height: | Size: 527 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
|
After Width: | Height: | Size: 73 KiB |
|
After Width: | Height: | Size: 1.2 MiB |
|
After Width: | Height: | Size: 1.2 MiB |
@@ -1,41 +0,0 @@
|
||||
{
|
||||
"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,140 +0,0 @@
|
||||
//
|
||||
// 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
|
||||
}
|
||||
|
Before Width: | Height: | Size: 364 KiB |
|
Before Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 1005 B |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 37 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 111 KiB |
|
Before Width: | Height: | Size: 4.8 KiB |
|
Before Width: | Height: | Size: 2.0 KiB |
|
Before Width: | Height: | Size: 2.2 KiB |
@@ -1,42 +0,0 @@
|
||||
/* No comment provided by engineer. */
|
||||
"Accept" = "Accept";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Decline" = "Decline";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"DeviceName" = "Device name: %@";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"DeviceSendingFiles" = "%1$@ is sending you %2$@";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Error.Crypto" = "Encryption error";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Error.Protocol" = "Communication error";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"NFiles" = "%d files";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"NotificationsDenied.Message" = "NearDrop needs to be able to display notifications for incoming file transfers. Please allow notifications in System Settings.";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"NotificationsDenied.OpenSettings" = "Open settings";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"NotificationsDenied.Title" = "Notification Permission Required";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"PinCode" = "PIN: %@";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"Quit" = "Quit NearDrop";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"TransferError" = "Failed to receive files from %@";
|
||||
|
||||
/* No comment provided by engineer. */
|
||||
"VisibleToEveryone" = "Visible to everyone";
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
//
|
||||
// NDNotificationCenterHackery.h
|
||||
// NearDrop
|
||||
//
|
||||
// Created by Grishka on 10.04.2023.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NDNotificationCenterHackery : NSObject
|
||||
|
||||
+ (void)removeDefaultAction:(UNMutableNotificationContent*) content;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -1,42 +0,0 @@
|
||||
//
|
||||
// NDNotificationCenterHackery.m
|
||||
// NearDrop
|
||||
//
|
||||
// Created by Grishka on 10.04.2023.
|
||||
//
|
||||
|
||||
#import <UserNotifications/UserNotifications.h>
|
||||
#import <AppKit/AppKit.h>
|
||||
#import "NDNotificationCenterHackery.h"
|
||||
|
||||
@interface UNMutableNotificationCategory : UNNotificationCategory
|
||||
@property(copy) NSString *actionsMenuTitle;
|
||||
@property(copy) UNNotificationAction *alternateAction;
|
||||
@property(copy) NSArray *minimalActions;
|
||||
@property unsigned long long backgroundStyle;
|
||||
@property(copy) NSArray *actions;
|
||||
@end
|
||||
|
||||
@interface UNNotificationIcon : NSObject
|
||||
+ (id)iconForApplicationIdentifier:(id)arg1;
|
||||
+ (id)iconAtPath:(id)arg1;
|
||||
+ (id)iconNamed:(id)arg1;
|
||||
@end
|
||||
|
||||
@interface UNMutableNotificationContent (NDPrivateAPIs)
|
||||
@property BOOL hasDefaultAction;
|
||||
@property(copy) NSString *defaultActionTitle;
|
||||
@property(copy) NSString *header;
|
||||
@property (assign,nonatomic) BOOL shouldDisplayActionsInline;
|
||||
@property (assign,nonatomic) BOOL shouldShowSubordinateIcon;
|
||||
@property (nonatomic,copy) NSString * accessoryImageName;
|
||||
@property(copy) UNNotificationIcon *icon;
|
||||
@end
|
||||
|
||||
@implementation NDNotificationCenterHackery
|
||||
|
||||
+ (void)removeDefaultAction:(UNMutableNotificationContent*) content{
|
||||
content.hasDefaultAction=false;
|
||||
}
|
||||
|
||||
@end
|
||||