mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Fixed permissions requesting for different call types.
This commit is contained in:
parent
c4c18d16ab
commit
80597e190a
5 changed files with 30 additions and 16 deletions
Telegram/SourceFiles/calls
|
@ -288,10 +288,19 @@ void Call::startIncoming() {
|
|||
}).send();
|
||||
}
|
||||
|
||||
void Call::switchVideoOutgoing() {
|
||||
const auto video = _videoOutgoing->state() == Webrtc::VideoState::Active;
|
||||
_delegate->callRequestPermissionsOrFail(crl::guard(this, [=] {
|
||||
videoOutgoing()->setState(StartVideoState(!video));
|
||||
}), true);
|
||||
|
||||
}
|
||||
|
||||
void Call::answer() {
|
||||
const auto video = _videoOutgoing->state() == Webrtc::VideoState::Active;
|
||||
_delegate->callRequestPermissionsOrFail(crl::guard(this, [=] {
|
||||
actuallyAnswer();
|
||||
}));
|
||||
}), video);
|
||||
}
|
||||
|
||||
void Call::actuallyAnswer() {
|
||||
|
|
|
@ -68,7 +68,9 @@ public:
|
|||
Ended,
|
||||
};
|
||||
virtual void playSound(Sound sound) = 0;
|
||||
virtual void callRequestPermissionsOrFail(Fn<void()> onSuccess) = 0;
|
||||
virtual void callRequestPermissionsOrFail(
|
||||
Fn<void()> onSuccess,
|
||||
bool video) = 0;
|
||||
virtual auto getVideoCapture()
|
||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> = 0;
|
||||
|
||||
|
@ -165,6 +167,7 @@ public:
|
|||
crl::time getDurationMs() const;
|
||||
float64 getWaitingSoundPeakValue() const;
|
||||
|
||||
void switchVideoOutgoing();
|
||||
void answer();
|
||||
void hangup();
|
||||
void redial();
|
||||
|
|
|
@ -55,7 +55,7 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
|
|||
}
|
||||
requestPermissionsOrFail(crl::guard(this, [=] {
|
||||
createCall(user, Call::Type::Outgoing, video);
|
||||
}));
|
||||
}), video);
|
||||
}
|
||||
|
||||
void Instance::startGroupCall(not_null<ChannelData*> channel) {
|
||||
|
@ -64,7 +64,7 @@ void Instance::startGroupCall(not_null<ChannelData*> channel) {
|
|||
}
|
||||
requestPermissionsOrFail(crl::guard(this, [=] {
|
||||
createGroupCall(channel, MTP_inputGroupCall(MTPlong(), MTPlong()));
|
||||
}));
|
||||
}), false);
|
||||
}
|
||||
|
||||
void Instance::joinGroupCall(
|
||||
|
@ -75,7 +75,7 @@ void Instance::joinGroupCall(
|
|||
}
|
||||
requestPermissionsOrFail(crl::guard(this, [=] {
|
||||
createGroupCall(channel, call);
|
||||
}));
|
||||
}), false);
|
||||
}
|
||||
|
||||
void Instance::callFinished(not_null<Call*> call) {
|
||||
|
@ -462,12 +462,15 @@ rpl::producer<GroupCall*> Instance::currentGroupCallValue() const {
|
|||
return _currentGroupCallChanges.events_starting_with(currentGroupCall());
|
||||
}
|
||||
|
||||
void Instance::requestPermissionsOrFail(Fn<void()> onSuccess) {
|
||||
void Instance::requestPermissionsOrFail(Fn<void()> onSuccess, bool video) {
|
||||
using Type = Platform::PermissionType;
|
||||
requestPermissionOrFail(Type::Microphone, [=] {
|
||||
requestPermissionOrFail(Type::Camera, [=] {
|
||||
crl::on_main(onSuccess);
|
||||
});
|
||||
auto callback = [=] { crl::on_main(onSuccess); };
|
||||
if (video) {
|
||||
requestPermissionOrFail(Type::Camera, std::move(callback));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,10 @@ private:
|
|||
void callFinished(not_null<Call*> call) override;
|
||||
void callFailed(not_null<Call*> call) override;
|
||||
void callRedial(not_null<Call*> call) override;
|
||||
void callRequestPermissionsOrFail(Fn<void()> onSuccess) override {
|
||||
requestPermissionsOrFail(std::move(onSuccess));
|
||||
void callRequestPermissionsOrFail(
|
||||
Fn<void()> onSuccess,
|
||||
bool video) override {
|
||||
requestPermissionsOrFail(std::move(onSuccess), video);
|
||||
}
|
||||
|
||||
void groupCallFinished(not_null<GroupCall*> call) override;
|
||||
|
@ -89,7 +91,7 @@ private:
|
|||
const MTPInputGroupCall &inputCall);
|
||||
void destroyGroupCall(not_null<GroupCall*> call);
|
||||
|
||||
void requestPermissionsOrFail(Fn<void()> onSuccess);
|
||||
void requestPermissionsOrFail(Fn<void()> onSuccess, bool video = true);
|
||||
void requestPermissionOrFail(Platform::PermissionType type, Fn<void()> onSuccess);
|
||||
|
||||
void refreshDhConfig();
|
||||
|
|
|
@ -307,10 +307,7 @@ void Panel::initControls() {
|
|||
});
|
||||
_camera->setClickedCallback([=] {
|
||||
if (_call) {
|
||||
_call->videoOutgoing()->setState(
|
||||
(_call->videoOutgoing()->state() == Webrtc::VideoState::Active)
|
||||
? Webrtc::VideoState::Inactive
|
||||
: Webrtc::VideoState::Active);
|
||||
_call->switchVideoOutgoing();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue