Prepare getting some stickers :D

This commit is contained in:
Sebastian J. Wolf 2020-10-05 23:08:47 +02:00
parent c8f4eaa9d7
commit c1ea773fae
4 changed files with 88 additions and 2 deletions

View file

@ -20,7 +20,7 @@
#define LOG(x) qDebug() << "[TDLibReceiver]" << x
#ifdef DEBUG
#if defined (QT_DEBUG) || defined (DEBUG)
# define VERBOSE(x) LOG(x)
#else
# define VERBOSE(x)
@ -99,6 +99,10 @@ TDLibReceiver::TDLibReceiver(void *tdLibClient, QObject *parent) : QThread(paren
handlers.insert("updateMessageContent", &TDLibReceiver::processUpdateMessageContent);
handlers.insert("updateDeleteMessages", &TDLibReceiver::processUpdateDeleteMessages);
handlers.insert("chats", &TDLibReceiver::processChats);
handlers.insert("updateRecentStickers", &TDLibReceiver::processUpdateRecentStickers);
handlers.insert("stickers", &TDLibReceiver::processStickers);
handlers.insert("updateInstalledStickerSets", &TDLibReceiver::processUpdateInstalledStickerSets);
handlers.insert("stickerSets", &TDLibReceiver::processStickerSets);
}
void TDLibReceiver::setActive(const bool &active)
@ -369,3 +373,27 @@ void TDLibReceiver::processChats(const QVariantMap &receivedInformation)
{
emit chats(receivedInformation);
}
void TDLibReceiver::processUpdateRecentStickers(const QVariantMap &receivedInformation)
{
LOG("Recent stickers updated");
emit recentStickersUpdated(receivedInformation.value("sticker_ids").toList());
}
void TDLibReceiver::processStickers(const QVariantMap &receivedInformation)
{
LOG("Received some stickers...");
emit stickers(receivedInformation.value("stickers").toList());
}
void TDLibReceiver::processUpdateInstalledStickerSets(const QVariantMap &receivedInformation)
{
LOG("Recent sticker sets updated");
emit installedStickerSetsUpdated(receivedInformation.value("sticker_set_ids").toList());
}
void TDLibReceiver::processStickerSets(const QVariantMap &receivedInformation)
{
LOG("Received some sticker sets...");
emit stickers(receivedInformation.value("sets").toList());
}

View file

@ -64,6 +64,10 @@ signals:
void messageContentUpdated(const QString &chatId, const QString &messageId, const QVariantMap &newContent);
void messagesDeleted(const QString &chatId, const QVariantList &messageIds);
void chats(const QVariantMap &chats);
void recentStickersUpdated(const QVariantList &stickerIds);
void stickers(const QVariantList &stickers);
void installedStickerSetsUpdated(const QVariantList &stickerSetIds);
void stickerSets(const QVariantList &stickerSets);
private:
typedef void (TDLibReceiver::*Handler)(const QVariantMap &);
@ -103,6 +107,10 @@ private:
void processUpdateMessageContent(const QVariantMap &receivedInformation);
void processUpdateDeleteMessages(const QVariantMap &receivedInformation);
void processChats(const QVariantMap &receivedInformation);
void processUpdateRecentStickers(const QVariantMap &receivedInformation);
void processStickers(const QVariantMap &receivedInformation);
void processUpdateInstalledStickerSets(const QVariantMap &receivedInformation);
void processStickerSets(const QVariantMap &receivedInformation);
};
#endif // TDLIBRECEIVER_H

View file

