MCPcopy Create free account
hub / github.com/YtFlow/Maple / StartConnectionCheck

Method StartConnectionCheck

Maple.App/MainPage.cpp:581–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579 }
580 }
581 fire_and_forget MainPage::StartConnectionCheck()
582 {
583 try {
584 const auto lifetime{ get_strong() };
585 IVectorView<IVpnProfile> profiles{ nullptr };
586
587 auto event_token{ ConnectionToggleSwitch().Toggled({ this, &MainPage::ConnectionToggleSwitch_Toggled }) };
588 while (true) {
589 if (m_vpnProfile == nullptr) {
590 profiles = co_await VpnMgmtAgent.GetProfilesAsync();
591 for (auto const p : profiles) {
592 if (p.ProfileName() == L"Maple" || p.ProfileName() == L"maple") {
593 m_vpnProfile = p.try_as<VpnPlugInProfile>();
594 break;
595 }
596 }
597 }
598 if (m_vpnProfile == nullptr) {
599 ConnectionToggleSwitch().IsEnabled(false);
600 }
601 else {
602 ToolTipService::SetToolTip(ConnectionToggleSwitchContainer(), nullptr);
603 auto status = VpnManagementConnectionStatus::Disconnected;
604 try {
605 status = m_vpnProfile.ConnectionStatus();
606 }
607 catch (...) {}
608
609 ConnectionToggleSwitch().IsEnabled(status == VpnManagementConnectionStatus::Connected
610 || status == VpnManagementConnectionStatus::Disconnected);
611 ConnectionToggleSwitch().Toggled(event_token);
612 ConnectionToggleSwitch().IsOn(status == VpnManagementConnectionStatus::Connected
613 || status == VpnManagementConnectionStatus::Connecting);
614 event_token = ConnectionToggleSwitch().Toggled({ this, &MainPage::ConnectionToggleSwitch_Toggled });
615 }
616 co_await 1s;
617 co_await resume_foreground(Dispatcher());
618 }
619 }
620 catch (...)
621 {
622 UI::NotifyException(L"Checking VPN status");
623 }
624 }
625
626 fire_and_forget MainPage::ConfigFolderSelectButton_Click(IInspectable const&, RoutedEventArgs const&)
627 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected