From ba840e537b10fb4b0a9a6f8c2d4708ee0b525d21 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 2 Nov 2023 13:48:48 +0100 Subject: {CMakeLists.txt,src/service.c}: Make building against librda optional. --- CMakeLists.txt | 18 +++++++++++++----- src/service.c | 12 +++++++++++- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c14ca59..848a1df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ set (GETTEXT_PACKAGE "ayatana-indicator-session") option(ENABLE_TESTS "Enable all tests and checks" OFF) option(ENABLE_COVERAGE "Enable coverage reports (includes enabling all tests and checks)" OFF) option(ENABLE_WERROR "Treat all build warnings as errors" OFF) +option(ENABLE_RDA "Enable RDA (remote desktop awareness)" ON) if(ENABLE_COVERAGE) set(ENABLE_TESTS ON) @@ -45,11 +46,18 @@ include (GNUInstallDirs) ## find_package (PkgConfig REQUIRED) include (FindPkgConfig) -pkg_check_modules (SERVICE REQUIRED - libayatana-common>=0.9.2 - glib-2.0>=2.36 - gio-unix-2.0>=2.36 - rda) +set (SERVICE REQUIRED + libayatana-common>=0.9.2 + glib-2.0>=2.36 + gio-unix-2.0>=2.36) + +if (ENABLE_RDA) + list (APPEND SERVICE rda) + add_definitions (-DRDA_ENABLED) +endif () + +pkg_check_modules (SERVICE REQUIRED ${SERVICE}) + include_directories (${SERVICE_INCLUDE_DIRS}) set (ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}) diff --git a/src/service.c b/src/service.c index 7711f97..eff36ca 100644 --- a/src/service.c +++ b/src/service.c @@ -22,7 +22,9 @@ #include #include #include -#include +#ifdef RDA_ENABLED +# include +#endif /* RDA_ENABLED */ #include "backend.h" #include "recoverable-problem.h" #include "service.h" @@ -885,12 +887,14 @@ create_session_section (IndicatorSessionService * self, int profile) } else { +#ifdef RDA_ENABLED gboolean bSuspendable = rda_session_can_be_suspended (); if (bSuspendable) { g_menu_append (menu, _("Suspend Remote Session"), "indicator.remotesuspend"); } +#endif } return G_MENU_MODEL (menu); @@ -1016,7 +1020,9 @@ on_logout_activated (GSimpleAction * a G_GNUC_UNUSED, if (!self->priv->bLocal) { +#ifdef RDA_ENABLED rda_session_terminate (); +#endif /* RDA_ENABLED */ } else { @@ -1099,7 +1105,9 @@ static void on_custom_activated (GSimpleAction *pAction G_GNUC_UNUSED, GVariant static void onRemoteSuspend (GSimpleAction *pAction G_GNUC_UNUSED, GVariant *pParam G_GNUC_UNUSED, gpointer pUserData) { +#ifdef RDA_ENABLED rda_session_suspend (); +#endif /* RDA_ENABLED */ } static void @@ -1413,7 +1421,9 @@ indicator_session_service_init (IndicatorSessionService * self) } self->priv = p; +#if RDA_ENABLED self->priv->bLocal = rda_session_is_local (); +#endif /* RDA_ENABLED */ /* init the backend objects */ p->cancellable = g_cancellable_new (); -- cgit v1.2.3 From 8fd1edd3777e16829492c9b57f5c583e161ae0af Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 2 Nov 2023 13:49:04 +0100 Subject: src/service.c: White-space fix. --- src/service.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/service.c b/src/service.c index eff36ca..e7682ee 100644 --- a/src/service.c +++ b/src/service.c @@ -1132,7 +1132,7 @@ init_gactions (IndicatorSessionService * self) { "suspend", on_suspend_activated }, { "power-off", on_power_off_activated }, { "custom", on_custom_activated }, - { "remotesuspend", onRemoteSuspend } + { "remotesuspend", onRemoteSuspend } }; p->actions = g_simple_action_group_new (); -- cgit v1.2.3 From eca237d3b0ba0cccbe8855db1fda53e70e4ee8ec Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 2 Nov 2023 13:51:36 +0100 Subject: src/service.c: Rename onRemoteSuspend -> on_remote_suspend (better matching with other function names). --- src/service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service.c b/src/service.c index e7682ee..c3122cd 100644 --- a/src/service.c +++ b/src/service.c @@ -1103,7 +1103,7 @@ static void on_custom_activated (GSimpleAction *pAction G_GNUC_UNUSED, GVariant ayatana_common_utils_open_url (sUri); } -static void onRemoteSuspend (GSimpleAction *pAction G_GNUC_UNUSED, GVariant *pParam G_GNUC_UNUSED, gpointer pUserData) +static void on_remote_suspend (GSimpleAction *pAction G_GNUC_UNUSED, GVariant *pParam G_GNUC_UNUSED, gpointer pUserData) { #ifdef RDA_ENABLED rda_session_suspend (); @@ -1132,7 +1132,7 @@ init_gactions (IndicatorSessionService * self) { "suspend", on_suspend_activated }, { "power-off", on_power_off_activated }, { "custom", on_custom_activated }, - { "remotesuspend", onRemoteSuspend } + { "remotesuspend", on_remote_suspend } }; p->actions = g_simple_action_group_new (); -- cgit v1.2.3