Rename FileProviderSocketController to FileProviderSocketManager, as it manages the...
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 22 Dec 2022 11:12:10 +0000 (12:12 +0100)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 12 May 2023 05:21:07 +0000 (13:21 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/CMakeLists.txt
src/gui/macOS/fileprovidersocketcontroller.cpp [deleted file]
src/gui/macOS/fileprovidersocketcontroller.h [deleted file]
src/gui/macOS/fileprovidersocketcontroller_mac.mm [deleted file]
src/gui/macOS/fileprovidersocketmanager.cpp [new file with mode: 0644]
src/gui/macOS/fileprovidersocketmanager.h [new file with mode: 0644]
src/gui/macOS/fileprovidersocketmanager_mac.mm [new file with mode: 0644]

index cd63cda99388b9bc3871bd8c53203b4c0d3c345b..dcef701dcb23fbcbab87dd87fffc2fb1d1dbb26f 100644 (file)
@@ -285,9 +285,9 @@ IF( APPLE )
         macOS/fileprovider_mac.mm
         macOS/fileproviderdomainmanager.h
         macOS/fileproviderdomainmanager_mac.mm
-        macOS/fileprovidersocketcontroller.h
-        macOS/fileprovidersocketcontroller.cpp
-        macOS/fileprovidersocketcontroller_mac.mm)
+        macOS/fileprovidersocketmanager.h
+        macOS/fileprovidersocketmanager.cpp
+        macOS/fileprovidersocketmanager_mac.mm)
 
     if(SPARKLE_FOUND AND BUILD_UPDATER)
         # Define this, we need to check in updater.cpp
