mirror of https://github.com/procxx/kepka.git
Game bot confirmations added.
This commit is contained in:
parent
578cf4ed61
commit
6d2fc5c642
|
@ -764,6 +764,8 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
"lng_open_this_link" = "Open this link?";
|
"lng_open_this_link" = "Open this link?";
|
||||||
"lng_open_link" = "Open";
|
"lng_open_link" = "Open";
|
||||||
|
"lng_allow_bot_pass" = "Do you allow {bot_name} to pass your Telegram name and id to the web pages you open via this bot?";
|
||||||
|
"lng_allow_bot" = "Allow";
|
||||||
|
|
||||||
"lng_bot_start" = "Start";
|
"lng_bot_start" = "Start";
|
||||||
"lng_bot_choose_group" = "Choose Group";
|
"lng_bot_choose_group" = "Choose Group";
|
||||||
|
|
|
@ -19,15 +19,16 @@ Full license: https://github.com/telegramdesktop/tdesktop/blob/master/LICENSE
|
||||||
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
*/
|
*/
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "lang.h"
|
#include "boxes/confirmbox.h"
|
||||||
|
|
||||||
#include "confirmbox.h"
|
#include "lang.h"
|
||||||
#include "mainwidget.h"
|
#include "mainwidget.h"
|
||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
#include "apiwrap.h"
|
#include "apiwrap.h"
|
||||||
#include "application.h"
|
#include "application.h"
|
||||||
#include "core/click_handler_types.h"
|
#include "core/click_handler_types.h"
|
||||||
#include "styles/style_boxes.h"
|
#include "styles/style_boxes.h"
|
||||||
|
#include "localstorage.h"
|
||||||
|
|
||||||
TextParseOptions _confirmBoxTextOptions = {
|
TextParseOptions _confirmBoxTextOptions = {
|
||||||
TextParseLinks | TextParseMultiline | TextParseRichText, // flags
|
TextParseLinks | TextParseMultiline | TextParseRichText, // flags
|
||||||
|
@ -195,6 +196,18 @@ void ConfirmLinkBox::onOpenLink() {
|
||||||
UrlClickHandler::doOpen(_url);
|
UrlClickHandler::doOpen(_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ConfirmBotGameBox::ConfirmBotGameBox(UserData *bot, const QString &url) : ConfirmBox(lng_allow_bot_pass(lt_bot_name, bot->name), lang(lng_allow_bot))
|
||||||
|
, _bot(bot)
|
||||||
|
, _url(url) {
|
||||||
|
connect(this, SIGNAL(confirmed()), this, SLOT(onOpenLink()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfirmBotGameBox::onOpenLink() {
|
||||||
|
Ui::hideLayer();
|
||||||
|
Local::makeBotTrusted(_bot);
|
||||||
|
UrlClickHandler::doOpen(_url);
|
||||||
|
}
|
||||||
|
|
||||||
MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth)
|
MaxInviteBox::MaxInviteBox(const QString &link) : AbstractBox(st::boxWidth)
|
||||||
, _close(this, lang(lng_box_ok), st::defaultBoxButton)
|
, _close(this, lang(lng_box_ok), st::defaultBoxButton)
|
||||||
, _text(st::boxTextFont, lng_participant_invite_sorry(lt_count, Global::ChatSizeMax()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
, _text(st::boxTextFont, lng_participant_invite_sorry(lt_count, Global::ChatSizeMax()), _confirmBoxTextOptions, st::boxWidth - st::boxPadding.left() - st::boxButtonPadding.right())
|
||||||
|
|
|
@ -125,6 +125,21 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ConfirmBotGameBox : public ConfirmBox {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
ConfirmBotGameBox(UserData *bot, const QString &url);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void onOpenLink();
|
||||||
|
|
||||||
|
private:
|
||||||
|
UserData *_bot;
|
||||||
|
QString _url;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class MaxInviteBox : public AbstractBox {
|
class MaxInviteBox : public AbstractBox {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
#include "boxes/confirmbox.h"
|
#include "boxes/confirmbox.h"
|
||||||
#include "core/qthelp_regex.h"
|
#include "core/qthelp_regex.h"
|
||||||
#include "core/qthelp_url.h"
|
#include "core/qthelp_url.h"
|
||||||
|
#include "localstorage.h"
|
||||||
|
|
||||||
QString UrlClickHandler::copyToClipboardContextItemText() const {
|
QString UrlClickHandler::copyToClipboardContextItemText() const {
|
||||||
return lang(isEmail() ? lng_context_copy_email : lng_context_copy_link);
|
return lang(isEmail() ? lng_context_copy_email : lng_context_copy_link);
|
||||||
|
@ -113,6 +114,20 @@ void HiddenUrlClickHandler::onClick(Qt::MouseButton button) const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BotGameUrlClickHandler::onClick(Qt::MouseButton button) const {
|
||||||
|
auto u = url();
|
||||||
|
|
||||||
|
u = tryConvertUrlToLocal(u);
|
||||||
|
|
||||||
|
if (u.startsWith(qstr("tg://"))) {
|
||||||
|
App::openLocalUrl(u);
|
||||||
|
} else if (!_bot || Local::isBotTrusted(_bot)) {
|
||||||
|
doOpen(u);
|
||||||
|
} else {
|
||||||
|
Ui::showLayer(new ConfirmBotGameBox(_bot, u));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString HiddenUrlClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
|
QString HiddenUrlClickHandler::getExpandedLinkText(ExpandLinksMode mode, const QStringRef &textPart) const {
|
||||||
QString result;
|
QString result;
|
||||||
if (mode == ExpandLinksAll) {
|
if (mode == ExpandLinksAll) {
|
||||||
|
|
|
@ -122,6 +122,17 @@ public:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class BotGameUrlClickHandler : public UrlClickHandler {
|
||||||
|
public:
|
||||||
|
BotGameUrlClickHandler(UserData *bot, QString url) : UrlClickHandler(url, false), _bot(bot) {
|
||||||
|
}
|
||||||
|
void onClick(Qt::MouseButton button) const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
UserData *_bot;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
class MentionClickHandler : public TextClickHandler {
|
class MentionClickHandler : public TextClickHandler {
|
||||||
public:
|
public:
|
||||||
MentionClickHandler(const QString &tag) : _tag(tag) {
|
MentionClickHandler(const QString &tag) : _tag(tag) {
|
||||||
|
|
|
@ -55,7 +55,7 @@ void activateBotCommand(const HistoryItem *msg, int row, int col) {
|
||||||
const HistoryMessageReplyMarkup::Button *button = nullptr;
|
const HistoryMessageReplyMarkup::Button *button = nullptr;
|
||||||
if (auto markup = msg->Get<HistoryMessageReplyMarkup>()) {
|
if (auto markup = msg->Get<HistoryMessageReplyMarkup>()) {
|
||||||
if (row < markup->rows.size()) {
|
if (row < markup->rows.size()) {
|
||||||
const auto &buttonRow(markup->rows.at(row));
|
auto &buttonRow = markup->rows[row];
|
||||||
if (col < buttonRow.size()) {
|
if (col < buttonRow.size()) {
|
||||||
button = &buttonRow.at(col);
|
button = &buttonRow.at(col);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ void activateBotCommand(const HistoryItem *msg, int row, int col) {
|
||||||
|
|
||||||
case ButtonType::Url: {
|
case ButtonType::Url: {
|
||||||
auto url = QString::fromUtf8(button->data);
|
auto url = QString::fromUtf8(button->data);
|
||||||
UrlClickHandler(url).onClick(Qt::LeftButton);
|
HiddenUrlClickHandler(url).onClick(Qt::LeftButton);
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ButtonType::RequestLocation: {
|
case ButtonType::RequestLocation: {
|
||||||
|
|
|
@ -5783,8 +5783,16 @@ void HistoryWidget::app_sendBotCallback(const HistoryMessageReplyMarkup::Button
|
||||||
|
|
||||||
bool lastKeyboardUsed = (_keyboard.forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)) && (_keyboard.forMsgId() == FullMsgId(_channel, msg->id));
|
bool lastKeyboardUsed = (_keyboard.forMsgId() == FullMsgId(_channel, _history->lastKeyboardId)) && (_keyboard.forMsgId() == FullMsgId(_channel, msg->id));
|
||||||
|
|
||||||
|
auto bot = msg->viaBot();
|
||||||
|
if (!bot) {
|
||||||
|
bot = msg->from()->asUser();
|
||||||
|
if (bot && !bot->botInfo) {
|
||||||
|
bot = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
using ButtonType = HistoryMessageReplyMarkup::Button::Type;
|
using ButtonType = HistoryMessageReplyMarkup::Button::Type;
|
||||||
BotCallbackInfo info = { msg->fullId(), row, col, (button->type == ButtonType::Game) };
|
BotCallbackInfo info = { bot, msg->fullId(), row, col, (button->type == ButtonType::Game) };
|
||||||
MTPmessages_GetBotCallbackAnswer::Flags flags = 0;
|
MTPmessages_GetBotCallbackAnswer::Flags flags = 0;
|
||||||
QByteArray sendData;
|
QByteArray sendData;
|
||||||
int32 sendGameId = 0;
|
int32 sendGameId = 0;
|
||||||
|
@ -5833,8 +5841,10 @@ void HistoryWidget::botCallbackDone(BotCallbackInfo info, const MTPmessages_BotC
|
||||||
auto url = qs(answerData.vurl);
|
auto url = qs(answerData.vurl);
|
||||||
if (info.game) {
|
if (info.game) {
|
||||||
url = appendShareGameScoreUrl(url, info.msgId);
|
url = appendShareGameScoreUrl(url, info.msgId);
|
||||||
|
BotGameUrlClickHandler(info.bot, url).onClick(Qt::LeftButton);
|
||||||
|
} else {
|
||||||
|
UrlClickHandler(url).onClick(Qt::LeftButton);
|
||||||
}
|
}
|
||||||
UrlClickHandler(url).onClick(Qt::LeftButton);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -961,6 +961,7 @@ private:
|
||||||
void addMessagesToBack(PeerData *peer, const QVector<MTPMessage> &messages);
|
void addMessagesToBack(PeerData *peer, const QVector<MTPMessage> &messages);
|
||||||
|
|
||||||
struct BotCallbackInfo {
|
struct BotCallbackInfo {
|
||||||
|
UserData *bot;
|
||||||
FullMsgId msgId;
|
FullMsgId msgId;
|
||||||
int row, col;
|
int row, col;
|
||||||
bool game;
|
bool game;
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -22,168 +22,170 @@ Copyright (c) 2014-2016 John Preston, https://desktop.telegram.org
|
||||||
|
|
||||||
#include "core/basic_types.h"
|
#include "core/basic_types.h"
|
||||||
|
|
||||||
namespace _local_inner {
|
namespace Local {
|
||||||
|
|
||||||
class Manager : public QObject {
|
void start();
|
||||||
|
void finish();
|
||||||
|
|
||||||
|
void readSettings();
|
||||||
|
void writeSettings();
|
||||||
|
void writeUserSettings();
|
||||||
|
void writeMtpData();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
bool checkPasscode(const QByteArray &passcode);
|
||||||
|
void setPasscode(const QByteArray &passcode);
|
||||||
|
|
||||||
|
enum ClearManagerTask {
|
||||||
|
ClearManagerAll = 0xFFFF,
|
||||||
|
ClearManagerDownloads = 0x01,
|
||||||
|
ClearManagerStorage = 0x02,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ClearManagerData;
|
||||||
|
class ClearManager : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
ClearManager();
|
||||||
|
bool addTask(int task);
|
||||||
|
bool hasTask(ClearManagerTask task);
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
|
|
||||||
Manager();
|
signals:
|
||||||
|
void succeed(int task, void *manager);
|
||||||
|
void failed(int task, void *manager);
|
||||||
|
|
||||||
void writeMap(bool fast);
|
private slots:
|
||||||
void writingMap();
|
void onStart();
|
||||||
void writeLocations(bool fast);
|
|
||||||
void writingLocations();
|
private:
|
||||||
void finish();
|
~ClearManager();
|
||||||
|
|
||||||
|
ClearManagerData *data;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
enum ReadMapState {
|
||||||
|
ReadMapFailed = 0,
|
||||||
|
ReadMapDone = 1,
|
||||||
|
ReadMapPassNeeded = 2,
|
||||||
|
};
|
||||||
|
ReadMapState readMap(const QByteArray &pass);
|
||||||
|
int32 oldMapVersion();
|
||||||
|
|
||||||
|
int32 oldSettingsVersion();
|
||||||
|
|
||||||
|
using TextWithTags = FlatTextarea::TextWithTags;
|
||||||
|
struct MessageDraft {
|
||||||
|
MessageDraft(MsgId msgId = 0, TextWithTags textWithTags = TextWithTags(), bool previewCancelled = false)
|
||||||
|
: msgId(msgId)
|
||||||
|
, textWithTags(textWithTags)
|
||||||
|
, previewCancelled(previewCancelled) {
|
||||||
|
}
|
||||||
|
MsgId msgId;
|
||||||
|
TextWithTags textWithTags;
|
||||||
|
bool previewCancelled;
|
||||||
|
};
|
||||||
|
void writeDrafts(const PeerId &peer, const MessageDraft &localDraft, const MessageDraft &editDraft);
|
||||||
|
void readDraftsWithCursors(History *h);
|
||||||
|
void writeDraftCursors(const PeerId &peer, const MessageCursor &localCursor, const MessageCursor &editCursor);
|
||||||
|
bool hasDraftCursors(const PeerId &peer);
|
||||||
|
bool hasDraft(const PeerId &peer);
|
||||||
|
|
||||||
|
void writeFileLocation(MediaKey location, const FileLocation &local);
|
||||||
|
FileLocation readFileLocation(MediaKey location, bool check = true);
|
||||||
|
|
||||||
|
void writeImage(const StorageKey &location, const ImagePtr &img);
|
||||||
|
void writeImage(const StorageKey &location, const StorageImageSaved &jpeg, bool overwrite = true);
|
||||||
|
TaskId startImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
||||||
|
int32 hasImages();
|
||||||
|
qint64 storageImagesSize();
|
||||||
|
|
||||||
|
void writeStickerImage(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
||||||
|
TaskId startStickerImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
||||||
|
bool willStickerImageLoad(const StorageKey &location);
|
||||||
|
bool copyStickerImage(const StorageKey &oldLocation, const StorageKey &newLocation);
|
||||||
|
int32 hasStickers();
|
||||||
|
qint64 storageStickersSize();
|
||||||
|
|
||||||
|
void writeAudio(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
||||||
|
TaskId startAudioLoad(const StorageKey &location, mtpFileLoader *loader);
|
||||||
|
bool copyAudio(const StorageKey &oldLocation, const StorageKey &newLocation);
|
||||||
|
int32 hasAudios();
|
||||||
|
qint64 storageAudiosSize();
|
||||||
|
|
||||||
|
void writeWebFile(const QString &url, const QByteArray &data, bool overwrite = true);
|
||||||
|
TaskId startWebFileLoad(const QString &url, webFileLoader *loader);
|
||||||
|
int32 hasWebFiles();
|
||||||
|
qint64 storageWebFilesSize();
|
||||||
|
|
||||||
|
void countVoiceWaveform(DocumentData *document);
|
||||||
|
|
||||||
|
void cancelTask(TaskId id);
|
||||||
|
|
||||||
|
void writeInstalledStickers();
|
||||||
|
void writeFeaturedStickers();
|
||||||
|
void writeRecentStickers();
|
||||||
|
void writeArchivedStickers();
|
||||||
|
void readInstalledStickers();
|
||||||
|
void readFeaturedStickers();
|
||||||
|
void readRecentStickers();
|
||||||
|
void readArchivedStickers();
|
||||||
|
int32 countStickersHash(bool checkOutdatedInfo = false);
|
||||||
|
int32 countRecentStickersHash();
|
||||||
|
int32 countFeaturedStickersHash();
|
||||||
|
|
||||||
|
void writeSavedGifs();
|
||||||
|
void readSavedGifs();
|
||||||
|
int32 countSavedGifsHash();
|
||||||
|
|
||||||
|
void writeBackground(int32 id, const QImage &img);
|
||||||
|
bool readBackground();
|
||||||
|
|
||||||
|
void writeRecentHashtagsAndBots();
|
||||||
|
void readRecentHashtagsAndBots();
|
||||||
|
|
||||||
|
void addSavedPeer(PeerData *peer, const QDateTime &position);
|
||||||
|
void removeSavedPeer(PeerData *peer);
|
||||||
|
void readSavedPeers();
|
||||||
|
|
||||||
|
void writeReportSpamStatuses();
|
||||||
|
|
||||||
|
void makeBotTrusted(UserData *bot);
|
||||||
|
bool isBotTrusted(UserData *bot);
|
||||||
|
|
||||||
|
bool encrypt(const void *src, void *dst, uint32 len, const void *key128);
|
||||||
|
bool decrypt(const void *src, void *dst, uint32 len, const void *key128);
|
||||||
|
|
||||||
|
namespace internal {
|
||||||
|
|
||||||
|
class Manager : public QObject {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
Manager();
|
||||||
|
|
||||||
|
void writeMap(bool fast);
|
||||||
|
void writingMap();
|
||||||
|
void writeLocations(bool fast);
|
||||||
|
void writingLocations();
|
||||||
|
void finish();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
void mapWriteTimeout();
|
void mapWriteTimeout();
|
||||||
void locationsWriteTimeout();
|
void locationsWriteTimeout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
QTimer _mapWriteTimer;
|
QTimer _mapWriteTimer;
|
||||||
QTimer _locationsWriteTimer;
|
QTimer _locationsWriteTimer;
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Local {
|
|
||||||
|
|
||||||
void start();
|
|
||||||
void finish();
|
|
||||||
|
|
||||||
void readSettings();
|
|
||||||
void writeSettings();
|
|
||||||
void writeUserSettings();
|
|
||||||
void writeMtpData();
|
|
||||||
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
bool checkPasscode(const QByteArray &passcode);
|
|
||||||
void setPasscode(const QByteArray &passcode);
|
|
||||||
|
|
||||||
enum ClearManagerTask {
|
|
||||||
ClearManagerAll = 0xFFFF,
|
|
||||||
ClearManagerDownloads = 0x01,
|
|
||||||
ClearManagerStorage = 0x02,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ClearManagerData;
|
|
||||||
class ClearManager : public QObject {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
ClearManager();
|
|
||||||
bool addTask(int task);
|
|
||||||
bool hasTask(ClearManagerTask task);
|
|
||||||
void start();
|
|
||||||
void stop();
|
|
||||||
|
|
||||||
signals:
|
|
||||||
void succeed(int task, void *manager);
|
|
||||||
void failed(int task, void *manager);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void onStart();
|
|
||||||
|
|
||||||
private:
|
|
||||||
~ClearManager();
|
|
||||||
|
|
||||||
ClearManagerData *data;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
enum ReadMapState {
|
|
||||||
ReadMapFailed = 0,
|
|
||||||
ReadMapDone = 1,
|
|
||||||
ReadMapPassNeeded = 2,
|
|
||||||
};
|
|
||||||
ReadMapState readMap(const QByteArray &pass);
|
|
||||||
int32 oldMapVersion();
|
|
||||||
|
|
||||||
int32 oldSettingsVersion();
|
|
||||||
|
|
||||||
using TextWithTags = FlatTextarea::TextWithTags;
|
|
||||||
struct MessageDraft {
|
|
||||||
MessageDraft(MsgId msgId = 0, TextWithTags textWithTags = TextWithTags(), bool previewCancelled = false)
|
|
||||||
: msgId(msgId)
|
|
||||||
, textWithTags(textWithTags)
|
|
||||||
, previewCancelled(previewCancelled) {
|
|
||||||
}
|
|
||||||
MsgId msgId;
|
|
||||||
TextWithTags textWithTags;
|
|
||||||
bool previewCancelled;
|
|
||||||
};
|
|
||||||
void writeDrafts(const PeerId &peer, const MessageDraft &localDraft, const MessageDraft &editDraft);
|
|
||||||
void readDraftsWithCursors(History *h);
|
|
||||||
void writeDraftCursors(const PeerId &peer, const MessageCursor &localCursor, const MessageCursor &editCursor);
|
|
||||||
bool hasDraftCursors(const PeerId &peer);
|
|
||||||
bool hasDraft(const PeerId &peer);
|
|
||||||
|
|
||||||
void writeFileLocation(MediaKey location, const FileLocation &local);
|
|
||||||
FileLocation readFileLocation(MediaKey location, bool check = true);
|
|
||||||
|
|
||||||
void writeImage(const StorageKey &location, const ImagePtr &img);
|
|
||||||
void writeImage(const StorageKey &location, const StorageImageSaved &jpeg, bool overwrite = true);
|
|
||||||
TaskId startImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
|
||||||
int32 hasImages();
|
|
||||||
qint64 storageImagesSize();
|
|
||||||
|
|
||||||
void writeStickerImage(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
|
||||||
TaskId startStickerImageLoad(const StorageKey &location, mtpFileLoader *loader);
|
|
||||||
bool willStickerImageLoad(const StorageKey &location);
|
|
||||||
bool copyStickerImage(const StorageKey &oldLocation, const StorageKey &newLocation);
|
|
||||||
int32 hasStickers();
|
|
||||||
qint64 storageStickersSize();
|
|
||||||
|
|
||||||
void writeAudio(const StorageKey &location, const QByteArray &data, bool overwrite = true);
|
|
||||||
TaskId startAudioLoad(const StorageKey &location, mtpFileLoader *loader);
|
|
||||||
bool copyAudio(const StorageKey &oldLocation, const StorageKey &newLocation);
|
|
||||||
int32 hasAudios();
|
|
||||||
qint64 storageAudiosSize();
|
|
||||||
|
|
||||||
void writeWebFile(const QString &url, const QByteArray &data, bool overwrite = true);
|
|
||||||
TaskId startWebFileLoad(const QString &url, webFileLoader *loader);
|
|
||||||
int32 hasWebFiles();
|
|
||||||
qint64 storageWebFilesSize();
|
|
||||||
|
|
||||||
void countVoiceWaveform(DocumentData *document);
|
|
||||||
|
|
||||||
void cancelTask(TaskId id);
|
|
||||||
|
|
||||||
void writeInstalledStickers();
|
|
||||||
void writeFeaturedStickers();
|
|
||||||
void writeRecentStickers();
|
|
||||||
void writeArchivedStickers();
|
|
||||||
void readInstalledStickers();
|
|
||||||
void readFeaturedStickers();
|
|
||||||
void readRecentStickers();
|
|
||||||
void readArchivedStickers();
|
|
||||||
int32 countStickersHash(bool checkOutdatedInfo = false);
|
|
||||||
int32 countRecentStickersHash();
|
|
||||||
int32 countFeaturedStickersHash();
|
|
||||||
|
|
||||||
void writeSavedGifs();
|
|
||||||
void readSavedGifs();
|
|
||||||
int32 countSavedGifsHash();
|
|
||||||
|
|
||||||
void writeBackground(int32 id, const QImage &img);
|
|
||||||
bool readBackground();
|
|
||||||
|
|
||||||
void writeRecentHashtagsAndBots();
|
|
||||||
void readRecentHashtagsAndBots();
|
|
||||||
|
|
||||||
void addSavedPeer(PeerData *peer, const QDateTime &position);
|
|
||||||
void removeSavedPeer(PeerData *peer);
|
|
||||||
void readSavedPeers();
|
|
||||||
|
|
||||||
void writeReportSpamStatuses();
|
|
||||||
|
|
||||||
bool encrypt(const void *src, void *dst, uint32 len, const void *key128);
|
|
||||||
bool decrypt(const void *src, void *dst, uint32 len, const void *key128);
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // namespace internal
|
||||||
|
} // namespace Local
|
||||||
|
|
|
@ -4680,72 +4680,73 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
auto &set = d.vstickerset.c_messages_stickerSet();
|
auto &set = d.vstickerset.c_messages_stickerSet();
|
||||||
if (set.vset.type() == mtpc_stickerSet) {
|
if (set.vset.type() == mtpc_stickerSet) {
|
||||||
auto &s = set.vset.c_stickerSet();
|
auto &s = set.vset.c_stickerSet();
|
||||||
|
if (!s.is_masks()) {
|
||||||
auto &sets = Global::RefStickerSets();
|
auto &sets = Global::RefStickerSets();
|
||||||
auto it = sets.find(s.vid.v);
|
auto it = sets.find(s.vid.v);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
it = sets.insert(s.vid.v, Stickers::Set(s.vid.v, s.vaccess_hash.v, stickerSetTitle(s), qs(s.vshort_name), s.vcount.v, s.vhash.v, s.vflags.v | MTPDstickerSet::Flag::f_installed));
|
it = sets.insert(s.vid.v, Stickers::Set(s.vid.v, s.vaccess_hash.v, stickerSetTitle(s), qs(s.vshort_name), s.vcount.v, s.vhash.v, s.vflags.v | MTPDstickerSet::Flag::f_installed));
|
||||||
} else {
|
} else {
|
||||||
it->flags |= MTPDstickerSet::Flag::f_installed;
|
it->flags |= MTPDstickerSet::Flag::f_installed;
|
||||||
if (it->flags & MTPDstickerSet::Flag::f_archived) {
|
if (it->flags & MTPDstickerSet::Flag::f_archived) {
|
||||||
it->flags &= ~MTPDstickerSet::Flag::f_archived;
|
it->flags &= ~MTPDstickerSet::Flag::f_archived;
|
||||||
writeArchived = true;
|
writeArchived = true;
|
||||||
}
|
|
||||||
}
|
|
||||||
auto inputSet = MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access));
|
|
||||||
auto &v = set.vdocuments.c_vector().v;
|
|
||||||
it->stickers.clear();
|
|
||||||
it->stickers.reserve(v.size());
|
|
||||||
for (int32 i = 0, l = v.size(); i < l; ++i) {
|
|
||||||
auto doc = App::feedDocument(v.at(i));
|
|
||||||
if (!doc || !doc->sticker()) continue;
|
|
||||||
|
|
||||||
it->stickers.push_back(doc);
|
|
||||||
if (doc->sticker()->set.type() != mtpc_inputStickerSetID) {
|
|
||||||
doc->sticker()->set = inputSet;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
it->emoji.clear();
|
|
||||||
auto &packs = set.vpacks.c_vector().v;
|
|
||||||
for (int32 i = 0, l = packs.size(); i < l; ++i) {
|
|
||||||
if (packs.at(i).type() != mtpc_stickerPack) continue;
|
|
||||||
auto &pack = packs.at(i).c_stickerPack();
|
|
||||||
if (EmojiPtr e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
|
||||||
auto &stickers = pack.vdocuments.c_vector().v;
|
|
||||||
StickerPack p;
|
|
||||||
p.reserve(stickers.size());
|
|
||||||
for (int32 j = 0, c = stickers.size(); j < c; ++j) {
|
|
||||||
DocumentData *doc = App::document(stickers.at(j).v);
|
|
||||||
if (!doc || !doc->sticker()) continue;
|
|
||||||
|
|
||||||
p.push_back(doc);
|
|
||||||
}
|
}
|
||||||
it->emoji.insert(e, p);
|
|
||||||
}
|
}
|
||||||
}
|
auto inputSet = MTP_inputStickerSetID(MTP_long(it->id), MTP_long(it->access));
|
||||||
|
auto &v = set.vdocuments.c_vector().v;
|
||||||
|
it->stickers.clear();
|
||||||
|
it->stickers.reserve(v.size());
|
||||||
|
for (int i = 0, l = v.size(); i < l; ++i) {
|
||||||
|
auto doc = App::feedDocument(v.at(i));
|
||||||
|
if (!doc || !doc->sticker()) continue;
|
||||||
|
|
||||||
auto &order(Global::RefStickerSetsOrder());
|
it->stickers.push_back(doc);
|
||||||
int32 insertAtIndex = 0, currentIndex = order.indexOf(s.vid.v);
|
if (doc->sticker()->set.type() != mtpc_inputStickerSetID) {
|
||||||
if (currentIndex != insertAtIndex) {
|
doc->sticker()->set = inputSet;
|
||||||
if (currentIndex > 0) {
|
}
|
||||||
order.removeAt(currentIndex);
|
|
||||||
}
|
}
|
||||||
order.insert(insertAtIndex, s.vid.v);
|
it->emoji.clear();
|
||||||
}
|
auto &packs = set.vpacks.c_vector().v;
|
||||||
|
for (int i = 0, l = packs.size(); i < l; ++i) {
|
||||||
|
if (packs.at(i).type() != mtpc_stickerPack) continue;
|
||||||
|
auto &pack = packs.at(i).c_stickerPack();
|
||||||
|
if (auto e = emojiGetNoColor(emojiFromText(qs(pack.vemoticon)))) {
|
||||||
|
auto &stickers = pack.vdocuments.c_vector().v;
|
||||||
|
StickerPack p;
|
||||||
|
p.reserve(stickers.size());
|
||||||
|
for (int j = 0, c = stickers.size(); j < c; ++j) {
|
||||||
|
auto doc = App::document(stickers.at(j).v);
|
||||||
|
if (!doc || !doc->sticker()) continue;
|
||||||
|
|
||||||
auto custom = sets.find(Stickers::CustomSetId);
|
p.push_back(doc);
|
||||||
if (custom != sets.cend()) {
|
}
|
||||||
for (int32 i = 0, l = it->stickers.size(); i < l; ++i) {
|
it->emoji.insert(e, p);
|
||||||
int32 removeIndex = custom->stickers.indexOf(it->stickers.at(i));
|
}
|
||||||
if (removeIndex >= 0) custom->stickers.removeAt(removeIndex);
|
|
||||||
}
|
}
|
||||||
if (custom->stickers.isEmpty()) {
|
|
||||||
sets.erase(custom);
|
auto &order(Global::RefStickerSetsOrder());
|
||||||
|
int32 insertAtIndex = 0, currentIndex = order.indexOf(s.vid.v);
|
||||||
|
if (currentIndex != insertAtIndex) {
|
||||||
|
if (currentIndex > 0) {
|
||||||
|
order.removeAt(currentIndex);
|
||||||
|
}
|
||||||
|
order.insert(insertAtIndex, s.vid.v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto custom = sets.find(Stickers::CustomSetId);
|
||||||
|
if (custom != sets.cend()) {
|
||||||
|
for (int32 i = 0, l = it->stickers.size(); i < l; ++i) {
|
||||||
|
int32 removeIndex = custom->stickers.indexOf(it->stickers.at(i));
|
||||||
|
if (removeIndex >= 0) custom->stickers.removeAt(removeIndex);
|
||||||
|
}
|
||||||
|
if (custom->stickers.isEmpty()) {
|
||||||
|
sets.erase(custom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Local::writeInstalledStickers();
|
||||||
|
if (writeArchived) Local::writeArchivedStickers();
|
||||||
|
emit stickersUpdated();
|
||||||
}
|
}
|
||||||
Local::writeInstalledStickers();
|
|
||||||
if (writeArchived) Local::writeArchivedStickers();
|
|
||||||
emit stickersUpdated();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
@ -4756,7 +4757,7 @@ void MainWidget::feedUpdate(const MTPUpdate &update) {
|
||||||
auto &order = d.vorder.c_vector().v;
|
auto &order = d.vorder.c_vector().v;
|
||||||
auto &sets = Global::StickerSets();
|
auto &sets = Global::StickerSets();
|
||||||
Stickers::Order result;
|
Stickers::Order result;
|
||||||
for (int32 i = 0, l = order.size(); i < l; ++i) {
|
for (int i = 0, l = order.size(); i < l; ++i) {
|
||||||
if (sets.constFind(order.at(i).v) == sets.cend()) {
|
if (sets.constFind(order.at(i).v) == sets.cend()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue