File indexing completed on 2024-05-05 07:58:26
0001 /* 0002 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org> 0003 SPDX-FileCopyrightText: 2018 Igor Poboiko <igor.poboiko@gmail.com> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef PERSON_PLUGIN_MANAGER_H 0009 #define PERSON_PLUGIN_MANAGER_H 0010 0011 #include <kpeople/kpeople_export.h> 0012 0013 #include <QHash> 0014 #include <QVariant> 0015 0016 namespace KPeople 0017 { 0018 class AbstractPersonAction; 0019 class BasePersonsDataSource; 0020 0021 /** 0022 This class allows applications to manage DataSource plugins 0023 0024 It can be useful if an application wants to use custom DataSource, 0025 without exposing it to other KPeople-based applications 0026 (i.e. without installing a system-wide plugin) 0027 0028 Another use-case is that it allows to pass custom arguments to DataSources 0029 (i.e. an ItemModel which will be used as a source of data) 0030 0031 @since 5.51 0032 */ 0033 class KPEOPLE_EXPORT PersonPluginManager 0034 { 0035 public: 0036 /** 0037 * Use this if you explicitly don't want KPeople to autoload all the 0038 * available data source plugins. 0039 * 0040 * The default behavior is to autoload them 0041 */ 0042 static void setAutoloadDataSourcePlugins(bool autoloadDataSourcePlugins); 0043 static QList<BasePersonsDataSource *> dataSourcePlugins(); 0044 /** 0045 * Adds custom data source. If DataSource with such @p sourceId was already loaded, we override it 0046 * 0047 * Takes ownership of the @p source 0048 */ 0049 static void addDataSource(const QString &sourceId, BasePersonsDataSource *source); 0050 static BasePersonsDataSource *dataSource(const QString &sourceId); 0051 0052 /** 0053 * Instead of loading datasources from plugins, set sources manually 0054 * This is for unit tests only 0055 */ 0056 static void setDataSourcePlugins(const QHash<QString, BasePersonsDataSource *> &dataSources); 0057 0058 /** 0059 * Creates a contact with the specified @p properties 0060 * @returns if it could be done successfully 0061 * 0062 * @since 5.62 0063 */ 0064 static bool addContact(const QVariantMap &properties); 0065 0066 /** 0067 * Deletes a contact with the specified &p uri 0068 * @returns if it could be done successfully 0069 * 0070 * @since 5.62 0071 */ 0072 static bool deleteContact(const QString &uri); 0073 }; 0074 } 0075 0076 #endif // PERSON_PLUGIN_MANAGER_H