comparison src/plugins/plugin_xep_0085.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 2ef523f0b5c3
children c897c8d321b3
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 sat.core import exceptions 22 from sat.core import exceptions
22 from logging import info 23 from logging import info
23 from wokkel import disco, iwokkel 24 from wokkel import disco, iwokkel
24 from zope.interface import implements 25 from zope.interface import implements
25 from twisted.words.protocols.jabber.jid import JID 26 from twisted.words.protocols.jabber.jid import JID
115 def updateEntityData(self, entity_jid, value, profile): 116 def updateEntityData(self, entity_jid, value, profile):
116 """ 117 """
117 Update the entity data of the given profile for one or all contacts. 118 Update the entity data of the given profile for one or all contacts.
118 Reset the chat state(s) display if the notification has been disabled. 119 Reset the chat state(s) display if the notification has been disabled.
119 @param entity_jid: contact's JID, or '@ALL@' to update all contacts. 120 @param entity_jid: contact's JID, or '@ALL@' to update all contacts.
120 @param value: True, False or '@NONE@' to delete the entity data 121 @param value: True, False or C.PROF_KEY_NONE to delete the entity data
121 @param profile: current profile 122 @param profile: current profile
122 """ 123 """
123 self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile) 124 self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile)
124 if not value or value == "@NONE@": 125 if not value or value == C.PROF_KEY_NONE:
125 # disable chat state for this or these contact(s) 126 # disable chat state for this or these contact(s)
126 self.host.bridge.chatStateReceived(unicode(entity_jid), "", profile) 127 self.host.bridge.chatStateReceived(unicode(entity_jid), "", profile)
127 128
128 def paramUpdateTrigger(self, name, value, category, type, profile): 129 def paramUpdateTrigger(self, name, value, category, type, profile):
129 """ 130 """
131 @param name: parameter name 132 @param name: parameter name
132 @param value: "true" to activate the notifications, or any other value to delete it 133 @param value: "true" to activate the notifications, or any other value to delete it
133 @param category: parameter category 134 @param category: parameter category
134 """ 135 """
135 if (category, name) == (PARAM_KEY, PARAM_NAME): 136 if (category, name) == (PARAM_KEY, PARAM_NAME):
136 self.updateEntityData("@ALL@", True if value == "true" else "@NONE@", profile) 137 self.updateEntityData("@ALL@", True if value == "true" else C.PROF_KEY_NONE, profile)
137 return False 138 return False
138 return True 139 return True
139 140
140 def messageReceivedTrigger(self, message, post_treat, profile): 141 def messageReceivedTrigger(self, message, post_treat, profile):
141 """ 142 """