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"
36 #include "notebook.h"
37 
38 #include <KCalendarCore/CalStorage>
39 #include <KCalendarCore/Calendar>
40 
41 namespace KCalendarCore {
42 class Incidence;
43 }
44 
45 class MkcalTool;
46 
47 namespace mKCal {
48 
58  DBSelect
59 };
60 
61 // Default alarm receiver is the organiser application.
62 const char *const DBusService = "com.nokia.organiser";
63 const char *const DBusInterface = "com.nokia.OrganiserAlarmIf";
64 const char *const DBusPath = "/";
65 const char *const DBusName = "alarm";
66 
75  : public KCalendarCore::CalStorage, public KCalendarCore::Calendar::CalendarObserver
76 {
77  Q_OBJECT
78 
79 public:
80 
84  enum DeleteAction {
86  PurgeDeleted
87  };
88 
92  typedef QSharedPointer<ExtendedStorage> Ptr;
93 
109  explicit ExtendedStorage(const ExtendedCalendar::Ptr &cal, bool validateNotebooks = true);
110 
114  virtual ~ExtendedStorage();
115 
120  virtual bool open() = 0;
121 
126  virtual bool load() = 0;
127 
135  virtual bool load(const QString &uid, const QDateTime &recurrenceId = QDateTime()) = 0;
136 
143  virtual bool load(const QDate &date) = 0;
144 
152  virtual bool load(const QDate &start, const QDate &end) = 0;
153 
160  virtual bool loadSeries(const QString &uid) = 0;
161 
170  virtual bool loadIncidenceInstance(const QString &instanceIdentifier) = 0;
171 
178  virtual bool loadNotebookIncidences(const QString &notebookUid) = 0;
179 
183  virtual bool loadJournals() = 0;
184 
190  virtual bool loadPlainIncidences() = 0;
191 
197  virtual bool loadRecurringIncidences() = 0;
198 
204  virtual bool loadGeoIncidences() = 0;
205 
215  virtual bool loadGeoIncidences(float geoLatitude, float geoLongitude,
216  float diffLatitude, float diffLongitude) = 0;
217 
223  virtual bool loadAttendeeIncidences() = 0;
224 
225  // Smart Loading Functions //
226 
232  virtual int loadUncompletedTodos() = 0;
233 
243  virtual int loadCompletedTodos(bool hasDate, int limit, QDateTime *last) = 0;
244 
255  virtual int loadIncidences(bool hasDate, int limit, QDateTime *last) = 0;
256 
268  virtual int loadFutureIncidences(int limit, QDateTime *last) = 0;
269 
280  virtual int loadGeoIncidences(bool hasDate, int limit, QDateTime *last) = 0;
281 
288 
298  virtual int loadOldInvitationIncidences(int limit, QDateTime *last) = 0;
299 
307  virtual KCalendarCore::Person::List loadContacts() = 0;
308 
318  virtual int loadContactIncidences(const KCalendarCore::Person &person,
319  int limit, QDateTime *last) = 0;
320 
330  virtual int loadJournals(int limit, QDateTime *last) = 0;
331 
339  virtual bool purgeDeletedIncidences(const KCalendarCore::Incidence::List &list) = 0;
340 
345  virtual bool save() = 0;
346 
356  virtual bool save(DeleteAction deleteAction) = 0;
357 
366  virtual bool notifyOpened(const KCalendarCore::Incidence::Ptr &incidence) = 0;
367 
373  virtual bool cancel() = 0;
374 
379  virtual bool close() = 0;
380 
381  // Internal Calendar Listener Methods //
382 
387  virtual void calendarModified(bool modified, KCalendarCore::Calendar *calendar) = 0;
388 
393  virtual void calendarIncidenceAdded(const KCalendarCore::Incidence::Ptr &incidence) = 0;
394 
399  virtual void calendarIncidenceChanged(const KCalendarCore::Incidence::Ptr &incidence) = 0;
400 
405  virtual void calendarIncidenceDeleted(const KCalendarCore::Incidence::Ptr &incidence, const KCalendarCore::Calendar *calendar) = 0;
406 
411  virtual void calendarIncidenceAdditionCanceled(const KCalendarCore::Incidence::Ptr &incidence) = 0;
412 
413  // Synchronization Specific Methods //
414 
427  virtual bool insertedIncidences(KCalendarCore::Incidence::List *list,
428  const QDateTime &after = QDateTime(),
429  const QString &notebookUid = QString()) = 0;
430 
441  virtual bool modifiedIncidences(KCalendarCore::Incidence::List *list,
442  const QDateTime &after = QDateTime(),
443  const QString &notebookUid = QString()) = 0;
444 
453  virtual bool deletedIncidences(KCalendarCore::Incidence::List *list,
454  const QDateTime &after = QDateTime(),
455  const QString &notebookUid = QString()) = 0;
456 
464  virtual bool allIncidences(KCalendarCore::Incidence::List *list,
465  const QString &notebookUid = QString()) = 0;
466 
475  virtual bool duplicateIncidences(KCalendarCore::Incidence::List *list,
476  const KCalendarCore::Incidence::Ptr &incidence,
477  const QString &notebookUid = QString()) = 0;
478 
485  virtual QDateTime incidenceDeletedDate(const KCalendarCore::Incidence::Ptr &incidence) = 0;
486 
492  virtual int eventCount() = 0;
493 
499  virtual int todoCount() = 0;
500 
506  virtual int journalCount() = 0;
507 
508  // Observer Specific Methods //
509 
518  void registerObserver(ExtendedStorageObserver *observer);
519 
528  void unregisterObserver(ExtendedStorageObserver *observer);
529 
530  // Notebook Methods //
531 
544  bool addNotebook(const Notebook::Ptr &nb, bool signal = true);
545 
553  bool updateNotebook(const Notebook::Ptr &nb);
554 
564  bool deleteNotebook(const Notebook::Ptr &nb, bool onlyMemory = false);
565 
572  bool setDefaultNotebook(const Notebook::Ptr &nb);
573 
579  Notebook::Ptr defaultNotebook();
580 
587  Notebook::Ptr notebook(const QString &uid);
588 
596  Notebook::Ptr notebook(Notebook::List &list, const QString &uid);
597 
603  Notebook::List notebooks();
604 
612  void setValidateNotebooks(bool validateNotebooks);
613 
621  bool validateNotebooks();
622 
630  bool isValidNotebook(const QString &notebookUid);
631 
632  // Alarm Methods //
633 
644  KCalendarCore::Incidence::Ptr checkAlarm(const QString &uid, const QString &recurrenceId,
645  bool loadAlways = false);
646 
655  Notebook::Ptr createDefaultNotebook(QString name = QString(),
656  QString color = QString());
657 
665  virtual void virtual_hook(int id, void *data) = 0;
666 
667 protected:
668  virtual bool loadNotebooks() = 0;
669  virtual bool reloadNotebooks() = 0;
670  virtual bool modifyNotebook(const Notebook::Ptr &nb, DBOperation dbop,
671  bool signal = true) = 0;
672 
673  bool getLoadDates(const QDate &start, const QDate &end,
674  QDateTime &loadStart, QDateTime &loadEnd);
675 
676  void setLoadDates(const QDate &start, const QDate &end);
677 
678  void setModified(const QString &info);
679  void setProgress(const QString &info);
680  void setFinished(bool error, const QString &info);
681 
682  // These alarm methods are used to communicate with an external
683  // daemon, like timed, to bind Incidence::Alarm with the system notification.
684  void clearAlarms(const KCalendarCore::Incidence::Ptr &incidence);
685  void clearAlarms(const KCalendarCore::Incidence::List &incidences);
686  void clearAlarms(const QString &nname);
687  void setAlarms(const KCalendarCore::Incidence::Ptr &incidence);
688  void setAlarms(const KCalendarCore::Incidence::List &incidences);
689  void resetAlarms(const KCalendarCore::Incidence::List &incidences);
690  void resetAlarms(const KCalendarCore::Incidence::Ptr &incidence);
691 
692  bool isUncompletedTodosLoaded();
693  void setIsUncompletedTodosLoaded(bool loaded);
694 
695  bool isCompletedTodosDateLoaded();
696  void setIsCompletedTodosDateLoaded(bool loaded);
697  bool isCompletedTodosCreatedLoaded();
698  void setIsCompletedTodosCreatedLoaded(bool loaded);
699 
700  bool isJournalsLoaded();
701  void setIsJournalsLoaded(bool loaded);
702 
703  bool isDateLoaded();
704  void setIsDateLoaded(bool loaded);
705  bool isCreatedLoaded();
706  void setIsCreatedLoaded(bool loaded);
707  bool isFutureDateLoaded();
708  void setIsFutureDateLoaded(bool loaded);
709 
710  bool isGeoDateLoaded();
711  void setIsGeoDateLoaded(bool loaded);
712  bool isGeoCreatedLoaded();
713  void setIsGeoCreatedLoaded(bool loaded);
714 
715  bool isUnreadIncidencesLoaded();
716  void setIsUnreadIncidencesLoaded(bool loaded);
717 
718  bool isInvitationIncidencesLoaded();
719  void setIsInvitationIncidencesLoaded(bool loaded);
720 
721  void clearLoaded();
722 
723 private:
724  //@cond PRIVATE
725  Q_DISABLE_COPY(ExtendedStorage)
726  class MKCAL_HIDE Private;
727  Private *const d;
728  //@endcond
729 
730  friend class ::MkcalTool;
731 };
732 
733 }
734 
735 #endif
This class provides a calendar storage interface.
Definition: extendedstorage.h:76
void setAlarms(const KCalendarCore::Incidence::List &incidences)
QSharedPointer< ExtendedStorage > Ptr
A shared pointer to a ExtendedStorage.
Definition: extendedstorage.h:92
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 int loadOldInvitationIncidences(int limit, QDateTime *last)=0
Load incidences that are related to an invitation.
void resetAlarms(const KCalendarCore::Incidence::List &incidences)
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 modifyNotebook(const Notebook::Ptr &nb, DBOperation dbop, bool signal=true)=0
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 int loadUnreadInvitationIncidences()=0
Load all unread incidences that are related to an invitation.
virtual bool close()=0
virtual bool save(DeleteAction deleteAction)=0
This is an overload of save() method.
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:84
@ MarkDeleted
Definition: extendedstorage.h:85
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.
void resetAlarms(const KCalendarCore::Incidence::Ptr &incidence)
virtual bool reloadNotebooks()=0
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
void clearAlarms(const KCalendarCore::Incidence::Ptr &incidence)
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.
void setAlarms(const KCalendarCore::Incidence::Ptr &incidence)
The ExtendedStorageObserver class.
Definition: extendedstorageobserver.h:46
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.
#define MKCAL_EXPORT
Definition: mkcal_export.h:27
#define MKCAL_HIDE
Definition: mkcal_export.h:31
Definition: extendedstorage.h:41
Definition: extendedstorage.h:47
DBOperation
Database operation type.
Definition: extendedstorage.h:52
@ DBUpdate
Definition: extendedstorage.h:55
@ DBSelect
Definition: extendedstorage.h:58
@ DBMarkDeleted
Definition: extendedstorage.h:56
@ DBNone
Definition: extendedstorage.h:53
@ DBInsert
Definition: extendedstorage.h:54
@ DBDelete
Definition: extendedstorage.h:57
const char *const DBusPath
Definition: extendedstorage.h:64
const char *const DBusService
Definition: extendedstorage.h:62
const char *const DBusInterface
Definition: extendedstorage.h:63
const char *const DBusName
Definition: extendedstorage.h:65
This file is part of the API for handling calendar data and defines the Notebook class.

Generated on Tue Jun 29 2021 09:14:45 for libextendedkcal by doxygen 1.9.1