extendedstorage.h
Go to the documentation of this file.
1/*
2 This file is part of the mkcal library.
3
4 Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
5 Contact: Alvaro Manera <alvaro.manera@nokia.com>
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Library General Public
9 License as published by the Free Software Foundation; either
10 version 2 of the License, or (at your option) any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Library General Public License for more details.
16
17 You should have received a copy of the GNU Library General Public License
18 along with this library; see the file COPYING.LIB. If not, write to
19 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 Boston, MA 02110-1301, USA.
21*/
31#ifndef MKCAL_EXTENDEDSTORAGE_H
32#define MKCAL_EXTENDEDSTORAGE_H
33
34#include "mkcal_export.h"
35#include "extendedcalendar.h"
37#include "notebook.h"
38
39#include <KCalendarCore/CalStorage>
40#include <KCalendarCore/Calendar>
41
42namespace KCalendarCore {
43class Incidence;
44}
45
46class MkcalTool;
47class tst_load;
48
49namespace mKCal {
50
62 : public KCalendarCore::CalStorage, public KCalendarCore::Calendar::CalendarObserver
63{
64 Q_OBJECT
65
66public:
67
73 PurgeDeleted
74 };
75
79 typedef QSharedPointer<ExtendedStorage> Ptr;
80
96 explicit ExtendedStorage(const ExtendedCalendar::Ptr &cal, bool validateNotebooks = true);
97
101 virtual ~ExtendedStorage();
102
107 virtual bool open() = 0;
108
113 virtual bool load() = 0;
114
121 virtual bool load(const QString &uid) = 0;
122
131 bool loadSeries(const QString &uid);
132
147 bool load(const QString &uid, const QDateTime &recurrenceId);
148
162 virtual bool load(const QDate &date);
163
173 virtual bool load(const QDate &start, const QDate &end) = 0;
174
183 virtual bool loadIncidenceInstance(const QString &instanceIdentifier);
184
191 virtual bool loadNotebookIncidences(const QString &notebookUid) = 0;
192
204 virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list,
205 const QString &notebook = QString()) = 0;
206
211 virtual bool save() = 0;
212
222 virtual bool save(DeleteAction deleteAction) = 0;
223
228 virtual bool close();
229
230 // Internal Calendar Listener Methods //
231
236 virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar) = 0;
237
242 virtual void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence) = 0;
243
248 virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence) = 0;
249
254 virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar) = 0;
255
260 virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence) = 0;
261
262 // Synchronization Specific Methods //
263
276 virtual bool insertedIncidences(KCalendarCore::Incidence::List *list,
277 const QDateTime &after = QDateTime(),
278 const QString &notebookUid = QString()) = 0;
279
290 virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list,
291 const QDateTime &after = QDateTime(),
292 const QString &notebookUid = QString()) = 0;
293
302 virtual bool deletedIncidences(KCalendarCore::Incidence::List *list,
303 const QDateTime &after = QDateTime(),
304 const QString &notebookUid = QString()) = 0;
305
313 virtual bool allIncidences(KCalendarCore::Incidence::List *list,
314 const QString &notebookUid = QString()) = 0;
315
337 virtual bool search(const QString &key, QStringList *identifiers, int limit = 0) = 0;
338
345 virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence) = 0;
346
347 // Observer Specific Methods //
348
357 void registerObserver(ExtendedStorageObserver *observer);
358
367 void unregisterObserver(ExtendedStorageObserver *observer);
368
369 // Notebook Methods //
370
382 bool addNotebook(const Notebook::Ptr &nb);
383
391 bool updateNotebook(const Notebook::Ptr &nb);
392
400 bool deleteNotebook(const Notebook::Ptr &nb);
401
408 bool setDefaultNotebook(const Notebook::Ptr &nb);
409
415 Notebook::Ptr defaultNotebook();
416
423 Notebook::Ptr notebook(const QString &uid) const;
424
430 Notebook::List notebooks();
431
439 void setValidateNotebooks(bool validateNotebooks);
440
448 bool validateNotebooks() const;
449
457 bool isValidNotebook(const QString &notebookUid) const;
458
470 Notebook::Ptr createDefaultNotebook(QString name = QString(),
471 QString color = QString());
472
480 virtual void virtual_hook(int id, void *data) = 0;
481
482protected:
483 virtual bool loadNotebooks() = 0;
484 virtual bool insertNotebook(const Notebook::Ptr &nb) = 0;
485 virtual bool modifyNotebook(const Notebook::Ptr &nb) = 0;
486 virtual bool eraseNotebook(const Notebook::Ptr &nb) = 0;
487
488 bool getLoadDates(const QDate &start, const QDate &end,
489 QDateTime *loadStart, QDateTime *loadEnd) const;
490
491 void addLoadedRange(const QDate &start, const QDate &end) const;
492 bool isRecurrenceLoaded() const;
493 void setIsRecurrenceLoaded(bool loaded);
494
495 void emitStorageModified(const QString &info);
496 void emitStorageFinished(bool error, const QString &info);
497 void emitStorageUpdated(const KCalendarCore::Incidence::List &added,
498 const KCalendarCore::Incidence::List &modified,
499 const KCalendarCore::Incidence::List &deleted);
500
501private:
502 //@cond PRIVATE
503 Q_DISABLE_COPY(ExtendedStorage)
504 class Private;
505 Private *const d;
506 //@endcond
507
508 friend class ::MkcalTool;
509 friend class ::tst_load;
510};
511
512}
513
514#endif
This class provides a calendar storage interface.
Definition extendedstorage.h:63
virtual bool open()=0
virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list, const QString &notebook=QString())=0
Remove from storage all incidences that have been previously marked as deleted and that matches the U...
virtual bool load()=0
virtual bool load(const QString &uid)=0
Load all incidences sharing the same uid into the memory.
virtual bool loadNotebookIncidences(const QString &notebookUid)=0
Load incidences of one notebook into the memory.
virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar)=0
virtual bool load(const QDate &start, const QDate &end)=0
Load incidences between given dates into the memory.
virtual bool search(const QString &key, QStringList *identifiers, int limit=0)=0
Get all incidences from storage that match key.
virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence)=0
Get deletion time of incidence.
QSharedPointer< ExtendedStorage > Ptr
A shared pointer to a ExtendedStorage.
Definition extendedstorage.h:79
virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar)=0
virtual bool save(DeleteAction deleteAction)=0
This is an overload of save() method.
virtual bool loadNotebooks()=0
DeleteAction
Action to be performed on save for deleted incidences.
Definition extendedstorage.h:71
@ MarkDeleted
Definition extendedstorage.h:72
virtual bool allIncidences(KCalendarCore::Incidence::List *list, const QString &notebookUid=QString())=0
Get all incidences from storage.
virtual bool save()=0
virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString &notebookUid=QString())=0
Get modified incidences from storage.
virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence)=0
virtual bool modifyNotebook(const Notebook::Ptr &nb)=0
virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence)=0
virtual bool eraseNotebook(const Notebook::Ptr &nb)=0
virtual void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence)=0
virtual void virtual_hook(int id, void *data)=0
Standard trick to add virtuals later.
virtual bool insertedIncidences(KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString &notebookUid=QString())=0
Get inserted incidences from storage.
virtual bool deletedIncidences(KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString &notebookUid=QString())=0
Get deleted incidences from storage.
virtual bool insertNotebook(const Notebook::Ptr &nb)=0
The ExtendedStorageObserver class.
Definition extendedstorageobserver.h:47
QSharedPointer< Notebook > Ptr
A shared pointer to a Notebook object.
Definition notebook.h:51
QList< Ptr > List
List of notebooks.
Definition notebook.h:61
This file is part of the API for handling calendar data and defines the ExtendedCalendar class.
This file is part of the API for handling calendar data and defines the ExtendedStorageObserver to be...
#define MKCAL_EXPORT
Definition mkcal_export.h:29
Definition extendedstorage.h:42
Definition extendedstorage.h:49
This file is part of the API for handling calendar data and defines the Notebook class.

Generated on Thu Nov 28 2024 09:02:24 for libextendedkcal by doxygen 1.12.0