commit:     83141082196bb550fd8ac075df0e1ab412b36ea4
Author:     bip125 <bip125 <AT> yandex <DOT> com>
AuthorDate: Wed Feb 18 18:21:18 2026 +0000
Commit:     bip125 <bip125 <AT> yandex <DOT> com>
CommitDate: Wed Feb 18 18:32:21 2026 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=83141082

net-im/forkgram: new package, add 6.5.1

Signed-off-by: bip125 <bip125 <AT> yandex.com>

 net-im/forkgram/Manifest                           |   1 +
 .../0000-data_data_sponsored_messages.cpp.patch    |  64 +++++
 .../files/0001-kde-theme-injection-fix.patch       |  13 +
 .../files/invite-peeking-restrictions.patch        |  13 +
 .../forkgram/files/option-to-disable-stories.patch |  81 +++++++
 net-im/forkgram/files/pins.patch                   | 104 ++++++++
 net-im/forkgram/files/saving-restrictions.patch    | 206 ++++++++++++++++
 .../files/tdesktop-3.3.2-system-minizip.patch      |  23 ++
 .../files/tdesktop-4.11.3-system-libyuv.patch      |  24 ++
 .../forkgram/files/tdesktop-4.11.3-zlib-ng.patch   |  53 ++++
 .../files/tdesktop-5.14.3-system-cppgir.patch      |  31 +++
 .../files/tdesktop-5.2.2-libdispatch.patch         |  24 ++
 .../files/tdesktop-5.2.2-qt6-no-wayland.patch      |  86 +++++++
 net-im/forkgram/files/tdesktop-5.7.2-cstring.patch |  12 +
 net-im/forkgram/files/tdesktop-5.8.3-cstdint.patch |  15 ++
 .../files/tdesktop-6.3.2-loosen-minizip.patch      |  20 ++
 net-im/forkgram/forkgram-6.5.1.ebuild              | 269 +++++++++++++++++++++
 net-im/forkgram/metadata.xml                       |  27 +++
 18 files changed, 1066 insertions(+)

diff --git a/net-im/forkgram/Manifest b/net-im/forkgram/Manifest
new file mode 100644
index 0000000000..4f8b5589f5
--- /dev/null
+++ b/net-im/forkgram/Manifest
@@ -0,0 +1 @@
+DIST frk-v6.5.1-full.tar.gz 77119672 BLAKE2B 
68203545dad444b934fe6edf7a17d95d6624fb0f37dfc6117d5934245ee67aefe0e700392f3a8ec65a99fcaf0f0b9f62ca638b332c65f00576972456ad9002ce
 SHA512 
aa26227f9675fd0202d119235372dfba7b5af78fe1531924b248a36c4c27c5621f9c9df46ca5eb24ede027c2441e84015b90f7a171f08440b86ee5f05cb29cf2

