KNSCore::EngineBase

Search for usage in LXR

#include <enginebase.h>

Inheritance diagram for KNSCore::EngineBase:

Public Types

enum class  ContentWarningType { Static , Executables }
 
- Public Types inherited from QObject
typedef  QObjectList
 

Properties

ContentWarningType contentWarningType
 
QStringList providerIDs
 
bool uploadEnabled
 
QString useLabel
 
- Properties inherited from QObject
 objectName
 

Signals

void loadingProvider ()
 
void providerAdded (KNSCore::ProviderCore *provider)
 
void providersChanged ()
 
void signalCategoriesMetadataLoaded (const QList< KNSCore::CategoryMetadata > &categories)
 
void signalCategoriesMetadataLoded (const QList< Provider::CategoryMetadata > &categories)
 
void signalErrorCode (KNSCore::ErrorCode::ErrorCode errorCode, const QString &message, const QVariant &metadata)
 
void signalMessage (const QString &message)
 
void signalProvidersLoaded ()
 
void signalSearchPresetsLoaded (const QList< KNSCore::SearchPreset > &presets)
 
void signalSearchPresetsLoaded (const QList< Provider::SearchPreset > &presets)
 

Public Member Functions

 EngineBase (QObject *parent=nullptr)
 
void addDownloadTagFilter (const QString &filter)
 
void addTagFilter (const QString &filter)
 
QList< Attica::Provider * > atticaProviders () const
 
void becomeFan (const Entry &entry)
 
QSharedPointer< Cache > cache () const
 
QStringList categories () const
 
QList< Provider::CategoryMetadatacategoriesMetadata ()
 
QList< CategoryMetadatacategoriesMetadata2 ()
 
ContentWarningType contentWarningType () const
 
Q_SIGNAL void contentWarningTypeChanged ()
 
QSharedPointer< ProviderdefaultProvider () const
 
QStringList downloadTagFilter () const
 
bool hasAdoptionCommand () const
 
virtual bool init (const QString &configfile)
 
QString name () const
 
QSharedPointer< Providerprovider (const QString &providerId) const
 
QStringList providerIDs () const
 
ResultsStreamsearch (const KNSCore::Provider::SearchRequest &request)
 
ResultsStreamsearch (const KNSCore::SearchRequest &request)
 
QList< Provider::SearchPresetsearchPresets ()
 
QList< SearchPresetsearchPresets2 ()
 
void setDownloadTagFilter (const QStringList &filter)
 
void setTagFilter (const QStringList &filter)
 
QStringList tagFilter () const
 
bool uploadEnabled () const
 
Q_SIGNAL void uploadEnabledChanged ()
 
QString useLabel () const
 
Q_SIGNAL void useLabelChanged ()
 
bool userCanBecomeFan (const Entry &entry)
 
bool userCanVote (const Entry &entry)
 
void vote (const Entry &entry, uint rating)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Static Public Member Functions

static QStringList availableConfigFiles ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Protected Member Functions

virtual void addProvider (QSharedPointer< KNSCore::Provider > provider)
 
Installation * installation () const
 
QList< QSharedPointer< Provider > > providers () const
 
virtual void updateStatus ()
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Protected Attributes

std::unique_ptr< EngineBasePrivate > d
 

Detailed Description

KNewStuff engine.

An engine keeps track of data which is available locally and remote and offers high-level synchronization calls as well as upload and download primitives using an underlying GHNS protocol.

This is a base class for different engine implementations

Definition at line 55 of file enginebase.h.

Member Enumeration Documentation

◆ ContentWarningType

The ContentWarningType enum.

Since
6.1
Enumerator
Static 

Content consists of static assets only Installation should not pose a security risk.

Executables 

Content may contain scripts or other executable code Users should be warned to treat it like any other program.

Definition at line 387 of file enginebase.h.

Property Documentation

◆ contentWarningType

ContentWarningType KNSCore::EngineBase::contentWarningType
read

Definition at line 81 of file enginebase.h.

◆ providerIDs

QStringList KNSCore::EngineBase::providerIDs
read
Since
5.85

Definition at line 76 of file enginebase.h.

◆ uploadEnabled

bool KNSCore::EngineBase::uploadEnabled
read

Whether or not the configuration says that the providers are expected to support uploading.

As it stands, this is used to determine whether or not to show the Upload... action where that is displayed (primarily NewStuff.Page).

Since
5.85

Definition at line 71 of file enginebase.h.

◆ useLabel

QString KNSCore::EngineBase::useLabel
read

Text that should be displayed for the adoption button, this defaults to "Use".

Since
5.77

Definition at line 63 of file enginebase.h.

Constructor & Destructor Documentation

◆ EngineBase()

EngineBase::EngineBase ( QObject * parent = nullptr)

