# HG changeset patch # User Goffi # Date 1527103696 -7200 # Node ID 60b63c3e63a1e29d1739c371d347b721975b0863 # Parent c7d15ef4bfa8babbff19461b94e731601f322fea plugin file sharing: use new EntitiesSelectorMenu to select entities which can access shared files diff -r c7d15ef4bfa8 -r 60b63c3e63a1 cagou/plugins/plugin_wid_file_sharing.py --- a/cagou/plugins/plugin_wid_file_sharing.py Wed May 23 21:27:28 2018 +0200 +++ b/cagou/plugins/plugin_wid_file_sharing.py Wed May 23 21:28:16 2018 +0200 @@ -27,6 +27,7 @@ from sat_frontends.tools import jid from cagou.core.constants import Const as C from cagou.core import cagou_widget +from cagou.core.menu import EntitiesSelectorMenu from cagou.core.utils import FilterBehavior from cagou import G from kivy import properties @@ -408,13 +409,17 @@ ## Share methods ## - def share(self, menu): - item = self.menu_item - self.clear_menu() + def do_share(self, entities_jids, item): + if entities_jids: + access = {u'read': {u'type': 'whitelist', + u'jids': entities_jids}} + else: + access = {} + G.host.bridge.FISSharePath( item.name, item.filepath, - json.dumps({}, ensure_ascii=False), + json.dumps(access, ensure_ascii=False), self.profile, callback=lambda name: G.host.addNote( _(u"sharing folder"), @@ -423,6 +428,12 @@ title=_(u"sharing folder"), message=_(u"can't share folder: {msg}"))) + def share(self, menu): + item = self.menu_item + self.clear_menu() + EntitiesSelectorMenu(instructions=SELECT_INSTRUCTIONS, + callback=partial(self.do_share, item=item)).show() + def unshare(self, menu): item = self.menu_item self.clear_menu()