From: Claudio Cambra Date: Wed, 28 Dec 2022 16:46:12 +0000 (+0100) Subject: Add sendMessage to fileprovidersocketcontroller X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~96^2^2~55^2~312 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9f2fff37824ef16286e862e00e61313823288a59;p=nextcloud-desktop.git Add sendMessage to fileprovidersocketcontroller Signed-off-by: Claudio Cambra --- diff --git a/src/gui/macOS/fileprovidersocketcontroller.cpp b/src/gui/macOS/fileprovidersocketcontroller.cpp index 04cf67964..af90a22f0 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 6a17eb826..54ad59c7b 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);