Definition at line 93 of file enginebase.cpp.

◆ ~EngineBase()

EngineBase::~EngineBase ( )
override

Definition at line 112 of file enginebase.cpp.

Member Function Documentation

◆ addDownloadTagFilter()

void EngineBase::addDownloadTagFilter ( const QString & filter)

Add a single filter entry to the download tag filter.

The filter should be in the same form as the filter lines in the list used by setDownloadsTagFilter(QStringList)

Parameters
filterThe filter in the form of a string
See also
setTagFilter(QStringList)
setDownloadTagFilter(QStringList)
Since
5.51

Definition at line 461 of file enginebase.cpp.

◆ addProvider()

void EngineBase::addProvider ( QSharedPointer< KNSCore::Provider > provider)
protectedvirtual

Add a provider and connect it to the right slots.

Deprecated
since 6.9 Use providerAdded signal

Definition at line 339 of file enginebase.cpp.

◆ addTagFilter()

void KNSCore::EngineBase::addTagFilter ( const QString & filter)

Add a single filter entry to the entry tag filter.

The filter should be in the same form as the filter lines in the list used by setTagFilter(QStringList)

Parameters
filterThe filter in the form of a string
See also
setTagFilter(QStringList)
Since
5.51

Definition at line 440 of file enginebase.cpp.

◆ atticaProviders()

QList< Attica::Provider * > EngineBase::atticaProviders ( ) const
Returns
the list of attica (OCS) providers this engine is connected to
Since
5.92

Definition at line 469 of file enginebase.cpp.

◆ availableConfigFiles()

QStringList EngineBase::availableConfigFiles ( )
static

List of all available config files.

This list will contain no duplicated filenames. The returned file paths are absolute.

Since
5.83

Definition at line 102 of file enginebase.cpp.

◆ becomeFan()

void EngineBase::becomeFan ( const Entry & entry)

This will mark the user who is currently authenticated as a fan of the entry passed to the function.

Parameters
entryThe entry the user wants to be a fan of

Definition at line 500 of file enginebase.cpp.

◆ cache()

QSharedPointer< Cache > EngineBase::cache ( ) const

Get the entries cache for this engine (note that it may be null if the engine is not yet initialized).

Returns
The cache for this engine (or null if the engine is not initialized)
Since
5.74
Deprecated
since 6.9 Do not use the cache directly

Definition at line 421 of file enginebase.cpp.

◆ categories()

QStringList EngineBase::categories ( ) const

The list of the server-side names of the categories handled by this engine instance.

This corresponds directly to the list of categories in your knsrc file. This is not supposed to be used as user-facing strings -

See also
categoriesMetadata() for that.
Returns
The categories which this instance of Engine handles

Definition at line 286 of file enginebase.cpp.

◆ categoriesMetadata()

QList< Provider::CategoryMetadata > EngineBase::categoriesMetadata ( )
Deprecated
since 6.9 use categoriesMetadata2

Definition at line 292 of file enginebase.cpp.

◆ categoriesMetadata2()

QList< CategoryMetadata > EngineBase::categoriesMetadata2 ( )

The list of metadata for the categories handled by this engine instance.

If you wish to show the categories to the user, this is the data to use. The category name is the string used to set categories for the filter, and also what is returned by both categories() and categoriesFilter(). The human-readable name is displayName, and the only thing which should be shown to the user.

Returns
The metadata for all categories handled by this engine

Definition at line 302 of file enginebase.cpp.

◆ contentWarningType()

EngineBase::ContentWarningType EngineBase::contentWarningType ( ) const

The level of warning that should be presented to the user.

Since
6.1
See also
ContentWarningType

Definition at line 549 of file enginebase.cpp.

◆ contentWarningTypeChanged()

Q_SIGNAL void KNSCore::EngineBase::contentWarningTypeChanged ( )

Emitted after the initial config load.

Since
6.1

◆ defaultProvider()

QSharedPointer< Provider > EngineBase::defaultProvider ( ) const

Return the first provider in the providers list (usually the default provider)

Returns
The first Provider (or null if the engine is not initialized)
Since
5.63
Deprecated
since 6.9 Do not write provider-specific code

Definition at line 514 of file enginebase.cpp.

◆ downloadTagFilter()

QStringList EngineBase::downloadTagFilter ( ) const

Gets the current downloadlink tag filter list.

See also
setDownloadTagFilter(QStringList)
Since
5.51

Definition at line 456 of file enginebase.cpp.

◆ hasAdoptionCommand()

bool EngineBase::hasAdoptionCommand ( ) const

Whether or not an adoption command exists for this engine.

See also
adoptionCommand(KNSCore::Entry)
Returns
True if an adoption command exists

