From: Hannah von Reth Date: Tue, 12 May 2020 12:10:02 +0000 (+0200) Subject: Fix order of pluginkit commands and modernise X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~104 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=11b9e3fa618a7f807159ddfb0dc172c596aa8f97;p=nextcloud-desktop.git Fix order of pluginkit commands and modernise --- diff --git a/src/gui/socketapi.cpp b/src/gui/socketapi.cpp index e453271bf..e1bfcdf61 100644 --- a/src/gui/socketapi.cpp +++ b/src/gui/socketapi.cpp @@ -64,6 +64,7 @@ #include #include +#include #include #ifdef Q_OS_MAC @@ -232,18 +233,24 @@ 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) - cmd = QString("pluginkit -v -e use -i " APPLICATION_REV_DOMAIN ".FinderSyncExt"); - ret = system(cmd.toLocal8Bit()); + auto _system = [](const QString &cmd, const QStringList &args){ + QProcess process; + process.setProcessChannelMode(QProcess::MergedChannels); + process.start(cmd, args); + if (!process.waitForFinished()) + { + qCWarning(lcSocketApi) << "Failed to load shell extension:" << cmd << args.join(" ") << process.errorString(); + } else { + qCInfo(lcSocketApi) << (process.exitCode() != 0 ? "Failed to load" : "Loaded") << "shell extension:" << cmd << args.join(" ") << process.readAll(); + } + }; // 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()); + _system(QStringLiteral("pluginkit"), {QStringLiteral("-a"),QStringLiteral("%1Contents/PlugIns/FinderSyncExt.appex/").arg(bundlePath)}); + // Tell Finder to use the Extension (checking it from System Preferences -> Extensions) + _system(QStringLiteral("pluginkit"), {QStringLiteral("-e"), QStringLiteral("use"), QStringLiteral("-i"), QStringLiteral(APPLICATION_REV_DOMAIN ".FinderSyncExt")}); #endif } else if (Utility::isLinux() || Utility::isBSD()) {