From fff19d70649589b81a896e4deb032a7bd4bdca1e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 31 Mar 2015 18:54:04 -0500 Subject: add an Alarm class to represent ical valarm components; change the Appointment class to hold an arbitrary number of Alarms. --- include/datetime/appointment.h | 26 ++++++++++++++++++++++---- include/datetime/snap.h | 3 ++- 2 files changed, 24 insertions(+), 5 deletions(-) (limited to 'include/datetime') diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h index ab89c2f..337d9b8 100644 --- a/include/datetime/appointment.h +++ b/include/datetime/appointment.h @@ -21,14 +21,31 @@ #define INDICATOR_DATETIME_APPOINTMENT_H #include + +#include #include +#include +#include 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; + std::chrono::seconds duration; + + 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 +56,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 alarms; + bool operator== (const Appointment& that) const; }; 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& settings); virtual ~Snap(); - typedef std::function appointment_func; + typedef std::function appointment_func; void operator()(const Appointment& appointment, + const Alarm& alarm, appointment_func snooze, appointment_func ok); -- cgit v1.2.3 From eab70c8626906fcf98f5d5653a8ea1bebd2cfc89 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 3 Apr 2015 12:31:36 -0500 Subject: add override keyword to WakeupTimer --- include/datetime/wakeup-timer-mainloop.h | 4 ++-- include/datetime/wakeup-timer-powerd.h | 4 ++-- include/datetime/wakeup-timer.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include/datetime') 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&); ~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&); ~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; }; /*** -- cgit v1.2.3 From 6e4367c088eb9026f29295c650f8639e09423212 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 3 Apr 2015 12:36:46 -0500 Subject: add override keyword to Clock class --- include/datetime/clock-mock.h | 2 +- include/datetime/clock.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include/datetime') 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& zones); virtual ~LiveClock(); - virtual DateTime localtime() const; + virtual DateTime localtime() const override; private: class Impl; -- cgit v1.2.3 From 8c7daeeb87abd0be1b96169da18baf018c4859c9 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 3 Apr 2015 13:11:39 -0500 Subject: add the new Alarm class as an argument to the alarm queue class --- include/datetime/alarm-queue-simple.h | 18 ++++++------------ include/datetime/alarm-queue.h | 2 +- include/datetime/date-time.h | 3 +++ include/datetime/planner-snooze.h | 3 +-- 4 files changed, 11 insertions(+), 15 deletions(-) (limited to 'include/datetime') 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 // std::shared_ptr + #include #include #include @@ -39,20 +41,12 @@ public: const std::shared_ptr& upcoming_planner, const std::shared_ptr& timer); ~SimpleAlarmQueue(); - core::Signal& alarm_reached(); + core::Signal& alarm_reached() override; private: - void requeue(); - bool find_next_alarm(Appointment& setme) const; - std::vector find_current_alarms() const; - void check_alarms(); - - std::set> m_triggered; - const std::shared_ptr m_clock; - const std::shared_ptr m_planner; - const std::shared_ptr m_timer; - core::Signal m_alarm_reached; - DateTime m_datetime; + class Impl; + friend class Impl; + std::unique_ptr 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& alarm_reached() = 0; + virtual core::Signal& alarm_reached() =0; }; /*** diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h index 7dfc207..7e19a9d 100644 --- a/include/datetime/date-time.h +++ b/include/datetime/date-time.h @@ -22,6 +22,7 @@ #include // GDateTime +#include #include // time_t #include // std::shared_ptr @@ -43,6 +44,8 @@ public: 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&, const std::shared_ptr&); ~SnoozePlanner(); - void add(const Appointment&); - core::Property>& appointments() override; + void add(const Appointment&, const Alarm&); protected: class Impl; -- cgit v1.2.3 From 62d68e6453c0ad69ff4d71099441a8151e9a9bea Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 5 Apr 2015 17:27:52 -0500 Subject: fix misuse of ECalComponentAlarmInstance's fields. --- include/datetime/appointment.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/datetime') diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h index 337d9b8..e9c1bc2 100644 --- a/include/datetime/appointment.h +++ b/include/datetime/appointment.h @@ -39,7 +39,6 @@ struct Alarm std::string text; std::string audio_url; DateTime time; - std::chrono::seconds duration; bool operator== (const Alarm& that) const; }; -- cgit v1.2.3 From 38a39c03d5b44c825afe0d10f67cc0802dcf2573 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 5 Apr 2015 21:12:01 -0500 Subject: remove some new bits that turned out to be unneeded after all --- include/datetime/appointment.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include/datetime') diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h index e9c1bc2..e323c9c 100644 --- a/include/datetime/appointment.h +++ b/include/datetime/appointment.h @@ -22,9 +22,7 @@ #include -#include #include -#include #include namespace unity { -- cgit v1.2.3 From 4438c3a50d4c10d7516d736cb31ded01c57c791e Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Mon, 6 Apr 2015 13:16:24 -0500 Subject: in DateTime class, make it harder to accidentally mix local and nonlocal timezones by replacing DateTime::DateTime(time_t) with two methods, DateTime::Local(time_t) and DateTime(GTimeZone*, time_t) --- include/datetime/date-time.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/datetime') diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h index 7e19a9d..ea9ea36 100644 --- a/include/datetime/date-time.h +++ b/include/datetime/date-time.h @@ -37,10 +37,11 @@ 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); -- cgit v1.2.3