mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Create sha-1 of own capabilities once
This commit is contained in:
parent
7621a84675
commit
345a9e3f40
@ -49,12 +49,15 @@
|
|||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
#include "xmpp/stanza.h"
|
#include "xmpp/stanza.h"
|
||||||
#include "xmpp/form.h"
|
#include "xmpp/form.h"
|
||||||
|
#include "xmpp/capabilities.h"
|
||||||
|
|
||||||
static gchar *cache_loc;
|
static gchar *cache_loc;
|
||||||
static GKeyFile *cache;
|
static GKeyFile *cache;
|
||||||
|
|
||||||
static GHashTable *jid_lookup;
|
static GHashTable *jid_lookup;
|
||||||
|
|
||||||
|
static char *my_sha1;
|
||||||
|
|
||||||
static void _caps_destroy(Capabilities *caps);
|
static void _caps_destroy(Capabilities *caps);
|
||||||
static gchar* _get_cache_file(void);
|
static gchar* _get_cache_file(void);
|
||||||
static void _save_cache(void);
|
static void _save_cache(void);
|
||||||
@ -71,6 +74,8 @@ caps_init(void)
|
|||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
jid_lookup = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
jid_lookup = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
|
||||||
|
|
||||||
|
my_sha1 = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -425,6 +430,17 @@ caps_create(xmpp_stanza_t *query)
|
|||||||
return new_caps;
|
return new_caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
caps_get_my_sha1(xmpp_ctx_t * const ctx)
|
||||||
|
{
|
||||||
|
if (my_sha1 == NULL) {
|
||||||
|
xmpp_stanza_t *query = caps_create_query_response_stanza(ctx);
|
||||||
|
my_sha1 = caps_create_sha1_str(query);
|
||||||
|
xmpp_stanza_release(query);
|
||||||
|
}
|
||||||
|
|
||||||
|
return my_sha1;
|
||||||
|
}
|
||||||
|
|
||||||
xmpp_stanza_t *
|
xmpp_stanza_t *
|
||||||
caps_create_query_response_stanza(xmpp_ctx_t * const ctx)
|
caps_create_query_response_stanza(xmpp_ctx_t * const ctx)
|
||||||
|
@ -46,5 +46,6 @@ gboolean caps_contains(const char * const caps_ver);
|
|||||||
char* caps_create_sha1_str(xmpp_stanza_t * const query);
|
char* caps_create_sha1_str(xmpp_stanza_t * const query);
|
||||||
xmpp_stanza_t* caps_create_query_response_stanza(xmpp_ctx_t * const ctx);
|
xmpp_stanza_t* caps_create_query_response_stanza(xmpp_ctx_t * const ctx);
|
||||||
Capabilities* caps_create(xmpp_stanza_t *query);
|
Capabilities* caps_create(xmpp_stanza_t *query);
|
||||||
|
char* caps_get_my_sha1(xmpp_ctx_t * const ctx);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1198,14 +1198,13 @@ stanza_attach_caps(xmpp_ctx_t * const ctx, xmpp_stanza_t * const presence)
|
|||||||
xmpp_stanza_set_ns(caps, STANZA_NS_CAPS);
|
xmpp_stanza_set_ns(caps, STANZA_NS_CAPS);
|
||||||
xmpp_stanza_t *query = caps_create_query_response_stanza(ctx);
|
xmpp_stanza_t *query = caps_create_query_response_stanza(ctx);
|
||||||
|
|
||||||
char *sha1 = caps_create_sha1_str(query);
|
char *sha1 = caps_get_my_sha1(ctx);
|
||||||
xmpp_stanza_set_attribute(caps, STANZA_ATTR_HASH, "sha-1");
|
xmpp_stanza_set_attribute(caps, STANZA_ATTR_HASH, "sha-1");
|
||||||
xmpp_stanza_set_attribute(caps, STANZA_ATTR_NODE, "http://www.profanity.im");
|
xmpp_stanza_set_attribute(caps, STANZA_ATTR_NODE, "http://www.profanity.im");
|
||||||
xmpp_stanza_set_attribute(caps, STANZA_ATTR_VER, sha1);
|
xmpp_stanza_set_attribute(caps, STANZA_ATTR_VER, sha1);
|
||||||
xmpp_stanza_add_child(presence, caps);
|
xmpp_stanza_add_child(presence, caps);
|
||||||
xmpp_stanza_release(caps);
|
xmpp_stanza_release(caps);
|
||||||
xmpp_stanza_release(query);
|
xmpp_stanza_release(query);
|
||||||
g_free(sha1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
|
Loading…
Reference in New Issue
Block a user