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
61};
62
71 : public KCalendarCore::CalStorage, public KCalendarCore::Calendar::CalendarObserver
72{
73 Q_OBJECT
74
75public:
76
82 PurgeDeleted
83 };
84
88 typedef QSharedPointer<ExtendedStorage> Ptr;
89
105 explicit ExtendedStorage(const ExtendedCalendar::Ptr &cal, bool validateNotebooks = true);
106
110 virtual ~ExtendedStorage();
111
116 virtual bool open() = 0;
117
122 virtual bool load() = 0;
123
131 virtual bool load(const QString &uid, const QDateTime &recurrenceId = QDateTime()) = 0;
132
146 virtual bool load(const QDate &date) = 0;
147
157 virtual bool load(const QDate &start, const QDate &end) = 0;
158
165 virtual bool loadSeries(const QString &uid) = 0;
166
175 virtual bool loadIncidenceInstance(const QString &instanceIdentifier) = 0;
176
183 virtual bool loadNotebookIncidences(const QString &notebookUid) = 0;
184
188 virtual bool loadJournals() = 0;
189
195 virtual bool loadPlainIncidences() = 0;
196
202 virtual bool loadRecurringIncidences() = 0;
203
209 virtual bool loadGeoIncidences() = 0;
210
220 virtual bool loadGeoIncidences(float geoLatitude, float geoLongitude,
221 float diffLatitude, float diffLongitude) = 0;
222
228 virtual bool loadAttendeeIncidences() = 0;
229
230 // Smart Loading Functions //
231
237 virtual int loadUncompletedTodos() = 0;
238
248 virtual int loadCompletedTodos(bool hasDate, int limit, QDateTime *last) = 0;
249
260 virtual int loadIncidences(bool hasDate, int limit, QDateTime *last) = 0;
261
273 virtual int loadFutureIncidences(int limit, QDateTime *last) = 0;
274
285 virtual int loadGeoIncidences(bool hasDate, int limit, QDateTime *last) = 0;
286
294 virtual KCalendarCore::Person::List loadContacts() = 0;
295
305 virtual int loadContactIncidences(const KCalendarCore::Person &person,
306 int limit, QDateTime *last) = 0;
307
317 virtual int loadJournals(int limit, QDateTime *last) = 0;
318
326 virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list) = 0;
327
332 virtual bool save() = 0;
333
343 virtual bool save(DeleteAction deleteAction) = 0;
344
353 virtual bool notifyOpened(const KCalendarCore::Incidence::Ptr &incidence) = 0;
354
360 virtual bool cancel() = 0;
361
366 virtual bool close();
367
368 // Internal Calendar Listener Methods //
369
374 virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar) = 0;
375
380 virtual void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence) = 0;
381
386 virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence) = 0;
387
392 virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar) = 0;
393
398 virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence) = 0;
399
400 // Synchronization Specific Methods //
401
414 virtual bool insertedIncidences(KCalendarCore::Incidence::List *list,
415 const QDateTime &after = QDateTime(),
416 const QString &notebookUid = QString()) = 0;
417
428 virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list,
429 const QDateTime &after = QDateTime(),
430 const QString &notebookUid = QString()) = 0;
431
440 virtual bool deletedIncidences(KCalendarCore::Incidence::List *list,
441 const QDateTime &after = QDateTime(),
442 const QString &notebookUid = QString()) = 0;
443
451 virtual bool allIncidences(KCalendarCore::Incidence::List *list,
452 const QString &notebookUid = QString()) = 0;
453
462 virtual bool duplicateIncidences(KCalendarCore::Incidence::List *list,
463 const KCalendarCore::Incidence::Ptr &incidence,
464 const QString &notebookUid = QString()) = 0;
465
472 virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence) = 0;
473
479 virtual int eventCount() = 0;
480
486 virtual int todoCount() = 0;
487
493 virtual int journalCount() = 0;
494
495 // Observer Specific Methods //
496
505 void registerObserver(ExtendedStorageObserver *observer);
506
515 void unregisterObserver(ExtendedStorageObserver *observer);
516
517 // Notebook Methods //
518
530 bool addNotebook(const Notebook::Ptr &nb);
531
539 bool updateNotebook(const Notebook::Ptr &nb);
540
548 bool deleteNotebook(const Notebook::Ptr &nb);
549
556 bool setDefaultNotebook(const Notebook::Ptr &nb);
557
563 Notebook::Ptr defaultNotebook();
564
571 Notebook::Ptr notebook(const QString &uid);
572
580 Notebook::Ptr notebook(Notebook::List &list, const QString &uid);
581
587 Notebook::List notebooks();
588
596 void setValidateNotebooks(bool validateNotebooks);
597
605 bool validateNotebooks();
606
614 bool isValidNotebook(const QString &notebookUid);
615
616 // Alarm Methods //
617
628 KCalendarCore::Incidence::Ptr checkAlarm(const QString &uid, const QString &recurrenceId,
629 bool loadAlways = false);
630
639 Notebook::Ptr createDefaultNotebook(QString name = QString(),
640 QString color = QString());
641
649 virtual void virtual_hook(int id, void *data) = 0;
650
651protected:
652 virtual bool loadNotebooks() = 0;
653 virtual bool modifyNotebook(const Notebook::Ptr &nb, DBOperation dbop) = 0;
654
655 bool getLoadDates(const QDate &start, const QDate &end,
656 QDateTime *loadStart, QDateTime *loadEnd) const;
657
658 void addLoadedRange(const QDate &start, const QDate &end) const;
659 bool isRecurrenceLoaded() const;
660 void setIsRecurrenceLoaded(bool loaded);
661
662 void setModified(const QString &info);
663 void setFinished(bool error, const QString &info);
664 void setUpdated(const KCalendarCore::Incidence::List &added,
665 const KCalendarCore::Incidence::List &modified,
666 const KCalendarCore::Incidence::List &deleted);
667
668 bool isUncompletedTodosLoaded();
669 void setIsUncompletedTodosLoaded(bool loaded);
670
671 bool isCompletedTodosDateLoaded();
672 void setIsCompletedTodosDateLoaded(bool loaded);
673 bool isCompletedTodosCreatedLoaded();
674 void setIsCompletedTodosCreatedLoaded(bool loaded);
675
676 bool isJournalsLoaded();
677 void setIsJournalsLoaded(bool loaded);
678
679 bool isDateLoaded();
680 void setIsDateLoaded(bool loaded);
681 bool isCreatedLoaded();
682 void setIsCreatedLoaded(bool loaded);
683 bool isFutureDateLoaded();
684 void setIsFutureDateLoaded(bool loaded);
685
686 bool isGeoDateLoaded();
687 void setIsGeoDateLoaded(bool loaded);
688 bool isGeoCreatedLoaded();
689 void setIsGeoCreatedLoaded(bool loaded);
690
691 void clearLoaded();
692
693private:
694 //@cond PRIVATE
695 Q_DISABLE_COPY(ExtendedStorage)
696 class MKCAL_HIDE Private;
697 Private *const d;
698 //@endcond
699
700 friend class ::MkcalTool;
701 friend class ::tst_load;
702};
703
704}
705
706#endif
This class provides a calendar storage interface.
Definition: extendedstorage.h:72
QSharedPointer< ExtendedStorage > Ptr
A shared pointer to a ExtendedStorage.
Definition: extendedstorage.h:88
virtual bool loadJournals()=0
Load journal type entries.
virtual int loadGeoIncidences(bool hasDate, int limit, QDateTime *last)=0
Load incidences that have location information based on parameters.
virtual int loadJournals(int limit, QDateTime *last)=0
Load journal entries based on parameters.
virtual bool open()=0
virtual bool load()=0
virtual bool duplicateIncidences(KCalendarCore::Incidence::List *list, const KCalendarCore::Incidence::Ptr &incidence, const QString &notebookUid=QString())=0
Get possible duplicates for given incidence.
virtual bool loadNotebookIncidences(const QString &notebookUid)=0
Load incidences of one notebook into the memory.
virtual int loadCompletedTodos(bool hasDate, int limit, QDateTime *last)=0
Load completed todos based on parameters.
virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar)=0
virtual bool loadIncidenceInstance(const QString &instanceIdentifier)=0
Load the incidence matching the given identifier.
virtual bool load(const QDate &start, const QDate &end)=0
Load incidences between given dates into the memory.
virtual int journalCount()=0
Get count of journals.
virtual bool load(const QDate &date)=0
Load incidences at given date into the memory.
virtual bool loadRecurringIncidences()=0
Load recurring incidences.
virtual int loadIncidences(bool hasDate, int limit, QDateTime *last)=0
Load incidences based on start/due date or creation date.
virtual int loadContactIncidences(const KCalendarCore::Person &person, int limit, QDateTime *last)=0
Load all incidences that have the specified attendee.
Notebook::Ptr notebook(Notebook::List &list, const QString &uid)
Search for notebook in a list.
virtual bool load(const QString &uid, const QDateTime &recurrenceId=QDateTime())=0
Load incidence by uid into the memory.
virtual bool cancel()=0
Cancel any ongoing action (load etc.).
virtual bool loadGeoIncidences()=0
Load incidences that have geo parameters.
virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence)=0
Get deletion time of incidence.
virtual int todoCount()=0
Get count of todos.
virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list)=0
Remove from storage all incidences that have been previously marked as deleted and that matches the U...
virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar)=0
virtual int eventCount()=0
Get count of events.
virtual bool save(DeleteAction deleteAction)=0
This is an overload of save() method.
virtual bool modifyNotebook(const Notebook::Ptr &nb, DBOperation dbop)=0
virtual bool loadNotebooks()=0
virtual bool loadAttendeeIncidences()=0
Load incidences that have attendee.
DeleteAction
Action to be performed on save for deleted incidences.
Definition: extendedstorage.h:80
@ MarkDeleted
Definition: extendedstorage.h:81
virtual KCalendarCore::Person::List loadContacts()=0
Load all contacts in the database.
virtual bool allIncidences(KCalendarCore::Incidence::List *list, const QString &notebookUid=QString())=0
Get all incidences from storage.
virtual bool save()=0
virtual bool loadSeries(const QString &uid)=0
Load all incidences sharing the same uid into the memory.
virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list, const QDateTime &after=QDateTime(), const QString &notebookUid=QString())=0
Get modified incidences from storage.
virtual bool loadGeoIncidences(float geoLatitude, float geoLongitude, float diffLatitude, float diffLongitude)=0
Load incidences that have geo parameters inside given rectangle.
virtual bool loadPlainIncidences()=0
Load plain incidences (no startdate and no enddate).
virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence)=0
virtual bool notifyOpened(const KCalendarCore::Incidence::Ptr &incidence)=0
Mark if supported by the storage that an incidence has been opened.
virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence)=0
virtual int loadUncompletedTodos()=0
Load all uncompleted todos.
virtual int loadFutureIncidences(int limit, QDateTime *last)=0
Load future incidences based on start/due date.
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.
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:27
#define MKCAL_HIDE
Definition: mkcal_export.h:31
Definition: extendedstorage.h:42
Definition: extendedstorage.h:49
DBOperation
Database operation type.
Definition: extendedstorage.h:54
@ DBUpdate
Definition: extendedstorage.h:57
@ DBSelect
Definition: extendedstorage.h:60
@ DBMarkDeleted
Definition: extendedstorage.h:58
@ DBNone
Definition: extendedstorage.h:55
@ DBInsert
Definition: extendedstorage.h:56
@ DBDelete
Definition: extendedstorage.h:59
This file is part of the API for handling calendar data and defines the Notebook class.

Generated on Mon May 30 2022 06:54:51 for libextendedkcal by doxygen 1.9.6