-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix android GDPR
- Loading branch information
Showing
9 changed files
with
334 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
...ppleGeneralDataProtectionRegulationPlugin/AppleGeneralDataProtectionRegulationInterface.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#pragma once | ||
|
||
#include "Interface/ServiceInterface.h" | ||
|
||
namespace Mengine | ||
{ | ||
class AppleGeneralDataProtectionRegulationServiceInterface | ||
: public ServiceInterface | ||
{ | ||
SERVICE_DECLARE( "AppleGeneralDataProtectionRegulationServiceInterface" ) | ||
|
||
public: | ||
virtual void setGDPRPass( bool _passGDPR ) = 0; | ||
virtual bool isGDPRPass() const = 0; | ||
}; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
#define APPLE_GENERALDATAPROTECTIONREGULATION_SERVICE()\ | ||
((Mengine::AppleGeneralDataProtectionRegulationServiceInterface *)SERVICE_GET(Mengine::AppleGeneralDataProtectionRegulationServiceInterface)) | ||
////////////////////////////////////////////////////////////////////////// |
23 changes: 23 additions & 0 deletions
23
...s/AppleGeneralDataProtectionRegulationPlugin/AppleGeneralDataProtectionRegulationPlugin.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#pragma once | ||
|
||
#include "Kernel/PluginBase.h" | ||
|
||
namespace Mengine | ||
{ | ||
class AppleGeneralDataProtectionRegulationPlugin | ||
: public PluginBase | ||
{ | ||
PLUGIN_DECLARE( "AppleGeneralDataProtectionRegulation" ) | ||
|
||
public: | ||
AppleGeneralDataProtectionRegulationPlugin(); | ||
~AppleGeneralDataProtectionRegulationPlugin() override; | ||
|
||
protected: | ||
bool _availablePlugin() const override; | ||
bool _initializePlugin() override; | ||
void _finalizePlugin() override; | ||
void _destroyPlugin() override; | ||
}; | ||
} | ||
|
93 changes: 93 additions & 0 deletions
93
.../AppleGeneralDataProtectionRegulationPlugin/AppleGeneralDataProtectionRegulationPlugin.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#include "AppleGeneralDataProtectionRegulationPlugin.h" | ||
|
||
#ifdef MENGINE_USE_SCRIPT_SERVICE | ||
# include "Interface/ScriptServiceInterface.h" | ||
|
||
# include "AppleGeneralDataProtectionRegulationScriptEmbedding.h" | ||
#endif | ||
|
||
#include "AppleGeneralDataProtectionRegulationInterface.h" | ||
|
||
#include "Kernel/ConfigHelper.h" | ||
#include "Kernel/OptionHelper.h" | ||
#include "Kernel/FactorableUnique.h" | ||
#include "Kernel/NotificationHelper.h" | ||
|
||
////////////////////////////////////////////////////////////////////////// | ||
SERVICE_EXTERN( AppleGeneralDataProtectionRegulationService ); | ||
////////////////////////////////////////////////////////////////////////// | ||
PLUGIN_FACTORY( AppleGeneralDataProtectionRegulation, Mengine::AppleGeneralDataProtectionRegulationPlugin ) | ||
////////////////////////////////////////////////////////////////////////// | ||
namespace Mengine | ||
{ | ||
////////////////////////////////////////////////////////////////////////// | ||
AppleGeneralDataProtectionRegulationPlugin::AppleGeneralDataProtectionRegulationPlugin() | ||
{ | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
AppleGeneralDataProtectionRegulationPlugin::~AppleGeneralDataProtectionRegulationPlugin() | ||
{ | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleGeneralDataProtectionRegulationPlugin::_availablePlugin() const | ||
{ | ||
if( HAS_OPTION( "applegeneraldataprotectionregulation" ) == true ) | ||
{ | ||
return true; | ||
} | ||
|
||
if( HAS_OPTION( "noapplegeneraldataprotectionregulation" ) == true ) | ||
{ | ||
return false; | ||
} | ||
|
||
bool AppleGeneralDataProtectionRegulationPlugin_Available = CONFIG_VALUE( "AppleGeneralDataProtectionRegulationPlugin", "Available", true ); | ||
|
||
if( AppleGeneralDataProtectionRegulationPlugin_Available == false ) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleGeneralDataProtectionRegulationPlugin::_initializePlugin() | ||
{ | ||
if( SERVICE_CREATE( AppleGeneralDataProtectionRegulationService, MENGINE_DOCUMENT_FACTORABLE ) == false ) | ||
{ | ||
return false; | ||
} | ||
|
||
#ifdef MENGINE_USE_SCRIPT_SERVICE | ||
NOTIFICATION_ADDOBSERVERLAMBDA_THIS( NOTIFICATOR_SCRIPT_EMBEDDING, [this]() | ||
{ | ||
SCRIPT_SERVICE() | ||
->addScriptEmbedding( STRINGIZE_STRING_LOCAL( "AppleGeneralDataProtectionRegulationScriptEmbedding" ), Helper::makeFactorableUnique<AppleGeneralDataProtectionRegulationScriptEmbedding>( MENGINE_DOCUMENT_FACTORABLE ) ); | ||
}, MENGINE_DOCUMENT_FACTORABLE ); | ||
|
||
NOTIFICATION_ADDOBSERVERLAMBDA_THIS( NOTIFICATOR_SCRIPT_EJECTING, []() | ||
{ | ||
SCRIPT_SERVICE() | ||
->removeScriptEmbedding( STRINGIZE_STRING_LOCAL( "AppleGeneralDataProtectionRegulationScriptEmbedding" ) ); | ||
}, MENGINE_DOCUMENT_FACTORABLE ); | ||
#endif | ||
|
||
return true; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
void AppleGeneralDataProtectionRegulationPlugin::_finalizePlugin() | ||
{ | ||
#ifdef MENGINE_USE_SCRIPT_SERVICE | ||
NOTIFICATION_REMOVEOBSERVER_THIS( NOTIFICATOR_SCRIPT_EMBEDDING ); | ||
NOTIFICATION_REMOVEOBSERVER_THIS( NOTIFICATOR_SCRIPT_EJECTING ); | ||
#endif | ||
|
||
SERVICE_FINALIZE( AppleGeneralDataProtectionRegulationService ); | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
void AppleGeneralDataProtectionRegulationPlugin::_destroyPlugin() | ||
{ | ||
SERVICE_DESTROY( AppleGeneralDataProtectionRegulationService ); | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
} |
21 changes: 21 additions & 0 deletions
21
...neralDataProtectionRegulationPlugin/AppleGeneralDataProtectionRegulationScriptEmbedding.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "Interface/ScriptEmbeddingInterface.h" | ||
|
||
#include "Kernel/Factorable.h" | ||
|
||
namespace Mengine | ||
{ | ||
class AppleGeneralDataProtectionRegulationScriptEmbedding | ||
: public ScriptEmbeddingInterface | ||
, public Factorable | ||
{ | ||
public: | ||
AppleGeneralDataProtectionRegulationScriptEmbedding(); | ||
~AppleGeneralDataProtectionRegulationScriptEmbedding() override; | ||
|
||
public: | ||
bool embed( pybind::kernel_interface * _kernel ) override; | ||
void eject( pybind::kernel_interface * _kernel ) override; | ||
}; | ||
} |
65 changes: 65 additions & 0 deletions
65
...eralDataProtectionRegulationPlugin/AppleGeneralDataProtectionRegulationScriptEmbedding.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "AppleGeneralDataProtectionRegulationScriptEmbedding.h" | ||
|
||
#include "AppleGeneralDataProtectionRegulationInterface.h" | ||
|
||
#include "Interface/ScriptServiceInterface.h" | ||
|
||
#include "Environment/Python/PythonIncluder.h" | ||
#include "Environment/Python/PythonDocumentTraceback.h" | ||
|
||
#include "Kernel/FactorableUnique.h" | ||
#include "Kernel/ConstStringHelper.h" | ||
#include "Kernel/DocumentHelper.h" | ||
#include "Kernel/Logger.h" | ||
|
||
namespace Mengine | ||
{ | ||
namespace Detail | ||
{ | ||
////////////////////////////////////////////////////////////////////////// | ||
static void s_AppleGeneralDataProtectionRegulation_setGDPRPass( bool _passGDPR ) | ||
{ | ||
APPLE_GENERALDATAPROTECTIONREGULATION_SERVICE() | ||
->setGDPRPass( _passGDPR ); | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
static void s_AppleGeneralDataProtectionRegulation_isGDPRPass( bool _passGDPR ) | ||
{ | ||
bool passGDPR = APPLE_GENERALDATAPROTECTIONREGULATION_SERVICE() | ||
->isGDPRPass(); | ||
|
||
return passGDPR; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
AppleGeneralDataProtectionRegulationScriptEmbedding::AppleGeneralDataProtectionRegulationEmbedding() | ||
{ | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
AppleGeneralDataProtectionRegulationScriptEmbedding::~AppleGeneralDataProtectionRegulationEmbedding() | ||
{ | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
bool AppleGeneralDataProtectionRegulationScriptEmbedding::embed( pybind::kernel_interface * _kernel ) | ||
{ | ||
SCRIPT_SERVICE() | ||
->setAvailablePlugin( "AppleGeneralDataProtectionRegulation", true ); | ||
|
||
pybind::def_function( _kernel, "appleSetGDPRPass", &Detail::s_AppleGeneralDataProtectionRegulation_setGDPRPass ); | ||
pybind::def_function( _kernel, "appleIsGDPRPass", &Detail::s_AppleGeneralDataProtectionRegulation_isGDPRPass ); | ||
|
||
return true; | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
void AppleGeneralDataProtectionRegulationScriptEmbedding::eject( pybind::kernel_interface * _kernel ) | ||
{ | ||
SCRIPT_SERVICE() | ||
->setAvailablePlugin( "AppleGeneralDataProtectionRegulation", false ); | ||
|
||
_kernel->remove_from_module( "appleSetGDPRPass", nullptr ); | ||
_kernel->remove_from_module( "appleIsGDPRPass", nullptr ); | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
} | ||
|
24 changes: 24 additions & 0 deletions
24
.../AppleGeneralDataProtectionRegulationPlugin/AppleGeneralDataProtectionRegulationService.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "AppleGeneralDataProtectionRegulationInterface.h" | ||
|
||
#include "Kernel/ServiceBase.h" | ||
|
||
namespace Mengine | ||
{ | ||
class AppleGeneralDataProtectionRegulationService | ||
: public ServiceBase<AppleGeneralDataProtectionRegulationServiceInterface> | ||
{ | ||
public: | ||
AppleGeneralDataProtectionRegulationService(); | ||
~AppleGeneralDataProtectionRegulationService() override; | ||
|
||
protected: | ||
bool _initializeService() override; | ||
void _finalizeService() override; | ||
|
||
public: | ||
void setGDPRPass( bool _passGDPR ) override; | ||
bool isGDPRPass() const override; | ||
}; | ||
} |
58 changes: 58 additions & 0 deletions
58
...AppleGeneralDataProtectionRegulationPlugin/AppleGeneralDataProtectionRegulationService.mm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "AppleGeneralDataProtectionRegulationService.h" | ||
|
||
#include "Environment/Apple/AppleUtils.h" | ||
|
||
#include "Kernel/Logger.h" | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <StoreKit/StoreKit.h> | ||
|
||
//////////////////////////////////////////////////////////////////////////// | ||
SERVICE_FACTORY( AppleGeneralDataProtectionRegulationService, Mengine::AppleGeneralDataProtectionRegulationService ); | ||
////////////////////////////////////////////////////////////////////////// | ||
namespace Mengine | ||
{ | ||
////////////////////////////////////////////////////////////////////////// | ||
AppleGeneralDataProtectionRegulationService::AppleGeneralDataProtectionRegulationService() | ||
{ | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
AppleGeneralDataProtectionRegulationService::~AppleGeneralDataProtectionRegulationService() | ||
{ | ||
} | ||
///////////////////////////////////////////////////////////////////////////// | ||
bool AppleGeneralDataProtectionRegulationService::_initializeService() | ||
{ | ||
//Empty | ||
|
||
return true; | ||
} | ||
//////////////////////////////////////////////////////////////////////// | ||
void AppleGeneralDataProtectionRegulationService::_finalizeService() | ||
{ | ||
//Empty | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
void AppleGeneralDataProtectionRegulationService::setGDPRPass( bool _passGDPR ) | ||
{ | ||
LOGGER_MESSAGE( "set GDPR pass [%d]" | ||
, _passGDPR | ||
); | ||
|
||
if (@available(iOS 14.0, *)) { | ||
UIWindowScene * foregroundScene = nil; | ||
for( UIWindowScene * scene in UIApplication.sharedApplication.connectedScenes ) { | ||
if( scene.activationState == UISceneActivationStateForegroundActive ) { | ||
foregroundScene = scene; | ||
} | ||
} | ||
|
||
if( foregroundScene != nil ) { | ||
[SKStoreReviewController requestReviewInScene:foregroundScene]; | ||
} | ||
} else if (@available(iOS 10.3, *)) { | ||
[SKStoreReviewController requestReview]; | ||
} | ||
} | ||
////////////////////////////////////////////////////////////////////////// | ||
} |
27 changes: 27 additions & 0 deletions
27
src/Plugins/AppleGeneralDataProtectionRegulationPlugin/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
MENGINE_PROJECT(AppleGeneralDataProtectionRegulationPlugin) | ||
|
||
ADD_FILTER( | ||
src | ||
AppleGeneralDataProtectionRegulationInterface.h | ||
AppleGeneralDataProtectionRegulationService.h | ||
AppleGeneralDataProtectionRegulationService.mm | ||
|
||
AppleGeneralDataProtectionRegulationPlugin.h | ||
AppleGeneralDataProtectionRegulationPlugin.mm | ||
) | ||
|
||
if(MENGINE_USE_SCRIPT_SERVICE) | ||
ADD_FILTER( | ||
embedding | ||
AppleGeneralDataProtectionRegulationScriptEmbedding.h | ||
AppleGeneralDataProtectionRegulationScriptEmbedding.mm | ||
) | ||
|
||
INCLUDE_DIRECTORIES(${THIRDPARTY_DIR}/pybind/include) | ||
endif() | ||
|
||
ADD_MENGINE_PLUGIN(MENGINE_PLUGIN_APPLE_GENERALDATAPROTECTIONREGULATION) | ||
|
||
if(MENGINE_USE_SCRIPT_SERVICE) | ||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${THIRDPARTY_LIB_DIR}/${MENGINE_LIB_PREFIX}pybind${MENGINE_LIB_SUFFIX}) | ||
endif() |