1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-11-03 19:37:16 -05:00

Change connection_create_stanza_id()

To return identifier and uuid together.
We can remove the prefix later on.
This commit is contained in:
Michael Vetter 2019-10-17 09:23:11 +02:00
parent 708bc83870
commit 8f5d1751b2

View File

@ -458,22 +458,22 @@ connection_free_uuid(char *uuid)
char* char*
connection_create_stanza_id(char *prefix) connection_create_stanza_id(char *prefix)
{ {
char *result = NULL; unsigned char *digest = (unsigned char*)malloc(XMPP_SHA1_DIGEST_SIZE);
GString *result_str = g_string_new("");
char *uuid = connection_create_uuid(); char *uuid = connection_create_uuid();
if (prefix) { assert(digest != NULL);
g_string_printf(result_str, "prof_%s_%s", prefix, uuid); assert(uuid != NULL);
} else {
g_string_printf(result_str, "prof_%s", uuid);
}
connection_free_uuid(uuid); GString *tmp = g_string_new("");
g_string_printf(tmp, "%s%s", prof_identifier, uuid);
xmpp_sha1_digest((unsigned char*)tmp->str, strlen(tmp->str), digest);
g_string_free(tmp, TRUE);
result = result_str->str; char *b64 = g_base64_encode(digest, XMPP_SHA1_DIGEST_SIZE);
g_string_free(result_str, FALSE); assert(b64 != NULL);
free(digest);
return result; return b64;
} }
char* char*