some missing commits from branch
This commit is contained in:
parent
0b9e57a16d
commit
1a96012420
|
@ -22,6 +22,8 @@
|
||||||
## GNU General Public License for more details.
|
## GNU General Public License for more details.
|
||||||
##
|
##
|
||||||
|
|
||||||
|
import common.gajim
|
||||||
|
|
||||||
class Contact:
|
class Contact:
|
||||||
'''Information concerning each contact'''
|
'''Information concerning each contact'''
|
||||||
def __init__(self, jid='', name='', groups=[], show='', status='', sub='',
|
def __init__(self, jid='', name='', groups=[], show='', status='', sub='',
|
||||||
|
@ -59,7 +61,7 @@ class GC_Contact:
|
||||||
def __init__(self, room_jid='', nick='', show='', status='', role='',
|
def __init__(self, room_jid='', nick='', show='', status='', role='',
|
||||||
affiliation='', jid = ''):
|
affiliation='', jid = ''):
|
||||||
self.room_jid = room_jid
|
self.room_jid = room_jid
|
||||||
self.nick = nick
|
self.name = name
|
||||||
self.show = show
|
self.show = show
|
||||||
self.status = status
|
self.status = status
|
||||||
self.role = role
|
self.role = role
|
||||||
|
@ -67,7 +69,7 @@ class GC_Contact:
|
||||||
self.jid = jid
|
self.jid = jid
|
||||||
|
|
||||||
def get_full_jid(self):
|
def get_full_jid(self):
|
||||||
return self.room_jid + '/' + self.nick
|
return self.room_jid + '/' + self.name
|
||||||
|
|
||||||
class Contacts:
|
class Contacts:
|
||||||
'''Information concerning all contacts and groupchat contacts'''
|
'''Information concerning all contacts and groupchat contacts'''
|
||||||
|
@ -137,7 +139,7 @@ class Contacts:
|
||||||
'''Removes all contacts for a given jid'''
|
'''Removes all contacts for a given jid'''
|
||||||
if not self._contacts.has_key(account):
|
if not self._contacts.has_key(account):
|
||||||
return
|
return
|
||||||
if not self._contacts[account].has_key(contact.jid):
|
if not self._contacts[account].has_key(jid):
|
||||||
return
|
return
|
||||||
del self._contacts[account][jid]
|
del self._contacts[account][jid]
|
||||||
|
|
||||||
|
@ -183,7 +185,7 @@ class Contacts:
|
||||||
if jid in self._contacts[account]:
|
if jid in self._contacts[account]:
|
||||||
return self._contacts[account][jid][0]
|
return self._contacts[account][jid][0]
|
||||||
else: # it's fake jid
|
else: # it's fake jid
|
||||||
room, nick = gajim.get_room_and_nick_from_fjid(jid)
|
room, nick = common.gajim.get_room_and_nick_from_fjid(jid)
|
||||||
if self._gc_contacts[account].has_key(room) and \
|
if self._gc_contacts[account].has_key(room) and \
|
||||||
nick in self._gc_contacts[account][room]:
|
nick in self._gc_contacts[account][room]:
|
||||||
return self._gc_contacts[account][room][nick]
|
return self._gc_contacts[account][room][nick]
|
||||||
|
@ -224,7 +226,7 @@ class Contacts:
|
||||||
|
|
||||||
def contact_from_gc_contact(self, gc_contact):
|
def contact_from_gc_contact(self, gc_contact):
|
||||||
'''Create a Contact instance from a GC_Contact instance'''
|
'''Create a Contact instance from a GC_Contact instance'''
|
||||||
return Contact(jid = gc_contact.get_full_jid(), name = gc_contact.nick,
|
return Contact(jid = gc_contact.get_full_jid(), name = gc_contact.name,
|
||||||
groups = ['none'], show = gc_contact.show, status = gc_contact.status,
|
groups = ['none'], show = gc_contact.show, status = gc_contact.status,
|
||||||
sub = 'none')
|
sub = 'none')
|
||||||
|
|
||||||
|
@ -235,15 +237,15 @@ class Contacts:
|
||||||
def add_gc_contact(self, account, gc_contact):
|
def add_gc_contact(self, account, gc_contact):
|
||||||
# No such account before ?
|
# No such account before ?
|
||||||
if not self._gc_contacts.has_key(account):
|
if not self._gc_contacts.has_key(account):
|
||||||
self._contacts[account] = {gc_contact.room_jid : {gc_contact.nick: \
|
self._contacts[account] = {gc_contact.room_jid : {gc_contact.name: \
|
||||||
gc_contact}}
|
gc_contact}}
|
||||||
return
|
return
|
||||||
# No such room_jid before ?
|
# No such room_jid before ?
|
||||||
if not self._gc_contacts[account].has_key(gc_contact.room_jid):
|
if not self._gc_contacts[account].has_key(gc_contact.room_jid):
|
||||||
self._gc_contacts[account][gc_contact.room_jid] = {gc_contact.nick: \
|
self._gc_contacts[account][gc_contact.room_jid] = {gc_contact.name: \
|
||||||
gc_contact}
|
gc_contact}
|
||||||
return
|
return
|
||||||
self._gc_contacts[account][gc_contact.room_jid][gc_contact.nick] = \
|
self._gc_contacts[account][gc_contact.room_jid][gc_contact.name] = \
|
||||||
gc_contact
|
gc_contact
|
||||||
|
|
||||||
def remove_gc_contact(self, account, gc_contact):
|
def remove_gc_contact(self, account, gc_contact):
|
||||||
|
@ -252,9 +254,9 @@ class Contacts:
|
||||||
if not self._gc_contacts[account].has_key(gc_contact.room_jid):
|
if not self._gc_contacts[account].has_key(gc_contact.room_jid):
|
||||||
return
|
return
|
||||||
if not self._gc_contacts[account][gc_contact.room_jid].has_key(
|
if not self._gc_contacts[account][gc_contact.room_jid].has_key(
|
||||||
gc_contact.nick):
|
gc_contact.name):
|
||||||
return
|
return
|
||||||
self._gc_contacts[account][gc_contact.room_jid].remove(gc_contact.nick)
|
del self._gc_contacts[account][gc_contact.room_jid][gc_contact.name]
|
||||||
# It was the last nick in room ?
|
# It was the last nick in room ?
|
||||||
if not len(self._gc_contacts[account][gc_contact.room_jid]):
|
if not len(self._gc_contacts[account][gc_contact.room_jid]):
|
||||||
del self._gc_contacts[account][gc_contact.room_jid]
|
del self._gc_contacts[account][gc_contact.room_jid]
|
||||||
|
|
Loading…
Reference in New Issue