Contact instance doesn't need role and affiliation

add some function to Contacts class
This commit is contained in:
Yann Leboulanger 2005-12-20 22:24:01 +00:00
parent fd89e6eaab
commit 31efa00b85
1 changed files with 14 additions and 4 deletions

View File

@ -25,8 +25,8 @@
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='',
ask='', resource='', priority=5, keyID='', role='', affiliation='', ask='', resource='', priority=5, keyID='', our_chatstate=None,
our_chatstate=None, chatstate=None): chatstate=None):
self.jid = jid self.jid = jid
self.name = name self.name = name
self.groups = groups self.groups = groups
@ -37,8 +37,6 @@ class Contact:
self.resource = resource self.resource = resource
self.priority = priority self.priority = priority
self.keyID = keyID self.keyID = keyID
self.role = role
self.affiliation = affiliation
# please read jep-85 http://www.jabber.org/jeps/jep-0085.html # please read jep-85 http://www.jabber.org/jeps/jep-0085.html
# we keep track of jep85 support by the peer by three extra states: # we keep track of jep85 support by the peer by three extra states:
@ -78,6 +76,12 @@ class Contacts:
self._gc_contacts = {} # list of contacts that are in gc {acct: {room_jid: {nick: C}}} self._gc_contacts = {} # list of contacts that are in gc {acct: {room_jid: {nick: C}}}
self._sub_contacts = {} # {acct: {jid1: jid2}} means jid1 is sub of jid2 self._sub_contacts = {} # {acct: {jid1: jid2}} means jid1 is sub of jid2
def create_contact(self, jid='', name='', groups=[], show='', status='',
sub='', ask='', resource='', priority=5, keyID='', our_chatstate=None,
chatstate=None):
return Contact(jid, name, groups, show, status, sub, ask, resource,
priority, keyID, our_chatstate, chatstate)
def add_contact(self, account, contact): def add_contact(self, account, contact):
# No such account before ? # No such account before ?
if not self._contacts.has_key(account): if not self._contacts.has_key(account):
@ -173,3 +177,9 @@ class Contacts:
contact = self.get_contact_instance_with_highest_priority(account, contact = self.get_contact_instance_with_highest_priority(account,
parrent_jid) parrent_jid)
return contact return contact
def contact_from_gc_contact(self, gc_contact):
'''Create a Contact instance from a GC_Contact instance'''
return Contact(jid = gc_contact.get_full_jid(), name = gc_contact.nick,
groups = ['none'], show = gc_contact.show, status = gc_contact.status,
sub = 'none')