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 <calstorage.h>
39 #include <calendar.h>
40 
41 #include <kdatetime.h>
42 
43 namespace KCalCore {
44 class Incidence;
45 }
46 
47 class MkcalTool;
48 
49 namespace mKCal {
50 
61 };
62 
63 // Default alarm receiver is the organiser application.
64 const char *const DBusService = "com.nokia.organiser";
65 const char *const DBusInterface = "com.nokia.OrganiserAlarmIf";
66 const char *const DBusPath = "/";
67 const char *const DBusName = "alarm";
68 
77  : public KCalCore::CalStorage, public KCalCore::Calendar::CalendarObserver
78 {
79  Q_OBJECT
80 
81 public:
82 
86  enum DeleteAction {
88  PurgeDeleted
89  };
90 
94  typedef QSharedPointer<ExtendedStorage> Ptr;
95 
111  explicit ExtendedStorage(const ExtendedCalendar::Ptr &cal, bool validateNotebooks = false);
112 
116  virtual ~ExtendedStorage();
117 
122  virtual bool open() = 0;
123 
128  virtual bool load() = 0;
129 
137  virtual bool load(const QString &uid, const KDateTime &recurrenceId = KDateTime()) = 0;
138 
145  virtual bool load(const QDate &date) = 0;
146 
154  virtual bool load(const QDate &start, const QDate &end) = 0;
155 
162  virtual bool loadSeries(const QString &uid) = 0;
163 
170  virtual bool loadNotebookIncidences(const QString &notebookUid) = 0;
171 
175  virtual bool loadJournals() = 0;
176 
182  virtual bool loadPlainIncidences() = 0;
183 
189  virtual bool loadRecurringIncidences() = 0;
190 
196  virtual bool loadGeoIncidences() = 0;
197 
207  virtual bool loadGeoIncidences(float geoLatitude, float geoLongitude,
208  float diffLatitude, float diffLongitude) = 0;
209 
215  virtual bool loadAttendeeIncidences() = 0;
216 
217  // Smart Loading Functions //
218 
224  virtual int loadUncompletedTodos() = 0;
225 
235  virtual int loadCompletedTodos(bool hasDate, int limit, KDateTime *last) = 0;
236 
247  virtual int loadIncidences(bool hasDate, int limit, KDateTime *last) = 0;
248 
260  virtual int loadFutureIncidences(int limit, KDateTime *last) = 0;
261 
272  virtual int loadGeoIncidences(bool hasDate, int limit, KDateTime *last) = 0;
273 
279  virtual int loadUnreadInvitationIncidences() = 0;
280 
290  virtual int loadOldInvitationIncidences(int limit, KDateTime *last) = 0;
291 
299  virtual KCalCore::Person::List loadContacts() = 0;
300 
310  virtual int loadContactIncidences(const KCalCore::Person::Ptr &person,
311  int limit, KDateTime *last) = 0;
312 
322  virtual int loadJournals(int limit, KDateTime *last) = 0;
323 
331  virtual bool purgeDeletedIncidences(const KCalCore::Incidence::List &list) = 0;
332 
337  virtual bool save() = 0;
338 
348  virtual bool save(DeleteAction deleteAction) = 0;
349 
358  virtual bool notifyOpened(const KCalCore::Incidence::Ptr &incidence) = 0;
359 
365  virtual bool cancel() = 0;
366 
371  virtual bool close() = 0;
372 
373  // Internal Calendar Listener Methods //
374 
379  virtual void calendarModified(bool modified, KCalCore::Calendar *calendar) = 0;
380 
385  virtual void calendarIncidenceAdded(const KCalCore::Incidence::Ptr &incidence) = 0;
386 
391  virtual void calendarIncidenceChanged(const KCalCore::Incidence::Ptr &incidence) = 0;
392 
397  virtual void calendarIncidenceDeleted(const KCalCore::Incidence::Ptr &incidence) = 0;
398 
403  virtual void calendarIncidenceAdditionCanceled(const KCalCore::Incidence::Ptr &incidence) = 0;
404 
405  // Synchronization Specific Methods //
406 
419  virtual bool insertedIncidences(KCalCore::Incidence::List *list,
420  const KDateTime &after = KDateTime(),
421  const QString &notebookUid = QString()) = 0;
422 
433  virtual bool modifiedIncidences(KCalCore::Incidence::List *list,
434  const KDateTime &after = KDateTime(),
435  const QString &notebookUid = QString()) = 0;
436 
445  virtual bool deletedIncidences(KCalCore::Incidence::List *list,
446  const KDateTime &after = KDateTime(),
447  const QString &notebookUid = QString()) = 0;
448 
456  virtual bool allIncidences(KCalCore::Incidence::List *list,
457  const QString &notebookUid = QString()) = 0;
458 
467  virtual bool duplicateIncidences(KCalCore::Incidence::List *list,
468  const KCalCore::Incidence::Ptr &incidence,
469  const QString &notebookUid = QString()) = 0;
470 
477  virtual KDateTime incidenceDeletedDate(const KCalCore::Incidence::Ptr &incidence) = 0;
478 
484  virtual int eventCount() = 0;
485 
491  virtual int todoCount() = 0;
492 
498  virtual int journalCount() = 0;
499 
500  // Observer Specific Methods //
501 
510  void registerObserver(ExtendedStorageObserver *observer);
511 
520  void unregisterObserver(ExtendedStorageObserver *observer);
521 
522  // Notebook Methods //
523 
536  bool addNotebook(const Notebook::Ptr &nb, bool signal = true);
537 
545  bool updateNotebook(const Notebook::Ptr &nb);
546 
556  bool deleteNotebook(const Notebook::Ptr &nb, bool onlyMemory = false);
557 
564  bool setDefaultNotebook(const Notebook::Ptr &nb);
565 
571  Notebook::Ptr defaultNotebook();
572 
579  Notebook::Ptr notebook(const QString &uid);
580 
588  Notebook::Ptr notebook(Notebook::List &list, const QString &uid);
589 
595  Notebook::List notebooks();
596 
604  void setValidateNotebooks(bool validateNotebooks);
605 
613  bool validateNotebooks();
614 
622  bool isValidNotebook(const QString &notebookUid);
623 
624  // Alarm Methods //
625 
636  KCalCore::Incidence::Ptr checkAlarm(const QString &uid, const QString &recurrenceId,
637  bool loadAlways = false);
638 
647  Notebook::Ptr createDefaultNotebook(QString name = QString(),
648  QString color = QString());
649 
657  virtual void virtual_hook(int id, void *data) = 0;
658 
659 protected:
660  virtual bool loadNotebooks() = 0;
661  virtual bool reloadNotebooks() = 0;
662  virtual bool modifyNotebook(const Notebook::Ptr &nb, DBOperation dbop,
663  bool signal = true) = 0;
664 
665  bool getLoadDates(const QDate &start, const QDate &end,
666  KDateTime &loadStart, KDateTime &loadEnd);
667 
668  void setLoadDates(const QDate &start, const QDate &end);
669 
670  void setModified(const QString &info);
671  void setProgress(const QString &info);
672  void setFinished(bool error, const QString &info);
673 
674  // These alarm methods are used to communicate with an external
675  // daemon, like timed, to bind Incidence::Alarm with the system notification.
676  void clearAlarms(const KCalCore::Incidence::Ptr &incidence);
677  void clearAlarms(const KCalCore::Incidence::List &incidences);
678  void clearAlarms(const QString &nname);
679  void setAlarms(const KCalCore::Incidence::Ptr &incidence);
680  void setAlarms(const KCalCore::Incidence::List &incidences);
681  void resetAlarms(const KCalCore::Incidence::List &incidences);
682  void resetAlarms(const KCalCore::Incidence::Ptr &incidence);
683 
684  bool isUncompletedTodosLoaded();
685  void setIsUncompletedTodosLoaded(bool loaded);
686 
687  bool isCompletedTodosDateLoaded();
688  void setIsCompletedTodosDateLoaded(bool loaded);
689  bool isCompletedTodosCreatedLoaded();
690  void setIsCompletedTodosCreatedLoaded(bool loaded);
691 
692  bool isJournalsLoaded();
693  void setIsJournalsLoaded(bool loaded);
694 
695  bool isDateLoaded();
696  void setIsDateLoaded(bool loaded);
697  bool isCreatedLoaded();
698  void setIsCreatedLoaded(bool loaded);
699  bool isFutureDateLoaded();
700  void setIsFutureDateLoaded(bool loaded);
701 
702  bool isGeoDateLoaded();
703  void setIsGeoDateLoaded(bool loaded);
704  bool isGeoCreatedLoaded();
705  void setIsGeoCreatedLoaded(bool loaded);
706 
707  bool isUnreadIncidencesLoaded();
708  void setIsUnreadIncidencesLoaded(bool loaded);
709 
710  bool isInvitationIncidencesLoaded();
711  void setIsInvitationIncidencesLoaded(bool loaded);
712 
713  void clearLoaded();
714 
715 private:
716  //@cond PRIVATE
717  Q_DISABLE_COPY(ExtendedStorage)
718  class MKCAL_HIDE Private;
719  Private *const d;
720  //@endcond
721 
722  friend class ::MkcalTool;
723 };
724 
725 }
726 
727 #endif
extendedcalendar.h
MKCAL_HIDE
#define MKCAL_HIDE
Definition: mkcal_export.h:31
mKCal::DBInsert
@ DBInsert
Definition: extendedstorage.h:56
mKCal::DBNone
@ DBNone
Definition: extendedstorage.h:55
mKCal::DBusService
const char *const DBusService
Definition: extendedstorage.h:64
notebook.h
mKCal::ExtendedStorage
This class provides a calendar storage interface.
Definition: extendedstorage.h:76
mKCal::DBOperation
DBOperation
Database operation type.
Definition: extendedstorage.h:54
mKCal::ExtendedStorageObserver
Definition: extendedstorageobserver.h:45
mkcal_export.h
mKCal::DBSelect
@ DBSelect
Definition: extendedstorage.h:60
KCalCore
Definition: extendedstorage.h:43
mKCal::Notebook::Ptr
QSharedPointer< Notebook > Ptr
A shared pointer to a Notebook object.
Definition: notebook.h:53
mKCal
Definition: extendedstorage.h:49
mKCal::ExtendedStorage::MarkDeleted
@ MarkDeleted
Definition: extendedstorage.h:87
mKCal::DBDelete
@ DBDelete
Definition: extendedstorage.h:59
mKCal::DBUpdate
@ DBUpdate
Definition: extendedstorage.h:57
mKCal::DBusName
const char *const DBusName
Definition: extendedstorage.h:67
mKCal::ExtendedStorage::Ptr
QSharedPointer< ExtendedStorage > Ptr
A shared pointer to a ExtendedStorage.
Definition: extendedstorage.h:94
mKCal::DBusInterface
const char *const DBusInterface
Definition: extendedstorage.h:65
mKCal::Notebook::List
QList< Ptr > List
List of notebooks.
Definition: notebook.h:63
MKCAL_EXPORT
#define MKCAL_EXPORT
Definition: mkcal_export.h:27
mKCal::DBusPath
const char *const DBusPath
Definition: extendedstorage.h:66
mKCal::DBMarkDeleted
@ DBMarkDeleted
Definition: extendedstorage.h:58
mKCal::ExtendedStorage::DeleteAction
DeleteAction
Action to be performed on save for deleted incidences.
Definition: extendedstorage.h:86

Generated on Sat Oct 17 2020 06:54:57 for libextendedkcal by doxygen 1.8.17