-
Notifications
You must be signed in to change notification settings - Fork 669
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean-ups before switching macOS to local sockets
- introduce the Platform class, which can do RAII style set-up/tear-down - macOS: move Finder integration into the Utility namespace - move retrieve the socket path into the Utility namespace
- Loading branch information
Showing
13 changed files
with
379 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) by Daniel Molkentin <[email protected]> | ||
* Copyright (C) by Erik Verbruggen <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#include "application.h" | ||
#include "guiutility.h" | ||
|
||
#include <QProcess> | ||
|
||
#import <Foundation/NSBundle.h> | ||
|
||
namespace OCC { | ||
|
||
void Utility::tweakUIStyle() | ||
{ | ||
} | ||
|
||
void Utility::startShellIntegration() | ||
{ | ||
QString bundlePath = QUrl::fromNSURL([NSBundle mainBundle].bundleURL).path(); | ||
|
||
auto _system = [](const QString &cmd, const QStringList &args) { | ||
QProcess process; | ||
process.setProcessChannelMode(QProcess::MergedChannels); | ||
process.start(cmd, args); | ||
if (!process.waitForFinished()) { | ||
qCWarning(lcGuiUtility) << "Failed to load shell extension:" << cmd | ||
<< args.join(QLatin1Char(' ')) << process.errorString(); | ||
} else { | ||
qCInfo(lcGuiUtility) << (process.exitCode() != 0 ? "Failed to load" : "Loaded") | ||
<< "shell extension:" << cmd << args.join(QLatin1Char(' ')) | ||
<< process.readAll(); | ||
} | ||
}; | ||
|
||
// Add it again. This was needed for Mojave to trigger a load. | ||
_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") }); | ||
} | ||
|
||
QString Utility::socketApiSocketPath() | ||
{ | ||
// This must match the code signing Team setting of the extension | ||
// Example for developer builds (with ad-hoc signing identity): "" "com.owncloud.desktopclient" ".socketApi" | ||
// Example for official signed packages: "9B5WD74GWJ." "com.owncloud.desktopclient" ".socketApi" | ||
return QLatin1String(SOCKETAPI_TEAM_IDENTIFIER_PREFIX APPLICATION_REV_DOMAIN ".socketApi"); | ||
} | ||
|
||
} // namespace OCC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) by Erik Verbruggen <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#include "guiutility.h" | ||
#include "theme.h" | ||
|
||
#include <QStandardPaths> | ||
|
||
namespace OCC { | ||
|
||
void Utility::tweakUIStyle() | ||
{ | ||
} | ||
|
||
void Utility::startShellIntegration() | ||
{ | ||
} | ||
|
||
QString Utility::socketApiSocketPath() | ||
{ | ||
QString runtimeDir = QStandardPaths::writableLocation(QStandardPaths::RuntimeLocation); | ||
return runtimeDir + "/" + Theme::instance()->appName() + "/socket"; | ||
} | ||
|
||
} // namespace OCC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) by Erik Verbruggen <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#include "application.h" | ||
#include "guiutility.h" | ||
|
||
#include <QCoreApplication> | ||
|
||
namespace OCC { | ||
|
||
void Utility::tweakUIStyle() | ||
{ | ||
// The Windows style still has pixelated elements with Qt 5.6, | ||
// it's recommended to use the Fusion style in this case, even | ||
// though it looks slightly less native. Check here after the | ||
// QApplication was constructed, but before any QWidget is | ||
// constructed. | ||
if (qGuiApp->devicePixelRatio() > 1) { | ||
QApplication::setStyle(QStringLiteral("fusion")); | ||
} | ||
} | ||
|
||
void Utility::startShellIntegration() | ||
{ | ||
} | ||
|
||
QString Utility::socketApiSocketPath() | ||
{ | ||
return QLatin1String("\\\\.\\pipe\\") + QLatin1String("ownCloud-") + qEnvironmentVariable("USERNAME"); | ||
// TODO: once the windows extension supports multiple | ||
// client connections, switch back to the theme name | ||
// See issue #2388 | ||
// + Theme::instance()->appName(); | ||
} | ||
|
||
} // namespace OCC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright (C) by Erik Verbruggen <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but | ||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
*/ | ||
|
||
#include "platform.h" | ||
|
||
namespace OCC { | ||
|
||
Platform::~Platform() | ||
{ | ||
} | ||
|
||
} // OCC namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
/* | ||
* Copyright (C) by Daniel Molkentin <[email protected]> | ||
* Copyright (C) by Erik Verbruggen <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
|
@@ -12,23 +12,20 @@ | |
* for more details. | ||
*/ | ||
|
||
#include <memory> | ||
|
||
namespace OCC { | ||
namespace Mac { | ||
|
||
/** | ||
* @brief CocoaInitializer provides an AutoRelease Pool via RIIA for use in main() | ||
* @ingroup gui | ||
/** | ||
* @brief The Platform is the baseclass for all platform classes, which in turn implement platform | ||
* specific functionality for the GUI. | ||
*/ | ||
class CocoaInitializer | ||
{ | ||
public: | ||
CocoaInitializer(); | ||
~CocoaInitializer(); | ||
class Platform | ||
{ | ||
public: | ||
virtual ~Platform() = 0; | ||
|
||
private: | ||
class Private; | ||
Private *d; | ||
}; | ||
static std::unique_ptr<Platform> create(); | ||
}; | ||
|
||
} // namespace Mac | ||
} // namespace OCC | ||
} // OCC namespace |
Oops, something went wrong.