1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Start implementing XEP-0084

So far we just subscribe and get the IDs.
This commit is contained in:
Michael Vetter 2019-12-18 10:14:46 +01:00
parent 3bb2e07c1e
commit 771dfab123
6 changed files with 141 additions and 0 deletions

View File

@ -15,6 +15,7 @@ core_sources = \
src/xmpp/bookmark.c src/xmpp/bookmark.h \
src/xmpp/blocking.c src/xmpp/blocking.h \
src/xmpp/form.c src/xmpp/form.h \
src/xmpp/avatar.c src/xmpp/avatar.h \
src/event/common.c src/event/common.h \
src/event/server_events.c src/event/server_events.h \
src/event/client_events.c src/event/client_events.h \

View File

@ -54,6 +54,7 @@
#include "xmpp/muc.h"
#include "xmpp/chat_session.h"
#include "xmpp/roster_list.h"
#include "xmpp/avatar.h"
#ifdef HAVE_LIBOTR
#include "otr/otr.h"
@ -90,6 +91,8 @@ sv_ev_login_account_success(char *account_name, gboolean secured)
omemo_on_connect(account);
#endif
avatar_pep_subscribe();
ui_handle_login_account_success(account, secured);
// attempt to rejoin all rooms

94
src/xmpp/avatar.c Normal file
View File

@ -0,0 +1,94 @@
/*
* omemo.c
* vim: expandtab:ts=4:sts=4:sw=4
*
* Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give permission to
* link the code of portions of this program with the OpenSSL library under
* certain conditions as described in each individual source file, and
* distribute linked combinations including the two.
*
* You must obey the GNU General Public License in all respects for all of the
* code used other than OpenSSL. If you modify file(s) with this exception, you
* may extend this exception to your version of the file(s), but you are not
* obligated to do so. If you do not wish to do so, delete this exception
* statement from your version. If you delete this exception statement from all
* source files in the program, then also delete it here.
*
*/
#include <glib.h>
#include "log.h"
#include "xmpp/connection.h"
#include "xmpp/form.h"
#include "xmpp/iq.h"
#include "xmpp/message.h"
#include "xmpp/stanza.h"
static int _avatar_metadata_nofication(xmpp_stanza_t *const stanza, void *const userdata);
void
avatar_pep_subscribe(void)
{
message_pubsub_event_handler_add(STANZA_NS_USER_AVATAR_METADATA, _avatar_metadata_nofication, NULL, NULL);
message_pubsub_event_handler_add(STANZA_NS_USER_AVATAR_DATA, _avatar_metadata_nofication, NULL, NULL);
caps_add_feature(XMPP_FEATURE_USER_AVATAR_METADATA_NOTIFY);
}
static int
_avatar_metadata_nofication(xmpp_stanza_t *const stanza, void *const userdata)
{
const char *from = xmpp_stanza_get_attribute(stanza, STANZA_ATTR_FROM);
from = from;
xmpp_stanza_t *root = NULL;
xmpp_stanza_t *event = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB_EVENT);
if (event) {
root = event;
}
xmpp_stanza_t *pubsub = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_PUBSUB);
if (pubsub) {
root = pubsub;
}
if (!root) {
return 1;
}
xmpp_stanza_t *items = xmpp_stanza_get_child_by_name(root, "items");
if (!items) {
return 1;
}
xmpp_stanza_t *item = xmpp_stanza_get_child_by_name(items, "item");
if (item) {
xmpp_stanza_t *metadata = xmpp_stanza_get_child_by_name(item, "metadata");
if (!metadata)
return 1;
xmpp_stanza_t *info = xmpp_stanza_get_child_by_name(metadata, "info");
const char *id = xmpp_stanza_get_id(info);
id = id;
}
return 1;
}

38
src/xmpp/avatar.h Normal file
View File

@ -0,0 +1,38 @@
/*
* omemo.h
* vim: expandtab:ts=4:sts=4:sw=4
*
* Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
*
* This file is part of Profanity.
*
* Profanity is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Profanity is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Profanity. If not, see <https://www.gnu.org/licenses/>.
*
* In addition, as a special exception, the copyright holders give permission to
* link the code of portions of this program with the OpenSSL library under
* certain conditions as described in each individual source file, and
* distribute linked combinations including the two.
*
* You must obey the GNU General Public License in all respects for all of the
* code used other than OpenSSL. If you modify file(s) with this exception, you
* may extend this exception to your version of the file(s), but you are not
* obligated to do so. If you do not wish to do so, delete this exception
* statement from your version. If you delete this exception statement from all
* source files in the program, then also delete it here.
*
*/
#include <glib.h>
void avatar_pep_subscribe(void);

View File

@ -2,6 +2,7 @@
* stanza.h
*
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
* Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
*
* This file is part of Profanity.
*
@ -198,6 +199,8 @@
#define STANZA_NS_OMEMO_DEVICELIST "eu.siacs.conversations.axolotl.devicelist"
#define STANZA_NS_OMEMO_BUNDLES "eu.siacs.conversations.axolotl.bundles"
#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_DATAFORM_SOFTWARE "urn:xmpp:dataforms:softwareinfo"

View File

@ -2,6 +2,7 @@
* xmpp.h
*
* Copyright (C) 2012 - 2019 James Booth <boothj5@gmail.com>
* Copyright (C) 2019 Michael Vetter <jubalh@iodoru.org>
*
* This file is part of Profanity.
*
@ -66,6 +67,7 @@
#define XMPP_FEATURE_OMEMO_DEVICELIST_NOTIFY "eu.siacs.conversations.axolotl.devicelist+notify"
#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"
typedef enum {
JABBER_CONNECTING,