From eef2e2120a15813eaff286107a5da17c075282ef Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 22 Aug 2012 16:05:48 +0200 Subject: [PATCH 2/4] Turn various DBus flag/option strings into constants https://bugs.freedesktop.org/show_bug.cgi?id=53934 --- dbus/realm-dbus-constants.h | 10 ++++++++++ service/realm-diagnostics.c | 2 +- service/realm-kerberos.c | 4 ++-- service/realm-samba-provider.c | 2 +- service/realm-samba.c | 6 +++--- service/realm-sssd-ad-provider.c | 2 +- service/realm-sssd-ad.c | 7 ++++--- service/realm-sssd-ipa.c | 4 ++-- tools/realm-enroll.c | 2 +- 9 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dbus/realm-dbus-constants.h b/dbus/realm-dbus-constants.h index 3c5784e..eee45b1 100644 --- a/dbus/realm-dbus-constants.h +++ b/dbus/realm-dbus-constants.h @@ -56,6 +56,16 @@ G_BEGIN_DECLS #define REALM_DBUS_LOGIN_POLICY_PERMITTED "allow-permitted-logins" #define REALM_DBUS_LOGIN_POLICY_DENY "deny-any-login" +#define REALM_DBUS_OPTION_OPERATION "operation" +#define REALM_DBUS_OPTION_COMPUTER_OU "computer-ou" +#define REALM_DBUS_OPTION_SERVER_SOFTWARE "server-software" +#define REALM_DBUS_OPTION_CLIENT_SOFTWARE "client-software" + +#define REALM_DBUS_IDENTIFIER_ACTIVE_DIRECTORY "active-directory" +#define REALM_DBUS_IDENTIFIER_WINBIND "winbind" +#define REALM_DBUS_IDENTIFIER_FREEIPA "freeipa" +#define REALM_DBUS_IDENTIFIER_SSSD "sssd" + G_END_DECLS #endif /* __REALM_DBUS_CONSTANTS_H__ */ diff --git a/service/realm-diagnostics.c b/service/realm-diagnostics.c index a60bcb4..2d4239f 100644 --- a/service/realm-diagnostics.c +++ b/service/realm-diagnostics.c @@ -56,7 +56,7 @@ realm_diagnostics_setup_options (GDBusMethodInvocation *invocation, g_return_if_fail (G_IS_DBUS_METHOD_INVOCATION (invocation)); g_return_if_fail (options != NULL); - if (g_variant_lookup (options, "operation", "(s)", &operation_id)) { + if (g_variant_lookup (options, REALM_DBUS_OPTION_OPERATION, "(s)", &operation_id)) { g_object_set_qdata_full (G_OBJECT (invocation), operation_id_quark, operation_id, g_free); } diff --git a/service/realm-kerberos.c b/service/realm-kerberos.c index cdae6ab..8d949c5 100644 --- a/service/realm-kerberos.c +++ b/service/realm-kerberos.c @@ -1199,12 +1199,12 @@ realm_kerberos_calculate_join_computer_ou (RealmKerberos *self, g_return_val_if_fail (REALM_IS_KERBEROS (self), NULL); if (options) { - if (!g_variant_lookup (options, "computer-ou", "&s", &computer_ou)) + if (!g_variant_lookup (options, REALM_DBUS_OPTION_COMPUTER_OU, "&s", &computer_ou)) computer_ou = NULL; } if (!computer_ou) - computer_ou = realm_settings_value (realm_kerberos_get_name (self), "join-computer-ou"); + computer_ou = realm_settings_value (realm_kerberos_get_name (self), REALM_DBUS_OPTION_COMPUTER_OU); return g_strdup (computer_ou); } diff --git a/service/realm-samba-provider.c b/service/realm-samba-provider.c index 147c694..4d0c8ad 100644 --- a/service/realm-samba-provider.c +++ b/service/realm-samba-provider.c @@ -145,7 +145,7 @@ realm_samba_provider_discover_finish (RealmProvider *provider, g_variant_ref_sink (*realms); /* Return a higher priority if we're the default */ - return realm_provider_is_default ("active-directory", "winbind") ? 100 : 50; + return realm_provider_is_default (REALM_DBUS_IDENTIFIER_ACTIVE_DIRECTORY, REALM_DBUS_IDENTIFIER_WINBIND) ? 100 : 50; } static void diff --git a/service/realm-samba.c b/service/realm-samba.c index 78c2706..1e9f3ed 100644 --- a/service/realm-samba.c +++ b/service/realm-samba.c @@ -67,8 +67,8 @@ realm_samba_constructed (GObject *obj) G_OBJECT_CLASS (realm_samba_parent_class)->constructed (obj); realm_kerberos_set_details (kerberos, - "server-software", "active-directory", - "client-software", "winbind", + REALM_DBUS_OPTION_SERVER_SOFTWARE, REALM_DBUS_IDENTIFIER_ACTIVE_DIRECTORY, + REALM_DBUS_OPTION_CLIENT_SOFTWARE, REALM_DBUS_IDENTIFIER_WINBIND, NULL); /* @@ -417,7 +417,7 @@ realm_samba_unenroll_async (RealmKerberos *realm, _("Not currently joined to a domain")); g_simple_async_result_complete_in_idle (res); - } else if (g_variant_lookup (options, "computer-ou", "&s", &computer_ou)) { + } else if (g_variant_lookup (options, REALM_DBUS_OPTION_COMPUTER_OU, "&s", &computer_ou)) { g_simple_async_result_set_error (res, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "The computer-ou argument is not supported when leaving a domain (using samba)."); g_simple_async_result_complete_in_idle (res); diff --git a/service/realm-sssd-ad-provider.c b/service/realm-sssd-ad-provider.c index 980196e..cfd30a5 100644 --- a/service/realm-sssd-ad-provider.c +++ b/service/realm-sssd-ad-provider.c @@ -152,7 +152,7 @@ realm_sssd_ad_provider_discover_finish (RealmProvider *provider, g_variant_ref_sink (*realms); /* Return a higher priority if we're the default */ - return realm_provider_is_default ("active-directory", "sssd") ? 100 : 50; + return realm_provider_is_default (REALM_DBUS_IDENTIFIER_ACTIVE_DIRECTORY, REALM_DBUS_IDENTIFIER_SSSD) ? 100 : 50; } static void diff --git a/service/realm-sssd-ad.c b/service/realm-sssd-ad.c index 7d239f1..7fe49d9 100644 --- a/service/realm-sssd-ad.c +++ b/service/realm-sssd-ad.c @@ -16,6 +16,7 @@ #include "realm-ad-discover.h" #include "realm-command.h" +#include "realm-dbus-constants.h" #include "realm-diagnostics.h" #include "realm-errors.h" #include "realm-packages.h" @@ -56,8 +57,8 @@ realm_sssd_ad_constructed (GObject *obj) G_OBJECT_CLASS (realm_sssd_ad_parent_class)->constructed (obj); realm_kerberos_set_details (kerberos, - "server-software", "active-directory", - "client-software", "sssd", + REALM_DBUS_OPTION_SERVER_SOFTWARE, REALM_DBUS_IDENTIFIER_ACTIVE_DIRECTORY, + REALM_DBUS_OPTION_CLIENT_SOFTWARE, REALM_DBUS_IDENTIFIER_SSSD, NULL); /* @@ -458,7 +459,7 @@ realm_sssd_ad_unenroll_async (RealmKerberos *realm, _("Not currently joined to this domain")); g_simple_async_result_complete_in_idle (res); - } else if (g_variant_lookup (options, "computer-ou", "&s", &computer_ou)) { + } else if (g_variant_lookup (options, REALM_DBUS_OPTION_COMPUTER_OU, "&s", &computer_ou)) { g_simple_async_result_set_error (res, G_DBUS_ERROR, G_DBUS_ERROR_INVALID_ARGS, "The computer-ou argument is not supported when leaving a domain (using samba)."); g_simple_async_result_complete_in_idle (res); diff --git a/service/realm-sssd-ipa.c b/service/realm-sssd-ipa.c index 1340998..02abe83 100644 --- a/service/realm-sssd-ipa.c +++ b/service/realm-sssd-ipa.c @@ -58,8 +58,8 @@ realm_sssd_ipa_constructed (GObject *obj) G_OBJECT_CLASS (realm_sssd_ipa_parent_class)->constructed (obj); realm_kerberos_set_details (kerberos, - "server-software", "freeipa", - "client-software", "sssd", + REALM_DBUS_OPTION_SERVER_SOFTWARE, REALM_DBUS_IDENTIFIER_FREEIPA, + REALM_DBUS_OPTION_CLIENT_SOFTWARE, REALM_DBUS_IDENTIFIER_SSSD, NULL); /* diff --git a/tools/realm-enroll.c b/tools/realm-enroll.c index ed86ae0..b1a680d 100644 --- a/tools/realm-enroll.c +++ b/tools/realm-enroll.c @@ -389,7 +389,7 @@ realm_join_or_leave (RealmDbusKerberosMembership *membership, sync.result = NULL; sync.loop = g_main_loop_new (NULL, FALSE); - options = realm_build_options ("computer-ou", computer_ou, NULL); + options = realm_build_options (REALM_DBUS_OPTION_COMPUTER_OU, computer_ou, NULL); g_variant_ref_sink (options); /* Start actual operation */ -- 1.7.11.5