about summary refs log tree commit diff stats
path: root/src/xmpp/capabilities.c
diff options
context:
space:
mode:
authorJames Booth <boothj5@gmail.com>2016-08-13 23:43:54 +0100
committerJames Booth <boothj5@gmail.com>2016-08-13 23:43:54 +0100
commit9cecef5609ee1cb05cd2eae29bc31190dd3e5d41 (patch)
tree585c2631513216b18a08e0339e8d4b9787b16d87 /src/xmpp/capabilities.c
parent9ce59b1589c34152483637805232791d61fc5e87 (diff)
downloadprofani-tty-9cecef5609ee1cb05cd2eae29bc31190dd3e5d41.tar.gz
Move caps_create_query_response_stanza -> stanza_create_caps_query_element
Diffstat (limited to 'src/xmpp/capabilities.c')
-rw-r--r--src/xmpp/capabilities.c79
1 files changed, 22 insertions, 57 deletions
diff --git a/src/xmpp/capabilities.c b/src/xmpp/capabilities.c
index f773a559..26cb3c0c 100644
--- a/src/xmpp/capabilities.c
+++ b/src/xmpp/capabilities.c
@@ -106,6 +106,27 @@ caps_init(void)
     my_sha1 = NULL;
 }
 
+GList*
+caps_get_features(void)
+{
+    GList *result = NULL;
+
+    GList *curr = prof_features;
+    while (curr) {
+        result = g_list_append(result, curr->data);
+        curr = g_list_next(curr);
+    }
+
+    GList *plugin_features = plugins_get_disco_features();
+    curr = plugin_features;
+    while (curr) {
+        result = g_list_append(result, curr->data);
+        curr = g_list_next(curr);
+    }
+
+    return result;
+}
+
 void
 caps_add_by_ver(const char *const ver, EntityCapabilities *caps)
 {
@@ -540,7 +561,7 @@ char*
 caps_get_my_sha1(xmpp_ctx_t *const ctx)
 {
     if (my_sha1 == NULL) {
-        xmpp_stanza_t *query = caps_create_query_response_stanza(ctx);
+        xmpp_stanza_t *query = stanza_create_caps_query_element(ctx);
         my_sha1 = caps_create_sha1_str(query);
         xmpp_stanza_release(query);
     }
@@ -557,62 +578,6 @@ caps_reset_ver(void)
     }
 }
 
-xmpp_stanza_t*
-caps_create_query_response_stanza(xmpp_ctx_t *const ctx)
-{
-    xmpp_stanza_t *query = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(query, STANZA_NAME_QUERY);
-    xmpp_stanza_set_ns(query, XMPP_NS_DISCO_INFO);
-
-    xmpp_stanza_t *identity = xmpp_stanza_new(ctx);
-    xmpp_stanza_set_name(identity, "identity");
-    xmpp_stanza_set_attribute(identity, "category", "client");
-    xmpp_stanza_set_attribute(identity, "type", "console");
-
-    GString *name_str = g_string_new("Profanity ");
-    g_string_append(name_str, PACKAGE_VERSION);
-    if (strcmp(PACKAGE_STATUS, "development") == 0) {
-#ifdef HAVE_GIT_VERSION
-        g_string_append(name_str, "dev.");
-        g_string_append(name_str, PROF_GIT_BRANCH);
-        g_string_append(name_str, ".");
-        g_string_append(name_str, PROF_GIT_REVISION);
-#else
-        g_string_append(name_str, "dev");
-#endif
-    }
-    xmpp_stanza_set_attribute(identity, "name", name_str->str);
-    g_string_free(name_str, TRUE);
-    xmpp_stanza_add_child(query, identity);
-    xmpp_stanza_release(identity);
-
-    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();
-    curr = plugin_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);
-    }
-    g_list_free(plugin_features);
-
-    return query;
-}
-
 void
 caps_close(void)
 {