aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2014-06-10 11:56:32 -0500
committerCharles Kerr <charles.kerr@canonical.com>2014-06-10 11:56:32 -0500
commit03a7615f1ff6f4bb1d8bf955c042151336edac9b (patch)
tree8fbca3fe56f01ffb72d30fa806a8eb28bae70b16 /src
parente32110f08d6888e25db5bcedb7fd274aa8caea51 (diff)
downloadayatana-indicator-datetime-03a7615f1ff6f4bb1d8bf955c042151336edac9b.tar.gz
ayatana-indicator-datetime-03a7615f1ff6f4bb1d8bf955c042151336edac9b.tar.bz2
ayatana-indicator-datetime-03a7615f1ff6f4bb1d8bf955c042151336edac9b.zip
in SimpleAlarmQueue, the 'alarms we don't want to trigger' list needs to be composed of uid + timestamp. Keying off of only timestamp doesn't work because UIDs can be recycled as users edit and reuse alarms.
Diffstat (limited to 'src')
-rw-r--r--src/alarm-queue-simple.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/alarm-queue-simple.cpp b/src/alarm-queue-simple.cpp
index 00608c9..2e36380 100644
--- a/src/alarm-queue-simple.cpp
+++ b/src/alarm-queue-simple.cpp
@@ -79,7 +79,8 @@ void SimpleAlarmQueue::requeue()
// kick any current alarms
for (auto current : find_current_alarms())
{
- m_triggered.insert(current.uid);
+ const std::pair<std::string,DateTime> trig {current.uid, current.begin};
+ m_triggered.insert(trig);
m_alarm_reached(current);
}
@@ -103,16 +104,26 @@ bool SimpleAlarmQueue::find_next_alarm(Appointment& setme) const
const auto now = m_clock->localtime();
const auto beginning_of_minute = now.add_full (0, 0, 0, 0, 0, -now.seconds());
- for(const auto& walk : m_planner->appointments().get())
+ const auto appointments = m_planner->appointments().get();
+ g_message ("planner has %zu appointments in it", (size_t)appointments.size());
+
+ for(const auto& walk : appointments)
{
- if (m_triggered.count(walk.uid)) // did we already use this one?
+ const std::pair<std::string,DateTime> trig {walk.uid, walk.begin};
+ if (m_triggered.count(trig)) {
+ g_message ("skipping; already used");
continue;
+ }
- if (walk.begin < beginning_of_minute) // has this one already passed?
+ if (walk.begin < beginning_of_minute) { // has this one already passed?
+ g_message ("skipping; too old");
continue;
+ }
- if (found && (tmp.begin < walk.begin)) // do we already have a better match?
+ if (found && (tmp.begin < walk.begin)) { // do we already have a better match?
+ g_message ("skipping; bad match");
continue;
+ }
tmp = walk;
found = true;
@@ -133,7 +144,8 @@ std::vector<Appointment> SimpleAlarmQueue::find_current_alarms() const
for(const auto& walk : m_planner->appointments().get())
{
- if (m_triggered.count(walk.uid)) // did we already use this one?
+ const std::pair<std::string,DateTime> trig {walk.uid, walk.begin};
+ if (m_triggered.count(trig)) // did we already use this one?
continue;
if (!DateTime::is_same_minute(now, walk.begin))
continue;