mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-16 22:27:20 +02:00
Support special video calls service messages.
This commit is contained in:
parent
aba8f72c36
commit
6f90e57523
6 changed files with 58 additions and 30 deletions
|
@ -1736,10 +1736,15 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
"lng_call_box_status_group" = "({amount}) {status}";
|
||||
|
||||
"lng_call_outgoing" = "Outgoing call";
|
||||
"lng_call_video_outgoing" = "Outgoing video call";
|
||||
"lng_call_incoming" = "Incoming call";
|
||||
"lng_call_video_incoming" = "Incoming video call";
|
||||
"lng_call_missed" = "Missed call";
|
||||
"lng_call_video_missed" = "Missed video call";
|
||||
"lng_call_cancelled" = "Cancelled call";
|
||||
"lng_call_video_cancelled" = "Cancelled video call";
|
||||
"lng_call_declined" = "Declined call";
|
||||
"lng_call_video_declined" = "Declined video call";
|
||||
"lng_call_duration_info" = "{time}, {duration}";
|
||||
"lng_call_type_and_duration" = "{type} ({duration})";
|
||||
|
||||
|
|
|
@ -974,8 +974,11 @@ void Call::finish(FinishType type, const MTPPhoneCallDiscardReason &reason) {
|
|||
auto duration = getDurationMs() / 1000;
|
||||
auto connectionId = _instance ? _instance->getPreferredRelayId() : 0;
|
||||
_finishByTimeoutTimer.call(kHangupTimeoutMs, [this, finalState] { setState(finalState); });
|
||||
const auto flags = (_videoState.current() == VideoState::Enabled)
|
||||
? MTPphone_DiscardCall::Flag::f_video
|
||||
: MTPphone_DiscardCall::Flag(0);
|
||||
_api.request(MTPphone_DiscardCall(
|
||||
MTP_flags(0),
|
||||
MTP_flags(flags),
|
||||
MTP_inputPhoneCall(
|
||||
MTP_long(_id),
|
||||
MTP_long(_accessHash)),
|
||||
|
|
|
@ -67,6 +67,7 @@ constexpr auto kFastRevokeRestriction = 24 * 60 * TimeId(60);
|
|||
return CallFinishReason::Hangup;
|
||||
}();
|
||||
result.duration = call.vduration().value_or_empty();
|
||||
result.video = call.is_video();
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -874,7 +875,7 @@ const Call *MediaCall::call() const {
|
|||
}
|
||||
|
||||
QString MediaCall::notificationText() const {
|
||||
auto result = Text(parent(), _call.finishReason);
|
||||
auto result = Text(parent(), _call.finishReason, _call.video);
|
||||
if (_call.duration > 0) {
|
||||
result = tr::lng_call_type_and_duration(
|
||||
tr::now,
|
||||
|
@ -916,17 +917,28 @@ std::unique_ptr<HistoryView::Media> MediaCall::createView(
|
|||
|
||||
QString MediaCall::Text(
|
||||
not_null<HistoryItem*> item,
|
||||
CallFinishReason reason) {
|
||||
CallFinishReason reason,
|
||||
bool video) {
|
||||
if (item->out()) {
|
||||
return (reason == CallFinishReason::Missed)
|
||||
? tr::lng_call_cancelled(tr::now)
|
||||
: tr::lng_call_outgoing(tr::now);
|
||||
return ((reason == CallFinishReason::Missed)
|
||||
? (video
|
||||
? tr::lng_call_video_cancelled
|
||||
: tr::lng_call_cancelled)
|
||||
: (video
|
||||
? tr::lng_call_video_outgoing
|
||||
: tr::lng_call_outgoing))(tr::now);
|
||||
} else if (reason == CallFinishReason::Missed) {
|
||||
return tr::lng_call_missed(tr::now);
|
||||
return (video
|
||||
? tr::lng_call_video_missed
|
||||
: tr::lng_call_missed)(tr::now);
|
||||
} else if (reason == CallFinishReason::Busy) {
|
||||
return tr::lng_call_declined(tr::now);
|
||||
return (video
|
||||
? tr::lng_call_video_declined
|
||||
: tr::lng_call_declined)(tr::now);
|
||||
}
|
||||
return tr::lng_call_incoming(tr::now);
|
||||
return (video
|
||||
? tr::lng_call_video_incoming
|
||||
: tr::lng_call_incoming)(tr::now);
|
||||
}
|
||||
|
||||
MediaWebPage::MediaWebPage(
|
||||
|
|
|
@ -51,6 +51,7 @@ struct Call {
|
|||
|
||||
int duration = 0;
|
||||
FinishReason finishReason = FinishReason::Missed;
|
||||
bool video = false;
|
||||
};
|
||||
|
||||
struct Invoice {
|
||||
|
@ -287,7 +288,8 @@ public:
|
|||
|
||||
static QString Text(
|
||||
not_null<HistoryItem*> item,
|
||||
CallFinishReason reason);
|
||||
CallFinishReason reason,
|
||||
bool video);
|
||||
|
||||
private:
|
||||
Call _call;
|
||||
|
|
|
@ -21,29 +21,36 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|||
#include "styles/style_history.h"
|
||||
|
||||
namespace HistoryView {
|
||||
namespace {
|
||||
|
||||
using FinishReason = Data::CallFinishReason;
|
||||
|
||||
[[nodiscard]] int ComputeDuration(FinishReason reason, int duration) {
|
||||
return (reason != FinishReason::Missed
|
||||
&& reason != FinishReason::Busy)
|
||||
? duration
|
||||
: 0;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
Call::Call(
|
||||
not_null<Element*> parent,
|
||||
not_null<Data::Call*> call)
|
||||
: Media(parent) {
|
||||
_duration = call->duration;
|
||||
_reason = call->finishReason;
|
||||
|
||||
: Media(parent)
|
||||
, _duration(ComputeDuration(call->finishReason, call->duration))
|
||||
, _reason(call->finishReason)
|
||||
, _video(call->video) {
|
||||
const auto item = parent->data();
|
||||
_text = Data::MediaCall::Text(item, _reason);
|
||||
_text = Data::MediaCall::Text(item, _reason, _video);
|
||||
_status = parent->dateTime().time().toString(cTimeFormat());
|
||||
if (_duration) {
|
||||
if (_reason != FinishReason::Missed
|
||||
&& _reason != FinishReason::Busy) {
|
||||
_status = tr::lng_call_duration_info(
|
||||
tr::now,
|
||||
lt_time,
|
||||
_status,
|
||||
lt_duration,
|
||||
formatDurationWords(_duration));
|
||||
} else {
|
||||
_duration = 0;
|
||||
}
|
||||
_status = tr::lng_call_duration_info(
|
||||
tr::now,
|
||||
lt_time,
|
||||
_status,
|
||||
lt_duration,
|
||||
formatDurationWords(_duration));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -39,15 +39,14 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
Data::CallFinishReason reason() const;
|
||||
|
||||
private:
|
||||
using FinishReason = Data::CallFinishReason;
|
||||
|
||||
QSize countOptimalSize() override;
|
||||
|
||||
FinishReason _reason;
|
||||
int _duration = 0;
|
||||
const int _duration = 0;
|
||||
const FinishReason _reason;
|
||||
const bool _video = false;
|
||||
|
||||
QString _text;
|
||||
QString _status;
|
||||
|
|
Loading…
Add table
Reference in a new issue