mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
Add sendMessage to fileprovidersocketcontroller
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
parent
28a79d4767
commit
9f2fff3782
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user