Add initial system policy checking for turning off data collection

This commit is contained in:
Marek Roszko 2022-04-09 14:01:07 -04:00
parent 0015574a60
commit b3c5054d6c
7 changed files with 169 additions and 1 deletions

View File

@ -34,6 +34,8 @@
#include <settings/common_settings.h>
#include <settings/settings_manager.h>
#include <kiplatform/policy.h>
PANEL_DATA_COLLECTION::PANEL_DATA_COLLECTION( PAGED_DIALOG* aDialog, wxWindow* aParent ) :
PANEL_DATA_COLLECTION_BASE( aParent ), m_dialog( aDialog )
{
@ -44,6 +46,13 @@ bool PANEL_DATA_COLLECTION::TransferDataToWindow()
{
applySettingsToPanel();
KIPLATFORM::POLICY::STATE policyState =
KIPLATFORM::POLICY::GetPolicyState( "DataCollection" );
if( policyState != KIPLATFORM::POLICY::STATE::NOT_CONFIGURED )
{
Disable();
}
return true;
}

View File

@ -60,6 +60,8 @@
#include <trace_helpers.h>
#include <paths.h>
#include <kiplatform/policy.h>
#ifdef KICAD_USE_SENTRY
#include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid_generators.hpp>
@ -218,6 +220,13 @@ const wxString PGM_BASE::AskUserForPreferredEditor( const wxString& aDefaultEdit
#ifdef KICAD_USE_SENTRY
bool PGM_BASE::IsSentryOptedIn()
{
KIPLATFORM::POLICY::STATE policyState =
KIPLATFORM::POLICY::GetPolicyState( wxT( "DataCollection" ) );
if( policyState != KIPLATFORM::POLICY::STATE::NOT_CONFIGURED )
{
return policyState == KIPLATFORM::POLICY::STATE::ENABLED;
}
return m_sentry_optin_fn.Exists();
}
@ -319,7 +328,11 @@ void PGM_BASE::sentryInit()
void PGM_BASE::sentryPrompt()
{
if( !m_settings_manager->GetCommonSettings()->m_DoNotShowAgain.data_collection_prompt )
KIPLATFORM::POLICY::STATE policyState =
KIPLATFORM::POLICY::GetPolicyState( wxT( "DataCollection" ) );
if( policyState == KIPLATFORM::POLICY::STATE::NOT_CONFIGURED
&& !m_settings_manager->GetCommonSettings()->m_DoNotShowAgain.data_collection_prompt )
{
wxMessageDialog optIn = wxMessageDialog(
nullptr,

View File

@ -11,6 +11,7 @@ if( APPLE )
set( PLATFORM_SRCS
osx/app.mm
osx/environment.mm
osx/policy.mm
osx/ui.mm
)
@ -24,6 +25,7 @@ elseif( WIN32 )
set( PLATFORM_SRCS
msw/app.cpp
msw/environment.cpp
msw/policy.cpp
msw/ui.cpp
)
@ -36,6 +38,7 @@ elseif( UNIX )
set( PLATFORM_SRCS
gtk/app.cpp
gtk/environment.cpp
gtk/policy.cpp
gtk/ui.cpp
)

View File

@ -0,0 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kiplatform/policy.h>
#include <wx/string.h>
KIPLATFORM::POLICY::STATE KIPLATFORM::POLICY::GetPolicyState( const wxString& aKey )
{
return STATE::NOT_CONFIGURED;
}

View File

@ -0,0 +1,42 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KIPLATFORM_POLICY_H_
#define KIPLATFORM_POLICY_H_
class wxString;
namespace KIPLATFORM
{
namespace POLICY
{
enum class STATE
{
ENABLED,
DISABLED,
NOT_CONFIGURED
};
STATE GetPolicyState( const wxString& aKey );
}
}
#endif

View File

@ -0,0 +1,45 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kiplatform/policy.h>
#include <wx/string.h>
#include <wx/msw/registry.h>
#define POLICY_KEY_ROOT "Software\\Policies\\KiCad\\KiCad"
KIPLATFORM::POLICY::STATE KIPLATFORM::POLICY::GetPolicyState( const wxString& aKey )
{
wxRegKey key( wxRegKey::HKLM, POLICY_KEY_ROOT );
if( key.Exists() )
{
long value;
if( key.QueryValue( aKey, &value ) )
{
if( value == 1 )
return POLICY::STATE::ENABLED;
else
return POLICY::STATE::DISABLED;
}
}
return STATE::NOT_CONFIGURED;
}

View File

@ -0,0 +1,28 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2022 Mark Roszko <mark.roszko@gmail.com>
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <kiplatform/policy.h>
#include <wx/string.h>
KIPLATFORM::POLICY::STATE KIPLATFORM::POLICY::GetPolicyState( const wxString& aKey )
{
return STATE::NOT_CONFIGURED;
}