blob: 160b2ac38f6d3c4d4a4680e4963a1bdd95c63c2b [file] [log] [blame]
Edric Milaret67007d12015-05-07 09:40:09 -04001/***************************************************************************
2 * Copyright (C) 2015 by Savoir-Faire Linux *
3 * Author: Edric Ladent Milaret <edric.ladent-milaret@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, see <http://www.gnu.org/licenses/>. *
17 **************************************************************************/
18
19#ifndef WINDOWSCONTACTBACKEND_H
20#define WINDOWSCONTACTBACKEND_H
21
22#include <QObject>
23#include <QStandardPaths>
24#include <QDir>
25#include <QXmlStreamReader>
26#include <QtConcurrent/QtConcurrent>
Edric Milaretdb76aa82015-05-11 16:01:00 -040027#include <QImage>
Edric Milaret43f3c1e2015-07-16 17:52:47 -040028#include <QFileSystemWatcher>
Edric Milaret67007d12015-05-07 09:40:09 -040029
30#include "person.h"
31#include "collectioninterface.h"
32#include "contactmethod.h"
33#include "phonedirectorymodel.h"
34
35class WindowsContactBackend : public CollectionInterface
36{
37public:
38 explicit WindowsContactBackend(CollectionMediator<Person>* mediator, CollectionInterface* parent = nullptr);
39 virtual ~WindowsContactBackend();
40
41 virtual bool load() override;
42 virtual bool reload() override;
43 virtual bool clear() override;
44 virtual QString name () const override;
45 virtual QString category () const override;
46 virtual bool isEnabled() const override;
47 virtual QByteArray id () const override;
48 virtual FlagPack<CollectionInterface::SupportedFeatures> supportedFeatures() const override;
49
50private:
51 bool loadRun();
52private:
53 CollectionMediator<Person>* mediator_;
Edric Milaretdb76aa82015-05-11 16:01:00 -040054 constexpr static int sizePhoto_ = 50;
Edric Milaret43f3c1e2015-07-16 17:52:47 -040055 QFileSystemWatcher* watcher_;
56
57private:
58 bool getPersonFromContactFile(const QDir &contactDir, const QString& contactFileName);
Edric Milaret67007d12015-05-07 09:40:09 -040059};
60
61class WindowsContactEditor : public CollectionEditor<Person>
62{
63public:
64 WindowsContactEditor(CollectionMediator<Person>* m, WindowsContactBackend* parent);
65 ~WindowsContactEditor();
66 virtual bool save ( const Person* item ) override;
67 virtual bool remove ( const Person* item ) override;
68 virtual bool edit ( Person* item ) override;
69 virtual bool addNew ( const Person* item ) override;
70 virtual bool addExisting( const Person* item ) override;
71
72private:
73 virtual QVector<Person*> items() const override;
74
75 QVector<Person*> items_;
76 WindowsContactBackend* collection_;
77};
78
79#endif // WINDOWSCONTACTBACKEND_H