increase version
[kdepim.git] / console / calendarjanitor / calendarjanitor.h
blob30a02e5f67bb11f508572ca4f71d9690ea87486c
1 /*
2 Copyright (c) 2013 Sérgio Martins <iamsergio@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with this program; if not, write to the Free Software Foundation, Inc.,
16 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 As a special exception, permission is given to link this program
19 with any edition of Qt, and distribute the resulting executable,
20 without including the source code for Qt in the source distribution.
23 #ifndef CALENDARJANITOR_H
24 #define CALENDARJANITOR_H
26 #include "options.h"
28 #include <KCalCore/Incidence>
30 #include <Akonadi/Calendar/IncidenceChanger>
31 #include <Akonadi/Calendar/FetchJobCalendar>
32 #include <AkonadiCore/Collection>
33 #include <AkonadiCore/Item>
34 #include <QObject>
35 #include <QString>
36 #include <QMultiMap>
38 class CollectionLoader;
40 class CalendarJanitor : public QObject
42 Q_OBJECT
43 public:
44 explicit CalendarJanitor(const Options &options, QObject *parent = Q_NULLPTR);
46 void start();
48 Q_SIGNALS:
49 void finished(bool success);
51 private Q_SLOTS:
52 void onCollectionsFetched(bool success);
53 void onItemsFetched(bool success, const QString &errorMessage);
54 void onModifyFinished(int changeId, const Akonadi::Item &item,
55 Akonadi::IncidenceChanger::ResultCode resultCode, const QString &errorMessage);
56 void onDeleteFinished(int changeId, const QVector<Akonadi::Item::Id> &,
57 Akonadi::IncidenceChanger::ResultCode resultCode, const QString &errorMessage);
59 void processNextCollection();
61 // For each collection we process, we run a bunch of tests on it.
62 void runNextTest();
64 void sanityCheck1();
65 void sanityCheck2();
66 void sanityCheck3();
67 void sanityCheck4();
68 void sanityCheck5();
69 void sanityCheck6();
70 void sanityCheck7();
71 void sanityCheck8();
72 void sanityCheck9();
74 void stripOldAlarms();
76 void printFound(const Akonadi::Item &item, const QString &explanation = QString());
78 void beginTest(const QString &message);
79 void endTest(bool print = true, const QString &fixExplanation = QString(),
80 const QString &fixExplanation2 = QString());
82 void deleteIncidence(const Akonadi::Item &item);
84 private:
85 CollectionLoader *m_collectionLoader;
86 Akonadi::Collection::List m_collectionsToProcess;
87 Akonadi::Item::List m_itemsToProcess;
88 Options m_options;
89 Akonadi::IncidenceChanger *m_changer;
90 Akonadi::Collection m_currentCollection;
91 Options::SanityCheck m_currentSanityCheck;
92 int m_pendingModifications;
93 int m_pendingDeletions;
94 bool m_strippingOldAlarms;
96 QList<Akonadi::Item::Id> m_test1Results;
97 QStringList m_test2Results;
99 int m_numDamaged;
100 bool m_fixingEnabled;
102 QString m_summary; // to print at the end.
103 QMultiMap<QString, KCalCore::Incidence::Ptr> m_incidenceMap;
104 QMap<KCalCore::Incidence::Ptr, Akonadi::Item> m_incidenceToItem;
106 Akonadi::FetchJobCalendar::Ptr m_calendar;
108 int m_returnCode;
111 #endif // CALENDARJANITOR_H