From 8d6da37030be810284e011ce2b057c0b161af345 Mon Sep 17 00:00:00 2001 From: Raul Metsma Date: Fri, 15 May 2026 14:57:48 +0300 Subject: [PATCH] Use Apple modern NSSharingService API IB-8952 Reported by Mark Zelinski (mazeli@taltech.ee) Signed-off-by: Raul Metsma --- client/Application_mac.mm | 49 +++++------------------------------ qdigidoc4.eToken.entitlements | 11 -------- qdigidoc4.entitlements | 11 -------- 3 files changed, 7 insertions(+), 64 deletions(-) diff --git a/client/Application_mac.mm b/client/Application_mac.mm index bf5eee56e..1282fdb97 100644 --- a/client/Application_mac.mm +++ b/client/Application_mac.mm @@ -20,7 +20,6 @@ #include "Application.h" #include -#include #include #include #include @@ -100,49 +99,15 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr void Application::mailTo( const QUrl &url ) { QUrlQuery q(url); - if(NSURL *appUrl = [NSWorkspace.sharedWorkspace URLForApplicationToOpenURL:url.toNSURL()]) + NSSharingService *service = [NSSharingService sharingServiceNamed:NSSharingServiceNameComposeEmail]; + if(service) { - QString p; - QTextStream s( &p ); - if([appUrl.path rangeOfString:@"/Applications/Mail.app"].location != NSNotFound) - { - s << "on run" << Qt::endl - << "set vattachment to \"" << q.queryItemValue("attachment") << "\"" << Qt::endl - << "set vsubject to \"" << q.queryItemValue("subject") << "\"" << Qt::endl - << "tell application \"Mail\"" << Qt::endl - << "set msg to make new outgoing message with properties {subject:vsubject, visible:true}" << Qt::endl - << "tell content of msg to make new attachment with properties {file name:(vattachment as POSIX file) as alias}" << Qt::endl - << "activate" << Qt::endl - << "end tell" << Qt::endl - << "end run" << Qt::endl; - } - else if([appUrl.path rangeOfString:@"Outlook"].location != NSNotFound) - { - s << "on run" << Qt::endl - << "set vattachment to \"" << q.queryItemValue(u"attachment"_s) << "\" as POSIX file" << Qt::endl - << "set vsubject to \"" << q.queryItemValue(u"subject"_s) << "\"" << Qt::endl - << "tell application \"Microsoft Outlook\"" << Qt::endl - << "activate" << Qt::endl - << "set vmessage to make new outgoing message with properties {subject:vsubject}" << Qt::endl - << "make new attachment at vmessage with properties {file: vattachment}" << Qt::endl - << "open vmessage" << Qt::endl - << "end tell" << Qt::endl - << "end run" << Qt::endl; - } -#if 0 - else if([appUrl.path rangeOfString:"/Applications/Thunderbird.app"].location != NSNotFound) - { - // TODO: Handle Thunderbird here? Impossible? - } -#endif - if(!p.isEmpty()) - { - NSDictionary *err; - if([[[NSAppleScript alloc] initWithSource:p.toNSString()] executeAndReturnError:&err]) - return; - } + service.subject = q.queryItemValue(u"subject"_s).toNSString(); + NSURL *fileURL = [NSURL fileURLWithPath:q.queryItemValue(u"attachment"_s).toNSString()]; + [service performWithItems:@[fileURL]]; + return; } - QDesktopServices::openUrl( url ); + QDesktopServices::openUrl(url); } QString Application::groupContainerPath() diff --git a/qdigidoc4.eToken.entitlements b/qdigidoc4.eToken.entitlements index 90d7ce138..5d62ea2b6 100644 --- a/qdigidoc4.eToken.entitlements +++ b/qdigidoc4.eToken.entitlements @@ -10,13 +10,6 @@ com.apple.security.print - com.apple.security.scripting-targets - - com.apple.mail - - com.apple.mail.compose - - com.apple.security.smartcard com.apple.security.cs.disable-library-validation @@ -25,10 +18,6 @@ group.ee.ria.qdigidoc4.tsl - com.apple.security.temporary-exception.apple-events - - com.microsoft.outlook - com.apple.security.temporary-exception.files.absolute-path.read-only /private/etc/eToken.conf diff --git a/qdigidoc4.entitlements b/qdigidoc4.entitlements index 8074dfedb..918db428d 100644 --- a/qdigidoc4.entitlements +++ b/qdigidoc4.entitlements @@ -14,22 +14,11 @@ com.apple.security.print - com.apple.security.scripting-targets - - com.apple.mail - - com.apple.mail.compose - - com.apple.security.smartcard com.apple.security.application-groups group.ee.ria.qdigidoc4.tsl - com.apple.security.temporary-exception.apple-events - - com.microsoft.outlook -