comparison src/plugins/plugin_xep_0060.py @ 916:1a759096ccbd

core: use of Const for profile_key + replaced '@DEFAULT@' default profile_key by '@NONE@'
author Goffi <goffi@goffi.org>
date Fri, 21 Mar 2014 16:27:09 +0100
parents a7b2aacf22ac
children 301b342c697a
comparison
equal deleted inserted replaced
915:6f96ee4d8cc0 916:1a759096ccbd
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. 18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 19
20 from sat.core.i18n import _ 20 from sat.core.i18n import _
21 from sat.core.constants import Const as C
21 from logging import debug, info, error 22 from logging import debug, info, error
22 from wokkel.pubsub import PubSubRequest 23 from wokkel.pubsub import PubSubRequest
23 from wokkel import disco, pubsub 24 from wokkel import disco, pubsub
24 from zope.interface import implements 25 from zope.interface import implements
25 26
93 err_mess = _('INTERNAL ERROR: no handler for required profile') 94 err_mess = _('INTERNAL ERROR: no handler for required profile')
94 error(err_mess) 95 error(err_mess)
95 raise Exception(err_mess) 96 raise Exception(err_mess)
96 return profile, client 97 return profile, client
97 98
98 def publish(self, service, nodeIdentifier, items=None, profile_key='@DEFAULT@'): 99 def publish(self, service, nodeIdentifier, items=None, profile_key=C.PROF_KEY_NONE):
99 profile, client = self.__getClientNProfile(profile_key, 'publish item') 100 profile, client = self.__getClientNProfile(profile_key, 'publish item')
100 return client.publish(service, nodeIdentifier, items, client.parent.jid) 101 return client.publish(service, nodeIdentifier, items, client.parent.jid)
101 102
102 def getItems(self, service, node, max_items=None, item_ids=None, sub_id=None, profile_key='@DEFAULT@'): 103 def getItems(self, service, node, max_items=None, item_ids=None, sub_id=None, profile_key=C.PROF_KEY_NONE):
103 profile, client = self.__getClientNProfile(profile_key, 'get items') 104 profile, client = self.__getClientNProfile(profile_key, 'get items')
104 return client.items(service, node, max_items, item_ids, sub_id, client.parent.jid) 105 return client.items(service, node, max_items, item_ids, sub_id, client.parent.jid)
105 106
106 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key='@DEFAULT@'): 107 def getOptions(self, service, nodeIdentifier, subscriber, subscriptionIdentifier=None, profile_key=C.PROF_KEY_NONE):
107 profile, client = self.__getClientNProfile(profile_key, 'get options') 108 profile, client = self.__getClientNProfile(profile_key, 'get options')
108 return client.getOptions(service, nodeIdentifier, subscriber, subscriptionIdentifier) 109 return client.getOptions(service, nodeIdentifier, subscriber, subscriptionIdentifier)
109 110
110 def setOptions(self, service, nodeIdentifier, subscriber, options, subscriptionIdentifier=None, profile_key='@DEFAULT@'): 111 def setOptions(self, service, nodeIdentifier, subscriber, options, subscriptionIdentifier=None, profile_key=C.PROF_KEY_NONE):
111 profile, client = self.__getClientNProfile(profile_key, 'set options') 112 profile, client = self.__getClientNProfile(profile_key, 'set options')
112 return client.setOptions(service, nodeIdentifier, subscriber, options, subscriptionIdentifier) 113 return client.setOptions(service, nodeIdentifier, subscriber, options, subscriptionIdentifier)
113 114
114 def createNode(self, service, nodeIdentifier, options, profile_key='@DEFAULT@'): 115 def createNode(self, service, nodeIdentifier, options, profile_key=C.PROF_KEY_NONE):
115 profile, client = self.__getClientNProfile(profile_key, 'create node') 116 profile, client = self.__getClientNProfile(profile_key, 'create node')
116 return client.createNode(service, nodeIdentifier, options) 117 return client.createNode(service, nodeIdentifier, options)
117 118
118 def deleteNode(self, service, nodeIdentifier, profile_key='@DEFAULT@'): 119 def deleteNode(self, service, nodeIdentifier, profile_key=C.PROF_KEY_NONE):
119 profile, client = self.__getClientNProfile(profile_key, 'delete node') 120 profile, client = self.__getClientNProfile(profile_key, 'delete node')
120 return client.deleteNode(service, nodeIdentifier) 121 return client.deleteNode(service, nodeIdentifier)
121 122
122 def retractItems(self, service, nodeIdentifier, itemIdentifiers, profile_key='@DEFAULT@'): 123 def retractItems(self, service, nodeIdentifier, itemIdentifiers, profile_key=C.PROF_KEY_NONE):
123 profile, client = self.__getClientNProfile(profile_key, 'retract items') 124 profile, client = self.__getClientNProfile(profile_key, 'retract items')
124 return client.retractItems(service, nodeIdentifier, itemIdentifiers) 125 return client.retractItems(service, nodeIdentifier, itemIdentifiers)
125 126
126 def subscribe(self, service, nodeIdentifier, sub_jid=None, options=None, profile_key='@DEFAULT@'): 127 def subscribe(self, service, nodeIdentifier, sub_jid=None, options=None, profile_key=C.PROF_KEY_NONE):
127 profile, client = self.__getClientNProfile(profile_key, 'subscribe node') 128 profile, client = self.__getClientNProfile(profile_key, 'subscribe node')
128 return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options) 129 return client.subscribe(service, nodeIdentifier, sub_jid or client.parent.jid.userhostJID(), options=options)
129 130
130 131
131 class SatPubSubClient(pubsub.PubSubClient): 132 class SatPubSubClient(pubsub.PubSubClient):