Add detection of unsupported file type

This commit is contained in:
Leon Böttger committed 2025-05-17 13:28:36 +02:00
1 parent e7654313f3
commit 6b883e9457
20 files changed
+47 -3

No files matched your search

+19 -1
View File
@@ -344,7 +344,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
}
private func pressAcceptButton(transferID: String) {
if false || (!isPlusVersion() && transmissionCount() > 1) {
if (!isPlusVersion() && transmissionCount() > 1) {
continueTransmission(accept: true, transferID: transferID, storeInTemp: true)
log("Showing plus screen...")
@@ -363,9 +363,27 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
BezelNotification.show(messageText: "InsertedIntoClipboard".localized(), icon: .clipboard)
}
}
func showUnsupportedFileAlert(for device: RemoteDeviceInfo?) {
DispatchQueue.main.async {
let alert = NSAlert()
alert.alertStyle = .critical
alert.messageText = String(format: NSLocalizedString("TransferError", value: "Failed to receive files from %@", comment: ""), arguments: [device?.name ?? "??"])
alert.informativeText = "UnsupportedFileType".localized()
alert.addButton(withTitle: "InformDeveloper".localized())
alert.addButton(withTitle: "CloseAlert".localized())
let _ = alert.runModal()
}
}
func incomingTransfer(id: String, didFinishWith error: Error?) {
guard let transfer = activeIncomingTransfers[id] else { return }
if let error = error {
var description = ""
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ wants to open \"%2$@\" on your Mac.";
"InsertedIntoClipboard" = "Inserted";
"UnsupportedFileType" = "The file you tried to send is currently not supported. Please send an error report.";
/* No comment provided by engineer. */
"Error.Crypto" = "Encryption error";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "يرغب %1$@ في فتح \"%2$@\" على جهاز Mac الخاص بك.";
"InsertedIntoClipboard" = "تم الإدراج";
"UnsupportedFileType" = "الملف الذي حاولت إرساله غير مدعوم حالياً. يُرجى إرسال تقرير بالخطأ.";
/* No comment provided by engineer. */
"Error.Crypto" = "خطأ في التشفير";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ möchte \"%2$@\" auf deinem Mac öffnen.";
"InsertedIntoClipboard" = "Eingefügt";
"UnsupportedFileType" = "Die Datei, die du senden wolltest, wird derzeit nicht unterstützt. Bitte sende einen Fehlerbericht.";
/* No comment provided by engineer. */
"Error.Crypto" = "Verschlüsselungsfehler";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ quiere abrir \"%2$@\" en tu Mac.";
"InsertedIntoClipboard" = "Insertado";
"UnsupportedFileType" = "El archivo que intentaste enviar no es compatible actualmente. Por favor, envía un informe de error.";
/* No comment provided by engineer. */
"Error.Crypto" = " Error de encriptación";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ souhaite ouvrir \"%2$@\" sur votre Mac.";
"InsertedIntoClipboard" = "Inséré";
"UnsupportedFileType" = "Le fichier que vous avez essayé d'envoyer n'est pas pris en charge actuellement. Veuillez envoyer un rapport d'erreur.";
/* No comment provided by engineer. */
"Error.Crypto" = "Erreur de cryptage";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ meg szeretné nyitni a(z) \"%2$@\" hivatkozást a Mac-eden.";
"InsertedIntoClipboard" = "Beillesztve";
"UnsupportedFileType" = "A fájl, amelyet megpróbáltál küldeni, jelenleg nem támogatott. Kérjük, küldj hibajelentést.";
/* No comment provided by engineer. */
"Error.Crypto" = "Titkosítási hiba";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ vuole aprire \"%2$@\" sul tuo Mac.";
"InsertedIntoClipboard" = "Inserito";
"UnsupportedFileType" = "Il file che hai provato a inviare non è attualmente supportato. Invia un rapporto di errore.";
/* No comment provided by engineer. */
"Error.Crypto" = "Errore di crittografia";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ があなたの Mac で \"%2$@\" を開こうとしています。";
"InsertedIntoClipboard" = "挿入されました";
"UnsupportedFileType" = "送信しようとしたファイルは現在サポートされていません。エラーレポートを送信してください。";
/* No comment provided by engineer. */
"Error.Crypto" = "暗号化エラー";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@이(가) Mac에서 \"%2$@\"을(를) 열려고 합니다.";
"InsertedIntoClipboard" = "삽입됨";
"UnsupportedFileType" = "보내려는 파일은 현재 지원되지 않습니다. 오류 보고서를 보내주세요.";
/* No comment provided by engineer. */
"Error.Crypto" = "암호화 오류";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ wil \"%2$@\" openen op je Mac.";
"InsertedIntoClipboard" = "Ingevoerd";
"UnsupportedFileType" = "Het bestand dat je probeerde te verzenden, wordt momenteel niet ondersteund. Stuur een foutrapport.";
/* No comment provided by engineer. */
"Error.Crypto" = "Fout bij codering";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ deseja abrir \"%2$@\" no seu Mac.";
"InsertedIntoClipboard" = "Inserido";
"UnsupportedFileType" = "O arquivo que você tentou enviar não é compatível no momento. Por favor, envie um relatório de erro.";
/* No comment provided by engineer. */
"Error.Crypto" = "Erro de encriptação";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ pretende abrir \"%2$@\" no seu Mac.";
"InsertedIntoClipboard" = "Inserido";
"UnsupportedFileType" = "O ficheiro que tentou enviar não é atualmente suportado. Por favor, envie um relatório de erro.";
/* No comment provided by engineer. */
"Error.Crypto" = "Erro de encriptação";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ dorește să deschidă \"%2$@\" pe Mac-ul tău.";
"InsertedIntoClipboard" = "Inserat";
"UnsupportedFileType" = "Fișierul pe care ai încercat să-l trimiți nu este momentan acceptat. Te rugăm să trimiți un raport de eroare.";
/* No comment provided by engineer. */
"Error.Crypto" = "Eroare de criptare";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ хочет открыть \"%2$@\" на вашем Mac.";
"InsertedIntoClipboard" = "Вставлено";
"UnsupportedFileType" = "Файл, который вы пытались отправить, в настоящее время не поддерживается. Пожалуйста, отправьте отчет об ошибке.";
/* No comment provided by engineer. */
"Error.Crypto" = "Ошибка шифрования";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ ต้องการเปิด \"%2$@\" บน Mac ของคุณ";
"InsertedIntoClipboard" = "แทรกแล้ว";
"UnsupportedFileType" = "ไฟล์ที่คุณพยายามส่งยังไม่รองรับในขณะนี้ โปรดส่งรายงานข้อผิดพลาด";
/* No comment provided by engineer. */
"Error.Crypto" = "การเข้ารหัสผิดพลาด";
+1
View File
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ хоче відкрити \"%2$@\" на вашому Mac.";
"InsertedIntoClipboard" = "Вставлено";
"UnsupportedFileType" = "Файл, який ви намагалися надіслати, наразі не підтримується. Будь ласка, надішліть звіт про помилку.";
/* No comment provided by engineer. */
"Error.Crypto" = "Помилка шифрування";
@@ -16,6 +16,7 @@
"DeviceSendingUrl" = "%1$@ 想要在你的 Mac 上打开 \"%2$@\"。";
"InsertedIntoClipboard" = "已插入";
"UnsupportedFileType" = "您尝试发送的文件当前不受支持。请发送错误报告。";
/* No comment provided by engineer. */
"Error.Crypto" = "加密出错";
+10 -2
View File
@@ -369,12 +369,20 @@ class InboundNearbyConnection: NearbyConnection {
}
}
else {
rejectTransfer(with: .unsupportedAttachmentType)
rejectDueToUnsupportedFileType(frame)
}
} else {
rejectTransfer(with: .unsupportedAttachmentType)
rejectDueToUnsupportedFileType(frame)
}
}
func rejectDueToUnsupportedFileType(_ frame: Sharing_Nearby_Frame) {
log("Rejecting transfer due to unsupported file type. Frame is \(frame.debugDescription)")
NearbyConnectionManager.shared.mainAppDelegate?.showUnsupportedFileAlert(for: remoteDeviceInfo)
rejectTransfer(with: .unsupportedAttachmentType)
}
func submitUserConsent(accepted: Bool, storeInTemp: Bool = false) {
DispatchQueue.global(qos: .utility).async {
@@ -146,6 +146,7 @@ public protocol MainAppDelegate {
func incomingTransfer(id: String, didFinishWith error: Error?)
func showFirewallAlert()
func showCopiedToClipboardAlert()
func showUnsupportedFileAlert(for: RemoteDeviceInfo?)
}
public protocol ShareExtensionDelegate: AnyObject {