sqlitestorage.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  Copyright (c) 2014-2019 Jolla Ltd.
6  Copyright (c) 2019 Open Mobile Platform LLC.
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public
10  License as published by the Free Software Foundation; either
11  version 2 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public License
19  along with this library; see the file COPYING.LIB. If not, write to
20  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  Boston, MA 02110-1301, USA.
22 
23 */
34 #ifndef MKCAL_SQLITESTORAGE_H
35 #define MKCAL_SQLITESTORAGE_H
36 
37 #include "mkcal_export.h"
38 #include "extendedstorage.h"
39 
40 #include <sqlite3.h>
41 
42 namespace mKCal {
43 
44 const int VersionMajor = 11; // Major version, if different than stored in database, open fails
45 const int VersionMinor = 0; // Minor version, if different than stored in database, open warning
46 
54 {
55  Q_OBJECT
56 
57 public:
58 
62  typedef QSharedPointer<SqliteStorage> Ptr;
63 
73  explicit SqliteStorage(const ExtendedCalendar::Ptr &cal,
74  const QString &databaseName,
75  bool validateNotebooks = false);
76 
80  virtual ~SqliteStorage();
81 
85  QString databaseName() const;
86 
91  bool open();
92 
97  bool load();
98 
103  bool load(const QString &uid, const KDateTime &recurrenceId = KDateTime());
104 
109  bool load(const QDate &date);
110 
115  bool load(const QDate &start, const QDate &end);
116 
121  bool loadSeries(const QString &uid);
122 
127  bool loadNotebookIncidences(const QString &notebookUid);
128 
133  bool loadJournals();
134 
139  bool loadPlainIncidences();
140 
145  bool loadRecurringIncidences();
146 
151  bool loadGeoIncidences();
152 
157  bool loadGeoIncidences(float geoLatitude, float geoLongitude,
158  float diffLatitude, float diffLongitude);
159 
164  bool loadAttendeeIncidences();
165 
170  int loadUncompletedTodos();
171 
176  int loadCompletedTodos(bool hasDate, int limit, KDateTime *last);
177 
182  int loadIncidences(bool hasDate, int limit, KDateTime *last);
183 
188  int loadFutureIncidences(int limit, KDateTime *last);
189 
194  int loadGeoIncidences(bool hasDate, int limit, KDateTime *last);
195 
200  int loadUnreadInvitationIncidences();
201 
206  int loadOldInvitationIncidences(int limit, KDateTime *last);
207 
212  KCalCore::Person::List loadContacts();
213 
218  int loadContactIncidences(const KCalCore::Person::Ptr &person, int limit, KDateTime *last);
219 
224  int loadJournals(int limit, KDateTime *last);
225 
230  bool notifyOpened(const KCalCore::Incidence::Ptr &incidence);
231 
236  bool purgeDeletedIncidences(const KCalCore::Incidence::List &list);
237 
242  bool save();
243 
248  bool save(ExtendedStorage::DeleteAction deleteAction);
249 
254  bool cancel();
255 
260  bool close();
261 
266  void calendarModified(bool modified, KCalCore::Calendar *calendar);
267 
272  void calendarIncidenceCreated(const KCalCore::Incidence::Ptr &incidence);
273 
278  void calendarIncidenceAdded(const KCalCore::Incidence::Ptr &incidence);
279 
284  void calendarIncidenceChanged(const KCalCore::Incidence::Ptr &incidence);
285 
290  void calendarIncidenceDeleted(const KCalCore::Incidence::Ptr &incidence);
291 
296  void calendarIncidenceAdditionCanceled(const KCalCore::Incidence::Ptr &incidence);
297 
302  bool insertedIncidences(KCalCore::Incidence::List *list, const KDateTime &after,
303  const QString &notebookUid = QString());
304 
309  bool modifiedIncidences(KCalCore::Incidence::List *list, const KDateTime &after,
310  const QString &notebookUid = QString());
311 
316  bool deletedIncidences(KCalCore::Incidence::List *list, const KDateTime &after,
317  const QString &notebookUid = QString());
318 
323  bool allIncidences(KCalCore::Incidence::List *list, const QString &notebookUid = QString());
324 
329  bool duplicateIncidences(KCalCore::Incidence::List *list,
330  const KCalCore::Incidence::Ptr &incidence,
331  const QString &notebookUid = QString());
332 
337  KDateTime incidenceDeletedDate(const KCalCore::Incidence::Ptr &incidence);
338 
343  int eventCount();
344 
349  int todoCount();
350 
355  int journalCount();
356 
361  virtual void virtual_hook(int id, void *data);
362 
363 
364  // Helper Functions //
365 
372  sqlite3_int64 toOriginTime(KDateTime dt);
373 
380  sqlite3_int64 toLocalOriginTime(KDateTime dt);
381 
387  KDateTime fromLocalOriginTime(sqlite3_int64 seconds);
388 
394  KDateTime fromOriginTime(sqlite3_int64 seconds);
395 
402  KDateTime fromOriginTime(sqlite3_int64 seconds, QString zonename);
403 
404 private:
410  bool initializeDatabase();
411 
412 protected:
413  bool loadNotebooks();
414  bool reloadNotebooks();
415  bool modifyNotebook(const Notebook::Ptr &nb, DBOperation dbop, bool signal = true);
416 
417 private:
418  //@cond PRIVATE
419  Q_DISABLE_COPY(SqliteStorage)
420  class MKCAL_HIDE Private;
421  Private *const d;
422  //@endcond
423 
424 public Q_SLOTS:
425  void fileChanged(const QString &path);
426 
427  void queryFinished();
428 };
429 
430 #define sqlite3_exec( db ) \
431 { \
432  /* kDebug() << "SQL query:" << query; */ \
433  rv = sqlite3_exec( (db), query, NULL, 0, &errmsg ); \
434  if ( rv ) { \
435  if ( rv != SQLITE_CONSTRAINT ) { \
436  qCWarning(lcMkcal) << "sqlite3_exec error code:" << rv; \
437  } \
438  if ( errmsg ) { \
439  if ( rv != SQLITE_CONSTRAINT ) { \
440  qCWarning(lcMkcal) << errmsg; \
441  } \
442  sqlite3_free( errmsg ); \
443  errmsg = NULL; \
444  } \
445  if ( rv != SQLITE_CONSTRAINT ) { \
446  goto error; \
447  } \
448  } \
449 }
450 
451 #define sqlite3_prepare_v2( db, query, qsize, stmt, tail ) \
452 { \
453  /* kDebug() << "SQL query:" << query; */ \
454  rv = sqlite3_prepare_v2( (db), (query), (qsize), (stmt), (tail) ); \
455  if ( rv ) { \
456  qCWarning(lcMkcal) << "sqlite3_prepare error code:" << rv; \
457  qCWarning(lcMkcal) << sqlite3_errmsg( (db) ); \
458  goto error; \
459  } \
460 }
461 
462 #define sqlite3_bind_text( stmt, index, value, size, desc ) \
463 { \
464  rv = sqlite3_bind_text( (stmt), (index), (value), (size), (desc) ); \
465  if ( rv ) { \
466  qCWarning(lcMkcal) << "sqlite3_bind_text error:" << rv << "on index and value:" << index << value; \
467  goto error; \
468  } \
469  index++; \
470 }
471 
472 #define sqlite3_bind_int( stmt, index, value ) \
473 { \
474  rv = sqlite3_bind_int( (stmt), (index), (value) ); \
475  if ( rv ) { \
476  qCWarning(lcMkcal) << "sqlite3_bind_int error:" << rv << "on index and value:" << index << value; \
477  goto error; \
478  } \
479  index++; \
480 }
481 
482 #define sqlite3_bind_int64( stmt, index, value ) \
483 { \
484  rv = sqlite3_bind_int64( (stmt), (index), (value) ); \
485  if ( rv ) { \
486  qCWarning(lcMkcal) << "sqlite3_bind_int64 error:" << rv << "on index and value:" << index << value; \
487  goto error; \
488  } \
489  index++; \
490 }
491 
492 #define sqlite3_bind_double( stmt, index, value ) \
493 { \
494  rv = sqlite3_bind_double( (stmt), (index), (value) ); \
495  if ( rv ) { \
496  qCWarning(lcMkcal) << "sqlite3_bind_int error:" << rv << "on index and value:" << index << value; \
497  goto error; \
498  } \
499  index++; \
500 }
501 
502 #define sqlite3_step( stmt ) \
503 { \
504  rv = sqlite3_step( (stmt) ); \
505  if ( rv && rv != SQLITE_DONE && rv != SQLITE_ROW ) { \
506  if ( rv != SQLITE_CONSTRAINT ) { \
507  qCWarning(lcMkcal) << "sqlite3_step error:" << rv; \
508  } \
509  goto error; \
510  } \
511 }
512 
513 #define CREATE_VERSION \
514  "CREATE TABLE IF NOT EXISTS Version(Major INTEGER, Minor INTEGER)"
515 #define CREATE_TIMEZONES \
516  "CREATE TABLE IF NOT EXISTS Timezones(TzId INTEGER PRIMARY KEY, ICalData TEXT)"
517 #define CREATE_CALENDARS \
518  "CREATE TABLE IF NOT EXISTS Calendars(CalendarId TEXT PRIMARY KEY, Name TEXT, Description TEXT, Color INTEGER, Flags INTEGER, syncDate INTEGER, pluginName TEXT, account TEXT, attachmentSize INTEGER, modifiedDate INTEGER, sharedWith TEXT, syncProfile TEXT, createdDate INTEGER, extra1 STRING, extra2 STRING)"
519 
520 //Extra fields added for future use in case they are needed. They will be documented here
521 //So we can add somthing without breaking the schema and not adding tables
522 
523 #define CREATE_COMPONENTS \
524  "CREATE TABLE IF NOT EXISTS Components(ComponentId INTEGER PRIMARY KEY AUTOINCREMENT, Notebook TEXT, Type TEXT, Summary TEXT, Category TEXT, DateStart INTEGER, DateStartLocal INTEGER, StartTimeZone TEXT, HasDueDate INTEGER, DateEndDue INTEGER, DateEndDueLocal INTEGER, EndDueTimeZone TEXT, Duration INTEGER, Classification INTEGER, Location TEXT, Description TEXT, Status INTEGER, GeoLatitude REAL, GeoLongitude REAL, Priority INTEGER, Resources TEXT, DateCreated INTEGER, DateStamp INTEGER, DateLastModified INTEGER, Sequence INTEGER, Comments TEXT, Attachments TEXT, Contact TEXT, InvitationStatus INTEGER, RecurId INTEGER, RecurIdLocal INTEGER, RecurIdTimeZone TEXT, RelatedTo TEXT, URL TEXT, UID TEXT, Transparency INTEGER, LocalOnly INTEGER, Percent INTEGER, DateCompleted INTEGER, DateCompletedLocal INTEGER, CompletedTimeZone TEXT, DateDeleted INTEGER, extra1 STRING, extra2 STRING, extra3 INTEGER)"
525 
526 //Extra fields added for future use in case they are needed. They will be documented here
527 //So we can add somthing without breaking the schema and not adding tables
528 
529 #define CREATE_RDATES \
530  "CREATE TABLE IF NOT EXISTS Rdates(ComponentId INTEGER, Type INTEGER, Date INTEGER, DateLocal INTEGER, TimeZone TEXT)"
531 #define CREATE_CUSTOMPROPERTIES \
532  "CREATE TABLE IF NOT EXISTS Customproperties(ComponentId INTEGER, Name TEXT, Value TEXT, Parameters TEXT)"
533 #define CREATE_RECURSIVE \
534  "CREATE TABLE IF NOT EXISTS Recursive(ComponentId INTEGER, RuleType INTEGER, Frequency INTEGER, Until INTEGER, UntilLocal INTEGER, untilTimeZone TEXT, Count INTEGER, Interval INTEGER, BySecond TEXT, ByMinute TEXT, ByHour TEXT, ByDay TEXT, ByDayPos Text, ByMonthDay TEXT, ByYearDay TEXT, ByWeekNum TEXT, ByMonth TEXT, BySetPos TEXT, WeekStart INTEGER)"
535 #define CREATE_ALARM \
536  "CREATE TABLE IF NOT EXISTS Alarm(ComponentId INTEGER, Action INTEGER, Repeat INTEGER, Duration INTEGER, Offset INTEGER, Relation TEXT, DateTrigger INTEGER, DateTriggerLocal INTEGER, triggerTimeZone TEXT, Description TEXT, Attachment TEXT, Summary TEXT, Address TEXT, CustomProperties TEXT, isEnabled INTEGER)"
537 #define CREATE_ATTENDEE \
538 "CREATE TABLE IF NOT EXISTS Attendee(ComponentId INTEGER, Email TEXT, Name TEXT, IsOrganizer INTEGER, Role INTEGER, PartStat INTEGER, Rsvp INTEGER, DelegatedTo TEXT, DelegatedFrom TEXT)"
539 #define CREATE_CALENDARPROPERTIES \
540  "CREATE TABLE IF NOT EXISTS Calendarproperties(CalendarId REFERENCES Calendars(CalendarId) ON DELETE CASCADE, Name TEXT NOT NULL, Value TEXT, UNIQUE (CalendarId, Name))"
541 
542 #define INDEX_CALENDAR \
543 "CREATE INDEX IF NOT EXISTS IDX_CALENDAR on Calendars(CalendarId)"
544 #define INDEX_INVITATION \
545 "CREATE INDEX IF NOT EXISTS IDX_INVITATION on Invitations(InvitationId)"
546 #define INDEX_COMPONENT \
547 "CREATE INDEX IF NOT EXISTS IDX_COMPONENT on Components(ComponentId, Notebook, DateStart, DateEndDue, DateDeleted)"
548 #define INDEX_COMPONENT_UID \
549 "CREATE UNIQUE INDEX IF NOT EXISTS IDX_COMPONENT_UID on Components(UID, RecurId, DateDeleted)"
550 #define INDEX_COMPONENT_NOTEBOOK \
551 "CREATE INDEX IF NOT EXISTS IDX_COMPONENT_NOTEBOOK on Components(Notebook)"
552 #define INDEX_RDATES \
553 "CREATE INDEX IF NOT EXISTS IDX_RDATES on Rdates(ComponentId)"
554 #define INDEX_CUSTOMPROPERTIES \
555 "CREATE INDEX IF NOT EXISTS IDX_CUSTOMPROPERTIES on Customproperties(ComponentId)"
556 #define INDEX_RECURSIVE \
557 "CREATE INDEX IF NOT EXISTS IDX_RECURSIVE on Recursive(ComponentId)"
558 #define INDEX_ALARM \
559 "CREATE INDEX IF NOT EXISTS IDX_ALARM on Alarm(ComponentId)"
560 #define INDEX_ATTENDEE \
561 "CREATE UNIQUE INDEX IF NOT EXISTS IDX_ATTENDEE on Attendee(ComponentId, Email)"
562 #define INDEX_CALENDARPROPERTIES \
563 "CREATE INDEX IF NOT EXISTS IDX_CALENDARPROPERTIES on Calendarproperties(CalendarId)"
564 
565 #define INSERT_VERSION \
566 "insert into Version values (?, ?)"
567 #define INSERT_TIMEZONES \
568 "insert into Timezones values (1, '')"
569 #define INSERT_CALENDARS \
570 "insert into Calendars values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '', '')"
571 #define INSERT_INVITATIONS \
572 "insert into Invitations values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
573 #define INSERT_COMPONENTS \
574 "insert into Components values (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, '', '', 0)"
575 #define INSERT_CUSTOMPROPERTIES \
576 "insert into Customproperties values (?, ?, ?, ?)"
577 #define INSERT_CALENDARPROPERTIES \
578 "insert into Calendarproperties values (?, ?, ?)"
579 #define INSERT_RDATES \
580 "insert into Rdates values (?, ?, ?, ?, ?)"
581 #define INSERT_RECURSIVE \
582 "insert into Recursive values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
583 #define INSERT_ALARM \
584 "insert into Alarm values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
585 #define INSERT_ATTENDEE \
586 "insert into Attendee values (?, ?, ?, ?, ?, ?, ?, ?, ?)"
587 
588 #define UPDATE_TIMEZONES \
589 "update Timezones set ICalData=? where TzId=1"
590 #define UPDATE_CALENDARS \
591 "update Calendars set Name=?, Description=?, Color=?, Flags=?, syncDate=?, pluginName=?, account=?, attachmentSize=?, modifiedDate=?, sharedWith=?, syncProfile=?, createdDate=? where CalendarId=?"
592 #define UPDATE_COMPONENTS \
593 "update Components set Notebook=?, Type=?, Summary=?, Category=?, DateStart=?, DateStartLocal=?, StartTimeZone=?, HasDueDate=?, DateEndDue=?, DateEndDueLocal=?, EndDueTimeZone=?, Duration=?, Classification=?, Location=?, Description=?, Status=?, GeoLatitude=?, GeoLongitude=?, Priority=?, Resources=?, DateCreated=?, DateStamp=?, DateLastModified=?, Sequence=?, Comments=?, Attachments=?, Contact=?, InvitationStatus=?, RecurId=?, RecurIdLocal=?, RecurIdTimeZone=?, RelatedTo=?, URL=?, UID=?, Transparency=?, LocalOnly=?, DateCompleted=?, DateCompletedLocal=?, CompletedTimeZone=?, Percent=? where ComponentId=?"
594 #define UPDATE_COMPONENTS_AS_DELETED \
595 "update Components set DateDeleted=? where ComponentId=?"
596 //"update Components set DateDeleted=strftime('%s','now') where ComponentId=?"
597 
598 #define DELETE_TIMEZONES \
599 "delete from Timezones where TzId=1"
600 #define DELETE_CALENDARS \
601 "delete from Calendars where CalendarId=?"
602 #define DELETE_INVITATIONS \
603 "delete from Invitations where InvitationId=?"
604 #define DELETE_COMPONENTS \
605 "delete from Components where ComponentId=?"
606 #define DELETE_RDATES \
607 "delete from Rdates where ComponentId=?"
608 #define DELETE_CUSTOMPROPERTIES \
609 "delete from Customproperties where ComponentId=?"
610 #define DELETE_CALENDARPROPERTIES \
611 "delete from Calendarproperties where CalendarId=?"
612 #define DELETE_RECURSIVE \
613 "delete from Recursive where ComponentId=?"
614 #define DELETE_ALARM \
615 "delete from Alarm where ComponentId=?"
616 #define DELETE_ATTENDEE \
617 "delete from Attendee where ComponentId=?"
618 
619 #define SELECT_VERSION \
620 "select * from Version"
621 #define SELECT_TIMEZONES \
622 "select * from Timezones where TzId=1"
623 #define SELECT_CALENDARS_ALL \
624 "select * from Calendars order by Name"
625 #define SELECT_INVITATIONS_ALL \
626 "select * from Invitations"
627 #define SELECT_COMPONENTS_ALL \
628 "select * from Components where DateDeleted=0"
629 #define SELECT_COMPONENTS_BY_NOTEBOOK \
630 "select * from Components where Notebook=? and DateDeleted=0"
631 #define SELECT_COMPONENTS_BY_GEO \
632 "select * from Components where GeoLatitude!=255.0 and GeoLongitude!=255.0 and DateDeleted=0"
633 #define SELECT_COMPONENTS_BY_GEO_AREA \
634 "select * from Components where GeoLatitude>=? and GeoLongitude>=? and GeoLatitude<=? and GeoLongitude<=? and DateDeleted=0"
635 #define SELECT_COMPONENTS_BY_JOURNAL \
636 "select * from Components where Type='Journal' and DateDeleted=0"
637 #define SELECT_COMPONENTS_BY_JOURNAL_DATE \
638 "select * from Components where Type='Journal' and DateDeleted=0 and datestart<=? order by DateStart desc, DateCreated desc"
639 #define SELECT_COMPONENTS_BY_PLAIN \
640 "select * from Components where DateStart=0 and DateEndDue=0 and DateDeleted=0"
641 #define SELECT_COMPONENTS_BY_RECURSIVE \
642 "select * from components where ((ComponentId in (select DISTINCT ComponentId from recursive)) or (RecurId!=0)) and DateDeleted=0"
643 #define SELECT_COMPONENTS_BY_ATTENDEE \
644 "select * from components where ComponentId in (select DISTINCT ComponentId from attendee) and DateDeleted=0"
645 #define SELECT_COMPONENTS_BY_DATE_BOTH \
646 "select * from Components where DateStart<=? and DateEndDue>=? and DateDeleted=0"
647 #define SELECT_COMPONENTS_BY_DATE_START \
648 "select * from Components where DateEndDue>=? and DateDeleted=0"
649 #define SELECT_COMPONENTS_BY_DATE_END \
650 "select * from Components where DateStart<=? and DateDeleted=0"
651 #define SELECT_COMPONENTS_BY_UID_AND_RECURID \
652 "select * from Components where UID=? and RecurId=? and DateDeleted=0"
653 #define SELECT_COMPONENTS_BY_UID \
654 "select * from Components where UID=? and DateDeleted=0"
655 #define SELECT_COMPONENTS_BY_NOTEBOOKUID \
656 "select * from Components where Notebook=? and DateDeleted=0"
657 #define SELECT_ROWID_FROM_COMPONENTS_BY_UID_AND_RECURID \
658 "select ComponentId from Components where UID=? and RecurId=? and DateDeleted=0"
659 #define SELECT_COMPONENTS_BY_UNCOMPLETED_TODOS \
660 "select * from Components where Type='Todo' and DateCompleted=0 and DateDeleted=0"
661 #define SELECT_COMPONENTS_BY_COMPLETED_TODOS_AND_DATE \
662 "select * from Components where Type='Todo' and DateCompleted<>0 and DateEndDue<>0 and DateEndDue<=? and DateDeleted=0 order by DateEndDue desc, DateCreated desc"
663 #define SELECT_COMPONENTS_BY_COMPLETED_TODOS_AND_CREATED \
664 "select * from Components where Type='Todo' and DateCompleted<>0 and DateEndDue=0 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
665 #define SELECT_COMPONENTS_BY_DATE_SMART \
666 "select * from Components where DateEndDue<>0 and DateEndDue<=? and DateDeleted=0 order by DateEndDue desc, DateCreated desc"
667 
668 #define FUTURE_DATE_SMART_FIELD \
669 " (case type when 'Todo' then DateEndDue else DateStart end) "
670 #define SELECT_COMPONENTS_BY_FUTURE_DATE_SMART \
671  "select * from Components where " \
672  FUTURE_DATE_SMART_FIELD ">=? and DateDeleted=0 order by " \
673  FUTURE_DATE_SMART_FIELD " asc, DateCreated asc"
674 
675 #define SELECT_COMPONENTS_BY_CREATED_SMART \
676 "select * from Components where DateEndDue=0 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
677 #define SELECT_COMPONENTS_BY_GEO_AND_DATE \
678 "select * from Components where GeoLatitude!=255.0 and GeoLongitude!=255.0 and DateEndDue<>0 and DateEndDue<=? and DateDeleted=0 order by DateEndDue desc, DateCreated desc"
679 #define SELECT_COMPONENTS_BY_GEO_AND_CREATED \
680 "select * from Components where GeoLatitude!=255.0 and GeoLongitude!=255.0 and DateEndDue=0 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
681 #define SELECT_COMPONENTS_BY_INVITATION_UNREAD \
682 "select * from Components where InvitationStatus=1 and DateDeleted=0"
683 #define SELECT_COMPONENTS_BY_INVITATION_AND_CREATED \
684 "select * from Components where InvitationStatus>1 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
685 #define SELECT_COMPONENTS_BY_ATTENDEE_EMAIL_AND_CREATED \
686 "select * from Components where ComponentId in (select distinct ComponentId from Attendee where email=?) and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
687 #define SELECT_COMPONENTS_BY_ATTENDEE_AND_CREATED \
688 "select * from Components where ComponentId in (select distinct ComponentId from Attendee) and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
689 #define SELECT_RDATES_BY_ID \
690 "select * from Rdates where ComponentId=?"
691 #define SELECT_CUSTOMPROPERTIES_BY_ID \
692 "select * from Customproperties where ComponentId=?"
693 #define SELECT_RECURSIVE_BY_ID \
694 "select * from Recursive where ComponentId=?"
695 #define SELECT_ALARM_BY_ID \
696 "select * from Alarm where ComponentId=?"
697 #define SELECT_ATTENDEE_BY_ID \
698 "select * from Attendee where ComponentId=?"
699 #define SELECT_CALENDARPROPERTIES_BY_ID \
700 "select * from Calendarproperties where CalendarId=?"
701 #define SELECT_COMPONENTS_BY_DUPLICATE \
702 "select * from Components where DateStart=? and Summary=? and DateDeleted=0"
703 #define SELECT_COMPONENTS_BY_DUPLICATE_AND_NOTEBOOK \
704 "select * from Components where DateStart=? and Summary=? and Notebook=? and DateDeleted=0"
705 #define SELECT_COMPONENTS_BY_CREATED \
706 "select * from Components where DateCreated>=? and DateDeleted=0"
707 #define SELECT_COMPONENTS_BY_CREATED_AND_NOTEBOOK \
708 "select * from Components where DateCreated>=? and Notebook=? and DateDeleted=0"
709 #define SELECT_COMPONENTS_BY_LAST_MODIFIED \
710 "select * from Components where DateLastModified>=? and DateCreated<? and DateDeleted=0"
711 #define SELECT_COMPONENTS_BY_LAST_MODIFIED_AND_NOTEBOOK \
712 "select * from Components where DateLastModified>=? and DateCreated<? and Notebook=? and DateDeleted=0"
713 #define SELECT_COMPONENTS_BY_DELETED \
714 "select * from Components where DateDeleted>=? and DateCreated<?"
715 #define SELECT_COMPONENTS_BY_DELETED_AND_NOTEBOOK \
716 "select * from Components where DateDeleted>=? and DateCreated<? and Notebook=?"
717 #define SELECT_COMPONENTS_BY_UID_RECID_AND_DELETED \
718 "select ComponentId, DateDeleted from Components where UID=? and RecurId=? and DateDeleted<>0"
719 #define SELECT_ATTENDEE_AND_COUNT \
720 "select Email, Name, count(Email) from Attendee where Email<>0 group by Email"
721 #define SELECT_EVENT_COUNT \
722 "select count(*) from Components where Type='Event' and DateDeleted=0"
723 #define SELECT_TODO_COUNT \
724 "select count(*) from Components where Type='Todo' and DateDeleted=0"
725 #define SELECT_JOURNAL_COUNT \
726 "select count(*) from Components where Type='Journal' and DateDeleted=0"
727 
728 #define BEGIN_TRANSACTION \
729 "BEGIN IMMEDIATE;"
730 #define COMMIT_TRANSACTION \
731 "END;"
732 
733 }
734 
735 #endif
mKCal::VersionMajor
const int VersionMajor
Definition: sqlitestorage.h:44
MKCAL_HIDE
#define MKCAL_HIDE
Definition: mkcal_export.h:31
mKCal::SqliteStorage
This class provides a calendar storage as an sqlite database.
Definition: sqlitestorage.h:53
mKCal::ExtendedStorage
This class provides a calendar storage interface.
Definition: extendedstorage.h:76
mKCal::DBOperation
DBOperation
Database operation type.
Definition: extendedstorage.h:54
mkcal_export.h
mKCal::SqliteStorage::Ptr
QSharedPointer< SqliteStorage > Ptr
A shared pointer to a SqliteStorage.
Definition: sqlitestorage.h:62
mKCal::Notebook::Ptr
QSharedPointer< Notebook > Ptr
A shared pointer to a Notebook object.
Definition: notebook.h:53
mKCal
Definition: extendedstorage.h:49
MKCAL_EXPORT
#define MKCAL_EXPORT
Definition: mkcal_export.h:27
extendedstorage.h
mKCal::VersionMinor
const int VersionMinor
Definition: sqlitestorage.h:45
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