diff --git a/src/gui/macOS/fileprovidersocketcontroller.cpp b/src/gui/macOS/fileprovidersocketcontroller.cpp
deleted file mode 100644 (file)
index 6ed6e0f..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2022 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 "fileprovidersocketcontroller.h"
-
-namespace OCC
-{
-
-namespace Mac
-{
-
-Q_LOGGING_CATEGORY(lcFileProviderSocketController, "nextcloud.gui.macos.fileprovider.socketcontroller", QtInfoMsg)
-
-FileProviderSocketController::FileProviderSocketController(QObject *parent)
-    : QObject{parent}
-{
-#ifdef Q_OS_MACOS
-    _socketPath = fileProviderSocketPath();
-#endif
-    startListening();
-}
-
-void FileProviderSocketController::startListening()
-{
-    QLocalServer::removeServer(_socketPath);
-
-    const auto serverStarted = _socketServer.listen(_socketPath);
-    if (!serverStarted) {
-        qCWarning(lcFileProviderSocketController) << "Could not start file provider socket server"
-                                                  << _socketPath;
-    } else {
-        qCInfo(lcFileProviderSocketController) << "File provider socket server started, listening"
-                                               << _socketPath;
-    }
-
-    connect(&_socketServer, &QLocalServer::newConnection,
-            this, &FileProviderSocketController::slotNewConnection);
-}
-
-void FileProviderSocketController::slotNewConnection()
-{
-    if (!_socketServer.hasPendingConnections()) {
-        return;
-    }
-
-    const auto socket = _socketServer.nextPendingConnection();
-    if (!socket) {
-        return;
-    }
-}
-
-} // namespace Mac
-
-} // namespace OCC
diff --git a/src/gui/macOS/fileprovidersocketcontroller.h b/src/gui/macOS/fileprovidersocketcontroller.h
deleted file mode 100644 (file)
index feb6447..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2022 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.
- */
-
-#pragma once
-
-#include <QObject>
-#include <QLocalServer>
-#include <QLoggingCategory>
-
-namespace OCC
-{
-
-namespace Mac {
-
-#ifdef Q_OS_MACOS
-QString fileProviderSocketPath();
-#endif
-
-class FileProviderSocketController : public QObject
-{
-    Q_OBJECT
-
-public:
-    explicit FileProviderSocketController(QObject *parent = nullptr);
-
-private slots:
-    void startListening();
-    void slotNewConnection();
-
-private:
-    QString _socketPath;
-    QLocalServer _socketServer;
-
-};
-
-} // namespace Mac
-
-} // namespace OCC
diff --git a/src/gui/macOS/fileprovidersocketcontroller_mac.mm b/src/gui/macOS/fileprovidersocketcontroller_mac.mm
deleted file mode 100644 (file)
index 8377adb..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2022 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.
- */
-
-#import <Cocoa/Cocoa.h>
-#import <QString>
-
-#include "config.h"
-
-namespace OCC
-{
-
-namespace Mac
-{
-
-QString fileProviderSocketPath()
-{
-    // This must match the code signing Team setting of the extension
-    // Example for developer builds (with ad-hoc signing identity): "" "com.owncloud.desktopclient" ".fileprovidersocket"
-    // Example for official signed packages: "9B5WD74GWJ." "com.owncloud.desktopclient" ".fileprovidersocket"
-    NSString *appGroupId = @SOCKETAPI_TEAM_IDENTIFIER_PREFIX APPLICATION_REV_DOMAIN;
-
-    NSURL *container = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:appGroupId];
-    NSURL *socketPath = [container URLByAppendingPathComponent:@".fileprovidersocket" isDirectory:false];
-    return QString::fromNSString(socketPath.path);
-}
-
-} // namespace Mac
-
-} // namespace OCC
diff --git a/src/gui/macOS/fileprovidersocketmanager.cpp b/src/gui/macOS/fileprovidersocketmanager.cpp
new file mode 100644 (file)
index 0000000..0a571db
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2022 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 "fileprovidersocketmanager.h"
+
+#include <QLocalSocket>
+
+namespace OCC
+{
+
+namespace Mac
+{
+
+Q_LOGGING_CATEGORY(lcFileProviderSocketManager, "nextcloud.gui.macos.fileprovider.socketmanager", QtInfoMsg)
+
+FileProviderSocketManager::FileProviderSocketManager(QObject *parent)
+    : QObject{parent}
+{
+#ifdef Q_OS_MACOS
+    _socketPath = fileProviderSocketPath();
+#endif
+    startListening();
+}
+
+void FileProviderSocketManager::startListening()
+{
+    QLocalServer::removeServer(_socketPath);
+
+    const auto serverStarted = _socketServer.listen(_socketPath);
+    if (!serverStarted) {
+        qCWarning(lcFileProviderSocketManager) << "Could not start file provider socket server"
+                                               << _socketPath;
+    } else {
+        qCInfo(lcFileProviderSocketManager) << "File provider socket server started, listening"
+                                            << _socketPath;
+    }
+
+    connect(&_socketServer, &QLocalServer::newConnection,
+            this, &FileProviderSocketManager::slotNewConnection);
+}
+
+void FileProviderSocketManager::slotNewConnection()
+{
+    if (!_socketServer.hasPendingConnections()) {
+        return;
+    }
+
+    const auto socket = _socketServer.nextPendingConnection();
+    if (!socket) {
+        return;
+    }
+
+}
+
+} // namespace Mac
+
+} // namespace OCC
diff --git a/src/gui/macOS/fileprovidersocketmanager.h b/src/gui/macOS/fileprovidersocketmanager.h
new file mode 100644 (file)
index 0000000..df6f195
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#pragma once
+
+#include <QObject>
+#include <QLocalServer>
+#include <QLoggingCategory>
+
+namespace OCC
+{
+
+namespace Mac {
+
+#ifdef Q_OS_MACOS
+QString fileProviderSocketPath();
+#endif
+
+class FileProviderSocketManager : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit FileProviderSocketManager(QObject *parent = nullptr);
+
+private slots:
+    void startListening();
+    void slotNewConnection();
+
+private:
+    QString _socketPath;
+    QLocalServer _socketServer;
+};
+
+} // namespace Mac
+
+} // namespace OCC
diff --git a/src/gui/macOS/fileprovidersocketmanager_mac.mm b/src/gui/macOS/fileprovidersocketmanager_mac.mm
new file mode 100644 (file)
index 0000000..8377adb
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2022 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.
+ */
+
+#import <Cocoa/Cocoa.h>
+#import <QString>
+
+#include "config.h"
+
+namespace OCC
+{
+
+namespace Mac
+{
+
+QString fileProviderSocketPath()
+{
+    // This must match the code signing Team setting of the extension
+    // Example for developer builds (with ad-hoc signing identity): "" "com.owncloud.desktopclient" ".fileprovidersocket"
+    // Example for official signed packages: "9B5WD74GWJ." "com.owncloud.desktopclient" ".fileprovidersocket"
+    NSString *appGroupId = @SOCKETAPI_TEAM_IDENTIFIER_PREFIX APPLICATION_REV_DOMAIN;
+
+    NSURL *container = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:appGroupId];
+    NSURL *socketPath = [container URLByAppendingPathComponent:@".fileprovidersocket" isDirectory:false];
+    return QString::fromNSString(socketPath.path);
+}
+
+} // namespace Mac
+
+} // namespace OCC