Skip to content

Commit

Permalink
Rewrite QuickLook plugin to use recent API
Browse files Browse the repository at this point in the history
IB-7359

Signed-off-by: Raul Metsma <[email protected]>
  • Loading branch information
metsma committed Aug 15, 2022
1 parent fc725df commit d9b7e79
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
2 changes: 1 addition & 1 deletion client/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class DigidocConf: public digidoc::XmlConfCurrent
bool PKCS12Disable() const override
{ return s.value(QStringLiteral("PKCS12Disable"), digidoc::XmlConfCurrent::PKCS12Disable()).toBool(); }
std::string TSLCache() const override
{ return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation).toStdString(); }
{ return Application::groupContainer().toStdString(); }
bool TSLOnlineDigest() const override
{ return s.value(QStringLiteral("TSLOnlineDigest"), digidoc::XmlConfCurrent::TSLOnlineDigest()).toBool(); }

Expand Down
3 changes: 3 additions & 0 deletions client/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ class Application final: public Common
static QVariant confValue(ConfParameter parameter, const QVariant &value = {});
static void clearConfValue( ConfParameter parameter );
static void setConfValue( ConfParameter parameter, const QVariant &value );
#if defined(Q_OS_MAC)
static QString groupContainer();
#endif

public Q_SLOTS:
void showAbout();
Expand Down
24 changes: 15 additions & 9 deletions client/Application_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ - (void)appReopen:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDe
QApplication::postEvent( qApp, new REOpenEvent );
}

- (void)openClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error
- (void)openClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString * __autoreleasing *)error
{
Q_UNUSED(data)
Q_UNUSED(error)
Expand All @@ -50,7 +50,7 @@ - (void)openClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
QMetaObject::invokeMethod( qApp, "showClient", Q_ARG(QStringList,result) );
}

- (void)signClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error
- (void)signClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString * __autoreleasing *)error
{
Q_UNUSED(data)
Q_UNUSED(error)
Expand All @@ -60,7 +60,7 @@ - (void)signClient:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
QMetaObject::invokeMethod(qApp, "showClient", Q_ARG(QStringList,result), Q_ARG(bool,false), Q_ARG(bool,true));
}

- (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString **)error
- (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSString * __autoreleasing *)error
{
Q_UNUSED(data)
Q_UNUSED(error)
Expand All @@ -77,6 +77,12 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
[NSDocumentController.sharedDocumentController noteNewRecentDocumentURL:[NSURL fileURLWithPath:file.toNSString()]];
}

QString Application::groupContainer()
{
NSURL *directory = [NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:@"ET847QJV9F.ee.ria.qdigidoc4.shared"];
return QString::fromNSString(directory.path);
}

void Application::initMacEvents()
{
static bool isInitalized = false;
Expand Down Expand Up @@ -109,8 +115,8 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
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
<< "set vattachment to \"" << q.queryItemValue(QStringLiteral("attachment")) << "\"" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue(QStringLiteral("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
Expand All @@ -121,8 +127,8 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
else if([appUrl.path rangeOfString:@"Entourage"].location != NSNotFound)
{
s << "on run" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue("attachment") << "\"" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue("subject") << "\"" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue(QStringLiteral("attachment")) << "\"" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue(QStringLiteral("subject")) << "\"" << Qt::endl
<< "tell application \"Microsoft Entourage\"" << Qt::endl
<< "set vmessage to make new outgoing message with properties" << Qt::endl
<< "{subject:vsubject, attachments:vattachment}" << Qt::endl
Expand All @@ -134,8 +140,8 @@ - (void)openCrypto:(NSPasteboard *)pboard userData:(NSString *)data error:(NSStr
else if([appUrl.path rangeOfString:@"Outlook"].location != NSNotFound)
{
s << "on run" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue("attachment") << "\" as POSIX file" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue("subject") << "\"" << Qt::endl
<< "set vattachment to \"" << q.queryItemValue(QStringLiteral("attachment")) << "\" as POSIX file" << Qt::endl
<< "set vsubject to \"" << q.queryItemValue(QStringLiteral("subject")) << "\"" << Qt::endl
<< "tell application \"Microsoft Outlook\"" << Qt::endl
<< "activate" << Qt::endl
<< "set vmessage to make new outgoing message with properties {subject:vsubject}" << Qt::endl
Expand Down
9 changes: 5 additions & 4 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ if( APPLE )
target_link_libraries( ${PROGNAME} "-framework Security" "-framework Quartz" "-framework Cocoa" "-fobjc-arc")
add_custom_command( TARGET ${PROGNAME} POST_BUILD
COMMAND cp -a ${PKCS11_MODULE} $<TARGET_FILE_DIR:${PROGNAME}>
COMMAND mkdir -p $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Library/QuickLook
COMMAND cp -a $<TARGET_BUNDLE_DIR:DigiDocQL> $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Library/QuickLook
COMMAND mkdir -p $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/PlugIns
COMMAND cp -a $<TARGET_BUNDLE_DIR:DigiDocQL> $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/PlugIns
)
add_custom_target( macdeployqt DEPENDS ${PROGNAME}
COMMAND ${qtCore_install_prefix}/macdeployqt $<TARGET_BUNDLE_DIR:${PROGNAME}>
Expand All @@ -195,8 +195,9 @@ if( APPLE )
$<TARGET_FILE_DIR:${PROGNAME}>/*.*
$<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Frameworks/digidocpp.framework/Libraries/*
$<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Frameworks/*.framework
$<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/PlugIns/*/*
$<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/Library/QuickLook/DigiDocQL.qlgenerator
$<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/PlugIns/*/*.dylib
COMMAND codesign -f -s \"$$SIGNCERT\" $<TARGET_BUNDLE_CONTENT_DIR:${PROGNAME}>/PlugIns/DigiDocQL.appex
--entitlements ${CMAKE_SOURCE_DIR}/extensions/DigiDocQL/PreviewViewController.entitlements
COMMAND if echo \"$$SIGNCERT\" | grep -q "Developer ID" \; then
codesign -f -s \"$$SIGNCERT\" $<TARGET_BUNDLE_DIR:${PROGNAME}> --entitlements ${CMAKE_SOURCE_DIR}/${PROGNAME}.eToken.entitlements\;
else
Expand Down

0 comments on commit d9b7e79

Please sign in to comment.