diff --git a/docs/api/plugins/xep_0027.rst b/docs/api/plugins/xep_0027.rst index 418baada..566c9427 100644 --- a/docs/api/plugins/xep_0027.rst +++ b/docs/api/plugins/xep_0027.rst @@ -9,6 +9,48 @@ XEP-0027: Current Jabber OpenPGP Usage :exclude-members: session_bind, plugin_init, plugin_end +Internal API methods +-------------------- + +The default API here is managing a JID→Keyid dict in-memory. + +.. glossary:: + + get_keyid + - **jid**: :class:`~.JID` to get. + - **node**: unused + - **ifrom**: unused + - **args**: unused + - **returns**: ``Optional[str]``, the keyid or None + + Get the KeyiD for a JID, None if it is not found. + + set_keyid + - **jid**: :class:`~.JID` to set the id for. + - **node**: unused + - **ifrom**: unused + - **args**: ``str``, keyid to set + + Set the KeyiD for a JID. + + del_keyid + - **jid**: :class:`~.JID` to delete from the mapping. + - **node**: unused + - **ifrom**: unused + - **args**: unused + + Delete the KeyiD for a JID. + + get_keyids + - **jid**: unused + - **node**: unused + - **ifrom**: unused + - **args**: unused + - **returns**: ``Dict[JID, str]`` the full internal mapping + + Get all currently stored KeyIDs. + + Stanza elements --------------- diff --git a/slixmpp/plugins/xep_0027/gpg.py b/slixmpp/plugins/xep_0027/gpg.py index af5df044..61da7ff0 100644 --- a/slixmpp/plugins/xep_0027/gpg.py +++ b/slixmpp/plugins/xep_0027/gpg.py @@ -5,9 +5,11 @@ # See the file LICENSE for copying permission. from slixmpp.thirdparty import GPG +from asyncio import Future + from slixmpp.stanza import Presence, Message -from slixmpp.plugins.base import BasePlugin, register_plugin -from slixmpp.xmlstream import ElementBase, register_stanza_plugin +from slixmpp.plugins.base import BasePlugin +from slixmpp.xmlstream import register_stanza_plugin from slixmpp.xmlstream.handler import Callback from slixmpp.xmlstream.matcher import StanzaPath from slixmpp.plugins.xep_0027 import stanza, Signed, Encrypted @@ -32,6 +34,9 @@ def _extract_data(data, kind): class XEP_0027(BasePlugin): + """ + XEP-0027: Current Jabber OpenPGP Usage + """ name = 'xep_0027' description = 'XEP-0027: Current Jabber OpenPGP Usage' @@ -122,16 +127,36 @@ class XEP_0027(BasePlugin): v = self.gpg.verify(template % (data, sig)) return v - def set_keyid(self, jid=None, keyid=None): - self.api['set_keyid'](jid, args=keyid) + def set_keyid(self, jid=None, keyid=None) -> Future: + """Set a keyid for a specific JID. - def get_keyid(self, jid=None): + .. versionchanged:: 1.8.0 + This function now returns a Future. + """ + return self.api['set_keyid'](jid, args=keyid) + + def get_keyid(self, jid=None) -> Future: + """Get a keyid for a jid. + + .. versionchanged:: 1.8.0 + This function now returns a Future. + """ return self.api['get_keyid'](jid) - def del_keyid(self, jid=None): - self.api['del_keyid'](jid) + def del_keyid(self, jid=None) -> Future: + """Delete a keyid. - def get_keyids(self): + .. versionchanged:: 1.8.0 + This function now returns a Future. + """ + return self.api['del_keyid'](jid) + + def get_keyids(self) -> Future: + """Get stored keyids. + + .. versionchanged:: 1.8.0 + This function now returns a Future. + """ return self.api['get_keyids']() def _handle_signed_presence(self, pres):