diff --git a/src/gui/macOS/fileprovidersocketcontroller.cpp b/src/gui/macOS/fileprovidersocketcontroller.cpp index 04cf67964c..af90a22f05 100644 --- a/src/gui/macOS/fileprovidersocketcontroller.cpp +++ b/src/gui/macOS/fileprovidersocketcontroller.cpp @@ -57,6 +57,24 @@ void FileProviderSocketController::slotReadyRead() } } +void FileProviderSocketController::sendMessage(const QString &message) const +{ + if (!_socket) { + qCWarning(lcFileProviderSocketController) << "Not sending message on dead file provider socket:" << message; + return; + } + + qCDebug(lcFileProviderSocketController) << "Sending File Provider socket message:" << message; + const auto lineEndChar = '\n'; + const auto messageToSend = message.endsWith(lineEndChar) ? message : message + lineEndChar; + const auto bytesToSend = messageToSend.toUtf8(); + const auto sent = _socket->write(bytesToSend); + + if (sent != bytesToSend.length()) { + qCWarning(lcFileProviderSocketController) << "Could not send all data on file provider socket for:" << message; + } +} + } } diff --git a/src/gui/macOS/fileprovidersocketcontroller.h b/src/gui/macOS/fileprovidersocketcontroller.h index 6a17eb8263..54ad59c7bd 100644 --- a/src/gui/macOS/fileprovidersocketcontroller.h +++ b/src/gui/macOS/fileprovidersocketcontroller.h @@ -32,6 +32,9 @@ public: signals: void socketDestroyed(const QLocalSocket * const socket); +public slots: + void sendMessage(const QString &message) const; + private slots: void slotOnDisconnected(); void slotSocketDestroyed(QObject *object);