diff --git a/net-im/forkgram/files/0000-data_data_sponsored_messages.cpp.patch 
b/net-im/forkgram/files/0000-data_data_sponsored_messages.cpp.patch
new file mode 100644
index 0000000000..6dd9de1632
--- /dev/null
+++ b/net-im/forkgram/files/0000-data_data_sponsored_messages.cpp.patch
@@ -0,0 +1,64 @@
+diff --git i/Telegram/SourceFiles/data/data_sponsored_messages.cpp 
w/Telegram/SourceFiles/data/data_sponsored_messages.cpp
+index 10e69d37b..fbcb20158 100644
+--- i/Telegram/SourceFiles/data/components/sponsored_messages.cpp
++++ w/Telegram/SourceFiles/data/components/sponsored_messages.cpp
+@@ -30,7 +30,7 @@
+ namespace {
+ 
+ constexpr auto kMs = crl::time(1000);
+-constexpr auto kRequestTimeLimit = 5 * 60 * crl::time(1000);
++constexpr auto kRequestTimeLimit = 9999999 * 60 * crl::time(1000);
+ 
+ const auto kFlaggedPreload = ((MediaPreload*)quintptr(0x01));
+ 
+@@ -74,6 +74,9 @@ void SponsoredMessages::clearOldRequests
+ 
+ SponsoredMessages::AppendResult SponsoredMessages::append(
+               not_null<History*> history) {
++      if (1) {
++              return SponsoredMessages::AppendResult::None;
++      }
+       if (isTopBarFor(history)) {
+               return SponsoredMessages::AppendResult::None;
+       }
+@@ -110,6 +113,9 @@ void SponsoredMessages::inject(
+               MsgId injectAfterMsgId,
+               int betweenHeight,
+               int fallbackWidth) {
++      if (1) {
++              return;
++      }
+       if (!canHaveFor(history)) {
+               return;
+       }
+@@ -245,11 +245,6 @@
+ }
+ 
+ bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
+-      if (history->peer->isChannel()) {
+-              return true;
+-      } else if (const auto user = history->peer->asUser()) {
+-              return user->isBot();
+-      }
+       return false;
+ }
+ 
+@@ -259,11 +254,6 @@
+ }
+ 
+ bool SponsoredMessages::isTopBarFor(not_null<History*> history) const {
+-      if (peerIsUser(history->peer->id)) {
+-              if (const auto user = history->peer->asUser()) {
+-                      return user->isBot();
+-              }
+-      }
+       return false;
+ }
+  
+ void SponsoredMessages::request(not_null<History*> history, Fn<void()> done) {
++      if (1) {
++              return;
++      }
+       if (!canHaveFor(history)) {
+               return;
+       }

diff --git a/net-im/forkgram/files/0001-kde-theme-injection-fix.patch 
b/net-im/forkgram/files/0001-kde-theme-injection-fix.patch
new file mode 100644
index 0000000000..ccfddf176a
--- /dev/null
+++ b/net-im/forkgram/files/0001-kde-theme-injection-fix.patch
@@ -0,0 +1,13 @@
+diff --git a/Telegram/SourceFiles/platform/linux/tray_linux.cpp 
b/Telegram/SourceFiles/platform/linux/tray_linux.cpp
+index 2cc92f331..82e131ea9 100644
+--- a/Telegram/SourceFiles/platform/linux/tray_linux.cpp
++++ b/Telegram/SourceFiles/platform/linux/tray_linux.cpp
+@@ -105,7 +105,7 @@ QIcon IconGraphic::systemIcon() const {
+ }
+ 
+ bool IconGraphic::isCounterNeeded(const State &state) const {
+-      return state.systemIcon.name() != PanelIconName(
++      return true || state.systemIcon.name() != PanelIconName(
+               state.counter,
+               state.muted);
+ }

diff --git a/net-im/forkgram/files/invite-peeking-restrictions.patch 
b/net-im/forkgram/files/invite-peeking-restrictions.patch
new file mode 100644
index 0000000000..6506726af0
--- /dev/null
+++ b/net-im/forkgram/files/invite-peeking-restrictions.patch
@@ -0,0 +1,13 @@
+diff --git a/Telegram/SourceFiles/data/data_channel.cpp 
b/Telegram/SourceFiles/data/data_channel.cpp
+index dddc441..fdf9e81 100644
+--- a/Telegram/SourceFiles/data/data_channel.cpp
++++ b/Telegram/SourceFiles/data/data_channel.cpp
+@@ -779,7 +779,7 @@ void ChannelData::clearInvitePeek() {
+ }
+ 
+ TimeId ChannelData::invitePeekExpires() const {
+-      return _invitePeek ? _invitePeek->expires : 0;
++      return 0;
+ }
+ 
+ QString ChannelData::invitePeekHash() const {

diff --git a/net-im/forkgram/files/option-to-disable-stories.patch 
b/net-im/forkgram/files/option-to-disable-stories.patch
new file mode 100644
index 0000000000..54ac2c7297
--- /dev/null
+++ b/net-im/forkgram/files/option-to-disable-stories.patch
@@ -0,0 +1,81 @@
+diff --git a/Telegram/SourceFiles/data/data_stories.cpp 
b/Telegram/SourceFiles/data/data_stories.cpp
+index d3baee3..04ee5a4 100644
+--- a/Telegram/SourceFiles/data/data_stories.cpp
++++ b/Telegram/SourceFiles/data/data_stories.cpp
+@@ -8,6 +8,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+ #include "data/data_stories.h"
+
+ #include "base/unixtime.h"
++#include "base/options.h"
+ #include "apiwrap.h"
+ #include "core/application.h"
+ #include "data/data_changes.h"
+@@ -48,6 +49,14 @@ constexpr auto kPollingViewsPerPage = 
Story::kRecentViewersMax;
+
+ using UpdateFlag = StoryUpdate::Flag;
+
++base::options::toggle DisableStories({
++      .id = kOptionDisableStories,
++      .name = "Disable stories",
++      .description = "",
++      .defaultValue = false,
++});
++
++
+ [[nodiscard]] std::optional<StoryMedia> ParseMedia(
+               not_null<Session*> owner,
+               const MTPMessageMedia &media) {
+@@ -95,6 +104,8 @@ using UpdateFlag = StoryUpdate::Flag;
+
+ } // namespace
+
++const char kOptionDisableStories[] = "disable-stories";
++
+ StoriesSourceInfo StoriesSource::info() const {
+       return {
+               .id = peer->id,
+@@ -534,6 +534,11 @@ Story *Stories::parseAndApply(
+               not_null<PeerData*> peer,
+               const MTPDstoryItem &data,
+               TimeId now) {
++
++  if (DisableStories.value()) {
++    return nullptr;
++  }
++
+       const auto id = data.vid().v;
+       const auto fullId = FullStoryId{ peer->id, id };
+       auto &stories = _stories[peer->id];
+diff --git a/Telegram/SourceFiles/data/data_stories.h 
b/Telegram/SourceFiles/data/data_stories.h
+index 1cc3bb3..b42ef79 100644
+--- a/Telegram/SourceFiles/data/data_stories.h
++++ b/Telegram/SourceFiles/data/data_stories.h
+@@ -30,6 +30,8 @@ struct StoryIdDates;
+ class Story;
+ class StoryPreload;
+
++extern const char kOptionDisableStories[];
++
+ struct StoriesIds {
+       base::flat_set<StoryId, std::greater<>> list;
+
+diff --git a/Telegram/SourceFiles/settings/settings_experimental.cpp 
b/Telegram/SourceFiles/settings/settings_experimental.cpp
+index 3b9a5a0..2f9ad4d 100644
+--- a/Telegram/SourceFiles/settings/settings_experimental.cpp
++++ b/Telegram/SourceFiles/settings/settings_experimental.cpp
+@@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
+ #include "core/sandbox.h"
+ #include "core/launcher.h"
+ #include "chat_helpers/tabbed_panel.h"
++#include "data/data_stories.h";
+ #include "dialogs/dialogs_widget.h"
+ #include "info/profile/info_profile_actions.h"
+ #include "lang/lang_keys.h"
+@@ -142,5 +143,6 @@ void SetupExperimental(
+                               : rpl::producer<>()));
+       };
+
++      addToggle(Data::kOptionDisableStories);
+       addToggle(ChatHelpers::kOptionTabbedPanelShowOnClick);
+       addToggle(Dialogs::kOptionForumHideChatsList);
+       addToggle(Core::kOptionFractionalScalingEnabled);

diff --git a/net-im/forkgram/files/pins.patch b/net-im/forkgram/files/pins.patch
new file mode 100644
index 0000000000..d42b80248c
--- /dev/null
+++ b/net-im/forkgram/files/pins.patch
@@ -0,0 +1,104 @@
+diff -NaurBwdp a/Telegram/SourceFiles/data/data_session.cpp 
b/Telegram/SourceFiles/data/data_session.cpp
+--- a/Telegram/SourceFiles/data/data_session.cpp       2022-12-28 
03:29:59.721281542 +0700
++++ b/Telegram/SourceFiles/data/data_session.cpp       2022-12-28 
03:35:05.748566381 +0700
+@@ -2138,48 +2138,28 @@ void Session::applyDialog(
+ }
+ 
+ bool Session::pinnedCanPin(not_null<Dialogs::Entry*> entry) const {
+-      if ([[maybe_unused]] const auto sublist = entry->asSublist()) {
+-              if (sublist->parentChat()) {
+-                      return false;
+-              }
+-              const auto saved = &savedMessages();
+-              return pinnedChatsOrder(saved).size() < pinnedChatsLimit(saved);
+-      } else if (const auto topic = entry->asTopic()) {
+-              const auto forum = topic->forum();
+-              return pinnedChatsOrder(forum).size() < pinnedChatsLimit(forum);
+-      } else {
+-              const auto folder = entry->folder();
+-              return pinnedChatsOrder(folder).size() < 
pinnedChatsLimit(folder);
+-      }
++      return true;
+ }
+ 
+ bool Session::pinnedCanPin(
+               FilterId filterId,
+               not_null<History*> history) const {
+-      Expects(filterId != 0);
+-
+-      const auto &list = chatsFilters().list();
+-      const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
+-      return (i == end(list))
+-              || (i->always().contains(history))
+-              || (i->always().size() < pinnedChatsLimit(filterId));
++      return true;
+ }
+ 
+ int Session::pinnedChatsLimit(Data::Folder *folder) const {
+       const auto limits = Data::PremiumLimits(_session);
+-      return folder
+-              ? limits.dialogsFolderPinnedCurrent()
+-              : limits.dialogsPinnedCurrent();
++      return 999999;
+ }
+ 
+ int Session::pinnedChatsLimit(FilterId filterId) const {
+       const auto limits = Data::PremiumLimits(_session);
+-      return limits.dialogFiltersChatsCurrent();
++      return 999999;
+ }
+ 
+ int Session::pinnedChatsLimit(not_null<Data::Forum*> forum) const {
+       const auto limits = Data::PremiumLimits(_session);
+-      return limits.topicsPinnedCurrent();
++      return 999999;
+ }
+ 
+ int Session::pinnedChatsLimit(not_null<Data::SavedMessages*> saved) const {
+@@ -2190,12 +2173,7 @@ rpl::producer<int> Session::maxPinnedCha
+       // We always use premium limit in the MainList limit producer,
+       // because it slices the list to that limit. We don't want to slice
+       // premium-ly added chats from the pinned list because of sync issues.
+-      return _session->appConfig().value(
+-      ) | rpl::map([folder, limits = Data::PremiumLimits(_session)] {
+-              return folder
+-                      ? limits.dialogsFolderPinnedPremium()
+-                      : limits.dialogsPinnedPremium();
+-      });
++      return rpl::single(999999);
+ }
+ 
+ rpl::producer<int> Session::maxPinnedChatsLimitValue(
+@@ -2204,18 +2182,12 @@ rpl::producer<int> Session::maxPinnedCha
+       // We always use premium limit in the MainList limit producer,
+       // because it slices the list to that limit. We don't want to slice
+       // premium-ly added chats from the pinned list because of sync issues.
+-      return _session->appConfig().value(
+-      ) | rpl::map([limits = Data::PremiumLimits(_session)] {
+-              return limits.dialogFiltersChatsPremium();
+-      });
++      return rpl::single(999999);
+ }
+ 
+ rpl::producer<int> Session::maxPinnedChatsLimitValue(
+               not_null<Data::Forum*> forum) const {
+-      return _session->appConfig().value(
+-      ) | rpl::map([limits = Data::PremiumLimits(_session)] {
+-              return limits.topicsPinnedCurrent();
+-      });
++      return rpl::single(999999);
+ }
+ 
+ rpl::producer<int> Session::maxPinnedChatsLimitValue(
+@@ -2224,10 +2196,7 @@ rpl::producer<int> Session::maxPinnedCha
+       // We always use premium limit in the MainList limit producer,
+       // because it slices the list to that limit. We don't want to slice
+       // premium-ly added chats from the pinned list because of sync issues.
+-      return _session->appConfig().value(
+-      ) | rpl::map([limits = Data::PremiumLimits(_session)] {
+-              return limits.savedSublistsPinnedPremium();
+-      });
++      return rpl::single(999999);
+ }
+ 
+ int Session::groupFreeTranscribeLevel() const {

diff --git a/net-im/forkgram/files/saving-restrictions.patch 
b/net-im/forkgram/files/saving-restrictions.patch
new file mode 100644
index 0000000000..3f98688a9b
--- /dev/null
+++ b/net-im/forkgram/files/saving-restrictions.patch
@@ -0,0 +1,206 @@
+diff --git a/Telegram/SourceFiles/data/data_story.cpp 
b/Telegram/SourceFiles/data/data_story.cpp
+index d5faa43..c6b26dc 100644
+--- a/Telegram/SourceFiles/data/data_story.cpp
++++ b/Telegram/SourceFiles/data/data_story.cpp
+@@ -399,12 +399,11 @@ bool Story::edited() const {
+ }
+ 
+ bool Story::canDownloadIfPremium() const {
+-      return !forbidsForward() || _peer->isSelf();
++      return true;
+ }
+ 
+ bool Story::canDownloadChecked() const {
+-      return _peer->isSelf()
+-              || (canDownloadIfPremium() && _peer->session().premium());
++      return true;
+ }
+ 
+ bool Story::canShare() const {
+diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp 
b/Telegram/SourceFiles/history/history_inner_widget.cpp
+index 2f1dabe..bd6d25f 100644
+--- a/Telegram/SourceFiles/history/history_inner_widget.cpp
++++ b/Telegram/SourceFiles/history/history_inner_widget.cpp
+@@ -621,16 +621,7 @@ void HistoryInner::setupSharingDisallowed() {
+ }
+ 
+ bool HistoryInner::hasSelectRestriction() const {
+-      if (session().frozen()) {
+-              return true;
+-      } else if (!_sharingDisallowed.current()) {
+-              return false;
+-      } else if (const auto chat = _peer->asChat()) {
+-              return !chat->canDeleteMessages();
+-      } else if (const auto channel = _peer->asChannel()) {
+-              return !channel->canDeleteMessages();
+-      }
+-      return true;
++      return false;
+ }
+ 
+ void HistoryInner::messagesReceived(
+@@ -3023,12 +3008,12 @@ void HistoryInner::showContextMenu(QContextMenuEvent 
*e, bool showFromTouch) {
+ }
+ 
+ bool HistoryInner::hasCopyRestriction(HistoryItem *item) const {
+-      return !_peer->allowsForwarding() || (item && item->forbidsForward());
++      return false;
+ }
+ 
+ bool HistoryInner::hasCopyMediaRestriction(
+               not_null<HistoryItem*> item) const {
+-      return hasCopyRestriction(item) || item->forbidsSaving();
++      return false;
+ }
+ 
+ bool HistoryInner::showCopyRestriction(HistoryItem *item) {
+@@ -3052,14 +3052,6 @@ bool HistoryInner::showCopyRestriction(HistoryItem 
*item) {
+ }
+ 
+ bool HistoryInner::hasCopyRestrictionForSelected() const {
+-      if (hasCopyRestriction()) {
+-              return true;
+-      }
+-      for (const auto &[item, selection] : _selected) {
+-              if (item && item->forbidsForward()) {
+-                      return true;
+-              }
+-      }
+       return false;
+ }
+ 
+diff --git a/Telegram/SourceFiles/history/history_item.cpp 
b/Telegram/SourceFiles/history/history_item.cpp
+index 55e1def..745338c 100644
+--- a/Telegram/SourceFiles/history/history_item.cpp
++++ b/Telegram/SourceFiles/history/history_item.cpp
+@@ -2358,11 +2358,6 @@ bool HistoryItem::forbidsForward() const {
+ }
+ 
+ bool HistoryItem::forbidsSaving() const {
+-      if (forbidsForward()) {
+-              return true;
+-      } else if (const auto invoice = _media ? _media->invoice() : nullptr) {
+-              return HasExtendedMedia(*invoice);
+-      }
+       return false;
+ }
+ 
+diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp 
b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
+index 3de0cb2..0359ab3 100644
+--- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
++++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
+@@ -1581,13 +1581,11 @@ bool ListWidget::isEmpty() const {
+ }
+ 
+ bool ListWidget::hasCopyRestriction(HistoryItem *item) const {
+-      return _delegate->listCopyRestrictionType(item)
+-              != CopyRestrictionType::None;
++      return false;
+ }
+ 
+ bool ListWidget::hasCopyMediaRestriction(not_null<HistoryItem*> item) const {
+-      return _delegate->listCopyMediaRestrictionType(item)
+-              != CopyRestrictionType::None;
++      return false;
+ }
+ 
+ bool ListWidget::showCopyRestriction(HistoryItem *item) {
+@@ -1613,21 +1611,6 @@ bool 
ListWidget::showCopyMediaRestriction(not_null<HistoryItem*> item) {
+ }
+ 
+ bool ListWidget::hasCopyRestrictionForSelected() const {
+-      if (hasCopyRestriction()) {
+-              return true;
+-      }
+-      if (_selected.empty()) {
+-              if (_selectedTextItem && _selectedTextItem->forbidsForward()) {
+-                      return true;
+-              }
+-      }
+-      for (const auto &[itemId, selection] : _selected) {
+-              if (const auto item = session().data().message(itemId)) {
+-                      if (item->forbidsForward()) {
+-                              return true;
+-                      }
+-              }
+-      }
+       return false;
+ }
+ 
+@@ -1646,9 +1628,7 @@ bool ListWidget::showCopyRestrictionForSelected() {
+ }
+ 
+ bool ListWidget::hasSelectRestriction() const {
+-      return session().frozen()
+-              || (_delegate->listSelectRestrictionType()
+-                      != CopyRestrictionType::None);
++      return false;
+ }
+ 
+ Element *ListWidget::lookupItemByY(int y) const {
+diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp 
b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
+index fa0d6ed..a569215 100644
+--- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
++++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
+@@ -1244,15 +1244,14 @@ void TopBarWidget::updateMembersShowArea() {
+ }
+ 
+ bool TopBarWidget::showSelectedState() const {
+-      return (_selectedCount > 0)
+-              && (_canDelete || _canForward || _canSendNow);
++      return _selectedCount > 0;
+ }
+ 
+ void TopBarWidget::showSelected(SelectedState state) {
+       auto canDelete = (state.count > 0 && state.count == 
state.canDeleteCount);
+       auto canForward = (state.count > 0 && state.count == 
state.canForwardCount);
+       auto canSendNow = (state.count > 0 && state.count == 
state.canSendNowCount);
+-      auto count = (!canDelete && !canForward && !canSendNow) ? 0 : 
state.count;
++      auto count = state.count;
+       if (_selectedCount == count
+               && _canDelete == canDelete
+               && _canForward == canForward
+diff --git a/Telegram/SourceFiles/info/media/info_media_provider.cpp 
b/Telegram/SourceFiles/info/media/info_media_provider.cpp
+index 3e75975..ee23733 100644
+--- a/Telegram/SourceFiles/info/media/info_media_provider.cpp
++++ b/Telegram/SourceFiles/info/media/info_media_provider.cpp
+@@ -62,16 +62,7 @@ Type Provider::type() {
+ }
+ 
+ bool Provider::hasSelectRestriction() {
+-      if (_peer->session().frozen()) {
+-              return true;
+-      } else if (_peer->allowsForwarding()) {
+-              return false;
+-      } else if (const auto chat = _peer->asChat()) {
+-              return !chat->canDeleteMessages();
+-      } else if (const auto channel = _peer->asChannel()) {
+-              return !channel->canDeleteMessages();
+-      }
+-      return true;
++      return false;
+ }
+ 
+ rpl::producer<bool> Provider::hasSelectRestrictionChanges() {
+diff --git a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp 
b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
+index 0a58cdb..626773f 100644
+--- a/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
++++ b/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
+@@ -1109,16 +1109,7 @@ QSize OverlayWidget::flipSizeByRotation(
+ }
+ 
+ bool OverlayWidget::hasCopyMediaRestriction(bool skipPremiumCheck) const {
+-      if (const auto story = _stories ? _stories->story() : nullptr) {
+-              if (story->call()) {
+-                      return true;
+-              }
+-              return skipPremiumCheck
+-                      ? !story->canDownloadIfPremium()
+-                      : !story->canDownloadChecked();
+-      }
+-      return (_history && !_history->peer->allowsForwarding())
+-              || (_message && _message->forbidsSaving());
++  return false;
+ }
+ 
+ bool OverlayWidget::showCopyMediaRestriction(bool skipPRemiumCheck) {

diff --git a/net-im/forkgram/files/tdesktop-3.3.2-system-minizip.patch 
b/net-im/forkgram/files/tdesktop-3.3.2-system-minizip.patch
new file mode 100644
index 0000000000..583d25dabe
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-3.3.2-system-minizip.patch
@@ -0,0 +1,23 @@
+diff -up tdesktop-6.1.3-full/Telegram/CMakeLists.txt 
tdesktop-6.1.3-full/Telegram/CMakeLists.txt
+--- a/Telegram/CMakeLists.txt  2025-09-23 21:10:04.130684914 +0200
++++ b/Telegram/CMakeLists.txt  2025-09-23 21:10:04.142044324 +0200
+@@ -60,7 +60,7 @@ PRIVATE
+     # include paths (usually ${PREFIX}/include/minizip) before any depend that
+     # would add ${PREFIX}/include. This path may have a different <zip.h>,
+     # for example installed by libzip (https://libzip.org).
+-    desktop-app::external_minizip
++    minizip
+ 
+     tdesktop::td_export
+     tdesktop::td_iv
+diff -up tdesktop-6.1.3-full/cmake/external/CMakeLists.txt 
tdesktop-6.1.3-full/cmake/external/CMakeLists.txt
+--- a/cmake/external/CMakeLists.txt    2025-08-22 19:17:08.000000000 +0200
++++ b/cmake/external/CMakeLists.txt    2025-09-23 21:10:31.362021168 +0200
+@@ -36,7 +36,6 @@ add_checked_subdirectory(iconv)
+ add_checked_subdirectory(jpeg)
+ add_checked_subdirectory(kcoreaddons)
+ add_checked_subdirectory(lz4)
+-add_checked_subdirectory(minizip)
+ add_checked_subdirectory(openal)
+ add_checked_subdirectory(openh264)
+ add_checked_subdirectory(openssl)

diff --git a/net-im/forkgram/files/tdesktop-4.11.3-system-libyuv.patch 
b/net-im/forkgram/files/tdesktop-4.11.3-system-libyuv.patch
new file mode 100644
index 0000000000..7785d31161
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-4.11.3-system-libyuv.patch
@@ -0,0 +1,24 @@
+diff -up 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceHelper.cpp.omv~
 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceHelper.cpp
+--- 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceHelper.cpp.omv~
      2023-11-03 00:20:24.015400091 +0100
++++ 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceHelper.cpp
   2023-11-03 00:20:31.887272290 +0100
+@@ -24,7 +24,7 @@
+ #include "modules/desktop_capture/desktop_capturer.h"
+ #include "system_wrappers/include/clock.h"
+ #include "api/video/i420_buffer.h"
+-#include "third_party/libyuv/include/libyuv.h"
++#include <libyuv.h>
+ 
+ #ifdef WEBRTC_MAC
+ #import <QuartzCore/QuartzCore.h>
+diff -up 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceManager.cpp.omv~
 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceManager.cpp
+--- 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceManager.cpp.omv~
     2023-11-03 00:21:18.732578616 +0100
++++ 
tdesktop-4.11.3-full/Telegram/ThirdParty/tgcalls/tgcalls/desktop_capturer/DesktopCaptureSourceManager.cpp
  2023-11-03 00:21:26.263477359 +0100
+@@ -10,7 +10,7 @@
+ 
+ #include "modules/desktop_capture/desktop_and_cursor_composer.h"
+ #include "modules/desktop_capture/desktop_capturer_differ_wrapper.h"
+-#include "third_party/libyuv/include/libyuv.h"
++#include <libyuv.h>
+ #include "api/video/i420_buffer.h"
+ #include "tgcalls/desktop_capturer/DesktopCaptureSourceHelper.h"
+ 

diff --git a/net-im/forkgram/files/tdesktop-4.11.3-zlib-ng.patch 
b/net-im/forkgram/files/tdesktop-4.11.3-zlib-ng.patch
new file mode 100644
index 0000000000..331ea7338f
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-4.11.3-zlib-ng.patch
@@ -0,0 +1,53 @@
+diff -up 
tdesktop-4.15.6-full/Telegram/SourceFiles/core/crash_report_window.cpp 
tdesktop-4.15.6-full/Telegram/SourceFiles/core/crash_report_window.cpp
+diff -up 
tdesktop-4.15.6-full/Telegram/SourceFiles/payments/ui/payments_panel.cpp 
tdesktop-4.15.6-full/Telegram/SourceFiles/payments/ui/payments_panel.cpp
+--- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp      2024-03-25 
14:47:53.000000000 +0100
++++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp      2024-03-31 
00:43:45.915381497 +0100
+@@ -25,6 +25,7 @@ https://github.com/telegramdesktop/tdesk
+ #include "webview/webview_interface.h"
+ #include "styles/style_payments.h"
+ #include "styles/style_layers.h"
++#include <QJsonDocument>
+ 
+ namespace Payments::Ui {
+ namespace {
+diff -up 
tdesktop-4.15.6-full/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp
 
tdesktop-4.15.6-full/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp
+--- a/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp   
2024-03-25 14:47:53.000000000 +0100
++++ b/Telegram/SourceFiles/window/themes/window_theme_editor_box.cpp   
2024-03-31 00:43:45.915381497 +0100
+@@ -49,6 +49,10 @@ https://github.com/telegramdesktop/tdesk
+ 
+ #include <QtCore/QBuffer>
+ 
++#ifndef Z_DEFAULT_COMPRESSION
++#define Z_DEFAULT_COMPRESSION (-1)
++#endif
++
+ namespace Window {
+ namespace Theme {
+ namespace {
+diff -up tdesktop-4.15.6-full/Telegram/lib_base/base/zlib_help.h 
tdesktop-4.15.6-full/Telegram/lib_base/base/zlib_help.h
+--- a/Telegram/lib_base/base/zlib_help.h       2024-03-24 14:05:37.000000000 
+0100
++++ b/Telegram/lib_base/base/zlib_help.h       2024-03-31 00:43:45.915381497 
+0100
+@@ -14,6 +14,11 @@
+ #undef small
+ #endif // small
+ 
++typedef void* voidp;
++typedef void* voidpf;
++typedef unsigned int uInt;
++typedef unsigned long uLong;
++
+ namespace zlib {
+ namespace internal {
+ 
+diff -up 
tdesktop-4.15.6-full/Telegram/SourceFiles/core/crash_report_window.cpp.omv~ 
tdesktop-4.15.6-full/Telegram/SourceFiles/core/crash_report_window.cpp
+--- a/Telegram/SourceFiles/core/crash_report_window.cpp.omv~   2024-03-31 
01:26:39.209532819 +0100
++++ b/Telegram/SourceFiles/core/crash_report_window.cpp        2024-03-31 
01:26:48.785630918 +0100
+@@ -23,6 +23,8 @@ https://github.com/telegramdesktop/tdesk
+ #include <QtCore/QStandardPaths>
+ #include <QtCore/QTimer>
+ 
++#define Z_DEFAULT_COMPRESSION (-1)
++
+ namespace {
+ 
+ constexpr auto kDefaultProxyPort = 80;

diff --git a/net-im/forkgram/files/tdesktop-5.14.3-system-cppgir.patch 
b/net-im/forkgram/files/tdesktop-5.14.3-system-cppgir.patch
new file mode 100644
index 0000000000..a6da5fd1a9
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-5.14.3-system-cppgir.patch
@@ -0,0 +1,31 @@
+Use system cppgir
+
+https://github.com/desktop-app/cmake_helpers/issues/282
+https://github.com/desktop-app/cmake_helpers/pull/305
+--- tdesktop-5.14.3-full.orig/cmake/external/glib/CMakeLists.txt
++++ tdesktop-5.14.3-full/cmake/external/glib/CMakeLists.txt
+@@ -7,13 +7,6 @@
+ add_library(external_glib INTERFACE IMPORTED GLOBAL)
+ add_library(desktop-app::external_glib ALIAS external_glib)
+ 
+-block()
+-    set(BUILD_TESTING OFF)
+-    set(BUILD_DOC OFF)
+-    set(BUILD_EXAMPLES OFF)
+-    add_subdirectory(cppgir EXCLUDE_FROM_ALL)
+-endblock()
+-
+ include(generate_cppgir.cmake)
+ generate_cppgir(external_glib Gio-2.0)
+ 
+--- tdesktop-5.14.3-full.orig/cmake/external/glib/generate_cppgir.cmake
++++ tdesktop-5.14.3-full/cmake/external/glib/generate_cppgir.cmake
+@@ -4,6 +4,8 @@
+ # For license and copyright information please follow this link:
+ # https://github.com/desktop-app/legal/blob/master/LEGAL
+ 
++find_package(CppGir REQUIRED)
++
+ function(generate_cppgir target_name gir)
+     set(cppgir_loc ${cmake_helpers_loc}/external/glib/cppgir)
+ 

diff --git a/net-im/forkgram/files/tdesktop-5.2.2-libdispatch.patch 
b/net-im/forkgram/files/tdesktop-5.2.2-libdispatch.patch
new file mode 100644
index 0000000000..dee252c5a7
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-5.2.2-libdispatch.patch
@@ -0,0 +1,24 @@
+# https://bugs.gentoo.org/881697
+# https://github.com/telegramdesktop/tdesktop/issues/17437
+
+--- tdesktop-5.2.0-orig/cmake/external/CMakeLists.txt
++++ tdesktop-5.2.0-full/cmake/external/CMakeLists.txt
+@@ -18,7 +18,7 @@
+     add_checked_subdirectory(cld3)
+ endif()
+ add_checked_subdirectory(crash_reports)
+-if (LINUX)
++if (LINUX AND DESKTOP_APP_USE_LIBDISPATCH)
+     add_checked_subdirectory(dispatch)
+ endif()
+ add_checked_subdirectory(expected)
+--- tdesktop-5.2.0-orig/cmake/variables.cmake
++++ tdesktop-5.2.0-full/cmake/variables.cmake
+@@ -21,6 +21,7 @@
+ endif()
+ 
+ option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON)
++cmake_dependent_option(DESKTOP_APP_USE_LIBDISPATCH "Use libdispatch instead 
of QThreadPool." OFF LINUX ON)
+ cmake_dependent_option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code 
for X11 integration." OFF LINUX ON)
+ cmake_dependent_option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple 
allocation tracer." OFF LINUX OFF)
+ cmake_dependent_option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt 
plugins for self-contained packages." OFF LINUX OFF)

diff --git a/net-im/forkgram/files/tdesktop-5.2.2-qt6-no-wayland.patch 
b/net-im/forkgram/files/tdesktop-5.2.2-qt6-no-wayland.patch
new file mode 100644
index 0000000000..b411b8e92e
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-5.2.2-qt6-no-wayland.patch
@@ -0,0 +1,86 @@
+Allow disabling wayland integration for Qt6 builds
+
+Upstream has removed the required toggle for wayland integration, and instead
+is forcing it when the program is being built with Qt6 version 6.5.0 or higher.
+
+Currently this is simple to work around, but its future feasibility remains to
+be seen, depending on what upstream thinks about this.
+
+https://bugs.gentoo.org/928451
+https://github.com/desktop-app/cmake_helpers/commit/a428df5440e76a726abc30924766ac7da0cb381c
+
+--- a/Telegram/lib_base/base/platform/linux/base_linux_xdg_activation_token.cpp
++++ b/Telegram/lib_base/base/platform/linux/base_linux_xdg_activation_token.cpp
+@@ -15,7 +15,7 @@
+ namespace base::Platform {
+ 
+ void RunWithXdgActivationToken(Fn<void(QString)> callback) {
+-#if defined QT_FEATURE_wayland && QT_CONFIG(wayland)
++#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION && defined 
QT_FEATURE_wayland && QT_CONFIG(wayland)
+       const auto window = QGuiApplication::focusWindow();
+       if (!window) {
+               callback({});
+--- a/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp
++++ b/Telegram/lib_ui/ui/platform/linux/ui_utility_linux.cpp
+@@ -414,7 +414,7 @@
+ }
+ #endif // !DESKTOP_APP_DISABLE_X11_INTEGRATION
+ 
+-#if defined QT_FEATURE_wayland && QT_CONFIG(wayland)
++#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION && defined 
QT_FEATURE_wayland && QT_CONFIG(wayland)
+ void ShowWaylandWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
+       static const auto wl_proxy_marshal_array = [] {
+               void (*result)(
+@@ -544,7 +544,7 @@
+ }
+ 
+ bool WindowMarginsSupported() {
+-#if defined QT_FEATURE_wayland && QT_CONFIG(wayland)
++#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION && defined 
QT_FEATURE_wayland && QT_CONFIG(wayland)
+       static const auto WaylandResult = [] {
+               using namespace QNativeInterface::Private;
+               QWindow window;
+@@ -571,7 +571,7 @@
+ }
+ 
+ void SetWindowMargins(not_null<QWidget*> widget, const QMargins &margins) {
+-#if defined QT_FEATURE_wayland && QT_CONFIG(wayland)
++#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION && defined 
QT_FEATURE_wayland && QT_CONFIG(wayland)
+       using namespace QNativeInterface::Private;
+       const auto window = not_null(widget->windowHandle());
+       const auto platformWindow = not_null(window->handle());
+@@ -593,7 +593,7 @@
+ }
+ 
+ void ShowWindowMenu(not_null<QWidget*> widget, const QPoint &point) {
+-#if defined QT_FEATURE_wayland && QT_CONFIG(wayland)
++#if !defined DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION && defined 
QT_FEATURE_wayland && QT_CONFIG(wayland)
+       if (::Platform::IsWayland()) {
+               ShowWaylandWindowMenu(widget, point);
+               return;
+--- a/cmake/options.cmake
++++ b/cmake/options.cmake
+@@ -23,6 +23,13 @@
+     )
+ endif()
+ 
++if (DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION)
++    target_compile_definitions(common_options
++    INTERFACE
++      DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION
++    )
++endif()
++
+ if (WIN32)
+     include(cmake/options_win.cmake)
+ elseif (APPLE)
+--- a/cmake/variables.cmake
++++ b/cmake/variables.cmake
+@@ -21,6 +21,7 @@
+ 
+ option(DESKTOP_APP_LOTTIE_USE_CACHE "Use caching in lottie animations." ON)
+ cmake_dependent_option(DESKTOP_APP_DISABLE_X11_INTEGRATION "Disable all code 
for X11 integration." OFF LINUX ON)
++cmake_dependent_option(DESKTOP_APP_DISABLE_WAYLAND_INTEGRATION "Disable all 
code for Wayland integration." OFF LINUX ON)
+ cmake_dependent_option(DESKTOP_APP_USE_ALLOCATION_TRACER "Use simple 
allocation tracer." OFF LINUX OFF)
+ cmake_dependent_option(DESKTOP_APP_USE_PACKAGED_LAZY "Bundle recommended Qt 
plugins for self-contained packages." OFF LINUX OFF)
+ option(DESKTOP_APP_USE_PACKAGED_FONTS "Use preinstalled fonts instead of 
bundled patched ones." OFF)

diff --git a/net-im/forkgram/files/tdesktop-5.7.2-cstring.patch 
b/net-im/forkgram/files/tdesktop-5.7.2-cstring.patch
new file mode 100644
index 0000000000..e9baaf60c1
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-5.7.2-cstring.patch
@@ -0,0 +1,12 @@
+diff --git a/Telegram/lib_base/base/basic_types.h 
b/Telegram/lib_base/base/basic_types.h
+index 241417f..4204fae 100644
+--- a/Telegram/lib_base/base/basic_types.h
++++ b/Telegram/lib_base/base/basic_types.h
+@@ -17,6 +17,7 @@
+ #include <QtCore/QString>
+ 
+ #include <string>
++#include <cstring>
+ #include <exception>
+ #include <memory>
+ #include <ctime>

diff --git a/net-im/forkgram/files/tdesktop-5.8.3-cstdint.patch 
b/net-im/forkgram/files/tdesktop-5.8.3-cstdint.patch
new file mode 100644
index 0000000000..5f01718405
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-5.8.3-cstdint.patch
@@ -0,0 +1,15 @@
+Fix missing cstdint include
+
+/var/tmp/portage/net-im/telegram-desktop-5.8.3/work/tdesktop-5.8.3-full/Telegram/lib_webview/webview/webview_interface.h:99:14:
 error: ‘int64_t’ in namespace ‘std’ does not name a type
+   99 |         std::int64_t streamOffset = 0;
+      |              ^~~~~~~
+--- tdesktop-5.8.3-full.orig/Telegram/lib_webview/webview/webview_interface.h
++++ tdesktop-5.8.3-full/Telegram/lib_webview/webview/webview_interface.h
+@@ -12,6 +12,7 @@
+ #include <string>
+ #include <optional>
+ #include <functional>
++#include <cstdint>
+ 
+ #include <rpl/never.h>
+ #include <rpl/producer.h>

diff --git a/net-im/forkgram/files/tdesktop-6.3.2-loosen-minizip.patch 
b/net-im/forkgram/files/tdesktop-6.3.2-loosen-minizip.patch
new file mode 100644
index 0000000000..d9232d336e
--- /dev/null
+++ b/net-im/forkgram/files/tdesktop-6.3.2-loosen-minizip.patch
@@ -0,0 +1,20 @@
+Loosen minizip requirement
+
+The new minizip-ng reports itself as version 4, but should be compatible with
+the old one. I doubt there will ever be much breakage here, so completely
+removing the version requirement makes sense.
+
+Warning! I have not tested minizip-ng at runtime. All my systems are stable,
+I'll just see the bug reports arrive if anything's up.
+
+--- tdesktop-6.3.2-full.orig/cmake/external/minizip/CMakeLists.txt
++++ tdesktop-6.3.2-full/cmake/external/minizip/CMakeLists.txt
+@@ -10,7 +10,7 @@
+ if (DESKTOP_APP_USE_PACKAGED)
+     find_package(PkgConfig REQUIRED)
+     if (PkgConfig_FOUND)
+-        pkg_check_modules(DESKTOP_APP_MINIZIP IMPORTED_TARGET REQUIRED 
minizip<2.0.0)
++        pkg_check_modules(DESKTOP_APP_MINIZIP IMPORTED_TARGET REQUIRED 
minizip)
+     endif()
+ 
+     if (DESKTOP_APP_MINIZIP_FOUND)

diff --git a/net-im/forkgram/forkgram-6.5.1.ebuild 
b/net-im/forkgram/forkgram-6.5.1.ebuild
new file mode 100644
index 0000000000..e3d63f27f2
--- /dev/null
+++ b/net-im/forkgram/forkgram-6.5.1.ebuild
@@ -0,0 +1,269 @@
+# Copyright 2026 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{11..14} )
+
+inherit xdg cmake python-any-r1 optfeature flag-o-matic
+
+DESCRIPTION="Fork of the official Telegram Desktop app with small useful 
additions"
+HOMEPAGE="https://github.com/forkgram/tdesktop";
+
+SRC_URI="https://github.com/forkgram/tdesktop/releases/download/v${PV}/frk-v${PV}-full.tar.gz";
+S="${WORKDIR}/frk-v${PV}-full"
+
+LICENSE="BSD GPL-3-with-openssl-exception LGPL-2+"
+SLOT="0"
+KEYWORDS="~amd64"
+IUSE="dbus enchant +fonts +libdispatch screencast wayland webkit +X"
+
+CDEPEND="
+       app-arch/lz4:=
+       dev-cpp/abseil-cpp:=
+       dev-cpp/ada:=
+       dev-cpp/cld3:=
+       >=dev-cpp/glibmm-2.77:2.68
+       dev-libs/glib:2
+       dev-libs/openssl:=
+       >=dev-libs/protobuf-21.12
+       dev-libs/qr-code-generator:=
+       dev-libs/xxhash
+       >=dev-qt/qtbase-6.5:6=[dbus?,gui,network,opengl,ssl,wayland?,widgets,X?]
+       >=dev-qt/qtimageformats-6.5:6
+       >=dev-qt/qtsvg-6.5:6
+       media-libs/libjpeg-turbo:=
+       media-libs/openal
+       media-libs/opus
+       media-libs/rnnoise
+       >=media-libs/tg_owt-0_pre20241202:=[screencast=,X=]
+       >=media-video/ffmpeg-6:=[opus,vpx]
+       net-libs/tdlib:=[tde2e]
+       virtual/minizip:=
+       kde-frameworks/kcoreaddons:6
+       !enchant? ( >=app-text/hunspell-1.7:= )
+       enchant? ( app-text/enchant:= )
+       libdispatch? ( dev-libs/libdispatch )
+       webkit? ( wayland? (
+               >=dev-qt/qtdeclarative-6.5:6
+               >=dev-qt/qtwayland-6.5:6[compositor(+),qml]
+       ) )
+       X? (
+               x11-libs/libxcb:=
+               x11-libs/xcb-util-keysyms
+       )
+"
+RDEPEND="${CDEPEND}
+       !!net-im/telegram-desktop
+       !!net-im/telegram-desktop-bin
+       webkit? ( || ( net-libs/webkit-gtk:4.1 net-libs/webkit-gtk:6 ) )
+"
+DEPEND="${CDEPEND}
+       >=dev-cpp/cppgir-2.0_p20240315
+       >=dev-cpp/ms-gsl-4.1.0
+       dev-cpp/expected
+       dev-cpp/expected-lite
+       dev-cpp/range-v3
+"
+BDEPEND="
+       ${PYTHON_DEPS}
+       >=dev-build/cmake-3.16
+       >=dev-cpp/cppgir-2.0_p20240315
+       >=dev-libs/gobject-introspection-1.82.0-r2
+       >=dev-util/gdbus-codegen-2.80.5-r1
+       virtual/pkgconfig
+       wayland? ( dev-util/wayland-scanner )
+"
+# NOTE: dev-cpp/expected-lite used indirectly by a dev-cpp/cppgir header file
+
+PATCHES=(
+       # Gentoo build fixes
+       "${FILESDIR}"/tdesktop-5.2.2-qt6-no-wayland.patch
+       "${FILESDIR}"/tdesktop-5.2.2-libdispatch.patch
+       "${FILESDIR}"/tdesktop-5.7.2-cstring.patch
+       "${FILESDIR}"/tdesktop-5.8.3-cstdint.patch
+       "${FILESDIR}"/tdesktop-5.14.3-system-cppgir.patch
+       "${FILESDIR}"/tdesktop-4.11.3-system-libyuv.patch
+       "${FILESDIR}"/tdesktop-4.11.3-zlib-ng.patch
+       "${FILESDIR}"/tdesktop-3.3.2-system-minizip.patch
+       "${FILESDIR}"/tdesktop-6.3.2-loosen-minizip.patch
+       # Forkgram-specific patches
+       "${FILESDIR}"/option-to-disable-stories.patch
+       "${FILESDIR}"/0000-data_data_sponsored_messages.cpp.patch
+       "${FILESDIR}"/pins.patch
+       "${FILESDIR}"/invite-peeking-restrictions.patch
+       "${FILESDIR}"/saving-restrictions.patch
+       "${FILESDIR}"/0001-kde-theme-injection-fix.patch
+)
+
+pkg_pretend() {
+       if [[ ${MERGE_TYPE} != binary ]]; then
+               if has ccache ${FEATURES}; then
+                       ewarn "ccache does not work with ${PN} out of the box"
+                       ewarn "due to usage of precompiled headers"
+                       ewarn "check bug https://bugs.gentoo.org/715114 for 
more info"
+                       ewarn
+               fi
+       fi
+}
+
+src_prepare() {
+       # Happily fail if libraries aren't found...
+       find -type f \( -name 'CMakeLists.txt' -o -name '*.cmake' \) \
+               \! -path './cmake/external/qt/package.cmake' \
+               -print0 | xargs -0 sed -i \
+               -e '/pkg_check_modules(/s/[^ ]*)/REQUIRED &/' \
+               -e '/find_package(/s/)/ REQUIRED)/' \
+               -e '/find_library(/s/)/ REQUIRED)/' || die
+       # Make sure to check the excluded files for new
+       # CMAKE_DISABLE_FIND_PACKAGE entries.
+
+       # Some packages are found through pkg_check_modules, rather than 
find_package
+       sed -e '/find_package(lz4 /d' -i cmake/external/lz4/CMakeLists.txt || 
die
+       sed -e '/find_package(Opus /d' -i cmake/external/opus/CMakeLists.txt || 
die
+       sed -e '/find_package(xxHash /d' -i 
cmake/external/xxhash/CMakeLists.txt || die
+
+       # Greedily remove ThirdParty directories, keep only ones that interest 
us
+       local keep=(
+               rlottie  # Patched, not recommended to unbundle by upstream
+               libprisma  # Telegram-specific library, no stable releases
+               tgcalls  # Telegram-specific library, no stable releases
+               xdg-desktop-portal  # Only a few xml files are used with 
gdbus-codegen
+       )
+       for x in Telegram/ThirdParty/*; do
+               has "${x##*/}" "${keep[@]}" || rm -r "${x}" || die
+       done
+
+       # Control QtDBus dependency from here, to avoid messing with QtGui.
+       # QtGui will use find_package to find QtDbus as well, which
+       # conflicts with the -DCMAKE_DISABLE_FIND_PACKAGE method.
+       if ! use dbus; then
+               sed -e '/find_package(Qt[^ ]* OPTIONAL_COMPONENTS/s/DBus *//' \
+                       -i cmake/external/qt/package.cmake || die
+       fi
+
+       # Control automagic dep only needed when USE="webkit wayland"
+       if ! use webkit || ! use wayland; then
+               sed -e 's/QT_CONFIG(wayland_compositor_quick)/0/' \
+                       -i 
Telegram/lib_webview/webview/platform/linux/webview_linux_compositor.h || die
+       fi
+
+       # Shut the CMake 4 QA checker up by removing unused CMakeLists files
+       rm Telegram/ThirdParty/rlottie/CMakeLists.txt || die
+       rm cmake/external/glib/cppgir/expected-lite/example/CMakeLists.txt || 
die
+       rm cmake/external/glib/cppgir/expected-lite/test/CMakeLists.txt || die
+       rm cmake/external/glib/cppgir/expected-lite/CMakeLists.txt || die
+
+       cmake_src_prepare
+}
+
+src_configure() {
+       # Having user paths sneak into the build environment through the
+       # XDG_DATA_DIRS variable causes all sorts of weirdness with cppgir:
+       # - bug 909038: can't read from flatpak directories (fixed upstream)
+       # - bug 920819: system-wide directories ignored when variable is set
+       export XDG_DATA_DIRS="${ESYSROOT}/usr/share"
+
+       # Evil flag (See https://bugs.gentoo.org/919201)
+       filter-flags -fno-delete-null-pointer-checks
+
+       # lto1-wpa uses ~7GB RAM at link time; upstream disables LTO by default
+       filter-lto
+
+       # The ABI of media-libs/tg_owt breaks if the -DNDEBUG flag doesn't keep
+       # the same state across both projects.
+       # See https://bugs.gentoo.org/866055
+       append-cppflags -DNDEBUG
+
+       # 
https://github.com/telegramdesktop/tdesktop/issues/17437#issuecomment-1001160398
+       use !libdispatch && append-cppflags -DCRL_FORCE_QT
+
+       local no_webkit_wayland=$(use webkit && use wayland && echo no || echo 
yes)
+       local use_webkit_wayland=$(use webkit && use wayland && echo yes || 
echo no)
+       local mycmakeargs=(
+               -DQT_VERSION_MAJOR=6
+
+               # Override new cmake.eclass defaults 
(https://bugs.gentoo.org/921939)
+               # Upstream never tests this any other way
+               -DCMAKE_DISABLE_PRECOMPILE_HEADERS=OFF
+
+               # keep off per upstream default; cmake eclass may otherwise 
re-enable
+               -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF
+
+               # Control automagic dependencies on certain packages
+               ## These libraries are only used in lib_webview, for wayland
+               ## See 
Telegram/lib_webview/webview/platform/linux/webview_linux_compositor.h
+               -DCMAKE_DISABLE_FIND_PACKAGE_Qt6Quick=${no_webkit_wayland}
+               
-DCMAKE_DISABLE_FIND_PACKAGE_Qt6QuickWidgets=${no_webkit_wayland}
+               
-DCMAKE_DISABLE_FIND_PACKAGE_Qt6WaylandCompositor=${no_webkit_wayland}
+
+               # Make sure dependencies that aren't patched to be REQUIRED in
+               # src_prepare, are found.  This was suggested to me by the 
telegram
+               # devs, in lieu of having explicit flags in the build system.
+               -DCMAKE_REQUIRE_FIND_PACKAGE_Qt6DBus=$(usex dbus)
+               -DCMAKE_REQUIRE_FIND_PACKAGE_Qt6Quick=${use_webkit_wayland}
+               
-DCMAKE_REQUIRE_FIND_PACKAGE_Qt6QuickWidgets=${use_webkit_wayland}
+               
-DCMAKE_REQUIRE_FIND_PACKAGE_Qt6WaylandCompositor=${use_webkit_wayland}
+
+               -DDESKTOP_APP_DISABLE_QT_PLUGINS=ON
+               -DDESKTOP_APP_DISABLE_X11_INTEGRATION=$(usex !X)
+               ## Enables enchant and disables hunspell
+               -DDESKTOP_APP_USE_ENCHANT=$(usex enchant)
+               ## Use system fonts instead of bundled ones
+               -DDESKTOP_APP_USE_PACKAGED_FONTS=$(usex !fonts)
+               ## See tdesktop-*-libdispatch.patch
+               -DDESKTOP_APP_USE_LIBDISPATCH=$(usex libdispatch)
+       )
+
+       if [[ -n ${MY_TDESKTOP_API_ID} && -n ${MY_TDESKTOP_API_HASH} ]]; then
+               einfo "Found custom API credentials"
+               mycmakeargs+=(
+                       -DTDESKTOP_API_ID="${MY_TDESKTOP_API_ID}"
+                       -DTDESKTOP_API_HASH="${MY_TDESKTOP_API_HASH}"
+               )
+       else
+               # 
https://github.com/telegramdesktop/tdesktop/blob/dev/snap/snapcraft.yaml
+               # Building with snapcraft API credentials by default
+               # Custom API credentials can be obtained here:
+               # 
https://github.com/telegramdesktop/tdesktop/blob/dev/docs/api_credentials.md
+               # After getting credentials you can export variables:
+               #   export MY_TDESKTOP_API_ID="your_id"
+               #   export MY_TDESKTOP_API_HASH="your_hash"
+               # and restart the build.
+               # You can set above variables (without export) in
+               # /etc/portage/env/net-im/forkgram — portage will use them 
automatically.
+               mycmakeargs+=(
+                       -DTDESKTOP_API_ID="611335"
+                       -DTDESKTOP_API_HASH="d524b414d21f4d37f08684c1df41ac9c"
+               )
+       fi
+
+       cmake_src_configure
+}
+
+src_compile() {
+       # The cppgir program causes the gen/gio/_types.hpp file to be updated.
+       # Since this program can usually be invoked anywhere in the build 
process,
+       # running it *after* some files depending on the header have been 
compiled
+       # causes Telegram to be linked again during src_install(). This is a 
slow
+       # process, so we try to avoid it by running all cppgir targets upfront.
+       cmake_build $("${CMAKE_BINARY}" --build "${BUILD_DIR}" -t help | sed -n 
'/^[^/]*_cppgir:/s/:.*//p')
+       cmake_build
+       cmake_build  # Just in case, should say "no work to do"
+}
+
+pkg_postinst() {
+       xdg_pkg_postinst
+       if ! use X && ! use screencast; then
+               ewarn "both the 'X' and 'screencast' USE flags are disabled, 
screen sharing won't work!"
+               ewarn
+       fi
+       if ! use libdispatch; then
+               ewarn "Disabling USE=libdispatch may cause performance 
degradation"
+               ewarn "due to fallback to poor QThreadPool! Please see"
+               ewarn 
"https://github.com/telegramdesktop/tdesktop/wiki/The-Packaged-Building-Mode";
+               ewarn
+       fi
+       optfeature_header
+       optfeature "AVIF, HEIF and JpegXL image support" 
kde-frameworks/kimageformats:6[avif,heif,jpegxl]
+}

diff --git a/net-im/forkgram/metadata.xml b/net-im/forkgram/metadata.xml
new file mode 100644
index 0000000000..954d980db7
--- /dev/null
+++ b/net-im/forkgram/metadata.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd";>
+<pkgmetadata>
+       <maintainer type="person">
+               <email>[email protected]</email>
+               <name>bip125</name>
+       </maintainer>
+       <longdescription>
+               Forkgram is a fork of the official Telegram Desktop application.
+               It does not fundamentally change the official client but adds
+               small useful features such as optional stories, pin management
+               improvements, and restrictions on invite peeking and saving.
+       </longdescription>
+       <use>
+               <flag name="dbus">Enable D-Bus support for desktop 
integration</flag>
+               <flag name="enchant">Use app-text/enchant spell-checking 
backend instead of app-text/hunspell</flag>
+               <flag name="fonts">Use built-in patched copy of open-sans fonts 
(overrides fontconfig)</flag>
+               <flag name="libdispatch">Use dev-libs/libdispatch for better 
thread pool performance</flag>
+               <flag name="screencast">Enable screencasting support via 
media-libs/tg_owt</flag>
+               <flag name="webkit">Enable WebKit-based in-app browser 
(requires USE=wayland)</flag>
+       </use>
+       <upstream>
+               <remote-id type="github">forkgram/tdesktop</remote-id>
+               <bugs-to>https://github.com/forkgram/tdesktop/issues</bugs-to>
+               
<changelog>https://github.com/forkgram/tdesktop/releases</changelog>
+       </upstream>
+</pkgmetadata>


Reply via email to