mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Add devicelist subscription
This commit is contained in:
parent
2602cbf785
commit
bce1981128
@ -171,7 +171,8 @@ otr4_sources = \
|
|||||||
src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c
|
src/otr/otrlib.h src/otr/otrlibv4.c src/otr/otr.h src/otr/otr.c
|
||||||
|
|
||||||
omemo_sources = \
|
omemo_sources = \
|
||||||
src/omemo/omemo.h src/omemo/omemo.c src/omemo/crypto.h src/omemo/crypto.c
|
src/omemo/omemo.h src/omemo/omemo.c src/omemo/crypto.h src/omemo/crypto.c \
|
||||||
|
src/xmpp/omemo.h src/xmpp/omemo.c
|
||||||
|
|
||||||
if BUILD_PYTHON_API
|
if BUILD_PYTHON_API
|
||||||
core_sources += $(python_sources)
|
core_sources += $(python_sources)
|
||||||
|
15
src/xmpp/omemo.c
Normal file
15
src/xmpp/omemo.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include "xmpp/connection.h"
|
||||||
|
#include "xmpp/iq.h"
|
||||||
|
#include "xmpp/stanza.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
omemo_devicelist_publish(void)
|
||||||
|
{
|
||||||
|
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||||
|
char *barejid = xmpp_jid_bare(ctx, session_get_account_name());
|
||||||
|
xmpp_stanza_t *iq = stanza_create_omemo_devicelist_subscription(ctx, barejid);
|
||||||
|
iq_send_stanza(iq);
|
||||||
|
xmpp_stanza_release(iq);
|
||||||
|
|
||||||
|
free(barejid);
|
||||||
|
}
|
1
src/xmpp/omemo.h
Normal file
1
src/xmpp/omemo.h
Normal file
@ -0,0 +1 @@
|
|||||||
|
void omemo_devicelist_publish(void);
|
@ -60,6 +60,10 @@
|
|||||||
#include "xmpp/chat_session.h"
|
#include "xmpp/chat_session.h"
|
||||||
#include "xmpp/jid.h"
|
#include "xmpp/jid.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_OMEMO
|
||||||
|
#include "xmpp/omemo.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
// for auto reconnect
|
// for auto reconnect
|
||||||
static struct {
|
static struct {
|
||||||
char *name;
|
char *name;
|
||||||
@ -313,6 +317,9 @@ session_login_success(gboolean secured)
|
|||||||
roster_request();
|
roster_request();
|
||||||
bookmark_request();
|
bookmark_request();
|
||||||
blocking_request();
|
blocking_request();
|
||||||
|
#ifdef HAVE_OMEMO
|
||||||
|
omemo_devicelist_publish();
|
||||||
|
#endif
|
||||||
|
|
||||||
// items discovery
|
// items discovery
|
||||||
char *domain = connection_get_domain();
|
char *domain = connection_get_domain();
|
||||||
|
@ -2092,6 +2092,31 @@ stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room,
|
|||||||
return iq;
|
return iq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xmpp_stanza_t*
|
||||||
|
stanza_create_omemo_devicelist_pubsub_subscription(xmpp_ctx_t *ctx, const char *const jid)
|
||||||
|
{
|
||||||
|
char *id = connection_create_stanza_id("omemo_devicelist_subscribe");
|
||||||
|
xmpp_stanza_t *iq = xmpp_iq_new(ctx, STANZA_TYPE_SET, id);
|
||||||
|
free(id);
|
||||||
|
|
||||||
|
xmpp_stanza_t *pubsub = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(pubsub, STANZA_NAME_PUBSUB);
|
||||||
|
xmpp_stanza_set_ns(pubsub, STANZA_NS_PUBSUB);
|
||||||
|
|
||||||
|
xmpp_stanza_t *subscribe = xmpp_stanza_new(ctx);
|
||||||
|
xmpp_stanza_set_name(subscribe, "subscribe");
|
||||||
|
xmpp_stanza_set_attribute(subscribe, "node", "eu.siacs.conversations.axolotl.devicelist");
|
||||||
|
xmpp_stanza_set_attribute(subscribe, "jid", jid);
|
||||||
|
|
||||||
|
xmpp_stanza_add_child(pubsub, subscribe);
|
||||||
|
xmpp_stanza_add_child(iq, pubsub);
|
||||||
|
|
||||||
|
xmpp_stanza_release(subscribe);
|
||||||
|
xmpp_stanza_release(pubsub);
|
||||||
|
|
||||||
|
return iq;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_stanza_add_unique_id(xmpp_stanza_t *stanza, char *prefix)
|
_stanza_add_unique_id(xmpp_stanza_t *stanza, char *prefix)
|
||||||
{
|
{
|
||||||
|
@ -284,6 +284,8 @@ xmpp_stanza_t* stanza_create_room_kick_iq(xmpp_ctx_t *const ctx, const char *con
|
|||||||
xmpp_stanza_t* stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target, const char *const node);
|
xmpp_stanza_t* stanza_create_command_exec_iq(xmpp_ctx_t *ctx, const char *const target, const char *const node);
|
||||||
xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, const char *const node, const char *const sessionid, DataForm *form);
|
xmpp_stanza_t* stanza_create_command_config_submit_iq(xmpp_ctx_t *ctx, const char *const room, const char *const node, const char *const sessionid, DataForm *form);
|
||||||
|
|
||||||
|
xmpp_stanza_t* stanza_create_omemo_devicelist_pubsub_subscription(xmpp_ctx_t *ctx, const char *const jid);
|
||||||
|
|
||||||
int stanza_get_idle_time(xmpp_stanza_t *const stanza);
|
int stanza_get_idle_time(xmpp_stanza_t *const stanza);
|
||||||
|
|
||||||
void stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri);
|
void stanza_attach_priority(xmpp_ctx_t *const ctx, xmpp_stanza_t *const presence, const int pri);
|
||||||
|
Loading…
Reference in New Issue
Block a user