blob: dd81233c10a22800333aed6e1df69cf00280fbe9 [file] [log] [blame]
Alexandre Lision3b0bd332015-03-15 18:43:07 -04001/*
Alexandre Lision2db8f472015-07-22 15:05:46 -04002 * Copyright (C) 2015 Savoir-faire Linux Inc.
Alexandre Lision3b0bd332015-03-15 18:43:07 -04003 * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Alexandre Lision3b0bd332015-03-15 18:43:07 -040018 */
Alexandre Lision3b0bd332015-03-15 18:43:07 -040019
20#include <collectioninterface.h>
21#include <collectioneditor.h>
22
23class Person;
Alexandre Lision2db8f472015-07-22 15:05:46 -040024@class ABPerson;
25@class NSMutableArray;
26@class NSNotification;
Alexandre Lision3b0bd332015-03-15 18:43:07 -040027
28template<typename T> class CollectionMediator;
29
30class AddressBookBackend : public CollectionInterface
31{
32public:
33 explicit AddressBookBackend(CollectionMediator<Person>* mediator);
34 virtual ~AddressBookBackend();
35
36 virtual bool load() override;
37 virtual bool reload() override;
38 virtual bool clear() override;
39 virtual QString name () const override;
40 virtual QString category () const override;
41 virtual QVariant icon () const override;
42 virtual bool isEnabled() const override;
43 virtual QByteArray id () const override;
Alexandre Lision39224632015-05-01 11:52:17 -040044 virtual FlagPack<SupportedFeatures> supportedFeatures() const override;
Alexandre Lision3b0bd332015-03-15 18:43:07 -040045
Alexandre Lision2db8f472015-07-22 15:05:46 -040046 bool addNewPerson(Person *item);
47 bool removePerson(NSString* uid);
48
Alexandre Lision3b0bd332015-03-15 18:43:07 -040049private:
50 CollectionMediator<Person>* m_pMediator;
Alexandre Lision2db8f472015-07-22 15:05:46 -040051 NSMutableArray* observers;
52
53 void handleNotification(NSNotification* ns);
54 Person* abPersonToPerson(ABPerson* ab);
Alexandre Lision3b0bd332015-03-15 18:43:07 -040055
56 void asyncLoad(int startingPoint);
Alexandre Lision2db8f472015-07-22 15:05:46 -040057};