[docs]classXEP_0292(BasePlugin):""" vCard4 over XMPP Does not implement the IQ semantics that neither movim does gajim implement, cf https://xmpp.org/extensions/xep-0292.html#self-iq-retrieval and https://xmpp.org/extensions/xep-0292.html#self-iq-publication Does not implement the "empty pubsub event item" as a notification mechanism, that neither gajim nor movim implement https://xmpp.org/extensions/xep-0292.html#sect-idm45744791178720 Relies on classic pubsub semantics instead. """xmpp:ComponentXMPPname="xep_0292"description="vCard4 Over XMPP"dependencies={"xep_0163","xep_0060","xep_0030"}stanza=stanzadefplugin_init(self):pubsub_stanza=self.xmpp["xep_0060"].stanzaregister_stanza_plugin(pubsub_stanza.Item,stanza.VCard4)register_stanza_plugin(pubsub_stanza.EventItem,stanza.VCard4)self.xmpp['xep_0060'].map_node_event(stanza.NS,'vcard4')defplugin_end(self):self.xmpp['xep_0030'].del_feature(feature=stanza.NS)self.xmpp['xep_0163'].remove_interest(stanza.NS)
[docs]defpublish_vcard(self,full_name:Optional[str]=None,given:Optional[str]=None,surname:Optional[str]=None,birthday:Optional[date]=None,nickname:Optional[str]=None,phone:Optional[str]=None,note:Optional[str]=None,url:Optional[str]=None,email:Optional[str]=None,country:Optional[str]=None,locality:Optional[str]=None,impp:Optional[str]=None,**pubsubkwargs,):""" Publish a vcard using PEP """vcard=stanza.VCard4()ifimpp:vcard.add_impp(impp)ifnickname:vcard.add_nickname(nickname)iffull_name:vcard["full_name"]=full_nameifgiven:vcard["given"]=givenifsurname:vcard["surname"]=surnameifbirthday:vcard["birthday"]=birthdayifnote:vcard.add_note(note)ifurl:vcard.add_url(url)ifemail:vcard.add_email(email)ifphone:vcard.add_tel(phone)ifcountryandlocality:vcard.add_address(country,locality)elifcountry:vcard.add_address(country,locality)returnself.xmpp["xep_0163"].publish(vcard,id="current",**pubsubkwargs)
[docs]defretrieve_vcard(self,jid:JID,**pubsubkwargs):""" Retrieve a vcard using PEP """returnself.xmpp["xep_0060"].get_item(jid,stanza.VCard4.namespace,"current",**pubsubkwargs)