KNewStuff
enginebase.cpp
42 connect(d->installation, &Installation::signalInstallationError, this, [this](const QString &message) {
43 Q_EMIT signalErrorCode(ErrorCode::InstallationError, i18n("An error occurred during the installation process:\n%1", message), QVariant());
53 configSearchLocations << QStandardPaths::standardLocations(QStandardPaths::GenericConfigLocation);
75 resolvedConfigFilePath = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("knsrcfiles/%1").arg(configfile));
79 Q_EMIT signalErrorCode(KNSCore::ErrorCode::ConfigFileError, i18n("Configuration file does not exist: \"%1\"", configfile), configfile);
87 Q_EMIT signalErrorCode(KNSCore::ErrorCode::ConfigFileError, i18n("Configuration file exists, but cannot be opened: \"%1\"", configfile), configfile);
88 qCCritical(KNEWSTUFFCORE) << "The knsrc file" << configfile << "was found but could not be opened.";
92 const KConfigGroup group = conf.hasGroup(QStringLiteral("KNewStuff")) ? conf.group(QStringLiteral("KNewStuff")) : conf.group(QStringLiteral("KNewStuff3"));
94 Q_EMIT signalErrorCode(KNSCore::ErrorCode::ConfigFileError, i18n("Configuration file is invalid: \"%1\"", configfile), configfile);
108 d->providerFileUrl = group.readEntry("ProvidersUrl", QUrl(QStringLiteral("https://autoconfig.kde.org/ocs/providers.xml")));
111 d->providerFileUrl = QUrl::fromLocalFile(QLatin1String("%1.providers").arg(configfile.left(configfile.length() - 6)));
117 QByteArray rawContentWarningType = group.readEntry("ContentWarning", QByteArrayLiteral("Static"));
119 int value = QMetaEnum::fromType<ContentWarningType>().keyToValue(rawContentWarningType.constData(), &ok);
123 qCWarning(KNEWSTUFFCORE) << "Could not parse ContentWarning, invalid entry" << rawContentWarningType;
145 // Cache cleanup option, to help work around people deleting files from underneath KNewStuff (this
151 d->shouldRemoveDeletedEntries = group.readEntry("RemoveDeadEntries", d->shouldRemoveDeletedEntries);
168 connect(d->atticaProviderManager, &Attica::ProviderManager::providerAdded, this, &EngineBase::atticaProviderLoaded);
169 connect(d->atticaProviderManager, &Attica::ProviderManager::failedToLoad, this, &EngineBase::slotProvidersFailed);
177 qCDebug(KNEWSTUFFCORE) << "No xml loader for this url yet, so create one and temporarily store that" << d->providerFileUrl;
186 connect(loader, &XmlLoader::signalHttpError, this, [this](int status, QList<QNetworkReply::RawHeaderPair> rawHeaders) {
192 // Retry-After is not a known header, so we need to do a bit of running around to make that work
193 // Also, the fromHttpDate function is in the private qnetworkrequest header, so we can't use that
194 // So, simple workaround, just pass it through a dummy request and get a formatted date out (the
202 QTimer::singleShot(retryAfter.toMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch(), this, &EngineBase::loadProviders);
205 // more than that, spit out TryAgainLaterError to let the user know what we're doing with their time
209 formatter.formatSpelloutDuration(retryAfter.toMSecsSinceEpoch() - QDateTime::currentMSecsSinceEpoch())),
299 } else if (providers.tagName() != QLatin1String("ghnsproviders") && providers.tagName() != QLatin1String("knewstuffproviders")) {
302 i18n("Could not load get hot new stuff providers from file: %1", d->providerFileUrl.toString()),
312 if (isAtticaProviderFile || n.attribute(QStringLiteral("type")).toLower() == QLatin1String("rest")) {
314 connect(provider.data(), &Provider::categoriesMetadataLoded, this, [this](const QList<Provider::CategoryMetadata> &categories) {
321 connect(provider.data(), &Provider::searchPresetsLoaded, this, [this](const QList<Provider::SearchPreset> &presets) {
333 Q_EMIT signalErrorCode(KNSCore::ErrorCode::ProviderError, i18n("Error initializing provider."), d->providerFileUrl);
344 qCDebug(KNEWSTUFFCORE) << "Found provider: " << atticaProvider.baseUrl() << " but it does not support content";
347 QSharedPointer<KNSCore::Provider> provider = QSharedPointer<KNSCore::Provider>(new AtticaProvider(atticaProvider, d->categories, {}));
348 connect(provider.data(), &Provider::categoriesMetadataLoded, this, [this](const QList<Provider::CategoryMetadata> &categories) {
QUrl baseUrl() const
bool hasContentService() const
bool hasGroup(const QString &group) const
KConfigGroup group(const QString &group)
QString readEntry(const char *key, const char *aDefault=nullptr) const
bool exists() const
AccessMode accessMode() const override
QString formatSpelloutDuration(quint64 msecs) const
bool uploadEnabled
Whether or not the configuration says that the providers are expected to support uploading.
Definition enginebase.h:67
void signalErrorCode(KNSCore::ErrorCode::ErrorCode errorCode, const QString &message, const QVariant &metadata)
Fires in the case of any critical or serious errors, such as network or API problems.
void addTagFilter(const QString &filter)
Add a single filter entry to the entry tag filter.
Definition enginebase.cpp:373
bool userCanBecomeFan(const Entry &entry)
Whether or not the user is allowed to become a fan of a particular entry.
Definition enginebase.cpp:427
QStringList categories() const
The list of the server-side names of the categories handled by this engine instance.
Definition enginebase.cpp:226
virtual void addProvider(QSharedPointer< KNSCore::Provider > provider)
Add a provider and connect it to the right slots.
Definition enginebase.cpp:251
void becomeFan(const Entry &entry)
This will mark the user who is currently authenticated as a fan of the entry passed to the function.
Definition enginebase.cpp:433
bool hasAdoptionCommand() const
Whether or not an adoption command exists for this engine.
Definition enginebase.cpp:457
QSharedPointer< Cache > cache() const
Get the entries cache for this engine (note that it may be null if the engine is not yet initialized)...
Definition enginebase.cpp:355
void setTagFilter(const QStringList &filter)
Set a filter for results, which filters out all entries which do not match the filter,...
Definition enginebase.cpp:360
Q_SIGNAL void contentWarningTypeChanged()
Emitted after the initial config load.
QSharedPointer< Provider > provider(const QString &providerId) const
The Provider instance with the passed ID.
Definition enginebase.cpp:439
Q_SIGNAL void uploadEnabledChanged()
Fired when the uploadEnabled property changes.
Q_SIGNAL void useLabelChanged()
Signal gets emitted when the useLabel property changes.
bool userCanVote(const Entry &entry)
Whether or not a user is able to vote on the passed entry.
Definition enginebase.cpp:415
static QStringList availableConfigFiles()
List of all available config files.
Definition enginebase.cpp:47
QStringList downloadTagFilter() const
Gets the current downloadlink tag filter list.
Definition enginebase.cpp:389
void providersChanged()
Fired whenever the list of providers changes.
QString useLabel
Text that should be displayed for the adoption button, this defaults to "Use".
Definition enginebase.h:59
void vote(const Entry &entry, uint rating)
Cast a vote on the passed entry.
Definition enginebase.cpp:421
QList< Attica::Provider * > atticaProviders() const
Definition enginebase.cpp:402
QList< Provider::CategoryMetadata > categoriesMetadata()
The list of metadata for the categories handled by this engine instance.
Definition enginebase.cpp:231
ResultsStream * search(const KNSCore::Provider::SearchRequest &request)
Returns a stream object that will fulfill the request.
Definition enginebase.cpp:471
void addDownloadTagFilter(const QString &filter)
Add a single filter entry to the download tag filter.
Definition enginebase.cpp:394
QSharedPointer< Provider > defaultProvider() const
Return the first provider in the providers list (usually the default provider)
Definition enginebase.cpp:444
ContentWarningType contentWarningType
Definition enginebase.h:77
void setDownloadTagFilter(const QStringList &filter)
Sets a filter to be applied to the downloads for an entry.
Definition enginebase.cpp:381
void signalMessage(const QString &message)
Indicates a message to be added to the ui's log, or sent to a messagebox.
virtual QString id() const =0
A unique Id for this provider (the url in most cases)
void basicsLoaded()
Fired when the provider's basic information has been fetched and updated.
void setTagFilter(const QStringList &tagFilter)
Set the tag filter used for entries by this provider.
Definition provider.cpp:84
void searchPresetsLoaded(const QList< KNSCore::Provider::SearchPreset > &presets)
Fires when the provider has loaded search presets.
void setDownloadTagFilter(const QStringList &downloadTagFilter)
Set the tag filter used for download items by this provider.
Definition provider.cpp:94
The ResultsStream is returned by EngineBase::search.
Definition resultsstream.h:33
Q_SCRIPTABLE CaptureState status()
QString i18n(const char *text, const TYPE &arg...)
KCOREADDONS_EXPORT QStringList findAllUniqueFiles(const QStringList &dirs, const QStringList &nameFilters={})
QCA_EXPORT ProviderList providers()
const char * constData() const const
qint64 currentMSecsSinceEpoch()
qint64 currentSecsSinceEpoch()
qint64 toMSecsSinceEpoch() const const
qint64 toSecsSinceEpoch() const const
QDomElement documentElement() const const
QString attribute(const QString &name, const QString &defValue) const const
bool isNull() const const
QDomElement nextSiblingElement(const QString &tagName, const QString &namespaceURI) const const
QString completeBaseName() const const
bool exists() const const
void reserve(qsizetype size)
QMetaEnum fromType()
int keyToValue(const char *key, bool *ok) const const
RawHeaderPair
LastModifiedHeader
QVariant header(KnownHeaders header) const const
void setRawHeader(const QByteArray &headerName, const QByteArray &headerValue)
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
LocateDirectory
GenericDataLocation
QString locate(StandardLocation type, const QString &fileName, LocateOptions options)
QStringList locateAll(StandardLocation type, const QString &fileName, LocateOptions options)
QStringList standardLocations(StandardLocation type)
QString left(qsizetype n) const const
qsizetype length() const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
singleShot
QUrl fromLocalFile(const QString &localFile)
QDateTime toDateTime() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:12:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:12:42 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.