mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
ox: use glib date function in _gettimestamp and fix memleak
This commit is contained in:
parent
e16bff2328
commit
7acc044a52
@ -55,14 +55,13 @@ static int _ox_metadata_result(xmpp_stanza_t* const stanza, void* const userdata
|
|||||||
static void _ox_request_public_key(const char* const jid, const char* const fingerprint);
|
static void _ox_request_public_key(const char* const jid, const char* const fingerprint);
|
||||||
static int _ox_public_key_result(xmpp_stanza_t* const stanza, void* const userdata);
|
static int _ox_public_key_result(xmpp_stanza_t* const stanza, void* const userdata);
|
||||||
|
|
||||||
/*!
|
/* Return Current Date and Time.
|
||||||
* \brief Current Date and Time.
|
|
||||||
*
|
*
|
||||||
* XEP-0082: XMPP Date and Time Profiles
|
* XEP-0082: XMPP Date and Time Profiles
|
||||||
* https://xmpp.org/extensions/xep-0082.html
|
* https://xmpp.org/extensions/xep-0082.html
|
||||||
*
|
*
|
||||||
* \return YYYY-MM-DDThh:mm:ssZ
|
* According to ISO8601
|
||||||
*
|
* YYYY-MM-DDThh:mm:ssZ
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static char* _gettimestamp();
|
static char* _gettimestamp();
|
||||||
@ -268,7 +267,9 @@ _ox_metadata_node__public_key(const char* const fingerprint)
|
|||||||
xmpp_stanza_t* pubkeymetadata = xmpp_stanza_new(ctx);
|
xmpp_stanza_t* pubkeymetadata = xmpp_stanza_new(ctx);
|
||||||
xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA);
|
xmpp_stanza_set_name(pubkeymetadata, STANZA_NAME_PUBKEY_METADATA);
|
||||||
xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT, fingerprint);
|
xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_V4_FINGERPRINT, fingerprint);
|
||||||
xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_DATE, _gettimestamp());
|
char* timestamp = _gettimestamp();
|
||||||
|
xmpp_stanza_set_attribute(pubkeymetadata, STANZA_ATTR_DATE, timestamp);
|
||||||
|
free(timestamp);
|
||||||
|
|
||||||
xmpp_stanza_add_child(publickeyslist, pubkeymetadata);
|
xmpp_stanza_add_child(publickeyslist, pubkeymetadata);
|
||||||
xmpp_stanza_add_child(item, publickeyslist);
|
xmpp_stanza_add_child(item, publickeyslist);
|
||||||
@ -476,13 +477,10 @@ _ox_public_key_result(xmpp_stanza_t* const stanza, void* const userdata)
|
|||||||
char*
|
char*
|
||||||
_gettimestamp()
|
_gettimestamp()
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
GDateTime* dt = g_date_time_new_now_local();
|
||||||
struct tm* tm = localtime(&now);
|
gchar* datestr = g_date_time_format(dt, "%FT%TZ");
|
||||||
char buf[255];
|
g_date_time_unref(dt);
|
||||||
strftime(buf, sizeof(buf), "%FT%T", tm);
|
return datestr;
|
||||||
GString* d = g_string_new(buf);
|
|
||||||
g_string_append(d, "Z");
|
|
||||||
return strdup(d->str);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_LIBGPGME
|
#endif // HAVE_LIBGPGME
|
||||||
|
Loading…
Reference in New Issue
Block a user