KIO

kurifilter.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000-2001, 2003, 2010 Dawit Alemayehu <adawit at kde.org>
4
5 Original author
6 SPDX-FileCopyrightText: 2000 Yves Arrouye <yves@realnames.com>
7
8 SPDX-License-Identifier: LGPL-2.0-or-later
9*/
10
11#ifndef KURIFILTER_H
12#define KURIFILTER_H
13
14#include "kiogui_export.h"
15
16#include <QHash>
17#include <QObject>
18#include <QPair>
19#include <QStringList>
20#include <QUrl>
21
22#include <memory>
23
24#ifdef Q_OS_WIN
25#undef ERROR
26#endif
27
28class KUriFilterPrivate;
29class KUriFilterDataPrivate;
30class QHostInfo;
31
32/**
33 * @class KUriFilterSearchProvider kurifilter.h <KUriFilter>
34 *
35 * Class that holds information about a search provider.
36 *
37 */
38class KIOGUI_EXPORT KUriFilterSearchProvider
39{
40public:
41 /**
42 * Default constructor.
43 */
45
46 /**
47 * Copy constructor.
48 */
50
51 /**
52 * Destructor.
53 */
55
56 /**
57 * Returns the desktop filename of the search provider without any extension.
58 *
59 * For example, if the desktop filename of the search provider was
60 * "foobar.desktop", this function will return "foobar".
61 */
62 QString desktopEntryName() const;
63
64 /**
65 * Returns the descriptive name of the search provider, e.g.\ "Google News".
66 *
67 * This name comes from the "Name=" property entry in the desktop file that
68 * contains the search provider's information.
69 */
70 QString name() const;
71
72 /**
73 * Returns the icon name associated with the search provider when available.
74 */
75 virtual QString iconName() const;
76
77 /**
78 * Returns all the web shortcut keys associated with this search provider.
79 *
80 * @see defaultKey
81 */
82 QStringList keys() const;
83
84 /**
85 * Returns the default web shortcut key for this search provider.
86 *
87 * Right now this is the same as doing keys().first(), it might however
88 * change based on what the backend plugins do.
89 *
90 * @see keys
91 */
92 QString defaultKey() const;
93
94 /**
95 * Assignment operator.
96 */
98
99protected:
100 void setDesktopEntryName(const QString &);
101 void setIconName(const QString &);
102 void setKeys(const QStringList &);
103 void setName(const QString &);
104
105private:
106 friend class KUriFilterPlugin;
107 class KUriFilterSearchProviderPrivate;
108 std::unique_ptr<KUriFilterSearchProviderPrivate> const d;
109};
110
111/**
112 * @class KUriFilterData kurifilter.h <KUriFilter>
113 *
114 * This class is a basic messaging class used to exchange filtering information
115 * between the filter plugins and the application requesting the filtering
116 * service.
117 *
118 * Use this object if you require a more detailed information about the URI you
119 * want to filter. Any application can create an instance of this class and send
120 * it to KUriFilter to have the plugins fill out all possible information about
121 * the URI.
122 *
123 * On successful filtering you can use @ref uriType() to determine what type
124 * of resource the request was filtered into. See @ref KUriFilter::UriTypes for
125 * details. If an error is encountered, then @ref KUriFilter::Error is returned.
126 * You can use @ref errorMsg to obtain the error information.
127 *
128 * The functions in this class are not reentrant.
129 *
130 * \b Example
131 *
132 * Here is a basic example of how this class is used with @ref KUriFilter:
133 * \code
134 * KUriFilterData filterData (QLatin1String("kde.org"));
135 * bool filtered = KUriFilter::self()->filterUri(filterData);
136 * \endcode
137 *
138 * If you are only interested in getting the list of preferred search providers,
139 * then you can do the following:
140 *
141 * \code
142 * KUriFilterData data;
143 * data.setData("<text-to-search-for>");
144 * data.setSearchFilteringOption(KUriFilterData::RetrievePreferredSearchProvidersOnly);
145 * bool filtered = KUriFilter::self()->filterSearchUri(data, KUriFilter::NormalTextFilter);
146 * \endcode
147 *
148 * @short A class for exchanging filtering information.
149 * @author Dawit Alemayehu <adawit at kde.org>
150 */
151
152class KIOGUI_EXPORT KUriFilterData
153{
154public:
155 /**
156 * Describes the type of the URI that was filtered.
157 */
158 enum UriTypes {
159 NetProtocol = 0, ///< Any network protocol: http, ftp, nttp, pop3, etc...
160 LocalFile, ///< A local file whose executable flag is not set
161 LocalDir, ///< A local directory
162 Executable, ///< A local file whose executable flag is set
163 Help, ///< A man or info page
164 Shell, ///< A shell executable (ex: echo "Test..." >> ~/testfile)
165 Blocked, ///< A URI that should be blocked/filtered (ex: ad filtering)
166 Error, ///< An incorrect URI (ex: "~johndoe" when user johndoe does not exist in that system)
167 Unknown, ///< A URI that is not identified. Default value when a KUriFilterData is first created.
168 };
169
170 /**
171 * This enum describes the search filtering options to be used.
172 *
173 * @li SearchFilterOptionNone
174 * No search filter options are set and normal filtering is performed
175 * on the input data.
176 * @li RetrieveSearchProvidersOnly
177 * If set, the list of all available search providers are returned without
178 * any input filtering. This flag only applies when used in conjunction
179 * with the @ref KUriFilter::NormalTextFilter flag.
180 * @li RetrievePreferredSearchProvidersOnly
181 * If set, the list of preferred search providers are returned without
182 * any input filtering. This flag only applies when used in conjunction
183 * with the @ref KUriFilter::NormalTextFilter flag.
184 * @li RetrieveAvailableSearchProvidersOnly
185 * Same as doing RetrievePreferredSearchProvidersOnly | RetrieveSearchProvidersOnly,
186 * where all available search providers are returned if no preferred ones
187 * ones are available. No input filtering will be performed.
188 *
189 * @see setSearchFilteringOptions
190 * @see KUriFilter::filterSearchUri
191 * @see SearchFilterOptions
192 */
194 SearchFilterOptionNone = 0x0,
195 RetrieveSearchProvidersOnly = 0x01,
196 RetrievePreferredSearchProvidersOnly = 0x02,
197 RetrieveAvailableSearchProvidersOnly = (RetrievePreferredSearchProvidersOnly | RetrieveSearchProvidersOnly),
198 };
199 /**
200 * Stores a combination of #SearchFilterOption values.
201 */
203
204 /**
205 * Default constructor.
206 *
207 * Creates a UriFilterData object.
208 */
210
211 /**
212 * Creates a KUriFilterData object from the given URL.
213 *
214 * @param url is the URL to be filtered.
215 */
216 explicit KUriFilterData(const QUrl &url);
217
218 /**
219 * Creates a KUriFilterData object from the given string.
220 *
221 * @param url is the string to be filtered.
222 */
223 explicit KUriFilterData(const QString &url);
224
225 /**
226 * Copy constructor.
227 *
228 * Creates a KUriFilterData object from another KURIFilterData object.
229 *
230 * @param other the uri filter data to be copied.
231 */
232 KUriFilterData(const KUriFilterData &other);
233
234 /**
235 * Destructor.
236 */
238
239 /**
240 * Returns the filtered or the original URL.
241 *
242 * If one of the plugins successfully filtered the original input, this
243 * function returns it. Otherwise, it will return the input itself.
244 *
245 * @return the filtered or original url.
246 */
247 QUrl uri() const;
248
249 /**
250 * Returns an error message.
251 *
252 * This functions returns the error message set by the plugin whenever the
253 * uri type is set to KUriFilterData::ERROR. Otherwise, it returns a nullptr
254 * string.
255 *
256 * @return the error message or a nullptr when there is none.
257 */
258 QString errorMsg() const;
259
260 /**
261 * Returns the URI type.
262 *
263 * This method always returns KUriFilterData::UNKNOWN if the given URL was
264 * not filtered.
265 *
266 * @return the type of the URI
267 */
268 UriTypes uriType() const;
269
270 /**
271 * Returns the absolute path if one has already been set.
272 *
273 * @return the absolute path, or QString()
274 *
275 * @see hasAbsolutePath()
276 */
277 QString absolutePath() const;
278
279 /**
280 * Checks whether the supplied data had an absolute path.
281 *
282 * @return true if the supplied data has an absolute path
283 *
284 * @see absolutePath()
285 */
286 bool hasAbsolutePath() const;
287
288 /**
289 * Returns the command line options and arguments for a local resource
290 * when present.
291 *
292 * @return options and arguments when present, otherwise QString()
293 */
294 QString argsAndOptions() const;
295
296 /**
297 * Checks whether the current data is a local resource with command line
298 * options and arguments.
299 *
300 * @return true if the current data has command line options and arguments
301 */
302 bool hasArgsAndOptions() const;
303
304 /**
305 * @return true if the filters should attempt to check whether the
306 * supplied uri is an executable. False otherwise.
307 */
308 bool checkForExecutables() const;
309
310 /**
311 * The string as typed by the user, before any URL processing is done.
312 */
313 QString typedString() const;
314
315 /**
316 * Returns the search term portion of the typed string.
317 *
318 * If the @ref typedString was not filtered by a search filter plugin, this
319 * function returns an empty string.
320 *
321 * @see typedString
322 */
323 QString searchTerm() const;
324
325 /**
326 * Returns the character that is used to separate the search term from the
327 * keyword.
328 *
329 * If @ref typedString was not filtered by a search filter plugin, this
330 * function returns a null character.
331 *
332 * @see typedString
333 */
334 QChar searchTermSeparator() const;
335
336 /**
337 * Returns the name of the search service provider, e.g.\ Google.
338 *
339 * If @ref typedString was not filtered by a search filter plugin, this
340 * function returns an empty string.
341 *
342 * @see typedString
343 */
344 QString searchProvider() const;
345
346 /**
347 * Returns a list of the names of preferred or available search providers.
348 *
349 * This function returns the list of providers marked as preferred whenever
350 * the input data, i.e. @ref typedString, is successfully filtered.
351 *
352 * If no default search provider has been selected prior to a filter request,
353 * this function will return an empty list. To avoid this problem you must
354 * either set an alternate default search provider using @ref setAlternateDefaultSearchProvider
355 * or set one of the @ref SearchFilterOption flags if you are only interested
356 * in getting the list of providers and not filtering the input.
357 *
358 * Additionally, you can also provide alternate search providers in case
359 * there are no preferred ones already selected.
360 *
361 * You can use @ref queryForPreferredServiceProvider to obtain the query
362 * associated with the list of search providers returned by this function.
363 *
364 * @see setAlternateSearchProviders
365 * @see setAlternateDefaultSearchProvider
366 * @see setSearchFilteringOption
367 * @see queryForPreferredServiceProvider
368 */
369 QStringList preferredSearchProviders() const;
370
371 /**
372 * Returns information about @p provider.
373 *
374 * You can use this function to obtain the more information about the search
375 * providers returned by @ref preferredSearchProviders.
376 *
377 * @see preferredSearchProviders
378 * @see KUriFilterSearchProvider
379 */
380 KUriFilterSearchProvider queryForSearchProvider(const QString &provider) const;
381
382 /**
383 * Returns the web shortcut url for the given preferred search provider.
384 *
385 * You can use this function to obtain the query for the preferred search
386 * providers returned by @ref preferredSearchProviders.
387 *
388 * The query returned by this function is in web shortcut format, i.e.
389 * "gg:foo bar", and must be re-filtered through KUriFilter to obtain a
390 * valid url.
391 *
392 * @see preferredSearchProviders
393 */
394 QString queryForPreferredSearchProvider(const QString &provider) const;
395
396 /**
397 * Returns all the query urls for the given search provider.
398 *
399 * Use this function to obtain all the different queries that can be used
400 * for the given provider. For example, if a search engine provider named
401 * "foobar" has web shortcuts named "foobar", "foo" and "bar", then this
402 * function, unlike @ref queryForPreferredSearchProvider, will return a
403 * a query for each and every web shortcut.
404 *
405 * @see queryForPreferredSearchProvider
406 */
407 QStringList allQueriesForSearchProvider(const QString &provider) const;
408
409 /**
410 * Returns the icon associated with the given preferred search provider.
411 *
412 * You can use this function to obtain the icon names associated with the
413 * preferred search providers returned by @ref preferredSearchProviders.
414 *
415 * @see preferredSearchProviders
416 */
417 QString iconNameForPreferredSearchProvider(const QString &provider) const;
418
419 /**
420 * Returns the list of alternate search providers.
421 *
422 * This function returns an empty list if @ref setAlternateSearchProviders
423 * was not called to set the alternate search providers to be when no
424 * preferred providers have been chosen by the user through the search
425 * configuration module.
426 *
427 * @see setAlternatteSearchProviders
428 * @see preferredSearchProviders
429 */
430 QStringList alternateSearchProviders() const;
431
432 /**
433 * Returns the search provider to use when a default provider is not available.
434 *
435 * This function returns an empty string if @ref setAlternateDefaultSearchProvider
436 * was not called to set the default search provider to be used when none has been
437 * chosen by the user through the search configuration module.
438 *
439 * @see setAlternateDefaultSearchProvider
440 */
441 QString alternateDefaultSearchProvider() const;
442
443 /**
444 * Returns the default protocol to use when filtering potentially valid url inputs.
445 *
446 * By default this function will return an empty string.
447 *
448 * @see setDefaultUrlScheme
449 */
450 QString defaultUrlScheme() const;
451
452 /**
453 * Returns the specified search filter options.
454 *
455 * By default this function returns @ref SearchFilterOptionNone.
456 *
457 * @see setSearchFilteringOptions
458 */
459 SearchFilterOptions searchFilteringOptions() const;
460
461 /**
462 * The name of the icon that matches the current filtered URL.
463 *
464 * This function returns a null string by default and when no icon is found
465 * for the filtered URL.
466 */
467 QString iconName();
468
469 /**
470 * Check whether the provided uri is executable or not.
471 *
472 * Setting this to false ensures that typing the name of an executable does
473 * not start that application. This is useful in the location bar of a
474 * browser. The default value is true.
475 */
476 void setCheckForExecutables(bool check);
477
478 /**
479 * Same as above except the argument is a URL.
480 *
481 * Use this function to set the string to be filtered when you construct an
482 * empty filter object.
483 *
484 * @param url the URL to be filtered.
485 */
486 void setData(const QUrl &url);
487
488 /**
489 * Sets the URL to be filtered.
490 *
491 * Use this function to set the string to be
492 * filtered when you construct an empty filter
493 * object.
494 *
495 * @param url the string to be filtered.
496 */
497 void setData(const QString &url);
498
499 /**
500 * Sets the absolute path to be used whenever the supplied data is a
501 * relative local URL.
502 *
503 * NOTE: This function should only be used for local resources, i.e. the
504 * "file:/" protocol. It is useful for specifying the absolute path in
505 * cases where the actual URL might be relative. If deriving the path from
506 * a QUrl, make sure you set the argument for this function to the result
507 * of calling path () instead of url ().
508 *
509 * @param abs_path the absolute path to the local resource.
510 *
511 * @return true if absolute path is successfully set. Otherwise, false.
512 */
513 bool setAbsolutePath(const QString &abs_path);
514
515 /**
516 * Sets a list of search providers to use in case no preferred search
517 * providers are available.
518 *
519 * The list of preferred search providers set using this function will only
520 * be used if the default and favorite search providers have not yet been
521 * selected by the user. Otherwise, the providers specified through this
522 * function will be ignored.
523 *
524 * @see alternateSearchProviders
525 * @see preferredSearchProviders
526 */
527 void setAlternateSearchProviders(const QStringList &providers);
528
529 /**
530 * Sets the search provider to use in case no default provider is available.
531 *
532 * The default search provider set using this function will only be used if
533 * the default and favorite search providers have not yet been selected by
534 * the user. Otherwise, the default provider specified by through function
535 * will be ignored.
536 *
537 * @see alternateDefaultSearchProvider
538 * @see preferredSearchProviders
539 */
540 void setAlternateDefaultSearchProvider(const QString &provider);
541
542 /**
543 * Sets the default scheme used when filtering potentially valid url inputs.
544 *
545 * Use this function to change the default protocol used when filtering
546 * potentially valid url inputs. The default protocol is http.
547 *
548 * If the scheme is specified without a separator, then "://" will be used
549 * as the separator by default. For example, if the default url scheme was
550 * simply set to "ftp", then a potentially valid url input such as "kde.org"
551 * will be filtered to "ftp://kde.org".
552 *
553 * @see defaultUrlScheme
554 */
555 void setDefaultUrlScheme(const QString &);
556
557 /**
558 * Sets the options used by search filter plugins to filter requests.
559 *
560 * The default search filter option is @ref SearchFilterOptionNone. See
561 * @ref SearchFilterOption for the description of the other flags.
562 *
563 * It is important to note that the options set through this function can
564 * prevent any filtering from being performed by search filter plugins.
565 * As such, @ref uriTypes can return KUriFilterData::Unknown and @ref uri
566 * can return an invalid url even though the filtering request returned
567 * a successful response.
568 *
569 * @see searchFilteringOptions
570 */
571 void setSearchFilteringOptions(SearchFilterOptions options);
572
573 /**
574 * Overloaded assignment operator.
575 *
576 * This function allows you to easily assign a QUrl
577 * to a KUriFilterData object.
578 *
579 * @return an instance of a KUriFilterData object.
580 */
581 KUriFilterData &operator=(const QUrl &url);
582
583 /**
584 * Overloaded assignment operator.
585 *
586 * This function allows you to easily assign a QString to a KUriFilterData
587 * object.
588 *
589 * @return an instance of a KUriFilterData object.
590 */
591 KUriFilterData &operator=(const QString &url);
592
593private:
594 friend class KUriFilterPlugin;
595 std::unique_ptr<KUriFilterDataPrivate> d;
596};
597
598/**
599 * @class KUriFilter kurifilter.h <KUriFilter>
600 *
601 * KUriFilter applies a number of filters to a URI and returns a filtered version if any
602 * filter matches.
603 * A simple example is "kde.org" to "http://www.kde.org", which is commonplace in web browsers.
604 *
605 * The filters are implemented as plugins in @ref KUriFilterPlugin subclasses.
606 *
607 * KUriFilter is a singleton object: obtain the instance by calling
608 * @p KUriFilter::self() and use the public member functions to
609 * perform the filtering.
610 *
611 * \b Example
612 *
613 * To simply filter a given string:
614 *
615 * \code
616 * QString url("kde.org");
617 * bool filtered = KUriFilter::self()->filteredUri( url );
618 * \endcode
619 *
620 * You can alternatively use a QUrl:
621 *
622 * \code
623 * QUrl url("kde.org");
624 * bool filtered = KUriFilter::self()->filterUri( url );
625 * \endcode
626 *
627 * If you have a constant string or a constant URL, simply invoke the
628 * corresponding function to obtain the filtered string or URL instead
629 * of a boolean flag:
630 *
631 * \code
632 * QString filteredText = KUriFilter::self()->filteredUri( "kde.org" );
633 * \endcode
634 *
635 * All of the above examples should result in "kde.org" being filtered into
636 * "http://kde.org".
637 *
638 * You can also restrict the filters to be used by supplying the name of the
639 * filters you want to use. By default all available filters are used.
640 *
641 * To use specific filters, add the names of the filters you want to use to a
642 * QStringList and invoke the appropriate filtering function.
643 *
644 * The examples below show the use of specific filters. KDE ships with the
645 * following filter plugins by default:
646 *
647 * kshorturifilter:
648 * This is used for filtering potentially valid url inputs such as "kde.org"
649 * Additionally it filters shell variables and shortcuts such as $HOME and
650 * ~ as well as man and info page shortcuts, # and ## respectively.
651 *
652 * kuriikwsfilter:
653 * This is used for filtering normal input text into a web search url using the
654 * configured fallback search engine selected by the user.
655 *
656 * kurisearchfilter:
657 * This is used for filtering KDE webshortcuts. For example "gg:KDE" will be
658 * converted to a url for searching the work "KDE" using the Google search
659 * engine.
660 *
661 * localdomainfilter:
662 * This is used for doing a DNS lookup to determine whether the input is a valid
663 * local address.
664 *
665 * fixuphosturifilter:
666 * This is used to append "www." to the host name of a pre filtered http url
667 * if the original url cannot be resolved.
668 *
669 * \code
670 * QString text ("kde.org");
671 * bool filtered = KUriFilter::self()->filterUri(text, QLatin1String("kshorturifilter"));
672 * \endcode
673 *
674 * The above code should result in "kde.org" being filtered into "http://kde.org".
675 *
676 * \code
677 * QStringList list;
678 * list << QLatin1String("kshorturifilter") << QLatin1String("localdomainfilter");
679 * bool filtered = KUriFilter::self()->filterUri( text, list );
680 * \endcode
681 *
682 * Additionally if you only want to do search related filtering, you can use the
683 * search specific function, @ref filterSearchUri, that is available in KDE
684 * 4.5 and higher. For example, to search for a given input on the web you
685 * can do the following:
686 *
687 * KUriFilterData filterData ("foo");
688 * bool filtered = KUriFilter::self()->filterSearchUri(filterData, KUriFilterData::NormalTextFilter);
689 *
690 * KUriFilter converts all filtering requests to use @ref KUriFilterData
691 * internally. The use of this bi-directional class allows you to send specific
692 * instructions to the filter plugins as well as receive detailed information
693 * about the filtered request from them. See the documentation of KUriFilterData
694 * class for more examples and details.
695 *
696 * All functions in this class are thread safe and reentrant.
697 *
698 * @short Filters the given input into a valid url whenever possible.
699 */
700class KIOGUI_EXPORT KUriFilter
701{
702public:
703 /**
704 * This enum describes the types of search plugin filters available.
705 *
706 * @li NormalTextFilter The plugin used to filter normal text, e.g. "some term to search".
707 * @li WebShortcutFilter The plugin used to filter web shortcuts, e.g. gg:KDE.
708 *
709 * @see SearchFilterTypes
710 */
712 NormalTextFilter = 0x01,
713 WebShortcutFilter = 0x02,
714 };
715 /**
716 * Stores a combination of #SearchFilterType values.
717 */
719
720 /**
721 * Destructor
722 */
724
725 /**
726 * Returns an instance of KUriFilter.
727 */
728 static KUriFilter *self();
729
730 /**
731 * Filters @p data using the specified @p filters.
732 *
733 * If no named filters are specified, the default, then all the
734 * URI filter plugins found will be used.
735 *
736 * @param data object that contains the URI to be filtered.
737 * @param filters specify the list of filters to be used.
738 *
739 * @return a boolean indicating whether the URI has been changed
740 */
741 bool filterUri(KUriFilterData &data, const QStringList &filters = QStringList());
742
743 /**
744 * Filters the URI given by the URL.
745 *
746 * The given URL is filtered based on the specified list of filters.
747 * If the list is empty all available filters would be used.
748 *
749 * @param uri the URI to filter.
750 * @param filters specify the list of filters to be used.
751 *
752 * @return a boolean indicating whether the URI has been changed
753 */
754 bool filterUri(QUrl &uri, const QStringList &filters = QStringList());
755
756 /**
757 * Filters a string representing a URI.
758 *
759 * The given URL is filtered based on the specified list of filters.
760 * If the list is empty all available filters would be used.
761 *
762 * @param uri The URI to filter.
763 * @param filters specify the list of filters to be used.
764 *
765 * @return a boolean indicating whether the URI has been changed
766 */
767 bool filterUri(QString &uri, const QStringList &filters = QStringList());
768
769 /**
770 * Returns the filtered URI.
771 *
772 * The given URL is filtered based on the specified list of filters.
773 * If the list is empty all available filters would be used.
774 *
775 * @param uri The URI to filter.
776 * @param filters specify the list of filters to be used.
777 *
778 * @return the filtered URI or null if it cannot be filtered
779 */
780 QUrl filteredUri(const QUrl &uri, const QStringList &filters = QStringList());
781
782 /**
783 * Return a filtered string representation of a URI.
784 *
785 * The given URL is filtered based on the specified list of filters.
786 * If the list is empty all available filters would be used.
787 *
788 * @param uri the URI to filter.
789 * @param filters specify the list of filters to be used.
790 *
791 * @return the filtered URI or null if it cannot be filtered
792 */
793 QString filteredUri(const QString &uri, const QStringList &filters = QStringList());
794
795 /**
796 * Filter @p data using the criteria specified by @p types.
797 *
798 * The search filter type can be individual value of @ref SearchFilterTypes
799 * or a combination of those types using the bitwise OR operator.
800 *
801 * You can also use the flags from @ref KUriFilterData::SearchFilterOption
802 * to alter the filtering mechanisms of the search filter providers.
803 *
804 * @param data object that contains the URI to be filtered.
805 * @param types the search filters used to filter the request.
806 * @return true if the specified @p data was successfully filtered.
807 *
808 * @see KUriFilterData::setSearchFilteringOptions
809 */
810 bool filterSearchUri(KUriFilterData &data, SearchFilterTypes types);
811
812 /**
813 * Return a list of the names of all loaded plugins.
814 *
815 * @return a QStringList of plugin names
816 */
817 QStringList pluginNames() const;
818
819protected:
820 /**
821 * Constructor.
822 *
823 * Creates a KUriFilter object and calls loads all available URI filter plugins.
824 */
825 KUriFilter();
826
827private:
828 std::unique_ptr<KUriFilterPrivate> const d;
829 friend class KUriFilterSingleton;
830};
831
832Q_DECLARE_OPERATORS_FOR_FLAGS(KUriFilterData::SearchFilterOptions)
833Q_DECLARE_OPERATORS_FOR_FLAGS(KUriFilter::SearchFilterTypes)
834
835#endif
This class is a basic messaging class used to exchange filtering information between the filter plugi...
Definition kurifilter.h:153
UriTypes
Describes the type of the URI that was filtered.
Definition kurifilter.h:158
@ Error
An incorrect URI (ex: "~johndoe" when user johndoe does not exist in that system)
Definition kurifilter.h:166
@ Blocked
A URI that should be blocked/filtered (ex: ad filtering)
Definition kurifilter.h:165
@ Shell
A shell executable (ex: echo "Test..." >> ~/testfile)
Definition kurifilter.h:164
@ Unknown
A URI that is not identified. Default value when a KUriFilterData is first created.
Definition kurifilter.h:167
@ Executable
A local file whose executable flag is set.
Definition kurifilter.h:162
@ LocalFile
A local file whose executable flag is not set.
Definition kurifilter.h:160
@ Help
A man or info page.
Definition kurifilter.h:163
@ LocalDir
A local directory.
Definition kurifilter.h:161
SearchFilterOption
This enum describes the search filtering options to be used.
Definition kurifilter.h:193
~KUriFilterData()
Destructor.
Class that holds information about a search provider.
Definition kurifilter.h:39
virtual ~KUriFilterSearchProvider()
Destructor.
KUriFilter applies a number of filters to a URI and returns a filtered version if any filter matches.
Definition kurifilter.h:701
SearchFilterType
This enum describes the types of search plugin filters available.
Definition kurifilter.h:711
~KUriFilter()
Destructor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:49:56 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.