00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00033 #ifndef MKCAL_SQLITESTORAGE_H
00034 #define MKCAL_SQLITESTORAGE_H
00035
00036 #include "mkcal_export.h"
00037 #include "extendedstorage.h"
00038
00039 #include <sqlite3.h>
00040
00041 namespace mKCal {
00042
00043 const int VersionMajor = 11;
00044 const int VersionMinor = 0;
00045
00052 class MKCAL_EXPORT SqliteStorage : public ExtendedStorage
00053 {
00054 Q_OBJECT
00055
00056 public:
00057
00061 typedef QSharedPointer<SqliteStorage> Ptr;
00062
00076 explicit SqliteStorage( const ExtendedCalendar::Ptr &cal,
00077 const QString &databaseName,
00078 bool useTracker = false,
00079 bool validateNotebooks = false,
00080 bool synchronousTrackerSave = false);
00081
00085 virtual ~SqliteStorage();
00086
00090 QString databaseName() const;
00091
00095 bool useTracker() const;
00096
00101 bool open();
00102
00107 bool load();
00108
00113 bool load( const QString &uid, const KDateTime &recurrenceId = KDateTime() );
00114
00119 bool load( const QDate &date );
00120
00125 bool load( const QDate &start, const QDate &end );
00126
00131 bool loadNotebookIncidences( const QString ¬ebookUid );
00132
00137 bool loadJournals();
00138
00143 bool loadPlainIncidences();
00144
00149 bool loadRecurringIncidences();
00150
00155 bool loadGeoIncidences();
00156
00161 bool loadGeoIncidences( float geoLatitude, float geoLongitude,
00162 float diffLatitude, float diffLongitude );
00163
00168 bool loadAttendeeIncidences();
00169
00174 int loadUncompletedTodos();
00175
00180 int loadCompletedTodos( bool hasDate, int limit, KDateTime *last );
00181
00186 int loadIncidences( bool hasDate, int limit, KDateTime *last );
00187
00192 int loadFutureIncidences( int limit, KDateTime *last );
00193
00198 int loadGeoIncidences( bool hasDate, int limit, KDateTime *last );
00199
00204 int loadUnreadInvitationIncidences();
00205
00210 int loadOldInvitationIncidences( int limit, KDateTime *last );
00211
00216 KCalCore::Person::List loadContacts();
00217
00222 int loadContactIncidences( const KCalCore::Person::Ptr &person, int limit, KDateTime *last );
00223
00228 int loadJournals( int limit, KDateTime *last );
00229
00234 bool notifyOpened( const KCalCore::Incidence::Ptr &incidence );
00235
00240 bool save();
00241
00246 bool cancel();
00247
00252 bool close();
00253
00258 void calendarModified( bool modified, KCalCore::Calendar *calendar );
00259
00264 void calendarIncidenceCreated( const KCalCore::Incidence::Ptr &incidence );
00265
00270 void calendarIncidenceAdded( const KCalCore::Incidence::Ptr &incidence );
00271
00276 void calendarIncidenceChanged( const KCalCore::Incidence::Ptr &incidence );
00277
00282 void calendarIncidenceDeleted( const KCalCore::Incidence::Ptr &incidence );
00283
00288 void calendarIncidenceAdditionCanceled( const KCalCore::Incidence::Ptr &incidence );
00289
00294 bool insertedIncidences( KCalCore::Incidence::List *list, const KDateTime &after,
00295 const QString ¬ebookUid = QString() );
00296
00301 bool modifiedIncidences( KCalCore::Incidence::List *list, const KDateTime &after,
00302 const QString ¬ebookUid = QString() );
00303
00308 bool deletedIncidences( KCalCore::Incidence::List *list, const KDateTime &after,
00309 const QString ¬ebookUid = QString() );
00310
00315 bool deletedIncidencesCreatedAfter( KCalCore::Incidence::List *list, const KDateTime &after,
00316 const QString ¬ebookUid = QString() );
00317
00322 bool allIncidences( KCalCore::Incidence::List *list, const QString ¬ebookUid = QString() );
00323
00328 bool duplicateIncidences( KCalCore::Incidence::List *list,
00329 const KCalCore::Incidence::Ptr &incidence,
00330 const QString ¬ebookUid = QString() );
00331
00336 KDateTime incidenceDeletedDate( const KCalCore::Incidence::Ptr &incidence );
00337
00342 int eventCount();
00343
00348 int todoCount();
00349
00354 int journalCount();
00355
00360 virtual void virtual_hook( int id, void *data );
00361
00362
00363
00364
00371 sqlite3_int64 toOriginTime( KDateTime dt );
00372
00379 sqlite3_int64 toLocalOriginTime(KDateTime dt);
00380
00386 KDateTime fromOriginTime( sqlite3_int64 seconds );
00387
00394 KDateTime fromOriginTime( sqlite3_int64 seconds, QString zonename );
00395
00400 const QList<int> saveErrors();
00401
00406 const QList<int> modifyNotebookErrors();
00407
00408 protected:
00409 bool loadNotebooks();
00410 bool reloadNotebooks();
00411 bool modifyNotebook( const Notebook::Ptr &nb, DBOperation dbop, bool signal = true );
00412
00413 private:
00414
00415 Q_DISABLE_COPY( SqliteStorage )
00416 class MKCAL_HIDE Private;
00417 Private *const d;
00418
00419
00420 public Q_SLOTS:
00421 void fileChanged( const QString &path );
00422
00423 void queryFinished();
00424
00425 };
00426
00427 #define sqlite3_exec( db ) \
00428 { \
00429 \
00430 rv = sqlite3_exec( (db), query, NULL, 0, &errmsg ); \
00431 if ( rv ) { \
00432 if ( rv != SQLITE_CONSTRAINT ) { \
00433 kError() << "sqlite3_exec error code:" << rv; \
00434 } \
00435 if ( errmsg ) { \
00436 if ( rv != SQLITE_CONSTRAINT ) { \
00437 kError() << errmsg; \
00438 } \
00439 sqlite3_free( errmsg ); \
00440 errmsg = NULL; \
00441 } \
00442 if ( rv != SQLITE_CONSTRAINT ) { \
00443 goto error; \
00444 } \
00445 } \
00446 }
00447
00448 #define sqlite3_prepare_v2( db, query, qsize, stmt, tail ) \
00449 { \
00450 \
00451 rv = sqlite3_prepare_v2( (db), (query), (qsize), (stmt), (tail) ); \
00452 if ( rv ) { \
00453 kError() << "sqlite3_prepare error code:" << rv; \
00454 kError() << sqlite3_errmsg( (db) ); \
00455 goto error; \
00456 } \
00457 }
00458
00459 #define sqlite3_bind_text( stmt, index, value, size, desc ) \
00460 { \
00461 rv = sqlite3_bind_text( (stmt), (index), (value), (size), (desc) ); \
00462 if ( rv ) { \
00463 kError() << "sqlite3_bind_text error:" << rv << "on index and value:" << index << value; \
00464 goto error; \
00465 } \
00466 index++; \
00467 }
00468
00469 #define sqlite3_bind_int( stmt, index, value ) \
00470 { \
00471 rv = sqlite3_bind_int( (stmt), (index), (value) ); \
00472 if ( rv ) { \
00473 kError() << "sqlite3_bind_int error:" << rv << "on index and value:" << index << value; \
00474 goto error; \
00475 } \
00476 index++; \
00477 }
00478
00479 #define sqlite3_bind_int64( stmt, index, value ) \
00480 { \
00481 rv = sqlite3_bind_int64( (stmt), (index), (value) ); \
00482 if ( rv ) { \
00483 kError() << "sqlite3_bind_int64 error:" << rv << "on index and value:" << index << value; \
00484 goto error; \
00485 } \
00486 index++; \
00487 }
00488
00489 #define sqlite3_bind_double( stmt, index, value ) \
00490 { \
00491 rv = sqlite3_bind_double( (stmt), (index), (value) ); \
00492 if ( rv ) { \
00493 kError() << "sqlite3_bind_int error:" << rv << "on index and value:" << index << value; \
00494 goto error; \
00495 } \
00496 index++; \
00497 }
00498
00499 #define sqlite3_step( stmt ) \
00500 { \
00501 rv = sqlite3_step( (stmt) ); \
00502 if ( rv && rv != SQLITE_DONE && rv != SQLITE_ROW ) { \
00503 if ( rv != SQLITE_CONSTRAINT ) { \
00504 kError() << "sqlite3_step error:" << rv; \
00505 } \
00506 goto error; \
00507 } \
00508 }
00509
00510 #define CREATE_VERSION \
00511 "CREATE TABLE IF NOT EXISTS Version(Major INTEGER, Minor INTEGER)"
00512 #define CREATE_TIMEZONES \
00513 "CREATE TABLE IF NOT EXISTS Timezones(TzId INTEGER PRIMARY KEY, ICalData TEXT)"
00514 #define CREATE_CALENDARS \
00515 "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)"
00516
00517
00518
00519
00520 #define CREATE_COMPONENTS \
00521 "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)"
00522
00523
00524
00525
00526 #define CREATE_RDATES \
00527 "CREATE TABLE IF NOT EXISTS Rdates(ComponentId INTEGER, Type INTEGER, Date INTEGER, DateLocal INTEGER, TimeZone TEXT)"
00528 #define CREATE_CUSTOMPROPERTIES \
00529 "CREATE TABLE IF NOT EXISTS Customproperties(ComponentId INTEGER, Name TEXT, Value TEXT, Parameters TEXT)"
00530 #define CREATE_RECURSIVE \
00531 "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)"
00532 #define CREATE_ALARM \
00533 "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)"
00534 #define CREATE_ATTENDEE \
00535 "CREATE TABLE IF NOT EXISTS Attendee(ComponentId INTEGER, Email TEXT, Name TEXT, IsOrganizer INTEGER, Role INTEGER, PartStat INTEGER, Rsvp INTEGER, DelegatedTo TEXT, DelegatedFrom TEXT)"
00536
00537 #define INDEX_CALENDAR \
00538 "CREATE INDEX IF NOT EXISTS IDX_CALENDAR on Calendars(CalendarId)"
00539 #define INDEX_INVITATION \
00540 "CREATE INDEX IF NOT EXISTS IDX_INVITATION on Invitations(InvitationId)"
00541 #define INDEX_COMPONENT \
00542 "CREATE INDEX IF NOT EXISTS IDX_COMPONENT on Components(ComponentId, Notebook, DateStart, DateEndDue, DateDeleted)"
00543 #define INDEX_COMPONENT_UID \
00544 "CREATE UNIQUE INDEX IF NOT EXISTS IDX_COMPONENT_UID on Components(UID, RecurId, DateDeleted)"
00545 #define INDEX_COMPONENT_NOTEBOOK \
00546 "CREATE INDEX IF NOT EXISTS IDX_COMPONENT_NOTEBOOK on Components(Notebook)"
00547 #define INDEX_RDATES \
00548 "CREATE INDEX IF NOT EXISTS IDX_RDATES on Rdates(ComponentId)"
00549 #define INDEX_CUSTOMPROPERTIES \
00550 "CREATE INDEX IF NOT EXISTS IDX_CUSTOMPROPERTIES on Customproperties(ComponentId)"
00551 #define INDEX_RECURSIVE \
00552 "CREATE INDEX IF NOT EXISTS IDX_RECURSIVE on Recursive(ComponentId)"
00553 #define INDEX_ALARM \
00554 "CREATE INDEX IF NOT EXISTS IDX_ALARM on Alarm(ComponentId)"
00555 #define INDEX_ATTENDEE \
00556 "CREATE UNIQUE INDEX IF NOT EXISTS IDX_ATTENDEE on Attendee(ComponentId, Email)"
00557
00558 #define INSERT_VERSION \
00559 "insert into Version values (?, ?)"
00560 #define INSERT_TIMEZONES \
00561 "insert into Timezones values (1, '')"
00562 #define INSERT_CALENDARS \
00563 "insert into Calendars values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '', '')"
00564 #define INSERT_INVITATIONS \
00565 "insert into Invitations values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
00566 #define INSERT_COMPONENTS \
00567 "insert into Components values (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, '', '', 0)"
00568 #define INSERT_CUSTOMPROPERTIES \
00569 "insert into Customproperties values (?, ?, ?, ?)"
00570 #define INSERT_RDATES \
00571 "insert into Rdates values (?, ?, ?, ?, ?)"
00572 #define INSERT_RECURSIVE \
00573 "insert into Recursive values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
00574 #define INSERT_ALARM \
00575 "insert into Alarm values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
00576 #define INSERT_ATTENDEE \
00577 "insert into Attendee values (?, ?, ?, ?, ?, ?, ?, ?, ?)"
00578
00579 #define UPDATE_TIMEZONES \
00580 "update Timezones set ICalData=? where TzId=1"
00581 #define UPDATE_CALENDARS \
00582 "update Calendars set Name=?, Description=?, Color=?, Flags=?, syncDate=?, pluginName=?, account=?, attachmentSize=?, modifiedDate=?, sharedWith=?, syncProfile=?, createdDate=? where CalendarId=?"
00583 #define UPDATE_COMPONENTS \
00584 "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=?"
00585
00586 #define DELETE_TIMEZONES \
00587 "delete from Timezones where TzId=1"
00588 #define DELETE_CALENDARS \
00589 "delete from Calendars where CalendarId=?"
00590 #define DELETE_INVITATIONS \
00591 "delete from Invitations where InvitationId=?"
00592 #define DELETE_COMPONENTS \
00593 "update Components set DateDeleted=? where ComponentId=?"
00594
00595 #define DELETE_RDATES \
00596 "delete from Rdates where ComponentId=?"
00597 #define DELETE_CUSTOMPROPERTIES \
00598 "delete from Customproperties where ComponentId=?"
00599 #define DELETE_RECURSIVE \
00600 "delete from Recursive where ComponentId=?"
00601 #define DELETE_ALARM \
00602 "delete from Alarm where ComponentId=?"
00603 #define DELETE_ATTENDEE \
00604 "delete from Attendee where ComponentId=?"
00605
00606 #define SELECT_VERSION \
00607 "select * from Version"
00608 #define SELECT_TIMEZONES \
00609 "select * from Timezones where TzId=1"
00610 #define SELECT_CALENDARS_ALL \
00611 "select * from Calendars order by Name"
00612 #define SELECT_INVITATIONS_ALL \
00613 "select * from Invitations"
00614 #define SELECT_COMPONENTS_ALL \
00615 "select * from Components where DateDeleted=0"
00616 #define SELECT_COMPONENTS_BY_NOTEBOOK \
00617 "select * from Components where Notebook=? and DateDeleted=0"
00618 #define SELECT_COMPONENTS_BY_GEO \
00619 "select * from Components where GeoLatitude!=255.0 and GeoLongitude!=255.0 and DateDeleted=0"
00620 #define SELECT_COMPONENTS_BY_GEO_AREA \
00621 "select * from Components where GeoLatitude>=? and GeoLongitude>=? and GeoLatitude<=? and GeoLongitude<=? and DateDeleted=0"
00622 #define SELECT_COMPONENTS_BY_JOURNAL \
00623 "select * from Components where Type='Journal' and DateDeleted=0"
00624 #define SELECT_COMPONENTS_BY_JOURNAL_DATE \
00625 "select * from Components where Type='Journal' and DateDeleted=0 and datestart<=? order by DateStart desc, DateCreated desc"
00626 #define SELECT_COMPONENTS_BY_PLAIN \
00627 "select * from Components where DateStart=0 and DateEndDue=0 and DateDeleted=0"
00628 #define SELECT_COMPONENTS_BY_RECURSIVE \
00629 "select * from components where ((ComponentId in (select DISTINCT ComponentId from recursive)) or (RecurId!=0)) and DateDeleted=0"
00630 #define SELECT_COMPONENTS_BY_ATTENDEE \
00631 "select * from components where ComponentId in (select DISTINCT ComponentId from attendee) and DateDeleted=0"
00632 #define SELECT_COMPONENTS_BY_DATE_BOTH \
00633 "select * from Components where DateStart<=? and DateEndDue>=? and DateDeleted=0"
00634 #define SELECT_COMPONENTS_BY_DATE_START \
00635 "select * from Components where DateEndDue>=? and DateDeleted=0"
00636 #define SELECT_COMPONENTS_BY_DATE_END \
00637 "select * from Components where DateStart<=? and DateDeleted=0"
00638 #define SELECT_COMPONENTS_BY_UID_AND_RECURID \
00639 "select * from Components where UID=? and RecurId=? and DateDeleted=0"
00640 #define SELECT_COMPONENTS_BY_NOTEBOOKUID \
00641 "select * from Components where Notebook=? and DateDeleted=0"
00642 #define SELECT_ROWID_FROM_COMPONENTS_BY_UID_AND_RECURID \
00643 "select ComponentId from Components where UID=? and RecurId=? and DateDeleted=0"
00644 #define SELECT_COMPONENTS_BY_UNCOMPLETED_TODOS \
00645 "select * from Components where Type='Todo' and DateCompleted=0 and DateDeleted=0"
00646 #define SELECT_COMPONENTS_BY_COMPLETED_TODOS_AND_DATE \
00647 "select * from Components where Type='Todo' and DateCompleted<>0 and DateEndDue<>0 and DateEndDue<=? and DateDeleted=0 order by DateEndDue desc, DateCreated desc"
00648 #define SELECT_COMPONENTS_BY_COMPLETED_TODOS_AND_CREATED \
00649 "select * from Components where Type='Todo' and DateCompleted<>0 and DateEndDue=0 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
00650 #define SELECT_COMPONENTS_BY_DATE_SMART \
00651 "select * from Components where DateEndDue<>0 and DateEndDue<=? and DateDeleted=0 order by DateEndDue desc, DateCreated desc"
00652
00653 #define FUTURE_DATE_SMART_FIELD \
00654 " (case type when 'Todo' then DateEndDue else DateStart end) "
00655 #define SELECT_COMPONENTS_BY_FUTURE_DATE_SMART \
00656 "select * from Components where " \
00657 FUTURE_DATE_SMART_FIELD ">=? and DateDeleted=0 order by " \
00658 FUTURE_DATE_SMART_FIELD " asc, DateCreated asc"
00659
00660 #define SELECT_COMPONENTS_BY_CREATED_SMART \
00661 "select * from Components where DateEndDue=0 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
00662 #define SELECT_COMPONENTS_BY_GEO_AND_DATE \
00663 "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"
00664 #define SELECT_COMPONENTS_BY_GEO_AND_CREATED \
00665 "select * from Components where GeoLatitude!=255.0 and GeoLongitude!=255.0 and DateEndDue=0 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
00666 #define SELECT_COMPONENTS_BY_INVITATION_UNREAD \
00667 "select * from Components where InvitationStatus=1 and DateDeleted=0"
00668 #define SELECT_COMPONENTS_BY_INVITATION_AND_CREATED \
00669 "select * from Components where InvitationStatus>1 and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
00670 #define SELECT_COMPONENTS_BY_ATTENDEE_EMAIL_AND_CREATED \
00671 "select * from Components where ComponentId in (select distinct ComponentId from Attendee where email=?) and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
00672 #define SELECT_COMPONENTS_BY_ATTENDEE_AND_CREATED \
00673 "select * from Components where ComponentId in (select distinct ComponentId from Attendee) and DateCreated<=? and DateDeleted=0 order by DateCreated desc"
00674 #define SELECT_RDATES_BY_ID \
00675 "select * from Rdates where ComponentId=?"
00676 #define SELECT_CUSTOMPROPERTIES_BY_ID \
00677 "select * from Customproperties where ComponentId=?"
00678 #define SELECT_RECURSIVE_BY_ID \
00679 "select * from Recursive where ComponentId=?"
00680 #define SELECT_ALARM_BY_ID \
00681 "select * from Alarm where ComponentId=?"
00682 #define SELECT_ATTENDEE_BY_ID \
00683 "select * from Attendee where ComponentId=?"
00684 #define SELECT_COMPONENTS_BY_DUPLICATE \
00685 "select * from Components where DateStart=? and Summary=? and DateDeleted=0"
00686 #define SELECT_COMPONENTS_BY_DUPLICATE_AND_NOTEBOOK \
00687 "select * from Components where DateStart=? and Summary=? and Notebook=? and DateDeleted=0"
00688 #define SELECT_COMPONENTS_BY_CREATED \
00689 "select * from Components where DateCreated>=? and DateDeleted=0"
00690 #define SELECT_COMPONENTS_BY_CREATED_AND_NOTEBOOK \
00691 "select * from Components where DateCreated>=? and Notebook=? and DateDeleted=0"
00692 #define SELECT_COMPONENTS_BY_LAST_MODIFIED \
00693 "select * from Components where DateLastModified>=? and DateCreated<? and DateDeleted=0"
00694 #define SELECT_COMPONENTS_BY_LAST_MODIFIED_AND_NOTEBOOK \
00695 "select * from Components where DateLastModified>=? and DateCreated<? and Notebook=? and DateDeleted=0"
00696 #define SELECT_COMPONENTS_BY_DELETED \
00697 "select * from Components where DateDeleted>=? and DateCreated<?"
00698 #define SELECT_COMPONENTS_BY_DELETED_AND_NOTEBOOK \
00699 "select * from Components where DateDeleted>=? and DateCreated<? and Notebook=?"
00700 #define SELECT_COMPONENTS_BY_ALL_DELETED \
00701 "select * from Components where DateDeleted>=?"
00702 #define SELECT_COMPONENTS_BY_ALL_DELETED_AND_NOTEBOOK \
00703 "select * from Components where DateDeleted>=? and Notebook=?"
00704 #define SELECT_COMPONENTS_BY_UID_AND_DELETED \
00705 "select DateDeleted from Components where UID=? and DateDeleted<>0"
00706 #define SELECT_ATTENDEE_AND_COUNT \
00707 "select Email, Name, count(Email) from Attendee where Email<>0 group by Email"
00708 #define SELECT_EVENT_COUNT \
00709 "select count(*) from Components where Type='Event' and DateDeleted=0"
00710 #define SELECT_TODO_COUNT \
00711 "select count(*) from Components where Type='Todo' and DateDeleted=0"
00712 #define SELECT_JOURNAL_COUNT \
00713 "select count(*) from Components where Type='Journal' and DateDeleted=0"
00714
00715 #define BEGIN_TRANSACTION \
00716 "BEGIN IMMEDIATE;"
00717 #define COMMIT_TRANSACTION \
00718 "END;"
00719
00720 #define FLOATING_DATE "FloatingDate"
00721 }
00722
00723 #endif