diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-12-08 10:40:44 +0000 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2017-12-08 10:40:44 +0000 |
commit | f54505942ce2dcc73fcbad79d4f5cdce991bf8cb (patch) | |
tree | 9aab8e9b612adfff946a93365cd0d2fea9aeb74c /src | |
parent | 4a6ec712275b179decd1844232dce44bc9f9dc19 (diff) | |
download | ayatana-indicator-datetime-f54505942ce2dcc73fcbad79d4f5cdce991bf8cb.tar.gz ayatana-indicator-datetime-f54505942ce2dcc73fcbad79d4f5cdce991bf8cb.tar.bz2 ayatana-indicator-datetime-f54505942ce2dcc73fcbad79d4f5cdce991bf8cb.zip |
Make the datetime indicator build on non-Ubuntu systems (which mostly lack url-dispatcher and Ubuntu Touch sound schema files.
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/actions-live.cpp | 12 | ||||
-rw-r--r-- | src/actions.cpp | 6 | ||||
-rw-r--r-- | src/main.cpp | 8 | ||||
-rw-r--r-- | src/menu.cpp | 19 | ||||
-rw-r--r-- | src/snap.cpp | 3 |
6 files changed, 49 insertions, 11 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f8d219a..f0c5e28 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,11 +44,13 @@ set (SERVICE_CXX_SOURCES include (GdbusCodegen) set(SERVICE_GENERATED_SOURCES) add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-alarm-properties - com.canonical.indicator - ${CMAKE_SOURCE_DIR}/data/com.canonical.indicator.datetime.AlarmProperties.xml) -add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-accounts-sound - com.ubuntu.touch - ${CMAKE_SOURCE_DIR}/src/com.ubuntu.touch.AccountsService.Sound.xml) + org.ayatana.indicator + ${CMAKE_SOURCE_DIR}/data/org.ayatana.indicator.datetime.AlarmProperties.xml) +if(HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS) + add_gdbus_codegen(SERVICE_GENERATED_SOURCES dbus-accounts-sound + com.ubuntu.touch + ${CMAKE_SOURCE_DIR}/src/com.ubuntu.touch.AccountsService.Sound.xml) +endif() # add warnings/coverage info on handwritten files # but not the autogenerated ones... diff --git a/src/actions-live.cpp b/src/actions-live.cpp index 5f98dfd..994fc3c 100644 --- a/src/actions-live.cpp +++ b/src/actions-live.cpp @@ -19,7 +19,9 @@ #include <datetime/actions-live.h> +#ifdef HAS_URLDISPATCHER #include <url-dispatcher.h> +#endif #include <glib.h> @@ -49,11 +51,13 @@ void LiveActions::execute_command(const std::string& cmdstr) } } +#ifdef HAS_URLDISPATCHER void LiveActions::dispatch_url(const std::string& url) { g_debug("Dispatching url '%s'", url.c_str()); url_dispatch_send(url.c_str(), nullptr, nullptr); } +#endif /*** **** @@ -61,11 +65,14 @@ void LiveActions::dispatch_url(const std::string& url) void LiveActions::desktop_open_settings_app() { +#ifdef HAS_URLDISPATCHER if (g_getenv ("MIR_SOCKET") != nullptr) { dispatch_url("settings:///system/time-date"); } - else if ((g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)) + else +#endif + if ((g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "Unity") == 0)) { execute_command("unity-control-center datetime"); } @@ -128,6 +135,7 @@ void LiveActions::desktop_open_calendar_app(const DateTime& dt) **** ***/ +#ifdef HAS_URLDISPATCHER void LiveActions::phone_open_alarm_app() { dispatch_url("appid://com.ubuntu.clock/clock/current-user-version"); @@ -135,6 +143,7 @@ void LiveActions::phone_open_alarm_app() void LiveActions::phone_open_appointment(const Appointment& appt) { + if (!appt.activation_url.empty()) { dispatch_url(appt.activation_url); @@ -160,6 +169,7 @@ void LiveActions::phone_open_settings_app() { dispatch_url("settings:///system/time-date"); } +#endif /*** **** diff --git a/src/actions.cpp b/src/actions.cpp index e89b116..d288a0e 100644 --- a/src/actions.cpp +++ b/src/actions.cpp @@ -88,6 +88,7 @@ void on_desktop_settings_activated (GSimpleAction*, GVariant*, gpointer gself) static_cast<Actions*>(gself)->desktop_open_settings_app(); } +#ifdef HAS_URLDISPATCHER void on_phone_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself) { auto self = static_cast<Actions*>(gself); @@ -108,7 +109,7 @@ void on_phone_settings_activated (GSimpleAction*, GVariant*, gpointer gself) { static_cast<Actions*>(gself)->phone_open_settings_app(); } - +#endif void on_set_location(GSimpleAction * /*action*/, GVariant * param, @@ -204,11 +205,12 @@ Actions::Actions(const std::shared_ptr<State>& state): { "desktop.open-calendar-app", on_desktop_calendar_activated, "x", nullptr }, { "desktop.open-settings-app", on_desktop_settings_activated }, +#ifdef HAS_URLDISPATCHER { "phone.open-appointment", on_phone_appointment_activated, "s", nullptr }, { "phone.open-alarm-app", on_phone_alarm_activated }, { "phone.open-calendar-app", on_phone_calendar_activated, "x", nullptr }, { "phone.open-settings-app", on_phone_settings_activated }, - +#endif { "calendar-active", nullptr, nullptr, "false", on_calendar_active_changed }, { "set-location", on_set_location, "s" } }; diff --git a/src/main.cpp b/src/main.cpp index 31654c9..fdd84b5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,9 @@ #include <datetime/planner-snooze.h> #include <datetime/planner-range.h> #include <datetime/settings-live.h> +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS #include <datetime/snap.h> +#endif #include <datetime/state.h> #include <datetime/timezones-live.h> #include <datetime/timezone-timedated.h> @@ -90,6 +92,7 @@ namespace return state; } +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS std::shared_ptr<AlarmQueue> create_simple_alarm_queue(const std::shared_ptr<Clock>& clock, const std::shared_ptr<Planner>& snooze_planner, const std::shared_ptr<Engine>& engine, @@ -113,6 +116,7 @@ namespace auto wakeup_timer = std::make_shared<PowerdWakeupTimer>(clock); return std::make_shared<SimpleAlarmQueue>(clock, planner, wakeup_timer); } +#endif } int @@ -133,9 +137,10 @@ main(int /*argc*/, char** /*argv*/) auto actions = std::make_shared<LiveActions>(state); MenuFactory factory(actions, state); +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS // set up the snap decisions auto snooze_planner = std::make_shared<SnoozePlanner>(state->settings, state->clock); - auto notification_engine = std::make_shared<uin::Engine>("indicator-datetime-service"); + auto notification_engine = std::make_shared<ain::Engine>("ayatana-indicator-datetime-service"); std::unique_ptr<Snap> snap (new Snap(notification_engine, state->settings)); auto alarm_queue = create_simple_alarm_queue(state->clock, snooze_planner, engine, timezone_); auto on_snooze = [snooze_planner](const Appointment& appointment, const Alarm& alarm) { @@ -147,6 +152,7 @@ main(int /*argc*/, char** /*argv*/) engine->disable_ubuntu_alarm(appointment); }; alarm_queue->alarm_reached().connect(on_alarm_reached); +#endif // create the menus std::vector<std::shared_ptr<Menu>> menus; diff --git a/src/menu.cpp b/src/menu.cpp index 250cb72..7be3719 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -240,9 +240,12 @@ private: const char * action_name; +#ifdef HAS_URLDISPATCHER if (profile == Phone) action_name = "indicator.phone.open-calendar-app"; - else if (profile == Desktop) + else +#endif + if (profile == Desktop) action_name = "indicator.desktop.open-calendar-app"; else action_name = nullptr; @@ -288,9 +291,12 @@ private: const char * action_name; +#ifdef HAS_URLDISPATCHER if (profile == Phone) action_name = "indicator.phone.open-appointment"; - else if ((profile == Desktop) && m_actions->desktop_has_calendar_app()) + else +#endif + if ((profile == Desktop) && m_actions->desktop_has_calendar_app()) action_name = "indicator.desktop.open-appointment"; else action_name = nullptr; @@ -357,6 +363,7 @@ private: g_object_unref(menu_item); } } +#ifdef HAS_URLDISPATCHER else if (profile==Phone) { auto menu_item = g_menu_item_new (_("Clock"), "indicator.phone.open-alarm-app"); @@ -366,6 +373,7 @@ private: add_appointments (menu, profile); } +#endif return G_MENU_MODEL(menu); } @@ -405,8 +413,10 @@ private: if (profile == Desktop) action_name = "indicator.desktop.open-settings-app"; +#ifdef HAS_URLDISPATCHER else if (profile == Phone) action_name = "indicator.phone.open-settings-app"; +#endif else action_name = nullptr; @@ -493,6 +503,8 @@ public: DesktopBaseMenu(DesktopGreeter,"desktop_greeter", state_, actions_) {} }; + +#ifdef HAS_URLDISPATCHER class PhoneBaseMenu: public MenuImpl { protected: @@ -551,6 +563,7 @@ public: std::shared_ptr<Actions>& actions_): PhoneBaseMenu(PhoneGreeter, "phone_greeter", state_, actions_) {} }; +#endif /**** ***** @@ -578,6 +591,7 @@ MenuFactory::buildMenu(Menu::Profile profile) menu.reset(new DesktopGreeterMenu(m_state, m_actions)); break; +#ifdef HAS_URLDISPATCHER case Menu::Phone: menu.reset(new PhoneMenu(m_state, m_actions)); break; @@ -585,6 +599,7 @@ MenuFactory::buildMenu(Menu::Profile profile) case Menu::PhoneGreeter: menu.reset(new PhoneGreeterMenu(m_state, m_actions)); break; +#endif default: g_warn_if_reached(); diff --git a/src/snap.cpp b/src/snap.cpp index 58ebd3b..2f1158a 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -17,6 +17,7 @@ * Charles Kerr <charles.kerr@canonical.com> */ +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS #include "dbus-accounts-sound.h" #include <datetime/snap.h> @@ -259,3 +260,5 @@ Snap::operator()(const Appointment& appointment, } // namespace datetime } // namespace indicator } // namespace ayatana + +#endif |