Define basic FileProviderDomainSyncStatus private implementation
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 9 Jan 2024 15:30:27 +0000 (23:30 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Mon, 19 Feb 2024 14:45:19 +0000 (22:45 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/macOS/fileproviderdomainsyncstatus.cpp [deleted file]
src/gui/macOS/fileproviderdomainsyncstatus.h
src/gui/macOS/fileproviderdomainsyncstatus_mac.mm [new file with mode: 0644]

diff --git a/src/gui/macOS/fileproviderdomainsyncstatus.cpp b/src/gui/macOS/fileproviderdomainsyncstatus.cpp
deleted file mode 100644 (file)
index 7e7508a..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (C) 2024 by Claudio Cambra <claudio.cambra@nextcloud.com>
-*
-* 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 "fileproviderdomainsyncstatus.h"
-
-namespace OCC::Mac
-{
-
-} // OCC::Mac
\ No newline at end of file
index d95f28779bed44f84c13279fbadeb2cead5d7f3d..fc299a10bdd7d69f997413bfbf1a620922306b3a 100644 (file)
 * for more details.
 */
 
+#include <QObject>
+
 #pragma once
 
 namespace OCC::Mac
 {
 
-class FileProviderDomainSyncStatus
+class FileProviderDomainSyncStatus : public QObject
 {
+    Q_OBJECT
+
+public:
+    explicit FileProviderDomainSyncStatus(const QString &domainIdentifier, QObject *parent = nullptr);
+
+private:
+    class MacImplementation;
+    std::unique_ptr<MacImplementation> d;
 };
 
 } // OCC::Mac
diff --git a/src/gui/macOS/fileproviderdomainsyncstatus_mac.mm b/src/gui/macOS/fileproviderdomainsyncstatus_mac.mm
new file mode 100644 (file)
index 0000000..c8b822a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+* Copyright (C) 2024 by Claudio Cambra <claudio.cambra@nextcloud.com>
+*
+* 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 "fileproviderdomainsyncstatus.h"
+
+#include <QLoggingCategory>
+
+#include "gui/macOS/fileproviderutils.h"
+
+#import <FileProvider/FileProvider.h>
+
+namespace OCC::Mac
+{
+
+Q_LOGGING_CATEGORY(lcMacFileProviderDomainSyncStatus, "nextcloud.gui.macfileproviderdomainsyncstatus", QtInfoMsg)
+
+class FileProviderDomainSyncStatus::MacImplementation
+{
+public:
+    explicit MacImplementation(const QString &domainIdentifier)
+    {
+        _domain = FileProviderUtils::domainForIdentifier(domainIdentifier);
+        _manager = [NSFileProviderManager managerForDomain:_domain];
+
+        if (_manager == nil) {
+            qCWarning(lcMacFileProviderDomainSyncStatus) << "Could not get manager for domain" << domainIdentifier;
+        }
+    }
+
+    ~MacImplementation() = default;
+
+private:
+    NSFileProviderDomain *_domain;
+    NSFileProviderManager *_manager;
+};
+
+FileProviderDomainSyncStatus::FileProviderDomainSyncStatus(const QString &domainIdentifier, QObject *parent)
+    : QObject(parent)
+    , d(std::make_unique<MacImplementation>(domainIdentifier))
+{
+}
+
+} // OCC::Mac