From cd52f3dcd774530bc32c57afdba695c21b5e059e Mon Sep 17 00:00:00 2001 From: Marius Vollmer Date: Mon, 11 Mar 2013 14:52:59 +0200 Subject: [PATCH 1/4] Clean up example domain delay configuration. * Use realm_settings_double. * Use "example-leave-delay" as appropriate instead of "example-join-delay". * Document example-join-delay and example-leave-delay. --- doc/internals/realmd-internals.xml | 12 ++++++++---- service/realm-example.c | 22 +++++----------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/doc/internals/realmd-internals.xml b/doc/internals/realmd-internals.xml index 87d3aa6..f4b99dd 100644 --- a/doc/internals/realmd-internals.xml +++ b/doc/internals/realmd-internals.xml @@ -349,9 +349,8 @@ -[example] -enabled = no -# enabled = yes +[providers] +example = yes @@ -364,9 +363,14 @@ enabled = no example-administrator = Administrator # Password for above mock admin account example-password = bureaucracy +# How long to delay when joining this domain, in seconds. +example-join-delay = 2.5 +# How long to delay when leaving +example-leave-delay = 1 +# Whether to disallow leaving without a password +example-no-auto-leave = yes -
diff --git a/service/realm-example.c b/service/realm-example.c index 4c4ff83..cf33133 100644 --- a/service/realm-example.c +++ b/service/realm-example.c @@ -220,21 +220,9 @@ typedef struct { } OpData; static gdouble -settings_join_delay (const gchar *realm_name) +settings_delay (const gchar *realm_name, const gchar *key) { - gchar *endptr = NULL; - const gchar *string; - gdouble value; - - string = realm_settings_value (realm_name, "example-join-delay"); - if (string == NULL) - return 0.0; - - value = g_strtod (string, &endptr); - if (!endptr || endptr[0] != '\0') - return 0.0; - - return value * G_USEC_PER_SEC; + return realm_settings_double (realm_name, key, 0.0) * G_USEC_PER_SEC; } static void @@ -309,7 +297,7 @@ realm_example_join_async (RealmKerberosMembership *membership, OpData *data = g_new0 (OpData, 1); data->self = g_object_ref (self); data->async = g_object_ref (async); - usleep_async (settings_join_delay (realm_name), + usleep_async (settings_delay (realm_name, "example-join-delay"), realm_invocation_get_cancellable (invocation), on_join_sleep_done, data); } @@ -396,7 +384,7 @@ realm_example_leave_password_async (RealmKerberosMembership *membership, OpData *data = g_new0 (OpData, 1); data->self = g_object_ref (self); data->async = g_object_ref (async); - usleep_async (settings_join_delay (realm_name), + usleep_async (settings_delay (realm_name, "example-leave-delay"), realm_invocation_get_cancellable (invocation), on_leave_sleep_done, data); } @@ -431,7 +419,7 @@ realm_example_leave_automatic_async (RealmKerberosMembership *membership, OpData *data = g_new0 (OpData, 1); data->self = g_object_ref (self); data->async = g_object_ref (async); - usleep_async (settings_join_delay (realm_name), + usleep_async (settings_delay (realm_name, "example-leave-delay"), realm_invocation_get_cancellable (invocation), on_leave_sleep_done, data); } -- 1.8.1.4