@ -32,7 +32,7 @@
#define LOG(x) qDebug() << "[TDLibWrapper]" << x
#ifdef DEBUG
#if defined (QT_DEBUG) || defined (DEBUG)
# define VERBOSE(x) LOG(x)
#else
# define VERBOSE(x)
@ -86,6 +86,10 @@ TDLibWrapper::TDLibWrapper(QObject *parent) : QObject(parent), settings("harbour
connect(this->tdLibReceiver, SIGNAL(messageContentUpdated(QString, QString, QVariantMap)), this, SLOT(handleMessageContentUpdated(QString, QString, QVariantMap)));
connect(this->tdLibReceiver, SIGNAL(messagesDeleted(QString, QVariantList)), this, SLOT(handleMessagesDeleted(QString, QVariantList)));
connect(this->tdLibReceiver, SIGNAL(chats(QVariantMap)), this, SLOT(handleChats(QVariantMap)));
connect(this->tdLibReceiver, SIGNAL(recentStickersUpdated(QVariantList)), this, SLOT(handleRecentStickersUpdated(QVariantList)));
connect(this->tdLibReceiver, SIGNAL(stickers(QVariantList)), this, SLOT(handleStickers(QVariantList)));
connect(this->tdLibReceiver, SIGNAL(installedStickerSetsUpdated(QVariantList)), this, SLOT(handleInstalledStickerSetsUpdated(QVariantList)));
connect(this->tdLibReceiver, SIGNAL(stickerSets(QVariantList)), this, SLOT(handleStickerSets(QVariantList)));
this->tdLibReceiver->start();
@ -414,6 +418,22 @@ void TDLibWrapper::getMapThumbnailFile(const QString &chatId, const double &lati
this->sendRequest(requestObject);
}
void TDLibWrapper::getRecentStickers()
{
LOG("Retrieving recent stickers");
QVariantMap requestObject;
requestObject.insert(_TYPE, "getRecentStickers");
this->sendRequest(requestObject);
}
void TDLibWrapper::getInstalledStickerSets()
{
LOG("Retrieving installed sticker sets");
QVariantMap requestObject;
requestObject.insert(_TYPE, "getInstalledStickerSets");
this->sendRequest(requestObject);
}
QVariantMap TDLibWrapper::getUserInformation()
{
return this->userInformation;
@ -755,6 +775,26 @@ void TDLibWrapper::handleChats(const QVariantMap &chats)
emit this->chatsReceived(chats);
}
void TDLibWrapper::handleRecentStickersUpdated(const QVariantList &stickerIds)
{
emit this->recentStickersUpdated(stickerIds);
}
void TDLibWrapper::handleStickers(const QVariantList &stickers)
{
emit this->stickersReceived(stickers);
}
void TDLibWrapper::handleInstalledStickerSetsUpdated(const QVariantList &stickerSetIds)
{
emit this->installedStickerSetsUpdated(stickerSetIds);
}
void TDLibWrapper::handleStickerSets(const QVariantList &stickerSets)
{
emit this->stickerSetsReceived(stickerSets);
}
void TDLibWrapper::setInitialParameters()
{
LOG("Sending initial parameters to TD Lib");

View file

@ -131,6 +131,8 @@ public:
Q_INVOKABLE void editMessageText(const QString &chatId, const QString &messageId, const QString &message);
Q_INVOKABLE void deleteMessages(const QString &chatId, const QVariantList messageIds);
Q_INVOKABLE void getMapThumbnailFile(const QString &chatId, const double &latitude, const double &longitude, const int &width, const int &height);
Q_INVOKABLE void getRecentStickers();
Q_INVOKABLE void getInstalledStickerSets();
public:
const Group* getGroup(qlonglong groupId) const;
@ -167,6 +169,10 @@ signals:
void messageContentUpdated(const QString &chatId, const QString &messageId, const QVariantMap &newContent);
void messagesDeleted(const QString &chatId, const QVariantList &messageIds);
void chatsReceived(const QVariantMap &chats);
void recentStickersUpdated(const QVariantList &stickerIds);
void stickersReceived(const QVariantList &stickers);
void installedStickerSetsUpdated(const QVariantList &stickerSetIds);
void stickerSetsReceived(const QVariantList &stickerSets);
public slots:
void handleVersionDetected(const QString &version);
@ -197,6 +203,10 @@ public slots:
void handleMessageContentUpdated(const QString &chatId, const QString &messageId, const QVariantMap &newContent);
void handleMessagesDeleted(const QString &chatId, const QVariantList &messageIds);
void handleChats(const QVariantMap &chats);
void handleRecentStickersUpdated(const QVariantList &stickerIds);
void handleStickers(const QVariantList &stickers);
void handleInstalledStickerSetsUpdated(const QVariantList &stickerSetIds);
void handleStickerSets(const QVariantList &stickerSets);
private:
void setInitialParameters();