mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +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
|
@ -288,10 +288,19 @@ void Call::startIncoming() {
|
||||||
}).send();
|
}).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() {
|
void Call::answer() {
|
||||||
|
const auto video = _videoOutgoing->state() == Webrtc::VideoState::Active;
|
||||||
_delegate->callRequestPermissionsOrFail(crl::guard(this, [=] {
|
_delegate->callRequestPermissionsOrFail(crl::guard(this, [=] {
|
||||||
actuallyAnswer();
|
actuallyAnswer();
|
||||||
}));
|
}), video);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Call::actuallyAnswer() {
|
void Call::actuallyAnswer() {
|
||||||
|
|
|
@ -68,7 +68,9 @@ public:
|
||||||
Ended,
|
Ended,
|
||||||
};
|
};
|
||||||
virtual void playSound(Sound sound) = 0;
|
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()
|
virtual auto getVideoCapture()
|
||||||
-> std::shared_ptr<tgcalls::VideoCaptureInterface> = 0;
|
-> std::shared_ptr<tgcalls::VideoCaptureInterface> = 0;
|
||||||
|
|
||||||
|
@ -165,6 +167,7 @@ public:
|
||||||
crl::time getDurationMs() const;
|
crl::time getDurationMs() const;
|
||||||
float64 getWaitingSoundPeakValue() const;
|
float64 getWaitingSoundPeakValue() const;
|
||||||
|
|
||||||
|
void switchVideoOutgoing();
|
||||||
void answer();
|
void answer();
|
||||||
void hangup();
|
void hangup();
|
||||||
void redial();
|
void redial();
|
||||||
|
|
|
@ -55,7 +55,7 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
|
||||||
}
|
}
|
||||||
requestPermissionsOrFail(crl::guard(this, [=] {
|
requestPermissionsOrFail(crl::guard(this, [=] {
|
||||||
createCall(user, Call::Type::Outgoing, video);
|
createCall(user, Call::Type::Outgoing, video);
|
||||||
}));
|
}), video);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::startGroupCall(not_null<ChannelData*> channel) {
|
void Instance::startGroupCall(not_null<ChannelData*> channel) {
|
||||||
|
@ -64,7 +64,7 @@ void Instance::startGroupCall(not_null<ChannelData*> channel) {
|
||||||
}
|
}
|
||||||
requestPermissionsOrFail(crl::guard(this, [=] {
|
requestPermissionsOrFail(crl::guard(this, [=] {
|
||||||
createGroupCall(channel, MTP_inputGroupCall(MTPlong(), MTPlong()));
|
createGroupCall(channel, MTP_inputGroupCall(MTPlong(), MTPlong()));
|
||||||
}));
|
}), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::joinGroupCall(
|
void Instance::joinGroupCall(
|
||||||
|
@ -75,7 +75,7 @@ void Instance::joinGroupCall(
|
||||||
}
|
}
|
||||||
requestPermissionsOrFail(crl::guard(this, [=] {
|
requestPermissionsOrFail(crl::guard(this, [=] {
|
||||||
createGroupCall(channel, call);
|
createGroupCall(channel, call);
|
||||||
}));
|
}), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::callFinished(not_null<Call*> call) {
|
void Instance::callFinished(not_null<Call*> call) {
|
||||||
|
@ -462,12 +462,15 @@ rpl::producer<GroupCall*> Instance::currentGroupCallValue() const {
|
||||||
return _currentGroupCallChanges.events_starting_with(currentGroupCall());
|
return _currentGroupCallChanges.events_starting_with(currentGroupCall());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Instance::requestPermissionsOrFail(Fn<void()> onSuccess) {
|
void Instance::requestPermissionsOrFail(Fn<void()> onSuccess, bool video) {
|
||||||
using Type = Platform::PermissionType;
|
using Type = Platform::PermissionType;
|
||||||
requestPermissionOrFail(Type::Microphone, [=] {
|
requestPermissionOrFail(Type::Microphone, [=] {
|
||||||
requestPermissionOrFail(Type::Camera, [=] {
|
auto callback = [=] { crl::on_main(onSuccess); };
|
||||||
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 callFinished(not_null<Call*> call) override;
|
||||||
void callFailed(not_null<Call*> call) override;
|
void callFailed(not_null<Call*> call) override;
|
||||||
void callRedial(not_null<Call*> call) override;
|
void callRedial(not_null<Call*> call) override;
|
||||||
void callRequestPermissionsOrFail(Fn<void()> onSuccess) override {
|
void callRequestPermissionsOrFail(
|
||||||
requestPermissionsOrFail(std::move(onSuccess));
|
Fn<void()> onSuccess,
|
||||||
|
bool video) override {
|
||||||
|
requestPermissionsOrFail(std::move(onSuccess), video);
|
||||||
}
|
}
|
||||||
|
|
||||||
void groupCallFinished(not_null<GroupCall*> call) override;
|
void groupCallFinished(not_null<GroupCall*> call) override;
|
||||||
|
@ -89,7 +91,7 @@ private:
|
||||||
const MTPInputGroupCall &inputCall);
|
const MTPInputGroupCall &inputCall);
|
||||||
void destroyGroupCall(not_null<GroupCall*> call);
|
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 requestPermissionOrFail(Platform::PermissionType type, Fn<void()> onSuccess);
|
||||||
|
|
||||||
void refreshDhConfig();
|
void refreshDhConfig();
|
||||||
|
|
|
@ -307,10 +307,7 @@ void Panel::initControls() {
|
||||||
});
|
});
|
||||||
_camera->setClickedCallback([=] {
|
_camera->setClickedCallback([=] {
|
||||||
if (_call) {
|
if (_call) {
|
||||||
_call->videoOutgoing()->setState(
|
_call->switchVideoOutgoing();
|
||||||
(_call->videoOutgoing()->state() == Webrtc::VideoState::Active)
|
|
||||||
? Webrtc::VideoState::Inactive
|
|
||||||
: Webrtc::VideoState::Active);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue