mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-18 07:24:07 +00:00
41 lines
857 B
C++
41 lines
857 B
C++
#include "globalbroadcaster.h"
|
|
#include <QGlobalStatic>
|
|
#include "utils.hh"
|
|
|
|
Q_GLOBAL_STATIC( GlobalBroadcaster, bdcaster )
|
|
GlobalBroadcaster::GlobalBroadcaster( QObject * parent ) : QObject( parent )
|
|
{
|
|
QStringList whiteUrlHosts = { "ajax.googleapis.com" };
|
|
|
|
for( auto host : whiteUrlHosts )
|
|
{
|
|
addWhitelist( host );
|
|
}
|
|
}
|
|
|
|
GlobalBroadcaster * GlobalBroadcaster::instance()
|
|
{
|
|
return bdcaster;
|
|
}
|
|
void GlobalBroadcaster::setPreference( Config::Preferences * p )
|
|
{
|
|
preference = p;
|
|
}
|
|
Config::Preferences * GlobalBroadcaster::getPreference()
|
|
{
|
|
return preference;
|
|
}
|
|
|
|
void GlobalBroadcaster::addWhitelist( QString url )
|
|
{
|
|
whitelist.insert( url );
|
|
auto baseUrl = Utils::Url::getHostBase( url );
|
|
whitelist.insert( baseUrl );
|
|
}
|
|
|
|
bool GlobalBroadcaster::existedInWhitelist( QString url )
|
|
{
|
|
return whitelist.contains(url);
|
|
}
|
|
// namespace global
|