aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2013-12-17 22:08:08 -0600
committerCharles Kerr <charles.kerr@canonical.com>2013-12-17 22:08:08 -0600
commit0e11a8ac5e0e90ae1b576287e13011593dcdc88c (patch)
treea67c4065e6af1223b521e2401856c175ac4acdf6
parent2690929aeaef44f2b9c818a7e033ce0ef676fbcd (diff)
downloadayatana-indicator-datetime-0e11a8ac5e0e90ae1b576287e13011593dcdc88c.tar.gz
ayatana-indicator-datetime-0e11a8ac5e0e90ae1b576287e13011593dcdc88c.tar.bz2
ayatana-indicator-datetime-0e11a8ac5e0e90ae1b576287e13011593dcdc88c.zip
add other datetime header files
-rw-r--r--include/datetime/CMakeLists.txt2
-rw-r--r--include/datetime/appointment.h63
-rw-r--r--include/datetime/date-time.h93
-rw-r--r--include/datetime/dbus-shared.h24
-rw-r--r--include/datetime/settings-shared.h49
-rw-r--r--include/datetime/timezones-live.h56
-rw-r--r--include/datetime/timezones.h56
-rw-r--r--include/datetime/utils.h67
8 files changed, 410 insertions, 0 deletions
diff --git a/include/datetime/CMakeLists.txt b/include/datetime/CMakeLists.txt
new file mode 100644
index 0000000..139597f
--- /dev/null
+++ b/include/datetime/CMakeLists.txt
@@ -0,0 +1,2 @@
+
+
diff --git a/include/datetime/appointment.h b/include/datetime/appointment.h
new file mode 100644
index 0000000..098b0d0
--- /dev/null
+++ b/include/datetime/appointment.h
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2013 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_APPOINTMENT_H
+#define INDICATOR_DATETIME_APPOINTMENT_H
+
+#include <datetime/date-time.h>
+#include <string>
+
+namespace unity {
+namespace indicator {
+namespace datetime {
+
+/**
+ * PODS representing a calendar appointment
+ */
+struct Appointment
+{
+public:
+ std::string color;
+ std::string summary;
+ std::string url;
+ std::string uid;
+ bool is_event = false;
+ bool is_daily = false;
+ bool has_alarms = false;
+ DateTime begin;
+ DateTime end;
+
+ bool operator== (const Appointment& that) const
+ {
+ return (color==that.color) &&
+ (summary==that.summary) &&
+ (url==that.url) &&
+ (uid==that.uid) &&
+ (is_event==that.is_event) &&
+ (has_alarms==that.has_alarms) &&
+ (begin==that.begin) &&
+ (end==that.end);
+ }
+};
+
+} // namespace datetime
+} // namespace indicator
+} // namespace unity
+
+#endif // INDICATOR_DATETIME_APPOINTMENT_H
diff --git a/include/datetime/date-time.h b/include/datetime/date-time.h
new file mode 100644
index 0000000..bbcd00a
--- /dev/null
+++ b/include/datetime/date-time.h
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2013 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_DATETIME_H
+#define INDICATOR_DATETIME_DATETIME_H
+
+#include <glib.h> // GDateTime
+
+#include <memory> // std::shared_ptr
+
+namespace unity {
+namespace indicator {
+namespace datetime {
+
+/**
+ * C++ wrapper class for GDateTime
+ */
+class DateTime
+{
+public:
+
+ GDateTime* get() const
+ {
+ return dt_.get();
+ }
+
+ GDateTime* operator()() const
+ {
+ return get();
+ }
+
+ void set (GDateTime* in) {
+ auto deleter = [](GDateTime* dt){g_date_time_unref(dt);};
+ dt_ = std::shared_ptr<GDateTime>(g_date_time_ref(in), deleter);
+ }
+
+ DateTime& operator=(GDateTime* in)
+ {
+ set (in);
+ return *this;
+ }
+
+ DateTime& operator=(const DateTime& in)
+ {
+ set (in.get());
+ return *this;
+ }
+
+ bool operator<(const DateTime& that) const
+ {
+ return g_date_time_compare (get(), that.get()) < 0;
+ }
+
+ bool operator!=(const DateTime& that) const
+ {
+ return !(*this == that);
+ }
+
+ bool operator==(const DateTime& that) const
+ {
+ GDateTime * dt = get();
+ GDateTime * tdt = that.get();
+ if (!dt && !tdt) return true;
+ if (!dt || !tdt) return false;
+ return g_date_time_compare (get(), that.get()) == 0;
+ }
+
+private:
+
+ std::shared_ptr<GDateTime> dt_;
+};
+
+} // namespace datetime
+} // namespace indicator
+} // namespace unity
+
+#endif // INDICATOR_DATETIME_DATETIME_H
diff --git a/include/datetime/dbus-shared.h b/include/datetime/dbus-shared.h
new file mode 100644
index 0000000..24319e3
--- /dev/null
+++ b/include/datetime/dbus-shared.h
@@ -0,0 +1,24 @@
+/*
+An indicator to show date and time information.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+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/>.
+*/
+
+#define BUS_NAME "com.canonical.indicator.datetime"
+#define BUS_PATH "/com/canonical/indicator/datetime"
+
diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h
new file mode 100644
index 0000000..896db95
--- /dev/null
+++ b/include/datetime/settings-shared.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2010 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:
+ * Ted Gould <ted@canonical.com>
+ * Charles Kerr <charles.kerr@canonical.com>
+ */
+
+#ifndef __DATETIME_SETTINGS_SHARED_H__
+#define __DATETIME_SETTINGS_SHARED_H__
+
+typedef enum
+{
+ TIME_FORMAT_MODE_LOCALE_DEFAULT,
+ TIME_FORMAT_MODE_12_HOUR,
+ TIME_FORMAT_MODE_24_HOUR,
+ TIME_FORMAT_MODE_CUSTOM
+}
+TimeFormatMode;
+
+#define SETTINGS_INTERFACE "com.canonical.indicator.datetime"
+#define SETTINGS_SHOW_CLOCK_S "show-clock"
+#define SETTINGS_TIME_FORMAT_S "time-format"
+#define SETTINGS_SHOW_SECONDS_S "show-seconds"
+#define SETTINGS_SHOW_DAY_S "show-day"
+#define SETTINGS_SHOW_DATE_S "show-date"
+#define SETTINGS_SHOW_YEAR_S "show-year"
+#define SETTINGS_CUSTOM_TIME_FORMAT_S "custom-time-format"
+#define SETTINGS_SHOW_CALENDAR_S "show-calendar"
+#define SETTINGS_SHOW_WEEK_NUMBERS_S "show-week-numbers"
+#define SETTINGS_SHOW_EVENTS_S "show-events"
+#define SETTINGS_SHOW_LOCATIONS_S "show-locations"
+#define SETTINGS_SHOW_DETECTED_S "show-auto-detected-location"
+#define SETTINGS_LOCATIONS_S "locations"
+#define SETTINGS_TIMEZONE_NAME_S "timezone-name"
+
+#endif /* __DATETIME_SETTINGS_SHARED_H__ */
diff --git a/include/datetime/timezones-live.h b/include/datetime/timezones-live.h
new file mode 100644
index 0000000..3075bd8
--- /dev/null
+++ b/include/datetime/timezones-live.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2013 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_LIVE_TIMEZONES_H
+#define INDICATOR_DATETIME_LIVE_TIMEZONES_H
+
+#include <datetime/timezones.h> // base class
+#include <datetime/timezone-file.h> // aggregated
+#include <datetime/timezone-geoclue.h> // aggregated
+
+#include <memory> // shared_ptr<>
+
+namespace unity {
+namespace indicator {
+namespace datetime {
+
+/**
+ * \brief Timezones object that uses a #FileTimezone and #GeoclueTimezone
+ * to detect what timezone we're in
+ */
+class LiveTimezones: public Timezones
+{
+public:
+ LiveTimezones(const std::string& filename);
+
+ /** \brief Whether or not to track location by IP address */
+ core::Property<bool> geolocationEnabled = core::Property<bool>(false);
+
+private:
+ FileTimezone file_;
+ std::shared_ptr<GeoclueTimezone> geo_;
+ void updateGeolocation();
+ void updateTimezones();
+};
+
+} // namespace datetime
+} // namespace indicator
+} // namespace unity
+
+#endif // INDICATOR_DATETIME_LIVE_TIMEZONES_H
diff --git a/include/datetime/timezones.h b/include/datetime/timezones.h
new file mode 100644
index 0000000..0b97683
--- /dev/null
+++ b/include/datetime/timezones.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2013 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_TIMEZONES_H
+#define INDICATOR_DATETIME_TIMEZONES_H
+
+#include <datetime/timezone.h>
+
+#include <core/property.h>
+
+namespace unity {
+namespace indicator {
+namespace datetime {
+
+/** \brief Aggregates one or more timezone detectors and decides which to use */
+class Timezones
+{
+public:
+
+ Timezones() =default;
+
+ virtual ~Timezones() =default;
+
+ /**
+ * \brief the current timezone
+ */
+ core::Property<std::string> timezone;
+
+ /**
+ * \brief all the detected timezones.
+ * The count is >1 iff the detection mechamisms disagree.
+ */
+ core::Property<std::set<std::string> > timezones;
+};
+
+} // namespace datetime
+} // namespace indicator
+} // namespace unity
+
+#endif // INDICATOR_DATETIME_TIMEZONES_H
diff --git a/include/datetime/utils.h b/include/datetime/utils.h
new file mode 100644
index 0000000..bd2e132
--- /dev/null
+++ b/include/datetime/utils.h
@@ -0,0 +1,67 @@
+/* -*- Mode: C; coding: utf-8; indent-tabs-mode: nil; tab-width: 2 -*-
+
+A dialog for setting time and date preferences.
+
+Copyright 2010 Canonical Ltd.
+
+Authors:
+ Michael Terry <michael.terry@canonical.com>
+
+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/>.
+*/
+
+#ifndef __DATETIME_UTILS_H__
+#define __DATETIME_UTILS_H__
+
+#include <glib.h>
+#include <gio/gio.h> /* GSettings */
+
+G_BEGIN_DECLS
+
+gboolean is_locale_12h (void);
+
+void split_settings_location (const char * location,
+ char ** zone,
+ char ** name);
+
+gchar * get_current_zone_name (const char * location,
+ GSettings * settings);
+
+#if 0
+gchar* join_date_and_time_format_strings (const char * date_fmt,
+ const char * time_fmt);
+/***
+****
+***/
+
+const gchar * get_terse_time_format_string (GDateTime * time);
+
+const gchar * get_terse_header_time_format_string (void);
+
+const gchar * get_full_time_format_string (GSettings * settings);
+
+gchar * generate_terse_format_string_at_time (GDateTime * now,
+ GDateTime * time);
+
+gchar * generate_full_format_string (gboolean show_day,
+ gboolean show_date,
+ gboolean show_year,
+ GSettings * settings);
+#endif
+
+gchar * generate_full_format_string_at_time (GDateTime * now,
+ GDateTime * time);
+
+G_END_DECLS
+
+#endif