File indexing completed on 2024-06-16 13:25:13

0001 /* This file is part of the KDE project
0002    Copyright (C) 1998, 1999 Torben Weis <weis@kde.org>
0003    Copyright (C) 2007 David Faure <faure@kde.org>
0004    Copyright (C) 2015 Jarosław Staniek <staniek@kde.org>
0005 
0006    This library is free software; you can redistribute it and/or
0007    modify it under the terms of the GNU Library General Public
0008    License as published by the Free Software Foundation; either
0009    version 2 of the License, or (at your option) any later version.
0010 
0011    This library is distributed in the hope that it will be useful,
0012    but WITHOUT ANY WARRANTY; without even the implied warranty of
0013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0014    Library General Public License for more details.
0015 
0016    You should have received a copy of the GNU Library General Public License
0017    along with this library; see the file COPYING.LIB.  If not, write to
0018    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0019  * Boston, MA 02110-1301, USA.
0020 */
0021 
0022 #ifndef KDB_JSONTRADER_P_H
0023 #define KDB_JSONTRADER_P_H
0024 
0025 #include <QList>
0026 #include <QString>
0027 
0028 class QPluginLoader;
0029 
0030 /**
0031  *  Support class to fetch a list of relevant plugins
0032  */
0033 class KDbJsonTrader
0034 {
0035 public:
0036     KDbJsonTrader();
0037 
0038     ~KDbJsonTrader();
0039 
0040     static KDbJsonTrader *self();
0041 
0042     /**
0043      * The main function in the KDbJsonTrader class.
0044      *
0045      * It will return a list of QPluginLoader objects that match your
0046      * specifications.  The only required parameter is the @a servicetype.
0047      * The @a mimetype parameter is used to limit the possible choices
0048      * returned based on the constraints you give it.
0049      *
0050      * The keys used in the query (Type, ServiceType, Exec) are all
0051      * fields found in .json information files.
0052      *
0053      * @param servicetype A service type like 'KMyApp/Plugin' or 'KFilePlugin'.
0054      * @param mimetype    A mimetype constraint to limit the choices returned, QString() to
0055      *                    get all services of the given @p servicetype.
0056      *
0057      * @return A list of QPluginLoader that satisfy the query
0058      * @see https://techbase.kde.org/Development/Tutorials/Services/Traders#The_KTrader_Query_Language
0059      *
0060      * @note Ownership of the QPluginLoader objects is transferred to the caller.
0061      */
0062      QList<QPluginLoader *> query(const QString &servicetype, const QString &mimetype = QString());
0063 
0064 private:
0065      Q_DISABLE_COPY(KDbJsonTrader)
0066      class Private;
0067      Private * const d;
0068 };
0069 
0070 #endif