comparison sat/plugins/plugin_exp_list_of_interest.py @ 2913:672e6be3290f

plugins sharing invitation, invitation, list of interest: handle invitation to a file sharing repository
author Goffi <goffi@goffi.org>
date Sun, 14 Apr 2019 08:21:51 +0200
parents a3faf1c86596
children 47df940738a7
comparison
equal deleted inserted replaced
2912:a3faf1c86596 2913:672e6be3290f
33 PLUGIN_INFO = { 33 PLUGIN_INFO = {
34 C.PI_NAME: "List of Interest", 34 C.PI_NAME: "List of Interest",
35 C.PI_IMPORT_NAME: "LIST_INTEREST", 35 C.PI_IMPORT_NAME: "LIST_INTEREST",
36 C.PI_TYPE: "EXP", 36 C.PI_TYPE: "EXP",
37 C.PI_PROTOCOLS: [], 37 C.PI_PROTOCOLS: [],
38 C.PI_DEPENDENCIES: ["XEP-0060"], 38 C.PI_DEPENDENCIES: [u"XEP-0060", u"XEP-0329"],
39 C.PI_RECOMMENDATIONS: [], 39 C.PI_RECOMMENDATIONS: [],
40 C.PI_MAIN: "ListInterest", 40 C.PI_MAIN: "ListInterest",
41 C.PI_HANDLER: "yes", 41 C.PI_HANDLER: "yes",
42 C.PI_DESCRIPTION: _(u"Experimental handling of interesting XMPP locations"), 42 C.PI_DESCRIPTION: _(u"Experimental handling of interesting XMPP locations"),
43 } 43 }
77 """Register an interesting element in personal list 77 """Register an interesting element in personal list
78 78
79 @param namespace(unicode): namespace of the interest 79 @param namespace(unicode): namespace of the interest
80 this is used as a cache, to avoid the need to retrieve the item only to get 80 this is used as a cache, to avoid the need to retrieve the item only to get
81 its namespace 81 its namespace
82 @param service(jid.JID): pubsub service of the 82 @param service(jid.JID): target pubsub service
83 @param node(unicode): target pubsub node 83 @param node(unicode): target pubsub node
84 @param item_id(unicode, None): target pubsub id 84 @param item_id(unicode, None): target pubsub id
85 @param creator(bool): True if client's profile is the creator of the node 85 @param creator(bool): True if client's profile is the creator of the node
86 This is used a cache, to avoid the need to retrieve affiliations 86 This is used a cache, to avoid the need to retrieve affiliations
87 @param name(unicode, None): name of the interest 87 @param name(unicode, None): name of the interest
100 pubsub_elt[u"item"] = item_id 100 pubsub_elt[u"item"] = item_id
101 if creator: 101 if creator:
102 pubsub_elt[u"creator"] = C.BOOL_TRUE 102 pubsub_elt[u"creator"] = C.BOOL_TRUE
103 if element is not None: 103 if element is not None:
104 pubsub_elt.addChild(element) 104 pubsub_elt.addChild(element)
105 item_elt = pubsub.Item(payload=interest_elt)
106 yield self._p.publish(
107 client, client.jid.userhostJID(), NS_LIST_INTEREST, items=[item_elt]
108 )
109
110 @defer.inlineCallbacks
111 def registerFileSharing(
112 self, client, service, repos_type=None, namespace=None, path=None, name=None):
113 """Register an interesting file repository in personal list
114
115 @param service(jid.JID): service of the file repository
116 @param repos_type(unicode): type of the repository
117 @param namespace(unicode, None): namespace of the repository
118 @param path(unicode, None): path of the repository
119 @param name(unicode, None): name of the repository
120 """
121 yield self.createNode(client)
122 interest_elt = domish.Element((NS_LIST_INTEREST, u"interest"))
123 interest_elt[u"namespace"] = self.host.getNamespace(u"fis")
124 if name is not None:
125 interest_elt[u'name'] = name
126 file_sharing_elt = interest_elt.addElement(u"file_sharing")
127 file_sharing_elt[u"service"] = service.full()
128 if repos_type is not None:
129 file_sharing_elt[u"type"] = repos_type
130 if namespace is not None:
131 file_sharing_elt[u"namespace"] = namespace
132 if path is not None:
133 file_sharing_elt[u"path"] = path
105 item_elt = pubsub.Item(payload=interest_elt) 134 item_elt = pubsub.Item(payload=interest_elt)
106 yield self._p.publish( 135 yield self._p.publish(
107 client, client.jid.userhostJID(), NS_LIST_INTEREST, items=[item_elt] 136 client, client.jid.userhostJID(), NS_LIST_INTEREST, items=[item_elt]
108 ) 137 )
109 138