Definition at line 528 of file enginebase.cpp.

◆ init()

bool EngineBase::init ( const QString & configfile)
virtual

Initializes the engine.

This step is application-specific and relies on an external configuration file, which determines all the details about the initialization.

Parameters
configfileKNewStuff2 configuration file (*.knsrc)
Returns
true if any valid configuration was found, false otherwise
See also
KNS3::DownloadDialog

Definition at line 121 of file enginebase.cpp.

◆ installation()

Installation * EngineBase::installation ( ) const
protected

Definition at line 537 of file enginebase.cpp.

◆ name()

QString KNSCore::EngineBase::name ( ) const

The name as defined by the knsrc file.

Returns
The name associated with the engine's configuration file
Since
5.63

Definition at line 281 of file enginebase.cpp.

◆ provider()

QSharedPointer< Provider > EngineBase::provider ( const QString & providerId) const

The Provider instance with the passed ID.

Parameters
providerIdThe ID of the Provider to fetch
Returns
The Provider with the passed ID, or null if non such Provider exists
Since
5.63
Deprecated
since 6.9 Do not write provider-specific code

Definition at line 507 of file enginebase.cpp.

◆ providerIDs()

QStringList EngineBase::providerIDs ( ) const

The IDs of all providers known by this engine.

Use this in combination with provider(const QString&) to iterate over all providers.

Returns
The string IDs of all known providers
Since
5.85

Definition at line 523 of file enginebase.cpp.

◆ providers()

QList< QSharedPointer< Provider > > EngineBase::providers ( ) const
protected
Deprecated
since 6.9 Do not write provider-specific code

Definition at line 555 of file enginebase.cpp.

◆ providersChanged

void KNSCore::EngineBase::providersChanged ( )
signal

Fired whenever the list of providers changes.

Since
5.85
Deprecated
since 6.9 Use providerAdded signal

◆ search() [1/2]

ResultsStream * EngineBase::search ( const KNSCore::Provider::SearchRequest & request)

Returns a stream object that will fulfill the request.

Since
6.0
Deprecated
since 6.9 Use the new search function

Definition at line 543 of file enginebase.cpp.

◆ search() [2/2]

KNSCore::ResultsStream * KNSCore::EngineBase::search ( const KNSCore::SearchRequest & request)

Returns a stream object that will fulfill the request.

Since
6.9

Definition at line 561 of file enginebase.cpp.

◆ searchPresets()

QList< Provider::SearchPreset > EngineBase::searchPresets ( )
Deprecated
since 6.9 use searchPresets2

Definition at line 308 of file enginebase.cpp.

◆ searchPresets2()

QList< SearchPreset > EngineBase::searchPresets2 ( )
Since
6.9

Definition at line 323 of file enginebase.cpp.

◆ setDownloadTagFilter()

void EngineBase::setDownloadTagFilter ( const QStringList & filter)

Sets a filter to be applied to the downloads for an entry.

The logic is the same as used in setTagFilter(QStringList), but vitally, only one downloadlink is required to match the filter for the list to be valid. If you do not wish to show the others in your client, you must hide them yourself.

For an entry to be accepted when a download tag filter is set, it must also be accepted by the entry filter (so, for example, while a list of downloads might be accepted, if the entry has ghns_excluded set, and the default entry filter is set, the entry will still be filtered out).

In your knsrc file, set DownloadTagFilter to the filter you wish to apply, using the same logic as described for the entry tagfilter.

Parameters
filterThe filter in the form of a list of strings
See also
setTagFilter(QStringList)
Since
5.51

Definition at line 448 of file enginebase.cpp.

◆ setTagFilter()

void EngineBase::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.

This filters only on the tags specified for the entry itself. To filter the downloadlinks, use setDownloadTagFilter(QStringList).

Note
The default filter if one is not set from your knsrc file will filter out entries marked as ghns_excluded=1. To retain this when setting a custom filter, add "ghns_excluded!=1" as one of the filters.
Some tags provided by OCS do not supply a value (and are simply passed as a key). These will be interpreted as having the value 1 for filtering purposes. An example of this might be ghns_excluded, which in reality will generally be passed through ocs as "ghns_excluded" rather than "ghns_excluded=1"
As tags are metadata, they are provided in the form of adjectives. They are never supplied as action verbs or instructions (as an example, a good tag to suggest that for example a wallpaper is painted would be "painted" as opposed to "paint", and another example might be that an item should be "excluded" as opposed to "exclude").

== Examples of use == Value for tag "tagname" must be exactly "tagdata": tagname==tagdata

Value for tag "tagname" must be different from "tagdata": tagname!=tagdata

== KNSRC entry == A tag filter line in a .knsrc file, which is a comma separated list of tag/value pairs, might look like:

