Changeset 9044

Show
Ignore:
Timestamp:
11/23/07 21:54:25 (13 months ago)
Author:
asterix
Message:

fis metacontact behaviour. fixes #3464

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/common/contacts.py

    r9043 r9044  
    425425                Data is {'jid': jid, 'account': account, 'order': order} 
    426426                order is optional''' 
     427                jid1 = data1['jid'] 
     428                jid2 = data2['jid'] 
     429                account1 = data1['account'] 
     430                account2 = data2['account'] 
     431                contact1 = self.get_contact_with_highest_priority(account1, jid1) 
     432                contact2 = self.get_contact_with_highest_priority(account2, jid2) 
     433                show_list = ['not in roster', 'error', 'offline', 'invisible', 'dnd', 
     434                        'xa', 'away', 'chat', 'online', 'requested', 'message'] 
     435                show1 = show_list.index(contact1.show) 
     436                show2 = show_list.index(contact2.show) 
     437                # If only one is offline, it's always second 
     438                if show1 > 2 and show2 < 3: 
     439                        return 1 
     440                if show2 > 2 and show1 < 3: 
     441                        return -1 
    427442                if 'order' in data1 and 'order' in data2: 
    428443                        if data1['order'] > data2['order']: 
     
    430445                        if data1['order'] < data2['order']: 
    431446                                return -1 
    432                 jid1 = data1['jid'] 
    433                 jid2 = data2['jid'] 
    434447                transport1 = common.gajim.get_transport_name_from_jid(jid1) 
    435448                transport2 = common.gajim.get_transport_name_from_jid(jid2) 
     
    438451                if transport1 and not transport2: 
    439452                        return -1 
    440                 contact1 = self.get_contact_with_highest_priority(data1['account'], jid1) 
    441                 contact2 = self.get_contact_with_highest_priority(data2['account'], jid2) 
    442453                if contact1.priority > contact2.priority: 
    443454                        return 1 
    444455                if contact2.priority > contact1.priority: 
    445456                        return -1 
    446                 show_list = ['not in roster', 'error', 'offline', 'invisible', 'dnd', 
    447                         'xa', 'away', 'chat', 'online', 'requested', 'message'] 
    448                 show1 = show_list.index(contact1.show) 
    449                 show2 = show_list.index(contact2.show) 
    450457                if show1 > show2: 
    451458                        return 1 
     
    457464                        return -1 
    458465                # If all is the same, compare accounts, they can't be the same 
    459                 account1 = data1['account'] 
    460                 account2 = data2['account'] 
    461466                if account1 > account2: 
    462467                        return 1