Changeset 8478 for branches/pep/src/common/contacts.py
- Timestamp:
- 08/09/07 17:39:18 (17 months ago)
- Files:
-
- 1 modified
-
branches/pep/src/common/contacts.py (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/pep/src/common/contacts.py
r8197 r8478 3 3 ## Copyright (C) 2006 Yann Le Boulanger <asterix@lagaule.org> 4 4 ## Copyright (C) 2006 Nikos Kouremenos <kourem@gmail.com> 5 ## Copyright (C) 2007 Lukas Petrovicky <lukas@petrovicky.net> 6 ## Copyright (C) 2007 Julien Pivotto <roidelapluie@gmail.com> 5 7 ## 6 8 ## … … 21 23 def __init__(self, jid='', name='', groups=[], show='', status='', sub='', 22 24 ask='', resource='', priority=0, keyID='', our_chatstate=None, 23 chatstate=None, last_status_time=None, msg_id = None, composing_ jep = None):25 chatstate=None, last_status_time=None, msg_id = None, composing_xep = None): 24 26 self.jid = jid 25 27 self.name = name … … 38 40 self.keyID = keyID 39 41 42 # Capabilities; filled by caps.py/ConnectionCaps object 43 # every time it gets these from presence stanzas 44 self.caps_node=None 45 self.caps_ver=None 46 self.caps_exts=None 47 40 48 # please read jep-85 http://www.jabber.org/jeps/jep-0085.html 41 49 # we keep track of jep85 support with the peer by three extra states: … … 48 56 self.msg_id = msg_id 49 57 # tell which JEP we're using for composing state 50 # None = have to ask, JEP-0022 = use this jep,51 # JEP-0085 = use this jep, False = no composing support52 self.composing_ jep = composing_jep58 # None = have to ask, XEP-0022 = use this jep, 59 # XEP-0085 = use this jep, False = no composing support 60 self.composing_xep = composing_xep 53 61 # this is contact's chatstate 54 62 self.chatstate = chatstate … … 154 162 def create_contact(self, jid='', name='', groups=[], show='', status='', 155 163 sub='', ask='', resource='', priority=0, keyID='', our_chatstate=None, 156 chatstate=None, last_status_time=None, composing_ jep=None):164 chatstate=None, last_status_time=None, composing_xep=None): 157 165 return Contact(jid, name, groups, show, status, sub, ask, resource, 158 166 priority, keyID, our_chatstate, chatstate, last_status_time, 159 composing_ jep)167 composing_xep) 160 168 161 169 def copy_contact(self, contact): … … 209 217 self.remove_metacontact(account, jid) 210 218 219 def get_contacts(self, account, jid): 220 '''Returns the list of contact instances for this jid.''' 221 if jid in self._contacts[account]: 222 return self._contacts[account][jid] 223 else: 224 return [] 225 211 226 def get_contact(self, account, jid, resource = None): 212 '''Returns the list of contact instances for this jid (one per resource) 213 or [] if no resource is given 214 returns the contact instance for the given resource if it's given 215 or None if there is not''' 227 '''Returns the contact instance for the given resource if it's given else 228 the first contact is no resource is given or None if there is not''' 216 229 if jid in self._contacts[account]: 217 contacts = self._contacts[account][jid]218 230 if not resource: 219 return contacts220 for c in contacts:231 return self._contacts[account][jid][0] 232 for c in self._contacts[account][jid]: 221 233 if c.resource == resource: 222 234 return c 223 if resource: 224 return None 225 return [] 226 227 def get_contacts_from_jid(self, account, jid): 228 '''we may have two or more resources on that jid''' 229 if jid in self._contacts[account]: 230 contacts_instances = self._contacts[account][jid] 231 return contacts_instances 232 return [] 235 return None 236 237 def get_contact_from_full_jid(self, account, fjid): 238 ''' Get Contact object for specific resource of given jid''' 239 barejid, resource = common.gajim.get_room_and_nick_from_fjid(fjid) 240 return self.get_contact(account, barejid, resource) 233 241 234 242 def get_highest_prio_contact_from_contacts(self, contacts): … … 242 250 243 251 def get_contact_with_highest_priority(self, account, jid): 244 contacts = self.get_contacts _from_jid(account, jid)252 contacts = self.get_contacts(account, jid) 245 253 if not contacts and '/' in jid: 246 254 # jid may be a fake jid, try it … … 259 267 group_contacts = [] 260 268 for jid in self._contacts[account]: 261 contacts = self.get_contacts _from_jid(account, jid)269 contacts = self.get_contacts(account, jid) 262 270 if group in contacts[0].groups: 263 271 group_contacts += contacts
