[dss-commits] digitalSTROM Server branch, master, updated. 422eccecc7303543ba93b798bd6f6de23c07c56d
git version control
dss-commits at forum.digitalstrom.org
Fri Dec 11 11:13:15 CET 2009
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "digitalSTROM Server".
The branch, master has been updated
via 422eccecc7303543ba93b798bd6f6de23c07c56d (commit)
from 28a0d8be37e21c06d25c2ce5dcc1317793f5c211 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 422eccecc7303543ba93b798bd6f6de23c07c56d
Author: Patrick Stählin <pstaehlin at futurelab.ch>
Date: Thu Dec 10 19:35:42 2009 +0100
Added ical rrules for relative timed events
A iCal event needs to have the following properties set:
* iCalStartTime
* iCalRRule
Closes #241
-----------------------------------------------------------------------
Changes:
diff --git a/core/event.cpp b/core/event.cpp
index f96a05f..79e48e0 100644
--- a/core/event.cpp
+++ b/core/event.cpp
@@ -414,8 +414,8 @@ namespace dss {
: m_EventRunner(NULL)
{ } // ctor
- void EventQueue::pushEvent(boost::shared_ptr<Event> _event) {
- Logger::getInstance()->log(string("EventQueue: New event '") + _event->getName() + "' in queue...", lsInfo);
+ boost::shared_ptr<Schedule> EventQueue::scheduleFromEvent(boost::shared_ptr<Event> _event) {
+ boost::shared_ptr<Schedule> result;
if(_event->hasPropertySet(EventPropertyTime)) {
DateTime when;
bool validDate = false;
@@ -423,31 +423,44 @@ namespace dss {
if(timeStr.size() >= 2) {
// relative time
if(timeStr[0] == '+') {
- string timeOffset = timeStr.substr(1, string::npos);
+ std::string timeOffset = timeStr.substr(1, string::npos);
int offset = strToIntDef(timeOffset, -1);
if(offset >= 0) {
when = when.addSeconds(offset);
validDate = true;
} else {
- Logger::getInstance()->log(string("EventQueue::pushEvent: Could not parse offset or offset is below zero: '") + timeOffset + "'", lsError);
+ Logger::getInstance()->log(string("EventQueue::scheduleFromEvent: Could not parse offset or offset is below zero: '") + timeOffset + "'", lsError);
}
} else {
try {
when = DateTime::fromISO(timeStr);
validDate = true;
} catch(std::runtime_error& e) {
- Logger::getInstance()->log(string("EventQueue::pushEvent: Invalid time specified '") + timeStr + "' error: " + e.what(), lsError);
+ Logger::getInstance()->log(string("EventQueue::scheduleFromEvent: Invalid time specified '") + timeStr + "' error: " + e.what(), lsError);
}
}
}
if(validDate) {
- Logger::getInstance()->log(string("EventQueue::pushEvent: Event has a valid time, rescheduling at ") + (string)when, lsInfo);
- boost::shared_ptr<Schedule> sched(new StaticSchedule(when));
- ScheduledEvent* scheduledEvent = new ScheduledEvent(_event, sched);
- m_EventRunner->addEvent(scheduledEvent);
+ Logger::getInstance()->log(string("EventQueue::scheduleFromEvent: Event has a valid time, rescheduling at ") + (string)when, lsInfo);
+ result.reset(new StaticSchedule(when));
} else {
- Logger::getInstance()->log("EventQueue::pushEvent: Dropping event with invalid time", lsError);
+ Logger::getInstance()->log("EventQueue::scheduleFromEvent: Dropping event with invalid time", lsError);
}
+ } else if(_event->hasPropertySet(EventPropertyICalStartTime) && _event->hasPropertySet(EventPropertyICalRRule)) {
+ std::string timeStr = _event->getPropertyByName(EventPropertyICalStartTime);
+ std::string rRuleStr = _event->getPropertyByName(EventPropertyICalRRule);
+ Logger::getInstance()->log(string("EventQueue::schedleFromEvent: Event has a ICalRule rescheduling at ") + timeStr + " with Rule " + rRuleStr, lsInfo);
+ result.reset(new ICalSchedule(rRuleStr, timeStr));
+ }
+ return result;
+ } // scheduleFromEvent
+
+ void EventQueue::pushEvent(boost::shared_ptr<Event> _event) {
+ Logger::getInstance()->log(string("EventQueue: New event '") + _event->getName() + "' in queue...", lsInfo);
+ boost::shared_ptr<Schedule> schedule = scheduleFromEvent(_event);
+ if(schedule != NULL) {
+ ScheduledEvent* scheduledEvent = new ScheduledEvent(_event, schedule);
+ m_EventRunner->addEvent(scheduledEvent);
} else {
m_QueueMutex.lock();
m_EventQueue.push(_event);
@@ -593,6 +606,12 @@ namespace dss {
if(evt->hasPropertySet(EventPropertyTime)) {
evt->unsetProperty(EventPropertyTime);
}
+ if(evt->hasPropertySet(EventPropertyICalStartTime)) {
+ evt->unsetProperty(EventPropertyICalStartTime);
+ }
+ if(evt->hasPropertySet(EventPropertyICalRRule)) {
+ evt->unsetProperty(EventPropertyICalRRule);
+ }
m_EventQueue->pushEvent(evt);
} else {
Logger::getInstance()->log("EventRunner: Cannot push event back to queue because the Queue is NULL", lsFatal);
@@ -740,5 +759,7 @@ namespace dss {
const char* EventPropertyLocation = "location";
const char* EventPropertyContext = "context";
const char* EventPropertyTime = "time";
+ const char* EventPropertyICalStartTime = "iCalStartTime";
+ const char* EventPropertyICalRRule = "iCalRRule";
} // namespace dss
diff --git a/core/event.h b/core/event.h
index 710900e..7085549 100644
--- a/core/event.h
+++ b/core/event.h
@@ -235,6 +235,7 @@ namespace dss {
Mutex m_QueueMutex;
EventRunner* m_EventRunner;
+ boost::shared_ptr<Schedule> scheduleFromEvent(boost::shared_ptr<Event> _event);
public:
EventQueue();
void pushEvent(boost::shared_ptr<Event> _event);
@@ -349,6 +350,8 @@ namespace dss {
extern const char* EventPropertyLocation;
extern const char* EventPropertyContext;
extern const char* EventPropertyTime;
+ extern const char* EventPropertyICalStartTime;
+ extern const char* EventPropertyICalRRule;
} // namespace dss
hooks/post-receive
--
digitalSTROM Server
More information about the dss-commits
mailing list