From 41b7c07a9c869ba5a35e9a2a8960bcbf457bdcb0 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Sun, 11 Aug 2013 14:32:28 +0300 Subject: [PATCH] group: start cleaning up the interface For UCS we need to add more global group related data structures. Start to internalize groups list. --- src/core/sipe-core.c | 8 ++------ src/core/sipe-group.c | 20 ++++++++++++++++---- src/core/sipe-group.h | 18 ++++++++++++++---- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/src/core/sipe-core.c b/src/core/sipe-core.c index ea27ca3f..790c78a6 100644 --- a/src/core/sipe-core.c +++ b/src/core/sipe-core.c @@ -308,6 +308,7 @@ struct sipe_core_public *sipe_core_allocate(const gchar *signin_name, sipe_private->public.sip_domain = g_strdup(user_domain[1]); g_strfreev(user_domain); + sipe_group_init(sipe_private); sipe_buddy_init(sipe_private); sipe_private->our_publications = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)g_hash_table_destroy); @@ -428,12 +429,7 @@ void sipe_core_deallocate(struct sipe_core_public *sipe_public) g_hash_table_destroy(sipe_private->our_publications); g_hash_table_destroy(sipe_private->user_state_publications); sipe_subscriptions_destroy(sipe_private); - - if (sipe_private->groups) { - GSList *entry; - while ((entry = sipe_private->groups) != NULL) - sipe_group_free(sipe_private, entry->data); - } + sipe_group_free(sipe_private); if (sipe_private->our_publication_keys) sipe_utils_slist_free_full(sipe_private->our_publication_keys, g_free); diff --git a/src/core/sipe-group.c b/src/core/sipe-group.c index 3165b08b..077f31e7 100755 --- a/src/core/sipe-group.c +++ b/src/core/sipe-group.c @@ -210,8 +210,8 @@ sipe_group_add(struct sipe_core_private *sipe_private, } } -void sipe_group_free(struct sipe_core_private *sipe_private, - struct sipe_group *group) +static void group_free(struct sipe_core_private *sipe_private, + struct sipe_group *group) { sipe_private->groups = g_slist_remove(sipe_private->groups, group); @@ -225,7 +225,7 @@ void sipe_group_remove(struct sipe_core_private *sipe_private, if (group) { SIPE_DEBUG_INFO("removing group %s (id %d)", group->name, group->id); sipe_backend_buddy_group_remove(SIPE_CORE_PUBLIC, group->name); - sipe_group_free(sipe_private, group); + group_free(sipe_private, group); } } @@ -274,7 +274,7 @@ sipe_core_group_remove(struct sipe_core_public *sipe_public, request); g_free(request); - sipe_group_free(sipe_private, s_group); + group_free(sipe_private, s_group); } else { SIPE_DEBUG_INFO("Cannot find group %s to delete", name); } @@ -364,6 +364,18 @@ void sipe_core_group_set_alias(struct sipe_core_public *sipe_public, send_buddy_update(sipe_private, buddy, alias); } +void sipe_group_init(struct sipe_core_private *sipe_private) +{ + sipe_private->groups = NULL; +} + +void sipe_group_free(struct sipe_core_private *sipe_private) +{ + GSList *entry; + while ((entry = sipe_private->groups) != NULL) + group_free(sipe_private, entry->data); +} + /* Local Variables: mode: c diff --git a/src/core/sipe-group.h b/src/core/sipe-group.h index 2a60f6cd..f92ac451 100644 --- a/src/core/sipe-group.h +++ b/src/core/sipe-group.h @@ -47,10 +47,6 @@ gboolean sipe_group_rename(struct sipe_core_private *sipe_private, void sipe_group_add(struct sipe_core_private *sipe_private, struct sipe_group * group); -/* remove group from core and free the data structure */ -void sipe_group_free(struct sipe_core_private *sipe_private, - struct sipe_group *group); - /* remove group from core & backend */ void sipe_group_remove(struct sipe_core_private *sipe_private, struct sipe_group *group); @@ -58,3 +54,17 @@ void sipe_group_remove(struct sipe_core_private *sipe_private, /* update alias/group list for a buddy on the server */ void sipe_group_update_buddy(struct sipe_core_private *sipe_private, struct sipe_buddy *buddy); + +/** + * Initialize group data + * + * @param sipe_private SIPE core data + */ +void sipe_group_init(struct sipe_core_private *sipe_private); + +/** + * Free group data + * + * @param sipe_private SIPE core data + */ +void sipe_group_free(struct sipe_core_private *sipe_private); -- 2.11.4.GIT