xep-0308: Initial support for incoming LMC

This commit is contained in:
Michael Vetter
2020-02-10 13:19:54 +01:00
parent 968006e1dd
commit f16d56a15e
5 changed files with 75 additions and 7 deletions

View File

@@ -110,6 +110,8 @@ caps_init(void)
if (prefs_get_boolean(PREF_LASTACTIVITY)) {
g_hash_table_add(prof_features, strdup(STANZA_NS_LASTACTIVITY));
}
//TODO: depend on setting
g_hash_table_add(prof_features, strdup(STANZA_NS_LAST_MESSAGE_CORRECTION));
my_sha1 = NULL;
}

View File

@@ -188,6 +188,7 @@ message_init(void)
message->jid = NULL;
message->id = NULL;
message->originid = NULL;
message->replace_id = NULL;
message->body = NULL;
message->encrypted = NULL;
message->plain = NULL;
@@ -215,6 +216,10 @@ message_free(ProfMessage *message)
xmpp_free(ctx, message->originid);
}
if (message->replace_id) {
xmpp_free(ctx, message->replace_id);
}
if (message->body) {
xmpp_free(ctx, message->body);
}
@@ -1113,6 +1118,20 @@ _handle_chat(xmpp_stanza_t *const stanza)
ProfMessage *message = message_init();
message->jid = jid;
// message stanza id
const char *id = xmpp_stanza_get_id(stanza);
if (id) {
message->id = strdup(id);
}
xmpp_stanza_t *replace_id_stanza = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_LAST_MESSAGE_CORRECTION);
if (replace_id_stanza) {
const char *replace_id = xmpp_stanza_get_id(replace_id_stanza);
if (replace_id) {
message->replace_id = strdup(replace_id);
}
}
if (mucuser) {
message->mucuser = TRUE;
}

View File

@@ -201,6 +201,7 @@
#define STANZA_NS_STABLE_ID "urn:xmpp:sid:0"
#define STANZA_NS_USER_AVATAR_DATA "urn:xmpp:avatar:data"
#define STANZA_NS_USER_AVATAR_METADATA "urn:xmpp:avatar:metadata"
#define STANZA_NS_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
#define STANZA_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"

View File

@@ -68,6 +68,7 @@
#define XMPP_FEATURE_PUBSUB "http://jabber.org/protocol/pubsub"
#define XMPP_FEATURE_PUBSUB_PUBLISH_OPTIONS "http://jabber.org/protocol/pubsub#publish-options"
#define XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY "urn:xmpp:avatar:metadata+notify"
#define XMPP_FEATURE_LAST_MESSAGE_CORRECTION "urn:xmpp:message-correct:0"
typedef enum {
JABBER_CONNECTING,
@@ -130,6 +131,8 @@ typedef struct prof_message_t {
char *id;
/* </origin-id> XEP-0359 */
char *originid;
/* <replace id> XEP-0308 LMC */
char *replace_id;
/* The raw body from xmpp message, either plaintext or OTR encrypted text */
char *body;
/* The encrypted message as for PGP */