[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ruqola] src: Add support for channel with password
From: Laurent Montel <null () kde ! org>
Date: 2018-09-27 20:53:08
Message-ID: E1g5dHY-0005B1-Uy () code ! kde ! org
[Download RAW message or body]
Git commit b8b7c266b949815ff7708fbdae9733b4de00e2f9 by Laurent Montel.
Committed on 27/09/2018 at 20:52.
Pushed by mlaurent into branch 'master'.
Add support for channel with password
C +36 -26 src/apps/qml/ChannelPasswordDialog.qml [from: \
src/rocketchatrestapi-qt5/chat/getmessagejob.h - 051% similarity] M +16 -0 \
src/apps/qml/Desktop.qml M +1 -0 src/apps/qml/qml.qrc
M +1 -0 src/rocketchatrestapi-qt5/authentication/googleauthjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/archivechanneljob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/changechannelannouncementjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/changechanneldescriptionjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/changechannelnamejob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/changechannelreadonlyjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/changechanneltopicjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/channeladdmoderatorjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/channels/channeladdownerjob.cpp
M +8 -4 src/rocketchatrestapi-qt5/channels/channeljoinjob.cpp
M +2 -1 src/rocketchatrestapi-qt5/channels/channeljoinjob.h
M +4 -5 src/rocketchatrestapi-qt5/chat/getmessagejob.cpp
M +1 -1 src/rocketchatrestapi-qt5/chat/getmessagejob.h
M +2 -3 src/rocketchatrestapi-qt5/chat/ignoreuserjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/directmessage/createdmjob.cpp
M +2 -3 src/rocketchatrestapi-qt5/e2e/addkeytochainjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/e2e/fetchkeychainjob.cpp
M +2 -2 src/rocketchatrestapi-qt5/e2e/fetchmykeysjob.cpp
M +9 -0 src/rocketchatrestapi-qt5/restapiabstractjob.cpp
M +1 -0 src/rocketchatrestapi-qt5/restapiabstractjob.h
M +1 -0 src/rocketchatrestapi-qt5/restapirequest.cpp
M +2 -1 src/rocketchatrestapi-qt5/restapirequest.h
M +7 -1 src/ruqolacore/rocketchataccount.cpp
M +3 -0 src/ruqolacore/rocketchataccount.h
https://commits.kde.org/ruqola/b8b7c266b949815ff7708fbdae9733b4de00e2f9
diff --git a/src/rocketchatrestapi-qt5/chat/getmessagejob.h \
b/src/apps/qml/ChannelPasswordDialog.qml similarity index 51%
copy from src/rocketchatrestapi-qt5/chat/getmessagejob.h
copy to src/apps/qml/ChannelPasswordDialog.qml
index 51ce939f..d5cc6347 100644
--- a/src/rocketchatrestapi-qt5/chat/getmessagejob.h
+++ b/src/apps/qml/ChannelPasswordDialog.qml
@@ -18,40 +18,50 @@
Boston, MA 02110-1301, USA.
*/
-#ifndef GETMESSAGEJOB_H
-#define GETMESSAGEJOB_H
+import QtQuick 2.9
+import QtQuick.Layouts 1.3
+import QtQuick.Controls 2.2 as QQC2
+import QtQuick.Window 2.0
+import KDE.Ruqola.DebugCategory 1.0
-#include "restapiabstractjob.h"
-#include "librestapi_private_export.h"
+QQC2.Dialog {
+ id: channelPasswordDialog
-#include <QNetworkRequest>
-namespace RocketChatRestApi {
-class LIBROCKETCHATRESTAPI_QT5_TESTS_EXPORT GetMessageJob : public \
RestApiAbstractJob
-{
- Q_OBJECT
-public:
- explicit GetMessageJob(QObject *parent = nullptr);
- ~GetMessageJob() override;
+ title: i18n("Channel Password")
- Q_REQUIRED_RESULT bool requireHttpAuthentication() const override;
+ standardButtons: QQC2.Dialog.Ok | QQC2.Dialog.Cancel
- Q_REQUIRED_RESULT bool start() override;
- Q_REQUIRED_RESULT QNetworkRequest request() const override;
+ signal joinRoom(string roomId, string password)
+ x: parent.width / 2 - width / 2
+ y: parent.height / 2 - height / 2
- Q_REQUIRED_RESULT bool canStart() const override;
+ modal: true
- Q_REQUIRED_RESULT QString getMessageId() const;
- void setMessageId(const QString &messageId);
+ property string roomId: ""
-Q_SIGNALS:
- void getMessageDone(const QJsonObject &obj);
+ function initializeAndOpen()
+ {
+ passwordField.text = "";
+ open()
+ }
-private:
- Q_DISABLE_COPY(GetMessageJob)
- void slotIgnoreUserFinished();
- QString mMessageId;
-};
+ ColumnLayout {
+ QQC2.Label {
+ text: i18n("Channel %1", roomId);
+ }
+
+ QQC2.Label {
+ text: i18n("Password:");
+ }
+ QQC2.TextField {
+ id: passwordField
+ selectByMouse: true
+ }
+ }
+
+ onAccepted: {
+ channelPasswordDialog.joinRoom(roomId, passwordField.text)
+ }
}
-#endif // GETMESSAGEJOB_H
diff --git a/src/apps/qml/Desktop.qml b/src/apps/qml/Desktop.qml
index 3f077503..cba8394e 100644
--- a/src/apps/qml/Desktop.qml
+++ b/src/apps/qml/Desktop.qml
@@ -245,6 +245,22 @@ Kirigami.ApplicationWindow {
id: mainComponent
}
+ ChannelPasswordDialog {
+ id: channelPasswordDialog
+ onJoinRoom: {
+ rocketChatAccount.joinRoom(roomId, password)
+ }
+ }
+
+ Connections {
+ target: rocketChatAccount
+ onMissingChannelPassword: {
+ channelPasswordDialog.roomId = roomId
+ channelPasswordDialog.visible = true
+ }
+ }
+
+
onClosing: {
Qt.quit();
}
diff --git a/src/apps/qml/qml.qrc b/src/apps/qml/qml.qrc
index 8a2b5595..3a2eb2a5 100644
--- a/src/apps/qml/qml.qrc
+++ b/src/apps/qml/qml.qrc
@@ -43,6 +43,7 @@
<file>DeleteFileAttachmentDialog.qml</file>
<file>UserInfoDialog.qml</file>
<file>CreateNewAccountDialog.qml</file>
+ <file>ChannelPasswordDialog.qml</file>
</qresource>
<qresource prefix="/messages">
<file alias="SystemMessage.qml">messages/SystemMessage.qml</file>
diff --git a/src/rocketchatrestapi-qt5/authentication/googleauthjob.cpp \
b/src/rocketchatrestapi-qt5/authentication/googleauthjob.cpp index 9b5a89fe..84a6a0b4 \
100644
--- a/src/rocketchatrestapi-qt5/authentication/googleauthjob.cpp
+++ b/src/rocketchatrestapi-qt5/authentication/googleauthjob.cpp
@@ -88,6 +88,7 @@ void GoogleAuthJob::slotGoogleauthDone()
Q_EMIT googleauthDone(authToken, userId);
}
} else {
+ addLoggerWarning("Error during login" + data);
qCWarning(ROCKETCHATQTRESTAPI_LOG) << "Error during login" << data;
}
}
diff --git a/src/rocketchatrestapi-qt5/channels/archivechanneljob.cpp \
b/src/rocketchatrestapi-qt5/channels/archivechanneljob.cpp index 08cb6fd4..10e7c993 \
100644
--- a/src/rocketchatrestapi-qt5/channels/archivechanneljob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/archivechanneljob.cpp
@@ -57,10 +57,10 @@ void ArchiveChannelJob::slotArchiveChannelFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "archive or unarchive channel \
success: " << data; + addLoggerInfo(QByteArrayLiteral("archive or \
unarchive channel success: ") + replyJson.toJson(QJsonDocument::Indented)); Q_EMIT \
archiveChannelDone(); } else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to archive \
or unarchive a channel" << data; + \
addLoggerWarning(QByteArrayLiteral("Problem when we tried to archive or unarchive a \
channel: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/changechannelannouncementjob.cpp \
b/src/rocketchatrestapi-qt5/channels/changechannelannouncementjob.cpp index \
ff1d1df2..0472f3e1 100644
--- a/src/rocketchatrestapi-qt5/channels/changechannelannouncementjob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/changechannelannouncementjob.cpp
@@ -57,10 +57,10 @@ void \
ChangeChannelAnnouncementJob::slotChangeAnnouncementFinished() const QJsonObject \
replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Change announcement success: " << \
data; + addLoggerInfo(QByteArrayLiteral("Change announcement success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT changeAnnouncementDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to change \
announcement: " << data; + addLoggerWarning(QByteArrayLiteral("Problem \
when we tried to change announcement: ") + \
replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/changechanneldescriptionjob.cpp \
b/src/rocketchatrestapi-qt5/channels/changechanneldescriptionjob.cpp index \
42d823c0..f70305f0 100644
--- a/src/rocketchatrestapi-qt5/channels/changechanneldescriptionjob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/changechanneldescriptionjob.cpp
@@ -57,10 +57,10 @@ void ChangeChannelDescriptionJob::slotChangeDescriptionFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Change description success: " << \
data; + addLoggerInfo(QByteArrayLiteral("Change description success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT changeDescriptionDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to change \
description: " << data; + addLoggerWarning(QByteArrayLiteral("Problem when \
we tried to change description: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/changechannelnamejob.cpp \
b/src/rocketchatrestapi-qt5/channels/changechannelnamejob.cpp index \
55dcaef1..ad774f8c 100644
--- a/src/rocketchatrestapi-qt5/channels/changechannelnamejob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/changechannelnamejob.cpp
@@ -57,10 +57,10 @@ void ChangeChannelNameJob::slotChangeNameFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Change name success: " << data;
+ addLoggerInfo(QByteArrayLiteral("Change name success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT changeNameDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to change \
name: " << data; + addLoggerWarning(QByteArrayLiteral("Problem when we \
tried to change name: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/changechannelreadonlyjob.cpp \
b/src/rocketchatrestapi-qt5/channels/changechannelreadonlyjob.cpp index \
49950914..deb64643 100644
--- a/src/rocketchatrestapi-qt5/channels/changechannelreadonlyjob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/changechannelreadonlyjob.cpp
@@ -57,10 +57,10 @@ void ChangeChannelReadonlyJob::slotChangeReadonlyFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Change read only success: " << \
data; + addLoggerInfo(QByteArrayLiteral("Change read only success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT changeReadonlyDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to change \
read only status: " << data; + addLoggerInfo(QByteArrayLiteral("Problem \
when we tried to change read only status: ") + \
replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/changechanneltopicjob.cpp \
b/src/rocketchatrestapi-qt5/channels/changechanneltopicjob.cpp index \
225e62f7..60375478 100644
--- a/src/rocketchatrestapi-qt5/channels/changechanneltopicjob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/changechanneltopicjob.cpp
@@ -56,10 +56,10 @@ void ChangeChannelTopicJob::slotChangeTopicFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Change Topic success: " << data;
+ addLoggerInfo(QByteArrayLiteral("Change Topic success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT changeTopicDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to change \
topic" << data; + addLoggerWarning(QByteArrayLiteral("Problem when we \
tried to change topic: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/channeladdmoderatorjob.cpp \
b/src/rocketchatrestapi-qt5/channels/channeladdmoderatorjob.cpp index \
1c4ad254..4cde3f0f 100644
--- a/src/rocketchatrestapi-qt5/channels/channeladdmoderatorjob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/channeladdmoderatorjob.cpp
@@ -57,10 +57,10 @@ void ChannelAddModeratorJob::slotAddModeratorFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Add owner success: " << data;
+ addLoggerInfo(QByteArrayLiteral("Add moderator success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT addModeratorDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to add \
moderator : " << data; + addLoggerWarning(QByteArrayLiteral("Problem when \
we tried to add moderator: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/channeladdownerjob.cpp \
b/src/rocketchatrestapi-qt5/channels/channeladdownerjob.cpp index 139b9b75..cfda1426 \
100644
--- a/src/rocketchatrestapi-qt5/channels/channeladdownerjob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/channeladdownerjob.cpp
@@ -57,10 +57,10 @@ void ChannelAddOwnerJob::slotAddOwnerFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Add owner success: " << data;
+ addLoggerInfo(QByteArrayLiteral("Add owner success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT addOwnerDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to add \
owner : " << data; + addLoggerWarning(QByteArrayLiteral("Problem when we \
tried to add owner: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/channeljoinjob.cpp \
b/src/rocketchatrestapi-qt5/channels/channeljoinjob.cpp index e1d21da4..1b1a6ccb \
100644
--- a/src/rocketchatrestapi-qt5/channels/channeljoinjob.cpp
+++ b/src/rocketchatrestapi-qt5/channels/channeljoinjob.cpp
@@ -57,11 +57,15 @@ void ChannelJoinJob::slotChannelJoinFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "channel join success: " << data;
- Q_EMIT setChannelJoinDone();
+ addLoggerInfo(QByteArrayLiteral("channel join success: ") + \
replyJson.toJson(QJsonDocument::Indented)); + Q_EMIT \
setChannelJoinDone(mRoomId); } else {
- //Need password ?
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to join to \
channel" << data; + //Need assword ?
+ addLoggerWarning(QByteArrayLiteral("Problem when we tried to join to \
channel: ") + replyJson.toJson(QJsonDocument::Indented)); + //Invalid \
password + if (replyObject[QStringLiteral("errorType")].toString() == \
QLatin1String("error-code-invalid")) { + Q_EMIT \
missingChannelPassword(mRoomId); + }
}
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/channels/channeljoinjob.h \
b/src/rocketchatrestapi-qt5/channels/channeljoinjob.h index 68bac91f..33f4a499 100644
--- a/src/rocketchatrestapi-qt5/channels/channeljoinjob.h
+++ b/src/rocketchatrestapi-qt5/channels/channeljoinjob.h
@@ -46,7 +46,8 @@ public:
void setJoinCode(const QString &joinCode);
Q_SIGNALS:
- void setChannelJoinDone();
+ void setChannelJoinDone(const QString &roomId);
+ void missingChannelPassword(const QString &roomId);
private:
Q_DISABLE_COPY(ChannelJoinJob)
diff --git a/src/rocketchatrestapi-qt5/chat/getmessagejob.cpp \
b/src/rocketchatrestapi-qt5/chat/getmessagejob.cpp index 15bfc02b..6fa2d066 100644
--- a/src/rocketchatrestapi-qt5/chat/getmessagejob.cpp
+++ b/src/rocketchatrestapi-qt5/chat/getmessagejob.cpp
@@ -48,12 +48,12 @@ bool GetMessageJob::start()
return false;
}
QNetworkReply *reply = mNetworkAccessManager->get(request());
- connect(reply, &QNetworkReply::finished, this, \
&GetMessageJob::slotIgnoreUserFinished); + connect(reply, \
&QNetworkReply::finished, this, \
&GetMessageJob::slotGetMessageFinished);
addLoggerInfo(QByteArrayLiteral("GetMessageJob: get message starting"));
return true;
}
-void GetMessageJob::slotIgnoreUserFinished()
+void GetMessageJob::slotGetMessageFinished()
{
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if (reply) {
@@ -61,11 +61,10 @@ void GetMessageJob::slotIgnoreUserFinished()
const QJsonDocument replyJson = QJsonDocument::fromJson(data);
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- addLoggerInfo(QByteArrayLiteral("GetMessageJob: finished: ") + \
replyJson.toJson(QJsonDocument::Indented)); + \
addLoggerInfo(QByteArrayLiteral("GetMessageJob: success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT getMessageDone(replyObject);
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Ignore user success: " << data;
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to get \
message"; + addLoggerInfo(QByteArrayLiteral("GetMessageJob: Problem when \
we tried to get message : ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/chat/getmessagejob.h \
b/src/rocketchatrestapi-qt5/chat/getmessagejob.h index 51ce939f..dd18b04f 100644
--- a/src/rocketchatrestapi-qt5/chat/getmessagejob.h
+++ b/src/rocketchatrestapi-qt5/chat/getmessagejob.h
@@ -50,7 +50,7 @@ Q_SIGNALS:
private:
Q_DISABLE_COPY(GetMessageJob)
- void slotIgnoreUserFinished();
+ void slotGetMessageFinished();
QString mMessageId;
};
}
diff --git a/src/rocketchatrestapi-qt5/chat/ignoreuserjob.cpp \
b/src/rocketchatrestapi-qt5/chat/ignoreuserjob.cpp index 5bf64784..04af24ea 100644
--- a/src/rocketchatrestapi-qt5/chat/ignoreuserjob.cpp
+++ b/src/rocketchatrestapi-qt5/chat/ignoreuserjob.cpp
@@ -61,11 +61,10 @@ void IgnoreUserJob::slotIgnoreUserFinished()
const QJsonDocument replyJson = QJsonDocument::fromJson(data);
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- addLoggerInfo(QByteArrayLiteral("IgnoreUserJob: finished: ") + \
replyJson.toJson(QJsonDocument::Indented)); + \
addLoggerInfo(QByteArrayLiteral("IgnoreUserJob: success: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT ignoreUserDone(replyObject);
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Ignore user success: " << data;
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to ignore \
user message"; + addLoggerWarning(QByteArrayLiteral("GProblem when we \
tried to ignore user message: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/directmessage/createdmjob.cpp \
b/src/rocketchatrestapi-qt5/directmessage/createdmjob.cpp index 2c67e9be..77f3e62e \
100644
--- a/src/rocketchatrestapi-qt5/directmessage/createdmjob.cpp
+++ b/src/rocketchatrestapi-qt5/directmessage/createdmjob.cpp
@@ -58,10 +58,10 @@ void CreateDmJob::slotCreateDmFinished()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Create direct message success: " << \
data; + addLoggerInfo(QByteArrayLiteral("Create direct message sucess: ") \
+ replyJson.toJson(QJsonDocument::Indented)); Q_EMIT createDmDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to create \
direct message: " << data; + addLoggerWarning(QByteArrayLiteral("Create \
direct message Problem: ") + replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/e2e/addkeytochainjob.cpp \
b/src/rocketchatrestapi-qt5/e2e/addkeytochainjob.cpp index e334f97b..1fe08fb6 100644
--- a/src/rocketchatrestapi-qt5/e2e/addkeytochainjob.cpp
+++ b/src/rocketchatrestapi-qt5/e2e/addkeytochainjob.cpp
@@ -53,15 +53,14 @@ void AddKeyToChainJob::slotAddKeyToChainFinished()
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if (reply) {
const QByteArray data = reply->readAll();
- addLoggerInfo(QByteArrayLiteral("AddKeyToChainJob: finished: ") + data);
const QJsonDocument replyJson = QJsonDocument::fromJson(data);
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Change favorite status done: " << \
data; + addLoggerInfo(QByteArrayLiteral("AddKeyToChainJob: sucess: ") + \
replyJson.toJson(QJsonDocument::Indented)); Q_EMIT addKeyToChainDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to change \
favorite status" << data; + \
addLoggerWarning(QByteArrayLiteral("AddKeyToChainJob: Problem: ") + \
replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/e2e/fetchkeychainjob.cpp \
b/src/rocketchatrestapi-qt5/e2e/fetchkeychainjob.cpp index b015fdb0..07a3dc21 100644
--- a/src/rocketchatrestapi-qt5/e2e/fetchkeychainjob.cpp
+++ b/src/rocketchatrestapi-qt5/e2e/fetchkeychainjob.cpp
@@ -70,11 +70,11 @@ void FetchKeyChainJob::slotFetchKeyChain()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- addLoggerInfo(QByteArrayLiteral("FetchKeyChainJob: finished: ") + \
replyJson.toJson(QJsonDocument::Indented)); + \
addLoggerInfo(QByteArrayLiteral("FetchKeyChainJob: success: ") + \
replyJson.toJson(QJsonDocument::Indented)); //TODO
Q_EMIT fetchKeyChainDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to get \
username suggestion" << data; + \
addLoggerWarning(QByteArrayLiteral("FetchKeyChainJob: Problem: ") + \
replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/e2e/fetchmykeysjob.cpp \
b/src/rocketchatrestapi-qt5/e2e/fetchmykeysjob.cpp index 622b1beb..78a4ac52 100644
--- a/src/rocketchatrestapi-qt5/e2e/fetchmykeysjob.cpp
+++ b/src/rocketchatrestapi-qt5/e2e/fetchmykeysjob.cpp
@@ -66,11 +66,11 @@ void FetchMyKeysJob::slotFetchMyKeys()
const QJsonObject replyObject = replyJson.object();
if (replyObject[QStringLiteral("success")].toBool()) {
- addLoggerInfo(QByteArrayLiteral("FetchMyKeysJob: finished: ") + \
replyJson.toJson(QJsonDocument::Indented)); + \
addLoggerInfo(QByteArrayLiteral("FetchMyKeysJob: success: ") + \
replyJson.toJson(QJsonDocument::Indented)); //TODO
Q_EMIT fetchMyKeysDone();
} else {
- qCWarning(ROCKETCHATQTRESTAPI_LOG) <<" Problem when we tried to get \
username suggestion" << data; + \
addLoggerWarning(QByteArrayLiteral("FetchMyKeysJob: success: ") + \
replyJson.toJson(QJsonDocument::Indented)); }
}
deleteLater();
diff --git a/src/rocketchatrestapi-qt5/restapiabstractjob.cpp \
b/src/rocketchatrestapi-qt5/restapiabstractjob.cpp index 16ff317e..d5906e71 100644
--- a/src/rocketchatrestapi-qt5/restapiabstractjob.cpp
+++ b/src/rocketchatrestapi-qt5/restapiabstractjob.cpp
@@ -115,3 +115,12 @@ void RestApiAbstractJob::addLoggerInfo(const QByteArray &str)
qCDebug(ROCKETCHATQTRESTAPI_LOG) << "RESTAPI: " << str;
}
}
+
+void RestApiAbstractJob::addLoggerWarning(const QByteArray &str)
+{
+ if (mRestApiLogger) {
+ mRestApiLogger->dataSent("RESTAPI: " + str);
+ } else {
+ qCWarning(ROCKETCHATQTRESTAPI_LOG) << "RESTAPI: " << str;
+ }
+}
diff --git a/src/rocketchatrestapi-qt5/restapiabstractjob.h \
b/src/rocketchatrestapi-qt5/restapiabstractjob.h index 8d5689ef..9caec5cb 100644
--- a/src/rocketchatrestapi-qt5/restapiabstractjob.h
+++ b/src/rocketchatrestapi-qt5/restapiabstractjob.h
@@ -53,6 +53,7 @@ public:
void setRestApiLogger(RocketChatRestApi::AbstractLogger *restApiLogger);
void addLoggerInfo(const QByteArray &str);
+ void addLoggerWarning(const QByteArray &str);
Q_REQUIRED_RESULT virtual bool canStart() const;
diff --git a/src/rocketchatrestapi-qt5/restapirequest.cpp \
b/src/rocketchatrestapi-qt5/restapirequest.cpp index 397288a8..da029c31 100644
--- a/src/rocketchatrestapi-qt5/restapirequest.cpp
+++ b/src/rocketchatrestapi-qt5/restapirequest.cpp
@@ -959,6 +959,7 @@ void RestApiRequest::channelJoin(const QString &roomId, const \
QString &joinCode) job->setJoinCode(joinCode);
job->setRoomId(roomId);
connect(job, &ChannelJoinJob::setChannelJoinDone, this, \
&RestApiRequest::setChannelJoinDone); + connect(job, \
&ChannelJoinJob::missingChannelPassword, this, \
&RestApiRequest::missingChannelPassword); if (!job->start()) {
qCDebug(ROCKETCHATQTRESTAPI_LOG) << "Impossible to start setChannelJoin";
}
diff --git a/src/rocketchatrestapi-qt5/restapirequest.h \
b/src/rocketchatrestapi-qt5/restapirequest.h index b35679cd..a2cbaa20 100644
--- a/src/rocketchatrestapi-qt5/restapirequest.h
+++ b/src/rocketchatrestapi-qt5/restapirequest.h
@@ -145,7 +145,8 @@ Q_SIGNALS:
void fetchMyKeysDone();
void fetchKeyChainDone();
void setJoinCodeDone();
- void setChannelJoinDone();
+ void setChannelJoinDone(const QString &roomId);
+ void missingChannelPassword(const QString &roomId);
private:
Q_DISABLE_COPY(RestApiRequest)
diff --git a/src/ruqolacore/rocketchataccount.cpp \
b/src/ruqolacore/rocketchataccount.cpp index c695f1e5..dcc4a682 100644
--- a/src/ruqolacore/rocketchataccount.cpp
+++ b/src/ruqolacore/rocketchataccount.cpp
@@ -344,6 +344,8 @@ RocketChatRestApi::RestApiRequest *RocketChatAccount::restApi()
{
if (!mRestApi) {
mRestApi = new RocketChatRestApi::RestApiRequest(this);
+ connect(mRestApi, &RocketChatRestApi::RestApiRequest::setChannelJoinDone, \
this, &RocketChatAccount::setChannelJoinDone); + connect(mRestApi, \
&RocketChatRestApi::RestApiRequest::missingChannelPassword, this, \
&RocketChatAccount::missingChannelPassword); \
mRestApi->setServerUrl(mSettings->serverUrl()); \
mRestApi->setRestApiLogger(mRuqolaLogger); }
@@ -480,6 +482,11 @@ void RocketChatAccount::openChannel(const QString &url)
//TODO search correct room + select it.
}
+void RocketChatAccount::setChannelJoinDone(const QString &roomId)
+{
+ ddp()->subscribeRoomMessage(roomId);
+}
+
void RocketChatAccount::joinJitsiConfCall(const QString &roomId)
{
qCDebug(RUQOLA_LOG) << " void RocketChatAccount::joinJitsiConfCall(const QString \
&roomId)"<<roomId; @@ -543,7 +550,6 @@ void RocketChatAccount::joinRoom(const QString \
&roomId, const QString &joinCode) //TODO use restapi
ddp()->joinRoom(roomId, joinCode);
#endif
- ddp()->subscribeRoomMessage(roomId);
}
void RocketChatAccount::channelAndPrivateAutocomplete(const QString &pattern)
diff --git a/src/ruqolacore/rocketchataccount.h b/src/ruqolacore/rocketchataccount.h
index 64f7c6ba..53004a81 100644
--- a/src/ruqolacore/rocketchataccount.h
+++ b/src/ruqolacore/rocketchataccount.h
@@ -263,6 +263,7 @@ Q_SIGNALS:
void notification(const QString &title, const QString &message, const QPixmap \
&pixmap);
void fileDownloaded(const QString &filePath, const QUrl &cacheImageUrl);
void updateNotification(bool hasAlert, int nbUnread, const QString \
&accountName); + void missingChannelPassword(const QString &roomId);
private:
Q_DISABLE_COPY(RocketChatAccount)
@@ -277,6 +278,8 @@ private:
void initializeAuthenticationPlugins();
void setDefaultAuthentication(AuthenticationManager::OauthType type);
void userStatusChanged(const User &user);
+ void setChannelJoinDone(const QString &roomId);
+
QVector<File> parseFilesInChannel(const QJsonObject &obj);
PluginAuthenticationInterface *mDefaultAuthenticationInterface = nullptr;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic