From 6c1941a365877a42175ec3bc89ab0efabcc30e17 Mon Sep 17 00:00:00 2001 From: Stefan Becker Date: Sun, 27 Nov 2011 20:46:34 +0200 Subject: [PATCH] core cleanup: move groups list to sipe_private This makes sipe-group.c sip_account_data-free and removes the need to include sipe.h. I noticed that several modules, like sipe-group.c, don't include config.h although they include sipe-nls.h. --- src/core/sipe-core-private.h | 1 + src/core/sipe-core.c | 6 +++--- src/core/sipe-domino.c | 6 +++++- src/core/sipe-group.c | 43 +++++++++++++++++++++++++------------------ src/core/sipe-user.c | 4 ++++ src/core/sipe.c | 6 +++--- src/core/sipe.h | 8 -------- src/purple/purple-buddy.c | 6 +++++- src/purple/purple-im.c | 6 +++++- 9 files changed, 51 insertions(+), 35 deletions(-) diff --git a/src/core/sipe-core-private.h b/src/core/sipe-core-private.h index afc10ad2..2722ee9f 100644 --- a/src/core/sipe-core-private.h +++ b/src/core/sipe-core-private.h @@ -59,6 +59,7 @@ struct sipe_core_private { guint deltanum_acl; /* setACE (OCS2005 only) */ /* Buddies */ + GSList *groups; GHashTable *buddies; /* Scheduling system */ diff --git a/src/core/sipe-core.c b/src/core/sipe-core.c index 58b72d4d..e05a4959 100644 --- a/src/core/sipe-core.c +++ b/src/core/sipe-core.c @@ -211,8 +211,8 @@ void sipe_core_deallocate(struct sipe_core_public *sipe_public) g_hash_table_destroy(sip->user_state_publications); sipe_subscriptions_destroy(sipe_private); - if (sip->groups) { - GSList *entry = sip->groups; + if (sipe_private->groups) { + GSList *entry = sipe_private->groups; while (entry) { struct sipe_group *group = entry->data; g_free(group->name); @@ -220,7 +220,7 @@ void sipe_core_deallocate(struct sipe_core_public *sipe_public) entry = entry->next; } } - g_slist_free(sip->groups); + g_slist_free(sipe_private->groups); if (sip->our_publication_keys) { GSList *entry = sip->our_publication_keys; diff --git a/src/core/sipe-domino.c b/src/core/sipe-domino.c index 324222f9..a53eefc0 100755 --- a/src/core/sipe-domino.c +++ b/src/core/sipe-domino.c @@ -3,7 +3,7 @@ * * pidgin-sipe * - * Copyright (C) 2010 SIPE Project + * Copyright (C) 2010-11 SIPE Project * Copyright (C) 2010 pier11 * * @@ -53,6 +53,10 @@ https://sourceforge.net/tracker/?func=detail&aid=2945346&group_id=194563&atid=94 Similar functionality for iCalendar/CalDAV/Google would be great to implement too. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/src/core/sipe-group.c b/src/core/sipe-group.c index df1d8c4d..c565e341 100755 --- a/src/core/sipe-group.c +++ b/src/core/sipe-group.c @@ -20,19 +20,28 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include -#include "sipe-core.h" -#include "sipe-core-private.h" -#include "sipe-backend.h" +#include "sipmsg.h" #include "sip-soap.h" #include "sip-transport.h" -#include "sipe-xml.h" +#include "sipe-backend.h" #include "sipe-buddy.h" -#include "sipmsg.h" +#include "sipe-core.h" +#include "sipe-core-private.h" #include "sipe-group.h" #include "sipe-nls.h" -#include "sipe.h" +#include "sipe-utils.h" +#include "sipe-xml.h" + +struct group_user_context { + gchar *group_name; + gchar *user_name; +}; static void sipe_group_context_destroy(gpointer data) @@ -104,14 +113,13 @@ struct sipe_group* sipe_group_find_by_id(struct sipe_core_private *sipe_private, int id) { - struct sipe_account_data *sip = SIPE_ACCOUNT_DATA_PRIVATE; struct sipe_group *group; GSList *entry; - if (sip == NULL) { + + if (!sipe_private) return NULL; - } - entry = sip->groups; + entry = sipe_private->groups; while (entry) { group = entry->data; if (group->id == id) { @@ -126,14 +134,13 @@ struct sipe_group* sipe_group_find_by_name(struct sipe_core_private *sipe_private, const gchar * name) { - struct sipe_account_data *sip = SIPE_ACCOUNT_DATA_PRIVATE; struct sipe_group *group; GSList *entry; - if (!sip || !name) { + + if (!sipe_private || !name) return NULL; - } - entry = sip->groups; + entry = sipe_private->groups; while (entry) { group = entry->data; if (sipe_strequal(group->name, name)) { @@ -174,11 +181,11 @@ void sipe_group_add(struct sipe_core_private *sipe_private, struct sipe_group * group) { - struct sipe_account_data *sip = SIPE_ACCOUNT_DATA_PRIVATE; if (sipe_backend_buddy_group_add(SIPE_CORE_PUBLIC,group->name)) { SIPE_DEBUG_INFO("added group %s (id %d)", group->name, group->id); - sip->groups = g_slist_append(sip->groups, group); + sipe_private->groups = g_slist_append(sipe_private->groups, + group); } else { @@ -222,7 +229,6 @@ sipe_core_group_remove(struct sipe_core_public *sipe_public, struct sipe_group *s_group = sipe_group_find_by_name(sipe_private, name); if (s_group) { - struct sipe_account_data *sip = SIPE_ACCOUNT_DATA; gchar *request; SIPE_DEBUG_INFO("Deleting group %s", name); request = g_strdup_printf("%d", @@ -232,7 +238,8 @@ sipe_core_group_remove(struct sipe_core_public *sipe_public, request); g_free(request); - sip->groups = g_slist_remove(sip->groups, s_group); + sipe_private->groups = g_slist_remove(sipe_private->groups, + s_group); g_free(s_group->name); g_free(s_group); } else { diff --git a/src/core/sipe-user.c b/src/core/sipe-user.c index 844f5dc0..bca786cf 100644 --- a/src/core/sipe-user.c +++ b/src/core/sipe-user.c @@ -20,6 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "sipe-common.h" diff --git a/src/core/sipe.c b/src/core/sipe.c index 7f2a87a7..8291f8bd 100644 --- a/src/core/sipe.c +++ b/src/core/sipe.c @@ -1096,7 +1096,7 @@ static gboolean sipe_process_roaming_contacts(struct sipe_core_private *sipe_pri } // Make sure we have at least one group - if (g_slist_length(sip->groups) == 0) { + if (g_slist_length(sipe_private->groups) == 0) { sipe_group_create(sipe_private, _("Other Contacts"), NULL); } @@ -1129,8 +1129,8 @@ static gboolean sipe_process_roaming_contacts(struct sipe_core_private *sipe_pri struct sipe_group *group = sipe_group_find_by_id(sipe_private, g_ascii_strtod(item_groups[i], NULL)); // If couldn't find the right group for this contact, just put them in the first group we have - if (group == NULL && g_slist_length(sip->groups) > 0) { - group = sip->groups->data; + if (group == NULL && g_slist_length(sipe_private->groups) > 0) { + group = sipe_private->groups->data; } if (group != NULL) { diff --git a/src/core/sipe.h b/src/core/sipe.h index 44c86407..2ce74ae2 100644 --- a/src/core/sipe.h +++ b/src/core/sipe.h @@ -91,7 +91,6 @@ struct sipe_account_data { GSList *containers; /* MS-PRES containers */ struct _PurpleAccount *account; gchar *regcallid; - GSList *groups; struct sipe_calendar *cal; gchar *email; /** 2005 Custom XML piece. @@ -111,13 +110,6 @@ struct sipe_auth_job { struct sipe_core_private *sipe_private; }; -struct group_user_context { - gchar * group_name; - gchar * user_name; -}; - -GSList * slist_insert_unique_sorted(GSList *list, gpointer data, GCompareFunc func); - /** * Publishes self status * based on own calendar information, diff --git a/src/purple/purple-buddy.c b/src/purple/purple-buddy.c index 82cb10a4..cd3b7871 100644 --- a/src/purple/purple-buddy.c +++ b/src/purple/purple-buddy.c @@ -3,7 +3,7 @@ * * pidgin-sipe * - * Copyright (C) 2010 SIPE Project + * Copyright (C) 2010-11 SIPE Project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "purple-private.h" diff --git a/src/purple/purple-im.c b/src/purple/purple-im.c index 0537e34c..452a2d7a 100644 --- a/src/purple/purple-im.c +++ b/src/purple/purple-im.c @@ -3,7 +3,7 @@ * * pidgin-sipe * - * Copyright (C) 2010 SIPE Project + * Copyright (C) 2010-11 SIPE Project * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,6 +20,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include -- 2.11.4.GIT