From 9c4e02db77fd3333c038c46ffa7a40ed9e33b949 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Aug 2016 23:53:41 +0100 Subject: Move caps static functions --- src/xmpp/capabilities.c | 118 ++++++++++++++++++++++++------------------------ 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index 4cf97336..d64c79a0 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -201,65 +201,6 @@ caps_cache_contains(const char *const ver) return (g_key_file_has_group(cache, ver)); } -static EntityCapabilities* -_caps_by_ver(const char *const ver) -{ - if (g_key_file_has_group(cache, ver)) { - EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t)); - - char *category = g_key_file_get_string(cache, ver, "category", NULL); - char *type = g_key_file_get_string(cache, ver, "type", NULL); - char *name = g_key_file_get_string(cache, ver, "name", NULL); - if (category || type || name) { - DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t)); - identity->category = category; - identity->type = type; - identity->name = name; - new_caps->identity = identity; - } else { - new_caps->identity = NULL; - } - - char *software = g_key_file_get_string(cache, ver, "software", NULL); - char *software_version = g_key_file_get_string(cache, ver, "software_version", NULL); - char *os = g_key_file_get_string(cache, ver, "os", NULL); - char *os_version = g_key_file_get_string(cache, ver, "os_version", NULL); - if (software || software_version || os || os_version) { - SoftwareVersion *software_versionp = malloc(sizeof(struct software_version_t)); - software_versionp->software = software; - software_versionp->software_version = software_version; - software_versionp->os = os; - software_versionp->os_version = os_version; - new_caps->software_version = software_versionp; - } else { - new_caps->software_version = NULL; - } - - gsize features_len = 0; - gchar **features = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL); - if (features && features_len > 0) { - GSList *features_list = NULL; - int i; - for (i = 0; i < features_len; i++) { - features_list = g_slist_append(features_list, strdup(features[i])); - } - new_caps->features = features_list; - g_strfreev(features); - } else { - new_caps->features = NULL; - } - return new_caps; - } else { - return NULL; - } -} - -static EntityCapabilities* -_caps_by_jid(const char *const jid) -{ - return g_hash_table_lookup(jid_to_caps, jid); -} - EntityCapabilities* caps_lookup(const char *const jid) { @@ -591,6 +532,65 @@ caps_close(void) prof_features = NULL; } +static EntityCapabilities* +_caps_by_ver(const char *const ver) +{ + if (!g_key_file_has_group(cache, ver)) { + return NULL; + } + + EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t)); + + char *category = g_key_file_get_string(cache, ver, "category", NULL); + char *type = g_key_file_get_string(cache, ver, "type", NULL); + char *name = g_key_file_get_string(cache, ver, "name", NULL); + if (category || type || name) { + DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t)); + identity->category = category; + identity->type = type; + identity->name = name; + new_caps->identity = identity; + } else { + new_caps->identity = NULL; + } + + char *software = g_key_file_get_string(cache, ver, "software", NULL); + char *software_version = g_key_file_get_string(cache, ver, "software_version", NULL); + char *os = g_key_file_get_string(cache, ver, "os", NULL); + char *os_version = g_key_file_get_string(cache, ver, "os_version", NULL); + if (software || software_version || os || os_version) { + SoftwareVersion *software_versionp = malloc(sizeof(struct software_version_t)); + software_versionp->software = software; + software_versionp->software_version = software_version; + software_versionp->os = os; + software_versionp->os_version = os_version; + new_caps->software_version = software_versionp; + } else { + new_caps->software_version = NULL; + } + + gsize features_len = 0; + gchar **features = g_key_file_get_string_list(cache, ver, "features", &features_len, NULL); + if (features && features_len > 0) { + GSList *features_list = NULL; + int i; + for (i = 0; i < features_len; i++) { + features_list = g_slist_append(features_list, strdup(features[i])); + } + new_caps->features = features_list; + g_strfreev(features); + } else { + new_caps->features = NULL; + } + return new_caps; +} + +static EntityCapabilities* +_caps_by_jid(const char *const jid) +{ + return g_hash_table_lookup(jid_to_caps, jid); +} + static void _disco_identity_destroy(DiscoIdentity *disco_identity) { -- cgit 1.4.1-2-gfad0