00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __DB_CALLS_H__
00025 #define __DB_CALLS_H__
00026
00027 #define CALENDARS_TABLE "Calendars"
00028 #define COMPONENTS_TABLE "Components"
00029 #define COMPONENTDETAILS_TABLE "ComponentDetails"
00030 #define ALARM_TABLE "Alarm"
00031 #define RECURSIVE_TABLE "Recursive"
00032 #define SMARTCAL_TABLE "Components"
00033 #define TRASH_TABLE "Trash"
00034 #define PARAMS_TABLE "Parameters"
00035 #define XPROP_TABLE "XProperties"
00036 #define IDMAP_TABLE "IDMAP"
00037 #define CACHE_TABLE "CACHE"
00038 #define INSTANCES_TABLE "Instances"
00039
00040 #define CAL_FIELD_ID "CalendarId"
00041 #define CAL_FIELD_NAME "Name"
00042 #define CAL_FIELD_COLOR "Colour"
00043 #define CAL_FIELD_ISVISIBLE "IsVisible"
00044 #define CAL_FIELD_ISREADONLY "IsReadonly"
00045 #define CAL_FIELD_CALTYPE "CalendarType"
00046 #define CAL_FIELD_TUNE "CalendarTune"
00047 #define CAL_FIELD_VERSION "CalendarVersion"
00048 #define CAL_FIELD_PROFILE "CalendarProfile"
00049
00050 #define ENTRY_FIELD_CALID "CalendarId"
00051 #define ENTRY_FIELD_ID "Id"
00052 #define ENTRY_FIELD_TYPE "ComponentType"
00053 #define ENTRY_FIELD_FLAGS "Flags"
00054 #define ENTRY_FIELD_DTSTART "DateStart"
00055 #define ENTRY_FIELD_DTEND "DateEnd"
00056 #define ENTRY_FIELD_SUMMARY "Summary"
00057 #define ENTRY_FIELD_LOC "Location"
00058 #define ENTRY_FIELD_DESC "Description"
00059 #define ENTRY_FIELD_STATUS "Status"
00060 #define ENTRY_FIELD_UID "Uid"
00061 #define ENTRY_FIELD_UNTIL "Until"
00062 #define ENTRY_FIELD_ALLDAY "AllDay"
00063 #define ENTRY_FIELD_CRTIME "CreatedTime"
00064 #define ENTRY_FIELD_MODTIME "ModifiedTime"
00065 #define ENTRY_FIELD_TZID "Tzid"
00066 #define ENTRY_FIELD_TZOFFSET "TzOffset"
00067
00068 #define SMARTCAL_FIELD_CALID "CalendarId"
00069 #define SMARTCAL_FIELD_EUID "Uid"
00070 #define SMARTCAL_FIELD_FNAME "Summary"
00071 #define SMARTCAL_FIELD_BDAY "DateStart"
00072 #define SMARTCAL_FIELD_TYPE "ComponentType"
00073
00074 #define COMP_FIELD_ID "Id"
00075 #define COMP_FIELD_TYPE "ComponentType"
00076 #define COMP_FIELD_CLAS "Class"
00077 #define COMP_FIELD_GEO "Geo"
00078 #define COMP_FIELD_PRIO "Priority"
00079 #define COMP_FIELD_DTSTAMP "DateStamp"
00080 #define COMP_FIELD_SEQ "Sequence"
00081 #define COMP_FIELD_TRANSP "Transparency"
00082 #define COMP_FIELD_UID "Uid"
00083 #define COMP_FIELD_URL "Url"
00084 #define COMP_FIELD_ATTACH "Attach"
00085 #define COMP_FIELD_CATEGORY "Category"
00086 #define COMP_FIELD_COMMENT "Comment"
00087 #define COMP_FIELD_CONTACT "Contact"
00088 #define COMP_FIELD_RELATED "Related"
00089 #define COMP_FIELD_RESOURCES "Resources"
00090 #define COMP_FIELD_PERCENT "Percent"
00091 #define COMP_FIELD_COMPLETED "Completed"
00092 #define COMP_FIELD_XPROP "x-prop"
00093
00094 #define ORG_FIELD_ID "Id"
00095 #define ORG_FIELD_TYPE "ComponentType"
00096 #define ORG_FIELD_CNPARAM "CnParam"
00097 #define ORG_FIELD_DIRPARAM "DirParam"
00098 #define ORG_FIELD_SENTPARAM "SentByParam"
00099 #define ORG_FIELD_LANGPARAM "LanguageParam"
00100
00101 #define RECUR_FIELD_ID "Id"
00102 #define RECUR_RRULE "Rrule"
00103 #define RECUR_RDATES "Rdates"
00104 #define RECUR_EDATES "Exdates"
00105 #define RECUR_EXRULE "Exrule"
00106 #define RECUR_RECURID "RecurrenceId"
00107 #define RECUR_RTYPE "Rtype"
00108
00109 #define CACHE_START "DateStart"
00110 #define CACHE_ID "Id"
00111
00112 #define ATT_FIELD_ID "Id"
00113 #define ATT_FIELD_TYPE "ComponentType"
00114 #define ATT_FIELD_CUPARAM "CuTypeParam"
00115 #define ATT_FIELD_MEMPARAM "MemberParam"
00116 #define ATT_FIELD_ROLEPARAM "RoleParam"
00117 #define ATT_FIELD_ROLE_PARSTAT "ParticipationStatus"
00118 #define ATT_FIELD_RSVP "Rsvp"
00119 #define ATT_FIELD_DELTO "DelegatedTo"
00120 #define ATT_FIELD_DELFROM "DelegatedFrom"
00121 #define ATT_FIELD_SENTPARAM "SentBy"
00122 #define ATT_FIELD_CNPARAM "CnParam"
00123 #define ATT_FIELD_DIRPARAM "DirParam"
00124 #define ATT_FIELD_LANGPARAM "LanguageParam"
00125
00126 #define ALARM_FIELD_ID "Id"
00127 #define ALARM_FIELD_TRIGGER "Trigger"
00128 #define ALARM_FIELD_REPEAT "Repeat"
00129 #define ALARM_FIELD_DURATION "Duration"
00130 #define ALARM_FIELD_ACTION "Action"
00131 #define ALARM_FIELD_COOKIEID "CookieId"
00132 #define ALARM_FIELD_ATTACH "Attach"
00133 #define IMPORT "imported calendar-"
00134 #define SEMI_COLON ";"
00135 #define EXCLAMATION "!"
00136
00137
00138 #define TRASH_FIELD_ID "ComponentId"
00139 #define TRASH_FIELD_CALID "CalendarId"
00140 #define TRASH_FIELD_TYPE "ComponentType"
00141 #define TRASH_FIELD_TIME "DeletedTime"
00142 #define TRASH_FIELD_CTIME "CreatedTime"
00143
00144 #define PARAM_FIELD_ID "ComponentId"
00145 #define PARAM_FIELD_PROPNAME "PropertyType"
00146 #define PARAM_FIELD_PROPVALUE "PropertyValue"
00147 #define PARAM_FIELD_PARAMNAME "ParamName"
00148 #define PARAM_FIELD_PARAMVALUE "ParamValue"
00149
00150 #define XPROP_FIELD_ID "ComponentId"
00151 #define XPROP_FIELD_XPROPNAME "XPropertyName"
00152 #define XPROP_FIELD_XPROPVALUE "XPropertyValue"
00153
00154 #define IDMAP_FIELD_LOCALID "LocalId"
00155 #define IDMAP_FIELD_EXTID "ExternalId"
00156
00157
00158 #define TIMEZONE_TABLE "TIMEZONE"
00159 #define TIMEZONE_FIELD_TZID "TzId"
00160 #define TIMEZONE_FIELD_LOCATION "Location"
00161 #define TIMEZONE_FIELD_DTSTSTD "DtStartStd"
00162 #define TIMEZONE_FIELD_DTSTDST "DtStartDst"
00163 #define TIMEZONE_FIELD_TZOFFSTD "TzOffsetStd"
00164 #define TIMEZONE_FIELD_TZOFFDST "TzOffsetDst"
00165 #define TIMEZONE_FIELD_RRULESTD "RRuleStd"
00166 #define TIMEZONE_FIELD_RRULEDST "RRuleDst"
00167 #define TIMEZONE_FIELD_TZNAME "TzName"
00168 #define TIMEZONE_FIELD_DSTFLAG "DSTFlag"
00169
00170 #define CREATE_DEFAULT_CALENDAR "insert into Calendars values(1,\"cal_ti_calendar_synced\", 0, 1, 0, 4,\"\", \"1.0\", 0)"
00171 #define CREATE_PRIVATE_CALENDAR "insert into Calendars values(2,\"cal_ti_calendar_private\", 1, 1, 0, 3,\"\", \"1.0\", 0)"
00172 #define INSERT_CALENDAR "insert into Calendars (%s, %s, %s, %s, %s,%s, %s,%s) values (?, ?, ?, ?, ?,?,?,?)"
00173 #define INSERT_ENTRY "insert into Components ( %s,%s,%s, %s, %s, %s, %s, %s, %s, %s,%s,%s,%s,%s, %s, %s) values (?,?,?,?,?, ?, ?, ?, ?, ?, ?, ?, ?,?,?, ?)"
00174 #define INSERT_COMPONENT "insert into ComponentDetails (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s) values (?, ?, ?, ? ,? ,?, ?, ?, ?, ? ,? ,?, ?, ?, ?, ? ,? ,?)"
00175 #define INSERT_RECURSIVE "insert into RECURSIVE ( %s, %s, %s, %s, %s, %s,%s) values ( ?, ?, ?, ?, ?, ?,?)"
00176 #define INSERT_ALARM "insert into ALARM ( %s,%s,%s, %s, %s, %s, %s) values (?,?, ?, ?, ?, ?, ?)"
00177
00178 #define INSERT_SMARTCAL "insert into Components (%s, %s, %s, %s, %s) values (?, ?, ?, ?, ?)"
00179 #define INSERT_TRASH "insert into Trash (%s, %s, %s, %s, %s) values (?, ?, ?, ?, ?)"
00180 #define INSERT_PARAM "insert into Parameters (%s,%s,%s,%s,%s) values (?,?,?,?,?)"
00181 #define INSERT_XPROP "insert into XProperties (%s,%s,%s) values (?,?,?)"
00182 #define INSERT_IDMAP "insert into IDMAP (%s,%s) values (?,?)"
00183 #define INSERT_CACHE "insert into CACHE (%s, %s) values (?, ?)"
00184 #define INSERT_INSTANCES "insert into Instances (%s, %s, %s) values (?,?,?)"
00185 #define DELETE_INSTANCES "delete from Instances where %s=%s"
00186 #define SELECT_INSTANCES "select DateStart, DateEnd from Instances where Id = \"%s\" and DateEnd >= %d and DateStart <= %d ORDER BY DateStart"
00187 #define SELECT_INSTANCE_NUMBER "select COUNT(*) from Instances where Id = \"%s\" and DateEnd >= %d and DateStart <= %d "
00188
00189 #define SELECT_IDS_FROM_INSTANCES "select DISTINCT Id from Instances where DateEnd >= %d and DateStart <= %d "
00190
00191 #define UPDATE_PARAM "update Parameters set %s=?, %s=?, %s=? where %s=?"
00192 #define UPDATE_TABLE "update %s set %s=? where %s= ?"
00193 #define UPDATE_TABLE_AND "update %s set %s = ? where %s = ? AND %s = ?"
00194 #define UPDATE_TABLE_OR "update %s set %s = ? where %s = ? OR %s = ?"
00195 #define UPDATE_COLS_TABLE_AND "update %s set %s = ?, %s = ? where %s = ? AND %s = ?"
00196 #define UPDATE_COLS_TABLE_OR "update %s set %s = ?, %s = ? where %s = ? OR %s = ?"
00197 #define UPDATE_ALARM "update ALARM set %s=?, %s=?, %s=?, %s=?,%s=?,%s=? where %s=?"
00198 #define CALENDAR_UPDATE "update CALENDARS set %s=?, %s=?, %s=?, %s=?, %s=?,%s=?,%s = ?,%s=? where %s=%d"
00199 #define UPDATE_COMPONENTS "update Components set %s=?,%s=?,%s=?,%s=?,%s=?,%s=?, %s=?, %s=?, %s=?,%s=?,%s=?,%s=? ,%s=?,%s=?,%s=? where %s=?"
00200 #define UPDATE_COMPONENTDETAILS "update ComponentDetails set %s=?,%s=?,%s=?,%s=?,%s=?, %s=?, %s=?, %s=?,%s=?,%s=?, %s=?,%s=?,%s=?,%s=?,%s=?,%s=?,%s=? where %s=?"
00201 #define UPDATE_RECURSIVE "update RECURSIVE set %s=?,%s=?,%s=?,%s=?,%s=?,%s=? where %s=?"
00202 #define UPDATE_SMARTCAL "update Components set %s=?, %s=? where %s=?"
00203
00204 #define DELETE_BY_ID "delete from %s where %s = %d"
00205 #define DELETE_TABLE "delete from %s where %s = ?"
00206 #define DELETE_TABLE_AND "delete from %s where %s = ? AND %s = ?"
00207 #define DELETE_TABLE_OR "delete from %s where %s = ? OR %s = ?"
00208 #define DEL_ROW_BY_CALID "delete from %s where %s in (select %s from Components where %s = %d)"
00209 #define DELETE_TABLE_PROP "delete from %s where %s = ? AND %s != ? AND %s != ?"
00210 #define DROP_TABLE "delete from %s"
00211 #define ERASE_TABLE "drop table %s"
00212 #define RENAME_TABLE "alter table %s rename to %s"
00213 #define MIGRATE_TABLE "insert into %s select * from %s"
00214 #define MIGRATE_COMPONENTS "alter table Components add column TzOffset INTEGER default 0"
00215
00216 #define CREATE_CAL "CREATE TABLE IF NOT EXISTS Calendars(CalendarId INTEGER PRIMARY KEY AUTOINCREMENT, Name TEXT UNIQUE,\
00217 Colour INTEGER,IsVisible INTEGER,IsReadonly INTEGER,CalendarType INTEGER,\
00218 CalendarTune TEXT,CalendarVersion TEXT,CalendarProfile INTEGER)"
00219 #define CREATE_ENTRY "CREATE TABLE IF NOT EXISTS Components(Id INTEGER PRIMARY KEY AUTOINCREMENT,CalendarId INTEGER,\
00220 ComponentType INTEGER, Flags INTEGER, DateStart INTEGER, DateEnd INTEGER,\
00221 Summary TEXT, Location TEXT, Description TEXT, Status INTEGER,Uid TEXT , \
00222 Until INTEGER,AllDay INTEGER,CreatedTime INTEGER,ModifiedTime INTEGER,Tzid TEXT, TzOffset INTEGER)"
00223 #define CREATE_COMPONENT "CREATE TABLE IF NOT EXISTS ComponentDetails(Id INTEGER , ComponentType INTEGER, \
00224 Class TEXT,Geo TEXT,Priority INTEGER, DateStamp TEXT, Sequence INTEGER,\
00225 Transparency TEXT, Uid INTEGER, Url TEXT,\
00226 Attach TEXT,Category TEXT, Comment TEXT, Contact TEXT, Related TEXT,\
00227 Resources TEXT, Percent INTEGER,Completed TEXT)"
00228 #define CREATE_ORGANIZER "CREATE TABLE IF NOT EXISTS ORGANIZER(Id TEXT, ComponentType INTEGER,\
00229 CnParam TEXT, DirParam TEXT, SentByParam TEXT, LanguageParam TEXT)"
00230
00231 #define CREATE_RECURSIVE "CREATE TABLE IF NOT EXISTS RECURSIVE (Id INTEGER, Rrule text,Rdates text,\
00232 Exdates text,Exrule text,RecurrenceId integer,Rtype INTEGER)"
00233 #define CREATE_ATTENDEE "CREATE TABLE IF NOT EXISTS ATTENDEE(Id TEXT, ComponentType INTEGER,\
00234 CuTypeParam INTEGET,MemberParam TEXT,RoleParam INTEGER, \
00235 ParticipationStatus INTEGER, Rsvp INTEGER,DelegatedTo TEXT,DelegatedFrom TEXT,\
00236 SentBy TEXT, CnParam TEXT, DirParam TEXT, LanguageParam TEXT)"
00237 #define CREATE_ALARM "CREATE TABLE IF NOT EXISTS ALARM (Id INTEGER, Trigger INTEGER, Repeat INTEGER,\
00238 Duration INTEGER, Action INTEGER,CookieId TEXT,Attach TEXT)"
00239 #define CREATE_TRASH "CREATE TABLE IF NOT EXISTS Trash (ComponentId INTEGER, CalendarId INTEGER, \
00240 ComponentType INTEGER, DeletedTime INTEGER, CreatedTime INTEGER)"
00241 #define CREATE_PARAM "CREATE TABLE IF NOT EXISTS Parameters(ComponentId INTEGER, PropertyType TEXT,\
00242 PropertyValue TEXT,ParamName TEXT,ParamValue TEXT)"
00243
00244 #define CREATE_XPROP "CREATE TABLE IF NOT EXISTS XProperties(ComponentId INTEGER, XPropertyName TEXT ,\
00245 XPropertyValue TEXT)"
00246 #define CREATE_IDMAP "CREATE TABLE IF NOT EXISTS IDMAP(LocalId INTEGER, ExternalId TEXT)"
00247
00248 #define CREATE_INSTANCES "CREATE TABLE IF NOT EXISTS Instances(Id INTEGER,DateStart INTEGER,DateEnd INTEGER)"
00249 #define SELECT_TAB_COND3 "select %s from %s where %s = %d"
00250 #define SELECT_DOMAIN "select %s from %s where %s =\"%s\""
00251 #define SELECT_DOMAIN_AND "select %s from %s where %s = %d AND %s = %d"
00252 #define SELECT_TAB_COND2 "select * from %s where %s = \"%s\""
00253 #define SELECT_TAB_COND_AND "select * from %s where %s = %d AND %s=%d"
00254 #define SELECT_TAB_COND_TODO "select * from %s where %s = %d AND %s=%d AND %s = %d"
00255 #define SELECT_TAB_COND_AND_VIS "select * from %s where %s <> %d AND %s=%d AND %s in (select %s from %s where %s=1)"
00256 #define SELECT_TAB "select * from %s"
00257 #define SELECT_COUNTCOMPONENT "select COUNT(*) from %s where %s = %d"
00258 #define SELECT_LIMITEDCACHE "select * from CACHE where DateStart > %d ORDER BY DateStart DESC LIMIT %d"
00259 #define SELECT_LIMITEDCACHE2 "select * from CACHE where DateStart < %d ORDER BY DateStart LIMIT %d"
00260
00261 #define SELECT_TWO_TAB "select * from %s %s"
00262 #define SELECT_THREE_TAB "select * from %s %s %s"
00263 #define SELECT_TAB_COND "select * from %s where %s = ?"
00264 #define SELECT_TAB_AND "select * from %s where %s = ? AND %s = ?"
00265 #define SELECT_TAB_OR "select * from %s where %s = ? OR %s = ?"
00266 #define SELECT_RANGE "select * from %s where %s = %d AND %s >= %d AND %s <= %d"
00267 #define SELECT_MULTI_RANGE "select * from %s where %s = %d AND %s = %d AND %s >= %d AND %s <= %d"
00268 #define SELECT_INNER_JOIN "select components.*,componentdetails.* from components INNER JOIN componentdetails where components.Id=\"%s\" AND Components.Id=ComponentDetails.Id"
00269 #define SELECT_PRCR_OFFSET_LIMIT "select * from %s where %s = %d AND (%s = %d OR %s=%d) AND (%s = %d OR %s = %d) AND (%d < %s OR %d = %s) LIMIT %d OFFSET %d"
00270 #define SELECT_MRCR_OFFSET_LIMIT_UNION "select * from %s where %s = %d AND %s = %d AND %s >= %d AND %s <= %d AND (%s != %d AND %s != %d) union select * from %s where %s = %d AND (%s = 2 OR allday = 1) AND (%s + %s)= %d AND (%s != %d AND %s != %d) union select * from %s where %s = %d AND %s = %d AND allday = 0 AND (%s = %d OR %s = %d) AND (%d < %s OR %d = %s) union select * from %s where %s = %d AND %s = %d AND allday = 1 AND (%s = %d OR %s = %d) AND (%d < (%s + %s) OR %d = %s) LIMIT %d OFFSET %d"
00271 #define SELECT_MRCR_OFFSET_LIMIT "select * from %s where %s = %d AND %s = %d AND %s >= %d AND %s <= %d AND (%s != %d AND %s != %d) LIMIT %d OFFSET %d"
00272 #define SELECT_MULTI_RANGE_MRCR "select * from %s where %s = %d AND %s = %d AND %s >= %d AND %s <= %d AND (%s != %d AND %s != %d) union select * from %s where %s = %d AND allday = 1 AND %s = %d AND (%s + %s) >= %d AND (%s + %s) <= %d AND (%s != %d AND %s != %d)"
00273 #define SELECT_MULTI_RANGE_PRCR_CHECK "select * from %s where %s = %d AND (%s = %d OR %s=%d) AND (%s = %d OR %s = %d) AND (%d < %s OR %d = %s)"
00274 #define SELECT_MULTI_RANGE_PRCR "select * from %s where %s = %d AND (%s = %d OR %s=%d) AND (%s = %d OR %s = %d)"
00275 #define GET_EXPIRED_EVENTS "select %s from components where %s= %d and %s= %d and %s < %d"
00276 #define GET_EXPIRED_TODOS "select %s from components where %s= %d and %s= %d and %s = %d and %s < %d"
00277 #define GET_ADDED_ENTRIES "select %s from components where %s > %d AND %s=%d AND %s=%d"
00278 #define GET_MODIFIED_ENTRIES "select %s from components where %s < %d AND %s > %d and %s=%d AND %s=%d"
00279 #define GET_TODAYS_ALLDAY_VIS "select Id,calendarId,summary,DateStart,tzid from components where %s + %s = %d and %s=%d AND %s=%d AND %s in (select %s from %s where %s=1)"
00280 #define GET_ALLDAY_ENTRIES "select %s from components where %s >= %d AND %s <= %d and %s=%d AND %s=%d"
00281 #define GET_IMPORT_CALENDAR "select max(Name) from calendars where Name like \'%s\'"
00282 #define GET_CTIME_UID "select CreatedTime from Components where Id = \"%s\""
00283 #define GET_COMPID_FROM_TRASH "select ComponentId from TRASH where DeletedTime > %d AND CalendarId = %d AND ComponentType= %d"
00284 #define SELECT_PROP_AND "select * from Parameters where ComponentId=\"%s\" AND\
00285 PropertyType = \"%s\" AND PropertyValue = \"%s\""
00286 #define SELECT_DISTINCT_PROP "select distinct PropertyValue from Parameters where ComponentId = \"%s\" AND\
00287 PropertyType = \"%s\""
00288 #define SELECT_UPCOMING_EVENT_VIS "select Id,calendarId,summary,DateStart,Tzid,AllDay from components where ID not in (select Id from components where AllDay=%d AND DateStart <= %d AND DateEnd >= %d AND componentType = %d )AND DateStart > %d AND ComponentType=%d AND %s in (select %s from %s where %s=1) ORDER BY DateStart,Summary LIMIT 1 OFFSET %d"
00289 #define SELECT_UPCOMING_EVENT "select Id,calendarId,summary,DateStart from components where ID not in (select Id from components where AllDay=%d AND DateStart <= %d AND DateEnd >= %d AND componentType = %d )AND DateStart >= %d AND ComponentType=%d ORDER BY DateStart,Summary LIMIT 1 OFFSET %d"
00290 #define SELECT_UPCOMING_TODO_VIS "select Id,calendarId,summary,DateStart,Tzid,AllDay from components where DateStart >= %d AND ComponentType=%d AND status =%d AND %s in (select %s from %s where %s=1) ORDER BY Datestart,summary LIMIT 1 OFFSET %d"
00291 #define SELECT_UPCOMING_TODO "select Id,calendarId,summary,DateStart from components where DateStart >= %d AND ComponentType=%d AND status =%d ORDER BY Datestart,summary LIMIT 1 OFFSET %d"
00292
00293 #define INDEX_CALENDAR "CREATE INDEX IF NOT EXISTS IDX_CALENDAR on Calendars(CalendarId,Name)"
00294 #define INDEX_COMPONENT "CREATE INDEX IF NOT EXISTS IDX_COMPONENT on Components(Id,ComponentType,DateStart,DateEnd,status,Until,ModifiedTime)"
00295 #define INDEX_COMPONENT_DETAILS "CREATE INDEX IF NOT EXISTS IDX_DETAILS on ComponentDetails(Id,ComponentType)"
00296 #define INDEX_RECURSIVE "CREATE INDEX IF NOT EXISTS IDX_RECURSIVE on RECURSIVE(Id)"
00297 #define INDEX_ALARM "CREATE INDEX IF NOT EXISTS IDX_ALARM on ALARM(Id,CookieId)"
00298 #define INDEX_PARAM "CREATE INDEX IF NOT EXISTS IDX_PARAM on Parameters(ComponentId TEXT, PropertyType TEXT,PropertyValue,ParamName)"
00299 #define INDEX_TRASH "CREATE INDEX IF NOT EXISTS IDX_TRASH on TRASH(ComponentId,CalendarId,deletedTime)"
00300 #define INDEX_INSTANCES "CREATE INDEX IF NOT EXISTS IDX_INST on Instances(Id,DateStart,DateEnd)"
00301
00302
00303 #define SELECT_DUPLICATE_ENTRY "select Id from Components where summary = \"%s\" AND dateStart = %d AND ComponentType = %d AND CalendarId = %d "
00304 #define SELECT_ENTRY_RETAIN "select Id from components where ModifiedTime > %d and Id = \"%s\""
00305 #define SELECT_PREV_NEXT_ALLDAY "select * from components where (Allday =1 and DateStart <= %d and DateEnd>= %d)"
00306 #define SELECT_PREV_COMPONENT SELECT_PREV_NEXT_ALLDAY "UNION select * from components where (DateStart <= %d AND componentType = %d AND (Flags!=%d OR Flags != %d) AND (calendarId in (select calendarid from calendars where IsVisible =1 ))) OR Id = \"%s\" ORDER BY DateStart ,Summary,CreatedTime LIMIT 20 OFFSET 0"
00307 #define SELECT_NEXT_COMPONENT SELECT_PREV_NEXT_ALLDAY "UNION select * from components where (DateStart >= %d AND componentType = %d AND (Flags!=%d OR Flags != %d) AND (calendarId in (select calendarid from calendars where IsVisible =1 ))) OR Id = \"%s\" ORDER BY DateStart,Summary,CreatedTime LIMIT 20 OFFSET 0"
00308 #define SELECT_ACTIVE_ALARM "select Id from Alarm where Id in (select Id from components where calendarid = %d) AND CookieId != \"%s\" AND Trigger >= %d "
00309 #define SELECT_VISIBLE_ALARM "select Id from Alarm where Id in (select Id from components where calendarid = %d) AND CookieId = \"%s\" AND Trigger >= %d "
00310 #define SELECT_ALL_ENTRIES "select * from %s where %s = %d AND %s=%d LIMIT %d OFFSET %d"
00311 #define SELECT_RECURSIVE_FUTURE_INSTANCE "select * from components where (Flags = %d OR Flags = %d) AND (Until >= %d OR Until = %d) AND (calendarId in (select calendarid from calendars where IsVisible =1 ))"
00312 #define SELECT_RECURSIVE_PREVIOUS_INSTANCE "select * from components where (Flags = %d OR Flags = %d) AND datestart <= %d AND (calendarId in (select calendarid from calendars where IsVisible =1 ))"
00313 #define SELECT_EVENTS_TODOS_OFFSET_LIMIT_UNION "select * from %s where %s = %d AND (%s = %d AND %s < %d AND %s >= %d) AND (%s != %d AND %s != %d) union select * from %s where %s = %d AND ((%s = %d OR allday = 1) AND (%s + %s) >= %d AND (%s + %s) <= %d) AND (%s != %d AND %s != %d) union select * from %s where %s = %d AND %s = %d AND (%s = %d OR %s = %d) AND allday = 0 AND (%d <= %s OR %d = %s) union select * from %s where %s = %d AND (%s = %d OR %s=%d) AND (%s = %d OR %s = %d) AND allday = 1 AND (%d <= (\"%s\" + \"%s\") OR %d = %s) LIMIT %d OFFSET %d"
00314 #define GET_EXPIRED_NONRECURSIVE_EVENTS "select %s from components where %s= %d and %s= %d and %s < %d and ( %s != %d AND %s!=%d) "
00315 #define GET_EXPIRED_RECURSIVE_EVENTS "select %s from components where %s= %d and %s= %d and ( %s = %d OR %s=%d) LIMIT %d"
00316 #define SELECT_NOS_VISIBLE_CAL "select * from %s where %s = %d "
00317
00318 #define CREATE_TIMEZONE "CREATE TABLE IF NOT EXISTS TIMEZONE (Location TEXT,TzId TEXT,DtStartStd INTEGER,DtStartDst INTEGER,TzOffsetStd INTEGER,TzOffsetDst INTEGER,RRuleStd TEXT,RRuleDst TEXT,TzName TEXT,DSTFlag INTEGER )"
00319 #define INSERT_TIMEZONE "insert into TIMEZONE (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s) values(?, ?, ?, ?, ?, ?, ?, ?,? ,?)"
00320 #define INDEX_TIMEZONE "CREATE INDEX IF NOT EXISTS IDX_TIMEZONE on TIMEZONE(Location)"
00321
00322 #define SELECT_LOCATION "select %s from %s where (%s = 1 AND %s = %d )"
00323
00324 # define SELECT_ALREADY_HAPPENING_EVENT "select * from components where allday!= 1 AND ((DateStart < %d AND DateEnd > %d AND componentType = %d AND (Flags!=%d OR Flags != %d)) OR Id = \"%s\") AND calendarId in (select calendarid from calendars where IsVisible =1 ) ORDER BY DateStart,Summary LIMIT 10 OFFSET 0"
00325 #define SELECT_LOCATION_FROM_OFFSET "select location from timezone where %s = %d AND %s = %d AND %s=%d LIMIT 1 OFFSET 0"
00326 #define SELECT_LOCATION_FROM_OFFSET_WITH_DST "select location from timezone where %s = %d AND %s = %d AND %s=%d AND (%s = \"%s\" OR %s =\"%s\") LIMIT 1 OFFSET 0"
00327
00328 #define DELETE_TRIGGER "CREATE TRIGGER IF NOT EXISTS delete_component after delete on components \
00329 begin \
00330 delete from ComponentDetails where componentdetails.Id=OLD.Id; \
00331 delete from Recursive where recursive.Id=OLD.Id; \
00332 delete from Alarm where alarm.Id=OLD.Id; \
00333 delete from Parameters where parameters.ComponentId=OLD.Id; \
00334 delete from XProperties where xproperties.ComponentId=OLD.Id; \
00335 delete from Instances where Instances.Id=OLD.Id; \
00336 end "
00337 #define DROP_TRIGGER "DROP TRIGGER delete_component"
00338
00339 #define COUNT_NONRECURSIVECOMPONENT "select COUNT(id) from %s where id in (select id from components where \
00340 componenttype=1 AND dateEnd < %d AND (Flags !=3 AND Flags !=5 ) union select id from components \
00341 where componenttype = 2 AND status = 1 AND dateStart < %d )"
00342
00343 #define SELECT_ID_CALENDARID_FROM_NONRECURSIVECOMPONENT \
00344 "select Id,CalendarId from components where componenttype = 1 AND dateEnd < %d AND (Flags !=3 AND Flags !=5 ) \
00345 union \
00346 select Id,CalendarId from components where componenttype = 2 AND status = 1 AND dateStart < %d LIMIT %d"
00347
00348 #define DELETION_NONRECURSIVECOMPONENT "delete from components where id in (select id from components where id in (select id from components where componenttype=1 AND dateEnd < ? AND (Flags !=3 AND Flags !=5 ) union select id from components where componenttype = 2 AND status = 1 AND dateStart < ?) ORDER BY dateStart DESC LIMIT ?)"
00349
00350 #define DELETE_GROUP_ID "delete from Components where id in ("
00351 #define GET_EXPIRED_RECURSIVE_EVENTS_COUNT "select COUNT(*) from components where %s= %d and %s= %d and ( %s = %d OR %s=%d)"
00352
00353 #define SELECT_INNER_JOIN_BATCH "select * from components left join componentdetails on components.Id = componentdetails.Id Left Join alarm on components.Id = alarm.Id Left Join Recursive on components.Id = Recursive.Id where Calendarid = %d AND Components.ComponentType = %d"
00354 #define SELECT_TAB_COND_AND2 "select * from %s where %s = \"%s\" "
00355 #define SELECT_BIRTHDAY_COUNT "select COUNT(*) from components where componentType = 4 AND dateStart =%d"
00356
00357 #define SELECT_ALL_CALCOMP__UNION "select * from %s where ((%s = %d AND %s < %d AND %s >= %d) OR ( %s = %d AND %s >= %d AND %s <= %d )) AND (%s != %d AND %s != %d) AND calendarId in (select calendarid from calendars where IsVisible =1 ) union select * from %s where (%s = %d OR %s=%d) AND (%s = %d OR %s = %d) AND (%d < %s OR %d = %s) AND calendarId in (select calendarid from calendars where IsVisible =1) ORDER BY CalendarId LIMIT %d OFFSET %d "
00358
00359 #define SELECT_ALL_IN_INTERVAL_BY_INSTANCES "select * from components where (%s = %d OR %s = %d OR %s = %d) AND Id IN (select DISTINCT Id from Instances where DateEnd >= %d and DateStart <= %d ) AND calendarId in (select calendarid from calendars where IsVisible =1) ORDER BY CalendarId LIMIT %d OFFSET %d "
00360
00361 #define SELECT_ID_LIKE "select * from cache where Id like "
00362 #define SELECT_COUNT "select Id from %s LIMIT 1 OFFSET 0"
00363 #define SELECT_LEFT_JOIN "select * from components left join componentdetails on components.Id = componentdetails.Id Left Join alarm on components.Id = alarm.Id Left Join Recursive on components.Id = Recursive.Id where components.Id = \"%s\" "
00364 #define SELECT_EVENTS_IN_LIST "select * from components left join componentdetails on components.Id = componentdetails.Id Left Join alarm on components.Id = alarm.Id Left Join Recursive on components.Id = Recursive.Id where components.id in("
00365 #define SELECT_BDAYS_BY_EXT_ID "select * from components left join componentdetails on components.Id = componentdetails.Id Left Join alarm on components.Id = alarm.Id Left Join Recursive on components.Id = Recursive.Id join IDMAP where components.id = Idmap.LocalId AND idmap.ExternalId = \"%s\""
00366 #define SELECT_BY_ID "select * from %s where CalendarId = %d"
00367 #define UPDATE_UNTIL "update components set until = %d where Id = %d"
00368 #define SELECT_ALL_CALCOMP__UNION_NORMAL "select * from %s where ((%s = %d AND %s < %d AND %s >= %d) OR ( %s = %d AND %s >= %d AND %s <= %d )) AND (%s != %d AND %s != %d) AND calendarId in (select calendarid from calendars where IsVisible =1 ) ORDER BY CalendarId LIMIT %d OFFSET %d "
00369 #define SELECT_ALL_CALCOMP__UNION_RECURSIVE "select * from %s where (%s = %d OR %s=%d) AND (%s = %d OR %s = %d) AND (%d < %s OR %d = %s) AND calendarId in (select calendarid from calendars where IsVisible =1) ORDER BY CalendarId LIMIT %d OFFSET %d "
00370 #define CHECK_PREV_VISIBLE_EVENT "select * from components where componenttype = 1 and datestart <= %d and id != %q and calendarId in (select calendarid from calendars where IsVisible =1 ) ORDER BY DateStart ,Summary,CreatedTime LIMIT 1 OFFSET 0 "
00371 #define CHECK_NEXT_VISIBLE_EVENT "select * from components where componenttype = 1 and (datestart >= %d OR until >= %d) and Id!= %q AND calendarId in (select calendarid from calendars where IsVisible =1) ORDER BY DateStart ,Summary,CreatedTime LIMIT 1 OFFSET 0"
00372 #define SELECT_REPEAT_EVENT_UNTIL_MINUSONE "select * from components where componenttype =1 and (flags = %d OR flags = %d) and until =-1 AND calendarId in (select calendarid from calendars where IsVisible =1) ORDER BY DateStart ,Summary,CreatedTime"
00373
00374 #define GET_IDS_FROM_COMPONENTS_FOR_CALENDAR "select Id from Components where CalendarId=%d"
00375
00376 #endif