2016-04-04 21:09:46 +00:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
2018-01-03 10:23:14 +00:00
|
|
|
the official desktop application for the Telegram messaging service.
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2018-01-03 10:23:14 +00:00
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
2016-04-04 21:09:46 +00:00
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2020-05-27 14:31:39 +00:00
|
|
|
#include "data/data_cloud_file.h"
|
2020-11-12 15:46:17 +00:00
|
|
|
#include "api/api_common.h"
|
2021-06-14 06:21:56 +00:00
|
|
|
#include "media/view/media_view_open_common.h"
|
2020-05-27 14:31:39 +00:00
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
class FileLoader;
|
2019-09-13 06:06:02 +00:00
|
|
|
class History;
|
2020-11-12 15:46:17 +00:00
|
|
|
class UserData;
|
2021-10-02 11:28:21 +00:00
|
|
|
struct HistoryMessageMarkupData;
|
2019-06-21 12:27:46 +00:00
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
class LocationPoint;
|
|
|
|
} // namespace Data
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
namespace InlineBots {
|
|
|
|
|
|
|
|
namespace Layout {
|
|
|
|
class ItemBase;
|
|
|
|
} // namespace Layout
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
class SendData;
|
|
|
|
} // namespace internal
|
|
|
|
|
|
|
|
class Result {
|
|
|
|
private:
|
|
|
|
// See http://stackoverflow.com/a/8147326
|
|
|
|
struct Creator;
|
|
|
|
|
|
|
|
public:
|
2017-02-21 13:45:56 +00:00
|
|
|
// Constructor is public only for std::make_unique<>() to work.
|
2016-04-04 21:09:46 +00:00
|
|
|
// You should use create() static method instead.
|
2020-05-28 13:51:18 +00:00
|
|
|
Result(not_null<Main::Session*> session, const Creator &creator);
|
|
|
|
|
|
|
|
static std::unique_ptr<Result> Create(
|
|
|
|
not_null<Main::Session*> session,
|
|
|
|
uint64 queryId,
|
|
|
|
const MTPBotInlineResult &mtpData);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2016-04-05 20:24:27 +00:00
|
|
|
uint64 getQueryId() const {
|
|
|
|
return _queryId;
|
|
|
|
}
|
|
|
|
QString getId() const {
|
|
|
|
return _id;
|
|
|
|
}
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2016-04-05 20:24:27 +00:00
|
|
|
// This is real SendClickHandler::onClick implementation for the specified
|
|
|
|
// inline bot result. If it returns true you need to send this result.
|
|
|
|
bool onChoose(Layout::ItemBase *layout);
|
2016-04-04 21:09:46 +00:00
|
|
|
|
2021-06-14 06:21:56 +00:00
|
|
|
Media::View::OpenRequest openRequest();
|
2016-04-04 21:09:46 +00:00
|
|
|
void cancelFile();
|
|
|
|
|
|
|
|
bool hasThumbDisplay() const;
|
|
|
|
|
2019-08-09 19:19:23 +00:00
|
|
|
void addToHistory(
|
|
|
|
History *history,
|
2021-07-28 11:55:02 +00:00
|
|
|
MessageFlags flags,
|
2019-08-09 19:19:23 +00:00
|
|
|
MsgId msgId,
|
2020-09-01 06:44:18 +00:00
|
|
|
PeerId fromId,
|
2021-07-28 11:55:02 +00:00
|
|
|
TimeId date,
|
2019-08-09 19:19:23 +00:00
|
|
|
UserId viaBotId,
|
|
|
|
MsgId replyToId,
|
|
|
|
const QString &postAuthor) const;
|
2017-06-11 18:33:20 +00:00
|
|
|
QString getErrorOnSend(History *history) const;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
// interface for Layout:: usage
|
2019-06-21 12:27:46 +00:00
|
|
|
std::optional<Data::LocationPoint> getLocationPoint() const;
|
2016-04-04 21:09:46 +00:00
|
|
|
QString getLayoutTitle() const;
|
|
|
|
QString getLayoutDescription() const;
|
|
|
|
|
2016-09-28 21:33:05 +00:00
|
|
|
~Result();
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
private:
|
2020-06-08 09:06:50 +00:00
|
|
|
void createGame(not_null<Main::Session*> session);
|
2018-03-04 20:04:13 +00:00
|
|
|
QSize thumbBox() const;
|
|
|
|
MTPWebDocument adjustAttributes(const MTPWebDocument &document);
|
|
|
|
MTPVector<MTPDocumentAttribute> adjustAttributes(
|
|
|
|
const MTPVector<MTPDocumentAttribute> &document,
|
|
|
|
const MTPstring &mimeType);
|
2016-04-09 08:29:34 +00:00
|
|
|
|
2016-04-05 20:24:27 +00:00
|
|
|
enum class Type {
|
|
|
|
Unknown,
|
|
|
|
Photo,
|
|
|
|
Video,
|
|
|
|
Audio,
|
|
|
|
Sticker,
|
|
|
|
File,
|
|
|
|
Gif,
|
|
|
|
Article,
|
|
|
|
Contact,
|
2016-04-11 10:59:01 +00:00
|
|
|
Geo,
|
2016-04-05 20:24:27 +00:00
|
|
|
Venue,
|
2016-09-28 16:23:25 +00:00
|
|
|
Game,
|
2016-04-05 20:24:27 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
friend class internal::SendData;
|
|
|
|
friend class Layout::ItemBase;
|
2016-04-04 21:09:46 +00:00
|
|
|
struct Creator {
|
2020-05-28 13:51:18 +00:00
|
|
|
uint64 queryId = 0;
|
|
|
|
Type type = Type::Unknown;
|
2016-04-04 21:09:46 +00:00
|
|
|
};
|
|
|
|
|
2020-05-28 13:51:18 +00:00
|
|
|
not_null<Main::Session*> _session;
|
2016-04-05 20:24:27 +00:00
|
|
|
uint64 _queryId = 0;
|
|
|
|
QString _id;
|
|
|
|
Type _type = Type::Unknown;
|
2018-03-04 20:04:13 +00:00
|
|
|
QString _title, _description, _url;
|
|
|
|
QString _content_url;
|
2016-04-05 20:24:27 +00:00
|
|
|
DocumentData *_document = nullptr;
|
|
|
|
PhotoData *_photo = nullptr;
|
2016-09-28 16:23:25 +00:00
|
|
|
GameData *_game = nullptr;
|
2016-04-05 20:24:27 +00:00
|
|
|
|
2021-10-02 11:28:21 +00:00
|
|
|
std::unique_ptr<HistoryMessageMarkupData> _replyMarkup;
|
2016-04-06 08:00:37 +00:00
|
|
|
|
2020-05-27 14:31:39 +00:00
|
|
|
Data::CloudImage _thumbnail;
|
|
|
|
Data::CloudImage _locationThumbnail;
|
2016-04-05 20:24:27 +00:00
|
|
|
|
2017-02-21 13:45:56 +00:00
|
|
|
std::unique_ptr<internal::SendData> sendData;
|
2016-04-04 21:09:46 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2020-11-12 15:46:17 +00:00
|
|
|
struct ResultSelected {
|
|
|
|
not_null<Result*> result;
|
|
|
|
not_null<UserData*> bot;
|
|
|
|
Api::SendOptions options;
|
2021-06-14 06:21:56 +00:00
|
|
|
// Open in OverlayWidget;
|
|
|
|
bool open = false;
|
2020-11-12 15:46:17 +00:00
|
|
|
};
|
|
|
|
|
2016-04-04 21:09:46 +00:00
|
|
|
} // namespace InlineBots
|