KNewStuff
engine.cpp
55 QString getAdoptionCommand(const QString &command, const KNSCore::EntryInternal& entry, Installation *inst)
73 qCWarning(KNEWSTUFFCORE) << "can only adopt one file, will be using the first" << entry.installedFiles().at(0);
92 qCInfo(KNEWSTUFFCORE) << "Directory entry" << thisDir << "ends in a *, indicating this was installed from an archive - see Installation::archiveEntries";
99 qCInfo(KNEWSTUFFCORE) << "Current path" << currentPath << "does not start with" << rootPath << "and should be ignored";
106 qCInfo(KNEWSTUFFCORE) << "Current path" << currentPath << "is not a directory, and should be ignored";
116 qCWarning(KNEWSTUFFCORE) << "Failed to locate any shared installed directory in" << dirs << "and this is almost certainly very bad.";
129 // Used for updating purposes - we ought to be saving this information, but we also have to deal with old stuff, and so... this will have to do for now, and so
154 connect(m_installation, &Installation::signalInstallationFinished, this, &Engine::slotInstallationFinished);
155 connect(m_installation, &Installation::signalInstallationFailed, this, &Engine::slotInstallationFailed);
156 connect(m_installation, &Installation::signalInstallationError, this, [this](const QString &message){ Q_EMIT signalErrorCode(ErrorCode::InstallationError, i18n("An error occurred during the installation process:\n%1", message), QVariant()); });
159 connect(this, &Engine::signalErrorCode, this, [this] (const KNSCore::ErrorCode &, const QString &msg, const QVariant &) {
194 // TODO KF6: This is fallback logic for an old location for the knsrc files. This is deprecated in KF5 and should be removed in KF6
199 actualConfig = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("knsrcfiles/%1").arg(configfile));
204 qCWarning(KNEWSTUFFCORE) << "Using a deprecated location for the knsrc file" << configfile << " - please contact the author of the software which provides this file to get it updated to use the new location";
206 configFileName = QFileInfo(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("knsrcfiles/%1").arg(configfile))).baseName();
207 conf.reset(new KConfig(QStringLiteral("knsrcfiles/%1").arg(configfile), KConfig::FullConfig, QStandardPaths::GenericDataLocation));
214 Q_EMIT signalErrorCode(KNSCore::ConfigFileError, i18n("Configuration file exists, but cannot be opened: \"%1\"", configfile), configfile);
215 qCCritical(KNEWSTUFFCORE) << "The knsrc file '" << configfile << "' was found but could not be opened.";
227 Q_EMIT signalErrorCode(KNSCore::ConfigFileError, i18n("Configuration file is invalid: \"%1\"", configfile), configfile);
257 connect(this, &Engine::signalEntryEvent, m_cache.data(), [this] (const EntryInternal &entry, EntryInternal::EntryEvent event) {
265 // Cache cleanup option, to help work around people deleting files from underneath KNewStuff (this
271 d->shouldRemoveDeletedEntries = group.readEntry("RemoveDeadEntries", d->shouldRemoveDeletedEntries);
311 connect(d->m_atticaProviderManager, &Attica::ProviderManager::providerAdded, this, &Engine::atticaProviderLoaded);
312 connect(d->m_atticaProviderManager, &Attica::ProviderManager::failedToLoad, this, &Engine::slotProvidersFailed);
320 qCDebug(KNEWSTUFFCORE) << "No xml loader for this url yet, so create one and temporarily store that" << m_providerFileUrl;
323 connect(loader, &XmlLoader::signalLoaded, this, [this](){ s_engineProviderLoaders()->localData().remove(m_providerFileUrl); });
324 connect(loader, &XmlLoader::signalFailed, this, [this](){ s_engineProviderLoaders()->localData().remove(m_providerFileUrl); });
343 } else if (providers.tagName() != QLatin1String("ghnsproviders") && providers.tagName() != QLatin1String("knewstuffproviders")) {
345 Q_EMIT signalErrorCode(KNSCore::ProviderError, i18n("Could not load get hot new stuff providers from file: %1", m_providerFileUrl), m_providerFileUrl);
354 if (isAtticaProviderFile || n.attribute(QStringLiteral("type")).toLower() == QLatin1String("rest")) {
368 Q_EMIT signalErrorCode(KNSCore::ProviderError, i18n("Error initializing provider."), m_providerFileUrl);
379 qCDebug(KNEWSTUFFCORE) << "Found provider: " << atticaProvider.baseUrl() << " but it does not support content";
419 Q_EMIT signalErrorCode(KNSCore::ProviderError, i18n("Loading of providers from file: %1 failed", m_providerFileUrl), m_providerFileUrl);
436 void Engine::slotEntriesLoaded(const KNSCore::Provider::SearchRequest &request, KNSCore::EntryInternal::List entries)
439 qCDebug(KNEWSTUFFCORE) << "loaded page " << request.page << "current page" << m_currentPage << "count:" << entries.count();
534 m_currentRequest = KNSCore::Provider::SearchRequest(KNSCore::Provider::Newest, KNSCore::Provider::ExactEntryId, id);
611 qCDebug(KNEWSTUFFCORE) << "Get more data! current page: " << m_currentPage << " requested: " << m_currentRequest.page;
655 // If there is only one downloadable item, then we can fairly safely assume that's what we're wanting
661 qCDebug(KNEWSTUFFCORE) << "Try and identify a download link to use from a total of" << entry.downloadLinkCount();
662 // While this seems silly, the payload gets reset when fetching the new download link information
670 // If there is no payload to identify, we will assume the payload is already known and just use that
703 qCDebug(KNEWSTUFFCORE) << "If there's nothing to identify, and we've arrived here, then we know what the payload is";
707 qCDebug(KNEWSTUFFCORE) << "We've got more to get before we can attempt to identify anything, so fetch the next one...";
718 qCDebug(KNEWSTUFFCORE) << "We now have all the links, so let's try and identify the correct one...";
721 const QList<EntryInternal::DownloadLinkInformation> downloadLinks = entry.downloadLinkInformationList();
730 qCDebug(KNEWSTUFFCORE) << "Next simplest option, filename is the same but in a different folder";
739 // Possibly the payload itself is named differently (by a CDN, for example), but the link identifier is the same...
740 qCDebug(KNEWSTUFFCORE) << "Possibly the payload itself is named differently (by a CDN, for example), but the link identifier is the same...";
743 qCDebug(KNEWSTUFFCORE) << "Download link" << downloadLink.name << downloadLink.id << downloadLink.size << downloadLink.descriptionLink;
747 qCDebug(KNEWSTUFFCORE) << "Found a suitable download link for" << fileName << "which should match" << identifiedLink;
752 // Least simple option, no match - ask the user to pick (and if we still haven't got one... that's us done, no installation)
753 qCDebug(KNEWSTUFFCORE) << "Least simple option, no match - ask the user to pick (and if we still haven't got one... that's us done, no installation)";
756 question->setQuestion(i18n("Please pick the item from the list below which should be used to apply this update. We were unable to identify which item to select, based on the original item, which was named %1", fileName.toString()));
768 qCWarning(KNEWSTUFFCORE) << "We failed to identify a good link for updating" << entry.name() << "and are unable to perform the update";
772 Q_EMIT signalErrorCode(ErrorCode::InstallationError, i18n("We failed to identify a good link for updating %1, and are unable to perform the update", entry.name()), {entry.uniqueId()});
797 qCDebug(KNEWSTUFFCORE) << "could not find a cached entry with following id:" << entry.uniqueId() <<
837 void Engine::slotPreviewLoaded(const KNSCore::EntryInternal &entry, EntryInternal::PreviewType type)
950 const QStringList paths = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
void setInterval(int msec)
void signalLoaded(const QDomDocument &)
Indicates that the list of providers has been successfully loaded.
void loadPreview(const KNSCore::EntryInternal &entry, EntryInternal::PreviewType type)
Attempt to load a specific preview for the specified entry.
Definition: engine.cpp:819
The configuration file is missing or somehow incorrect. The configuration file filename will be held ...
Definition: errorcode.h:29
QList< Provider::CategoryMetadata > categoriesMetadata()
The list of metadata for the categories handled by this engine instance.
Definition: engine.cpp:299
QString busyMessage() const
String representation of the engines busy state.
QString name(const QVariant &location)
virtual QString id() const =0
A unique Id for this provider (the url in most cases)
Provider::SortMode sortMode() const
The sort mode set on the current request.
Definition: engine.cpp:512
QString attribute(const QString &name, const QString &defValue) const const
ExitStatus
void setTagFilter(const QStringList &tagFilter)
Set the tag filter used for entries by this provider.
Definition: provider.cpp:73
QString toString() const const
QStringList downloadTagFilter() const
Gets the current downloadlink tag filter list.
Definition: engine.cpp:591
Installation of a content item has failed. If known, the entry's unique ID will be the metadata...
Definition: errorcode.h:31
< As Archive, except that if there is more than an item in the file, put contents in a subdirectory w...
Definition: installation.h:65
bool hasContentService() const
const T & at(int i) const const
UncompressionOptions uncompressionSetting() const
Returns the uncompression setting, in a computer-readable format.
Definition: installation.cpp:901
void checkForUpdates()
Request for packages that are installed and need update.
Definition: engine.cpp:909
Contains the core functionality for handling interaction with NewStuff providers. ...
Definition: atticaprovider.cpp:27
void insert(const QString &name, const QString &value)
bool contains(const QString &str, Qt::CaseSensitivity cs) const const
QStringList categories() const
The list of the server-side names of the categories handled by this engine instance.
Definition: engine.cpp:289
void setSearchTerm(const QString &searchString)
Sets a string search term.
Definition: engine.cpp:545
QDomElement nextSiblingElement(const QString &tagName) const const
bool userCanBecomeFan(const EntryInternal &entry)
Whether or not the user is allowed to become a fan of a particular entry.
Definition: engine.cpp:878
void setDownloadTagFilter(const QStringList &downloadTagFilter)
Set the tag filter used for download items by this provider.
Definition: provider.cpp:83
void addTagFilter(const QString &filter)
Add a single filter entry to the entry tag filter.
Definition: engine.cpp:575
QDomElement documentElement() const const
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
void setDownloadTagFilter(const QStringList &filter)
Sets a filter to be applied to the downloads for an entry.
Definition: engine.cpp:583
void fetchEntryById(const QString &id)
Convenience method to launch a search for one specific entry.
Definition: engine.cpp:531
bool hasAdoptionCommand() const
Whether or not an adoption command exists for this engine.
Definition: engine.cpp:934
void setArguments(const QStringList &arguments)
void chop(int n)
QCA_EXPORT ProviderList providers()
Q_INVOKABLE void adoptEntry(const KNSCore::EntryInternal &entry)
Adopt an entry using the adoption command.
Definition: engine.cpp:1055
ErrorCode
An enumeration of specific error conditions which might occur and which users of KNewStuff would want...
Definition: errorcode.h:25
void setBusyMessage(const QString &busyMessage)
Definition: engine.cpp:993
int size() const const
QStringList standardLocations(QStandardPaths::StandardLocation type)
void reset(T *other)
virtual bool event(QEvent *e)
Q_SIGNAL void busyStateChanged()
Signal gets emitted when the busy state changes.
void setPath(const QString &path, QUrl::ParsingMode mode)
void timeout()
void addQueryItem(const QString &key, const QString &value)
int count(const T &value) const const
QString fromLocal8Bit(const char *str, int size)
void contactAuthor(const EntryInternal &entry)
Try to contact the author of the entry by email or showing their homepage.
Definition: engine.cpp:845
Q_SIGNAL void useLabelChanged()
Signal gets emitted when the useLabel property changes.
CommentsModel * commentsForEntry(const KNSCore::EntryInternal &entry)
This function will return an instance of a model which contains comments for the entry passed to it...
Definition: engine.cpp:974
void setCategoriesFilter(const QStringList &categories)
Set the categories that will be included in searches.
Definition: engine.cpp:497
Adopting one entry has failed. The adoption command will be in the metadata as a QVariantList.
Definition: errorcode.h:33
QList< DownloadLinkInformation > downloadLinkInformationList() const
A list of downloadable data for this entry.
Definition: entryinternal.cpp:411
QChar fromLatin1(char c)
void load(const QUrl &url)
Starts asynchronously loading the xml document from the specified URL.
Definition: xmlloader.cpp:28
void addDownloadTagFilter(const QString &filter)
Add a single filter entry to the download tag filter.
Definition: engine.cpp:596
Loading an image has failed. The entry name and preview type which failed will be held in the metadat...
Definition: errorcode.h:32
bool isEmpty() const const
void setConfigLocationFallback(bool enableFallback)
Sets whether or not the config file location discovery fallback should be active. ...
Definition: engine.cpp:957
QStringList installedFiles() const
Retrieve the locally installed files.
Definition: entryinternal.cpp:391
int downloadLinkCount() const
The number of available download options for this entry.
Definition: entryinternal.cpp:406
bool isEmpty() const const
bool startsWith(const QString &s, Qt::CaseSensitivity cs) const const
void setScheme(const QString &scheme)
void finished(int exitCode)
QString searchTerm() const
The search term for the current search (empty if none is set)
Definition: engine.cpp:557
void checkForInstalled()
Requests installed packages with an up to date state.
Definition: engine.cpp:917
QSharedPointer< Provider > provider(const QString &providerId) const
The Provider instance with the passed ID.
Definition: engine.cpp:962
A model which takes care of the comments for a single EntryInternal.
Definition: core/commentsmodel.h:42
GenericDataLocation
void setStatus(KNS3::Entry::Status status)
Sets the entry's status.
Definition: entryinternal.cpp:381
KCOREADDONS_EXPORT QStringList splitArgs(const QString &cmd, Options flags=NoOptions, Errors *err=nullptr)
int indexOf(QStringView str, int from) const const
void signalMessage(const QString &message)
Indicates a message to be added to the ui's log, or sent to a messagebox.
Provider::Filter filter() const
The result filter set on the current request.
Definition: engine.cpp:526
void setFilter(Provider::Filter filter)
Set a filter for results (defaults to none), which will allow you to show only installed entries...
Definition: engine.cpp:517
void setPageSize(int pageSize)
Set the page size for requests not made explicitly with requestData(int,int)
Definition: engine.cpp:939
void setSortMode(Provider::SortMode mode)
Set the order the search results are returned in.
Definition: engine.cpp:503
Q_INVOKABLE void revalidateCacheEntries()
If the same engine gets reused and the user could have used the delete functionality of the KCMs the ...
Definition: engine.cpp:1032
QString useLabel() const
Text that should be displayed for the adoption button, this defaults to i18n("Use") ...
QString toLower() const const
void setProgram(const QString &program)
KCOREADDONS_EXPORT QString quoteArg(const QString &arg)
void signalInstallationError(const QString &message)
An informational signal fired when a serious error occurs during the installation.
void becomeFan(const EntryInternal &entry)
This will mark the user who is currently authenticated as a fan of the entry passed to the function...
Definition: engine.cpp:884
bool contains(const T &value) const const
QString targetInstallationPath() const
Definition: installation.cpp:342
void stop()
bool isNull() const const
void vote(const EntryInternal &entry, uint rating)
Cast a vote on the passed entry.
Definition: engine.cpp:872
QString adoptionCommand(const KNSCore::EntryInternal &entry) const
The adoption command can be used to allow a user to make use of an entry's installed data...
Definition: engine.cpp:928
QString i18n(const char *text, const TYPE &arg...)
void setProcessEnvironment(const QProcessEnvironment &environment)
QString cleanPath(const QString &path)
T takeLast()
bool isRelative() const const
virtual void loadEntries(const KNSCore::Provider::SearchRequest &request)=0
load the given search and return given page
KIOFILEWIDGETS_EXPORT QString dir(const QString &fileClass)
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: engine.cpp:1027
T takeFirst()
Q_SIGNAL void busyMessageChanged()
Signal gets emitted when the busy message changes.
void setBusy(BusyState state, const QString &busyMessage)
Utility method to set both the state and busyMessage.
Definition: engine.cpp:1022
QVector< QStringRef > splitRef(const QString &sep, QString::SplitBehavior behavior, Qt::CaseSensitivity cs) const const
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
QDomElement firstChildElement(const QString &tagName) const const
QSharedPointer< Provider > defaultProvider() const
Return the first provider in the providers list (usually the default provider)
Definition: engine.cpp:967
A provider has failed to load or initialize. The provider file URL or provider URL will be held in th...
Definition: errorcode.h:30
void setQuery(const QString &query, QUrl::ParsingMode mode)
void start(int msec)
void loadDetails(const KNSCore::EntryInternal &entry)
Get the full details of a specific entry.
Definition: engine.cpp:813
QStringList categoriesFilter() const
The list of categories searches will actually show results from.
Definition: engine.cpp:294
QString tagName() const const
QProcessEnvironment systemEnvironment()
FullConfig
void install(const KNSCore::EntryInternal &entry)
Installs an entry's payload file.
Definition: installation.cpp:204
KNS3::Entry::Status status() const
Retrieves the entry's status.
Definition: entryinternal.cpp:376
bool openUrl(const QUrl &url)
static QStringList configSearchLocations(bool includeFallbackLocations=false)
Get a list of all the locations which will be used when searching for knsrc files, in the order in which the search will occur.
Definition: engine.cpp:944
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
void signalErrorCode(const KNSCore::ErrorCode &errorCode, const QString &message, const QVariant &metadata)
Fires in the case of any critical or serious errors, such as network or API problems.
QUrl baseUrl() const
QString providerId() const
The id of the provider this entry belongs to.
Definition: entryinternal.cpp:138
bool userCanVote(const EntryInternal &entry)
Whether or not a user is able to vote on the passed entry.
Definition: engine.cpp:866
T readEntry(const QString &key, const T &aDefault) const
QString baseName() const const
void install(KNSCore::EntryInternal entry, int linkId=1)
Installs an entry's payload file.
Definition: engine.cpp:639
void destroyed(QObject *obj)
void start(const QString &program, const QStringList &arguments, QIODevice::OpenMode mode)
Q_EMITQ_EMIT
QByteArray readAllStandardError()
QString locate(QStandardPaths::StandardLocation type, const QString &fileName, QStandardPaths::LocateOptions options)
void setTagFilter(const QStringList &filter)
Set a filter for results, which filters out all entries which do not match the filter, as applied to the tags for the entry.
Definition: engine.cpp:562
void setSingleShot(bool singleShot)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 22:44:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Jan 19 2021 22:44:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.