Changeset 9027

Show
Ignore:
Timestamp:
11/21/07 09:44:25 (11 months ago)
Author:
asterix
Message:

in metacontacts, if one contact is offline and one is not, the online one has a higher priority. fixes #3464

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/gajim_0.11.3-bugfixes/src/common/contacts.py

    r9019 r9027  
    390390                Data is {'jid': jid, 'account': account, 'order': order} 
    391391                order is optional''' 
     392                jid1 = data1['jid'] 
     393                jid2 = data2['jid'] 
     394                account1 = data1['account'] 
     395                account2 = data2['account'] 
     396                contact1 = self.get_contact_with_highest_priority(account1, jid1) 
     397                contact2 = self.get_contact_with_highest_priority(account2, jid2) 
     398                show_list = ['not in roster', 'error', 'offline', 'invisible', 'dnd', 
     399                        'xa', 'away', 'chat', 'online', 'requested', 'message'] 
     400                show1 = show_list.index(contact1.show) 
     401                show2 = show_list.index(contact2.show) 
     402                # If only one is offline, it's always second 
     403                if show1 > 2 and show2 < 3: 
     404                        return 1 
     405                if show2 > 2 and show1 < 3: 
     406                        return -1 
    392407                if 'order' in data1 and 'order' in data2: 
    393408                        if data1['order'] > data2['order']: 
     
    395410                        if data1['order'] < data2['order']: 
    396411                                return -1 
    397                 jid1 = data1['jid'] 
    398                 jid2 = data2['jid'] 
    399412                transport1 = common.gajim.get_transport_name_from_jid(jid1) 
    400413                transport2 = common.gajim.get_transport_name_from_jid(jid2) 
     
    403416                if transport1 and not transport2: 
    404417                        return -1 
    405                 contact1 = self.get_contact_with_highest_priority(data1['account'], jid1) 
    406                 contact2 = self.get_contact_with_highest_priority(data2['account'], jid2) 
    407418                if contact1.priority > contact2.priority: 
    408419                        return 1 
    409420                if contact2.priority > contact1.priority: 
    410421                        return -1 
    411                 show_list = ['not in roster', 'error', 'offline', 'invisible', 'dnd', 
    412                         'xa', 'away', 'chat', 'online', 'requested', 'message'] 
    413                 show1 = show_list.index(contact1.show) 
    414                 show2 = show_list.index(contact2.show) 
    415422                if show1 > show2: 
    416423                        return 1 
     
    422429                        return -1 
    423430                # If all is the same, compare accounts, they can't be the same 
    424                 account1 = data1['account'] 
    425                 account2 = data2['account'] 
    426431                if account1 > account2: 
    427432                        return 1