[gnome-online-accounts/wip/rishi/gobject-modernize: 2/5] kerberos-identity-manager: Drop the priv pointer
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/gobject-modernize: 2/5] kerberos-identity-manager: Drop the priv pointer
- Date: Thu, 28 Nov 2019 18:29:19 +0000 (UTC)
commit d9023fb1dc537c965d02133f47d6ae5b2630de85
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Nov 28 15:14:48 2019 +0100
kerberos-identity-manager: Drop the priv pointer
The current GObject recommendation is to use the generated
get_instance_private function instead of a separate priv pointer in the
instance struct. This saves one pointer per class in the hierarchy
multiplied by the number of instances of the type, and the function is
fast enough because it only does pointer arithmetic.
src/goaidentity/goakerberosidentitymanager.c | 349 +++++++++++++++------------
src/goaidentity/goakerberosidentitymanager.h | 1 -
2 files changed, 193 insertions(+), 157 deletions(-)
---
diff --git a/src/goaidentity/goakerberosidentitymanager.c b/src/goaidentity/goakerberosidentitymanager.c
index 295aed23..0bfee721 100644
--- a/src/goaidentity/goakerberosidentitymanager.c
+++ b/src/goaidentity/goakerberosidentitymanager.c
@@ -126,12 +126,15 @@ operation_new (GoaKerberosIdentityManager *self,
OperationType type,
GTask *task)
{
+ GoaKerberosIdentityManagerPrivate *priv;
Operation *operation;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
operation = g_slice_new0 (Operation);
operation->manager = self;
- operation->scheduler_cancellable = g_object_ref (self->priv->scheduler_cancellable);
+ operation->scheduler_cancellable = g_object_ref (priv->scheduler_cancellable);
operation->type = type;
@@ -253,12 +256,15 @@ goa_kerberos_identify_manager_send_to_context (GMainContext *context,
static void
schedule_refresh (GoaKerberosIdentityManager *self)
{
+ GoaKerberosIdentityManagerPrivate *priv;
Operation *operation;
- g_atomic_int_inc (&self->priv->pending_refresh_count);
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ g_atomic_int_inc (&priv->pending_refresh_count);
operation = operation_new (self, NULL, OPERATION_TYPE_REFRESH, NULL);
- g_thread_pool_push (self->priv->thread_pool, operation, NULL);
+ g_thread_pool_push (priv->thread_pool, operation, NULL);
}
static IdentitySignalWork *
@@ -418,34 +424,34 @@ remove_identity (GoaKerberosIdentityManager *self,
Operation *operation,
GoaIdentity *identity)
{
-
+ GoaKerberosIdentityManagerPrivate *priv;
IdentitySignalWork *work;
const char *identifier;
char *name;
GList *other_identities = NULL;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
identifier = goa_identity_get_identifier (identity);
name = goa_kerberos_identity_get_realm_name (GOA_KERBEROS_IDENTITY (identity));
if (name != NULL)
{
- other_identities = g_hash_table_lookup (self->priv->identities_by_realm, name);
- g_hash_table_remove (self->priv->identities_by_realm, name);
+ other_identities = g_hash_table_lookup (priv->identities_by_realm, name);
+ g_hash_table_remove (priv->identities_by_realm, name);
other_identities = g_list_remove (other_identities, identity);
}
if (other_identities != NULL)
- {
- g_hash_table_replace (self->priv->identities_by_realm,
- g_strdup (name), other_identities);
- }
+ g_hash_table_replace (priv->identities_by_realm, g_strdup (name), other_identities);
+
g_free (name);
work = identity_signal_work_new (self, identity);
- g_hash_table_remove (self->priv->expired_identities, identifier);
- g_hash_table_remove (self->priv->identities, identifier);
+ g_hash_table_remove (priv->expired_identities, identifier);
+ g_hash_table_remove (priv->identities, identifier);
goa_kerberos_identify_manager_send_to_context (operation->context,
(GSourceFunc)
@@ -475,10 +481,13 @@ drop_stale_identities (GoaKerberosIdentityManager *self,
Operation *operation,
GHashTable *known_identities)
{
+ GoaKerberosIdentityManagerPrivate *priv;
GList *stale_identity_ids;
GList *node;
- stale_identity_ids = g_hash_table_get_keys (self->priv->identities);
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ stale_identity_ids = g_hash_table_get_keys (priv->identities);
node = stale_identity_ids;
while (node != NULL)
@@ -489,7 +498,7 @@ drop_stale_identities (GoaKerberosIdentityManager *self,
identity = g_hash_table_lookup (known_identities, identifier);
if (identity == NULL)
{
- identity = g_hash_table_lookup (self->priv->identities, identifier);
+ identity = g_hash_table_lookup (priv->identities, identifier);
if (identity != NULL)
{
@@ -535,16 +544,15 @@ add_identity (GoaKerberosIdentityManager *self,
GoaIdentity *identity,
const char *identifier)
{
+ GoaKerberosIdentityManagerPrivate *priv;
IdentitySignalWork *work;
- g_hash_table_replace (self->priv->identities,
- g_strdup (identifier), g_object_ref (identity));
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ g_hash_table_replace (priv->identities, g_strdup (identifier), g_object_ref (identity));
if (!goa_identity_is_signed_in (identity))
- {
- g_hash_table_replace (self->priv->expired_identities,
- g_strdup (identifier), identity);
- }
+ g_hash_table_replace (priv->expired_identities, g_strdup (identifier), identity);
work = identity_signal_work_new (self, identity);
goa_kerberos_identify_manager_send_to_context (operation->context,
@@ -560,15 +568,18 @@ refresh_identity (GoaKerberosIdentityManager *self,
GHashTable *refreshed_identities,
GoaIdentity *identity)
{
+ GoaKerberosIdentityManagerPrivate *priv;
const char *identifier;
GoaIdentity *old_identity;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
identifier = goa_identity_get_identifier (identity);
if (identifier == NULL)
return;
- old_identity = g_hash_table_lookup (self->priv->identities, identifier);
+ old_identity = g_hash_table_lookup (priv->identities, identifier);
if (old_identity != NULL)
{
@@ -599,41 +610,42 @@ static gboolean
refresh_identities (GoaKerberosIdentityManager *self,
Operation *operation)
{
+ GoaKerberosIdentityManagerPrivate *priv;
krb5_error_code error_code;
krb5_ccache cache;
krb5_cccol_cursor cursor;
const char *error_message;
GHashTable *refreshed_identities;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
/* If we have more refreshes queued up, don't bother doing this one
*/
- if (!g_atomic_int_dec_and_test (&self->priv->pending_refresh_count))
+ if (!g_atomic_int_dec_and_test (&priv->pending_refresh_count))
{
return FALSE;
}
g_debug ("GoaKerberosIdentityManager: Refreshing identities");
refreshed_identities = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- error_code = krb5_cccol_cursor_new (self->priv->kerberos_context, &cursor);
+ error_code = krb5_cccol_cursor_new (priv->kerberos_context, &cursor);
if (error_code != 0)
{
- error_message =
- krb5_get_error_message (self->priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (priv->kerberos_context, error_code);
g_debug ("GoaKerberosIdentityManager: Error looking up available credential caches: %s",
error_message);
- krb5_free_error_message (self->priv->kerberos_context, error_message);
+ krb5_free_error_message (priv->kerberos_context, error_message);
goto done;
}
- error_code = krb5_cccol_cursor_next (self->priv->kerberos_context, cursor, &cache);
+ error_code = krb5_cccol_cursor_next (priv->kerberos_context, cursor, &cache);
while (error_code == 0 && cache != NULL)
{
GoaIdentity *identity;
- identity = goa_kerberos_identity_new (self->priv->kerberos_context,
- cache, NULL);
+ identity = goa_kerberos_identity_new (priv->kerberos_context, cache, NULL);
if (identity != NULL)
{
@@ -641,21 +653,19 @@ refresh_identities (GoaKerberosIdentityManager *self,
g_object_unref (identity);
}
- krb5_cc_close (self->priv->kerberos_context, cache);
- error_code = krb5_cccol_cursor_next (self->priv->kerberos_context,
- cursor, &cache);
+ krb5_cc_close (priv->kerberos_context, cache);
+ error_code = krb5_cccol_cursor_next (priv->kerberos_context, cursor, &cache);
}
if (error_code != 0)
{
- error_message =
- krb5_get_error_message (self->priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (priv->kerberos_context, error_code);
g_debug ("GoaKerberosIdentityManager: Error iterating over available credential caches: %s",
error_message);
- krb5_free_error_message (self->priv->kerberos_context, error_message);
+ krb5_free_error_message (priv->kerberos_context, error_message);
}
- krb5_cccol_cursor_free (self->priv->kerberos_context, &cursor);
+ krb5_cccol_cursor_free (priv->kerberos_context, &cursor);
done:
drop_stale_identities (self, operation, refreshed_identities);
g_hash_table_unref (refreshed_identities);
@@ -681,10 +691,13 @@ static void
list_identities (GoaKerberosIdentityManager *self,
Operation *operation)
{
+ GoaKerberosIdentityManagerPrivate *priv;
GList *identities;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
g_debug ("GoaKerberosIdentityManager: Listing identities");
- identities = g_hash_table_get_values (self->priv->identities);
+ identities = g_hash_table_get_values (priv->identities);
identities = g_list_sort (identities, (GCompareFunc) identity_sort_func);
@@ -814,10 +827,13 @@ static void
get_identity (GoaKerberosIdentityManager *self,
Operation *operation)
{
+ GoaKerberosIdentityManagerPrivate *priv;
GoaIdentity *identity;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
g_debug ("GoaKerberosIdentityManager: get identity %s", operation->identifier);
- identity = g_hash_table_lookup (self->priv->identities, operation->identifier);
+ identity = g_hash_table_lookup (priv->identities, operation->identifier);
if (identity == NULL)
{
@@ -835,27 +851,28 @@ static krb5_error_code
get_new_credentials_cache (GoaKerberosIdentityManager *self,
krb5_ccache *credentials_cache)
{
+ GoaKerberosIdentityManagerPrivate *priv;
krb5_error_code error_code;
gboolean supports_multiple_identities;
- if (g_strcmp0 (self->priv->credentials_cache_type, "FILE") == 0)
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ if (g_strcmp0 (priv->credentials_cache_type, "FILE") == 0)
{
g_debug ("GoaKerberosIdentityManager: credential cache type %s doesn't supports cache collections",
- self->priv->credentials_cache_type);
+ priv->credentials_cache_type);
supports_multiple_identities = FALSE;
}
- else if (g_strcmp0 (self->priv->credentials_cache_type, "DIR") == 0 ||
- g_strcmp0 (self->priv->credentials_cache_type, "KEYRING") == 0)
+ else if (g_strcmp0 (priv->credentials_cache_type, "DIR") == 0 || g_strcmp0 (priv->credentials_cache_type,
"KEYRING") == 0)
{
- g_debug ("GoaKerberosIdentityManager: credential cache type %s supports cache collections",
- self->priv->credentials_cache_type);
+ g_debug ("GoaKerberosIdentityManager: credential cache type %s supports cache collections",
priv->credentials_cache_type);
supports_multiple_identities = TRUE;
}
else
{
g_debug ("GoaKerberosIdentityManager: don't know if credential cache type %s supports cache
collections, "
"assuming yes",
- self->priv->credentials_cache_type);
+ priv->credentials_cache_type);
supports_multiple_identities = TRUE;
}
@@ -868,18 +885,10 @@ get_new_credentials_cache (GoaKerberosIdentityManager *self,
* ccache names for subsequent tickets.
*
*/
- if (!supports_multiple_identities ||
- g_hash_table_size (self->priv->identities) == 0)
- {
- error_code = krb5_cc_default (self->priv->kerberos_context, credentials_cache);
- }
+ if (!supports_multiple_identities || g_hash_table_size (priv->identities) == 0)
+ error_code = krb5_cc_default (priv->kerberos_context, credentials_cache);
else
- {
- error_code = krb5_cc_new_unique (self->priv->kerberos_context,
- self->priv->credentials_cache_type,
- NULL,
- credentials_cache);
- }
+ error_code = krb5_cc_new_unique (priv->kerberos_context, priv->credentials_cache_type, NULL,
credentials_cache);
return error_code;
}
@@ -888,15 +897,18 @@ static void
sign_in_identity (GoaKerberosIdentityManager *self,
Operation *operation)
{
+ GoaKerberosIdentityManagerPrivate *priv;
GoaIdentity *identity;
GError *error;
krb5_error_code error_code;
gboolean is_new_identity = FALSE;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
g_debug ("GoaKerberosIdentityManager: signing in identity %s",
operation->identifier);
error = NULL;
- identity = g_hash_table_lookup (self->priv->identities, operation->identifier);
+ identity = g_hash_table_lookup (priv->identities, operation->identifier);
if (identity == NULL)
{
krb5_ccache credentials_cache;
@@ -907,11 +919,10 @@ sign_in_identity (GoaKerberosIdentityManager *self,
{
const char *error_message;
- error_message =
- krb5_get_error_message (self->priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (priv->kerberos_context, error_code);
g_debug ("GoaKerberosIdentityManager: Error creating new cache for identity credentials:
%s",
error_message);
- krb5_free_error_message (self->priv->kerberos_context, error_message);
+ krb5_free_error_message (priv->kerberos_context, error_message);
g_task_return_new_error (operation->task,
GOA_IDENTITY_MANAGER_ERROR,
@@ -920,16 +931,14 @@ sign_in_identity (GoaKerberosIdentityManager *self,
return;
}
- identity = goa_kerberos_identity_new (self->priv->kerberos_context,
- credentials_cache,
- &error);
+ identity = goa_kerberos_identity_new (priv->kerberos_context, credentials_cache, &error);
if (identity == NULL)
{
- krb5_cc_destroy (self->priv->kerberos_context, credentials_cache);
+ krb5_cc_destroy (priv->kerberos_context, credentials_cache);
g_task_return_error (operation->task, error);
return;
}
- krb5_cc_close (self->priv->kerberos_context, credentials_cache);
+ krb5_cc_close (priv->kerberos_context, credentials_cache);
is_new_identity = TRUE;
}
else
@@ -957,9 +966,7 @@ sign_in_identity (GoaKerberosIdentityManager *self,
else
{
g_task_return_pointer (operation->task, g_object_ref (identity), g_object_unref);
- g_hash_table_replace (self->priv->identities,
- g_strdup (operation->identifier),
- g_object_ref (identity));
+ g_hash_table_replace (priv->identities, g_strdup (operation->identifier), g_object_ref (identity));
}
g_object_unref (identity);
@@ -997,31 +1004,41 @@ sign_out_identity (GoaKerberosIdentityManager *self,
static void
block_scheduler_job (GoaKerberosIdentityManager *self)
{
- g_mutex_lock (&self->priv->scheduler_job_lock);
- while (self->priv->is_blocking_scheduler_job)
- g_cond_wait (&self->priv->scheduler_job_unblocked,
- &self->priv->scheduler_job_lock);
- self->priv->is_blocking_scheduler_job = TRUE;
- g_mutex_unlock (&self->priv->scheduler_job_lock);
+ GoaKerberosIdentityManagerPrivate *priv;
+
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ g_mutex_lock (&priv->scheduler_job_lock);
+ while (priv->is_blocking_scheduler_job)
+ g_cond_wait (&priv->scheduler_job_unblocked, &priv->scheduler_job_lock);
+ priv->is_blocking_scheduler_job = TRUE;
+ g_mutex_unlock (&priv->scheduler_job_lock);
}
static void
stop_blocking_scheduler_job (GoaKerberosIdentityManager *self)
{
- g_mutex_lock (&self->priv->scheduler_job_lock);
- self->priv->is_blocking_scheduler_job = FALSE;
- g_cond_signal (&self->priv->scheduler_job_unblocked);
- g_mutex_unlock (&self->priv->scheduler_job_lock);
+ GoaKerberosIdentityManagerPrivate *priv;
+
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ g_mutex_lock (&priv->scheduler_job_lock);
+ priv->is_blocking_scheduler_job = FALSE;
+ g_cond_signal (&priv->scheduler_job_unblocked);
+ g_mutex_unlock (&priv->scheduler_job_lock);
}
static void
wait_for_scheduler_job_to_become_unblocked (GoaKerberosIdentityManager *self)
{
- g_mutex_lock (&self->priv->scheduler_job_lock);
- while (self->priv->is_blocking_scheduler_job)
- g_cond_wait (&self->priv->scheduler_job_unblocked,
- &self->priv->scheduler_job_lock);
- g_mutex_unlock (&self->priv->scheduler_job_lock);
+ GoaKerberosIdentityManagerPrivate *priv;
+
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ g_mutex_lock (&priv->scheduler_job_lock);
+ while (priv->is_blocking_scheduler_job)
+ g_cond_wait (&priv->scheduler_job_unblocked, &priv->scheduler_job_lock);
+ g_mutex_unlock (&priv->scheduler_job_lock);
}
static void
@@ -1116,9 +1133,12 @@ goa_kerberos_identity_manager_get_identity (GoaIdentityManager *manager,
gpointer user_data)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (manager);
+ GoaKerberosIdentityManagerPrivate *priv;
GTask *task;
Operation *operation;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, goa_kerberos_identity_manager_get_identity);
@@ -1127,7 +1147,7 @@ goa_kerberos_identity_manager_get_identity (GoaIdentityManager *manager,
operation->identifier = g_strdup (identifier);
- g_thread_pool_push (self->priv->thread_pool, operation, NULL);
+ g_thread_pool_push (priv->thread_pool, operation, NULL);
}
static GoaIdentity *
@@ -1146,16 +1166,19 @@ goa_kerberos_identity_manager_list_identities (GoaIdentityManager *manager,
gpointer user_data)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (manager);
+ GoaKerberosIdentityManagerPrivate *priv;
GTask *task;
Operation *operation;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, goa_kerberos_identity_manager_list_identities);
operation = operation_new (self, cancellable, OPERATION_TYPE_LIST, task);
g_object_unref (task);
- g_thread_pool_push (self->priv->thread_pool, operation, NULL);
+ g_thread_pool_push (priv->thread_pool, operation, NULL);
}
static GList *
@@ -1175,9 +1198,12 @@ goa_kerberos_identity_manager_renew_identity (GoaIdentityManager *manager,
gpointer user_data)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (manager);
+ GoaKerberosIdentityManagerPrivate *priv;
GTask *task;
Operation *operation;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, goa_kerberos_identity_manager_renew_identity);
@@ -1186,7 +1212,7 @@ goa_kerberos_identity_manager_renew_identity (GoaIdentityManager *manager,
operation->identity = g_object_ref (identity);
- g_thread_pool_push (self->priv->thread_pool, operation, NULL);
+ g_thread_pool_push (priv->thread_pool, operation, NULL);
}
static void
@@ -1211,9 +1237,12 @@ goa_kerberos_identity_manager_sign_identity_in (GoaIdentityManager *manager,
gpointer user_data)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (manager);
+ GoaKerberosIdentityManagerPrivate *priv;
GTask *task;
Operation *operation;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, goa_kerberos_identity_manager_sign_identity_in);
@@ -1233,7 +1262,7 @@ goa_kerberos_identity_manager_sign_identity_in (GoaIdentityManager *manager,
g_cond_init (&operation->inquiry_finished_condition);
operation->is_inquiring = FALSE;
- g_thread_pool_push (self->priv->thread_pool, operation, NULL);
+ g_thread_pool_push (priv->thread_pool, operation, NULL);
}
static GoaIdentity *
@@ -1253,9 +1282,12 @@ goa_kerberos_identity_manager_sign_identity_out (GoaIdentityManager *manager,
gpointer user_data)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (manager);
+ GoaKerberosIdentityManagerPrivate *priv;
GTask *task;
Operation *operation;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
task = g_task_new (self, cancellable, callback, user_data);
g_task_set_source_tag (task, goa_kerberos_identity_manager_sign_identity_out);
@@ -1264,7 +1296,7 @@ goa_kerberos_identity_manager_sign_identity_out (GoaIdentityManager *manager,
operation->identity = g_object_ref (identity);
- g_thread_pool_push (self->priv->thread_pool, operation, NULL);
+ g_thread_pool_push (priv->thread_pool, operation, NULL);
}
static void
@@ -1281,16 +1313,19 @@ goa_kerberos_identity_manager_name_identity (GoaIdentityManager *manager,
GoaIdentity *identity)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (manager);
+ GoaKerberosIdentityManagerPrivate *priv;
char *name;
GList *other_identities;
gboolean other_identity_needs_rename;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
name = goa_kerberos_identity_get_realm_name (GOA_KERBEROS_IDENTITY (identity));
if (name == NULL)
return NULL;
- other_identities = g_hash_table_lookup (self->priv->identities_by_realm, name);
+ other_identities = g_hash_table_lookup (priv->identities_by_realm, name);
/* If there was already exactly one identity for this realm before,
* then it was going by just the realm name, so we need to rename it
@@ -1303,9 +1338,7 @@ goa_kerberos_identity_manager_name_identity (GoaIdentityManager *manager,
other_identities = g_list_remove (other_identities, identity);
other_identities = g_list_prepend (other_identities, identity);
- g_hash_table_replace (self->priv->identities_by_realm,
- g_strdup (name),
- other_identities);
+ g_hash_table_replace (priv->identities_by_realm, g_strdup (name), other_identities);
if (other_identities->next != NULL)
{
@@ -1362,6 +1395,7 @@ static gboolean
monitor_credentials_cache (GoaKerberosIdentityManager *self,
GError **error)
{
+ GoaKerberosIdentityManagerPrivate *priv;
krb5_ccache default_cache;
const char *cache_type;
const char *cache_path;
@@ -1370,24 +1404,25 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
GError *monitoring_error = NULL;
gboolean can_monitor = TRUE;
- error_code = krb5_cc_default (self->priv->kerberos_context, &default_cache);
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ error_code = krb5_cc_default (priv->kerberos_context, &default_cache);
if (error_code != 0)
{
const char *error_message;
- error_message =
- krb5_get_error_message (self->priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (priv->kerberos_context, error_code);
g_set_error_literal (error,
GOA_IDENTITY_MANAGER_ERROR,
GOA_IDENTITY_MANAGER_ERROR_ACCESSING_CREDENTIALS,
error_message);
- krb5_free_error_message (self->priv->kerberos_context, error_message);
+ krb5_free_error_message (priv->kerberos_context, error_message);
return FALSE;
}
- cache_type = krb5_cc_get_type (self->priv->kerberos_context, default_cache);
+ cache_type = krb5_cc_get_type (priv->kerberos_context, default_cache);
g_assert (cache_type != NULL);
if (strcmp (cache_type, "FILE") != 0 && strcmp (cache_type, "DIR") != 0)
@@ -1397,8 +1432,8 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
can_monitor = FALSE;
}
- g_free (self->priv->credentials_cache_type);
- self->priv->credentials_cache_type = g_strdup (cache_type);
+ g_free (priv->credentials_cache_type);
+ priv->credentials_cache_type = g_strdup (cache_type);
/* If we're using a FILE type credential cache, then the
* default cache file is the only cache we care about,
@@ -1408,7 +1443,7 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
* cache file is one of many possible cache files, all in the
* same directory. We want to monitor that directory.
*/
- cache_path = krb5_cc_get_name (self->priv->kerberos_context, default_cache);
+ cache_path = krb5_cc_get_name (priv->kerberos_context, default_cache);
/* The cache name might have a : in front of it.
* See goakerberosidentity.c (fetch_raw_credentials) for similar code
@@ -1462,18 +1497,15 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
}
else
{
- self->priv->credentials_cache_changed_signal_id =
- g_signal_connect (G_OBJECT (monitor), "changed",
- G_CALLBACK (on_credentials_cache_changed), self);
- self->priv->credentials_cache_monitor = monitor;
+ priv->credentials_cache_changed_signal_id = g_signal_connect (G_OBJECT (monitor), "changed",
+ G_CALLBACK
(on_credentials_cache_changed), self);
+ priv->credentials_cache_monitor = monitor;
}
if (!can_monitor)
- self->priv->polling_timeout_id = g_timeout_add_seconds (FALLBACK_POLLING_INTERVAL,
- (GSourceFunc) on_polling_timeout,
- self);
+ priv->polling_timeout_id = g_timeout_add_seconds (FALLBACK_POLLING_INTERVAL, (GSourceFunc)
on_polling_timeout, self);
- krb5_cc_close (self->priv->kerberos_context, default_cache);
+ krb5_cc_close (priv->kerberos_context, default_cache);
return TRUE;
}
@@ -1481,18 +1513,22 @@ monitor_credentials_cache (GoaKerberosIdentityManager *self,
static void
stop_watching_credentials_cache (GoaKerberosIdentityManager *self)
{
- if (self->priv->credentials_cache_monitor != NULL)
+ GoaKerberosIdentityManagerPrivate *priv;
+
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ if (priv->credentials_cache_monitor != NULL)
{
- if (!g_file_monitor_is_cancelled (self->priv->credentials_cache_monitor))
- g_file_monitor_cancel (self->priv->credentials_cache_monitor);
+ if (!g_file_monitor_is_cancelled (priv->credentials_cache_monitor))
+ g_file_monitor_cancel (priv->credentials_cache_monitor);
- g_clear_object (&self->priv->credentials_cache_monitor);
+ g_clear_object (&priv->credentials_cache_monitor);
}
- if (self->priv->polling_timeout_id != 0)
+ if (priv->polling_timeout_id != 0)
{
- g_source_remove (self->priv->polling_timeout_id);
- self->priv->polling_timeout_id = 0;
+ g_source_remove (priv->polling_timeout_id);
+ priv->polling_timeout_id = 0;
}
}
@@ -1502,24 +1538,26 @@ goa_kerberos_identity_manager_initable_init (GInitable *initable,
GError **error)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (initable);
+ GoaKerberosIdentityManagerPrivate *priv;
krb5_error_code error_code;
GError *monitoring_error;
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return FALSE;
- error_code = krb5_init_context (&self->priv->kerberos_context);
+ error_code = krb5_init_context (&priv->kerberos_context);
if (error_code != 0)
{
const char *error_message;
- error_message =
- krb5_get_error_message (self->priv->kerberos_context, error_code);
+ error_message = krb5_get_error_message (priv->kerberos_context, error_code);
g_set_error_literal (error,
GOA_IDENTITY_MANAGER_ERROR,
GOA_IDENTITY_MANAGER_ERROR_INITIALIZING, error_message);
- krb5_free_error_message (self->priv->kerberos_context, error_message);
+ krb5_free_error_message (priv->kerberos_context, error_message);
return FALSE;
}
@@ -1546,70 +1584,66 @@ initable_interface_init (GInitableIface *interface)
static void
goa_kerberos_identity_manager_init (GoaKerberosIdentityManager *self)
{
+ GoaKerberosIdentityManagerPrivate *priv;
GError *error;
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
- GOA_TYPE_KERBEROS_IDENTITY_MANAGER,
- GoaKerberosIdentityManagerPrivate);
- self->priv->identities = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
- self->priv->expired_identities = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
- self->priv->identities_by_realm = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ priv->identities = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_object_unref);
+ priv->expired_identities = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+ priv->identities_by_realm = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
error = NULL;
- self->priv->thread_pool = g_thread_pool_new (goa_kerberos_identity_manager_thread_pool_func,
- NULL,
- 1,
- FALSE,
- &error);
+ priv->thread_pool = g_thread_pool_new (goa_kerberos_identity_manager_thread_pool_func, NULL, 1, FALSE,
&error);
g_assert_no_error (error);
- g_mutex_init (&self->priv->scheduler_job_lock);
- g_cond_init (&self->priv->scheduler_job_unblocked);
+ g_mutex_init (&priv->scheduler_job_lock);
+ g_cond_init (&priv->scheduler_job_unblocked);
- self->priv->scheduler_cancellable = g_cancellable_new ();
- g_cancellable_connect (self->priv->scheduler_cancellable,
- G_CALLBACK (on_scheduler_cancellable_cancelled),
- self,
- NULL);
+ priv->scheduler_cancellable = g_cancellable_new ();
+ g_cancellable_connect (priv->scheduler_cancellable, G_CALLBACK (on_scheduler_cancellable_cancelled), self,
NULL);
}
static void
goa_kerberos_identity_manager_dispose (GObject *object)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (object);
+ GoaKerberosIdentityManagerPrivate *priv;
- if (self->priv->scheduler_cancellable != NULL)
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
+
+ if (priv->scheduler_cancellable != NULL)
{
- if (!g_cancellable_is_cancelled (self->priv->scheduler_cancellable))
+ if (!g_cancellable_is_cancelled (priv->scheduler_cancellable))
{
- g_cancellable_cancel (self->priv->scheduler_cancellable);
+ g_cancellable_cancel (priv->scheduler_cancellable);
}
- g_clear_object (&self->priv->scheduler_cancellable);
+ g_clear_object (&priv->scheduler_cancellable);
}
- if (self->priv->thread_pool != NULL)
+ if (priv->thread_pool != NULL)
{
- g_thread_pool_free (self->priv->thread_pool, FALSE, TRUE);
- self->priv->thread_pool = NULL;
+ g_thread_pool_free (priv->thread_pool, FALSE, TRUE);
+ priv->thread_pool = NULL;
}
- if (self->priv->identities_by_realm != NULL)
+ if (priv->identities_by_realm != NULL)
{
- g_hash_table_unref (self->priv->identities_by_realm);
- self->priv->identities_by_realm = NULL;
+ g_hash_table_unref (priv->identities_by_realm);
+ priv->identities_by_realm = NULL;
}
- if (self->priv->expired_identities != NULL)
+ if (priv->expired_identities != NULL)
{
- g_hash_table_unref (self->priv->expired_identities);
- self->priv->expired_identities = NULL;
+ g_hash_table_unref (priv->expired_identities);
+ priv->expired_identities = NULL;
}
- if (self->priv->identities != NULL)
+ if (priv->identities != NULL)
{
- g_hash_table_unref (self->priv->identities);
- self->priv->identities = NULL;
+ g_hash_table_unref (priv->identities);
+ priv->identities = NULL;
}
stop_watching_credentials_cache (self);
@@ -1621,11 +1655,14 @@ static void
goa_kerberos_identity_manager_finalize (GObject *object)
{
GoaKerberosIdentityManager *self = GOA_KERBEROS_IDENTITY_MANAGER (object);
+ GoaKerberosIdentityManagerPrivate *priv;
+
+ priv = goa_kerberos_identity_manager_get_instance_private (self);
- g_free (self->priv->credentials_cache_type);
+ g_free (priv->credentials_cache_type);
- g_cond_clear (&self->priv->scheduler_job_unblocked);
- krb5_free_context (self->priv->kerberos_context);
+ g_cond_clear (&priv->scheduler_job_unblocked);
+ krb5_free_context (priv->kerberos_context);
G_OBJECT_CLASS (goa_kerberos_identity_manager_parent_class)->finalize (object);
}
diff --git a/src/goaidentity/goakerberosidentitymanager.h b/src/goaidentity/goakerberosidentitymanager.h
index 9af046a5..07f917ff 100644
--- a/src/goaidentity/goakerberosidentitymanager.h
+++ b/src/goaidentity/goakerberosidentitymanager.h
@@ -39,7 +39,6 @@ typedef struct _GoaKerberosIdentityManagerPrivate GoaKerberosIdentityManagerPriv
struct _GoaKerberosIdentityManager
{
GObject parent_instance;
- GoaKerberosIdentityManagerPrivate *priv;
};
struct _GoaKerberosIdentityManagerClass
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]