From 462e8e6d8e46475ea3222056f65ff40823e9e0bf Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sun, 9 Mar 2014 22:26:26 -0500 Subject: don't connect to EDS when running in the greeter. --- include/datetime/engine-eds.h | 4 ++- include/datetime/engine-mock.h | 68 ++++++++++++++++++++++++++++++++++++++++ include/datetime/engine.h | 68 ++++++++++++++++++++++++++++++++++++++++ include/datetime/planner-eds.h | 59 ---------------------------------- include/datetime/planner-range.h | 36 ++++++++++++++++----- 5 files changed, 168 insertions(+), 67 deletions(-) create mode 100644 include/datetime/engine-mock.h create mode 100644 include/datetime/engine.h delete mode 100644 include/datetime/planner-eds.h (limited to 'include') diff --git a/include/datetime/engine-eds.h b/include/datetime/engine-eds.h index e269167..4b260a8 100644 --- a/include/datetime/engine-eds.h +++ b/include/datetime/engine-eds.h @@ -20,6 +20,8 @@ #ifndef INDICATOR_DATETIME_ENGINE_EDS__H #define INDICATOR_DATETIME_ENGINE_EDS__H +#include + #include #include #include @@ -40,7 +42,7 @@ namespace datetime { * * @see EdsPlanner */ -class EdsEngine +class EdsEngine: public Engine { public: EdsEngine(); diff --git a/include/datetime/engine-mock.h b/include/datetime/engine-mock.h new file mode 100644 index 0000000..ecbf102 --- /dev/null +++ b/include/datetime/engine-mock.h @@ -0,0 +1,68 @@ +/* + * 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 . + * + * Authors: + * Charles Kerr + */ + +#ifndef INDICATOR_DATETIME_ENGINE_MOCK__H +#define INDICATOR_DATETIME_ENGINE_MOCK__H + +#include + +namespace unity { +namespace indicator { +namespace datetime { + +/**** +***** +****/ + +/** + * A no-op #Engine + * + * @see Engine + */ +class MockEngine: public Engine +{ +public: + MockEngine() =default; + ~MockEngine() =default; + + void get_appointments(const DateTime& /*begin*/, + const DateTime& /*end*/, + const Timezone& /*default_timezone*/, + std::function&)> appointment_func) { + appointment_func(m_appointments); + } + + core::Signal<>& changed() { + return m_changed; + } + +private: + core::Signal<> m_changed; + std::vector m_appointments; +}; + +/*** +**** +***/ + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif // INDICATOR_DATETIME_ENGINE_NOOP__H diff --git a/include/datetime/engine.h b/include/datetime/engine.h new file mode 100644 index 0000000..2e8237e --- /dev/null +++ b/include/datetime/engine.h @@ -0,0 +1,68 @@ +/* + * 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 . + * + * Authors: + * Charles Kerr + */ + +#ifndef INDICATOR_DATETIME_ENGINE__H +#define INDICATOR_DATETIME_ENGINE__H + +#include +#include +#include + +#include +#include + +namespace unity { +namespace indicator { +namespace datetime { + +/**** +***** +****/ + +/** + * Class wrapper around the backend that generates appointments + * + * @see EdsEngine + * @see EdsPlanner + */ +class Engine +{ +public: + virtual ~Engine() =default; + + virtual void get_appointments(const DateTime& begin, + const DateTime& end, + const Timezone& default_timezone, + std::function&)> appointment_func) =0; + + virtual core::Signal<>& changed() =0; + +protected: + Engine() =default; +}; + +/*** +**** +***/ + +} // namespace datetime +} // namespace indicator +} // namespace unity + +#endif // INDICATOR_DATETIME_ENGINE__H diff --git a/include/datetime/planner-eds.h b/include/datetime/planner-eds.h deleted file mode 100644 index 95b5d79..0000000 --- a/include/datetime/planner-eds.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 . - * - * Authors: - * Charles Kerr - */ - -#ifndef INDICATOR_DATETIME_PLANNER_EDS_H -#define INDICATOR_DATETIME_PLANNER_EDS_H - -#include - -#include -#include - -#include // shared_ptr, unique_ptr - -namespace unity { -namespace indicator { -namespace datetime { - -/** - * \brief An EDS-based #RangePlanner - */ -class EdsPlanner: public RangePlanner -{ -public: - EdsPlanner(const std::shared_ptr& eds_engine, - const std::shared_ptr& timezone); - virtual ~EdsPlanner(); - - core::Property>& appointments(); - -protected: - void rebuild_now(); - -private: - std::shared_ptr m_engine; - std::shared_ptr m_timezone; - core::Property> m_appointments; -}; - -} // namespace datetime -} // namespace indicator -} // namespace unity - -#endif // INDICATOR_DATETIME_PLANNER_EDS_H diff --git a/include/datetime/planner-range.h b/include/datetime/planner-range.h index 5306cdc..25334a6 100644 --- a/include/datetime/planner-range.h +++ b/include/datetime/planner-range.h @@ -23,6 +23,7 @@ #include #include +#include namespace unity { namespace indicator { @@ -36,25 +37,46 @@ namespace datetime { class RangePlanner: public Planner { public: - virtual ~RangePlanner(); - core::Property>& range(); + virtual ~RangePlanner() =default; + virtual core::Property>& range() =0; protected: - RangePlanner(); + RangePlanner() =default; +}; - void rebuild_soon(); - virtual void rebuild_now() =0; +/** + * \brief A #RangePlanner that uses an #Engine to generate appointments + * + * @see Planner + */ +class SimpleRangePlanner: public RangePlanner +{ +public: + SimpleRangePlanner(const std::shared_ptr& engine, + const std::shared_ptr& timezone); + virtual ~SimpleRangePlanner(); + + core::Property>& appointments(); + core::Property>& range(); private: + // rebuild scaffolding + void rebuild_soon(); + virtual void rebuild_now(); static gboolean rebuild_now_static(gpointer); guint m_rebuild_tag = 0; + + std::shared_ptr m_engine; + std::shared_ptr m_timezone; core::Property> m_range; + core::Property> m_appointments; // we've got a GSignal tag here, so disable copying - RangePlanner(const RangePlanner&) =delete; - RangePlanner& operator=(const RangePlanner&) =delete; + SimpleRangePlanner(const RangePlanner&) =delete; + SimpleRangePlanner& operator=(const RangePlanner&) =delete; }; + } // namespace datetime } // namespace indicator } // namespace unity -- cgit v1.2.3