From c92145c3b96934f968c160d1888c87ff6a052b27 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Sat, 16 Jun 2007 21:31:19 +0000 Subject: [PATCH] [misc] repare sending composing chatstates using xep instead of xep. Fix #3241. --- src/chat_control.py | 26 +++++++++---------- src/common/connection.py | 12 ++++----- src/common/contacts.py | 12 ++++----- .../zeroconf/connection_handlers_zeroconf.py | 12 ++++----- src/common/zeroconf/connection_zeroconf.py | 6 ++--- src/gajim.py | 10 +++---- src/message_control.py | 4 +-- 7 files changed, 41 insertions(+), 41 deletions(-) diff --git a/src/chat_control.py b/src/chat_control.py index e043029f0..b18e3b138 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -502,7 +502,7 @@ class ChatControlBase(MessageControl): return False def send_message(self, message, keyID = '', type = 'chat', chatstate = None, - msg_id = None, composing_jep = None, resource = None): + msg_id = None, composing_xep = None, resource = None): '''Send the given message to the active tab. Doesn't return None if error ''' if not message or message == '\n': @@ -512,7 +512,7 @@ class ChatControlBase(MessageControl): if not self._process_command(message): ret = MessageControl.send_message(self, message, keyID, type = type, chatstate = chatstate, msg_id = msg_id, - composing_jep = composing_jep, resource = resource, + composing_xep = composing_xep, resource = resource, user_nick = self.user_nick) if ret: return ret @@ -1117,12 +1117,12 @@ class ChatControl(ChatControlBase): if cs and st in ('composing_only', 'all'): if contact.show == 'offline': chatstate = '' - elif contact.composing_jep == 'JEP-0085': + elif contact.composing_xep == 'XEP-0085': if st == 'all' or cs == 'composing': chatstate = helpers.get_uf_chatstate(cs) else: chatstate = '' - elif contact.composing_jep == 'JEP-0022': + elif contact.composing_xep == 'XEP-0022': if cs in ('composing', 'paused'): # only print composing, paused chatstate = helpers.get_uf_chatstate(cs) @@ -1255,10 +1255,10 @@ class ChatControl(ChatControlBase): chatstates_on = gajim.config.get('outgoing_chat_state_notifications') != \ 'disabled' - composing_jep = contact.composing_jep + composing_xep = contact.composing_xep chatstate_to_send = None if chatstates_on and contact is not None: - if composing_jep is None: + if composing_xep is None: # no info about peer # send active to discover chat state capabilities # this is here (and not in send_chatstate) @@ -1267,13 +1267,13 @@ class ChatControl(ChatControlBase): if contact.our_chatstate: # We already asked for xep 85, don't ask it twice - composing_jep = 'asked_once' + composing_xep = 'asked_once' chatstate_to_send = 'active' contact.our_chatstate = 'ask' # pseudo state # if peer supports jep85 and we are not 'ask', send 'active' # NOTE: first active and 'ask' is set in gajim.py - elif composing_jep is not False: + elif composing_xep is not False: #send active chatstate on every message (as JEP says) chatstate_to_send = 'active' contact.our_chatstate = 'active' @@ -1283,7 +1283,7 @@ class ChatControl(ChatControlBase): self._schedule_activity_timers() if not ChatControlBase.send_message(self, message, keyID, type = 'chat', - chatstate = chatstate_to_send, composing_jep = composing_jep): + chatstate = chatstate_to_send, composing_xep = composing_xep): self.print_conversation(message, self.contact.jid, encrypted = encrypted) @@ -1579,7 +1579,7 @@ class ChatControl(ChatControlBase): if contact.show == 'offline': return - if contact.composing_jep is False: # jid cannot do jep85 nor jep22 + if contact.composing_xep is False: # jid cannot do xep85 nor xep22 return # if the new state we wanna send (state) equals @@ -1587,7 +1587,7 @@ class ChatControl(ChatControlBase): if contact.our_chatstate == state: return - if contact.composing_jep is None: + if contact.composing_xep is None: # we don't know anything about jid, so return # NOTE: # send 'active', set current state to 'ask' and return is done @@ -1601,7 +1601,7 @@ class ChatControl(ChatControlBase): # in JEP22, when we already sent stop composing # notification on paused, don't resend it - if contact.composing_jep == 'JEP-0022' and \ + if contact.composing_xep == 'XEP-0022' and \ contact.our_chatstate in ('paused', 'active', 'inactive') and \ state is not 'composing': # not composing == in (active, inactive, gone) contact.our_chatstate = 'active' @@ -1623,7 +1623,7 @@ class ChatControl(ChatControlBase): self.reset_kbd_mouse_timeout_vars() MessageControl.send_message(self, None, chatstate = state, - msg_id = contact.msg_id, composing_jep = contact.composing_jep) + msg_id = contact.msg_id, composing_xep = contact.composing_xep) contact.our_chatstate = state if contact.our_chatstate == 'active': self.reset_kbd_mouse_timeout_vars() diff --git a/src/common/connection.py b/src/common/connection.py index 3b9507238..4e44333d5 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -807,7 +807,7 @@ class Connection(ConnectionHandlers): self.connection.send(msg_iq) def send_message(self, jid, msg, keyID, type = 'chat', subject='', - chatstate = None, msg_id = None, composing_jep = None, resource = None, + chatstate = None, msg_id = None, composing_xep = None, resource = None, user_nick = None, xhtml = None): if not self.connection: return 1 @@ -861,12 +861,12 @@ class Connection(ConnectionHandlers): # please note that the only valid tag inside a message containing a # tag is the active event if chatstate is not None: - if (composing_jep == 'JEP-0085' or not composing_jep) and \ - composing_jep != 'asked_once': - # JEP-0085 + if (composing_xep == 'XEP-0085' or not composing_xep) and \ + composing_xep != 'asked_once': + # XEP-0085 msg_iq.setTag(chatstate, namespace = common.xmpp.NS_CHATSTATES) - if composing_jep in ('JEP-0022', 'asked_once') or not composing_jep: - # JEP-0022 + if composing_xep in ('XEP-0022', 'asked_once') or not composing_xep: + # XEP-0022 chatstate_node = msg_iq.setTag('x', namespace = common.xmpp.NS_EVENT) if not msgtxt: # when no , add diff --git a/src/common/contacts.py b/src/common/contacts.py index b309981d4..06f8e2eca 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -20,7 +20,7 @@ class Contact: '''Information concerning each contact''' def __init__(self, jid='', name='', groups=[], show='', status='', sub='', ask='', resource='', priority=0, keyID='', our_chatstate=None, - chatstate=None, last_status_time=None, msg_id = None, composing_jep = None): + chatstate=None, last_status_time=None, msg_id = None, composing_xep = None): self.jid = jid self.name = name self.contact_name = '' # nick choosen by contact @@ -43,9 +43,9 @@ class Contact: self.our_chatstate = our_chatstate self.msg_id = msg_id # tell which JEP we're using for composing state - # None = have to ask, JEP-0022 = use this jep, - # JEP-0085 = use this jep, False = no composing support - self.composing_jep = composing_jep + # None = have to ask, XEP-0022 = use this jep, + # XEP-0085 = use this jep, False = no composing support + self.composing_xep = composing_xep # this is contact's chatstate self.chatstate = chatstate self.last_status_time = last_status_time @@ -149,10 +149,10 @@ class Contacts: def create_contact(self, jid='', name='', groups=[], show='', status='', sub='', ask='', resource='', priority=0, keyID='', our_chatstate=None, - chatstate=None, last_status_time=None, composing_jep=None): + chatstate=None, last_status_time=None, composing_xep=None): return Contact(jid, name, groups, show, status, sub, ask, resource, priority, keyID, our_chatstate, chatstate, last_status_time, - composing_jep) + composing_xep) def copy_contact(self, contact): return self.create_contact(jid = contact.jid, name = contact.name, diff --git a/src/common/zeroconf/connection_handlers_zeroconf.py b/src/common/zeroconf/connection_handlers_zeroconf.py index 2d36d4661..165b318d4 100644 --- a/src/common/zeroconf/connection_handlers_zeroconf.py +++ b/src/common/zeroconf/connection_handlers_zeroconf.py @@ -663,23 +663,23 @@ class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionBytestream): invite = None delayed = msg.getTag('x', namespace = common.xmpp.NS_DELAY) != None msg_id = None - composing_jep = None + composing_xep = None xtags = msg.getTags('x') # chatstates - look for chatstate tags in a message if not delayed if not delayed: - composing_jep = False + composing_xep = False children = msg.getChildren() for child in children: if child.getNamespace() == 'http://jabber.org/protocol/chatstates': chatstate = child.getName() - composing_jep = 'JEP-0085' + composing_xep = 'XEP-0085' break # No JEP-0085 support, fallback to JEP-0022 if not chatstate: chatstate_child = msg.getTag('x', namespace = common.xmpp.NS_EVENT) if chatstate_child: chatstate = 'active' - composing_jep = 'JEP-0022' + composing_xep = 'XEP-0022' if not msgtxt and chatstate_child.getTag('composing'): chatstate = 'composing' # JEP-0172 User Nickname @@ -715,14 +715,14 @@ class ConnectionHandlersZeroconf(ConnectionVcard, ConnectionBytestream): msg_id = gajim.logger.write('chat_msg_recv', frm, msgtxt, tim = tim, subject = subject) self.dispatch('MSG', (frm, msgtxt, tim, encrypted, mtype, subject, - chatstate, msg_id, composing_jep, user_nick, msghtml)) + chatstate, msg_id, composing_xep, user_nick, msghtml)) elif mtype == 'normal': # it's single message if self.name not in no_log_for and jid not in no_log_for and msgtxt: gajim.logger.write('single_msg_recv', frm, msgtxt, tim = tim, subject = subject) if invite: self.dispatch('MSG', (frm, msgtxt, tim, encrypted, 'normal', - subject, chatstate, msg_id, composing_jep, user_nick)) + subject, chatstate, msg_id, composing_xep, user_nick)) # END messageCB def parse_data_form(self, node): diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index 29d40226c..68932238e 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -348,7 +348,7 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): return STATUS_LIST[self.connected] def send_message(self, jid, msg, keyID, type = 'chat', subject='', - chatstate = None, msg_id = None, composing_jep = None, resource = None, + chatstate = None, msg_id = None, composing_xep = None, resource = None, user_nick = None): fjid = jid @@ -396,10 +396,10 @@ class ConnectionZeroconf(ConnectionHandlersZeroconf): # please note that the only valid tag inside a message containing a # tag is the active event if chatstate is not None: - if composing_jep == 'JEP-0085' or not composing_jep: + if composing_xep == 'XEP-0085' or not composing_xep: # JEP-0085 msg_iq.setTag(chatstate, namespace = common.xmpp.NS_CHATSTATES) - if composing_jep == 'JEP-0022' or not composing_jep: + if composing_xep == 'XEP-0022' or not composing_xep: # JEP-0022 chatstate_node = msg_iq.setTag('x', namespace = common.xmpp.NS_EVENT) if not msgtxt: # when no , add diff --git a/src/gajim.py b/src/gajim.py index 284f9aca5..054d09f5b 100755 --- a/src/gajim.py +++ b/src/gajim.py @@ -641,7 +641,7 @@ class Interface: # (when contact signs out or has errors) if array[1] in ('offline', 'error'): contact1.our_chatstate = contact1.chatstate = \ - contact1.composing_jep = None + contact1.composing_xep = None gajim.connections[account].remove_transfers_for_contact(contact1) self.roster.chg_contact_status(contact1, array[1], status_message, account) @@ -670,7 +670,7 @@ class Interface: def handle_event_msg(self, account, array): # 'MSG' (account, (jid, msg, time, encrypted, msg_type, subject, - # chatstate, msg_id, composing_jep, user_nick, xhtml)) + # chatstate, msg_id, composing_xep, user_nick, xhtml)) # user_nick is JEP-0172 full_jid_with_resource = array[0] @@ -683,7 +683,7 @@ class Interface: subject = array[5] chatstate = array[6] msg_id = array[7] - composing_jep = array[8] + composing_xep = array[8] xhtml = array[10] if gajim.config.get('ignore_incoming_xhtml'): xhtml = None @@ -727,8 +727,8 @@ class Interface: if contact and isinstance(contact, list): contact = contact[0] if contact: - if contact.composing_jep != 'JEP-0085': # We cache xep85 support - contact.composing_jep = composing_jep + if contact.composing_xep != 'XEP-0085': # We cache xep85 support + contact.composing_xep = composing_xep if chat_control and chat_control.type_id == message_control.TYPE_CHAT: if chatstate is not None: # other peer sent us reply, so he supports jep85 or jep22 diff --git a/src/message_control.py b/src/message_control.py index d67e52f70..38b44cb58 100644 --- a/src/message_control.py +++ b/src/message_control.py @@ -111,7 +111,7 @@ class MessageControl: return len(gajim.events.get_events(self.account, self.contact.jid)) def send_message(self, message, keyID = '', type = 'chat', - chatstate = None, msg_id = None, composing_jep = None, resource = None, + chatstate = None, msg_id = None, composing_xep = None, resource = None, user_nick = None): '''Send the given message to the active tab. Doesn't return None if error ''' @@ -119,5 +119,5 @@ class MessageControl: # Send and update history return gajim.connections[self.account].send_message(jid, message, keyID, type = type, chatstate = chatstate, msg_id = msg_id, - composing_jep = composing_jep, resource = self.resource, + composing_xep = composing_xep, resource = self.resource, user_nick = user_nick)