aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/datetime/alarm-queue-simple.h18
-rw-r--r--include/datetime/alarm-queue.h2
-rw-r--r--include/datetime/appointment.h23
-rw-r--r--include/datetime/clock-mock.h2
-rw-r--r--include/datetime/clock.h2
-rw-r--r--include/datetime/date-time.h6
-rw-r--r--include/datetime/planner-snooze.h3
-rw-r--r--include/datetime/snap.h3
-rw-r--r--include/datetime/wakeup-timer-mainloop.h4
-rw-r--r--include/datetime/wakeup-timer-powerd.h4
-rw-r--r--include/datetime/wakeup-timer.h2
11 files changed, 41 insertions, 28 deletions
diff --git a/include/datetime/alarm-queue-simple.h b/include/datetime/alarm-queue-simple.h
index d191aec..838d28a 100644
--- a/include/datetime/alarm-queue-simple.h
+++ b/include/datetime/alarm-queue-simple.h
@@ -20,6 +20,8 @@
#ifndef INDICATOR_DATETIME_ALARM_QUEUE_SIMPLE_H
#define INDICATOR_DATETIME_ALARM_QUEUE_SIMPLE_H
+#include <memory> // std::shared_ptr
+
#include <datetime/alarm-queue.h>
#include <datetime/clock.h>
#include <datetime/planner.h>
@@ -39,20 +41,12 @@ public:
const std::shared_ptr<Planner>& upcoming_planner,
const std::shared_ptr<WakeupTimer>& timer);
~SimpleAlarmQueue();
- core::Signal<const Appointment&>& alarm_reached();
+ core::Signal<const Appointment&, const Alarm&>& alarm_reached() override;
private:
- void requeue();
- bool find_next_alarm(Appointment& setme) const;
- std::vector<Appointment> find_current_alarms() const;
- void check_alarms();
-
- std::set<std::pair<std::string,DateTime>> m_triggered;
- const std::shared_ptr<Clock> m_clock;
- const std::shared_ptr<Planner> m_planner;
- const std::shared_ptr<WakeupTimer> m_timer;
- core::Signal<const Appointment&> m_alarm_reached;
- DateTime m_datetime;
+ class Impl;
+ friend class Impl;
+ std::unique_ptr<Impl> impl;
};
diff --git a/include/datetime/alarm-queue.h b/include/datetime/alarm-queue.h
index ea51957..98abd7a 100644
--- a/include/datetime/alarm-queue.h
+++ b/include/datetime/alarm-queue.h
@@ -45,7 +45,7 @@ class AlarmQueue
public:
AlarmQueue() =default;
virtual ~AlarmQueue() =default;
- virtual core::Signal<const Appointment&>& alarm_reached() = 0;
+ virtual core::Signal<const Appointment&, const Alarm&>& alarm_reached() =0;
};
/***
diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h
index ab89c2f..e323c9c 100644
--- a/include/datetime/appointment.h
+++ b/include/datetime/appointment.h
@@ -21,14 +21,28 @@
#define INDICATOR_DATETIME_APPOINTMENT_H
#include <datetime/date-time.h>
+
#include <string>
+#include <vector>
namespace unity {
namespace indicator {
namespace datetime {
/**
- * \brief Plain Old Data Structure that represents a calendar appointment.
+ * \brief Basic information required to raise a notification about some Appointment.
+ */
+struct Alarm
+{
+ std::string text;
+ std::string audio_url;
+ DateTime time;
+
+ bool operator== (const Alarm& that) const;
+};
+
+/**
+ * \brief An instance of an appointment; e.g. a calendar event or clock-app alarm
*
* @see Planner
*/
@@ -39,14 +53,15 @@ public:
Type type = EVENT;
bool is_ubuntu_alarm() const { return type == UBUNTU_ALARM; }
+ std::string uid;
std::string color;
std::string summary;
- std::string url;
- std::string uid;
- std::string audio_url;
+ std::string activation_url;
DateTime begin;
DateTime end;
+ std::vector<Alarm> alarms;
+
bool operator== (const Appointment& that) const;
};
diff --git a/include/datetime/clock-mock.h b/include/datetime/clock-mock.h
index 84fd860..011d079 100644
--- a/include/datetime/clock-mock.h
+++ b/include/datetime/clock-mock.h
@@ -39,7 +39,7 @@ public:
explicit MockClock(const DateTime& dt): m_localtime(dt) {}
~MockClock() =default;
- DateTime localtime() const { return m_localtime; }
+ DateTime localtime() const override { return m_localtime; }
void set_localtime(const DateTime& dt)
{
diff --git a/include/datetime/clock.h b/include/datetime/clock.h
index 8745d24..4a0642f 100644
--- a/include/datetime/clock.h
+++ b/include/datetime/clock.h
@@ -76,7 +76,7 @@ class LiveClock: public Clock
public:
LiveClock (const std::shared_ptr<const Timezone>& zones);
virtual ~LiveClock();
- virtual DateTime localtime() const;
+ virtual DateTime localtime() const override;
private:
class Impl;
diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h
index 7dfc207..ea9ea36 100644
--- a/include/datetime/date-time.h
+++ b/include/datetime/date-time.h
@@ -22,6 +22,7 @@
#include <glib.h> // GDateTime
+#include <chrono>
#include <ctime> // time_t
#include <memory> // std::shared_ptr
@@ -36,13 +37,16 @@ class DateTime
{
public:
static DateTime NowLocal();
+ static DateTime Local(time_t);
static DateTime Local(int year, int month, int day, int hour, int minute, double seconds);
DateTime();
- explicit DateTime(time_t t);
+ DateTime(GTimeZone* tz, time_t t);
DateTime(GTimeZone* tz, GDateTime* dt);
DateTime(GTimeZone* tz, int year, int month, int day, int hour, int minute, double seconds);
DateTime& operator=(const DateTime& in);
+ DateTime& operator+=(const std::chrono::minutes&);
+ DateTime& operator+=(const std::chrono::seconds&);
DateTime to_timezone(const std::string& zone) const;
DateTime start_of_month() const;
DateTime start_of_day() const;
diff --git a/include/datetime/planner-snooze.h b/include/datetime/planner-snooze.h
index e2619fa..fc08d27 100644
--- a/include/datetime/planner-snooze.h
+++ b/include/datetime/planner-snooze.h
@@ -39,9 +39,8 @@ public:
SnoozePlanner(const std::shared_ptr<Settings>&,
const std::shared_ptr<Clock>&);
~SnoozePlanner();
- void add(const Appointment&);
-
core::Property<std::vector<Appointment>>& appointments() override;
+ void add(const Appointment&, const Alarm&);
protected:
class Impl;
diff --git a/include/datetime/snap.h b/include/datetime/snap.h
index 572158d..cc091d3 100644
--- a/include/datetime/snap.h
+++ b/include/datetime/snap.h
@@ -42,8 +42,9 @@ public:
const std::shared_ptr<const Settings>& settings);
virtual ~Snap();
- typedef std::function<void(const Appointment&)> appointment_func;
+ typedef std::function<void(const Appointment&, const Alarm&)> appointment_func;
void operator()(const Appointment& appointment,
+ const Alarm& alarm,
appointment_func snooze,
appointment_func ok);
diff --git a/include/datetime/wakeup-timer-mainloop.h b/include/datetime/wakeup-timer-mainloop.h
index 86da8cf..5acb150 100644
--- a/include/datetime/wakeup-timer-mainloop.h
+++ b/include/datetime/wakeup-timer-mainloop.h
@@ -41,8 +41,8 @@ class MainloopWakeupTimer: public WakeupTimer
public:
explicit MainloopWakeupTimer(const std::shared_ptr<Clock>&);
~MainloopWakeupTimer();
- void set_wakeup_time (const DateTime&);
- core::Signal<>& timeout();
+ void set_wakeup_time (const DateTime&) override;
+ core::Signal<>& timeout() override;
private:
MainloopWakeupTimer(const MainloopWakeupTimer&) =delete;
diff --git a/include/datetime/wakeup-timer-powerd.h b/include/datetime/wakeup-timer-powerd.h
index f11febe..5237fb9 100644
--- a/include/datetime/wakeup-timer-powerd.h
+++ b/include/datetime/wakeup-timer-powerd.h
@@ -41,8 +41,8 @@ class PowerdWakeupTimer: public WakeupTimer
public:
explicit PowerdWakeupTimer(const std::shared_ptr<Clock>&);
~PowerdWakeupTimer();
- void set_wakeup_time(const DateTime&);
- core::Signal<>& timeout();
+ void set_wakeup_time(const DateTime&) override;
+ core::Signal<>& timeout() override;
private:
PowerdWakeupTimer(const PowerdWakeupTimer&) =delete;
diff --git a/include/datetime/wakeup-timer.h b/include/datetime/wakeup-timer.h
index 0a9923c..3e5344c 100644
--- a/include/datetime/wakeup-timer.h
+++ b/include/datetime/wakeup-timer.h
@@ -41,7 +41,7 @@ public:
WakeupTimer() =default;
virtual ~WakeupTimer() =default;
virtual void set_wakeup_time (const DateTime&) =0;
- virtual core::Signal<>& timeout() = 0;
+ virtual core::Signal<>& timeout() =0;
};
/***