mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-04-01 00:08:02 +00:00
Beta version 1.4.4: Add some checks.
This commit is contained in:
parent
44eac2bf07
commit
a429e22b93
@ -241,7 +241,9 @@ void Call::startIncoming() {
|
||||
}
|
||||
|
||||
void Call::answer() {
|
||||
_delegate->requestMicrophonePermissionOrFail([this](){ actuallyAnswer(); });
|
||||
_delegate->requestMicrophonePermissionOrFail(crl::guard(this, [=] {
|
||||
actuallyAnswer();
|
||||
}));
|
||||
}
|
||||
|
||||
void Call::actuallyAnswer() {
|
||||
|
@ -40,9 +40,9 @@ void Instance::startOutgoingCall(not_null<UserData*> user) {
|
||||
Ui::show(Box<InformBox>(lng_call_error_not_available(lt_user, App::peerName(user))));
|
||||
return;
|
||||
}
|
||||
requestMicrophonePermissionOrFail([this, user](){
|
||||
requestMicrophonePermissionOrFail(crl::guard(this, [=] {
|
||||
createCall(user, Call::Type::Outgoing);
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
void Instance::callFinished(not_null<Call*> call) {
|
||||
@ -294,7 +294,7 @@ void Instance::requestMicrophonePermissionOrFail(Fn<void()> onSuccess) {
|
||||
if (status==Platform::PermissionStatus::Granted) {
|
||||
onSuccess();
|
||||
} else if(status==Platform::PermissionStatus::CanRequest) {
|
||||
Platform::RequestPermission(Platform::PermissionType::Microphone, [this, onSuccess](Platform::PermissionStatus status){
|
||||
Platform::RequestPermission(Platform::PermissionType::Microphone, crl::guard(this, [=](Platform::PermissionStatus status) {
|
||||
if (status==Platform::PermissionStatus::Granted) {
|
||||
crl::on_main(onSuccess);
|
||||
} else {
|
||||
@ -302,15 +302,15 @@ void Instance::requestMicrophonePermissionOrFail(Fn<void()> onSuccess) {
|
||||
_currentCall->hangup();
|
||||
}
|
||||
}
|
||||
});
|
||||
}));
|
||||
} else {
|
||||
if (alreadyInCall()) {
|
||||
_currentCall->hangup();
|
||||
}
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_no_mic_permission), lang(lng_menu_settings), [](){
|
||||
Ui::show(Box<ConfirmBox>(lang(lng_no_mic_permission), lang(lng_menu_settings), crl::guard(this, [] {
|
||||
Platform::OpenSystemSettingsForPermission(Platform::PermissionType::Microphone);
|
||||
Ui::hideLayer();
|
||||
}));
|
||||
})));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ enum class PeerToPeer {
|
||||
|
||||
class Panel;
|
||||
|
||||
class Instance : private MTP::Sender, private Call::Delegate, private base::Subscriber {
|
||||
class Instance : private MTP::Sender, private Call::Delegate, private base::Subscriber, public base::has_weak_ptr {
|
||||
public:
|
||||
Instance();
|
||||
|
||||
|
@ -438,11 +438,10 @@ PermissionStatus GetPermissionStatus(PermissionType type){
|
||||
}
|
||||
|
||||
void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCallback){
|
||||
|
||||
resultCallback(PermissionStatus::Granted);
|
||||
}
|
||||
|
||||
void OpenSystemSettingsForPermission(PermissionType type){
|
||||
|
||||
}
|
||||
|
||||
namespace ThirdParty {
|
||||
|
@ -288,7 +288,8 @@ void RegisterCustomScheme() {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunguarded-availability"
|
||||
PermissionStatus GetPermissionStatus(PermissionType type) {
|
||||
switch(type) {
|
||||
#ifndef OS_MAC_OLD
|
||||
switch (type) {
|
||||
case PermissionType::Microphone:
|
||||
if([AVCaptureDevice respondsToSelector: @selector(authorizationStatusForMediaType:)]) { // Available starting with 10.14
|
||||
switch([AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio]) {
|
||||
@ -301,32 +302,38 @@ PermissionStatus GetPermissionStatus(PermissionType type) {
|
||||
return PermissionStatus::Denied;
|
||||
}
|
||||
}
|
||||
return PermissionStatus::Granted;
|
||||
break;
|
||||
}
|
||||
#endif // OS_MAC_OLD
|
||||
return PermissionStatus::Granted;
|
||||
}
|
||||
|
||||
void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCallback) {
|
||||
switch(type) {
|
||||
#ifndef OS_MAC_OLD
|
||||
switch (type) {
|
||||
case PermissionType::Microphone:
|
||||
if([AVCaptureDevice respondsToSelector: @selector(requestAccessForMediaType:completionHandler:)]) { // Available starting with 10.14
|
||||
if ([AVCaptureDevice respondsToSelector: @selector(requestAccessForMediaType:completionHandler:)]) { // Available starting with 10.14
|
||||
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
|
||||
crl::on_main([=] {
|
||||
resultCallback(granted ? PermissionStatus::Granted : PermissionStatus::Denied);
|
||||
});
|
||||
}];
|
||||
}else{
|
||||
resultCallback(PermissionStatus::Granted);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#endif // OS_MAC_OLD
|
||||
resultCallback(PermissionStatus::Granted);
|
||||
}
|
||||
#pragma clang diagnostic pop // -Wunguarded-availability
|
||||
|
||||
void OpenSystemSettingsForPermission(PermissionType type) {
|
||||
switch(type) {
|
||||
#ifndef OS_MAC_OLD
|
||||
switch (type) {
|
||||
case PermissionType::Microphone:
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"x-apple.systempreferences:com.apple.preference.security?Privacy_Microphone"]];
|
||||
break;
|
||||
}
|
||||
#endif // OS_MAC_OLD
|
||||
}
|
||||
|
||||
} // namespace Platform
|
||||
|
@ -17,6 +17,7 @@ enum class PermissionStatus {
|
||||
CanRequest,
|
||||
Denied,
|
||||
};
|
||||
|
||||
enum class PermissionType {
|
||||
Microphone,
|
||||
};
|
||||
|
@ -627,7 +627,7 @@ void RegisterCustomScheme() {
|
||||
}
|
||||
|
||||
PermissionStatus GetPermissionStatus(PermissionType type) {
|
||||
if(type==PermissionType::Microphone) {
|
||||
if (type==PermissionType::Microphone) {
|
||||
PermissionStatus result=PermissionStatus::Granted;
|
||||
HKEY hKey;
|
||||
LSTATUS res=RegOpenKeyEx(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\CapabilityAccessManager\\ConsentStore\\microphone", 0, KEY_QUERY_VALUE, &hKey);
|
||||
@ -648,11 +648,11 @@ PermissionStatus GetPermissionStatus(PermissionType type) {
|
||||
}
|
||||
|
||||
void RequestPermission(PermissionType type, Fn<void(PermissionStatus)> resultCallback) {
|
||||
|
||||
resultCallback(PermissionStatus::Granted);
|
||||
}
|
||||
|
||||
void OpenSystemSettingsForPermission(PermissionType type) {
|
||||
if(type==PermissionType::Microphone) {
|
||||
if (type==PermissionType::Microphone) {
|
||||
ShellExecute(NULL, L"open", L"ms-settings:privacy-microphone", NULL, NULL, SW_SHOWDEFAULT);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user