From f54505942ce2dcc73fcbad79d4f5cdce991bf8cb Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Fri, 8 Dec 2017 10:40:44 +0000 Subject: Make the datetime indicator build on non-Ubuntu systems (which mostly lack url-dispatcher and Ubuntu Touch sound schema files. --- src/CMakeLists.txt | 12 +++++++----- src/actions-live.cpp | 12 +++++++++++- src/actions.cpp | 6 ++++-- src/main.cpp | 8 +++++++- src/menu.cpp | 19 +++++++++++++++++-- src/snap.cpp | 3 +++ 6 files changed, 49 insertions(+), 11 deletions(-) (limited to 'src') 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 +#ifdef HAS_URLDISPATCHER #include +#endif #include @@ -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(gself)->desktop_open_settings_app(); } +#ifdef HAS_URLDISPATCHER void on_phone_appointment_activated (GSimpleAction*, GVariant *vuid, gpointer gself) { auto self = static_cast(gself); @@ -108,7 +109,7 @@ void on_phone_settings_activated (GSimpleAction*, GVariant*, gpointer gself) { static_cast(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): { "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 #include #include +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS #include +#endif #include #include #include @@ -90,6 +92,7 @@ namespace return state; } +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS std::shared_ptr create_simple_alarm_queue(const std::shared_ptr& clock, const std::shared_ptr& snooze_planner, const std::shared_ptr& engine, @@ -113,6 +116,7 @@ namespace auto wakeup_timer = std::make_shared(clock); return std::make_shared(clock, planner, wakeup_timer); } +#endif } int @@ -133,9 +137,10 @@ main(int /*argc*/, char** /*argv*/) auto actions = std::make_shared(state); MenuFactory factory(actions, state); +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS // set up the snap decisions auto snooze_planner = std::make_shared(state->settings, state->clock); - auto notification_engine = std::make_shared("indicator-datetime-service"); + auto notification_engine = std::make_shared("ayatana-indicator-datetime-service"); std::unique_ptr 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> 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_): 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 */ +#ifdef HAVE_UT_ACCTSERVICE_SYSTEMSOUND_SETTINGS #include "dbus-accounts-sound.h" #include @@ -259,3 +260,5 @@ Snap::operator()(const Appointment& appointment, } // namespace datetime } // namespace indicator } // namespace ayatana + +#endif -- cgit v1.2.3