diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b93a7be62..40708e92a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -2096,6 +2096,10 @@ deviceTokenTizenPush reg_id:string = DeviceToken; pushReceiverId id:int64 = PushReceiverId; +//@description Describes a gradient background @top_color A top color of the background in the RGB24 format @bottom_color A bottom color of the background in the RGB24 format +gradientInfo top_color:int32 bottom_color:int32 = GradientInfo; + + //@class BackgroundType @description Describes a type of a background //@description A wallpaper in JPEG format @@ -2109,11 +2113,11 @@ backgroundTypeWallpaper is_blurred:Bool is_moving:Bool = BackgroundType; //@intensity Intensity of the pattern when it is shown above the main background color, 0-100 backgroundTypePattern is_moving:Bool color:int32 intensity:int32 = BackgroundType; -//@description A solid background @color A color of the background in RGB24 format +//@description A solid background @color A color of the background in the RGB24 format backgroundTypeSolid color:int32 = BackgroundType; -//@description A gradient background @top_color A top color of the background in RGB24 format @bottom_color A bottom color of the background in RGB24 format -backgroundTypeGradient top_color:int32 bottom_color:int32 = BackgroundType; +//@description A gradient background @gradient Gradient description +backgroundTypeGradient gradient:gradientInfo = BackgroundType; //@description Describes a chat background diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index de3de4f0e..3e465e703 100644 Binary files a/td/generate/scheme/td_api.tlo and b/td/generate/scheme/td_api.tlo differ diff --git a/td/telegram/BackgroundType.cpp b/td/telegram/BackgroundType.cpp index 4aacb04cd..6d07357a7 100644 --- a/td/telegram/BackgroundType.cpp +++ b/td/telegram/BackgroundType.cpp @@ -70,7 +70,10 @@ Result get_background_type(const td_api::BackgroundType *type) { } case td_api::backgroundTypeGradient::ID: { auto gradient = static_cast(type); - result = BackgroundType(gradient->top_color_, gradient->bottom_color_); + if (gradient->gradient_ == nullptr) { + return Status::Error(400, "Gradient info must not be empty"); + } + result = BackgroundType(gradient->gradient_->top_color_, gradient->gradient_->bottom_color_); break; } default: @@ -123,6 +126,10 @@ BackgroundType get_background_type(bool is_pattern, } } +td_api::object_ptr get_gradient_info_object(int32 top_color, int32 bottom_color) { + return td_api::make_object(top_color, bottom_color); +} + td_api::object_ptr get_background_type_object(const BackgroundType &type) { switch (type.type) { case BackgroundType::Type::Wallpaper: @@ -132,7 +139,7 @@ td_api::object_ptr get_background_type_object(const Back case BackgroundType::Type::Solid: return td_api::make_object(type.color); case BackgroundType::Type::Gradient: - return td_api::make_object(type.color, type.intensity); + return td_api::make_object(get_gradient_info_object(type.color, type.intensity)); default: UNREACHABLE(); return nullptr; diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 56af732f7..3cc0dc45f 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1271,6 +1271,11 @@ class CliClient final : public Actor { return td_api::make_object(send_date); } + td_api::object_ptr get_gradient_background(int32 top_color, int32 bottom_color) { + auto gradient_info = td_api::make_object(top_color, bottom_color); + return td_api::make_object(std::move(gradient_info)); + } + static td_api::object_ptr execute(td_api::object_ptr f) { if (GET_VERBOSITY_LEVEL() < VERBOSITY_NAME(td_requests)) { LOG(ERROR) << "Execute request: " << to_string(f); @@ -2102,9 +2107,9 @@ class CliClient final : public Actor { send_get_background_url(td_api::make_object(-1)); send_get_background_url(td_api::make_object(0xABCDEF)); send_get_background_url(td_api::make_object(0x1000000)); - send_get_background_url(td_api::make_object(0xABCDEF, 0xFEDCBA)); - send_get_background_url(td_api::make_object(0, 0)); - send_get_background_url(td_api::make_object(-1, -1)); + send_get_background_url(get_gradient_background(0xABCDEF, 0xFEDCBA)); + send_get_background_url(get_gradient_background(0, 0)); + send_get_background_url(get_gradient_background(-1, -1)); } else if (op == "sbg") { send_request(td_api::make_object(args)); } else if (op == "sbgd") { @@ -2124,8 +2129,7 @@ class CliClient final : public Actor { string top_color; string bottom_color; std::tie(top_color, bottom_color) = split(args); - auto background_type = td_api::make_object(to_integer(top_color), - to_integer(bottom_color)); + auto background_type = get_gradient_background(to_integer(top_color), to_integer(bottom_color)); send_request(td_api::make_object(nullptr, std::move(background_type), op == "sbggd")); } else if (op == "sbgwid" || op == "sbgwidd") { send_request(td_api::make_object(