diff --git a/plugins/banner_tweaks/plugin.py b/plugins/banner_tweaks/plugin.py index a100cfe45..2e7faeb31 100644 --- a/plugins/banner_tweaks/plugin.py +++ b/plugins/banner_tweaks/plugin.py @@ -135,27 +135,17 @@ class BannerTweaksPlugin(GajimPlugin): if cs and st in ('composing_only', 'all'): if contact.show == 'offline': chatstate = '' - elif contact.composing_xep == 'XEP-0085': - if st == 'all' or cs == 'composing': - chatstate = helpers.get_uf_chatstate(cs) - else: - chatstate = '' - elif contact.composing_xep == 'XEP-0022': - if cs in ('composing', 'paused'): - # only print composing, paused - chatstate = helpers.get_uf_chatstate(cs) - else: - chatstate = '' - else: - # When does that happen ? See [7797] and [7804] + elif st == 'all' or cs == 'composing': chatstate = helpers.get_uf_chatstate(cs) + else: + chatstate = '' label_text = '%s%s %s' % \ - (font_attrs, name, font_attrs_small, acct_info, chatstate) + (font_attrs, name, font_attrs_small, acct_info, chatstate) else: # weight="heavy" size="x-large" label_text = '%s%s' % \ - (font_attrs, name, font_attrs_small, acct_info) + (font_attrs, name, font_attrs_small, acct_info) banner_name_label.set_markup(label_text) diff --git a/src/chat_control.py b/src/chat_control.py index 295574271..136a0a018 100644 --- a/src/chat_control.py +++ b/src/chat_control.py @@ -54,6 +54,7 @@ from common.pep import MOODS, ACTIVITIES from common.xmpp.protocol import NS_XHTML, NS_XHTML_IM, NS_FILE, NS_MUC from common.xmpp.protocol import NS_RECEIPTS, NS_ESESSION from common.xmpp.protocol import NS_JINGLE_RTP_AUDIO, NS_JINGLE_RTP_VIDEO, NS_JINGLE_ICE_UDP +from common.xmpp.protocol import NS_CHATSTATES from common.connection_handlers_events import MessageOutgoingEvent from command_system.implementation.middleware import ChatCommandProcessor @@ -850,8 +851,8 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): return label def send_message(self, message, keyID='', type_='chat', chatstate=None, - msg_id=None, composing_xep=None, resource=None, xhtml=None, callback=None, - callback_args=[], process_commands=True): + msg_id=None, resource=None, xhtml=None, callback=None, callback_args=[], + process_commands=True): """ Send the given message to the active tab. Doesn't return None if error """ @@ -866,9 +867,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools): gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, account=self.account, jid=self.contact.jid, message=message, keyID=keyID, type_=type_, chatstate=chatstate, msg_id=msg_id, - composing_xep=composing_xep, resource=resource, - user_nick=self.user_nick, xhtml=xhtml, label=label, - callback=callback, callback_args=callback_args, control=self)) + resource=resource, user_nick=self.user_nick, xhtml=xhtml, + label=label, callback=callback, callback_args=callback_args, + control=self)) # Record the history of sent messages self.save_message(message, 'sent') @@ -2037,24 +2038,13 @@ class ChatControl(ChatControlBase): if cs and st in ('composing_only', 'all'): if contact.show == 'offline': chatstate = '' - elif contact.composing_xep == 'XEP-0085': - if st == 'all' or cs == 'composing': - chatstate = helpers.get_uf_chatstate(cs) - else: - chatstate = '' - elif contact.composing_xep == 'XEP-0022': - if cs in ('composing', 'paused'): - # only print composing, paused - chatstate = helpers.get_uf_chatstate(cs) - else: - chatstate = '' - else: - # When does that happen ? See [7797] and [7804] + elif st == 'all' or cs == 'composing': chatstate = helpers.get_uf_chatstate(cs) + else: + chatstate = '' label_text = '%s%s %s' \ - % (font_attrs, name, font_attrs_small, - acct_info, chatstate) + % (font_attrs, name, font_attrs_small, acct_info, chatstate) if acct_info: acct_info = ' ' + acct_info label_tooltip = '%s%s %s' % (name, acct_info, chatstate) @@ -2210,7 +2200,7 @@ class ChatControl(ChatControlBase): dialogs.ESessionInfoWindow(self.session) def send_message(self, message, keyID='', chatstate=None, xhtml=None, - process_commands=True): + process_commands=True): """ Send a message to contact """ @@ -2234,25 +2224,9 @@ class ChatControl(ChatControlBase): chatstates_on = gajim.config.get('outgoing_chat_state_notifications') != \ 'disabled' - composing_xep = contact.composing_xep chatstate_to_send = None if chatstates_on and contact is not 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) - # because we want it sent with REAL message - # (not standlone) eg. one that has body - - if contact.our_chatstate: - # We already asked for xep 85, don't ask it twice - 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_xep is not False: + if contact.supports(NS_CHATSTATES): # send active chatstate on every message (as XEP says) chatstate_to_send = 'active' contact.our_chatstate = 'active' @@ -2275,10 +2249,9 @@ class ChatControl(ChatControlBase): xep0184_id=xep0184_id, xhtml=xhtml, displaymarking=displaymarking) ChatControlBase.send_message(self, message, keyID, type_='chat', - chatstate=chatstate_to_send, composing_xep=composing_xep, - xhtml=xhtml, callback=_on_sent, - callback_args=[contact, message, encrypted, xhtml, self.get_seclabel()], - process_commands=process_commands) + chatstate=chatstate_to_send, xhtml=xhtml, callback=_on_sent, + callback_args=[contact, message, encrypted, xhtml, + self.get_seclabel()], process_commands=process_commands) def on_message_sent(self, account_and_message): @@ -2598,7 +2571,7 @@ class ChatControl(ChatControlBase): if contact.show == 'offline': return - if contact.composing_xep is False: # jid cannot do xep85 nor xep22 + if not contact.supports(NS_CHATSTATES): return # if the new state we wanna send (state) equals @@ -2606,28 +2579,7 @@ class ChatControl(ChatControlBase): if contact.our_chatstate == state: return - 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 - # in self.send_message() because we need REAL message (with ) - # for that procedure so return to make sure we send only once - # 'active' until we know peer supports jep85 - return - - if contact.our_chatstate == 'ask': - return - - # in JEP22, when we already sent stop composing - # notification on paused, don't resend it - 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' - self.reset_kbd_mouse_timeout_vars() - return - - # if we're inactive prevent composing (JEP violation) + # if wel're inactive prevent composing (XEP violation) if contact.our_chatstate == 'inactive' and state == 'composing': # go active before gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, @@ -2638,11 +2590,10 @@ class ChatControl(ChatControlBase): gajim.nec.push_outgoing_event(MessageOutgoingEvent(None, account=self.account, jid=self.contact.jid, chatstate=state, - msg_id=contact.msg_id, composing_xep=contact.composing_xep, - control=self)) + msg_id=contact.msg_id, control=self)) contact.our_chatstate = state - if contact.our_chatstate == 'active': + if state == 'active': self.reset_kbd_mouse_timeout_vars() def shutdown(self): diff --git a/src/common/connection.py b/src/common/connection.py index edda989b6..d9998181b 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -248,9 +248,9 @@ class CommonConnection: raise NotImplementedError def _prepare_message(self, jid, msg, keyID, type_='chat', subject='', - chatstate=None, msg_id=None, composing_xep=None, resource=None, - user_nick=None, xhtml=None, session=None, forward_from=None, form_node=None, - label=None, original_message=None, delayed=None, callback=None): + chatstate=None, msg_id=None, resource=None, user_nick=None, xhtml=None, + session=None, forward_from=None, form_node=None, label=None, + original_message=None, delayed=None, callback=None): if not self.connection or self.connected < 2: return 1 try: @@ -299,35 +299,34 @@ class CommonConnection: self._message_encrypted_cb(output, type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, subject, chatstate, msg_id, - composing_xep, label, forward_from, delayed, - session, form_node, user_nick, keyID, - callback) + label, forward_from, delayed, session, + form_node, user_nick, keyID, callback) gajim.nec.push_incoming_event(GPGTrustKeyEvent(None, conn=self, callback=_on_always_trust)) else: self._message_encrypted_cb(output, type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, - subject, chatstate, msg_id, composing_xep, label, - forward_from, delayed, session, form_node, - user_nick, keyID, callback) + subject, chatstate, msg_id, label, forward_from, + delayed, session, form_node, user_nick, keyID, + callback) gajim.thread_interface(encrypt_thread, [msg, keyID, False], - _on_encrypted, []) + _on_encrypted, []) return self._message_encrypted_cb(('', error), type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, subject, - chatstate, msg_id, composing_xep, label, forward_from, delayed, - session, form_node, user_nick, keyID, callback) + chatstate, msg_id, label, forward_from, delayed, session, + form_node, user_nick, keyID, callback) self._on_continue_message(type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, subject, msgenc, keyID, chatstate, msg_id, - composing_xep, label, forward_from, delayed, session, form_node, - user_nick, callback) + label, forward_from, delayed, session, form_node, user_nick, + callback) def _message_encrypted_cb(self, output, type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, subject, chatstate, msg_id, - composing_xep, label, forward_from, delayed, session, form_node, user_nick, - keyID, callback): + label, forward_from, delayed, session, form_node, user_nick, keyID, + callback): msgenc, error = output if msgenc and not error: @@ -339,8 +338,8 @@ class CommonConnection: ' (' + msgtxt + ')' self._on_continue_message(type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, subject, msgenc, keyID, - chatstate, msg_id, composing_xep, label, forward_from, delayed, - session, form_node, user_nick, callback) + chatstate, msg_id, label, forward_from, delayed, session, + form_node, user_nick, callback) return # Encryption failed, do not send message tim = localtime() @@ -349,8 +348,7 @@ class CommonConnection: def _on_continue_message(self, type_, msg, msgtxt, original_message, fjid, resource, jid, xhtml, subject, msgenc, keyID, chatstate, msg_id, - composing_xep, label, forward_from, delayed, session, form_node, user_nick, - callback): + label, forward_from, delayed, session, form_node, user_nick, callback): if type_ == 'chat': msg_iq = common.xmpp.Message(to=fjid, body=msgtxt, typ=type_, xhtml=xhtml) @@ -386,27 +384,17 @@ class CommonConnection: contact = gajim.contacts.get_contact_with_highest_priority(self.name, jid) - # chatstates - if peer supports xep85 or xep22, send chatstates - # please note that the only valid tag inside a message containing a - # tag is the active event - if chatstate is not None and contact: - if ((composing_xep == 'XEP-0085' or not composing_xep) \ - and composing_xep != 'asked_once') or \ - contact.supports(common.xmpp.NS_CHATSTATES): - # XEP-0085 - msg_iq.setTag(chatstate, namespace=common.xmpp.NS_CHATSTATES) - 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 chatstate is 'composing' or msgtxt: - chatstate_node.addChild(name='composing') + # chatstates - if peer supports xep85, send chatstates + # please note that the only valid tag inside a message containing a + # tag is the active event + if chatstate and contact and contact.supports(NS_CHATSTATES): + msg_iq.setTag(chatstate, namespace=NS_CHATSTATES) if forward_from: addresses = msg_iq.addChild('addresses', - namespace=common.xmpp.NS_ADDRESS) + namespace=common.xmpp.NS_ADDRESS) addresses.addChild('address', attrs = {'type': 'ofrom', - 'jid': forward_from}) + 'jid': forward_from}) # XEP-0203 if delayed: @@ -433,7 +421,7 @@ class CommonConnection: if callback: callback(jid, msg, keyID, forward_from, session, original_message, - subject, type_, msg_iq, xhtml) + subject, type_, msg_iq, xhtml) def log_message(self, jid, msg, forward_from, session, original_message, subject, type_, xhtml=None): @@ -717,9 +705,9 @@ class Connection(CommonConnection, ConnectionHandlers): self.privacy_rules_requested = False self.streamError = '' self.secret_hmac = str(random.random())[2:] - - self.sm = Smacks(self) # Stream Management - + + self.sm = Smacks(self) # Stream Management + gajim.ged.register_event_handler('privacy-list-received', ged.CORE, self._nec_privacy_list_received) gajim.ged.register_event_handler('agent-info-error-received', ged.CORE, @@ -1791,10 +1779,10 @@ class Connection(CommonConnection, ConnectionHandlers): self.connection.send(msg_iq) def send_message(self, jid, msg, keyID=None, type_='chat', subject='', - chatstate=None, msg_id=None, composing_xep=None, resource=None, - user_nick=None, xhtml=None, label=None, session=None, forward_from=None, - form_node=None, original_message=None, delayed=None, callback=None, - callback_args=[], now=False): + chatstate=None, msg_id=None, resource=None, user_nick=None, xhtml=None, + label=None, session=None, forward_from=None, form_node=None, + original_message=None, delayed=None, callback=None, callback_args=[], + now=False): def cb(jid, msg, keyID, forward_from, session, original_message, subject, type_, msg_iq, xhtml): @@ -1809,9 +1797,9 @@ class Connection(CommonConnection, ConnectionHandlers): subject, type_, xhtml) self._prepare_message(jid, msg, keyID, type_=type_, subject=subject, - chatstate=chatstate, msg_id=msg_id, composing_xep=composing_xep, - resource=resource, user_nick=user_nick, xhtml=xhtml, label=label, - session=session, forward_from=forward_from, form_node=form_node, + chatstate=chatstate, msg_id=msg_id, resource=resource, + user_nick=user_nick, xhtml=xhtml, label=label, session=session, + forward_from=forward_from, form_node=form_node, original_message=original_message, delayed=delayed, callback=cb) def _nec_message_outgoing(self, obj): @@ -1834,9 +1822,8 @@ class Connection(CommonConnection, ConnectionHandlers): self._prepare_message(obj.jid, obj.message, obj.keyID, type_=obj.type_, subject=obj.subject, chatstate=obj.chatstate, msg_id=obj.msg_id, - composing_xep=obj.composing_xep, resource=obj.resource, - user_nick=obj.user_nick, xhtml=obj.xhtml, label=obj.label, - session=obj.session, forward_from=obj.forward_from, + resource=obj.resource, user_nick=obj.user_nick, xhtml=obj.xhtml, + label=obj.label, session=obj.session, forward_from=obj.forward_from, form_node=obj.form_node, original_message=obj.original_message, delayed=obj.delayed, callback=cb) diff --git a/src/common/connection_handlers.py b/src/common/connection_handlers.py index d44be1e30..482a2edae 100644 --- a/src/common/connection_handlers.py +++ b/src/common/connection_handlers.py @@ -907,8 +907,7 @@ class ConnectionHandlersBase: # reset chatstate if needed: # (when contact signs out or has errors) if obj.show in ('offline', 'error'): - obj.contact.our_chatstate = obj.contact.chatstate = \ - obj.contact.composing_xep = None + obj.contact.our_chatstate = obj.contact.chatstate = None # TODO: This causes problems when another # resource signs off! diff --git a/src/common/connection_handlers_events.py b/src/common/connection_handlers_events.py index 3e691b1b9..b7b8cb9d3 100644 --- a/src/common/connection_handlers_events.py +++ b/src/common/connection_handlers_events.py @@ -35,6 +35,7 @@ from common import exceptions from common.zeroconf import zeroconf from common.logger import LOG_DB_PATH from common.pep import SUPPORTED_PERSONAL_USER_EVENTS +from common.xmpp.protocol import NS_CHATSTATES import gtkgui_helpers @@ -74,28 +75,16 @@ class HelperEvent: Extract chatstate from a stanza Requires self.stanza and self.msgtxt """ - self.composing_xep = None self.chatstate = None # chatstates - look for chatstate tags in a message if not delayed delayed = self.stanza.getTag('x', namespace=xmpp.NS_DELAY) is not None if not delayed: - self.composing_xep = False children = self.stanza.getChildren() for child in children: - if child.getNamespace() == 'http://jabber.org/protocol/chatstates': + if child.getNamespace() == NS_CHATSTATES: self.chatstate = child.getName() - self.composing_xep = 'XEP-0085' break - # No XEP-0085 support, fallback to XEP-0022 - if not self.chatstate: - chatstate_child = self.stanza.getTag('x', - namespace=xmpp.NS_EVENT) - if chatstate_child: - self.chatstate = 'active' - self.composing_xep = 'XEP-0022' - if not self.msgtxt and chatstate_child.getTag('composing'): - self.chatstate = 'composing' class HttpAuthReceivedEvent(nec.NetworkIncomingEvent): name = 'http-auth-received' @@ -1170,7 +1159,6 @@ class ChatstateReceivedEvent(nec.NetworkIncomingEvent): self.jid = self.msg_obj.jid self.fjid = self.msg_obj.fjid self.resource = self.msg_obj.resource - self.composing_xep = self.msg_obj.composing_xep self.chatstate = self.msg_obj.chatstate return True @@ -2177,7 +2165,6 @@ class MessageOutgoingEvent(nec.NetworkIncomingEvent): self.subject = '' self.chatstate = None self.msg_id = None - self.composing_xep = None self.resource = None self.user_nick = None self.xhtml = None diff --git a/src/common/contacts.py b/src/common/contacts.py index e115ef46d..8ddce5b45 100644 --- a/src/common/contacts.py +++ b/src/common/contacts.py @@ -46,7 +46,7 @@ class XMPPEntity(object): class CommonContact(XMPPEntity): def __init__(self, jid, account, resource, show, status, name, - our_chatstate, composing_xep, chatstate, client_caps=None): + our_chatstate, chatstate, client_caps=None): XMPPEntity.__init__(self, jid, account, resource) @@ -57,17 +57,8 @@ class CommonContact(XMPPEntity): self.client_caps = client_caps or caps_cache.NullClientCaps() # please read xep-85 http://www.xmpp.org/extensions/xep-0085.html - # we keep track of xep85 support with the peer by three extra states: - # None, False and 'ask' - # None if no info about peer - # False if peer does not support xep85 - # 'ask' if we sent the first 'active' chatstate and are waiting for reply # this holds what WE SEND to contact (our current chatstate) self.our_chatstate = our_chatstate - # tell which XEP we're using for composing state - # None = have to ask, XEP-0022 = use this xep, - # XEP-0085 = use this xep, False = no composing support - self.composing_xep = composing_xep # this is contact's chatstate self.chatstate = chatstate @@ -97,12 +88,12 @@ class Contact(CommonContact): Information concerning a contact """ def __init__(self, jid, account, name='', groups=[], show='', status='', - sub='', ask='', resource='', priority=0, keyID='', client_caps=None, - our_chatstate=None, chatstate=None, last_status_time=None, msg_id= - None, composing_xep=None, last_activity_time=None): + sub='', ask='', resource='', priority=0, keyID='', client_caps=None, + our_chatstate=None, chatstate=None, last_status_time=None, msg_id=None, + last_activity_time=None): CommonContact.__init__(self, jid, account, resource, show, status, name, - our_chatstate, composing_xep, chatstate, client_caps=client_caps) + our_chatstate, chatstate, client_caps=client_caps) self.contact_name = '' # nick choosen by contact self.groups = [i for i in set(groups)] # filter duplicate values @@ -184,11 +175,11 @@ class GC_Contact(CommonContact): """ def __init__(self, room_jid, account, name='', show='', status='', role='', - affiliation='', jid='', resource='', our_chatstate=None, - composing_xep=None, chatstate=None): + affiliation='', jid='', resource='', our_chatstate=None, + chatstate=None): CommonContact.__init__(self, jid, account, resource, show, status, name, - our_chatstate, composing_xep, chatstate) + our_chatstate, chatstate) self.room_jid = room_jid self.role = role @@ -205,8 +196,8 @@ class GC_Contact(CommonContact): Create a Contact instance from this GC_Contact instance """ return Contact(jid=self.get_full_jid(), account=self.account, - name=self.name, groups=[], show=self.show, status=self.status, - sub='none', client_caps=self.client_caps) + name=self.name, groups=[], show=self.show, status=self.status, + sub='none', client_caps=self.client_caps) class LegacyContactsAPI: @@ -249,15 +240,15 @@ class LegacyContactsAPI: def create_contact(self, jid, account, name='', groups=[], show='', status='', sub='', ask='', resource='', priority=0, keyID='', client_caps=None, our_chatstate=None, chatstate=None, last_status_time=None, - composing_xep=None, last_activity_time=None): + last_activity_time=None): # Use Account object if available account = self._accounts.get(account, account) return Contact(jid=jid, account=account, name=name, groups=groups, - show=show, status=status, sub=sub, ask=ask, resource=resource, - priority=priority, keyID=keyID, client_caps=client_caps, - our_chatstate=our_chatstate, chatstate=chatstate, - last_status_time=last_status_time, composing_xep=composing_xep, - last_activity_time=last_activity_time) + show=show, status=status, sub=sub, ask=ask, resource=resource, + priority=priority, keyID=keyID, client_caps=client_caps, + our_chatstate=our_chatstate, chatstate=chatstate, + last_status_time=last_status_time, + last_activity_time=last_activity_time) def create_self_contact(self, jid, account, resource, show, status, priority, name='', keyID=''): @@ -266,27 +257,28 @@ class LegacyContactsAPI: account = self._accounts.get(account, account) # Use Account object if available self_contact = self.create_contact(jid=jid, account=account, name=nick, groups=['self_contact'], show=show, status=status, - sub='both', ask='none', priority=priority, keyID=keyID, + sub='both', ask='none', priority=priority, keyID=keyID, resource=resource) self_contact.pep = conn.pep return self_contact - def create_not_in_roster_contact(self, jid, account, resource='', name='', keyID=''): - account = self._accounts.get(account, account) # Use Account object if available + def create_not_in_roster_contact(self, jid, account, resource='', name='', + keyID=''): + # Use Account object if available + account = self._accounts.get(account, account) return self.create_contact(jid=jid, account=account, resource=resource, - name=name, groups=[_('Not in Roster')], show='not in roster', - status='', sub='none', keyID=keyID) + name=name, groups=[_('Not in Roster')], show='not in roster', + status='', sub='none', keyID=keyID) def copy_contact(self, contact): return self.create_contact(contact.jid, contact.account, - name=contact.name, groups=contact.groups, show=contact.show, - status=contact.status, sub=contact.sub, ask=contact.ask, - resource=contact.resource, priority=contact.priority, - keyID=contact.keyID, client_caps=contact.client_caps, - our_chatstate=contact.our_chatstate, chatstate=contact.chatstate, - last_status_time=contact.last_status_time, - composing_xep=contact.composing_xep, - last_activity_time=contact.last_activity_time) + name=contact.name, groups=contact.groups, show=contact.show, + status=contact.status, sub=contact.sub, ask=contact.ask, + resource=contact.resource, priority=contact.priority, + keyID=contact.keyID, client_caps=contact.client_caps, + our_chatstate=contact.our_chatstate, chatstate=contact.chatstate, + last_status_time=contact.last_status_time, + last_activity_time=contact.last_activity_time) def add_contact(self, account, contact): if account not in self._accounts: diff --git a/src/common/zeroconf/connection_zeroconf.py b/src/common/zeroconf/connection_zeroconf.py index cb5a780de..8c96ec23b 100644 --- a/src/common/zeroconf/connection_zeroconf.py +++ b/src/common/zeroconf/connection_zeroconf.py @@ -333,10 +333,10 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): msg=_('Please check if avahi-daemon is running.'))) def send_message(self, jid, msg, keyID, type_='chat', subject='', - chatstate=None, msg_id=None, composing_xep=None, resource=None, - user_nick=None, xhtml=None, label=None, session=None, forward_from=None, - form_node=None, original_message=None, delayed=None, callback=None, - callback_args=[], now=True): + chatstate=None, msg_id=None, resource=None, user_nick=None, xhtml=None, + label=None, session=None, forward_from=None, form_node=None, + original_message=None, delayed=None, callback=None, callback_args=[], + now=True): def on_send_ok(msg_id): gajim.nec.push_incoming_event(MessageSentEvent(None, conn=self, @@ -366,8 +366,8 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): msg=None, time_=None, session=session)) self._prepare_message(jid, msg, keyID, type_=type_, subject=subject, - chatstate=chatstate, msg_id=msg_id, composing_xep=composing_xep, - resource=resource, user_nick=user_nick, xhtml=xhtml, session=session, + chatstate=chatstate, msg_id=msg_id, resource=resource, + user_nick=user_nick, xhtml=xhtml, session=session, forward_from=forward_from, form_node=form_node, original_message=original_message, delayed=delayed, callback=cb) @@ -406,9 +406,8 @@ class ConnectionZeroconf(CommonConnection, ConnectionHandlersZeroconf): self._prepare_message(obj.jid, obj.message, obj.keyID, type_=obj.type_, subject=obj.subject, chatstate=obj.chatstate, msg_id=obj.msg_id, - composing_xep=obj.composing_xep, resource=obj.resource, - user_nick=obj.user_nick, xhtml=obj.xhtml, label=obj.label, - session=obj.session, forward_from=obj.forward_from, + resource=obj.resource, user_nick=obj.user_nick, xhtml=obj.xhtml, + label=obj.label, session=obj.session, forward_from=obj.forward_from, form_node=obj.form_node, original_message=obj.original_message, delayed=obj.delayed, callback=cb) diff --git a/src/gui_interface.py b/src/gui_interface.py index fdf0a5b22..f0f3fd73f 100644 --- a/src/gui_interface.py +++ b/src/gui_interface.py @@ -368,11 +368,6 @@ class Interface: jids = obj.fjid.split('/', 1) jid = jids[0] - if obj.error_code == '503': - # If we get server-not-found error, stop sending chatstates - for contact in gajim.contacts.get_contacts(account, jid): - contact.composing_xep = False - session = obj.session gc_control = self.msg_win_mgr.get_gc_control(jid, account) diff --git a/src/remote_control.py b/src/remote_control.py index f6cb2c408..584a4790d 100644 --- a/src/remote_control.py +++ b/src/remote_control.py @@ -138,8 +138,7 @@ class Remote: def on_chatstate_received(self, obj): self.raise_signal('ChatState', (obj.conn.name, [ - obj.jid, obj.fjid, obj.stanza, obj.resource, obj.composing_xep, - obj.chatstate])) + obj.jid, obj.fjid, obj.stanza, obj.resource, obj.chatstate])) def on_message_sent(self, obj): try: diff --git a/src/session.py b/src/session.py index 158bb974a..9f00b53e6 100644 --- a/src/session.py +++ b/src/session.py @@ -116,8 +116,6 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): contact = gajim.contacts.get_contact(self.conn.name, obj.jid, obj.resource) if contact: - if contact.composing_xep != 'XEP-0085': # We cache xep85 support - contact.composing_xep = obj.composing_xep if self.control and self.control.type_id == \ message_control.TYPE_CHAT: if obj.chatstate is not None: @@ -169,7 +167,7 @@ class ChatControlSession(stanza_session.EncryptedStanzaSession): gajim.interface.remote_ctrl.raise_signal('NewMessage', ( self.conn.name, [obj.fjid, obj.msgtxt, obj.timestamp, obj.encrypted, obj.mtype, obj.subject, obj.chatstate, msg_id, - obj.composing_xep, obj.user_nick, obj.xhtml, obj.form_node])) + obj.user_nick, obj.xhtml, obj.form_node])) def roster_message2(self, obj): """ diff --git a/test/unit/test_contacts.py b/test/unit/test_contacts.py index 957f54e42..e0a184312 100644 --- a/test/unit/test_contacts.py +++ b/test/unit/test_contacts.py @@ -15,8 +15,8 @@ class TestCommonContact(unittest.TestCase): def setUp(self): self.contact = CommonContact(jid='', account="", resource='', show='', - status='', name='', our_chatstate=None, composing_xep=None, - chatstate=None, client_caps=None) + status='', name='', our_chatstate=None, chatstate=None, + client_caps=None) def test_default_client_supports(self): ''' @@ -44,7 +44,7 @@ class TestContact(TestCommonContact): domain model by smoke testing that no attribute values are lost''' attributes = ["jid", "resource", "show", "status", "name", "our_chatstate", - "composing_xep", "chatstate", "client_caps", "priority", "sub"] + "chatstate", "client_caps", "priority", "sub"] for attr in attributes: self.assertTrue(hasattr(self.contact, attr), msg="expected: " + attr) @@ -60,7 +60,7 @@ class TestGC_Contact(TestCommonContact): domain model by asserting no attributes have been lost''' attributes = ["jid", "resource", "show", "status", "name", "our_chatstate", - "composing_xep", "chatstate", "client_caps", "role", "room_jid"] + "chatstate", "client_caps", "role", "room_jid"] for attr in attributes: self.assertTrue(hasattr(self.contact, attr), msg="expected: " + attr)