diff options
-rw-r--r-- | clients/cli/nmcli.h | 7 | ||||
-rw-r--r-- | clients/cli/polkit-agent.c | 38 | ||||
-rw-r--r-- | clients/common/nm-polkit-listener.c | 4 | ||||
-rw-r--r-- | clients/common/nm-polkit-listener.h | 14 |
4 files changed, 21 insertions, 42 deletions
diff --git a/clients/cli/nmcli.h b/clients/cli/nmcli.h index cbde4359f9..93f91b14ab 100644 --- a/clients/cli/nmcli.h +++ b/clients/cli/nmcli.h @@ -21,15 +21,8 @@ #define NMC_NMCLI_H #include "nm-secret-agent-old.h" - #include "nm-meta-setting-desc.h" - -#if WITH_POLKIT_AGENT #include "nm-polkit-listener.h" -#else -/* polkit agent is not available; define fake NMPolkitListener */ -typedef gpointer NMPolkitListener; -#endif typedef char *(*NmcCompEntryFunc) (const char *, int); diff --git a/clients/cli/polkit-agent.c b/clients/cli/polkit-agent.c index ecd58ba548..ce11a68635 100644 --- a/clients/cli/polkit-agent.c +++ b/clients/cli/polkit-agent.c @@ -19,8 +19,6 @@ #include "nm-default.h" -#if WITH_POLKIT_AGENT - #include "polkit-agent.h" #include <stdio.h> @@ -29,9 +27,9 @@ #include <unistd.h> #include "nm-polkit-listener.h" - #include "common.h" +#if WITH_POLKIT_AGENT static char * polkit_request (const char *request, const char *action_id, @@ -39,7 +37,7 @@ polkit_request (const char *request, const char *icon_name, const char *user, gboolean echo_on, - gpointer user_data) + gpointer user_data) { char *response, *tmp, *p; @@ -79,10 +77,12 @@ polkit_completed (gboolean gained_authorization) /* We don't print anything here. The outcome will be evident from * the operation result anyway. */ } +#endif gboolean nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error) { +#if WITH_POLKIT_AGENT PolkitAgentListener *listener; g_return_val_if_fail (error == NULL || *error == NULL, FALSE); @@ -97,18 +97,22 @@ nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error) nm_polkit_listener_set_completed_callback (NM_POLKIT_LISTENER (listener), polkit_completed); nmc->pk_listener = NM_POLKIT_LISTENER (listener); +#endif return TRUE; } void nmc_polkit_agent_fini (NmCli* nmc) { +#if WITH_POLKIT_AGENT g_clear_object (&nmc->pk_listener); +#endif } gboolean nmc_start_polkit_agent_start_try (NmCli *nmc) { +#if WITH_POLKIT_AGENT GError *error = NULL; /* We don't register polkit agent at all when running non-interactively */ @@ -121,30 +125,6 @@ nmc_start_polkit_agent_start_try (NmCli *nmc) g_error_free (error); return FALSE; } +#endif return TRUE; } - -#else -/* polkit agent is not avalable; implement stub functions. */ - -#include "nmcli.h" -#include "polkit-agent.h" - -gboolean -nmc_polkit_agent_init (NmCli* nmc, gboolean for_session, GError **error) -{ - return TRUE; -} - -void -nmc_polkit_agent_fini (NmCli* nmc) -{ -} - -gboolean -nmc_start_polkit_agent_start_try (NmCli *nmc) -{ - return TRUE; -} - -#endif /* #if WITH_POLKIT_AGENT */ diff --git a/clients/common/nm-polkit-listener.c b/clients/common/nm-polkit-listener.c index 69f490624f..1fae2eb56b 100644 --- a/clients/common/nm-polkit-listener.c +++ b/clients/common/nm-polkit-listener.c @@ -33,12 +33,12 @@ #include "nm-default.h" +#include "nm-polkit-listener.h" + #include <string.h> #include <stdio.h> #include <stdlib.h> -#include "nm-polkit-listener.h" - G_DEFINE_TYPE (NMPolkitListener, nm_polkit_listener, POLKIT_AGENT_TYPE_LISTENER) #define NM_POLKIT_LISTENER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_POLKIT_LISTENER, NMPolkitListenerPrivate)) diff --git a/clients/common/nm-polkit-listener.h b/clients/common/nm-polkit-listener.h index a8256460fd..b43a970065 100644 --- a/clients/common/nm-polkit-listener.h +++ b/clients/common/nm-polkit-listener.h @@ -19,6 +19,12 @@ #ifndef __NM_POLKIT_LISTENER_H__ #define __NM_POLKIT_LISTENER_H__ +struct _NMPolkitListener; + +typedef struct _NMPolkitListener NMPolkitListener; + +#if WITH_POLKIT_AGENT + #define POLKIT_AGENT_I_KNOW_API_IS_SUBJECT_TO_CHANGE #include <polkitagent/polkitagent.h> @@ -72,14 +78,12 @@ typedef void (*NMPolkitListenerOnShowErrorFunc) (const char *text); typedef void (*NMPolkitListenerOnCompletedFunc) (gboolean gained_authorization); -typedef struct { +struct _NMPolkitListener { PolkitAgentListener parent; - -} NMPolkitListener; +}; typedef struct { PolkitAgentListenerClass parent; - } NMPolkitListenerClass; GType nm_polkit_listener_get_type (void); @@ -95,4 +99,6 @@ void nm_polkit_listener_set_show_error_callback (NMPolkitListener *self, void nm_polkit_listener_set_completed_callback (NMPolkitListener *self, NMPolkitListenerOnCompletedFunc completed_callback); +#endif + #endif /* __NM_POLKIT_LISTENER_H__ */ |