2018-12-31 20:04:05 +01:00
|
|
|
//
|
2020-01-01 02:23:48 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2020
|
2018-12-31 20:04:05 +01:00
|
|
|
//
|
|
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "td/telegram/DialogId.h"
|
|
|
|
#include "td/telegram/files/FileId.h"
|
2019-01-19 22:54:29 +01:00
|
|
|
#include "td/telegram/files/FileType.h"
|
2019-06-08 11:26:35 +02:00
|
|
|
#include "td/telegram/net/DcId.h"
|
2019-06-19 02:18:44 +02:00
|
|
|
#include "td/telegram/PhotoSizeSource.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
#include "td/telegram/SecretInputMedia.h"
|
2019-06-08 11:26:35 +02:00
|
|
|
#include "td/telegram/UserId.h"
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
#include "td/telegram/secret_api.h"
|
|
|
|
#include "td/telegram/td_api.h"
|
|
|
|
#include "td/telegram/telegram_api.h"
|
|
|
|
|
2019-03-01 20:51:33 +01:00
|
|
|
#include "td/utils/buffer.h"
|
|
|
|
#include "td/utils/common.h"
|
2020-07-06 14:26:29 +02:00
|
|
|
#include "td/utils/MovableValue.h"
|
2019-03-01 20:51:33 +01:00
|
|
|
#include "td/utils/StringBuilder.h"
|
2019-07-23 00:50:12 +02:00
|
|
|
#include "td/utils/Variant.h"
|
2019-03-01 20:51:33 +01:00
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class FileManager;
|
|
|
|
|
|
|
|
struct Dimensions {
|
|
|
|
uint16 width = 0;
|
|
|
|
uint16 height = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DialogPhoto {
|
|
|
|
FileId small_file_id;
|
|
|
|
FileId big_file_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct ProfilePhoto : public DialogPhoto {
|
|
|
|
int64 id = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct PhotoSize {
|
2018-04-03 09:35:04 +02:00
|
|
|
int32 type = 0;
|
2018-12-31 20:04:05 +01:00
|
|
|
Dimensions dimensions;
|
|
|
|
int32 size = 0;
|
|
|
|
FileId file_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Photo {
|
2020-07-06 14:26:29 +02:00
|
|
|
MovableValue<int64, -2> id;
|
2018-12-31 20:04:05 +01:00
|
|
|
int32 date = 0;
|
2019-03-01 20:51:33 +01:00
|
|
|
string minithumbnail;
|
2018-12-31 20:04:05 +01:00
|
|
|
vector<PhotoSize> photos;
|
|
|
|
|
|
|
|
bool has_stickers = false;
|
|
|
|
vector<FileId> sticker_file_ids;
|
2020-06-23 20:04:26 +02:00
|
|
|
|
|
|
|
bool is_empty() const {
|
2020-07-06 14:26:29 +02:00
|
|
|
return id.get() == -2;
|
2020-06-23 20:04:26 +02:00
|
|
|
}
|
2018-12-31 20:04:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
Dimensions get_dimensions(int32 width, int32 height);
|
|
|
|
|
|
|
|
bool operator==(const Dimensions &lhs, const Dimensions &rhs);
|
|
|
|
bool operator!=(const Dimensions &lhs, const Dimensions &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const Dimensions &dimensions);
|
|
|
|
|
2019-03-01 20:51:33 +01:00
|
|
|
td_api::object_ptr<td_api::minithumbnail> get_minithumbnail_object(const string &packed);
|
|
|
|
|
2019-06-08 11:26:35 +02:00
|
|
|
ProfilePhoto get_profile_photo(FileManager *file_manager, UserId user_id, int64 user_access_hash,
|
2018-12-31 20:04:05 +01:00
|
|
|
tl_object_ptr<telegram_api::UserProfilePhoto> &&profile_photo_ptr);
|
|
|
|
tl_object_ptr<td_api::profilePhoto> get_profile_photo_object(FileManager *file_manager,
|
|
|
|
const ProfilePhoto *profile_photo);
|
|
|
|
|
|
|
|
bool operator==(const ProfilePhoto &lhs, const ProfilePhoto &rhs);
|
|
|
|
bool operator!=(const ProfilePhoto &lhs, const ProfilePhoto &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const ProfilePhoto &profile_photo);
|
|
|
|
|
2019-06-08 11:26:35 +02:00
|
|
|
DialogPhoto get_dialog_photo(FileManager *file_manager, DialogId dialog_id, int64 dialog_access_hash,
|
|
|
|
tl_object_ptr<telegram_api::ChatPhoto> &&chat_photo_ptr);
|
2020-07-07 12:00:56 +02:00
|
|
|
tl_object_ptr<td_api::chatPhotoInfo> get_chat_photo_info_object(FileManager *file_manager,
|
|
|
|
const DialogPhoto *dialog_photo);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-06-08 11:26:35 +02:00
|
|
|
DialogPhoto as_dialog_photo(const Photo &photo);
|
|
|
|
|
2019-01-20 04:34:47 +01:00
|
|
|
vector<FileId> dialog_photo_get_file_ids(const DialogPhoto &dialog_photo);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool operator==(const DialogPhoto &lhs, const DialogPhoto &rhs);
|
|
|
|
bool operator!=(const DialogPhoto &lhs, const DialogPhoto &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const DialogPhoto &dialog_photo);
|
|
|
|
|
2020-06-01 19:34:48 +02:00
|
|
|
enum class PhotoFormat : int32 { Jpeg, Png, Webp, Gif, Tgs, Mpeg4 };
|
2020-05-11 21:17:49 +02:00
|
|
|
|
2019-03-01 20:51:33 +01:00
|
|
|
PhotoSize get_secret_thumbnail_photo_size(FileManager *file_manager, BufferSlice bytes, DialogId owner_dialog_id,
|
|
|
|
int32 width, int32 height);
|
2019-06-08 11:26:35 +02:00
|
|
|
Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id,
|
|
|
|
int64 access_hash, string file_reference, DcId dc_id,
|
|
|
|
DialogId owner_dialog_id, tl_object_ptr<telegram_api::PhotoSize> &&size_ptr,
|
2020-05-11 21:17:49 +02:00
|
|
|
PhotoFormat format);
|
2020-05-30 00:48:56 +02:00
|
|
|
PhotoSize get_video_photo_size(FileManager *file_manager, PhotoSizeSource source, int64 id, int64 access_hash,
|
|
|
|
string file_reference, DcId dc_id, DialogId owner_dialog_id,
|
|
|
|
tl_object_ptr<telegram_api::videoSize> &&size);
|
2018-03-03 22:33:26 +01:00
|
|
|
PhotoSize get_web_document_photo_size(FileManager *file_manager, FileType file_type, DialogId owner_dialog_id,
|
|
|
|
tl_object_ptr<telegram_api::WebDocument> web_document_ptr);
|
2020-05-31 21:22:15 +02:00
|
|
|
td_api::object_ptr<td_api::thumbnail> get_thumbnail_object(FileManager *file_manager, const PhotoSize &photo_size,
|
|
|
|
PhotoFormat format);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
bool operator==(const PhotoSize &lhs, const PhotoSize &rhs);
|
|
|
|
bool operator!=(const PhotoSize &lhs, const PhotoSize &rhs);
|
|
|
|
|
2018-04-03 09:35:04 +02:00
|
|
|
bool operator<(const PhotoSize &lhs, const PhotoSize &rhs);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const PhotoSize &photo_size);
|
|
|
|
|
2019-06-08 11:26:35 +02:00
|
|
|
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::Photo> &&photo, DialogId owner_dialog_id);
|
2018-12-31 20:04:05 +01:00
|
|
|
Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&photo, DialogId owner_dialog_id);
|
2019-06-17 01:05:56 +02:00
|
|
|
Photo get_encrypted_file_photo(FileManager *file_manager, tl_object_ptr<telegram_api::encryptedFile> &&file,
|
|
|
|
tl_object_ptr<secret_api::decryptedMessageMediaPhoto> &&photo, DialogId owner_dialog_id);
|
2018-09-27 21:44:40 +02:00
|
|
|
Photo get_web_document_photo(FileManager *file_manager, tl_object_ptr<telegram_api::WebDocument> web_document,
|
|
|
|
DialogId owner_dialog_id);
|
2020-07-06 17:45:43 +02:00
|
|
|
tl_object_ptr<td_api::photo> get_photo_object(FileManager *file_manager, const Photo &photo);
|
2020-07-07 12:48:56 +02:00
|
|
|
tl_object_ptr<td_api::chatPhoto> get_chat_photo_object(FileManager *file_manager, const Photo &photo);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
void photo_delete_thumbnail(Photo &photo);
|
|
|
|
|
2020-05-03 14:44:33 +02:00
|
|
|
bool photo_has_input_media(FileManager *file_manager, const Photo &photo, bool is_secret, bool is_bot);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
|
|
|
SecretInputMedia photo_get_secret_input_media(FileManager *file_manager, const Photo &photo,
|
|
|
|
tl_object_ptr<telegram_api::InputEncryptedFile> input_file,
|
|
|
|
const string &caption, BufferSlice thumbnail);
|
|
|
|
|
|
|
|
tl_object_ptr<telegram_api::InputMedia> photo_get_input_media(FileManager *file_manager, const Photo &photo,
|
|
|
|
tl_object_ptr<telegram_api::InputFile> input_file,
|
2018-01-30 18:06:54 +01:00
|
|
|
int32 ttl);
|
2018-12-31 20:04:05 +01:00
|
|
|
|
2019-01-06 00:15:07 +01:00
|
|
|
vector<FileId> photo_get_file_ids(const Photo &photo);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
bool operator==(const Photo &lhs, const Photo &rhs);
|
|
|
|
bool operator!=(const Photo &lhs, const Photo &rhs);
|
|
|
|
|
|
|
|
StringBuilder &operator<<(StringBuilder &string_builder, const Photo &photo);
|
|
|
|
|
2019-01-22 17:08:41 +01:00
|
|
|
tl_object_ptr<telegram_api::userProfilePhoto> convert_photo_to_profile_photo(
|
|
|
|
const tl_object_ptr<telegram_api::photo> &photo);
|
|
|
|
|
2018-12-31 20:04:05 +01:00
|
|
|
} // namespace td
|