aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--chat.cpp6
-rw-r--r--chat.h2
-rw-r--r--context.cpp18
-rw-r--r--context.h3
-rw-r--r--qml/ChatPage.qml16
-rw-r--r--qml/ChatlistPage.qml12
-rw-r--r--qml/Message.qml4
7 files changed, 39 insertions, 22 deletions
diff --git a/chat.cpp b/chat.cpp
index bcda818..0d023bb 100644
--- a/chat.cpp
+++ b/chat.cpp
@@ -54,6 +54,12 @@ DcChat::getColor()
}
bool
+DcChat::isContactRequest()
+{
+ return dc_chat_is_contact_request(m_chat);
+}
+
+bool
DcChat::canSend()
{
return dc_chat_can_send(m_chat);
diff --git a/chat.h b/chat.h
index 6cb7769..70a813c 100644
--- a/chat.h
+++ b/chat.h
@@ -9,6 +9,7 @@ class DcChat : public QObject {
Q_OBJECT
Q_PROPERTY(uint32_t id READ getId CONSTANT)
Q_PROPERTY(QString name READ getName CONSTANT);
+ Q_PROPERTY(bool isContactRequest READ isContactRequest CONSTANT)
Q_PROPERTY(bool canSend READ canSend CONSTANT)
Q_PROPERTY(bool muted READ isMuted CONSTANT)
@@ -22,6 +23,7 @@ public:
Q_INVOKABLE QString getName();
Q_INVOKABLE QString getProfileImage();
Q_INVOKABLE QColor getColor();
+ Q_INVOKABLE bool isContactRequest ();
Q_INVOKABLE bool canSend();
Q_INVOKABLE bool isMuted();
diff --git a/context.cpp b/context.cpp
index fbd4129..a827d5a 100644
--- a/context.cpp
+++ b/context.cpp
@@ -74,6 +74,18 @@ Context::deleteChat(uint32_t chatId)
dc_delete_chat(m_context, chatId);
}
+void
+Context::blockChat(uint32_t chatId)
+{
+ dc_block_chat(m_context, chatId);
+}
+
+void
+Context::unblockChat(uint32_t chatId)
+{
+ dc_unblock_chat(m_context, chatId);
+}
+
QString
Context::getChatEncrinfo(uint32_t chatId)
{
@@ -212,12 +224,6 @@ Context::setChatMuteDuration(uint32_t chatId, int64_t duration)
return dc_set_chat_mute_duration(m_context, chatId, duration);
}
-uint32_t
-Context::decideOnContactRequest(uint32_t msgId, int decision)
-{
- return dc_decide_on_contact_request(m_context, msgId, decision);
-}
-
DcMessage *
Context::newMessage(int viewtype)
{
diff --git a/context.h b/context.h
index 1b7abc2..02f0711 100644
--- a/context.h
+++ b/context.h
@@ -29,6 +29,8 @@ public:
Q_INVOKABLE DcChatlist *getChatlist(int flags);
Q_INVOKABLE void setChatVisibility(uint32_t chatId, int visibility);
Q_INVOKABLE void deleteChat(uint32_t chatId);
+ Q_INVOKABLE void blockChat(uint32_t chatId);
+ Q_INVOKABLE void unblockChat(uint32_t chatId);
Q_INVOKABLE QString getChatEncrinfo(uint32_t chatId);
Q_INVOKABLE uint32_t getChatEphemeralTimer(uint32_t chatId);
Q_INVOKABLE DcChat *getChat(uint32_t chatId);
@@ -47,7 +49,6 @@ public:
Q_INVOKABLE bool setChatMuteDuration(uint32_t chatId, int64_t duration);
Q_INVOKABLE QString getMessageInfo(uint32_t msgId);
Q_INVOKABLE QString getMessageHtml(uint32_t msgId);
- Q_INVOKABLE uint32_t decideOnContactRequest(uint32_t msgId, int decision);
Q_INVOKABLE DcMessage *newMessage(int viewtype);
Q_INVOKABLE void importBackup(QString tarfile);
diff --git a/qml/ChatPage.qml b/qml/ChatPage.qml
index 3099488..9b2e7c6 100644
--- a/qml/ChatPage.qml
+++ b/qml/ChatPage.qml
@@ -15,7 +15,20 @@ Kirigami.ScrollablePage {
required property DcAccountsEventEmitter eventEmitter
required property var chatId
- readonly property DcChat chat: context.getChat(chatId)
+ property DcChat chat: context.getChat(chatId)
+
+ contextualActions: [
+ Kirigami.Action {
+ text: "Accept contact request"
+ onTriggered: chatPage.context.unblockChat(chatPage.chatId)
+ visible: chatPage.chat && chatPage.chat.isContactRequest
+ },
+ Kirigami.Action {
+ text: "Block contact request"
+ onTriggered: chatPage.context.blockChat(chatPage.chatId)
+ visible: chatPage.chat && chatPage.chat.isContactRequest
+ }
+ ]
function updateMessagelist() {
// Reverse message list, because it is laid out from bottom to top.
@@ -57,6 +70,7 @@ Kirigami.ScrollablePage {
function onChatModified() {
console.log("CHAT MODIFIED!")
+ chatPage.chat = context.getChat(chatId)
}
function onIncomingMessage(accountId, chatId, msgId) {
console.log("Incoming message for chat " + chatId)
diff --git a/qml/ChatlistPage.qml b/qml/ChatlistPage.qml
index 343b8da..7ba516a 100644
--- a/qml/ChatlistPage.qml
+++ b/qml/ChatlistPage.qml
@@ -49,14 +49,6 @@ Kirigami.ScrollablePage {
console.log("Can't open Settings page")
}
}
- },
- Kirigami.Action {
- text: "Contact requests"
- onTriggered: {
- chatlist.currentIndex = -1
- loadChat(1)
- console.log("Opening contact requests chat");
- }
}
]
@@ -145,8 +137,8 @@ Kirigami.ScrollablePage {
var chatId = chatlistModel.get(chatlist.currentIndex).chatId
- if (chatId == 1 || chatId > 9) {
- // chatId == DC_CHAT_ID_DEADDROP || chatId > DC_CHAT_ID_LAST_SPECIAL
+ if (chatId > 9) {
+ // chatId > DC_CHAT_ID_LAST_SPECIAL
loadChat(chatId)
} else if (chatId == 6) {
diff --git a/qml/Message.qml b/qml/Message.qml
index 1c7f7f3..69f5f62 100644
--- a/qml/Message.qml
+++ b/qml/Message.qml
@@ -148,10 +148,6 @@ RowLayout {
text: "Info"
onTriggered: messageDialog.open()
}
- Action {
- text: "Start chat"
- onTriggered: messageObject.context.decideOnContactRequest(messageObject.message.id, 0)
- }
}
}