Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use operation system version to check mac version #415

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/seadrive-gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,9 @@ void SeadriveGui::connectDaemon()
if (!account.isValid()) {
// account has beed deleted, remove account from domain.
rpc_client->deleteDomainAccount(domain_id);
if (!checkOSVersion144()) {
stopDaemon();
}
MessagePoller *message_poller = messagePoller(domain_id);
if (message_poller) {
message_pollers_.remove(domain_id);
Expand Down
27 changes: 23 additions & 4 deletions src/utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include <QSslCipher>
#include <QSslCertificate>

#include <QVersionNumber>
#include <QOperatingSystemVersion>

#include "seadrive-gui.h"

Expand All @@ -54,6 +54,7 @@ const char *kSeafileClientBrand = "SeaDrive";
#if defined(Q_OS_MAC)
const char *kSeadriveWorkDir = "Library/Containers/com.seafile.seadrive.fprovider/Data";
const char *kSeadriveConfDir = "Documents";
const char *kSeadirveProcName = "SeaDrive File Provider";
#elif defined(Q_OS_WIN32)
const char *kSeadriveConfDir = "seadrive";
#else
Expand Down Expand Up @@ -879,13 +880,31 @@ QString trimNULL(QString& s) {

#ifdef Q_OS_MAC
bool checkOSVersion144() {
QString osVersion = QSysInfo::productVersion();
QVersionNumber currentVersion = QVersionNumber::fromString(osVersion);
QVersionNumber minAllowedVersion(14, 4, 0);
QOperatingSystemVersion currentVersion = QOperatingSystemVersion::current();
QOperatingSystemVersion minAllowedVersion(QOperatingSystemVersion::MacOS, 14, 4);

if (currentVersion < minAllowedVersion) {
return false;
}
return true;
}

void stopDaemon()
{
QProcess findProcessId;
findProcessId.start("pgrep", QStringList(kSeadirveProcName));
findProcessId.waitForFinished();
QByteArray result = findProcessId.readAllStandardOutput().trimmed();
if (result.isEmpty()) {
return;
}

QString pidString = QString::fromUtf8(result);
qint64 pid = pidString.toLongLong();

QProcess killProcess;
killProcess.start("kill", QStringList() << "-9" << QString::number(pid));
killProcess.waitForFinished();
}

#endif
1 change: 1 addition & 0 deletions src/utils/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ QString trimNULL(QString& s);

#ifdef Q_OS_MAC
bool checkOSVersion144();
void stopDaemon();
#endif

#endif