KPeople

basepersonsdatasource.h
1 /*
2  SPDX-FileCopyrightText: 2013 Martin Klapetek <[email protected]>
3  SPDX-FileCopyrightText: 2013 David Edmundson <[email protected]>
4 
5  SPDX-License-Identifier: LGPL-2.1-or-later
6 */
7 
8 #ifndef BASE_PERSONS_DATA_SOURCE_H
9 #define BASE_PERSONS_DATA_SOURCE_H
10 
11 #include <QObject>
12 #include <QVariant>
13 
14 #include <kpeoplebackend/kpeoplebackend_export.h>
15 
16 #include "allcontactsmonitor.h"
17 #include "contactmonitor.h"
18 
19 namespace KPeople
20 {
21 class BasePersonsDataSourcePrivate;
22 
23 // This is a QObject for KPluginFactory
24 class KPEOPLEBACKEND_EXPORT BasePersonsDataSource : public QObject
25 {
26  Q_OBJECT
27 public:
28  BasePersonsDataSource(QObject *parent, const QVariantList &args = QVariantList());
29  ~BasePersonsDataSource() override;
30 
31  /**
32  * Return a ref counted AllContactMonitor which lists and monitors all contacts from a source
33  */
34  AllContactsMonitorPtr allContactsMonitor();
35 
36  /**
37  * Return a ref counted watcher for a single contact
38  */
39  ContactMonitorPtr contactMonitor(const QString &contactUri);
40 
41  /**
42  * Returns the ID used by this datasource.
43  * i.e if the contactIDs are in the form akonadi://?item=324 this method should return "akonadi"
44  */
45  virtual QString sourcePluginId() const = 0;
46 
47 protected:
48  virtual AllContactsMonitor *createAllContactsMonitor() = 0;
49 
50  /**
51  * Base classes can implement this in order to not load every contact
52  * otherwise the AllContactWatcher will be used and filtered.
53  */
54  virtual ContactMonitor *createContactMonitor(const QString &contactUri);
55 
56 private:
57  Q_DISABLE_COPY(BasePersonsDataSource)
58  Q_DECLARE_PRIVATE(BasePersonsDataSource)
59  BasePersonsDataSourcePrivate *d_ptr;
60 };
61 
62 class KPEOPLEBACKEND_EXPORT BasePersonsDataSourceV2 : public BasePersonsDataSource
63 {
64  Q_OBJECT
65 public:
66  BasePersonsDataSourceV2(QObject *parent, const QVariantList &args = QVariantList());
67 
68  virtual bool addContact(const QVariantMap &properties) = 0;
69  virtual bool deleteContact(const QString &uri) = 0;
70 };
71 
72 }
73 #endif // BASE_PERSONS_DATA_SOURCE_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Aug 14 2022 04:09:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.