fix logic for observers to work as XEP 0162 says
This commit is contained in:
parent
467f4d8aa1
commit
a1820a4ed5
|
@ -1,16 +1,8 @@
|
||||||
## common/contacts.py
|
## common/contacts.py
|
||||||
##
|
##
|
||||||
## Contributors for this file:
|
## Copyright (C) 2006 Yann Le Boulanger <asterix@lagaule.org>
|
||||||
## - Yann Le Boulanger <asterix@lagaule.org>
|
## Copyright (C) 2006 Nikos Kouremenos <kourem@gmail.com>
|
||||||
##
|
##
|
||||||
## Copyright (C) 2003-2004 Yann Le Boulanger <asterix@lagaule.org>
|
|
||||||
## Vincent Hanquez <tab@snarc.org>
|
|
||||||
## Copyright (C) 2005 Yann Le Boulanger <asterix@lagaule.org>
|
|
||||||
## Vincent Hanquez <tab@snarc.org>
|
|
||||||
## Nikos Kouremenos <kourem@gmail.com>
|
|
||||||
## Dimitur Kirov <dkirov@gmail.com>
|
|
||||||
## Travis Shirk <travis@pobox.com>
|
|
||||||
## Norman Rasmussen <norman@rasmussen.co.za>
|
|
||||||
##
|
##
|
||||||
## This program is free software; you can redistribute it and/or modify
|
## This program is free software; you can redistribute it and/or modify
|
||||||
## it under the terms of the GNU General Public License as published
|
## it under the terms of the GNU General Public License as published
|
||||||
|
@ -27,8 +19,8 @@ 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='',
|
||||||
ask='', resource='', priority=0, keyID='', our_chatstate=None,
|
ask='', resource='', priority=0, keyID='', our_chatstate=None,
|
||||||
chatstate=None, last_status_time=None, msg_id = None, composing_jep = None):
|
chatstate=None, last_status_time=None, msg_id = None, composing_jep = None):
|
||||||
self.jid = jid
|
self.jid = jid
|
||||||
self.name = name
|
self.name = name
|
||||||
self.groups = groups
|
self.groups = groups
|
||||||
|
@ -68,29 +60,37 @@ class Contact:
|
||||||
return self.jid.split('@')[0]
|
return self.jid.split('@')[0]
|
||||||
|
|
||||||
def is_hidden_from_roster(self):
|
def is_hidden_from_roster(self):
|
||||||
'''if roster should not be visible in roster'''
|
'''if contact should not be visible in roster'''
|
||||||
# JEP-0162
|
# XEP-0162: http://www.xmpp.org/extensions/xep-0162.html
|
||||||
hide = True
|
if self.sub in ('both', 'to'):
|
||||||
if self.sub in ('both', 'to', 'from'):
|
|
||||||
hide = False
|
hide = False
|
||||||
elif self.ask == 'subscribe':
|
elif self.sub in ('none', 'from') and self.ask == 'subscribe':
|
||||||
hide = False
|
hide = False
|
||||||
elif self.name or len(self.groups):
|
elif self.sub in ('none', 'from') and (self.name or len(self.groups)):
|
||||||
hide = False
|
hide = False
|
||||||
|
else:
|
||||||
|
hide = True
|
||||||
return hide
|
return hide
|
||||||
|
|
||||||
def is_observer(self):
|
def is_observer(self):
|
||||||
# XEP-0162: http://www.xmpp.org/extensions/xep-0162.html
|
# XEP-0162: http://www.xmpp.org/extensions/xep-0162.html
|
||||||
is_observer = False
|
is_observer = False
|
||||||
if self.is_hidden_from_roster() and self.sub == 'from':
|
if self.sub == 'from' and not self.is_transport()\
|
||||||
|
and self.is_hidden_from_roster():
|
||||||
is_observer = True
|
is_observer = True
|
||||||
return is_observer
|
return is_observer
|
||||||
|
|
||||||
|
def is_transport(self):
|
||||||
|
# if not '@' or '@' starts the jid then contact is transport
|
||||||
|
if self.jid.find('@') <= 0:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class GC_Contact:
|
class GC_Contact:
|
||||||
'''Information concerning each groupchat contact'''
|
'''Information concerning each groupchat contact'''
|
||||||
def __init__(self, room_jid='', name='', show='', status='', role='',
|
def __init__(self, room_jid='', name='', show='', status='', role='',
|
||||||
affiliation='', jid = '', resource = ''):
|
affiliation='', jid = '', resource = ''):
|
||||||
self.room_jid = room_jid
|
self.room_jid = room_jid
|
||||||
self.name = name
|
self.name = name
|
||||||
self.show = show
|
self.show = show
|
||||||
|
|
|
@ -228,7 +228,7 @@ class RosterWindow:
|
||||||
return
|
return
|
||||||
contact.groups = [_('Transports')]
|
contact.groups = [_('Transports')]
|
||||||
|
|
||||||
# JEP-0162
|
# XEP-0162
|
||||||
hide = contact.is_hidden_from_roster()
|
hide = contact.is_hidden_from_roster()
|
||||||
if hide and contact.sub != 'from':
|
if hide and contact.sub != 'from':
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue