From 5da48a5239eeb82c086da8f8c2f489fe82f86996 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Fri, 31 Aug 2018 15:03:33 +0200 Subject: [PATCH] SocketApi: Fix owncloud/enterprise#2938 --- src/gui/socketapi.cpp | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index 427110b46..3e6291815 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -58,6 +58,9 @@ #include +#ifdef Q_OS_MAC +#include +#endif // This is the version that is returned when the client asks for the VERSION. // The first number should be changed if there is an incompatible change that breaks old clients. @@ -198,8 +201,19 @@ SocketApi::SocketApi(QObject *parent) // Example for official signed packages: "9B5WD74GWJ." "com.owncloud.desktopclient" ".socketApi" socketPath = SOCKETAPI_TEAM_IDENTIFIER_PREFIX APPLICATION_REV_DOMAIN ".socketApi"; #ifdef Q_OS_MAC + int ret = 0; + CFURLRef url = (CFURLRef)CFAutorelease((CFURLRef)CFBundleCopyBundleURL(CFBundleGetMainBundle())); + QString bundlePath = QUrl::fromCFURL(url).path(); + QString cmd; + // Tell Finder to use the Extension (checking it from System Preferences -> Extensions) - system("pluginkit -e use -i " APPLICATION_REV_DOMAIN ".FinderSyncExt &"); + cmd = QString("pluginkit -v -e use -i " APPLICATION_REV_DOMAIN ".FinderSyncExt"); + ret = system(cmd.toLocal8Bit()); + + // Add it again. This was needed for Mojave to trigger a load. + cmd = QString("pluginkit -v -a ") + bundlePath + "Contents/PlugIns/FinderSyncExt.appex/"; + ret = system(cmd.toLocal8Bit()); + #endif } else if (Utility::isLinux() || Utility::isBSD()) { QString runtimeDir; @@ -238,11 +252,6 @@ SocketApi::~SocketApi() // All remaining sockets will be destroyed with _localServer, their parent ASSERT(_listeners.isEmpty() || _listeners.first().socket->parent() == &_localServer); _listeners.clear(); - -#ifdef Q_OS_MAC - // Unload the extension (uncheck from System Preferences -> Extensions) - system("pluginkit -e ignore -i " APPLICATION_REV_DOMAIN ".FinderSyncExt &"); -#endif } void SocketApi::slotNewConnection() -- 2.30.2