diff --git a/src/backends/webdav/CalDAVSource.cpp b/src/backends/webdav/CalDAVSource.cpp index fa16935..ad53c02 100644 --- a/src/backends/webdav/CalDAVSource.cpp +++ b/src/backends/webdav/CalDAVSource.cpp @@ -28,6 +28,7 @@ static std::string SubIDName(const std::string &subid) /** remove X-SYNCEVOLUTION-EXDATE-DETACHED from VEVENT */ static void removeSyncEvolutionExdateDetached(icalcomponent *parent) { + icalproperty *prop = icalcomponent_get_first_property(parent, ICAL_ANY_PROPERTY); while (prop) { icalproperty *next = icalcomponent_get_next_property(parent, ICAL_ANY_PROPERTY); @@ -54,13 +55,16 @@ CalDAVSource::CalDAVSource(const SyncSourceParams ¶ms, this, _1, _2, _3); m_operations.m_restoreData = boost::bind(&CalDAVSource::restoreData, this, _1, _2, _3); + + ConfigProps props; + params.m_nodes.getProperties()->readProperties(props); } void CalDAVSource::listAllSubItems(SubRevisionMap_t &revisions) { revisions.clear(); - const std::string query = + std::string query = "\n" "\n" @@ -96,8 +100,13 @@ void CalDAVSource::listAllSubItems(SubRevisionMap_t &revisions) // filter expected by Yahoo! Calendar "\n" "\n" - "\n" - "\n" + "\n"; + + std::string startDateFilter = getStartDate(); + if (!startDateFilter.empty()) + query += "\n"; + + query += "\n" "\n" "\n" "\n"; @@ -135,7 +144,7 @@ void CalDAVSource::addResource(StringMap &items, void CalDAVSource::updateAllSubItems(SubRevisionMap_t &revisions) { // list items to identify new, updated and removed ones - const std::string query = + std::string query = "\n" "\n" @@ -145,7 +154,13 @@ void CalDAVSource::updateAllSubItems(SubRevisionMap_t &revisions) // filter expected by Yahoo! Calendar "\n" "\n" - "\n" + "\n"; + + std::string startDateFilter = getStartDate(); + if (!startDateFilter.empty()) + query += "\n"; + + query += "\n" "\n" "\n" @@ -1122,7 +1137,7 @@ CalDAVSource::Event &CalDAVSource::loadItem(Event &event) report.run(); #else std::string query = - StringPrintf("\n" + "\n" "\n" "\n" @@ -1132,8 +1147,13 @@ CalDAVSource::Event &CalDAVSource::loadItem(Event &event) // filter expected by Yahoo! Calendar "\n" "\n" - "\n" - "\n" + "\n"; + + std::string startDateFilter = getStartDate(); + if (!startDateFilter.empty()) + query += "\n"; + + query += StringPrintf("\n" "\n" "\n" "\n" @@ -1141,6 +1161,7 @@ CalDAVSource::Event &CalDAVSource::loadItem(Event &event) "\n" "\n", event.m_UID.c_str()); + Timespec deadline = createDeadline(); getSession()->startOperation("REPORT 'single item'", deadline); while (true) { @@ -1351,7 +1372,7 @@ void CalDAVSource::backupData(const SyncSource::Operations::ConstBackupInfo &old cache.init(oldBackup, newBackup, false); // stream directly from REPORT with full data into backup - const std::string query = + std::string query = "\n" "\n" @@ -1362,7 +1383,13 @@ void CalDAVSource::backupData(const SyncSource::Operations::ConstBackupInfo &old // filter expected by Yahoo! Calendar "\n" "\n" - "\n" + "\n"; + + std::string startDateFilter = getStartDate(); + if (!startDateFilter.empty()) + query += "\n"; + + query += "\n" "\n" "\n" diff --git a/src/syncevo/SyncConfig.cpp b/src/syncevo/SyncConfig.cpp index e63a9d7..54688ac 100644 --- a/src/syncevo/SyncConfig.cpp +++ b/src/syncevo/SyncConfig.cpp @@ -2847,6 +2847,12 @@ static ConfigProperty sourcePropDatabaseID(Aliases("database") + "evolutionsourc "data datastore is marked with at the end\n" "of the line, if there is a default.\n"); +static ConfigProperty sourcePropCalendarStartDate(Aliases("startDate"), + "Defines the start date used during the calendar sync.\n" + "This can be set do limit the number of events imported from the source calendar.\n" + "\n" + "Leve it empty if you want to import all events.\n"); + static StringConfigProperty sourcePropDatabaseFormat("databaseFormat", "Defines the data format to be used by the backend for its\n" "own storage. Typically backends only support one format\n" @@ -2941,6 +2947,7 @@ public: registry.push_back(&sourcePropSyncFormat); registry.push_back(&sourcePropForceSyncFormat); registry.push_back(&sourcePropDatabaseID); + registry.push_back(&sourcePropCalendarStartDate); registry.push_back(&sourcePropDatabaseFormat); registry.push_back(&sourcePropUser); registry.push_back(&sourcePropPassword); @@ -2966,6 +2973,7 @@ public: // peer independent source properties sourcePropBackend.setSharing(ConfigProperty::SOURCE_SET_SHARING); sourcePropDatabaseID.setSharing(ConfigProperty::SOURCE_SET_SHARING); + sourcePropCalendarStartDate.setSharing(ConfigProperty::SOURCE_SET_SHARING); sourcePropDatabaseFormat.setSharing(ConfigProperty::SOURCE_SET_SHARING); sourcePropUser.setSharing(ConfigProperty::SOURCE_SET_SHARING); sourcePropPassword.setSharing(ConfigProperty::SOURCE_SET_SHARING); @@ -3036,12 +3044,13 @@ SyncSourceNodes::getNode(const ConfigProperty &prop) const InitStateString SyncSourceConfig::getDatabaseID() const { return sourcePropDatabaseID.getProperty(*getNode(sourcePropDatabaseID)); } void SyncSourceConfig::setDatabaseID(const string &value, bool temporarily) { sourcePropDatabaseID.setProperty(*getNode(sourcePropDatabaseID), value, temporarily); } +InitStateString SyncSourceConfig::getStartDate() const { return sourcePropCalendarStartDate.getProperty(*getNode(sourcePropCalendarStartDate)); } +void SyncSourceConfig::setStartDate(const string &value, bool temporarily) { sourcePropCalendarStartDate.setProperty(*getNode(sourcePropCalendarStartDate), value, temporarily); } UserIdentity SyncSourceConfig::getUser() const { InitStateString user = sourcePropUser.getProperty(*getNode(sourcePropUser)); UserIdentity id(UserIdentity::fromString(user)); return id; } - void SyncSourceConfig::setUsername(const string &value, bool temporarily) { sourcePropUser.setProperty(*getNode(sourcePropUser), value, temporarily); } InitStateString SyncSourceConfig::getPassword() const { return sourcePropPassword.getProperty(*getNode(sourcePropPassword)); diff --git a/src/syncevo/SyncConfig.h b/src/syncevo/SyncConfig.h index c692362..37967d8 100644 --- a/src/syncevo/SyncConfig.h +++ b/src/syncevo/SyncConfig.h @@ -1920,6 +1920,10 @@ class SyncSourceConfig { virtual InitStateString getDatabaseID() const; virtual void setDatabaseID(const std::string &value, bool temporarily = false); + /** selects the start date for calendar sync */ + virtual InitStateString getStartDate() const; + virtual void setStartDate(const std::string &value, bool temporarily = false); + /** * internal property: unique integer ID for the source, needed by Synthesis XML , * zero if unset