Mercurial > libervia-backend
comparison src/plugins/plugin_xep_0085.py @ 643:262d9d9ad27a
plugin XEP-0085: renamed category and parameter
author | souliane <souliane@mailoo.org> |
---|---|
date | Sat, 07 Sep 2013 19:50:12 +0200 |
parents | 7ea6d5a86e58 |
children | 5c5cf5bca240 |
comparison
equal
deleted
inserted
replaced
642:e07a03d52321 | 643:262d9d9ad27a |
---|---|
31 | 31 |
32 NS_XMPP_CLIENT = "jabber:client" | 32 NS_XMPP_CLIENT = "jabber:client" |
33 NS_CHAT_STATES = "http://jabber.org/protocol/chatstates" | 33 NS_CHAT_STATES = "http://jabber.org/protocol/chatstates" |
34 CHAT_STATES = ["active", "inactive", "gone", "composing", "paused"] | 34 CHAT_STATES = ["active", "inactive", "gone", "composing", "paused"] |
35 MESSAGE_TYPES = ["chat", "groupchat"] | 35 MESSAGE_TYPES = ["chat", "groupchat"] |
36 PARAM_KEY = "Chat State Notifications" | 36 PARAM_KEY = "Notifications" |
37 PARAM_NAME = "Enabled" | 37 PARAM_NAME = "Enable chat state notifications" |
38 ENTITY_KEY = PARAM_KEY + "_" + PARAM_NAME | |
38 | 39 |
39 PLUGIN_INFO = { | 40 PLUGIN_INFO = { |
40 "name": "Chat State Notifications Protocol Plugin", | 41 "name": "Chat State Notifications Protocol Plugin", |
41 "import_name": "XEP-0085", | 42 "import_name": "XEP-0085", |
42 "type": "XEP", | 43 "type": "XEP", |
114 """ | 115 """ |
115 Update the entity data and reset the chat state display | 116 Update the entity data and reset the chat state display |
116 if the notification has been disabled. Parameter "entity_jid" | 117 if the notification has been disabled. Parameter "entity_jid" |
117 could be @ALL@ to update all entities. | 118 could be @ALL@ to update all entities. |
118 """ | 119 """ |
119 self.host.memory.updateEntityData(entity_jid, PARAM_KEY, value, profile) | 120 self.host.memory.updateEntityData(entity_jid, ENTITY_KEY, value, profile) |
120 if not value or value == "@NONE@": | 121 if not value or value == "@NONE@": |
121 # disable chat state for this or these contact(s) | 122 # disable chat state for this or these contact(s) |
122 self.host.bridge.chatStateReceived(unicode(entity_jid), "", profile) | 123 self.host.bridge.chatStateReceived(unicode(entity_jid), "", profile) |
123 | 124 |
124 def paramUpdateTrigger(self, name, value, category, type, profile): | 125 def paramUpdateTrigger(self, name, value, category, type, profile): |
175 # check if notifications should be sent to this contact | 176 # check if notifications should be sent to this contact |
176 contact_enabled = True | 177 contact_enabled = True |
177 to_jid = JID(message.getAttribute("to")) | 178 to_jid = JID(message.getAttribute("to")) |
178 try: | 179 try: |
179 contact_enabled = self.host.memory.getEntityData( | 180 contact_enabled = self.host.memory.getEntityData( |
180 to_jid, [PARAM_KEY], profile)[PARAM_KEY] | 181 to_jid, [ENTITY_KEY], profile)[ENTITY_KEY] |
181 except (exceptions.UnknownEntityError, KeyError): | 182 except (exceptions.UnknownEntityError, KeyError): |
182 # enable it for the first time | 183 # enable it for the first time |
183 self.updateEntityData(to_jid, True, profile) | 184 self.updateEntityData(to_jid, True, profile) |
184 if not contact_enabled: | 185 if not contact_enabled: |
185 return True | 186 return True |
234 if profile is None: | 235 if profile is None: |
235 raise exceptions.ProfileUnknownError | 236 raise exceptions.ProfileUnknownError |
236 try: | 237 try: |
237 self.map[profile][to_jid]._onEvent("composing") | 238 self.map[profile][to_jid]._onEvent("composing") |
238 except: | 239 except: |
240 # it just means that no first message has been sent already | |
239 return | 241 return |
240 | 242 |
241 | 243 |
242 class ChatStateMachine: | 244 class ChatStateMachine: |
243 """ | 245 """ |