KNewStuff

engine.h
1 /*
2  knewstuff3/engine.h.
3  SPDX-FileCopyrightText: 2007 Josef Spillner <[email protected]>
4  SPDX-FileCopyrightText: 2007-2010 Frederik Gladhorn <[email protected]>
5  SPDX-FileCopyrightText: 2009 Jeremy Whiting <[email protected]>
6 
7  SPDX-License-Identifier: LGPL-2.1-or-later
8 */
9 
10 #ifndef KNEWSTUFF3_ENGINE_P_H
11 #define KNEWSTUFF3_ENGINE_P_H
12 
13 #include <QHash>
14 #include <QObject>
15 #include <QSharedPointer>
16 #include <QString>
17 
18 #include "entryinternal.h"
19 #include "errorcode.h"
20 #include "provider.h"
21 
22 #include "knewstuffcore_export.h"
23 
24 class QTimer;
25 class KJob;
26 class EnginePrivate;
27 
28 namespace Attica
29 {
30 class Provider;
31 }
32 
33 /**
34  * Contains the core functionality for handling interaction with NewStuff providers.
35  * The entrypoint for most things will be the creation of an instance of KNSCore::Engine
36  * which will other classes then either use or get instantiated from directly.
37  *
38  * NOTE: When implementing anything on top of KNSCore, without using either KNS3 or the
39  * Qt Quick components, you will need to implement a custom QuestionListener (see that
40  * class for instructions)
41  *
42  * @see KNSCore::Engine
43  * @see KNSCore::ItemsModel
44  * @see KNSCore::QuestionListener
45  */
46 namespace KNSCore
47 {
48 class Cache;
49 class CommentsModel;
50 class Installation;
51 
52 /**
53  * KNewStuff engine.
54  * An engine keeps track of data which is available locally and remote
55  * and offers high-level synchronization calls as well as upload and download
56  * primitives using an underlying GHNS protocol.
57  */
58 class KNEWSTUFFCORE_EXPORT Engine : public QObject
59 {
60  Q_OBJECT
61 
62  /**
63  * Current state of the engine, the state con contain multiple operations
64  * an empty BusyState represents the idle status
65  * @since 5.74
66  */
67  Q_PROPERTY(BusyState busyState READ busyState WRITE setBusyState NOTIFY busyStateChanged)
68 
69  /**
70  * String representation of the engines busy state, in the case of idle this string is empty
71  * @since 5.74
72  */
73  Q_PROPERTY(QString busyMessage READ busyMessage WRITE setBusyMessage NOTIFY busyMessageChanged)
74 
75  /**
76  * Text that should be displayed for the adoption button, this defaults to "Use"
77  * @since 5.77
78  */
79  Q_PROPERTY(QString useLabel READ useLabel NOTIFY useLabelChanged)
80 
81  /**
82  * Whether or not the configuration says that the providers are expected to support uploading.
83  * As it stands, this is used to determine whether or not to show the Upload... action where
84  * that is displayed (primarily NewStuff.Page).
85  * @since 5.85
86  */
87  Q_PROPERTY(bool uploadEnabled READ uploadEnabled NOTIFY uploadEnabledChanged)
88 
89  /**
90  * @since 5.85
91  */
92  Q_PROPERTY(QStringList providerIDs READ providerIDs NOTIFY providersChanged)
93 public:
94  /**
95  * Constructor.
96  */
97  explicit Engine(QObject *parent = nullptr);
98 
99  /**
100  * Destructor. Frees up all the memory again which might be taken
101  * by cached entries and providers.
102  */
103  ~Engine() override;
104 
105  enum class BusyOperation {
106  Initializing,
107  LoadingData,
108  LoadingPreview,
109  InstallingEntry,
110  };
111  Q_DECLARE_FLAGS(BusyState, BusyOperation)
112 
113  /**
114  * Initializes the engine. This step is application-specific and relies
115  * on an external configuration file, which determines all the details
116  * about the initialization.
117  *
118  * @param configfile KNewStuff2 configuration file (*.knsrc)
119  * @return \b true if any valid configuration was found, \b false otherwise
120  * @see KNS3::DownloadDialog
121  */
122  bool init(const QString &configfile);
123 
124  /**
125  * The name as defined by the knsrc file
126  * @return The name associated with the engine's configuration file
127  * @since 5.63
128  */
129  QString name() const;
130 
131  /**
132  * Installs an entry's payload file. This includes verification, if
133  * necessary, as well as decompression and other steps according to the
134  * application's *.knsrc file.
135  *
136  * @param entry Entry to be installed
137  *
138  * @see signalInstallationFinished
139  * @see signalInstallationFailed
140  */
141  void install(KNSCore::EntryInternal entry, int linkId = 1);
142 
143  /**
144  * Uninstalls an entry. It reverses the steps which were performed
145  * during the installation.
146  *
147  * @param entry The entry to deinstall
148  */
149  void uninstall(KNSCore::EntryInternal entry);
150 
151  /**
152  * Attempt to load a specific preview for the specified entry.
153  *
154  * @param entry The entry to fetch a preview for
155  * @param type The particular preview to fetch
156  *
157  * @see signalEntryPreviewLoaded(KNSCore::EntryInternal, KNSCore::EntryInternal::PreviewType);
158  * @see signalPreviewFailed();
159  */
160  void loadPreview(const KNSCore::EntryInternal &entry, EntryInternal::PreviewType type);
161  /**
162  * Get the full details of a specific entry
163  *
164  * @param entry The entry to get full details for
165  *
166  * @see Entry::signalEntryDetailsLoaded(KNSCore::EntryInternal)
167  */
168  void loadDetails(const KNSCore::EntryInternal &entry);
169 
170  /**
171  * Set the order the search results are returned in.
172  *
173  * Search requests default to showing the newest entries first.
174  *
175  * Note: This will automatically launch a search, which means
176  * you do not need to call requestData manually.
177  *
178  * @see KNSCore::Provider::SearchRequest
179  * @param mode The order you want search results to come back in.
180  */
181  void setSortMode(Provider::SortMode mode);
182  /**
183  * The sort mode set on the current request
184  * @see setSortMode(Provider::SortMode)
185  * @since 5.63
186  */
187  Provider::SortMode sortMode() const;
188  /**
189  * Set a filter for results (defaults to none), which will allow you
190  * to show only installed entries, installed entries which have updates,
191  * or a specific item with a specified ID. The latter further requires
192  * the search term to be the exact ID of the entry you wish to retrieve.
193  *
194  * Note: This will automatically launch a search, which means
195  * you do not need to call requestData manually.
196  *
197  * @see fetchEntryById(QString)
198  * @see setSearchTerm(QString)
199  * @param filter The type of results you wish to see
200  */
201  void setFilter(Provider::Filter filter);
202  /**
203  * The result filter set on the current request
204  * @see setFilter(Provider::Filter)
205  * @since 5.63
206  */
207  Provider::Filter filter() const;
208 
209  /**
210  * Set the categories that will be included in searches
211  *
212  * Note: This will automatically launch a search, which means
213  * you do not need to call requestData manually.
214  *
215  * @see KNSCore::Engine::categories()
216  * @param categories A list of strings of categories
217  */
218  void setCategoriesFilter(const QStringList &categories);
219  /**
220  * Sets a string search term.
221  *
222  * Note: This will automatically launch a search, which means
223  * you do not need to call requestData manually.
224  *
225  * @param searchString The search term you wish to search for
226  */
227  void setSearchTerm(const QString &searchString);
228  /**
229  * The search term for the current search (empty if none is set)
230  * @return The current search term
231  * @since 5.63
232  */
233  QString searchTerm() const;
234  void reloadEntries();
235  void requestMoreData();
236  void requestData(int page, int pageSize);
237 
238  /**
239  * Set a filter for results, which filters out all entries which do not match
240  * the filter, as applied to the tags for the entry. This filters only on the
241  * tags specified for the entry itself. To filter the downloadlinks, use
242  * setDownloadTagFilter(QStringList).
243  *
244  * @note The default filter if one is not set from your knsrc file will filter
245  * out entries marked as ghns_excluded=1. To retain this when setting a custom
246  * filter, add "ghns_excluded!=1" as one of the filters.
247  *
248  * @note Some tags provided by OCS do not supply a value (and are simply passed
249  * as a key). These will be interpreted as having the value 1 for filtering
250  * purposes. An example of this might be ghns_excluded, which in reality will
251  * generally be passed through ocs as "ghns_excluded" rather than "ghns_excluded=1"
252  *
253  * @note As tags are metadata, they are provided in the form of adjectives. They
254  * are never supplied as action verbs or instructions (as an example, a good tag
255  * to suggest that for example a wallpaper is painted would be "painted" as opposed
256  * to "paint", and another example might be that an item should be "excluded" as
257  * opposed to "exclude").
258  *
259  * == Examples of use ==
260  * Value for tag "tagname" must be exactly "tagdata":
261  * tagname==tagdata
262  *
263  * Value for tag "tagname" must be different from "tagdata":
264  * tagname!=tagdata
265  *
266  * == KNSRC entry ==
267  * A tag filter line in a .knsrc file, which is a comma separated list of
268  * tag/value pairs, might look like:
269  *
270  * TagFilter=ghns_excluded!=1,data##mimetype==application/cbr+zip,data##mimetype==application/cbr+rar
271  * which would honour the exclusion and filter out anything that does not
272  * include a comic book archive in either zip or rar format in one or more
273  * of the download items.
274  * Notice in particular that there are two data##mimetype entries. Use this
275  * for when a tag may have multiple values.
276  *
277  * TagFilter=application##architecture==x86_64
278  * which would not honour the exclusion, and would filter out all entries
279  * which do not mark themselves as having a 64bit application binary in at
280  * least one download item.
281  *
282  * The value does not current support wildcards. The list should be considered
283  * a binary AND operation (that is, all filter entries must match for the data
284  * entry to be included in the return data)
285  *
286  * @param filter The filter in the form of a list of strings
287  * @see setDownloadTagFilter(QStringList)
288  * @since 5.51
289  */
290  void setTagFilter(const QStringList &filter);
291  /**
292  * Gets the current tag filter list
293  * @see setTagFilter(QStringList)
294  * @since 5.51
295  */
296  QStringList tagFilter() const;
297  /**
298  * Add a single filter entry to the entry tag filter. The filter should be in
299  * the same form as the filter lines in the list used by setTagFilter(QStringList)
300  * @param filter The filter in the form of a string
301  * @see setTagFilter(QStringList)
302  * @since 5.51
303  */
304  void addTagFilter(const QString &filter);
305  /**
306  * Sets a filter to be applied to the downloads for an entry. The logic is the
307  * same as used in setTagFilter(QStringList), but vitally, only one downloadlink
308  * is required to match the filter for the list to be valid. If you do not wish
309  * to show the others in your client, you must hide them yourself.
310  *
311  * For an entry to be accepted when a download tag filter is set, it must also
312  * be accepted by the entry filter (so, for example, while a list of downloads
313  * might be accepted, if the entry has ghns_excluded set, and the default entry
314  * filter is set, the entry will still be filtered out).
315  *
316  * In your knsrc file, set DownloadTagFilter to the filter you wish to apply,
317  * using the same logic as described for the entry tagfilter.
318  *
319  * @param filter The filter in the form of a list of strings
320  * @see setTagFilter(QStringList)
321  * @since 5.51
322  */
323  void setDownloadTagFilter(const QStringList &filter);
324  /**
325  * Gets the current downloadlink tag filter list
326  * @see setDownloadTagFilter(QStringList)
327  * @since 5.51
328  */
329  QStringList downloadTagFilter() const;
330  /**
331  * Add a single filter entry to the download tag filter. The filter should be in
332  * the same form as the filter lines in the list used by setDownloadsTagFilter(QStringList)
333  * @param filter The filter in the form of a string
334  * @see setTagFilter(QStringList)
335  * @see setDownloadTagFilter(QStringList)
336  * @since 5.51
337  */
338  void addDownloadTagFilter(const QString &filter);
339 
340  /**
341  * Request for packages that are installed and need update
342  *
343  * These will be reported through the signal @see signalUpdateableEntriesLoaded().
344  */
345  void checkForUpdates();
346 
347  /**
348  * Requests installed packages with an up to date state
349  *
350  * @see signalEntriesLoaded()
351  */
352  void checkForInstalled();
353 
354  /**
355  * Convenience method to launch a search for one specific entry.
356  *
357  * @note it will reset the engine state (use storeSearch() and restoreSearch() to handle this if needed)
358  *
359  * @param id The ID of the entry you wish to fetch
360  */
361  Q_INVOKABLE void fetchEntryById(const QString &id);
362 
363  /**
364  * Restore a previously saved search to be current
365  * Also emits the appropriate signals so any views depending
366  * on the information can be updated)
367  *
368  * @since 5.79
369  */
370  Q_INVOKABLE void restoreSearch();
371 
372  /**
373  * Stores the current search parameters internally
374  * This might for example be used to allow you to restore the current view state
375  * after performing a single-entry fetch with fetchEntryById(QString). That function
376  * does not perform this action itself, because it may well not be the desired
377  * outcome.
378  *
379  * @since 5.79
380  */
381  Q_INVOKABLE void storeSearch();
382 
383  /**
384  * Try to contact the author of the entry by email or showing their homepage.
385  */
386  void contactAuthor(const EntryInternal &entry);
387 
388  /**
389  * Whether or not a user is able to vote on the passed entry.
390  *
391  * @param entry The entry to check votability on
392  * @return True if the user is able to vote on the entry
393  */
394  bool userCanVote(const EntryInternal &entry);
395  /**
396  * Cast a vote on the passed entry.
397  *
398  * @param entry The entry to vote on
399  * @param rating A number from 0 to 100, 50 being neutral, 0 being most negative and 100 being most positive.
400  */
401  void vote(const EntryInternal &entry, uint rating);
402 
403  /**
404  * Whether or not the user is allowed to become a fan of
405  * a particular entry.
406  * Not all providers (and consequently entries) support the fan functionality
407  * and you can use this function to determine this ability.
408  * @param entry The entry the user might wish to be a fan of
409  * @return Whether or not it is possible for the user to become a fan of that entry
410  */
411  bool userCanBecomeFan(const EntryInternal &entry);
412  /**
413  * This will mark the user who is currently authenticated as a fan
414  * of the entry passed to the function.
415  * @param entry The entry the user wants to be a fan of
416  */
417  void becomeFan(const EntryInternal &entry);
418  // FIXME There is currently no exposed API to remove the fan status
419 
420  /**
421  * The list of the server-side names of the categories handled by this
422  * engine instance. This corresponds directly to the list of categories
423  * in your knsrc file. This is not supposed to be used as user-facing
424  * strings - @see categoriesMetadata() for that.
425  *
426  * @return The categories which this instance of Engine handles
427  */
428  QStringList categories() const;
429  /**
430  * The list of categories searches will actually show results from. This
431  * is a subset of the categories() list.
432  *
433  * @see KNSCore::Engine::setCategoriesFilter(QString)
434  */
435  QStringList categoriesFilter() const;
436 
437  /**
438  * The list of metadata for the categories handled by this engine instance.
439  * If you wish to show the categories to the user, this is the data to use.
440  * The category name is the string used to set categories for the filter,
441  * and also what is returned by both categories() and categoriesFilter().
442  * The human-readable name is displayName, and the only thing which should
443  * be shown to the user.
444  *
445  * @return The metadata for all categories handled by this engine
446  */
447  QList<Provider::CategoryMetadata> categoriesMetadata();
448 
449  QList<Provider::SearchPreset> searchPresets();
450 
451 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 77)
452  /**
453  * The adoption command can be used to allow a user to make use of an entry's
454  * installed data. For example, this command might be used to ask the system to
455  * switch to a wallpaper or icon theme which was installed with KNS.
456  *
457  * The following is how this might look in a knsrc file. The example shows how
458  * an external tool is called on the directory containing the installed file
459  * represented by %d. If you wish to directly point to the installed file, the
460  * substitution variable is %f.
461  * <pre>
462  AdoptionCommand=/usr/lib64/libexec/plasma-changeicons %d
463  * </pre>
464  *
465  * @param entry The entry to return an adoption command for
466  * @return The command to run to adopt this entry's installed data
467  * @deprecated Since 5.77, use Engine::adoptEntry(const KNSCore::EntryInternal &entry) instead
468  */
469  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 77, "Use Engine::adoptEntry(const KNSCore::EntryInternal &entry) instead")
470  QString adoptionCommand(const KNSCore::EntryInternal &entry) const;
471 #endif
472 
473  /**
474  * Whether or not an adoption command exists for this engine
475  *
476  * @see adoptionCommand(KNSCore::EntryInternal)
477  * @return True if an adoption command exists
478  */
479  bool hasAdoptionCommand() const;
480 
481  /**
482  * Adopt an entry using the adoption command. This will also take care of displaying error messages
483  * @param entry Entry that should be adopted
484  * @see signalErrorCode
485  * @see signalEntryEvent
486  * @since 5.77
487  */
488  Q_INVOKABLE void adoptEntry(const KNSCore::EntryInternal &entry);
489 
490  /**
491  * Text that should be displayed for the adoption button, this defaults to i18n("Use")
492  * @since 5.77
493  */
494  QString useLabel() const;
495 
496  /**
497  * Signal gets emitted when the useLabel property changes
498  * @since 5.77
499  */
500  Q_SIGNAL void useLabelChanged();
501 
502  /**
503  * Set the page size for requests not made explicitly with requestData(int,int)
504  * @param pageSize the default number of entries to request from the provider
505  * @see requestData(int,int)
506  */
507  void setPageSize(int pageSize);
508 
509 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 83)
510  /**
511  * Get a list of all the locations which will be used when searching for knsrc
512  * files, in the order in which the search will occur.
513  *
514  * @param includeFallbackLocations Whether or not the deprecated search locations are included
515  * @return The search list for knsrc files
516  * @since 5.57
517  * @deprecated Since 5.83, use Engine::availableConfigFiles instead
518  */
519  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 83, "Use Engine::availableConfigFiles instead")
520  static QStringList configSearchLocations(bool includeFallbackLocations = false);
521 #endif
522 
523 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 83)
524  /**
525  * Sets whether or not the config file location discovery fallback should be active.
526  * If enabled (default), if the config file is not found in the knsrcfiles location,
527  * then the engine will also look in the systemwide config location (usually /etc/xdg
528  * on linux). If disabled, this fallback location will not be searched.
529  *
530  * @param enableFallback Whether or not the fallback discovery should be enabled
531  * @since 5.57
532  * @deprecated Since 5.83, the engine includes the fallback paths by default
533  */
534  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 83, "The engine includes the fallback paths by default")
535  void setConfigLocationFallback(bool enableFallback);
536 #endif
537 
538  /**
539  * List of all available config files. This list will contain no duplicated filenames.
540  * The returned file paths are absolute.
541  * @since 5.83
542  */
543  static QStringList availableConfigFiles();
544 
545  /**
546  * The Provider instance with the passed ID
547  *
548  * @param providerId The ID of the Provider to fetch
549  * @return The Provider with the passed ID, or null if non such Provider exists
550  * @since 5.63
551  */
552  QSharedPointer<Provider> provider(const QString &providerId) const;
553 
554  /**
555  * Return the first provider in the providers list (usually the default provider)
556  * @return The first Provider (or null if the engine is not initialized)
557  * @since 5.63
558  */
560 
561  /**
562  * The IDs of all providers known by this engine. Use this in combination with
563  * provider(const QString&) to iterate over all providers.
564  * @return The string IDs of all known providers
565  * @since 5.85
566  */
567  QStringList providerIDs() const;
568 
569  /**
570  * Fired whenever the list of providers changes
571  * @since 5.85
572  */
573  Q_SIGNAL void providersChanged();
574 
575  /**
576  * This function will return an instance of a model which contains comments for
577  * the entry passed to it. The model may be empty (if there are no comments for
578  * the entry, which also covers situations where the entry's provider does not
579  * support commenting)
580  *
581  * @param entry The entry to fetch comments for
582  * @return A model which contains the comments for the specified entry
583  * @since 5.63
584  */
585  CommentsModel *commentsForEntry(const KNSCore::EntryInternal &entry);
586 
587  /**
588  * String representation of the engines busy state
589  * @since 5.74
590  */
591  QString busyMessage() const;
592 
593  /**
594  * @since 5.74
595  * @see setBusy
596  * @see setBusyState
597  */
598  void setBusyMessage(const QString &busyMessage);
599 
600  /**
601  * Signal gets emitted when the busy message changes
602  * @since 5.74 String representation of the engines busy state
603  */
604  Q_SIGNAL void busyMessageChanged();
605 
606  /**
607  * Busy state of the engine
608  * @since 5.74
609  */
610  BusyState busyState() const;
611 
612  /**
613  * Sets the busy state of the engine
614  * @since 5.74
615  * @see setBusy
616  * @see setBusyMessage
617  */
618  void setBusyState(BusyState state);
619 
620  /**
621  * Signal gets emitted when the busy state changes
622  * @since 5.74
623  */
624  Q_SIGNAL void busyStateChanged();
625 
626  /**
627  * Utility method to set both the state and busyMessage
628  * @since 5.74
629  */
630  void setBusy(BusyState state, const QString &busyMessage);
631 
632  /**
633  * Get the entries cache for this engine (note that it may be null if the engine is
634  * not yet initialized).
635  * @return The cache for this engine (or null if the engine is not initialized)
636  * @since 5.74
637  */
638  QSharedPointer<Cache> cache() const;
639 
640  /**
641  * If the same engine gets reused and the user could have used the delete functionality of the KCMs the cache could
642  * be out of sync. If the RemoveDeadEntries option is set to true this will remove deleted entries from the cache
643  * and the signalEntryChanged slot will be emitted with the updated entry
644  * @since 5.74
645  */
646  Q_INVOKABLE void revalidateCacheEntries();
647 
648  /**
649  * Whether or not the configuration says that the providers are expected to support uploading.
650  * @return True if the providers are expected to support uploading
651  * @since 5.85
652  */
653  bool uploadEnabled() const;
654 
655  /**
656  * Fired when the uploadEnabled property changes
657  * @since 5.85
658  */
659  Q_SIGNAL void uploadEnabledChanged();
660 
661 Q_SIGNALS:
662  /**
663  * Indicates a message to be added to the ui's log, or sent to a messagebox
664  */
665  void signalMessage(const QString &message);
666 
667  void signalProvidersLoaded();
668  void signalEntriesLoaded(const KNSCore::EntryInternal::List &entries);
669  void signalUpdateableEntriesLoaded(const KNSCore::EntryInternal::List &entries);
670 
671 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 77)
672  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 77, "Use Engine::signalEntryEvent instead")
673  void signalEntryChanged(const KNSCore::EntryInternal &entry);
674 #endif
675 
676 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 77)
677  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 77, "Use Engine::signalEntryEvent instead")
678  void signalEntryDetailsLoaded(const KNSCore::EntryInternal &entry);
679 #endif
680 
681  // a new search result is there, clear the list of items
682  void signalResetView();
683 
684  void signalEntryPreviewLoaded(const KNSCore::EntryInternal &, KNSCore::EntryInternal::PreviewType);
685  void signalPreviewFailed();
686 
687  void signalEntryUploadFinished();
688  void signalEntryUploadFailed();
689 
690  void signalDownloadDialogDone(KNSCore::EntryInternal::List);
691  void jobStarted(KJob *, const QString &);
692 
693 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 53)
694  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 53, "Use Engine::signalErrorCode(const KNSCore::ErrorCode &, const QString &, const QVariant &)")
695  void signalError(const QString &);
696 #endif
697 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 74)
698  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 74, "Use Engine::busyStateChanged() and Engine::busyMessageChanged() instead")
699  void signalBusy(const QString &);
700 #endif
701 #if KNEWSTUFFCORE_ENABLE_DEPRECATED_SINCE(5, 74)
702  KNEWSTUFFCORE_DEPRECATED_VERSION(5, 74, "Use Engine::busyStateChanged() and Engine::busyMessageChanged() instead")
703  void signalIdle(const QString &);
704 #endif
705 
706  /**
707  * Fires in the case of any critical or serious errors, such as network or API problems.
708  * @param errorCode Represents the specific type of error which has occurred
709  * @param message A human-readable message which can be shown to the end user
710  * @param metadata Any additional data which might be hepful to further work out the details of the error (see KNSCore::EntryInternal::ErrorCode for the
711  * metadata details)
712  * @see KNSCore::EntryInternal::ErrorCode
713  * @since 5.53
714  */
715  void signalErrorCode(const KNSCore::ErrorCode &errorCode, const QString &message, const QVariant &metadata);
716 
717  void signalCategoriesMetadataLoded(const QList<Provider::CategoryMetadata> &categories);
718 
719  /**
720  * Fires when the engine has loaded search presets. These represent interesting
721  * searches for the user, such as recommendations.
722  * @since 5.83
723  */
724  void signalSearchPresetsLoaded(const QList<Provider::SearchPreset> &presets);
725  /**
726  * This is fired for any event related directly to a single EntryInternal instance
727  * @see EntryInternal::EntryEvent for details on which specific event is being notified
728  * @since 5.77
729  */
730  void signalEntryEvent(const EntryInternal &entry, EntryInternal::EntryEvent event);
731 
732 private Q_SLOTS:
733  // the .knsrc file was loaded
734  void slotProviderFileLoaded(const QDomDocument &doc);
735  // instead of getting providers from knsrc, use what was configured in ocs systemsettings
736  void atticaProviderLoaded(const Attica::Provider &provider);
737 
738  // loading the .knsrc file failed
739  void slotProvidersFailed();
740 
741  // called when a provider is ready to work
742  void providerInitialized(KNSCore::Provider *);
743 
744  void slotEntriesLoaded(const KNSCore::Provider::SearchRequest &, KNSCore::EntryInternal::List);
745  void slotEntryDetailsLoaded(const KNSCore::EntryInternal &entry);
746  void slotPreviewLoaded(const KNSCore::EntryInternal &entry, KNSCore::EntryInternal::PreviewType type);
747 
748  void slotSearchTimerExpired();
749 
750  void slotEntryChanged(const KNSCore::EntryInternal &entry);
751  void slotInstallationFinished();
752  void slotInstallationFailed(const QString &message);
753  void downloadLinkLoaded(const KNSCore::EntryInternal &entry);
754 
755  void providerJobStarted(KJob *);
756 
757 private:
758  /**
759  * load providers from the providersurl in the knsrc file
760  * creates providers based on their type and adds them to the list of providers
761  */
762  void loadProviders();
763 
764  /**
765  Add a provider and connect it to the right slots
766  */
767  void addProvider(QSharedPointer<KNSCore::Provider> provider);
768 
769  void updateStatus();
770 
771  void doRequest();
772 
773  // FIXME KF6: move all of this in EnginePrivate
774  // handle installation of entries
775  Installation *m_installation;
776  // read/write cache of entries
777  QSharedPointer<Cache> m_cache;
778  QTimer *m_searchTimer;
779  // The url of the file containing information about content providers
780  /// TODO KF6 This really wants to be turned into a QUrl (which will have implications for our public API, so not doing it just now)
781  QString m_providerFileUrl;
782  // Categories from knsrc file
783  QStringList m_categories;
784 
786 
787  QString m_adoptionCommand;
788 
789  // the current request from providers
790  Provider::SearchRequest m_currentRequest;
791 
792  EnginePrivate *const d;
793 
794  // the page that is currently displayed, so it is not requested repeatedly
795  int m_currentPage;
796 
797  // when requesting entries from a provider, how many to ask for
798  int m_pageSize;
799 
800  int m_numDataJobs;
801  int m_numPictureJobs;
802  int m_numInstallJobs;
803  // If the provider is ready to be used
804  bool m_initialized;
805 
806  Q_DISABLE_COPY(Engine)
807 };
808 
809 }
810 
811 #endif
Contains the core functionality for handling interaction with NewStuff providers. ...
used to keep track of a search
Definition: provider.h:72
const QLatin1String name
ErrorCode
An enumeration of specific error conditions which might occur and which users of KNewStuff would want...
Definition: errorcode.h:24
PartitionTable::TableType type
QCA_EXPORT Provider * defaultProvider()
A model which takes care of the comments for a single EntryInternal.
KNewStuff Base Provider class.
Definition: provider.h:42
QCA_EXPORT void init()
KNewStuff data entry container.
Definition: entryinternal.h:49
KNewStuff engine.
Definition: engine.h:58
KNewStuff entry installation.
Definition: installation.h:37
Definition: engine.h:28
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Nov 30 2021 22:38:13 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.