diff --git a/harbour-fernschreiber.pro b/harbour-fernschreiber.pro
index a85c92e..d2a7fa5 100644
--- a/harbour-fernschreiber.pro
+++ b/harbour-fernschreiber.pro
@@ -27,6 +27,7 @@ SOURCES += src/harbour-fernschreiber.cpp \
src/fernschreiberutils.cpp \
src/notificationmanager.cpp \
src/processlauncher.cpp \
+ src/stickermanager.cpp \
src/tdlibreceiver.cpp \
src/tdlibwrapper.cpp
@@ -111,6 +112,7 @@ HEADERS += \
src/fernschreiberutils.h \
src/notificationmanager.h \
src/processlauncher.h \
+ src/stickermanager.h \
src/tdlibreceiver.h \
src/tdlibsecrets.h \
src/tdlibwrapper.h
diff --git a/qml/pages/ChatPage.qml b/qml/pages/ChatPage.qml
index aaabbc5..1e3a33e 100644
--- a/qml/pages/ChatPage.qml
+++ b/qml/pages/ChatPage.qml
@@ -939,6 +939,20 @@ Page {
}
}
}
+
+ Item {
+ id: stickerPickerOverlayItem
+ anchors.fill: parent
+ visible: false
+ Rectangle {
+ id: stickerPickerOverlayBackground
+ anchors.fill: parent
+
+ color: Theme.overlayBackgroundColor
+ opacity: 0.7
+ }
+ }
+
}
Column {
@@ -1038,11 +1052,20 @@ Page {
pageStack.push(documentPickerPage);
}
}
- IconButton {
- id: stickerAttachmentButton
- icon.source: "../../images/icon-m-sticker.png"
- onClicked: {
- // TODO
+ HighlightImage {
+ source: "../../images/icon-m-sticker.png"
+ width: documentAttachmentButton.width
+ height: documentAttachmentButton.height
+ color: Theme.primaryColor
+ highlightColor: Theme.highlightColor
+ highlighted: stickerPickerOverlayItem.visible
+ MouseArea {
+ anchors.fill: parent
+ onClicked: {
+ //console.log("RECENT STICKERS: " + JSON.stringify(stickerManager.getRecentStickers()));
+ //console.log("INSTALLED SETS: " + JSON.stringify(stickerManager.getInstalledStickerSets()));
+ stickerPickerOverlayItem.visible = !stickerPickerOverlayItem.visible;
+ }
}
}
}
diff --git a/qml/pages/OverviewPage.qml b/qml/pages/OverviewPage.qml
index 4288334..bcc452c 100644
--- a/qml/pages/OverviewPage.qml
+++ b/qml/pages/OverviewPage.qml
@@ -94,6 +94,8 @@ Page {
function updateContent() {
tdLibWrapper.getChats();
+ tdLibWrapper.getRecentStickers();
+ tdLibWrapper.getInstalledStickerSets();
}
function initializePage() {
diff --git a/src/harbour-fernschreiber.cpp b/src/harbour-fernschreiber.cpp
index b020546..b6ad42c 100644
--- a/src/harbour-fernschreiber.cpp
+++ b/src/harbour-fernschreiber.cpp
@@ -36,6 +36,7 @@
#include "notificationmanager.h"
#include "dbusadaptor.h"
#include "processlauncher.h"
+#include "stickermanager.h"
int main(int argc, char *argv[])
{
@@ -66,6 +67,9 @@ int main(int argc, char *argv[])
ProcessLauncher processLauncher;
context->setContextProperty("processLauncher", &processLauncher);
+ StickerManager stickerManager(tdLibWrapper);
+ context->setContextProperty("stickerManager", &stickerManager);
+
view->setSource(SailfishApp::pathTo("qml/harbour-fernschreiber.qml"));
view->show();
return app->exec();
diff --git a/src/stickermanager.cpp b/src/stickermanager.cpp
new file mode 100644
index 0000000..28487aa
--- /dev/null
+++ b/src/stickermanager.cpp
@@ -0,0 +1,96 @@
+/*
+ Copyright (C) 2020 Sebastian J. Wolf
+
+ This file is part of Fernschreiber.
+
+ Fernschreiber is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Fernschreiber is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fernschreiber. If not, see .
+*/
+
+#include "stickermanager.h"
+#include
+#include
+
+#define LOG(x) qDebug() << "[StickerManager]" << x
+
+StickerManager::StickerManager(TDLibWrapper *tdLibWrapper, QObject *parent) : QObject(parent)
+{
+ LOG("Initializing...");
+ this->tdLibWrapper = tdLibWrapper;
+
+ connect(this->tdLibWrapper, SIGNAL(recentStickersUpdated(QVariantList)), this, SLOT(handleRecentStickersUpdated(QVariantList)));
+ connect(this->tdLibWrapper, SIGNAL(stickersReceived(QVariantList)), this, SLOT(handleStickersReceived(QVariantList)));
+ connect(this->tdLibWrapper, SIGNAL(installedStickerSetsUpdated(QVariantList)), this, SLOT(handleInstalledStickerSetsUpdated(QVariantList)));
+ connect(this->tdLibWrapper, SIGNAL(stickerSetsReceived(QVariantList)), this, SLOT(handleStickerSetsReceived(QVariantList)));
+}
+
+StickerManager::~StickerManager()
+{
+ LOG("Destroying myself...");
+}
+
+QVariantList StickerManager::getRecentStickers()
+{
+ return this->recentStickers;
+}
+
+QVariantList StickerManager::getInstalledStickerSets()
+{
+ return this->installedStickerSets;
+}
+
+void StickerManager::handleRecentStickersUpdated(const QVariantList &stickerIds)
+{
+ LOG("Receiving recent stickers...." << stickerIds);
+ this->recentStickerIds = stickerIds;
+}
+
+void StickerManager::handleStickersReceived(const QVariantList &stickers)
+{
+ LOG("Receiving stickers...." << stickers);
+ QListIterator stickersIterator(stickers);
+ while (stickersIterator.hasNext()) {
+ QVariantMap newSticker = stickersIterator.next().toMap();
+ this->stickers.insert(newSticker.value("sticker").toMap().value("id").toString(), newSticker);
+ }
+
+ this->recentStickers.clear();
+ QListIterator stickerIdIterator(this->recentStickerIds);
+ while (stickerIdIterator.hasNext()) {
+ QString stickerId = stickerIdIterator.next().toString();
+ this->recentStickers.append(this->stickers.value(stickerId));
+ }
+}
+
+void StickerManager::handleInstalledStickerSetsUpdated(const QVariantList &stickerSetIds)
+{
+ LOG("Receiving installed sticker IDs...." << stickerSetIds);
+ this->installedStickerSetIds = stickerSetIds;
+}
+
+void StickerManager::handleStickerSetsReceived(const QVariantList &stickerSets)
+{
+ LOG("Receiving sticker sets...." << stickerSets);
+ QListIterator stickerSetsIterator(stickerSets);
+ while (stickerSetsIterator.hasNext()) {
+ QVariantMap newStickerSet = stickerSetsIterator.next().toMap();
+ this->stickerSets.insert(newStickerSet.value("id").toString(), newStickerSet);
+ }
+
+ this->installedStickerSets.clear();
+ QListIterator stickerSetIdIterator(this->installedStickerSetIds);
+ while (stickerSetIdIterator.hasNext()) {
+ QString stickerSetId = stickerSetIdIterator.next().toString();
+ this->installedStickerSets.append(this->stickerSets.value(stickerSetId));
+ }
+}
diff --git a/src/stickermanager.h b/src/stickermanager.h
new file mode 100644
index 0000000..2ccdf54
--- /dev/null
+++ b/src/stickermanager.h
@@ -0,0 +1,61 @@
+/*
+ Copyright (C) 2020 Sebastian J. Wolf
+
+ This file is part of Fernschreiber.
+
+ Fernschreiber is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Fernschreiber is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Fernschreiber. If not, see .
+*/
+
+#ifndef STICKERMANAGER_H
+#define STICKERMANAGER_H
+
+#include
+#include
+#include
+
+#include "tdlibwrapper.h"
+
+class StickerManager : public QObject
+{
+ Q_OBJECT
+public:
+ explicit StickerManager(TDLibWrapper *tdLibWrapper, QObject *parent = nullptr);
+ ~StickerManager();
+
+ Q_INVOKABLE QVariantList getRecentStickers();
+ Q_INVOKABLE QVariantList getInstalledStickerSets();
+
+signals:
+
+private slots:
+
+ void handleRecentStickersUpdated(const QVariantList &stickerIds);
+ void handleStickersReceived(const QVariantList &stickers);
+ void handleInstalledStickerSetsUpdated(const QVariantList &stickerSetIds);
+ void handleStickerSetsReceived(const QVariantList &stickerSets);
+
+private:
+
+ TDLibWrapper *tdLibWrapper;
+
+ QVariantList recentStickers;
+ QVariantList recentStickerIds;
+ QVariantList installedStickerSets;
+ QVariantList installedStickerSetIds;
+ QVariantMap stickers;
+ QVariantMap stickerSets;
+
+};
+
+#endif // STICKERMANAGER_H
diff --git a/src/tdlibreceiver.cpp b/src/tdlibreceiver.cpp
index 1a76bea..dd63f6a 100644
--- a/src/tdlibreceiver.cpp
+++ b/src/tdlibreceiver.cpp
@@ -395,5 +395,5 @@ void TDLibReceiver::processUpdateInstalledStickerSets(const QVariantMap &receive
void TDLibReceiver::processStickerSets(const QVariantMap &receivedInformation)
{
LOG("Received some sticker sets...");
- emit stickers(receivedInformation.value("sets").toList());
+ emit stickerSets(receivedInformation.value("sets").toList());
}
diff --git a/src/tdlibwrapper.cpp b/src/tdlibwrapper.cpp
index 950c348..533c908 100644
--- a/src/tdlibwrapper.cpp
+++ b/src/tdlibwrapper.cpp
@@ -336,6 +336,23 @@ void TDLibWrapper::sendDocumentMessage(const QString &chatId, const QString &fil
this->sendRequest(requestObject);
}
+void TDLibWrapper::sendStickerMessage(const QString &chatId, const QVariantMap &stickerInformation, const QString &replyToMessageId)
+{
+ LOG("Sending sticker message" << chatId << stickerInformation << replyToMessageId);
+ QVariantMap requestObject;
+ requestObject.insert(_TYPE, "sendMessage");
+ requestObject.insert("chat_id", chatId);
+ if (replyToMessageId != "0") {
+ requestObject.insert("reply_to_message_id", replyToMessageId);
+ }
+ QVariantMap inputMessageContent;
+ inputMessageContent.insert(_TYPE, "inputMessageSticker");
+ inputMessageContent.insert("sticker", stickerInformation);
+
+ requestObject.insert("input_message_content", inputMessageContent);
+ this->sendRequest(requestObject);
+}
+
void TDLibWrapper::getMessage(const QString &chatId, const QString &messageId)
{
LOG("Retrieving message" << chatId << messageId);
diff --git a/src/tdlibwrapper.h b/src/tdlibwrapper.h
index 2e4405c..cb710f5 100644
--- a/src/tdlibwrapper.h
+++ b/src/tdlibwrapper.h
@@ -118,6 +118,7 @@ public:
Q_INVOKABLE void sendPhotoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendVideoMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
Q_INVOKABLE void sendDocumentMessage(const QString &chatId, const QString &filePath, const QString &message, const QString &replyToMessageId = "0");
+ Q_INVOKABLE void sendStickerMessage(const QString &chatId, const QVariantMap &stickerInformation, const QString &replyToMessageId = "0");
Q_INVOKABLE void getMessage(const QString &chatId, const QString &messageId);
Q_INVOKABLE void setOptionInteger(const QString &optionName, const int &optionValue);
Q_INVOKABLE void setChatNotificationSettings(const QString &chatId, const QVariantMap ¬ificationSettings);