7#include "remotecontentmanager.h"
8#include "remotecontentinfo.h"
10#include <KSharedConfig>
12using namespace MessageViewer;
15static const char myRemoteContentGroupName[] =
"RemoteContent";
17RemoteContentManager::RemoteContentManager(
QObject *parent)
23RemoteContentManager::~RemoteContentManager()
34void RemoteContentManager::clear()
36 mRemoveContentInfo.clear();
39bool RemoteContentManager::isAutorized(
const QString &url)
const
42 if (info.url() == url) {
43 return info.status() == RemoteContentInfo::RemoteContentInfoStatus::Authorized;
49bool RemoteContentManager::isAutorized(
const QUrl &url,
bool &contains)
const
57 if (info.url() == urlToString) {
59 return info.status() == RemoteContentInfo::RemoteContentInfoStatus::Authorized;
60 }
else if (info.url() == host) {
62 return info.status() == RemoteContentInfo::RemoteContentInfoStatus::Authorized;
68bool RemoteContentManager::isBlocked(
const QUrl &url,
bool &contains)
const
76 if (info.url() == urlToString) {
78 return info.status() == RemoteContentInfo::RemoteContentInfoStatus::Blocked;
79 }
else if (info.url() == host) {
81 return info.status() == RemoteContentInfo::RemoteContentInfoStatus::Blocked;
87void RemoteContentManager::loadSettings()
89 mRemoveContentInfo.clear();
94 mRemoveContentInfo.reserve(blockedUrl.
count() + authorizedUrl.
count());
95 for (
const QString &url : blockedUrl) {
98 info.setStatus(RemoteContentInfo::RemoteContentInfoStatus::Blocked);
99 mRemoveContentInfo.append(info);
101 for (
const QString &url : authorizedUrl) {
104 info.setStatus(RemoteContentInfo::RemoteContentInfoStatus::Authorized);
105 mRemoveContentInfo.append(info);
109void RemoteContentManager::writeSettings()
116 switch (info.status()) {
117 case RemoteContentInfo::RemoteContentInfoStatus::Unknown:
119 case RemoteContentInfo::RemoteContentInfoStatus::Blocked:
120 blockedUrl.
append(info.url());
122 case RemoteContentInfo::RemoteContentInfoStatus::Authorized:
123 authorizedUrl.
append(info.url());
127 group.writeEntry(
"Blocked", blockedUrl);
128 group.writeEntry(
"Authorized", authorizedUrl);
134 mRemoveContentInfo = removeContentInfo;
139 return mRemoveContentInfo;
144 mRemoveContentInfo.append(info);
150 if (info.url() == newInfo.url()) {
157#include "moc_remotecontentmanager.cpp"
static KSharedConfig::Ptr openConfig(const QString &fileName=QString(), OpenFlags mode=FullConfig, QStandardPaths::StandardLocation type=QStandardPaths::GenericConfigLocation)
The RemoteContentInfo class.
The RemoteContentManager class.
void append(QList< T > &&value)
qsizetype count() const const
QString host(ComponentFormattingOptions options) const const
QString toString(FormattingOptions options) const const