comparison src/core/sat_main.py @ 2443:81a45e7886c9

core: added a mechanism to associate short names to namespaces: - new internal registerNamespace can be used by a plugin to associate a short name to a namespace - new NamespacesGet bridge method retrieve those associations
author Goffi <goffi@goffi.org>
date Sun, 19 Nov 2017 16:46:07 +0100
parents a9fac72825a2
children 0199c0bd4c60
comparison
equal deleted inserted replaced
2442:b8ffb7f8056b 2443:81a45e7886c9
53 self._menus = OrderedDict() # dynamic menus. key: callback_id, value: menu data (dictionnary) 53 self._menus = OrderedDict() # dynamic menus. key: callback_id, value: menu data (dictionnary)
54 self._menus_paths = {} # path to id. key: (menu_type, lower case tuple of path), value: menu id 54 self._menus_paths = {} # path to id. key: (menu_type, lower case tuple of path), value: menu id
55 self.initialised = defer.Deferred() 55 self.initialised = defer.Deferred()
56 self.profiles = {} 56 self.profiles = {}
57 self.plugins = {} 57 self.plugins = {}
58 self._ns_map = {} # map for short name to whole namespace
58 59
59 self.memory = Memory(self) 60 self.memory = Memory(self)
60 self.trigger = trigger.TriggerManager() # trigger are used to change SàT behaviour 61 self.trigger = trigger.TriggerManager() # trigger are used to change SàT behaviour
61 62
62 bridge_name = self.memory.getConfig('', 'bridge', 'dbus') 63 bridge_name = self.memory.getConfig('', 'bridge', 'dbus')
116 self.bridge.register_method("discoInfos", self.memory.disco._discoInfos) 117 self.bridge.register_method("discoInfos", self.memory.disco._discoInfos)
117 self.bridge.register_method("discoItems", self.memory.disco._discoItems) 118 self.bridge.register_method("discoItems", self.memory.disco._discoItems)
118 self.bridge.register_method("saveParamsTemplate", self.memory.save_xml) 119 self.bridge.register_method("saveParamsTemplate", self.memory.save_xml)
119 self.bridge.register_method("loadParamsTemplate", self.memory.load_xml) 120 self.bridge.register_method("loadParamsTemplate", self.memory.load_xml)
120 self.bridge.register_method("sessionInfosGet", self.getSessionInfos) 121 self.bridge.register_method("sessionInfosGet", self.getSessionInfos)
122 self.bridge.register_method("namespacesGet", self.getNamespaces)
121 123
122 self.memory.initialized.addCallback(self._postMemoryInit) 124 self.memory.initialized.addCallback(self._postMemoryInit)
123 125
124 @property 126 @property
125 def version(self): 127 def version(self):
953 languageSwitch(language) 955 languageSwitch(language)
954 help_string = _(menu_data['help_string']) 956 help_string = _(menu_data['help_string'])
955 languageSwitch() 957 languageSwitch()
956 return help_string 958 return help_string
957 959
960 # misc methods
961
962 def registerNamespace(self, short_name, namespace):
963 """associate a namespace to a short name"""
964 if short_name in self._ns_map:
965 raise exceptions.ConflictError(u'this short name is already used')
966 self._ns_map[short_name] = namespace
967
968 def getNamespaces(self):
969 return self._ns_map
970
958 def getSessionInfos(self, profile_key): 971 def getSessionInfos(self, profile_key):
959 """compile interesting data on current profile session""" 972 """compile interesting data on current profile session"""
960 client = self.getClient(profile_key) 973 client = self.getClient(profile_key)
961 data = { 974 data = {
962 "jid": client.jid.full(), 975 "jid": client.jid.full(),