TagFilter=ghns_excluded!=1,data##mimetype==application/cbr+zip,data##mimetype==application/cbr+rar which would honour the exclusion and filter out anything that does not include a comic book archive in either zip or rar format in one or more of the download items. Notice in particular that there are two data##mimetype entries. Use this for when a tag may have multiple values.

TagFilter=application##architecture==x86_64 which would not honour the exclusion, and would filter out all entries which do not mark themselves as having a 64bit application binary in at least one download item.

The value does not current support wildcards. The list should be considered a binary AND operation (that is, all filter entries must match for the data entry to be included in the return data)

Parameters
filterThe filter in the form of a list of strings
See also
setDownloadTagFilter(QStringList)
Since
5.51

Definition at line 427 of file enginebase.cpp.

◆ signalCategoriesMetadataLoded

void KNSCore::EngineBase::signalCategoriesMetadataLoded ( const QList< Provider::CategoryMetadata > & categories)
signal
Deprecated
since 6.9 Use variant with new argument type

◆ signalErrorCode

void KNSCore::EngineBase::signalErrorCode ( KNSCore::ErrorCode::ErrorCode errorCode,
const QString & message,
const QVariant & metadata )
signal

Fires in the case of any critical or serious errors, such as network or API problems.

Parameters
errorCodeRepresents the specific type of error which has occurred
messageA human-readable message which can be shown to the end user
metadataAny additional data which might be helpful to further work out the details of the error (see KNSCore::Entry::ErrorCode for the metadata details)
See also
KNSCore::Entry::ErrorCode
Since
5.53

◆ signalMessage

void KNSCore::EngineBase::signalMessage ( const QString & message)
signal

Indicates a message to be added to the ui's log, or sent to a messagebox.

◆ signalSearchPresetsLoaded [1/2]

void KNSCore::EngineBase::signalSearchPresetsLoaded ( const QList< KNSCore::SearchPreset > & presets)
signal

Fires when the engine has loaded search presets.

These represent interesting searches for the user, such as recommendations.

Since
6.9

◆ signalSearchPresetsLoaded [2/2]

void KNSCore::EngineBase::signalSearchPresetsLoaded ( const QList< Provider::SearchPreset > & presets)
signal

Fires when the engine has loaded search presets.

These represent interesting searches for the user, such as recommendations.

Since
5.83
Deprecated
since 6.9 Use variant with new argument type

◆ tagFilter()

QStringList EngineBase::tagFilter ( ) const

Gets the current tag filter list.

See also
setTagFilter(QStringList)
Since
5.51

Definition at line 435 of file enginebase.cpp.

◆ updateStatus()

void EngineBase::updateStatus ( )
protectedvirtual

Definition at line 533 of file enginebase.cpp.

◆ uploadEnabled()

bool EngineBase::uploadEnabled ( ) const

Whether or not the configuration says that the providers are expected to support uploading.

Returns
True if the providers are expected to support uploading
Since
5.85

Definition at line 333 of file enginebase.cpp.

◆ uploadEnabledChanged()

Q_SIGNAL void KNSCore::EngineBase::uploadEnabledChanged ( )

Fired when the uploadEnabled property changes.

Since
5.85

◆ useLabel()

QString EngineBase::useLabel ( ) const

Text that should be displayed for the adoption button, this defaults to i18n("Use")

Since
5.77

Definition at line 328 of file enginebase.cpp.

◆ useLabelChanged()

Q_SIGNAL void KNSCore::EngineBase::useLabelChanged ( )

Signal gets emitted when the useLabel property changes.

Since
5.77

◆ userCanBecomeFan()

bool EngineBase::userCanBecomeFan ( const Entry & entry)

Whether or not the user is allowed to become a fan of a particular entry.

Not all providers (and consequently entries) support the fan functionality and you can use this function to determine this ability.

Parameters
entryThe entry the user might wish to be a fan of
Returns
Whether or not it is possible for the user to become a fan of that entry

Definition at line 494 of file enginebase.cpp.

◆ userCanVote()

bool EngineBase::userCanVote ( const Entry & entry)

Whether or not a user is able to vote on the passed entry.

Parameters
entryThe entry to check votability on
Returns
True if the user is able to vote on the entry

Definition at line 482 of file enginebase.cpp.

◆ vote()

void EngineBase::vote ( const Entry & entry,
uint rating )

Cast a vote on the passed entry.

Parameters
entryThe entry to vote on
ratingA number from 0 to 100, 50 being neutral, 0 being most negative and 100 being most positive.

Definition at line 488 of file enginebase.cpp.

Member Data Documentation

◆ d

std::unique_ptr<EngineBasePrivate> KNSCore::EngineBase::d
protected

Definition at line 511 of file enginebase.h.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:07:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.