aboutsummaryrefslogtreecommitdiff
path: root/include/datetime
diff options
context:
space:
mode:
Diffstat (limited to 'include/datetime')
-rw-r--r--include/datetime/clock-watcher.h72
-rw-r--r--include/datetime/date-time.h3
-rw-r--r--include/datetime/planner-eds.h5
-rw-r--r--include/datetime/snap.h51
-rw-r--r--include/datetime/timezone-file.h4
5 files changed, 131 insertions, 4 deletions
diff --git a/include/datetime/clock-watcher.h b/include/datetime/clock-watcher.h
new file mode 100644
index 0000000..e93b468
--- /dev/null
+++ b/include/datetime/clock-watcher.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2014 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#ifndef INDICATOR_DATETIME_CLOCK_WATCHER_H
+#define INDICATOR_DATETIME_CLOCK_WATCHER_H
+
+#include <datetime/state.h>
+#include <datetime/appointment.h>
+
+#include <core/signal.h>
+
+#include <memory>
+#include <set>
+#include <string>
+
+namespace unity {
+namespace indicator {
+namespace datetime {
+
+
+/**
+ * \brief Watches the clock and appointments to notify when an
+ * appointment's time is reached.
+ */
+class ClockWatcher
+{
+public:
+ ClockWatcher() =default;
+ virtual ~ClockWatcher() =default;
+ virtual core::Signal<const Appointment&>& alarm_reached() = 0;
+};
+
+
+/**
+ * \brief A #ClockWatcher implementation
+ */
+class ClockWatcherImpl: public ClockWatcher
+{
+public:
+ ClockWatcherImpl(const std::shared_ptr<const State>& state);
+ ~ClockWatcherImpl() =default;
+ core::Signal<const Appointment&>& alarm_reached();
+
+private:
+ void pulse();
+ std::set<std::string> m_triggered;
+ std::shared_ptr<const State> m_state;
+ core::Signal<const Appointment&> m_alarm_reached;
+};
+
+
+} // namespace datetime
+} // namespace indicator
+} // namespace unity
+
+#endif // INDICATOR_DATETIME_CLOCK_WATCHER_H
diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h
index 2ad7856..b054a1f 100644
--- a/include/datetime/date-time.h
+++ b/include/datetime/date-time.h
@@ -41,6 +41,7 @@ public:
DateTime& operator=(GDateTime* in);
DateTime& operator=(const DateTime& in);
DateTime to_timezone(const std::string& zone) const;
+ DateTime add_full(int years, int months, int days, int hours, int minutes, double seconds) const;
void reset(GDateTime* in=nullptr);
GDateTime* get() const;
@@ -48,9 +49,11 @@ public:
std::string format(const std::string& fmt) const;
int day_of_month() const;
+ double seconds() const;
int64_t to_unix() const;
bool operator<(const DateTime& that) const;
+ bool operator<=(const DateTime& that) const;
bool operator!=(const DateTime& that) const;
bool operator==(const DateTime& that) const;
diff --git a/include/datetime/planner-eds.h b/include/datetime/planner-eds.h
index f3abce0..a99f611 100644
--- a/include/datetime/planner-eds.h
+++ b/include/datetime/planner-eds.h
@@ -20,9 +20,10 @@
#ifndef INDICATOR_DATETIME_PLANNER_EDS_H
#define INDICATOR_DATETIME_PLANNER_EDS_H
+#include <datetime/clock.h>
#include <datetime/planner.h>
-#include <memory> // unique_ptr
+#include <memory> // shared_ptr, unique_ptr
namespace unity {
namespace indicator {
@@ -34,7 +35,7 @@ namespace datetime {
class PlannerEds: public Planner
{
public:
- PlannerEds();
+ PlannerEds(const std::shared_ptr<Clock>& clock);
virtual ~PlannerEds();
private:
diff --git a/include/datetime/snap.h b/include/datetime/snap.h
new file mode 100644
index 0000000..a493772
--- /dev/null
+++ b/include/datetime/snap.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2014 Canonical Ltd.
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Authors:
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#ifndef INDICATOR_DATETIME_SNAP_H
+#define INDICATOR_DATETIME_SNAP_H
+
+#include <datetime/appointment.h>
+
+#include <memory>
+#include <functional>
+
+namespace unity {
+namespace indicator {
+namespace datetime {
+
+/**
+ * \brief Pops up Snap Decisions for appointments
+ */
+class Snap
+{
+public:
+ Snap();
+ virtual ~Snap();
+
+ typedef std::function<void(const Appointment&)> appointment_func;
+ void operator()(const Appointment& appointment,
+ appointment_func show,
+ appointment_func dismiss);
+};
+
+} // namespace datetime
+} // namespace indicator
+} // namespace unity
+
+#endif // INDICATOR_DATETIME_SNAP_H
diff --git a/include/datetime/timezone-file.h b/include/datetime/timezone-file.h
index d77aaae..a67c01a 100644
--- a/include/datetime/timezone-file.h
+++ b/include/datetime/timezone-file.h
@@ -42,8 +42,8 @@ public:
~FileTimezone();
private:
- void setFilename(const std::string& filename);
- static void onFileChanged(gpointer gself);
+ void set_filename(const std::string& filename);
+ static void on_file_changed(gpointer gself);
void clear();
void reload();