KPeople

allcontactsmonitor.h
1/*
2 SPDX-FileCopyrightText: 2013 David Edmundson <davidedmundson@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.1-or-later
5*/
6
7#ifndef ALLCONTACTSMONITOR_H
8#define ALLCONTACTSMONITOR_H
9
10#include <QObject>
11#include <QSharedPointer>
12
13#include <kpeoplebackend/abstractcontact.h>
14#include <kpeoplebackend/kpeoplebackend_export.h>
15
16namespace KPeople
17{
18class AllContactsMonitorPrivate;
19
20/**
21 * This class should be subclassed by each datasource and return a list of
22 * all contacts that the datasource knows about.
23 *
24 * Subclasses are expected to be asynchronous
25 *
26 * @since 5.8
27 */
28class KPEOPLEBACKEND_EXPORT AllContactsMonitor : public QObject
29{
30 Q_OBJECT
31public:
32 explicit AllContactsMonitor(); // TODO make protected? this isn't useful unless subclassed
33 ~AllContactsMonitor() override;
34
35 /**
36 * Returns all currently loaded contacts
37 */
38 virtual QMap<QString, AbstractContact::Ptr> contacts();
39
40 // TODO redo as a state enum - InitialLoad, Fail, Loaded
41 bool isInitialFetchComplete() const;
42
43 bool initialFetchSuccess() const;
44
45Q_SIGNALS:
46 /**
47 * DataSources should emit this whenever a known contact changes
48 */
49 void contactChanged(const QString &contactUri, const KPeople::AbstractContact::Ptr &contact);
50
51 /**
52 * DataSources should emit this whenever a contact is added
53 */
54 void contactAdded(const QString &contactUri, const KPeople::AbstractContact::Ptr &contact);
55
56 /**
57 * DataSources should emit this whenever a contact is removed and they are no longer able to supply up-to-date data on a contact
58 */
59 void contactRemoved(const QString &contactUri);
60
61 /**
62 * Notifies that the DataSource has completed it's initial fetch.
63 *
64 * @warning DataSources should use emitInitialFetchComplete() instead of emitting this signal
65 * directly.
66 *
67 * @param success True when the fetch was successful, False when an error occurred.
68 */
69 void initialFetchComplete(bool success);
70
71protected Q_SLOTS:
72 /**
73 * DataSources should call this once they have finished initial retrieval of all contacts from their
74 * storage.
75 *
76 * This will emit initialFetchComplete() signal
77 *
78 * @p success Whether the fetch was successful.
79 */
80 void emitInitialFetchComplete(bool success);
81
82private:
83 Q_DISABLE_COPY(AllContactsMonitor)
84 Q_DECLARE_PRIVATE(AllContactsMonitor)
85 AllContactsMonitorPrivate *d_ptr;
86};
87
88}
90
91#endif // ALLCONTACTSMONITOR_H
This class should be subclassed by each datasource and return a list of all contacts that the datasou...
void contactRemoved(const QString &contactUri)
DataSources should emit this whenever a contact is removed and they are no longer able to supply up-t...
void contactAdded(const QString &contactUri, const KPeople::AbstractContact::Ptr &contact)
DataSources should emit this whenever a contact is added.
void contactChanged(const QString &contactUri, const KPeople::AbstractContact::Ptr &contact)
DataSources should emit this whenever a known contact changes.
void initialFetchComplete(bool success)
Notifies that the DataSource has completed it's initial fetch.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:45 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.