Philipp Hörist pushed to branch master at gajim / gajim

Commits:

8 changed files:

Changes:

  • src/chat_control.py
    ... ... @@ -978,11 +978,11 @@ class ChatControl(ChatControlBase):
    978 978
     
    
    979 979
             def _on_sent(obj, msg_stanza, message, encrypted, xhtml, label):
    
    980 980
                 id_ = msg_stanza.getID()
    
    981
    -            if self.contact.supports(NS_RECEIPTS) and gajim.config.get_per(
    
    982
    -            'accounts', self.account, 'request_receipt'):
    
    983
    -                xep0184_id = id_
    
    984
    -            else:
    
    985
    -                xep0184_id = None
    
    981
    +            xep0184_id = None
    
    982
    +            if self.contact.jid != gajim.get_jid_from_account(self.account):
    
    983
    +                if self.contact.supports(NS_RECEIPTS) and gajim.config.get_per(
    
    984
    +                'accounts', self.account, 'request_receipt'):
    
    985
    +                    xep0184_id = id_
    
    986 986
                 if label:
    
    987 987
                     displaymarking = label.getTag('displaymarking')
    
    988 988
                 else:
    
    ... ... @@ -1233,6 +1233,9 @@ class ChatControl(ChatControlBase):
    1233 1233
             if contact and contact.sub in ('to', 'none'):
    
    1234 1234
                 return
    
    1235 1235
     
    
    1236
    +        if self.contact.jid == gajim.get_jid_from_account(self.account):
    
    1237
    +            return
    
    1238
    +
    
    1236 1239
             elif chatstate_setting == 'composing_only' and state != 'active' and\
    
    1237 1240
                     state != 'composing':
    
    1238 1241
                 return
    

  • src/chat_control_base.py
    ... ... @@ -701,7 +701,9 @@ class ChatControlBase(MessageControl, ChatCommandProcessor, CommandTools):
    701 701
             # refresh timers
    
    702 702
             self.reset_kbd_mouse_timeout_vars()
    
    703 703
     
    
    704
    -        if gajim.config.get('outgoing_chat_state_notifications') == 'disabled':
    
    704
    +        notifications = gajim.config.get('outgoing_chat_state_notifications')
    
    705
    +        if (self.contact.jid == gajim.get_jid_from_account(self.account) or
    
    706
    +                notifications == 'disabled'):
    
    705 707
                 chatstate = None
    
    706 708
     
    
    707 709
             label = self.get_seclabel()
    

  • src/common/connection.py
    ... ... @@ -355,7 +355,10 @@ class CommonConnection:
    355 355
             else:
    
    356 356
                 msgtxt = obj.message
    
    357 357
     
    
    358
    -        fjid = obj.get_full_jid()
    
    358
    +        if obj.jid == gajim.get_jid_from_account(self.name):
    
    359
    +            fjid = obj.jid
    
    360
    +        else:
    
    361
    +            fjid = obj.get_full_jid()
    
    359 362
     
    
    360 363
             if obj.correction_msg:
    
    361 364
                 id_ = obj.correction_msg.getID()
    
    ... ... @@ -464,10 +467,11 @@ class CommonConnection:
    464 467
                                       namespace=nbxmpp.NS_MSG_HINTS)
    
    465 468
     
    
    466 469
                 # XEP-0184
    
    467
    -            if msgtxt and gajim.config.get_per('accounts', self.name,
    
    468
    -            'request_receipt') and contact and contact.supports(
    
    469
    -            nbxmpp.NS_RECEIPTS):
    
    470
    -                msg_iq.setTag('request', namespace=nbxmpp.NS_RECEIPTS)
    
    470
    +            if obj.jid != gajim.get_jid_from_account(self.name):
    
    471
    +                if msgtxt and gajim.config.get_per('accounts', self.name,
    
    472
    +                'request_receipt') and contact and contact.supports(
    
    473
    +                nbxmpp.NS_RECEIPTS):
    
    474
    +                    msg_iq.setTag('request', namespace=nbxmpp.NS_RECEIPTS)
    
    471 475
     
    
    472 476
                 if obj.forward_from:
    
    473 477
                     addresses = msg_iq.addChild('addresses',
    

  • src/common/connection_handlers.py
    ... ... @@ -1174,17 +1174,19 @@ class ConnectionHandlersBase:
    1174 1174
                 jid_to = gajim.get_jid_without_resource(fjid_to)
    
    1175 1175
                 if jid_to == gajim.get_jid_from_account(self.name):
    
    1176 1176
                     reply = True
    
    1177
    -        if obj.receipt_request_tag and gajim.config.get_per('accounts',
    
    1178
    -        self.name, 'answer_receipts') and ((contact and contact.sub \
    
    1179
    -        not in ('to', 'none')) or gc_contact) and obj.mtype != 'error' and \
    
    1180
    -        reply:
    
    1181
    -            receipt = nbxmpp.Message(to=obj.fjid, typ='chat')
    
    1182
    -            receipt.setTag('received', namespace='urn:xmpp:receipts',
    
    1183
    -                attrs={'id': obj.id_})
    
    1184
    -
    
    1185
    -            if obj.thread_id:
    
    1186
    -                receipt.setThread(obj.thread_id)
    
    1187
    -            self.connection.send(receipt)
    
    1177
    +
    
    1178
    +        if obj.jid != gajim.get_jid_from_account(self.name):
    
    1179
    +            if obj.receipt_request_tag and gajim.config.get_per('accounts',
    
    1180
    +            self.name, 'answer_receipts') and ((contact and contact.sub \
    
    1181
    +            not in ('to', 'none')) or gc_contact) and obj.mtype != 'error' and \
    
    1182
    +            reply:
    
    1183
    +                receipt = nbxmpp.Message(to=obj.fjid, typ='chat')
    
    1184
    +                receipt.setTag('received', namespace='urn:xmpp:receipts',
    
    1185
    +                    attrs={'id': obj.id_})
    
    1186
    +
    
    1187
    +                if obj.thread_id:
    
    1188
    +                    receipt.setThread(obj.thread_id)
    
    1189
    +                self.connection.send(receipt)
    
    1188 1190
     
    
    1189 1191
             # We got our message's receipt
    
    1190 1192
             if obj.receipt_received_tag and gajim.config.get_per('accounts',
    

  • src/common/connection_handlers_events.py
    ... ... @@ -1124,6 +1124,15 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
    1124 1124
             self.sent = False
    
    1125 1125
             account = self.conn.name
    
    1126 1126
     
    
    1127
    +        our_full_jid = gajim.get_jid_from_account(account, full=True)
    
    1128
    +        if self.stanza.getFrom() == our_full_jid:
    
    1129
    +            # Drop messages sent from our own full jid
    
    1130
    +            # It can happen that when we sent message to our own bare jid
    
    1131
    +            # that the server routes that message back to us
    
    1132
    +            log.info('Received message from self: %s, message is dropped'
    
    1133
    +                     % self.stanza.getFrom())
    
    1134
    +            return
    
    1135
    +
    
    1127 1136
             # check if the message is a roster item exchange (XEP-0144)
    
    1128 1137
             if self.stanza.getTag('x', namespace=nbxmpp.NS_ROSTERX):
    
    1129 1138
                 gajim.nec.push_incoming_event(RosterItemExchangeEvent(None,
    
    ... ... @@ -1179,6 +1188,17 @@ class MessageReceivedEvent(nec.NetworkIncomingEvent, HelperEvent):
    1179 1188
                             to = gajim.get_jid_from_account(account)
    
    1180 1189
                         self.stanza.setFrom(to)
    
    1181 1190
                         self.sent = True
    
    1191
    +                elif carbon_marker.getName() == 'received':
    
    1192
    +                    full_frm = str(self.stanza.getFrom())
    
    1193
    +                    frm = gajim.get_jid_without_resource(full_frm)
    
    1194
    +                    if frm == gajim.get_jid_from_account(account):
    
    1195
    +                        # Drop 'received' Carbons from ourself, we already
    
    1196
    +                        # got the message with the 'sent' Carbon or via the
    
    1197
    +                        # message itself
    
    1198
    +                        log.info(
    
    1199
    +                            'Drop "received"-Carbon from ourself: %s'
    
    1200
    +                            % full_frm)
    
    1201
    +                        return
    
    1182 1202
                     try:
    
    1183 1203
                         self.get_jid_resource()
    
    1184 1204
                     except helpers.InvalidFormat:
    

  • src/common/gajim.py
    ... ... @@ -420,13 +420,16 @@ def jid_is_transport(jid):
    420 420
             return True
    
    421 421
         return False
    
    422 422
     
    
    423
    -def get_jid_from_account(account_name):
    
    423
    +def get_jid_from_account(account_name, full=False):
    
    424 424
         """
    
    425 425
         Return the jid we use in the given account
    
    426 426
         """
    
    427 427
         name = config.get_per('accounts', account_name, 'name')
    
    428 428
         hostname = config.get_per('accounts', account_name, 'hostname')
    
    429 429
         jid = name + '@' + hostname
    
    430
    +    if full:
    
    431
    +        resource = connections[account_name].server_resource
    
    432
    +        jid += '/' + resource
    
    430 433
         return jid
    
    431 434
     
    
    432 435
     def get_our_jids():
    

  • src/message_control.py
    ... ... @@ -235,7 +235,8 @@ class MessageControl(object):
    235 235
             conn = gajim.connections[self.account]
    
    236 236
     
    
    237 237
             if not self.session:
    
    238
    -            if not obj.resource:
    
    238
    +            if (not obj.resource and
    
    239
    +                    obj.jid != gajim.get_jid_from_account(self.account)):
    
    239 240
                     if self.resource:
    
    240 241
                         obj.resource = self.resource
    
    241 242
                     else:
    

  • src/roster_window.py
    ... ... @@ -2734,7 +2734,8 @@ class RosterWindow:
    2734 2734
                     typ = 'error'
    
    2735 2735
                 if obj.forwarded and obj.sent:
    
    2736 2736
                     typ = 'out'
    
    2737
    -                xep0184_id = obj.id_
    
    2737
    +                if obj.jid != gajim.get_jid_from_account(obj.conn.name):
    
    2738
    +                    xep0184_id = obj.id_
    
    2738 2739
     
    
    2739 2740
                 obj.session.control.print_conversation(obj.msgtxt, typ,
    
    2740 2741
                     tim=obj.timestamp, encrypted=obj.encrypted, subject=obj.subject,
    
    ... ... @@ -3916,7 +3917,7 @@ class RosterWindow:
    3916 3917
                 contact = gajim.contacts.get_contact_with_highest_priority(account,
    
    3917 3918
                         jid)
    
    3918 3919
             if jid == gajim.get_jid_from_account(account):
    
    3919
    -            resource = contact.resource
    
    3920
    +            resource = None
    
    3920 3921
     
    
    3921 3922
             gajim.interface.on_open_chat_window(None, contact, account, \
    
    3922 3923
                 resource=resource, session=session)