New Command: Delete OMEMO device list

With new new comamnd delete-device-list (mode omemo), the PEP node
eu.siacs.conversations.axolotl.devicelist will be delete.
This commit is contained in:
Stefan 2023-07-29 16:53:15 +02:00
parent ce2fbbdbfe
commit 194b0f1fef
4 changed files with 78 additions and 7 deletions

View File

@ -1,13 +1,13 @@
'\" t '\" t
.\" Title: xmppc .\" Title: xmppc
.\" Author: [see the "AUTHOR" section] .\" Author: [see the "AUTHOR" section]
.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/> .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
.\" Date: 05/16/2020 .\" Date: 07/29/2023
.\" Manual: \ \& .\" Manual: \ \&
.\" Source: \ \& .\" Source: \ \&
.\" Language: English .\" Language: English
.\" .\"
.TH "XMPPC" "1" "05/16/2020" "\ \&" "\ \&" .TH "XMPPC" "1" "07/29/2023" "\ \&" "\ \&"
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
.\" * Define some portability stuff .\" * Define some portability stuff
.\" ----------------------------------------------------------------- .\" -----------------------------------------------------------------
@ -149,6 +149,18 @@ OMEMO Mode (XEP\-0384)
\fBlist\fR \fBlist\fR
\- List the device IDs and fingerprints \- List the device IDs and fingerprints
.RE .RE
.sp
.RS 4
.ie n \{\
\h'-04'\(bu\h'+03'\c
.\}
.el \{\
.sp -1
.IP \(bu 2.3
.\}
\fBdelete\-device\-list\fR
\- Deletes the OMEMO device list
.RE
.RE .RE
.PP .PP
\fB\-m openpgp\fR \fB\-m openpgp\fR
@ -352,7 +364,7 @@ See https://codeberg\&.org/Anoxinon_e\&.V\&./xmppc/issues
.sp -1 .sp -1
.IP \(bu 2.3 .IP \(bu 2.3
.\} .\}
DebXWoody (OpenPGP: A602F76893F138B4A8EFDDD5C2DC916F35751C24) DebXWoody
.RE .RE
.SH "RESOURCES" .SH "RESOURCES"
.sp .sp

View File

@ -71,6 +71,7 @@ PGP Mode (XEP-0027)
OMEMO Mode (XEP-0384) OMEMO Mode (XEP-0384)
* *list* - List the device IDs and fingerprints * *list* - List the device IDs and fingerprints
* *delete-device-list* - Deletes the OMEMO device list
*-m openpgp*:: *-m openpgp*::
openpgp mode (XEP-0373) openpgp mode (XEP-0373)
@ -146,7 +147,7 @@ See <https://codeberg.org/Anoxinon_e.V./xmppc/issues>
AUTHOR AUTHOR
------ ------
* DebXWoody (OpenPGP: A602F76893F138B4A8EFDDD5C2DC916F35751C24) * DebXWoody
RESOURCES RESOURCES
--------- ---------

View File

@ -560,6 +560,7 @@ static void _show_help() {
printf("\n"); printf("\n");
printf(" -m --mode omemo xmppc omemo mode (XEP-0384)\n"); printf(" -m --mode omemo xmppc omemo mode (XEP-0384)\n");
printf(" list List the device IDs and fingerprints\n"); printf(" list List the device IDs and fingerprints\n");
printf(" delete-device-list Delete OMEMO device list\n");
printf("\n"); printf("\n");
printf(" -m --mode openpgp xmppc openpgp mode (XEP-0373)\n"); printf(" -m --mode openpgp xmppc openpgp mode (XEP-0373)\n");
printf(" signcrypt <jid> <message> Sending pgp signed and encrypted message to jid\n"); printf(" signcrypt <jid> <message> Sending pgp signed and encrypted message to jid\n");

View File

@ -52,12 +52,24 @@ static void _omemo_device_list_query(xmppc_t *xmppc);
static int _omemo_device_list_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, static int _omemo_device_list_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
void *const userdata); void *const userdata);
static void _omemo_delete_device_list_query(xmppc_t *xmppc);
static int _omemo_delete_device_list_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
void *const userdata);
static void _omemo_bundles_query(xmppc_t *xmppc, const char* deviceid); static void _omemo_bundles_query(xmppc_t *xmppc, const char* deviceid);
static int _omemo_bundles_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza, static int _omemo_bundles_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
void *const userdata); void *const userdata);
void omemo_execute_command(xmppc_t *xmppc, int agrc, char *argv[]) { void omemo_execute_command(xmppc_t *xmppc, int argc, char *argv[]) {
if(argc > 0) {
if(strcmp("list", argv[0]) == 0) {
_omemo_device_list_query(xmppc); _omemo_device_list_query(xmppc);
} else if(strcmp("delete-device-list", argv[0]) == 0) {
_omemo_delete_device_list_query(xmppc);
} else {
logError(xmppc, "Unbekanner Befehl: %s\n", argv[0]);
}
}
} }
void _omemo_device_list_query(xmppc_t *xmppc) { void _omemo_device_list_query(xmppc_t *xmppc) {
@ -184,4 +196,49 @@ int _omemo_bundles_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
return 0; return 0;
} }
/**
<iq type='set'
from='hamlet@denmark.lit/elsinore'
to='pubsub.shakespeare.lit'
id='delete1'>
<pubsub xmlns='http://jabber.org/protocol/pubsub#owner'>
<delete node='princely_musings'/>
</pubsub>
</iq>
**/
static void _omemo_delete_device_list_query(xmppc_t *xmppc) {
xmpp_conn_t *conn = xmppc->conn;
xmpp_stanza_t *iq, *query, *item;
char* id = xmpp_uuid_gen(xmppc->ctx);
iq = xmpp_iq_new(xmpp_conn_get_context(conn), "set", id);
const char *jid = xmpp_conn_get_jid(conn);
xmpp_stanza_set_from(iq, jid);
xmpp_stanza_set_to(iq, jid);
query = xmpp_stanza_new(xmpp_conn_get_context(conn));
xmpp_stanza_set_name(query, "pubsub");
xmpp_stanza_set_ns(query, "http://jabber.org/protocol/pubsub#owner");
xmpp_stanza_add_child(iq, query);
item = xmpp_stanza_new(xmpp_conn_get_context(conn));
xmpp_stanza_set_name(item, "delete");
xmpp_stanza_set_attribute(item, "node",
"eu.siacs.conversations.axolotl.devicelist");
xmpp_stanza_add_child(query, item);
xmpp_stanza_release(query);
xmpp_stanza_release(item);
xmpp_id_handler_add(conn, _omemo_delete_device_list_reply , id, xmppc);
xmpp_send(conn, iq);
}
int _omemo_delete_device_list_reply(xmpp_conn_t *const conn, xmpp_stanza_t *const stanza,
void *const userdata) {
xmppc_t *xmppc = (xmppc_t *)userdata;
if(strcmp(xmpp_stanza_get_type(stanza), "error") == 0) {
printf("Fehler\n");
return 0;
}
printf("Done\n");
xmpp_disconnect(xmppc->conn);
xmpp_stop(xmppc->ctx);
return 0;
}