From 6ec159737b3321a9adfe8c1358df28f93a72eb2e Mon Sep 17 00:00:00 2001 From: James Booth Date: Fri, 12 Aug 2016 22:25:35 +0100 Subject: [PATCH 1/6] Use list for profanity service discovery features --- src/xmpp/capabilities.c | 91 ++++++++++++----------------------------- 1 file changed, 27 insertions(+), 64 deletions(-) diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index c270bd09..da10129a 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -67,6 +67,7 @@ static GKeyFile *cache; static GHashTable *jid_to_ver; static GHashTable *jid_to_caps; +static GList *prof_features; static char *my_sha1; static void _save_cache(void); @@ -90,6 +91,18 @@ caps_init(void) jid_to_ver = g_hash_table_new_full(g_str_hash, g_str_equal, free, free); jid_to_caps = g_hash_table_new_full(g_str_hash, g_str_equal, free, (GDestroyNotify)caps_destroy); + prof_features = NULL; + prof_features = g_list_append(prof_features, strdup(STANZA_NS_CAPS)); + prof_features = g_list_append(prof_features, strdup(XMPP_NS_DISCO_INFO)); + prof_features = g_list_append(prof_features, strdup(XMPP_NS_DISCO_ITEMS)); + prof_features = g_list_append(prof_features, strdup(STANZA_NS_MUC)); + prof_features = g_list_append(prof_features, strdup(STANZA_NS_CONFERENCE)); + prof_features = g_list_append(prof_features, strdup(STANZA_NS_VERSION)); + prof_features = g_list_append(prof_features, strdup(STANZA_NS_CHATSTATES)); + prof_features = g_list_append(prof_features, strdup(STANZA_NS_PING)); + prof_features = g_list_append(prof_features, strdup(STANZA_NS_RECEIPTS)); + prof_features = g_list_append(prof_features, strdup(STANZA_NS_LASTACTIVITY)); + my_sha1 = NULL; } @@ -588,62 +601,22 @@ caps_create_query_response_stanza(xmpp_ctx_t *const ctx) } xmpp_stanza_set_attribute(identity, "name", name_str->str); g_string_free(name_str, TRUE); - - xmpp_stanza_t *feature_caps = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_caps, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_caps, STANZA_ATTR_VAR, STANZA_NS_CAPS); - - xmpp_stanza_t *feature_discoinfo = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_discoinfo, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_discoinfo, STANZA_ATTR_VAR, XMPP_NS_DISCO_INFO); - - xmpp_stanza_t *feature_discoitems = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_discoitems, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_discoitems, STANZA_ATTR_VAR, XMPP_NS_DISCO_ITEMS); - - xmpp_stanza_t *feature_muc = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_muc, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_muc, STANZA_ATTR_VAR, STANZA_NS_MUC); - - xmpp_stanza_t *feature_conference = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_conference, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_conference, STANZA_ATTR_VAR, STANZA_NS_CONFERENCE); - - xmpp_stanza_t *feature_version = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_version, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_version, STANZA_ATTR_VAR, STANZA_NS_VERSION); - - xmpp_stanza_t *feature_chatstates = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_chatstates, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_chatstates, STANZA_ATTR_VAR, STANZA_NS_CHATSTATES); - - xmpp_stanza_t *feature_ping = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_ping, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_ping, STANZA_ATTR_VAR, STANZA_NS_PING); - - xmpp_stanza_t *feature_receipts = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_receipts, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_receipts, STANZA_ATTR_VAR, STANZA_NS_RECEIPTS); - - xmpp_stanza_t *feature_last = xmpp_stanza_new(ctx); - xmpp_stanza_set_name(feature_last, STANZA_NAME_FEATURE); - xmpp_stanza_set_attribute(feature_last, STANZA_ATTR_VAR, STANZA_NS_LASTACTIVITY); - xmpp_stanza_add_child(query, identity); + xmpp_stanza_release(identity); - xmpp_stanza_add_child(query, feature_caps); - xmpp_stanza_add_child(query, feature_chatstates); - xmpp_stanza_add_child(query, feature_discoinfo); - xmpp_stanza_add_child(query, feature_discoitems); - xmpp_stanza_add_child(query, feature_muc); - xmpp_stanza_add_child(query, feature_version); - xmpp_stanza_add_child(query, feature_last); - xmpp_stanza_add_child(query, feature_conference); - xmpp_stanza_add_child(query, feature_ping); - xmpp_stanza_add_child(query, feature_receipts); + GList *curr = prof_features; + while (curr) { + xmpp_stanza_t *feature = xmpp_stanza_new(ctx); + xmpp_stanza_set_name(feature, STANZA_NAME_FEATURE); + xmpp_stanza_set_attribute(feature, STANZA_ATTR_VAR, curr->data); + xmpp_stanza_add_child(query, feature); + xmpp_stanza_release(feature); + + curr = g_list_next(curr); + } GList *plugin_features = plugins_get_disco_features(); - GList *curr = plugin_features; + curr = plugin_features; while (curr) { xmpp_stanza_t *feature = xmpp_stanza_new(ctx); xmpp_stanza_set_name(feature, STANZA_NAME_FEATURE); @@ -655,18 +628,6 @@ caps_create_query_response_stanza(xmpp_ctx_t *const ctx) } g_list_free(plugin_features); - xmpp_stanza_release(feature_receipts); - xmpp_stanza_release(feature_ping); - xmpp_stanza_release(feature_conference); - xmpp_stanza_release(feature_last); - xmpp_stanza_release(feature_version); - xmpp_stanza_release(feature_muc); - xmpp_stanza_release(feature_discoitems); - xmpp_stanza_release(feature_discoinfo); - xmpp_stanza_release(feature_chatstates); - xmpp_stanza_release(feature_caps); - xmpp_stanza_release(identity); - return query; } @@ -679,6 +640,8 @@ caps_close(void) g_hash_table_destroy(jid_to_caps); free(cache_loc); cache_loc = NULL; + g_list_free_full(prof_features, free); + prof_features = NULL; } void From e949114284a5c68bcb0a0d9c0bfd3ed88014154c Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Aug 2016 16:21:25 +0100 Subject: [PATCH 2/6] Reduce variable scope in caps_create_sha1_str --- src/xmpp/capabilities.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index da10129a..da3ea3c3 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -297,25 +297,18 @@ _caps_copy(Capabilities *caps) char* caps_create_sha1_str(xmpp_stanza_t *const query) { - const char *category = NULL; - const char *type = NULL; - const char *lang = NULL; - const char *name = NULL; - const char *feature_str = NULL; GSList *identities = NULL; GSList *features = NULL; GSList *form_names = NULL; - DataForm *form = NULL; - FormField *field = NULL; GHashTable *forms = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify)form_destroy); xmpp_stanza_t *child = xmpp_stanza_get_children(query); while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_IDENTITY) == 0) { - category = xmpp_stanza_get_attribute(child, "category"); - type = xmpp_stanza_get_attribute(child, "type"); - lang = xmpp_stanza_get_attribute(child, "xml:lang"); - name = xmpp_stanza_get_attribute(child, "name"); + const char *category = xmpp_stanza_get_attribute(child, "category"); + const char *type = xmpp_stanza_get_attribute(child, "type"); + const char *lang = xmpp_stanza_get_attribute(child, "xml:lang"); + const char *name = xmpp_stanza_get_attribute(child, "name"); GString *identity_str = g_string_new(category); g_string_append(identity_str, "/"); @@ -334,11 +327,11 @@ caps_create_sha1_str(xmpp_stanza_t *const query) identities = g_slist_insert_sorted(identities, g_strdup(identity_str->str), (GCompareFunc)strcmp); g_string_free(identity_str, TRUE); } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_FEATURE) == 0) { - feature_str = xmpp_stanza_get_attribute(child, "var"); + const char *feature_str = xmpp_stanza_get_attribute(child, "var"); features = g_slist_insert_sorted(features, g_strdup(feature_str), (GCompareFunc)strcmp); } else if (g_strcmp0(xmpp_stanza_get_name(child), STANZA_NAME_X) == 0) { if (g_strcmp0(xmpp_stanza_get_ns(child), STANZA_NS_DATA) == 0) { - form = form_create(child); + DataForm *form = form_create(child); char *form_type = form_get_form_type_field(form); form_names = g_slist_insert_sorted(form_names, g_strdup(form_type), (GCompareFunc)strcmp); g_hash_table_insert(forms, g_strdup(form_type), form); @@ -364,7 +357,7 @@ caps_create_sha1_str(xmpp_stanza_t *const query) curr = form_names; while (curr) { - form = g_hash_table_lookup(forms, curr->data); + DataForm *form = g_hash_table_lookup(forms, curr->data); char *form_type = form_get_form_type_field(form); g_string_append(s, form_type); g_string_append(s, "<"); @@ -372,7 +365,7 @@ caps_create_sha1_str(xmpp_stanza_t *const query) GSList *sorted_fields = form_get_non_form_type_fields_sorted(form); GSList *curr_field = sorted_fields; while (curr_field) { - field = curr_field->data; + FormField *field = curr_field->data; g_string_append(s, field->var); g_string_append(s, "<"); From 80eb5bee90b6af97b2e5d14c8d4aa5cc924a1a9d Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Aug 2016 16:39:25 +0100 Subject: [PATCH 3/6] Rename Capabilties -> EntityCapabilities --- src/ui/console.c | 4 +-- src/ui/window.c | 4 +-- src/xmpp/capabilities.c | 42 ++++++++++++++++---------------- src/xmpp/capabilities.h | 6 ++--- src/xmpp/iq.c | 6 ++--- src/xmpp/xmpp.h | 8 +++--- tests/unittests/xmpp/stub_xmpp.c | 4 +-- 7 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/ui/console.c b/src/ui/console.c index 600bbdf3..50ab60a6 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -549,7 +549,7 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) ProfWin *console = wins_get_console(); cons_show(""); - Capabilities *caps = caps_lookup(fulljid); + EntityCapabilities *caps = caps_lookup(fulljid); if (caps) { const char *resource_presence = string_from_resource_presence(presence); @@ -1002,7 +1002,7 @@ cons_show_account(ProfAccount *account) } win_vprint(console, '-', 0, NULL, NO_DATE, 0, "", ""); Jid *jidp = jid_create_from_bare_and_resource(account->jid, resource->name); - Capabilities *caps = caps_lookup(jidp->fulljid); + EntityCapabilities *caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { diff --git a/src/ui/window.c b/src/ui/window.c index 080fd0ca..b62c5e86 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -760,7 +760,7 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_vprint(window, '!', 0, NULL, 0, 0, "", " Role: %s", occupant_role); Jid *jidp = jid_create_from_bare_and_resource(room, occupant->nick); - Capabilities *caps = caps_lookup(jidp->fulljid); + EntityCapabilities *caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { @@ -878,7 +878,7 @@ win_show_info(ProfWin *window, PContact contact) win_newline(window); Jid *jidp = jid_create_from_bare_and_resource(barejid, resource->name); - Capabilities *caps = caps_lookup(jidp->fulljid); + EntityCapabilities *caps = caps_lookup(jidp->fulljid); jid_destroy(jidp); if (caps) { diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index da3ea3c3..7f532a0d 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -71,9 +71,9 @@ static GList *prof_features; static char *my_sha1; static void _save_cache(void); -static Capabilities* _caps_by_ver(const char *const ver); -static Capabilities* _caps_by_jid(const char *const jid); -Capabilities* _caps_copy(Capabilities *caps); +static EntityCapabilities* _caps_by_ver(const char *const ver); +static EntityCapabilities* _caps_by_jid(const char *const jid); +EntityCapabilities* _caps_copy(EntityCapabilities *caps); void caps_init(void) @@ -107,7 +107,7 @@ caps_init(void) } void -caps_add_by_ver(const char *const ver, Capabilities *caps) +caps_add_by_ver(const char *const ver, EntityCapabilities *caps) { gboolean cached = g_key_file_has_group(cache, ver); if (!cached) { @@ -149,7 +149,7 @@ caps_add_by_ver(const char *const ver, Capabilities *caps) } void -caps_add_by_jid(const char *const jid, Capabilities *caps) +caps_add_by_jid(const char *const jid, EntityCapabilities *caps) { g_hash_table_insert(jid_to_caps, strdup(jid), caps); } @@ -166,11 +166,11 @@ caps_contains(const char *const ver) return (g_key_file_has_group(cache, ver)); } -static Capabilities* +static EntityCapabilities* _caps_by_ver(const char *const ver) { if (g_key_file_has_group(cache, ver)) { - Capabilities *new_caps = malloc(sizeof(struct capabilities_t)); + EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t)); char *category = g_key_file_get_string(cache, ver, "category", NULL); if (category) { @@ -240,24 +240,24 @@ _caps_by_ver(const char *const ver) } } -static Capabilities* +static EntityCapabilities* _caps_by_jid(const char *const jid) { return g_hash_table_lookup(jid_to_caps, jid); } -Capabilities* +EntityCapabilities* caps_lookup(const char *const jid) { char *ver = g_hash_table_lookup(jid_to_ver, jid); if (ver) { - Capabilities *caps = _caps_by_ver(ver); + EntityCapabilities *caps = _caps_by_ver(ver); if (caps) { log_debug("Capabilities lookup %s, found by verification string %s.", jid, ver); return caps; } } else { - Capabilities *caps = _caps_by_jid(jid); + EntityCapabilities *caps = _caps_by_jid(jid); if (caps) { log_debug("Capabilities lookup %s, found by JID.", jid); return _caps_copy(caps); @@ -268,13 +268,13 @@ caps_lookup(const char *const jid) return NULL; } -Capabilities* -_caps_copy(Capabilities *caps) +EntityCapabilities* +_caps_copy(EntityCapabilities *caps) { if (!caps) { return NULL; } else { - Capabilities *result = (Capabilities *)malloc(sizeof(Capabilities)); + EntityCapabilities *result = (EntityCapabilities *)malloc(sizeof(EntityCapabilities)); result->category = caps->category ? strdup(caps->category) : NULL; result->type = caps->type ? strdup(caps->type) : NULL; result->name = caps->name ? strdup(caps->name) : NULL; @@ -395,17 +395,13 @@ caps_create_sha1_str(xmpp_stanza_t *const query) return result; } -Capabilities* +EntityCapabilities* caps_create(xmpp_stanza_t *query) { - const char *category = NULL; - const char *type = NULL; - const char *name = NULL; char *software = NULL; char *software_version = NULL; char *os = NULL; char *os_version = NULL; - GSList *features = NULL; xmpp_stanza_t *softwareinfo = xmpp_stanza_get_child_by_ns(query, STANZA_NS_DATA); if (softwareinfo) { @@ -437,6 +433,7 @@ caps_create(xmpp_stanza_t *query) xmpp_stanza_t *child = xmpp_stanza_get_children(query); GSList *identity_stanzas = NULL; + GSList *features = NULL; while (child) { if (g_strcmp0(xmpp_stanza_get_name(child), "feature") == 0) { features = g_slist_append(features, strdup(xmpp_stanza_get_attribute(child, "var"))); @@ -495,13 +492,16 @@ caps_create(xmpp_stanza_t *query) g_slist_free(identity_stanzas); + const char *category = NULL; + const char *type = NULL; + const char *name = NULL; if (found) { category = xmpp_stanza_get_attribute(found, "category"); type = xmpp_stanza_get_attribute(found, "type"); name = xmpp_stanza_get_attribute(found, "name"); } - Capabilities *new_caps = malloc(sizeof(struct capabilities_t)); + EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t)); if (category) { new_caps->category = strdup(category); @@ -638,7 +638,7 @@ caps_close(void) } void -caps_destroy(Capabilities *caps) +caps_destroy(EntityCapabilities *caps) { if (caps) { free(caps->category); diff --git a/src/xmpp/capabilities.h b/src/xmpp/capabilities.h index 71fc06f1..88563fcc 100644 --- a/src/xmpp/capabilities.h +++ b/src/xmpp/capabilities.h @@ -49,14 +49,14 @@ void caps_init(void); -void caps_add_by_ver(const char *const ver, Capabilities *caps); -void caps_add_by_jid(const char *const jid, Capabilities *caps); +void caps_add_by_ver(const char *const ver, EntityCapabilities *caps); +void caps_add_by_jid(const char *const jid, EntityCapabilities *caps); void caps_map_jid_to_ver(const char *const jid, const char *const ver); gboolean caps_contains(const char *const ver); char* caps_create_sha1_str(xmpp_stanza_t *const query); xmpp_stanza_t* caps_create_query_response_stanza(xmpp_ctx_t *const ctx); -Capabilities* caps_create(xmpp_stanza_t *query); +EntityCapabilities* caps_create(xmpp_stanza_t *query); char* caps_get_my_sha1(xmpp_ctx_t *const ctx); #endif diff --git a/src/xmpp/iq.c b/src/xmpp/iq.c index 3a29fbfc..2d27be0c 100644 --- a/src/xmpp/iq.c +++ b/src/xmpp/iq.c @@ -746,7 +746,7 @@ _caps_response_id_handler(xmpp_stanza_t *const stanza, void *const userdata) log_info("Capabilties already cached: %s", given_sha1); } else { log_info("Capabilities not cached: %s, storing", given_sha1); - Capabilities *capabilities = caps_create(query); + EntityCapabilities *capabilities = caps_create(query); caps_add_by_ver(given_sha1, capabilities); caps_destroy(capabilities); } @@ -810,7 +810,7 @@ _caps_response_for_jid_id_handler(xmpp_stanza_t *const stanza, void *const userd } log_info("Associating capabilities with: %s", jid); - Capabilities *capabilities = caps_create(query); + EntityCapabilities *capabilities = caps_create(query); caps_add_by_jid(jid, capabilities); free(jid); @@ -874,7 +874,7 @@ _caps_response_legacy_id_handler(xmpp_stanza_t *const stanza, void *const userda log_info("Capabilties already cached: %s", node); } else { log_info("Capabilities not cached: %s, storing", node); - Capabilities *capabilities = caps_create(query); + EntityCapabilities *capabilities = caps_create(query); caps_add_by_ver(node, capabilities); caps_destroy(capabilities); } diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index c34ee60a..3f1094a5 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -82,7 +82,7 @@ typedef struct bookmark_t { gboolean autojoin; } Bookmark; -typedef struct capabilities_t { +typedef struct entity_capabilities_t { char *category; char *type; char *name; @@ -91,7 +91,7 @@ typedef struct capabilities_t { char *os; char *os_version; GSList *features; -} Capabilities; +} EntityCapabilities; typedef struct disco_item_t { char *jid; @@ -173,9 +173,9 @@ void iq_room_role_list(const char * const room, char *role); void iq_autoping_check(void); void iq_http_upload_request(HTTPUpload *upload); -Capabilities* caps_lookup(const char *const jid); +EntityCapabilities* caps_lookup(const char *const jid); void caps_close(void); -void caps_destroy(Capabilities *caps); +void caps_destroy(EntityCapabilities *caps); void caps_reset_ver(void); gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str); diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index c80224a7..d0c15c52 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -203,13 +203,13 @@ void iq_last_activity_request(gchar *jid) {} void iq_autoping_check(void) {} // caps functions -Capabilities* caps_lookup(const char * const jid) +EntityCapabilities* caps_lookup(const char * const jid) { return NULL; } void caps_close(void) {} -void caps_destroy(Capabilities *caps) {} +void caps_destroy(EntityCapabilities *caps) {} void caps_reset_ver(void) {} gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str) From 0bd5b5200af5628ed6d841139c44cf3dabee8e3e Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Aug 2016 17:19:24 +0100 Subject: [PATCH 4/6] Use DiscoIdentity in EntityCapabilities --- src/ui/console.c | 40 ++++++----- src/ui/window.c | 40 ++++++----- src/xmpp/capabilities.c | 152 ++++++++++++++++++++++------------------ src/xmpp/xmpp.h | 16 ++--- 4 files changed, 133 insertions(+), 115 deletions(-) diff --git a/src/ui/console.c b/src/ui/console.c index 50ab60a6..882b5da8 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -558,25 +558,27 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) win_print(console, '-', 0, NULL, NO_DATE, 0, "", ":"); // show identity - if (caps->category || caps->type || caps->name) { + if (caps->identity) { + DiscoIdentity *identity = caps->identity; win_print(console, '-', 0, NULL, NO_EOL, 0, "", "Identity: "); - if (caps->name) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name); - if (caps->category || caps->type) { + if (identity->name) { + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + if (identity->category || identity->type) { win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type); - if (caps->category) { + if (identity->type) { + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + if (identity->category) { win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category); + if (identity->category) { + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(console); } + if (caps->software) { win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", caps->software); } @@ -1007,25 +1009,27 @@ cons_show_account(ProfAccount *account) if (caps) { // show identity - if (caps->category || caps->type || caps->name) { + if (caps->identity) { + DiscoIdentity *identity = caps->identity; win_print(console, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); - if (caps->name) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name); - if (caps->category || caps->type) { + if (identity->name) { + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + if (identity->category || identity->type) { win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->type) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type); - if (caps->category) { + if (identity->type) { + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + if (identity->category) { win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->category) { - win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category); + if (identity->category) { + win_print(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(console); } + if (caps->software) { win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software); } diff --git a/src/ui/window.c b/src/ui/window.c index b62c5e86..6e405563 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -765,25 +765,27 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa if (caps) { // show identity - if (caps->category || caps->type || caps->name) { + if (caps->identity) { + DiscoIdentity *identity = caps->identity; win_print(window, '!', 0, NULL, NO_EOL, 0, "", " Identity: "); - if (caps->name) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name); - if (caps->category || caps->type) { + if (identity->name) { + win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + if (identity->category || identity->type) { win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->type) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type); - if (caps->category) { + if (identity->type) { + win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + if (identity->category) { win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->category) { - win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category); + if (identity->category) { + win_print(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(window); } + if (caps->software) { win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software); } @@ -883,25 +885,27 @@ win_show_info(ProfWin *window, PContact contact) if (caps) { // show identity - if (caps->category || caps->type || caps->name) { + if (caps->identity) { + DiscoIdentity *identity = caps->identity; win_print(window, '-', 0, NULL, NO_EOL, 0, "", " Identity: "); - if (caps->name) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->name); - if (caps->category || caps->type) { + if (identity->name) { + win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->name); + if (identity->category || identity->type) { win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->type) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->type); - if (caps->category) { + if (identity->type) { + win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->type); + if (identity->category) { win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", " "); } } - if (caps->category) { - win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", caps->category); + if (identity->category) { + win_print(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", identity->category); } win_newline(window); } + if (caps->software) { win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software); } diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index 7f532a0d..fe3a855c 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -109,43 +109,52 @@ caps_init(void) void caps_add_by_ver(const char *const ver, EntityCapabilities *caps) { - gboolean cached = g_key_file_has_group(cache, ver); - if (!cached) { - if (caps->name) { - g_key_file_set_string(cache, ver, "name", caps->name); - } - if (caps->category) { - g_key_file_set_string(cache, ver, "category", caps->category); - } - if (caps->type) { - g_key_file_set_string(cache, ver, "type", caps->type); - } - if (caps->software) { - g_key_file_set_string(cache, ver, "software", caps->software); - } - if (caps->software_version) { - g_key_file_set_string(cache, ver, "software_version", caps->software_version); - } - if (caps->os) { - g_key_file_set_string(cache, ver, "os", caps->os); - } - if (caps->os_version) { - g_key_file_set_string(cache, ver, "os_version", caps->os_version); - } - if (caps->features) { - GSList *curr_feature = caps->features; - int num = g_slist_length(caps->features); - const gchar* features_list[num]; - int curr = 0; - while (curr_feature) { - features_list[curr++] = curr_feature->data; - curr_feature = g_slist_next(curr_feature); - } - g_key_file_set_string_list(cache, ver, "features", features_list, num); - } - - _save_cache(); + if (ver == NULL || caps == NULL) { + return; } + + gboolean cached = g_key_file_has_group(cache, ver); + if (cached) { + return; + } + + if (caps->identity) { + DiscoIdentity *identity = caps->identity; + if (identity->name) { + g_key_file_set_string(cache, ver, "name", identity->name); + } + if (identity->category) { + g_key_file_set_string(cache, ver, "category", identity->category); + } + if (identity->type) { + g_key_file_set_string(cache, ver, "type", identity->type); + } + } + if (caps->software) { + g_key_file_set_string(cache, ver, "software", caps->software); + } + if (caps->software_version) { + g_key_file_set_string(cache, ver, "software_version", caps->software_version); + } + if (caps->os) { + g_key_file_set_string(cache, ver, "os", caps->os); + } + if (caps->os_version) { + g_key_file_set_string(cache, ver, "os_version", caps->os_version); + } + if (caps->features) { + GSList *curr_feature = caps->features; + int num = g_slist_length(caps->features); + const gchar* features_list[num]; + int curr = 0; + while (curr_feature) { + features_list[curr++] = curr_feature->data; + curr_feature = g_slist_next(curr_feature); + } + g_key_file_set_string_list(cache, ver, "features", features_list, num); + } + + _save_cache(); } void @@ -173,24 +182,16 @@ _caps_by_ver(const char *const ver) EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t)); char *category = g_key_file_get_string(cache, ver, "category", NULL); - if (category) { - new_caps->category = category; - } else { - new_caps->category = NULL; - } - char *type = g_key_file_get_string(cache, ver, "type", NULL); - if (type) { - new_caps->type = type; - } else { - new_caps->type = NULL; - } - char *name = g_key_file_get_string(cache, ver, "name", NULL); - if (name) { - new_caps->name = name; + 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->name = NULL; + new_caps->identity = NULL; } char *software = g_key_file_get_string(cache, ver, "software", NULL); @@ -275,9 +276,17 @@ _caps_copy(EntityCapabilities *caps) return NULL; } else { EntityCapabilities *result = (EntityCapabilities *)malloc(sizeof(EntityCapabilities)); - result->category = caps->category ? strdup(caps->category) : NULL; - result->type = caps->type ? strdup(caps->type) : NULL; - result->name = caps->name ? strdup(caps->name) : NULL; + + if (caps->identity) { + DiscoIdentity *identity = (DiscoIdentity*)malloc(sizeof(DiscoIdentity)); + identity->category = caps->identity->category ? strdup(caps->identity->category) : NULL; + identity->type = caps->identity->type ? strdup(caps->identity->type) : NULL; + identity->name = caps->identity->name ? strdup(caps->identity->name) : NULL; + result->identity = identity; + } else { + result->identity = NULL; + } + result->software = caps->software ? strdup(caps->software) : NULL; result->software_version = caps->software_version ? strdup(caps->software_version) : NULL; result->os = caps->os ? strdup(caps->os) : NULL; @@ -503,21 +512,16 @@ caps_create(xmpp_stanza_t *query) EntityCapabilities *new_caps = malloc(sizeof(struct entity_capabilities_t)); - if (category) { - new_caps->category = strdup(category); + if (category || type || name) { + DiscoIdentity *identity = malloc(sizeof(struct disco_identity_t)); + identity->category = category ? strdup(category) : NULL; + identity->type = type ? strdup(type) : NULL; + identity->name = name ? strdup(name) : NULL; + new_caps->identity = identity; } else { - new_caps->category = NULL; - } - if (type) { - new_caps->type = strdup(type); - } else { - new_caps->type = NULL; - } - if (name) { - new_caps->name = strdup(name); - } else { - new_caps->name = NULL; + new_caps->identity = NULL; } + if (software) { new_caps->software = software; } else { @@ -637,13 +641,21 @@ caps_close(void) prof_features = NULL; } +static void +_disco_identity_destroy(DiscoIdentity *disco_identity) +{ + if (disco_identity) { + free(disco_identity->category); + free(disco_identity->name); + free(disco_identity->type); + } +} + void caps_destroy(EntityCapabilities *caps) { if (caps) { - free(caps->category); - free(caps->type); - free(caps->name); + _disco_identity_destroy(caps->identity); free(caps->software); free(caps->software_version); free(caps->os); diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 3f1094a5..3ab5fb56 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -82,10 +82,14 @@ typedef struct bookmark_t { gboolean autojoin; } Bookmark; -typedef struct entity_capabilities_t { - char *category; - char *type; +typedef struct disco_identity_t { char *name; + char *type; + char *category; +} DiscoIdentity; + +typedef struct entity_capabilities_t { + DiscoIdentity *identity; char *software; char *software_version; char *os; @@ -98,12 +102,6 @@ typedef struct disco_item_t { char *name; } DiscoItem; -typedef struct disco_identity_t { - char *name; - char *type; - char *category; -} DiscoIdentity; - void session_init(void); jabber_conn_status_t session_connect_with_details(const char *const jid, const char *const passwd, const char *const altdomain, const int port, const char *const tls_policy); From ed75f1ec71e7f3b4e025af7a4eb61673f97f19b2 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Aug 2016 17:43:43 +0100 Subject: [PATCH 5/6] Use SoftwareVersion in EntityCapabilities --- src/ui/console.c | 71 +++++++++++++------------ src/ui/window.c | 72 ++++++++++++++------------ src/xmpp/capabilities.c | 111 +++++++++++++++++++--------------------- src/xmpp/xmpp.h | 8 ++- 4 files changed, 137 insertions(+), 125 deletions(-) diff --git a/src/ui/console.c b/src/ui/console.c index 882b5da8..3c104f4d 100644 --- a/src/ui/console.c +++ b/src/ui/console.c @@ -579,23 +579,26 @@ cons_show_caps(const char *const fulljid, resource_presence_t presence) win_newline(console); } - if (caps->software) { - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", caps->software); - } if (caps->software_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); - } - if (caps->software || caps->software_version) { - win_newline(console); - } - if (caps->os) { - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", caps->os); - } - if (caps->os_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); - } - if (caps->os || caps->os_version) { - win_newline(console); + SoftwareVersion *software_version = caps->software_version; + if (software_version->software) { + win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "Software: %s", software_version->software); + } + if (software_version->software_version) { + win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + } + if (software_version->software || software_version->software_version) { + win_newline(console); + } + if (software_version->os) { + win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", "OS: %s", software_version->os); + } + if (software_version->os_version) { + win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + } + if (software_version->os || software_version->os_version) { + win_newline(console); + } } if (caps->features) { @@ -1030,24 +1033,28 @@ cons_show_account(ProfAccount *account) win_newline(console); } - if (caps->software) { - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software); - } if (caps->software_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); - } - if (caps->software || caps->software_version) { - win_newline(console); - } - if (caps->os) { - win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os); - } - if (caps->os_version) { - win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); - } - if (caps->os || caps->os_version) { - win_newline(console); + SoftwareVersion *software_version = caps->software_version; + if (software_version->software) { + win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + } + if (software_version->software_version) { + win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + } + if (software_version->software || software_version->software_version) { + win_newline(console); + } + if (software_version->os) { + win_vprint(console, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + } + if (software_version->os_version) { + win_vprint(console, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + } + if (software_version->os || software_version->os_version) { + win_newline(console); + } } + caps_destroy(caps); } diff --git a/src/ui/window.c b/src/ui/window.c index 6e405563..277ce4e6 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -786,24 +786,28 @@ win_show_occupant_info(ProfWin *window, const char *const room, Occupant *occupa win_newline(window); } - if (caps->software) { - win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software); - } if (caps->software_version) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); - } - if (caps->software || caps->software_version) { - win_newline(window); - } - if (caps->os) { - win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os); - } - if (caps->os_version) { - win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); - } - if (caps->os || caps->os_version) { - win_newline(window); + SoftwareVersion *software_version = caps->software_version; + if (software_version->software) { + win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + } + if (software_version->software_version) { + win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + } + if (software_version->software || software_version->software_version) { + win_newline(window); + } + if (software_version->os) { + win_vprint(window, '!', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + } + if (software_version->os_version) { + win_vprint(window, '!', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + } + if (software_version->os || software_version->os_version) { + win_newline(window); + } } + caps_destroy(caps); } @@ -906,24 +910,28 @@ win_show_info(ProfWin *window, PContact contact) win_newline(window); } - if (caps->software) { - win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", caps->software); - } if (caps->software_version) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->software_version); - } - if (caps->software || caps->software_version) { - win_newline(window); - } - if (caps->os) { - win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", caps->os); - } - if (caps->os_version) { - win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", caps->os_version); - } - if (caps->os || caps->os_version) { - win_newline(window); + SoftwareVersion *software_version = caps->software_version; + if (software_version->software) { + win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " Software: %s", software_version->software); + } + if (software_version->software_version) { + win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->software_version); + } + if (software_version->software || software_version->software_version) { + win_newline(window); + } + if (software_version->os) { + win_vprint(window, '-', 0, NULL, NO_EOL, 0, "", " OS: %s", software_version->os); + } + if (software_version->os_version) { + win_vprint(window, '-', 0, NULL, NO_DATE | NO_EOL, 0, "", ", %s", software_version->os_version); + } + if (software_version->os || software_version->os_version) { + win_newline(window); + } } + caps_destroy(caps); } diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index fe3a855c..a4e9244d 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -130,18 +130,23 @@ caps_add_by_ver(const char *const ver, EntityCapabilities *caps) g_key_file_set_string(cache, ver, "type", identity->type); } } - if (caps->software) { - g_key_file_set_string(cache, ver, "software", caps->software); - } + if (caps->software_version) { - g_key_file_set_string(cache, ver, "software_version", caps->software_version); - } - if (caps->os) { - g_key_file_set_string(cache, ver, "os", caps->os); - } - if (caps->os_version) { - g_key_file_set_string(cache, ver, "os_version", caps->os_version); + SoftwareVersion *software_version = caps->software_version; + if (software_version->software) { + g_key_file_set_string(cache, ver, "software", software_version->software); + } + if (software_version->software_version) { + g_key_file_set_string(cache, ver, "software_version", software_version->software_version); + } + if (software_version->os) { + g_key_file_set_string(cache, ver, "os", software_version->os); + } + if (software_version->os_version) { + g_key_file_set_string(cache, ver, "os_version", software_version->os_version); + } } + if (caps->features) { GSList *curr_feature = caps->features; int num = g_slist_length(caps->features); @@ -195,33 +200,20 @@ _caps_by_ver(const char *const ver) } char *software = g_key_file_get_string(cache, ver, "software", NULL); - if (software) { - new_caps->software = software; - } else { - new_caps->software = NULL; - } - char *software_version = g_key_file_get_string(cache, ver, "software_version", NULL); - if (software_version) { - new_caps->software_version = software_version; + 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; } - char *os = g_key_file_get_string(cache, ver, "os", NULL); - if (os) { - new_caps->os = os; - } else { - new_caps->os = NULL; - } - - char *os_version = g_key_file_get_string(cache, ver, "os_version", NULL); - if (os_version) { - new_caps->os_version = os_version; - } else { - new_caps->os_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) { @@ -287,10 +279,15 @@ _caps_copy(EntityCapabilities *caps) result->identity = NULL; } - result->software = caps->software ? strdup(caps->software) : NULL; - result->software_version = caps->software_version ? strdup(caps->software_version) : NULL; - result->os = caps->os ? strdup(caps->os) : NULL; - result->os_version = caps->os_version ? strdup(caps->os_version) : NULL; + if (caps->software_version) { + SoftwareVersion *software_version = (SoftwareVersion*)malloc(sizeof(SoftwareVersion)); + software_version->software = caps->software_version->software ? strdup(caps->software_version->software) : NULL; + software_version->software_version = caps->software_version->software_version ? strdup(caps->software_version->software_version) : NULL; + software_version->os = caps->software_version->os ? strdup(caps->software_version->os) : NULL; + software_version->os_version = caps->software_version->os_version ? strdup(caps->software_version->os_version) : NULL; + } else { + result->software_version = NULL; + } result->features = NULL; GSList *curr = caps->features; @@ -522,26 +519,14 @@ caps_create(xmpp_stanza_t *query) new_caps->identity = NULL; } - if (software) { - new_caps->software = software; - } else { - new_caps->software = NULL; - } - if (software_version) { - new_caps->software_version = software_version; - } else { - new_caps->software_version = NULL; - } - if (os) { - new_caps->os = os; - } else { - new_caps->os = NULL; - } - if (os_version) { - new_caps->os_version = os_version; - } else { - new_caps->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; } + if (features) { new_caps->features = features; } else { @@ -651,15 +636,23 @@ _disco_identity_destroy(DiscoIdentity *disco_identity) } } +static void +_software_version_destroy(SoftwareVersion *software_version) +{ + if (software_version) { + free(software_version->software); + free(software_version->software_version); + free(software_version->os); + free(software_version->os_version); + } +} + void caps_destroy(EntityCapabilities *caps) { if (caps) { _disco_identity_destroy(caps->identity); - free(caps->software); - free(caps->software_version); - free(caps->os); - free(caps->os_version); + _software_version_destroy(caps->software_version); if (caps->features) { g_slist_free_full(caps->features, free); } diff --git a/src/xmpp/xmpp.h b/src/xmpp/xmpp.h index 3ab5fb56..93b02cb2 100644 --- a/src/xmpp/xmpp.h +++ b/src/xmpp/xmpp.h @@ -88,12 +88,16 @@ typedef struct disco_identity_t { char *category; } DiscoIdentity; -typedef struct entity_capabilities_t { - DiscoIdentity *identity; +typedef struct software_version_t { char *software; char *software_version; char *os; char *os_version; +} SoftwareVersion; + +typedef struct entity_capabilities_t { + DiscoIdentity *identity; + SoftwareVersion *software_version; GSList *features; } EntityCapabilities; From 9ce59b1589c34152483637805232791d61fc5e87 Mon Sep 17 00:00:00 2001 From: James Booth Date: Sat, 13 Aug 2016 17:49:19 +0100 Subject: [PATCH 6/6] Free DiscoIdentity and SoftwareVersion --- src/xmpp/capabilities.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c index a4e9244d..f773a559 100644 --- a/src/xmpp/capabilities.c +++ b/src/xmpp/capabilities.c @@ -633,6 +633,7 @@ _disco_identity_destroy(DiscoIdentity *disco_identity) free(disco_identity->category); free(disco_identity->name); free(disco_identity->type); + free(disco_identity); } } @@ -644,6 +645,7 @@ _software_version_destroy(SoftwareVersion *software_version) free(software_version->software_version); free(software_version->os); free(software_version->os_version); + free(software_version); } }