File indexing completed on 2024-05-05 16:16:34
0001 /* 0002 SPDX-FileCopyrightText: 2013 Martin Klapetek <mklapetek@kde.org> 0003 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org> 0004 0005 SPDX-License-Identifier: LGPL-2.1-or-later 0006 */ 0007 0008 #ifndef BASE_PERSONS_DATA_SOURCE_H 0009 #define BASE_PERSONS_DATA_SOURCE_H 0010 0011 #include <QObject> 0012 #include <QVariant> 0013 0014 #include <kpeoplebackend/kpeoplebackend_export.h> 0015 0016 #include "allcontactsmonitor.h" 0017 #include "contactmonitor.h" 0018 0019 namespace KPeople 0020 { 0021 class BasePersonsDataSourcePrivate; 0022 0023 // This is a QObject for KPluginFactory 0024 class KPEOPLEBACKEND_EXPORT BasePersonsDataSource : public QObject 0025 { 0026 Q_OBJECT 0027 public: 0028 BasePersonsDataSource(QObject *parent, const QVariantList &args = QVariantList()); 0029 ~BasePersonsDataSource() override; 0030 0031 /** 0032 * Return a ref counted AllContactMonitor which lists and monitors all contacts from a source 0033 */ 0034 AllContactsMonitorPtr allContactsMonitor(); 0035 0036 /** 0037 * Return a ref counted watcher for a single contact 0038 */ 0039 ContactMonitorPtr contactMonitor(const QString &contactUri); 0040 0041 /** 0042 * Returns the ID used by this datasource. 0043 * i.e if the contactIDs are in the form akonadi://?item=324 this method should return "akonadi" 0044 */ 0045 virtual QString sourcePluginId() const = 0; 0046 0047 protected: 0048 virtual AllContactsMonitor *createAllContactsMonitor() = 0; 0049 0050 /** 0051 * Base classes can implement this in order to not load every contact 0052 * otherwise the AllContactWatcher will be used and filtered. 0053 */ 0054 virtual ContactMonitor *createContactMonitor(const QString &contactUri); 0055 0056 private: 0057 Q_DISABLE_COPY(BasePersonsDataSource) 0058 Q_DECLARE_PRIVATE(BasePersonsDataSource) 0059 BasePersonsDataSourcePrivate *d_ptr; 0060 }; 0061 0062 class KPEOPLEBACKEND_EXPORT BasePersonsDataSourceV2 : public BasePersonsDataSource 0063 { 0064 Q_OBJECT 0065 public: 0066 BasePersonsDataSourceV2(QObject *parent, const QVariantList &args = QVariantList()); 0067 0068 virtual bool addContact(const QVariantMap &properties) = 0; 0069 virtual bool deleteContact(const QString &uri) = 0; 0070 }; 0071 0072 } 0073 #endif // BASE_PERSONS_DATA_SOURCE_H